Nicholai b20db98051
Some checks failed
CI / build-and-test (pull_request) Failing after 1m19s
feat(ci,flags,ops): ship end-to-end CI, feature-flag framework, gated surfaces, and ops docs
CI (.gitea/workflows/ci.yaml): lint → typecheck → vitest w/ coverage → OpenNext build → preview smoke → bundle-size budgets; Node 20; npm ci; artifacts; safe env; D1 dry-run scaffold.

Budgets: add scripts/budgets.mjs; TOTAL_STATIC_MAX_BYTES and MAX_ASSET_BYTES thresholds; report top offenders; fail on breach; README CI section.

Flags: add lib/flags.ts with typed booleans and safe defaults (ADMIN_ENABLED, ARTISTS_MODULE_ENABLED, UPLOADS_ADMIN_ENABLED, BOOKING_ENABLED, PUBLIC_APPOINTMENT_REQUESTS_ENABLED, REFERENCE_UPLOADS_PUBLIC_ENABLED, DEPOSITS_ENABLED, PUBLIC_DB_ARTISTS_ENABLED, ADVANCED_NAV_SCROLL_ANIMATIONS_ENABLED, STRICT_CI_GATES_ENABLED, ISR_CACHE_R2_ENABLED); robust parsing; client provider; unit tests.

Wiring: gate Admin shell and admin write APIs (503 JSON on uploads and artists writes); disable booking submit and short-circuit booking mutations when off; render static Hero/Artists when advanced animations off; tests for UI and API guards.

Ops: expand docs/prd/rollback-strategy.md with “Feature Flags Operations,” Cloudflare Dashboard and wrangler.toml steps, preview simulation, incident playbook, and post-toggle smoke checklist.

Release: add docs/releases/2025-09-19-feature-flags-rollout.md with last-good commit, preview/production flag matrices, rollback notes, and smoke results; link from rollback doc.

Chore: fix TS issues (gift-cards boolean handling, Lenis options, tailwind darkMode), remove next-on-pages peer conflict, update package.json scripts, configure Gitea act_runner label, open draft PR to trigger CI.

Refs: CI-1, FF-1, FF-2, FF-3, OPS-1
Impact: defaults preserve current behavior; no runtime changes unless flags flipped
2025-09-19 21:33:09 -06:00

1 line
20 KiB
JavaScript

