regular-calendar 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +36 -35
- package/dist/index.css +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +8285 -7570
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),m=require("react"),dr=require("react-dom"),_a=require("react-i18next");function $i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const S=$i(m),Vi=$i(dr);function zi(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=zi(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Bi(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=zi(e))&&(n&&(n+=" "),n+=t);return n}function de(...e){return Bi(e)}const ye={Spinner:({className:e,...t})=>{const{role:r,...n}=t;return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:de("animate-spin",e),...n,role:"presentation",children:i.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})},Check:({className:e,...t})=>{const{role:r,...n}=t;return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})})},X:({className:e,...t})=>{const{role:r,...n}=t;return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})},ChevronLeft:({className:e,...t})=>{const{role:r,...n}=t;return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:i.jsx("path",{d:"M15 18l-6-6 6-6"})})},ChevronRight:({className:e,...t})=>{const{role:r,...n}=t;return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:i.jsx("path",{d:"M9 18l6-6-6-6"})})},ChevronDown:({className:e,...t})=>{const{role:r,...n}=t;return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:i.jsx("path",{d:"M6 9l6 6 6-6"})})},Calendar:({className:e,...t})=>{const{role:r,...n}=t;return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),i.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),i.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})},Plus:({className:e,...t})=>{const{role:r,...n}=t;return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[i.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),i.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})},Edit:({className:e,...t})=>{const{role:r,...n}=t;return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})},Trash:({className:e,...t})=>{const{role:r,...n}=t;return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[i.jsx("polyline",{points:"3 6 5 6 21 6"}),i.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})},AlertTriangle:({className:e,...t})=>{const{role:r,...n}=t;return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[i.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),i.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),i.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}},vt=S.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:de("flex w-full rounded-md border border-input bg-background px-ui py-ui 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",e),ref:n,...r}));vt.displayName="Input";function Sa({value:e=[],onChange:t,personnel:r,placeholder:n,className:s,disabled:a=!1}){const[o,c]=m.useState(!1),[l,u]=m.useState(""),[f,d]=m.useState(-1),h=m.useRef(null),p=m.useMemo(()=>{if(!l||!r)return[];const b=l.toLowerCase();return b.length<1?[]:r.filter(C=>e.some(x=>x.personnelId===C.id)?!1:C.name.toLowerCase().includes(b)||C.department?.toLowerCase().includes(b)).slice(0,5)},[l,r,e]);m.useEffect(()=>{d(-1),c(p.length>0)},[p]);const w=b=>{t([...e,b]),u(""),c(!1),h.current?.focus()},g=b=>{const C=[...e];C.splice(b,1),t(C)},y=b=>{if(!b.nativeEvent.isComposing){if(o&&p.length>0){if(b.key==="ArrowDown"){b.preventDefault(),d(C=>C===-1?0:(C+1)%p.length);return}else if(b.key==="ArrowUp"){b.preventDefault(),d(C=>C===-1?p.length-1:(C-1+p.length)%p.length);return}}if(b.key==="Enter")if(b.preventDefault(),f>=0&&p[f]){const C=p[f];w({name:C.name,email:C.email||"",personnelId:C.id,type:"personnel"})}else l.trim().length>0&&w({name:l.trim(),type:"external"});else b.key==="Backspace"&&l===""&&e.length>0?g(e.length-1):b.key==="Escape"&&c(!1)}},v=()=>{setTimeout(()=>{c(!1)},200)};return i.jsxs("div",{className:de("flex flex-wrap items-center gap-ui px-ui py-[calc(var(--ui-component-padding-y)/2)] border rounded-md bg-background focus-within:ring-2 ring-ring ring-offset-2 border-input min-h-ui",s),children:[e.map((b,C)=>i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-1)] bg-secondary text-secondary-foreground px-[var(--ui-space-2)] py-[var(--ui-space-1)] rounded text-sm group",children:[i.jsx("span",{children:b.name}),!a&&i.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),g(C)},className:"text-muted-foreground group-hover:text-destructive transition-colors",children:i.jsx(ye.X,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})]},b.personnelId??b.email??`${b.type}-${b.name}`)),i.jsxs("div",{className:"relative flex-1 min-w-[var(--ui-space-30)]",children:[i.jsx(vt,{ref:h,value:l,onChange:b=>u(b.target.value),onKeyDown:y,onFocus:()=>{p.length>0&&c(!0)},onBlur:v,placeholder:e.length===0?n:"",disabled:a,className:de("border-0 focus-visible:ring-0 px-[var(--ui-space-0)] h-auto py-[var(--ui-space-1)] shadow-none bg-transparent",a&&"cursor-not-allowed text-muted-foreground"),autoComplete:"off"}),o&&p.length>0&&i.jsx("div",{className:"absolute top-full left-[var(--ui-space-0)] z-50 w-full min-w-[var(--ui-space-50)] mt-[var(--ui-space-1)] bg-popover text-popover-foreground border border-border rounded-md shadow-md overflow-hidden animate-in fade-in-0 zoom-in-95",children:p.map((b,C)=>i.jsxs("button",{type:"button",className:de("px-ui py-ui text-sm cursor-pointer flex justify-between items-center",C===f?"bg-accent text-accent-foreground":"hover:bg-accent hover:text-accent-foreground"),onClick:x=>{x.preventDefault(),x.stopPropagation(),w({name:b.name,email:b.email||"",personnelId:b.id,type:"personnel"})},onMouseEnter:()=>d(C),children:[i.jsx("span",{className:"font-medium",children:b.name}),b.department&&i.jsx("span",{className:"text-xs text-muted-foreground ml-[var(--ui-space-2)]",children:b.department})]},b.id))})]})]})}var gn=e=>e.type==="checkbox",fr=e=>e instanceof Date,Ge=e=>e==null;const Hi=e=>typeof e=="object";var Ee=e=>!Ge(e)&&!Array.isArray(e)&&Hi(e)&&!fr(e),Wi=e=>Ee(e)&&e.target?gn(e.target)?e.target.checked:e.target.value:e,Yu=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ui=(e,t)=>e.has(Yu(t)),Gu=e=>{const t=e.constructor&&e.constructor.prototype;return Ee(t)&&t.hasOwnProperty("isPrototypeOf")},Ca=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Re(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Ca&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ee(e)&&Gu(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=Re(e[s]));return n}var ms=e=>/^\w*$/.test(e),_e=e=>e===void 0,ka=e=>Array.isArray(e)?e.filter(Boolean):[],Da=e=>ka(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Y=(e,t,r)=>{if(!t||!Ee(e))return r;const n=(ms(t)?[t]:Da(t)).reduce((s,a)=>Ge(s)?s:s[a],e);return _e(n)||n===e?_e(e[t])?r:e[t]:n},rt=e=>typeof e=="boolean",Be=e=>typeof e=="function",ge=(e,t,r)=>{let n=-1;const s=ms(t)?[t]:Da(t),a=s.length,o=a-1;for(;++n<a;){const c=s[n];let l=r;if(n!==o){const u=e[c];l=Ee(u)||Array.isArray(u)?u:isNaN(+s[n+1])?{}:[]}if(c==="__proto__"||c==="constructor"||c==="prototype")return;e[c]=l,e=e[c]}};const Hn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},pt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Lt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ja=m.createContext(null);ja.displayName="HookFormContext";const ps=()=>m.useContext(ja),qu=e=>{const{children:t,...r}=e;return m.createElement(ja.Provider,{value:r},t)};var Zi=(e,t,r,n=!0)=>{const s={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const o=a;return t._proxyFormState[o]!==pt.all&&(t._proxyFormState[o]=!n||pt.all),r&&(r[o]=!0),e[o]}});return s};const Na=typeof window<"u"?m.useLayoutEffect:m.useEffect;function Xu(e){const t=ps(),{control:r=t.control,disabled:n,name:s,exact:a}=e||{},[o,c]=m.useState(r._formState),l=m.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Na(()=>r._subscribe({name:s,formState:l.current,exact:a,callback:u=>{!n&&c({...r._formState,...u})}}),[s,n,a]),m.useEffect(()=>{l.current.isValid&&r._setValid(!0)},[r]),m.useMemo(()=>Zi(o,r,l.current,!1),[o,r])}var at=e=>typeof e=="string",ta=(e,t,r,n,s)=>at(e)?(n&&t.watch.add(e),Y(r,e,s)):Array.isArray(e)?e.map(a=>(n&&t.watch.add(a),Y(r,a))):(n&&(t.watchAll=!0),r),ra=e=>Ge(e)||!Hi(e);function gt(e,t,r=new WeakSet){if(ra(e)||ra(t))return Object.is(e,t);if(fr(e)&&fr(t))return e.getTime()===t.getTime();const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const a of n){const o=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const c=t[a];if(fr(o)&&fr(c)||Ee(o)&&Ee(c)||Array.isArray(o)&&Array.isArray(c)?!gt(o,c,r):!Object.is(o,c))return!1}}return!0}function Ku(e){const t=ps(),{control:r=t.control,name:n,defaultValue:s,disabled:a,exact:o,compute:c}=e||{},l=m.useRef(s),u=m.useRef(c),f=m.useRef(void 0),d=m.useRef(r),h=m.useRef(n);u.current=c;const[p,w]=m.useState(()=>{const x=r._getWatch(n,l.current);return u.current?u.current(x):x}),g=m.useCallback(x=>{const _=ta(n,r._names,x||r._formValues,!1,l.current);return u.current?u.current(_):_},[r._formValues,r._names,n]),y=m.useCallback(x=>{if(!a){const _=ta(n,r._names,x||r._formValues,!1,l.current);if(u.current){const k=u.current(_);gt(k,f.current)||(w(k),f.current=k)}else w(_)}},[r._formValues,r._names,a,n]);Na(()=>((d.current!==r||!gt(h.current,n))&&(d.current=r,h.current=n,y()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:x=>{y(x.values)}})),[r,o,n,y]),m.useEffect(()=>r._removeUnmounted());const v=d.current!==r,b=h.current,C=m.useMemo(()=>{if(a)return null;const x=!v&&!gt(b,n);return v||x?g():null},[a,v,n,b,g]);return C!==null?C:p}function Ju(e){const t=ps(),{name:r,disabled:n,control:s=t.control,shouldUnregister:a,defaultValue:o,exact:c=!0}=e,l=Ui(s._names.array,r),u=m.useMemo(()=>Y(s._formValues,r,Y(s._defaultValues,r,o)),[s,r,o]),f=Ku({control:s,name:r,defaultValue:u,exact:c}),d=Xu({control:s,name:r,exact:c}),h=m.useRef(e),p=m.useRef(void 0),w=m.useRef(s.register(r,{...e.rules,value:f,...rt(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const g=m.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Y(d.errors,r)},isDirty:{enumerable:!0,get:()=>!!Y(d.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!Y(d.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!Y(d.validatingFields,r)},error:{enumerable:!0,get:()=>Y(d.errors,r)}}),[d,r]),y=m.useCallback(x=>w.current.onChange({target:{value:Wi(x),name:r},type:Hn.CHANGE}),[r]),v=m.useCallback(()=>w.current.onBlur({target:{value:Y(s._formValues,r),name:r},type:Hn.BLUR}),[r,s._formValues]),b=m.useCallback(x=>{const _=Y(s._fields,r);_&&_._f&&x&&(_._f.ref={focus:()=>Be(x.focus)&&x.focus(),select:()=>Be(x.select)&&x.select(),setCustomValidity:k=>Be(x.setCustomValidity)&&x.setCustomValidity(k),reportValidity:()=>Be(x.reportValidity)&&x.reportValidity()})},[s._fields,r]),C=m.useMemo(()=>({name:r,value:f,...rt(n)||d.disabled?{disabled:d.disabled||n}:{},onChange:y,onBlur:v,ref:b}),[r,n,d.disabled,y,v,b,f]);return m.useEffect(()=>{const x=s._options.shouldUnregister||a,_=p.current;_&&_!==r&&!l&&s.unregister(_),s.register(r,{...h.current.rules,...rt(h.current.disabled)?{disabled:h.current.disabled}:{}});const k=(j,E)=>{const A=Y(s._fields,j);A&&A._f&&(A._f.mount=E)};if(k(r,!0),x){const j=Re(Y(s._options.defaultValues,r,h.current.defaultValue));ge(s._defaultValues,r,j),_e(Y(s._formValues,r))&&ge(s._formValues,r,j)}return!l&&s.register(r),p.current=r,()=>{(l?x&&!s._state.action:x)?s.unregister(r):k(r,!1)}},[r,s,l,a]),m.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),m.useMemo(()=>({field:C,formState:d,fieldState:g}),[C,d,g])}const Qu=e=>e.render(Ju(e));var Yi=(e,t,r,n,s)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:s||!0}}:{},en=e=>Array.isArray(e)?e:[e],So=()=>{let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next&&a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}};function Gi(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const s=e[n],a=t[n];if(s&&Ee(s)&&a){const o=Gi(s,a);Ee(o)&&(r[n]=o)}else e[n]&&(r[n]=a)}return r}var ze=e=>Ee(e)&&!Object.keys(e).length,Ea=e=>e.type==="file",Wn=e=>{if(!Ca)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},qi=e=>e.type==="select-multiple",Aa=e=>e.type==="radio",ed=e=>Aa(e)||gn(e),$s=e=>Wn(e)&&e.isConnected;function td(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=_e(e)?n++:e[t[n++]];return e}function rd(e){for(const t in e)if(e.hasOwnProperty(t)&&!_e(e[t]))return!1;return!0}function ke(e,t){const r=Array.isArray(t)?t:ms(t)?[t]:Da(t),n=r.length===1?e:td(e,r),s=r.length-1,a=r[s];return n&&delete n[a],s!==0&&(Ee(n)&&ze(n)||Array.isArray(n)&&rd(n))&&ke(e,r.slice(0,-1)),e}var nd=e=>{for(const t in e)if(Be(e[t]))return!0;return!1};function Xi(e){return Array.isArray(e)||Ee(e)&&!nd(e)}function na(e,t={}){for(const r in e){const n=e[r];Xi(n)?(t[r]=Array.isArray(n)?[]:{},na(n,t[r])):_e(n)||(t[r]=!0)}return t}function jr(e,t,r){r||(r=na(t));for(const n in e){const s=e[n];if(Xi(s))_e(t)||ra(r[n])?r[n]=na(s,Array.isArray(s)?[]:{}):jr(s,Ge(t)?{}:t[n],r[n]);else{const a=t[n];r[n]=!gt(s,a)}}return r}const Co={value:!1,isValid:!1},ko={value:!0,isValid:!0};var Ki=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!_e(e[0].attributes.value)?_e(e[0].value)||e[0].value===""?ko:{value:e[0].value,isValid:!0}:ko:Co}return Co},Ji=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>_e(e)?e:t?e===""?NaN:e&&+e:r&&at(e)?new Date(e):n?n(e):e;const Do={isValid:!1,value:null};var Qi=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Do):Do;function jo(e){const t=e.ref;return Ea(t)?t.files:Aa(t)?Qi(e.refs).value:qi(t)?[...t.selectedOptions].map(({value:r})=>r):gn(t)?Ki(e.refs).value:Ji(_e(t.value)?e.ref.value:t.value,e)}var sd=(e,t,r,n)=>{const s={};for(const a of e){const o=Y(t,a);o&&ge(s,a,o._f)}return{criteriaMode:r,names:[...e],fields:s,shouldUseNativeValidation:n}},Un=e=>e instanceof RegExp,Kr=e=>_e(e)?e:Un(e)?e.source:Ee(e)?Un(e.value)?e.value.source:e.value:e,No=e=>({isOnSubmit:!e||e===pt.onSubmit,isOnBlur:e===pt.onBlur,isOnChange:e===pt.onChange,isOnAll:e===pt.all,isOnTouch:e===pt.onTouched});const Eo="AsyncFunction";var ad=e=>!!e&&!!e.validate&&!!(Be(e.validate)&&e.validate.constructor.name===Eo||Ee(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Eo)),od=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ao=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const tn=(e,t,r,n)=>{for(const s of r||Object.keys(e)){const a=Y(e,s);if(a){const{_f:o,...c}=a;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],s)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(tn(c,t))break}else if(Ee(c)&&tn(c,t))break}}};function Ro(e,t,r){const n=Y(e,r);if(n||ms(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const a=s.join("."),o=Y(t,a),c=Y(e,a);if(o&&!Array.isArray(o)&&r!==a)return{name:r};if(c&&c.type)return{name:a,error:c};if(c&&c.root&&c.root.type)return{name:`${a}.root`,error:c.root};s.pop()}return{name:r}}var id=(e,t,r,n)=>{r(e);const{name:s,...a}=e;return ze(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(o=>t[o]===(!n||pt.all))},cd=(e,t,r)=>!e||!t||e===t||en(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),ld=(e,t,r,n,s)=>s.isOnAll?!1:!r&&s.isOnTouch?!(t||e):(r?n.isOnBlur:s.isOnBlur)?!e:(r?n.isOnChange:s.isOnChange)?e:!0,ud=(e,t)=>!ka(Y(e,t)).length&&ke(e,t),dd=(e,t,r)=>{const n=en(Y(e,r));return ge(n,"root",t[r]),ge(e,r,n),e};function To(e,t,r="validate"){if(at(e)||Array.isArray(e)&&e.every(at)||rt(e)&&!e)return{type:r,message:at(e)?e:"",ref:t}}var _r=e=>Ee(e)&&!Un(e)?e:{value:e,message:""},Po=async(e,t,r,n,s,a)=>{const{ref:o,refs:c,required:l,maxLength:u,minLength:f,min:d,max:h,pattern:p,validate:w,name:g,valueAsNumber:y,mount:v}=e._f,b=Y(r,g);if(!v||t.has(g))return{};const C=c?c[0]:o,x=R=>{s&&C.reportValidity&&(C.setCustomValidity(rt(R)?"":R||""),C.reportValidity())},_={},k=Aa(o),j=gn(o),E=k||j,A=(y||Ea(o))&&_e(o.value)&&_e(b)||Wn(o)&&o.value===""||b===""||Array.isArray(b)&&!b.length,T=Yi.bind(null,g,n,_),M=(R,V,F,G=Lt.maxLength,$=Lt.minLength)=>{const L=R?V:F;_[g]={type:R?G:$,message:L,ref:o,...T(R?G:$,L)}};if(a?!Array.isArray(b)||!b.length:l&&(!E&&(A||Ge(b))||rt(b)&&!b||j&&!Ki(c).isValid||k&&!Qi(c).isValid)){const{value:R,message:V}=at(l)?{value:!!l,message:l}:_r(l);if(R&&(_[g]={type:Lt.required,message:V,ref:C,...T(Lt.required,V)},!n))return x(V),_}if(!A&&(!Ge(d)||!Ge(h))){let R,V;const F=_r(h),G=_r(d);if(!Ge(b)&&!isNaN(b)){const $=o.valueAsNumber||b&&+b;Ge(F.value)||(R=$>F.value),Ge(G.value)||(V=$<G.value)}else{const $=o.valueAsDate||new Date(b),L=z=>new Date(new Date().toDateString()+" "+z),P=o.type=="time",H=o.type=="week";at(F.value)&&b&&(R=P?L(b)>L(F.value):H?b>F.value:$>new Date(F.value)),at(G.value)&&b&&(V=P?L(b)<L(G.value):H?b<G.value:$<new Date(G.value))}if((R||V)&&(M(!!R,F.message,G.message,Lt.max,Lt.min),!n))return x(_[g].message),_}if((u||f)&&!A&&(at(b)||a&&Array.isArray(b))){const R=_r(u),V=_r(f),F=!Ge(R.value)&&b.length>+R.value,G=!Ge(V.value)&&b.length<+V.value;if((F||G)&&(M(F,R.message,V.message),!n))return x(_[g].message),_}if(p&&!A&&at(b)){const{value:R,message:V}=_r(p);if(Un(R)&&!b.match(R)&&(_[g]={type:Lt.pattern,message:V,ref:o,...T(Lt.pattern,V)},!n))return x(V),_}if(w){if(Be(w)){const R=await w(b,r),V=To(R,C);if(V&&(_[g]={...V,...T(Lt.validate,V.message)},!n))return x(V.message),_}else if(Ee(w)){let R={};for(const V in w){if(!ze(R)&&!n)break;const F=To(await w[V](b,r),C,V);F&&(R={...F,...T(V,F.message)},x(F.message),n&&(_[g]=R))}if(!ze(R)&&(_[g]={ref:C,...R},!n))return _}}return x(!0),_};const fd={mode:pt.onSubmit,reValidateMode:pt.onChange,shouldFocusError:!0};function hd(e={}){let t={...fd,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Be(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},n={},s=Ee(t.defaultValues)||Ee(t.values)?Re(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Re(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...f};let h={...d};const p={array:So(),state:So()},w=t.criteriaMode===pt.all,g=D=>N=>{clearTimeout(u),u=setTimeout(D,N)},y=async D=>{if(!o.keepIsValid&&!t.disabled&&(d.isValid||h.isValid||D)){let N;t.resolver?(N=ze((await E()).errors),v()):N=await T(n,!0),N!==r.isValid&&p.state.next({isValid:N})}},v=(D,N)=>{!t.disabled&&(d.isValidating||d.validatingFields||h.isValidating||h.validatingFields)&&((D||Array.from(c.mount)).forEach(O=>{O&&(N?ge(r.validatingFields,O,N):ke(r.validatingFields,O))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ze(r.validatingFields)}))},b=(D,N=[],O,X,Z=!0,U=!0)=>{if(X&&O&&!t.disabled){if(o.action=!0,U&&Array.isArray(Y(n,D))){const ee=O(Y(n,D),X.argA,X.argB);Z&&ge(n,D,ee)}if(U&&Array.isArray(Y(r.errors,D))){const ee=O(Y(r.errors,D),X.argA,X.argB);Z&&ge(r.errors,D,ee),ud(r.errors,D)}if((d.touchedFields||h.touchedFields)&&U&&Array.isArray(Y(r.touchedFields,D))){const ee=O(Y(r.touchedFields,D),X.argA,X.argB);Z&&ge(r.touchedFields,D,ee)}(d.dirtyFields||h.dirtyFields)&&(r.dirtyFields=jr(s,a)),p.state.next({name:D,isDirty:R(D,N),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ge(a,D,N)},C=(D,N)=>{ge(r.errors,D,N),p.state.next({errors:r.errors})},x=D=>{r.errors=D,p.state.next({errors:r.errors,isValid:!1})},_=(D,N,O,X)=>{const Z=Y(n,D);if(Z){const U=Y(a,D,_e(O)?Y(s,D):O);_e(U)||X&&X.defaultChecked||N?ge(a,D,N?U:jo(Z._f)):G(D,U),o.mount&&!o.action&&y()}},k=(D,N,O,X,Z)=>{let U=!1,ee=!1;const le={name:D};if(!t.disabled){if(!O||X){(d.isDirty||h.isDirty)&&(ee=r.isDirty,r.isDirty=le.isDirty=R(),U=ee!==le.isDirty);const he=gt(Y(s,D),N);ee=!!Y(r.dirtyFields,D),he?ke(r.dirtyFields,D):ge(r.dirtyFields,D,!0),le.dirtyFields=r.dirtyFields,U=U||(d.dirtyFields||h.dirtyFields)&&ee!==!he}if(O){const he=Y(r.touchedFields,D);he||(ge(r.touchedFields,D,O),le.touchedFields=r.touchedFields,U=U||(d.touchedFields||h.touchedFields)&&he!==O)}U&&Z&&p.state.next(le)}return U?le:{}},j=(D,N,O,X)=>{const Z=Y(r.errors,D),U=(d.isValid||h.isValid)&&rt(N)&&r.isValid!==N;if(t.delayError&&O?(l=g(()=>C(D,O)),l(t.delayError)):(clearTimeout(u),l=null,O?ge(r.errors,D,O):ke(r.errors,D)),(O?!gt(Z,O):Z)||!ze(X)||U){const ee={...X,...U&&rt(N)?{isValid:N}:{},errors:r.errors,name:D};r={...r,...ee},p.state.next(ee)}},E=async D=>(v(D,!0),await t.resolver(a,t.context,sd(D||c.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),A=async D=>{const{errors:N}=await E(D);if(v(D),D)for(const O of D){const X=Y(N,O);X?ge(r.errors,O,X):ke(r.errors,O)}else r.errors=N;return N},T=async(D,N,O={valid:!0})=>{for(const X in D){const Z=D[X];if(Z){const{_f:U,...ee}=Z;if(U){const le=c.array.has(U.name),he=Z._f&&ad(Z._f);he&&d.validatingFields&&v([U.name],!0);const Ve=await Po(Z,c.disabled,a,w,t.shouldUseNativeValidation&&!N,le);if(he&&d.validatingFields&&v([U.name]),Ve[U.name]&&(O.valid=!1,N))break;!N&&(Y(Ve,U.name)?le?dd(r.errors,Ve,U.name):ge(r.errors,U.name,Ve[U.name]):ke(r.errors,U.name))}!ze(ee)&&await T(ee,N,O)}}return O.valid},M=()=>{for(const D of c.unMount){const N=Y(n,D);N&&(N._f.refs?N._f.refs.every(O=>!$s(O)):!$s(N._f.ref))&&pe(D)}c.unMount=new Set},R=(D,N)=>!t.disabled&&(D&&N&&ge(a,D,N),!gt(re(),s)),V=(D,N,O)=>ta(D,c,{...o.mount?a:_e(N)?s:at(D)?{[D]:N}:N},O,N),F=D=>ka(Y(o.mount?a:s,D,t.shouldUnregister?Y(s,D,[]):[])),G=(D,N,O={})=>{const X=Y(n,D);let Z=N;if(X){const U=X._f;U&&(!U.disabled&&ge(a,D,Ji(N,U)),Z=Wn(U.ref)&&Ge(N)?"":N,qi(U.ref)?[...U.ref.options].forEach(ee=>ee.selected=Z.includes(ee.value)):U.refs?gn(U.ref)?U.refs.forEach(ee=>{(!ee.defaultChecked||!ee.disabled)&&(Array.isArray(Z)?ee.checked=!!Z.find(le=>le===ee.value):ee.checked=Z===ee.value||!!Z)}):U.refs.forEach(ee=>ee.checked=ee.value===Z):Ea(U.ref)?U.ref.value="":(U.ref.value=Z,U.ref.type||p.state.next({name:D,values:Re(a)})))}(O.shouldDirty||O.shouldTouch)&&k(D,Z,O.shouldTouch,O.shouldDirty,!0),O.shouldValidate&&z(D)},$=(D,N,O)=>{for(const X in N){if(!N.hasOwnProperty(X))return;const Z=N[X],U=D+"."+X,ee=Y(n,U);(c.array.has(D)||Ee(Z)||ee&&!ee._f)&&!fr(Z)?$(U,Z,O):G(U,Z,O)}},L=(D,N,O={})=>{const X=Y(n,D),Z=c.array.has(D),U=Re(N);ge(a,D,U),Z?(p.array.next({name:D,values:Re(a)}),(d.isDirty||d.dirtyFields||h.isDirty||h.dirtyFields)&&O.shouldDirty&&p.state.next({name:D,dirtyFields:jr(s,a),isDirty:R(D,U)})):X&&!X._f&&!Ge(U)?$(D,U,O):G(D,U,O),Ao(D,c)&&p.state.next({...r,name:D}),p.state.next({name:o.mount?D:void 0,values:Re(a)})},P=async D=>{o.mount=!0;const N=D.target;let O=N.name,X=!0;const Z=Y(n,O),U=he=>{X=Number.isNaN(he)||fr(he)&&isNaN(he.getTime())||gt(he,Y(a,O,he))},ee=No(t.mode),le=No(t.reValidateMode);if(Z){let he,Ve;const Je=N.type?jo(Z._f):Wi(D),mt=D.type===Hn.BLUR||D.type===Hn.FOCUS_OUT,Fs=!od(Z._f)&&!t.resolver&&!Y(r.errors,O)&&!Z._f.deps||ld(mt,Y(r.touchedFields,O),r.isSubmitted,le,ee),Yr=Ao(O,c,mt);ge(a,O,Je),mt?(!N||!N.readOnly)&&(Z._f.onBlur&&Z._f.onBlur(D),l&&l(0)):Z._f.onChange&&Z._f.onChange(D);const cr=k(O,Je,mt),jn=!ze(cr)||Yr;if(!mt&&p.state.next({name:O,type:D.type,values:Re(a)}),Fs)return(d.isValid||h.isValid)&&(t.mode==="onBlur"?mt&&y():mt||y()),jn&&p.state.next({name:O,...Yr?{}:cr});if(!mt&&Yr&&p.state.next({...r}),t.resolver){const{errors:Nn}=await E([O]);if(v([O]),U(Je),X){const En=Ro(r.errors,n,O),An=Ro(Nn,n,En.name||O);he=An.error,O=An.name,Ve=ze(Nn)}}else v([O],!0),he=(await Po(Z,c.disabled,a,w,t.shouldUseNativeValidation))[O],v([O]),U(Je),X&&(he?Ve=!1:(d.isValid||h.isValid)&&(Ve=await T(n,!0)));X&&(Z._f.deps&&(!Array.isArray(Z._f.deps)||Z._f.deps.length>0)&&z(Z._f.deps),j(O,Ve,he,cr))}},H=(D,N)=>{if(Y(r.errors,N)&&D.focus)return D.focus(),1},z=async(D,N={})=>{let O,X;const Z=en(D);if(t.resolver){const U=await A(_e(D)?D:Z);O=ze(U),X=D?!Z.some(ee=>Y(U,ee)):O}else D?(X=(await Promise.all(Z.map(async U=>{const ee=Y(n,U);return await T(ee&&ee._f?{[U]:ee}:ee)}))).every(Boolean),!(!X&&!r.isValid)&&y()):X=O=await T(n);return p.state.next({...!at(D)||(d.isValid||h.isValid)&&O!==r.isValid?{}:{name:D},...t.resolver||!D?{isValid:O}:{},errors:r.errors}),N.shouldFocus&&!X&&tn(n,H,D?Z:c.mount),X},re=(D,N)=>{let O={...o.mount?a:s};return N&&(O=Gi(N.dirtyFields?r.dirtyFields:r.touchedFields,O)),_e(D)?O:at(D)?Y(O,D):D.map(X=>Y(O,X))},q=(D,N)=>({invalid:!!Y((N||r).errors,D),isDirty:!!Y((N||r).dirtyFields,D),error:Y((N||r).errors,D),isValidating:!!Y(r.validatingFields,D),isTouched:!!Y((N||r).touchedFields,D)}),I=D=>{D&&en(D).forEach(N=>ke(r.errors,N)),p.state.next({errors:D?r.errors:{}})},B=(D,N,O)=>{const X=(Y(n,D,{_f:{}})._f||{}).ref,Z=Y(r.errors,D)||{},{ref:U,message:ee,type:le,...he}=Z;ge(r.errors,D,{...he,...N,ref:X}),p.state.next({name:D,errors:r.errors,isValid:!1}),O&&O.shouldFocus&&X&&X.focus&&X.focus()},se=(D,N)=>Be(D)?p.state.subscribe({next:O=>"values"in O&&D(V(void 0,N),O)}):V(D,N,!0),ne=D=>p.state.subscribe({next:N=>{cd(D.name,N.name,D.exact)&&id(N,D.formState||d,kn,D.reRenderRoot)&&D.callback({values:{...a},...r,...N,defaultValues:s})}}).unsubscribe,fe=D=>(o.mount=!0,h={...h,...D.formState},ne({...D,formState:{...f,...D.formState}})),pe=(D,N={})=>{for(const O of D?en(D):c.mount)c.mount.delete(O),c.array.delete(O),N.keepValue||(ke(n,O),ke(a,O)),!N.keepError&&ke(r.errors,O),!N.keepDirty&&ke(r.dirtyFields,O),!N.keepTouched&&ke(r.touchedFields,O),!N.keepIsValidating&&ke(r.validatingFields,O),!t.shouldUnregister&&!N.keepDefaultValue&&ke(s,O);p.state.next({values:Re(a)}),p.state.next({...r,...N.keepDirty?{isDirty:R()}:{}}),!N.keepIsValid&&y()},Ae=({disabled:D,name:N})=>{(rt(D)&&o.mount||D||c.disabled.has(N))&&(D?c.disabled.add(N):c.disabled.delete(N))},xe=(D,N={})=>{let O=Y(n,D);const X=rt(N.disabled)||rt(t.disabled);return ge(n,D,{...O||{},_f:{...O&&O._f?O._f:{ref:{name:D}},name:D,mount:!0,...N}}),c.mount.add(D),O?Ae({disabled:rt(N.disabled)?N.disabled:t.disabled,name:D}):_(D,!0,N.value),{...X?{disabled:N.disabled||t.disabled}:{},...t.progressive?{required:!!N.required,min:Kr(N.min),max:Kr(N.max),minLength:Kr(N.minLength),maxLength:Kr(N.maxLength),pattern:Kr(N.pattern)}:{},name:D,onChange:P,onBlur:P,ref:Z=>{if(Z){xe(D,N),O=Y(n,D);const U=_e(Z.value)&&Z.querySelectorAll&&Z.querySelectorAll("input,select,textarea")[0]||Z,ee=ed(U),le=O._f.refs||[];if(ee?le.find(he=>he===U):U===O._f.ref)return;ge(n,D,{_f:{...O._f,...ee?{refs:[...le.filter($s),U,...Array.isArray(Y(s,D))?[{}]:[]],ref:{type:U.type,name:D}}:{ref:U}}}),_(D,!1,void 0,U)}else O=Y(n,D,{}),O._f&&(O._f.mount=!1),(t.shouldUnregister||N.shouldUnregister)&&!(Ui(c.array,D)&&o.action)&&c.unMount.add(D)}}},Ze=()=>t.shouldFocusError&&tn(n,H,c.mount),Ye=D=>{rt(D)&&(p.state.next({disabled:D}),tn(n,(N,O)=>{const X=Y(n,O);X&&(N.disabled=X._f.disabled||D,Array.isArray(X._f.refs)&&X._f.refs.forEach(Z=>{Z.disabled=X._f.disabled||D}))},0,!1))},Xe=(D,N)=>async O=>{let X;O&&(O.preventDefault&&O.preventDefault(),O.persist&&O.persist());let Z=Re(a);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:U,values:ee}=await E();v(),r.errors=U,Z=Re(ee)}else await T(n);if(c.disabled.size)for(const U of c.disabled)ke(Z,U);if(ke(r.errors,"root"),ze(r.errors)){p.state.next({errors:{}});try{await D(Z,O)}catch(U){X=U}}else N&&await N({...r.errors},O),Ze(),setTimeout(Ze);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ze(r.errors)&&!X,submitCount:r.submitCount+1,errors:r.errors}),X)throw X},Ke=(D,N={})=>{Y(n,D)&&(_e(N.defaultValue)?L(D,Re(Y(s,D))):(L(D,N.defaultValue),ge(s,D,Re(N.defaultValue))),N.keepTouched||ke(r.touchedFields,D),N.keepDirty||(ke(r.dirtyFields,D),r.isDirty=N.defaultValue?R(D,Re(Y(s,D))):R()),N.keepError||(ke(r.errors,D),d.isValid&&y()),p.state.next({...r}))},_t=(D,N={})=>{const O=D?Re(D):s,X=Re(O),Z=ze(D),U=Z?s:X;if(N.keepDefaultValues||(s=O),!N.keepValues){if(N.keepDirtyValues){const ee=new Set([...c.mount,...Object.keys(jr(s,a))]);for(const le of Array.from(ee))Y(r.dirtyFields,le)?ge(U,le,Y(a,le)):L(le,Y(U,le))}else{if(Ca&&_e(D))for(const ee of c.mount){const le=Y(n,ee);if(le&&le._f){const he=Array.isArray(le._f.refs)?le._f.refs[0]:le._f.ref;if(Wn(he)){const Ve=he.closest("form");if(Ve){Ve.reset();break}}}}if(N.keepFieldsRef)for(const ee of c.mount)L(ee,Y(U,ee));else n={}}a=t.shouldUnregister?N.keepDefaultValues?Re(s):{}:Re(U),p.array.next({values:{...U}}),p.state.next({values:{...U}})}c={mount:N.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!N.keepIsValid||!!N.keepDirtyValues||!t.shouldUnregister&&!ze(U),o.watch=!!t.shouldUnregister,o.keepIsValid=!!N.keepIsValid,o.action=!1,N.keepErrors||(r.errors={}),p.state.next({submitCount:N.keepSubmitCount?r.submitCount:0,isDirty:Z?!1:N.keepDirty?r.isDirty:!!(N.keepDefaultValues&&!gt(D,s)),isSubmitted:N.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Z?{}:N.keepDirtyValues?N.keepDefaultValues&&a?jr(s,a):r.dirtyFields:N.keepDefaultValues&&D?jr(s,D):N.keepDirty?r.dirtyFields:{},touchedFields:N.keepTouched?r.touchedFields:{},errors:N.keepErrors?r.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},ft=(D,N)=>_t(Be(D)?D(a):D,{...t.resetOptions,...N}),Zt=(D,N={})=>{const O=Y(n,D),X=O&&O._f;if(X){const Z=X.refs?X.refs[0]:X.ref;Z.focus&&setTimeout(()=>{Z.focus(),N.shouldSelect&&Be(Z.select)&&Z.select()})}},kn=D=>{r={...r,...D}},ht={control:{register:xe,unregister:pe,getFieldState:q,handleSubmit:Xe,setError:B,_subscribe:ne,_runSchema:E,_updateIsValidating:v,_focusError:Ze,_getWatch:V,_getDirty:R,_setValid:y,_setFieldArray:b,_setDisabledField:Ae,_setErrors:x,_getFieldArray:F,_reset:_t,_resetDefaultValues:()=>Be(t.defaultValues)&&t.defaultValues().then(D=>{ft(D,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:Ye,_subjects:p,_proxyFormState:d,get _fields(){return n},get _formValues(){return a},get _state(){return o},set _state(D){o=D},get _defaultValues(){return s},get _names(){return c},set _names(D){c=D},get _formState(){return r},get _options(){return t},set _options(D){t={...t,...D}}},subscribe:fe,trigger:z,register:xe,handleSubmit:Xe,watch:se,setValue:L,getValues:re,reset:ft,resetField:Ke,clearErrors:I,unregister:pe,setError:B,setFocus:Zt,getFieldState:q};return{...ht,formControl:ht}}function ec(e={}){const t=m.useRef(void 0),r=m.useRef(void 0),[n,s]=m.useState({isDirty:!1,isValidating:!1,isLoading:Be(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Be(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!Be(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...c}=hd(e);t.current={...c,formState:n}}const a=t.current.control;return a._options=e,Na(()=>{const o=a._subscribe({formState:a._proxyFormState,callback:()=>s({...a._formState}),reRenderRoot:!0});return s(c=>({...c,isReady:!0})),a._formState.isReady=!0,o},[a]),m.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),m.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),m.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),m.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),m.useEffect(()=>{if(a._proxyFormState.isDirty){const o=a._getDirty();o!==n.isDirty&&a._subjects.state.next({isDirty:o})}},[a,n.isDirty]),m.useEffect(()=>{var o;e.values&&!gt(e.values,r.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),!((o=a._options.resetOptions)===null||o===void 0)&&o.keepIsValid||a._setValid(),r.current=e.values,s(c=>({...c}))):a._resetDefaultValues()},[a,e.values]),m.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=Zi(n,a),t.current}const Oo=(e,t,r)=>{if(e&&"reportValidity"in e){const n=Y(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},tc=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?Oo(n.ref,r,e):n.refs&&n.refs.forEach(s=>Oo(s,r,e))}},md=(e,t)=>{t.shouldUseNativeValidation&&tc(e,t);const r={};for(const n in e){const s=Y(t.fields,n),a=Object.assign(e[n]||{},{ref:s&&s.ref});if(pd(t.names||Object.keys(e),n)){const o=Object.assign({},Y(r,n));ge(o,"root",a),ge(r,n,o)}else ge(r,n,a)}return r},pd=(e,t)=>e.some(r=>r.startsWith(t+"."));var gd=function(e,t){for(var r={};e.length;){var n=e[0],s=n.code,a=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var c=n.unionErrors[0].errors[0];r[o]={message:c.message,type:c.code}}else r[o]={message:a,type:s};if("unionErrors"in n&&n.unionErrors.forEach(function(f){return f.errors.forEach(function(d){return e.push(d)})}),t){var l=r[o].types,u=l&&l[n.code];r[o]=Yi(o,t,r,s,u?[].concat(u,n.message):n.message)}e.shift()}return r},rc=function(e,t,r){return r===void 0&&(r={}),function(n,s,a){try{return Promise.resolve((function(o,c){try{var l=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(u){return a.shouldUseNativeValidation&&tc({},a),{errors:{},values:r.raw?n:u}})}catch(u){return c(u)}return l&&l.then?l.then(void 0,c):l})(0,function(o){if((function(c){return Array.isArray(c?.errors)})(o))return{values:{},errors:md(gd(o.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw o}))}catch(o){return Promise.reject(o)}}},me;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function r(s){throw new Error}e.assertNever=r,e.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},e.getValidEnumValues=s=>{const a=e.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(a){return s[a]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},e.find=(s,a)=>{for(const o of s)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(me||(me={}));var Mo;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Mo||(Mo={}));const Q=me.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kt=e=>{switch(typeof e){case"undefined":return Q.undefined;case"string":return Q.string;case"number":return Number.isNaN(e)?Q.nan:Q.number;case"boolean":return Q.boolean;case"function":return Q.function;case"bigint":return Q.bigint;case"symbol":return Q.symbol;case"object":return Array.isArray(e)?Q.array:e===null?Q.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Q.promise:typeof Map<"u"&&e instanceof Map?Q.map:typeof Set<"u"&&e instanceof Set?Q.set:typeof Date<"u"&&e instanceof Date?Q.date:Q.object;default:return Q.unknown}},W=me.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class zt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(a){return a.message},n={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let c=n,l=0;for(;l<o.path.length;){const u=o.path[l];l===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(o))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),n}static assert(t){if(!(t instanceof zt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,me.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},n=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];r[a]=r[a]||[],r[a].push(t(s))}else n.push(t(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}zt.create=e=>new zt(e);const sa=(e,t)=>{let r;switch(e.code){case W.invalid_type:e.received===Q.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case W.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,me.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:r=`Unrecognized key(s) in object: ${me.joinValues(e.keys,", ")}`;break;case W.invalid_union:r="Invalid input";break;case W.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${me.joinValues(e.options)}`;break;case W.invalid_enum_value:r=`Invalid enum value. Expected ${me.joinValues(e.options)}, received '${e.received}'`;break;case W.invalid_arguments:r="Invalid function arguments";break;case W.invalid_return_type:r="Invalid function return type";break;case W.invalid_date:r="Invalid date";break;case W.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:me.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case W.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case W.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case W.custom:r="Invalid input";break;case W.invalid_intersection_types:r="Intersection results could not be merged";break;case W.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case W.not_finite:r="Number must be finite";break;default:r=t.defaultError,me.assertNever(e)}return{message:r}};let vd=sa;function yd(){return vd}const xd=e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)c=u(o,{data:t,defaultError:c}).message;return{...s,path:a,message:c}};function K(e,t){const r=yd(),n=xd({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===sa?void 0:sa].filter(s=>!!s)});e.common.issues.push(n)}class We{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const n=[];for(const s of r){if(s.status==="aborted")return oe;s.status==="dirty"&&t.dirty(),n.push(s.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){const n=[];for(const s of r){const a=await s.key,o=await s.value;n.push({key:a,value:o})}return We.mergeObjectSync(t,n)}static mergeObjectSync(t,r){const n={};for(const s of r){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return oe;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[a.value]=o.value)}return{status:t.value,value:n}}}const oe=Object.freeze({status:"aborted"}),Qr=e=>({status:"dirty",value:e}),dt=e=>({status:"valid",value:e}),Io=e=>e.status==="aborted",Fo=e=>e.status==="dirty",Pr=e=>e.status==="valid",Zn=e=>typeof Promise<"u"&&e instanceof Promise;var te;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(te||(te={}));class Ot{constructor(t,r,n,s){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Lo=(e,t)=>{if(Pr(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new zt(e.common.issues);return this._error=r,this._error}}};function ce(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(o,c)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??n??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:l??r??c.defaultError}},description:s}}class ue{get description(){return this._def.description}_getType(t){return Kt(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Kt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new We,ctx:{common:t.parent.common,data:t.data,parsedType:Kt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if(Zn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){const n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Kt(t)},s=this._parseSync({data:t,path:n.path,parent:n});return Lo(n,s)}"~validate"(t){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Kt(t)};if(!this["~standard"].async)try{const n=this._parseSync({data:t,path:[],parent:r});return Pr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Pr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){const n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){const n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Kt(t)},s=this._parse({data:t,path:n.path,parent:n}),a=await(Zn(s)?s:Promise.resolve(s));return Lo(n,a)}refine(t,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{const o=t(s),c=()=>a.addIssue({code:W.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(t,r){return this._refinement((n,s)=>t(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(t){return new Ir({schema:this,typeName:ae.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Qt.create(this,this._def)}nullable(){return Fr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tt.create(this)}promise(){return Kn.create(this,this._def)}or(t){return Gn.create([this,t],this._def)}and(t){return qn.create(this,t,this._def)}transform(t){return new Ir({...ce(this._def),schema:this,typeName:ae.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new la({...ce(this._def),innerType:this,defaultValue:r,typeName:ae.ZodDefault})}brand(){return new Bd({typeName:ae.ZodBranded,type:this,...ce(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new ua({...ce(this._def),innerType:this,catchValue:r,typeName:ae.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Ra.create(this,t)}readonly(){return da.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bd=/^c[^\s-]{8,}$/i,wd=/^[0-9a-z]+$/,_d=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sd=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Cd=/^[a-z0-9_-]{21}$/i,kd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Dd=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,jd=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Vs;const Ed=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ad=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Rd=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Td=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pd=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Od=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nc="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Md=new RegExp(`^${nc}$`);function sc(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Id(e){return new RegExp(`^${sc(e)}$`)}function Fd(e){let t=`${nc}T${sc(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Ld(e,t){return!!((t==="v4"||!t)&&Ed.test(e)||(t==="v6"||!t)&&Rd.test(e))}function $d(e,t){if(!kd.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function Vd(e,t){return!!((t==="v4"||!t)&&Ad.test(e)||(t==="v6"||!t)&&Td.test(e))}class jt extends ue{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Q.string){const a=this._getOrReturnCtx(t);return K(a,{code:W.invalid_type,expected:Q.string,received:a.parsedType}),oe}const n=new We;let s;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:W.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:W.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const o=t.data.length>a.value,c=t.data.length<a.value;(o||c)&&(s=this._getOrReturnCtx(t,s),o?K(s,{code:W.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&K(s,{code:W.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")jd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"email",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Vs||(Vs=new RegExp(Nd,"u")),Vs.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"emoji",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Sd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"uuid",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Cd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"nanoid",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")bd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"cuid",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")wd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"cuid2",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")_d.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"ulid",code:W.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),K(s,{validation:"url",code:W.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"regex",code:W.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(t,s),K(s,{code:W.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(s=this._getOrReturnCtx(t,s),K(s,{code:W.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(s=this._getOrReturnCtx(t,s),K(s,{code:W.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Fd(a).test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{code:W.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Md.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{code:W.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Id(a).test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{code:W.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Dd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"duration",code:W.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ld(t.data,a.version)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"ip",code:W.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?$d(t.data,a.alg)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"jwt",code:W.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Vd(t.data,a.version)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"cidr",code:W.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Pd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"base64",code:W.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Od.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"base64url",code:W.invalid_string,message:a.message}),n.dirty()):me.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(s=>t.test(s),{validation:r,code:W.invalid_string,...te.errToObj(n)})}_addCheck(t){return new jt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...te.errToObj(t)})}url(t){return this._addCheck({kind:"url",...te.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...te.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...te.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...te.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...te.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...te.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...te.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...te.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...te.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...te.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...te.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...te.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...te.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...te.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...te.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...te.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...te.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...te.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...te.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...te.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...te.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...te.errToObj(r)})}nonempty(t){return this.min(1,te.errToObj(t))}trim(){return new jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}jt.create=e=>new jt({checks:[],typeName:ae.ZodString,coerce:e?.coerce??!1,...ce(e)});function zd(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}class hr extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Q.number){const a=this._getOrReturnCtx(t);return K(a,{code:W.invalid_type,expected:Q.number,received:a.parsedType}),oe}let n;const s=new We;for(const a of this._def.checks)a.kind==="int"?me.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),K(n,{code:W.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:W.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:W.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?zd(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),K(n,{code:W.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),K(n,{code:W.not_finite,message:a.message}),s.dirty()):me.assertNever(a);return{status:s.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,te.toString(r))}gt(t,r){return this.setLimit("min",t,!1,te.toString(r))}lte(t,r){return this.setLimit("max",t,!0,te.toString(r))}lt(t,r){return this.setLimit("max",t,!1,te.toString(r))}setLimit(t,r,n,s){return new hr({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:te.toString(s)}]})}_addCheck(t){return new hr({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:te.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:te.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:te.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:te.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:te.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:te.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:te.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:te.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:te.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&me.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}}hr.create=e=>new hr({checks:[],typeName:ae.ZodNumber,coerce:e?.coerce||!1,...ce(e)});class mr extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Q.bigint)return this._getInvalidInput(t);let n;const s=new We;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:W.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:W.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),K(n,{code:W.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):me.assertNever(a);return{status:s.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return K(r,{code:W.invalid_type,expected:Q.bigint,received:r.parsedType}),oe}gte(t,r){return this.setLimit("min",t,!0,te.toString(r))}gt(t,r){return this.setLimit("min",t,!1,te.toString(r))}lte(t,r){return this.setLimit("max",t,!0,te.toString(r))}lt(t,r){return this.setLimit("max",t,!1,te.toString(r))}setLimit(t,r,n,s){return new mr({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:te.toString(s)}]})}_addCheck(t){return new mr({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:te.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:te.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:te.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:te.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:te.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}mr.create=e=>new mr({checks:[],typeName:ae.ZodBigInt,coerce:e?.coerce??!1,...ce(e)});class Yn extends ue{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Q.boolean){const n=this._getOrReturnCtx(t);return K(n,{code:W.invalid_type,expected:Q.boolean,received:n.parsedType}),oe}return dt(t.data)}}Yn.create=e=>new Yn({typeName:ae.ZodBoolean,coerce:e?.coerce||!1,...ce(e)});class Or extends ue{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Q.date){const a=this._getOrReturnCtx(t);return K(a,{code:W.invalid_type,expected:Q.date,received:a.parsedType}),oe}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return K(a,{code:W.invalid_date}),oe}const n=new We;let s;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:W.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:W.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):me.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Or({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:te.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:te.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}Or.create=e=>new Or({checks:[],coerce:e?.coerce||!1,typeName:ae.ZodDate,...ce(e)});class $o extends ue{_parse(t){if(this._getType(t)!==Q.symbol){const n=this._getOrReturnCtx(t);return K(n,{code:W.invalid_type,expected:Q.symbol,received:n.parsedType}),oe}return dt(t.data)}}$o.create=e=>new $o({typeName:ae.ZodSymbol,...ce(e)});class Vo extends ue{_parse(t){if(this._getType(t)!==Q.undefined){const n=this._getOrReturnCtx(t);return K(n,{code:W.invalid_type,expected:Q.undefined,received:n.parsedType}),oe}return dt(t.data)}}Vo.create=e=>new Vo({typeName:ae.ZodUndefined,...ce(e)});class zo extends ue{_parse(t){if(this._getType(t)!==Q.null){const n=this._getOrReturnCtx(t);return K(n,{code:W.invalid_type,expected:Q.null,received:n.parsedType}),oe}return dt(t.data)}}zo.create=e=>new zo({typeName:ae.ZodNull,...ce(e)});class aa extends ue{constructor(){super(...arguments),this._any=!0}_parse(t){return dt(t.data)}}aa.create=e=>new aa({typeName:ae.ZodAny,...ce(e)});class oa extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(t){return dt(t.data)}}oa.create=e=>new oa({typeName:ae.ZodUnknown,...ce(e)});class nr extends ue{_parse(t){const r=this._getOrReturnCtx(t);return K(r,{code:W.invalid_type,expected:Q.never,received:r.parsedType}),oe}}nr.create=e=>new nr({typeName:ae.ZodNever,...ce(e)});class Bo extends ue{_parse(t){if(this._getType(t)!==Q.undefined){const n=this._getOrReturnCtx(t);return K(n,{code:W.invalid_type,expected:Q.void,received:n.parsedType}),oe}return dt(t.data)}}Bo.create=e=>new Bo({typeName:ae.ZodVoid,...ce(e)});class Tt extends ue{_parse(t){const{ctx:r,status:n}=this._processInputParams(t),s=this._def;if(r.parsedType!==Q.array)return K(r,{code:W.invalid_type,expected:Q.array,received:r.parsedType}),oe;if(s.exactLength!==null){const o=r.data.length>s.exactLength.value,c=r.data.length<s.exactLength.value;(o||c)&&(K(r,{code:o?W.too_big:W.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(K(r,{code:W.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(K(r,{code:W.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,c)=>s.type._parseAsync(new Ot(r,o,r.path,c)))).then(o=>We.mergeArray(n,o));const a=[...r.data].map((o,c)=>s.type._parseSync(new Ot(r,o,r.path,c)));return We.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new Tt({...this._def,minLength:{value:t,message:te.toString(r)}})}max(t,r){return new Tt({...this._def,maxLength:{value:t,message:te.toString(r)}})}length(t,r){return new Tt({...this._def,exactLength:{value:t,message:te.toString(r)}})}nonempty(t){return this.min(1,t)}}Tt.create=(e,t)=>new Tt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ae.ZodArray,...ce(t)});function Nr(e){if(e instanceof De){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=Qt.create(Nr(n))}return new De({...e._def,shape:()=>t})}else return e instanceof Tt?new Tt({...e._def,type:Nr(e.element)}):e instanceof Qt?Qt.create(Nr(e.unwrap())):e instanceof Fr?Fr.create(Nr(e.unwrap())):e instanceof pr?pr.create(e.items.map(t=>Nr(t))):e}class De extends ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=me.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Q.object){const u=this._getOrReturnCtx(t);return K(u,{code:W.invalid_type,expected:Q.object,received:u.parsedType}),oe}const{status:n,ctx:s}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof nr&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||c.push(u);const l=[];for(const u of o){const f=a[u],d=s.data[u];l.push({key:{status:"valid",value:u},value:f._parse(new Ot(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof nr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of c)l.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")c.length>0&&(K(s,{code:W.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of c){const d=s.data[f];l.push({key:{status:"valid",value:f},value:u._parse(new Ot(s,d,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of l){const d=await f.key,h=await f.value;u.push({key:d,value:h,alwaysSet:f.alwaysSet})}return u}).then(u=>We.mergeObjectSync(n,u)):We.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(t){return te.errToObj,new De({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{const s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:te.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new De({...this._def,unknownKeys:"strip"})}passthrough(){return new De({...this._def,unknownKeys:"passthrough"})}extend(t){return new De({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new De({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ae.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new De({...this._def,catchall:t})}pick(t){const r={};for(const n of me.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new De({...this._def,shape:()=>r})}omit(t){const r={};for(const n of me.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new De({...this._def,shape:()=>r})}deepPartial(){return Nr(this)}partial(t){const r={};for(const n of me.objectKeys(this.shape)){const s=this.shape[n];t&&!t[n]?r[n]=s:r[n]=s.optional()}return new De({...this._def,shape:()=>r})}required(t){const r={};for(const n of me.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Qt;)a=a._def.innerType;r[n]=a}return new De({...this._def,shape:()=>r})}keyof(){return ac(me.objectKeys(this.shape))}}De.create=(e,t)=>new De({shape:()=>e,unknownKeys:"strip",catchall:nr.create(),typeName:ae.ZodObject,...ce(t)});De.strictCreate=(e,t)=>new De({shape:()=>e,unknownKeys:"strict",catchall:nr.create(),typeName:ae.ZodObject,...ce(t)});De.lazycreate=(e,t)=>new De({shape:e,unknownKeys:"strip",catchall:nr.create(),typeName:ae.ZodObject,...ce(t)});class Gn extends ue{_parse(t){const{ctx:r}=this._processInputParams(t),n=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new zt(c.ctx.common.issues));return K(r,{code:W.invalid_union,unionErrors:o}),oe}if(r.common.async)return Promise.all(n.map(async a=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const l of n){const u={...r,common:{...r.common,issues:[]},parent:null},f=l._parseSync({data:r.data,path:r.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(l=>new zt(l));return K(r,{code:W.invalid_union,unionErrors:c}),oe}}get options(){return this._def.options}}Gn.create=(e,t)=>new Gn({options:e,typeName:ae.ZodUnion,...ce(t)});function ia(e,t){const r=Kt(e),n=Kt(t);if(e===t)return{valid:!0,data:e};if(r===Q.object&&n===Q.object){const s=me.objectKeys(t),a=me.objectKeys(e).filter(c=>s.indexOf(c)!==-1),o={...e,...t};for(const c of a){const l=ia(e[c],t[c]);if(!l.valid)return{valid:!1};o[c]=l.data}return{valid:!0,data:o}}else if(r===Q.array&&n===Q.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const o=e[a],c=t[a],l=ia(o,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return r===Q.date&&n===Q.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class qn extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t),s=(a,o)=>{if(Io(a)||Io(o))return oe;const c=ia(a.value,o.value);return c.valid?((Fo(a)||Fo(o))&&r.dirty(),{status:r.value,value:c.data}):(K(n,{code:W.invalid_intersection_types}),oe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qn.create=(e,t,r)=>new qn({left:e,right:t,typeName:ae.ZodIntersection,...ce(r)});class pr extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.array)return K(n,{code:W.invalid_type,expected:Q.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return K(n,{code:W.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(K(n,{code:W.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((o,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new Ot(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>We.mergeArray(r,o)):We.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new pr({...this._def,rest:t})}}pr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pr({items:e,typeName:ae.ZodTuple,rest:null,...ce(t)})};class Xn extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.object)return K(n,{code:W.invalid_type,expected:Q.object,received:n.parsedType}),oe;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in n.data)s.push({key:a._parse(new Ot(n,c,n.path,c)),value:o._parse(new Ot(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?We.mergeObjectAsync(r,s):We.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof ue?new Xn({keyType:t,valueType:r,typeName:ae.ZodRecord,...ce(n)}):new Xn({keyType:jt.create(),valueType:t,typeName:ae.ZodRecord,...ce(r)})}}class Ho extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.map)return K(n,{code:W.invalid_type,expected:Q.map,received:n.parsedType}),oe;const s=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([c,l],u)=>({key:s._parse(new Ot(n,c,n.path,[u,"key"])),value:a._parse(new Ot(n,l,n.path,[u,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of o){const u=await l.key,f=await l.value;if(u.status==="aborted"||f.status==="aborted")return oe;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),c.set(u.value,f.value)}return{status:r.value,value:c}})}else{const c=new Map;for(const l of o){const u=l.key,f=l.value;if(u.status==="aborted"||f.status==="aborted")return oe;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),c.set(u.value,f.value)}return{status:r.value,value:c}}}}Ho.create=(e,t,r)=>new Ho({valueType:t,keyType:e,typeName:ae.ZodMap,...ce(r)});class cn extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.set)return K(n,{code:W.invalid_type,expected:Q.set,received:n.parsedType}),oe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(K(n,{code:W.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(K(n,{code:W.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const a=this._def.valueType;function o(l){const u=new Set;for(const f of l){if(f.status==="aborted")return oe;f.status==="dirty"&&r.dirty(),u.add(f.value)}return{status:r.value,value:u}}const c=[...n.data.values()].map((l,u)=>a._parse(new Ot(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>o(l)):o(c)}min(t,r){return new cn({...this._def,minSize:{value:t,message:te.toString(r)}})}max(t,r){return new cn({...this._def,maxSize:{value:t,message:te.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}cn.create=(e,t)=>new cn({valueType:e,minSize:null,maxSize:null,typeName:ae.ZodSet,...ce(t)});class Wo extends ue{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Wo.create=(e,t)=>new Wo({getter:e,typeName:ae.ZodLazy,...ce(t)});class ca extends ue{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return K(r,{received:r.data,code:W.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:t.data}}get value(){return this._def.value}}ca.create=(e,t)=>new ca({value:e,typeName:ae.ZodLiteral,...ce(t)});function ac(e,t){return new Mr({values:e,typeName:ae.ZodEnum,...ce(t)})}class Mr extends ue{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),n=this._def.values;return K(r,{expected:me.joinValues(n),received:r.parsedType,code:W.invalid_type}),oe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),n=this._def.values;return K(r,{received:r.data,code:W.invalid_enum_value,options:n}),oe}return dt(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Mr.create(t,{...this._def,...r})}exclude(t,r=this._def){return Mr.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}}Mr.create=ac;class Uo extends ue{_parse(t){const r=me.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Q.string&&n.parsedType!==Q.number){const s=me.objectValues(r);return K(n,{expected:me.joinValues(s),received:n.parsedType,code:W.invalid_type}),oe}if(this._cache||(this._cache=new Set(me.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=me.objectValues(r);return K(n,{received:n.data,code:W.invalid_enum_value,options:s}),oe}return dt(t.data)}get enum(){return this._def.values}}Uo.create=(e,t)=>new Uo({values:e,typeName:ae.ZodNativeEnum,...ce(t)});class Kn extends ue{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==Q.promise&&r.common.async===!1)return K(r,{code:W.invalid_type,expected:Q.promise,received:r.parsedType}),oe;const n=r.parsedType===Q.promise?r.data:Promise.resolve(r.data);return dt(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Kn.create=(e,t)=>new Kn({type:e,typeName:ae.ZodPromise,...ce(t)});class Ir extends ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ae.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:n}=this._processInputParams(t),s=this._def.effect||null,a={addIssue:o=>{K(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async c=>{if(r.value==="aborted")return oe;const l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?oe:l.status==="dirty"||r.value==="dirty"?Qr(l.value):l});{if(r.value==="aborted")return oe;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?oe:c.status==="dirty"||r.value==="dirty"?Qr(c.value):c}}if(s.type==="refinement"){const o=c=>{const l=s.refinement(c,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?oe:(c.status==="dirty"&&r.dirty(),o(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?oe:(c.status==="dirty"&&r.dirty(),o(c.value).then(()=>({status:r.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Pr(o))return oe;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Pr(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:r.value,value:c})):oe);me.assertNever(s)}}Ir.create=(e,t,r)=>new Ir({schema:e,typeName:ae.ZodEffects,effect:t,...ce(r)});Ir.createWithPreprocess=(e,t,r)=>new Ir({schema:t,effect:{type:"preprocess",transform:e},typeName:ae.ZodEffects,...ce(r)});class Qt extends ue{_parse(t){return this._getType(t)===Q.undefined?dt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Qt.create=(e,t)=>new Qt({innerType:e,typeName:ae.ZodOptional,...ce(t)});class Fr extends ue{_parse(t){return this._getType(t)===Q.null?dt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Fr.create=(e,t)=>new Fr({innerType:e,typeName:ae.ZodNullable,...ce(t)});class la extends ue{_parse(t){const{ctx:r}=this._processInputParams(t);let n=r.data;return r.parsedType===Q.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}la.create=(e,t)=>new la({innerType:e,typeName:ae.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ce(t)});class ua extends ue{_parse(t){const{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Zn(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ua.create=(e,t)=>new ua({innerType:e,typeName:ae.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ce(t)});class Zo extends ue{_parse(t){if(this._getType(t)!==Q.nan){const n=this._getOrReturnCtx(t);return K(n,{code:W.invalid_type,expected:Q.nan,received:n.parsedType}),oe}return{status:"valid",value:t.data}}}Zo.create=e=>new Zo({typeName:ae.ZodNaN,...ce(e)});class Bd extends ue{_parse(t){const{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Ra extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?oe:a.status==="dirty"?(r.dirty(),Qr(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(t,r){return new Ra({in:t,out:r,typeName:ae.ZodPipeline})}}class da extends ue{_parse(t){const r=this._def.innerType._parse(t),n=s=>(Pr(s)&&(s.value=Object.freeze(s.value)),s);return Zn(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}da.create=(e,t)=>new da({innerType:e,typeName:ae.ZodReadonly,...ce(t)});var ae;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(ae||(ae={}));const J=jt.create,Ce=hr.create;mr.create;const qe=Yn.create,Se=Or.create,oc=aa.create,Hd=oa.create;nr.create;const Bt=Tt.create,Le=De.create,gs=Gn.create;qn.create;pr.create;const ic=Xn.create,$t=ca.create,vn=Mr.create;Kn.create;Qt.create;Fr.create;const Jn={string:(e=>jt.create({...e,coerce:!0})),number:(e=>hr.create({...e,coerce:!0})),boolean:(e=>Yn.create({...e,coerce:!0})),bigint:(e=>mr.create({...e,coerce:!0})),date:(e=>Or.create({...e,coerce:!0}))};function Yo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ta(...e){return t=>{let r=!1;const n=e.map(s=>{const a=Yo(s,t);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let s=0;s<n.length;s++){const a=n[s];typeof a=="function"?a():Yo(e[s],null)}}}}function it(...e){return S.useCallback(Ta(...e),e)}var Wd=Symbol.for("react.lazy"),Qn=S[" use ".trim().toString()];function Ud(e){return typeof e=="object"&&e!==null&&"then"in e}function cc(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Wd&&"_payload"in e&&Ud(e._payload)}function Zd(e){const t=Gd(e),r=S.forwardRef((n,s)=>{let{children:a,...o}=n;cc(a)&&typeof Qn=="function"&&(a=Qn(a._payload));const c=S.Children.toArray(a),l=c.find(Xd);if(l){const u=l.props.children,f=c.map(d=>d===l?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:d);return i.jsx(t,{...o,ref:s,children:S.isValidElement(u)?S.cloneElement(u,void 0,f):null})}return i.jsx(t,{...o,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}var Yd=Zd("Slot");function Gd(e){const t=S.forwardRef((r,n)=>{let{children:s,...a}=r;if(cc(s)&&typeof Qn=="function"&&(s=Qn(s._payload)),S.isValidElement(s)){const o=Jd(s),c=Kd(a,s.props);return s.type!==S.Fragment&&(c.ref=n?Ta(n,o):o),S.cloneElement(s,c)}return S.Children.count(s)>1?S.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var qd=Symbol("radix.slottable");function Xd(e){return S.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qd}function Kd(e,t){const r={...t};for(const n in t){const s=e[n],a=t[n];/^on[A-Z]/.test(n)?s&&a?r[n]=(...c)=>{const l=a(...c);return s(...c),l}:s&&(r[n]=s):n==="style"?r[n]={...s,...a}:n==="className"&&(r[n]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function Jd(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}const Go=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,qo=Bi,Qd=(e,t)=>r=>{var n;if(t?.variants==null)return qo(e,r?.class,r?.className);const{variants:s,defaultVariants:a}=t,o=Object.keys(s).map(u=>{const f=r?.[u],d=a?.[u];if(f===null)return null;const h=Go(f)||Go(d);return s[u][h]}),c=r&&Object.entries(r).reduce((u,f)=>{let[d,h]=f;return h===void 0||(u[d]=h),u},{}),l=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:d,className:h,...p}=f;return Object.entries(p).every(w=>{let[g,y]=w;return Array.isArray(y)?y.includes({...a,...c}[g]):{...a,...c}[g]===y})?[...u,d,h]:u},[]);return qo(e,o,l,r?.class,r?.className)},rn=Qd("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 min-w-[var(--ui-space-0)] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-chart-4 text-white shadow-sm hover:bg-chart-4/90",outline:"border border-input bg-transparent text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-accent underline-offset-4 underline hover:text-accent/80 !h-auto !py-[var(--ui-space-0)]",positive:"bg-chart-2 text-white shadow-sm hover:bg-chart-2/90",warning:"bg-chart-3 text-white shadow-sm hover:bg-chart-3/90",info:"bg-chart-5 text-white shadow-sm hover:bg-chart-5/90","outline-positive":"border border-chart-2 text-chart-2 hover:bg-chart-2/10","outline-negative":"border border-muted text-muted-foreground hover:bg-muted/10",fab:"rounded-full h-[var(--ui-space-14)] w-[var(--ui-space-14)] p-[var(--ui-space-0)] shadow-lg hover:shadow-xl bg-primary text-primary-foreground hover:bg-primary/90","circle-help":"bg-accent text-accent-foreground shadow-sm hover:bg-accent/90 rounded-full","circle-alert":"bg-chart-3 text-white shadow-sm hover:bg-chart-3/90 rounded-full",abort:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",negative:"bg-muted text-muted-foreground shadow-sm hover:bg-muted/80",delete:"bg-chart-4 text-white shadow-sm hover:bg-chart-4/90",pause:"bg-chart-3 text-white shadow-sm hover:bg-chart-3/90","outline-abort":"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",option:"border border-[hsl(210,30%,35%)] dark:border-border bg-background text-foreground shadow-none hover:bg-accent/30 hover:text-foreground","option-active":"border-2 border-primary bg-primary/10 text-foreground shadow-none hover:bg-primary/20","outline-delete":"border border-destructive/50 text-destructive bg-background hover:bg-destructive/10 hover:border-destructive"},size:{default:"px-ui-button py-ui text-ui min-h-ui-touch",sm:"rounded-md px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-xs",lg:"rounded-md px-[var(--ui-space-8)] py-[var(--ui-space-3)]",icon:"p-ui min-h-ui-touch min-w-[var(--ui-touch-target-min)]",circle:"rounded-full p-[var(--ui-space-2)] aspect-square"}},defaultVariants:{variant:"default",size:"default"}}),ie=S.forwardRef(({className:e,variant:t="default",size:r,children:n,loading:s=!1,success:a=!1,error:o=!1,icon:c,asChild:l=!1,disabled:u,maxLabelLength:f=100,...d},h)=>{const p=l?Yd:"button",w=a?"positive":o?"destructive":t,g=()=>{if(s)return i.jsx(ye.Spinner,{className:"h-ui-icon w-ui-icon"});if(a)return i.jsx(ye.Check,{className:"h-ui-icon w-ui-icon"});if(o)return i.jsx(ye.X,{className:"h-ui-icon w-ui-icon"});const y=typeof n=="string"&&n.length>f?`${n.slice(0,Math.max(0,f-1))}…`:n,v=typeof n=="string"&&typeof y=="string"&&y!==n,b=typeof n=="string"?i.jsx("span",{className:"min-w-[var(--ui-space-0)] flex-1 whitespace-nowrap",title:v?n:void 0,children:y}):n;return i.jsxs("span",{className:"flex min-w-[var(--ui-space-0)] items-center",children:[c&&i.jsx(c,{className:de(n?"mr-[var(--ui-space-2)]":"mr-[var(--ui-space-0)]","h-ui-icon w-ui-icon")}),b]})};return i.jsx(p,{className:de(rn({variant:w,size:r,className:e})),ref:h,disabled:u||s||a||o,...d,children:g()})});ie.displayName="Button";function ef(e,t){const r=S.createContext(t),n=a=>{const{children:o,...c}=a,l=S.useMemo(()=>c,Object.values(c));return i.jsx(r.Provider,{value:l,children:o})};n.displayName=e+"Provider";function s(a){const o=S.useContext(r);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[n,s]}function vs(e,t=[]){let r=[];function n(a,o){const c=S.createContext(o),l=r.length;r=[...r,o];const u=d=>{const{scope:h,children:p,...w}=d,g=h?.[e]?.[l]||c,y=S.useMemo(()=>w,Object.values(w));return i.jsx(g.Provider,{value:y,children:p})};u.displayName=a+"Provider";function f(d,h){const p=h?.[e]?.[l]||c,w=S.useContext(p);if(w)return w;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[u,f]}const s=()=>{const a=r.map(o=>S.createContext(o));return function(c){const l=c?.[e]||a;return S.useMemo(()=>({[`__scope${e}`]:{...c,[e]:l}}),[c,l])}};return s.scopeName=e,[n,tf(s,...t)]}function tf(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const o=n.reduce((c,{useScope:l,scopeName:u})=>{const d=l(a)[`__scope${u}`];return{...c,...d}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}function He(e,t,{checkForDefaultPrevented:r=!0}={}){return function(s){if(e?.(s),r===!1||!s.defaultPrevented)return t?.(s)}}var sr=globalThis?.document?S.useLayoutEffect:()=>{},rf=S[" useInsertionEffect ".trim().toString()]||sr;function Pa({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[s,a,o]=nf({defaultProp:t,onChange:r}),c=e!==void 0,l=c?e:s;{const f=S.useRef(e!==void 0);S.useEffect(()=>{const d=f.current;d!==c&&console.warn(`${n} is changing from ${d?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,n])}const u=S.useCallback(f=>{if(c){const d=sf(f)?f(e):f;d!==e&&o.current?.(d)}else a(f)},[c,e,a,o]);return[l,u]}function nf({defaultProp:e,onChange:t}){const[r,n]=S.useState(e),s=S.useRef(r),a=S.useRef(t);return rf(()=>{a.current=t},[t]),S.useEffect(()=>{s.current!==r&&(a.current?.(r),s.current=r)},[r,s]),[r,n,a]}function sf(e){return typeof e=="function"}function af(e){const t=S.useRef({value:e,previous:e});return S.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function lc(e){const[t,r]=S.useState(void 0);return sr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let o,c;if("borderBoxSize"in a){const l=a.borderBoxSize,u=Array.isArray(l)?l[0]:l;o=u.inlineSize,c=u.blockSize}else o=e.offsetWidth,c=e.offsetHeight;r({width:o,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}function of(e,t){return S.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=cf(t),s=typeof r=="function"?r({present:n.isPresent}):S.Children.only(r),a=it(n.ref,lf(s));return typeof r=="function"||n.isPresent?S.cloneElement(s,{ref:a}):null};xr.displayName="Presence";function cf(e){const[t,r]=S.useState(),n=S.useRef(null),s=S.useRef(e),a=S.useRef("none"),o=e?"mounted":"unmounted",[c,l]=of(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const u=Rn(n.current);a.current=c==="mounted"?u:"none"},[c]),sr(()=>{const u=n.current,f=s.current;if(f!==e){const h=a.current,p=Rn(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,l]),sr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,d=p=>{const g=Rn(n.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(a.current=Rn(n.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:S.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Rn(e){return e?.animationName||"none"}function lf(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Oa(e){const t=uf(e),r=S.forwardRef((n,s)=>{const{children:a,...o}=n,c=S.Children.toArray(a),l=c.find(ff);if(l){const u=l.props.children,f=c.map(d=>d===l?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:d);return i.jsx(t,{...o,ref:s,children:S.isValidElement(u)?S.cloneElement(u,void 0,f):null})}return i.jsx(t,{...o,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function uf(e){const t=S.forwardRef((r,n)=>{const{children:s,...a}=r;if(S.isValidElement(s)){const o=mf(s),c=hf(a,s.props);return s.type!==S.Fragment&&(c.ref=n?Ta(n,o):o),S.cloneElement(s,c)}return S.Children.count(s)>1?S.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var df=Symbol("radix.slottable");function ff(e){return S.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===df}function hf(e,t){const r={...t};for(const n in t){const s=e[n],a=t[n];/^on[A-Z]/.test(n)?s&&a?r[n]=(...c)=>{const l=a(...c);return s(...c),l}:s&&(r[n]=s):n==="style"?r[n]={...s,...a}:n==="className"&&(r[n]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function mf(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var pf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=pf.reduce((e,t)=>{const r=Oa(`Primitive.${t}`),n=S.forwardRef((s,a)=>{const{asChild:o,...c}=s,l=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(l,{...c,ref:a})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function gf(e,t){e&&Vi.flushSync(()=>e.dispatchEvent(t))}var ys="Checkbox",[vf]=vs(ys),[yf,Ma]=vf(ys);function xf(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:s,disabled:a,form:o,name:c,onCheckedChange:l,required:u,value:f="on",internal_do_not_use_render:d}=e,[h,p]=Pa({prop:r,defaultProp:s??!1,onChange:l,caller:ys}),[w,g]=S.useState(null),[y,v]=S.useState(null),b=S.useRef(!1),C=w?!!o||!!w.closest("form"):!0,x={checked:h,disabled:a,setChecked:p,control:w,setControl:g,name:c,form:o,value:f,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:er(s)?!1:s,isFormControl:C,bubbleInput:y,setBubbleInput:v};return i.jsx(yf,{scope:t,...x,children:bf(d)?d(x):n})}var uc="CheckboxTrigger",dc=S.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},s)=>{const{control:a,value:o,disabled:c,checked:l,required:u,setControl:f,setChecked:d,hasConsumerStoppedPropagationRef:h,isFormControl:p,bubbleInput:w}=Ma(uc,e),g=it(s,f),y=S.useRef(l);return S.useEffect(()=>{const v=a?.form;if(v){const b=()=>d(y.current);return v.addEventListener("reset",b),()=>v.removeEventListener("reset",b)}},[a,d]),i.jsx(Ie.button,{type:"button",role:"checkbox","aria-checked":er(l)?"mixed":l,"aria-required":u,"data-state":gc(l),"data-disabled":c?"":void 0,disabled:c,value:o,...n,ref:g,onKeyDown:He(t,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:He(r,v=>{d(b=>er(b)?!0:!b),w&&p&&(h.current=v.isPropagationStopped(),h.current||v.stopPropagation())})})});dc.displayName=uc;var Ia=S.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:a,required:o,disabled:c,value:l,onCheckedChange:u,form:f,...d}=e;return i.jsx(xf,{__scopeCheckbox:r,checked:s,defaultChecked:a,disabled:c,required:o,onCheckedChange:u,name:n,form:f,value:l,internal_do_not_use_render:({isFormControl:h})=>i.jsxs(i.Fragment,{children:[i.jsx(dc,{...d,ref:t,__scopeCheckbox:r}),h&&i.jsx(pc,{__scopeCheckbox:r})]})})});Ia.displayName=ys;var fc="CheckboxIndicator",hc=S.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...s}=e,a=Ma(fc,r);return i.jsx(xr,{present:n||er(a.checked)||a.checked===!0,children:i.jsx(Ie.span,{"data-state":gc(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});hc.displayName=fc;var mc="CheckboxBubbleInput",pc=S.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:a,defaultChecked:o,required:c,disabled:l,name:u,value:f,form:d,bubbleInput:h,setBubbleInput:p}=Ma(mc,e),w=it(r,p),g=af(a),y=lc(n);S.useEffect(()=>{const b=h;if(!b)return;const C=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(C,"checked").set,k=!s.current;if(g!==a&&_){const j=new Event("click",{bubbles:k});b.indeterminate=er(a),_.call(b,er(a)?!1:a),b.dispatchEvent(j)}},[h,g,a,s]);const v=S.useRef(er(a)?!1:a);return i.jsx(Ie.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??v.current,required:c,disabled:l,name:u,value:f,form:d,...t,tabIndex:-1,ref:w,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});pc.displayName=mc;function bf(e){return typeof e=="function"}function er(e){return e==="indeterminate"}function gc(e){return er(e)?"indeterminate":e?"checked":"unchecked"}const ln=S.forwardRef(({className:e,...t},r)=>i.jsx(Ia,{ref:r,className:de("peer h-ui-checkbox w-ui-checkbox shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:i.jsx(hc,{className:de("flex items-center justify-center text-current"),children:i.jsx(ye.Check,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})}));ln.displayName=Ia.displayName;function Ne(e,t,r){const n=t||void 0;switch(r){case"header":return new Intl.DateTimeFormat(n,{year:"numeric",month:"short"}).format(e);case"picker":return new Intl.DateTimeFormat(n,{year:"numeric",month:"short",day:"numeric"}).format(e);case"weekday":{const s=new Intl.DateTimeFormat(n,{weekday:"short"}).format(e);return n?.startsWith("ja")?`(${s})`:new Intl.DateTimeFormat(n,{weekday:"long"}).format(e)}case"weekdayShort":return new Intl.DateTimeFormat(n,{weekday:"short"}).format(e);case"day":return new Intl.NumberFormat(n).format(e.getDate());case"monthDayShort":return new Intl.DateTimeFormat(n,{month:"short",day:"numeric",weekday:"short"}).format(e);case"compact":return new Intl.DateTimeFormat(n,{month:"numeric",day:"numeric",weekday:"short"}).format(e);case"time":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric"}).format(e);case"timeWithSeconds":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",second:"numeric"}).format(e);case"timeWithMs":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}).format(e);case"minute":return new Intl.DateTimeFormat(n,{minute:"numeric"}).format(e);case"second":return new Intl.DateTimeFormat(n,{second:"numeric"}).format(e);case"time12":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",hour12:!0}).format(e);case"time24":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",hour12:!1}).format(e);case"year":return new Intl.DateTimeFormat(n,{year:"numeric"}).format(e);case"month":return new Intl.DateTimeFormat(n,{month:"long"}).format(e);case"monthShort":return new Intl.DateTimeFormat(n,{month:"short"}).format(e);case"full":{const s=new Intl.DateTimeFormat(n,{year:"numeric",month:"long",day:"numeric"}).format(e),a=new Intl.DateTimeFormat(n,{weekday:"short"}).format(e);return n?.startsWith("ja")?`${s}(${a})`:new Intl.DateTimeFormat(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"}).format(e)}case"yearMonth":return new Intl.DateTimeFormat(n,{year:"numeric",month:"long"}).format(e);case"monthDay":return new Intl.DateTimeFormat(n,{month:"long",day:"numeric"}).format(e);default:return e.toLocaleDateString(n)}}const wf={loading:"Loading",today_button:"Today",previous:"Previous",next:"Next",view_day:"Day",view_week:"Week",view_month:"Month",days_short_sun:"Sun",days_short_mon:"Mon",days_short_tue:"Tue",days_short_wed:"Wed",days_short_thu:"Thu",days_short_fri:"Fri",days_short_sat:"Sat",user_name_label:"User Name",name_placeholder:"Enter name",attendee_label:"Attendee",attendee_placeholder:"Enter attendee name",resource_label:"Resource",resource_placeholder:"Select resource",start_time_label:"Start Time",duration_label:"Duration",status_label:"Status",note_label:"Notes",delete_button:"Delete",cancel_button:"Cancel",save_button:"Save",confirm_delete_title:"Delete Event",confirm_delete_message:"Are you sure you want to delete this event?",event_edit_title:"Edit Event",event_create_title:"Create Event",facility_prompt_group_name:"Enter group name",facility_confirm_delete_group_message:"Delete this group?",facility_prompt_resource_name:"Enter resource name",facility_confirm_delete_resource_message:"Delete this resource?",close:"Close",facility_settings_title:"Facility Settings",facility_label_group_name:"Group",facility_label_resource_name:"Resource",facility_action_add_group:"Add Group",facility_action_add_resource:"Add Resource",facility_label_no_groups:"No groups",facility_action_done:"Done",settings_title:"Settings",settings_language:"Language",settings_theme:"Theme",option_light:"Light",option_dark:"Dark",settings_density:"Density",option_compact:"Compact",option_normal:"Normal",option_spacious:"Spacious",settings_radius:"Radius",settings_font_size:"Font Size",settings_week_start:"Week Starts On",option_sunday:"Sunday",option_monday:"Monday",settings_business_hours:"Business Hours",settings_closed_days:"Closed Days",settings_pagination:"Facility Pagination",settings_page_size:"Items per page",page:"Page",previousPage:"Previous Page",nextPage:"Next Page",day_cell:"Day cell",event_custom_edit_title:"Edit Event",event_custom_create_title:"Create Event",event_name_label:"Event Name",event_name_placeholder:"Enter event name",usage_label:"Usage",usage_placeholder:"Select usage",all_day:"All day",date_time_label:"Date & Time",attendee_self:"Only me",date_picker_label:"Select date",personnel_list_title:"Personnel",personnel_search_placeholder:"Search by name or email...",personnel_priority_high:"High Priority",personnel_priority_normal:"Normal",personnel_priority_low:"Low Priority",personnel_no_results:"No matching personnel found",personnel_selected_count:"{{count}} selected",personnel_context_hint:"Right-click to set priority",keypad_title_number:"Enter number",keypad_title_phone:"Enter phone number",keypad_title_time:"Enter time",keypad_error_max_length:"Up to {{max}} characters",keypad_error_hyphen_repeat:"Hyphen cannot be repeated",keypad_error_decimal_repeat:"Only one decimal point is allowed",keypad_error_time_invalid:"Enter a valid 4-digit time (e.g., 0930)",keypad_error_value_required:"Please enter a value",keypad_error_decimal_end:"Value cannot end with a decimal point",keypad_error_hyphen_end:"Value cannot end with a hyphen"};function $e(){const{t:e,i18n:t}=_a.useTranslation();return{t:(n,s)=>{const a=typeof s=="string"?{defaultValue:s}:s??{},o=a.defaultValue??wf[n]??n;return e(n,{...a,defaultValue:o})},i18n:t}}function br(e,t){const r=new Date(e);return r.setDate(r.getDate()+t),r}function _f(e,t){return br(e,t*7)}function Fa(e,t){const r=new Date(e),n=r.getMonth()+t;return r.setMonth(n),r.getMonth()!==(n%12+12)%12&&r.setDate(0),r}function Sf(e,t){return Fa(e,-1)}function gr(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function Cf(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function vc(e){const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),t}function yc(e){const t=new Date(e);return t.setMonth(t.getMonth()+1),t.setDate(0),t.setHours(23,59,59,999),t}function nn(e,t){const r=t?.weekStartsOn??0,n=new Date(e),s=n.getDay(),a=(s<r?7:0)+s-r;return n.setDate(n.getDate()-a),n.setHours(0,0,0,0),n}function fa(e,t){const r=nn(e,t),n=br(r,6);return n.setHours(23,59,59,999),n}function lr(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function kf(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function Xo(e,t){const r=e.getTime();return r>=t.start.getTime()&&r<=t.end.getTime()}function xc(e,t){return e.start.getTime()<t.end.getTime()&&t.start.getTime()<e.end.getTime()}function Ko(e){const t=gr(e.start),n=gr(e.end).getTime(),s=[],a=new Date(t);for(;a.getTime()<=n;)s.push(new Date(a)),a.setDate(a.getDate()+1);return s}function Df(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function bc(e){const t=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0");return`${t}:${r}`}function Er(e){return`${Df(e)}T${bc(e)}`}function Jo({className:e,locale:t,mode:r="single",selected:n,onSelect:s,disabled:a,numberOfMonths:o=1,defaultMonth:c}){const[l,u]=S.useState(c||new Date),f=_=>a?Array.isArray(a)?a.some(k=>k instanceof Date?lr(_,k):typeof k=="object"&&"before"in k&&k.before?_<k.before:typeof k=="object"&&"after"in k&&k.after?_>k.after:!1):a instanceof Date?lr(_,a):typeof a=="function"?a(_):!1:!1,d=_=>{if(!n)return!1;if(r==="single"&&n instanceof Date)return lr(_,n);if(r==="range"&&n.from){const k=n;if(k.from&&lr(_,k.from)||k.to&&lr(_,k.to))return!0;if(k.from&&k.to)return Xo(_,{start:k.from,end:k.to})}return!1},h=_=>{let k=!1,j=!1,E=!1;if(r==="range"&&n?.from){const A=n;A.from&&lr(_,A.from)&&(k=!0),A.to&&lr(_,A.to)&&(j=!0),A.from&&A.to&&Xo(_,{start:A.from,end:A.to})&&(E=!0)}return de(rn({variant:"ghost"}),"p-ui font-normal aria-selected:opacity-100",d(_)&&"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",E&&!k&&!j&&"bg-accent text-accent-foreground rounded-none",k&&"bg-primary text-primary-foreground rounded-l-md rounded-r-none",j&&"bg-primary text-primary-foreground rounded-l-none rounded-r-md",r==="single"&&d(_)&&"rounded-md",!kf(_,l)&&"text-muted-foreground opacity-50",f(_)&&"text-muted-foreground opacity-50 cursor-not-allowed")},p=_=>{if(!f(_)){if(r==="single")s?.(_);else if(r==="range"){const k=n||{from:void 0,to:void 0};!k.from||k.from&&k.to?s?.({from:_,to:void 0}):_<k.from?s?.({from:_,to:void 0}):s?.({from:k.from,to:_})}}},w=()=>u(Fa(l,1)),g=()=>u(Sf(l)),y=vc(l),v=yc(y),b=nn(y),C=fa(v),x=Ko({start:b,end:C});return i.jsxs("div",{className:de("p-ui flex flex-col gap-y-ui",e),children:[i.jsxs("div",{className:"flex items-center justify-between gap-x-ui",children:[i.jsx("button",{type:"button",onClick:g,className:de(rn({variant:"outline"}),"bg-transparent p-ui hover:bg-accent hover:text-accent-foreground"),children:i.jsx(ye.ChevronLeft,{className:"h-ui-icon w-ui-icon",strokeWidth:3})}),i.jsx("div",{className:"font-medium text-ui",children:Ne(l,t,"header")}),i.jsx("button",{type:"button",onClick:w,className:de(rn({variant:"outline"}),"bg-transparent p-ui hover:bg-accent hover:text-accent-foreground"),children:i.jsx(ye.ChevronRight,{className:"h-ui-icon w-ui-icon",strokeWidth:3})})]}),i.jsxs("table",{className:"w-full border-collapse space-y-[var(--ui-space-1)]",children:[i.jsx("thead",{children:i.jsx("tr",{children:Ko({start:nn(l),end:fa(nn(l))}).map(_=>{const k=_.getDay(),j=k===0,E=k===6;return i.jsx("th",{className:de("rounded-md font-normal text-[0.8rem]",j&&"text-red-500",E&&"text-blue-500",!j&&!E&&"text-muted-foreground"),children:i.jsx("div",{className:"flex justify-center items-center p-ui",children:Ne(_,t,"weekdayShort")})},_.getTime())})})}),i.jsx("tbody",{children:Array.from({length:Math.ceil(x.length/7)}).map((_,k)=>{const j=x.slice(k*7,(k+1)*7);return i.jsx("tr",{className:"w-full",children:j.map(E=>i.jsx("td",{className:"p-[var(--ui-space-0)] text-center relative focus-within:relative",children:i.jsx("button",{type:"button",onClick:()=>p(E),className:h(E),disabled:f(E),children:Ne(E,t,"day")})},E.getTime()))},j[0]?.getTime()||k)})})]})]})}function Lr(e){const t=S.useRef(e);return S.useEffect(()=>{t.current=e}),S.useMemo(()=>(...r)=>t.current?.(...r),[])}function jf(e,t=globalThis?.document){const r=Lr(e);S.useEffect(()=>{const n=s=>{s.key==="Escape"&&r(s)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var Nf="DismissableLayer",ha="dismissableLayer.update",Ef="dismissableLayer.pointerDownOutside",Af="dismissableLayer.focusOutside",Qo,wc=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),La=S.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:c,...l}=e,u=S.useContext(wc),[f,d]=S.useState(null),h=f?.ownerDocument??globalThis?.document,[,p]=S.useState({}),w=it(t,j=>d(j)),g=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(y),b=f?g.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,x=b>=v,_=Pf(j=>{const E=j.target,A=[...u.branches].some(T=>T.contains(E));!x||A||(s?.(j),o?.(j),j.defaultPrevented||c?.())},h),k=Of(j=>{const E=j.target;[...u.branches].some(T=>T.contains(E))||(a?.(j),o?.(j),j.defaultPrevented||c?.())},h);return jf(j=>{b===u.layers.size-1&&(n?.(j),!j.defaultPrevented&&c&&(j.preventDefault(),c()))},h),S.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Qo=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),ei(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Qo)}},[f,h,r,u]),S.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),ei())},[f,u]),S.useEffect(()=>{const j=()=>p({});return document.addEventListener(ha,j),()=>document.removeEventListener(ha,j)},[]),i.jsx(Ie.div,{...l,ref:w,style:{pointerEvents:C?x?"auto":"none":void 0,...e.style},onFocusCapture:He(e.onFocusCapture,k.onFocusCapture),onBlurCapture:He(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:He(e.onPointerDownCapture,_.onPointerDownCapture)})});La.displayName=Nf;var Rf="DismissableLayerBranch",Tf=S.forwardRef((e,t)=>{const r=S.useContext(wc),n=S.useRef(null),s=it(t,n);return S.useEffect(()=>{const a=n.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),i.jsx(Ie.div,{...e,ref:s})});Tf.displayName=Rf;function Pf(e,t=globalThis?.document){const r=Lr(e),n=S.useRef(!1),s=S.useRef(()=>{});return S.useEffect(()=>{const a=c=>{if(c.target&&!n.current){let l=function(){_c(Ef,r,u,{discrete:!0})};const u={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=l,t.addEventListener("click",s.current,{once:!0})):l()}else t.removeEventListener("click",s.current);n.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function Of(e,t=globalThis?.document){const r=Lr(e),n=S.useRef(!1);return S.useEffect(()=>{const s=a=>{a.target&&!n.current&&_c(Af,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function ei(){const e=new CustomEvent(ha);document.dispatchEvent(e)}function _c(e,t,r,{discrete:n}){const s=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),n?gf(s,a):s.dispatchEvent(a)}var zs=0;function Sc(){S.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ti()),document.body.insertAdjacentElement("beforeend",e[1]??ti()),zs++,()=>{zs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zs--}},[])}function ti(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Bs="focusScope.autoFocusOnMount",Hs="focusScope.autoFocusOnUnmount",ri={bubbles:!1,cancelable:!0},Mf="FocusScope",$a=S.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=e,[c,l]=S.useState(null),u=Lr(s),f=Lr(a),d=S.useRef(null),h=it(t,g=>l(g)),p=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(n){let g=function(C){if(p.paused||!c)return;const x=C.target;c.contains(x)?d.current=x:Xt(d.current,{select:!0})},y=function(C){if(p.paused||!c)return;const x=C.relatedTarget;x!==null&&(c.contains(x)||Xt(d.current,{select:!0}))},v=function(C){if(document.activeElement===document.body)for(const _ of C)_.removedNodes.length>0&&Xt(c)};document.addEventListener("focusin",g),document.addEventListener("focusout",y);const b=new MutationObserver(v);return c&&b.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",y),b.disconnect()}}},[n,c,p.paused]),S.useEffect(()=>{if(c){si.add(p);const g=document.activeElement;if(!c.contains(g)){const v=new CustomEvent(Bs,ri);c.addEventListener(Bs,u),c.dispatchEvent(v),v.defaultPrevented||(If(zf(Cc(c)),{select:!0}),document.activeElement===g&&Xt(c))}return()=>{c.removeEventListener(Bs,u),setTimeout(()=>{const v=new CustomEvent(Hs,ri);c.addEventListener(Hs,f),c.dispatchEvent(v),v.defaultPrevented||Xt(g??document.body,{select:!0}),c.removeEventListener(Hs,f),si.remove(p)},0)}}},[c,u,f,p]);const w=S.useCallback(g=>{if(!r&&!n||p.paused)return;const y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(y&&v){const b=g.currentTarget,[C,x]=Ff(b);C&&x?!g.shiftKey&&v===x?(g.preventDefault(),r&&Xt(C,{select:!0})):g.shiftKey&&v===C&&(g.preventDefault(),r&&Xt(x,{select:!0})):v===b&&g.preventDefault()}},[r,n,p.paused]);return i.jsx(Ie.div,{tabIndex:-1,...o,ref:h,onKeyDown:w})});$a.displayName=Mf;function If(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(Xt(n,{select:t}),document.activeElement!==r)return}function Ff(e){const t=Cc(e),r=ni(t,e),n=ni(t.reverse(),e);return[r,n]}function Cc(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ni(e,t){for(const r of e)if(!Lf(r,{upTo:t}))return r}function Lf(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function $f(e){return e instanceof HTMLInputElement&&"select"in e}function Xt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&$f(e)&&t&&e.select()}}var si=Vf();function Vf(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=ai(e,t),e.unshift(t)},remove(t){e=ai(e,t),e[0]?.resume()}}}function ai(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function zf(e){return e.filter(t=>t.tagName!=="A")}var Bf=S[" useId ".trim().toString()]||(()=>{}),Hf=0;function Ln(e){const[t,r]=S.useState(Bf());return sr(()=>{r(n=>n??String(Hf++))},[e]),e||(t?`radix-${t}`:"")}const Wf=["top","right","bottom","left"],ar=Math.min,st=Math.max,es=Math.round,Tn=Math.floor,Pt=e=>({x:e,y:e}),Uf={left:"right",right:"left",bottom:"top",top:"bottom"},Zf={start:"end",end:"start"};function ma(e,t,r){return st(e,ar(t,r))}function Ht(e,t){return typeof e=="function"?e(t):e}function Wt(e){return e.split("-")[0]}function Br(e){return e.split("-")[1]}function Va(e){return e==="x"?"y":"x"}function za(e){return e==="y"?"height":"width"}const Yf=new Set(["top","bottom"]);function Nt(e){return Yf.has(Wt(e))?"y":"x"}function Ba(e){return Va(Nt(e))}function Gf(e,t,r){r===void 0&&(r=!1);const n=Br(e),s=Ba(e),a=za(s);let o=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=ts(o)),[o,ts(o)]}function qf(e){const t=ts(e);return[pa(e),t,pa(t)]}function pa(e){return e.replace(/start|end/g,t=>Zf[t])}const oi=["left","right"],ii=["right","left"],Xf=["top","bottom"],Kf=["bottom","top"];function Jf(e,t,r){switch(e){case"top":case"bottom":return r?t?ii:oi:t?oi:ii;case"left":case"right":return t?Xf:Kf;default:return[]}}function Qf(e,t,r,n){const s=Br(e);let a=Jf(Wt(e),r==="start",n);return s&&(a=a.map(o=>o+"-"+s),t&&(a=a.concat(a.map(pa)))),a}function ts(e){return e.replace(/left|right|bottom|top/g,t=>Uf[t])}function eh(e){return{top:0,right:0,bottom:0,left:0,...e}}function kc(e){return typeof e!="number"?eh(e):{top:e,right:e,bottom:e,left:e}}function rs(e){const{x:t,y:r,width:n,height:s}=e;return{width:n,height:s,top:r,left:t,right:t+n,bottom:r+s,x:t,y:r}}function ci(e,t,r){let{reference:n,floating:s}=e;const a=Nt(t),o=Ba(t),c=za(o),l=Wt(t),u=a==="y",f=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,h=n[c]/2-s[c]/2;let p;switch(l){case"top":p={x:f,y:n.y-s.height};break;case"bottom":p={x:f,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-s.width,y:d};break;default:p={x:n.x,y:n.y}}switch(Br(t)){case"start":p[o]-=h*(r&&u?-1:1);break;case"end":p[o]+=h*(r&&u?-1:1);break}return p}const th=async(e,t,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:a=[],platform:o}=r,c=a.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:d}=ci(u,n,l),h=n,p={},w=0;for(let g=0;g<c.length;g++){const{name:y,fn:v}=c[g],{x:b,y:C,data:x,reset:_}=await v({x:f,y:d,initialPlacement:n,placement:h,strategy:s,middlewareData:p,rects:u,platform:o,elements:{reference:e,floating:t}});f=b??f,d=C??d,p={...p,[y]:{...p[y],...x}},_&&w<=50&&(w++,typeof _=="object"&&(_.placement&&(h=_.placement),_.rects&&(u=_.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:s}):_.rects),{x:f,y:d}=ci(u,h,l)),g=-1)}return{x:f,y:d,placement:h,strategy:s,middlewareData:p}};async function un(e,t){var r;t===void 0&&(t={});const{x:n,y:s,platform:a,rects:o,elements:c,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=Ht(t,e),w=kc(p),y=c[h?d==="floating"?"reference":"floating":d],v=rs(await a.getClippingRect({element:(r=await(a.isElement==null?void 0:a.isElement(y)))==null||r?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:u,rootBoundary:f,strategy:l})),b=d==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),x=await(a.isElement==null?void 0:a.isElement(C))?await(a.getScale==null?void 0:a.getScale(C))||{x:1,y:1}:{x:1,y:1},_=rs(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:C,strategy:l}):b);return{top:(v.top-_.top+w.top)/x.y,bottom:(_.bottom-v.bottom+w.bottom)/x.y,left:(v.left-_.left+w.left)/x.x,right:(_.right-v.right+w.right)/x.x}}const rh=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:s,rects:a,platform:o,elements:c,middlewareData:l}=t,{element:u,padding:f=0}=Ht(e,t)||{};if(u==null)return{};const d=kc(f),h={x:r,y:n},p=Ba(s),w=za(p),g=await o.getDimensions(u),y=p==="y",v=y?"top":"left",b=y?"bottom":"right",C=y?"clientHeight":"clientWidth",x=a.reference[w]+a.reference[p]-h[p]-a.floating[w],_=h[p]-a.reference[p],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let j=k?k[C]:0;(!j||!await(o.isElement==null?void 0:o.isElement(k)))&&(j=c.floating[C]||a.floating[w]);const E=x/2-_/2,A=j/2-g[w]/2-1,T=ar(d[v],A),M=ar(d[b],A),R=T,V=j-g[w]-M,F=j/2-g[w]/2+E,G=ma(R,F,V),$=!l.arrow&&Br(s)!=null&&F!==G&&a.reference[w]/2-(F<R?T:M)-g[w]/2<0,L=$?F<R?F-R:F-V:0;return{[p]:h[p]+L,data:{[p]:G,centerOffset:F-G-L,...$&&{alignmentOffset:L}},reset:$}}}),nh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:s,middlewareData:a,rects:o,initialPlacement:c,platform:l,elements:u}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:g=!0,...y}=Ht(e,t);if((r=a.arrow)!=null&&r.alignmentOffset)return{};const v=Wt(s),b=Nt(c),C=Wt(c)===c,x=await(l.isRTL==null?void 0:l.isRTL(u.floating)),_=h||(C||!g?[ts(c)]:qf(c)),k=w!=="none";!h&&k&&_.push(...Qf(c,g,w,x));const j=[c,..._],E=await un(t,y),A=[];let T=((n=a.flip)==null?void 0:n.overflows)||[];if(f&&A.push(E[v]),d){const F=Gf(s,o,x);A.push(E[F[0]],E[F[1]])}if(T=[...T,{placement:s,overflows:A}],!A.every(F=>F<=0)){var M,R;const F=(((M=a.flip)==null?void 0:M.index)||0)+1,G=j[F];if(G&&(!(d==="alignment"?b!==Nt(G):!1)||T.every(P=>Nt(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:F,overflows:T},reset:{placement:G}};let $=(R=T.filter(L=>L.overflows[0]<=0).sort((L,P)=>L.overflows[1]-P.overflows[1])[0])==null?void 0:R.placement;if(!$)switch(p){case"bestFit":{var V;const L=(V=T.filter(P=>{if(k){const H=Nt(P.placement);return H===b||H==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(H=>H>0).reduce((H,z)=>H+z,0)]).sort((P,H)=>P[1]-H[1])[0])==null?void 0:V[0];L&&($=L);break}case"initialPlacement":$=c;break}if(s!==$)return{reset:{placement:$}}}return{}}}};function li(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ui(e){return Wf.some(t=>e[t]>=0)}const sh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:n="referenceHidden",...s}=Ht(e,t);switch(n){case"referenceHidden":{const a=await un(t,{...s,elementContext:"reference"}),o=li(a,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:ui(o)}}}case"escaped":{const a=await un(t,{...s,altBoundary:!0}),o=li(a,r.floating);return{data:{escapedOffsets:o,escaped:ui(o)}}}default:return{}}}}},Dc=new Set(["left","top"]);async function ah(e,t){const{placement:r,platform:n,elements:s}=e,a=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=Wt(r),c=Br(r),l=Nt(r)==="y",u=Dc.has(o)?-1:1,f=a&&l?-1:1,d=Ht(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof w=="number"&&(p=c==="end"?w*-1:w),l?{x:p*f,y:h*u}:{x:h*u,y:p*f}}const oh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:s,y:a,placement:o,middlewareData:c}=t,l=await ah(t,e);return o===((r=c.offset)==null?void 0:r.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:s+l.x,y:a+l.y,data:{...l,placement:o}}}}},ih=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:s}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:c={fn:y=>{let{x:v,y:b}=y;return{x:v,y:b}}},...l}=Ht(e,t),u={x:r,y:n},f=await un(t,l),d=Nt(Wt(s)),h=Va(d);let p=u[h],w=u[d];if(a){const y=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=p+f[y],C=p-f[v];p=ma(b,p,C)}if(o){const y=d==="y"?"top":"left",v=d==="y"?"bottom":"right",b=w+f[y],C=w-f[v];w=ma(b,w,C)}const g=c.fn({...t,[h]:p,[d]:w});return{...g,data:{x:g.x-r,y:g.y-n,enabled:{[h]:a,[d]:o}}}}}},ch=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:s,rects:a,middlewareData:o}=t,{offset:c=0,mainAxis:l=!0,crossAxis:u=!0}=Ht(e,t),f={x:r,y:n},d=Nt(s),h=Va(d);let p=f[h],w=f[d];const g=Ht(c,t),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=h==="y"?"height":"width",x=a.reference[h]-a.floating[C]+y.mainAxis,_=a.reference[h]+a.reference[C]-y.mainAxis;p<x?p=x:p>_&&(p=_)}if(u){var v,b;const C=h==="y"?"width":"height",x=Dc.has(Wt(s)),_=a.reference[d]-a.floating[C]+(x&&((v=o.offset)==null?void 0:v[d])||0)+(x?0:y.crossAxis),k=a.reference[d]+a.reference[C]+(x?0:((b=o.offset)==null?void 0:b[d])||0)-(x?y.crossAxis:0);w<_?w=_:w>k&&(w=k)}return{[h]:p,[d]:w}}}},lh=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:s,rects:a,platform:o,elements:c}=t,{apply:l=()=>{},...u}=Ht(e,t),f=await un(t,u),d=Wt(s),h=Br(s),p=Nt(s)==="y",{width:w,height:g}=a.floating;let y,v;d==="top"||d==="bottom"?(y=d,v=h===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(v=d,y=h==="end"?"top":"bottom");const b=g-f.top-f.bottom,C=w-f.left-f.right,x=ar(g-f[y],b),_=ar(w-f[v],C),k=!t.middlewareData.shift;let j=x,E=_;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(E=C),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(j=b),k&&!h){const T=st(f.left,0),M=st(f.right,0),R=st(f.top,0),V=st(f.bottom,0);p?E=w-2*(T!==0||M!==0?T+M:st(f.left,f.right)):j=g-2*(R!==0||V!==0?R+V:st(f.top,f.bottom))}await l({...t,availableWidth:E,availableHeight:j});const A=await o.getDimensions(c.floating);return w!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function xs(){return typeof window<"u"}function Hr(e){return jc(e)?(e.nodeName||"").toLowerCase():"#document"}function ot(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function It(e){var t;return(t=(jc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jc(e){return xs()?e instanceof Node||e instanceof ot(e).Node:!1}function yt(e){return xs()?e instanceof Element||e instanceof ot(e).Element:!1}function Mt(e){return xs()?e instanceof HTMLElement||e instanceof ot(e).HTMLElement:!1}function di(e){return!xs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ot(e).ShadowRoot}const uh=new Set(["inline","contents"]);function yn(e){const{overflow:t,overflowX:r,overflowY:n,display:s}=xt(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!uh.has(s)}const dh=new Set(["table","td","th"]);function fh(e){return dh.has(Hr(e))}const hh=[":popover-open",":modal"];function bs(e){return hh.some(t=>{try{return e.matches(t)}catch{return!1}})}const mh=["transform","translate","scale","rotate","perspective"],ph=["transform","translate","scale","rotate","perspective","filter"],gh=["paint","layout","strict","content"];function Ha(e){const t=Wa(),r=yt(e)?xt(e):e;return mh.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||ph.some(n=>(r.willChange||"").includes(n))||gh.some(n=>(r.contain||"").includes(n))}function vh(e){let t=or(e);for(;Mt(t)&&!$r(t);){if(Ha(t))return t;if(bs(t))return null;t=or(t)}return null}function Wa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const yh=new Set(["html","body","#document"]);function $r(e){return yh.has(Hr(e))}function xt(e){return ot(e).getComputedStyle(e)}function ws(e){return yt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function or(e){if(Hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||di(e)&&e.host||It(e);return di(t)?t.host:t}function Nc(e){const t=or(e);return $r(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mt(t)&&yn(t)?t:Nc(t)}function dn(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const s=Nc(e),a=s===((n=e.ownerDocument)==null?void 0:n.body),o=ot(s);if(a){const c=ga(o);return t.concat(o,o.visualViewport||[],yn(s)?s:[],c&&r?dn(c):[])}return t.concat(s,dn(s,[],r))}function ga(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ec(e){const t=xt(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const s=Mt(e),a=s?e.offsetWidth:r,o=s?e.offsetHeight:n,c=es(r)!==a||es(n)!==o;return c&&(r=a,n=o),{width:r,height:n,$:c}}function Ua(e){return yt(e)?e:e.contextElement}function Ar(e){const t=Ua(e);if(!Mt(t))return Pt(1);const r=t.getBoundingClientRect(),{width:n,height:s,$:a}=Ec(t);let o=(a?es(r.width):r.width)/n,c=(a?es(r.height):r.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const xh=Pt(0);function Ac(e){const t=ot(e);return!Wa()||!t.visualViewport?xh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bh(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==ot(e)?!1:t}function vr(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const s=e.getBoundingClientRect(),a=Ua(e);let o=Pt(1);t&&(n?yt(n)&&(o=Ar(n)):o=Ar(e));const c=bh(a,r,n)?Ac(a):Pt(0);let l=(s.left+c.x)/o.x,u=(s.top+c.y)/o.y,f=s.width/o.x,d=s.height/o.y;if(a){const h=ot(a),p=n&&yt(n)?ot(n):n;let w=h,g=ga(w);for(;g&&n&&p!==w;){const y=Ar(g),v=g.getBoundingClientRect(),b=xt(g),C=v.left+(g.clientLeft+parseFloat(b.paddingLeft))*y.x,x=v.top+(g.clientTop+parseFloat(b.paddingTop))*y.y;l*=y.x,u*=y.y,f*=y.x,d*=y.y,l+=C,u+=x,w=ot(g),g=ga(w)}}return rs({width:f,height:d,x:l,y:u})}function _s(e,t){const r=ws(e).scrollLeft;return t?t.left+r:vr(It(e)).left+r}function Rc(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-_s(e,r),s=r.top+t.scrollTop;return{x:n,y:s}}function wh(e){let{elements:t,rect:r,offsetParent:n,strategy:s}=e;const a=s==="fixed",o=It(n),c=t?bs(t.floating):!1;if(n===o||c&&a)return r;let l={scrollLeft:0,scrollTop:0},u=Pt(1);const f=Pt(0),d=Mt(n);if((d||!d&&!a)&&((Hr(n)!=="body"||yn(o))&&(l=ws(n)),Mt(n))){const p=vr(n);u=Ar(n),f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}const h=o&&!d&&!a?Rc(o,l):Pt(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+f.x+h.x,y:r.y*u.y-l.scrollTop*u.y+f.y+h.y}}function _h(e){return Array.from(e.getClientRects())}function Sh(e){const t=It(e),r=ws(e),n=e.ownerDocument.body,s=st(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),a=st(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+_s(e);const c=-r.scrollTop;return xt(n).direction==="rtl"&&(o+=st(t.clientWidth,n.clientWidth)-s),{width:s,height:a,x:o,y:c}}const fi=25;function Ch(e,t){const r=ot(e),n=It(e),s=r.visualViewport;let a=n.clientWidth,o=n.clientHeight,c=0,l=0;if(s){a=s.width,o=s.height;const f=Wa();(!f||f&&t==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}const u=_s(n);if(u<=0){const f=n.ownerDocument,d=f.body,h=getComputedStyle(d),p=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,w=Math.abs(n.clientWidth-d.clientWidth-p);w<=fi&&(a-=w)}else u<=fi&&(a+=u);return{width:a,height:o,x:c,y:l}}const kh=new Set(["absolute","fixed"]);function Dh(e,t){const r=vr(e,!0,t==="fixed"),n=r.top+e.clientTop,s=r.left+e.clientLeft,a=Mt(e)?Ar(e):Pt(1),o=e.clientWidth*a.x,c=e.clientHeight*a.y,l=s*a.x,u=n*a.y;return{width:o,height:c,x:l,y:u}}function hi(e,t,r){let n;if(t==="viewport")n=Ch(e,r);else if(t==="document")n=Sh(It(e));else if(yt(t))n=Dh(t,r);else{const s=Ac(e);n={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return rs(n)}function Tc(e,t){const r=or(e);return r===t||!yt(r)||$r(r)?!1:xt(r).position==="fixed"||Tc(r,t)}function jh(e,t){const r=t.get(e);if(r)return r;let n=dn(e,[],!1).filter(c=>yt(c)&&Hr(c)!=="body"),s=null;const a=xt(e).position==="fixed";let o=a?or(e):e;for(;yt(o)&&!$r(o);){const c=xt(o),l=Ha(o);!l&&c.position==="fixed"&&(s=null),(a?!l&&!s:!l&&c.position==="static"&&!!s&&kh.has(s.position)||yn(o)&&!l&&Tc(e,o))?n=n.filter(f=>f!==o):s=c,o=or(o)}return t.set(e,n),n}function Nh(e){let{element:t,boundary:r,rootBoundary:n,strategy:s}=e;const o=[...r==="clippingAncestors"?bs(t)?[]:jh(t,this._c):[].concat(r),n],c=o[0],l=o.reduce((u,f)=>{const d=hi(t,f,s);return u.top=st(d.top,u.top),u.right=ar(d.right,u.right),u.bottom=ar(d.bottom,u.bottom),u.left=st(d.left,u.left),u},hi(t,c,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Eh(e){const{width:t,height:r}=Ec(e);return{width:t,height:r}}function Ah(e,t,r){const n=Mt(t),s=It(t),a=r==="fixed",o=vr(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=Pt(0);function u(){l.x=_s(s)}if(n||!n&&!a)if((Hr(t)!=="body"||yn(s))&&(c=ws(t)),n){const p=vr(t,!0,a,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else s&&u();a&&!n&&s&&u();const f=s&&!n&&!a?Rc(s,c):Pt(0),d=o.left+c.scrollLeft-l.x-f.x,h=o.top+c.scrollTop-l.y-f.y;return{x:d,y:h,width:o.width,height:o.height}}function Ws(e){return xt(e).position==="static"}function mi(e,t){if(!Mt(e)||xt(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return It(e)===r&&(r=r.ownerDocument.body),r}function Pc(e,t){const r=ot(e);if(bs(e))return r;if(!Mt(e)){let s=or(e);for(;s&&!$r(s);){if(yt(s)&&!Ws(s))return s;s=or(s)}return r}let n=mi(e,t);for(;n&&fh(n)&&Ws(n);)n=mi(n,t);return n&&$r(n)&&Ws(n)&&!Ha(n)?r:n||vh(e)||r}const Rh=async function(e){const t=this.getOffsetParent||Pc,r=this.getDimensions,n=await r(e.floating);return{reference:Ah(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Th(e){return xt(e).direction==="rtl"}const Ph={convertOffsetParentRelativeRectToViewportRelativeRect:wh,getDocumentElement:It,getClippingRect:Nh,getOffsetParent:Pc,getElementRects:Rh,getClientRects:_h,getDimensions:Eh,getScale:Ar,isElement:yt,isRTL:Th};function Oc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Oh(e,t){let r=null,n;const s=It(e);function a(){var c;clearTimeout(n),(c=r)==null||c.disconnect(),r=null}function o(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),a();const u=e.getBoundingClientRect(),{left:f,top:d,width:h,height:p}=u;if(c||t(),!h||!p)return;const w=Tn(d),g=Tn(s.clientWidth-(f+h)),y=Tn(s.clientHeight-(d+p)),v=Tn(f),C={rootMargin:-w+"px "+-g+"px "+-y+"px "+-v+"px",threshold:st(0,ar(1,l))||1};let x=!0;function _(k){const j=k[0].intersectionRatio;if(j!==l){if(!x)return o();j?o(!1,j):n=setTimeout(()=>{o(!1,1e-7)},1e3)}j===1&&!Oc(u,e.getBoundingClientRect())&&o(),x=!1}try{r=new IntersectionObserver(_,{...C,root:s.ownerDocument})}catch{r=new IntersectionObserver(_,C)}r.observe(e)}return o(!0),a}function Mh(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=n,u=Ua(e),f=s||a?[...u?dn(u):[],...dn(t)]:[];f.forEach(v=>{s&&v.addEventListener("scroll",r,{passive:!0}),a&&v.addEventListener("resize",r)});const d=u&&c?Oh(u,r):null;let h=-1,p=null;o&&(p=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let w,g=l?vr(e):null;l&&y();function y(){const v=vr(e);g&&!Oc(g,v)&&r(),g=v,w=requestAnimationFrame(y)}return r(),()=>{var v;f.forEach(b=>{s&&b.removeEventListener("scroll",r),a&&b.removeEventListener("resize",r)}),d?.(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const Ih=oh,Fh=ih,Lh=nh,$h=lh,Vh=sh,pi=rh,zh=ch,Bh=(e,t,r)=>{const n=new Map,s={platform:Ph,...r},a={...s.platform,_c:n};return th(e,t,{...s,platform:a})};var Hh=typeof document<"u",Wh=function(){},$n=Hh?m.useLayoutEffect:Wh;function ns(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!ns(e[n],t[n]))return!1;return!0}if(s=Object.keys(e),r=s.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,s[n]))return!1;for(n=r;n--!==0;){const a=s[n];if(!(a==="_owner"&&e.$$typeof)&&!ns(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Mc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gi(e,t){const r=Mc(e);return Math.round(t*r)/r}function Us(e){const t=S.useRef(e);return $n(()=>{t.current=e}),t}function Uh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[f,d]=S.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=S.useState(n);ns(h,n)||p(n);const[w,g]=S.useState(null),[y,v]=S.useState(null),b=S.useCallback(P=>{P!==k.current&&(k.current=P,g(P))},[]),C=S.useCallback(P=>{P!==j.current&&(j.current=P,v(P))},[]),x=a||w,_=o||y,k=S.useRef(null),j=S.useRef(null),E=S.useRef(f),A=l!=null,T=Us(l),M=Us(s),R=Us(u),V=S.useCallback(()=>{if(!k.current||!j.current)return;const P={placement:t,strategy:r,middleware:h};M.current&&(P.platform=M.current),Bh(k.current,j.current,P).then(H=>{const z={...H,isPositioned:R.current!==!1};F.current&&!ns(E.current,z)&&(E.current=z,Vi.flushSync(()=>{d(z)}))})},[h,t,r,M,R]);$n(()=>{u===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(P=>({...P,isPositioned:!1})))},[u]);const F=S.useRef(!1);$n(()=>(F.current=!0,()=>{F.current=!1}),[]),$n(()=>{if(x&&(k.current=x),_&&(j.current=_),x&&_){if(T.current)return T.current(x,_,V);V()}},[x,_,V,T,A]);const G=S.useMemo(()=>({reference:k,floating:j,setReference:b,setFloating:C}),[b,C]),$=S.useMemo(()=>({reference:x,floating:_}),[x,_]),L=S.useMemo(()=>{const P={position:r,left:0,top:0};if(!$.floating)return P;const H=gi($.floating,f.x),z=gi($.floating,f.y);return c?{...P,transform:"translate("+H+"px, "+z+"px)",...Mc($.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:H,top:z}},[r,c,$.floating,f.x,f.y]);return S.useMemo(()=>({...f,update:V,refs:G,elements:$,floatingStyles:L}),[f,V,G,$,L])}const Zh=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:s}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?pi({element:n.current,padding:s}).fn(r):{}:n?pi({element:n,padding:s}).fn(r):{}}}},Yh=(e,t)=>({...Ih(e),options:[e,t]}),Gh=(e,t)=>({...Fh(e),options:[e,t]}),qh=(e,t)=>({...zh(e),options:[e,t]}),Xh=(e,t)=>({...Lh(e),options:[e,t]}),Kh=(e,t)=>({...$h(e),options:[e,t]}),Jh=(e,t)=>({...Vh(e),options:[e,t]}),Qh=(e,t)=>({...Zh(e),options:[e,t]});var em="Arrow",Ic=S.forwardRef((e,t)=>{const{children:r,width:n=10,height:s=5,...a}=e;return i.jsx(Ie.svg,{...a,ref:t,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ic.displayName=em;var tm=Ic,Za="Popper",[Fc,Lc]=vs(Za),[rm,$c]=Fc(Za),Vc=e=>{const{__scopePopper:t,children:r}=e,[n,s]=S.useState(null);return i.jsx(rm,{scope:t,anchor:n,onAnchorChange:s,children:r})};Vc.displayName=Za;var zc="PopperAnchor",Bc=S.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...s}=e,a=$c(zc,r),o=S.useRef(null),c=it(t,o),l=S.useRef(null);return S.useEffect(()=>{const u=l.current;l.current=n?.current||o.current,u!==l.current&&a.onAnchorChange(l.current)}),n?null:i.jsx(Ie.div,{...s,ref:c})});Bc.displayName=zc;var Ya="PopperContent",[nm,sm]=Fc(Ya),Hc=S.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:a="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:w,...g}=e,y=$c(Ya,r),[v,b]=S.useState(null),C=it(t,fe=>b(fe)),[x,_]=S.useState(null),k=lc(x),j=k?.width??0,E=k?.height??0,A=n+(a!=="center"?"-"+a:""),T=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},M=Array.isArray(u)?u:[u],R=M.length>0,V={padding:T,boundary:M.filter(om),altBoundary:R},{refs:F,floatingStyles:G,placement:$,isPositioned:L,middlewareData:P}=Uh({strategy:"fixed",placement:A,whileElementsMounted:(...fe)=>Mh(...fe,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Yh({mainAxis:s+E,alignmentAxis:o}),l&&Gh({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?qh():void 0,...V}),l&&Xh({...V}),Kh({...V,apply:({elements:fe,rects:pe,availableWidth:Ae,availableHeight:xe})=>{const{width:Ze,height:Ye}=pe.reference,Xe=fe.floating.style;Xe.setProperty("--radix-popper-available-width",`${Ae}px`),Xe.setProperty("--radix-popper-available-height",`${xe}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ze}px`),Xe.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),x&&Qh({element:x,padding:c}),im({arrowWidth:j,arrowHeight:E}),h&&Jh({strategy:"referenceHidden",...V})]}),[H,z]=Zc($),re=Lr(w);sr(()=>{L&&re?.()},[L,re]);const q=P.arrow?.x,I=P.arrow?.y,B=P.arrow?.centerOffset!==0,[se,ne]=S.useState();return sr(()=>{v&&ne(window.getComputedStyle(v).zIndex)},[v]),i.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:L?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(" "),...P.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(nm,{scope:r,placedSide:H,onArrowChange:_,arrowX:q,arrowY:I,shouldHideArrow:B,children:i.jsx(Ie.div,{"data-side":H,"data-align":z,...g,ref:C,style:{...g.style,animation:L?void 0:"none"}})})})});Hc.displayName=Ya;var Wc="PopperArrow",am={top:"bottom",right:"left",bottom:"top",left:"right"},Uc=S.forwardRef(function(t,r){const{__scopePopper:n,...s}=t,a=sm(Wc,n),o=am[a.placedSide];return i.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:i.jsx(tm,{...s,ref:r,style:{...s.style,display:"block"}})})});Uc.displayName=Wc;function om(e){return e!==null}var im=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:s}=t,o=s.arrow?.centerOffset!==0,c=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[u,f]=Zc(r),d={start:"0%",center:"50%",end:"100%"}[f],h=(s.arrow?.x??0)+c/2,p=(s.arrow?.y??0)+l/2;let w="",g="";return u==="bottom"?(w=o?d:`${h}px`,g=`${-l}px`):u==="top"?(w=o?d:`${h}px`,g=`${n.floating.height+l}px`):u==="right"?(w=`${-l}px`,g=o?d:`${p}px`):u==="left"&&(w=`${n.floating.width+l}px`,g=o?d:`${p}px`),{data:{x:w,y:g}}}});function Zc(e){const[t,r="center"]=e.split("-");return[t,r]}var cm=Vc,Yc=Bc,lm=Hc,um=Uc,dm="Portal",Ga=S.forwardRef((e,t)=>{const{container:r,...n}=e,[s,a]=S.useState(!1);sr(()=>a(!0),[]);const o=r||s&&globalThis?.document?.body;return o?dr.createPortal(i.jsx(Ie.div,{...n,ref:t}),o):null});Ga.displayName=dm;var fm=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,Pn=new WeakMap,On={},Zs=0,Gc=function(e){return e&&(e.host||Gc(e.parentNode))},hm=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=Gc(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},mm=function(e,t,r,n){var s=hm(t,Array.isArray(e)?e:[e]);On[r]||(On[r]=new WeakMap);var a=On[r],o=[],c=new Set,l=new Set(s),u=function(d){!d||c.has(d)||(c.add(d),u(d.parentNode))};s.forEach(u);var f=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(c.has(h))f(h);else try{var p=h.getAttribute(n),w=p!==null&&p!=="false",g=(Sr.get(h)||0)+1,y=(a.get(h)||0)+1;Sr.set(h,g),a.set(h,y),o.push(h),g===1&&w&&Pn.set(h,!0),y===1&&h.setAttribute(r,"true"),w||h.setAttribute(n,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return f(t),c.clear(),Zs++,function(){o.forEach(function(d){var h=Sr.get(d)-1,p=a.get(d)-1;Sr.set(d,h),a.set(d,p),h||(Pn.has(d)||d.removeAttribute(n),Pn.delete(d)),p||d.removeAttribute(r)}),Zs--,Zs||(Sr=new WeakMap,Sr=new WeakMap,Pn=new WeakMap,On={})}},qc=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),s=fm(e);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live], script"))),mm(n,s,r,"aria-hidden")):function(){return null}},Dt=function(){return Dt=Object.assign||function(t){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Dt.apply(this,arguments)};function Xc(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function pm(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,a;n<s;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var Vn="right-scroll-bar-position",zn="width-before-scroll-bar",gm="with-scroll-bars-hidden",vm="--removed-body-scroll-bar-size";function Ys(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ym(e,t){var r=m.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var s=r.value;s!==n&&(r.value=n,r.callback(n,s))}}}})[0];return r.callback=t,r.facade}var xm=typeof window<"u"?S.useLayoutEffect:S.useEffect,vi=new WeakMap;function bm(e,t){var r=ym(null,function(n){return e.forEach(function(s){return Ys(s,n)})});return xm(function(){var n=vi.get(r);if(n){var s=new Set(n),a=new Set(e),o=r.current;s.forEach(function(c){a.has(c)||Ys(c,null)}),a.forEach(function(c){s.has(c)||Ys(c,o)})}vi.set(r,e)},[e]),r}function wm(e){return e}function _m(e,t){t===void 0&&(t=wm);var r=[],n=!1,s={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(a){var o=t(a,n);return r.push(o),function(){r=r.filter(function(c){return c!==o})}},assignSyncMedium:function(a){for(n=!0;r.length;){var o=r;r=[],o.forEach(a)}r={push:function(c){return a(c)},filter:function(){return r}}},assignMedium:function(a){n=!0;var o=[];if(r.length){var c=r;r=[],c.forEach(a),o=r}var l=function(){var f=o;o=[],f.forEach(a)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(f){o.push(f),u()},filter:function(f){return o=o.filter(f),r}}}};return s}function Sm(e){e===void 0&&(e={});var t=_m(null);return t.options=Dt({async:!0,ssr:!1},e),t}var Kc=function(e){var t=e.sideCar,r=Xc(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return S.createElement(n,Dt({},r))};Kc.isSideCarExport=!0;function Cm(e,t){return e.useMedium(t),Kc}var Jc=Sm(),Gs=function(){},Ss=S.forwardRef(function(e,t){var r=S.useRef(null),n=S.useState({onScrollCapture:Gs,onWheelCapture:Gs,onTouchMoveCapture:Gs}),s=n[0],a=n[1],o=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,f=e.enabled,d=e.shards,h=e.sideCar,p=e.noRelative,w=e.noIsolation,g=e.inert,y=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,C=e.gapMode,x=Xc(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=h,k=bm([r,t]),j=Dt(Dt({},x),s);return S.createElement(S.Fragment,null,f&&S.createElement(_,{sideCar:Jc,removeScrollBar:u,shards:d,noRelative:p,noIsolation:w,inert:g,setCallbacks:a,allowPinchZoom:!!y,lockRef:r,gapMode:C}),o?S.cloneElement(S.Children.only(c),Dt(Dt({},j),{ref:k})):S.createElement(b,Dt({},j,{className:l,ref:k}),c))});Ss.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ss.classNames={fullWidth:zn,zeroRight:Vn};var km=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Dm(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=km();return t&&e.setAttribute("nonce",t),e}function jm(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Nm(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Em=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Dm())&&(jm(t,r),Nm(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Am=function(){var e=Em();return function(t,r){S.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Qc=function(){var e=Am(),t=function(r){var n=r.styles,s=r.dynamic;return e(n,s),null};return t},Rm={left:0,top:0,right:0,gap:0},qs=function(e){return parseInt(e||"",10)||0},Tm=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[qs(r),qs(n),qs(s)]},Pm=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Rm;var t=Tm(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},Om=Qc(),Rr="data-scroll-locked",Mm=function(e,t,r,n){var s=e.left,a=e.top,o=e.right,c=e.gap;return r===void 0&&(r="margin"),`
|
|
2
|
-
.`.concat(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),m=require("react"),mr=require("react-dom"),ja=require("react-i18next");function qi(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const k=qi(m),Xi=qi(mr);function Ki(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=Ki(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Ji(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=Ki(e))&&(n&&(n+=" "),n+=t);return n}function de(...e){return Ji(e)}const ye={Spinner:({className:e,...t})=>{const{role:r,...n}=t;return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:de("animate-spin",e),...n,role:"presentation",children:o.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})},Check:({className:e,...t})=>{const{role:r,...n}=t;return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})},X:({className:e,...t})=>{const{role:r,...n}=t;return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})},ChevronLeft:({className:e,...t})=>{const{role:r,...n}=t;return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:o.jsx("path",{d:"M15 18l-6-6 6-6"})})},ChevronRight:({className:e,...t})=>{const{role:r,...n}=t;return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:o.jsx("path",{d:"M9 18l6-6-6-6"})})},ChevronDown:({className:e,...t})=>{const{role:r,...n}=t;return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:o.jsx("path",{d:"M6 9l6 6 6-6"})})},Calendar:({className:e,...t})=>{const{role:r,...n}=t;return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),o.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),o.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),o.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})},Plus:({className:e,...t})=>{const{role:r,...n}=t;return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[o.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),o.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})},Edit:({className:e,...t})=>{const{role:r,...n}=t;return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[o.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),o.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})},Trash:({className:e,...t})=>{const{role:r,...n}=t;return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[o.jsx("polyline",{points:"3 6 5 6 21 6"}),o.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})},AlertTriangle:({className:e,...t})=>{const{role:r,...n}=t;return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,...n,role:"presentation",children:[o.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),o.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),o.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}},xt=k.forwardRef(({className:e,type:t,...r},n)=>o.jsx("input",{type:t,className:de("flex w-full rounded-md border border-input bg-background px-ui py-ui 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",e),ref:n,...r}));xt.displayName="Input";function Da({value:e=[],onChange:t,personnel:r,placeholder:n,className:s,disabled:a=!1}){const[i,c]=m.useState(!1),[l,u]=m.useState(""),[f,d]=m.useState(-1),h=m.useRef(null),p=m.useMemo(()=>{if(!l||!r)return[];const v=l.toLowerCase();return v.length<1?[]:r.filter(_=>e.some(b=>b.personnelId===_.id)?!1:_.name.toLowerCase().includes(v)||_.department?.toLowerCase().includes(v)).slice(0,5)},[l,r,e]);m.useEffect(()=>{d(-1),c(p.length>0)},[p]);const w=v=>{t([...e,v]),u(""),c(!1),h.current?.focus()},g=v=>{const _=[...e];_.splice(v,1),t(_)},y=v=>{if(!v.nativeEvent.isComposing){if(i&&p.length>0){if(v.key==="ArrowDown"){v.preventDefault(),d(_=>_===-1?0:(_+1)%p.length);return}else if(v.key==="ArrowUp"){v.preventDefault(),d(_=>_===-1?p.length-1:(_-1+p.length)%p.length);return}}if(v.key==="Enter")if(v.preventDefault(),f>=0&&p[f]){const _=p[f];w({name:_.name,email:_.email||"",personnelId:_.id,type:"personnel"})}else l.trim().length>0&&w({name:l.trim(),type:"external"});else v.key==="Backspace"&&l===""&&e.length>0?g(e.length-1):v.key==="Escape"&&c(!1)}},x=()=>{setTimeout(()=>{c(!1)},200)};return o.jsxs("div",{className:de("flex flex-wrap items-center gap-ui px-ui py-[calc(var(--ui-component-padding-y)/2)] border rounded-md bg-background focus-within:ring-2 ring-ring ring-offset-2 border-input min-h-ui",s),children:[e.map((v,_)=>o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-1)] bg-secondary text-secondary-foreground px-[var(--ui-space-2)] py-[var(--ui-space-1)] rounded text-sm group",children:[o.jsx("span",{children:v.name}),!a&&o.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),g(_)},className:"text-muted-foreground group-hover:text-destructive transition-colors",children:o.jsx(ye.X,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})]},v.personnelId??v.email??`${v.type}-${v.name}`)),o.jsxs("div",{className:"relative flex-1 min-w-[var(--ui-space-30)]",children:[o.jsx(xt,{ref:h,value:l,onChange:v=>u(v.target.value),onKeyDown:y,onFocus:()=>{p.length>0&&c(!0)},onBlur:x,placeholder:e.length===0?n:"",disabled:a,className:de("border-0 focus-visible:ring-0 px-[var(--ui-space-0)] h-auto py-[var(--ui-space-1)] shadow-none bg-transparent",a&&"cursor-not-allowed text-muted-foreground"),autoComplete:"off"}),i&&p.length>0&&o.jsx("div",{className:"absolute top-full left-[var(--ui-space-0)] z-50 w-full min-w-[var(--ui-space-50)] mt-[var(--ui-space-1)] bg-popover text-popover-foreground border border-border rounded-md shadow-md overflow-hidden animate-in fade-in-0 zoom-in-95",children:p.map((v,_)=>o.jsxs("button",{type:"button",className:de("px-ui py-ui text-sm cursor-pointer flex justify-between items-center",_===f?"bg-accent text-accent-foreground":"hover:bg-accent hover:text-accent-foreground"),onClick:b=>{b.preventDefault(),b.stopPropagation(),w({name:v.name,email:v.email||"",personnelId:v.id,type:"personnel"})},onMouseEnter:()=>d(_),children:[o.jsx("span",{className:"font-medium",children:v.name}),v.department&&o.jsx("span",{className:"text-xs text-muted-foreground ml-[var(--ui-space-2)]",children:v.department})]},v.id))})]})]})}var yn=e=>e.type==="checkbox",pr=e=>e instanceof Date,Ge=e=>e==null;const Qi=e=>typeof e=="object";var Ee=e=>!Ge(e)&&!Array.isArray(e)&&Qi(e)&&!pr(e),ec=e=>Ee(e)&&e.target?yn(e.target)?e.target.checked:e.target.value:e,td=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,tc=(e,t)=>e.has(td(t)),rd=e=>{const t=e.constructor&&e.constructor.prototype;return Ee(t)&&t.hasOwnProperty("isPrototypeOf")},Na=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Te(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Na&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ee(e)&&rd(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=Te(e[s]));return n}var gs=e=>/^\w*$/.test(e),Se=e=>e===void 0,Ea=e=>Array.isArray(e)?e.filter(Boolean):[],Aa=e=>Ea(e.replace(/["|']|\]/g,"").split(/\.|\[/)),q=(e,t,r)=>{if(!t||!Ee(e))return r;const n=(gs(t)?[t]:Aa(t)).reduce((s,a)=>Ge(s)?s:s[a],e);return Se(n)||n===e?Se(e[t])?r:e[t]:n},rt=e=>typeof e=="boolean",He=e=>typeof e=="function",ge=(e,t,r)=>{let n=-1;const s=gs(t)?[t]:Aa(t),a=s.length,i=a-1;for(;++n<a;){const c=s[n];let l=r;if(n!==i){const u=e[c];l=Ee(u)||Array.isArray(u)?u:isNaN(+s[n+1])?{}:[]}if(c==="__proto__"||c==="constructor"||c==="prototype")return;e[c]=l,e=e[c]}};const Wn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},vt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ht={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ta=m.createContext(null);Ta.displayName="HookFormContext";const vs=()=>m.useContext(Ta),nd=e=>{const{children:t,...r}=e;return m.createElement(Ta.Provider,{value:r},t)};var rc=(e,t,r,n=!0)=>{const s={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const i=a;return t._proxyFormState[i]!==vt.all&&(t._proxyFormState[i]=!n||vt.all),r&&(r[i]=!0),e[i]}});return s};const Ra=typeof window<"u"?m.useLayoutEffect:m.useEffect;function sd(e){const t=vs(),{control:r=t.control,disabled:n,name:s,exact:a}=e||{},[i,c]=m.useState(r._formState),l=m.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ra(()=>r._subscribe({name:s,formState:l.current,exact:a,callback:u=>{!n&&c({...r._formState,...u})}}),[s,n,a]),m.useEffect(()=>{l.current.isValid&&r._setValid(!0)},[r]),m.useMemo(()=>rc(i,r,l.current,!1),[i,r])}var ot=e=>typeof e=="string",na=(e,t,r,n,s)=>ot(e)?(n&&t.watch.add(e),q(r,e,s)):Array.isArray(e)?e.map(a=>(n&&t.watch.add(a),q(r,a))):(n&&(t.watchAll=!0),r),sa=e=>Ge(e)||!Qi(e);function yt(e,t,r=new WeakSet){if(sa(e)||sa(t))return Object.is(e,t);if(pr(e)&&pr(t))return e.getTime()===t.getTime();const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const a of n){const i=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const c=t[a];if(pr(i)&&pr(c)||Ee(i)&&Ee(c)||Array.isArray(i)&&Array.isArray(c)?!yt(i,c,r):!Object.is(i,c))return!1}}return!0}function ad(e){const t=vs(),{control:r=t.control,name:n,defaultValue:s,disabled:a,exact:i,compute:c}=e||{},l=m.useRef(s),u=m.useRef(c),f=m.useRef(void 0),d=m.useRef(r),h=m.useRef(n);u.current=c;const[p,w]=m.useState(()=>{const b=r._getWatch(n,l.current);return u.current?u.current(b):b}),g=m.useCallback(b=>{const S=na(n,r._names,b||r._formValues,!1,l.current);return u.current?u.current(S):S},[r._formValues,r._names,n]),y=m.useCallback(b=>{if(!a){const S=na(n,r._names,b||r._formValues,!1,l.current);if(u.current){const C=u.current(S);yt(C,f.current)||(w(C),f.current=C)}else w(S)}},[r._formValues,r._names,a,n]);Ra(()=>((d.current!==r||!yt(h.current,n))&&(d.current=r,h.current=n,y()),r._subscribe({name:n,formState:{values:!0},exact:i,callback:b=>{y(b.values)}})),[r,i,n,y]),m.useEffect(()=>r._removeUnmounted());const x=d.current!==r,v=h.current,_=m.useMemo(()=>{if(a)return null;const b=!x&&!yt(v,n);return x||b?g():null},[a,x,n,v,g]);return _!==null?_:p}function od(e){const t=vs(),{name:r,disabled:n,control:s=t.control,shouldUnregister:a,defaultValue:i,exact:c=!0}=e,l=tc(s._names.array,r),u=m.useMemo(()=>q(s._formValues,r,q(s._defaultValues,r,i)),[s,r,i]),f=ad({control:s,name:r,defaultValue:u,exact:c}),d=sd({control:s,name:r,exact:c}),h=m.useRef(e),p=m.useRef(void 0),w=m.useRef(s.register(r,{...e.rules,value:f,...rt(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const g=m.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!q(d.errors,r)},isDirty:{enumerable:!0,get:()=>!!q(d.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!q(d.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!q(d.validatingFields,r)},error:{enumerable:!0,get:()=>q(d.errors,r)}}),[d,r]),y=m.useCallback(b=>w.current.onChange({target:{value:ec(b),name:r},type:Wn.CHANGE}),[r]),x=m.useCallback(()=>w.current.onBlur({target:{value:q(s._formValues,r),name:r},type:Wn.BLUR}),[r,s._formValues]),v=m.useCallback(b=>{const S=q(s._fields,r);S&&S._f&&b&&(S._f.ref={focus:()=>He(b.focus)&&b.focus(),select:()=>He(b.select)&&b.select(),setCustomValidity:C=>He(b.setCustomValidity)&&b.setCustomValidity(C),reportValidity:()=>He(b.reportValidity)&&b.reportValidity()})},[s._fields,r]),_=m.useMemo(()=>({name:r,value:f,...rt(n)||d.disabled?{disabled:d.disabled||n}:{},onChange:y,onBlur:x,ref:v}),[r,n,d.disabled,y,x,v,f]);return m.useEffect(()=>{const b=s._options.shouldUnregister||a,S=p.current;S&&S!==r&&!l&&s.unregister(S),s.register(r,{...h.current.rules,...rt(h.current.disabled)?{disabled:h.current.disabled}:{}});const C=(j,N)=>{const E=q(s._fields,j);E&&E._f&&(E._f.mount=N)};if(C(r,!0),b){const j=Te(q(s._options.defaultValues,r,h.current.defaultValue));ge(s._defaultValues,r,j),Se(q(s._formValues,r))&&ge(s._formValues,r,j)}return!l&&s.register(r),p.current=r,()=>{(l?b&&!s._state.action:b)?s.unregister(r):C(r,!1)}},[r,s,l,a]),m.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),m.useMemo(()=>({field:_,formState:d,fieldState:g}),[_,d,g])}const id=e=>e.render(od(e));var nc=(e,t,r,n,s)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:s||!0}}:{},rn=e=>Array.isArray(e)?e:[e],Do=()=>{let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next&&a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}};function sc(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const s=e[n],a=t[n];if(s&&Ee(s)&&a){const i=sc(s,a);Ee(i)&&(r[n]=i)}else e[n]&&(r[n]=a)}return r}var ze=e=>Ee(e)&&!Object.keys(e).length,Pa=e=>e.type==="file",Un=e=>{if(!Na)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ac=e=>e.type==="select-multiple",Ma=e=>e.type==="radio",cd=e=>Ma(e)||yn(e),zs=e=>Un(e)&&e.isConnected;function ld(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=Se(e)?n++:e[t[n++]];return e}function ud(e){for(const t in e)if(e.hasOwnProperty(t)&&!Se(e[t]))return!1;return!0}function Ce(e,t){const r=Array.isArray(t)?t:gs(t)?[t]:Aa(t),n=r.length===1?e:ld(e,r),s=r.length-1,a=r[s];return n&&delete n[a],s!==0&&(Ee(n)&&ze(n)||Array.isArray(n)&&ud(n))&&Ce(e,r.slice(0,-1)),e}var dd=e=>{for(const t in e)if(He(e[t]))return!0;return!1};function oc(e){return Array.isArray(e)||Ee(e)&&!dd(e)}function aa(e,t={}){for(const r in e){const n=e[r];oc(n)?(t[r]=Array.isArray(n)?[]:{},aa(n,t[r])):Se(n)||(t[r]=!0)}return t}function Tr(e,t,r){r||(r=aa(t));for(const n in e){const s=e[n];if(oc(s))Se(t)||sa(r[n])?r[n]=aa(s,Array.isArray(s)?[]:{}):Tr(s,Ge(t)?{}:t[n],r[n]);else{const a=t[n];r[n]=!yt(s,a)}}return r}const No={value:!1,isValid:!1},Eo={value:!0,isValid:!0};var ic=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Se(e[0].attributes.value)?Se(e[0].value)||e[0].value===""?Eo:{value:e[0].value,isValid:!0}:Eo:No}return No},cc=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>Se(e)?e:t?e===""?NaN:e&&+e:r&&ot(e)?new Date(e):n?n(e):e;const Ao={isValid:!1,value:null};var lc=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Ao):Ao;function To(e){const t=e.ref;return Pa(t)?t.files:Ma(t)?lc(e.refs).value:ac(t)?[...t.selectedOptions].map(({value:r})=>r):yn(t)?ic(e.refs).value:cc(Se(t.value)?e.ref.value:t.value,e)}var fd=(e,t,r,n)=>{const s={};for(const a of e){const i=q(t,a);i&&ge(s,a,i._f)}return{criteriaMode:r,names:[...e],fields:s,shouldUseNativeValidation:n}},Zn=e=>e instanceof RegExp,en=e=>Se(e)?e:Zn(e)?e.source:Ee(e)?Zn(e.value)?e.value.source:e.value:e,Ro=e=>({isOnSubmit:!e||e===vt.onSubmit,isOnBlur:e===vt.onBlur,isOnChange:e===vt.onChange,isOnAll:e===vt.all,isOnTouch:e===vt.onTouched});const Po="AsyncFunction";var hd=e=>!!e&&!!e.validate&&!!(He(e.validate)&&e.validate.constructor.name===Po||Ee(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Po)),md=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Mo=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const nn=(e,t,r,n)=>{for(const s of r||Object.keys(e)){const a=q(e,s);if(a){const{_f:i,...c}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],s)&&!n)return!0;if(i.ref&&t(i.ref,i.name)&&!n)return!0;if(nn(c,t))break}else if(Ee(c)&&nn(c,t))break}}};function Oo(e,t,r){const n=q(e,r);if(n||gs(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const a=s.join("."),i=q(t,a),c=q(e,a);if(i&&!Array.isArray(i)&&r!==a)return{name:r};if(c&&c.type)return{name:a,error:c};if(c&&c.root&&c.root.type)return{name:`${a}.root`,error:c.root};s.pop()}return{name:r}}var pd=(e,t,r,n)=>{r(e);const{name:s,...a}=e;return ze(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!n||vt.all))},gd=(e,t,r)=>!e||!t||e===t||rn(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),vd=(e,t,r,n,s)=>s.isOnAll?!1:!r&&s.isOnTouch?!(t||e):(r?n.isOnBlur:s.isOnBlur)?!e:(r?n.isOnChange:s.isOnChange)?e:!0,yd=(e,t)=>!Ea(q(e,t)).length&&Ce(e,t),xd=(e,t,r)=>{const n=rn(q(e,r));return ge(n,"root",t[r]),ge(e,r,n),e};function Io(e,t,r="validate"){if(ot(e)||Array.isArray(e)&&e.every(ot)||rt(e)&&!e)return{type:r,message:ot(e)?e:"",ref:t}}var jr=e=>Ee(e)&&!Zn(e)?e:{value:e,message:""},$o=async(e,t,r,n,s,a)=>{const{ref:i,refs:c,required:l,maxLength:u,minLength:f,min:d,max:h,pattern:p,validate:w,name:g,valueAsNumber:y,mount:x}=e._f,v=q(r,g);if(!x||t.has(g))return{};const _=c?c[0]:i,b=A=>{s&&_.reportValidity&&(_.setCustomValidity(rt(A)?"":A||""),_.reportValidity())},S={},C=Ma(i),j=yn(i),N=C||j,E=(y||Pa(i))&&Se(i.value)&&Se(v)||Un(i)&&i.value===""||v===""||Array.isArray(v)&&!v.length,R=nc.bind(null,g,n,S),M=(A,$,O,B=Ht.maxLength,L=Ht.minLength)=>{const I=A?$:O;S[g]={type:A?B:L,message:I,ref:i,...R(A?B:L,I)}};if(a?!Array.isArray(v)||!v.length:l&&(!N&&(E||Ge(v))||rt(v)&&!v||j&&!ic(c).isValid||C&&!lc(c).isValid)){const{value:A,message:$}=ot(l)?{value:!!l,message:l}:jr(l);if(A&&(S[g]={type:Ht.required,message:$,ref:_,...R(Ht.required,$)},!n))return b($),S}if(!E&&(!Ge(d)||!Ge(h))){let A,$;const O=jr(h),B=jr(d);if(!Ge(v)&&!isNaN(v)){const L=i.valueAsNumber||v&&+v;Ge(O.value)||(A=L>O.value),Ge(B.value)||($=L<B.value)}else{const L=i.valueAsDate||new Date(v),I=H=>new Date(new Date().toDateString()+" "+H),P=i.type=="time",z=i.type=="week";ot(O.value)&&v&&(A=P?I(v)>I(O.value):z?v>O.value:L>new Date(O.value)),ot(B.value)&&v&&($=P?I(v)<I(B.value):z?v<B.value:L<new Date(B.value))}if((A||$)&&(M(!!A,O.message,B.message,Ht.max,Ht.min),!n))return b(S[g].message),S}if((u||f)&&!E&&(ot(v)||a&&Array.isArray(v))){const A=jr(u),$=jr(f),O=!Ge(A.value)&&v.length>+A.value,B=!Ge($.value)&&v.length<+$.value;if((O||B)&&(M(O,A.message,$.message),!n))return b(S[g].message),S}if(p&&!E&&ot(v)){const{value:A,message:$}=jr(p);if(Zn(A)&&!v.match(A)&&(S[g]={type:Ht.pattern,message:$,ref:i,...R(Ht.pattern,$)},!n))return b($),S}if(w){if(He(w)){const A=await w(v,r),$=Io(A,_);if($&&(S[g]={...$,...R(Ht.validate,$.message)},!n))return b($.message),S}else if(Ee(w)){let A={};for(const $ in w){if(!ze(A)&&!n)break;const O=Io(await w[$](v,r),_,$);O&&(A={...O,...R($,O.message)},b(O.message),n&&(S[g]=A))}if(!ze(A)&&(S[g]={ref:_,...A},!n))return S}}return b(!0),S};const bd={mode:vt.onSubmit,reValidateMode:vt.onChange,shouldFocusError:!0};function wd(e={}){let t={...bd,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:He(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},n={},s=Ee(t.defaultValues)||Ee(t.values)?Te(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Te(s),i={action:!1,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...f};let h={...d};const p={array:Do(),state:Do()},w=t.criteriaMode===vt.all,g=D=>T=>{clearTimeout(u),u=setTimeout(D,T)},y=async D=>{if(!i.keepIsValid&&!t.disabled&&(d.isValid||h.isValid||D)){let T;t.resolver?(T=ze((await N()).errors),x()):T=await R(n,!0),T!==r.isValid&&p.state.next({isValid:T})}},x=(D,T)=>{!t.disabled&&(d.isValidating||d.validatingFields||h.isValidating||h.validatingFields)&&((D||Array.from(c.mount)).forEach(F=>{F&&(T?ge(r.validatingFields,F,T):Ce(r.validatingFields,F))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ze(r.validatingFields)}))},v=(D,T=[],F,X,Y=!0,Z=!0)=>{if(X&&F&&!t.disabled){if(i.action=!0,Z&&Array.isArray(q(n,D))){const ee=F(q(n,D),X.argA,X.argB);Y&&ge(n,D,ee)}if(Z&&Array.isArray(q(r.errors,D))){const ee=F(q(r.errors,D),X.argA,X.argB);Y&&ge(r.errors,D,ee),yd(r.errors,D)}if((d.touchedFields||h.touchedFields)&&Z&&Array.isArray(q(r.touchedFields,D))){const ee=F(q(r.touchedFields,D),X.argA,X.argB);Y&&ge(r.touchedFields,D,ee)}(d.dirtyFields||h.dirtyFields)&&(r.dirtyFields=Tr(s,a)),p.state.next({name:D,isDirty:A(D,T),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ge(a,D,T)},_=(D,T)=>{ge(r.errors,D,T),p.state.next({errors:r.errors})},b=D=>{r.errors=D,p.state.next({errors:r.errors,isValid:!1})},S=(D,T,F,X)=>{const Y=q(n,D);if(Y){const Z=q(a,D,Se(F)?q(s,D):F);Se(Z)||X&&X.defaultChecked||T?ge(a,D,T?Z:To(Y._f)):B(D,Z),i.mount&&!i.action&&y()}},C=(D,T,F,X,Y)=>{let Z=!1,ee=!1;const le={name:D};if(!t.disabled){if(!F||X){(d.isDirty||h.isDirty)&&(ee=r.isDirty,r.isDirty=le.isDirty=A(),Z=ee!==le.isDirty);const he=yt(q(s,D),T);ee=!!q(r.dirtyFields,D),he?Ce(r.dirtyFields,D):ge(r.dirtyFields,D,!0),le.dirtyFields=r.dirtyFields,Z=Z||(d.dirtyFields||h.dirtyFields)&&ee!==!he}if(F){const he=q(r.touchedFields,D);he||(ge(r.touchedFields,D,F),le.touchedFields=r.touchedFields,Z=Z||(d.touchedFields||h.touchedFields)&&he!==F)}Z&&Y&&p.state.next(le)}return Z?le:{}},j=(D,T,F,X)=>{const Y=q(r.errors,D),Z=(d.isValid||h.isValid)&&rt(T)&&r.isValid!==T;if(t.delayError&&F?(l=g(()=>_(D,F)),l(t.delayError)):(clearTimeout(u),l=null,F?ge(r.errors,D,F):Ce(r.errors,D)),(F?!yt(Y,F):Y)||!ze(X)||Z){const ee={...X,...Z&&rt(T)?{isValid:T}:{},errors:r.errors,name:D};r={...r,...ee},p.state.next(ee)}},N=async D=>(x(D,!0),await t.resolver(a,t.context,fd(D||c.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),E=async D=>{const{errors:T}=await N(D);if(x(D),D)for(const F of D){const X=q(T,F);X?ge(r.errors,F,X):Ce(r.errors,F)}else r.errors=T;return T},R=async(D,T,F={valid:!0})=>{for(const X in D){const Y=D[X];if(Y){const{_f:Z,...ee}=Y;if(Z){const le=c.array.has(Z.name),he=Y._f&&hd(Y._f);he&&d.validatingFields&&x([Z.name],!0);const Ve=await $o(Y,c.disabled,a,w,t.shouldUseNativeValidation&&!T,le);if(he&&d.validatingFields&&x([Z.name]),Ve[Z.name]&&(F.valid=!1,T))break;!T&&(q(Ve,Z.name)?le?xd(r.errors,Ve,Z.name):ge(r.errors,Z.name,Ve[Z.name]):Ce(r.errors,Z.name))}!ze(ee)&&await R(ee,T,F)}}return F.valid},M=()=>{for(const D of c.unMount){const T=q(n,D);T&&(T._f.refs?T._f.refs.every(F=>!zs(F)):!zs(T._f.ref))&&pe(D)}c.unMount=new Set},A=(D,T)=>!t.disabled&&(D&&T&&ge(a,D,T),!yt(te(),s)),$=(D,T,F)=>na(D,c,{...i.mount?a:Se(T)?s:ot(D)?{[D]:T}:T},F,T),O=D=>Ea(q(i.mount?a:s,D,t.shouldUnregister?q(s,D,[]):[])),B=(D,T,F={})=>{const X=q(n,D);let Y=T;if(X){const Z=X._f;Z&&(!Z.disabled&&ge(a,D,cc(T,Z)),Y=Un(Z.ref)&&Ge(T)?"":T,ac(Z.ref)?[...Z.ref.options].forEach(ee=>ee.selected=Y.includes(ee.value)):Z.refs?yn(Z.ref)?Z.refs.forEach(ee=>{(!ee.defaultChecked||!ee.disabled)&&(Array.isArray(Y)?ee.checked=!!Y.find(le=>le===ee.value):ee.checked=Y===ee.value||!!Y)}):Z.refs.forEach(ee=>ee.checked=ee.value===Y):Pa(Z.ref)?Z.ref.value="":(Z.ref.value=Y,Z.ref.type||p.state.next({name:D,values:Te(a)})))}(F.shouldDirty||F.shouldTouch)&&C(D,Y,F.shouldTouch,F.shouldDirty,!0),F.shouldValidate&&H(D)},L=(D,T,F)=>{for(const X in T){if(!T.hasOwnProperty(X))return;const Y=T[X],Z=D+"."+X,ee=q(n,Z);(c.array.has(D)||Ee(Y)||ee&&!ee._f)&&!pr(Y)?L(Z,Y,F):B(Z,Y,F)}},I=(D,T,F={})=>{const X=q(n,D),Y=c.array.has(D),Z=Te(T);ge(a,D,Z),Y?(p.array.next({name:D,values:Te(a)}),(d.isDirty||d.dirtyFields||h.isDirty||h.dirtyFields)&&F.shouldDirty&&p.state.next({name:D,dirtyFields:Tr(s,a),isDirty:A(D,Z)})):X&&!X._f&&!Ge(Z)?L(D,Z,F):B(D,Z,F),Mo(D,c)&&p.state.next({...r,name:D}),p.state.next({name:i.mount?D:void 0,values:Te(a)})},P=async D=>{i.mount=!0;const T=D.target;let F=T.name,X=!0;const Y=q(n,F),Z=he=>{X=Number.isNaN(he)||pr(he)&&isNaN(he.getTime())||yt(he,q(a,F,he))},ee=Ro(t.mode),le=Ro(t.reValidateMode);if(Y){let he,Ve;const Je=T.type?To(Y._f):ec(D),gt=D.type===Wn.BLUR||D.type===Wn.FOCUS_OUT,Ls=!md(Y._f)&&!t.resolver&&!q(r.errors,F)&&!Y._f.deps||vd(gt,q(r.touchedFields,F),r.isSubmitted,le,ee),Xr=Mo(F,c,gt);ge(a,F,Je),gt?(!T||!T.readOnly)&&(Y._f.onBlur&&Y._f.onBlur(D),l&&l(0)):Y._f.onChange&&Y._f.onChange(D);const fr=C(F,Je,gt),Nn=!ze(fr)||Xr;if(!gt&&p.state.next({name:F,type:D.type,values:Te(a)}),Ls)return(d.isValid||h.isValid)&&(t.mode==="onBlur"?gt&&y():gt||y()),Nn&&p.state.next({name:F,...Xr?{}:fr});if(!gt&&Xr&&p.state.next({...r}),t.resolver){const{errors:En}=await N([F]);if(x([F]),Z(Je),X){const An=Oo(r.errors,n,F),Tn=Oo(En,n,An.name||F);he=Tn.error,F=Tn.name,Ve=ze(En)}}else x([F],!0),he=(await $o(Y,c.disabled,a,w,t.shouldUseNativeValidation))[F],x([F]),Z(Je),X&&(he?Ve=!1:(d.isValid||h.isValid)&&(Ve=await R(n,!0)));X&&(Y._f.deps&&(!Array.isArray(Y._f.deps)||Y._f.deps.length>0)&&H(Y._f.deps),j(F,Ve,he,fr))}},z=(D,T)=>{if(q(r.errors,T)&&D.focus)return D.focus(),1},H=async(D,T={})=>{let F,X;const Y=rn(D);if(t.resolver){const Z=await E(Se(D)?D:Y);F=ze(Z),X=D?!Y.some(ee=>q(Z,ee)):F}else D?(X=(await Promise.all(Y.map(async Z=>{const ee=q(n,Z);return await R(ee&&ee._f?{[Z]:ee}:ee)}))).every(Boolean),!(!X&&!r.isValid)&&y()):X=F=await R(n);return p.state.next({...!ot(D)||(d.isValid||h.isValid)&&F!==r.isValid?{}:{name:D},...t.resolver||!D?{isValid:F}:{},errors:r.errors}),T.shouldFocus&&!X&&nn(n,z,D?Y:c.mount),X},te=(D,T)=>{let F={...i.mount?a:s};return T&&(F=sc(T.dirtyFields?r.dirtyFields:r.touchedFields,F)),Se(D)?F:ot(D)?q(F,D):D.map(X=>q(F,X))},G=(D,T)=>({invalid:!!q((T||r).errors,D),isDirty:!!q((T||r).dirtyFields,D),error:q((T||r).errors,D),isValidating:!!q(r.validatingFields,D),isTouched:!!q((T||r).touchedFields,D)}),V=D=>{D&&rn(D).forEach(T=>Ce(r.errors,T)),p.state.next({errors:D?r.errors:{}})},W=(D,T,F)=>{const X=(q(n,D,{_f:{}})._f||{}).ref,Y=q(r.errors,D)||{},{ref:Z,message:ee,type:le,...he}=Y;ge(r.errors,D,{...he,...T,ref:X}),p.state.next({name:D,errors:r.errors,isValid:!1}),F&&F.shouldFocus&&X&&X.focus&&X.focus()},se=(D,T)=>He(D)?p.state.subscribe({next:F=>"values"in F&&D($(void 0,T),F)}):$(D,T,!0),ne=D=>p.state.subscribe({next:T=>{gd(D.name,T.name,D.exact)&&pd(T,D.formState||d,jn,D.reRenderRoot)&&D.callback({values:{...a},...r,...T,defaultValues:s})}}).unsubscribe,fe=D=>(i.mount=!0,h={...h,...D.formState},ne({...D,formState:{...f,...D.formState}})),pe=(D,T={})=>{for(const F of D?rn(D):c.mount)c.mount.delete(F),c.array.delete(F),T.keepValue||(Ce(n,F),Ce(a,F)),!T.keepError&&Ce(r.errors,F),!T.keepDirty&&Ce(r.dirtyFields,F),!T.keepTouched&&Ce(r.touchedFields,F),!T.keepIsValidating&&Ce(r.validatingFields,F),!t.shouldUnregister&&!T.keepDefaultValue&&Ce(s,F);p.state.next({values:Te(a)}),p.state.next({...r,...T.keepDirty?{isDirty:A()}:{}}),!T.keepIsValid&&y()},Ae=({disabled:D,name:T})=>{(rt(D)&&i.mount||D||c.disabled.has(T))&&(D?c.disabled.add(T):c.disabled.delete(T))},xe=(D,T={})=>{let F=q(n,D);const X=rt(T.disabled)||rt(t.disabled);return ge(n,D,{...F||{},_f:{...F&&F._f?F._f:{ref:{name:D}},name:D,mount:!0,...T}}),c.mount.add(D),F?Ae({disabled:rt(T.disabled)?T.disabled:t.disabled,name:D}):S(D,!0,T.value),{...X?{disabled:T.disabled||t.disabled}:{},...t.progressive?{required:!!T.required,min:en(T.min),max:en(T.max),minLength:en(T.minLength),maxLength:en(T.maxLength),pattern:en(T.pattern)}:{},name:D,onChange:P,onBlur:P,ref:Y=>{if(Y){xe(D,T),F=q(n,D);const Z=Se(Y.value)&&Y.querySelectorAll&&Y.querySelectorAll("input,select,textarea")[0]||Y,ee=cd(Z),le=F._f.refs||[];if(ee?le.find(he=>he===Z):Z===F._f.ref)return;ge(n,D,{_f:{...F._f,...ee?{refs:[...le.filter(zs),Z,...Array.isArray(q(s,D))?[{}]:[]],ref:{type:Z.type,name:D}}:{ref:Z}}}),S(D,!1,void 0,Z)}else F=q(n,D,{}),F._f&&(F._f.mount=!1),(t.shouldUnregister||T.shouldUnregister)&&!(tc(c.array,D)&&i.action)&&c.unMount.add(D)}}},Ze=()=>t.shouldFocusError&&nn(n,z,c.mount),Ye=D=>{rt(D)&&(p.state.next({disabled:D}),nn(n,(T,F)=>{const X=q(n,F);X&&(T.disabled=X._f.disabled||D,Array.isArray(X._f.refs)&&X._f.refs.forEach(Y=>{Y.disabled=X._f.disabled||D}))},0,!1))},Xe=(D,T)=>async F=>{let X;F&&(F.preventDefault&&F.preventDefault(),F.persist&&F.persist());let Y=Te(a);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:Z,values:ee}=await N();x(),r.errors=Z,Y=Te(ee)}else await R(n);if(c.disabled.size)for(const Z of c.disabled)Ce(Y,Z);if(Ce(r.errors,"root"),ze(r.errors)){p.state.next({errors:{}});try{await D(Y,F)}catch(Z){X=Z}}else T&&await T({...r.errors},F),Ze(),setTimeout(Ze);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ze(r.errors)&&!X,submitCount:r.submitCount+1,errors:r.errors}),X)throw X},Ke=(D,T={})=>{q(n,D)&&(Se(T.defaultValue)?I(D,Te(q(s,D))):(I(D,T.defaultValue),ge(s,D,Te(T.defaultValue))),T.keepTouched||Ce(r.touchedFields,D),T.keepDirty||(Ce(r.dirtyFields,D),r.isDirty=T.defaultValue?A(D,Te(q(s,D))):A()),T.keepError||(Ce(r.errors,D),d.isValid&&y()),p.state.next({...r}))},kt=(D,T={})=>{const F=D?Te(D):s,X=Te(F),Y=ze(D),Z=Y?s:X;if(T.keepDefaultValues||(s=F),!T.keepValues){if(T.keepDirtyValues){const ee=new Set([...c.mount,...Object.keys(Tr(s,a))]);for(const le of Array.from(ee))q(r.dirtyFields,le)?ge(Z,le,q(a,le)):I(le,q(Z,le))}else{if(Na&&Se(D))for(const ee of c.mount){const le=q(n,ee);if(le&&le._f){const he=Array.isArray(le._f.refs)?le._f.refs[0]:le._f.ref;if(Un(he)){const Ve=he.closest("form");if(Ve){Ve.reset();break}}}}if(T.keepFieldsRef)for(const ee of c.mount)I(ee,q(Z,ee));else n={}}a=t.shouldUnregister?T.keepDefaultValues?Te(s):{}:Te(Z),p.array.next({values:{...Z}}),p.state.next({values:{...Z}})}c={mount:T.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!d.isValid||!!T.keepIsValid||!!T.keepDirtyValues||!t.shouldUnregister&&!ze(Z),i.watch=!!t.shouldUnregister,i.keepIsValid=!!T.keepIsValid,i.action=!1,T.keepErrors||(r.errors={}),p.state.next({submitCount:T.keepSubmitCount?r.submitCount:0,isDirty:Y?!1:T.keepDirty?r.isDirty:!!(T.keepDefaultValues&&!yt(D,s)),isSubmitted:T.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Y?{}:T.keepDirtyValues?T.keepDefaultValues&&a?Tr(s,a):r.dirtyFields:T.keepDefaultValues&&D?Tr(s,D):T.keepDirty?r.dirtyFields:{},touchedFields:T.keepTouched?r.touchedFields:{},errors:T.keepErrors?r.errors:{},isSubmitSuccessful:T.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},mt=(D,T)=>kt(He(D)?D(a):D,{...t.resetOptions,...T}),Xt=(D,T={})=>{const F=q(n,D),X=F&&F._f;if(X){const Y=X.refs?X.refs[0]:X.ref;Y.focus&&setTimeout(()=>{Y.focus(),T.shouldSelect&&He(Y.select)&&Y.select()})}},jn=D=>{r={...r,...D}},pt={control:{register:xe,unregister:pe,getFieldState:G,handleSubmit:Xe,setError:W,_subscribe:ne,_runSchema:N,_updateIsValidating:x,_focusError:Ze,_getWatch:$,_getDirty:A,_setValid:y,_setFieldArray:v,_setDisabledField:Ae,_setErrors:b,_getFieldArray:O,_reset:kt,_resetDefaultValues:()=>He(t.defaultValues)&&t.defaultValues().then(D=>{mt(D,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:Ye,_subjects:p,_proxyFormState:d,get _fields(){return n},get _formValues(){return a},get _state(){return i},set _state(D){i=D},get _defaultValues(){return s},get _names(){return c},set _names(D){c=D},get _formState(){return r},get _options(){return t},set _options(D){t={...t,...D}}},subscribe:fe,trigger:H,register:xe,handleSubmit:Xe,watch:se,setValue:I,getValues:te,reset:mt,resetField:Ke,clearErrors:V,unregister:pe,setError:W,setFocus:Xt,getFieldState:G};return{...pt,formControl:pt}}function uc(e={}){const t=m.useRef(void 0),r=m.useRef(void 0),[n,s]=m.useState({isDirty:!1,isValidating:!1,isLoading:He(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:He(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!He(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...c}=wd(e);t.current={...c,formState:n}}const a=t.current.control;return a._options=e,Ra(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>s({...a._formState}),reRenderRoot:!0});return s(c=>({...c,isReady:!0})),a._formState.isReady=!0,i},[a]),m.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),m.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),m.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),m.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),m.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==n.isDirty&&a._subjects.state.next({isDirty:i})}},[a,n.isDirty]),m.useEffect(()=>{var i;e.values&&!yt(e.values,r.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),!((i=a._options.resetOptions)===null||i===void 0)&&i.keepIsValid||a._setValid(),r.current=e.values,s(c=>({...c}))):a._resetDefaultValues()},[a,e.values]),m.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=rc(n,a),t.current}const Fo=(e,t,r)=>{if(e&&"reportValidity"in e){const n=q(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},dc=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?Fo(n.ref,r,e):n.refs&&n.refs.forEach(s=>Fo(s,r,e))}},_d=(e,t)=>{t.shouldUseNativeValidation&&dc(e,t);const r={};for(const n in e){const s=q(t.fields,n),a=Object.assign(e[n]||{},{ref:s&&s.ref});if(Sd(t.names||Object.keys(e),n)){const i=Object.assign({},q(r,n));ge(i,"root",a),ge(r,n,i)}else ge(r,n,a)}return r},Sd=(e,t)=>e.some(r=>r.startsWith(t+"."));var kd=function(e,t){for(var r={};e.length;){var n=e[0],s=n.code,a=n.message,i=n.path.join(".");if(!r[i])if("unionErrors"in n){var c=n.unionErrors[0].errors[0];r[i]={message:c.message,type:c.code}}else r[i]={message:a,type:s};if("unionErrors"in n&&n.unionErrors.forEach(function(f){return f.errors.forEach(function(d){return e.push(d)})}),t){var l=r[i].types,u=l&&l[n.code];r[i]=nc(i,t,r,s,u?[].concat(u,n.message):n.message)}e.shift()}return r},fc=function(e,t,r){return r===void 0&&(r={}),function(n,s,a){try{return Promise.resolve((function(i,c){try{var l=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(u){return a.shouldUseNativeValidation&&dc({},a),{errors:{},values:r.raw?n:u}})}catch(u){return c(u)}return l&&l.then?l.then(void 0,c):l})(0,function(i){if((function(c){return Array.isArray(c?.errors)})(i))return{values:{},errors:_d(kd(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},me;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function r(s){throw new Error}e.assertNever=r,e.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},e.getValidEnumValues=s=>{const a=e.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),i={};for(const c of a)i[c]=s[c];return e.objectValues(i)},e.objectValues=s=>e.objectKeys(s).map(function(a){return s[a]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},e.find=(s,a)=>{for(const i of s)if(a(i))return i},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(me||(me={}));var Lo;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Lo||(Lo={}));const Q=me.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),nr=e=>{switch(typeof e){case"undefined":return Q.undefined;case"string":return Q.string;case"number":return Number.isNaN(e)?Q.nan:Q.number;case"boolean":return Q.boolean;case"function":return Q.function;case"bigint":return Q.bigint;case"symbol":return Q.symbol;case"object":return Array.isArray(e)?Q.array:e===null?Q.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Q.promise:typeof Map<"u"&&e instanceof Map?Q.map:typeof Set<"u"&&e instanceof Set?Q.set:typeof Date<"u"&&e instanceof Date?Q.date:Q.object;default:return Q.unknown}},U=me.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ut extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let c=n,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(i))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),n}static assert(t){if(!(t instanceof Ut))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,me.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},n=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];r[a]=r[a]||[],r[a].push(t(s))}else n.push(t(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Ut.create=e=>new Ut(e);const oa=(e,t)=>{let r;switch(e.code){case U.invalid_type:e.received===Q.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case U.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,me.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:r=`Unrecognized key(s) in object: ${me.joinValues(e.keys,", ")}`;break;case U.invalid_union:r="Invalid input";break;case U.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${me.joinValues(e.options)}`;break;case U.invalid_enum_value:r=`Invalid enum value. Expected ${me.joinValues(e.options)}, received '${e.received}'`;break;case U.invalid_arguments:r="Invalid function arguments";break;case U.invalid_return_type:r="Invalid function return type";break;case U.invalid_date:r="Invalid date";break;case U.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:me.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case U.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case U.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case U.custom:r="Invalid input";break;case U.invalid_intersection_types:r="Intersection results could not be merged";break;case U.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case U.not_finite:r="Number must be finite";break;default:r=t.defaultError,me.assertNever(e)}return{message:r}};let Cd=oa;function jd(){return Cd}const Dd=e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)c=u(i,{data:t,defaultError:c}).message;return{...s,path:a,message:c}};function K(e,t){const r=jd(),n=Dd({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===oa?void 0:oa].filter(s=>!!s)});e.common.issues.push(n)}class We{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const n=[];for(const s of r){if(s.status==="aborted")return ie;s.status==="dirty"&&t.dirty(),n.push(s.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){const n=[];for(const s of r){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return We.mergeObjectSync(t,n)}static mergeObjectSync(t,r){const n={};for(const s of r){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return ie;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:t.value,value:n}}}const ie=Object.freeze({status:"aborted"}),tn=e=>({status:"dirty",value:e}),ht=e=>({status:"valid",value:e}),Vo=e=>e.status==="aborted",zo=e=>e.status==="dirty",$r=e=>e.status==="valid",Yn=e=>typeof Promise<"u"&&e instanceof Promise;var re;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(re||(re={}));class Ft{constructor(t,r,n,s){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ho=(e,t)=>{if($r(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Ut(e.common.issues);return this._error=r,this._error}}};function ce(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(i,c)=>{const{message:l}=e;return i.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??n??c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:l??r??c.defaultError}},description:s}}class ue{get description(){return this._def.description}_getType(t){return nr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:nr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new We,ctx:{common:t.parent.common,data:t.data,parsedType:nr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if(Yn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){const n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:nr(t)},s=this._parseSync({data:t,path:n.path,parent:n});return Ho(n,s)}"~validate"(t){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:nr(t)};if(!this["~standard"].async)try{const n=this._parseSync({data:t,path:[],parent:r});return $r(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>$r(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){const n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){const n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:nr(t)},s=this._parse({data:t,path:n.path,parent:n}),a=await(Yn(s)?s:Promise.resolve(s));return Ho(n,a)}refine(t,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{const i=t(s),c=()=>a.addIssue({code:U.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(c(),!1)):i?!0:(c(),!1)})}refinement(t,r){return this._refinement((n,s)=>t(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(t){return new Vr({schema:this,typeName:ae.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return ar.create(this,this._def)}nullable(){return zr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return It.create(this)}promise(){return Jn.create(this,this._def)}or(t){return qn.create([this,t],this._def)}and(t){return Xn.create(this,t,this._def)}transform(t){return new Vr({...ce(this._def),schema:this,typeName:ae.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new da({...ce(this._def),innerType:this,defaultValue:r,typeName:ae.ZodDefault})}brand(){return new Xd({typeName:ae.ZodBranded,type:this,...ce(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new fa({...ce(this._def),innerType:this,catchValue:r,typeName:ae.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Oa.create(this,t)}readonly(){return ha.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Nd=/^c[^\s-]{8,}$/i,Ed=/^[0-9a-z]+$/,Ad=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Td=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Rd=/^[a-z0-9_-]{21}$/i,Pd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Md=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Od=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Id="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Hs;const $d=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Fd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Ld=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Vd=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zd=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Hd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,hc="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Bd=new RegExp(`^${hc}$`);function mc(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Wd(e){return new RegExp(`^${mc(e)}$`)}function Ud(e){let t=`${hc}T${mc(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Zd(e,t){return!!((t==="v4"||!t)&&$d.test(e)||(t==="v6"||!t)&&Ld.test(e))}function Yd(e,t){if(!Pd.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function Gd(e,t){return!!((t==="v4"||!t)&&Fd.test(e)||(t==="v6"||!t)&&Vd.test(e))}class At extends ue{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Q.string){const a=this._getOrReturnCtx(t);return K(a,{code:U.invalid_type,expected:Q.string,received:a.parsedType}),ie}const n=new We;let s;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:U.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:U.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,c=t.data.length<a.value;(i||c)&&(s=this._getOrReturnCtx(t,s),i?K(s,{code:U.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&K(s,{code:U.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Od.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"email",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Hs||(Hs=new RegExp(Id,"u")),Hs.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"emoji",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Td.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"uuid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Rd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"nanoid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Nd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"cuid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Ed.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"cuid2",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Ad.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"ulid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),K(s,{validation:"url",code:U.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"regex",code:U.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(t,s),K(s,{code:U.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(s=this._getOrReturnCtx(t,s),K(s,{code:U.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(s=this._getOrReturnCtx(t,s),K(s,{code:U.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ud(a).test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{code:U.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Bd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{code:U.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Wd(a).test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{code:U.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Md.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"duration",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Zd(t.data,a.version)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"ip",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Yd(t.data,a.alg)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"jwt",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Gd(t.data,a.version)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"cidr",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?zd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"base64",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Hd.test(t.data)||(s=this._getOrReturnCtx(t,s),K(s,{validation:"base64url",code:U.invalid_string,message:a.message}),n.dirty()):me.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(s=>t.test(s),{validation:r,code:U.invalid_string,...re.errToObj(n)})}_addCheck(t){return new At({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...re.errToObj(t)})}url(t){return this._addCheck({kind:"url",...re.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...re.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...re.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...re.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...re.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...re.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...re.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...re.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...re.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...re.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...re.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...re.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...re.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...re.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...re.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...re.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...re.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...re.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...re.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...re.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...re.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...re.errToObj(r)})}nonempty(t){return this.min(1,re.errToObj(t))}trim(){return new At({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new At({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new At({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}At.create=e=>new At({checks:[],typeName:ae.ZodString,coerce:e?.coerce??!1,...ce(e)});function qd(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(e.toFixed(s).replace(".","")),i=Number.parseInt(t.toFixed(s).replace(".",""));return a%i/10**s}class vr extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Q.number){const a=this._getOrReturnCtx(t);return K(a,{code:U.invalid_type,expected:Q.number,received:a.parsedType}),ie}let n;const s=new We;for(const a of this._def.checks)a.kind==="int"?me.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),K(n,{code:U.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:U.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:U.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?qd(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),K(n,{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),K(n,{code:U.not_finite,message:a.message}),s.dirty()):me.assertNever(a);return{status:s.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,re.toString(r))}gt(t,r){return this.setLimit("min",t,!1,re.toString(r))}lte(t,r){return this.setLimit("max",t,!0,re.toString(r))}lt(t,r){return this.setLimit("max",t,!1,re.toString(r))}setLimit(t,r,n,s){return new vr({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:re.toString(s)}]})}_addCheck(t){return new vr({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:re.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:re.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:re.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:re.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:re.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&me.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}}vr.create=e=>new vr({checks:[],typeName:ae.ZodNumber,coerce:e?.coerce||!1,...ce(e)});class yr extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Q.bigint)return this._getInvalidInput(t);let n;const s=new We;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:U.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),K(n,{code:U.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),K(n,{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):me.assertNever(a);return{status:s.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return K(r,{code:U.invalid_type,expected:Q.bigint,received:r.parsedType}),ie}gte(t,r){return this.setLimit("min",t,!0,re.toString(r))}gt(t,r){return this.setLimit("min",t,!1,re.toString(r))}lte(t,r){return this.setLimit("max",t,!0,re.toString(r))}lt(t,r){return this.setLimit("max",t,!1,re.toString(r))}setLimit(t,r,n,s){return new yr({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:re.toString(s)}]})}_addCheck(t){return new yr({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:re.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}yr.create=e=>new yr({checks:[],typeName:ae.ZodBigInt,coerce:e?.coerce??!1,...ce(e)});class Gn extends ue{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Q.boolean){const n=this._getOrReturnCtx(t);return K(n,{code:U.invalid_type,expected:Q.boolean,received:n.parsedType}),ie}return ht(t.data)}}Gn.create=e=>new Gn({typeName:ae.ZodBoolean,coerce:e?.coerce||!1,...ce(e)});class Fr extends ue{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Q.date){const a=this._getOrReturnCtx(t);return K(a,{code:U.invalid_type,expected:Q.date,received:a.parsedType}),ie}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return K(a,{code:U.invalid_date}),ie}const n=new We;let s;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:U.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(s=this._getOrReturnCtx(t,s),K(s,{code:U.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):me.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Fr({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:re.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:re.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}Fr.create=e=>new Fr({checks:[],coerce:e?.coerce||!1,typeName:ae.ZodDate,...ce(e)});class Bo extends ue{_parse(t){if(this._getType(t)!==Q.symbol){const n=this._getOrReturnCtx(t);return K(n,{code:U.invalid_type,expected:Q.symbol,received:n.parsedType}),ie}return ht(t.data)}}Bo.create=e=>new Bo({typeName:ae.ZodSymbol,...ce(e)});class Wo extends ue{_parse(t){if(this._getType(t)!==Q.undefined){const n=this._getOrReturnCtx(t);return K(n,{code:U.invalid_type,expected:Q.undefined,received:n.parsedType}),ie}return ht(t.data)}}Wo.create=e=>new Wo({typeName:ae.ZodUndefined,...ce(e)});class Uo extends ue{_parse(t){if(this._getType(t)!==Q.null){const n=this._getOrReturnCtx(t);return K(n,{code:U.invalid_type,expected:Q.null,received:n.parsedType}),ie}return ht(t.data)}}Uo.create=e=>new Uo({typeName:ae.ZodNull,...ce(e)});class ia extends ue{constructor(){super(...arguments),this._any=!0}_parse(t){return ht(t.data)}}ia.create=e=>new ia({typeName:ae.ZodAny,...ce(e)});class ca extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ht(t.data)}}ca.create=e=>new ca({typeName:ae.ZodUnknown,...ce(e)});class ir extends ue{_parse(t){const r=this._getOrReturnCtx(t);return K(r,{code:U.invalid_type,expected:Q.never,received:r.parsedType}),ie}}ir.create=e=>new ir({typeName:ae.ZodNever,...ce(e)});class Zo extends ue{_parse(t){if(this._getType(t)!==Q.undefined){const n=this._getOrReturnCtx(t);return K(n,{code:U.invalid_type,expected:Q.void,received:n.parsedType}),ie}return ht(t.data)}}Zo.create=e=>new Zo({typeName:ae.ZodVoid,...ce(e)});class It extends ue{_parse(t){const{ctx:r,status:n}=this._processInputParams(t),s=this._def;if(r.parsedType!==Q.array)return K(r,{code:U.invalid_type,expected:Q.array,received:r.parsedType}),ie;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,c=r.data.length<s.exactLength.value;(i||c)&&(K(r,{code:i?U.too_big:U.too_small,minimum:c?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(K(r,{code:U.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(K(r,{code:U.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,c)=>s.type._parseAsync(new Ft(r,i,r.path,c)))).then(i=>We.mergeArray(n,i));const a=[...r.data].map((i,c)=>s.type._parseSync(new Ft(r,i,r.path,c)));return We.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new It({...this._def,minLength:{value:t,message:re.toString(r)}})}max(t,r){return new It({...this._def,maxLength:{value:t,message:re.toString(r)}})}length(t,r){return new It({...this._def,exactLength:{value:t,message:re.toString(r)}})}nonempty(t){return this.min(1,t)}}It.create=(e,t)=>new It({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ae.ZodArray,...ce(t)});function Rr(e){if(e instanceof je){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=ar.create(Rr(n))}return new je({...e._def,shape:()=>t})}else return e instanceof It?new It({...e._def,type:Rr(e.element)}):e instanceof ar?ar.create(Rr(e.unwrap())):e instanceof zr?zr.create(Rr(e.unwrap())):e instanceof xr?xr.create(e.items.map(t=>Rr(t))):e}class je extends ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=me.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Q.object){const u=this._getOrReturnCtx(t);return K(u,{code:U.invalid_type,expected:Q.object,received:u.parsedType}),ie}const{status:n,ctx:s}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),c=[];if(!(this._def.catchall instanceof ir&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||c.push(u);const l=[];for(const u of i){const f=a[u],d=s.data[u];l.push({key:{status:"valid",value:u},value:f._parse(new Ft(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof ir){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of c)l.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")c.length>0&&(K(s,{code:U.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of c){const d=s.data[f];l.push({key:{status:"valid",value:f},value:u._parse(new Ft(s,d,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of l){const d=await f.key,h=await f.value;u.push({key:d,value:h,alwaysSet:f.alwaysSet})}return u}).then(u=>We.mergeObjectSync(n,u)):We.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(t){return re.errToObj,new je({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{const s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:re.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(t){return new je({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new je({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ae.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new je({...this._def,catchall:t})}pick(t){const r={};for(const n of me.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new je({...this._def,shape:()=>r})}omit(t){const r={};for(const n of me.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new je({...this._def,shape:()=>r})}deepPartial(){return Rr(this)}partial(t){const r={};for(const n of me.objectKeys(this.shape)){const s=this.shape[n];t&&!t[n]?r[n]=s:r[n]=s.optional()}return new je({...this._def,shape:()=>r})}required(t){const r={};for(const n of me.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof ar;)a=a._def.innerType;r[n]=a}return new je({...this._def,shape:()=>r})}keyof(){return pc(me.objectKeys(this.shape))}}je.create=(e,t)=>new je({shape:()=>e,unknownKeys:"strip",catchall:ir.create(),typeName:ae.ZodObject,...ce(t)});je.strictCreate=(e,t)=>new je({shape:()=>e,unknownKeys:"strict",catchall:ir.create(),typeName:ae.ZodObject,...ce(t)});je.lazycreate=(e,t)=>new je({shape:e,unknownKeys:"strip",catchall:ir.create(),typeName:ae.ZodObject,...ce(t)});class qn extends ue{_parse(t){const{ctx:r}=this._processInputParams(t),n=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;const i=a.map(c=>new Ut(c.ctx.common.issues));return K(r,{code:U.invalid_union,unionErrors:i}),ie}if(r.common.async)return Promise.all(n.map(async a=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const l of n){const u={...r,common:{...r.common,issues:[]},parent:null},f=l._parseSync({data:r.data,path:r.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const c=i.map(l=>new Ut(l));return K(r,{code:U.invalid_union,unionErrors:c}),ie}}get options(){return this._def.options}}qn.create=(e,t)=>new qn({options:e,typeName:ae.ZodUnion,...ce(t)});function la(e,t){const r=nr(e),n=nr(t);if(e===t)return{valid:!0,data:e};if(r===Q.object&&n===Q.object){const s=me.objectKeys(t),a=me.objectKeys(e).filter(c=>s.indexOf(c)!==-1),i={...e,...t};for(const c of a){const l=la(e[c],t[c]);if(!l.valid)return{valid:!1};i[c]=l.data}return{valid:!0,data:i}}else if(r===Q.array&&n===Q.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const i=e[a],c=t[a],l=la(i,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return r===Q.date&&n===Q.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Xn extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t),s=(a,i)=>{if(Vo(a)||Vo(i))return ie;const c=la(a.value,i.value);return c.valid?((zo(a)||zo(i))&&r.dirty(),{status:r.value,value:c.data}):(K(n,{code:U.invalid_intersection_types}),ie)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Xn.create=(e,t,r)=>new Xn({left:e,right:t,typeName:ae.ZodIntersection,...ce(r)});class xr extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.array)return K(n,{code:U.invalid_type,expected:Q.array,received:n.parsedType}),ie;if(n.data.length<this._def.items.length)return K(n,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ie;!this._def.rest&&n.data.length>this._def.items.length&&(K(n,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((i,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new Ft(n,i,n.path,c)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>We.mergeArray(r,i)):We.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new xr({...this._def,rest:t})}}xr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xr({items:e,typeName:ae.ZodTuple,rest:null,...ce(t)})};class Kn extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.object)return K(n,{code:U.invalid_type,expected:Q.object,received:n.parsedType}),ie;const s=[],a=this._def.keyType,i=this._def.valueType;for(const c in n.data)s.push({key:a._parse(new Ft(n,c,n.path,c)),value:i._parse(new Ft(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?We.mergeObjectAsync(r,s):We.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof ue?new Kn({keyType:t,valueType:r,typeName:ae.ZodRecord,...ce(n)}):new Kn({keyType:At.create(),valueType:t,typeName:ae.ZodRecord,...ce(r)})}}class Yo extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.map)return K(n,{code:U.invalid_type,expected:Q.map,received:n.parsedType}),ie;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([c,l],u)=>({key:s._parse(new Ft(n,c,n.path,[u,"key"])),value:a._parse(new Ft(n,l,n.path,[u,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of i){const u=await l.key,f=await l.value;if(u.status==="aborted"||f.status==="aborted")return ie;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),c.set(u.value,f.value)}return{status:r.value,value:c}})}else{const c=new Map;for(const l of i){const u=l.key,f=l.value;if(u.status==="aborted"||f.status==="aborted")return ie;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),c.set(u.value,f.value)}return{status:r.value,value:c}}}}Yo.create=(e,t,r)=>new Yo({valueType:t,keyType:e,typeName:ae.ZodMap,...ce(r)});class un extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Q.set)return K(n,{code:U.invalid_type,expected:Q.set,received:n.parsedType}),ie;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(K(n,{code:U.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(K(n,{code:U.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const a=this._def.valueType;function i(l){const u=new Set;for(const f of l){if(f.status==="aborted")return ie;f.status==="dirty"&&r.dirty(),u.add(f.value)}return{status:r.value,value:u}}const c=[...n.data.values()].map((l,u)=>a._parse(new Ft(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>i(l)):i(c)}min(t,r){return new un({...this._def,minSize:{value:t,message:re.toString(r)}})}max(t,r){return new un({...this._def,maxSize:{value:t,message:re.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}un.create=(e,t)=>new un({valueType:e,minSize:null,maxSize:null,typeName:ae.ZodSet,...ce(t)});class Go extends ue{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Go.create=(e,t)=>new Go({getter:e,typeName:ae.ZodLazy,...ce(t)});class ua extends ue{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return K(r,{received:r.data,code:U.invalid_literal,expected:this._def.value}),ie}return{status:"valid",value:t.data}}get value(){return this._def.value}}ua.create=(e,t)=>new ua({value:e,typeName:ae.ZodLiteral,...ce(t)});function pc(e,t){return new Lr({values:e,typeName:ae.ZodEnum,...ce(t)})}class Lr extends ue{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),n=this._def.values;return K(r,{expected:me.joinValues(n),received:r.parsedType,code:U.invalid_type}),ie}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),n=this._def.values;return K(r,{received:r.data,code:U.invalid_enum_value,options:n}),ie}return ht(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Lr.create(t,{...this._def,...r})}exclude(t,r=this._def){return Lr.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}}Lr.create=pc;class qo extends ue{_parse(t){const r=me.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Q.string&&n.parsedType!==Q.number){const s=me.objectValues(r);return K(n,{expected:me.joinValues(s),received:n.parsedType,code:U.invalid_type}),ie}if(this._cache||(this._cache=new Set(me.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=me.objectValues(r);return K(n,{received:n.data,code:U.invalid_enum_value,options:s}),ie}return ht(t.data)}get enum(){return this._def.values}}qo.create=(e,t)=>new qo({values:e,typeName:ae.ZodNativeEnum,...ce(t)});class Jn extends ue{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==Q.promise&&r.common.async===!1)return K(r,{code:U.invalid_type,expected:Q.promise,received:r.parsedType}),ie;const n=r.parsedType===Q.promise?r.data:Promise.resolve(r.data);return ht(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Jn.create=(e,t)=>new Jn({type:e,typeName:ae.ZodPromise,...ce(t)});class Vr extends ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ae.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:n}=this._processInputParams(t),s=this._def.effect||null,a={addIssue:i=>{K(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async c=>{if(r.value==="aborted")return ie;const l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?ie:l.status==="dirty"||r.value==="dirty"?tn(l.value):l});{if(r.value==="aborted")return ie;const c=this._def.schema._parseSync({data:i,path:n.path,parent:n});return c.status==="aborted"?ie:c.status==="dirty"||r.value==="dirty"?tn(c.value):c}}if(s.type==="refinement"){const i=c=>{const l=s.refinement(c,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?ie:(c.status==="dirty"&&r.dirty(),i(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?ie:(c.status==="dirty"&&r.dirty(),i(c.value).then(()=>({status:r.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!$r(i))return ie;const c=s.transform(i.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>$r(i)?Promise.resolve(s.transform(i.value,a)).then(c=>({status:r.value,value:c})):ie);me.assertNever(s)}}Vr.create=(e,t,r)=>new Vr({schema:e,typeName:ae.ZodEffects,effect:t,...ce(r)});Vr.createWithPreprocess=(e,t,r)=>new Vr({schema:t,effect:{type:"preprocess",transform:e},typeName:ae.ZodEffects,...ce(r)});class ar extends ue{_parse(t){return this._getType(t)===Q.undefined?ht(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ar.create=(e,t)=>new ar({innerType:e,typeName:ae.ZodOptional,...ce(t)});class zr extends ue{_parse(t){return this._getType(t)===Q.null?ht(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}zr.create=(e,t)=>new zr({innerType:e,typeName:ae.ZodNullable,...ce(t)});class da extends ue{_parse(t){const{ctx:r}=this._processInputParams(t);let n=r.data;return r.parsedType===Q.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}da.create=(e,t)=>new da({innerType:e,typeName:ae.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ce(t)});class fa extends ue{_parse(t){const{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yn(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ut(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ut(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}fa.create=(e,t)=>new fa({innerType:e,typeName:ae.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ce(t)});class Xo extends ue{_parse(t){if(this._getType(t)!==Q.nan){const n=this._getOrReturnCtx(t);return K(n,{code:U.invalid_type,expected:Q.nan,received:n.parsedType}),ie}return{status:"valid",value:t.data}}}Xo.create=e=>new Xo({typeName:ae.ZodNaN,...ce(e)});class Xd extends ue{_parse(t){const{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Oa extends ue{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ie:a.status==="dirty"?(r.dirty(),tn(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(t,r){return new Oa({in:t,out:r,typeName:ae.ZodPipeline})}}class ha extends ue{_parse(t){const r=this._def.innerType._parse(t),n=s=>($r(s)&&(s.value=Object.freeze(s.value)),s);return Yn(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}ha.create=(e,t)=>new ha({innerType:e,typeName:ae.ZodReadonly,...ce(t)});var ae;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(ae||(ae={}));const J=At.create,we=vr.create;yr.create;const qe=Gn.create,ke=Fr.create,gc=ia.create,Kd=ca.create;ir.create;const Zt=It.create,Fe=je.create,ys=qn.create;Xn.create;xr.create;const vc=Kn.create,Bt=ua.create,_r=Lr.create;Jn.create;ar.create;zr.create;const Qn={string:(e=>At.create({...e,coerce:!0})),number:(e=>vr.create({...e,coerce:!0})),boolean:(e=>Gn.create({...e,coerce:!0})),bigint:(e=>yr.create({...e,coerce:!0})),date:(e=>Fr.create({...e,coerce:!0}))};function Ko(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ia(...e){return t=>{let r=!1;const n=e.map(s=>{const a=Ko(s,t);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let s=0;s<n.length;s++){const a=n[s];typeof a=="function"?a():Ko(e[s],null)}}}}function ct(...e){return k.useCallback(Ia(...e),e)}var Jd=Symbol.for("react.lazy"),es=k[" use ".trim().toString()];function Qd(e){return typeof e=="object"&&e!==null&&"then"in e}function yc(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Jd&&"_payload"in e&&Qd(e._payload)}function ef(e){const t=rf(e),r=k.forwardRef((n,s)=>{let{children:a,...i}=n;yc(a)&&typeof es=="function"&&(a=es(a._payload));const c=k.Children.toArray(a),l=c.find(sf);if(l){const u=l.props.children,f=c.map(d=>d===l?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:d);return o.jsx(t,{...i,ref:s,children:k.isValidElement(u)?k.cloneElement(u,void 0,f):null})}return o.jsx(t,{...i,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}var tf=ef("Slot");function rf(e){const t=k.forwardRef((r,n)=>{let{children:s,...a}=r;if(yc(s)&&typeof es=="function"&&(s=es(s._payload)),k.isValidElement(s)){const i=of(s),c=af(a,s.props);return s.type!==k.Fragment&&(c.ref=n?Ia(n,i):i),k.cloneElement(s,c)}return k.Children.count(s)>1?k.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var nf=Symbol("radix.slottable");function sf(e){return k.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===nf}function af(e,t){const r={...t};for(const n in t){const s=e[n],a=t[n];/^on[A-Z]/.test(n)?s&&a?r[n]=(...c)=>{const l=a(...c);return s(...c),l}:s&&(r[n]=s):n==="style"?r[n]={...s,...a}:n==="className"&&(r[n]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function of(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}const Jo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Qo=Ji,cf=(e,t)=>r=>{var n;if(t?.variants==null)return Qo(e,r?.class,r?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(u=>{const f=r?.[u],d=a?.[u];if(f===null)return null;const h=Jo(f)||Jo(d);return s[u][h]}),c=r&&Object.entries(r).reduce((u,f)=>{let[d,h]=f;return h===void 0||(u[d]=h),u},{}),l=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:d,className:h,...p}=f;return Object.entries(p).every(w=>{let[g,y]=w;return Array.isArray(y)?y.includes({...a,...c}[g]):{...a,...c}[g]===y})?[...u,d,h]:u},[]);return Qo(e,i,l,r?.class,r?.className)},sn=cf("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 min-w-[var(--ui-space-0)] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-chart-4 text-white shadow-sm hover:bg-chart-4/90",outline:"border border-input bg-transparent text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-accent underline-offset-4 underline hover:text-accent/80 !h-auto !py-[var(--ui-space-0)]",positive:"bg-chart-2 text-white shadow-sm hover:bg-chart-2/90",warning:"bg-chart-3 text-white shadow-sm hover:bg-chart-3/90",info:"bg-chart-5 text-white shadow-sm hover:bg-chart-5/90","outline-positive":"border border-chart-2 text-chart-2 hover:bg-chart-2/10","outline-negative":"border border-muted text-muted-foreground hover:bg-muted/10",fab:"rounded-full h-[var(--ui-space-14)] w-[var(--ui-space-14)] p-[var(--ui-space-0)] shadow-lg hover:shadow-xl bg-primary text-primary-foreground hover:bg-primary/90","circle-help":"bg-accent text-accent-foreground shadow-sm hover:bg-accent/90 rounded-full","circle-alert":"bg-chart-3 text-white shadow-sm hover:bg-chart-3/90 rounded-full",abort:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",negative:"bg-muted text-muted-foreground shadow-sm hover:bg-muted/80",delete:"bg-chart-4 text-white shadow-sm hover:bg-chart-4/90",pause:"bg-chart-3 text-white shadow-sm hover:bg-chart-3/90","outline-abort":"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",option:"border border-[hsl(210,30%,35%)] dark:border-border bg-background text-foreground shadow-none hover:bg-accent/30 hover:text-foreground","option-active":"border-2 border-primary bg-primary/10 text-foreground shadow-none hover:bg-primary/20","outline-delete":"border border-destructive/50 text-destructive bg-background hover:bg-destructive/10 hover:border-destructive"},size:{default:"px-ui-button py-ui text-ui min-h-ui-touch",sm:"rounded-md px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-xs",lg:"rounded-md px-[var(--ui-space-8)] py-[var(--ui-space-3)]",icon:"p-ui min-h-ui-touch min-w-[var(--ui-touch-target-min)]",circle:"rounded-full p-[var(--ui-space-2)] aspect-square"}},defaultVariants:{variant:"default",size:"default"}}),oe=k.forwardRef(({className:e,variant:t="default",size:r,children:n,loading:s=!1,success:a=!1,error:i=!1,icon:c,asChild:l=!1,disabled:u,maxLabelLength:f=100,...d},h)=>{const p=l?tf:"button",w=a?"positive":i?"destructive":t,g=()=>{if(s)return o.jsx(ye.Spinner,{className:"h-ui-icon w-ui-icon"});if(a)return o.jsx(ye.Check,{className:"h-ui-icon w-ui-icon"});if(i)return o.jsx(ye.X,{className:"h-ui-icon w-ui-icon"});const y=typeof n=="string"&&n.length>f?`${n.slice(0,Math.max(0,f-1))}…`:n,x=typeof n=="string"&&typeof y=="string"&&y!==n,v=typeof n=="string"?o.jsx("span",{className:"min-w-[var(--ui-space-0)] flex-1 whitespace-nowrap",title:x?n:void 0,children:y}):n;return o.jsxs("span",{className:"flex min-w-[var(--ui-space-0)] items-center",children:[c&&o.jsx(c,{className:de(n?"mr-[var(--ui-space-2)]":"mr-[var(--ui-space-0)]","h-ui-icon w-ui-icon")}),v]})};return o.jsx(p,{className:de(sn({variant:w,size:r,className:e})),ref:h,disabled:u||s||a||i,...d,children:g()})});oe.displayName="Button";function lf(e,t){const r=k.createContext(t),n=a=>{const{children:i,...c}=a,l=k.useMemo(()=>c,Object.values(c));return o.jsx(r.Provider,{value:l,children:i})};n.displayName=e+"Provider";function s(a){const i=k.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[n,s]}function xs(e,t=[]){let r=[];function n(a,i){const c=k.createContext(i),l=r.length;r=[...r,i];const u=d=>{const{scope:h,children:p,...w}=d,g=h?.[e]?.[l]||c,y=k.useMemo(()=>w,Object.values(w));return o.jsx(g.Provider,{value:y,children:p})};u.displayName=a+"Provider";function f(d,h){const p=h?.[e]?.[l]||c,w=k.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[u,f]}const s=()=>{const a=r.map(i=>k.createContext(i));return function(c){const l=c?.[e]||a;return k.useMemo(()=>({[`__scope${e}`]:{...c,[e]:l}}),[c,l])}};return s.scopeName=e,[n,uf(s,...t)]}function uf(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=n.reduce((c,{useScope:l,scopeName:u})=>{const d=l(a)[`__scope${u}`];return{...c,...d}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function Be(e,t,{checkForDefaultPrevented:r=!0}={}){return function(s){if(e?.(s),r===!1||!s.defaultPrevented)return t?.(s)}}var cr=globalThis?.document?k.useLayoutEffect:()=>{},df=k[" useInsertionEffect ".trim().toString()]||cr;function $a({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[s,a,i]=ff({defaultProp:t,onChange:r}),c=e!==void 0,l=c?e:s;{const f=k.useRef(e!==void 0);k.useEffect(()=>{const d=f.current;d!==c&&console.warn(`${n} is changing from ${d?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,n])}const u=k.useCallback(f=>{if(c){const d=hf(f)?f(e):f;d!==e&&i.current?.(d)}else a(f)},[c,e,a,i]);return[l,u]}function ff({defaultProp:e,onChange:t}){const[r,n]=k.useState(e),s=k.useRef(r),a=k.useRef(t);return df(()=>{a.current=t},[t]),k.useEffect(()=>{s.current!==r&&(a.current?.(r),s.current=r)},[r,s]),[r,n,a]}function hf(e){return typeof e=="function"}function mf(e){const t=k.useRef({value:e,previous:e});return k.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function xc(e){const[t,r]=k.useState(void 0);return cr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let i,c;if("borderBoxSize"in a){const l=a.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,c=u.blockSize}else i=e.offsetWidth,c=e.offsetHeight;r({width:i,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}function pf(e,t){return k.useReducer((r,n)=>t[r][n]??r,e)}var Sr=e=>{const{present:t,children:r}=e,n=gf(t),s=typeof r=="function"?r({present:n.isPresent}):k.Children.only(r),a=ct(n.ref,vf(s));return typeof r=="function"||n.isPresent?k.cloneElement(s,{ref:a}):null};Sr.displayName="Presence";function gf(e){const[t,r]=k.useState(),n=k.useRef(null),s=k.useRef(e),a=k.useRef("none"),i=e?"mounted":"unmounted",[c,l]=pf(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=Rn(n.current);a.current=c==="mounted"?u:"none"},[c]),cr(()=>{const u=n.current,f=s.current;if(f!==e){const h=a.current,p=Rn(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,l]),cr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,d=p=>{const g=Rn(n.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(a.current=Rn(n.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:k.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Rn(e){return e?.animationName||"none"}function vf(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Fa(e){const t=yf(e),r=k.forwardRef((n,s)=>{const{children:a,...i}=n,c=k.Children.toArray(a),l=c.find(bf);if(l){const u=l.props.children,f=c.map(d=>d===l?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:d);return o.jsx(t,{...i,ref:s,children:k.isValidElement(u)?k.cloneElement(u,void 0,f):null})}return o.jsx(t,{...i,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function yf(e){const t=k.forwardRef((r,n)=>{const{children:s,...a}=r;if(k.isValidElement(s)){const i=_f(s),c=wf(a,s.props);return s.type!==k.Fragment&&(c.ref=n?Ia(n,i):i),k.cloneElement(s,c)}return k.Children.count(s)>1?k.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xf=Symbol("radix.slottable");function bf(e){return k.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xf}function wf(e,t){const r={...t};for(const n in t){const s=e[n],a=t[n];/^on[A-Z]/.test(n)?s&&a?r[n]=(...c)=>{const l=a(...c);return s(...c),l}:s&&(r[n]=s):n==="style"?r[n]={...s,...a}:n==="className"&&(r[n]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function _f(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Sf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=Sf.reduce((e,t)=>{const r=Fa(`Primitive.${t}`),n=k.forwardRef((s,a)=>{const{asChild:i,...c}=s,l=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(l,{...c,ref:a})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function kf(e,t){e&&Xi.flushSync(()=>e.dispatchEvent(t))}var bs="Checkbox",[Cf]=xs(bs),[jf,La]=Cf(bs);function Df(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:s,disabled:a,form:i,name:c,onCheckedChange:l,required:u,value:f="on",internal_do_not_use_render:d}=e,[h,p]=$a({prop:r,defaultProp:s??!1,onChange:l,caller:bs}),[w,g]=k.useState(null),[y,x]=k.useState(null),v=k.useRef(!1),_=w?!!i||!!w.closest("form"):!0,b={checked:h,disabled:a,setChecked:p,control:w,setControl:g,name:c,form:i,value:f,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:or(s)?!1:s,isFormControl:_,bubbleInput:y,setBubbleInput:x};return o.jsx(jf,{scope:t,...b,children:Nf(d)?d(b):n})}var bc="CheckboxTrigger",wc=k.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},s)=>{const{control:a,value:i,disabled:c,checked:l,required:u,setControl:f,setChecked:d,hasConsumerStoppedPropagationRef:h,isFormControl:p,bubbleInput:w}=La(bc,e),g=ct(s,f),y=k.useRef(l);return k.useEffect(()=>{const x=a?.form;if(x){const v=()=>d(y.current);return x.addEventListener("reset",v),()=>x.removeEventListener("reset",v)}},[a,d]),o.jsx(Ie.button,{type:"button",role:"checkbox","aria-checked":or(l)?"mixed":l,"aria-required":u,"data-state":jc(l),"data-disabled":c?"":void 0,disabled:c,value:i,...n,ref:g,onKeyDown:Be(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Be(r,x=>{d(v=>or(v)?!0:!v),w&&p&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})});wc.displayName=bc;var Va=k.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:a,required:i,disabled:c,value:l,onCheckedChange:u,form:f,...d}=e;return o.jsx(Df,{__scopeCheckbox:r,checked:s,defaultChecked:a,disabled:c,required:i,onCheckedChange:u,name:n,form:f,value:l,internal_do_not_use_render:({isFormControl:h})=>o.jsxs(o.Fragment,{children:[o.jsx(wc,{...d,ref:t,__scopeCheckbox:r}),h&&o.jsx(Cc,{__scopeCheckbox:r})]})})});Va.displayName=bs;var _c="CheckboxIndicator",Sc=k.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...s}=e,a=La(_c,r);return o.jsx(Sr,{present:n||or(a.checked)||a.checked===!0,children:o.jsx(Ie.span,{"data-state":jc(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});Sc.displayName=_c;var kc="CheckboxBubbleInput",Cc=k.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:a,defaultChecked:i,required:c,disabled:l,name:u,value:f,form:d,bubbleInput:h,setBubbleInput:p}=La(kc,e),w=ct(r,p),g=mf(a),y=xc(n);k.useEffect(()=>{const v=h;if(!v)return;const _=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(_,"checked").set,C=!s.current;if(g!==a&&S){const j=new Event("click",{bubbles:C});v.indeterminate=or(a),S.call(v,or(a)?!1:a),v.dispatchEvent(j)}},[h,g,a,s]);const x=k.useRef(or(a)?!1:a);return o.jsx(Ie.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??x.current,required:c,disabled:l,name:u,value:f,form:d,...t,tabIndex:-1,ref:w,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Cc.displayName=kc;function Nf(e){return typeof e=="function"}function or(e){return e==="indeterminate"}function jc(e){return or(e)?"indeterminate":e?"checked":"unchecked"}const dn=k.forwardRef(({className:e,...t},r)=>o.jsx(Va,{ref:r,className:de("peer h-ui-checkbox w-ui-checkbox shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:o.jsx(Sc,{className:de("flex items-center justify-center text-current"),children:o.jsx(ye.Check,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})}));dn.displayName=Va.displayName;function Ne(e,t,r){const n=t||void 0;switch(r){case"header":return new Intl.DateTimeFormat(n,{year:"numeric",month:"short"}).format(e);case"picker":return new Intl.DateTimeFormat(n,{year:"numeric",month:"short",day:"numeric"}).format(e);case"weekday":{const s=new Intl.DateTimeFormat(n,{weekday:"short"}).format(e);return n?.startsWith("ja")?`(${s})`:new Intl.DateTimeFormat(n,{weekday:"long"}).format(e)}case"weekdayShort":return new Intl.DateTimeFormat(n,{weekday:"short"}).format(e);case"day":return new Intl.NumberFormat(n).format(e.getDate());case"monthDayShort":return new Intl.DateTimeFormat(n,{month:"short",day:"numeric",weekday:"short"}).format(e);case"compact":return new Intl.DateTimeFormat(n,{month:"numeric",day:"numeric",weekday:"short"}).format(e);case"time":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric"}).format(e);case"timeWithSeconds":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",second:"numeric"}).format(e);case"timeWithMs":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}).format(e);case"minute":return new Intl.DateTimeFormat(n,{minute:"numeric"}).format(e);case"second":return new Intl.DateTimeFormat(n,{second:"numeric"}).format(e);case"time12":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",hour12:!0}).format(e);case"time24":return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",hour12:!1}).format(e);case"year":return new Intl.DateTimeFormat(n,{year:"numeric"}).format(e);case"month":return new Intl.DateTimeFormat(n,{month:"long"}).format(e);case"monthShort":return new Intl.DateTimeFormat(n,{month:"short"}).format(e);case"full":{const s=new Intl.DateTimeFormat(n,{year:"numeric",month:"long",day:"numeric"}).format(e),a=new Intl.DateTimeFormat(n,{weekday:"short"}).format(e);return n?.startsWith("ja")?`${s}(${a})`:new Intl.DateTimeFormat(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"}).format(e)}case"yearMonth":return new Intl.DateTimeFormat(n,{year:"numeric",month:"long"}).format(e);case"monthDay":return new Intl.DateTimeFormat(n,{month:"long",day:"numeric"}).format(e);default:return e.toLocaleDateString(n)}}const Ef={loading:"Loading",today_button:"Today",previous:"Previous",next:"Next",view_day:"Day",view_week:"Week",view_month:"Month",days_short_sun:"Sun",days_short_mon:"Mon",days_short_tue:"Tue",days_short_wed:"Wed",days_short_thu:"Thu",days_short_fri:"Fri",days_short_sat:"Sat",user_name_label:"User Name",name_placeholder:"Enter name",attendee_label:"Attendee",attendee_placeholder:"Enter attendee name",resource_label:"Resource",resource_placeholder:"Select resource",start_time_label:"Start Time",duration_label:"Duration",status_label:"Status",note_label:"Notes",delete_button:"Delete",cancel_button:"Cancel",save_button:"Save",confirm_delete_title:"Delete Event",confirm_delete_message:"Are you sure you want to delete this event?",event_edit_title:"Edit Event",event_create_title:"Create Event",facility_prompt_group_name:"Enter group name",facility_confirm_delete_group_message:"Delete this group?",facility_prompt_resource_name:"Enter resource name",facility_confirm_delete_resource_message:"Delete this resource?",close:"Close",facility_settings_title:"Facility Settings",facility_label_group_name:"Group",facility_label_resource_name:"Resource",facility_action_add_group:"Add Group",facility_action_add_resource:"Add Resource",facility_label_no_groups:"No groups",facility_action_done:"Done",settings_title:"Settings",settings_language:"Language",settings_theme:"Theme",option_light:"Light",option_dark:"Dark",settings_density:"Density",option_compact:"Compact",option_normal:"Normal",option_spacious:"Spacious",settings_radius:"Radius",settings_font_size:"Font Size",settings_week_start:"Week Starts On",option_sunday:"Sunday",option_monday:"Monday",settings_business_hours:"Business Hours",settings_closed_days:"Closed Days",settings_pagination:"Facility Pagination",settings_page_size:"Items per page",page:"Page",previousPage:"Previous Page",nextPage:"Next Page",day_cell:"Day cell",event_custom_edit_title:"Edit Event",event_custom_create_title:"Create Event",event_name_label:"Event Name",event_name_placeholder:"Enter event name",usage_label:"Usage",usage_placeholder:"Select usage",all_day:"All day",date_time_label:"Date & Time",attendee_self:"Only me",date_picker_label:"Select date",personnel_list_title:"職員一覧",personnel_search_placeholder:"Search by name or email...",personnel_priority_high:"High Priority",personnel_priority_normal:"Normal",personnel_priority_low:"Low Priority",personnel_no_results:"No matching personnel found",personnel_all_departments:"All Departments",personnel_selected_count:"{{count}} selected",personnel_context_hint:"Right-click to set priority",keypad_title_number:"Enter number",keypad_title_phone:"Enter phone number",keypad_title_time:"Enter time",keypad_error_max_length:"Up to {{max}} characters",keypad_error_hyphen_repeat:"Hyphen cannot be repeated",keypad_error_decimal_repeat:"Only one decimal point is allowed",keypad_error_time_invalid:"Enter a valid 4-digit time (e.g., 0930)",keypad_error_value_required:"Please enter a value",keypad_error_decimal_end:"Value cannot end with a decimal point",keypad_error_hyphen_end:"Value cannot end with a hyphen"};function Le(){const{t:e,i18n:t}=ja.useTranslation();return{t:(n,s)=>{const a=typeof s=="string"?{defaultValue:s}:s??{},i=a.defaultValue??Ef[n]??n;return e(n,{...a,defaultValue:i})},i18n:t}}function kr(e,t){const r=new Date(e);return r.setDate(r.getDate()+t),r}function Af(e,t){return kr(e,t*7)}function za(e,t){const r=new Date(e),n=r.getMonth()+t;return r.setMonth(n),r.getMonth()!==(n%12+12)%12&&r.setDate(0),r}function Tf(e,t){return za(e,-1)}function dt(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function Rf(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function ma(e){const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),t}function Dc(e){const t=new Date(e);return t.setMonth(t.getMonth()+1),t.setDate(0),t.setHours(23,59,59,999),t}function an(e,t){const r=t?.weekStartsOn??0,n=new Date(e),s=n.getDay(),a=(s<r?7:0)+s-r;return n.setDate(n.getDate()-a),n.setHours(0,0,0,0),n}function pa(e,t){const r=an(e,t),n=kr(r,6);return n.setHours(23,59,59,999),n}function hr(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Pf(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function ei(e,t){const r=e.getTime();return r>=t.start.getTime()&&r<=t.end.getTime()}function Nc(e,t){return e.start.getTime()<t.end.getTime()&&t.start.getTime()<e.end.getTime()}function ti(e){const t=dt(e.start),n=dt(e.end).getTime(),s=[],a=new Date(t);for(;a.getTime()<=n;)s.push(new Date(a)),a.setDate(a.getDate()+1);return s}function Mf(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function Ec(e){const t=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0");return`${t}:${r}`}function Pr(e){return`${Mf(e)}T${Ec(e)}`}function ri({className:e,locale:t,mode:r="single",selected:n,onSelect:s,disabled:a,numberOfMonths:i=1,defaultMonth:c}){const[l,u]=k.useState(c||(n instanceof Date?n:n?.from)||new Date),f=k.useRef(n);k.useEffect(()=>{if(n!==f.current){const C=n instanceof Date?n:n?.from;C&&u(ma(C)),f.current=n}},[n]);const d=C=>{if(!a)return!1;const j=dt(C);return Array.isArray(a)?a.some(N=>N instanceof Date?hr(j,dt(N)):typeof N=="object"&&"before"in N&&N.before?j.getTime()<dt(N.before).getTime():typeof N=="object"&&"after"in N&&N.after?j.getTime()>dt(N.after).getTime():!1):a instanceof Date?hr(j,dt(a)):typeof a=="function"?a(C):!1},h=C=>{if(!n)return!1;if(r==="single"&&n instanceof Date)return hr(C,n);if(r==="range"&&n.from){const j=n;if(j.from&&hr(C,j.from)||j.to&&hr(C,j.to))return!0;if(j.from&&j.to)return ei(C,{start:j.from,end:j.to})}return!1},p=C=>{let j=!1,N=!1,E=!1;if(r==="range"&&n?.from){const R=n;R.from&&hr(C,R.from)&&(j=!0),R.to&&hr(C,R.to)&&(N=!0),R.from&&R.to&&ei(C,{start:R.from,end:R.to})&&(E=!0)}return de(sn({variant:"ghost"}),"p-ui font-normal aria-selected:opacity-100",h(C)&&"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",E&&!j&&!N&&"bg-accent text-accent-foreground rounded-none",j&&"bg-primary text-primary-foreground rounded-l-md rounded-r-none",N&&"bg-primary text-primary-foreground rounded-l-none rounded-r-md",r==="single"&&h(C)&&"rounded-md",!Pf(C,l)&&"text-muted-foreground opacity-50",d(C)&&"text-muted-foreground opacity-50 cursor-not-allowed")},w=C=>{if(!d(C)){if(r==="single")s?.(C);else if(r==="range"){const j=n||{from:void 0,to:void 0};!j.from||j.from&&j.to?s?.({from:C,to:void 0}):C<j.from?s?.({from:C,to:void 0}):s?.({from:j.from,to:C})}}},g=()=>u(C=>za(new Date(C),1)),y=()=>u(C=>Tf(new Date(C))),x=ma(l),v=Dc(x),_=an(x),b=pa(v),S=ti({start:_,end:b});return o.jsxs("div",{className:de("p-ui flex flex-col gap-y-ui",e),children:[o.jsxs("div",{className:"flex items-center justify-between gap-x-ui",children:[o.jsx("button",{type:"button",onClick:y,"aria-label":"Go to previous month",className:de(sn({variant:"outline"}),"bg-transparent p-ui hover:bg-accent hover:text-accent-foreground"),children:o.jsx(ye.ChevronLeft,{className:"h-ui-icon w-ui-icon",strokeWidth:3})}),o.jsx("div",{className:"font-medium text-ui",children:Ne(l,t,"header")}),o.jsx("button",{type:"button",onClick:g,"aria-label":"Go to next month",className:de(sn({variant:"outline"}),"bg-transparent p-ui hover:bg-accent hover:text-accent-foreground"),children:o.jsx(ye.ChevronRight,{className:"h-ui-icon w-ui-icon",strokeWidth:3})})]}),o.jsxs("table",{className:"w-full border-collapse space-y-[var(--ui-space-1)]",children:[o.jsx("thead",{children:o.jsx("tr",{children:ti({start:an(l),end:pa(an(l))}).map(C=>{const j=C.getDay(),N=j===0,E=j===6;return o.jsx("th",{className:de("rounded-md font-normal text-[0.8rem]",N&&"text-red-500",E&&"text-blue-500",!N&&!E&&"text-muted-foreground"),children:o.jsx("div",{className:"flex justify-center items-center p-ui",children:Ne(C,t,"weekdayShort")})},C.getTime())})})}),o.jsx("tbody",{children:Array.from({length:Math.ceil(S.length/7)}).map((C,j)=>{const N=S.slice(j*7,(j+1)*7);return o.jsx("tr",{className:"w-full",children:N.map(E=>o.jsx("td",{className:"p-[var(--ui-space-0)] text-center relative focus-within:relative",children:o.jsx("button",{type:"button",onClick:()=>w(E),className:p(E),disabled:d(E),children:Ne(E,t,"day")})},E.getTime()))},N[0]?.getTime()||j)})})]})]})}function Hr(e){const t=k.useRef(e);return k.useEffect(()=>{t.current=e}),k.useMemo(()=>(...r)=>t.current?.(...r),[])}function Of(e,t=globalThis?.document){const r=Hr(e);k.useEffect(()=>{const n=s=>{s.key==="Escape"&&r(s)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var If="DismissableLayer",ga="dismissableLayer.update",$f="dismissableLayer.pointerDownOutside",Ff="dismissableLayer.focusOutside",ni,Ac=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=k.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...l}=e,u=k.useContext(Ac),[f,d]=k.useState(null),h=f?.ownerDocument??globalThis?.document,[,p]=k.useState({}),w=ct(t,j=>d(j)),g=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=g.indexOf(y),v=f?g.indexOf(f):-1,_=u.layersWithOutsidePointerEventsDisabled.size>0,b=v>=x,S=zf(j=>{const N=j.target,E=[...u.branches].some(R=>R.contains(N));!b||E||(s?.(j),i?.(j),j.defaultPrevented||c?.())},h),C=Hf(j=>{const N=j.target;[...u.branches].some(R=>R.contains(N))||(a?.(j),i?.(j),j.defaultPrevented||c?.())},h);return Of(j=>{v===u.layers.size-1&&(n?.(j),!j.defaultPrevented&&c&&(j.preventDefault(),c()))},h),k.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(ni=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),si(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=ni)}},[f,h,r,u]),k.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),si())},[f,u]),k.useEffect(()=>{const j=()=>p({});return document.addEventListener(ga,j),()=>document.removeEventListener(ga,j)},[]),o.jsx(Ie.div,{...l,ref:w,style:{pointerEvents:_?b?"auto":"none":void 0,...e.style},onFocusCapture:Be(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Be(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Be(e.onPointerDownCapture,S.onPointerDownCapture)})});Ha.displayName=If;var Lf="DismissableLayerBranch",Vf=k.forwardRef((e,t)=>{const r=k.useContext(Ac),n=k.useRef(null),s=ct(t,n);return k.useEffect(()=>{const a=n.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),o.jsx(Ie.div,{...e,ref:s})});Vf.displayName=Lf;function zf(e,t=globalThis?.document){const r=Hr(e),n=k.useRef(!1),s=k.useRef(()=>{});return k.useEffect(()=>{const a=c=>{if(c.target&&!n.current){let l=function(){Tc($f,r,u,{discrete:!0})};const u={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=l,t.addEventListener("click",s.current,{once:!0})):l()}else t.removeEventListener("click",s.current);n.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function Hf(e,t=globalThis?.document){const r=Hr(e),n=k.useRef(!1);return k.useEffect(()=>{const s=a=>{a.target&&!n.current&&Tc(Ff,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function si(){const e=new CustomEvent(ga);document.dispatchEvent(e)}function Tc(e,t,r,{discrete:n}){const s=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),n?kf(s,a):s.dispatchEvent(a)}var Bs=0;function Rc(){k.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ai()),document.body.insertAdjacentElement("beforeend",e[1]??ai()),Bs++,()=>{Bs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Bs--}},[])}function ai(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ws="focusScope.autoFocusOnMount",Us="focusScope.autoFocusOnUnmount",oi={bubbles:!1,cancelable:!0},Bf="FocusScope",Ba=k.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[c,l]=k.useState(null),u=Hr(s),f=Hr(a),d=k.useRef(null),h=ct(t,g=>l(g)),p=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(n){let g=function(_){if(p.paused||!c)return;const b=_.target;c.contains(b)?d.current=b:rr(d.current,{select:!0})},y=function(_){if(p.paused||!c)return;const b=_.relatedTarget;b!==null&&(c.contains(b)||rr(d.current,{select:!0}))},x=function(_){if(document.activeElement===document.body)for(const S of _)S.removedNodes.length>0&&rr(c)};document.addEventListener("focusin",g),document.addEventListener("focusout",y);const v=new MutationObserver(x);return c&&v.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",y),v.disconnect()}}},[n,c,p.paused]),k.useEffect(()=>{if(c){ci.add(p);const g=document.activeElement;if(!c.contains(g)){const x=new CustomEvent(Ws,oi);c.addEventListener(Ws,u),c.dispatchEvent(x),x.defaultPrevented||(Wf(qf(Pc(c)),{select:!0}),document.activeElement===g&&rr(c))}return()=>{c.removeEventListener(Ws,u),setTimeout(()=>{const x=new CustomEvent(Us,oi);c.addEventListener(Us,f),c.dispatchEvent(x),x.defaultPrevented||rr(g??document.body,{select:!0}),c.removeEventListener(Us,f),ci.remove(p)},0)}}},[c,u,f,p]);const w=k.useCallback(g=>{if(!r&&!n||p.paused)return;const y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,x=document.activeElement;if(y&&x){const v=g.currentTarget,[_,b]=Uf(v);_&&b?!g.shiftKey&&x===b?(g.preventDefault(),r&&rr(_,{select:!0})):g.shiftKey&&x===_&&(g.preventDefault(),r&&rr(b,{select:!0})):x===v&&g.preventDefault()}},[r,n,p.paused]);return o.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});Ba.displayName=Bf;function Wf(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(rr(n,{select:t}),document.activeElement!==r)return}function Uf(e){const t=Pc(e),r=ii(t,e),n=ii(t.reverse(),e);return[r,n]}function Pc(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ii(e,t){for(const r of e)if(!Zf(r,{upTo:t}))return r}function Zf(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Yf(e){return e instanceof HTMLInputElement&&"select"in e}function rr(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Yf(e)&&t&&e.select()}}var ci=Gf();function Gf(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=li(e,t),e.unshift(t)},remove(t){e=li(e,t),e[0]?.resume()}}}function li(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function qf(e){return e.filter(t=>t.tagName!=="A")}var Xf=k[" useId ".trim().toString()]||(()=>{}),Kf=0;function Ln(e){const[t,r]=k.useState(Xf());return cr(()=>{r(n=>n??String(Kf++))},[e]),e||(t?`radix-${t}`:"")}const Jf=["top","right","bottom","left"],lr=Math.min,st=Math.max,ts=Math.round,Pn=Math.floor,$t=e=>({x:e,y:e}),Qf={left:"right",right:"left",bottom:"top",top:"bottom"},eh={start:"end",end:"start"};function va(e,t,r){return st(e,lr(t,r))}function Yt(e,t){return typeof e=="function"?e(t):e}function Gt(e){return e.split("-")[0]}function Ur(e){return e.split("-")[1]}function Wa(e){return e==="x"?"y":"x"}function Ua(e){return e==="y"?"height":"width"}const th=new Set(["top","bottom"]);function Tt(e){return th.has(Gt(e))?"y":"x"}function Za(e){return Wa(Tt(e))}function rh(e,t,r){r===void 0&&(r=!1);const n=Ur(e),s=Za(e),a=Ua(s);let i=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=rs(i)),[i,rs(i)]}function nh(e){const t=rs(e);return[ya(e),t,ya(t)]}function ya(e){return e.replace(/start|end/g,t=>eh[t])}const ui=["left","right"],di=["right","left"],sh=["top","bottom"],ah=["bottom","top"];function oh(e,t,r){switch(e){case"top":case"bottom":return r?t?di:ui:t?ui:di;case"left":case"right":return t?sh:ah;default:return[]}}function ih(e,t,r,n){const s=Ur(e);let a=oh(Gt(e),r==="start",n);return s&&(a=a.map(i=>i+"-"+s),t&&(a=a.concat(a.map(ya)))),a}function rs(e){return e.replace(/left|right|bottom|top/g,t=>Qf[t])}function ch(e){return{top:0,right:0,bottom:0,left:0,...e}}function Mc(e){return typeof e!="number"?ch(e):{top:e,right:e,bottom:e,left:e}}function ns(e){const{x:t,y:r,width:n,height:s}=e;return{width:n,height:s,top:r,left:t,right:t+n,bottom:r+s,x:t,y:r}}function fi(e,t,r){let{reference:n,floating:s}=e;const a=Tt(t),i=Za(t),c=Ua(i),l=Gt(t),u=a==="y",f=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,h=n[c]/2-s[c]/2;let p;switch(l){case"top":p={x:f,y:n.y-s.height};break;case"bottom":p={x:f,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-s.width,y:d};break;default:p={x:n.x,y:n.y}}switch(Ur(t)){case"start":p[i]-=h*(r&&u?-1:1);break;case"end":p[i]+=h*(r&&u?-1:1);break}return p}const lh=async(e,t,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:a=[],platform:i}=r,c=a.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:d}=fi(u,n,l),h=n,p={},w=0;for(let g=0;g<c.length;g++){const{name:y,fn:x}=c[g],{x:v,y:_,data:b,reset:S}=await x({x:f,y:d,initialPlacement:n,placement:h,strategy:s,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});f=v??f,d=_??d,p={...p,[y]:{...p[y],...b}},S&&w<=50&&(w++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):S.rects),{x:f,y:d}=fi(u,h,l)),g=-1)}return{x:f,y:d,placement:h,strategy:s,middlewareData:p}};async function fn(e,t){var r;t===void 0&&(t={});const{x:n,y:s,platform:a,rects:i,elements:c,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=Yt(t,e),w=Mc(p),y=c[h?d==="floating"?"reference":"floating":d],x=ns(await a.getClippingRect({element:(r=await(a.isElement==null?void 0:a.isElement(y)))==null||r?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:u,rootBoundary:f,strategy:l})),v=d==="floating"?{x:n,y:s,width:i.floating.width,height:i.floating.height}:i.reference,_=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),b=await(a.isElement==null?void 0:a.isElement(_))?await(a.getScale==null?void 0:a.getScale(_))||{x:1,y:1}:{x:1,y:1},S=ns(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:_,strategy:l}):v);return{top:(x.top-S.top+w.top)/b.y,bottom:(S.bottom-x.bottom+w.bottom)/b.y,left:(x.left-S.left+w.left)/b.x,right:(S.right-x.right+w.right)/b.x}}const uh=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:s,rects:a,platform:i,elements:c,middlewareData:l}=t,{element:u,padding:f=0}=Yt(e,t)||{};if(u==null)return{};const d=Mc(f),h={x:r,y:n},p=Za(s),w=Ua(p),g=await i.getDimensions(u),y=p==="y",x=y?"top":"left",v=y?"bottom":"right",_=y?"clientHeight":"clientWidth",b=a.reference[w]+a.reference[p]-h[p]-a.floating[w],S=h[p]-a.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let j=C?C[_]:0;(!j||!await(i.isElement==null?void 0:i.isElement(C)))&&(j=c.floating[_]||a.floating[w]);const N=b/2-S/2,E=j/2-g[w]/2-1,R=lr(d[x],E),M=lr(d[v],E),A=R,$=j-g[w]-M,O=j/2-g[w]/2+N,B=va(A,O,$),L=!l.arrow&&Ur(s)!=null&&O!==B&&a.reference[w]/2-(O<A?R:M)-g[w]/2<0,I=L?O<A?O-A:O-$:0;return{[p]:h[p]+I,data:{[p]:B,centerOffset:O-B-I,...L&&{alignmentOffset:I}},reset:L}}}),dh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:s,middlewareData:a,rects:i,initialPlacement:c,platform:l,elements:u}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:g=!0,...y}=Yt(e,t);if((r=a.arrow)!=null&&r.alignmentOffset)return{};const x=Gt(s),v=Tt(c),_=Gt(c)===c,b=await(l.isRTL==null?void 0:l.isRTL(u.floating)),S=h||(_||!g?[rs(c)]:nh(c)),C=w!=="none";!h&&C&&S.push(...ih(c,g,w,b));const j=[c,...S],N=await fn(t,y),E=[];let R=((n=a.flip)==null?void 0:n.overflows)||[];if(f&&E.push(N[x]),d){const O=rh(s,i,b);E.push(N[O[0]],N[O[1]])}if(R=[...R,{placement:s,overflows:E}],!E.every(O=>O<=0)){var M,A;const O=(((M=a.flip)==null?void 0:M.index)||0)+1,B=j[O];if(B&&(!(d==="alignment"?v!==Tt(B):!1)||R.every(P=>Tt(P.placement)===v?P.overflows[0]>0:!0)))return{data:{index:O,overflows:R},reset:{placement:B}};let L=(A=R.filter(I=>I.overflows[0]<=0).sort((I,P)=>I.overflows[1]-P.overflows[1])[0])==null?void 0:A.placement;if(!L)switch(p){case"bestFit":{var $;const I=($=R.filter(P=>{if(C){const z=Tt(P.placement);return z===v||z==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(z=>z>0).reduce((z,H)=>z+H,0)]).sort((P,z)=>P[1]-z[1])[0])==null?void 0:$[0];I&&(L=I);break}case"initialPlacement":L=c;break}if(s!==L)return{reset:{placement:L}}}return{}}}};function hi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function mi(e){return Jf.some(t=>e[t]>=0)}const fh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:n="referenceHidden",...s}=Yt(e,t);switch(n){case"referenceHidden":{const a=await fn(t,{...s,elementContext:"reference"}),i=hi(a,r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:mi(i)}}}case"escaped":{const a=await fn(t,{...s,altBoundary:!0}),i=hi(a,r.floating);return{data:{escapedOffsets:i,escaped:mi(i)}}}default:return{}}}}},Oc=new Set(["left","top"]);async function hh(e,t){const{placement:r,platform:n,elements:s}=e,a=await(n.isRTL==null?void 0:n.isRTL(s.floating)),i=Gt(r),c=Ur(r),l=Tt(r)==="y",u=Oc.has(i)?-1:1,f=a&&l?-1:1,d=Yt(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof w=="number"&&(p=c==="end"?w*-1:w),l?{x:p*f,y:h*u}:{x:h*u,y:p*f}}const mh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:s,y:a,placement:i,middlewareData:c}=t,l=await hh(t,e);return i===((r=c.offset)==null?void 0:r.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:s+l.x,y:a+l.y,data:{...l,placement:i}}}}},ph=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:y=>{let{x,y:v}=y;return{x,y:v}}},...l}=Yt(e,t),u={x:r,y:n},f=await fn(t,l),d=Tt(Gt(s)),h=Wa(d);let p=u[h],w=u[d];if(a){const y=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=p+f[y],_=p-f[x];p=va(v,p,_)}if(i){const y=d==="y"?"top":"left",x=d==="y"?"bottom":"right",v=w+f[y],_=w-f[x];w=va(v,w,_)}const g=c.fn({...t,[h]:p,[d]:w});return{...g,data:{x:g.x-r,y:g.y-n,enabled:{[h]:a,[d]:i}}}}}},gh=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:s,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:l=!0,crossAxis:u=!0}=Yt(e,t),f={x:r,y:n},d=Tt(s),h=Wa(d);let p=f[h],w=f[d];const g=Yt(c,t),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const _=h==="y"?"height":"width",b=a.reference[h]-a.floating[_]+y.mainAxis,S=a.reference[h]+a.reference[_]-y.mainAxis;p<b?p=b:p>S&&(p=S)}if(u){var x,v;const _=h==="y"?"width":"height",b=Oc.has(Gt(s)),S=a.reference[d]-a.floating[_]+(b&&((x=i.offset)==null?void 0:x[d])||0)+(b?0:y.crossAxis),C=a.reference[d]+a.reference[_]+(b?0:((v=i.offset)==null?void 0:v[d])||0)-(b?y.crossAxis:0);w<S?w=S:w>C&&(w=C)}return{[h]:p,[d]:w}}}},vh=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:s,rects:a,platform:i,elements:c}=t,{apply:l=()=>{},...u}=Yt(e,t),f=await fn(t,u),d=Gt(s),h=Ur(s),p=Tt(s)==="y",{width:w,height:g}=a.floating;let y,x;d==="top"||d==="bottom"?(y=d,x=h===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(x=d,y=h==="end"?"top":"bottom");const v=g-f.top-f.bottom,_=w-f.left-f.right,b=lr(g-f[y],v),S=lr(w-f[x],_),C=!t.middlewareData.shift;let j=b,N=S;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(N=_),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(j=v),C&&!h){const R=st(f.left,0),M=st(f.right,0),A=st(f.top,0),$=st(f.bottom,0);p?N=w-2*(R!==0||M!==0?R+M:st(f.left,f.right)):j=g-2*(A!==0||$!==0?A+$:st(f.top,f.bottom))}await l({...t,availableWidth:N,availableHeight:j});const E=await i.getDimensions(c.floating);return w!==E.width||g!==E.height?{reset:{rects:!0}}:{}}}};function ws(){return typeof window<"u"}function Zr(e){return Ic(e)?(e.nodeName||"").toLowerCase():"#document"}function it(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Vt(e){var t;return(t=(Ic(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ic(e){return ws()?e instanceof Node||e instanceof it(e).Node:!1}function bt(e){return ws()?e instanceof Element||e instanceof it(e).Element:!1}function Lt(e){return ws()?e instanceof HTMLElement||e instanceof it(e).HTMLElement:!1}function pi(e){return!ws()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof it(e).ShadowRoot}const yh=new Set(["inline","contents"]);function xn(e){const{overflow:t,overflowX:r,overflowY:n,display:s}=wt(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!yh.has(s)}const xh=new Set(["table","td","th"]);function bh(e){return xh.has(Zr(e))}const wh=[":popover-open",":modal"];function _s(e){return wh.some(t=>{try{return e.matches(t)}catch{return!1}})}const _h=["transform","translate","scale","rotate","perspective"],Sh=["transform","translate","scale","rotate","perspective","filter"],kh=["paint","layout","strict","content"];function Ya(e){const t=Ga(),r=bt(e)?wt(e):e;return _h.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||Sh.some(n=>(r.willChange||"").includes(n))||kh.some(n=>(r.contain||"").includes(n))}function Ch(e){let t=ur(e);for(;Lt(t)&&!Br(t);){if(Ya(t))return t;if(_s(t))return null;t=ur(t)}return null}function Ga(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jh=new Set(["html","body","#document"]);function Br(e){return jh.has(Zr(e))}function wt(e){return it(e).getComputedStyle(e)}function Ss(e){return bt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ur(e){if(Zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pi(e)&&e.host||Vt(e);return pi(t)?t.host:t}function $c(e){const t=ur(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:Lt(t)&&xn(t)?t:$c(t)}function hn(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const s=$c(e),a=s===((n=e.ownerDocument)==null?void 0:n.body),i=it(s);if(a){const c=xa(i);return t.concat(i,i.visualViewport||[],xn(s)?s:[],c&&r?hn(c):[])}return t.concat(s,hn(s,[],r))}function xa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fc(e){const t=wt(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const s=Lt(e),a=s?e.offsetWidth:r,i=s?e.offsetHeight:n,c=ts(r)!==a||ts(n)!==i;return c&&(r=a,n=i),{width:r,height:n,$:c}}function qa(e){return bt(e)?e:e.contextElement}function Mr(e){const t=qa(e);if(!Lt(t))return $t(1);const r=t.getBoundingClientRect(),{width:n,height:s,$:a}=Fc(t);let i=(a?ts(r.width):r.width)/n,c=(a?ts(r.height):r.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Dh=$t(0);function Lc(e){const t=it(e);return!Ga()||!t.visualViewport?Dh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Nh(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==it(e)?!1:t}function br(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const s=e.getBoundingClientRect(),a=qa(e);let i=$t(1);t&&(n?bt(n)&&(i=Mr(n)):i=Mr(e));const c=Nh(a,r,n)?Lc(a):$t(0);let l=(s.left+c.x)/i.x,u=(s.top+c.y)/i.y,f=s.width/i.x,d=s.height/i.y;if(a){const h=it(a),p=n&&bt(n)?it(n):n;let w=h,g=xa(w);for(;g&&n&&p!==w;){const y=Mr(g),x=g.getBoundingClientRect(),v=wt(g),_=x.left+(g.clientLeft+parseFloat(v.paddingLeft))*y.x,b=x.top+(g.clientTop+parseFloat(v.paddingTop))*y.y;l*=y.x,u*=y.y,f*=y.x,d*=y.y,l+=_,u+=b,w=it(g),g=xa(w)}}return ns({width:f,height:d,x:l,y:u})}function ks(e,t){const r=Ss(e).scrollLeft;return t?t.left+r:br(Vt(e)).left+r}function Vc(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-ks(e,r),s=r.top+t.scrollTop;return{x:n,y:s}}function Eh(e){let{elements:t,rect:r,offsetParent:n,strategy:s}=e;const a=s==="fixed",i=Vt(n),c=t?_s(t.floating):!1;if(n===i||c&&a)return r;let l={scrollLeft:0,scrollTop:0},u=$t(1);const f=$t(0),d=Lt(n);if((d||!d&&!a)&&((Zr(n)!=="body"||xn(i))&&(l=Ss(n)),Lt(n))){const p=br(n);u=Mr(n),f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}const h=i&&!d&&!a?Vc(i,l):$t(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+f.x+h.x,y:r.y*u.y-l.scrollTop*u.y+f.y+h.y}}function Ah(e){return Array.from(e.getClientRects())}function Th(e){const t=Vt(e),r=Ss(e),n=e.ownerDocument.body,s=st(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),a=st(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+ks(e);const c=-r.scrollTop;return wt(n).direction==="rtl"&&(i+=st(t.clientWidth,n.clientWidth)-s),{width:s,height:a,x:i,y:c}}const gi=25;function Rh(e,t){const r=it(e),n=Vt(e),s=r.visualViewport;let a=n.clientWidth,i=n.clientHeight,c=0,l=0;if(s){a=s.width,i=s.height;const f=Ga();(!f||f&&t==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}const u=ks(n);if(u<=0){const f=n.ownerDocument,d=f.body,h=getComputedStyle(d),p=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,w=Math.abs(n.clientWidth-d.clientWidth-p);w<=gi&&(a-=w)}else u<=gi&&(a+=u);return{width:a,height:i,x:c,y:l}}const Ph=new Set(["absolute","fixed"]);function Mh(e,t){const r=br(e,!0,t==="fixed"),n=r.top+e.clientTop,s=r.left+e.clientLeft,a=Lt(e)?Mr(e):$t(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,l=s*a.x,u=n*a.y;return{width:i,height:c,x:l,y:u}}function vi(e,t,r){let n;if(t==="viewport")n=Rh(e,r);else if(t==="document")n=Th(Vt(e));else if(bt(t))n=Mh(t,r);else{const s=Lc(e);n={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return ns(n)}function zc(e,t){const r=ur(e);return r===t||!bt(r)||Br(r)?!1:wt(r).position==="fixed"||zc(r,t)}function Oh(e,t){const r=t.get(e);if(r)return r;let n=hn(e,[],!1).filter(c=>bt(c)&&Zr(c)!=="body"),s=null;const a=wt(e).position==="fixed";let i=a?ur(e):e;for(;bt(i)&&!Br(i);){const c=wt(i),l=Ya(i);!l&&c.position==="fixed"&&(s=null),(a?!l&&!s:!l&&c.position==="static"&&!!s&&Ph.has(s.position)||xn(i)&&!l&&zc(e,i))?n=n.filter(f=>f!==i):s=c,i=ur(i)}return t.set(e,n),n}function Ih(e){let{element:t,boundary:r,rootBoundary:n,strategy:s}=e;const i=[...r==="clippingAncestors"?_s(t)?[]:Oh(t,this._c):[].concat(r),n],c=i[0],l=i.reduce((u,f)=>{const d=vi(t,f,s);return u.top=st(d.top,u.top),u.right=lr(d.right,u.right),u.bottom=lr(d.bottom,u.bottom),u.left=st(d.left,u.left),u},vi(t,c,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function $h(e){const{width:t,height:r}=Fc(e);return{width:t,height:r}}function Fh(e,t,r){const n=Lt(t),s=Vt(t),a=r==="fixed",i=br(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=$t(0);function u(){l.x=ks(s)}if(n||!n&&!a)if((Zr(t)!=="body"||xn(s))&&(c=Ss(t)),n){const p=br(t,!0,a,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else s&&u();a&&!n&&s&&u();const f=s&&!n&&!a?Vc(s,c):$t(0),d=i.left+c.scrollLeft-l.x-f.x,h=i.top+c.scrollTop-l.y-f.y;return{x:d,y:h,width:i.width,height:i.height}}function Zs(e){return wt(e).position==="static"}function yi(e,t){if(!Lt(e)||wt(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Vt(e)===r&&(r=r.ownerDocument.body),r}function Hc(e,t){const r=it(e);if(_s(e))return r;if(!Lt(e)){let s=ur(e);for(;s&&!Br(s);){if(bt(s)&&!Zs(s))return s;s=ur(s)}return r}let n=yi(e,t);for(;n&&bh(n)&&Zs(n);)n=yi(n,t);return n&&Br(n)&&Zs(n)&&!Ya(n)?r:n||Ch(e)||r}const Lh=async function(e){const t=this.getOffsetParent||Hc,r=this.getDimensions,n=await r(e.floating);return{reference:Fh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Vh(e){return wt(e).direction==="rtl"}const zh={convertOffsetParentRelativeRectToViewportRelativeRect:Eh,getDocumentElement:Vt,getClippingRect:Ih,getOffsetParent:Hc,getElementRects:Lh,getClientRects:Ah,getDimensions:$h,getScale:Mr,isElement:bt,isRTL:Vh};function Bc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Hh(e,t){let r=null,n;const s=Vt(e);function a(){var c;clearTimeout(n),(c=r)==null||c.disconnect(),r=null}function i(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),a();const u=e.getBoundingClientRect(),{left:f,top:d,width:h,height:p}=u;if(c||t(),!h||!p)return;const w=Pn(d),g=Pn(s.clientWidth-(f+h)),y=Pn(s.clientHeight-(d+p)),x=Pn(f),_={rootMargin:-w+"px "+-g+"px "+-y+"px "+-x+"px",threshold:st(0,lr(1,l))||1};let b=!0;function S(C){const j=C[0].intersectionRatio;if(j!==l){if(!b)return i();j?i(!1,j):n=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!Bc(u,e.getBoundingClientRect())&&i(),b=!1}try{r=new IntersectionObserver(S,{..._,root:s.ownerDocument})}catch{r=new IntersectionObserver(S,_)}r.observe(e)}return i(!0),a}function Bh(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=n,u=qa(e),f=s||a?[...u?hn(u):[],...hn(t)]:[];f.forEach(x=>{s&&x.addEventListener("scroll",r,{passive:!0}),a&&x.addEventListener("resize",r)});const d=u&&c?Hh(u,r):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var _;(_=p)==null||_.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let w,g=l?br(e):null;l&&y();function y(){const x=br(e);g&&!Bc(g,x)&&r(),g=x,w=requestAnimationFrame(y)}return r(),()=>{var x;f.forEach(v=>{s&&v.removeEventListener("scroll",r),a&&v.removeEventListener("resize",r)}),d?.(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const Wh=mh,Uh=ph,Zh=dh,Yh=vh,Gh=fh,xi=uh,qh=gh,Xh=(e,t,r)=>{const n=new Map,s={platform:zh,...r},a={...s.platform,_c:n};return lh(e,t,{...s,platform:a})};var Kh=typeof document<"u",Jh=function(){},Vn=Kh?m.useLayoutEffect:Jh;function ss(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!ss(e[n],t[n]))return!1;return!0}if(s=Object.keys(e),r=s.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,s[n]))return!1;for(n=r;n--!==0;){const a=s[n];if(!(a==="_owner"&&e.$$typeof)&&!ss(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Wc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bi(e,t){const r=Wc(e);return Math.round(t*r)/r}function Ys(e){const t=k.useRef(e);return Vn(()=>{t.current=e}),t}function Qh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[f,d]=k.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=k.useState(n);ss(h,n)||p(n);const[w,g]=k.useState(null),[y,x]=k.useState(null),v=k.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),_=k.useCallback(P=>{P!==j.current&&(j.current=P,x(P))},[]),b=a||w,S=i||y,C=k.useRef(null),j=k.useRef(null),N=k.useRef(f),E=l!=null,R=Ys(l),M=Ys(s),A=Ys(u),$=k.useCallback(()=>{if(!C.current||!j.current)return;const P={placement:t,strategy:r,middleware:h};M.current&&(P.platform=M.current),Xh(C.current,j.current,P).then(z=>{const H={...z,isPositioned:A.current!==!1};O.current&&!ss(N.current,H)&&(N.current=H,Xi.flushSync(()=>{d(H)}))})},[h,t,r,M,A]);Vn(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(P=>({...P,isPositioned:!1})))},[u]);const O=k.useRef(!1);Vn(()=>(O.current=!0,()=>{O.current=!1}),[]),Vn(()=>{if(b&&(C.current=b),S&&(j.current=S),b&&S){if(R.current)return R.current(b,S,$);$()}},[b,S,$,R,E]);const B=k.useMemo(()=>({reference:C,floating:j,setReference:v,setFloating:_}),[v,_]),L=k.useMemo(()=>({reference:b,floating:S}),[b,S]),I=k.useMemo(()=>{const P={position:r,left:0,top:0};if(!L.floating)return P;const z=bi(L.floating,f.x),H=bi(L.floating,f.y);return c?{...P,transform:"translate("+z+"px, "+H+"px)",...Wc(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:z,top:H}},[r,c,L.floating,f.x,f.y]);return k.useMemo(()=>({...f,update:$,refs:B,elements:L,floatingStyles:I}),[f,$,B,L,I])}const em=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:s}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?xi({element:n.current,padding:s}).fn(r):{}:n?xi({element:n,padding:s}).fn(r):{}}}},tm=(e,t)=>({...Wh(e),options:[e,t]}),rm=(e,t)=>({...Uh(e),options:[e,t]}),nm=(e,t)=>({...qh(e),options:[e,t]}),sm=(e,t)=>({...Zh(e),options:[e,t]}),am=(e,t)=>({...Yh(e),options:[e,t]}),om=(e,t)=>({...Gh(e),options:[e,t]}),im=(e,t)=>({...em(e),options:[e,t]});var cm="Arrow",Uc=k.forwardRef((e,t)=>{const{children:r,width:n=10,height:s=5,...a}=e;return o.jsx(Ie.svg,{...a,ref:t,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});Uc.displayName=cm;var lm=Uc,Xa="Popper",[Zc,Yc]=xs(Xa),[um,Gc]=Zc(Xa),qc=e=>{const{__scopePopper:t,children:r}=e,[n,s]=k.useState(null);return o.jsx(um,{scope:t,anchor:n,onAnchorChange:s,children:r})};qc.displayName=Xa;var Xc="PopperAnchor",Kc=k.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...s}=e,a=Gc(Xc,r),i=k.useRef(null),c=ct(t,i),l=k.useRef(null);return k.useEffect(()=>{const u=l.current;l.current=n?.current||i.current,u!==l.current&&a.onAnchorChange(l.current)}),n?null:o.jsx(Ie.div,{...s,ref:c})});Kc.displayName=Xc;var Ka="PopperContent",[dm,fm]=Zc(Ka),Jc=k.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:w,...g}=e,y=Gc(Ka,r),[x,v]=k.useState(null),_=ct(t,fe=>v(fe)),[b,S]=k.useState(null),C=xc(b),j=C?.width??0,N=C?.height??0,E=n+(a!=="center"?"-"+a:""),R=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},M=Array.isArray(u)?u:[u],A=M.length>0,$={padding:R,boundary:M.filter(mm),altBoundary:A},{refs:O,floatingStyles:B,placement:L,isPositioned:I,middlewareData:P}=Qh({strategy:"fixed",placement:E,whileElementsMounted:(...fe)=>Bh(...fe,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[tm({mainAxis:s+N,alignmentAxis:i}),l&&rm({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?nm():void 0,...$}),l&&sm({...$}),am({...$,apply:({elements:fe,rects:pe,availableWidth:Ae,availableHeight:xe})=>{const{width:Ze,height:Ye}=pe.reference,Xe=fe.floating.style;Xe.setProperty("--radix-popper-available-width",`${Ae}px`),Xe.setProperty("--radix-popper-available-height",`${xe}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ze}px`),Xe.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),b&&im({element:b,padding:c}),pm({arrowWidth:j,arrowHeight:N}),h&&om({strategy:"referenceHidden",...$})]}),[z,H]=tl(L),te=Hr(w);cr(()=>{I&&te?.()},[I,te]);const G=P.arrow?.x,V=P.arrow?.y,W=P.arrow?.centerOffset!==0,[se,ne]=k.useState();return cr(()=>{x&&ne(window.getComputedStyle(x).zIndex)},[x]),o.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:I?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(" "),...P.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(dm,{scope:r,placedSide:z,onArrowChange:S,arrowX:G,arrowY:V,shouldHideArrow:W,children:o.jsx(Ie.div,{"data-side":z,"data-align":H,...g,ref:_,style:{...g.style,animation:I?void 0:"none"}})})})});Jc.displayName=Ka;var Qc="PopperArrow",hm={top:"bottom",right:"left",bottom:"top",left:"right"},el=k.forwardRef(function(t,r){const{__scopePopper:n,...s}=t,a=fm(Qc,n),i=hm[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(lm,{...s,ref:r,style:{...s.style,display:"block"}})})});el.displayName=Qc;function mm(e){return e!==null}var pm=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:s}=t,i=s.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,f]=tl(r),d={start:"0%",center:"50%",end:"100%"}[f],h=(s.arrow?.x??0)+c/2,p=(s.arrow?.y??0)+l/2;let w="",g="";return u==="bottom"?(w=i?d:`${h}px`,g=`${-l}px`):u==="top"?(w=i?d:`${h}px`,g=`${n.floating.height+l}px`):u==="right"?(w=`${-l}px`,g=i?d:`${p}px`):u==="left"&&(w=`${n.floating.width+l}px`,g=i?d:`${p}px`),{data:{x:w,y:g}}}});function tl(e){const[t,r="center"]=e.split("-");return[t,r]}var gm=qc,rl=Kc,vm=Jc,ym=el,xm="Portal",Ja=k.forwardRef((e,t)=>{const{container:r,...n}=e,[s,a]=k.useState(!1);cr(()=>a(!0),[]);const i=r||s&&globalThis?.document?.body;return i?mr.createPortal(o.jsx(Ie.div,{...n,ref:t}),i):null});Ja.displayName=xm;var bm=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Dr=new WeakMap,Mn=new WeakMap,On={},Gs=0,nl=function(e){return e&&(e.host||nl(e.parentNode))},wm=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=nl(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},_m=function(e,t,r,n){var s=wm(t,Array.isArray(e)?e:[e]);On[r]||(On[r]=new WeakMap);var a=On[r],i=[],c=new Set,l=new Set(s),u=function(d){!d||c.has(d)||(c.add(d),u(d.parentNode))};s.forEach(u);var f=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(c.has(h))f(h);else try{var p=h.getAttribute(n),w=p!==null&&p!=="false",g=(Dr.get(h)||0)+1,y=(a.get(h)||0)+1;Dr.set(h,g),a.set(h,y),i.push(h),g===1&&w&&Mn.set(h,!0),y===1&&h.setAttribute(r,"true"),w||h.setAttribute(n,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return f(t),c.clear(),Gs++,function(){i.forEach(function(d){var h=Dr.get(d)-1,p=a.get(d)-1;Dr.set(d,h),a.set(d,p),h||(Mn.has(d)||d.removeAttribute(n),Mn.delete(d)),p||d.removeAttribute(r)}),Gs--,Gs||(Dr=new WeakMap,Dr=new WeakMap,Mn=new WeakMap,On={})}},sl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),s=bm(e);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live], script"))),_m(n,s,r,"aria-hidden")):function(){return null}},Nt=function(){return Nt=Object.assign||function(t){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Nt.apply(this,arguments)};function al(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function Sm(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,a;n<s;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var zn="right-scroll-bar-position",Hn="width-before-scroll-bar",km="with-scroll-bars-hidden",Cm="--removed-body-scroll-bar-size";function qs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jm(e,t){var r=m.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var s=r.value;s!==n&&(r.value=n,r.callback(n,s))}}}})[0];return r.callback=t,r.facade}var Dm=typeof window<"u"?k.useLayoutEffect:k.useEffect,wi=new WeakMap;function Nm(e,t){var r=jm(null,function(n){return e.forEach(function(s){return qs(s,n)})});return Dm(function(){var n=wi.get(r);if(n){var s=new Set(n),a=new Set(e),i=r.current;s.forEach(function(c){a.has(c)||qs(c,null)}),a.forEach(function(c){s.has(c)||qs(c,i)})}wi.set(r,e)},[e]),r}function Em(e){return e}function Am(e,t){t===void 0&&(t=Em);var r=[],n=!1,s={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(a){var i=t(a,n);return r.push(i),function(){r=r.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(n=!0;r.length;){var i=r;r=[],i.forEach(a)}r={push:function(c){return a(c)},filter:function(){return r}}},assignMedium:function(a){n=!0;var i=[];if(r.length){var c=r;r=[],c.forEach(a),i=r}var l=function(){var f=i;i=[],f.forEach(a)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(f){i.push(f),u()},filter:function(f){return i=i.filter(f),r}}}};return s}function Tm(e){e===void 0&&(e={});var t=Am(null);return t.options=Nt({async:!0,ssr:!1},e),t}var ol=function(e){var t=e.sideCar,r=al(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return k.createElement(n,Nt({},r))};ol.isSideCarExport=!0;function Rm(e,t){return e.useMedium(t),ol}var il=Tm(),Xs=function(){},Cs=k.forwardRef(function(e,t){var r=k.useRef(null),n=k.useState({onScrollCapture:Xs,onWheelCapture:Xs,onTouchMoveCapture:Xs}),s=n[0],a=n[1],i=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,f=e.enabled,d=e.shards,h=e.sideCar,p=e.noRelative,w=e.noIsolation,g=e.inert,y=e.allowPinchZoom,x=e.as,v=x===void 0?"div":x,_=e.gapMode,b=al(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,C=Nm([r,t]),j=Nt(Nt({},b),s);return k.createElement(k.Fragment,null,f&&k.createElement(S,{sideCar:il,removeScrollBar:u,shards:d,noRelative:p,noIsolation:w,inert:g,setCallbacks:a,allowPinchZoom:!!y,lockRef:r,gapMode:_}),i?k.cloneElement(k.Children.only(c),Nt(Nt({},j),{ref:C})):k.createElement(v,Nt({},j,{className:l,ref:C}),c))});Cs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cs.classNames={fullWidth:Hn,zeroRight:zn};var Pm=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Mm(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Pm();return t&&e.setAttribute("nonce",t),e}function Om(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Im(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $m=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Mm())&&(Om(t,r),Im(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fm=function(){var e=$m();return function(t,r){k.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},cl=function(){var e=Fm(),t=function(r){var n=r.styles,s=r.dynamic;return e(n,s),null};return t},Lm={left:0,top:0,right:0,gap:0},Ks=function(e){return parseInt(e||"",10)||0},Vm=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[Ks(r),Ks(n),Ks(s)]},zm=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Lm;var t=Vm(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},Hm=cl(),Or="data-scroll-locked",Bm=function(e,t,r,n){var s=e.left,a=e.top,i=e.right,c=e.gap;return r===void 0&&(r="margin"),`
|
|
2
|
+
.`.concat(km,` {
|
|
3
3
|
overflow: hidden `).concat(n,`;
|
|
4
4
|
padding-right: `).concat(c,"px ").concat(n,`;
|
|
5
5
|
}
|
|
6
|
-
body[`).concat(
|
|
6
|
+
body[`).concat(Or,`] {
|
|
7
7
|
overflow: hidden `).concat(n,`;
|
|
8
8
|
overscroll-behavior: contain;
|
|
9
9
|
`).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&`
|
|
10
10
|
padding-left: `.concat(s,`px;
|
|
11
11
|
padding-top: `).concat(a,`px;
|
|
12
|
-
padding-right: `).concat(
|
|
12
|
+
padding-right: `).concat(i,`px;
|
|
13
13
|
margin-left:0;
|
|
14
14
|
margin-top:0;
|
|
15
15
|
margin-right: `).concat(c,"px ").concat(n,`;
|
|
16
16
|
`),r==="padding"&&"padding-right: ".concat(c,"px ").concat(n,";")].filter(Boolean).join(""),`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.`).concat(
|
|
19
|
+
.`).concat(zn,` {
|
|
20
20
|
right: `).concat(c,"px ").concat(n,`;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.`).concat(
|
|
23
|
+
.`).concat(Hn,` {
|
|
24
24
|
margin-right: `).concat(c,"px ").concat(n,`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.`).concat(
|
|
27
|
+
.`).concat(zn," .").concat(zn,` {
|
|
28
28
|
right: 0 `).concat(n,`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
.`).concat(
|
|
31
|
+
.`).concat(Hn," .").concat(Hn,` {
|
|
32
32
|
margin-right: 0 `).concat(n,`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
body[`).concat(
|
|
36
|
-
`).concat(
|
|
35
|
+
body[`).concat(Or,`] {
|
|
36
|
+
`).concat(Cm,": ").concat(c,`px;
|
|
37
37
|
}
|
|
38
|
-
`)},
|
|
38
|
+
`)},_i=function(){var e=parseInt(document.body.getAttribute(Or)||"0",10);return isFinite(e)?e:0},Wm=function(){k.useEffect(function(){return document.body.setAttribute(Or,(_i()+1).toString()),function(){var e=_i()-1;e<=0?document.body.removeAttribute(Or):document.body.setAttribute(Or,e.toString())}},[])},Um=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,s=n===void 0?"margin":n;Wm();var a=k.useMemo(function(){return zm(s)},[s]);return k.createElement(Hm,{styles:Bm(a,!t,s,r?"":"!important")})},ba=!1;if(typeof window<"u")try{var In=Object.defineProperty({},"passive",{get:function(){return ba=!0,!0}});window.addEventListener("test",In,In),window.removeEventListener("test",In,In)}catch{ba=!1}var Nr=ba?{passive:!1}:!1,Zm=function(e){return e.tagName==="TEXTAREA"},ll=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Zm(e)&&r[t]==="visible")},Ym=function(e){return ll(e,"overflowY")},Gm=function(e){return ll(e,"overflowX")},Si=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var s=ul(e,n);if(s){var a=dl(e,n),i=a[1],c=a[2];if(i>c)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},qm=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},Xm=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},ul=function(e,t){return e==="v"?Ym(t):Gm(t)},dl=function(e,t){return e==="v"?qm(t):Xm(t)},Km=function(e,t){return e==="h"&&t==="rtl"?-1:1},Jm=function(e,t,r,n,s){var a=Km(e,window.getComputedStyle(t).direction),i=a*n,c=r.target,l=t.contains(c),u=!1,f=i>0,d=0,h=0;do{if(!c)break;var p=dl(e,c),w=p[0],g=p[1],y=p[2],x=g-y-a*w;(w||x)&&ul(e,c)&&(d+=x,h+=w);var v=c.parentNode;c=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!l&&c!==document.body||l&&(t.contains(c)||t===c));return(f&&Math.abs(d)<1||!f&&Math.abs(h)<1)&&(u=!0),u},$n=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ki=function(e){return[e.deltaX,e.deltaY]},Ci=function(e){return e&&"current"in e?e.current:e},Qm=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ep=function(e){return`
|
|
39
39
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
40
40
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
41
|
-
`)},Ym=0,kr=[];function Gm(e){var t=S.useRef([]),r=S.useRef([0,0]),n=S.useRef(),s=S.useState(Ym++)[0],a=S.useState(Qc)[0],o=S.useRef(e);S.useEffect(function(){o.current=e},[e]),S.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var g=pm([e.lockRef.current],(e.shards||[]).map(wi),!0).filter(Boolean);return g.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var c=S.useCallback(function(g,y){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!o.current.allowPinchZoom;var v=In(g),b=r.current,C="deltaX"in g?g.deltaX:b[0]-v[0],x="deltaY"in g?g.deltaY:b[1]-v[1],_,k=g.target,j=Math.abs(C)>Math.abs(x)?"h":"v";if("touches"in g&&j==="h"&&k.type==="range")return!1;var E=window.getSelection(),A=E&&E.anchorNode,T=A?A===k||A.contains(k):!1;if(T)return!1;var M=xi(j,k);if(!M)return!0;if(M?_=j:(_=j==="v"?"h":"v",M=xi(j,k)),!M)return!1;if(!n.current&&"changedTouches"in g&&(C||x)&&(n.current=_),!_)return!0;var R=n.current||_;return Wm(R,y,g,R==="h"?C:x)},[]),l=S.useCallback(function(g){var y=g;if(!(!kr.length||kr[kr.length-1]!==a)){var v="deltaY"in y?bi(y):In(y),b=t.current.filter(function(_){return _.name===y.type&&(_.target===y.target||y.target===_.shadowParent)&&Um(_.delta,v)})[0];if(b&&b.should){y.cancelable&&y.preventDefault();return}if(!b){var C=(o.current.shards||[]).map(wi).filter(Boolean).filter(function(_){return _.contains(y.target)}),x=C.length>0?c(y,C[0]):!o.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),u=S.useCallback(function(g,y,v,b){var C={name:g,delta:y,target:v,should:b,shadowParent:qm(v)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(x){return x!==C})},1)},[]),f=S.useCallback(function(g){r.current=In(g),n.current=void 0},[]),d=S.useCallback(function(g){u(g.type,bi(g),g.target,c(g,e.lockRef.current))},[]),h=S.useCallback(function(g){u(g.type,In(g),g.target,c(g,e.lockRef.current))},[]);S.useEffect(function(){return kr.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Cr),document.addEventListener("touchmove",l,Cr),document.addEventListener("touchstart",f,Cr),function(){kr=kr.filter(function(g){return g!==a}),document.removeEventListener("wheel",l,Cr),document.removeEventListener("touchmove",l,Cr),document.removeEventListener("touchstart",f,Cr)}},[]);var p=e.removeScrollBar,w=e.inert;return S.createElement(S.Fragment,null,w?S.createElement(a,{styles:Zm(s)}):null,p?S.createElement(Fm,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function qm(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Xm=Cm(Jc,Gm);var qa=S.forwardRef(function(e,t){return S.createElement(Ss,Dt({},e,{ref:t,sideCar:Xm}))});qa.classNames=Ss.classNames;var Cs="Popover",[nl]=vs(Cs,[Lc]),xn=Lc(),[Km,ir]=nl(Cs),sl=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:s,onOpenChange:a,modal:o=!1}=e,c=xn(t),l=S.useRef(null),[u,f]=S.useState(!1),[d,h]=Pa({prop:n,defaultProp:s??!1,onChange:a,caller:Cs});return i.jsx(cm,{...c,children:i.jsx(Km,{scope:t,contentId:Ln(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:S.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>f(!0),[]),onCustomAnchorRemove:S.useCallback(()=>f(!1),[]),modal:o,children:r})})};sl.displayName=Cs;var al="PopoverAnchor",Jm=S.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=ir(al,r),a=xn(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:c}=s;return S.useEffect(()=>(o(),()=>c()),[o,c]),i.jsx(Yc,{...a,...n,ref:t})});Jm.displayName=al;var ol="PopoverTrigger",il=S.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=ir(ol,r),a=xn(r),o=it(t,s.triggerRef),c=i.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":fl(s.open),...n,ref:o,onClick:He(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?c:i.jsx(Yc,{asChild:!0,...a,children:c})});il.displayName=ol;var Xa="PopoverPortal",[Qm,ep]=nl(Xa,{forceMount:void 0}),cl=e=>{const{__scopePopover:t,forceMount:r,children:n,container:s}=e,a=ir(Xa,t);return i.jsx(Qm,{scope:t,forceMount:r,children:i.jsx(xr,{present:r||a.open,children:i.jsx(Ga,{asChild:!0,container:s,children:n})})})};cl.displayName=Xa;var Vr="PopoverContent",ll=S.forwardRef((e,t)=>{const r=ep(Vr,e.__scopePopover),{forceMount:n=r.forceMount,...s}=e,a=ir(Vr,e.__scopePopover);return i.jsx(xr,{present:n||a.open,children:a.modal?i.jsx(rp,{...s,ref:t}):i.jsx(np,{...s,ref:t})})});ll.displayName=Vr;var tp=Oa("PopoverContent.RemoveScroll"),rp=S.forwardRef((e,t)=>{const r=ir(Vr,e.__scopePopover),n=S.useRef(null),s=it(t,n),a=S.useRef(!1);return S.useEffect(()=>{const o=n.current;if(o)return qc(o)},[]),i.jsx(qa,{as:tp,allowPinchZoom:!0,children:i.jsx(ul,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(e.onCloseAutoFocus,o=>{o.preventDefault(),a.current||r.triggerRef.current?.focus()}),onPointerDownOutside:He(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,u=c.button===2||l;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:He(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),np=S.forwardRef((e,t)=>{const r=ir(Vr,e.__scopePopover),n=S.useRef(!1),s=S.useRef(!1);return i.jsx(ul,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(n.current||r.triggerRef.current?.focus(),a.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;r.triggerRef.current?.contains(o)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),ul=S.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:f,...d}=e,h=ir(Vr,r),p=xn(r);return Sc(),i.jsx($a,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:i.jsx(La,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:i.jsx(lm,{"data-state":fl(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),dl="PopoverClose",sp=S.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=ir(dl,r);return i.jsx(Ie.button,{type:"button",...n,ref:t,onClick:He(e.onClick,()=>s.onOpenChange(!1))})});sp.displayName=dl;var ap="PopoverArrow",op=S.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=xn(r);return i.jsx(um,{...s,...n,ref:t})});op.displayName=ap;function fl(e){return e?"open":"closed"}var ip=sl,cp=il,lp=cl,hl=ll;const up=ip,dp=cp,ml=S.forwardRef(({className:e,align:t="center",sideOffset:r=4,...n},s)=>i.jsx(lp,{children:i.jsx(hl,{ref:s,align:t,sideOffset:r,className:de("z-50 rounded-md border bg-popover p-[var(--ui-space-4)] text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-[var(--ui-space-2)] data-[side=left]:slide-in-from-right-[var(--ui-space-2)] data-[side=right]:slide-in-from-left-[var(--ui-space-2)] data-[side=top]:slide-in-from-bottom-[var(--ui-space-2)]",e),...n})}));ml.displayName=hl.displayName;function Ka(e){const{className:t,label:r,disabled:n,minDate:s,maxDate:a,monthsShown:o=1,selectsRange:c}=e,{t:l,i18n:u}=$e(),f=u.language?.startsWith("ja")?"ja-JP":"en-US",d=r??l("date_picker_label"),h=c?void 0:e.value??e.date,p=C=>{const x=C;c||(e.onChange&&e.onChange(x??null),e.setDate&&e.setDate(x))},w=c?{from:e.startDate??void 0,to:e.endDate??void 0}:void 0,g=C=>{const x=C;c&&e.onRangeChange&&e.onRangeChange([x?.from??null,x?.to??null])},y=[...s?[{before:s}]:[],...a?[{after:a}]:[]];let v=d;const b=c?!!w?.from:!!h;return c&&w?.from?(v=Ne(w.from,f,"picker"),w.to&&(v+=` - ${Ne(w.to,f,"picker")}`)):!c&&h&&(v=Ne(h,f,"picker")),i.jsxs(up,{children:[i.jsx(dp,{asChild:!0,children:i.jsxs(ie,{variant:"outline",disabled:n,className:de("w-full justify-start text-left font-normal",!b&&"opacity-70",t),children:[i.jsx(ye.Calendar,{className:"me-2 h-ui-icon w-ui-icon"}),v]})}),i.jsx(ml,{className:"w-auto p-[var(--ui-space-0)]",align:"start",children:c?i.jsx(Jo,{mode:"range",defaultMonth:w?.from,selected:w,onSelect:g,numberOfMonths:o,disabled:y,locale:f}):i.jsx(Jo,{mode:"single",selected:h,defaultMonth:h,onSelect:p,numberOfMonths:o,disabled:y,locale:f})})]})}const pl=S.forwardRef(({className:e,children:t,...r},n)=>i.jsx("label",{ref:n,className:de("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...r,children:t}));pl.displayName="Label";const Ja=qu,gl=S.createContext({}),Te=({...e})=>i.jsx(gl.Provider,{value:{name:e.name},children:i.jsx(Qu,{...e})}),ks=()=>{const e=S.useContext(gl),t=S.useContext(vl),{getFieldState:r,formState:n}=ps(),s=r(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...s}},vl=S.createContext({}),je=S.forwardRef(({className:e,...t},r)=>{const n=S.useId();return i.jsx(vl.Provider,{value:{id:n},children:i.jsx("div",{ref:r,className:de("space-y-[var(--ui-space-2)]",e),...t})})});je.displayName="FormItem";const we=S.forwardRef(({className:e,...t},r)=>{const{error:n,formItemId:s}=ks();return i.jsx(pl,{ref:r,className:de(n&&"text-destructive",e),htmlFor:s,...t})});we.displayName="FormLabel";const be=S.forwardRef(({...e},t)=>{const{error:r,formItemId:n,formDescriptionId:s,formMessageId:a}=ks();return i.jsx("div",{ref:t,id:n,"aria-describedby":r?`${s} ${a}`:`${s}`,"aria-invalid":!!r,...e})});be.displayName="FormControl";const nt=S.forwardRef(({className:e,children:t,...r},n)=>{const{error:s,formMessageId:a}=ks(),o=s?String(s?.message):t;return o?i.jsx("p",{ref:n,id:a,className:de("text-sm font-medium text-destructive",e),...r,children:o}):null});nt.displayName="FormMessage";var Ds="Dialog",[yl]=vs(Ds),[fp,wt]=yl(Ds),xl=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=e,c=S.useRef(null),l=S.useRef(null),[u,f]=Pa({prop:n,defaultProp:s??!1,onChange:a,caller:Ds});return i.jsx(fp,{scope:t,triggerRef:c,contentRef:l,contentId:Ln(),titleId:Ln(),descriptionId:Ln(),open:u,onOpenChange:f,onOpenToggle:S.useCallback(()=>f(d=>!d),[f]),modal:o,children:r})};xl.displayName=Ds;var bl="DialogTrigger",wl=S.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=wt(bl,r),a=it(t,s.triggerRef);return i.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":to(s.open),...n,ref:a,onClick:He(e.onClick,s.onOpenToggle)})});wl.displayName=bl;var Qa="DialogPortal",[hp,_l]=yl(Qa,{forceMount:void 0}),Sl=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:s}=e,a=wt(Qa,t);return i.jsx(hp,{scope:t,forceMount:r,children:S.Children.map(n,o=>i.jsx(xr,{present:r||a.open,children:i.jsx(Ga,{asChild:!0,container:s,children:o})}))})};Sl.displayName=Qa;var ss="DialogOverlay",Cl=S.forwardRef((e,t)=>{const r=_l(ss,e.__scopeDialog),{forceMount:n=r.forceMount,...s}=e,a=wt(ss,e.__scopeDialog);return a.modal?i.jsx(xr,{present:n||a.open,children:i.jsx(pp,{...s,ref:t})}):null});Cl.displayName=ss;var mp=Oa("DialogOverlay.RemoveScroll"),pp=S.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=wt(ss,r);return i.jsx(qa,{as:mp,allowPinchZoom:!0,shards:[s.contentRef],children:i.jsx(Ie.div,{"data-state":to(s.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),yr="DialogContent",kl=S.forwardRef((e,t)=>{const r=_l(yr,e.__scopeDialog),{forceMount:n=r.forceMount,...s}=e,a=wt(yr,e.__scopeDialog);return i.jsx(xr,{present:n||a.open,children:a.modal?i.jsx(gp,{...s,ref:t}):i.jsx(vp,{...s,ref:t})})});kl.displayName=yr;var gp=S.forwardRef((e,t)=>{const r=wt(yr,e.__scopeDialog),n=S.useRef(null),s=it(t,r.contentRef,n);return S.useEffect(()=>{const a=n.current;if(a)return qc(a)},[]),i.jsx(Dl,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(e.onCloseAutoFocus,a=>{a.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:He(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&a.preventDefault()}),onFocusOutside:He(e.onFocusOutside,a=>a.preventDefault())})}),vp=S.forwardRef((e,t)=>{const r=wt(yr,e.__scopeDialog),n=S.useRef(!1),s=S.useRef(!1);return i.jsx(Dl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(n.current||r.triggerRef.current?.focus(),a.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;r.triggerRef.current?.contains(o)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),Dl=S.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=e,c=wt(yr,r),l=S.useRef(null),u=it(t,l);return Sc(),i.jsxs(i.Fragment,{children:[i.jsx($a,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:i.jsx(La,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":to(c.open),...o,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(yp,{titleId:c.titleId}),i.jsx(bp,{contentRef:l,descriptionId:c.descriptionId})]})]})}),eo="DialogTitle",jl=S.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=wt(eo,r);return i.jsx(Ie.h2,{id:s.titleId,...n,ref:t})});jl.displayName=eo;var Nl="DialogDescription",El=S.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=wt(Nl,r);return i.jsx(Ie.p,{id:s.descriptionId,...n,ref:t})});El.displayName=Nl;var Al="DialogClose",Rl=S.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=wt(Al,r);return i.jsx(Ie.button,{type:"button",...n,ref:t,onClick:He(e.onClick,()=>s.onOpenChange(!1))})});Rl.displayName=Al;function to(e){return e?"open":"closed"}var Tl="DialogTitleWarning",[My,Pl]=ef(Tl,{contentName:yr,titleName:eo,docsSlug:"dialog"}),yp=({titleId:e})=>{const t=Pl(Tl),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
41
|
+
`)},tp=0,Er=[];function rp(e){var t=k.useRef([]),r=k.useRef([0,0]),n=k.useRef(),s=k.useState(tp++)[0],a=k.useState(cl)[0],i=k.useRef(e);k.useEffect(function(){i.current=e},[e]),k.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var g=Sm([e.lockRef.current],(e.shards||[]).map(Ci),!0).filter(Boolean);return g.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var c=k.useCallback(function(g,y){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var x=$n(g),v=r.current,_="deltaX"in g?g.deltaX:v[0]-x[0],b="deltaY"in g?g.deltaY:v[1]-x[1],S,C=g.target,j=Math.abs(_)>Math.abs(b)?"h":"v";if("touches"in g&&j==="h"&&C.type==="range")return!1;var N=window.getSelection(),E=N&&N.anchorNode,R=E?E===C||E.contains(C):!1;if(R)return!1;var M=Si(j,C);if(!M)return!0;if(M?S=j:(S=j==="v"?"h":"v",M=Si(j,C)),!M)return!1;if(!n.current&&"changedTouches"in g&&(_||b)&&(n.current=S),!S)return!0;var A=n.current||S;return Jm(A,y,g,A==="h"?_:b)},[]),l=k.useCallback(function(g){var y=g;if(!(!Er.length||Er[Er.length-1]!==a)){var x="deltaY"in y?ki(y):$n(y),v=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&Qm(S.delta,x)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var _=(i.current.shards||[]).map(Ci).filter(Boolean).filter(function(S){return S.contains(y.target)}),b=_.length>0?c(y,_[0]):!i.current.noIsolation;b&&y.cancelable&&y.preventDefault()}}},[]),u=k.useCallback(function(g,y,x,v){var _={name:g,delta:y,target:x,should:v,shadowParent:np(x)};t.current.push(_),setTimeout(function(){t.current=t.current.filter(function(b){return b!==_})},1)},[]),f=k.useCallback(function(g){r.current=$n(g),n.current=void 0},[]),d=k.useCallback(function(g){u(g.type,ki(g),g.target,c(g,e.lockRef.current))},[]),h=k.useCallback(function(g){u(g.type,$n(g),g.target,c(g,e.lockRef.current))},[]);k.useEffect(function(){return Er.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",f,Nr),function(){Er=Er.filter(function(g){return g!==a}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",f,Nr)}},[]);var p=e.removeScrollBar,w=e.inert;return k.createElement(k.Fragment,null,w?k.createElement(a,{styles:ep(s)}):null,p?k.createElement(Um,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function np(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const sp=Rm(il,rp);var Qa=k.forwardRef(function(e,t){return k.createElement(Cs,Nt({},e,{ref:t,sideCar:sp}))});Qa.classNames=Cs.classNames;var js="Popover",[fl]=xs(js,[Yc]),bn=Yc(),[ap,dr]=fl(js),hl=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:s,onOpenChange:a,modal:i=!1}=e,c=bn(t),l=k.useRef(null),[u,f]=k.useState(!1),[d,h]=$a({prop:n,defaultProp:s??!1,onChange:a,caller:js});return o.jsx(gm,{...c,children:o.jsx(ap,{scope:t,contentId:Ln(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:k.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:u,onCustomAnchorAdd:k.useCallback(()=>f(!0),[]),onCustomAnchorRemove:k.useCallback(()=>f(!1),[]),modal:i,children:r})})};hl.displayName=js;var ml="PopoverAnchor",op=k.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=dr(ml,r),a=bn(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:c}=s;return k.useEffect(()=>(i(),()=>c()),[i,c]),o.jsx(rl,{...a,...n,ref:t})});op.displayName=ml;var pl="PopoverTrigger",gl=k.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=dr(pl,r),a=bn(r),i=ct(t,s.triggerRef),c=o.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":wl(s.open),...n,ref:i,onClick:Be(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?c:o.jsx(rl,{asChild:!0,...a,children:c})});gl.displayName=pl;var eo="PopoverPortal",[ip,cp]=fl(eo,{forceMount:void 0}),vl=e=>{const{__scopePopover:t,forceMount:r,children:n,container:s}=e,a=dr(eo,t);return o.jsx(ip,{scope:t,forceMount:r,children:o.jsx(Sr,{present:r||a.open,children:o.jsx(Ja,{asChild:!0,container:s,children:n})})})};vl.displayName=eo;var Wr="PopoverContent",yl=k.forwardRef((e,t)=>{const r=cp(Wr,e.__scopePopover),{forceMount:n=r.forceMount,...s}=e,a=dr(Wr,e.__scopePopover);return o.jsx(Sr,{present:n||a.open,children:a.modal?o.jsx(up,{...s,ref:t}):o.jsx(dp,{...s,ref:t})})});yl.displayName=Wr;var lp=Fa("PopoverContent.RemoveScroll"),up=k.forwardRef((e,t)=>{const r=dr(Wr,e.__scopePopover),n=k.useRef(null),s=ct(t,n),a=k.useRef(!1);return k.useEffect(()=>{const i=n.current;if(i)return sl(i)},[]),o.jsx(Qa,{as:lp,allowPinchZoom:!0,children:o.jsx(xl,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Be(e.onCloseAutoFocus,i=>{i.preventDefault(),a.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Be(e.onPointerDownOutside,i=>{const c=i.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,u=c.button===2||l;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Be(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),dp=k.forwardRef((e,t)=>{const r=dr(Wr,e.__scopePopover),n=k.useRef(!1),s=k.useRef(!1);return o.jsx(xl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(n.current||r.triggerRef.current?.focus(),a.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;r.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),xl=k.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:f,...d}=e,h=dr(Wr,r),p=bn(r);return Rc(),o.jsx(Ba,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:o.jsx(vm,{"data-state":wl(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),bl="PopoverClose",fp=k.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=dr(bl,r);return o.jsx(Ie.button,{type:"button",...n,ref:t,onClick:Be(e.onClick,()=>s.onOpenChange(!1))})});fp.displayName=bl;var hp="PopoverArrow",mp=k.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,s=bn(r);return o.jsx(ym,{...s,...n,ref:t})});mp.displayName=hp;function wl(e){return e?"open":"closed"}var pp=hl,gp=gl,vp=vl,_l=yl;const yp=pp,xp=gp,Sl=k.forwardRef(({className:e,align:t="center",sideOffset:r=4,...n},s)=>o.jsx(vp,{children:o.jsx(_l,{ref:s,align:t,sideOffset:r,className:de("z-[100] rounded-md border bg-popover p-[var(--ui-space-4)] text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-[var(--ui-space-2)] data-[side=left]:slide-in-from-right-[var(--ui-space-2)] data-[side=right]:slide-in-from-left-[var(--ui-space-2)] data-[side=top]:slide-in-from-bottom-[var(--ui-space-2)]",e),...n})}));Sl.displayName=_l.displayName;function to(e){const{className:t,label:r,disabled:n,minDate:s,maxDate:a,monthsShown:i=1,selectsRange:c}=e,{t:l,i18n:u}=Le(),f=u.language?.startsWith("ja")?"ja-JP":"en-US",d=r??l("date_picker_label"),h=c?void 0:e.value??e.date,p=_=>{const b=_;c||(e.onChange&&e.onChange(b??null),e.setDate&&e.setDate(b))},w=c?{from:e.startDate??void 0,to:e.endDate??void 0}:void 0,g=_=>{const b=_;c&&e.onRangeChange&&e.onRangeChange([b?.from??null,b?.to??null])},y=[...s?[{before:s}]:[],...a?[{after:a}]:[]];let x=d;const v=c?!!w?.from:!!h;return c&&w?.from?(x=Ne(w.from,f,"picker"),w.to&&(x+=` - ${Ne(w.to,f,"picker")}`)):!c&&h&&(x=Ne(h,f,"picker")),o.jsxs(yp,{modal:!0,children:[o.jsx(xp,{asChild:!0,children:o.jsxs(oe,{variant:"outline",disabled:n,className:de("w-full justify-start text-left font-normal",!v&&"opacity-70",t),children:[o.jsx(ye.Calendar,{className:"me-2 h-ui-icon w-ui-icon"}),x]})}),o.jsx(Sl,{className:"w-auto p-[var(--ui-space-0)]",align:"start",children:c?o.jsx(ri,{mode:"range",defaultMonth:w?.from,selected:w,onSelect:g,numberOfMonths:i,disabled:y,locale:f}):o.jsx(ri,{mode:"single",selected:h,defaultMonth:h,onSelect:p,numberOfMonths:i,disabled:y,locale:f})})]})}const kl=k.forwardRef(({className:e,children:t,...r},n)=>o.jsx("label",{ref:n,className:de("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...r,children:t}));kl.displayName="Label";const ro=nd,Cl=k.createContext({}),Re=({...e})=>o.jsx(Cl.Provider,{value:{name:e.name},children:o.jsx(id,{...e})}),Ds=()=>{const e=k.useContext(Cl),t=k.useContext(jl),{getFieldState:r,formState:n}=vs(),s=r(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...s}},jl=k.createContext({}),De=k.forwardRef(({className:e,...t},r)=>{const n=k.useId();return o.jsx(jl.Provider,{value:{id:n},children:o.jsx("div",{ref:r,className:de("space-y-[var(--ui-space-2)]",e),...t})})});De.displayName="FormItem";const _e=k.forwardRef(({className:e,...t},r)=>{const{error:n,formItemId:s}=Ds();return o.jsx(kl,{ref:r,className:de(n&&"text-destructive",e),htmlFor:s,...t})});_e.displayName="FormLabel";const be=k.forwardRef(({...e},t)=>{const{error:r,formItemId:n,formDescriptionId:s,formMessageId:a}=Ds();return o.jsx("div",{ref:t,id:n,"aria-describedby":r?`${s} ${a}`:`${s}`,"aria-invalid":!!r,...e})});be.displayName="FormControl";const nt=k.forwardRef(({className:e,children:t,...r},n)=>{const{error:s,formMessageId:a}=Ds(),i=s?String(s?.message):t;return i?o.jsx("p",{ref:n,id:a,className:de("text-sm font-medium text-destructive",e),...r,children:i}):null});nt.displayName="FormMessage";var Ns="Dialog",[Dl]=xs(Ns),[bp,St]=Dl(Ns),Nl=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,c=k.useRef(null),l=k.useRef(null),[u,f]=$a({prop:n,defaultProp:s??!1,onChange:a,caller:Ns});return o.jsx(bp,{scope:t,triggerRef:c,contentRef:l,contentId:Ln(),titleId:Ln(),descriptionId:Ln(),open:u,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(d=>!d),[f]),modal:i,children:r})};Nl.displayName=Ns;var El="DialogTrigger",Al=k.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=St(El,r),a=ct(t,s.triggerRef);return o.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":ao(s.open),...n,ref:a,onClick:Be(e.onClick,s.onOpenToggle)})});Al.displayName=El;var no="DialogPortal",[wp,Tl]=Dl(no,{forceMount:void 0}),Rl=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:s}=e,a=St(no,t);return o.jsx(wp,{scope:t,forceMount:r,children:k.Children.map(n,i=>o.jsx(Sr,{present:r||a.open,children:o.jsx(Ja,{asChild:!0,container:s,children:i})}))})};Rl.displayName=no;var as="DialogOverlay",Pl=k.forwardRef((e,t)=>{const r=Tl(as,e.__scopeDialog),{forceMount:n=r.forceMount,...s}=e,a=St(as,e.__scopeDialog);return a.modal?o.jsx(Sr,{present:n||a.open,children:o.jsx(Sp,{...s,ref:t})}):null});Pl.displayName=as;var _p=Fa("DialogOverlay.RemoveScroll"),Sp=k.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=St(as,r);return o.jsx(Qa,{as:_p,allowPinchZoom:!0,shards:[s.contentRef],children:o.jsx(Ie.div,{"data-state":ao(s.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),wr="DialogContent",Ml=k.forwardRef((e,t)=>{const r=Tl(wr,e.__scopeDialog),{forceMount:n=r.forceMount,...s}=e,a=St(wr,e.__scopeDialog);return o.jsx(Sr,{present:n||a.open,children:a.modal?o.jsx(kp,{...s,ref:t}):o.jsx(Cp,{...s,ref:t})})});Ml.displayName=wr;var kp=k.forwardRef((e,t)=>{const r=St(wr,e.__scopeDialog),n=k.useRef(null),s=ct(t,r.contentRef,n);return k.useEffect(()=>{const a=n.current;if(a)return sl(a)},[]),o.jsx(Ol,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Be(e.onCloseAutoFocus,a=>{a.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Be(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:Be(e.onFocusOutside,a=>a.preventDefault())})}),Cp=k.forwardRef((e,t)=>{const r=St(wr,e.__scopeDialog),n=k.useRef(!1),s=k.useRef(!1);return o.jsx(Ol,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(n.current||r.triggerRef.current?.focus(),a.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;r.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),Ol=k.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,c=St(wr,r),l=k.useRef(null),u=ct(t,l);return Rc(),o.jsxs(o.Fragment,{children:[o.jsx(Ba,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(Ha,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ao(c.open),...i,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(jp,{titleId:c.titleId}),o.jsx(Np,{contentRef:l,descriptionId:c.descriptionId})]})]})}),so="DialogTitle",Il=k.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=St(so,r);return o.jsx(Ie.h2,{id:s.titleId,...n,ref:t})});Il.displayName=so;var $l="DialogDescription",Fl=k.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=St($l,r);return o.jsx(Ie.p,{id:s.descriptionId,...n,ref:t})});Fl.displayName=$l;var Ll="DialogClose",Vl=k.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,s=St(Ll,r);return o.jsx(Ie.button,{type:"button",...n,ref:t,onClick:Be(e.onClick,()=>s.onOpenChange(!1))})});Vl.displayName=Ll;function ao(e){return e?"open":"closed"}var zl="DialogTitleWarning",[Fy,Hl]=lf(zl,{contentName:wr,titleName:so,docsSlug:"dialog"}),jp=({titleId:e})=>{const t=Hl(zl),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
42
42
|
|
|
43
43
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
44
44
|
|
|
45
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return S.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},xp="DialogDescriptionWarning",bp=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Pl(xp).contentName}}.`;return S.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},wp=xl,_p=wl,Sp=Sl,Cp=Cl,kp=kl,_i=jl,Xs=El,Dp=Rl;const Wr=S.memo(S.forwardRef(({children:e,trigger:t,title:r,description:n,footer:s,footerClassName:a,className:o,contentClassName:c,open:l,onOpenChange:u,onClose:f,defaultOpen:d,draggable:h=!0,...p},w)=>{const[g,y]=S.useState({x:0,y:0}),[v,b]=S.useState(!1),C=S.useRef({x:0,y:0}),[x,_]=S.useState(d||!1),k=l!==void 0,j=k?l:x;S.useEffect(()=>{j||(y({x:0,y:0}),b(!1))},[j]);const E=R=>{k||_(R),u?.(R),!R&&f&&f()},A=R=>{h&&(b(!0),C.current={x:R.clientX-g.x,y:R.clientY-g.y})};S.useEffect(()=>{if(!v)return;const R=F=>{y({x:F.clientX-C.current.x,y:F.clientY-C.current.y})},V=()=>{b(!1)};return document.addEventListener("mousemove",R),document.addEventListener("mouseup",V),()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",V)}},[v]);const T=n??r??"Dialog content",M=i.jsxs(i.Fragment,{children:[!p.noHeader&&i.jsxs("div",{className:de("flex flex-col space-y-[var(--ui-space-1-5)] border-b border-border bg-card/50 flex-shrink-0",h&&"cursor-move",p.noPadding?"p-[var(--ui-space-1)]":"p-[var(--ui-component-padding-y)]"),role:"button",tabIndex:0,"aria-label":"Drag modal",onMouseDown:A,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&R.preventDefault()},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(_i,{className:de("text-lg font-semibold leading-none tracking-tight text-foreground",!r&&"sr-only"),children:r||"Dialog"}),i.jsxs(Dp,{className:"rounded-full p-[var(--ui-space-1)] opacity-70 ring-offset-background transition-all hover:opacity-100 hover:bg-accent focus:outline-none disabled:pointer-events-none cursor-pointer",children:[i.jsx(ye.X,{className:"h-[var(--ui-space-5)] w-[var(--ui-space-5)] text-foreground"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]}),n?i.jsx(Xs,{className:"text-sm text-muted-foreground",children:n}):i.jsx(Xs,{className:"sr-only",children:T})]}),p.noHeader&&i.jsxs(i.Fragment,{children:[i.jsx(_i,{className:"sr-only",children:r||"Dialog"}),i.jsx(Xs,{className:"sr-only",children:T})]}),i.jsx("div",{id:"modal-content",className:de("flex-1 overflow-y-auto",p.noPadding?"p-[var(--ui-space-0)]":"p-[var(--ui-modal-padding)]",c),children:e}),s&&i.jsx("div",{className:de("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-[var(--ui-space-2)] bg-background flex-shrink-0","p-[var(--ui-component-padding-y)]",a),children:s})]});return i.jsxs(wp,{open:j,onOpenChange:E,...p,children:[t&&i.jsx(_p,{asChild:!0,children:t}),i.jsxs(Sp,{children:[i.jsx(Cp,{className:"fixed inset-[var(--ui-space-0)] z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),i.jsx(kp,{ref:w,className:de("fixed z-50 flex flex-col gap-[var(--ui-space-0)] bg-background",!h&&"duration-200",!h&&"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",!h&&"bottom-[var(--ui-space-0)] left-[var(--ui-space-0)] right-[var(--ui-space-0)] w-full h-[var(--ui-space-90vh)] rounded-t-xl border-t border-border",!h&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",h&&"left-[var(--ui-space-50pct)] top-[var(--ui-space-50pct)] h-auto max-h-[var(--ui-space-90vh)] w-[var(--ui-space-90vw)] max-w-lg rounded-md border border-border",!h&&"sm:left-[var(--ui-space-50pct)] sm:top-[var(--ui-space-50pct)] sm:bottom-auto sm:right-auto sm:h-auto sm:max-h-[var(--ui-space-90vh)] sm:max-w-lg sm:rounded-md sm:border sm:border-border",!h&&"sm:data-[state=closed]:zoom-out-95 sm:data-[state=open]:zoom-in-95",!h&&"sm:data-[state=closed]:slide-out-to-left-[var(--ui-space-50pct)] sm:data-[state=closed]:slide-out-to-top-[var(--ui-space-48pct)]",!h&&"sm:data-[state=open]:slide-in-from-left-[var(--ui-space-50pct)] sm:data-[state=open]:slide-in-from-top-[var(--ui-space-48pct)]",o),style:h?{transform:`translate(calc(-50% + ${g.x}px), calc(-50% + ${g.y}px))`,cursor:v?"grabbing":void 0}:{transform:"translate(-50%, -50%)"},children:M})]})]})}));Wr.displayName="Modal";function ro({onConfirm:e,variant:t="default",...r}){return i.jsx(Wr,{...r,children:i.jsxs("div",{className:"flex justify-end gap-[var(--ui-space-2)] p-[var(--ui-component-padding-y)]",children:[i.jsx(ie,{variant:"outline",onClick:()=>r.onClose?.()||r.onOpenChange?.(!1),children:"Cancel"}),i.jsx(ie,{variant:t,onClick:e,children:"Confirm"})]})})}const kt=4,jp=e=>e?e.replace(/[^0-9]/g,"").slice(0,kt):"",Np=e=>{const t=e.padEnd(kt,"_");return`${t.slice(0,2)}:${t.slice(2,4)}`},Ep=e=>{if(e.length!==kt)return!1;const t=Number.parseInt(e.slice(0,2),10),r=Number.parseInt(e.slice(2,4),10);return t>=0&&t<=23&&r>=0&&r<=59},Ap=e=>`${e.slice(0,2)}:${e.slice(2,4)}`,Rp=m.memo(({open:e,title:t,onClose:r,displayContent:n,errorMessage:s,onNumberClick:a,onBackspace:o,onClear:c,onConfirm:l,additionalButton:u})=>i.jsx(Wr,{open:e,onOpenChange:f=>!f&&r(),title:t,onClose:r,children:i.jsxs("div",{className:"flex flex-col gap-[var(--ui-space-4)]",children:[i.jsx("div",{className:"bg-card border-2 border-theme-text-primary rounded-lg p-[var(--ui-modal-padding)] min-h-[var(--ui-space-15)] flex items-center justify-center text-lg font-semibold text-foreground",children:n}),s&&i.jsx("div",{className:"text-destructive text-sm text-center p-ui-gap bg-destructive/10 rounded-md border-l-[3px] border-destructive",children:s}),i.jsxs("div",{className:"grid grid-cols-3 gap-ui-gap",children:[[1,2,3,4,5,6,7,8,9].map(f=>i.jsx("button",{type:"button",onClick:()=>a(f.toString()),className:"min-h-[var(--ui-keypad-button-height)] text-lg font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:f},f)),u||i.jsx("div",{className:"min-h-[var(--ui-keypad-button-height)] bg-card rounded-lg"}),i.jsx("button",{type:"button",onClick:()=>a("0"),className:"min-h-[var(--ui-keypad-button-height)] text-lg font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:"0"}),i.jsx("button",{type:"button",onClick:o,className:"min-h-[var(--ui-keypad-button-height)] text-base font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:"⌫"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-ui-gap mt-[var(--ui-space-2)]",children:[i.jsx("button",{type:"button",onClick:c,className:"min-h-[var(--ui-keypad-button-height)] text-base font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:bg-destructive active:text-white active:border-theme-danger hover:bg-destructive hover:text-white hover:border-theme-danger",children:"C"}),i.jsx("button",{type:"button",onClick:l,className:"min-h-[var(--ui-keypad-button-height)] text-base font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:"OK"})]})]})})),Tp={number:{titleKey:"keypad_title_number",placeholder:"",maxLength:10},phone:{titleKey:"keypad_title_phone",placeholder:"090-0000-0000",maxLength:13},time:{titleKey:"keypad_title_time",placeholder:"__:__",maxLength:kt}},js=m.memo(({open:e,onClose:t,onSubmit:r,variant:n="number",initialValue:s="",title:a,placeholder:o,maxLength:c,allowDecimal:l=!1})=>{const{t:u}=$e(),f=m.useMemo(()=>n==="time"?jp(s):s,[n,s]),[d,h]=m.useState(f),[p,w]=m.useState(""),[g,y]=m.useState(!0),v=m.useMemo(()=>Tp[n],[n]),b=a??u(v.titleKey),C=o??v.placeholder,x=n==="time"?kt:c??v.maxLength,_=n==="number"&&l,k=n==="phone",j=n==="time";m.useEffect(()=>{e&&(h(f),w(""),y(!0))},[e,f]);const E=m.useCallback($=>{if(y(!1),j){h(L=>{const P=g?"":L;return P.length>=kt?(w(u("keypad_error_max_length",{defaultValue:`Up to ${kt} characters`,max:kt})),P):(w(""),P.length===0&&Number.parseInt($,10)>=3?`0${$}`:(P+$).slice(0,kt))});return}h(L=>{const P=g?"":L;return P.length>=x?(w(u("keypad_error_max_length",{defaultValue:`Up to ${x} characters`,max:x})),P):(w(""),`${P}${$}`)})},[x,j,g,u]),A=m.useCallback(()=>{k&&(y(!1),h($=>{const L=g?"":$;return L.length>=x?(w(u("keypad_error_max_length",{defaultValue:`Up to ${x} characters`,max:x})),L):L.endsWith("-")?(w(u("keypad_error_hyphen_repeat")),L):(w(""),`${L}-`)}))},[k,x,g,u]),T=m.useCallback(()=>{_&&(y(!1),h($=>{const L=g?"":$;return L.includes(".")?(w(u("keypad_error_decimal_repeat")),L):(w(""),`${L}.`)}))},[_,g,u]),M=m.useCallback(()=>{y(!1),h($=>$.slice(0,-1)),w("")},[]),R=m.useCallback(()=>{y(!1),h(""),w("")},[]),V=m.useCallback(()=>{if(j){h($=>Ep($)?(r(Ap($)),$):(w(u("keypad_error_time_invalid")),$));return}h($=>$===""?(w(u("keypad_error_value_required")),$):_&&$.endsWith(".")?(w(u("keypad_error_decimal_end")),$):k&&$.endsWith("-")?(w(u("keypad_error_hyphen_end")),$):(r($),$))},[_,k,j,r,u]);m.useEffect(()=>{if(!e)return;const $=L=>{L.key>="0"&&L.key<="9"||L.code>="Numpad0"&&L.code<="Numpad9"?(L.preventDefault(),E(L.key)):k&&(L.key==="-"||L.code==="NumpadSubtract"||L.key==="Minus")?(L.preventDefault(),A()):_&&(L.key==="."||L.code==="NumpadDecimal")?(L.preventDefault(),T()):L.key==="Backspace"?(L.preventDefault(),M()):L.key==="Enter"?(L.preventDefault(),V()):L.key==="Escape"&&(L.preventDefault(),t())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e,k,_,t,E,A,T,M,V]);const F=j?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-[var(--ui-space-2)] w-full",children:[i.jsx("span",{style:{fontSize:"24px",fontFamily:"monospace",color:"hsl(var(--foreground))",letterSpacing:"2px",fontWeight:600},children:Np(d)}),i.jsxs("span",{style:{fontSize:"12px",color:"var(--theme-text-secondary)"},children:["入力: ",d.padEnd(kt,"・")]})]}):i.jsx("span",{style:{fontSize:"24px",fontFamily:"monospace",color:"hsl(var(--foreground))",fontWeight:600},children:d||i.jsx("span",{style:{color:"var(--theme-text-secondary)"},children:C})}),G=m.useMemo(()=>{if(k||_){const $=k?"-":".",L=k?A:T;return i.jsx("button",{type:"button",onClick:L,className:"min-h-[var(--ui-keypad-button-height)] text-lg font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:$})}},[k,_,A,T]);return i.jsx(Rp,{open:e,title:b,onClose:t,displayContent:F,errorMessage:p,onNumberClick:E,onBackspace:M,onClear:R,onConfirm:V,additionalButton:G})});js.displayName="KeypadModal";const bn=S.createContext(null),Vt=({children:e,value:t,onValueChange:r,defaultValue:n,disabled:s})=>{const[a,o]=S.useState(n||""),[c,l]=S.useState(!1),[u,f]=S.useState(null),d=t!==void 0?t:a,h=p=>{o(p),r?.(p),l(!1)};return i.jsx(bn.Provider,{value:{value:d,onValueChange:h,open:c,setOpen:l,label:u,setLabel:f,disabled:s},children:i.jsx("div",{className:"relative",children:e})})},Et=S.forwardRef(({className:e,children:t,...r},n)=>{const s=S.useContext(bn);if(!s)throw new Error("SelectTrigger must be used within Select");return i.jsxs("button",{ref:n,type:"button",disabled:s.disabled||r.disabled,onClick:()=>!s.disabled&&s.setOpen(!s.open),className:de("flex w-full items-center justify-between rounded-md border border-input bg-background px-ui py-ui text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:[t,i.jsx(ye.ChevronDown,{className:"h-ui-icon w-ui-icon opacity-50"})]})});Et.displayName="SelectTrigger";const At=S.forwardRef(({className:e,placeholder:t,...r},n)=>{const s=S.useContext(bn);if(!s)throw new Error("SelectValue must be used within Select");return i.jsx("span",{ref:n,className:de("block truncate",e),...r,children:r.children||s.label||s.value||t})});At.displayName="SelectValue";const Rt=S.forwardRef(({className:e,children:t,...r},n)=>{const s=S.useContext(bn);if(!s)throw new Error("SelectContent must be used within Select");return s.open?i.jsx("div",{ref:n,className:de("absolute z-50 min-w-[var(--ui-space-32)] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80 w-full mt-[var(--ui-space-1)]",e),...r,children:i.jsx("div",{className:"p-[var(--ui-space-1)] max-h-[var(--ui-space-60)] overflow-y-auto",children:t})}):null});Rt.displayName="SelectContent";const ut=S.forwardRef(({className:e,children:t,value:r,...n},s)=>{const a=S.useContext(bn);if(!a)throw new Error("SelectItem must be used within Select");const o=a.value===r;return S.useEffect(()=>{o&&a.setLabel(t)},[o,t,a]),i.jsxs("button",{ref:s,type:"button",className:de("relative flex w-full cursor-default select-none items-center rounded-sm py-[var(--ui-space-1-5)] pl-[var(--ui-space-8)] pr-[var(--ui-space-2)] text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o?"bg-accent/50":"",e),onClick:()=>{a.setLabel(t),a.onValueChange(r)},...n,children:[i.jsx("span",{className:"absolute left-[var(--ui-space-2)] flex h-[var(--ui-space-3-5)] w-[var(--ui-space-3-5)] items-center justify-center",children:o&&i.jsx("span",{className:"h-[var(--ui-space-2)] w-[var(--ui-space-2)] rounded-full bg-current"})}),i.jsx("span",{className:"truncate",children:t})]})});ut.displayName="SelectItem";const fn=S.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{className:de("flex min-h-[var(--ui-space-20)] w-full rounded-md border border-input bg-background px-ui py-ui text-sm ring-offset-background 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",e),ref:r,...t}));fn.displayName="Textarea";function Ol(e){if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(/,|、/).map(t=>t.trim()).filter(Boolean).map(t=>({name:t,type:"external"}))}function Ml(e){return e.length>0?JSON.stringify(e):"[]"}function Il({personnel:e,currentUserId:t,isEditMode:r}){const n=m.useMemo(()=>s=>{let a=[];try{if(s&&s!=="[]"){const o=JSON.parse(s);Array.isArray(o)&&(a=o)}}catch{}if(!r&&t&&e&&!a.some(c=>c.personnelId===t)){const c=e.find(l=>l.id===t);c&&a.push({name:c.name,personnelId:c.id,type:"personnel"})}return{finalAttendees:a.length>0?JSON.stringify(a):"[]",shouldDelete:!1}},[r,t,e]);return{parseAttendees:Ol,stringifyAttendees:Ml,processAttendeesForSubmit:n}}function Fl(e,t,r,n){const{start:s,end:a}=r;if(Number.isNaN(s.getTime())||Number.isNaN(a.getTime()))return e.map(l=>({resourceId:l.id,isAvailable:!0,conflictingEvents:[],todaySchedule:[]}));const o=new Date(s);o.setHours(0,0,0,0);const c=new Date(s);return c.setHours(23,59,59,999),e.map(l=>{const u=l.id,f=t.filter(p=>p.resourceId===u&&p.id!==n&&p.status!=="cancelled"),d=f.filter(p=>{const w=p.isAllDay??p.extendedProps?.isAllDay,g=w===!0||w==="true"||w===1||w==="1",y=new Date(p.startDate);let v=new Date(p.endDate);return g&&(y.setHours(0,0,0,0),v<=y||v.getDate()===y.getDate()&&v.getFullYear()===y.getFullYear()&&v.getMonth()===y.getMonth()?(v=new Date(y),v.setDate(v.getDate()+1)):(v.setHours(0,0,0,0),v<=y&&(v=new Date(y),v.setDate(v.getDate()+1)))),s<v&&a>y}),h=f.filter(p=>{const w=new Date(p.startDate),g=new Date(p.endDate);return o<g&&c>w});return h.sort((p,w)=>p.startDate.getTime()-w.startDate.getTime()),{resourceId:u,isAvailable:d.length===0,conflictingEvents:d,todaySchedule:h}})}function Ll({resources:e,groups:t,events:r,timeRange:n,currentEventId:s,externalAvailability:a}){const o=m.useMemo(()=>a||Fl(e,r,n,s),[a,e,r,n,s]),c=m.useMemo(()=>e.filter(f=>o.find(h=>h.resourceId===f.id)?.isAvailable??!0),[e,o]),l=m.useMemo(()=>c.map(f=>{const d=t.find(h=>h.id===f.groupId);return d?`${f.name} (${d.name})`:f.name}),[c,t]),u=m.useMemo(()=>f=>{const d=e.find(p=>p.id===f);if(!d)return f;const h=t.find(p=>p.id===d.groupId);return h?`${d.name} (${h.name})`:d.name},[e,t]);return{availabilityList:o,availableResources:c,resourceNames:l,getDisplayName:u}}function Ns(e,t){return xc({start:e.startDate,end:e.endDate},{start:t.startDate,end:t.endDate})}function no(e,t){for(const r of t)if(r.status!=="cancelled"&&r.id!==e.id&&r.resourceId===e.resourceId&&Ns(r,e))return{resourceId:e.resourceId,existingSchedule:r,newSchedule:e,conflictType:"double-booking"};return null}function Es(e,t,r){return e.filter(n=>xc({start:n.startDate,end:n.endDate},{start:t,end:r}))}function $l(e,t){return e.filter(r=>r.resourceId===t)}function Pp(e,t){return Es(e,gr(t),Cf(t))}function so(e){return[...e].sort((t,r)=>t.startDate.getTime()-r.startDate.getTime())}function Op(e){return[...e].sort((t,r)=>t.order-r.order)}function Mp(e){return(e.endDate.getTime()-e.startDate.getTime())/(1e3*60*60)}function Ip(e){const t=Ne(e.startDate,void 0,"time24"),r=Ne(e.endDate,void 0,"time24");return`${e.title} (${t}-${r})`}const Dr=new Map,Fp=100;function ao(e,t){const r=gr(e),n=gr(t),s=`${r.getTime()}-${n.getTime()}`;if(Dr.has(s)){const c=Dr.get(s);if(c!==void 0)return c}const a=[];let o=r;for(;o<=n;)a.push(o),o=br(o,1);if(Dr.size>=Fp){const c=Dr.keys().next().value;c&&Dr.delete(c)}return Dr.set(s,a),a}function oo(e){switch(e){case 0:case 1:case 2:case 3:case 4:case 5:case 6:return e;default:return 1}}function As(e,t=1){return nn(e,{weekStartsOn:t})}function io(e,t=1){return fa(e,{weekStartsOn:t})}function co(e){return vc(e)}function Vl(e){return yc(e)}function Lp(e){const t=e.map(r=>({...r,hasConflict:!1}));for(let r=0;r<t.length;r++){const n=t[r];if(!(!n||n.status==="cancelled"))for(let s=r+1;s<t.length;s++){const a=t[s];!a||a.status==="cancelled"||n.resourceId===a.resourceId&&Ns(n,a)&&(n.hasConflict=!0,a.hasConflict=!0)}}return t}function zl(e,t,r){const n=r.startTime.split(":"),s=r.endTime.split(":"),a=Number(n[0]??0),o=Number(s[0]??23);if(t==="day"){const c=gr(e);c.setHours(a);const l=gr(e);if(o>=24){const u=Math.floor(o/24),f=o%24,d=br(l,u);return d.setHours(f,59,59,999),{start:c,end:d}}else return l.setHours(o,59,59,999),{start:c,end:l}}if(t==="week"){const c=oo(r.weekStartsOn),l=As(e,c),u=io(e,c);return{start:l,end:u}}return{start:co(e),end:Vl(e)}}function Bl({startDate:e,duration:t,resourceId:r,events:n,currentEventId:s}){return m.useMemo(()=>{const a=new Date(e),o=new Date(a),c=(Number(t)||0)*60;if(o.setMinutes(o.getMinutes()+c),!r||Number.isNaN(a.getTime()))return null;const l=n.filter(u=>u.id!==s);return no({startDate:a,endDate:o,resourceId:r},l)},[e,t,r,n,s])}const $p=e=>{const t=Math.floor(e),r=Math.round((e-t)*60);return t===0?`${r}m`:r===0?`${t}h`:`${t}h ${r}m`},Vp=(e,t)=>{const r=e?.[t];return typeof r=="string"?r:void 0},zp=Le({title:J().min(1,"required"),attendee:J().optional(),resourceId:J().optional(),startDate:J().min(1,"required"),durationHours:Ce().min(.25).max(24),note:J().optional(),isRecurring:qe().optional(),scheduleType:J().optional(),endDate:J().optional(),isAllDay:qe().optional()}),Si=[];function Hl({event:e,resources:t,groups:r,events:n,resourceAvailability:s,defaultResourceId:a,defaultStartTime:o,onSubmit:c,onCancel:l,onDelete:u,readOnlyResource:f=!1,personnel:d=Si,currentUserId:h,onAvailabilityRequest:p,customFields:w=Si}){const{t:g,i18n:y}=$e(),v=!!e,[b,C]=m.useState(!1),x=m.useMemo(()=>{const P={};return w.forEach(H=>{let z;H.type==="number"?(z=gs([Ce(),J().transform(re=>re===""?void 0:Number(re))]),H.required?z=Jn.number().min(1,"required"):z=Jn.number().optional()):H.type==="boolean"?z=qe().optional():(z=J(),H.required?z=z.min(1,"required"):z=z.optional()),P[H.name]=z}),zp.extend(P)},[w]),_=m.useMemo(()=>{const P={title:Vp(e?.extendedProps,"originalTitle")??e?.title??"",attendee:e?.attendee||"[]",resourceId:e?.resourceId||a||"",startDate:Er(e?.startDate||o||new Date),durationHours:e?Math.round((e.endDate.getTime()-e.startDate.getTime())/36e5*100)/100:1,note:e?.note||"",isRecurring:!1,isAllDay:e?.isAllDay||!1},H={};return w.forEach(z=>{const re=e?.extendedProps?.[z.name];H[z.name]=re!==void 0?re:z.defaultValue??""}),{...P,...H}},[e,a,o,w]),k=ec({resolver:rc(x),defaultValues:_});m.useEffect(()=>{k.reset(_)},[_,k]);const j=k.watch("isAllDay"),E=k.watch("startDate"),A=k.watch("durationHours"),T=k.watch("resourceId"),M=new Date(E);if(!Number.isNaN(M.getTime())){const P=(Number(A)||0)*60;M.setTime(new Date(E).getTime()+P*6e4)}const{availableResources:R,getDisplayName:V}=Ll({resources:t,groups:r,events:n,timeRange:{start:new Date(E),end:M},currentEventId:e?.id,externalAvailability:s});m.useEffect(()=>{if(p){const P=new Date(E);if(!Number.isNaN(P.getTime())){const H=new Date(P),z=(Number(A)||0)*60;H.setMinutes(H.getMinutes()+z),p({startDate:P,endDate:H})}}},[E,A,p]);const F=Bl({startDate:E,duration:A,resourceId:T,events:n,currentEventId:e?.id}),{parseAttendees:G,processAttendeesForSubmit:$}=Il({personnel:d,currentUserId:h,isEditMode:v}),L=P=>{const H=new Date(P.startDate);P.isAllDay&&H.setHours(0,0,0,0);const z=new Date(H),re=(Number(P.durationHours)||0)*60;z.setMinutes(z.getMinutes()+re);const{finalAttendees:q,shouldDelete:I}=$(P.attendee||"[]");if(I&&u){u();return}const{startDate:B,endDate:se,title:ne,attendee:fe,resourceId:pe,note:Ae,durationHours:xe,isAllDay:Ze,isRecurring:Ye,scheduleType:Xe,...Ke}=P,_t={...e?.extendedProps??{},...Ke};w.forEach(Zt=>{P[Zt.name]!==void 0&&(_t[Zt.name]=P[Zt.name])});const ft={title:ne,attendee:q,resourceId:pe||void 0,startDate:H,endDate:z,status:e?.status??"booked",note:Ae,durationHours:xe,isAllDay:!!P.isAllDay,extendedProps:_t};c(ft)};return i.jsxs(Ja,{...k,children:[i.jsxs("form",{onSubmit:k.handleSubmit(L),className:"space-y-[var(--ui-space-4)] text-foreground",children:[i.jsx(Te,{control:k.control,name:"title",render:({field:P})=>i.jsxs(je,{children:[i.jsxs(we,{children:[g("event_name_label")||"Event Name"," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx(be,{children:i.jsx(vt,{...P,placeholder:g("event_name_placeholder")||"Enter event name",autoFocus:!0})}),i.jsx(nt,{})]})}),i.jsx(Te,{control:k.control,name:"attendee",render:({field:P})=>i.jsxs(je,{children:[i.jsx(we,{children:g("attendee_label")||"Attendee"}),i.jsx(be,{children:i.jsx(Sa,{value:G(P.value),onChange:H=>P.onChange(JSON.stringify(H)),personnel:d||[],placeholder:g("attendee_placeholder")||"Enter attendee name"})}),i.jsx(nt,{})]})}),i.jsx(Te,{control:k.control,name:"resourceId",render:({field:P})=>{const H=V(P.value||"");return i.jsxs(je,{children:[i.jsx(we,{children:g("resource_label")}),f?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-ui py-ui bg-muted rounded-md text-sm border border-input min-h-ui flex items-center",children:H||g("resource_placeholder")}),i.jsx("input",{type:"hidden",...P})]}):i.jsx(be,{children:i.jsxs(Vt,{onValueChange:P.onChange,value:P.value||"",children:[i.jsx(be,{children:i.jsx(Et,{children:i.jsx(At,{placeholder:g("resource_placeholder"),children:H})})}),i.jsx(Rt,{children:R.map(z=>i.jsx(ut,{value:z.id,children:V(z.id)},z.id))})]})}),i.jsx(nt,{})]})}}),w.map(P=>i.jsx(Te,{control:k.control,name:P.name,render:({field:H})=>i.jsxs(je,{children:[i.jsxs(we,{children:[P.label,P.required&&i.jsx("span",{className:"text-red-500",children:" *"})]}),i.jsx(be,{children:P.type==="select"?i.jsxs(Vt,{onValueChange:H.onChange,value:String(H.value||""),children:[i.jsx(be,{children:i.jsx(Et,{children:i.jsx(At,{placeholder:"Select..."})})}),i.jsx(Rt,{children:P.options?.map(z=>i.jsx(ut,{value:z.value,children:z.label},z.value))})]}):P.type==="boolean"?i.jsxs("div",{className:"flex items-center space-x-[var(--ui-space-2)]",children:[i.jsx(ln,{checked:!!H.value,onCheckedChange:H.onChange}),i.jsx("span",{className:"text-sm text-muted-foreground",children:P.label})]}):P.type==="number"?i.jsx(vt,{type:"number",...H,value:String(H.value||""),onChange:H.onChange}):i.jsx(vt,{...H,value:String(H.value||"")})}),i.jsx(nt,{})]})},P.name)),i.jsxs("div",{className:"space-y-[var(--ui-space-2)]",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs(we,{className:"text-base font-semibold",children:[g("date_time_label")||"Date & Time"," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx(Te,{control:k.control,name:"isAllDay",render:({field:P})=>i.jsxs(je,{className:"flex flex-row items-center space-x-[var(--ui-space-2)] space-y-[var(--ui-space-0)]",children:[i.jsx(be,{children:i.jsx(ln,{checked:!!P.value,onCheckedChange:P.onChange,id:"isAllDay-checkbox"})}),i.jsx("label",{htmlFor:"isAllDay-checkbox",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:g("all_day")||"All Day"})]})})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-[var(--ui-space-4)] items-start",children:[i.jsx(Te,{control:k.control,name:"startDate",render:({field:P})=>i.jsxs(je,{className:"space-y-[var(--ui-space-1-5)]",children:[i.jsx(we,{className:"text-xs text-muted-foreground",children:g("date_label")||"Date"}),i.jsx(be,{children:i.jsx(Ka,{value:new Date(P.value),disabled:j,onChange:H=>{if(H){const z=new Date(P.value);j?H.setHours(0,0,0,0):H.setHours(z.getHours(),z.getMinutes()),P.onChange(Er(H))}},className:"w-full"})}),i.jsx(nt,{})]})}),j?i.jsx("div",{"aria-hidden":"true"}):i.jsx(Te,{control:k.control,name:"startDate",render:({field:P})=>i.jsxs(je,{className:"space-y-[var(--ui-space-1-5)]",children:[i.jsx(we,{className:"text-xs text-muted-foreground",children:g("time_label")||"Time"}),i.jsx(be,{children:i.jsx(vt,{value:Ne(new Date(P.value),y.language,"time24"),readOnly:!0,className:"cursor-pointer w-full text-center",onClick:()=>C(!0),tabIndex:-1})}),i.jsx(nt,{})]})}),j?i.jsx("div",{"aria-hidden":"true"}):i.jsx(Te,{control:k.control,name:"durationHours",render:({field:P})=>i.jsxs(je,{className:"space-y-[var(--ui-space-1-5)]",children:[i.jsx(we,{className:"text-xs text-muted-foreground",children:g("duration_label")}),i.jsxs(Vt,{onValueChange:H=>P.onChange(Number(H)),value:String(P.value),disabled:j,children:[i.jsx(be,{children:i.jsx(Et,{className:"w-full",children:i.jsx(At,{})})}),i.jsx(Rt,{className:"max-h-[var(--ui-space-50)]",children:[.25,.5,.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.5,4,4.5,5,6,8].map(H=>i.jsx(ut,{value:String(H),children:$p(H)},H))})]}),i.jsx(nt,{})]})}),j?i.jsx("div",{"aria-hidden":"true"}):i.jsxs("div",{className:"space-y-[var(--ui-space-1-5)]",children:[i.jsx(we,{className:"text-xs text-muted-foreground",children:"End Time"}),i.jsx("div",{className:"h-[var(--ui-component-height)] px-3 py-1 flex items-center justify-center border border-transparent text-sm text-foreground/80 font-medium whitespace-nowrap",children:Number.isNaN(M.getTime())?"-":Ne(M,y.language,"time24")})]})]})]}),F&&i.jsxs("div",{className:"p-[var(--ui-space-4)] bg-red-50 border border-red-500 rounded text-red-800 flex items-start gap-[var(--ui-space-2)]",children:[i.jsx(ye.AlertTriangle,{className:"w-[var(--ui-space-5)] h-[var(--ui-space-5)] flex-shrink-0"}),i.jsxs("div",{children:[i.jsx("strong",{className:"block text-sm",children:"Conflict Detected"}),i.jsxs("span",{className:"text-xs",children:[g("event_form_conflict_warning")," (",Ne(F.existingSchedule.startDate,y.language,"time24")," ","-"," ",Ne(F.existingSchedule.endDate,y.language,"time24"),")"]})]})]}),i.jsx(Te,{control:k.control,name:"note",render:({field:P})=>i.jsxs(je,{children:[i.jsx(we,{children:g("note_label")}),i.jsx(be,{children:i.jsx(fn,{...P,value:P.value||"",placeholder:"Add notes...",rows:2})})]})}),i.jsxs("div",{className:"flex gap-[var(--ui-space-3)] pt-[var(--ui-space-4)] border-t border-border",children:[v&&u&&i.jsx(ie,{type:"button",variant:"outline-delete",size:"sm",onClick:u,className:"flex-1",children:g("delete_button")}),i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:l,className:"flex-1",children:g("cancel_button")}),i.jsx(ie,{type:"submit",variant:"default",size:"sm",className:"flex-1",children:g("save_button")})]})]}),i.jsx(js,{open:b,onClose:()=>C(!1),onSubmit:P=>{const H=new Date(k.getValues("startDate")),[z,re]=P.split(":").map(Number);H.setHours(z||0,re||0),k.setValue("startDate",Er(H)),C(!1)},initialValue:Ne(new Date(k.getValues("startDate")),y.language,"time24"),variant:"time"})]})}function lo({isOpen:e,event:t,resources:r,groups:n,events:s,defaultResourceId:a,defaultStartTime:o,onClose:c,onSave:l,onDelete:u,readOnlyResource:f,personnel:d=[],currentUserId:h,resourceAvailability:p,onAvailabilityRequest:w,customFields:g}){const{t:y}=$e(),v=!!t,[b,C]=m.useState(!1),[x,_]=m.useState({open:!1,title:"",onConfirm:()=>{}});m.useEffect(()=>{if(e){C(!1);const j=setTimeout(()=>{C(!0)},500);return()=>clearTimeout(j)}C(!1)},[e]);const k=()=>{!t||!u||_({open:!0,title:y("confirm_delete_title"),description:y("confirm_delete_message"),onConfirm:()=>{u(t.id),_(j=>({...j,open:!1})),c()}})};return i.jsxs(Wr,{open:e,onOpenChange:j=>!j&&c(),title:y(v?"event_edit_title":"event_create_title"),className:"sm:max-w-3xl",children:[i.jsx("div",{style:{pointerEvents:b?"auto":"none"},children:i.jsx(Hl,{event:t,resources:r,groups:n,events:s,personnel:d,resourceAvailability:p,defaultResourceId:a,defaultStartTime:o,onSubmit:l,onCancel:c,onDelete:v&&u?k:void 0,readOnlyResource:f,currentUserId:h,onAvailabilityRequest:w,customFields:g})}),i.jsx(ro,{open:x.open,onOpenChange:j=>_(E=>({...E,open:j})),title:x.title,description:x.description,onConfirm:x.onConfirm,variant:"destructive"})]})}const Wl=m.createContext(void 0);function Ul(){const e=m.useContext(Wl);if(!e)throw new Error("useScheduleContext must be used within a ScheduleProvider");return e}function Bp({children:e,apiClient:t,onError:r}){const n=m.useRef(t);m.useEffect(()=>{n.current=t},[t]);const s=m.useRef(null),[a,o]=m.useState([]),[c,l]=m.useState([]),[u,f]=m.useState([]),[d,h]=m.useState([]),[p,w]=m.useState(null),[g,y]=m.useState([]),[v,b]=m.useState(!0),[C,x]=m.useState(null),[_,k]=m.useState(new Map);m.useEffect(()=>{(async()=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot load data."),b(!1);return}try{const I=t.getConfig(),B=t.getEvents();s.current||(s.current=t.getPersonnel().catch(Ae=>{throw s.current=null,Ae}));const[se,ne,fe]=await Promise.all([I,B,s.current]);h(se.groups),f(se.resources),w(se.settings);const pe=ne.filter(Ae=>!!Ae.resourceId);o(pe),y(fe)}catch(I){console.error("Failed to load schedule data",I),x(I instanceof Error?I.message:"Unknown error")}finally{b(!1)}})()},[t]);const j=m.useCallback(async q=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot create event.");return}try{const I=await t.createEvent(q);o(B=>[...B,I]),l(B=>[...B,I]),k(new Map)}catch(I){console.error("Failed to create event",I);const B=I instanceof Error?I:new Error(String(I));throw r?.(B),B}},[t,r]),E=m.useCallback(async(q,I)=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot update event.");return}try{const B=await t.updateEvent(q,I);o(se=>se.map(ne=>ne.id===q?B:ne)),l(se=>se.map(ne=>ne.id===q?B:ne)),k(new Map)}catch(B){console.error("Failed to update event",B);const se=B instanceof Error?B:new Error(String(B));throw r?.(se),se}},[t,r]),A=m.useCallback(async q=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot delete event.");return}try{await t.deleteEvent(q),o(I=>I.filter(B=>B.id!==q)),l(I=>I.filter(B=>B.id!==q)),k(new Map)}catch(I){console.error("Failed to delete event",I);const B=I instanceof Error?I:new Error(String(I));throw r?.(B),B}},[t,r]),T=m.useCallback(async q=>{const I=await t.createGroup(q);return h(B=>[...B,I]),I},[t]),M=m.useCallback(async(q,I)=>{const B=await t.updateGroup(q,I);return h(se=>se.map(ne=>ne.id===q?B:ne)),B},[t]),R=m.useCallback(async q=>{await t.deleteGroup(q),h(I=>I.filter(B=>B.id!==q))},[t]),V=m.useCallback(async q=>{const I=await t.createResource(q);return f(B=>[...B,I]),I},[t]),F=m.useCallback(async(q,I)=>{const B=await t.updateResource(q,I);return f(se=>se.map(ne=>ne.id===q?B:ne)),B},[t]),G=m.useCallback(async q=>{await t.deleteResource(q),f(I=>I.filter(B=>B.id!==q))},[t]),$=m.useCallback(async(q,I)=>{try{const B=await t.updatePersonnelPriority(q,I);y(se=>{const ne=se.map(fe=>fe.id===q?B:fe);return ne.sort((fe,pe)=>pe.priority!==fe.priority?pe.priority-fe.priority:fe.name.localeCompare(pe.name,"ja")),ne})}catch(B){console.error("Failed to update personnel priority",B);const se=B instanceof Error?B:new Error(String(B));throw r?.(se),se}},[t,r]),L=m.useCallback(async(q,I=!1)=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot fetch personnel events.");return}if(q.length===0){I||l([]);return}try{const B=await t.getEvents(q);l(I?se=>{const ne=new Set(se.map(pe=>pe.id)),fe=B.filter(pe=>!ne.has(pe.id));return[...se,...fe]}:B)}catch(B){throw console.error("Failed to fetch personnel events",B),B}},[t]),P=m.useCallback((q,I)=>{const B=new Date(q);return B.setHours(0,0,0,0),`${B.toISOString().split("T")[0]}_${I}`},[]),H=m.useCallback((q,I="day")=>{const B=P(q,I);return _.get(B)},[_,P]),z=m.useCallback(async(q,I="day")=>{const B=P(q,I),se=_.get(B);if(se)return se;try{const ne=await t.getResourceAvailability({date:q,view:I});return k(fe=>{const pe=new Map(fe);return pe.set(B,ne),pe}),ne}catch(ne){return console.error("Failed to fetch resource availability",ne),[]}},[_,t,P]),re={events:a,personnelEvents:c,resources:u,groups:d,settings:p,personnel:g,loading:v,error:C,createEvent:j,updateEvent:E,deleteEvent:A,createGroup:T,updateGroup:M,deleteGroup:R,createResource:V,updateResource:F,deleteResource:G,updatePersonnelPriority:$,fetchPersonnelEvents:L,fetchResourceAvailability:z,getResourceAvailabilityFromCache:H};return i.jsx(Wl.Provider,{value:re,children:e})}const Jr={SLOT_HEIGHT:60,HEADER_HEIGHT:64,TIME_COLUMN_WIDTH:64},ur={DAY_CELL_HEIGHT:110,DATE_COLUMN_WIDTH:56,MAX_VISIBLE_EVENTS:4};function uo(e){const t=new Map,r=new Map,n=new Map;for(const s of e){if(s.resourceId){const l=t.get(s.resourceId)??[];l.push(s),t.set(s.resourceId,l)}const a=zr(s.startDate),o=r.get(a)??[];o.push(s),r.set(a,o);const c=n.get(s.groupId)??[];c.push(s),n.set(s.groupId,c)}return{byResource:t,byDay:r,byGroup:n}}const Fn=new Map;function zr(e){const r=e.getTime().toString(),n=Fn.get(r);if(n)return n;const s=new Date(e);s.setHours(0,0,0,0);const a=s.toISOString().split("T")[0]??"";return Fn.size>1e3&&Fn.clear(),Fn.set(r,a),a}function Hp(e,t){return t.byResource.get(e)??[]}function Zl(e,t){const r=zr(e);return t.byDay.get(r)??[]}const Wp=({children:e})=>i.jsx(i.Fragment,{children:e}),Up=({children:e})=>i.jsx("div",{className:"group contents",children:e}),Zp=({children:e,asChild:t,...r})=>{if(t&&S.isValidElement(e)){const n=e;return S.cloneElement(n,{...r,className:de(n.props.className,"cursor-help")})}return i.jsx("span",{...r,className:"cursor-help inline-block",children:e})},Yp=({children:e,className:t,...r})=>i.jsx("div",{className:de("absolute z-50 overflow-hidden rounded-md border bg-popover px-[var(--ui-space-3)] py-[var(--ui-space-1-5)] text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-[var(--ui-space-2)] data-[side=left]:slide-in-from-right-[var(--ui-space-2)] data-[side=right]:slide-in-from-left-[var(--ui-space-2)] data-[side=top]:slide-in-from-bottom-[var(--ui-space-2)]","hidden group-hover:block w-max max-w-xs bottom-full mb-[var(--ui-space-2)] left-[var(--ui-space-1)]/2 -translate-x-[var(--ui-space-1)]/2",t),...r,children:e});function Gp({event:e,top:t,height:r,widthPercent:n=100,leftPercent:s=0,onClick:a,isDragging:o=!1,components:c}){const l=e.startDate.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),u=e.endDate.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),f=Math.round((e.endDate.getTime()-e.startDate.getTime())/(1e3*60*60)*10)/10,d=e.hasConflict?"bg-destructive border-destructive":e.color?"border-primary/30":"bg-primary border-primary/30",h=g=>g.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),p=`${f}h`,w={top:`${t}px`,height:`${r}px`,left:`${s}%`,width:`${n}%`,paddingLeft:s>0?"2px":"4px",paddingRight:s+n<100?"2px":"4px"};return e.color&&!e.hasConflict&&(w.backgroundColor=e.color),i.jsx(Wp,{children:i.jsxs(Up,{children:[i.jsx(Zp,{asChild:!0,children:i.jsx("button",{type:"button",className:`
|
|
45
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return k.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Dp="DialogDescriptionWarning",Np=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Hl(Dp).contentName}}.`;return k.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Ep=Nl,Ap=Al,Tp=Rl,Rp=Pl,Pp=Ml,ji=Il,Js=Fl,Mp=Vl;const Yr=k.memo(k.forwardRef(({children:e,trigger:t,title:r,description:n,footer:s,footerClassName:a,className:i,contentClassName:c,open:l,onOpenChange:u,onClose:f,defaultOpen:d,draggable:h=!0,...p},w)=>{const[g,y]=k.useState({x:0,y:0}),[x,v]=k.useState(!1),_=k.useRef({x:0,y:0}),[b,S]=k.useState(d||!1),C=l!==void 0,j=C?l:b;k.useEffect(()=>{j||(y({x:0,y:0}),v(!1))},[j]);const N=A=>{C||S(A),u?.(A),!A&&f&&f()},E=A=>{h&&(v(!0),_.current={x:A.clientX-g.x,y:A.clientY-g.y})};k.useEffect(()=>{if(!x)return;const A=O=>{y({x:O.clientX-_.current.x,y:O.clientY-_.current.y})},$=()=>{v(!1)};return document.addEventListener("mousemove",A),document.addEventListener("mouseup",$),()=>{document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",$)}},[x]);const R=n??r??"Dialog content",M=o.jsxs(o.Fragment,{children:[!p.noHeader&&o.jsxs("div",{className:de("flex flex-col space-y-[var(--ui-space-1-5)] border-b border-border bg-card/50 flex-shrink-0",h&&"cursor-move",p.noPadding?"p-[var(--ui-space-1)]":"p-[var(--ui-component-padding-y)]"),role:"button",tabIndex:0,"aria-label":"Drag modal",onMouseDown:E,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&A.preventDefault()},children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ji,{className:de("text-lg font-semibold leading-none tracking-tight text-foreground",!r&&"sr-only"),children:r||"Dialog"}),o.jsxs(Mp,{className:"rounded-full p-[var(--ui-space-1)] opacity-70 ring-offset-background transition-all hover:opacity-100 hover:bg-accent focus:outline-none disabled:pointer-events-none cursor-pointer",children:[o.jsx(ye.X,{className:"h-[var(--ui-space-5)] w-[var(--ui-space-5)] text-foreground"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]}),n?o.jsx(Js,{className:"text-sm text-muted-foreground",children:n}):o.jsx(Js,{className:"sr-only",children:R})]}),p.noHeader&&o.jsxs(o.Fragment,{children:[o.jsx(ji,{className:"sr-only",children:r||"Dialog"}),o.jsx(Js,{className:"sr-only",children:R})]}),o.jsx("div",{id:"modal-content",className:de("flex-1 overflow-y-auto",p.noPadding?"p-[var(--ui-space-0)]":"p-[var(--ui-modal-padding)]",c),children:e}),s&&o.jsx("div",{className:de("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-[var(--ui-space-2)] bg-background flex-shrink-0","p-[var(--ui-component-padding-y)]",a),children:s})]});return o.jsxs(Ep,{open:j,onOpenChange:N,...p,children:[t&&o.jsx(Ap,{asChild:!0,children:t}),o.jsxs(Tp,{children:[o.jsx(Rp,{className:"fixed inset-[var(--ui-space-0)] z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),o.jsx(Pp,{ref:w,className:de("fixed z-50 flex flex-col gap-[var(--ui-space-0)] bg-background",!h&&"duration-200",!h&&"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",!h&&"bottom-[var(--ui-space-0)] left-[var(--ui-space-0)] right-[var(--ui-space-0)] w-full h-[var(--ui-space-90vh)] rounded-t-xl border-t border-border",!h&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",h&&"left-[var(--ui-space-50pct)] top-[var(--ui-space-50pct)] h-auto max-h-[var(--ui-space-90vh)] w-[var(--ui-space-90vw)] max-w-lg rounded-md border border-border",!h&&"sm:left-[var(--ui-space-50pct)] sm:top-[var(--ui-space-50pct)] sm:bottom-auto sm:right-auto sm:h-auto sm:max-h-[var(--ui-space-90vh)] sm:max-w-lg sm:rounded-md sm:border sm:border-border",!h&&"sm:data-[state=closed]:zoom-out-95 sm:data-[state=open]:zoom-in-95",!h&&"sm:data-[state=closed]:slide-out-to-left-[var(--ui-space-50pct)] sm:data-[state=closed]:slide-out-to-top-[var(--ui-space-48pct)]",!h&&"sm:data-[state=open]:slide-in-from-left-[var(--ui-space-50pct)] sm:data-[state=open]:slide-in-from-top-[var(--ui-space-48pct)]",i),style:h?{transform:`translate(calc(-50% + ${g.x}px), calc(-50% + ${g.y}px))`,cursor:x?"grabbing":void 0}:{transform:"translate(-50%, -50%)"},children:M})]})]})}));Yr.displayName="Modal";function oo({onConfirm:e,variant:t="default",...r}){return o.jsx(Yr,{...r,children:o.jsxs("div",{className:"flex justify-end gap-[var(--ui-space-2)] p-[var(--ui-component-padding-y)]",children:[o.jsx(oe,{variant:"outline",onClick:()=>r.onClose?.()||r.onOpenChange?.(!1),children:"Cancel"}),o.jsx(oe,{variant:t,onClick:e,children:"Confirm"})]})})}const Dt=4,Op=e=>e?e.replace(/[^0-9]/g,"").slice(0,Dt):"",Ip=e=>{const t=e.padEnd(Dt,"_");return`${t.slice(0,2)}:${t.slice(2,4)}`},$p=e=>{if(e.length!==Dt)return!1;const t=Number.parseInt(e.slice(0,2),10),r=Number.parseInt(e.slice(2,4),10);return t>=0&&t<=23&&r>=0&&r<=59},Fp=e=>`${e.slice(0,2)}:${e.slice(2,4)}`,Lp=m.memo(({open:e,title:t,onClose:r,displayContent:n,errorMessage:s,onNumberClick:a,onBackspace:i,onClear:c,onConfirm:l,additionalButton:u})=>o.jsx(Yr,{open:e,onOpenChange:f=>!f&&r(),title:t,onClose:r,children:o.jsxs("div",{className:"flex flex-col gap-[var(--ui-space-4)]",children:[o.jsx("div",{className:"bg-card border-2 border-theme-text-primary rounded-lg p-[var(--ui-modal-padding)] min-h-[var(--ui-space-15)] flex items-center justify-center text-lg font-semibold text-foreground",children:n}),s&&o.jsx("div",{className:"text-destructive text-sm text-center p-ui-gap bg-destructive/10 rounded-md border-l-[3px] border-destructive",children:s}),o.jsxs("div",{className:"grid grid-cols-3 gap-ui-gap",children:[[1,2,3,4,5,6,7,8,9].map(f=>o.jsx("button",{type:"button",onClick:()=>a(f.toString()),className:"min-h-[var(--ui-keypad-button-height)] text-lg font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:f},f)),u||o.jsx("div",{className:"min-h-[var(--ui-keypad-button-height)] bg-card rounded-lg"}),o.jsx("button",{type:"button",onClick:()=>a("0"),className:"min-h-[var(--ui-keypad-button-height)] text-lg font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:"0"}),o.jsx("button",{type:"button",onClick:i,className:"min-h-[var(--ui-keypad-button-height)] text-base font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:"⌫"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-ui-gap mt-[var(--ui-space-2)]",children:[o.jsx("button",{type:"button",onClick:c,className:"min-h-[var(--ui-keypad-button-height)] text-base font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:bg-destructive active:text-white active:border-theme-danger hover:bg-destructive hover:text-white hover:border-theme-danger",children:"C"}),o.jsx("button",{type:"button",onClick:l,className:"min-h-[var(--ui-keypad-button-height)] text-base font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:"OK"})]})]})})),Vp={number:{titleKey:"keypad_title_number",placeholder:"",maxLength:10},phone:{titleKey:"keypad_title_phone",placeholder:"090-0000-0000",maxLength:13},time:{titleKey:"keypad_title_time",placeholder:"__:__",maxLength:Dt}},Es=m.memo(({open:e,onClose:t,onSubmit:r,variant:n="number",initialValue:s="",title:a,placeholder:i,maxLength:c,allowDecimal:l=!1})=>{const{t:u}=Le(),f=m.useMemo(()=>n==="time"?Op(s):s,[n,s]),[d,h]=m.useState(f),[p,w]=m.useState(""),[g,y]=m.useState(!0),x=m.useMemo(()=>Vp[n],[n]),v=a??u(x.titleKey),_=i??x.placeholder,b=n==="time"?Dt:c??x.maxLength,S=n==="number"&&l,C=n==="phone",j=n==="time";m.useEffect(()=>{e&&(h(f),w(""),y(!0))},[e,f]);const N=m.useCallback(L=>{if(y(!1),j){h(I=>{const P=g?"":I;return P.length>=Dt?(w(u("keypad_error_max_length",{defaultValue:`Up to ${Dt} characters`,max:Dt})),P):(w(""),P.length===0&&Number.parseInt(L,10)>=3?`0${L}`:(P+L).slice(0,Dt))});return}h(I=>{const P=g?"":I;return P.length>=b?(w(u("keypad_error_max_length",{defaultValue:`Up to ${b} characters`,max:b})),P):(w(""),`${P}${L}`)})},[b,j,g,u]),E=m.useCallback(()=>{C&&(y(!1),h(L=>{const I=g?"":L;return I.length>=b?(w(u("keypad_error_max_length",{defaultValue:`Up to ${b} characters`,max:b})),I):I.endsWith("-")?(w(u("keypad_error_hyphen_repeat")),I):(w(""),`${I}-`)}))},[C,b,g,u]),R=m.useCallback(()=>{S&&(y(!1),h(L=>{const I=g?"":L;return I.includes(".")?(w(u("keypad_error_decimal_repeat")),I):(w(""),`${I}.`)}))},[S,g,u]),M=m.useCallback(()=>{y(!1),h(L=>L.slice(0,-1)),w("")},[]),A=m.useCallback(()=>{y(!1),h(""),w("")},[]),$=m.useCallback(()=>{if(j){h(L=>$p(L)?(r(Fp(L)),L):(w(u("keypad_error_time_invalid")),L));return}h(L=>L===""?(w(u("keypad_error_value_required")),L):S&&L.endsWith(".")?(w(u("keypad_error_decimal_end")),L):C&&L.endsWith("-")?(w(u("keypad_error_hyphen_end")),L):(r(L),L))},[S,C,j,r,u]);m.useEffect(()=>{if(!e)return;const L=I=>{I.key>="0"&&I.key<="9"||I.code>="Numpad0"&&I.code<="Numpad9"?(I.preventDefault(),N(I.key)):C&&(I.key==="-"||I.code==="NumpadSubtract"||I.key==="Minus")?(I.preventDefault(),E()):S&&(I.key==="."||I.code==="NumpadDecimal")?(I.preventDefault(),R()):I.key==="Backspace"?(I.preventDefault(),M()):I.key==="Enter"?(I.preventDefault(),$()):I.key==="Escape"&&(I.preventDefault(),t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[e,C,S,t,N,E,R,M,$]);const O=j?o.jsxs("div",{className:"flex flex-col items-center justify-center gap-[var(--ui-space-2)] w-full",children:[o.jsx("span",{style:{fontSize:"24px",fontFamily:"monospace",color:"hsl(var(--foreground))",letterSpacing:"2px",fontWeight:600},children:Ip(d)}),o.jsxs("span",{style:{fontSize:"12px",color:"var(--theme-text-secondary)"},children:["入力: ",d.padEnd(Dt,"・")]})]}):o.jsx("span",{style:{fontSize:"24px",fontFamily:"monospace",color:"hsl(var(--foreground))",fontWeight:600},children:d||o.jsx("span",{style:{color:"var(--theme-text-secondary)"},children:_})}),B=m.useMemo(()=>{if(C||S){const L=C?"-":".",I=C?E:R;return o.jsx("button",{type:"button",onClick:I,className:"min-h-[var(--ui-keypad-button-height)] text-lg font-semibold bg-background text-foreground border-2 border-theme-text-primary rounded-lg cursor-pointer transition-all active:scale-95 active:brightness-90 hover:brightness-110",children:L})}},[C,S,E,R]);return o.jsx(Lp,{open:e,title:v,onClose:t,displayContent:O,errorMessage:p,onNumberClick:N,onBackspace:M,onClear:A,onConfirm:$,additionalButton:B})});Es.displayName="KeypadModal";const wn=k.createContext(null),Wt=({children:e,value:t,onValueChange:r,defaultValue:n,disabled:s})=>{const[a,i]=k.useState(n||""),[c,l]=k.useState(!1),[u,f]=k.useState(null),d=t!==void 0?t:a,h=p=>{i(p),r?.(p),l(!1)};return o.jsx(wn.Provider,{value:{value:d,onValueChange:h,open:c,setOpen:l,label:u,setLabel:f,disabled:s},children:o.jsx("div",{className:"relative",children:e})})},Rt=k.forwardRef(({className:e,children:t,...r},n)=>{const s=k.useContext(wn);if(!s)throw new Error("SelectTrigger must be used within Select");return o.jsxs("button",{ref:n,type:"button",disabled:s.disabled||r.disabled,onClick:()=>!s.disabled&&s.setOpen(!s.open),className:de("flex w-full items-center justify-between rounded-md border border-input bg-background px-ui py-ui text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:[t,o.jsx(ye.ChevronDown,{className:"h-ui-icon w-ui-icon opacity-50"})]})});Rt.displayName="SelectTrigger";const Pt=k.forwardRef(({className:e,placeholder:t,...r},n)=>{const s=k.useContext(wn);if(!s)throw new Error("SelectValue must be used within Select");return o.jsx("span",{ref:n,className:de("block truncate",e),...r,children:r.children||s.label||s.value||t})});Pt.displayName="SelectValue";const Mt=k.forwardRef(({className:e,children:t,...r},n)=>{const s=k.useContext(wn);if(!s)throw new Error("SelectContent must be used within Select");return s.open?o.jsx("div",{ref:n,className:de("absolute z-50 min-w-[var(--ui-space-32)] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80 w-full mt-[var(--ui-space-1)]",e),...r,children:o.jsx("div",{className:"p-[var(--ui-space-1)] max-h-[var(--ui-space-60)] overflow-y-auto",children:t})}):null});Mt.displayName="SelectContent";const at=k.forwardRef(({className:e,children:t,value:r,...n},s)=>{const a=k.useContext(wn);if(!a)throw new Error("SelectItem must be used within Select");const i=a.value===r;return k.useEffect(()=>{i&&a.setLabel(t)},[i,t,a]),o.jsxs("button",{ref:s,type:"button",className:de("relative flex w-full cursor-default select-none items-center rounded-sm py-[var(--ui-space-1-5)] pl-[var(--ui-space-8)] pr-[var(--ui-space-2)] text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",i?"bg-accent/50":"",e),onClick:()=>{a.setLabel(t),a.onValueChange(r)},...n,children:[o.jsx("span",{className:"absolute left-[var(--ui-space-2)] flex h-[var(--ui-space-3-5)] w-[var(--ui-space-3-5)] items-center justify-center",children:i&&o.jsx("span",{className:"h-[var(--ui-space-2)] w-[var(--ui-space-2)] rounded-full bg-current"})}),o.jsx("span",{className:"truncate",children:t})]})});at.displayName="SelectItem";const mn=k.forwardRef(({className:e,...t},r)=>o.jsx("textarea",{className:de("flex min-h-[var(--ui-space-20)] w-full rounded-md border border-input bg-background px-ui py-ui text-sm ring-offset-background 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",e),ref:r,...t}));mn.displayName="Textarea";function Bl(e){if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(/,|、/).map(t=>t.trim()).filter(Boolean).map(t=>({name:t,type:"external"}))}function Wl(e){return e.length>0?JSON.stringify(e):"[]"}function Ul({personnel:e,currentUserId:t,isEditMode:r}){const n=m.useMemo(()=>s=>{let a=[];try{if(s&&s!=="[]"){const i=JSON.parse(s);Array.isArray(i)&&(a=i)}}catch{}if(!r&&t&&e&&!a.some(c=>c.personnelId===t)){const c=e.find(l=>l.id===t);c&&a.push({name:c.name,personnelId:c.id,type:"personnel"})}return{finalAttendees:a.length>0?JSON.stringify(a):"[]",shouldDelete:!1}},[r,t,e]);return{parseAttendees:Bl,stringifyAttendees:Wl,processAttendeesForSubmit:n}}function Zl(e,t,r,n){const{start:s,end:a}=r;if(Number.isNaN(s.getTime())||Number.isNaN(a.getTime()))return e.map(l=>({resourceId:l.id,isAvailable:!0,conflictingEvents:[],todaySchedule:[]}));const i=new Date(s);i.setHours(0,0,0,0);const c=new Date(s);return c.setHours(23,59,59,999),e.map(l=>{const u=l.id,f=t.filter(p=>p.resourceId===u&&p.id!==n&&p.status!=="cancelled"),d=f.filter(p=>{const w=p.isAllDay??p.extendedProps?.isAllDay,g=w===!0||w==="true"||w===1||w==="1",y=new Date(p.startDate);let x=new Date(p.endDate);return g&&(y.setHours(0,0,0,0),x<=y||x.getDate()===y.getDate()&&x.getFullYear()===y.getFullYear()&&x.getMonth()===y.getMonth()?(x=new Date(y),x.setDate(x.getDate()+1)):(x.setHours(0,0,0,0),x<=y&&(x=new Date(y),x.setDate(x.getDate()+1)))),s<x&&a>y}),h=f.filter(p=>{const w=new Date(p.startDate),g=new Date(p.endDate);return i<g&&c>w});return h.sort((p,w)=>p.startDate.getTime()-w.startDate.getTime()),{resourceId:u,isAvailable:d.length===0,conflictingEvents:d,todaySchedule:h}})}function Yl({resources:e,groups:t,events:r,timeRange:n,currentEventId:s,externalAvailability:a}){const i=m.useMemo(()=>a||Zl(e,r,n,s),[a,e,r,n,s]),c=m.useMemo(()=>e.filter(f=>i.find(h=>h.resourceId===f.id)?.isAvailable??!0),[e,i]),l=m.useMemo(()=>c.map(f=>{const d=t.find(h=>h.id===f.groupId);return d?`${f.name} (${d.name})`:f.name}),[c,t]),u=m.useMemo(()=>f=>{const d=e.find(p=>p.id===f);if(!d)return f;const h=t.find(p=>p.id===d.groupId);return h?`${d.name} (${h.name})`:d.name},[e,t]);return{availabilityList:i,availableResources:c,resourceNames:l,getDisplayName:u}}function As(e,t){return Nc({start:e.startDate,end:e.endDate},{start:t.startDate,end:t.endDate})}function io(e,t){for(const r of t)if(r.status!=="cancelled"&&r.id!==e.id&&r.resourceId===e.resourceId&&As(r,e))return{resourceId:e.resourceId,existingSchedule:r,newSchedule:e,conflictType:"double-booking"};return null}function Ts(e,t,r){return e.filter(n=>Nc({start:n.startDate,end:n.endDate},{start:t,end:r}))}function wa(e,t){return e.filter(r=>r.resourceId===t)}function zp(e,t){return Ts(e,dt(t),Rf(t))}function co(e){return[...e].sort((t,r)=>t.startDate.getTime()-r.startDate.getTime())}function Hp(e){return[...e].sort((t,r)=>t.order-r.order)}function Bp(e){return(e.endDate.getTime()-e.startDate.getTime())/(1e3*60*60)}function Wp(e){const t=Ne(e.startDate,void 0,"time24"),r=Ne(e.endDate,void 0,"time24");return`${e.title} (${t}-${r})`}const Ar=new Map,Up=100;function lo(e,t){const r=dt(e),n=dt(t),s=`${r.getTime()}-${n.getTime()}`;if(Ar.has(s)){const c=Ar.get(s);if(c!==void 0)return c}const a=[];let i=r;for(;i<=n;)a.push(i),i=kr(i,1);if(Ar.size>=Up){const c=Ar.keys().next().value;c&&Ar.delete(c)}return Ar.set(s,a),a}function uo(e){switch(e){case 0:case 1:case 2:case 3:case 4:case 5:case 6:return e;default:return 1}}function Rs(e,t=1){return an(e,{weekStartsOn:t})}function fo(e,t=1){return pa(e,{weekStartsOn:t})}function ho(e){return ma(e)}function Gl(e){return Dc(e)}function Zp(e){const t=e.map(r=>({...r,hasConflict:!1}));for(let r=0;r<t.length;r++){const n=t[r];if(!(!n||n.status==="cancelled"))for(let s=r+1;s<t.length;s++){const a=t[s];!a||a.status==="cancelled"||n.resourceId===a.resourceId&&As(n,a)&&(n.hasConflict=!0,a.hasConflict=!0)}}return t}function ql(e,t,r){const n=r.startTime.split(":"),s=r.endTime.split(":"),a=Number(n[0]??0),i=Number(s[0]??23);if(t==="day"){const c=dt(e);c.setHours(a);const l=dt(e);if(i>=24){const u=Math.floor(i/24),f=i%24,d=kr(l,u);return d.setHours(f,59,59,999),{start:c,end:d}}else return l.setHours(i,59,59,999),{start:c,end:l}}if(t==="week"){const c=uo(r.weekStartsOn),l=Rs(e,c),u=fo(e,c);return{start:l,end:u}}return{start:ho(e),end:Gl(e)}}function Xl({startDate:e,duration:t,resourceId:r,events:n,currentEventId:s}){return m.useMemo(()=>{const a=new Date(e),i=new Date(a),c=(Number(t)||0)*60;if(i.setMinutes(i.getMinutes()+c),!r||Number.isNaN(a.getTime()))return null;const l=n.filter(u=>u.id!==s);return io({startDate:a,endDate:i,resourceId:r},l)},[e,t,r,n,s])}const Yp=e=>{const t=Math.floor(e),r=Math.round((e-t)*60);return t===0?`${r}m`:r===0?`${t}h`:`${t}h ${r}m`},Gp=(e,t)=>{const r=e?.[t];return typeof r=="string"?r:void 0},qp=Fe({title:J().min(1,"required"),attendee:J().optional(),resourceId:J().optional(),startDate:J().min(1,"required"),durationHours:we().min(.25).max(24),note:J().optional(),isRecurring:qe().optional(),scheduleType:J().optional(),endDate:J().optional(),isAllDay:qe().optional()}),Di=[];function Kl({event:e,resources:t,groups:r,events:n,resourceAvailability:s,defaultResourceId:a,defaultStartTime:i,onSubmit:c,onCancel:l,onDelete:u,readOnlyResource:f=!1,personnel:d=Di,currentUserId:h,onAvailabilityRequest:p,customFields:w=Di}){const{t:g,i18n:y}=Le(),x=!!e,[v,_]=m.useState(!1),b=m.useMemo(()=>{const P={};return w.forEach(z=>{let H;z.type==="number"?(H=ys([we(),J().transform(te=>te===""?void 0:Number(te))]),z.required?H=Qn.number().min(1,"required"):H=Qn.number().optional()):z.type==="boolean"?H=qe().optional():(H=J(),z.required?H=H.min(1,"required"):H=H.optional()),P[z.name]=H}),qp.extend(P)},[w]),S=m.useMemo(()=>{const P={title:Gp(e?.extendedProps,"originalTitle")??e?.title??"",attendee:e?.attendee||"[]",resourceId:e?.resourceId||a||"",startDate:Pr(e?.startDate||i||new Date),durationHours:e?Math.round((e.endDate.getTime()-e.startDate.getTime())/36e5*100)/100:1,note:e?.note||"",isRecurring:!1,isAllDay:e?.isAllDay||!1},z={};return w.forEach(H=>{const te=e?.extendedProps?.[H.name];z[H.name]=te!==void 0?te:H.defaultValue??""}),{...P,...z}},[e,a,i,w]),C=uc({resolver:fc(b),defaultValues:S});m.useEffect(()=>{C.reset(S)},[S,C]);const j=C.watch("isAllDay"),N=C.watch("startDate"),E=C.watch("durationHours"),R=C.watch("resourceId"),M=new Date(N);if(!Number.isNaN(M.getTime())){const P=(Number(E)||0)*60;M.setTime(new Date(N).getTime()+P*6e4)}const{availableResources:A,getDisplayName:$}=Yl({resources:t,groups:r,events:n,timeRange:{start:new Date(N),end:M},currentEventId:e?.id,externalAvailability:s});m.useEffect(()=>{if(p){const P=new Date(N);if(!Number.isNaN(P.getTime())){const z=new Date(P),H=(Number(E)||0)*60;z.setMinutes(z.getMinutes()+H),p({startDate:P,endDate:z})}}},[N,E,p]);const O=Xl({startDate:N,duration:E,resourceId:R,events:n,currentEventId:e?.id}),{parseAttendees:B,processAttendeesForSubmit:L}=Ul({personnel:d,currentUserId:h,isEditMode:x}),I=P=>{const z=new Date(P.startDate);P.isAllDay&&z.setHours(0,0,0,0);const H=new Date(z),te=(Number(P.durationHours)||0)*60;H.setMinutes(H.getMinutes()+te);const{finalAttendees:G,shouldDelete:V}=L(P.attendee||"[]");if(V&&u){u();return}const{startDate:W,endDate:se,title:ne,attendee:fe,resourceId:pe,note:Ae,durationHours:xe,isAllDay:Ze,isRecurring:Ye,scheduleType:Xe,...Ke}=P,kt={...e?.extendedProps??{},...Ke};w.forEach(Xt=>{P[Xt.name]!==void 0&&(kt[Xt.name]=P[Xt.name])});const mt={title:ne,attendee:G,resourceId:pe||void 0,startDate:z,endDate:H,status:e?.status??"booked",note:Ae,durationHours:xe,isAllDay:!!P.isAllDay,extendedProps:kt};c(mt)};return o.jsxs(ro,{...C,children:[o.jsxs("form",{onSubmit:C.handleSubmit(I),className:"space-y-[var(--ui-space-4)] text-foreground",children:[o.jsx(Re,{control:C.control,name:"title",render:({field:P})=>o.jsxs(De,{children:[o.jsxs(_e,{children:[g("event_name_label")||"Event Name"," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx(be,{children:o.jsx(xt,{...P,placeholder:g("event_name_placeholder")||"Enter event name",autoFocus:!0})}),o.jsx(nt,{})]})}),o.jsx(Re,{control:C.control,name:"attendee",render:({field:P})=>o.jsxs(De,{children:[o.jsx(_e,{children:g("attendee_label")||"Attendee"}),o.jsx(be,{children:o.jsx(Da,{value:B(P.value),onChange:z=>P.onChange(JSON.stringify(z)),personnel:d||[],placeholder:g("attendee_placeholder")||"Enter attendee name"})}),o.jsx(nt,{})]})}),o.jsx(Re,{control:C.control,name:"resourceId",render:({field:P})=>{const z=$(P.value||"");return o.jsxs(De,{children:[o.jsx(_e,{children:g("resource_label")}),f?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-ui py-ui bg-muted rounded-md text-sm border border-input min-h-ui flex items-center",children:z||g("resource_placeholder")}),o.jsx("input",{type:"hidden",...P})]}):o.jsx(be,{children:o.jsxs(Wt,{onValueChange:P.onChange,value:P.value||"",children:[o.jsx(be,{children:o.jsx(Rt,{children:o.jsx(Pt,{placeholder:g("resource_placeholder"),children:z})})}),o.jsx(Mt,{children:A.map(H=>o.jsx(at,{value:H.id,children:$(H.id)},H.id))})]})}),o.jsx(nt,{})]})}}),w.map(P=>o.jsx(Re,{control:C.control,name:P.name,render:({field:z})=>o.jsxs(De,{children:[o.jsxs(_e,{children:[P.label,P.required&&o.jsx("span",{className:"text-red-500",children:" *"})]}),o.jsx(be,{children:P.type==="select"?o.jsxs(Wt,{onValueChange:z.onChange,value:String(z.value||""),children:[o.jsx(be,{children:o.jsx(Rt,{children:o.jsx(Pt,{placeholder:"Select..."})})}),o.jsx(Mt,{children:P.options?.map(H=>o.jsx(at,{value:H.value,children:H.label},H.value))})]}):P.type==="boolean"?o.jsxs("div",{className:"flex items-center space-x-[var(--ui-space-2)]",children:[o.jsx(dn,{checked:!!z.value,onCheckedChange:z.onChange}),o.jsx("span",{className:"text-sm text-muted-foreground",children:P.label})]}):P.type==="number"?o.jsx(xt,{type:"number",...z,value:String(z.value||""),onChange:z.onChange}):o.jsx(xt,{...z,value:String(z.value||"")})}),o.jsx(nt,{})]})},P.name)),o.jsxs("div",{className:"space-y-[var(--ui-space-2)]",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(_e,{className:"text-base font-semibold",children:[g("date_time_label")||"Date & Time"," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx(Re,{control:C.control,name:"isAllDay",render:({field:P})=>o.jsxs(De,{className:"flex flex-row items-center space-x-[var(--ui-space-2)] space-y-[var(--ui-space-0)]",children:[o.jsx(be,{children:o.jsx(dn,{checked:!!P.value,onCheckedChange:P.onChange,id:"isAllDay-checkbox"})}),o.jsx("label",{htmlFor:"isAllDay-checkbox",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:g("all_day")||"All Day"})]})})]}),o.jsxs("div",{className:"grid grid-cols-4 gap-[var(--ui-space-4)] items-start",children:[o.jsx(Re,{control:C.control,name:"startDate",render:({field:P})=>o.jsxs(De,{className:"space-y-[var(--ui-space-1-5)]",children:[o.jsx(_e,{className:"text-xs text-muted-foreground",children:g("date_label")||"Date"}),o.jsx(be,{children:o.jsx(to,{value:new Date(P.value),disabled:j,onChange:z=>{if(z){const H=new Date(P.value);j?z.setHours(0,0,0,0):z.setHours(H.getHours(),H.getMinutes()),P.onChange(Pr(z))}},className:"w-full"})}),o.jsx(nt,{})]})}),j?o.jsx("div",{"aria-hidden":"true"}):o.jsx(Re,{control:C.control,name:"startDate",render:({field:P})=>o.jsxs(De,{className:"space-y-[var(--ui-space-1-5)]",children:[o.jsx(_e,{className:"text-xs text-muted-foreground",children:g("time_label")||"Time"}),o.jsx(be,{children:o.jsx(xt,{value:Ne(new Date(P.value),y.language,"time24"),readOnly:!0,className:"cursor-pointer w-full text-center",onClick:()=>_(!0),tabIndex:-1})}),o.jsx(nt,{})]})}),j?o.jsx("div",{"aria-hidden":"true"}):o.jsx(Re,{control:C.control,name:"durationHours",render:({field:P})=>o.jsxs(De,{className:"space-y-[var(--ui-space-1-5)]",children:[o.jsx(_e,{className:"text-xs text-muted-foreground",children:g("duration_label")}),o.jsxs(Wt,{onValueChange:z=>P.onChange(Number(z)),value:String(P.value),disabled:j,children:[o.jsx(be,{children:o.jsx(Rt,{className:"w-full",children:o.jsx(Pt,{})})}),o.jsx(Mt,{className:"max-h-[var(--ui-space-50)]",children:[.25,.5,.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.5,4,4.5,5,6,8].map(z=>o.jsx(at,{value:String(z),children:Yp(z)},z))})]}),o.jsx(nt,{})]})}),j?o.jsx("div",{"aria-hidden":"true"}):o.jsxs("div",{className:"space-y-[var(--ui-space-1-5)]",children:[o.jsx(_e,{className:"text-xs text-muted-foreground",children:"End Time"}),o.jsx("div",{className:"h-[var(--ui-component-height)] px-3 py-1 flex items-center justify-center border border-transparent text-sm text-foreground/80 font-medium whitespace-nowrap",children:Number.isNaN(M.getTime())?"-":Ne(M,y.language,"time24")})]})]})]}),O&&o.jsxs("div",{className:"p-[var(--ui-space-4)] bg-red-50 border border-red-500 rounded text-red-800 flex items-start gap-[var(--ui-space-2)]",children:[o.jsx(ye.AlertTriangle,{className:"w-[var(--ui-space-5)] h-[var(--ui-space-5)] flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("strong",{className:"block text-sm",children:"Conflict Detected"}),o.jsxs("span",{className:"text-xs",children:[g("event_form_conflict_warning")," (",Ne(O.existingSchedule.startDate,y.language,"time24")," ","-"," ",Ne(O.existingSchedule.endDate,y.language,"time24"),")"]})]})]}),o.jsx(Re,{control:C.control,name:"note",render:({field:P})=>o.jsxs(De,{children:[o.jsx(_e,{children:g("note_label")}),o.jsx(be,{children:o.jsx(mn,{...P,value:P.value||"",placeholder:"Add notes...",rows:2})})]})}),o.jsxs("div",{className:"flex gap-[var(--ui-space-3)] pt-[var(--ui-space-4)] border-t border-border",children:[x&&u&&o.jsx(oe,{type:"button",variant:"outline-delete",size:"sm",onClick:u,className:"flex-1",children:g("delete_button")}),o.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:l,className:"flex-1",children:g("cancel_button")}),o.jsx(oe,{type:"submit",variant:"default",size:"sm",className:"flex-1",children:g("save_button")})]})]}),o.jsx(Es,{open:v,onClose:()=>_(!1),onSubmit:P=>{const z=new Date(C.getValues("startDate")),[H,te]=P.split(":").map(Number);z.setHours(H||0,te||0),C.setValue("startDate",Pr(z)),_(!1)},initialValue:Ne(new Date(C.getValues("startDate")),y.language,"time24"),variant:"time"})]})}function mo({isOpen:e,event:t,resources:r,groups:n,events:s,defaultResourceId:a,defaultStartTime:i,onClose:c,onSave:l,onDelete:u,readOnlyResource:f,personnel:d=[],currentUserId:h,resourceAvailability:p,onAvailabilityRequest:w,customFields:g}){const{t:y}=Le(),x=!!t,[v,_]=m.useState(!1),[b,S]=m.useState({open:!1,title:"",onConfirm:()=>{}});m.useEffect(()=>{if(e){_(!1);const j=setTimeout(()=>{_(!0)},500);return()=>clearTimeout(j)}_(!1)},[e]);const C=()=>{!t||!u||S({open:!0,title:y("confirm_delete_title"),description:y("confirm_delete_message"),onConfirm:()=>{u(t.id),S(j=>({...j,open:!1})),c()}})};return o.jsxs(Yr,{open:e,onOpenChange:j=>!j&&c(),title:y(x?"event_edit_title":"event_create_title"),className:"sm:max-w-3xl",children:[o.jsx("div",{style:{pointerEvents:v?"auto":"none"},children:o.jsx(Kl,{event:t,resources:r,groups:n,events:s,personnel:d,resourceAvailability:p,defaultResourceId:a,defaultStartTime:i,onSubmit:l,onCancel:c,onDelete:x&&u?C:void 0,readOnlyResource:f,currentUserId:h,onAvailabilityRequest:w,customFields:g})}),o.jsx(oo,{open:b.open,onOpenChange:j=>S(N=>({...N,open:j})),title:b.title,description:b.description,onConfirm:b.onConfirm,variant:"destructive"})]})}const Jl=m.createContext(void 0);function Ql(){const e=m.useContext(Jl);if(!e)throw new Error("useScheduleContext must be used within a ScheduleProvider");return e}function Xp({children:e,apiClient:t,onError:r}){const n=m.useRef(t);m.useEffect(()=>{n.current=t},[t]);const s=m.useRef(null),[a,i]=m.useState([]),[c,l]=m.useState([]),[u,f]=m.useState([]),[d,h]=m.useState([]),[p,w]=m.useState(null),[g,y]=m.useState([]),[x,v]=m.useState(!0),[_,b]=m.useState(null),[S,C]=m.useState(new Map);m.useEffect(()=>{(async()=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot load data."),v(!1);return}try{const V=t.getConfig(),W=t.getEvents();s.current||(s.current=t.getPersonnel().catch(Ae=>{throw s.current=null,Ae}));const[se,ne,fe]=await Promise.all([V,W,s.current]);h(se.groups),f(se.resources),w(se.settings);const pe=ne.filter(Ae=>!!Ae.resourceId);i(pe),y(fe)}catch(V){console.error("Failed to load schedule data",V),b(V instanceof Error?V.message:"Unknown error")}finally{v(!1)}})()},[t]);const j=m.useCallback(async G=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot create event.");return}try{const V=await t.createEvent(G);i(W=>[...W,V]),l(W=>[...W,V]),C(new Map)}catch(V){console.error("Failed to create event",V);const W=V instanceof Error?V:new Error(String(V));throw r?.(W),W}},[t,r]),N=m.useCallback(async(G,V)=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot update event.");return}try{const W=await t.updateEvent(G,V);i(se=>se.map(ne=>ne.id===G?W:ne)),l(se=>se.map(ne=>ne.id===G?W:ne)),C(new Map)}catch(W){console.error("Failed to update event",W);const se=W instanceof Error?W:new Error(String(W));throw r?.(se),se}},[t,r]),E=m.useCallback(async G=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot delete event.");return}try{await t.deleteEvent(G),i(V=>V.filter(W=>W.id!==G)),l(V=>V.filter(W=>W.id!==G)),C(new Map)}catch(V){console.error("Failed to delete event",V);const W=V instanceof Error?V:new Error(String(V));throw r?.(W),W}},[t,r]),R=m.useCallback(async G=>{const V=await t.createGroup(G);return h(W=>[...W,V]),V},[t]),M=m.useCallback(async(G,V)=>{const W=await t.updateGroup(G,V);return h(se=>se.map(ne=>ne.id===G?W:ne)),W},[t]),A=m.useCallback(async G=>{await t.deleteGroup(G),h(V=>V.filter(W=>W.id!==G))},[t]),$=m.useCallback(async G=>{const V=await t.createResource(G);return f(W=>[...W,V]),V},[t]),O=m.useCallback(async(G,V)=>{const W=await t.updateResource(G,V);return f(se=>se.map(ne=>ne.id===G?W:ne)),W},[t]),B=m.useCallback(async G=>{await t.deleteResource(G),f(V=>V.filter(W=>W.id!==G))},[t]),L=m.useCallback(async(G,V)=>{try{const W=await t.updatePersonnelPriority(G,V);y(se=>{const ne=se.map(fe=>fe.id===G?W:fe);return ne.sort((fe,pe)=>pe.priority!==fe.priority?pe.priority-fe.priority:fe.name.localeCompare(pe.name,"ja")),ne})}catch(W){console.error("Failed to update personnel priority",W);const se=W instanceof Error?W:new Error(String(W));throw r?.(se),se}},[t,r]),I=m.useCallback(async(G,V=!1)=>{if(!t){console.error("ScheduleProvider: apiClient is undefined. Cannot fetch personnel events.");return}if(G.length===0){V||l([]);return}try{const W=await t.getEvents(G);l(V?se=>{const ne=new Set(se.map(pe=>pe.id)),fe=W.filter(pe=>!ne.has(pe.id));return[...se,...fe]}:W)}catch(W){throw console.error("Failed to fetch personnel events",W),W}},[t]),P=m.useCallback((G,V)=>{const W=new Date(G);return W.setHours(0,0,0,0),`${W.toISOString().split("T")[0]}_${V}`},[]),z=m.useCallback((G,V="day")=>{const W=P(G,V);return S.get(W)},[S,P]),H=m.useCallback(async(G,V="day")=>{const W=P(G,V),se=S.get(W);if(se)return se;try{const ne=await t.getResourceAvailability({date:G,view:V});return C(fe=>{const pe=new Map(fe);return pe.set(W,ne),pe}),ne}catch(ne){return console.error("Failed to fetch resource availability",ne),[]}},[S,t,P]),te={events:a,personnelEvents:c,resources:u,groups:d,settings:p,personnel:g,loading:x,error:_,createEvent:j,updateEvent:N,deleteEvent:E,createGroup:R,updateGroup:M,deleteGroup:A,createResource:$,updateResource:O,deleteResource:B,updatePersonnelPriority:L,fetchPersonnelEvents:I,fetchResourceAvailability:H,getResourceAvailabilityFromCache:z};return o.jsx(Jl.Provider,{value:te,children:e})}const er={SLOT_HEIGHT:60,SLOT_WIDTH:50,HEADER_HEIGHT:64,TIME_COLUMN_WIDTH:64},tr={DAY_CELL_HEIGHT:110,DATE_COLUMN_WIDTH:56,MAX_VISIBLE_EVENTS:4};function po(e){const t=new Map,r=new Map,n=new Map;for(const s of e){if(s.resourceId){const l=t.get(s.resourceId)??[];l.push(s),t.set(s.resourceId,l)}const a=gr(s.startDate),i=r.get(a)??[];i.push(s),r.set(a,i);const c=n.get(s.groupId)??[];c.push(s),n.set(s.groupId,c)}return{byResource:t,byDay:r,byGroup:n}}const Fn=new Map;function gr(e){const r=e.getTime().toString(),n=Fn.get(r);if(n)return n;const s=new Date(e);s.setHours(0,0,0,0);const a=s.toISOString().split("T")[0]??"";return Fn.size>1e3&&Fn.clear(),Fn.set(r,a),a}function Kp(e,t){return t.byResource.get(e)??[]}function eu(e,t){const r=gr(e);return t.byDay.get(r)??[]}const Jp=({children:e})=>o.jsx(o.Fragment,{children:e}),Qp=({children:e})=>o.jsx("div",{className:"group contents",children:e}),eg=({children:e,asChild:t,...r})=>{if(t&&k.isValidElement(e)){const n=e;return k.cloneElement(n,{...r,className:de(n.props.className,"cursor-help")})}return o.jsx("span",{...r,className:"cursor-help inline-block",children:e})},tg=({children:e,className:t,...r})=>o.jsx("div",{className:de("absolute z-50 overflow-hidden rounded-md border bg-popover px-[var(--ui-space-3)] py-[var(--ui-space-1-5)] text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-[var(--ui-space-2)] data-[side=left]:slide-in-from-right-[var(--ui-space-2)] data-[side=right]:slide-in-from-left-[var(--ui-space-2)] data-[side=top]:slide-in-from-bottom-[var(--ui-space-2)]","hidden group-hover:block w-max max-w-xs bottom-full mb-[var(--ui-space-2)] left-[var(--ui-space-1)]/2 -translate-x-[var(--ui-space-1)]/2",t),...r,children:e});function Ni({event:e,top:t,height:r,widthPercent:n=100,leftPercent:s=0,onClick:a,isDragging:i=!1,components:c,orientation:l="vertical"}){const u=e.startDate.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),f=e.endDate.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),d=Math.round((e.endDate.getTime()-e.startDate.getTime())/(1e3*60*60)*10)/10,h=e.hasConflict?"bg-destructive border-destructive":e.color?"border-primary/30":"bg-primary border-primary/30",p=x=>x.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),w=`${d}h`,y=l==="horizontal"?{left:`${t}px`,width:`${r}px`,top:`${s}%`,height:`${n}%`,paddingTop:s>0?"1px":"2px",paddingBottom:s+n<100?"1px":"2px"}:{top:`${t}px`,height:`${r}px`,left:`${s}%`,width:`${n}%`,paddingLeft:s>0?"2px":"4px",paddingRight:s+n<100?"2px":"4px"};return e.color&&!e.hasConflict&&(y.backgroundColor=e.color),o.jsx(Jp,{children:o.jsxs(Qp,{children:[o.jsx(eg,{asChild:!0,children:o.jsx("button",{type:"button",className:`
|
|
46
46
|
absolute rounded-md shadow-sm border
|
|
47
47
|
transition-all duration-200 cursor-pointer
|
|
48
|
-
${
|
|
49
|
-
${
|
|
48
|
+
${i?"opacity-50 scale-95":"hover:shadow-md hover:scale-[1.02] hover:z-20"}
|
|
49
|
+
${h} text-primary-foreground text-center
|
|
50
50
|
${e.hasConflict?"ring-2 ring-red-400 ring-offset-1":""}
|
|
51
|
-
`,style:{...w,zIndex:20},onClick:a,children:i.jsx("div",{className:"p-[var(--ui-space-2)] h-full flex flex-col items-center justify-start overflow-hidden",children:c?.EventCard?i.jsx(c.EventCard,{event:e,viewMode:"day",onClick:a,className:"w-full h-full"}):i.jsxs(i.Fragment,{children:[e.hasConflict&&i.jsx("div",{className:"text-xs font-bold mb-[var(--ui-space-1)]",children:"⚠️ Double Booking"}),i.jsx("div",{className:"font-semibold text-sm leading-snug break-words",children:e.title}),!e.isAllDay&&i.jsxs("div",{className:"flex items-center justify-center gap-[var(--ui-space-1)] text-[10px] opacity-90 mt-[var(--ui-space-1)] overflow-hidden whitespace-nowrap",children:[i.jsx("span",{className:"font-mono tabular-nums tracking-tight",children:h(e.startDate)}),f>=.5&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"-"}),i.jsx("span",{className:"font-mono tabular-nums tracking-tight",children:h(e.endDate)}),i.jsxs("span",{className:"ml-[var(--ui-space-0-5)] opacity-75",children:["(",p,")"]})]})]})]})})})}),i.jsx(Yp,{children:i.jsxs("div",{className:"space-y-[var(--ui-space-1)]",children:[e.hasConflict&&i.jsx("p",{className:"font-bold text-xs text-red-600",children:"⚠️ Double Booking"}),i.jsx("p",{className:"font-semibold text-xs",children:e.title}),i.jsxs("p",{className:"text-xs",children:[l," - ",u," (",f,"h)"]}),e.note&&i.jsx("p",{className:"text-[10px] text-muted-foreground max-w-[var(--ui-space-45)] break-words",children:e.note}),e.description&&i.jsx("p",{className:"text-[10px] text-muted-foreground max-w-[var(--ui-space-45)] break-words italic",children:e.description})]})})]})})}function qp({resource:e,events:t,allDayEvents:r=[],startTime:n,endTime:s,currentDate:a,slotHeight:o,onEventClick:c,onEmptySlotClick:l,components:u}){const f=n.split(":"),d=s.split(":"),h=Number(f[0]??0),p=Number(d[0]??23),w=m.useRef(null),g=[];for(let x=h;x<=p;x++)g.push(x);const y=m.useMemo(()=>{const x=[...t];if(r.length>0&&r.forEach(E=>{const A={...E},T=new Date(a);T.setHours(h,0,0,0);const M=new Date(a);M.setHours(p,0,0,0),A.startDate=T,A.endDate=M,x.push(A)}),x.length===0)return[];const _=[...x].sort((E,A)=>E.startDate.getTime()-A.startDate.getTime()),k=[];for(const E of _){let A=!1;for(const T of k)if(T.some(R=>Ns(R,E))){T.push(E),A=!0;break}A||k.push([E])}const j=[];for(const E of k)if(E.length===1){const A=E[0];A&&j.push({...A,column:0,totalColumns:1})}else{const A=Math.min(E.length,4);for(let T=0;T<E.length;T++){const M=E[T];M&&j.push({...M,column:T%A,totalColumns:A})}}return j},[t,r,a,h,p]);function v(x){const _=x,k=new Date(a);k.setHours(0,0,0,0);const j=$=>($.getTime()-k.getTime())/(1e3*60*60),E=j(_.startDate),A=j(_.endDate),T=E-h,M=A-E,R=T*o,V=M*o,F=100/x.totalColumns,G=x.column*100/x.totalColumns;return{top:R,height:V,widthPercent:F,leftPercent:G}}function b(x){if(!l)return;const _=x.currentTarget.getBoundingClientRect(),k=x.clientY-_.top,j=Math.max(0,k/o),E=Math.floor(h+j),A=Math.round(j%1*60),T=new Date;T.setHours(E,A,0,0),l(e.id,T)}function C(){if(!l)return;const x=new Date;x.setHours(h,0,0,0),l(e.id,x)}return i.jsxs("div",{className:"flex-1 min-w-[var(--ui-space-22-5)] border-r border-border hover:bg-muted/5 flex flex-col",children:[i.jsx("div",{className:"h-[var(--ui-space-14)] border-b border-border bg-background flex items-center justify-center sticky top-[var(--ui-space-0)] z-20 shrink-0 py-[var(--ui-space-2)]",children:i.jsxs("div",{className:"text-center relative",children:[i.jsx("div",{className:"font-semibold text-sm",children:e.name}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.length+r.length," events"]}),i.jsx(ie,{type:"button",variant:"ghost",className:"sr-only focus:not-sr-only focus:absolute focus:right-[var(--ui-space-2)] focus:top-[var(--ui-space-2)]",onClick:x=>{x.stopPropagation(),C()},children:`Add event to ${e.name}`})]})}),i.jsxs("div",{ref:w,className:"relative flex-1 w-full cursor-pointer",onPointerUp:b,children:[i.jsx("div",{className:"absolute inset-[var(--ui-space-0)] z-0 pointer-events-none flex flex-col",children:g.map(x=>i.jsx("div",{className:"border-b border-border/50 w-full",style:{height:`${o}px`}},x))}),i.jsx("div",{className:"relative w-full z-10",children:y.map(x=>{const{top:_,height:k,widthPercent:j,leftPercent:E}=v(x);return i.jsx(Gp,{event:x,top:_,height:k,widthPercent:j,leftPercent:E,onClick:A=>{A.stopPropagation(),c?.(x)},components:u},x.id)})})]})]})}function Xp({startTime:e,endTime:t,slotHeight:r=60}){const n=Kp(e,t);return i.jsxs("div",{className:"flex flex-col border-r border-border h-full bg-background",children:[i.jsx("div",{className:"h-[var(--ui-space-14)] border-b border-border bg-background sticky top-[var(--ui-space-0)] z-30"}),n.map(s=>i.jsxs("div",{className:"border-b border-border flex items-start justify-end pe-2 py-[var(--ui-space-1)] text-xs text-muted-foreground font-medium",style:{height:`${r}px`},children:[s,":00"]},s))]})}function Kp(e,t){const r=e.split(":"),n=t.split(":"),s=Number(r[0]??0),a=Number(n[0]??23),o=[];for(let c=s;c<=a;c++)o.push(c);return o}function Jp({currentDate:e,resources:t,events:r,settings:n,onEventClick:s,onEmptySlotClick:a,components:o}){const c=n.startTime.split(":"),l=n.endTime.split(":"),u=Number(c[0]??0),d=(Number(l[0]??23)-u+1)*Jr.SLOT_HEIGHT+Jr.HEADER_HEIGHT,{allDayEvents:h,timedEvents:p}=m.useMemo(()=>{const{start:y,end:v}=zl(e,"day",n),b=Es(r,y,v),C=so(b);return{allDayEvents:C.filter(x=>x.isAllDay),timedEvents:C.filter(x=>!x.isAllDay)}},[r,e,n]),w=m.useMemo(()=>uo(p),[p]),g=m.useMemo(()=>{const y=new Map;for(const v of t){const b=Hp(v.id,w);y.set(v.id,b)}return y},[t,w]);return i.jsx("div",{className:"flex flex-col h-full",children:i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"flex",style:{minHeight:`${d}px`},children:[i.jsx("div",{className:"sticky left-[var(--ui-space-0)] z-30 bg-background",style:{width:`${Jr.TIME_COLUMN_WIDTH}px`},children:i.jsx(Xp,{startTime:n.startTime,endTime:n.endTime,slotHeight:Jr.SLOT_HEIGHT})}),i.jsx("div",{className:"flex flex-1",children:t.map(y=>i.jsx(qp,{resource:y,events:g.get(y.id)||[],allDayEvents:h.filter(v=>v.resourceId===y.id),startTime:n.startTime,endTime:n.endTime,currentDate:e,slotHeight:Jr.SLOT_HEIGHT,onEventClick:s,onEmptySlotClick:a,components:o},y.id))})]})})})}const Qp=e=>e.startsWith("ja")?"ja-JP":"en-GB",Ci=e=>{switch(e){case"japanese":return"ja-JP-u-ca-japanese";case"buddhist":return"th-TH-u-ca-buddhist";case"islamic":return"ar-SA-u-ca-islamic";case"chinese":return"zh-CN-u-ca-chinese";default:return null}},eg=e=>e==="full"||e==="date"||e==="weekday"||e==="weekdayShort"||e==="yearMonth"||e==="monthDay"||e==="monthDayShort"||e==="compact",tg=()=>typeof document>"u"?null:document.documentElement.getAttribute("data-secondary-calendar"),rg=()=>typeof document>"u"?!1:document.documentElement.getAttribute("data-prefer-local-calendar")==="true",ng=e=>e.startsWith("ja")?"japanese":e.startsWith("th")?"buddhist":e.startsWith("ar")?"islamic":e.startsWith("zh")?"chinese":null,ki=(e,t,r,n)=>{const s=a=>new Intl.DateTimeFormat(t,{...a,calendar:n}).format(e);switch(r){case"weekday":return s({weekday:"long"});case"weekdayShort":return s({weekday:"short"});case"date":return s({year:"numeric",month:"short",day:"numeric"});case"monthDayShort":return s({month:"short",day:"numeric",weekday:"short"});case"compact":return s({month:"numeric",day:"numeric",weekday:"short"});case"yearMonth":return s({year:"numeric",month:"long"});case"monthDay":return s({month:"long",day:"numeric"});default:return s({year:"numeric",month:"long",day:"numeric",weekday:"long"})}},tr=m.memo(({date:e,format:t="full",variant:r,className:n,showSecondary:s,showDayOfWeek:a,...o})=>{const{i18n:c}=$e(),l=c.language||"en",u=Qp(l),f=t==="full"&&eg(r)?r:t,d=()=>f==="full"||f==="yearMonth"||f==="monthDay"||f==="monthDayShort"||f==="compact"||f==="weekday"||f==="weekdayShort"?Ne(e,u,f):f==="date"?Ne(e,u,"picker"):Ne(e,u,"full"),h=()=>rg()?ng(l):null,p=()=>{const v=h();if(v){const b=Ci(v)??u;return ki(e,b,f,v)}return d()},w=()=>{if(!s)return null;const v=tg();if(!v||v==="none")return null;const b=h();if(v===b)return null;const C=Ci(v)??u;return ki(e,C,f,v)},g=p(),y=w();return i.jsxs("span",{className:de("inline-block",n),...o,children:[g,y&&i.jsxs("span",{className:"ml-[var(--ui-space-2)] text-muted-foreground",children:["(",y,")"]})]})});function Yl({value:e,valueScale:t="ratio",options:r,className:n,...s}){const a=t==="percent"?e/100:e,o=new Intl.NumberFormat("en-US",{style:"percent",...r}).format(a);return i.jsx("span",{className:de("",n),...s,children:o})}function sg({date:e,density:t,isCurrentMonth:r,isClosedDay:n,maxSlots:s,onClick:a}){const o=e.getDate(),c=Math.round(t/100*s),l=t===0,u=l?0:.1+t/100*.9,f=t>50,d=f?"text-white":"text-foreground",h=f?"text-white/90":"text-muted-foreground";return i.jsxs("button",{type:"button",className:`
|
|
51
|
+
`,style:{...y,zIndex:20},onClick:a,children:o.jsx("div",{className:"p-[var(--ui-space-2)] h-full flex flex-col items-center justify-start overflow-hidden",children:c?.EventCard?o.jsx(c.EventCard,{event:e,viewMode:"day",onClick:a,className:"w-full h-full"}):o.jsxs(o.Fragment,{children:[e.hasConflict&&o.jsx("div",{className:"text-xs font-bold mb-[var(--ui-space-1)]",children:"⚠️ Double Booking"}),o.jsx("div",{className:"font-semibold text-sm leading-snug break-words",children:e.title}),!e.isAllDay&&o.jsxs("div",{className:"flex flex-wrap justify-center items-center gap-x-[var(--ui-space-1)] text-[10px] opacity-90 mt-[var(--ui-space-1)] w-full text-center leading-tight",children:[o.jsx("span",{className:"font-mono tabular-nums tracking-tight",children:p(e.startDate)}),d>=.5&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"-"}),o.jsx("span",{className:"font-mono tabular-nums tracking-tight",children:p(e.endDate)}),o.jsxs("span",{className:"ml-[var(--ui-space-0-5)] opacity-75",children:["(",w,")"]})]})]})]})})})}),o.jsx(tg,{children:o.jsxs("div",{className:"space-y-[var(--ui-space-1)]",children:[e.hasConflict&&o.jsx("p",{className:"font-bold text-xs text-red-600",children:"⚠️ Double Booking"}),o.jsx("p",{className:"font-semibold text-xs",children:e.title}),o.jsxs("p",{className:"text-xs",children:[u," - ",f," (",d,"h)"]}),e.note&&o.jsx("p",{className:"text-[10px] text-muted-foreground max-w-[var(--ui-space-45)] break-words",children:e.note}),e.description&&o.jsx("p",{className:"text-[10px] text-muted-foreground max-w-[var(--ui-space-45)] break-words italic",children:e.description})]})})]})})}function Ei({resource:e,events:t,allDayEvents:r=[],startTime:n,endTime:s,currentDate:a,slotSize:i,slotInterval:c=60,onEventClick:l,onEmptySlotClick:u,components:f,orientation:d="vertical",headerLeftOffset:h=0}){const p=n.split(":"),w=s.split(":"),g=Number(p[0]??0),y=Number(p[1]??0),x=Number(w[0]??23),v=Number(w[1]??0),_=m.useRef(null),b=d==="horizontal",S=m.useMemo(()=>{const A=g*60+y,$=x*60+v,O=[];for(let B=A;B<$;B+=c)O.push(B);return O},[g,y,x,v,c]),C=i,j=S.length*C,N=m.useMemo(()=>{const A=[...t];if(r.length>0&&r.forEach(L=>{const I={...L},P=new Date(a);P.setHours(g,y,0,0);const z=new Date(a);z.setHours(x,v,0,0),I.startDate=P,I.endDate=z,A.push(I)}),A.length===0)return[];const $=[...A].sort((L,I)=>L.startDate.getTime()-I.startDate.getTime()),O=[];for(const L of $){let I=!1;for(const P of O)if(P.some(H=>As(H,L))){P.push(L),I=!0;break}I||O.push([L])}const B=[];for(const L of O)if(L.length===1){const I=L[0];I&&B.push({...I,column:0,totalColumns:1})}else{const I=Math.min(L.length,4);for(let P=0;P<L.length;P++){const z=L[P];z&&B.push({...z,column:P%I,totalColumns:I})}}return B},[t,r,a,g,y,x,v]);function E(A){const $=A,O=new Date(a);O.setHours(g,y,0,0);const L=(G=>(G.getTime()-O.getTime())/(1e3*60))($.startDate),I=($.endDate.getTime()-$.startDate.getTime())/(1e3*60),P=L/c*i,z=I/c*i,H=100/A.totalColumns,te=A.column*100/A.totalColumns;return{top:P,height:z,widthPercent:H,leftPercent:te}}function R(A){if(!u)return;const $=A.currentTarget.getBoundingClientRect(),O=b?A.clientX-$.left:A.clientY-$.top,L=Math.max(0,Math.floor(O/i))*c,I=new Date(a);I.setHours(g,y,0,0),I.setMinutes(I.getMinutes()+L),u(e.id,I)}function M(){if(!u)return;const A=new Date(a);A.setHours(g,0,0,0),u(e.id,A)}return b?o.jsxs("div",{className:"flex border-b border-border hover:bg-muted/5 w-full h-[var(--ui-space-24)] shrink-0",children:[o.jsxs("div",{className:"w-[var(--ui-space-32)] flex-shrink-0 border-r border-border bg-background flex flex-col items-center justify-center sticky z-30 shrink-0 p-2",style:{left:h},children:[o.jsx("div",{className:"font-semibold text-xs text-center",children:e.name}),o.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[t.length+r.length," events"]})]}),o.jsxs("div",{ref:_,className:"relative flex-1 cursor-pointer min-w-max h-full",style:{minWidth:`${j}px`},onPointerUp:R,children:[o.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none flex",children:S.map(A=>o.jsx("div",{className:"border-r border-border/50 h-full",style:{width:`${C}px`}},A))}),o.jsx("div",{className:"relative h-full z-10 flex",children:N.map(A=>{const{top:$,height:O,widthPercent:B,leftPercent:L}=E(A);return o.jsx(Ni,{event:A,top:$,height:O,widthPercent:B,leftPercent:L,onClick:I=>{I.stopPropagation(),l?.(A)},components:f,orientation:"horizontal"},A.id)})})]})]}):o.jsxs("div",{className:"flex-1 min-w-[var(--ui-space-22-5)] border-r border-border hover:bg-muted/5 flex flex-col",children:[o.jsx("div",{className:"h-[var(--ui-space-14)] border-b border-border bg-background flex items-center justify-center sticky top-[var(--ui-space-0)] z-20 shrink-0 py-[var(--ui-space-2)]",children:o.jsxs("div",{className:"text-center relative",children:[o.jsx("div",{className:"font-semibold text-sm",children:e.name}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.length+r.length," events"]}),o.jsx(oe,{type:"button",variant:"ghost",className:"sr-only focus:not-sr-only focus:absolute focus:right-[var(--ui-space-2)] focus:top-[var(--ui-space-2)]",onClick:A=>{A.stopPropagation(),M()},children:`Add event to ${e.name}`})]})}),o.jsxs("div",{ref:_,className:"relative flex-1 w-full cursor-pointer",style:{minHeight:`${j}px`},onPointerUp:R,children:[o.jsx("div",{className:"absolute inset-[var(--ui-space-0)] z-0 pointer-events-none flex flex-col",children:S.map(A=>o.jsx("div",{className:"border-b border-border/50 w-full",style:{height:`${C}px`}},A))}),o.jsx("div",{className:"relative w-full z-10 flex flex-col",children:N.map(A=>{const{top:$,height:O,widthPercent:B,leftPercent:L}=E(A);return o.jsx(Ni,{event:A,top:$,height:O,widthPercent:B,leftPercent:L,onClick:I=>{I.stopPropagation(),l?.(A)},components:f,orientation:"vertical"},A.id)})})]})]})}function Ai({startTime:e,endTime:t,slotSize:r=60,slotInterval:n=60,orientation:s="vertical"}){const a=rg(e,t,n),i=s==="horizontal",c=r;return i?o.jsx("div",{className:"flex min-w-max",children:a.map(l=>o.jsx("div",{className:"border-r border-border flex items-center justify-center text-[10px] text-muted-foreground font-medium flex-shrink-0",style:{width:`${c}px`},children:l},l))}):o.jsxs("div",{className:"flex flex-col border-r border-border h-full bg-background",children:[o.jsx("div",{className:"h-[var(--ui-space-14)] border-b border-border bg-background sticky top-[var(--ui-space-0)] z-30"}),a.map(l=>o.jsx("div",{className:"border-b border-border flex items-start justify-end pe-2 py-[var(--ui-space-0-5)] text-xs text-muted-foreground font-medium",style:{height:`${c}px`},children:l},l))]})}function rg(e,t,r){const n=e.split(":"),s=t.split(":"),a=Number(n[0]??0),i=Number(n[1]??0),c=Number(s[0]??23),l=Number(s[1]??0),u=a*60+i,f=c*60+l,d=[];for(let h=u;h<f;h+=r){const p=Math.floor(h/60),w=h%60;d.push(`${p.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`)}return d}function ng({currentDate:e,resources:t,events:r,settings:n,groups:s=[],onEventClick:a,onEmptySlotClick:i,components:c}){const l=j=>{const[N,E]=j.split(":").map(Number);return N+E/60},u=l(n.startTime),f=l(n.endTime),d=Math.round(u*60),h=Math.round(f*60),p=n.slotInterval??60,w=Math.ceil((h-d)/p),g=w*er.SLOT_HEIGHT+er.HEADER_HEIGHT,y=w*er.SLOT_WIDTH,{allDayEvents:x,timedEvents:v}=m.useMemo(()=>{const{start:j,end:N}=ql(e,"day",n),E=Ts(r,j,N),R=co(E);return{allDayEvents:R.filter(M=>M.isAllDay),timedEvents:R.filter(M=>!M.isAllDay)}},[r,e,n]),_=m.useMemo(()=>po(v),[v]),b=m.useMemo(()=>{const j=new Map;for(const N of t){const E=Kp(N.id,_);j.set(N.id,E)}return j},[t,_]),S=m.useMemo(()=>{const j=new Map;for(const N of s)j.set(N.id,N);return j},[s]),C=n.orientation==="vertical";return o.jsx("div",{className:"flex flex-col h-full bg-background",children:C?o.jsx("div",{className:"flex-1 overflow-auto relative",children:o.jsxs("div",{className:"flex flex-col min-w-max",style:{minWidth:`${y+128}px`},children:[o.jsxs("div",{className:"flex border-b border-border bg-muted/40 sticky top-0 z-30",children:[o.jsxs("div",{className:"flex-shrink-0 bg-background border-r border-b border-border sticky left-0 z-50 flex",children:[o.jsx("div",{className:"w-[var(--ui-space-12)] border-r border-border shrink-0"})," ",o.jsx("div",{className:"w-[var(--ui-space-32)] flex-1 shrink-0"})," "]}),o.jsx(Ai,{startTime:n.startTime,endTime:n.endTime,slotSize:er.SLOT_WIDTH,slotInterval:n.slotInterval??60,orientation:"horizontal"})]}),o.jsx("div",{className:"flex flex-col",children:(()=>{const j=[];let N,E=[];return t.forEach((R,M)=>{const A=S.get(R.groupId),$=M>0?t[M-1]:null;$&&$.groupId!==R.groupId&&(j.push({group:N,resources:E}),E=[]),N=A,E.push(R)}),E.length>0&&j.push({group:N,resources:E}),j.map((R,M)=>o.jsxs("div",{className:"flex border-b border-border relative",children:[o.jsx("div",{className:"sticky left-0 z-20 w-[var(--ui-space-12)] flex-shrink-0 bg-background border-r border-border flex items-center justify-center font-bold text-muted-foreground writing-mode-vertical-rl",children:o.jsx("div",{className:"sticky top-[var(--ui-space-14)] py-2 max-h-screen",children:R.group?.name||"-"})}),o.jsx("div",{className:"flex flex-col flex-1 min-w-0",children:R.resources.map((A,$)=>o.jsx("div",{className:`${$<R.resources.length-1?"border-b border-border":""}`,children:o.jsx(Ei,{resource:A,events:b.get(A.id)||[],allDayEvents:x.filter(O=>O.resourceId===A.id),startTime:n.startTime,endTime:n.endTime,currentDate:e,slotSize:er.SLOT_WIDTH,slotInterval:n.slotInterval??60,onEventClick:a,onEmptySlotClick:i,components:c,orientation:"horizontal",headerLeftOffset:"var(--ui-space-12)"})},A.id))})]},`${R.group?.id}-${M}`))})()})]})}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"flex",style:{minHeight:`${g}px`},children:[o.jsxs("div",{className:"sticky left-[var(--ui-space-0)] z-30 bg-background",style:{width:`${er.TIME_COLUMN_WIDTH}px`},children:[o.jsx("div",{className:"sticky top-0 z-40 bg-background border-b border-r border-border h-[var(--ui-space-8)]"})," ",o.jsx(Ai,{startTime:n.startTime,endTime:n.endTime,slotSize:er.SLOT_HEIGHT,slotInterval:n.slotInterval??60,orientation:"vertical"})]}),o.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[o.jsx("div",{className:"flex sticky top-0 z-30 bg-background border-b border-border h-[var(--ui-space-8)]",children:(()=>{const j=[];for(let N=0;N<t.length;N++){const E=t[N],R=S.get(E.groupId);let M=1;for(;N+M<t.length&&t[N+M].groupId===E.groupId;)M++;j.push(o.jsx("div",{className:"flex items-center justify-center border-r border-border text-xs font-semibold bg-muted/20 truncate px-2",style:{flex:`${M} ${M} 0%`},children:R?.name||"-"},`group-${E.groupId}-${N}`)),N+=M-1}return j})()}),o.jsx("div",{className:"flex flex-1 min-w-0",children:t.map(j=>o.jsx(Ei,{resource:j,events:b.get(j.id)||[],allDayEvents:x.filter(N=>N.resourceId===j.id),startTime:n.startTime,endTime:n.endTime,currentDate:e,slotSize:er.SLOT_HEIGHT,slotInterval:n.slotInterval,onEventClick:a,onEmptySlotClick:i,components:c,orientation:"vertical"},j.id))})]})]})})})}const sg=e=>e.startsWith("ja")?"ja-JP":"en-GB",Ti=e=>{switch(e){case"japanese":return"ja-JP-u-ca-japanese";case"buddhist":return"th-TH-u-ca-buddhist";case"islamic":return"ar-SA-u-ca-islamic";case"chinese":return"zh-CN-u-ca-chinese";default:return null}},ag=e=>e==="full"||e==="date"||e==="weekday"||e==="weekdayShort"||e==="yearMonth"||e==="monthDay"||e==="monthDayShort"||e==="compact",og=()=>typeof document>"u"?null:document.documentElement.getAttribute("data-secondary-calendar"),ig=()=>typeof document>"u"?!1:document.documentElement.getAttribute("data-prefer-local-calendar")==="true",cg=e=>e.startsWith("ja")?"japanese":e.startsWith("th")?"buddhist":e.startsWith("ar")?"islamic":e.startsWith("zh")?"chinese":null,Ri=(e,t,r,n)=>{const s=a=>new Intl.DateTimeFormat(t,{...a,calendar:n}).format(e);switch(r){case"weekday":return s({weekday:"long"});case"weekdayShort":return s({weekday:"short"});case"date":return s({year:"numeric",month:"short",day:"numeric"});case"monthDayShort":return s({month:"short",day:"numeric",weekday:"short"});case"compact":return s({month:"numeric",day:"numeric",weekday:"short"});case"yearMonth":return s({year:"numeric",month:"long"});case"monthDay":return s({month:"long",day:"numeric"});default:return s({year:"numeric",month:"long",day:"numeric",weekday:"long"})}},Ot=m.memo(({date:e,format:t="full",variant:r,className:n,showSecondary:s,showDayOfWeek:a,...i})=>{const{i18n:c}=Le(),l=c.language||"en",u=sg(l),f=t==="full"&&ag(r)?r:t,d=()=>f==="full"||f==="yearMonth"||f==="monthDay"||f==="monthDayShort"||f==="compact"||f==="weekday"||f==="weekdayShort"?Ne(e,u,f):f==="date"?Ne(e,u,"picker"):Ne(e,u,"full"),h=()=>ig()?cg(l):null,p=()=>{const x=h();if(x){const v=Ti(x)??u;return Ri(e,v,f,x)}return d()},w=()=>{if(!s)return null;const x=og();if(!x||x==="none")return null;const v=h();if(x===v)return null;const _=Ti(x)??u;return Ri(e,_,f,x)},g=p(),y=w();return o.jsxs("span",{className:de("inline-block",n),...i,children:[g,y&&o.jsxs("span",{className:"ml-[var(--ui-space-2)] text-muted-foreground",children:["(",y,")"]})]})});function tu({value:e,valueScale:t="ratio",options:r,className:n,...s}){const a=t==="percent"?e/100:e,i=new Intl.NumberFormat("en-US",{style:"percent",...r}).format(a);return o.jsx("span",{className:de("",n),...s,children:i})}function lg({date:e,density:t,isCurrentMonth:r,isClosedDay:n,maxSlots:s,onClick:a}){const i=e.getDate(),c=Math.round(t/100*s),l=t===0,u=l?0:.1+t/100*.9,f=t>50,d=f?"text-white":"text-foreground",h=f?"text-white/90":"text-muted-foreground";return o.jsxs("button",{type:"button",className:`
|
|
52
52
|
border border-border rounded-md p-[var(--ui-space-2)] min-h-[var(--ui-space-25)] cursor-pointer text-left
|
|
53
53
|
transition-all hover:shadow-md
|
|
54
54
|
${r?"":"opacity-50"}
|
|
55
55
|
${n?"bg-muted":"bg-card"}
|
|
56
|
-
`,style:!n&&!l?{backgroundColor:`hsl(var(--theme-accent) / ${u})`}:void 0,onClick:a,children:[i.jsxs("div",{className:"flex items-center justify-between mb-[var(--ui-space-2)]",children:[i.jsx("span",{className:`text-sm font-semibold ${r?d:"text-muted-foreground"}`,children:o}),n&&i.jsx("span",{className:"text-xs px-[var(--ui-space-1-5)] py-[var(--ui-space-0-5)] rounded bg-theme-warning text-white font-medium",children:"定休日"})]}),!n&&i.jsxs("div",{className:"space-y-[var(--ui-space-1)]",children:[i.jsxs("div",{className:`text-xs ${h}`,children:[c,"/",s]}),i.jsx(Yl,{value:t,valueScale:"percent",options:{maximumFractionDigits:0},className:`text-xs font-medium ${d}`})]})]})}function ag(){const e=[{label:"0%",opacity:0},{label:"20%",opacity:.28},{label:"40%",opacity:.46},{label:"60%",opacity:.64},{label:"80%",opacity:.82},{label:"100%",opacity:1}];return i.jsxs("div",{className:"flex items-center justify-center gap-[var(--ui-space-4)] py-[var(--ui-space-3)] border-t border-border bg-background",children:[i.jsx("span",{className:"text-sm text-gray-600",children:"予約密度:"}),i.jsx("div",{className:"flex items-center gap-[var(--ui-space-1)]",children:e.map((t,r)=>i.jsxs("div",{className:"flex flex-col items-center gap-[var(--ui-space-1)]",children:[i.jsx("div",{className:"w-[var(--ui-space-8)] h-[var(--ui-space-8)] border border-gray-300",style:{backgroundColor:t.opacity===0?"white":`hsl(var(--theme-accent) / ${t.opacity})`}}),(r===0||r===e.length-1)&&i.jsx("span",{className:"text-xs text-gray-600",children:t.label})]},t.label))})]})}function og({month:e,resources:t,events:r,settings:n,selectedGroupId:s,onDayClick:a}){const{t:o}=$e(),{filteredResources:c,filteredEvents:l}=m.useMemo(()=>s?{filteredResources:t.filter(y=>y.groupId===s),filteredEvents:r.filter(y=>y.groupId===s)}:{filteredResources:t,filteredEvents:r},[s,t,r]),u=m.useMemo(()=>{const y=co(e),v=As(y,n.weekStartsOn??1);return ao(v,br(v,41))},[e,n.weekStartsOn]),f=m.useMemo(()=>uo(l),[l]),d=n.timeSlots?n.timeSlots.length:3,h=m.useMemo(()=>{const y=new Map,v=c.length*d;for(const b of u){const C=zr(b),x=Zl(b,f),_=v>0?x.length/v*100:0;y.set(C,_)}return y},[u,f,c.length,d]),p=m.useMemo(()=>{const y=u.filter(b=>b.getMonth()===e.getMonth()),v=y.reduce((b,C)=>{const x=zr(C);return b+(h.get(x)||0)},0);return y.length>0?Math.round(v/y.length):0},[u,e,h]),w=m.useMemo(()=>{const y=[];for(let v=0;v<u.length;v+=7)y.push(u.slice(v,v+7));return y},[u]),g=m.useMemo(()=>{const y=[],v=n.weekStartsOn===0?0:1,b=[o("days_short_sun"),o("days_short_mon"),o("days_short_tue"),o("days_short_wed"),o("days_short_thu"),o("days_short_fri"),o("days_short_sat")];for(let C=0;C<7;C++){const x=(v+C)%7;y.push(b[x]||"")}return y},[n.weekStartsOn,o]);return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"border-b border-border bg-background px-ui py-ui",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h2",{className:"text-lg font-semibold",children:i.jsx(tr,{date:e,format:"yearMonth"})}),i.jsx("div",{className:"flex items-center gap-[var(--ui-space-4)] mt-[var(--ui-space-2)]",children:i.jsxs("div",{className:"text-sm text-muted-foreground",children:["Resources: ",c.length," / Utilization:"," ",i.jsx(Yl,{value:p,valueScale:"percent",options:{maximumFractionDigits:0},className:"font-medium text-foreground"})]})})]}),i.jsx(ag,{})]})}),i.jsx("div",{className:"w-full p-[var(--ui-space-4)] overflow-y-auto",children:i.jsxs("div",{className:"w-full",children:[i.jsx("div",{className:"grid grid-cols-7 gap-[var(--ui-space-1)] mb-[var(--ui-space-1)]",children:g.map(y=>i.jsx("div",{className:"text-center font-semibold text-sm text-foreground py-[var(--ui-space-2)]",children:y},y))}),i.jsx("div",{className:"grid gap-[var(--ui-space-1)]",style:{gridTemplateRows:`repeat(${w.length}, 1fr)`},children:w.map(y=>i.jsx("div",{className:"grid grid-cols-7 gap-[var(--ui-space-1)]",children:y.map(v=>{const b=v.toISOString().split("T")[0]||"",C=h.get(b)||0,x=v.getMonth()===e.getMonth(),_=n.closedDays.includes(v.getDay());return i.jsx(sg,{date:v,density:C,isCurrentMonth:x,isClosedDay:_,maxSlots:c.length*d,onClick:()=>a?.(v)},b)})},y[0]?.toISOString()??"empty-week"))})]})})]})}function fo({currentView:e,onViewChange:t,options:r,className:n}){return i.jsx("div",{className:`flex bg-muted p-[calc(var(--ui-gap-base)/2)] rounded-md gap-[calc(var(--ui-gap-base)/2)] ${n||""}`,children:r.map(s=>i.jsx(ie,{variant:e===s.value?"default":"ghost",onClick:()=>t(s.value),className:"flex-1 h-[var(--ui-component-height)] px-[var(--ui-button-padding-x)]",children:s.label},s.value))})}function ig({currentDate:e,viewMode:t,groups:r,selectedGroupId:n,isLoading:s,hideGroupSelector:a,headerLeft:o,headerRight:c,onNavigate:l,onToday:u,onViewChange:f,onGroupChange:d,isPaginated:h,currentPage:p,totalPages:w,onPageChange:g,pageInfo:y}){const{t:v}=$e();return i.jsxs("header",{className:"border-b border-border px-[var(--ui-space-4)] py-[var(--ui-space-3)] flex items-center justify-between gap-[var(--ui-space-4)]",children:[i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:[i.jsx(ie,{variant:"outline",size:"icon",onClick:()=>l("prev"),"aria-label":v("previous"),children:i.jsx(ye.ChevronLeft,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),i.jsx(ie,{variant:"outline",onClick:u,children:v("today_button")}),i.jsx(ie,{variant:"outline",size:"icon",onClick:()=>l("next"),"aria-label":v("next"),children:i.jsx(ye.ChevronRight,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),i.jsx("span",{className:"text-lg font-bold ml-[var(--ui-space-2)]",children:i.jsx(tr,{date:e,showSecondary:!0,showDayOfWeek:!0})}),o]}),i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-4)]",children:[!a&&i.jsxs(Vt,{value:n??void 0,onValueChange:d,disabled:s||r.length===0,children:[i.jsx(Et,{className:"w-[var(--ui-space-50)]",children:i.jsx(At,{placeholder:"Select Group",children:r.find(b=>b.id===n)?.name||""})}),i.jsx(Rt,{children:r.map(b=>i.jsx(ut,{value:b.id,children:b.name},b.id))})]}),i.jsx(fo,{currentView:t,onViewChange:f,options:[{value:"day",label:v("view_day")},{value:"week",label:v("view_week")},{value:"month",label:v("view_month")}]}),h&&w&&w>1&&g&&i.jsx("div",{className:"flex bg-muted p-[calc(var(--ui-gap-base)/2)] rounded-md gap-[calc(var(--ui-gap-base)/2)]",children:Array.from({length:w}).map((b,C)=>{const x=y?.find(k=>k.page===C),_=x?`${v("page")} ${C+1}: ${x.startResource} - ${x.endResource}`:`${v("page")} ${C+1}`;return i.jsx(ie,{variant:(p??0)===C?"default":"ghost",onClick:()=>g(C),className:"h-[var(--ui-component-height)] w-[var(--ui-component-height)] p-0",title:_,children:C+1},C)})}),c]})]})}function cg(e,t){const r=e.getDay();return t.includes(r)}function lg({weekStart:e,resources:t,events:r,settings:n,groups:s=[],onEventClick:a,onEmptySlotClick:o,components:c}){const l=m.useMemo(()=>oo(n.weekStartsOn),[n.weekStartsOn]),u=m.useMemo(()=>As(e,l),[e,l]),f=m.useMemo(()=>io(e,l),[e,l]),d=m.useMemo(()=>{const v=new Map;for(const b of s)v.set(b.id,b);return v},[s]),h=m.useMemo(()=>ao(u,f),[u,f]),p=m.useMemo(()=>{const v=Es(r,u,br(f,1));return so(v)},[r,u,f]),w=m.useMemo(()=>uo(p),[p]),g=m.useMemo(()=>{const v=new Map;for(const b of h){const C=Zl(b,w).sort((_,k)=>_.isAllDay&&!k.isAllDay?-1:!_.isAllDay&&k.isAllDay?1:_.startDate.getTime()-k.startDate.getTime()),x=zr(b);v.set(x,C)}return v},[h,w]),y=m.useMemo(()=>{const v=new Date;return v.setHours(0,0,0,0),v},[]);return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"hidden md:block border-b border-border bg-background px-ui py-ui",children:i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("div",{children:[i.jsxs("h2",{className:"text-lg font-bold",children:[i.jsx(tr,{date:u,variant:"date"})," - ",h[6]&&i.jsx(tr,{date:h[6],variant:"monthDay"})]}),i.jsxs("div",{className:"text-sm text-muted-foreground mt-[var(--ui-space-1)]",children:["Events: ",p.length," / Resources: ",t.length]})]})})}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("div",{className:"flex border-b border-border bg-background sticky top-[var(--ui-space-0)] z-20",children:[i.jsx("div",{className:"flex-shrink-0 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)]",style:{width:`${ur.DATE_COLUMN_WIDTH}px`}}),t.map(v=>{const b=d.get(v.groupId);return i.jsxs("div",{className:"flex-1 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)] text-center overflow-hidden min-w-[var(--ui-space-20)]",children:[i.jsx("div",{className:"font-semibold text-xs leading-tight truncate",title:v.name,children:v.name}),i.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight truncate",children:b?.name||"-"})]},v.id)})]}),h.map(v=>{const b=new Date(v);b.setHours(0,0,0,0);const C=b.getTime()===y.getTime(),x=cg(v,n.closedDays),_=x?"bg-muted":C?"bg-background":"bg-card",k=x?"bg-muted":C?"bg-background":"bg-card",j=x?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-accent",E=zr(v),A=g.get(E)??[];return i.jsxs("div",{className:"flex border-b border-border",children:[i.jsx("div",{className:`flex-shrink-0 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)] flex items-center justify-center ${_}`,style:{width:`${ur.DATE_COLUMN_WIDTH}px`,height:`${ur.DAY_CELL_HEIGHT}px`},children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"font-semibold text-xs leading-tight whitespace-pre-line",children:i.jsx(tr,{date:v,variant:"compact"})}),x&&i.jsx("div",{className:"text-[10px] text-warning mt-[var(--ui-space-1)]",children:"Off"})]})}),t.map(T=>{const M=$l(A,T.id);return i.jsxs("div",{className:`relative flex-1 border-r border-border p-[var(--ui-space-0-5)] ${k} ${j} transition-colors overflow-hidden min-w-[var(--ui-space-20)]`,style:{height:`${ur.DAY_CELL_HEIGHT}px`},children:[i.jsx(ie,{type:"button",variant:"ghost",className:"absolute inset-[var(--ui-space-0)] z-0 p-[var(--ui-space-0)]",disabled:x||!o,"aria-label":`Add event to ${T.name}`,onClick:()=>{x||o?.(T.id,v)},onKeyDown:R=>{x||!o||(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),o(T.id,v))},children:i.jsx("span",{className:"sr-only",children:"Add"})}),i.jsxs("div",{className:"relative z-10 flex flex-col gap-[var(--ui-space-0)] h-full overflow-hidden",children:[M.slice(0,ur.MAX_VISIBLE_EVENTS).map(R=>{const V=R.hasConflict?"bg-destructive":R.color?"":"bg-primary",F=R.color&&!R.hasConflict?{backgroundColor:R.color}:{},G=R.startDate.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),$=({children:L})=>i.jsx("button",{type:"button",className:`${V} text-primary-foreground px-[var(--ui-space-1-5)] py-[var(--ui-space-0-5)] rounded text-sm cursor-pointer hover:brightness-110 transition-colors text-left leading-normal truncate w-full mb-[var(--ui-space-0-5)]`,style:F,onClick:P=>{P.stopPropagation(),a?.(R)},children:L},R.id);return c?.EventCard?i.jsx($,{children:i.jsx(c.EventCard,{event:R,viewMode:"week",isCompact:!0,onClick:()=>a?.(R)})},R.id):i.jsx($,{children:i.jsxs("span",{className:"font-medium",children:[R.hasConflict&&"⚠️ ",!R.isAllDay&&`${G} `,R.title]})},R.id)}),M.length>ur.MAX_VISIBLE_EVENTS&&i.jsxs("div",{className:"text-[9px] text-muted-foreground text-center",children:["+",M.length-ur.MAX_VISIBLE_EVENTS]})]})]},T.id)})]},v.toISOString())})]})})]})}function ug({allResources:e,paginationOptions:t}){const[r,n]=m.useState(0),s=t?.enabled??!1,a=t?.pageSize??8,o=e.length,{totalPages:c,pageDistribution:l}=m.useMemo(()=>{if(!s||o===0)return{totalPages:1,pageDistribution:[o]};if(o<=a)return{totalPages:1,pageDistribution:[o]};const w=Math.ceil(o/a),g=Math.floor(o/w),y=o%w,v=[];for(let b=0;b<w;b++){const C=b<y?g+1:g;v.push(C)}return{totalPages:w,pageDistribution:v}},[s,o,a]);r>=c&&c>0&&n(c-1);const u=m.useMemo(()=>{if(!s)return e;let w=0;for(let y=0;y<r;y++)w+=l[y]||0;const g=l[r]||e.length;return e.slice(w,w+g)},[e,s,r,l]),f=w=>{const g=Math.max(0,Math.min(w,c-1));n(g)},d=()=>f(r+1),h=()=>f(r-1),p=m.useMemo(()=>{if(!s||c<=1)return[];const w=[];let g=0;for(let y=0;y<c;y++){const v=l[y],b=e[g],C=e[g+v-1];b&&C&&w.push({page:y,startResource:b.name,endResource:C.name}),g+=v}return w},[s,c,l,e]);return{paginatedResources:u,currentPage:r,totalPages:c,goToPage:f,nextPage:d,prevPage:h,isPaginated:s,pageSize:l[r]??a,totalResources:o,pageInfo:p}}function Gl({events:e,resources:t,groups:r,selectedGroupId:n}){const s=m.useMemo(()=>n??r[0]?.id??null,[n,r]),a=m.useMemo(()=>s?t.filter(c=>c.groupId===s):t,[t,s]),o=m.useMemo(()=>s?e.filter(c=>c.groupId===s):e,[e,s]);return{effectiveGroupId:s,filteredResources:a,filteredEvents:o}}function ql({onEventCreate:e,onEventUpdate:t,onEventDelete:r,onDateChange:n,onViewChange:s}){const[a,o]=m.useState(!1),[c,l]=m.useState(void 0),[u,f]=m.useState({}),d=m.useCallback(v=>{l(v),f({}),o(!0)},[]),h=m.useCallback((v,b)=>{l(void 0),f({resourceId:v||void 0,startTime:b}),o(!0)},[]),p=m.useCallback(v=>{n?.(v),s?.("day")},[n,s]),w=m.useCallback(v=>{c?t?.(c.id,v):e?.(v),o(!1)},[c,e,t]),g=m.useCallback(v=>{r?.(v),o(!1)},[r]),y=m.useCallback(()=>{o(!1)},[]);return{isModalOpen:a,selectedEvent:c,newInfo:u,handleEventClick:d,handleEmptySlotClick:h,handleDayClick:p,handleModalSave:w,handleModalDelete:g,handleModalClose:y}}function ho(e,t,r){const n=r==="next"?1:-1;switch(t){case"day":return br(e,n);case"week":return _f(e,n);case"month":return Fa(e,n);default:return e}}function dg(){const e=new Date;return e.setHours(0,0,0,0),e}class Xl{getItem(t){if(typeof window>"u")return null;try{return localStorage.getItem(t)}catch(r){return console.warn(`Failed to get item from localStorage: ${t}`,r),null}}setItem(t,r){if(!(typeof window>"u"))try{localStorage.setItem(t,r)}catch(n){console.warn(`Failed to set item in localStorage: ${t}`,n)}}removeItem(t){if(!(typeof window>"u"))try{localStorage.removeItem(t)}catch(r){console.warn(`Failed to remove item from localStorage: ${t}`,r)}}}class fg{storage=new Map;getItem(t){return this.storage.get(t)??null}setItem(t,r){this.storage.set(t,r)}removeItem(t){this.storage.delete(t)}clear(){this.storage.clear()}keys(){return Array.from(this.storage.keys())}}const Rs=new Xl;function Kl({defaultView:e="day",defaultDate:t=new Date,defaultGroupId:r=null,enablePersistence:n=!1,storageKey:s="facility-schedule-view",storage:a=Rs,onDateChange:o,onViewChange:c,onGroupChange:l}){const[u,f]=m.useState(t),[d,h]=m.useState(()=>{if(n)try{const x=a.getItem(s);if(x&&["day","week","month"].includes(x))return x}catch(x){console.warn("Failed to load schedule view from storage",x)}return e}),[p,w]=m.useState(r);m.useEffect(()=>{if(n)try{a.setItem(s,d)}catch(x){console.warn("Failed to save schedule view to storage",x)}},[d,n,s,a]);const g=m.useCallback(x=>{o&&o(x),f(x)},[o]),y=m.useCallback(x=>{c&&c(x),h(x)},[c]),v=m.useCallback(x=>{l&&l(x),w(x)},[l]),b=m.useCallback(x=>{const _=ho(u,d,x);g(_)},[u,d,g]),C=m.useCallback(()=>{g(new Date)},[g]);return{currentDate:u,viewMode:d,selectedGroupId:p,setDate:g,setViewMode:y,setSelectedGroupId:v,navigate:b,goToToday:C}}function Jl({events:e,resources:t,groups:r,settings:n,currentDate:s,viewMode:a,selectedGroupId:o,onDateChange:c,onViewChange:l,onGroupChange:u,onEventCreate:f,onEventUpdate:d,onEventDelete:h,isLoading:p=!1,className:w,hideGroupSelector:g=!1,components:y,headerLeft:v,headerRight:b,defaultView:C="day",enablePersistence:x=!1,storageKey:_="facility-schedule-view",customFields:k,pagination:j}){const{t:E}=$e(),{currentDate:A,viewMode:T,selectedGroupId:M,setViewMode:R,setSelectedGroupId:V,navigate:F,goToToday:G,setDate:$}=Kl({defaultView:a||C,defaultDate:s,defaultGroupId:o,enablePersistence:x,storageKey:_,onDateChange:c,onViewChange:l,onGroupChange:u}),{effectiveGroupId:L,filteredResources:P,filteredEvents:H}=Gl({events:e,resources:t,groups:r,selectedGroupId:M}),{isModalOpen:z,selectedEvent:re,newInfo:q,handleEventClick:I,handleEmptySlotClick:B,handleDayClick:se,handleModalSave:ne,handleModalDelete:fe,handleModalClose:pe}=ql({onEventCreate:f,onEventUpdate:d,onEventDelete:h,onDateChange:$,onViewChange:R}),{paginatedResources:Ae,currentPage:xe,totalPages:Ze,goToPage:Ye,isPaginated:Xe,pageInfo:Ke}=ug({allResources:P,paginationOptions:j});return i.jsxs("div",{className:`flex flex-col h-full bg-background ${w}`,children:[i.jsx(ig,{currentDate:A,viewMode:T,groups:r,selectedGroupId:L,isLoading:p,hideGroupSelector:g,headerLeft:v,headerRight:b,onNavigate:F,onToday:G,onViewChange:R,onGroupChange:V,isPaginated:Xe,currentPage:xe,totalPages:Ze,onPageChange:Ye,pageInfo:Ke}),i.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[p&&i.jsxs("div",{className:"absolute inset-[var(--ui-space-0)] bg-background/50 z-10 flex items-center justify-center",children:[E("loading"),"..."]}),T==="day"&&i.jsx(Jp,{currentDate:A,resources:Ae,events:H,settings:n,onEventClick:I,onEmptySlotClick:B,components:y}),T==="week"&&i.jsx(lg,{weekStart:A,resources:Ae,events:H,settings:n,groups:r,onEventClick:I,onEmptySlotClick:B,components:y}),T==="month"&&i.jsx(og,{month:A,events:e,resources:Ae,settings:n,selectedGroupId:L,onDayClick:se})]}),y?.EventModal?i.jsx(y.EventModal,{isOpen:z,onClose:pe,event:re,resources:t,groups:r,events:e,defaultResourceId:q.resourceId,onSave:ne,onDelete:h?fe:void 0,readOnlyResource:!0,customFields:k}):i.jsx(lo,{isOpen:z,onClose:pe,event:re,resources:t,groups:r,events:e,defaultResourceId:q.resourceId,defaultStartTime:q.startTime,onSave:ne,onDelete:h?fe:void 0,readOnlyResource:!0,customFields:k})]})}const ya=["#3B82F6","#DC2626","#7C3AED","#0891B2","#EA580C","#DB2777","#4F46E5","#059669","#9333EA","#0284C7","#BE185D","#0D9488","#7C2D12","#1D4ED8","#9F1239","#6D28D9","#166534","#B45309","#1E40AF","#831843"];function mo(e){return ya[e%ya.length]}function hg(e){const t=new Map;return e.forEach((r,n)=>{t.set(r,mo(n))}),t}function Ql(e,t){const r=eu(t);return r.length>0?`${e} (${r.join(", ")})`:e}function eu(e){if(!e||e==="[]")return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(r=>{if(typeof r!="object"||r===null)return null;const n=r.name;return typeof n=="string"?n:null}).filter(r=>!!r)}catch{return e.split(/[,、]/).map(t=>t.trim()).filter(Boolean)}return[]}function tu(e,t){const r=s=>typeof s=="string"?s:void 0;let n=r(e?.ownerId)??r(e?.personnelId);if(!n&&t&&t!=="[]")try{const s=JSON.parse(t);Array.isArray(s)&&s.length>0&&(n=s[0].personnelId)}catch{}return n}function mg(e){const t=typeof e.extendedProps?.realId=="string"?e.extendedProps.realId:e.id;return{...e,id:t}}function pg(e,t){const r=new Map;return e.forEach(n=>{const s=typeof n.extendedProps?.isAllDay=="boolean"?n.extendedProps.isAllDay:void 0;(!n.attendee||n.attendee==="[]")&&r.set(n.id,{...n,isAllDay:n.isAllDay??s??!1})}),t.forEach(n=>{const s=typeof n.extendedProps?.isAllDay=="boolean"?n.extendedProps.isAllDay:void 0;r.set(n.id,{...n,isAllDay:n.isAllDay??s??!1})}),Array.from(r.values())}function gg(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch{return console.warn("[transformBookings] Failed to parse extendedProps",e),{}}return e}function ru(e,t){return e.flatMap(r=>r.bookings.map(n=>{const s=gg(n.extendedProps),a=Ql(n.title,n.attendee),o=tu(s,n.attendee);let c;if(o&&t.length>0){const l=t.findIndex(u=>u.id===o);l>=0&&(c=mo(l))}return{id:n.eventId,groupId:r.groupId,resourceId:r.resourceId,title:a,startDate:new Date(n.startDate),endDate:new Date(n.endDate),isAllDay:n.isAllDay,attendee:n.attendee,color:c,status:"booked",createdAt:new Date,updatedAt:new Date,extendedProps:{...s,originalTitle:n.title,ownerId:o}}}))}function vg({settings:e,currentUserId:t,enablePersistence:r=!0,pagination:n}){const{resources:s,groups:a,settings:o,loading:c,error:l,events:u,createEvent:f,updateEvent:d,deleteEvent:h,fetchResourceAvailability:p,personnel:w}=Ul(),g=t||w?.[0]?.id,[y,v]=m.useState(new Date),[b,C]=m.useState("day"),[x,_]=m.useState([]),[k,j]=m.useState(!1),[E,A]=m.useState([]),T=m.useCallback(async()=>{j(!0);try{const z=await p(y,b),re=ru(z,w);console.log(`[FacilityScheduleManager] Loaded ${re.length} events for ${b} view`),_(re)}catch(z){console.error("Failed to fetch data",z)}finally{j(!1)}},[y,b,p,w,u]);m.useEffect(()=>{T()},[T]);const M=m.useMemo(()=>{const z=new Map;for(const re of u)z.set(re.id,re);for(const re of x){const q=z.get(re.id);q?z.set(re.id,{...q,color:re.color||q.color,groupId:re.groupId||q.groupId}):z.set(re.id,re)}return Array.from(z.values())},[u,x]),R=m.useCallback(async z=>{const re={title:z.title,attendee:z.attendee,resourceId:z.resourceId||void 0,startDate:z.startDate,endDate:z.endDate,status:z.status,note:z.note,isAllDay:z.isAllDay,extendedProps:{...z.extendedProps||{},ownerId:g}};try{await f(re)}catch(q){console.error("Failed to save event",q)}},[f,g]),V=m.useCallback(async(z,re)=>{const q={title:re.title,attendee:re.attendee,resourceId:re.resourceId||void 0,startDate:re.startDate,endDate:re.endDate,status:re.status,note:re.note,isAllDay:re.isAllDay,extendedProps:{...re.extendedProps||{}}};try{await d(z,q)}catch(I){console.error("Failed to update event",I)}},[d]),F=m.useCallback(async z=>{try{await h(z)}catch(re){console.error("Failed to delete event",re)}},[h]),G=m.useCallback(async z=>{try{const re=await p(z.startDate,"day");A(re.map(q=>({resourceId:q.resourceId,isAvailable:q.isAvailable})))}catch(re){console.error("Failed to fetch specific availability",re)}},[p]),$=m.useRef({effectiveUserId:g,personnel:w,resourceAvailability:E,onAvailabilityRequest:G});m.useEffect(()=>{$.current={effectiveUserId:g,personnel:w,resourceAvailability:E,onAvailabilityRequest:G}},[g,w,E,G]);const L=m.useMemo(()=>z=>i.jsx(lo,{...z,currentUserId:$.current.effectiveUserId,personnel:$.current.personnel,readOnlyResource:!0,resourceAvailability:$.current.resourceAvailability,onAvailabilityRequest:$.current.onAvailabilityRequest}),[]);if(l)return i.jsxs("div",{className:"p-[var(--ui-space-4)] text-red-500",children:["Error: ",l]});if(!o||c)return i.jsx("div",{className:"p-[var(--ui-space-4)]",children:"Loading schedule data..."});const P={...o,weekStartsOn:e.weekStartsOn??o.weekStartsOn,startTime:e.businessHoursStart??o.startTime,endTime:e.businessHoursEnd??o.endTime},H={enabled:n?.enabled??e.paginationEnabled??o.paginationEnabled??!1,pageSize:n?.pageSize??e.paginationPageSize??o.paginationPageSize??8};return i.jsx(Jl,{events:M,resources:s,groups:a,settings:P,isLoading:c||k,currentDate:y,viewMode:b,onDateChange:v,onViewChange:C,onEventCreate:R,onEventUpdate:V,onEventDelete:F,components:{EventModal:L},enablePersistence:r,pagination:H})}function yg({groups:e,resources:t,onCreateGroup:r,onUpdateGroup:n,onDeleteGroup:s,onCreateResource:a,onUpdateResource:o,onDeleteResource:c,onClose:l}){const{t:u}=$e(),[f,d]=m.useState(null),[h,p]=m.useState(null),[w,g]=m.useState(""),y=F=>{d(F.id),g(F.name)},v=async F=>{w.trim()&&await n(F,{name:w}),d(null)},b=async()=>{const F=prompt(u("facility_prompt_group_name")||"Enter Group Name");F&&await r({name:F})},C=async F=>{confirm(u("facility_confirm_delete_group_message"))&&await s(F)},x=F=>{p(F.id),g(F.name)},_=async F=>{w.trim()&&await o(F,{name:w}),p(null)},k=async F=>{const G=prompt(u("facility_prompt_resource_name")||"Enter Resource Name");if(G){const $=t.filter(P=>P.groupId===F),L=Math.max(0,...$.map(P=>P.order));await a({name:G,groupId:F,order:L+1,isAvailable:!0})}},j=async F=>{confirm(u("facility_confirm_delete_resource_message"))&&await c(F)},E={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto"},A={backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)",width:"100%",maxWidth:"600px",maxHeight:"90vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},T={marginBottom:"24px"},M={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px",fontWeight:"bold",fontSize:"14px"},R={display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center"},V={padding:"0 8px",borderRadius:"var(--radius)",border:"1px solid hsl(var(--border))",backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))",fontSize:"var(--ui-font-size-base)",height:"var(--ui-component-height)",width:"100%"};return i.jsxs("div",{style:E,children:[i.jsx("button",{type:"button","aria-label":u("close"),onClick:l,style:{position:"absolute",inset:0,background:"transparent",border:"none",padding:0,margin:0}}),i.jsxs("div",{style:{...A,position:"relative",zIndex:1},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"24px",paddingBottom:"16px",borderBottom:"1px solid hsl(var(--border))"},children:[i.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:"bold"},children:u("facility_settings_title")}),i.jsx(ie,{variant:"ghost",size:"icon",onClick:l,children:i.jsx(ye.X,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-[var(--ui-space-6)]",children:[i.jsxs("div",{style:{...T,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid hsl(var(--border))",paddingBottom:"16px"},children:[i.jsxs("h3",{className:"text-md font-medium text-muted-foreground m-[var(--ui-space-0)]",children:[u("facility_label_group_name"),"s &"," ",u("facility_label_resource_name"),"s"]}),i.jsxs(ie,{onClick:b,children:[i.jsx(ye.Plus,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)] mr-[var(--ui-space-2)]"}),u("facility_action_add_group")]})]}),e.map(F=>i.jsxs("div",{style:{...T,borderBottom:"1px solid hsl(var(--border))",paddingBottom:"24px",marginBottom:"24px"},children:[i.jsx("div",{style:M,children:f===F.id?i.jsxs("div",{style:{display:"flex",gap:"8px",flex:1,alignItems:"center"},children:[i.jsx("input",{style:{...V,flex:1},value:w,onChange:G=>g(G.target.value)}),i.jsx(ie,{onClick:()=>v(F.id),children:u("save_button")}),i.jsx(ie,{variant:"ghost",onClick:()=>d(null),children:u("cancel_button")})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:"16px"},children:F.name}),i.jsxs("div",{style:{display:"flex",gap:"4px"},children:[i.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>y(F),children:i.jsx(ye.Edit,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),i.jsx(ie,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>C(F.id),children:i.jsx(ye.Trash,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})})]})]})}),i.jsxs("div",{style:R,children:[t.filter(G=>G.groupId===F.id).sort((G,$)=>G.order-$.order).map(G=>i.jsx("div",{style:{display:"flex",alignItems:"center",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)",padding:"4px 8px",backgroundColor:"hsl(var(--muted) / 0.3)"},children:h===G.id?i.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[i.jsx("input",{style:{...V,width:"120px",height:"28px",fontSize:"13px"},value:w,onChange:$=>g($.target.value)}),i.jsx(ie,{size:"sm",onClick:()=>_(G.id),children:u("save_button")}),i.jsx(ie,{size:"icon",variant:"ghost",className:"h-[var(--ui-space-6)] w-[var(--ui-space-6)]",onClick:()=>p(null),children:i.jsx(ye.X,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{marginRight:"8px",fontSize:"14px"},children:G.name}),i.jsx(ie,{variant:"ghost",size:"icon",className:"h-[var(--ui-space-6)] w-[var(--ui-space-6)] opacity-50 hover:opacity-100",onClick:()=>x(G),children:i.jsx(ye.Edit,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})}),i.jsx(ie,{variant:"ghost",size:"icon",className:"h-[var(--ui-space-6)] w-[var(--ui-space-6)] text-destructive opacity-50 hover:opacity-100",onClick:()=>j(G.id),children:i.jsx(ye.Trash,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})]})},G.id)),i.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>k(F.id),children:[i.jsx(ye.Plus,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)] mr-[var(--ui-space-1)]"}),u("facility_action_add_resource")]})]})]},F.id)),e.length===0&&i.jsx("div",{style:{textAlign:"center",padding:"32px",color:"hsl(var(--muted-foreground))"},children:u("facility_label_no_groups")})]}),i.jsx("div",{style:{padding:"24px",borderTop:"1px solid hsl(var(--border))",display:"flex",justifyContent:"flex-end"},children:i.jsx(ie,{onClick:l,children:u("facility_action_done")})})]})]})}function xg({form:e,onSubmit:t,onCancel:r,onDelete:n,isEditMode:s,canEdit:a,isAllDay:o,startDateVal:c,displayValue:l,availableResources:u,resourceDisplayNames:f,conflict:d,setIsTimeModalOpen:h,customFields:p=[],readOnlyResource:w=!1,personnel:g=[],currentUserId:y}){const{t:v,i18n:b}=_a.useTranslation(),C=x=>{const _=Math.floor(x),k=Math.round((x-_)*60);return _>0&&k>0?`${_}h ${k}m`:_>0?`${_}h`:`${k}m`};return i.jsx(Ja,{...e,children:i.jsxs("form",{onSubmit:e.handleSubmit(t),className:"space-y-[var(--ui-space-4)] text-foreground",children:[i.jsx(Te,{control:e.control,name:"title",render:({field:x})=>i.jsxs(je,{children:[i.jsxs(we,{children:[v("event_name_label","Event Name")," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx(be,{children:i.jsx(vt,{...x,placeholder:v("event_name_placeholder","Enter event name"),disabled:!a})}),i.jsx(nt,{})]})}),i.jsx(Te,{control:e.control,name:"attendee",render:({field:x})=>{const _=g.filter(k=>k.id!==y);return i.jsxs(je,{children:[i.jsx(we,{children:v("attendee_label","Attendee")}),i.jsx(be,{children:i.jsx(Sa,{value:x.value||[],onChange:x.onChange,personnel:_,placeholder:v("attendee_placeholder","Enter attendee names"),disabled:!a})}),i.jsx(nt,{})]})}}),i.jsx(Te,{control:e.control,name:"resourceId",render:({field:x})=>i.jsxs(je,{children:[i.jsx(we,{children:v("resource_label","Resource")}),w?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-ui py-ui bg-muted rounded-md text-sm border border-input min-h-ui flex items-center",children:l||v("resource_placeholder","Select a resource")}),i.jsx("input",{type:"hidden",...x})]}):i.jsx(be,{children:i.jsxs(Vt,{onValueChange:x.onChange,value:x.value,disabled:!a,children:[i.jsx(be,{children:i.jsx(Et,{children:i.jsx(At,{placeholder:v("resource_placeholder","Select a resource"),children:x.value?f.get(x.value)||x.value:null})})}),i.jsx(Rt,{children:u.map(_=>i.jsx(ut,{value:_.id,children:f.get(_.id)||_.name},_.id))})]})}),i.jsx(nt,{})]})}),i.jsxs("div",{className:"grid grid-cols-3 gap-[var(--ui-space-4)]",children:[i.jsxs("div",{className:"space-y-[var(--ui-space-4)]",children:[i.jsxs("div",{className:"flex justify-between items-center h-[var(--ui-space-5)]",children:[i.jsxs(we,{className:"m-0",children:[v("date_label","Date")," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx(Te,{control:e.control,name:"isAllDay",render:({field:x})=>i.jsxs(je,{className:"flex flex-row items-center space-x-[var(--ui-space-2)] space-y-[var(--ui-space-0)]",children:[i.jsx(be,{children:i.jsx(ln,{id:"isAllDay",checked:x.value,onCheckedChange:x.onChange,disabled:!a})}),i.jsx(we,{htmlFor:"isAllDay",className:"font-normal cursor-pointer text-xs",children:"All Day"})]})})]}),i.jsx(Te,{name:"startDate",control:e.control,render:({field:x})=>i.jsx(je,{children:i.jsx(be,{children:i.jsx(Ka,{value:new Date(x.value),disabled:!a,onChange:_=>{if(_){const k=new Date(x.value);o?_.setHours(0,0,0,0):_.setHours(k.getHours(),k.getMinutes()),x.onChange(Er(_))}}})})})})]}),i.jsxs("div",{className:"space-y-[var(--ui-space-4)]",children:[i.jsx("div",{className:"flex justify-between items-center h-[var(--ui-space-5)]",children:i.jsxs(we,{className:"m-0",children:[v("start_time_label","Start Time")," ",!o&&i.jsx("span",{className:"text-red-500",children:"*"})]})}),i.jsx("div",{className:"flex items-center",children:o?i.jsx("div",{className:"w-full px-ui py-ui text-sm border border-dashed border-border rounded-md bg-muted/10",children:" "}):i.jsx(vt,{value:bc(new Date(c)),readOnly:!0,className:"w-full cursor-pointer py-ui",onClick:()=>a&&h(!0),tabIndex:-1,disabled:!a})})]}),i.jsx(Te,{control:e.control,name:"durationHours",render:({field:x})=>i.jsxs(je,{className:"space-y-[var(--ui-space-4)]",children:[i.jsx("div",{className:"flex justify-between items-center h-[var(--ui-space-5)]",children:i.jsx(we,{className:"m-0",children:v("duration_label","Duration")})}),i.jsxs(Vt,{onValueChange:_=>x.onChange(Number(_)),value:String(x.value),disabled:o||!a,children:[i.jsx(be,{children:i.jsx(Et,{children:i.jsx(At,{})})}),i.jsx(Rt,{className:"max-h-[var(--ui-space-50)]",children:[.25,.5,.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.5,4,4.5,5].map(_=>i.jsx(ut,{value:String(_),children:C(_)},_))})]})]})})]}),p.map(x=>i.jsx(Te,{control:e.control,name:x.name,render:({field:_})=>i.jsxs(je,{children:[i.jsxs(we,{children:[x.label,x.required&&i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx(be,{children:x.type==="textarea"?i.jsx(fn,{..._,value:_.value||"",placeholder:x.placeholder,disabled:!a}):x.type==="select"?i.jsxs(Vt,{onValueChange:_.onChange,value:_.value||"",disabled:!a,children:[i.jsx(be,{children:i.jsx(Et,{children:i.jsx(At,{placeholder:x.placeholder})})}),i.jsx(Rt,{children:x.options?.map(k=>i.jsx(ut,{value:k.value,children:k.label},k.value))})]}):x.type==="number"?i.jsx(vt,{..._,value:_.value||"",type:"number",placeholder:x.placeholder,disabled:!a}):i.jsx(vt,{..._,value:_.value||"",placeholder:x.placeholder,disabled:!a})}),i.jsx(nt,{})]})},x.name)),d&&i.jsxs("div",{className:"p-[var(--ui-space-4)] bg-red-50 border border-red-500 rounded text-red-800 flex items-start gap-[var(--ui-space-2)]",children:[i.jsx(ye.AlertTriangle,{className:"w-[var(--ui-space-5)] h-[var(--ui-space-5)] flex-shrink-0"}),i.jsxs("div",{children:[i.jsx("strong",{className:"block text-sm",children:"Conflict Detected"}),i.jsxs("span",{className:"text-xs",children:[v("event_form_conflict_warning","Clash with existing event")," ","(",Ne(d.existingSchedule.startDate,b.language,"time24")," ","-"," ",Ne(d.existingSchedule.endDate,b.language,"time24"),")"]})]})]}),i.jsx(Te,{control:e.control,name:"status",render:({field:x})=>i.jsxs(je,{children:[i.jsx(we,{children:v("status_label","Status")}),i.jsxs(Vt,{onValueChange:x.onChange,value:x.value,disabled:!a,children:[i.jsx(be,{children:i.jsx(Et,{children:i.jsx(At,{})})}),i.jsxs(Rt,{children:[i.jsx(ut,{value:"booked",children:"Booked"}),i.jsx(ut,{value:"completed",children:"Completed"}),i.jsx(ut,{value:"cancelled",children:"Cancelled"})]})]})]})}),i.jsx(Te,{control:e.control,name:"note",render:({field:x})=>i.jsxs(je,{children:[i.jsx(we,{children:v("note_label","Note")}),i.jsx(be,{children:i.jsx(fn,{...x,placeholder:"Add notes...",rows:2,disabled:!a})})]})}),i.jsxs("div",{className:"flex gap-[var(--ui-space-3)] pt-[var(--ui-space-4)] border-t border-border",children:[a&&s&&n&&i.jsx(ie,{type:"button",variant:"outline-delete",size:"sm",onClick:n,className:"flex-1",children:v("delete_button","Delete")}),i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:r,className:"flex-1",children:a?v("cancel_button","Cancel"):"Close"}),a&&i.jsx(ie,{type:"submit",variant:"default",size:"sm",className:"flex-1",children:v("save_button","Save")})]})]})})}const bg=Le({title:J().min(1,"Event name is required"),attendee:Bt(oc()),resourceId:J().optional(),startDate:J().min(1,"Start date is required"),durationHours:Ce().min(.25).max(24),status:J().optional(),note:J().optional(),isAllDay:qe().optional()}),wg=(e=[])=>{const t=bg,r={};return e.forEach(n=>{let s;n.type==="number"?(s=gs([Ce(),J().transform(a=>Number(a))]),n.required?s=Jn.number().min(1,`${n.label} is required`):s=Jn.number().optional()):(s=J(),n.required?s=s.min(1,`${n.label} is required`):s=s.optional()),r[n.name]=s}),t.extend(r)};function nu({event:e,defaultResourceId:t,defaultStartTime:r,resources:n,personnel:s=[],customFields:a=[],currentUserId:o}){const c=!!e,l=m.useMemo(()=>wg(a),[a]),u=m.useMemo(()=>{const v=(_,k)=>{const j=_?.[k];return typeof j=="string"?j:void 0},b=(_,k)=>{if(!_)return[];try{const j=JSON.parse(_);if(Array.isArray(j))return j.filter(E=>!k||E.personnelId!==k)}catch{}return[]},C={title:v(e?.extendedProps,"originalTitle")||e?.title||"",attendee:b(e?.attendee,o),resourceId:e?.resourceId||t||n[0]?.id||"",startDate:Er(e?.startDate||r||new Date),durationHours:e?Math.round((e.endDate.getTime()-e.startDate.getTime())/36e5*100)/100:1,status:e?.status||"booked",note:e?.note||"",isAllDay:e?.isAllDay||!1},x={};return a.forEach(_=>{const k=e?.extendedProps?.[_.name];x[_.name]=k!==void 0?k:_.defaultValue??""}),{...C,...x}},[e,t,r,n,a,o]),f=ec({resolver:rc(l),defaultValues:u}),d=m.useMemo(()=>e?.id?`edit-${e.id}`:r?`create-${r.getTime()}`:"create-new",[e?.id,r]);m.useEffect(()=>{f.reset(u)},[d]);const h=f.watch("startDate"),p=f.watch("durationHours"),w=f.watch("resourceId"),g=f.watch("isAllDay")??!1,y=m.useMemo(()=>{const v=new Date(h);if(!Number.isNaN(v.getTime())){const b=(Number(p)||0)*60;v.setTime(new Date(h).getTime()+b*6e4)}return v},[h,p]);return{form:f,isEditMode:c,startDateVal:h,durationVal:p,resourceIdVal:w,isAllDay:g,endDateDisplay:y,personnel:s}}function su(e,t,r,n,s){return m.useMemo(()=>{const a=new Date(e);if(Number.isNaN(a.getTime())||!r)return null;const o=(Number(t)||0)*60,c=new Date(a.getTime()+o*6e4),l=n.filter(u=>u.id!==s);return no({startDate:a,endDate:c,resourceId:r},l)},[e,t,r,n,s])}function au(e,t,r,n,s){return e}function ou(e,t){return m.useMemo(()=>{const r=new Map;return e.forEach(n=>{const s=t.find(o=>o.id===n.groupId),a=s?`${n.name} (${s.name})`:n.name;r.set(n.id,a)}),r},[e,t])}function iu(e,t,r,n=[]){const s=new Date(e.startDate);e.isAllDay&&s.setHours(0,0,0,0);const a=(Number(e.durationHours)||0)*60,o=new Date(s.getTime()+a*6e4),c={...t?.extendedProps??{}};r&&!t&&(c.ownerId=r),n.forEach(f=>{e[f.name]!==void 0&&(c[f.name]=e[f.name])});const u=((f,d,h)=>{const p=[...f];if(h){let w=null;if(d)try{const g=JSON.parse(d);Array.isArray(g)&&(w=g.find(y=>y.personnelId===h))}catch{}w||(h==="9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"?w={name:"John Doe",personnelId:h,type:"personnel"}:w={name:"Self",personnelId:h,type:"personnel"}),w&&p.unshift(w)}return JSON.stringify(p)})(e.attendee,t?.attendee,r);return{...e,attendee:u,startDate:s,endDate:o,extendedProps:c}}function cu({isOpen:e,event:t,resources:r,events:n,groups:s,defaultResourceId:a,defaultStartTime:o,onClose:c,onSave:l,onDelete:u,readOnlyResource:f=!1,currentUserId:d,personnel:h,customFields:p=[]}){const{t:w,i18n:g}=_a.useTranslation(),{form:y,isEditMode:v,startDateVal:b,durationVal:C,resourceIdVal:x,isAllDay:_,endDateDisplay:k,personnel:j}=nu({event:t,defaultResourceId:a,defaultStartTime:o,resources:r,personnel:h,customFields:p,currentUserId:d}),E=typeof t?.extendedProps?.ownerId=="string"?t.extendedProps.ownerId:void 0,T=!d||!v||!E||E===d,[M,R]=m.useState(!1),[V,F]=m.useState(!1),[G,$]=m.useState({open:!1,title:"",onConfirm:()=>{}});m.useEffect(()=>{if(e){R(!1);const I=setTimeout(()=>R(!0),100);return()=>clearTimeout(I)}R(!1)},[e]);const L=su(b,C,x||"",n,t?.id),P=au(r,n,new Date(b),k,t?.id),H=ou(P,s),z=m.useMemo(()=>{const I=r.find(se=>se.id===x);if(!I)return x||"";const B=s.find(se=>se.id===I.groupId);return B?`${I.name} (${B.name})`:I.name},[x,r,s]),re=I=>{const B=iu(I,t,d,p);l(B)},q=()=>{!t||!u||$({open:!0,title:w("confirm_delete_title","Are you sure?"),description:w("confirm_delete_message","This action cannot be undone."),onConfirm:()=>{u(t.id),$(I=>({...I,open:!1})),c()}})};return i.jsxs(Wr,{open:e,onOpenChange:I=>!I&&c(),title:v?T?w("event_custom_edit_title","Edit Event"):"View Event (Read Only)":w("event_custom_create_title","Create Event"),children:[i.jsxs("div",{style:{pointerEvents:M?"auto":"none"},children:[!T&&v&&i.jsx("div",{className:"mb-[var(--ui-space-4)] p-[var(--ui-space-2)] bg-yellow-50 text-yellow-800 text-sm rounded border border-yellow-200",children:"You cannot edit this event because you are not the owner."}),i.jsx(xg,{form:y,onSubmit:re,onCancel:c,onDelete:u?q:void 0,isEditMode:v,canEdit:T,isAllDay:_,startDateVal:b,displayValue:z,availableResources:P,resourceDisplayNames:H,conflict:L,setIsTimeModalOpen:F,customFields:p,readOnlyResource:f,personnel:j,currentUserId:d})]}),i.jsx(js,{open:V,onClose:()=>F(!1),onSubmit:I=>{const B=new Date(y.getValues("startDate")),[se,ne]=I.split(":").map(Number);B.setHours(se||0,ne||0),y.setValue("startDate",Er(B)),F(!1)},initialValue:Ne(new Date(b),g.language,"time24"),variant:"time"}),i.jsx(ro,{open:G.open,onOpenChange:I=>$(B=>({...B,open:I})),title:G.title,description:G.description,onConfirm:G.onConfirm,variant:"destructive"})]})}const Ts=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ur(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function po(e){return"nodeType"in e}function Ue(e){var t,r;return e?Ur(e)?e:po(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function go(e){const{Document:t}=Ue(e);return e instanceof t}function wn(e){return Ur(e)?!1:e instanceof Ue(e).HTMLElement}function lu(e){return e instanceof Ue(e).SVGElement}function Zr(e){return e?Ur(e)?e.document:po(e)?go(e)?e:wn(e)||lu(e)?e.ownerDocument:document:document:document}const Ut=Ts?m.useLayoutEffect:m.useEffect;function Ps(e){const t=m.useRef(e);return Ut(()=>{t.current=e}),m.useCallback(function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return t.current==null?void 0:t.current(...n)},[])}function _g(){const e=m.useRef(null),t=m.useCallback((n,s)=>{e.current=setInterval(n,s)},[]),r=m.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function hn(e,t){t===void 0&&(t=[e]);const r=m.useRef(e);return Ut(()=>{r.current!==e&&(r.current=e)},t),r}function _n(e,t){const r=m.useRef();return m.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...t])}function as(e){const t=Ps(e),r=m.useRef(null),n=m.useCallback(s=>{s!==r.current&&t?.(s,r.current),r.current=s},[]);return[r,n]}function os(e){const t=m.useRef();return m.useEffect(()=>{t.current=e},[e]),t.current}let Ks={};function Os(e,t){return m.useMemo(()=>{if(t)return t;const r=Ks[e]==null?0:Ks[e]+1;return Ks[e]=r,e+"-"+r},[e,t])}function uu(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];return n.reduce((a,o)=>{const c=Object.entries(o);for(const[l,u]of c){const f=a[l];f!=null&&(a[l]=f+e*u)}return a},{...t})}}const Tr=uu(1),is=uu(-1);function Sg(e){return"clientX"in e&&"clientY"in e}function vo(e){if(!e)return!1;const{KeyboardEvent:t}=Ue(e.target);return t&&e instanceof t}function Cg(e){if(!e)return!1;const{TouchEvent:t}=Ue(e.target);return t&&e instanceof t}function cs(e){if(Cg(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Sg(e)?{x:e.clientX,y:e.clientY}:null}const mn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[mn.Translate.toString(e),mn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:n}=e;return t+" "+r+"ms "+n}}}),Di="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function kg(e){return e.matches(Di)?e:e.querySelector(Di)}const Dg={display:"none"};function jg(e){let{id:t,value:r}=e;return m.createElement("div",{id:t,style:Dg},r)}function Ng(e){let{id:t,announcement:r,ariaLiveType:n="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return m.createElement("div",{id:t,style:s,role:"status","aria-live":n,"aria-atomic":!0},r)}function Eg(){const[e,t]=m.useState("");return{announce:m.useCallback(n=>{n!=null&&t(n)},[]),announcement:e}}const du=m.createContext(null);function Ag(e){const t=m.useContext(du);m.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Rg(){const[e]=m.useState(()=>new Set),t=m.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[m.useCallback(n=>{let{type:s,event:a}=n;e.forEach(o=>{var c;return(c=o[s])==null?void 0:c.call(o,a)})},[e]),t]}const Tg={draggable:`
|
|
56
|
+
`,style:!n&&!l?{backgroundColor:`hsl(var(--theme-accent) / ${u})`}:void 0,onClick:a,children:[o.jsxs("div",{className:"flex items-center justify-between mb-[var(--ui-space-2)]",children:[o.jsx("span",{className:`text-sm font-semibold ${r?d:"text-muted-foreground"}`,children:i}),n&&o.jsx("span",{className:"text-xs px-[var(--ui-space-1-5)] py-[var(--ui-space-0-5)] rounded bg-theme-warning text-white font-medium",children:"定休日"})]}),!n&&o.jsxs("div",{className:"space-y-[var(--ui-space-1)]",children:[o.jsxs("div",{className:`text-xs ${h}`,children:[c,"/",s]}),o.jsx(tu,{value:t,valueScale:"percent",options:{maximumFractionDigits:0},className:`text-xs font-medium ${d}`})]})]})}function ug(){const e=[{label:"0%",opacity:0},{label:"20%",opacity:.28},{label:"40%",opacity:.46},{label:"60%",opacity:.64},{label:"80%",opacity:.82},{label:"100%",opacity:1}];return o.jsxs("div",{className:"flex items-center justify-center gap-[var(--ui-space-4)] py-[var(--ui-space-3)] border-t border-border bg-background",children:[o.jsx("span",{className:"text-sm text-gray-600",children:"予約密度:"}),o.jsx("div",{className:"flex items-center gap-[var(--ui-space-1)]",children:e.map((t,r)=>o.jsxs("div",{className:"flex flex-col items-center gap-[var(--ui-space-1)]",children:[o.jsx("div",{className:"w-[var(--ui-space-8)] h-[var(--ui-space-8)] border border-gray-300",style:{backgroundColor:t.opacity===0?"white":`hsl(var(--theme-accent) / ${t.opacity})`}}),(r===0||r===e.length-1)&&o.jsx("span",{className:"text-xs text-gray-600",children:t.label})]},t.label))})]})}function dg({month:e,resources:t,events:r,settings:n,selectedGroupId:s,onDayClick:a}){const{t:i}=Le(),{filteredResources:c,filteredEvents:l}=m.useMemo(()=>s?{filteredResources:t.filter(y=>y.groupId===s),filteredEvents:r.filter(y=>y.groupId===s)}:{filteredResources:t,filteredEvents:r},[s,t,r]),u=m.useMemo(()=>{const y=ho(e),x=Rs(y,n.weekStartsOn??1);return lo(x,kr(x,41))},[e,n.weekStartsOn]),f=m.useMemo(()=>po(l),[l]),d=n.timeSlots?n.timeSlots.length:3,h=m.useMemo(()=>{const y=new Map,x=c.length*d;for(const v of u){const _=gr(v),b=eu(v,f),S=x>0?b.length/x*100:0;y.set(_,S)}return y},[u,f,c.length,d]),p=m.useMemo(()=>{const y=u.filter(v=>v.getMonth()===e.getMonth()),x=y.reduce((v,_)=>{const b=gr(_);return v+(h.get(b)||0)},0);return y.length>0?Math.round(x/y.length):0},[u,e,h]),w=m.useMemo(()=>{const y=[];for(let x=0;x<u.length;x+=7)y.push(u.slice(x,x+7));return y},[u]),g=m.useMemo(()=>{const y=[],x=n.weekStartsOn===0?0:1,v=[i("days_short_sun"),i("days_short_mon"),i("days_short_tue"),i("days_short_wed"),i("days_short_thu"),i("days_short_fri"),i("days_short_sat")];for(let _=0;_<7;_++){const b=(x+_)%7;y.push(v[b]||"")}return y},[n.weekStartsOn,i]);return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx("div",{className:"border-b border-border bg-background px-ui py-ui",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("h2",{className:"text-lg font-semibold",children:o.jsx(Ot,{date:e,format:"yearMonth"})}),o.jsx("div",{className:"flex items-center gap-[var(--ui-space-4)] mt-[var(--ui-space-2)]",children:o.jsxs("div",{className:"text-sm text-muted-foreground",children:["Resources: ",c.length," / Utilization:"," ",o.jsx(tu,{value:p,valueScale:"percent",options:{maximumFractionDigits:0},className:"font-medium text-foreground"})]})})]}),o.jsx(ug,{})]})}),o.jsx("div",{className:"w-full p-[var(--ui-space-4)] overflow-y-auto",children:o.jsxs("div",{className:"w-full",children:[o.jsx("div",{className:"grid grid-cols-7 gap-[var(--ui-space-1)] mb-[var(--ui-space-1)]",children:g.map(y=>o.jsx("div",{className:"text-center font-semibold text-sm text-foreground py-[var(--ui-space-2)]",children:y},y))}),o.jsx("div",{className:"grid gap-[var(--ui-space-1)]",style:{gridTemplateRows:`repeat(${w.length}, 1fr)`},children:w.map(y=>o.jsx("div",{className:"grid grid-cols-7 gap-[var(--ui-space-1)]",children:y.map(x=>{const v=x.toISOString().split("T")[0]||"",_=h.get(v)||0,b=x.getMonth()===e.getMonth(),S=n.closedDays.includes(x.getDay());return o.jsx(lg,{date:x,density:_,isCurrentMonth:b,isClosedDay:S,maxSlots:c.length*d,onClick:()=>a?.(x)},v)})},y[0]?.toISOString()??"empty-week"))})]})})]})}function go({currentView:e,onViewChange:t,options:r,className:n}){return o.jsx("div",{className:`flex bg-muted p-[calc(var(--ui-gap-base)/2)] rounded-md gap-[calc(var(--ui-gap-base)/2)] ${n||""}`,children:r.map(s=>o.jsx(oe,{variant:e===s.value?"default":"ghost",onClick:()=>t(s.value),className:"flex-1 h-[var(--ui-component-height)] px-[var(--ui-button-padding-x)]",children:s.label},s.value))})}function fg({currentDate:e,viewMode:t,groups:r,selectedGroupId:n,isLoading:s,hideGroupSelector:a,headerLeft:i,headerRight:c,onNavigate:l,onToday:u,onViewChange:f,onGroupChange:d,isPaginated:h,currentPage:p,totalPages:w,onPageChange:g,pageInfo:y}){const{t:x}=Le();return o.jsxs("header",{className:"border-b border-border px-[var(--ui-space-4)] py-[var(--ui-space-3)] flex items-center justify-between gap-[var(--ui-space-4)]",children:[o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:[o.jsx(oe,{variant:"outline",size:"icon",onClick:()=>l("prev"),"aria-label":x("previous"),children:o.jsx(ye.ChevronLeft,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),o.jsx(oe,{variant:"outline",onClick:u,children:x("today_button")}),o.jsx(oe,{variant:"outline",size:"icon",onClick:()=>l("next"),"aria-label":x("next"),children:o.jsx(ye.ChevronRight,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),o.jsx("span",{className:"text-lg font-bold ml-[var(--ui-space-2)]",children:o.jsx(Ot,{date:e,showSecondary:!0,showDayOfWeek:!0})}),i]}),o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-4)]",children:[!a&&o.jsxs(Wt,{value:n??void 0,onValueChange:d,disabled:s||r.length===0,children:[o.jsx(Rt,{className:"w-[var(--ui-space-50)]",children:o.jsx(Pt,{placeholder:"Select Group",children:n==="ALL"?"All Facilities":r.find(v=>v.id===n)?.name||""})}),o.jsxs(Mt,{children:[o.jsx(at,{value:"ALL",children:"All Facilities"}),r.map(v=>o.jsx(at,{value:v.id,children:v.name},v.id))]})]}),o.jsx(go,{currentView:t,onViewChange:f,options:[{value:"day",label:x("view_day")},{value:"week",label:x("view_week")},{value:"month",label:x("view_month")}]}),h&&w&&w>1&&g&&o.jsx("div",{className:"flex bg-muted p-[calc(var(--ui-gap-base)/2)] rounded-md gap-[calc(var(--ui-gap-base)/2)]",children:Array.from({length:w}).map((v,_)=>{const b=y?.find(C=>C.page===_),S=b?`${x("page")} ${_+1}: ${b.startResource} - ${b.endResource}`:`${x("page")} ${_+1}`;return o.jsx(oe,{variant:(p??0)===_?"default":"ghost",onClick:()=>g(_),className:"h-[var(--ui-component-height)] w-[var(--ui-component-height)] p-0",title:S,children:_+1},_)})}),c]})]})}function Pi(e,t){const r=e.getDay();return t.includes(r)}function hg({weekStart:e,resources:t,events:r,settings:n,groups:s=[],onEventClick:a,onEmptySlotClick:i,components:c}){const l=m.useMemo(()=>uo(n.weekStartsOn),[n.weekStartsOn]),u=m.useMemo(()=>Rs(e,l),[e,l]),f=m.useMemo(()=>fo(e,l),[e,l]),d=m.useMemo(()=>{const v=new Map;for(const _ of s)v.set(_.id,_);return v},[s]),h=m.useMemo(()=>lo(u,f),[u,f]),p=m.useMemo(()=>{const v=Ts(r,u,kr(f,1));return co(v)},[r,u,f]),w=m.useMemo(()=>po(p),[p]),g=m.useMemo(()=>{const v=new Map;for(const _ of h){const b=eu(_,w).sort((C,j)=>C.isAllDay&&!j.isAllDay?-1:!C.isAllDay&&j.isAllDay?1:C.startDate.getTime()-j.startDate.getTime()),S=gr(_);v.set(S,b)}return v},[h,w]),y=m.useMemo(()=>{const v=new Date;return v.setHours(0,0,0,0),v},[]),x=n.orientation==="vertical";return o.jsxs("div",{className:"flex flex-col h-full bg-background overflow-hidden",children:[o.jsx("div",{className:"hidden md:block border-b border-border bg-background px-ui py-ui shrink-0",children:o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-bold",children:[o.jsx(Ot,{date:u,variant:"date"})," - ",h[6]&&o.jsx(Ot,{date:h[6],variant:"monthDay"})]}),o.jsxs("div",{className:"text-sm text-muted-foreground mt-[var(--ui-space-1)]",children:["Events: ",p.length," / Resources: ",t.length]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto",children:x?o.jsxs("div",{className:"flex flex-col min-w-max",children:[o.jsxs("div",{className:"flex border-b border-border bg-background sticky top-0 z-30",children:[o.jsxs("div",{className:"bg-background border-r border-border sticky left-0 z-40 flex shrink-0",children:[o.jsx("div",{className:"w-[var(--ui-space-12)] border-r border-border shrink-0"}),o.jsx("div",{className:"w-[var(--ui-space-32)] flex-1 shrink-0"})]}),h.map(v=>{const _=new Date(v);_.setHours(0,0,0,0);const b=_.getTime()===y.getTime();return o.jsx("div",{className:`flex-1 border-r border-border px-[var(--ui-space-2)] py-[var(--ui-space-2)] text-center min-w-[var(--ui-space-32)] ${b?"bg-primary/5":""}`,children:o.jsx("div",{className:"font-semibold text-xs leading-tight",children:o.jsx(Ot,{date:v,variant:"compact"})})},v.toISOString())})]}),o.jsx("div",{className:"flex flex-col",children:(()=>{const v=[];let _,b=[];return t.forEach((S,C)=>{const j=d.get(S.groupId),N=C>0?t[C-1]:null;N&&N.groupId!==S.groupId&&(v.push({group:_,resources:b}),b=[]),_=j,b.push(S)}),b.length>0&&v.push({group:_,resources:b}),v.map((S,C)=>o.jsxs("div",{className:"flex border-b border-border relative",children:[o.jsx("div",{className:"sticky left-0 z-21 w-[var(--ui-space-12)] flex-shrink-0 bg-background border-r border-border flex items-center justify-center font-bold text-muted-foreground writing-mode-vertical-rl",style:{left:0},children:o.jsx("div",{className:"sticky top-0 py-2 max-h-screen",children:S.group?.name||"-"})}),o.jsx("div",{className:"flex flex-col flex-1 min-w-0",children:S.resources.map((j,N)=>o.jsxs("div",{className:`flex hover:bg-muted/5 group/row relative ${N<S.resources.length-1?"border-b border-border":""}`,children:[o.jsx("div",{className:"w-[var(--ui-space-32)] flex-shrink-0 border-r border-border bg-background sticky left-[var(--ui-space-12)] z-20 px-[var(--ui-space-2)] py-[var(--ui-space-2)] flex flex-col justify-center",children:o.jsx("div",{className:"font-semibold text-xs leading-tight truncate",title:j.name,children:j.name})}),h.map(E=>{const R=new Date(E);R.setHours(0,0,0,0);const M=R.getTime()===y.getTime(),A=Pi(E,n.closedDays),$=gr(E),O=g.get($)??[],B=wa(O,j.id),L=A?"bg-muted":M?"bg-primary/5":"bg-background";return o.jsxs("div",{className:`relative flex-1 border-r border-border p-[var(--ui-space-0-5)] min-w-[var(--ui-space-32)] min-h-[var(--ui-space-24)] ${L} transition-colors overflow-hidden h-[var(--ui-space-24)]`,children:[o.jsx(oe,{type:"button",variant:"ghost",className:"absolute inset-0 z-0 p-0 hover:bg-accent/30","aria-label":`Add event to ${j.name}`,disabled:A||!i,onClick:()=>i?.(j.id,E)}),o.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 h-full overflow-hidden pointer-events-none",children:[B.slice(0,3).map(I=>o.jsx(Mi,{event:I,onClick:a,components:c},I.id)),B.length>3&&o.jsxs("div",{className:"text-[9px] text-muted-foreground text-center",children:["+",B.length-3]})]})]},E.toISOString())})]},j.id))})]},`${S.group?.id}-${C}`))})()})]}):o.jsxs("div",{className:"flex flex-col min-w-max",children:[o.jsxs("div",{className:"flex flex-col sticky top-0 z-30 bg-background border-b border-border",children:[o.jsxs("div",{className:"flex bg-background border-b border-border",children:[o.jsx("div",{className:"flex-shrink-0 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)] bg-background sticky left-0 z-40",style:{width:`${tr.DATE_COLUMN_WIDTH}px`}}),(()=>{const v=[];for(let _=0;_<t.length;_++){const b=t[_],S=d.get(b.groupId);let C=1;for(;_+C<t.length&&t[_+C].groupId===b.groupId;)C++;v.push(o.jsx("div",{className:"flex-1 flex items-center justify-center border-r border-border text-xs font-semibold bg-muted/20 truncate px-2 py-1",style:{minWidth:`${C*80}px`},children:S?.name||"-"},`group-${b.groupId}-${_}`)),_+=C-1}return v})()]}),o.jsxs("div",{className:"flex",children:[o.jsx("div",{className:"flex-shrink-0 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)] bg-background sticky left-0 z-40",style:{width:`${tr.DATE_COLUMN_WIDTH}px`}}),t.map(v=>o.jsx("div",{className:"flex-1 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)] text-center overflow-hidden min-w-[var(--ui-space-20)]",children:o.jsx("div",{className:"font-semibold text-xs leading-tight truncate",title:v.name,children:v.name})},v.id))]})]}),h.map(v=>{const _=new Date(v);_.setHours(0,0,0,0);const b=_.getTime()===y.getTime(),S=Pi(v,n.closedDays),C=gr(v),j=g.get(C)??[];return o.jsxs("div",{className:`flex border-b border-border ${b?"bg-primary/5":""}`,children:[o.jsx("div",{className:`flex-shrink-0 border-r border-border px-[var(--ui-space-1)] py-[var(--ui-space-2)] flex items-center justify-center sticky left-0 z-20 ${S?"bg-muted":"bg-card"}`,style:{width:`${tr.DATE_COLUMN_WIDTH}px`,minHeight:`${tr.DAY_CELL_HEIGHT}px`},children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"font-semibold text-xs leading-tight whitespace-pre-line",children:o.jsx(Ot,{date:v,variant:"compact"})}),S&&o.jsx("div",{className:"text-[10px] text-warning mt-[var(--ui-space-1)]",children:"Off"})]})}),t.map(N=>{const E=wa(j,N.id);return o.jsxs("div",{className:`relative flex-1 border-r border-border p-[var(--ui-space-0-5)] min-w-[var(--ui-space-20)] ${S?"bg-muted":"bg-card hover:bg-accent"} transition-colors overflow-hidden`,style:{minHeight:`${tr.DAY_CELL_HEIGHT}px`},children:[o.jsx(oe,{type:"button",variant:"ghost",className:"absolute inset-0 z-0 p-0","aria-label":`Add event to ${N.name}`,disabled:S||!i,onClick:()=>i?.(N.id,v)}),o.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 h-full overflow-hidden pointer-events-none",children:[E.slice(0,tr.MAX_VISIBLE_EVENTS).map(R=>o.jsx(Mi,{event:R,onClick:a,components:c},R.id)),E.length>tr.MAX_VISIBLE_EVENTS&&o.jsxs("div",{className:"text-[9px] text-muted-foreground text-center",children:["+",E.length-tr.MAX_VISIBLE_EVENTS]})]})]},N.id)})]},v.toISOString())})]})})]})}function Mi({event:e,onClick:t,components:r}){const n=e.hasConflict?"bg-destructive":e.color?"":"bg-primary",s=e.color&&!e.hasConflict?{backgroundColor:e.color}:{},a=e.startDate.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"}),i=({children:c})=>o.jsx("button",{type:"button",className:`${n} text-primary-foreground px-[var(--ui-space-1-5)] py-[var(--ui-space-0-5)] rounded text-[10px] cursor-pointer hover:brightness-110 transition-colors text-left leading-normal truncate w-full pointer-events-auto`,style:s,onClick:l=>{l.stopPropagation(),t?.(e)},children:c});return r?.EventCard?o.jsx(i,{children:o.jsx(r.EventCard,{event:e,viewMode:"week",isCompact:!0,onClick:()=>t?.(e)})}):o.jsx(i,{children:o.jsxs("span",{className:"font-medium",children:[e.hasConflict&&"⚠️ ",!e.isAllDay&&`${a} `,e.title]})})}function mg({allResources:e,paginationOptions:t}){const[r,n]=m.useState(0),s=t?.enabled??!1,a=t?.pageSize??8,i=e.length,{totalPages:c,pageDistribution:l}=m.useMemo(()=>{if(!s||i===0)return{totalPages:1,pageDistribution:[i]};if(i<=a)return{totalPages:1,pageDistribution:[i]};const w=Math.ceil(i/a),g=Math.floor(i/w),y=i%w,x=[];for(let v=0;v<w;v++){const _=v<y?g+1:g;x.push(_)}return{totalPages:w,pageDistribution:x}},[s,i,a]);r>=c&&c>0&&n(c-1);const u=m.useMemo(()=>{if(!s)return e;let w=0;for(let y=0;y<r;y++)w+=l[y]||0;const g=l[r]||e.length;return e.slice(w,w+g)},[e,s,r,l]),f=w=>{const g=Math.max(0,Math.min(w,c-1));n(g)},d=()=>f(r+1),h=()=>f(r-1),p=m.useMemo(()=>{if(!s||c<=1)return[];const w=[];let g=0;for(let y=0;y<c;y++){const x=l[y],v=e[g],_=e[g+x-1];v&&_&&w.push({page:y,startResource:v.name,endResource:_.name}),g+=x}return w},[s,c,l,e]);return{paginatedResources:u,currentPage:r,totalPages:c,goToPage:f,nextPage:d,prevPage:h,isPaginated:s,pageSize:l[r]??a,totalResources:i,pageInfo:p}}function ru({events:e,resources:t,groups:r,selectedGroupId:n}){const s=m.useMemo(()=>n??r[0]?.id??null,[n,r]),a=m.useMemo(()=>s==="ALL"?[...t].sort((c,l)=>{const u=r.findIndex(d=>d.id===c.groupId),f=r.findIndex(d=>d.id===l.groupId);return u!==f?u-f:0}):s?t.filter(c=>c.groupId===s):t,[t,s,r]),i=m.useMemo(()=>s==="ALL"?e:s?e.filter(c=>c.groupId===s):e,[e,s]);return{effectiveGroupId:s,filteredResources:a,filteredEvents:i}}function nu({onEventCreate:e,onEventUpdate:t,onEventDelete:r,onDateChange:n,onViewChange:s}){const[a,i]=m.useState(!1),[c,l]=m.useState(void 0),[u,f]=m.useState({}),d=m.useCallback(x=>{l(x),f({}),i(!0)},[]),h=m.useCallback((x,v)=>{l(void 0),f({resourceId:x||void 0,startTime:v}),i(!0)},[]),p=m.useCallback(x=>{n?.(x),s?.("day")},[n,s]),w=m.useCallback(x=>{c?t?.(c.id,x):e?.(x),i(!1)},[c,e,t]),g=m.useCallback(x=>{r?.(x),i(!1)},[r]),y=m.useCallback(()=>{i(!1)},[]);return{isModalOpen:a,selectedEvent:c,newInfo:u,handleEventClick:d,handleEmptySlotClick:h,handleDayClick:p,handleModalSave:w,handleModalDelete:g,handleModalClose:y}}function vo(e,t,r){const n=r==="next"?1:-1;switch(t){case"day":return kr(e,n);case"week":return Af(e,n);case"month":return za(e,n);default:return e}}function pg(){const e=new Date;return e.setHours(0,0,0,0),e}class su{getItem(t){if(typeof window>"u")return null;try{return localStorage.getItem(t)}catch(r){return console.warn(`Failed to get item from localStorage: ${t}`,r),null}}setItem(t,r){if(!(typeof window>"u"))try{localStorage.setItem(t,r)}catch(n){console.warn(`Failed to set item in localStorage: ${t}`,n)}}removeItem(t){if(!(typeof window>"u"))try{localStorage.removeItem(t)}catch(r){console.warn(`Failed to remove item from localStorage: ${t}`,r)}}}class gg{storage=new Map;getItem(t){return this.storage.get(t)??null}setItem(t,r){this.storage.set(t,r)}removeItem(t){this.storage.delete(t)}clear(){this.storage.clear()}keys(){return Array.from(this.storage.keys())}}const Ps=new su;function au({defaultView:e="day",defaultDate:t=new Date,defaultGroupId:r=null,enablePersistence:n=!1,storageKey:s="facility-schedule-view",storage:a=Ps,onDateChange:i,onViewChange:c,onGroupChange:l}){const[u,f]=m.useState(t),[d,h]=m.useState(()=>{if(n)try{const b=a.getItem(s);if(b&&["day","week","month"].includes(b))return b}catch(b){console.warn("Failed to load schedule view from storage",b)}return e}),[p,w]=m.useState(r);m.useEffect(()=>{if(n)try{a.setItem(s,d)}catch(b){console.warn("Failed to save schedule view to storage",b)}},[d,n,s,a]);const g=m.useCallback(b=>{i&&i(b),f(b)},[i]),y=m.useCallback(b=>{c&&c(b),h(b)},[c]),x=m.useCallback(b=>{l&&l(b),w(b)},[l]),v=m.useCallback(b=>{const S=vo(u,d,b);g(S)},[u,d,g]),_=m.useCallback(()=>{g(new Date)},[g]);return{currentDate:u,viewMode:d,selectedGroupId:p,setDate:g,setViewMode:y,setSelectedGroupId:x,navigate:v,goToToday:_}}function ou({events:e,resources:t,groups:r,settings:n,currentDate:s,viewMode:a,selectedGroupId:i,onDateChange:c,onViewChange:l,onGroupChange:u,onEventCreate:f,onEventUpdate:d,onEventDelete:h,isLoading:p=!1,className:w,hideGroupSelector:g=!1,components:y,headerLeft:x,headerRight:v,defaultView:_="day",enablePersistence:b=!1,storageKey:S="facility-schedule-view",customFields:C,pagination:j}){const{t:N}=Le(),{currentDate:E,viewMode:R,selectedGroupId:M,setViewMode:A,setSelectedGroupId:$,navigate:O,goToToday:B,setDate:L}=au({defaultView:a||_,defaultDate:s,defaultGroupId:i,enablePersistence:b,storageKey:S,onDateChange:c,onViewChange:l,onGroupChange:u}),{effectiveGroupId:I,filteredResources:P,filteredEvents:z}=ru({events:e,resources:t,groups:r,selectedGroupId:M}),{isModalOpen:H,selectedEvent:te,newInfo:G,handleEventClick:V,handleEmptySlotClick:W,handleDayClick:se,handleModalSave:ne,handleModalDelete:fe,handleModalClose:pe}=nu({onEventCreate:f,onEventUpdate:d,onEventDelete:h,onDateChange:L,onViewChange:A}),{paginatedResources:Ae,currentPage:xe,totalPages:Ze,goToPage:Ye,isPaginated:Xe,pageInfo:Ke}=mg({allResources:P,paginationOptions:j});return o.jsxs("div",{className:`flex flex-col h-full bg-background ${w}`,children:[o.jsx(fg,{currentDate:E,viewMode:R,groups:r,selectedGroupId:I,isLoading:p,hideGroupSelector:g,headerLeft:x,headerRight:v,onNavigate:O,onToday:B,onViewChange:A,onGroupChange:$,isPaginated:Xe,currentPage:xe,totalPages:Ze,onPageChange:Ye,pageInfo:Ke}),o.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[p&&o.jsxs("div",{className:"absolute inset-[var(--ui-space-0)] bg-background/50 z-10 flex items-center justify-center",children:[N("loading"),"..."]}),R==="day"&&o.jsx(ng,{currentDate:E,resources:Ae,events:z,settings:n,groups:r,onEventClick:V,onEmptySlotClick:W,components:y}),R==="week"&&o.jsx(hg,{weekStart:E,resources:Ae,events:z,settings:n,groups:r,onEventClick:V,onEmptySlotClick:W,components:y}),R==="month"&&o.jsx(dg,{month:E,events:e,resources:Ae,settings:n,selectedGroupId:I,onDayClick:se})]}),y?.EventModal?o.jsx(y.EventModal,{isOpen:H,onClose:pe,event:te,resources:t,groups:r,events:e,defaultResourceId:G.resourceId,onSave:ne,onDelete:h?fe:void 0,readOnlyResource:!0,customFields:C}):o.jsx(mo,{isOpen:H,onClose:pe,event:te,resources:t,groups:r,events:e,defaultResourceId:G.resourceId,defaultStartTime:G.startTime,onSave:ne,onDelete:h?fe:void 0,readOnlyResource:!0,customFields:C})]})}const _a=["#3B82F6","#DC2626","#7C3AED","#0891B2","#EA580C","#DB2777","#4F46E5","#059669","#9333EA","#0284C7","#BE185D","#0D9488","#7C2D12","#1D4ED8","#9F1239","#6D28D9","#166534","#B45309","#1E40AF","#831843"];function yo(e){return _a[e%_a.length]}function vg(e){const t=new Map;return e.forEach((r,n)=>{t.set(r,yo(n))}),t}function iu(e,t){const r=cu(t);return r.length>0?`${e} (${r.join(", ")})`:e}function cu(e){if(!e||e==="[]")return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(r=>{if(typeof r!="object"||r===null)return null;const n=r.name;return typeof n=="string"?n:null}).filter(r=>!!r)}catch{return e.split(/[,、]/).map(t=>t.trim()).filter(Boolean)}return[]}function lu(e,t){const r=s=>typeof s=="string"?s:void 0;let n=r(e?.ownerId)??r(e?.personnelId);if(!n&&t&&t!=="[]")try{const s=JSON.parse(t);Array.isArray(s)&&s.length>0&&(n=s[0].personnelId)}catch{}return n}function yg(e){const t=typeof e.extendedProps?.realId=="string"?e.extendedProps.realId:e.id;return{...e,id:t}}function xg(e,t){const r=new Map;return e.forEach(n=>{const s=typeof n.extendedProps?.isAllDay=="boolean"?n.extendedProps.isAllDay:void 0;(!n.attendee||n.attendee==="[]")&&r.set(n.id,{...n,isAllDay:n.isAllDay??s??!1})}),t.forEach(n=>{const s=typeof n.extendedProps?.isAllDay=="boolean"?n.extendedProps.isAllDay:void 0;r.set(n.id,{...n,isAllDay:n.isAllDay??s??!1})}),Array.from(r.values())}function bg(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch{return console.warn("[transformBookings] Failed to parse extendedProps",e),{}}return e}function uu(e,t){return e.flatMap(r=>r.bookings.map(n=>{const s=bg(n.extendedProps),a=iu(n.title,n.attendee),i=lu(s,n.attendee);let c;if(i&&t.length>0){const l=t.findIndex(u=>u.id===i);l>=0&&(c=yo(l))}return{id:n.eventId,groupId:r.groupId,resourceId:r.resourceId,title:a,startDate:new Date(n.startDate),endDate:new Date(n.endDate),isAllDay:n.isAllDay,attendee:n.attendee,color:c,status:"booked",createdAt:new Date,updatedAt:new Date,extendedProps:{...s,originalTitle:n.title,ownerId:i}}}))}function wg({settings:e,currentUserId:t,enablePersistence:r=!0,pagination:n}){const{resources:s,groups:a,settings:i,loading:c,error:l,events:u,createEvent:f,updateEvent:d,deleteEvent:h,fetchResourceAvailability:p,personnel:w}=Ql(),g=t||w?.[0]?.id,[y,x]=m.useState(new Date),[v,_]=m.useState("day"),[b,S]=m.useState([]),[C,j]=m.useState(!1),[N,E]=m.useState([]),R=m.useCallback(async()=>{j(!0);try{const H=await p(y,v),te=uu(H,w);console.log(`[FacilityScheduleManager] Loaded ${te.length} events for ${v} view`),S(te)}catch(H){console.error("Failed to fetch data",H)}finally{j(!1)}},[y,v,p,w,u]);m.useEffect(()=>{R()},[R]);const M=m.useMemo(()=>{const H=new Map;for(const te of u)H.set(te.id,te);for(const te of b){const G=H.get(te.id);G?H.set(te.id,{...G,color:te.color||G.color,groupId:te.groupId||G.groupId}):H.set(te.id,te)}return Array.from(H.values())},[u,b]),A=m.useCallback(async H=>{const te={title:H.title,attendee:H.attendee,resourceId:H.resourceId||void 0,startDate:H.startDate,endDate:H.endDate,status:H.status,note:H.note,isAllDay:H.isAllDay,extendedProps:{...H.extendedProps||{},ownerId:g}};try{await f(te)}catch(G){console.error("Failed to save event",G)}},[f,g]),$=m.useCallback(async(H,te)=>{const G={title:te.title,attendee:te.attendee,resourceId:te.resourceId||void 0,startDate:te.startDate,endDate:te.endDate,status:te.status,note:te.note,isAllDay:te.isAllDay,extendedProps:{...te.extendedProps||{}}};try{await d(H,G)}catch(V){console.error("Failed to update event",V)}},[d]),O=m.useCallback(async H=>{try{await h(H)}catch(te){console.error("Failed to delete event",te)}},[h]),B=m.useCallback(async H=>{try{const te=await p(H.startDate,"day");E(te.map(G=>({resourceId:G.resourceId,isAvailable:G.isAvailable})))}catch(te){console.error("Failed to fetch specific availability",te)}},[p]),L=m.useRef({effectiveUserId:g,personnel:w,resourceAvailability:N,onAvailabilityRequest:B});m.useEffect(()=>{L.current={effectiveUserId:g,personnel:w,resourceAvailability:N,onAvailabilityRequest:B}},[g,w,N,B]);const I=m.useMemo(()=>H=>o.jsx(mo,{...H,currentUserId:L.current.effectiveUserId,personnel:L.current.personnel,readOnlyResource:!0,resourceAvailability:L.current.resourceAvailability,onAvailabilityRequest:L.current.onAvailabilityRequest}),[]);if(l)return o.jsxs("div",{className:"p-[var(--ui-space-4)] text-red-500",children:["Error: ",l]});if(!i||c)return o.jsx("div",{className:"p-[var(--ui-space-4)]",children:"Loading schedule data..."});const P={...i,weekStartsOn:e.weekStartsOn??i.weekStartsOn,startTime:e.businessHoursStart!==void 0?`${e.businessHoursStart.toString().padStart(2,"0")}:00`:i.startTime,endTime:e.businessHoursEnd!==void 0?`${e.businessHoursEnd.toString().padStart(2,"0")}:00`:i.endTime,orientation:e.facilityOrientation,slotInterval:e.facilitySlotInterval||60},z={enabled:n?.enabled??e.paginationEnabled??i.paginationEnabled??!1,pageSize:n?.pageSize??e.paginationPageSize??i.paginationPageSize??8};return o.jsx(ou,{events:M,resources:s,groups:a,settings:P,isLoading:c||C,currentDate:y,viewMode:v,onDateChange:x,onViewChange:_,onEventCreate:A,onEventUpdate:$,onEventDelete:O,components:{EventModal:I},enablePersistence:r,pagination:z})}function _g({groups:e,resources:t,onCreateGroup:r,onUpdateGroup:n,onDeleteGroup:s,onCreateResource:a,onUpdateResource:i,onDeleteResource:c,onClose:l}){const{t:u}=Le(),[f,d]=m.useState(null),[h,p]=m.useState(null),[w,g]=m.useState(""),y=O=>{d(O.id),g(O.name)},x=async O=>{w.trim()&&await n(O,{name:w}),d(null)},v=async()=>{const O=prompt(u("facility_prompt_group_name")||"Enter Group Name");O&&await r({name:O})},_=async O=>{confirm(u("facility_confirm_delete_group_message"))&&await s(O)},b=O=>{p(O.id),g(O.name)},S=async O=>{w.trim()&&await i(O,{name:w}),p(null)},C=async O=>{const B=prompt(u("facility_prompt_resource_name")||"Enter Resource Name");if(B){const L=t.filter(P=>P.groupId===O),I=Math.max(0,...L.map(P=>P.order));await a({name:B,groupId:O,order:I+1,isAvailable:!0})}},j=async O=>{confirm(u("facility_confirm_delete_resource_message"))&&await c(O)},N={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto"},E={backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)",width:"100%",maxWidth:"600px",maxHeight:"90vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},R={marginBottom:"24px"},M={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px",fontWeight:"bold",fontSize:"14px"},A={display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center"},$={padding:"0 8px",borderRadius:"var(--radius)",border:"1px solid hsl(var(--border))",backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))",fontSize:"var(--ui-font-size-base)",height:"var(--ui-component-height)",width:"100%"};return o.jsxs("div",{style:N,children:[o.jsx("button",{type:"button","aria-label":u("close"),onClick:l,style:{position:"absolute",inset:0,background:"transparent",border:"none",padding:0,margin:0}}),o.jsxs("div",{style:{...E,position:"relative",zIndex:1},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"24px",paddingBottom:"16px",borderBottom:"1px solid hsl(var(--border))"},children:[o.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:"bold"},children:u("facility_settings_title")}),o.jsx(oe,{variant:"ghost",size:"icon",onClick:l,children:o.jsx(ye.X,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-[var(--ui-space-6)]",children:[o.jsxs("div",{style:{...R,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid hsl(var(--border))",paddingBottom:"16px"},children:[o.jsxs("h3",{className:"text-md font-medium text-muted-foreground m-[var(--ui-space-0)]",children:[u("facility_label_group_name"),"s &"," ",u("facility_label_resource_name"),"s"]}),o.jsxs(oe,{onClick:v,children:[o.jsx(ye.Plus,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)] mr-[var(--ui-space-2)]"}),u("facility_action_add_group")]})]}),e.map(O=>o.jsxs("div",{style:{...R,borderBottom:"1px solid hsl(var(--border))",paddingBottom:"24px",marginBottom:"24px"},children:[o.jsx("div",{style:M,children:f===O.id?o.jsxs("div",{style:{display:"flex",gap:"8px",flex:1,alignItems:"center"},children:[o.jsx("input",{style:{...$,flex:1},value:w,onChange:B=>g(B.target.value)}),o.jsx(oe,{onClick:()=>x(O.id),children:u("save_button")}),o.jsx(oe,{variant:"ghost",onClick:()=>d(null),children:u("cancel_button")})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:"16px"},children:O.name}),o.jsxs("div",{style:{display:"flex",gap:"4px"},children:[o.jsx(oe,{variant:"ghost",size:"icon",onClick:()=>y(O),children:o.jsx(ye.Edit,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),o.jsx(oe,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>_(O.id),children:o.jsx(ye.Trash,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})})]})]})}),o.jsxs("div",{style:A,children:[t.filter(B=>B.groupId===O.id).sort((B,L)=>B.order-L.order).map(B=>o.jsx("div",{style:{display:"flex",alignItems:"center",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)",padding:"4px 8px",backgroundColor:"hsl(var(--muted) / 0.3)"},children:h===B.id?o.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[o.jsx("input",{style:{...$,width:"120px",height:"28px",fontSize:"13px"},value:w,onChange:L=>g(L.target.value)}),o.jsx(oe,{size:"sm",onClick:()=>S(B.id),children:u("save_button")}),o.jsx(oe,{size:"icon",variant:"ghost",className:"h-[var(--ui-space-6)] w-[var(--ui-space-6)]",onClick:()=>p(null),children:o.jsx(ye.X,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{marginRight:"8px",fontSize:"14px"},children:B.name}),o.jsx(oe,{variant:"ghost",size:"icon",className:"h-[var(--ui-space-6)] w-[var(--ui-space-6)] opacity-50 hover:opacity-100",onClick:()=>b(B),children:o.jsx(ye.Edit,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})}),o.jsx(oe,{variant:"ghost",size:"icon",className:"h-[var(--ui-space-6)] w-[var(--ui-space-6)] text-destructive opacity-50 hover:opacity-100",onClick:()=>j(B.id),children:o.jsx(ye.Trash,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)]"})})]})},B.id)),o.jsxs(oe,{variant:"outline",size:"sm",onClick:()=>C(O.id),children:[o.jsx(ye.Plus,{className:"h-[var(--ui-space-3)] w-[var(--ui-space-3)] mr-[var(--ui-space-1)]"}),u("facility_action_add_resource")]})]})]},O.id)),e.length===0&&o.jsx("div",{style:{textAlign:"center",padding:"32px",color:"hsl(var(--muted-foreground))"},children:u("facility_label_no_groups")})]}),o.jsx("div",{style:{padding:"24px",borderTop:"1px solid hsl(var(--border))",display:"flex",justifyContent:"flex-end"},children:o.jsx(oe,{onClick:l,children:u("facility_action_done")})})]})]})}function Sg({form:e,onSubmit:t,onCancel:r,onDelete:n,isEditMode:s,canEdit:a,isAllDay:i,startDateVal:c,displayValue:l,availableResources:u,resourceDisplayNames:f,conflict:d,setIsTimeModalOpen:h,customFields:p=[],readOnlyResource:w=!1,personnel:g=[],currentUserId:y}){const{t:x,i18n:v}=ja.useTranslation(),_=b=>{const S=Math.floor(b),C=Math.round((b-S)*60);return S>0&&C>0?`${S}h ${C}m`:S>0?`${S}h`:`${C}m`};return o.jsx(ro,{...e,children:o.jsxs("form",{onSubmit:e.handleSubmit(t),className:"space-y-[var(--ui-space-4)] text-foreground",children:[o.jsx(Re,{control:e.control,name:"title",render:({field:b})=>o.jsxs(De,{children:[o.jsxs(_e,{children:[x("event_name_label","Event Name")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx(be,{children:o.jsx(xt,{...b,placeholder:x("event_name_placeholder","Enter event name"),disabled:!a})}),o.jsx(nt,{})]})}),o.jsx(Re,{control:e.control,name:"attendee",render:({field:b})=>{const S=g.filter(C=>C.id!==y);return o.jsxs(De,{children:[o.jsx(_e,{children:x("attendee_label","Attendee")}),o.jsx(be,{children:o.jsx(Da,{value:b.value||[],onChange:b.onChange,personnel:S,placeholder:x("attendee_placeholder","Enter attendee names"),disabled:!a})}),o.jsx(nt,{})]})}}),o.jsx(Re,{control:e.control,name:"resourceId",render:({field:b})=>o.jsxs(De,{children:[o.jsx(_e,{children:x("resource_label","Resource")}),w?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-ui py-ui bg-muted rounded-md text-sm border border-input min-h-ui flex items-center",children:l||x("resource_placeholder","Select a resource")}),o.jsx("input",{type:"hidden",...b})]}):o.jsx(be,{children:o.jsxs(Wt,{onValueChange:b.onChange,value:b.value,disabled:!a,children:[o.jsx(be,{children:o.jsx(Rt,{children:o.jsx(Pt,{placeholder:x("resource_placeholder","Select a resource"),children:b.value?f.get(b.value)||b.value:null})})}),o.jsx(Mt,{children:u.map(S=>o.jsx(at,{value:S.id,children:f.get(S.id)||S.name},S.id))})]})}),o.jsx(nt,{})]})}),o.jsxs("div",{className:"grid grid-cols-3 gap-[var(--ui-space-4)]",children:[o.jsxs("div",{className:"space-y-[var(--ui-space-4)]",children:[o.jsxs("div",{className:"flex justify-between items-center h-[var(--ui-space-5)]",children:[o.jsxs(_e,{className:"m-0",children:[x("date_label","Date")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx(Re,{control:e.control,name:"isAllDay",render:({field:b})=>o.jsxs(De,{className:"flex flex-row items-center space-x-[var(--ui-space-2)] space-y-[var(--ui-space-0)]",children:[o.jsx(be,{children:o.jsx(dn,{id:"isAllDay",checked:b.value,onCheckedChange:b.onChange,disabled:!a})}),o.jsx(_e,{htmlFor:"isAllDay",className:"font-normal cursor-pointer text-xs",children:"All Day"})]})})]}),o.jsx(Re,{name:"startDate",control:e.control,render:({field:b})=>o.jsx(De,{children:o.jsx(be,{children:o.jsx(to,{value:new Date(b.value),disabled:!a,onChange:S=>{if(S){const C=new Date(b.value);i?S.setHours(0,0,0,0):S.setHours(C.getHours(),C.getMinutes()),b.onChange(Pr(S))}}})})})})]}),o.jsxs("div",{className:"space-y-[var(--ui-space-4)]",children:[o.jsx("div",{className:"flex justify-between items-center h-[var(--ui-space-5)]",children:o.jsxs(_e,{className:"m-0",children:[x("start_time_label","Start Time")," ",!i&&o.jsx("span",{className:"text-red-500",children:"*"})]})}),o.jsx("div",{className:"flex items-center",children:i?o.jsx("div",{className:"w-full px-ui py-ui text-sm border border-dashed border-border rounded-md bg-muted/10",children:" "}):o.jsx(xt,{value:Ec(new Date(c)),readOnly:!0,className:"w-full cursor-pointer py-ui",onClick:()=>a&&h(!0),tabIndex:-1,disabled:!a})})]}),o.jsx(Re,{control:e.control,name:"durationHours",render:({field:b})=>o.jsxs(De,{className:"space-y-[var(--ui-space-4)]",children:[o.jsx("div",{className:"flex justify-between items-center h-[var(--ui-space-5)]",children:o.jsx(_e,{className:"m-0",children:x("duration_label","Duration")})}),o.jsxs(Wt,{onValueChange:S=>b.onChange(Number(S)),value:String(b.value),disabled:i||!a,children:[o.jsx(be,{children:o.jsx(Rt,{children:o.jsx(Pt,{})})}),o.jsx(Mt,{className:"max-h-[var(--ui-space-50)]",children:[.25,.5,.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.5,4,4.5,5].map(S=>o.jsx(at,{value:String(S),children:_(S)},S))})]})]})})]}),p.map(b=>o.jsx(Re,{control:e.control,name:b.name,render:({field:S})=>o.jsxs(De,{children:[o.jsxs(_e,{children:[b.label,b.required&&o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx(be,{children:b.type==="textarea"?o.jsx(mn,{...S,value:S.value||"",placeholder:b.placeholder,disabled:!a}):b.type==="select"?o.jsxs(Wt,{onValueChange:S.onChange,value:S.value||"",disabled:!a,children:[o.jsx(be,{children:o.jsx(Rt,{children:o.jsx(Pt,{placeholder:b.placeholder})})}),o.jsx(Mt,{children:b.options?.map(C=>o.jsx(at,{value:C.value,children:C.label},C.value))})]}):b.type==="number"?o.jsx(xt,{...S,value:S.value||"",type:"number",placeholder:b.placeholder,disabled:!a}):o.jsx(xt,{...S,value:S.value||"",placeholder:b.placeholder,disabled:!a})}),o.jsx(nt,{})]})},b.name)),d&&o.jsxs("div",{className:"p-[var(--ui-space-4)] bg-red-50 border border-red-500 rounded text-red-800 flex items-start gap-[var(--ui-space-2)]",children:[o.jsx(ye.AlertTriangle,{className:"w-[var(--ui-space-5)] h-[var(--ui-space-5)] flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("strong",{className:"block text-sm",children:"Conflict Detected"}),o.jsxs("span",{className:"text-xs",children:[x("event_form_conflict_warning","Clash with existing event")," ","(",Ne(d.existingSchedule.startDate,v.language,"time24")," ","-"," ",Ne(d.existingSchedule.endDate,v.language,"time24"),")"]})]})]}),o.jsx(Re,{control:e.control,name:"status",render:({field:b})=>o.jsxs(De,{children:[o.jsx(_e,{children:x("status_label","Status")}),o.jsxs(Wt,{onValueChange:b.onChange,value:b.value,disabled:!a,children:[o.jsx(be,{children:o.jsx(Rt,{children:o.jsx(Pt,{})})}),o.jsxs(Mt,{children:[o.jsx(at,{value:"booked",children:"Booked"}),o.jsx(at,{value:"completed",children:"Completed"}),o.jsx(at,{value:"cancelled",children:"Cancelled"})]})]})]})}),o.jsx(Re,{control:e.control,name:"note",render:({field:b})=>o.jsxs(De,{children:[o.jsx(_e,{children:x("note_label","Note")}),o.jsx(be,{children:o.jsx(mn,{...b,placeholder:"Add notes...",rows:2,disabled:!a})})]})}),o.jsxs("div",{className:"flex gap-[var(--ui-space-3)] pt-[var(--ui-space-4)] border-t border-border",children:[a&&s&&n&&o.jsx(oe,{type:"button",variant:"outline-delete",size:"sm",onClick:n,className:"flex-1",children:x("delete_button","Delete")}),o.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:r,className:"flex-1",children:a?x("cancel_button","Cancel"):"Close"}),a&&o.jsx(oe,{type:"submit",variant:"default",size:"sm",className:"flex-1",children:x("save_button","Save")})]})]})})}const kg=Fe({title:J().min(1,"Event name is required"),attendee:Zt(gc()),resourceId:J().optional(),startDate:J().min(1,"Start date is required"),durationHours:we().min(.25).max(24),status:J().optional(),note:J().optional(),isAllDay:qe().optional()}),Cg=(e=[])=>{const t=kg,r={};return e.forEach(n=>{let s;n.type==="number"?(s=ys([we(),J().transform(a=>Number(a))]),n.required?s=Qn.number().min(1,`${n.label} is required`):s=Qn.number().optional()):(s=J(),n.required?s=s.min(1,`${n.label} is required`):s=s.optional()),r[n.name]=s}),t.extend(r)};function du({event:e,defaultResourceId:t,defaultStartTime:r,resources:n,personnel:s=[],customFields:a=[],currentUserId:i}){const c=!!e,l=m.useMemo(()=>Cg(a),[a]),u=m.useMemo(()=>{const x=(S,C)=>{const j=S?.[C];return typeof j=="string"?j:void 0},v=(S,C)=>{if(!S)return[];try{const j=JSON.parse(S);if(Array.isArray(j))return j.filter(N=>!C||N.personnelId!==C)}catch{}return[]},_={title:x(e?.extendedProps,"originalTitle")||e?.title||"",attendee:v(e?.attendee,i),resourceId:e?.resourceId||t||n[0]?.id||"",startDate:Pr(e?.startDate||r||new Date),durationHours:e?Math.round((e.endDate.getTime()-e.startDate.getTime())/36e5*100)/100:1,status:e?.status||"booked",note:e?.note||"",isAllDay:e?.isAllDay||!1},b={};return a.forEach(S=>{const C=e?.extendedProps?.[S.name];b[S.name]=C!==void 0?C:S.defaultValue??""}),{..._,...b}},[e,t,r,n,a,i]),f=uc({resolver:fc(l),defaultValues:u}),d=m.useMemo(()=>e?.id?`edit-${e.id}`:r?`create-${r.getTime()}`:"create-new",[e?.id,r]);m.useEffect(()=>{f.reset(u)},[d]);const h=f.watch("startDate"),p=f.watch("durationHours"),w=f.watch("resourceId"),g=f.watch("isAllDay")??!1,y=m.useMemo(()=>{const x=new Date(h);if(!Number.isNaN(x.getTime())){const v=(Number(p)||0)*60;x.setTime(new Date(h).getTime()+v*6e4)}return x},[h,p]);return{form:f,isEditMode:c,startDateVal:h,durationVal:p,resourceIdVal:w,isAllDay:g,endDateDisplay:y,personnel:s}}function fu(e,t,r,n,s){return m.useMemo(()=>{const a=new Date(e);if(Number.isNaN(a.getTime())||!r)return null;const i=(Number(t)||0)*60,c=new Date(a.getTime()+i*6e4),l=n.filter(u=>u.id!==s);return io({startDate:a,endDate:c,resourceId:r},l)},[e,t,r,n,s])}function hu(e,t,r,n,s){return e}function mu(e,t){return m.useMemo(()=>{const r=new Map;return e.forEach(n=>{const s=t.find(i=>i.id===n.groupId),a=s?`${n.name} (${s.name})`:n.name;r.set(n.id,a)}),r},[e,t])}function pu(e,t,r,n=[]){const s=new Date(e.startDate);e.isAllDay&&s.setHours(0,0,0,0);const a=(Number(e.durationHours)||0)*60,i=new Date(s.getTime()+a*6e4),c={...t?.extendedProps??{}};r&&!t&&(c.ownerId=r),n.forEach(f=>{e[f.name]!==void 0&&(c[f.name]=e[f.name])});const u=((f,d,h)=>{const p=[...f];if(h){let w=null;if(d)try{const g=JSON.parse(d);Array.isArray(g)&&(w=g.find(y=>y.personnelId===h))}catch{}w||(h==="9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"?w={name:"John Doe",personnelId:h,type:"personnel"}:w={name:"Self",personnelId:h,type:"personnel"}),w&&p.unshift(w)}return JSON.stringify(p)})(e.attendee,t?.attendee,r);return{...e,attendee:u,startDate:s,endDate:i,extendedProps:c}}function gu({isOpen:e,event:t,resources:r,events:n,groups:s,defaultResourceId:a,defaultStartTime:i,onClose:c,onSave:l,onDelete:u,readOnlyResource:f=!1,currentUserId:d,personnel:h,customFields:p=[]}){const{t:w,i18n:g}=ja.useTranslation(),{form:y,isEditMode:x,startDateVal:v,durationVal:_,resourceIdVal:b,isAllDay:S,endDateDisplay:C,personnel:j}=du({event:t,defaultResourceId:a,defaultStartTime:i,resources:r,personnel:h,customFields:p,currentUserId:d}),N=typeof t?.extendedProps?.ownerId=="string"?t.extendedProps.ownerId:void 0,R=!d||!x||!N||N===d,[M,A]=m.useState(!1),[$,O]=m.useState(!1),[B,L]=m.useState({open:!1,title:"",onConfirm:()=>{}});m.useEffect(()=>{if(e){A(!1);const V=setTimeout(()=>A(!0),100);return()=>clearTimeout(V)}A(!1)},[e]);const I=fu(v,_,b||"",n,t?.id),P=hu(r,n,new Date(v),C,t?.id),z=mu(P,s),H=m.useMemo(()=>{const V=r.find(se=>se.id===b);if(!V)return b||"";const W=s.find(se=>se.id===V.groupId);return W?`${V.name} (${W.name})`:V.name},[b,r,s]),te=V=>{const W=pu(V,t,d,p);l(W)},G=()=>{!t||!u||L({open:!0,title:w("confirm_delete_title","Are you sure?"),description:w("confirm_delete_message","This action cannot be undone."),onConfirm:()=>{u(t.id),L(V=>({...V,open:!1})),c()}})};return o.jsxs(Yr,{open:e,onOpenChange:V=>!V&&c(),title:x?R?w("event_custom_edit_title","Edit Event"):"View Event (Read Only)":w("event_custom_create_title","Create Event"),children:[o.jsxs("div",{style:{pointerEvents:M?"auto":"none"},children:[!R&&x&&o.jsx("div",{className:"mb-[var(--ui-space-4)] p-[var(--ui-space-2)] bg-yellow-50 text-yellow-800 text-sm rounded border border-yellow-200",children:"You cannot edit this event because you are not the owner."}),o.jsx(Sg,{form:y,onSubmit:te,onCancel:c,onDelete:u?G:void 0,isEditMode:x,canEdit:R,isAllDay:S,startDateVal:v,displayValue:H,availableResources:P,resourceDisplayNames:z,conflict:I,setIsTimeModalOpen:O,customFields:p,readOnlyResource:f,personnel:j,currentUserId:d})]}),o.jsx(Es,{open:$,onClose:()=>O(!1),onSubmit:V=>{const W=new Date(y.getValues("startDate")),[se,ne]=V.split(":").map(Number);W.setHours(se||0,ne||0),y.setValue("startDate",Pr(W)),O(!1)},initialValue:Ne(new Date(v),g.language,"time24"),variant:"time"}),o.jsx(oo,{open:B.open,onOpenChange:V=>L(W=>({...W,open:V})),title:B.title,description:B.description,onConfirm:B.onConfirm,variant:"destructive"})]})}const Ms=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gr(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function xo(e){return"nodeType"in e}function Ue(e){var t,r;return e?Gr(e)?e:xo(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function bo(e){const{Document:t}=Ue(e);return e instanceof t}function _n(e){return Gr(e)?!1:e instanceof Ue(e).HTMLElement}function vu(e){return e instanceof Ue(e).SVGElement}function qr(e){return e?Gr(e)?e.document:xo(e)?bo(e)?e:_n(e)||vu(e)?e.ownerDocument:document:document:document}const qt=Ms?m.useLayoutEffect:m.useEffect;function Os(e){const t=m.useRef(e);return qt(()=>{t.current=e}),m.useCallback(function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return t.current==null?void 0:t.current(...n)},[])}function jg(){const e=m.useRef(null),t=m.useCallback((n,s)=>{e.current=setInterval(n,s)},[]),r=m.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function pn(e,t){t===void 0&&(t=[e]);const r=m.useRef(e);return qt(()=>{r.current!==e&&(r.current=e)},t),r}function Sn(e,t){const r=m.useRef();return m.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...t])}function os(e){const t=Os(e),r=m.useRef(null),n=m.useCallback(s=>{s!==r.current&&t?.(s,r.current),r.current=s},[]);return[r,n]}function is(e){const t=m.useRef();return m.useEffect(()=>{t.current=e},[e]),t.current}let Qs={};function Is(e,t){return m.useMemo(()=>{if(t)return t;const r=Qs[e]==null?0:Qs[e]+1;return Qs[e]=r,e+"-"+r},[e,t])}function yu(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];return n.reduce((a,i)=>{const c=Object.entries(i);for(const[l,u]of c){const f=a[l];f!=null&&(a[l]=f+e*u)}return a},{...t})}}const Ir=yu(1),cs=yu(-1);function Dg(e){return"clientX"in e&&"clientY"in e}function wo(e){if(!e)return!1;const{KeyboardEvent:t}=Ue(e.target);return t&&e instanceof t}function Ng(e){if(!e)return!1;const{TouchEvent:t}=Ue(e.target);return t&&e instanceof t}function ls(e){if(Ng(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Dg(e)?{x:e.clientX,y:e.clientY}:null}const gn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[gn.Translate.toString(e),gn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:n}=e;return t+" "+r+"ms "+n}}}),Oi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Eg(e){return e.matches(Oi)?e:e.querySelector(Oi)}const Ag={display:"none"};function Tg(e){let{id:t,value:r}=e;return m.createElement("div",{id:t,style:Ag},r)}function Rg(e){let{id:t,announcement:r,ariaLiveType:n="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return m.createElement("div",{id:t,style:s,role:"status","aria-live":n,"aria-atomic":!0},r)}function Pg(){const[e,t]=m.useState("");return{announce:m.useCallback(n=>{n!=null&&t(n)},[]),announcement:e}}const xu=m.createContext(null);function Mg(e){const t=m.useContext(xu);m.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Og(){const[e]=m.useState(()=>new Set),t=m.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[m.useCallback(n=>{let{type:s,event:a}=n;e.forEach(i=>{var c;return(c=i[s])==null?void 0:c.call(i,a)})},[e]),t]}const Ig={draggable:`
|
|
57
57
|
To pick up a draggable item, press the space bar.
|
|
58
58
|
While dragging, use the arrow keys to move the item.
|
|
59
59
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
60
|
-
`},Pg={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Og(e){let{announcements:t=Pg,container:r,hiddenTextDescribedById:n,screenReaderInstructions:s=Tg}=e;const{announce:a,announcement:o}=Eg(),c=Os("DndLiveRegion"),[l,u]=m.useState(!1);if(m.useEffect(()=>{u(!0)},[]),Ag(m.useMemo(()=>({onDragStart(d){let{active:h}=d;a(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;t.onDragMove&&a(t.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;a(t.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;a(t.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;a(t.onDragCancel({active:h,over:p}))}}),[a,t])),!l)return null;const f=m.createElement(m.Fragment,null,m.createElement(jg,{id:n,value:s.draggable}),m.createElement(Ng,{id:c,announcement:o}));return r?dr.createPortal(f,r):f}var Pe;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Pe||(Pe={}));function ls(){}function Mg(e,t){return m.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Ig(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return m.useMemo(()=>[...t].filter(n=>n!=null),[...t])}const bt=Object.freeze({x:0,y:0});function Fg(e,t){const r=cs(e);if(!r)return"0 0";const n={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return n.x+"% "+n.y+"%"}function Lg(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function $g(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Vg(e,t){const r=Math.max(t.top,e.top),n=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=s-n,c=a-r;if(n<s&&r<a){const l=t.width*t.height,u=e.width*e.height,f=o*c,d=f/(l+u-f);return Number(d.toFixed(4))}return 0}const zg=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const s=[];for(const a of n){const{id:o}=a,c=r.get(o);if(c){const l=Vg(c,t);l>0&&s.push({id:o,data:{droppableContainer:a,value:l}})}}return s.sort(Lg)};function Bg(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function fu(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:bt}function Hg(e){return function(r){for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];return s.reduce((o,c)=>({...o,top:o.top+e*c.y,bottom:o.bottom+e*c.y,left:o.left+e*c.x,right:o.right+e*c.x}),{...r})}}const Wg=Hg(1);function hu(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Ug(e,t,r){const n=hu(t);if(!n)return e;const{scaleX:s,scaleY:a,x:o,y:c}=n,l=e.left-o-(1-s)*parseFloat(r),u=e.top-c-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),f=s?e.width/s:e.width,d=a?e.height/a:e.height;return{width:f,height:d,top:u,right:l+f,bottom:u+d,left:l}}const Zg={ignoreTransform:!1};function Sn(e,t){t===void 0&&(t=Zg);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=Ue(e).getComputedStyle(e);u&&(r=Ug(r,u,f))}const{top:n,left:s,width:a,height:o,bottom:c,right:l}=r;return{top:n,left:s,width:a,height:o,bottom:c,right:l}}function ji(e){return Sn(e,{ignoreTransform:!0})}function Yg(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Gg(e,t){return t===void 0&&(t=Ue(e).getComputedStyle(e)),t.position==="fixed"}function qg(e,t){t===void 0&&(t=Ue(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const a=t[s];return typeof a=="string"?r.test(a):!1})}function yo(e,t){const r=[];function n(s){if(t!=null&&r.length>=t||!s)return r;if(go(s)&&s.scrollingElement!=null&&!r.includes(s.scrollingElement))return r.push(s.scrollingElement),r;if(!wn(s)||lu(s)||r.includes(s))return r;const a=Ue(e).getComputedStyle(s);return s!==e&&qg(s,a)&&r.push(s),Gg(s,a)?r:n(s.parentNode)}return e?n(e):r}function mu(e){const[t]=yo(e,1);return t??null}function Js(e){return!Ts||!e?null:Ur(e)?e:po(e)?go(e)||e===Zr(e).scrollingElement?window:wn(e)?e:null:null}function pu(e){return Ur(e)?e.scrollX:e.scrollLeft}function gu(e){return Ur(e)?e.scrollY:e.scrollTop}function xa(e){return{x:pu(e),y:gu(e)}}var Oe;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Oe||(Oe={}));function vu(e){return!Ts||!e?!1:e===document.scrollingElement}function yu(e){const t={x:0,y:0},r=vu(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},s=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,o=e.scrollTop>=n.y,c=e.scrollLeft>=n.x;return{isTop:s,isLeft:a,isBottom:o,isRight:c,maxScroll:n,minScroll:t}}const Xg={x:.2,y:.2};function Kg(e,t,r,n,s){let{top:a,left:o,right:c,bottom:l}=r;n===void 0&&(n=10),s===void 0&&(s=Xg);const{isTop:u,isBottom:f,isLeft:d,isRight:h}=yu(e),p={x:0,y:0},w={x:0,y:0},g={height:t.height*s.y,width:t.width*s.x};return!u&&a<=t.top+g.height?(p.y=Oe.Backward,w.y=n*Math.abs((t.top+g.height-a)/g.height)):!f&&l>=t.bottom-g.height&&(p.y=Oe.Forward,w.y=n*Math.abs((t.bottom-g.height-l)/g.height)),!h&&c>=t.right-g.width?(p.x=Oe.Forward,w.x=n*Math.abs((t.right-g.width-c)/g.width)):!d&&o<=t.left+g.width&&(p.x=Oe.Backward,w.x=n*Math.abs((t.left+g.width-o)/g.width)),{direction:p,speed:w}}function Jg(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,height:o}}const{top:t,left:r,right:n,bottom:s}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:s,width:e.clientWidth,height:e.clientHeight}}function xu(e){return e.reduce((t,r)=>Tr(t,xa(r)),bt)}function Qg(e){return e.reduce((t,r)=>t+pu(r),0)}function ev(e){return e.reduce((t,r)=>t+gu(r),0)}function bu(e,t){if(t===void 0&&(t=Sn),!e)return;const{top:r,left:n,bottom:s,right:a}=t(e);mu(e)&&(s<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const tv=[["x",["left","right"],Qg],["y",["top","bottom"],ev]];class xo{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=yo(r),s=xu(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,o,c]of tv)for(const l of o)Object.defineProperty(this,l,{get:()=>{const u=c(n),f=s[a]-u;return this.rect[l]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class sn{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var s;(s=this.target)==null||s.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function rv(e){const{EventTarget:t}=Ue(e);return e instanceof t?e:Zr(e)}function Qs(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var lt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(lt||(lt={}));function Ni(e){e.preventDefault()}function nv(e){e.stopPropagation()}var ve;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ve||(ve={}));const wu={start:[ve.Space,ve.Enter],cancel:[ve.Esc],end:[ve.Space,ve.Enter,ve.Tab]},sv=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case ve.Right:return{...r,x:r.x+25};case ve.Left:return{...r,x:r.x-25};case ve.Down:return{...r,y:r.y+25};case ve.Up:return{...r,y:r.y-25}}};class _u{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new sn(Zr(r)),this.windowListeners=new sn(Ue(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(lt.Resize,this.handleCancel),this.windowListeners.add(lt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(lt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&bu(n),r(bt)}handleKeyDown(t){if(vo(t)){const{active:r,context:n,options:s}=this.props,{keyboardCodes:a=wu,coordinateGetter:o=sv,scrollBehavior:c="smooth"}=s,{code:l}=t;if(a.end.includes(l)){this.handleEnd(t);return}if(a.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:u}=n.current,f=u?{x:u.left,y:u.top}:bt;this.referenceCoordinates||(this.referenceCoordinates=f);const d=o(t,{active:r,context:n.current,currentCoordinates:f});if(d){const h=is(d,f),p={x:0,y:0},{scrollableAncestors:w}=n.current;for(const g of w){const y=t.code,{isTop:v,isRight:b,isLeft:C,isBottom:x,maxScroll:_,minScroll:k}=yu(g),j=Jg(g),E={x:Math.min(y===ve.Right?j.right-j.width/2:j.right,Math.max(y===ve.Right?j.left:j.left+j.width/2,d.x)),y:Math.min(y===ve.Down?j.bottom-j.height/2:j.bottom,Math.max(y===ve.Down?j.top:j.top+j.height/2,d.y))},A=y===ve.Right&&!b||y===ve.Left&&!C,T=y===ve.Down&&!x||y===ve.Up&&!v;if(A&&E.x!==d.x){const M=g.scrollLeft+h.x,R=y===ve.Right&&M<=_.x||y===ve.Left&&M>=k.x;if(R&&!h.y){g.scrollTo({left:M,behavior:c});return}R?p.x=g.scrollLeft-M:p.x=y===ve.Right?g.scrollLeft-_.x:g.scrollLeft-k.x,p.x&&g.scrollBy({left:-p.x,behavior:c});break}else if(T&&E.y!==d.y){const M=g.scrollTop+h.y,R=y===ve.Down&&M<=_.y||y===ve.Up&&M>=k.y;if(R&&!h.x){g.scrollTo({top:M,behavior:c});return}R?p.y=g.scrollTop-M:p.y=y===ve.Down?g.scrollTop-_.y:g.scrollTop-k.y,p.y&&g.scrollBy({top:-p.y,behavior:c});break}}this.handleMove(t,Tr(is(d,this.referenceCoordinates),p))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}_u.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=wu,onActivation:s}=t,{active:a}=r;const{code:o}=e.nativeEvent;if(n.start.includes(o)){const c=a.activatorNode.current;return c&&e.target!==c?!1:(e.preventDefault(),s?.({event:e.nativeEvent}),!0)}return!1}}];function Ei(e){return!!(e&&"distance"in e)}function Ai(e){return!!(e&&"delay"in e)}class bo{constructor(t,r,n){var s;n===void 0&&(n=rv(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:a}=t,{target:o}=a;this.props=t,this.events=r,this.document=Zr(o),this.documentListeners=new sn(this.document),this.listeners=new sn(n),this.windowListeners=new sn(Ue(o)),this.initialCoordinates=(s=cs(a))!=null?s:bt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(lt.Resize,this.handleCancel),this.windowListeners.add(lt.DragStart,Ni),this.windowListeners.add(lt.VisibilityChange,this.handleCancel),this.windowListeners.add(lt.ContextMenu,Ni),this.documentListeners.add(lt.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ai(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Ei(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:n,onPending:s}=this.props;s(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(lt.Click,nv,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(lt.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:s,props:a}=this,{onMove:o,options:{activationConstraint:c}}=a;if(!s)return;const l=(r=cs(t))!=null?r:bt,u=is(s,l);if(!n&&c){if(Ei(c)){if(c.tolerance!=null&&Qs(u,c.tolerance))return this.handleCancel();if(Qs(u,c.distance))return this.handleStart()}if(Ai(c)&&Qs(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}t.cancelable&&t.preventDefault(),o(l)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===ve.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const av={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class wo extends bo{constructor(t){const{event:r}=t,n=Zr(r.target);super(t,av,n)}}wo.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const ov={move:{name:"mousemove"},end:{name:"mouseup"}};var ba;(function(e){e[e.RightClick=2]="RightClick"})(ba||(ba={}));class iv extends bo{constructor(t){super(t,ov,Zr(t.event.target))}}iv.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===ba.RightClick?!1:(n?.({event:r}),!0)}}];const ea={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class cv extends bo{constructor(t){super(t,ea)}static setup(){return window.addEventListener(ea.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ea.move.name,t)};function t(){}}}cv.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:s}=r;return s.length>1?!1:(n?.({event:r}),!0)}}];var an;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(an||(an={}));var us;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(us||(us={}));function lv(e){let{acceleration:t,activator:r=an.Pointer,canScroll:n,draggingRect:s,enabled:a,interval:o=5,order:c=us.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:h}=e;const p=dv({delta:d,disabled:!a}),[w,g]=_g(),y=m.useRef({x:0,y:0}),v=m.useRef({x:0,y:0}),b=m.useMemo(()=>{switch(r){case an.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case an.DraggableRect:return s}},[r,s,l]),C=m.useRef(null),x=m.useCallback(()=>{const k=C.current;if(!k)return;const j=y.current.x*v.current.x,E=y.current.y*v.current.y;k.scrollBy(j,E)},[]),_=m.useMemo(()=>c===us.TreeOrder?[...u].reverse():u,[c,u]);m.useEffect(()=>{if(!a||!u.length||!b){g();return}for(const k of _){if(n?.(k)===!1)continue;const j=u.indexOf(k),E=f[j];if(!E)continue;const{direction:A,speed:T}=Kg(k,E,b,t,h);for(const M of["x","y"])p[M][A[M]]||(T[M]=0,A[M]=0);if(T.x>0||T.y>0){g(),C.current=k,w(x,o),y.current=T,v.current=A;return}}y.current={x:0,y:0},v.current={x:0,y:0},g()},[t,x,n,g,a,o,JSON.stringify(b),JSON.stringify(p),w,u,_,f,JSON.stringify(h)])}const uv={x:{[Oe.Backward]:!1,[Oe.Forward]:!1},y:{[Oe.Backward]:!1,[Oe.Forward]:!1}};function dv(e){let{delta:t,disabled:r}=e;const n=os(t);return _n(s=>{if(r||!n||!s)return uv;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[Oe.Backward]:s.x[Oe.Backward]||a.x===-1,[Oe.Forward]:s.x[Oe.Forward]||a.x===1},y:{[Oe.Backward]:s.y[Oe.Backward]||a.y===-1,[Oe.Forward]:s.y[Oe.Forward]||a.y===1}}},[r,t,n])}function fv(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return _n(s=>{var a;return t==null?null:(a=n??s)!=null?a:null},[n,t])}function hv(e,t){return m.useMemo(()=>e.reduce((r,n)=>{const{sensor:s}=n,a=s.activators.map(o=>({eventName:o.eventName,handler:t(o.handler,n)}));return[...r,...a]},[]),[e,t])}var pn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(pn||(pn={}));var wa;(function(e){e.Optimized="optimized"})(wa||(wa={}));const Ri=new Map;function mv(e,t){let{dragging:r,dependencies:n,config:s}=t;const[a,o]=m.useState(null),{frequency:c,measure:l,strategy:u}=s,f=m.useRef(e),d=y(),h=hn(d),p=m.useCallback(function(v){v===void 0&&(v=[]),!h.current&&o(b=>b===null?v:b.concat(v.filter(C=>!b.includes(C))))},[h]),w=m.useRef(null),g=_n(v=>{if(d&&!r)return Ri;if(!v||v===Ri||f.current!==e||a!=null){const b=new Map;for(let C of e){if(!C)continue;if(a&&a.length>0&&!a.includes(C.id)&&C.rect.current){b.set(C.id,C.rect.current);continue}const x=C.node.current,_=x?new xo(l(x),x):null;C.rect.current=_,_&&b.set(C.id,_)}return b}return v},[e,a,r,d,l]);return m.useEffect(()=>{f.current=e},[e]),m.useEffect(()=>{d||p()},[r,d]),m.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),m.useEffect(()=>{d||typeof c!="number"||w.current!==null||(w.current=setTimeout(()=>{p(),w.current=null},c))},[c,d,p,...n]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:a!=null};function y(){switch(u){case pn.Always:return!1;case pn.BeforeDragging:return r;default:return!r}}}function _o(e,t){return _n(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function pv(e,t){return _o(e,t)}function gv(e){let{callback:t,disabled:r}=e;const n=Ps(t),s=m.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return m.useEffect(()=>()=>s?.disconnect(),[s]),s}function Ms(e){let{callback:t,disabled:r}=e;const n=Ps(t),s=m.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return m.useEffect(()=>()=>s?.disconnect(),[s]),s}function vv(e){return new xo(Sn(e),e)}function Ti(e,t,r){t===void 0&&(t=vv);const[n,s]=m.useState(null);function a(){s(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??r)!=null?u:null}const f=t(e);return JSON.stringify(l)===JSON.stringify(f)?l:f})}const o=gv({callback(l){if(e)for(const u of l){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){a();break}}}}),c=Ms({callback:a});return Ut(()=>{a(),e?(c?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(c?.disconnect(),o?.disconnect())},[e]),n}function yv(e){const t=_o(e);return fu(e,t)}const Pi=[];function xv(e){const t=m.useRef(e),r=_n(n=>e?n&&n!==Pi&&e&&t.current&&e.parentNode===t.current.parentNode?n:yo(e):Pi,[e]);return m.useEffect(()=>{t.current=e},[e]),r}function bv(e){const[t,r]=m.useState(null),n=m.useRef(e),s=m.useCallback(a=>{const o=Js(a.target);o&&r(c=>c?(c.set(o,xa(o)),new Map(c)):null)},[]);return m.useEffect(()=>{const a=n.current;if(e!==a){o(a);const c=e.map(l=>{const u=Js(l);return u?(u.addEventListener("scroll",s,{passive:!0}),[u,xa(u)]):null}).filter(l=>l!=null);r(c.length?new Map(c):null),n.current=e}return()=>{o(e),o(a)};function o(c){c.forEach(l=>{const u=Js(l);u?.removeEventListener("scroll",s)})}},[s,e]),m.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,o)=>Tr(a,o),bt):xu(e):bt,[e,t])}function Oi(e,t){t===void 0&&(t=[]);const r=m.useRef(null);return m.useEffect(()=>{r.current=null},t),m.useEffect(()=>{const n=e!==bt;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?is(e,r.current):bt}function wv(e){m.useEffect(()=>{if(!Ts)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function _v(e,t){return m.useMemo(()=>e.reduce((r,n)=>{let{eventName:s,handler:a}=n;return r[s]=o=>{a(o,t)},r},{}),[e,t])}function Su(e){return m.useMemo(()=>e?Yg(e):null,[e])}const Mi=[];function Sv(e,t){t===void 0&&(t=Sn);const[r]=e,n=Su(r?Ue(r):null),[s,a]=m.useState(Mi);function o(){a(()=>e.length?e.map(l=>vu(l)?n:new xo(t(l),l)):Mi)}const c=Ms({callback:o});return Ut(()=>{c?.disconnect(),o(),e.forEach(l=>c?.observe(l))},[e]),s}function Cu(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return wn(t)?t:e}function Cv(e){let{measure:t}=e;const[r,n]=m.useState(null),s=m.useCallback(u=>{for(const{target:f}of u)if(wn(f)){n(d=>{const h=t(f);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),a=Ms({callback:s}),o=m.useCallback(u=>{const f=Cu(u);a?.disconnect(),f&&a?.observe(f),n(f?t(f):null)},[t,a]),[c,l]=as(o);return m.useMemo(()=>({nodeRef:c,rect:r,setRef:l}),[r,c,l])}const kv=[{sensor:wo,options:{}},{sensor:_u,options:{}}],Dv={current:{}},Bn={draggable:{measure:ji},droppable:{measure:ji,strategy:pn.WhileDragging,frequency:wa.Optimized},dragOverlay:{measure:Sn}};class on extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const jv={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new on,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ls},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bn,measureDroppableContainers:ls,windowRect:null,measuringScheduled:!1},ku={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ls,draggableNodes:new Map,over:null,measureDroppableContainers:ls},Cn=m.createContext(ku),Du=m.createContext(jv);function Nv(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new on}}}function Ev(e,t){switch(t.type){case Pe.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Pe.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Pe.DragEnd:case Pe.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Pe.RegisterDroppable:{const{element:r}=t,{id:n}=r,s=new on(e.droppable.containers);return s.set(n,r),{...e,droppable:{...e.droppable,containers:s}}}case Pe.SetDroppableDisabled:{const{id:r,key:n,disabled:s}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const o=new on(e.droppable.containers);return o.set(r,{...a,disabled:s}),{...e,droppable:{...e.droppable,containers:o}}}case Pe.UnregisterDroppable:{const{id:r,key:n}=t,s=e.droppable.containers.get(r);if(!s||n!==s.key)return e;const a=new on(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Av(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:s}=m.useContext(Cn),a=os(n),o=os(r?.id);return m.useEffect(()=>{if(!t&&!n&&a&&o!=null){if(!vo(a)||document.activeElement===a.target)return;const c=s.get(o);if(!c)return;const{activatorNode:l,node:u}=c;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[l.current,u.current]){if(!f)continue;const d=kg(f);if(d){d.focus();break}}})}},[n,t,s,o,a]),null}function ju(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((s,a)=>a({transform:s,...n}),r):r}function Rv(e){return m.useMemo(()=>({draggable:{...Bn.draggable,...e?.draggable},droppable:{...Bn.droppable,...e?.droppable},dragOverlay:{...Bn.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Tv(e){let{activeNode:t,measure:r,initialRect:n,config:s=!0}=e;const a=m.useRef(!1),{x:o,y:c}=typeof s=="boolean"?{x:s,y:s}:s;Ut(()=>{if(!o&&!c||!t){a.current=!1;return}if(a.current||!n)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=r(u),d=fu(f,n);if(o||(d.x=0),c||(d.y=0),a.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=mu(u);h&&h.scrollBy({top:d.y,left:d.x})}},[t,o,c,n,r])}const Is=m.createContext({...bt,scaleX:1,scaleY:1});var Jt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Jt||(Jt={}));const Pv=m.memo(function(t){var r,n,s,a;let{id:o,accessibility:c,autoScroll:l=!0,children:u,sensors:f=kv,collisionDetection:d=zg,measuring:h,modifiers:p,...w}=t;const g=m.useReducer(Ev,void 0,Nv),[y,v]=g,[b,C]=Rg(),[x,_]=m.useState(Jt.Uninitialized),k=x===Jt.Initialized,{draggable:{active:j,nodes:E,translate:A},droppable:{containers:T}}=y,M=j!=null?E.get(j):null,R=m.useRef({initial:null,translated:null}),V=m.useMemo(()=>{var Fe;return j!=null?{id:j,data:(Fe=M?.data)!=null?Fe:Dv,rect:R}:null},[j,M]),F=m.useRef(null),[G,$]=m.useState(null),[L,P]=m.useState(null),H=hn(w,Object.values(w)),z=Os("DndDescribedBy",o),re=m.useMemo(()=>T.getEnabled(),[T]),q=Rv(h),{droppableRects:I,measureDroppableContainers:B,measuringScheduled:se}=mv(re,{dragging:k,dependencies:[A.x,A.y],config:q.droppable}),ne=fv(E,j),fe=m.useMemo(()=>L?cs(L):null,[L]),pe=Zu(),Ae=pv(ne,q.draggable.measure);Tv({activeNode:j!=null?E.get(j):null,config:pe.layoutShiftCompensation,initialRect:Ae,measure:q.draggable.measure});const xe=Ti(ne,q.draggable.measure,Ae),Ze=Ti(ne?ne.parentElement:null),Ye=m.useRef({activatorEvent:null,active:null,activeNode:ne,collisionRect:null,collisions:null,droppableRects:I,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Xe=T.getNodeFor((r=Ye.current.over)==null?void 0:r.id),Ke=Cv({measure:q.dragOverlay.measure}),_t=(n=Ke.nodeRef.current)!=null?n:ne,ft=k?(s=Ke.rect)!=null?s:xe:null,Zt=!!(Ke.nodeRef.current&&Ke.rect),kn=yv(Zt?null:xe),Dn=Su(_t?Ue(_t):null),ht=xv(k?Xe??ne:null),D=Sv(ht),N=ju(p,{transform:{x:A.x-kn.x,y:A.y-kn.y,scaleX:1,scaleY:1},activatorEvent:L,active:V,activeNodeRect:xe,containerNodeRect:Ze,draggingNodeRect:ft,over:Ye.current.over,overlayNodeRect:Ke.rect,scrollableAncestors:ht,scrollableAncestorRects:D,windowRect:Dn}),O=fe?Tr(fe,A):null,X=bv(ht),Z=Oi(X),U=Oi(X,[xe]),ee=Tr(N,Z),le=ft?Wg(ft,N):null,he=V&&le?d({active:V,collisionRect:le,droppableRects:I,droppableContainers:re,pointerCoordinates:O}):null,Ve=$g(he,"id"),[Je,mt]=m.useState(null),Fs=Zt?N:Tr(N,U),Yr=Bg(Fs,(a=Je?.rect)!=null?a:null,xe),cr=m.useRef(null),jn=m.useCallback((Fe,Qe)=>{let{sensor:et,options:Yt}=Qe;if(F.current==null)return;const ct=E.get(F.current);if(!ct)return;const tt=Fe.nativeEvent,St=new et({active:F.current,activeNode:ct,event:tt,options:Yt,context:Ye,onAbort(Me){if(!E.get(Me))return;const{onDragAbort:Ct}=H.current,Ft={id:Me};Ct?.(Ft),b({type:"onDragAbort",event:Ft})},onPending(Me,Gt,Ct,Ft){if(!E.get(Me))return;const{onDragPending:qr}=H.current,qt={id:Me,constraint:Gt,initialCoordinates:Ct,offset:Ft};qr?.(qt),b({type:"onDragPending",event:qt})},onStart(Me){const Gt=F.current;if(Gt==null)return;const Ct=E.get(Gt);if(!Ct)return;const{onDragStart:Ft}=H.current,Gr={activatorEvent:tt,active:{id:Gt,data:Ct.data,rect:R}};dr.unstable_batchedUpdates(()=>{Ft?.(Gr),_(Jt.Initializing),v({type:Pe.DragStart,initialCoordinates:Me,active:Gt}),b({type:"onDragStart",event:Gr}),$(cr.current),P(tt)})},onMove(Me){v({type:Pe.DragMove,coordinates:Me})},onEnd:wr(Pe.DragEnd),onCancel:wr(Pe.DragCancel)});cr.current=St;function wr(Me){return async function(){const{active:Ct,collisions:Ft,over:Gr,scrollAdjustedTranslate:qr}=Ye.current;let qt=null;if(Ct&&qr){const{cancelDrop:Xr}=H.current;qt={activatorEvent:tt,active:Ct,collisions:Ft,delta:qr,over:Gr},Me===Pe.DragEnd&&typeof Xr=="function"&&await Promise.resolve(Xr(qt))&&(Me=Pe.DragCancel)}F.current=null,dr.unstable_batchedUpdates(()=>{v({type:Me}),_(Jt.Uninitialized),mt(null),$(null),P(null),cr.current=null;const Xr=Me===Pe.DragEnd?"onDragEnd":"onDragCancel";if(qt){const Ls=H.current[Xr];Ls?.(qt),b({type:Xr,event:qt})}})}}},[E]),Nn=m.useCallback((Fe,Qe)=>(et,Yt)=>{const ct=et.nativeEvent,tt=E.get(Yt);if(F.current!==null||!tt||ct.dndKit||ct.defaultPrevented)return;const St={active:tt};Fe(et,Qe.options,St)===!0&&(ct.dndKit={capturedBy:Qe.sensor},F.current=Yt,jn(et,Qe))},[E,jn]),En=hv(f,Nn);wv(f),Ut(()=>{xe&&x===Jt.Initializing&&_(Jt.Initialized)},[xe,x]),m.useEffect(()=>{const{onDragMove:Fe}=H.current,{active:Qe,activatorEvent:et,collisions:Yt,over:ct}=Ye.current;if(!Qe||!et)return;const tt={active:Qe,activatorEvent:et,collisions:Yt,delta:{x:ee.x,y:ee.y},over:ct};dr.unstable_batchedUpdates(()=>{Fe?.(tt),b({type:"onDragMove",event:tt})})},[ee.x,ee.y]),m.useEffect(()=>{const{active:Fe,activatorEvent:Qe,collisions:et,droppableContainers:Yt,scrollAdjustedTranslate:ct}=Ye.current;if(!Fe||F.current==null||!Qe||!ct)return;const{onDragOver:tt}=H.current,St=Yt.get(Ve),wr=St&&St.rect.current?{id:St.id,rect:St.rect.current,data:St.data,disabled:St.disabled}:null,Me={active:Fe,activatorEvent:Qe,collisions:et,delta:{x:ct.x,y:ct.y},over:wr};dr.unstable_batchedUpdates(()=>{mt(wr),tt?.(Me),b({type:"onDragOver",event:Me})})},[Ve]),Ut(()=>{Ye.current={activatorEvent:L,active:V,activeNode:ne,collisionRect:le,collisions:he,droppableRects:I,draggableNodes:E,draggingNode:_t,draggingNodeRect:ft,droppableContainers:T,over:Je,scrollableAncestors:ht,scrollAdjustedTranslate:ee},R.current={initial:ft,translated:le}},[V,ne,he,le,E,_t,ft,I,T,Je,ht,ee]),lv({...pe,delta:A,draggingRect:le,pointerCoordinates:O,scrollableAncestors:ht,scrollableAncestorRects:D});const An=m.useMemo(()=>({active:V,activeNode:ne,activeNodeRect:xe,activatorEvent:L,collisions:he,containerNodeRect:Ze,dragOverlay:Ke,draggableNodes:E,droppableContainers:T,droppableRects:I,over:Je,measureDroppableContainers:B,scrollableAncestors:ht,scrollableAncestorRects:D,measuringConfiguration:q,measuringScheduled:se,windowRect:Dn}),[V,ne,xe,L,he,Ze,Ke,E,T,I,Je,B,ht,D,q,se,Dn]),Uu=m.useMemo(()=>({activatorEvent:L,activators:En,active:V,activeNodeRect:xe,ariaDescribedById:{draggable:z},dispatch:v,draggableNodes:E,over:Je,measureDroppableContainers:B}),[L,En,V,xe,v,z,E,Je,B]);return m.createElement(du.Provider,{value:C},m.createElement(Cn.Provider,{value:Uu},m.createElement(Du.Provider,{value:An},m.createElement(Is.Provider,{value:Yr},u)),m.createElement(Av,{disabled:c?.restoreFocus===!1})),m.createElement(Og,{...c,hiddenTextDescribedById:z}));function Zu(){const Fe=G?.autoScrollEnabled===!1,Qe=typeof l=="object"?l.enabled===!1:l===!1,et=k&&!Fe&&!Qe;return typeof l=="object"?{...l,enabled:et}:{enabled:et}}}),Ov=m.createContext(null),Ii="button",Mv="Draggable";function Iv(e){let{id:t,data:r,disabled:n=!1,attributes:s}=e;const a=Os(Mv),{activators:o,activatorEvent:c,active:l,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:h}=m.useContext(Cn),{role:p=Ii,roleDescription:w="draggable",tabIndex:g=0}=s??{},y=l?.id===t,v=m.useContext(y?Is:Ov),[b,C]=as(),[x,_]=as(),k=_v(o,t),j=hn(r);Ut(()=>(d.set(t,{id:t,key:a,node:b,activatorNode:x,data:j}),()=>{const A=d.get(t);A&&A.key===a&&d.delete(t)}),[d,t]);const E=m.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":n,"aria-pressed":y&&p===Ii?!0:void 0,"aria-roledescription":w,"aria-describedby":f.draggable}),[n,p,g,y,w,f.draggable]);return{active:l,activatorEvent:c,activeNodeRect:u,attributes:E,isDragging:y,listeners:n?void 0:k,node:b,over:h,setNodeRef:C,setActivatorNodeRef:_,transform:v}}function Fv(){return m.useContext(Du)}const Lv="Droppable",$v={timeout:25};function Vv(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:s}=e;const a=Os(Lv),{active:o,dispatch:c,over:l,measureDroppableContainers:u}=m.useContext(Cn),f=m.useRef({disabled:r}),d=m.useRef(!1),h=m.useRef(null),p=m.useRef(null),{disabled:w,updateMeasurementsFor:g,timeout:y}={...$v,...s},v=hn(g??n),b=m.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},y)},[y]),C=Ms({callback:b,disabled:w||!o}),x=m.useCallback((E,A)=>{C&&(A&&(C.unobserve(A),d.current=!1),E&&C.observe(E))},[C]),[_,k]=as(x),j=hn(t);return m.useEffect(()=>{!C||!_.current||(C.disconnect(),d.current=!1,C.observe(_.current))},[_,C]),m.useEffect(()=>(c({type:Pe.RegisterDroppable,element:{id:n,key:a,disabled:r,node:_,rect:h,data:j}}),()=>c({type:Pe.UnregisterDroppable,key:a,id:n})),[n]),m.useEffect(()=>{r!==f.current.disabled&&(c({type:Pe.SetDroppableDisabled,id:n,key:a,disabled:r}),f.current.disabled=r)},[n,a,r,c]),{active:o,rect:h,isOver:l?.id===n,node:_,over:l,setNodeRef:k}}function zv(e){let{animation:t,children:r}=e;const[n,s]=m.useState(null),[a,o]=m.useState(null),c=os(r);return!r&&!n&&c&&s(c),Ut(()=>{if(!a)return;const l=n?.key,u=n?.props.id;if(l==null||u==null){s(null);return}Promise.resolve(t(u,a)).then(()=>{s(null)})},[t,n,a]),m.createElement(m.Fragment,null,r,n?m.cloneElement(n,{ref:o}):null)}const Bv={x:0,y:0,scaleX:1,scaleY:1};function Hv(e){let{children:t}=e;return m.createElement(Cn.Provider,{value:ku},m.createElement(Is.Provider,{value:Bv},t))}const Wv={position:"fixed",touchAction:"none"},Uv=e=>vo(e)?"transform 250ms ease":void 0,Zv=m.forwardRef((e,t)=>{let{as:r,activatorEvent:n,adjustScale:s,children:a,className:o,rect:c,style:l,transform:u,transition:f=Uv}=e;if(!c)return null;const d=s?u:{...u,scaleX:1,scaleY:1},h={...Wv,width:c.width,height:c.height,top:c.top,left:c.left,transform:mn.Transform.toString(d),transformOrigin:s&&n?Fg(n,c):void 0,transition:typeof f=="function"?f(n):f,...l};return m.createElement(r,{className:o,style:h,ref:t},a)}),Yv=e=>t=>{let{active:r,dragOverlay:n}=t;const s={},{styles:a,className:o}=e;if(a!=null&&a.active)for(const[c,l]of Object.entries(a.active))l!==void 0&&(s[c]=r.node.style.getPropertyValue(c),r.node.style.setProperty(c,l));if(a!=null&&a.dragOverlay)for(const[c,l]of Object.entries(a.dragOverlay))l!==void 0&&n.node.style.setProperty(c,l);return o!=null&&o.active&&r.node.classList.add(o.active),o!=null&&o.dragOverlay&&n.node.classList.add(o.dragOverlay),function(){for(const[l,u]of Object.entries(s))r.node.style.setProperty(l,u);o!=null&&o.active&&r.node.classList.remove(o.active)}},Gv=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:mn.Transform.toString(t)},{transform:mn.Transform.toString(r)}]},qv={duration:250,easing:"ease",keyframes:Gv,sideEffects:Yv({styles:{active:{opacity:"0"}}})};function Xv(e){let{config:t,draggableNodes:r,droppableContainers:n,measuringConfiguration:s}=e;return Ps((a,o)=>{if(t===null)return;const c=r.get(a);if(!c)return;const l=c.node.current;if(!l)return;const u=Cu(o);if(!u)return;const{transform:f}=Ue(o).getComputedStyle(o),d=hu(f);if(!d)return;const h=typeof t=="function"?t:Kv(t);return bu(l,s.draggable.measure),h({active:{id:a,data:c.data,node:l,rect:s.draggable.measure(l)},draggableNodes:r,dragOverlay:{node:o,rect:s.dragOverlay.measure(u)},droppableContainers:n,measuringConfiguration:s,transform:d})})}function Kv(e){const{duration:t,easing:r,sideEffects:n,keyframes:s}={...qv,...e};return a=>{let{active:o,dragOverlay:c,transform:l,...u}=a;if(!t)return;const f={x:c.rect.left-o.rect.left,y:c.rect.top-o.rect.top},d={scaleX:l.scaleX!==1?o.rect.width*l.scaleX/c.rect.width:1,scaleY:l.scaleY!==1?o.rect.height*l.scaleY/c.rect.height:1},h={x:l.x-f.x,y:l.y-f.y,...d},p=s({...u,active:o,dragOverlay:c,transform:{initial:l,final:h}}),[w]=p,g=p[p.length-1];if(JSON.stringify(w)===JSON.stringify(g))return;const y=n?.({active:o,dragOverlay:c,...u}),v=c.node.animate(p,{duration:t,easing:r,fill:"forwards"});return new Promise(b=>{v.onfinish=()=>{y?.(),b()}})}}let Fi=0;function Jv(e){return m.useMemo(()=>{if(e!=null)return Fi++,Fi},[e])}const Qv=m.memo(e=>{let{adjustScale:t=!1,children:r,dropAnimation:n,style:s,transition:a,modifiers:o,wrapperElement:c="div",className:l,zIndex:u=999}=e;const{activatorEvent:f,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:w,droppableContainers:g,dragOverlay:y,over:v,measuringConfiguration:b,scrollableAncestors:C,scrollableAncestorRects:x,windowRect:_}=Fv(),k=m.useContext(Is),j=Jv(d?.id),E=ju(o,{activatorEvent:f,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:y.rect,over:v,overlayNodeRect:y.rect,scrollableAncestors:C,scrollableAncestorRects:x,transform:k,windowRect:_}),A=_o(h),T=Xv({config:n,draggableNodes:w,droppableContainers:g,measuringConfiguration:b}),M=A?y.setRef:void 0;return m.createElement(Hv,null,m.createElement(zv,{animation:T},d&&j?m.createElement(Zv,{key:j,id:d.id,ref:M,as:c,activatorEvent:f,adjustScale:t,className:l,transition:a,rect:A,style:{zIndex:u,...s},transform:E},r):null))}),Nu=e=>{if(e.extendedProps?.location){const t=e.extendedProps.location;if(typeof t=="string")return t;if(typeof t=="object"&&t!==null){const r=t,n=typeof r.building=="string"?r.building:"",s=typeof r.room=="string"?r.room:"";return`${n} ${s}`.trim()}}return e.description||""},ey=e=>!!e.extendedProps?.isAllDay,Eu=(e,t,r)=>{if(!e||e==="[]"||e==="")return t;try{const n=typeof e=="string"?JSON.parse(e):e;if(Array.isArray(n)){const a=n.filter(o=>!(typeof o!="object"||o===null||r&&"personnelId"in o&&o.personnelId===r)).map(o=>{const c=o.name;return typeof c=="string"?c:null}).filter(o=>!!o);return a.length>0?a.join(", "):""}}catch{}return typeof e=="string"?e:""},Au=({event:e,position:t,column:r=0,totalColumns:n=1,onEventClick:s,currentUserId:a,resources:o=[],renderEventContent:c,components:l,viewMode:u="week"})=>{const{attributes:f,listeners:d,setNodeRef:h,isDragging:p}=Iv({id:e.id,data:e,disabled:!1}),w=k=>{k.stopPropagation(),s?.(e)},g=e.title,y=Eu(e.attendee,"",a),b=o.find(k=>k.id===e.resourceId)?.name||Nu(e),C=t.height>=60,x=100/n,_=r*x;return i.jsx("button",{ref:h,...d,...f,onClick:w,type:"button",onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.stopPropagation(),s?.(e))},className:`
|
|
60
|
+
`},$g={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Fg(e){let{announcements:t=$g,container:r,hiddenTextDescribedById:n,screenReaderInstructions:s=Ig}=e;const{announce:a,announcement:i}=Pg(),c=Is("DndLiveRegion"),[l,u]=m.useState(!1);if(m.useEffect(()=>{u(!0)},[]),Mg(m.useMemo(()=>({onDragStart(d){let{active:h}=d;a(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;t.onDragMove&&a(t.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;a(t.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;a(t.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;a(t.onDragCancel({active:h,over:p}))}}),[a,t])),!l)return null;const f=m.createElement(m.Fragment,null,m.createElement(Tg,{id:n,value:s.draggable}),m.createElement(Rg,{id:c,announcement:i}));return r?mr.createPortal(f,r):f}var Pe;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Pe||(Pe={}));function us(){}function Lg(e,t){return m.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Vg(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return m.useMemo(()=>[...t].filter(n=>n!=null),[...t])}const _t=Object.freeze({x:0,y:0});function zg(e,t){const r=ls(e);if(!r)return"0 0";const n={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return n.x+"% "+n.y+"%"}function Hg(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function Bg(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Wg(e,t){const r=Math.max(t.top,e.top),n=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),i=s-n,c=a-r;if(n<s&&r<a){const l=t.width*t.height,u=e.width*e.height,f=i*c,d=f/(l+u-f);return Number(d.toFixed(4))}return 0}const Ug=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const s=[];for(const a of n){const{id:i}=a,c=r.get(i);if(c){const l=Wg(c,t);l>0&&s.push({id:i,data:{droppableContainer:a,value:l}})}}return s.sort(Hg)};function Zg(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function bu(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:_t}function Yg(e){return function(r){for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];return s.reduce((i,c)=>({...i,top:i.top+e*c.y,bottom:i.bottom+e*c.y,left:i.left+e*c.x,right:i.right+e*c.x}),{...r})}}const Gg=Yg(1);function wu(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function qg(e,t,r){const n=wu(t);if(!n)return e;const{scaleX:s,scaleY:a,x:i,y:c}=n,l=e.left-i-(1-s)*parseFloat(r),u=e.top-c-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),f=s?e.width/s:e.width,d=a?e.height/a:e.height;return{width:f,height:d,top:u,right:l+f,bottom:u+d,left:l}}const Xg={ignoreTransform:!1};function kn(e,t){t===void 0&&(t=Xg);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=Ue(e).getComputedStyle(e);u&&(r=qg(r,u,f))}const{top:n,left:s,width:a,height:i,bottom:c,right:l}=r;return{top:n,left:s,width:a,height:i,bottom:c,right:l}}function Ii(e){return kn(e,{ignoreTransform:!0})}function Kg(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Jg(e,t){return t===void 0&&(t=Ue(e).getComputedStyle(e)),t.position==="fixed"}function Qg(e,t){t===void 0&&(t=Ue(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const a=t[s];return typeof a=="string"?r.test(a):!1})}function _o(e,t){const r=[];function n(s){if(t!=null&&r.length>=t||!s)return r;if(bo(s)&&s.scrollingElement!=null&&!r.includes(s.scrollingElement))return r.push(s.scrollingElement),r;if(!_n(s)||vu(s)||r.includes(s))return r;const a=Ue(e).getComputedStyle(s);return s!==e&&Qg(s,a)&&r.push(s),Jg(s,a)?r:n(s.parentNode)}return e?n(e):r}function _u(e){const[t]=_o(e,1);return t??null}function ea(e){return!Ms||!e?null:Gr(e)?e:xo(e)?bo(e)||e===qr(e).scrollingElement?window:_n(e)?e:null:null}function Su(e){return Gr(e)?e.scrollX:e.scrollLeft}function ku(e){return Gr(e)?e.scrollY:e.scrollTop}function Sa(e){return{x:Su(e),y:ku(e)}}var Me;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Me||(Me={}));function Cu(e){return!Ms||!e?!1:e===document.scrollingElement}function ju(e){const t={x:0,y:0},r=Cu(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},s=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,i=e.scrollTop>=n.y,c=e.scrollLeft>=n.x;return{isTop:s,isLeft:a,isBottom:i,isRight:c,maxScroll:n,minScroll:t}}const ev={x:.2,y:.2};function tv(e,t,r,n,s){let{top:a,left:i,right:c,bottom:l}=r;n===void 0&&(n=10),s===void 0&&(s=ev);const{isTop:u,isBottom:f,isLeft:d,isRight:h}=ju(e),p={x:0,y:0},w={x:0,y:0},g={height:t.height*s.y,width:t.width*s.x};return!u&&a<=t.top+g.height?(p.y=Me.Backward,w.y=n*Math.abs((t.top+g.height-a)/g.height)):!f&&l>=t.bottom-g.height&&(p.y=Me.Forward,w.y=n*Math.abs((t.bottom-g.height-l)/g.height)),!h&&c>=t.right-g.width?(p.x=Me.Forward,w.x=n*Math.abs((t.right-g.width-c)/g.width)):!d&&i<=t.left+g.width&&(p.x=Me.Backward,w.x=n*Math.abs((t.left+g.width-i)/g.width)),{direction:p,speed:w}}function rv(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:i}=window;return{top:0,left:0,right:a,bottom:i,width:a,height:i}}const{top:t,left:r,right:n,bottom:s}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:s,width:e.clientWidth,height:e.clientHeight}}function Du(e){return e.reduce((t,r)=>Ir(t,Sa(r)),_t)}function nv(e){return e.reduce((t,r)=>t+Su(r),0)}function sv(e){return e.reduce((t,r)=>t+ku(r),0)}function Nu(e,t){if(t===void 0&&(t=kn),!e)return;const{top:r,left:n,bottom:s,right:a}=t(e);_u(e)&&(s<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const av=[["x",["left","right"],nv],["y",["top","bottom"],sv]];class So{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=_o(r),s=Du(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,i,c]of av)for(const l of i)Object.defineProperty(this,l,{get:()=>{const u=c(n),f=s[a]-u;return this.rect[l]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class on{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var s;(s=this.target)==null||s.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function ov(e){const{EventTarget:t}=Ue(e);return e instanceof t?e:qr(e)}function ta(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var ut;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ut||(ut={}));function $i(e){e.preventDefault()}function iv(e){e.stopPropagation()}var ve;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ve||(ve={}));const Eu={start:[ve.Space,ve.Enter],cancel:[ve.Esc],end:[ve.Space,ve.Enter,ve.Tab]},cv=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case ve.Right:return{...r,x:r.x+25};case ve.Left:return{...r,x:r.x-25};case ve.Down:return{...r,y:r.y+25};case ve.Up:return{...r,y:r.y-25}}};class Au{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new on(qr(r)),this.windowListeners=new on(Ue(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ut.Resize,this.handleCancel),this.windowListeners.add(ut.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ut.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&Nu(n),r(_t)}handleKeyDown(t){if(wo(t)){const{active:r,context:n,options:s}=this.props,{keyboardCodes:a=Eu,coordinateGetter:i=cv,scrollBehavior:c="smooth"}=s,{code:l}=t;if(a.end.includes(l)){this.handleEnd(t);return}if(a.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:u}=n.current,f=u?{x:u.left,y:u.top}:_t;this.referenceCoordinates||(this.referenceCoordinates=f);const d=i(t,{active:r,context:n.current,currentCoordinates:f});if(d){const h=cs(d,f),p={x:0,y:0},{scrollableAncestors:w}=n.current;for(const g of w){const y=t.code,{isTop:x,isRight:v,isLeft:_,isBottom:b,maxScroll:S,minScroll:C}=ju(g),j=rv(g),N={x:Math.min(y===ve.Right?j.right-j.width/2:j.right,Math.max(y===ve.Right?j.left:j.left+j.width/2,d.x)),y:Math.min(y===ve.Down?j.bottom-j.height/2:j.bottom,Math.max(y===ve.Down?j.top:j.top+j.height/2,d.y))},E=y===ve.Right&&!v||y===ve.Left&&!_,R=y===ve.Down&&!b||y===ve.Up&&!x;if(E&&N.x!==d.x){const M=g.scrollLeft+h.x,A=y===ve.Right&&M<=S.x||y===ve.Left&&M>=C.x;if(A&&!h.y){g.scrollTo({left:M,behavior:c});return}A?p.x=g.scrollLeft-M:p.x=y===ve.Right?g.scrollLeft-S.x:g.scrollLeft-C.x,p.x&&g.scrollBy({left:-p.x,behavior:c});break}else if(R&&N.y!==d.y){const M=g.scrollTop+h.y,A=y===ve.Down&&M<=S.y||y===ve.Up&&M>=C.y;if(A&&!h.x){g.scrollTo({top:M,behavior:c});return}A?p.y=g.scrollTop-M:p.y=y===ve.Down?g.scrollTop-S.y:g.scrollTop-C.y,p.y&&g.scrollBy({top:-p.y,behavior:c});break}}this.handleMove(t,Ir(cs(d,this.referenceCoordinates),p))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Au.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=Eu,onActivation:s}=t,{active:a}=r;const{code:i}=e.nativeEvent;if(n.start.includes(i)){const c=a.activatorNode.current;return c&&e.target!==c?!1:(e.preventDefault(),s?.({event:e.nativeEvent}),!0)}return!1}}];function Fi(e){return!!(e&&"distance"in e)}function Li(e){return!!(e&&"delay"in e)}class ko{constructor(t,r,n){var s;n===void 0&&(n=ov(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:a}=t,{target:i}=a;this.props=t,this.events=r,this.document=qr(i),this.documentListeners=new on(this.document),this.listeners=new on(n),this.windowListeners=new on(Ue(i)),this.initialCoordinates=(s=ls(a))!=null?s:_t,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(ut.Resize,this.handleCancel),this.windowListeners.add(ut.DragStart,$i),this.windowListeners.add(ut.VisibilityChange,this.handleCancel),this.windowListeners.add(ut.ContextMenu,$i),this.documentListeners.add(ut.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Li(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Fi(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:n,onPending:s}=this.props;s(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(ut.Click,iv,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ut.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:s,props:a}=this,{onMove:i,options:{activationConstraint:c}}=a;if(!s)return;const l=(r=ls(t))!=null?r:_t,u=cs(s,l);if(!n&&c){if(Fi(c)){if(c.tolerance!=null&&ta(u,c.tolerance))return this.handleCancel();if(ta(u,c.distance))return this.handleStart()}if(Li(c)&&ta(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}t.cancelable&&t.preventDefault(),i(l)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===ve.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const lv={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Co extends ko{constructor(t){const{event:r}=t,n=qr(r.target);super(t,lv,n)}}Co.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const uv={move:{name:"mousemove"},end:{name:"mouseup"}};var ka;(function(e){e[e.RightClick=2]="RightClick"})(ka||(ka={}));class dv extends ko{constructor(t){super(t,uv,qr(t.event.target))}}dv.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===ka.RightClick?!1:(n?.({event:r}),!0)}}];const ra={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fv extends ko{constructor(t){super(t,ra)}static setup(){return window.addEventListener(ra.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ra.move.name,t)};function t(){}}}fv.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:s}=r;return s.length>1?!1:(n?.({event:r}),!0)}}];var cn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(cn||(cn={}));var ds;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ds||(ds={}));function hv(e){let{acceleration:t,activator:r=cn.Pointer,canScroll:n,draggingRect:s,enabled:a,interval:i=5,order:c=ds.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:h}=e;const p=pv({delta:d,disabled:!a}),[w,g]=jg(),y=m.useRef({x:0,y:0}),x=m.useRef({x:0,y:0}),v=m.useMemo(()=>{switch(r){case cn.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case cn.DraggableRect:return s}},[r,s,l]),_=m.useRef(null),b=m.useCallback(()=>{const C=_.current;if(!C)return;const j=y.current.x*x.current.x,N=y.current.y*x.current.y;C.scrollBy(j,N)},[]),S=m.useMemo(()=>c===ds.TreeOrder?[...u].reverse():u,[c,u]);m.useEffect(()=>{if(!a||!u.length||!v){g();return}for(const C of S){if(n?.(C)===!1)continue;const j=u.indexOf(C),N=f[j];if(!N)continue;const{direction:E,speed:R}=tv(C,N,v,t,h);for(const M of["x","y"])p[M][E[M]]||(R[M]=0,E[M]=0);if(R.x>0||R.y>0){g(),_.current=C,w(b,i),y.current=R,x.current=E;return}}y.current={x:0,y:0},x.current={x:0,y:0},g()},[t,b,n,g,a,i,JSON.stringify(v),JSON.stringify(p),w,u,S,f,JSON.stringify(h)])}const mv={x:{[Me.Backward]:!1,[Me.Forward]:!1},y:{[Me.Backward]:!1,[Me.Forward]:!1}};function pv(e){let{delta:t,disabled:r}=e;const n=is(t);return Sn(s=>{if(r||!n||!s)return mv;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[Me.Backward]:s.x[Me.Backward]||a.x===-1,[Me.Forward]:s.x[Me.Forward]||a.x===1},y:{[Me.Backward]:s.y[Me.Backward]||a.y===-1,[Me.Forward]:s.y[Me.Forward]||a.y===1}}},[r,t,n])}function gv(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return Sn(s=>{var a;return t==null?null:(a=n??s)!=null?a:null},[n,t])}function vv(e,t){return m.useMemo(()=>e.reduce((r,n)=>{const{sensor:s}=n,a=s.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,n)}));return[...r,...a]},[]),[e,t])}var vn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(vn||(vn={}));var Ca;(function(e){e.Optimized="optimized"})(Ca||(Ca={}));const Vi=new Map;function yv(e,t){let{dragging:r,dependencies:n,config:s}=t;const[a,i]=m.useState(null),{frequency:c,measure:l,strategy:u}=s,f=m.useRef(e),d=y(),h=pn(d),p=m.useCallback(function(x){x===void 0&&(x=[]),!h.current&&i(v=>v===null?x:v.concat(x.filter(_=>!v.includes(_))))},[h]),w=m.useRef(null),g=Sn(x=>{if(d&&!r)return Vi;if(!x||x===Vi||f.current!==e||a!=null){const v=new Map;for(let _ of e){if(!_)continue;if(a&&a.length>0&&!a.includes(_.id)&&_.rect.current){v.set(_.id,_.rect.current);continue}const b=_.node.current,S=b?new So(l(b),b):null;_.rect.current=S,S&&v.set(_.id,S)}return v}return x},[e,a,r,d,l]);return m.useEffect(()=>{f.current=e},[e]),m.useEffect(()=>{d||p()},[r,d]),m.useEffect(()=>{a&&a.length>0&&i(null)},[JSON.stringify(a)]),m.useEffect(()=>{d||typeof c!="number"||w.current!==null||(w.current=setTimeout(()=>{p(),w.current=null},c))},[c,d,p,...n]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:a!=null};function y(){switch(u){case vn.Always:return!1;case vn.BeforeDragging:return r;default:return!r}}}function jo(e,t){return Sn(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function xv(e,t){return jo(e,t)}function bv(e){let{callback:t,disabled:r}=e;const n=Os(t),s=m.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return m.useEffect(()=>()=>s?.disconnect(),[s]),s}function $s(e){let{callback:t,disabled:r}=e;const n=Os(t),s=m.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return m.useEffect(()=>()=>s?.disconnect(),[s]),s}function wv(e){return new So(kn(e),e)}function zi(e,t,r){t===void 0&&(t=wv);const[n,s]=m.useState(null);function a(){s(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??r)!=null?u:null}const f=t(e);return JSON.stringify(l)===JSON.stringify(f)?l:f})}const i=bv({callback(l){if(e)for(const u of l){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){a();break}}}}),c=$s({callback:a});return qt(()=>{a(),e?(c?.observe(e),i?.observe(document.body,{childList:!0,subtree:!0})):(c?.disconnect(),i?.disconnect())},[e]),n}function _v(e){const t=jo(e);return bu(e,t)}const Hi=[];function Sv(e){const t=m.useRef(e),r=Sn(n=>e?n&&n!==Hi&&e&&t.current&&e.parentNode===t.current.parentNode?n:_o(e):Hi,[e]);return m.useEffect(()=>{t.current=e},[e]),r}function kv(e){const[t,r]=m.useState(null),n=m.useRef(e),s=m.useCallback(a=>{const i=ea(a.target);i&&r(c=>c?(c.set(i,Sa(i)),new Map(c)):null)},[]);return m.useEffect(()=>{const a=n.current;if(e!==a){i(a);const c=e.map(l=>{const u=ea(l);return u?(u.addEventListener("scroll",s,{passive:!0}),[u,Sa(u)]):null}).filter(l=>l!=null);r(c.length?new Map(c):null),n.current=e}return()=>{i(e),i(a)};function i(c){c.forEach(l=>{const u=ea(l);u?.removeEventListener("scroll",s)})}},[s,e]),m.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,i)=>Ir(a,i),_t):Du(e):_t,[e,t])}function Bi(e,t){t===void 0&&(t=[]);const r=m.useRef(null);return m.useEffect(()=>{r.current=null},t),m.useEffect(()=>{const n=e!==_t;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?cs(e,r.current):_t}function Cv(e){m.useEffect(()=>{if(!Ms)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function jv(e,t){return m.useMemo(()=>e.reduce((r,n)=>{let{eventName:s,handler:a}=n;return r[s]=i=>{a(i,t)},r},{}),[e,t])}function Tu(e){return m.useMemo(()=>e?Kg(e):null,[e])}const Wi=[];function Dv(e,t){t===void 0&&(t=kn);const[r]=e,n=Tu(r?Ue(r):null),[s,a]=m.useState(Wi);function i(){a(()=>e.length?e.map(l=>Cu(l)?n:new So(t(l),l)):Wi)}const c=$s({callback:i});return qt(()=>{c?.disconnect(),i(),e.forEach(l=>c?.observe(l))},[e]),s}function Ru(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return _n(t)?t:e}function Nv(e){let{measure:t}=e;const[r,n]=m.useState(null),s=m.useCallback(u=>{for(const{target:f}of u)if(_n(f)){n(d=>{const h=t(f);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),a=$s({callback:s}),i=m.useCallback(u=>{const f=Ru(u);a?.disconnect(),f&&a?.observe(f),n(f?t(f):null)},[t,a]),[c,l]=os(i);return m.useMemo(()=>({nodeRef:c,rect:r,setRef:l}),[r,c,l])}const Ev=[{sensor:Co,options:{}},{sensor:Au,options:{}}],Av={current:{}},Bn={draggable:{measure:Ii},droppable:{measure:Ii,strategy:vn.WhileDragging,frequency:Ca.Optimized},dragOverlay:{measure:kn}};class ln extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const Tv={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ln,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:us},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bn,measureDroppableContainers:us,windowRect:null,measuringScheduled:!1},Pu={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:us,draggableNodes:new Map,over:null,measureDroppableContainers:us},Cn=m.createContext(Pu),Mu=m.createContext(Tv);function Rv(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ln}}}function Pv(e,t){switch(t.type){case Pe.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Pe.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Pe.DragEnd:case Pe.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Pe.RegisterDroppable:{const{element:r}=t,{id:n}=r,s=new ln(e.droppable.containers);return s.set(n,r),{...e,droppable:{...e.droppable,containers:s}}}case Pe.SetDroppableDisabled:{const{id:r,key:n,disabled:s}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const i=new ln(e.droppable.containers);return i.set(r,{...a,disabled:s}),{...e,droppable:{...e.droppable,containers:i}}}case Pe.UnregisterDroppable:{const{id:r,key:n}=t,s=e.droppable.containers.get(r);if(!s||n!==s.key)return e;const a=new ln(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Mv(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:s}=m.useContext(Cn),a=is(n),i=is(r?.id);return m.useEffect(()=>{if(!t&&!n&&a&&i!=null){if(!wo(a)||document.activeElement===a.target)return;const c=s.get(i);if(!c)return;const{activatorNode:l,node:u}=c;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[l.current,u.current]){if(!f)continue;const d=Eg(f);if(d){d.focus();break}}})}},[n,t,s,i,a]),null}function Ou(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((s,a)=>a({transform:s,...n}),r):r}function Ov(e){return m.useMemo(()=>({draggable:{...Bn.draggable,...e?.draggable},droppable:{...Bn.droppable,...e?.droppable},dragOverlay:{...Bn.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Iv(e){let{activeNode:t,measure:r,initialRect:n,config:s=!0}=e;const a=m.useRef(!1),{x:i,y:c}=typeof s=="boolean"?{x:s,y:s}:s;qt(()=>{if(!i&&!c||!t){a.current=!1;return}if(a.current||!n)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=r(u),d=bu(f,n);if(i||(d.x=0),c||(d.y=0),a.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=_u(u);h&&h.scrollBy({top:d.y,left:d.x})}},[t,i,c,n,r])}const Fs=m.createContext({..._t,scaleX:1,scaleY:1});var sr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(sr||(sr={}));const $v=m.memo(function(t){var r,n,s,a;let{id:i,accessibility:c,autoScroll:l=!0,children:u,sensors:f=Ev,collisionDetection:d=Ug,measuring:h,modifiers:p,...w}=t;const g=m.useReducer(Pv,void 0,Rv),[y,x]=g,[v,_]=Og(),[b,S]=m.useState(sr.Uninitialized),C=b===sr.Initialized,{draggable:{active:j,nodes:N,translate:E},droppable:{containers:R}}=y,M=j!=null?N.get(j):null,A=m.useRef({initial:null,translated:null}),$=m.useMemo(()=>{var $e;return j!=null?{id:j,data:($e=M?.data)!=null?$e:Av,rect:A}:null},[j,M]),O=m.useRef(null),[B,L]=m.useState(null),[I,P]=m.useState(null),z=pn(w,Object.values(w)),H=Is("DndDescribedBy",i),te=m.useMemo(()=>R.getEnabled(),[R]),G=Ov(h),{droppableRects:V,measureDroppableContainers:W,measuringScheduled:se}=yv(te,{dragging:C,dependencies:[E.x,E.y],config:G.droppable}),ne=gv(N,j),fe=m.useMemo(()=>I?ls(I):null,[I]),pe=ed(),Ae=xv(ne,G.draggable.measure);Iv({activeNode:j!=null?N.get(j):null,config:pe.layoutShiftCompensation,initialRect:Ae,measure:G.draggable.measure});const xe=zi(ne,G.draggable.measure,Ae),Ze=zi(ne?ne.parentElement:null),Ye=m.useRef({activatorEvent:null,active:null,activeNode:ne,collisionRect:null,collisions:null,droppableRects:V,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Xe=R.getNodeFor((r=Ye.current.over)==null?void 0:r.id),Ke=Nv({measure:G.dragOverlay.measure}),kt=(n=Ke.nodeRef.current)!=null?n:ne,mt=C?(s=Ke.rect)!=null?s:xe:null,Xt=!!(Ke.nodeRef.current&&Ke.rect),jn=_v(Xt?null:xe),Dn=Tu(kt?Ue(kt):null),pt=Sv(C?Xe??ne:null),D=Dv(pt),T=Ou(p,{transform:{x:E.x-jn.x,y:E.y-jn.y,scaleX:1,scaleY:1},activatorEvent:I,active:$,activeNodeRect:xe,containerNodeRect:Ze,draggingNodeRect:mt,over:Ye.current.over,overlayNodeRect:Ke.rect,scrollableAncestors:pt,scrollableAncestorRects:D,windowRect:Dn}),F=fe?Ir(fe,E):null,X=kv(pt),Y=Bi(X),Z=Bi(X,[xe]),ee=Ir(T,Y),le=mt?Gg(mt,T):null,he=$&&le?d({active:$,collisionRect:le,droppableRects:V,droppableContainers:te,pointerCoordinates:F}):null,Ve=Bg(he,"id"),[Je,gt]=m.useState(null),Ls=Xt?T:Ir(T,Z),Xr=Zg(Ls,(a=Je?.rect)!=null?a:null,xe),fr=m.useRef(null),Nn=m.useCallback(($e,Qe)=>{let{sensor:et,options:Kt}=Qe;if(O.current==null)return;const lt=N.get(O.current);if(!lt)return;const tt=$e.nativeEvent,Ct=new et({active:O.current,activeNode:lt,event:tt,options:Kt,context:Ye,onAbort(Oe){if(!N.get(Oe))return;const{onDragAbort:jt}=z.current,zt={id:Oe};jt?.(zt),v({type:"onDragAbort",event:zt})},onPending(Oe,Jt,jt,zt){if(!N.get(Oe))return;const{onDragPending:Jr}=z.current,Qt={id:Oe,constraint:Jt,initialCoordinates:jt,offset:zt};Jr?.(Qt),v({type:"onDragPending",event:Qt})},onStart(Oe){const Jt=O.current;if(Jt==null)return;const jt=N.get(Jt);if(!jt)return;const{onDragStart:zt}=z.current,Kr={activatorEvent:tt,active:{id:Jt,data:jt.data,rect:A}};mr.unstable_batchedUpdates(()=>{zt?.(Kr),S(sr.Initializing),x({type:Pe.DragStart,initialCoordinates:Oe,active:Jt}),v({type:"onDragStart",event:Kr}),L(fr.current),P(tt)})},onMove(Oe){x({type:Pe.DragMove,coordinates:Oe})},onEnd:Cr(Pe.DragEnd),onCancel:Cr(Pe.DragCancel)});fr.current=Ct;function Cr(Oe){return async function(){const{active:jt,collisions:zt,over:Kr,scrollAdjustedTranslate:Jr}=Ye.current;let Qt=null;if(jt&&Jr){const{cancelDrop:Qr}=z.current;Qt={activatorEvent:tt,active:jt,collisions:zt,delta:Jr,over:Kr},Oe===Pe.DragEnd&&typeof Qr=="function"&&await Promise.resolve(Qr(Qt))&&(Oe=Pe.DragCancel)}O.current=null,mr.unstable_batchedUpdates(()=>{x({type:Oe}),S(sr.Uninitialized),gt(null),L(null),P(null),fr.current=null;const Qr=Oe===Pe.DragEnd?"onDragEnd":"onDragCancel";if(Qt){const Vs=z.current[Qr];Vs?.(Qt),v({type:Qr,event:Qt})}})}}},[N]),En=m.useCallback(($e,Qe)=>(et,Kt)=>{const lt=et.nativeEvent,tt=N.get(Kt);if(O.current!==null||!tt||lt.dndKit||lt.defaultPrevented)return;const Ct={active:tt};$e(et,Qe.options,Ct)===!0&&(lt.dndKit={capturedBy:Qe.sensor},O.current=Kt,Nn(et,Qe))},[N,Nn]),An=vv(f,En);Cv(f),qt(()=>{xe&&b===sr.Initializing&&S(sr.Initialized)},[xe,b]),m.useEffect(()=>{const{onDragMove:$e}=z.current,{active:Qe,activatorEvent:et,collisions:Kt,over:lt}=Ye.current;if(!Qe||!et)return;const tt={active:Qe,activatorEvent:et,collisions:Kt,delta:{x:ee.x,y:ee.y},over:lt};mr.unstable_batchedUpdates(()=>{$e?.(tt),v({type:"onDragMove",event:tt})})},[ee.x,ee.y]),m.useEffect(()=>{const{active:$e,activatorEvent:Qe,collisions:et,droppableContainers:Kt,scrollAdjustedTranslate:lt}=Ye.current;if(!$e||O.current==null||!Qe||!lt)return;const{onDragOver:tt}=z.current,Ct=Kt.get(Ve),Cr=Ct&&Ct.rect.current?{id:Ct.id,rect:Ct.rect.current,data:Ct.data,disabled:Ct.disabled}:null,Oe={active:$e,activatorEvent:Qe,collisions:et,delta:{x:lt.x,y:lt.y},over:Cr};mr.unstable_batchedUpdates(()=>{gt(Cr),tt?.(Oe),v({type:"onDragOver",event:Oe})})},[Ve]),qt(()=>{Ye.current={activatorEvent:I,active:$,activeNode:ne,collisionRect:le,collisions:he,droppableRects:V,draggableNodes:N,draggingNode:kt,draggingNodeRect:mt,droppableContainers:R,over:Je,scrollableAncestors:pt,scrollAdjustedTranslate:ee},A.current={initial:mt,translated:le}},[$,ne,he,le,N,kt,mt,V,R,Je,pt,ee]),hv({...pe,delta:E,draggingRect:le,pointerCoordinates:F,scrollableAncestors:pt,scrollableAncestorRects:D});const Tn=m.useMemo(()=>({active:$,activeNode:ne,activeNodeRect:xe,activatorEvent:I,collisions:he,containerNodeRect:Ze,dragOverlay:Ke,draggableNodes:N,droppableContainers:R,droppableRects:V,over:Je,measureDroppableContainers:W,scrollableAncestors:pt,scrollableAncestorRects:D,measuringConfiguration:G,measuringScheduled:se,windowRect:Dn}),[$,ne,xe,I,he,Ze,Ke,N,R,V,Je,W,pt,D,G,se,Dn]),Qu=m.useMemo(()=>({activatorEvent:I,activators:An,active:$,activeNodeRect:xe,ariaDescribedById:{draggable:H},dispatch:x,draggableNodes:N,over:Je,measureDroppableContainers:W}),[I,An,$,xe,x,H,N,Je,W]);return m.createElement(xu.Provider,{value:_},m.createElement(Cn.Provider,{value:Qu},m.createElement(Mu.Provider,{value:Tn},m.createElement(Fs.Provider,{value:Xr},u)),m.createElement(Mv,{disabled:c?.restoreFocus===!1})),m.createElement(Fg,{...c,hiddenTextDescribedById:H}));function ed(){const $e=B?.autoScrollEnabled===!1,Qe=typeof l=="object"?l.enabled===!1:l===!1,et=C&&!$e&&!Qe;return typeof l=="object"?{...l,enabled:et}:{enabled:et}}}),Fv=m.createContext(null),Ui="button",Lv="Draggable";function Vv(e){let{id:t,data:r,disabled:n=!1,attributes:s}=e;const a=Is(Lv),{activators:i,activatorEvent:c,active:l,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:h}=m.useContext(Cn),{role:p=Ui,roleDescription:w="draggable",tabIndex:g=0}=s??{},y=l?.id===t,x=m.useContext(y?Fs:Fv),[v,_]=os(),[b,S]=os(),C=jv(i,t),j=pn(r);qt(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:j}),()=>{const E=d.get(t);E&&E.key===a&&d.delete(t)}),[d,t]);const N=m.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":n,"aria-pressed":y&&p===Ui?!0:void 0,"aria-roledescription":w,"aria-describedby":f.draggable}),[n,p,g,y,w,f.draggable]);return{active:l,activatorEvent:c,activeNodeRect:u,attributes:N,isDragging:y,listeners:n?void 0:C,node:v,over:h,setNodeRef:_,setActivatorNodeRef:S,transform:x}}function zv(){return m.useContext(Mu)}const Hv="Droppable",Bv={timeout:25};function Wv(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:s}=e;const a=Is(Hv),{active:i,dispatch:c,over:l,measureDroppableContainers:u}=m.useContext(Cn),f=m.useRef({disabled:r}),d=m.useRef(!1),h=m.useRef(null),p=m.useRef(null),{disabled:w,updateMeasurementsFor:g,timeout:y}={...Bv,...s},x=pn(g??n),v=m.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(x.current)?x.current:[x.current]),p.current=null},y)},[y]),_=$s({callback:v,disabled:w||!i}),b=m.useCallback((N,E)=>{_&&(E&&(_.unobserve(E),d.current=!1),N&&_.observe(N))},[_]),[S,C]=os(b),j=pn(t);return m.useEffect(()=>{!_||!S.current||(_.disconnect(),d.current=!1,_.observe(S.current))},[S,_]),m.useEffect(()=>(c({type:Pe.RegisterDroppable,element:{id:n,key:a,disabled:r,node:S,rect:h,data:j}}),()=>c({type:Pe.UnregisterDroppable,key:a,id:n})),[n]),m.useEffect(()=>{r!==f.current.disabled&&(c({type:Pe.SetDroppableDisabled,id:n,key:a,disabled:r}),f.current.disabled=r)},[n,a,r,c]),{active:i,rect:h,isOver:l?.id===n,node:S,over:l,setNodeRef:C}}function Uv(e){let{animation:t,children:r}=e;const[n,s]=m.useState(null),[a,i]=m.useState(null),c=is(r);return!r&&!n&&c&&s(c),qt(()=>{if(!a)return;const l=n?.key,u=n?.props.id;if(l==null||u==null){s(null);return}Promise.resolve(t(u,a)).then(()=>{s(null)})},[t,n,a]),m.createElement(m.Fragment,null,r,n?m.cloneElement(n,{ref:i}):null)}const Zv={x:0,y:0,scaleX:1,scaleY:1};function Yv(e){let{children:t}=e;return m.createElement(Cn.Provider,{value:Pu},m.createElement(Fs.Provider,{value:Zv},t))}const Gv={position:"fixed",touchAction:"none"},qv=e=>wo(e)?"transform 250ms ease":void 0,Xv=m.forwardRef((e,t)=>{let{as:r,activatorEvent:n,adjustScale:s,children:a,className:i,rect:c,style:l,transform:u,transition:f=qv}=e;if(!c)return null;const d=s?u:{...u,scaleX:1,scaleY:1},h={...Gv,width:c.width,height:c.height,top:c.top,left:c.left,transform:gn.Transform.toString(d),transformOrigin:s&&n?zg(n,c):void 0,transition:typeof f=="function"?f(n):f,...l};return m.createElement(r,{className:i,style:h,ref:t},a)}),Kv=e=>t=>{let{active:r,dragOverlay:n}=t;const s={},{styles:a,className:i}=e;if(a!=null&&a.active)for(const[c,l]of Object.entries(a.active))l!==void 0&&(s[c]=r.node.style.getPropertyValue(c),r.node.style.setProperty(c,l));if(a!=null&&a.dragOverlay)for(const[c,l]of Object.entries(a.dragOverlay))l!==void 0&&n.node.style.setProperty(c,l);return i!=null&&i.active&&r.node.classList.add(i.active),i!=null&&i.dragOverlay&&n.node.classList.add(i.dragOverlay),function(){for(const[l,u]of Object.entries(s))r.node.style.setProperty(l,u);i!=null&&i.active&&r.node.classList.remove(i.active)}},Jv=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:gn.Transform.toString(t)},{transform:gn.Transform.toString(r)}]},Qv={duration:250,easing:"ease",keyframes:Jv,sideEffects:Kv({styles:{active:{opacity:"0"}}})};function ey(e){let{config:t,draggableNodes:r,droppableContainers:n,measuringConfiguration:s}=e;return Os((a,i)=>{if(t===null)return;const c=r.get(a);if(!c)return;const l=c.node.current;if(!l)return;const u=Ru(i);if(!u)return;const{transform:f}=Ue(i).getComputedStyle(i),d=wu(f);if(!d)return;const h=typeof t=="function"?t:ty(t);return Nu(l,s.draggable.measure),h({active:{id:a,data:c.data,node:l,rect:s.draggable.measure(l)},draggableNodes:r,dragOverlay:{node:i,rect:s.dragOverlay.measure(u)},droppableContainers:n,measuringConfiguration:s,transform:d})})}function ty(e){const{duration:t,easing:r,sideEffects:n,keyframes:s}={...Qv,...e};return a=>{let{active:i,dragOverlay:c,transform:l,...u}=a;if(!t)return;const f={x:c.rect.left-i.rect.left,y:c.rect.top-i.rect.top},d={scaleX:l.scaleX!==1?i.rect.width*l.scaleX/c.rect.width:1,scaleY:l.scaleY!==1?i.rect.height*l.scaleY/c.rect.height:1},h={x:l.x-f.x,y:l.y-f.y,...d},p=s({...u,active:i,dragOverlay:c,transform:{initial:l,final:h}}),[w]=p,g=p[p.length-1];if(JSON.stringify(w)===JSON.stringify(g))return;const y=n?.({active:i,dragOverlay:c,...u}),x=c.node.animate(p,{duration:t,easing:r,fill:"forwards"});return new Promise(v=>{x.onfinish=()=>{y?.(),v()}})}}let Zi=0;function ry(e){return m.useMemo(()=>{if(e!=null)return Zi++,Zi},[e])}const ny=m.memo(e=>{let{adjustScale:t=!1,children:r,dropAnimation:n,style:s,transition:a,modifiers:i,wrapperElement:c="div",className:l,zIndex:u=999}=e;const{activatorEvent:f,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:w,droppableContainers:g,dragOverlay:y,over:x,measuringConfiguration:v,scrollableAncestors:_,scrollableAncestorRects:b,windowRect:S}=zv(),C=m.useContext(Fs),j=ry(d?.id),N=Ou(i,{activatorEvent:f,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:y.rect,over:x,overlayNodeRect:y.rect,scrollableAncestors:_,scrollableAncestorRects:b,transform:C,windowRect:S}),E=jo(h),R=ey({config:n,draggableNodes:w,droppableContainers:g,measuringConfiguration:v}),M=E?y.setRef:void 0;return m.createElement(Yv,null,m.createElement(Uv,{animation:R},d&&j?m.createElement(Xv,{key:j,id:d.id,ref:M,as:c,activatorEvent:f,adjustScale:t,className:l,transition:a,rect:E,style:{zIndex:u,...s},transform:N},r):null))}),Iu=e=>{if(e.extendedProps?.location){const t=e.extendedProps.location;if(typeof t=="string")return t;if(typeof t=="object"&&t!==null){const r=t,n=typeof r.building=="string"?r.building:"",s=typeof r.room=="string"?r.room:"";return`${n} ${s}`.trim()}}return e.description||""},sy=e=>!!e.extendedProps?.isAllDay,$u=(e,t,r)=>{if(!e||e==="[]"||e==="")return t;try{const n=typeof e=="string"?JSON.parse(e):e;if(Array.isArray(n)){const a=n.filter(i=>!(typeof i!="object"||i===null||r&&"personnelId"in i&&i.personnelId===r)).map(i=>{const c=i.name;return typeof c=="string"?c:null}).filter(i=>!!i);return a.length>0?a.join(", "):""}}catch{}return typeof e=="string"?e:""},fs=({event:e,position:t,column:r=0,totalColumns:n=1,onEventClick:s,currentUserId:a,resources:i=[],renderEventContent:c,components:l,viewMode:u="week",orientation:f="horizontal",usePercentagePosition:d=!1})=>{const{attributes:h,listeners:p,setNodeRef:w,isDragging:g}=Vv({id:e.id,data:e,disabled:!1}),y=R=>{R.stopPropagation(),s?.(e)},x=e.title,v=$u(e.attendee,"",a),b=i.find(R=>R.id===e.resourceId)?.name||Iu(e),S=f==="vertical",C=S?t.top>=40:t.height>=60,j=100/n,N=r*j,E=S?{left:d?`${t.top}%`:`${t.top}px`,width:d?`${t.height}%`:`${t.height}px`,top:`calc(${N}% + 2px)`,height:`calc(${j}% - 4px)`,minWidth:d?void 0:"44px",backgroundColor:e.color||"#3b82f6",color:"white",zIndex:g?50:10+r}:{top:d?`${t.top}%`:`${t.top}px`,height:d?`${t.height}%`:`${t.height}px`,minHeight:d?void 0:"44px",left:`calc(${N}% + 2px)`,width:`calc(${j}% - 4px)`,backgroundColor:e.color||"#3b82f6",color:"white",zIndex:g?50:10+r};return o.jsx("button",{ref:w,...p,...h,onClick:y,type:"button",onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),R.stopPropagation(),s?.(e))},className:`
|
|
61
61
|
absolute rounded px-[var(--ui-space-1)] py-[var(--ui-space-1)] text-sm cursor-pointer
|
|
62
62
|
transition-all select-none flex flex-col items-start text-left
|
|
63
63
|
active:scale-95
|
|
64
|
-
${
|
|
65
|
-
`,style:
|
|
66
|
-
border-
|
|
67
|
-
${
|
|
68
|
-
|
|
64
|
+
${g?"opacity-50":"hover:shadow-md"}
|
|
65
|
+
`,style:E,children:l?.EventCard?o.jsx(l.EventCard,{event:e,viewMode:u||"week",isDragging:g,onClick:y,isCompact:t.height<50}):c?c(e,u||"week"):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"font-medium truncate text-xs w-full",children:x}),v!==""&&o.jsx("div",{className:"text-[10px] opacity-90 truncate w-full",children:v}),C&&b!==""&&o.jsx("div",{className:"text-[10px] opacity-90 truncate w-full",children:b})]})})},ay=({event:e,onClick:t,renderEventContent:r,components:n})=>{const s=l=>{l.stopPropagation(),t?.(e)},a=e.title,c=sy(e)?"All Day":`${e.startDate.getHours()}:${e.startDate.getMinutes().toString().padStart(2,"0")}`;return o.jsx("button",{type:"button",onClick:s,className:"w-full text-left text-sm px-[var(--ui-space-2)] py-[var(--ui-space-1)] mb-[var(--ui-space-0-5)] rounded truncate cursor-pointer active:scale-95 transition-transform select-none border-0 min-h-[var(--ui-space-7)] flex items-center",style:{backgroundColor:e.color||"#3b82f6",color:"white"},children:n?.EventCard?o.jsx(n.EventCard,{event:e,viewMode:"month",isDragging:!1,onClick:s,isCompact:!0}):r?r(e,"month"):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-medium mr-[var(--ui-space-1)]",children:c})," ",a]})})},oy=({event:e,currentUserId:t,resources:r=[]})=>{const n=e.title,s=$u(e.attendee,"",t),i=r.find(c=>c.id===e.resourceId)?.name||Iu(e);return o.jsxs("div",{className:"rounded px-[var(--ui-space-2)] py-[var(--ui-space-2)] text-sm shadow-lg min-h-[var(--ui-space-11)] flex flex-col items-start text-left",style:{backgroundColor:e.color||"#3b82f6",color:"white",width:"200px"},children:[o.jsx("div",{className:"font-medium w-full",children:n}),s!==""&&o.jsxs("div",{className:"text-xs opacity-90 w-full text-left",children:["with ",s]}),i!==""&&o.jsx("div",{className:"text-sm opacity-90 w-full text-left",children:i})]})},ft=60,Et=50,hs={start:8,end:20},iy=(e,t)=>{const r=[],n=new Date(e);n.setHours(0,0,0,0);const s=n.getDay();let a;t===1?a=n.getDate()-(s+6)%7:a=n.getDate()-s,n.setDate(a);for(let i=0;i<7;i++){const c=new Date(n);c.setHours(0,0,0,0),r.push(c),n.setDate(n.getDate()+1)}return r},Fu=(e,t=8,r=20)=>{const n=[];for(let s=t;s<r;s++)for(let a=0;a<60;a+=e){const i=`${s.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;n.push(i)}return n},cy=(e=30,t=8,r="Asia/Tokyo")=>{const n=new Date,{hour:s,minute:a}=ps(n,r),i=s*60+a,c=t*60,l=i-c,u=60/e,f=ft*u;return l/60*f},ly=(e=8,t=20,r="Asia/Tokyo")=>{const n=new Date,{hour:s}=ps(n,r);return s>=e&&s<t},ms=(e,t,r=8,n=20)=>{const s=new Date(t);s.setHours(0,0,0,0);const a=new Date(t);a.setHours(23,59,59,999);const i=new Date(t);return i.setHours(0,0,0,0),i.setMinutes(n*60),e.filter(c=>{const l=new Date(c.startDate),u=l.getTime()>=s.getTime()&&l.getTime()<=a.getTime(),f=l.getTime()>=s.getTime()+r*60*60*1e3&&l.getTime()<i.getTime();if(n>24){const d=new Date(s);if(d.setDate(s.getDate()+1),l.getTime()>=d.getTime()&&l.getTime()<i.getTime())return!0}return u&&f})},uy=(e,t)=>{const r=e.getFullYear(),n=e.getMonth(),s=new Date(r,n,1),a=s.getDay(),i=t===1?(a+6)%7:a,c=new Date(s);c.setDate(1-i);const l=[],u=new Date(c);for(let f=0;f<6;f++){const d=[];for(let h=0;h<7;h++)d.push(new Date(u)),u.setDate(u.getDate()+1);l.push(d)}return l},ps=(e,t="Asia/Tokyo")=>{try{const n=new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:t}).formatToParts(e),s=parseInt(n.find(i=>i.type==="hour")?.value||"0",10),a=parseInt(n.find(i=>i.type==="minute")?.value||"0",10);return{hour:s===24?0:s,minute:a}}catch(r){return console.error(`Invalid timezone: ${t}`,r),{hour:e.getHours(),minute:e.getMinutes()}}},Lu=(e,t=30,r=8,n="Asia/Tokyo")=>{const s=e.startDate,a=e.endDate,i=ps(s,n),c=ps(a,n),l=i.hour*60+i.minute;let u=c.hour*60+c.minute;u<l&&(u+=1440);const f=u-l,d=60/t,h=ft*d,p=r*60;let w=l-p;w<0&&(w+=1440);const g=w/60*h,y=f/60*h;return{top:g,height:y}},dy=(e,t)=>{const r=e.getDay();let n="";return t?n+="font-bold":n+="font-normal",r===0?n+=" text-red-600":r===6?n+=" text-blue-600":n+=" text-foreground",n},fy=(e,t,r,n="Asia/Tokyo")=>{if(e.length===0)return[];const s=e.map(d=>({...d,_start:new Date(d.startDate).getTime(),_end:new Date(d.endDate).getTime()})),a=(d,h)=>d._start<h._end&&d._end>h._start,i=[...s].sort((d,h)=>{const p=d._start-h._start;return p!==0?p:h._end-h._start-(d._end-d._start)}),c=Array.from({length:i.length},()=>[]);for(let d=0;d<i.length;d++)for(let h=d+1;h<i.length;h++)a(i[d],i[h])&&(c[d].push(h),c[h].push(d));const l=new Set,u=[];for(let d=0;d<i.length;d++){if(l.has(d))continue;const h=[],p=[d];for(l.add(d);p.length>0;){const w=p.shift();if(w!==void 0){h.push(w);for(const g of c[w])l.has(g)||(l.add(g),p.push(g))}}u.push(h)}const f=[];return u.forEach(d=>{d.sort((g,y)=>i[g]._start-i[y]._start);const h=[],p=new Map;d.forEach(g=>{const y=i[g];let x=-1;for(let v=0;v<h.length;v++){const _=h[v][h[v].length-1],b=i[_];if(y._start>=b._end){x=v;break}}x===-1&&(x=h.length,h.push([])),h[x].push(g),p.set(g,x)});const w=h.length;d.forEach(g=>{const y=i[g],x=p.get(g);if(x===void 0)return;const v=Lu(y,t,r,n),_=e.find(b=>b.id===y.id)??y;f.push({event:_,column:x,totalColumns:w,position:v})})}),f},Vu=({interval:e,isToday:t,startHour:r,endHour:n,relative:s=!1,timeZone:a="Asia/Tokyo"})=>{const[i,c]=m.useState(new Date);if(m.useEffect(()=>{const u=setInterval(()=>{c(new Date)},6e4);return()=>clearInterval(u)},[]),!t||!ly(r,n,a))return null;const l=cy(e,r,a);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`${s?"absolute":"fixed"} left-[var(--ui-space-0)] w-[var(--ui-space-2)] h-[var(--ui-space-2)] bg-red-500 rounded-full -translate-x-[var(--ui-space-1)]`,style:{top:`${l}px`,zIndex:20},"aria-hidden":"true",title:`Current time: ${i.toLocaleTimeString()}`}),o.jsx("div",{className:`${s?"absolute":"fixed"} left-[var(--ui-space-0)] right-[var(--ui-space-0)] h-[var(--ui-space-0-5)] bg-red-500`,style:{top:`${l}px`,zIndex:20},"aria-hidden":"true"})]})},Yi=({date:e,timeSlot:t,onClick:r,orientation:n="horizontal"})=>{const s=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),c=`${s}-${a}-${i}T${t}`,{setNodeRef:l,isOver:u}=Wv({id:c}),f=n==="vertical";return o.jsx("button",{ref:l,type:"button",onClick:()=>r?.(e,t),className:`
|
|
66
|
+
border-border cursor-pointer transition-colors p-0 m-0 block box-border
|
|
67
|
+
${f?"border-r h-full flex-shrink-0":"border-b w-full text-left"}
|
|
68
|
+
${u?"bg-accent/50":"hover:bg-muted/30"}
|
|
69
|
+
`,style:f?{width:`${Et}px`}:{height:`${ft}px`},"aria-label":`Time slot ${t}`})};function hy({currentDate:e,events:t,settings:r,onTimeSlotClick:n,onEventClick:s,currentUserId:a,resources:i,renderEventContent:c,components:l}){const{t:u}=Le(),f=r.slotInterval||r.defaultDuration||60,d=Number((r.startTime||r.businessHoursStart)?.split(":")[0]||hs.start),h=Number((r.endTime||r.businessHoursEnd)?.split(":")[0]||hs.end),p=m.useMemo(()=>Fu(f,d,h),[f,d,h]),w=m.useMemo(()=>ms(t,e,d,h),[t,e,d,h]),{allDayEvents:g,timeEvents:y}=m.useMemo(()=>{const E=[],R=[];return w.forEach(M=>{M.isAllDay?E.push(M):R.push(M)}),{allDayEvents:E,timeEvents:R}},[w]),x=m.useMemo(()=>y.map(E=>({event:E,position:Lu(E,f,d,r.timeZone)})),[y,f,d,r.timeZone]),v=new Date,_=e.toDateString()===v.toDateString(),b=m.useRef(null),[S,C]=m.useState(0);m.useEffect(()=>{const E=b.current;if(!E)return;const R=()=>{const A=E.offsetWidth-E.clientWidth;C(A>0?A:0)};R();const M=new ResizeObserver(R);return M.observe(E),()=>M.disconnect()},[]);const N=(r.orientation||"horizontal")==="vertical";return o.jsx("div",{className:"flex flex-col h-full bg-background text-foreground",children:N?o.jsx("div",{className:"flex-1 overflow-auto relative",children:o.jsxs("div",{className:"flex flex-col min-w-max",style:{minWidth:`${p.length*Et+128}px`},children:[o.jsxs("div",{className:"flex border-b border-border bg-muted/40 sticky top-0 z-30",children:[o.jsx("div",{className:"w-[var(--ui-space-32)] flex-shrink-0 border-r border-border bg-background sticky left-0 z-40"}),o.jsx("div",{className:"flex",children:p.map(E=>o.jsx("div",{className:"flex-shrink-0 text-center border-r border-border text-[10px] text-muted-foreground p-1 flex items-center justify-center box-border",style:{width:`${Et}px`},children:E},E))})]}),o.jsxs("div",{className:`flex border-b border-border relative min-h-[var(--ui-space-20)] ${_?"bg-primary/5":""}`,children:[o.jsxs("div",{className:"w-[var(--ui-space-32)] flex-shrink-0 border-r border-border sticky left-0 z-20 bg-background p-2 flex flex-col items-center justify-center",children:[o.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:o.jsx(Ot,{date:e,format:"weekday"})}),o.jsx("div",{className:`text-xl font-bold mt-[var(--ui-space-1)] ${_?"text-primary":""}`,children:e.getDate()})]}),o.jsxs("div",{className:"flex relative",children:[p.map(E=>o.jsx(Yi,{date:e,timeSlot:E,onClick:n,orientation:"vertical"},`${e.toISOString()}-${E}`)),x.map(({event:E,position:R})=>o.jsx(fs,{event:E,position:{top:R.top/ft*Et,height:R.height/ft*Et},onEventClick:s,currentUserId:a,resources:i,renderEventContent:c,components:l,viewMode:"day",orientation:"vertical"},E.id))]})]})]})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`border-b border-border p-[var(--ui-space-2)] sticky top-[var(--ui-space-0)] z-30 text-center ${_?"bg-muted/50":"bg-muted/40"}`,style:{paddingRight:S||void 0},children:[o.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:o.jsx(Ot,{date:e,format:"weekday"})}),o.jsx("div",{className:`text-xl font-bold mt-[var(--ui-space-1)] ${_?"text-primary":""}`,children:e.getDate()})]}),g.length>0&&o.jsxs("div",{className:"flex border-b border-border bg-muted/20 sticky top-[var(--ui-space-13)] z-30",style:{paddingRight:S||void 0},children:[o.jsx("div",{className:"w-[var(--ui-space-16)] flex-shrink-0 border-r border-border bg-background flex items-center justify-end pr-[var(--ui-space-1)]",children:o.jsx("span",{className:"text-[9px] text-muted-foreground",children:u("all_day")})}),o.jsx("div",{className:"flex-1 p-[var(--ui-space-0-5)] min-w-[var(--ui-space-0)]",children:o.jsx("div",{className:"flex flex-col gap-[var(--ui-space-0-5)]",children:g.map(E=>o.jsx("button",{type:"button",className:`
|
|
69
70
|
text-[9px] px-[var(--ui-space-1)] py-[var(--ui-space-0-5)] rounded w-full text-left truncate leading-tight
|
|
70
71
|
bg-primary text-primary-foreground
|
|
71
72
|
hover:brightness-110 transition-colors
|
|
72
|
-
`,style:
|
|
73
|
+
`,style:E.color?{backgroundColor:E.color}:{},onClick:R=>{R.stopPropagation(),s?.(E)},children:l?.EventCard?o.jsx(l.EventCard,{event:E,viewMode:"day",isCompact:!0,onClick:()=>s?.(E)}):E.title},E.id))})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto relative",ref:b,children:o.jsxs("div",{className:"flex",style:{minHeight:`${(h-d)*60/f*ft}px`},children:[o.jsx("div",{className:"w-[var(--ui-space-16)] flex-shrink-0 bg-background sticky left-[var(--ui-space-0)] z-20",children:p.map(E=>o.jsx("div",{className:"border-b border-border text-xs text-muted-foreground p-0 flex items-center justify-end pr-[var(--ui-space-2)] box-border",style:{height:`${ft}px`},children:E},E))}),o.jsxs("div",{className:"flex-1 relative border-l border-border min-w-[var(--ui-space-50)]",children:[o.jsx(Vu,{interval:f,isToday:_,startHour:d,endHour:h,relative:!0,timeZone:r.timeZone}),p.map(E=>o.jsx(Yi,{date:e,timeSlot:E,onClick:n,orientation:"horizontal"},E)),x.map(({event:E,position:R})=>o.jsx(fs,{event:E,position:R,onEventClick:s,currentUserId:a,resources:i,renderEventContent:c,components:l,viewMode:"day",orientation:"horizontal"},E.id))]})]})})]})})}function my({currentDate:e,events:t,settings:r,onDateClick:n,onEventClick:s,currentUserId:a,renderEventContent:i,components:c}){const{t:l}=Le(),u=r.weekStartsOn??1,f=m.useMemo(()=>uy(e,u),[e,u]),d=[l("days_short_sun"),l("days_short_mon"),l("days_short_tue"),l("days_short_wed"),l("days_short_thu"),l("days_short_fri"),l("days_short_sat")],h=u===1?[...d.slice(1),d[0]]:d,p=new Date,w=e.getMonth();return o.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground",children:[o.jsx("div",{className:"grid grid-cols-7 border-b border-border bg-muted/40",children:h.map(g=>o.jsx("div",{className:"p-[var(--ui-space-3)] text-center text-sm font-medium text-muted-foreground border-r border-border last:border-r-0",children:g},g))}),o.jsx("div",{className:"flex-1 grid gap-[var(--ui-space-0)]",style:{gridTemplateRows:`repeat(${f.length}, 1fr)`},children:f.map(g=>o.jsx("div",{className:"grid grid-cols-7 border-b border-border last:border-b-0 h-full",children:g.map(y=>{const x=y.toDateString()===p.toDateString(),v=y.getMonth()===w,_=y.toDateString()===e.toDateString(),b=ms(t,y,0,24);return o.jsxs("div",{className:`
|
|
73
74
|
relative border-r border-border last:border-r-0 p-ui-cell cursor-pointer
|
|
74
75
|
transition-colors
|
|
75
|
-
${
|
|
76
|
-
${
|
|
76
|
+
${v?"bg-background":"bg-muted/20 text-muted-foreground"}
|
|
77
|
+
${_?"bg-primary/5":""}
|
|
77
78
|
hover:bg-muted/50
|
|
78
79
|
flex flex-col
|
|
79
|
-
`,children:[
|
|
80
|
-
${
|
|
81
|
-
`,children:
|
|
82
|
-
${
|
|
83
|
-
`,children:y.getDate()})}),
|
|
84
|
-
${
|
|
85
|
-
`,children:[
|
|
80
|
+
`,children:[o.jsx("button",{type:"button",className:"absolute inset-[var(--ui-space-0)] z-0","aria-label":l("day_cell")??"Day cell",onClick:()=>n?.(y)}),o.jsx("div",{className:`text-sm font-medium mb-[var(--ui-space-1)] flex justify-between items-center
|
|
81
|
+
${dy(y,_)}
|
|
82
|
+
`,children:o.jsx("span",{className:`
|
|
83
|
+
${x?"bg-primary text-primary-foreground rounded-full w-[var(--ui-space-6)] h-[var(--ui-space-6)] flex items-center justify-center":""}
|
|
84
|
+
`,children:y.getDate()})}),o.jsxs("div",{className:"space-y-[var(--ui-space-1)] overflow-hidden flex-1 relative z-10",children:[b.slice(0,3).map(S=>o.jsx(ay,{event:S,onClick:s,currentUserId:a,renderEventContent:i,components:c},S.id)),b.length>3&&o.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",b.length-3," more"]})]})]},y.toISOString())})},g[0]?.toISOString()??"empty-week"))})]})}function py({currentDate:e,events:t,settings:r,onTimeSlotClick:n,onEventClick:s,currentUserId:a,resources:i,renderEventContent:c,components:l}){const{t:u}=Le(),f=r.slotInterval||r.defaultDuration||60,d=Number((r.startTime||r.businessHoursStart)?.split(":")[0]||hs.start),h=Number((r.endTime||r.businessHoursEnd)?.split(":")[0]||hs.end),p=r.weekStartsOn??1,w=m.useMemo(()=>iy(e,p),[e,p]),g=m.useMemo(()=>Fu(f,d,h),[f,d,h]),y=[u("days_short_sun"),u("days_short_mon"),u("days_short_tue"),u("days_short_wed"),u("days_short_thu"),u("days_short_fri"),u("days_short_sat")],v=new Date().toDateString(),_=m.useRef(null),[b,S]=m.useState(0);m.useEffect(()=>{const M=_.current;if(!M)return;const A=()=>{const O=M.offsetWidth-M.clientWidth;S(O>0?O:0)};A();const $=new ResizeObserver(A);return $.observe(M),()=>$.disconnect()},[]);const{allDayEvents:C,timedEvents:j}=m.useMemo(()=>{const M=[],A=[];return t.forEach($=>{$.isAllDay||$.extendedProps?.isAllDay?M.push($):A.push($)}),{allDayEvents:M,timedEvents:A}},[t]),N=m.useMemo(()=>w.map(M=>{const A=ms(j,M,d,h);return{date:M.toISOString(),events:fy(A,f,d,r.timeZone)}}),[w,j,f,d,r.timeZone,h]),R=(r.orientation||"horizontal")==="vertical";return o.jsx("div",{className:"flex flex-col h-full bg-background text-foreground",children:R?o.jsx("div",{className:"flex-1 overflow-auto relative",children:o.jsxs("div",{className:"flex flex-col min-w-max",style:{minWidth:`${g.length*Et+128}px`},children:[o.jsxs("div",{className:"flex border-b border-border bg-muted/40 sticky top-0 z-30",children:[o.jsx("div",{className:"w-[var(--ui-space-32)] flex-shrink-0 border-r border-border bg-background sticky left-0 z-40"}),o.jsx("div",{className:"flex",children:g.map(M=>o.jsx("div",{className:"flex-shrink-0 text-center border-r border-border text-[10px] text-muted-foreground p-1 flex items-center justify-center box-border",style:{width:`${Et}px`},children:M},M))})]}),w.map((M,A)=>{const $=M.toDateString()===v,O=M.toDateString()===e.toDateString(),B=M.getDay(),L=N[A];return o.jsxs("div",{className:`flex border-b border-border relative min-h-[80px] ${O?"bg-primary/5":""}`,children:[o.jsxs("div",{className:"w-[var(--ui-space-32)] flex-shrink-0 border-r border-border sticky left-0 z-20 bg-background p-2 flex flex-col items-center justify-center",children:[o.jsx("div",{className:`text-[10px] font-medium ${B===0?"text-red-500":B===6?"text-blue-500":"text-muted-foreground"}`,children:y[B]}),o.jsx("div",{className:`text-base font-bold ${$?"text-primary":""}`,children:M.getDate()})]}),o.jsxs("div",{className:"flex relative",children:[g.map(I=>o.jsx("button",{type:"button",onClick:()=>n?.(M,I),className:"border-r border-border cursor-pointer transition-colors hover:bg-muted/30 p-0 m-0 block box-border",style:{width:`${Et}px`,height:"100%"},"aria-label":`Time slot ${I}`},`${M.toISOString()}-${I}`)),L?.events.map(({event:I,position:P,column:z,totalColumns:H})=>o.jsx(fs,{event:I,position:{top:P.top/ft*Et,height:P.height/ft*Et},column:z,totalColumns:H,onEventClick:s,currentUserId:a,resources:i,renderEventContent:c,components:l,viewMode:"week",orientation:"vertical"},I.id))]})]},M.toISOString())})]})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex border-b border-border bg-muted/40 sticky top-[var(--ui-space-0)] z-30",style:{paddingRight:b||void 0},children:[o.jsx("div",{className:"w-[var(--ui-space-16)] flex-shrink-0 border-r border-border bg-background"}),w.map(M=>{const A=M.toDateString()===v,$=M.toDateString()===e.toDateString(),O=M.getDay();return o.jsxs("div",{className:`flex-1 p-[var(--ui-space-1)] text-center border-r border-border last:border-r-0 transition-colors min-w-[var(--ui-space-0)]
|
|
85
|
+
${$?"bg-primary/5":""}
|
|
86
|
+
`,children:[o.jsx("div",{className:`text-[10px] font-medium ${O===0?"text-red-500":O===6?"text-blue-500":"text-muted-foreground"}`,children:y[O]}),o.jsx("div",{className:`text-base font-bold ${A?"text-primary":""}`,children:M.getDate()})]},M.toISOString())})]}),C.length>0&&o.jsxs("div",{className:"flex border-b border-border bg-muted/20 sticky top-[var(--ui-space-13)] z-30",style:{paddingRight:b||void 0},children:[o.jsx("div",{className:"w-[var(--ui-space-16)] flex-shrink-0 border-r border-border bg-background flex items-center justify-end pr-[var(--ui-space-1)]",children:o.jsx("span",{className:"text-[9px] text-muted-foreground",children:u("all_day")})}),w.map(M=>{const A=ms(C,M,d,h);return o.jsx("div",{className:"flex-1 p-[var(--ui-space-0-5)] border-r border-border last:border-r-0 min-w-[var(--ui-space-0)]",children:o.jsx("div",{className:"flex flex-col gap-[var(--ui-space-0-5)]",children:A.map($=>o.jsx("button",{type:"button",className:`
|
|
86
87
|
text-[9px] px-[var(--ui-space-1)] py-[var(--ui-space-0-5)] rounded w-full text-left truncate leading-tight
|
|
87
88
|
bg-primary text-primary-foreground
|
|
88
89
|
hover:brightness-110 transition-colors
|
|
89
|
-
`,style:M.color?{backgroundColor:M.color}:{},onClick:R=>{R.stopPropagation(),s?.(M)},children:l?.EventCard?i.jsx(l.EventCard,{event:M,viewMode:"week",isCompact:!0,onClick:()=>s?.(M)}):M.title},M.id))})},A.toISOString())})]}),i.jsx("div",{className:"flex-1 overflow-y-auto relative",ref:C,children:i.jsxs("div",{className:"flex",style:{minHeight:`${(h-d)*60/f*rr}px`},children:[i.jsx("div",{className:"w-[var(--ui-space-16)] flex-shrink-0 sticky left-[var(--ui-space-0)] z-20 bg-background border-r border-border",children:g.map(A=>i.jsx("div",{className:"border-b border-border text-xs text-muted-foreground p-0 flex items-center justify-end pr-[var(--ui-space-2)] box-border",style:{height:`${rr}px`},children:A},A))}),i.jsx("div",{className:"flex-1 flex",children:w.map((A,T)=>{const M=A.toDateString()===b,R=E[T];return i.jsxs("div",{className:"flex-1 border-r border-border last:border-r-0 relative min-w-[var(--ui-space-0)]",children:[i.jsx(Pu,{interval:f,isToday:M,startHour:d,endHour:h,relative:!0,timeZone:r.timeZone}),g.map(V=>i.jsx("button",{type:"button",onClick:()=>n?.(A,V),className:"border-b border-border cursor-pointer transition-colors hover:bg-muted/30 w-full text-left p-0 m-0 block box-border",style:{height:`${rr}px`},"aria-label":`Time slot ${V}`},`${A.toISOString()}-${V}`)),R?.events.map(({event:V,position:F,column:G,totalColumns:$})=>i.jsx(Au,{event:V,position:F,column:G,totalColumns:$,onEventClick:s,currentUserId:a,resources:o,renderEventContent:c,components:l,viewMode:"week"},V.id))]},A.toISOString())})})]})})]})}function Ou({events:e,settings:t,currentDate:r,viewMode:n,onDateChange:s,onViewChange:a,onEventClick:o,onEventDrop:c,onTimeSlotClick:l,onDateClick:u,isLoading:f=!1,className:d,headerLeft:h,headerRight:p,defaultView:w="week",enablePersistence:g=!1,storageKey:y="regular-calendar-view",storage:v=Rs,currentUserId:b,resources:C=[],renderEventContent:x,components:_}){const{t:k}=$e(),[j,E]=m.useState(new Date),[A,T]=m.useState(()=>{if(g)try{const I=v.getItem(y);if(I&&["day","week","month"].includes(I))return I}catch(I){console.warn("Failed to load calendar view from storage",I)}return w}),M=r??j,R=n??A;m.useEffect(()=>{if(g&&!n)try{v.setItem(y,A)}catch(I){console.warn("Failed to save calendar view to storage",I)}},[A,g,y,n,v]);const V=I=>{const B=ho(M,R,I);s?s(B):E(B)},F=()=>{const I=new Date;s?s(I):E(I)},G=I=>{a?a(I):T(I)},$=(I,B)=>{const se=new Date(I);if(B){const[ne,fe]=B.split(":").map(Number);Number.isNaN(ne)||se.setHours(ne),Number.isNaN(fe)||se.setMinutes(fe)}l?.(se)},L=I=>{u&&u(I),s?s(I):E(I)},P=Ig(Mg(wo,{activationConstraint:{distance:8}})),[H,z]=m.useState(null),re=I=>{const{active:B}=I,se=e.find(ne=>ne.id===B.id);se&&z(se)},q=I=>{const{active:B,over:se}=I;if(z(null),!se||!c)return;const ne=e.find(Ze=>Ze.id===B.id);if(!ne)return;const fe=se.id,pe=new Date(fe);if(Number.isNaN(pe.getTime()))return;const Ae=fe.includes("T"),xe=new Date(pe);Ae||xe.setHours(ne.startDate.getHours(),ne.startDate.getMinutes()),c(ne,xe)};return i.jsxs(Pv,{sensors:P,onDragStart:re,onDragEnd:q,children:[i.jsxs("div",{className:`flex flex-col h-full bg-background ${d}`,children:[i.jsxs("header",{className:"border-b border-border px-[var(--ui-space-4)] py-[var(--ui-space-3)] flex items-center justify-between gap-[var(--ui-space-4)]",children:[i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:[i.jsx(ie,{variant:"outline",size:"icon",onClick:()=>V("prev"),children:i.jsx(ye.ChevronLeft,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),i.jsx(ie,{variant:"outline",onClick:F,children:k("today_button")}),i.jsx(ie,{variant:"outline",size:"icon",onClick:()=>V("next"),children:i.jsx(ye.ChevronRight,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),i.jsx("span",{className:"text-lg font-bold ml-[var(--ui-space-2)]",children:i.jsx(tr,{date:M,showSecondary:!0,showDayOfWeek:!0})}),h]}),i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-4)]",children:[i.jsx(fo,{currentView:R,onViewChange:G,options:[{value:"day",label:k("view_day")},{value:"week",label:k("view_week")},{value:"month",label:k("view_month")}]}),p]})]}),i.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[f&&i.jsx("div",{className:"absolute inset-[var(--ui-space-0)] bg-background/50 z-10 flex items-center justify-center",children:"Loading..."}),R==="day"&&i.jsx(uy,{currentDate:M,events:e,settings:t,onEventClick:o,onTimeSlotClick:$,currentUserId:b,resources:C,renderEventContent:x,components:_}),R==="week"&&i.jsx(fy,{currentDate:M,events:e,settings:t,onEventClick:o,onTimeSlotClick:$,currentUserId:b,resources:C,renderEventContent:x,components:_}),R==="month"&&i.jsx(dy,{currentDate:M,events:e,settings:t,onEventClick:o,onDateClick:L,currentUserId:b,renderEventContent:x,components:_})]})]}),i.jsx(Qv,{children:H?i.jsx(ry,{event:H,currentUserId:b,resources:C}):null})]})}function hy({events:e,resources:t,groups:r,settings:n,isLoading:s,onEventCreate:a,onEventUpdate:o,onEventDelete:c,onToast:l,customFields:u,personnel:f,currentUserId:d,i18n:h}){const[p,w]=m.useState(!1),[g,y]=m.useState(void 0),[v,b]=m.useState(void 0),C={...n,defaultDuration:30},x=e,_=T=>{b(T),y(void 0),w(!0)},k=T=>{y(T),b(void 0),w(!0)},j=()=>{w(!1),y(void 0),b(void 0)},E=async T=>{try{g?(await o(g.id,T),l?.("Event updated successfully","success")):(await a(T),l?.("Event created successfully","success")),j()}catch(M){console.error("Failed to save event",M),l?.("Failed to save event","error")}},A=async T=>{try{await c(T),l?.("Event deleted successfully","success"),j()}catch(M){console.error("Failed to delete event",M),l?.("Failed to delete event","error")}};return i.jsxs(i.Fragment,{children:[i.jsx(Ou,{events:x,settings:C,isLoading:s,onEventClick:k,onTimeSlotClick:_,onDateClick:_,enablePersistence:!0,defaultView:"week",storageKey:"regular-calendar-view",currentUserId:d,resources:t}),i.jsx(cu,{isOpen:p,onClose:j,onSave:E,onDelete:()=>{g?.id&&A(g.id)},event:g,defaultStartTime:v,resources:t,groups:r,events:e,personnel:f,currentUserId:d,customFields:u})]})}const Li=[...Array.from({length:24},(e,t)=>`${t.toString().padStart(2,"0")}:00`),"24:00","25:00","26:00","27:00","28:00","29:00","30:00"];function my({isOpen:e,onClose:t,settings:r,onUpdateSettings:n,onResetSettings:s}){const{t:a}=$e();if(!e)return null;const o=l=>{n(l)},c=[a("days_short_sun"),a("days_short_mon"),a("days_short_tue"),a("days_short_wed"),a("days_short_thu"),a("days_short_fri"),a("days_short_sat")];return i.jsxs("div",{className:"fixed inset-[var(--ui-space-0)] z-[9999] flex items-center justify-center bg-black/50 p-[var(--ui-space-4)]",children:[i.jsx("button",{type:"button","aria-label":a("close"),onClick:t,className:"absolute inset-[var(--ui-space-0)] border-none bg-transparent p-[var(--ui-space-0)] m-[var(--ui-space-0)] w-full h-full cursor-default"}),i.jsxs("div",{className:"relative z-10 w-full max-w-[var(--ui-space-125)] max-h-[var(--ui-space-90vh)] overflow-y-auto rounded-lg border border-border bg-background text-foreground shadow-xl p-[var(--ui-space-6)]",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-border pb-[var(--ui-space-4)] mb-[var(--ui-space-6)]",children:[i.jsx("h2",{className:"m-[var(--ui-space-0)] text-xl font-bold",children:a("settings_title")}),i.jsx(ie,{variant:"ghost",size:"icon",onClick:t,children:"✕"})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_language")}),i.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["ja","en"].map(l=>i.jsx(ie,{variant:r.language===l?"default":"outline",onClick:()=>o({language:l}),children:l==="ja"?"日本語":"English"},l))})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("label",{htmlFor:"settings-timezone",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:"TimeZone"}),i.jsxs("select",{id:"settings-timezone",value:r.timeZone||"Asia/Tokyo",onChange:l=>o({timeZone:l.target.value}),className:"h-ui w-full rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[i.jsx("option",{value:"Asia/Tokyo",children:"Asia/Tokyo (JST)"}),i.jsx("option",{value:"UTC",children:"UTC"}),i.jsx("option",{value:"America/New_York",children:"America/New_York (ET)"}),i.jsx("option",{value:"Europe/London",children:"Europe/London (GMT/BST)"}),i.jsx("option",{value:"Asia/Shanghai",children:"Asia/Shanghai (CST)"})]})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_theme")}),i.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["light","dark"].map(l=>i.jsx(ie,{variant:r.theme===l?"default":"outline",onClick:()=>o({theme:l}),children:a(l==="light"?"option_light":"option_dark")},l))})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_density")}),i.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["compact","normal","spacious"].map(l=>i.jsx(ie,{variant:r.density===l?"default":"outline",onClick:()=>o({density:l}),children:a(l==="compact"?"option_compact":l==="normal"?"option_normal":"option_spacious")},l))})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsxs("label",{htmlFor:"settings-radius",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:[a("settings_radius"),": ",r.borderRadius,"px"]}),i.jsx("input",{id:"settings-radius",type:"range",min:"0",max:"16",value:r.borderRadius,onChange:l=>o({borderRadius:Number(l.target.value)}),className:"w-full cursor-pointer"})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsxs("label",{htmlFor:"settings-font-size",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:[a("settings_font_size"),": ",r.fontSize,"px"]}),i.jsx("input",{id:"settings-font-size",type:"range",min:"12",max:"20",value:r.fontSize,onChange:l=>o({fontSize:Number(l.target.value)}),className:"w-full cursor-pointer"})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("label",{htmlFor:"settings-week-start",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_week_start")}),i.jsxs("select",{id:"settings-week-start",value:r.weekStartsOn,onChange:l=>o({weekStartsOn:Number(l.target.value)}),className:"h-ui w-full rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[i.jsx("option",{value:0,children:a("option_sunday")}),i.jsx("option",{value:1,children:a("option_monday")})]})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_business_hours")}),i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:[i.jsx("select",{value:r.businessHoursStart,onChange:l=>o({businessHoursStart:l.target.value}),className:"h-ui flex-1 rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:Li.map(l=>i.jsx("option",{value:l,children:l},l))}),i.jsx("span",{children:"〜"}),i.jsx("select",{value:r.businessHoursEnd,onChange:l=>o({businessHoursEnd:l.target.value}),className:"h-ui flex-1 rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:Li.map(l=>i.jsx("option",{value:l,children:l},l))})]})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_closed_days")}),i.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:c.map((l,u)=>i.jsx(ie,{variant:r.closedDays.includes(u)?"destructive":"outline",size:"sm",onClick:()=>{const f=r.closedDays.includes(u)?r.closedDays.filter(d=>d!==u):[...r.closedDays,u];o({closedDays:f})},className:"w-[var(--ui-space-10)] h-[var(--ui-space-10)] p-[var(--ui-space-0)]",children:l},l))})]}),i.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[i.jsxs("div",{className:"flex items-center justify-between mb-[var(--ui-space-2)]",children:[i.jsx("div",{className:"text-sm font-bold",children:a("settings_pagination")}),i.jsx("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:i.jsx(ie,{variant:r.paginationEnabled?"default":"outline",onClick:()=>o({paginationEnabled:!r.paginationEnabled}),children:r.paginationEnabled?"ON":"OFF"})})]}),r.paginationEnabled&&i.jsxs("div",{className:"flex items-center gap-[var(--ui-space-4)]",children:[i.jsxs("label",{htmlFor:"settings-page-size",className:"text-sm whitespace-nowrap",children:[a("settings_page_size"),": ",r.paginationPageSize]}),i.jsx("input",{id:"settings-page-size",type:"range",min:"4",max:"20",step:"1",value:r.paginationPageSize,onChange:l=>o({paginationPageSize:Number(l.target.value)}),className:"w-full cursor-pointer"})]})]}),s&&i.jsx("div",{className:"mt-[var(--ui-space-8)] border-t border-border pt-[var(--ui-space-4)]",children:i.jsx(ie,{variant:"outline",className:"w-full text-destructive hover:bg-destructive/10 hover:border-destructive h-ui",onClick:s,children:"Reset All Settings"})})]})]})}function py(e,t=document.documentElement){e.theme==="dark"?(t.style.setProperty("--background","210 20% 10%"),t.style.setProperty("--foreground","210 30% 96%"),t.style.setProperty("--card","210 20% 16%"),t.style.setProperty("--card-foreground","210 30% 96%"),t.style.setProperty("--popover","210 20% 10%"),t.style.setProperty("--popover-foreground","210 30% 96%"),t.style.setProperty("--primary","200 95% 42%"),t.style.setProperty("--primary-foreground","210 20% 10%"),t.style.setProperty("--secondary","210 20% 22%"),t.style.setProperty("--secondary-foreground","210 30% 96%"),t.style.setProperty("--muted","210 20% 22%"),t.style.setProperty("--muted-foreground","210 15% 60%"),t.style.setProperty("--accent","210 85% 42%"),t.style.setProperty("--accent-foreground","210 30% 96%"),t.style.setProperty("--destructive","0 50% 55%"),t.style.setProperty("--destructive-foreground","0 0% 100%"),t.style.setProperty("--border","210 20% 30%"),t.style.setProperty("--input","210 20% 30%"),t.style.setProperty("--ring","200 95% 42%"),t.setAttribute("data-theme","dark")):(t.style.setProperty("--background","0 0% 100%"),t.style.setProperty("--foreground","210 20% 10%"),t.style.setProperty("--card","0 0% 96%"),t.style.setProperty("--card-foreground","210 20% 10%"),t.style.setProperty("--popover","0 0% 100%"),t.style.setProperty("--popover-foreground","210 20% 10%"),t.style.setProperty("--primary","210 62% 49%"),t.style.setProperty("--primary-foreground","220 30% 15%"),t.style.setProperty("--secondary","210 12% 82%"),t.style.setProperty("--secondary-foreground","210 20% 10%"),t.style.setProperty("--muted","210 12% 82%"),t.style.setProperty("--muted-foreground","210 10% 45%"),t.style.setProperty("--accent","210 12% 82%"),t.style.setProperty("--accent-foreground","210 20% 10%"),t.style.setProperty("--destructive","0 55% 60%"),t.style.setProperty("--destructive-foreground","0 40% 20%"),t.style.setProperty("--border","210 16% 60%"),t.style.setProperty("--input","210 16% 60%"),t.style.setProperty("--ring","210 62% 49%"),t.removeAttribute("data-theme")),t.setAttribute("data-density",e.density),t.style.setProperty("--radius",`${e.borderRadius}px`),t.style.setProperty("--app-font-size",`${e.fontSize}px`),t.style.fontSize=`${e.fontSize}px`}class Mu{applyVariables(t){if(typeof window>"u"||!document.documentElement)return;const r=document.documentElement.style;t.density&&r.setProperty("--ui-density",t.density),t.tabletMode!==void 0&&r.setProperty("--tablet-mode",t.tabletMode?"1":"0"),t.radius!==void 0&&r.setProperty("--radius",`${t.radius}rem`),t.fontSize!==void 0&&r.setProperty("--font-size-base",`${t.fontSize}rem`),t.componentHeight!==void 0&&r.setProperty("--component-height",`${t.componentHeight}rem`),t.listRowHeight!==void 0&&r.setProperty("--list-row-height",`${t.listRowHeight}rem`),t.paddingX!==void 0&&r.setProperty("--padding-x",`${t.paddingX}rem`),t.paddingY!==void 0&&r.setProperty("--padding-y",`${t.paddingY}rem`),t.gap!==void 0&&r.setProperty("--gap",`${t.gap}rem`),t.iconSize!==void 0&&r.setProperty("--icon-size",`${t.iconSize}rem`),t.modalPadding!==void 0&&r.setProperty("--modal-padding",`${t.modalPadding}rem`),t.checkboxSize!==void 0&&r.setProperty("--checkbox-size",`${t.checkboxSize}rem`),t.buttonPaddingX!==void 0&&r.setProperty("--button-padding-x",`${t.buttonPaddingX}rem`),t.buttonPaddingY!==void 0&&r.setProperty("--button-padding-y",`${t.buttonPaddingY}rem`),t.badgePaddingX!==void 0&&r.setProperty("--badge-padding-x",`${t.badgePaddingX}rem`),t.badgePaddingY!==void 0&&r.setProperty("--badge-padding-y",`${t.badgePaddingY}rem`),t.cardPadding!==void 0&&r.setProperty("--card-padding",`${t.cardPadding}rem`),t.drawerWidthLeft!==void 0&&r.setProperty("--drawer-width-left",`${t.drawerWidthLeft}px`),t.drawerWidthRight!==void 0&&r.setProperty("--drawer-width-right",`${t.drawerWidthRight}px`),t.stepCircleSize!==void 0&&r.setProperty("--step-circle-size",`${t.stepCircleSize}rem`),t.switchWidth!==void 0&&r.setProperty("--switch-width",`${t.switchWidth}rem`),t.switchHeight!==void 0&&r.setProperty("--switch-height",`${t.switchHeight}rem`),t.switchThumbSize!==void 0&&r.setProperty("--switch-thumb-size",`${t.switchThumbSize}rem`),t.keypadButtonHeight!==void 0&&r.setProperty("--keypad-button-height",`${t.keypadButtonHeight}rem`)}removeVariables(){if(typeof window>"u"||!document.documentElement)return;const t=document.documentElement.style;t.removeProperty("--ui-density"),t.removeProperty("--tablet-mode"),t.removeProperty("--radius"),t.removeProperty("--font-size-base"),t.removeProperty("--component-height"),t.removeProperty("--list-row-height"),t.removeProperty("--padding-x"),t.removeProperty("--padding-y"),t.removeProperty("--gap"),t.removeProperty("--icon-size"),t.removeProperty("--modal-padding"),t.removeProperty("--checkbox-size"),t.removeProperty("--button-padding-x"),t.removeProperty("--button-padding-y"),t.removeProperty("--badge-padding-x"),t.removeProperty("--badge-padding-y"),t.removeProperty("--card-padding"),t.removeProperty("--drawer-width-left"),t.removeProperty("--drawer-width-right"),t.removeProperty("--step-circle-size"),t.removeProperty("--switch-width"),t.removeProperty("--switch-height"),t.removeProperty("--switch-thumb-size"),t.removeProperty("--keypad-button-height")}}class gy{appliedConfig;applyVariables(t){this.appliedConfig=t}removeVariables(){this.appliedConfig=void 0}reset(){this.appliedConfig=void 0}}const Iu=new Mu,Fu=m.createContext(void 0);function vy(){return m.useContext(Fu)}function yy({config:e={},applier:t=Iu,children:r}){const n=m.useMemo(()=>e,[e]);return m.useEffect(()=>(t.applyVariables(n),()=>{t.removeVariables()}),[n,t]),i.jsx(Fu.Provider,{value:n,children:r})}const xy=vn(["day","week","month"]),by=Le({name:J(),email:J().optional(),personnelId:J().optional(),type:vn(["personnel","external"]).default("external")}),Lu=Le({id:J(),resourceId:J().nullable().optional(),groupId:J(),title:J(),attendee:J(),startDate:Se(),endDate:Se(),status:J(),description:J().optional(),note:J().optional(),color:J().optional(),isAllDay:qe().optional(),extendedProps:ic(J(),Hd()).optional(),hasConflict:qe().optional(),createdAt:Se(),updatedAt:Se()}),wy=Bt(Lu),$u=Le({id:J(),name:J(),order:Ce(),isAvailable:qe(),groupId:J(),createdAt:Se(),updatedAt:Se(),deletedAt:Se().optional()}),_y=Le({id:J(),name:J(),displayMode:vn(["grid","list"]),dimension:Ce(),resources:Bt($u),createdAt:Se(),updatedAt:Se(),deletedAt:Se().optional()}),Vu=Le({id:J().or(Ce()),label:J(),startTime:J(),endTime:J()}),Sy=Le({defaultDuration:Ce(),startTime:J(),endTime:J(),closedDays:Bt(Ce()),weekStartsOn:gs([$t(0),$t(1),$t(2),$t(3),$t(4),$t(5),$t(6)]),timeZone:J().optional(),timeSlots:Bt(Vu).optional(),paginationEnabled:qe().optional(),paginationPageSize:Ce().optional()}),Cy=Le({date:Se(),bookedCount:Ce(),maxSlots:Ce(),density:Ce(),isClosedDay:qe()}),ky=Le({enabled:qe().default(!1),pageSize:Ce().default(8)});function zu({personnel:e,position:t,onClose:r,onSetPriority:n}){const{t:s}=$e(),a=m.useRef(null);if(m.useEffect(()=>{const c=l=>{a.current&&!a.current.contains(l.target)&&r()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),!e||!t)return null;const o=[{label:s("personnel_priority_high"),priority:1,icon:"⬆️"},{label:s("personnel_priority_normal"),priority:0,icon:"➖"},{label:s("personnel_priority_low"),priority:-1,icon:"⬇️"}];return i.jsxs("div",{ref:a,className:"fixed bg-popover border border-border rounded-md shadow-lg py-[var(--ui-space-1)] z-50 min-w-[var(--ui-space-40)]",style:{left:t.x,top:t.y},children:[i.jsx("div",{className:"px-[var(--ui-space-3)] py-[var(--ui-space-1-5)] text-xs text-muted-foreground border-b border-border",children:e.name}),o.map(c=>i.jsxs("button",{type:"button",className:`w-full px-[var(--ui-space-3)] py-[var(--ui-space-2)] text-left text-sm hover:bg-muted flex items-center gap-[var(--ui-space-2)] transition-colors
|
|
90
|
+
`,style:$.color?{backgroundColor:$.color}:{},onClick:O=>{O.stopPropagation(),s?.($)},children:l?.EventCard?o.jsx(l.EventCard,{event:$,viewMode:"week",isCompact:!0,onClick:()=>s?.($)}):$.title},$.id))})},M.toISOString())})]}),o.jsx("div",{className:"flex-1 overflow-y-auto relative",ref:_,children:o.jsxs("div",{className:"flex",style:{minHeight:`${(h-d)*60/f*ft}px`},children:[o.jsx("div",{className:"w-[var(--ui-space-16)] flex-shrink-0 sticky left-[var(--ui-space-0)] z-20 bg-background border-r border-border",children:g.map(M=>o.jsx("div",{className:"border-b border-border text-xs text-muted-foreground p-0 flex items-center justify-end pr-[var(--ui-space-2)] box-border",style:{height:`${ft}px`},children:M},M))}),o.jsx("div",{className:"flex-1 flex",children:w.map((M,A)=>{const $=M.toDateString()===v,O=N[A];return o.jsxs("div",{className:"flex-1 border-r border-border last:border-r-0 relative min-w-[var(--ui-space-0)]",children:[o.jsx(Vu,{interval:f,isToday:$,startHour:d,endHour:h,relative:!0,timeZone:r.timeZone}),g.map(B=>o.jsx("button",{type:"button",onClick:()=>n?.(M,B),className:"border-b border-border cursor-pointer transition-colors hover:bg-muted/30 w-full text-left p-0 m-0 block box-border",style:{height:`${ft}px`},"aria-label":`Time slot ${B}`},`${M.toISOString()}-${B}`)),O?.events.map(({event:B,position:L,column:I,totalColumns:P})=>o.jsx(fs,{event:B,position:L,column:I,totalColumns:P,onEventClick:s,currentUserId:a,resources:i,renderEventContent:c,components:l,viewMode:"week",orientation:"horizontal"},B.id))]},M.toISOString())})})]})})]})})}function zu({events:e,settings:t,currentDate:r,viewMode:n,onDateChange:s,onViewChange:a,onEventClick:i,onEventDrop:c,onTimeSlotClick:l,onDateClick:u,isLoading:f=!1,className:d,headerLeft:h,headerRight:p,defaultView:w="week",enablePersistence:g=!1,storageKey:y="regular-calendar-view",storage:x=Ps,currentUserId:v,resources:_=[],renderEventContent:b,components:S}){const{t:C}=Le(),[j,N]=m.useState(new Date),[E,R]=m.useState(()=>{if(g)try{const V=x.getItem(y);if(V&&["day","week","month"].includes(V))return V}catch(V){console.warn("Failed to load calendar view from storage",V)}return w}),M=r??j,A=n??E;m.useEffect(()=>{if(g&&!n)try{x.setItem(y,E)}catch(V){console.warn("Failed to save calendar view to storage",V)}},[E,g,y,n,x]);const $=V=>{const W=vo(M,A,V);s?s(W):N(W)},O=()=>{const V=new Date;s?s(V):N(V)},B=V=>{a?a(V):R(V)},L=(V,W)=>{const se=new Date(V);if(W){const[ne,fe]=W.split(":").map(Number);Number.isNaN(ne)||se.setHours(ne),Number.isNaN(fe)||se.setMinutes(fe)}l?.(se)},I=V=>{u&&u(V),s?s(V):N(V)},P=Vg(Lg(Co,{activationConstraint:{distance:8}})),[z,H]=m.useState(null),te=V=>{const{active:W}=V,se=e.find(ne=>ne.id===W.id);se&&H(se)},G=V=>{const{active:W,over:se}=V;if(H(null),!se||!c)return;const ne=e.find(Ze=>Ze.id===W.id);if(!ne)return;const fe=se.id,pe=new Date(fe);if(Number.isNaN(pe.getTime()))return;const Ae=fe.includes("T"),xe=new Date(pe);Ae||xe.setHours(ne.startDate.getHours(),ne.startDate.getMinutes()),c(ne,xe)};return o.jsxs($v,{sensors:P,onDragStart:te,onDragEnd:G,children:[o.jsxs("div",{className:`flex flex-col h-full bg-background ${d}`,children:[o.jsxs("header",{className:"border-b border-border px-[var(--ui-space-4)] py-[var(--ui-space-3)] flex items-center justify-between gap-[var(--ui-space-4)]",children:[o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:[o.jsx(oe,{variant:"outline",size:"icon",onClick:()=>$("prev"),children:o.jsx(ye.ChevronLeft,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),o.jsx(oe,{variant:"outline",onClick:O,children:C("today_button")}),o.jsx(oe,{variant:"outline",size:"icon",onClick:()=>$("next"),children:o.jsx(ye.ChevronRight,{className:"h-[var(--ui-space-4)] w-[var(--ui-space-4)]"})}),o.jsx("span",{className:"text-lg font-bold ml-[var(--ui-space-2)]",children:o.jsx(Ot,{date:M,showSecondary:!0,showDayOfWeek:!0})}),h]}),o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-4)]",children:[o.jsx(go,{currentView:A,onViewChange:B,options:[{value:"day",label:C("view_day")},{value:"week",label:C("view_week")},{value:"month",label:C("view_month")}]}),p]})]}),o.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[f&&o.jsx("div",{className:"absolute inset-[var(--ui-space-0)] bg-background/50 z-10 flex items-center justify-center",children:"Loading..."}),A==="day"&&o.jsx(hy,{currentDate:M,events:e,settings:t,onEventClick:i,onTimeSlotClick:L,currentUserId:v,resources:_,renderEventContent:b,components:S}),A==="week"&&o.jsx(py,{currentDate:M,events:e,settings:t,onEventClick:i,onTimeSlotClick:L,currentUserId:v,resources:_,renderEventContent:b,components:S}),A==="month"&&o.jsx(my,{currentDate:M,events:e,settings:t,onEventClick:i,onDateClick:I,currentUserId:v,renderEventContent:b,components:S})]})]}),o.jsx(ny,{children:z?o.jsx(oy,{event:z,currentUserId:v,resources:_}):null})]})}function gy({events:e,resources:t,groups:r,settings:n,isLoading:s,onEventCreate:a,onEventUpdate:i,onEventDelete:c,onToast:l,customFields:u,personnel:f,currentUserId:d,i18n:h}){const[p,w]=m.useState(!1),[g,y]=m.useState(void 0),[x,v]=m.useState(void 0),_={...n,defaultDuration:30},b=e,S=R=>{v(R),y(void 0),w(!0)},C=R=>{y(R),v(void 0),w(!0)},j=()=>{w(!1),y(void 0),v(void 0)},N=async R=>{try{g?(await i(g.id,R),l?.("Event updated successfully","success")):(await a(R),l?.("Event created successfully","success")),j()}catch(M){console.error("Failed to save event",M),l?.("Failed to save event","error")}},E=async R=>{try{await c(R),l?.("Event deleted successfully","success"),j()}catch(M){console.error("Failed to delete event",M),l?.("Failed to delete event","error")}};return o.jsxs(o.Fragment,{children:[o.jsx(zu,{events:b,settings:_,isLoading:s,onEventClick:C,onTimeSlotClick:S,onDateClick:S,enablePersistence:!0,defaultView:"week",storageKey:"regular-calendar-view",currentUserId:d,resources:t}),o.jsx(gu,{isOpen:p,onClose:j,onSave:N,onDelete:()=>{g?.id&&E(g.id)},event:g,defaultStartTime:x,resources:t,groups:r,events:e,personnel:f,currentUserId:d,customFields:u})]})}const Gi=[...Array.from({length:24},(e,t)=>`${t.toString().padStart(2,"0")}:00`),"24:00","25:00","26:00","27:00","28:00","29:00","30:00"];function vy({isOpen:e,onClose:t,settings:r,onUpdateSettings:n,onResetSettings:s}){const{t:a}=Le();if(!e)return null;const i=l=>{n(l)},c=[a("days_short_sun"),a("days_short_mon"),a("days_short_tue"),a("days_short_wed"),a("days_short_thu"),a("days_short_fri"),a("days_short_sat")];return o.jsxs("div",{className:"fixed inset-[var(--ui-space-0)] z-[9999] flex items-center justify-center bg-black/50 p-[var(--ui-space-4)]",children:[o.jsx("button",{type:"button","aria-label":a("close"),onClick:t,className:"absolute inset-[var(--ui-space-0)] border-none bg-transparent p-[var(--ui-space-0)] m-[var(--ui-space-0)] w-full h-full cursor-default"}),o.jsxs("div",{className:"relative z-10 w-full max-w-[var(--ui-space-125)] max-h-[var(--ui-space-90vh)] overflow-y-auto rounded-lg border border-border bg-background text-foreground shadow-xl p-[var(--ui-space-6)]",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-border pb-[var(--ui-space-4)] mb-[var(--ui-space-6)]",children:[o.jsx("h2",{className:"m-[var(--ui-space-0)] text-xl font-bold",children:a("settings_title")}),o.jsx(oe,{variant:"ghost",size:"icon",onClick:t,children:"✕"})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_language")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["ja","en"].map(l=>o.jsx(oe,{variant:r.language===l?"default":"outline",onClick:()=>i({language:l}),children:l==="ja"?"日本語":"English"},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("label",{htmlFor:"settings-timezone",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:"TimeZone"}),o.jsxs("select",{id:"settings-timezone",value:r.timeZone||"Asia/Tokyo",onChange:l=>i({timeZone:l.target.value}),className:"h-ui w-full rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[o.jsx("option",{value:"Asia/Tokyo",children:"Asia/Tokyo (JST)"}),o.jsx("option",{value:"UTC",children:"UTC"}),o.jsx("option",{value:"America/New_York",children:"America/New_York (ET)"}),o.jsx("option",{value:"Europe/London",children:"Europe/London (GMT/BST)"}),o.jsx("option",{value:"Asia/Shanghai",children:"Asia/Shanghai (CST)"})]})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_theme")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["light","dark"].map(l=>o.jsx(oe,{variant:r.theme===l?"default":"outline",onClick:()=>i({theme:l}),children:a(l==="light"?"option_light":"option_dark")},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_density")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["compact","normal","spacious"].map(l=>o.jsx(oe,{variant:r.density===l?"default":"outline",onClick:()=>i({density:l}),children:a(l==="compact"?"option_compact":l==="normal"?"option_normal":"option_spacious")},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_calendar_orientation","Calendar Orientation")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["horizontal","vertical"].map(l=>o.jsx(oe,{variant:r.calendarOrientation===l?"default":"outline",onClick:()=>i({calendarOrientation:l}),children:l==="horizontal"?a("option_horizontal","Horizontal"):a("option_vertical","Vertical")},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_calendar_interval","Calendar Slot Interval")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:[15,30,60,120].map(l=>o.jsxs(oe,{variant:r.calendarSlotInterval===l?"default":"outline",onClick:()=>i({calendarSlotInterval:l}),children:[l===15&&a("option_15m","15m"),l===30&&a("option_30m","30m"),l===60&&a("option_1h","1h"),l===120&&a("option_2h","2h")]},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_facility_orientation","Facility Orientation")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:["horizontal","vertical"].map(l=>o.jsx(oe,{variant:r.facilityOrientation===l?"default":"outline",onClick:()=>i({facilityOrientation:l}),children:l==="horizontal"?a("option_horizontal","Horizontal"):a("option_vertical","Vertical")},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_facility_interval","Facility Slot Interval")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:[15,30,60,120].map(l=>o.jsxs(oe,{variant:r.facilitySlotInterval===l?"default":"outline",onClick:()=>i({facilitySlotInterval:l}),children:[l===15&&a("option_15m","15m"),l===30&&a("option_30m","30m"),l===60&&a("option_1h","1h"),l===120&&a("option_2h","2h")]},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsxs("label",{htmlFor:"settings-radius",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:[a("settings_radius"),": ",r.borderRadius,"px"]}),o.jsx("input",{id:"settings-radius",type:"range",min:"0",max:"16",value:r.borderRadius,onChange:l=>i({borderRadius:Number(l.target.value)}),className:"w-full cursor-pointer"})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsxs("label",{htmlFor:"settings-font-size",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:[a("settings_font_size"),": ",r.fontSize,"px"]}),o.jsx("input",{id:"settings-font-size",type:"range",min:"12",max:"20",value:r.fontSize,onChange:l=>i({fontSize:Number(l.target.value)}),className:"w-full cursor-pointer"})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("label",{htmlFor:"settings-week-start",className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_week_start")}),o.jsxs("select",{id:"settings-week-start",value:r.weekStartsOn,onChange:l=>i({weekStartsOn:Number(l.target.value)}),className:"h-ui w-full rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[o.jsx("option",{value:0,children:a("option_sunday")}),o.jsx("option",{value:1,children:a("option_monday")})]})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_business_hours")}),o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:[o.jsx("select",{value:r.businessHoursStart,onChange:l=>i({businessHoursStart:l.target.value}),className:"h-ui flex-1 rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:Gi.map(l=>o.jsx("option",{value:l,children:l},l))}),o.jsx("span",{children:"〜"}),o.jsx("select",{value:r.businessHoursEnd,onChange:l=>i({businessHoursEnd:l.target.value}),className:"h-ui flex-1 rounded-md border border-input bg-background px-[var(--ui-space-3)] py-[var(--ui-space-1)] text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:Gi.map(l=>o.jsx("option",{value:l,children:l},l))})]})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsx("div",{className:"block mb-[var(--ui-space-2)] text-sm font-bold",children:a("settings_closed_days")}),o.jsx("div",{className:"flex flex-wrap gap-[var(--ui-space-2)]",children:c.map((l,u)=>o.jsx(oe,{variant:r.closedDays.includes(u)?"destructive":"outline",size:"sm",onClick:()=>{const f=r.closedDays.includes(u)?r.closedDays.filter(d=>d!==u):[...r.closedDays,u];i({closedDays:f})},className:"w-[var(--ui-space-10)] h-[var(--ui-space-10)] p-[var(--ui-space-0)]",children:l},l))})]}),o.jsxs("div",{className:"mb-[var(--ui-space-6)]",children:[o.jsxs("div",{className:"flex items-center justify-between mb-[var(--ui-space-2)]",children:[o.jsx("div",{className:"text-sm font-bold",children:a("settings_pagination")}),o.jsx("div",{className:"flex items-center gap-[var(--ui-space-2)]",children:o.jsx(oe,{variant:r.paginationEnabled?"default":"outline",onClick:()=>i({paginationEnabled:!r.paginationEnabled}),children:r.paginationEnabled?"ON":"OFF"})})]}),r.paginationEnabled&&o.jsxs("div",{className:"flex items-center gap-[var(--ui-space-4)]",children:[o.jsxs("label",{htmlFor:"settings-page-size",className:"text-sm whitespace-nowrap",children:[a("settings_page_size"),": ",r.paginationPageSize]}),o.jsx("input",{id:"settings-page-size",type:"range",min:"4",max:"20",step:"1",value:r.paginationPageSize,onChange:l=>i({paginationPageSize:Number(l.target.value)}),className:"w-full cursor-pointer"})]})]}),s&&o.jsx("div",{className:"mt-[var(--ui-space-8)] border-t border-border pt-[var(--ui-space-4)]",children:o.jsx(oe,{variant:"outline",className:"w-full text-destructive hover:bg-destructive/10 hover:border-destructive h-ui",onClick:s,children:"Reset All Settings"})})]})]})}function yy(e,t=document.documentElement){e.theme==="dark"?(t.style.setProperty("--background","210 20% 10%"),t.style.setProperty("--foreground","210 30% 96%"),t.style.setProperty("--card","210 20% 16%"),t.style.setProperty("--card-foreground","210 30% 96%"),t.style.setProperty("--popover","210 20% 10%"),t.style.setProperty("--popover-foreground","210 30% 96%"),t.style.setProperty("--primary","200 95% 42%"),t.style.setProperty("--primary-foreground","210 20% 10%"),t.style.setProperty("--secondary","210 20% 22%"),t.style.setProperty("--secondary-foreground","210 30% 96%"),t.style.setProperty("--muted","210 20% 22%"),t.style.setProperty("--muted-foreground","210 15% 60%"),t.style.setProperty("--accent","210 85% 42%"),t.style.setProperty("--accent-foreground","210 30% 96%"),t.style.setProperty("--destructive","0 50% 55%"),t.style.setProperty("--destructive-foreground","0 0% 100%"),t.style.setProperty("--border","210 20% 30%"),t.style.setProperty("--input","210 20% 30%"),t.style.setProperty("--ring","200 95% 42%"),t.setAttribute("data-theme","dark")):(t.style.setProperty("--background","0 0% 100%"),t.style.setProperty("--foreground","210 20% 10%"),t.style.setProperty("--card","0 0% 96%"),t.style.setProperty("--card-foreground","210 20% 10%"),t.style.setProperty("--popover","0 0% 100%"),t.style.setProperty("--popover-foreground","210 20% 10%"),t.style.setProperty("--primary","210 62% 49%"),t.style.setProperty("--primary-foreground","220 30% 15%"),t.style.setProperty("--secondary","210 12% 82%"),t.style.setProperty("--secondary-foreground","210 20% 10%"),t.style.setProperty("--muted","210 12% 82%"),t.style.setProperty("--muted-foreground","210 10% 45%"),t.style.setProperty("--accent","210 12% 82%"),t.style.setProperty("--accent-foreground","210 20% 10%"),t.style.setProperty("--destructive","0 55% 60%"),t.style.setProperty("--destructive-foreground","0 40% 20%"),t.style.setProperty("--border","210 16% 60%"),t.style.setProperty("--input","210 16% 60%"),t.style.setProperty("--ring","210 62% 49%"),t.removeAttribute("data-theme")),t.setAttribute("data-density",e.density),t.style.setProperty("--radius",`${e.borderRadius}px`),t.style.setProperty("--app-font-size",`${e.fontSize}px`),t.style.fontSize=`${e.fontSize}px`}class Hu{applyVariables(t){if(typeof window>"u"||!document.documentElement)return;const r=document.documentElement.style;t.density&&r.setProperty("--ui-density",t.density),t.tabletMode!==void 0&&r.setProperty("--tablet-mode",t.tabletMode?"1":"0"),t.radius!==void 0&&r.setProperty("--radius",`${t.radius}rem`),t.fontSize!==void 0&&r.setProperty("--font-size-base",`${t.fontSize}rem`),t.componentHeight!==void 0&&r.setProperty("--component-height",`${t.componentHeight}rem`),t.listRowHeight!==void 0&&r.setProperty("--list-row-height",`${t.listRowHeight}rem`),t.paddingX!==void 0&&r.setProperty("--padding-x",`${t.paddingX}rem`),t.paddingY!==void 0&&r.setProperty("--padding-y",`${t.paddingY}rem`),t.gap!==void 0&&r.setProperty("--gap",`${t.gap}rem`),t.iconSize!==void 0&&r.setProperty("--icon-size",`${t.iconSize}rem`),t.modalPadding!==void 0&&r.setProperty("--modal-padding",`${t.modalPadding}rem`),t.checkboxSize!==void 0&&r.setProperty("--checkbox-size",`${t.checkboxSize}rem`),t.buttonPaddingX!==void 0&&r.setProperty("--button-padding-x",`${t.buttonPaddingX}rem`),t.buttonPaddingY!==void 0&&r.setProperty("--button-padding-y",`${t.buttonPaddingY}rem`),t.badgePaddingX!==void 0&&r.setProperty("--badge-padding-x",`${t.badgePaddingX}rem`),t.badgePaddingY!==void 0&&r.setProperty("--badge-padding-y",`${t.badgePaddingY}rem`),t.cardPadding!==void 0&&r.setProperty("--card-padding",`${t.cardPadding}rem`),t.drawerWidthLeft!==void 0&&r.setProperty("--drawer-width-left",`${t.drawerWidthLeft}px`),t.drawerWidthRight!==void 0&&r.setProperty("--drawer-width-right",`${t.drawerWidthRight}px`),t.stepCircleSize!==void 0&&r.setProperty("--step-circle-size",`${t.stepCircleSize}rem`),t.switchWidth!==void 0&&r.setProperty("--switch-width",`${t.switchWidth}rem`),t.switchHeight!==void 0&&r.setProperty("--switch-height",`${t.switchHeight}rem`),t.switchThumbSize!==void 0&&r.setProperty("--switch-thumb-size",`${t.switchThumbSize}rem`),t.keypadButtonHeight!==void 0&&r.setProperty("--keypad-button-height",`${t.keypadButtonHeight}rem`)}removeVariables(){if(typeof window>"u"||!document.documentElement)return;const t=document.documentElement.style;t.removeProperty("--ui-density"),t.removeProperty("--tablet-mode"),t.removeProperty("--radius"),t.removeProperty("--font-size-base"),t.removeProperty("--component-height"),t.removeProperty("--list-row-height"),t.removeProperty("--padding-x"),t.removeProperty("--padding-y"),t.removeProperty("--gap"),t.removeProperty("--icon-size"),t.removeProperty("--modal-padding"),t.removeProperty("--checkbox-size"),t.removeProperty("--button-padding-x"),t.removeProperty("--button-padding-y"),t.removeProperty("--badge-padding-x"),t.removeProperty("--badge-padding-y"),t.removeProperty("--card-padding"),t.removeProperty("--drawer-width-left"),t.removeProperty("--drawer-width-right"),t.removeProperty("--step-circle-size"),t.removeProperty("--switch-width"),t.removeProperty("--switch-height"),t.removeProperty("--switch-thumb-size"),t.removeProperty("--keypad-button-height")}}class xy{appliedConfig;applyVariables(t){this.appliedConfig=t}removeVariables(){this.appliedConfig=void 0}reset(){this.appliedConfig=void 0}}const Bu=new Hu,Wu=m.createContext(void 0);function by(){return m.useContext(Wu)}function wy({config:e={},applier:t=Bu,children:r}){const n=m.useMemo(()=>e,[e]);return m.useEffect(()=>(t.applyVariables(n),()=>{t.removeVariables()}),[n,t]),o.jsx(Wu.Provider,{value:n,children:r})}const _y=_r(["day","week","month"]),Sy=Fe({name:J(),email:J().optional(),personnelId:J().optional(),type:_r(["personnel","external"]).default("external")}),Uu=Fe({id:J(),resourceId:J().nullable().optional(),groupId:J(),title:J(),attendee:J(),startDate:ke(),endDate:ke(),status:J(),description:J().optional(),note:J().optional(),color:J().optional(),isAllDay:qe().optional(),extendedProps:vc(J(),Kd()).optional(),hasConflict:qe().optional(),createdAt:ke(),updatedAt:ke()}),ky=Zt(Uu),Zu=Fe({id:J(),name:J(),order:we(),isAvailable:qe(),groupId:J(),createdAt:ke(),updatedAt:ke(),deletedAt:ke().optional()}),Cy=Fe({id:J(),name:J(),displayMode:_r(["grid","list"]),dimension:we(),resources:Zt(Zu),createdAt:ke(),updatedAt:ke(),deletedAt:ke().optional()}),Yu=Fe({id:J().or(we()),label:J(),startTime:J(),endTime:J()}),jy=Fe({defaultDuration:we(),startTime:J(),endTime:J(),closedDays:Zt(we()),weekStartsOn:ys([Bt(0),Bt(1),Bt(2),Bt(3),Bt(4),Bt(5),Bt(6)]),timeZone:J().optional(),timeSlots:Zt(Yu).optional(),paginationEnabled:qe().optional(),paginationPageSize:we().optional(),orientation:_r(["horizontal","vertical"]).optional(),slotInterval:we().optional()}),Dy=Fe({date:ke(),bookedCount:we(),maxSlots:we(),density:we(),isClosedDay:qe()}),Ny=Fe({enabled:qe().default(!1),pageSize:we().default(8)});function Gu({personnel:e,position:t,onClose:r,onSetPriority:n}){const{t:s}=Le(),a=m.useRef(null);if(m.useEffect(()=>{const c=l=>{a.current&&!a.current.contains(l.target)&&r()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),!e||!t)return null;const i=[{label:s("personnel_priority_high"),priority:1,icon:"⬆️"},{label:s("personnel_priority_normal"),priority:0,icon:"➖"},{label:s("personnel_priority_low"),priority:-1,icon:"⬇️"}];return o.jsxs("div",{ref:a,className:"fixed bg-popover border border-border rounded-md shadow-lg py-[var(--ui-space-1)] z-50 min-w-[var(--ui-space-40)]",style:{left:t.x,top:t.y},children:[o.jsx("div",{className:"px-[var(--ui-space-3)] py-[var(--ui-space-1-5)] text-xs text-muted-foreground border-b border-border",children:e.name}),i.map(c=>o.jsxs("button",{type:"button",className:`w-full px-[var(--ui-space-3)] py-[var(--ui-space-2)] text-left text-sm hover:bg-muted flex items-center gap-[var(--ui-space-2)] transition-colors
|
|
90
91
|
${e.priority===c.priority?"text-primary font-medium":"text-foreground"}
|
|
91
|
-
`,onClick:()=>{n(e.id,c.priority),r()},children:[i.jsx("span",{children:c.icon}),i.jsx("span",{children:c.label}),e.priority===c.priority&&i.jsx("span",{className:"ml-auto text-primary",children:"✓"})]},c.priority))]})}function Dy({personnel:e,selectedIds:t,onSelectionChange:r,onPriorityChange:n,className:s="",colorMap:a=new Map}){const{t:o}=$e(),[c,l]=m.useState(""),[u,f]=m.useState({personnel:null,position:null}),d=m.useMemo(()=>{if(!c.trim())return e;const y=c.toLowerCase();return e.filter(v=>v.name.toLowerCase().includes(y)||v.email.toLowerCase().includes(y))},[e,c]),h=m.useMemo(()=>{const y=d.filter(C=>C.priority===1),v=d.filter(C=>C.priority===0),b=d.filter(C=>C.priority===-1);return{high:y,normal:v,low:b}},[d]),p=y=>{t.includes(y)?r(t.filter(v=>v!==y)):r([...t,y])},w=(y,v)=>{y.preventDefault(),f({personnel:v,position:{x:y.clientX,y:y.clientY}})},g=y=>{const v=t.includes(y.id),b=a.get(y.id);return i.jsxs("button",{type:"button",className:`flex items-center gap-[var(--ui-space-2)] px-[var(--ui-space-2)] py-[var(--ui-space-1-5)] rounded cursor-pointer text-sm transition-colors ${v?"border":"hover:bg-muted/50 border border-transparent"}`,style:v&&b?{backgroundColor:`${b}20`,borderColor:b}:{},onClick:()=>p(y.id),onContextMenu:C=>w(C,y),children:[v&&b?i.jsx("div",{className:"w-[var(--ui-space-4)] h-[var(--ui-space-4)] rounded-sm flex-shrink-0",style:{backgroundColor:b}}):i.jsx("div",{className:"w-[var(--ui-space-4)] h-[var(--ui-space-4)] rounded border border-border flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-[var(--ui-space-0)]",children:[i.jsx("div",{className:"truncate font-medium",children:y.name}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",children:y.department})]}),y.priority===1&&i.jsx("span",{className:"text-xs",title:o("personnel_priority_high"),children:"⬆️"}),y.priority===-1&&i.jsx("span",{className:"text-xs",title:o("personnel_priority_low"),children:"⬇️"})]},y.id)};return i.jsxs("div",{className:`flex flex-col h-full bg-background border-r border-border ${s}`,children:[i.jsxs("div",{className:"p-[var(--ui-space-2)] border-b border-border",children:[i.jsx("div",{className:"text-sm font-semibold mb-[var(--ui-space-2)]",children:o("personnel_list_title")}),i.jsx("input",{type:"text",placeholder:o("personnel_search_placeholder"),value:c,onChange:y=>l(y.target.value),className:"w-full px-[var(--ui-space-2)] py-[var(--ui-space-1-5)] text-sm border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-[var(--ui-space-1)]",children:[h.high.length>0&&i.jsxs("div",{className:"mb-[var(--ui-space-2)]",children:[i.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-1)] text-xs font-semibold text-muted-foreground",children:o("personnel_priority_high")}),h.high.map(g)]}),h.normal.length>0&&i.jsxs("div",{className:"mb-[var(--ui-space-2)]",children:[h.high.length>0&&i.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-1)] text-xs font-semibold text-muted-foreground",children:o("personnel_priority_normal")}),h.normal.map(g)]}),h.low.length>0&&i.jsxs("div",{className:"mb-[var(--ui-space-2)]",children:[i.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-1)] text-xs font-semibold text-muted-foreground",children:o("personnel_priority_low")}),h.low.map(g)]}),d.length===0&&i.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-4)] text-center text-sm text-muted-foreground",children:o("personnel_no_results")})]}),i.jsx("div",{className:"p-[var(--ui-space-2)] border-t border-border text-xs text-muted-foreground",children:t.length>0?o("personnel_selected_count",{count:t.length,defaultValue:`${t.length} selected`}):o("personnel_context_hint")}),i.jsx(zu,{personnel:u.personnel,position:u.position,onClose:()=>f({personnel:null,position:null}),onSetPriority:n})]})}function jy({children:e,defaultWidth:t=256,minWidth:r=180,maxWidth:n=400,storageKey:s,storage:a=Rs,className:o=""}){const[c,l]=m.useState(()=>{if(s){const h=a.getItem(s);if(h){const p=parseInt(h,10);if(!Number.isNaN(p)&&p>=r&&p<=n)return p}}return t}),u=m.useRef(!1),f=m.useRef(null);m.useEffect(()=>{s&&a.setItem(s,String(c))},[c,s,a]);const d=m.useCallback(h=>{h.preventDefault(),u.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);return m.useEffect(()=>{const h=w=>{if(!u.current||!f.current)return;const g=f.current.getBoundingClientRect(),y=w.clientX-g.left;y>=r&&y<=n&&l(y)},p=()=>{u.current&&(u.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",h),document.addEventListener("mouseup",p),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}},[r,n]),i.jsxs("div",{ref:f,className:`relative flex-shrink-0 ${o}`,style:{width:c},children:[e,i.jsx("button",{type:"button","aria-label":"Resize",className:"absolute right-[var(--ui-space-0)] top-[var(--ui-space-0)] bottom-[var(--ui-space-0)] w-[var(--ui-space-1)] cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors z-10",onMouseDown:d})]})}const Ny=vn(["day","week","month"]),Bu=Le({id:J(),resourceId:J(),groupId:J(),title:J(),attendee:J(),startDate:Se(),endDate:Se(),status:J(),description:J().optional(),note:J().optional(),color:J().optional(),extendedProps:ic(J(),oc()).optional(),isAllDay:qe().optional(),hasConflict:qe().optional(),createdAt:Se(),updatedAt:Se()}),Ey=Bt(Bu),Hu=Le({id:J(),name:J(),order:Ce(),isAvailable:qe(),groupId:J(),createdAt:Se(),updatedAt:Se(),deletedAt:Se().optional()}),Ay=Le({id:J(),name:J(),displayMode:vn(["grid","list"]),dimension:Ce(),resources:Bt(Hu),createdAt:Se(),updatedAt:Se(),deletedAt:Se().optional()}),Wu=Le({id:J().or(Ce()),label:J(),startTime:J(),endTime:J()}),Ry=Le({defaultDuration:Ce(),startTime:J(),endTime:J(),closedDays:Bt(Ce()),weekStartsOn:gs([$t(0),$t(1)]),timeZone:J().optional(),businessHoursStart:J().optional(),businessHoursEnd:J().optional(),timeSlots:Bt(Wu).optional()}),Ty=Le({date:Se(),bookedCount:Ce(),maxSlots:Ce(),density:Ce(),isClosedDay:qe()}),Py=Object.freeze(Object.defineProperty({__proto__:null,DensityDataSchema:Ty,FacilityScheduleSettingsSchema:Ry,ResourceGroupSchema:Ay,ResourceSchema:Hu,ScheduleEventArraySchema:Ey,ScheduleEventSchema:Bu,TimeSlotSchema:Wu,ViewModeSchema:Ny},Symbol.toStringTag,{value:"Module"})),Oy={theme:"light",density:"normal",borderRadius:8,fontSize:16,weekStartsOn:1,businessHoursStart:"08:00",businessHoursEnd:"18:00",closedDays:[0,6],language:"ja",timeZone:"Asia/Tokyo",paginationEnabled:!1,paginationPageSize:8};exports.AttendeeInfoSchema=by;exports.AttendeeInput=Sa;exports.BrowserStorage=Xl;exports.Button=ie;exports.Checkbox=ln;exports.ConfirmModal=ro;exports.DEFAULT_SETTINGS=Oy;exports.DOMThemeApplier=Mu;exports.DateDisplay=tr;exports.DatePicker=Ka;exports.DefaultEventModal=cu;exports.DensityDataSchema=Cy;exports.EventForm=Hl;exports.EventModal=lo;exports.FacilitySchedule=Jl;exports.FacilityScheduleManager=vg;exports.FacilityScheduleSettingsSchema=Sy;exports.FacilityStructureSettings=yg;exports.Form=Ja;exports.FormControl=be;exports.FormField=Te;exports.FormItem=je;exports.FormLabel=we;exports.FormMessage=nt;exports.Icons=ye;exports.InMemoryStorage=fg;exports.Input=vt;exports.KeypadModal=js;exports.MockThemeApplier=gy;exports.Modal=Wr;exports.PERSONNEL_COLORS=ya;exports.PaginationOptionsSchema=ky;exports.PersonnelContextMenu=zu;exports.PersonnelPanel=Dy;exports.RegularCalendar=Ou;exports.RegularCalendarSchema=Py;exports.ResizablePanel=jy;exports.ResourceGroupSchema=_y;exports.ResourceSchema=$u;exports.ScheduleEventArraySchema=wy;exports.ScheduleEventSchema=Lu;exports.ScheduleManager=hy;exports.ScheduleProvider=Bp;exports.Select=Vt;exports.SelectContent=Rt;exports.SelectItem=ut;exports.SelectTrigger=Et;exports.SelectValue=At;exports.SettingsModal=my;exports.Textarea=fn;exports.ThemeProvider=yy;exports.TimeSlotSchema=Vu;exports.ViewModeSchema=xy;exports.ViewSelector=fo;exports.applyThemeSettings=py;exports.buttonVariants=rn;exports.calculateViewRange=zl;exports.checkScheduleConflict=no;exports.cleanEventId=mg;exports.createPersonnelColorMap=hg;exports.defaultStorage=Rs;exports.defaultThemeApplier=Iu;exports.detectAndMarkConflicts=Lp;exports.filterEventsByDateRange=Es;exports.filterEventsByDay=Pp;exports.filterEventsByResource=$l;exports.formatCalendarDate=Ne;exports.formatEventTitleWithAttendees=Ql;exports.generateDateRange=ao;exports.getEventDisplayText=Ip;exports.getEventDuration=Mp;exports.getMonthEnd=Vl;exports.getMonthStart=co;exports.getPersonnelColor=mo;exports.getResourceAvailability=Fl;exports.getToday=dg;exports.getWeekEnd=io;exports.getWeekStart=As;exports.hasTimeOverlap=Ns;exports.mergeEvents=pg;exports.navigateDate=ho;exports.normalizeWeekStartsOn=oo;exports.parseAttendeeNames=eu;exports.parseAttendees=Ol;exports.prepareEventFormData=iu;exports.resolveEventOwnerId=tu;exports.sortEventsByTime=so;exports.sortResourcesByOrder=Op;exports.stringifyAttendees=Ml;exports.transformBookingsToEvents=ru;exports.useAttendeeManagement=Il;exports.useAvailableResources=au;exports.useConflictCheck=su;exports.useEventForm=nu;exports.useFormField=ks;exports.useResourceAvailability=Ll;exports.useResourceDisplayNames=ou;exports.useScheduleConflict=Bl;exports.useScheduleContext=Ul;exports.useScheduleData=Gl;exports.useScheduleEventHandlers=ql;exports.useScheduleView=Kl;exports.useTheme=vy;
|
|
92
|
+
`,onClick:()=>{n(e.id,c.priority),r()},children:[o.jsx("span",{children:c.icon}),o.jsx("span",{children:c.label}),e.priority===c.priority&&o.jsx("span",{className:"ml-auto text-primary",children:"✓"})]},c.priority))]})}function Ey({personnel:e,selectedIds:t,onSelectionChange:r,onPriorityChange:n,className:s="",colorMap:a=new Map}){const{t:i}=Le(),[c,l]=m.useState(""),[u,f]=m.useState(!1),[d,h]=m.useState({personnel:null,position:null}),p=m.useMemo(()=>{const _=new Set(e.map(b=>b.department).filter(Boolean));return Array.from(_).sort()},[e]),w=m.useMemo(()=>{if(!c.trim())return e;const _=c.toLowerCase();return e.filter(b=>b.name.toLowerCase().includes(_)||b.department?.toLowerCase().includes(_))},[e,c]),g=m.useMemo(()=>{const _=w.filter(C=>C.priority===1),b=w.filter(C=>C.priority===0),S=w.filter(C=>C.priority===-1);return{high:_,normal:b,low:S}},[w]),y=_=>{t.includes(_)?r(t.filter(b=>b!==_)):r([...t,_])},x=(_,b)=>{_.preventDefault(),h({personnel:b,position:{x:_.clientX,y:_.clientY}})},v=_=>{const b=t.includes(_.id),S=a.get(_.id);return o.jsxs("button",{type:"button",className:`flex items-center gap-[var(--ui-space-2)] px-[var(--ui-space-2)] py-[var(--ui-space-1-5)] rounded cursor-pointer text-sm transition-colors w-full ${b?"border":"hover:bg-muted/50 border border-transparent"}`,style:b&&S?{backgroundColor:`${S}20`,borderColor:S}:{},onClick:()=>y(_.id),onContextMenu:C=>x(C,_),children:[b&&S?o.jsx("div",{className:"w-[var(--ui-space-3)] h-[var(--ui-space-3)] rounded-full flex-shrink-0",style:{backgroundColor:S}}):o.jsx("div",{className:"w-[var(--ui-space-3)] h-[var(--ui-space-3)] rounded-full flex-shrink-0 bg-transparent"}),o.jsxs("div",{className:"flex-1 min-w-[var(--ui-space-0)] text-left",children:[o.jsx("div",{className:"truncate font-medium",children:_.name}),o.jsx("div",{className:"truncate text-xs text-muted-foreground",children:_.department})]}),_.priority===1&&o.jsx("span",{className:"text-xs",title:i("personnel_priority_high"),children:"⬆️"}),_.priority===-1&&o.jsx("span",{className:"text-xs",title:i("personnel_priority_low"),children:"⬇️"})]},_.id)};return o.jsxs("div",{className:`flex flex-col h-full bg-background border-r border-border ${s}`,children:[o.jsxs("div",{className:"p-[var(--ui-space-2)] border-b border-border space-y-[var(--ui-space-2)]",children:[o.jsx("div",{className:"text-sm font-semibold",children:i("personnel_list_title")}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"text",placeholder:i("personnel_search_placeholder"),value:c,onChange:_=>l(_.target.value),onFocus:()=>f(!0),onBlur:()=>setTimeout(()=>f(!1),200),className:"w-full px-[var(--ui-space-2)] py-[var(--ui-space-1-5)] text-sm border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary"}),u&&o.jsx("div",{className:"absolute top-full left-0 w-full mt-1 bg-popover border border-border rounded shadow-lg z-50 max-h-48 overflow-y-auto",children:o.jsx("div",{className:"p-1",children:(()=>{if(!c.trim())return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground",children:i("personnel_all_departments")}),p.map(C=>o.jsx("button",{type:"button",className:"w-full text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground rounded-sm cursor-pointer",onClick:()=>l(C),children:C},C))]});const _=c.toLowerCase(),b=e.filter(C=>C.name.toLowerCase().includes(_));if(b.length>0)return b.map(C=>o.jsxs("button",{type:"button",className:"w-full text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground rounded-sm cursor-pointer",onClick:()=>l(C.name),children:[o.jsx("span",{className:"font-medium",children:C.name}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["(",C.department,")"]})]},C.id));const S=p.filter(C=>C.toLowerCase().includes(_));return S.length>0?S.map(C=>o.jsx("button",{type:"button",className:"w-full text-left px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground rounded-sm cursor-pointer",onClick:()=>l(C),children:C},C)):o.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground text-center",children:i("personnel_no_results")})})()})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-[var(--ui-space-1)]",children:[g.high.length>0&&o.jsxs("div",{className:"mb-[var(--ui-space-2)]",children:[o.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-1)] text-xs font-semibold text-muted-foreground",children:i("personnel_priority_high")}),g.high.map(v)]}),g.normal.length>0&&o.jsxs("div",{className:"mb-[var(--ui-space-2)]",children:[g.high.length>0&&o.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-1)] text-xs font-semibold text-muted-foreground",children:i("personnel_priority_normal")}),g.normal.map(v)]}),g.low.length>0&&o.jsxs("div",{className:"mb-[var(--ui-space-2)]",children:[o.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-1)] text-xs font-semibold text-muted-foreground",children:i("personnel_priority_low")}),g.low.map(v)]}),w.length===0&&o.jsx("div",{className:"px-[var(--ui-space-2)] py-[var(--ui-space-4)] text-center text-sm text-muted-foreground",children:i("personnel_no_results")})]}),o.jsx("div",{className:"p-[var(--ui-space-2)] border-t border-border text-xs text-muted-foreground",children:t.length>0?i("personnel_selected_count",{count:t.length,defaultValue:`${t.length} selected`}):i("personnel_context_hint")}),o.jsx(Gu,{personnel:d.personnel,position:d.position,onClose:()=>h({personnel:null,position:null}),onSetPriority:n})]})}function Ay({children:e,defaultWidth:t=256,minWidth:r=180,maxWidth:n=400,storageKey:s,storage:a=Ps,className:i=""}){const[c,l]=m.useState(()=>{if(s){const h=a.getItem(s);if(h){const p=parseInt(h,10);if(!Number.isNaN(p)&&p>=r&&p<=n)return p}}return t}),u=m.useRef(!1),f=m.useRef(null);m.useEffect(()=>{s&&a.setItem(s,String(c))},[c,s,a]);const d=m.useCallback(h=>{h.preventDefault(),u.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);return m.useEffect(()=>{const h=w=>{if(!u.current||!f.current)return;const g=f.current.getBoundingClientRect(),y=w.clientX-g.left;y>=r&&y<=n&&l(y)},p=()=>{u.current&&(u.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",h),document.addEventListener("mouseup",p),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}},[r,n]),o.jsxs("div",{ref:f,className:`relative flex-shrink-0 ${i}`,style:{width:c},children:[e,o.jsx("button",{type:"button","aria-label":"Resize",className:"absolute right-[var(--ui-space-0)] top-[var(--ui-space-0)] bottom-[var(--ui-space-0)] w-[var(--ui-space-1)] cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors z-10",onMouseDown:d})]})}const Ty=_r(["day","week","month"]),qu=_r(["horizontal","vertical"]),Xu=Fe({id:J(),resourceId:J(),groupId:J(),title:J(),attendee:J(),startDate:ke(),endDate:ke(),status:J(),description:J().optional(),note:J().optional(),color:J().optional(),extendedProps:vc(J(),gc()).optional(),isAllDay:qe().optional(),hasConflict:qe().optional(),createdAt:ke(),updatedAt:ke()}),Ry=Zt(Xu),Ku=Fe({id:J(),name:J(),order:we(),isAvailable:qe(),groupId:J(),createdAt:ke(),updatedAt:ke(),deletedAt:ke().optional()}),Py=Fe({id:J(),name:J(),displayMode:_r(["grid","list"]),dimension:we(),resources:Zt(Ku),createdAt:ke(),updatedAt:ke(),deletedAt:ke().optional()}),Ju=Fe({id:J().or(we()),label:J(),startTime:J(),endTime:J()}),My=Fe({defaultDuration:we(),startTime:J(),endTime:J(),closedDays:Zt(we()),weekStartsOn:ys([Bt(0),Bt(1)]),timeZone:J().optional(),businessHoursStart:J().optional(),businessHoursEnd:J().optional(),timeSlots:Zt(Ju).optional(),orientation:qu.optional(),slotInterval:we().optional()}),Oy=Fe({date:ke(),bookedCount:we(),maxSlots:we(),density:we(),isClosedDay:qe()}),Iy=Object.freeze(Object.defineProperty({__proto__:null,CalendarOrientationSchema:qu,DensityDataSchema:Oy,FacilityScheduleSettingsSchema:My,ResourceGroupSchema:Py,ResourceSchema:Ku,ScheduleEventArraySchema:Ry,ScheduleEventSchema:Xu,TimeSlotSchema:Ju,ViewModeSchema:Ty},Symbol.toStringTag,{value:"Module"})),$y={theme:"light",density:"normal",borderRadius:8,fontSize:16,weekStartsOn:1,businessHoursStart:"08:00",businessHoursEnd:"18:00",closedDays:[0,6],language:"ja",timeZone:"Asia/Tokyo",paginationEnabled:!1,paginationPageSize:8,calendarOrientation:"horizontal",facilityOrientation:"horizontal",calendarSlotInterval:60,facilitySlotInterval:60};exports.AttendeeInfoSchema=Sy;exports.AttendeeInput=Da;exports.BrowserStorage=su;exports.Button=oe;exports.Checkbox=dn;exports.ConfirmModal=oo;exports.DEFAULT_SETTINGS=$y;exports.DOMThemeApplier=Hu;exports.DateDisplay=Ot;exports.DatePicker=to;exports.DefaultEventModal=gu;exports.DensityDataSchema=Dy;exports.EventForm=Kl;exports.EventModal=mo;exports.FacilitySchedule=ou;exports.FacilityScheduleManager=wg;exports.FacilityScheduleSettingsSchema=jy;exports.FacilityStructureSettings=_g;exports.Form=ro;exports.FormControl=be;exports.FormField=Re;exports.FormItem=De;exports.FormLabel=_e;exports.FormMessage=nt;exports.Icons=ye;exports.InMemoryStorage=gg;exports.Input=xt;exports.KeypadModal=Es;exports.MockThemeApplier=xy;exports.Modal=Yr;exports.PERSONNEL_COLORS=_a;exports.PaginationOptionsSchema=Ny;exports.PersonnelContextMenu=Gu;exports.PersonnelPanel=Ey;exports.RegularCalendar=zu;exports.RegularCalendarSchema=Iy;exports.ResizablePanel=Ay;exports.ResourceGroupSchema=Cy;exports.ResourceSchema=Zu;exports.ScheduleEventArraySchema=ky;exports.ScheduleEventSchema=Uu;exports.ScheduleManager=gy;exports.ScheduleProvider=Xp;exports.Select=Wt;exports.SelectContent=Mt;exports.SelectItem=at;exports.SelectTrigger=Rt;exports.SelectValue=Pt;exports.SettingsModal=vy;exports.Textarea=mn;exports.ThemeProvider=wy;exports.TimeSlotSchema=Yu;exports.ViewModeSchema=_y;exports.ViewSelector=go;exports.applyThemeSettings=yy;exports.buttonVariants=sn;exports.calculateViewRange=ql;exports.checkScheduleConflict=io;exports.cleanEventId=yg;exports.createPersonnelColorMap=vg;exports.defaultStorage=Ps;exports.defaultThemeApplier=Bu;exports.detectAndMarkConflicts=Zp;exports.filterEventsByDateRange=Ts;exports.filterEventsByDay=zp;exports.filterEventsByResource=wa;exports.formatCalendarDate=Ne;exports.formatEventTitleWithAttendees=iu;exports.generateDateRange=lo;exports.getEventDisplayText=Wp;exports.getEventDuration=Bp;exports.getMonthEnd=Gl;exports.getMonthStart=ho;exports.getPersonnelColor=yo;exports.getResourceAvailability=Zl;exports.getToday=pg;exports.getWeekEnd=fo;exports.getWeekStart=Rs;exports.hasTimeOverlap=As;exports.mergeEvents=xg;exports.navigateDate=vo;exports.normalizeWeekStartsOn=uo;exports.parseAttendeeNames=cu;exports.parseAttendees=Bl;exports.prepareEventFormData=pu;exports.resolveEventOwnerId=lu;exports.sortEventsByTime=co;exports.sortResourcesByOrder=Hp;exports.stringifyAttendees=Wl;exports.transformBookingsToEvents=uu;exports.useAttendeeManagement=Ul;exports.useAvailableResources=hu;exports.useConflictCheck=fu;exports.useEventForm=du;exports.useFormField=Ds;exports.useResourceAvailability=Yl;exports.useResourceDisplayNames=mu;exports.useScheduleConflict=Xl;exports.useScheduleContext=Ql;exports.useScheduleData=ru;exports.useScheduleEventHandlers=nu;exports.useScheduleView=au;exports.useTheme=by;
|