"use strict";exports.id=9060,exports.ids=[9060],exports.modules={72171:(e,t,r)=>{r.d(t,{ArtistForm:()=>w});var s=r(97247),a=r(28964),i=r(34178),n=r(2704),l=r(34631),o=r(54641),d=r(58053),c=r(70170),u=r(44494),p=r(22394),m=r(27757),f=r(88964),h=r(67036),x=r(99219),g=r(37013),v=r(69964),b=r(10906),y=r(10283);let j=o.z.object({name:o.z.string().min(1,"Name is required"),bio:o.z.string().min(10,"Bio must be at least 10 characters"),specialties:o.z.array(o.z.string()).min(1,"At least one specialty is required"),instagramHandle:o.z.string().optional(),hourlyRate:o.z.number().min(0).optional(),isActive:o.z.boolean().default(!0),email:o.z.string().email().optional()});function w({artist:e,onSuccess:t}){let r=(0,i.useRouter)(),{toast:o}=(0,b.pm)(),[w,N]=(0,a.useState)(!1),[k,S]=(0,a.useState)(""),{uploadFiles:A,progress:C,isUploading:E,error:O,clearProgress:T}=(0,y.FL)({maxFiles:10,maxSize:5242880,allowedTypes:["image/jpeg","image/png","image/webp"]}),{register:z,handleSubmit:P,watch:R,setValue:_,formState:{errors:I}}=(0,n.cI)({resolver:(0,l.F)(j),defaultValues:{name:e?.name||"",bio:e?.bio||"",specialties:e?.specialties?"string"==typeof e.specialties?JSON.parse(e.specialties):e.specialties:[],instagramHandle:e?.instagramHandle||"",hourlyRate:e?.hourlyRate||void 0,isActive:e?.isActive!==!1,email:""}}),M=R("specialties"),F=()=>{k.trim()&&!M.includes(k.trim())&&(_("specialties",[...M,k.trim()]),S(""))},$=e=>{_("specialties",M.filter(t=>t!==e))},D=async t=>{if(!t||0===t.length)return;let r=Array.from(t);await A(r,{keyPrefix:e?`portfolio/${e.id}`:"temp-portfolio"})},H=async s=>{N(!0);try{let a=e?`/api/artists/${e.id}`:"/api/artists",i=await fetch(a,{method:e?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok){let e=await i.json();throw Error(e.error||"Failed to save artist")}let n=await i.json();o({title:"Success",description:e?"Artist updated successfully":"Artist created successfully"}),t?.(),e||r.push(`/admin/artists/${n.artist.id}`)}catch(e){console.error("Form submission error:",e),o({title:"Error",description:e instanceof Error?e.message:"Failed to save artist",variant:"destructive"})}finally{N(!1)}};return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)(m.Zb,{children:[s.jsx(m.Ol,{children:s.jsx(m.ll,{children:e?"Edit Artist":"Create New Artist"})}),s.jsx(m.aY,{children:(0,s.jsxs)("form",{onSubmit:P(H),className:"space-y-6",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx(p._,{htmlFor:"name",children:"Name *"}),s.jsx(c.I,{id:"name",...z("name"),placeholder:"Artist name"}),I.name&&s.jsx("p",{className:"text-sm text-red-600",children:I.name.message})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx(p._,{htmlFor:"email",children:"Email"}),s.jsx(c.I,{id:"email",type:"email",...z("email"),placeholder:"artist@unitedtattoo.com"}),I.email&&s.jsx("p",{className:"text-sm text-red-600",children:I.email.message})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx(p._,{htmlFor:"bio",children:"Bio *"}),s.jsx(u.g,{id:"bio",...z("bio"),placeholder:"Tell us about this artist...",rows:4}),I.bio&&s.jsx("p",{className:"text-sm text-red-600",children:I.bio.message})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx(p._,{children:"Specialties *"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[s.jsx(c.I,{value:k,onChange:e=>S(e.target.value),placeholder:"Add a specialty",onKeyPress:e=>"Enter"===e.key&&(e.preventDefault(),F())}),s.jsx(d.z,{type:"button",onClick:F,size:"sm",children:s.jsx(x.Z,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(e=>(0,s.jsxs)(f.C,{variant:"secondary",className:"flex items-center gap-1",children:[e,s.jsx("button",{type:"button",onClick:()=>$(e),className:"ml-1 hover:text-red-600",children:s.jsx(g.Z,{className:"h-3 w-3"})})]},e))}),I.specialties&&s.jsx("p",{className:"text-sm text-red-600",children:I.specialties.message})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx(p._,{htmlFor:"instagramHandle",children:"Instagram Handle"}),s.jsx(c.I,{id:"instagramHandle",...z("instagramHandle"),placeholder:"@username"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx(p._,{htmlFor:"hourlyRate",children:"Hourly Rate ($)"}),s.jsx(c.I,{id:"hourlyRate",type:"number",step:"0.01",...z("hourlyRate",{valueAsNumber:!0}),placeholder:"150.00"})]})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[s.jsx(h.r,{id:"isActive",checked:R("isActive"),onCheckedChange:e=>_("isActive",e)}),s.jsx(p._,{htmlFor:"isActive",children:"Active Artist"})]}),(0,s.jsxs)("div",{className:"flex justify-end space-x-2",children:[s.jsx(d.z,{type:"button",variant:"outline",onClick:()=>r.back(),children:"Cancel"}),s.jsx(d.z,{type:"submit",disabled:w,children:w?"Saving...":e?"Update Artist":"Create Artist"})]})]})})]}),e&&(0,s.jsxs)(m.Zb,{children:[s.jsx(m.Ol,{children:s.jsx(m.ll,{children:"Portfolio Images"})}),s.jsx(m.aY,{children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center",children:[s.jsx(v.Z,{className:"mx-auto h-12 w-12 text-gray-400"}),(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsxs)(p._,{htmlFor:"portfolio-upload",className:"cursor-pointer",children:[s.jsx("span",{className:"mt-2 block text-sm font-medium text-gray-900",children:"Upload portfolio images"}),s.jsx("span",{className:"mt-1 block text-sm text-gray-500",children:"PNG, JPG, WebP up to 5MB each"})]}),s.jsx(c.I,{id:"portfolio-upload",type:"file",multiple:!0,accept:"image/*",className:"hidden",onChange:e=>D(e.target.files)})]})]}),C.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[s.jsx("h4",{className:"font-medium",children:"Upload Progress"}),C.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[s.jsx("span",{className:"text-sm",children:e.filename}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:["uploading"===e.status&&s.jsx("div",{className:"w-20 bg-gray-200 rounded-full h-2",children:s.jsx("div",{className:"bg-blue-600 h-2 rounded-full transition-all",style:{width:`${e.progress}%`}})}),"complete"===e.status&&s.jsx(f.C,{variant:"default",children:"Complete"}),"error"===e.status&&s.jsx(f.C,{variant:"destructive",children:"Error"})]})]},e.id)),s.jsx(d.z,{type:"button",variant:"outline",size:"sm",onClick:T,children:"Clear Progress"})]}),O&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-red-700 text-sm",children:O})]})})]})]})}},88964:(e,t,r)=>{r.d(t,{C:()=>o});var s=r(97247);r(28964);var a=r(69008),i=r(87972),n=r(25008);let l=(0,i.j)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function o({className:e,variant:t,asChild:r=!1,...i}){let o=r?a.g7:"span";return s.jsx(o,{"data-slot":"badge",className:(0,n.cn)(l({variant:t}),e),...i})}},70170:(e,t,r)=>{r.d(t,{I:()=>i});var s=r(97247);r(28964);var a=r(25008);function i({className:e,type:t,...r}){return s.jsx("input",{type:t,"data-slot":"input",className:(0,a.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}},22394:(e,t,r)=>{r.d(t,{_:()=>n});var s=r(97247);r(28964);var a=r(94056),i=r(25008);function n({className:e,...t}){return s.jsx(a.f,{"data-slot":"label",className:(0,i.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}},67036:(e,t,r)=>{r.d(t,{r:()=>S});var s=r(97247),a=r(28964);function i(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function n(...e){return t=>{let r=!1,s=e.map(e=>{let s=i(e,t);return r||"function"!=typeof s||(r=!0),s});if(r)return()=>{for(let t=0;t<s.length;t++){let r=s[t];"function"==typeof r?r():i(e[t],null)}}}}function l(e){let t=a.useRef(e);return a.useEffect(()=>{t.current=e}),a.useMemo(()=>(...e)=>t.current?.(...e),[])}var o=globalThis?.document?a.useLayoutEffect:()=>{};r(46817);var d=a.forwardRef((e,t)=>{let{children:r,...i}=e,n=a.Children.toArray(r),l=n.find(p);if(l){let e=l.props.children,r=n.map(t=>t!==l?t:a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null);return(0,s.jsx)(c,{...i,ref:t,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return(0,s.jsx)(c,{...i,ref:t,children:r})});d.displayName="Slot";var c=a.forwardRef((e,t)=>{let{children:r,...s}=e;if(a.isValidElement(r)){let e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(r=(t=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning)?e.props.ref:e.props.ref||e.ref}(r);return a.cloneElement(r,{...function(e,t){let r={...t};for(let s in t){let a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...e)=>{i(...e),a(...e)}:a&&(r[s]=a):"style"===s?r[s]={...a,...i}:"className"===s&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}(s,r.props),ref:t?n(t,e):e})}return a.Children.count(r)>1?a.Children.only(null):null});c.displayName="SlotClone";var u=({children:e})=>(0,s.jsx)(s.Fragment,{children:e});function p(e){return a.isValidElement(e)&&e.type===u}var m=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,t)=>{let r=a.forwardRef((e,r)=>{let{asChild:a,...i}=e,n=a?d:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,s.jsx)(n,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),f="Switch",[h,x]=function(e,t=[]){let r=[],i=()=>{let t=r.map(e=>a.createContext(e));return function(r){let s=r?.[e]||t;return a.useMemo(()=>({[`__scope${e}`]:{...r,[e]:s}}),[r,s])}};return i.scopeName=e,[function(t,i){let n=a.createContext(i),l=r.length;r=[...r,i];let o=t=>{let{scope:r,children:i,...o}=t,d=r?.[e]?.[l]||n,c=a.useMemo(()=>o,Object.values(o));return(0,s.jsx)(d.Provider,{value:c,children:i})};return o.displayName=t+"Provider",[o,function(r,s){let o=s?.[e]?.[l]||n,d=a.useContext(o);if(d)return d;if(void 0!==i)return i;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let s=r.reduce((t,{useScope:r,scopeName:s})=>{let a=r(e)[`__scope${s}`];return{...t,...a}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}(i,...t)]}(f),[g,v]=h(f),b=a.forwardRef((e,t)=>{let{__scopeSwitch:r,name:i,checked:o,defaultChecked:d,required:c,disabled:u,value:p="on",onCheckedChange:f,form:h,...x}=e,[v,b]=a.useState(null),y=function(...e){return a.useCallback(n(...e),e)}(t,e=>b(e)),j=a.useRef(!1),k=!v||h||!!v.closest("form"),[S=!1,A]=function({prop:e,defaultProp:t,onChange:r=()=>{}}){let[s,i]=function({defaultProp:e,onChange:t}){let r=a.useState(e),[s]=r,i=a.useRef(s),n=l(t);return a.useEffect(()=>{i.current!==s&&(n(s),i.current=s)},[s,i,n]),r}({defaultProp:t,onChange:r}),n=void 0!==e,o=n?e:s,d=l(r);return[o,a.useCallback(t=>{if(n){let r="function"==typeof t?t(e):t;r!==e&&d(r)}else i(t)},[n,e,i,d])]}({prop:o,defaultProp:d,onChange:f});return(0,s.jsxs)(g,{scope:r,checked:S,disabled:u,children:[(0,s.jsx)(m.button,{type:"button",role:"switch","aria-checked":S,"aria-required":c,"data-state":N(S),"data-disabled":u?"":void 0,disabled:u,value:p,...x,ref:y,onClick:function(e,t,{checkForDefaultPrevented:r=!0}={}){return function(s){if(e?.(s),!1===r||!s.defaultPrevented)return t?.(s)}}(e.onClick,e=>{A(e=>!e),k&&(j.current=e.isPropagationStopped(),j.current||e.stopPropagation())})}),k&&(0,s.jsx)(w,{control:v,bubbles:!j.current,name:i,value:p,checked:S,required:c,disabled:u,form:h,style:{transform:"translateX(-100%)"}})]})});b.displayName=f;var y="SwitchThumb",j=a.forwardRef((e,t)=>{let{__scopeSwitch:r,...a}=e,i=v(y,r);return(0,s.jsx)(m.span,{"data-state":N(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t})});j.displayName=y;var w=e=>{let{control:t,checked:r,bubbles:i=!0,...n}=e,l=a.useRef(null),d=function(e){let t=a.useRef({value:e,previous:e});return a.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}(r),c=function(e){let[t,r]=a.useState(void 0);return o(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{let s,a;if(!Array.isArray(t)||!t.length)return;let i=t[0];if("borderBoxSize"in i){let e=i.borderBoxSize,t=Array.isArray(e)?e[0]:e;s=t.inlineSize,a=t.blockSize}else s=e.offsetWidth,a=e.offsetHeight;r({width:s,height:a})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}r(void 0)},[e]),t}(t);return a.useEffect(()=>{let e=l.current,t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(d!==r&&t){let s=new Event("click",{bubbles:i});t.call(e,r),e.dispatchEvent(s)}},[d,r,i]),(0,s.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...n,tabIndex:-1,ref:l,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function N(e){return e?"checked":"unchecked"}var k=r(25008);function S({className:e,...t}){return s.jsx(b,{"data-slot":"switch",className:(0,k.cn)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(j,{"data-slot":"switch-thumb",className:(0,k.cn)("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}},44494:(e,t,r)=>{r.d(t,{g:()=>i});var s=r(97247);r(28964);var a=r(25008);function i({className:e,...t}){return s.jsx("textarea",{"data-slot":"textarea",className:(0,a.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}},10283:(e,t,r)=>{r.d(t,{FL:()=>a});var s=r(28964);function a(e={}){let[t,r]=(0,s.useState)([]),[a,i]=(0,s.useState)(!1),[n,l]=(0,s.useState)(null),{maxFiles:o=10,maxSize:d=10485760,allowedTypes:c=["image/jpeg","image/png","image/webp","image/gif"],onProgress:u,onComplete:p,onError:m}=e,f=(0,s.useCallback)(e=>{let t=[],r=[];if(e.length>o)return r.push(`Maximum ${o} files allowed`),{valid:t,errors:r};for(let s of e){if(s.size>d){r.push(`${s.name}: File size exceeds ${Math.round(d/1024/1024)}MB limit`);continue}if(!c.includes(s.type)){r.push(`${s.name}: File type ${s.type} not allowed`);continue}t.push(s)}return{valid:t,errors:r}},[o,d,c]),h=(0,s.useCallback)(async(e,t)=>{let s=`${Date.now()}-${Math.random().toString(36).substring(2)}`,a={id:s,filename:e.name,progress:0,status:"uploading"};r(e=>[...e,a]),l(null);try{let a=setInterval(()=>{r(e=>e.map(e=>e.id===s&&e.progress<90?{...e,progress:Math.min(90,e.progress+20*Math.random())}:e))},200),i=new FormData;i.append("file",e),t&&i.append("key",t);let n=await fetch("/api/upload",{method:"POST",body:i});clearInterval(a);let l=await n.json();if(l.success)return r(e=>e.map(e=>e.id===s?{...e,progress:100,status:"complete",url:l.url}:e)),l;return r(e=>e.map(e=>e.id===s?{...e,status:"error",error:l.error}:e)),{success:!1,error:l.error||"Upload failed"}}catch(t){let e=t instanceof Error?t.message:"Upload failed";return r(t=>t.map(t=>t.id===s?{...t,status:"error",error:e}:t)),{success:!1,error:e}}},[]);return{uploadFiles:(0,s.useCallback)(async(e,r)=>{i(!0),l(null);try{let{valid:s,errors:a}=f(e);if(a.length>0){let e=a.join(", ");l(e),m?.(e);return}if(0===s.length){l("No valid files to upload"),m?.("No valid files to upload");return}let i=[];for(let e of s){let t=r?.keyPrefix?`${r.keyPrefix}/${Date.now()}-${e.name}`:void 0,s=await h(e,t);i.push(s)}let n=i.filter(e=>e.success).map(e=>({filename:s.find(t=>i.indexOf(e)===s.indexOf(t))?.name||"",url:e.url||"",key:e.key||"",size:s.find(t=>i.indexOf(e)===s.indexOf(t))?.size||0,mimeType:s.find(t=>i.indexOf(e)===s.indexOf(t))?.type||""})),o=i.map((e,t)=>({result:e,file:s[t]})).filter(({result:e})=>!e.success).map(({result:e,file:t})=>({filename:t.name,error:e.error||"Upload failed"})),d={successful:n,failed:o,total:s.length};p?.(d);let c=[...t];u?.(c)}catch(t){let e=t instanceof Error?t.message:"Upload failed";l(e),m?.(e)}finally{i(!1)}},[t,f,h,u,p,m]),uploadSingleFile:h,progress:t,isUploading:a,error:n,clearProgress:(0,s.useCallback)(()=>{r([]),l(null)},[]),removeFile:(0,s.useCallback)(e=>{r(t=>t.filter(t=>t.id!==e))},[])}}},10906:(e,t,r)=>{r.d(t,{pm:()=>p});var s=r(28964);let a=0,i=new Map,n=e=>{if(i.has(e))return;let t=setTimeout(()=>{i.delete(e),c({type:"REMOVE_TOAST",toastId:e})},1e6);i.set(e,t)},l=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:r}=t;return r?n(r):e.toasts.forEach(e=>{n(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===r||void 0===r?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},o=[],d={toasts:[]};function c(e){d=l(d,e),o.forEach(e=>{e(d)})}function u({...e}){let t=(a=(a+1)%Number.MAX_SAFE_INTEGER).toString(),r=()=>c({type:"DISMISS_TOAST",toastId:t});return c({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:e=>c({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function p(){let[e,t]=s.useState(d);return s.useEffect(()=>(o.push(t),()=>{let e=o.indexOf(t);e>-1&&o.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>c({type:"DISMISS_TOAST",toastId:e})}}},50820:(e,t,r)=>{r.d(t,{Z:()=>s});let s=(0,r(26323).Z)("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]])}};