@overmap-ai/forms 1.0.17-blur-updates.3 → 1.0.17-blur-updates.5

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.
@@ -1,4 +1,4 @@
1
- (function(E,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("react"),require("formik"),require("react-dom"),require("react-icons/ri"),require("lodash.get"),require("lodash.set"),require("@hello-pangea/dnd"),require("qr-scanner"),require("lodash.clonedeep"),require("@overmap-ai/core"),require("react-sketch-canvas")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","react","formik","react-dom","react-icons/ri","lodash.get","lodash.set","@hello-pangea/dnd","qr-scanner","lodash.clonedeep","@overmap-ai/core","react-sketch-canvas"],i):(E=typeof globalThis<"u"?globalThis:E||self,i(E.forms={},E.jsxRuntime,E.blocks,E.React,E.formik,E.ReactDOM,E.ri,E.get,E.set,E.dnd,E.QrScannerAPI,E.cloneDeep,E.core,E.reactSketchCanvas))})(this,function(E,i,c,d,U,gn,$,Q,yt,ie,Kr,Qr,de,Yr){"use strict";var aa=Object.defineProperty;var sa=(E,i,c)=>i in E?aa(E,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):E[i]=c;var T=(E,i,c)=>sa(E,typeof i!="symbol"?i+"":i,c);function vn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const v=vn(d),Jr=vn(gn),bt=d.memo(t=>{const{selectedColor:n,allColors:e,onFinish:r,trigger:o}=t,a=d.useCallback(s=>()=>{r(s)},[r]);return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{children:o}),i.jsx(c.Popover.Content,{size:"sm",children:i.jsx("div",{className:"grid w-max grid-cols-7 gap-x-1 gap-y-1",children:e.map(s=>i.jsx(c.IconButton,{onClick:a(s),style:{backgroundColor:s},type:"button",variant:"solid","aria-label":s,children:n===s&&i.jsx(c.RiIcon,{icon:"RiCheckLine"})},s))})})]})});bt.displayName="ColorPicker";function yn(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(e=yn(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Zr(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=yn(t))&&(r&&(r+=" "),r+=n);return r}const ye=Zr,bn=["image/jpeg","image/png","image/svg+xml"],Cn=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],wn=["application/pdf"],$e=d.memo(t=>{const{fileType:n}=t,e=d.useMemo(()=>Cn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileExcelLine"}):wn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFilePdfLine"}):bn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileImageLine"}):i.jsx(c.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});$e.displayName="FileIcon";const Ct=d.memo(d.forwardRef((t,n)=>{const{file:e,className:r,error:o,rightSlot:a,...s}=t;return i.jsxs("div",{className:ye(r,"flex h-8 w-full items-center gap-2 rounded-md border border-(--base-a6) bg-(--base-2) text-sm py-1 px-2 h-max",{"text-(--gray-11)":o}),ref:n,...s,children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):i.jsx($e,{fileType:(e==null?void 0:e.type)??""}),o||(e?i.jsx(c.Text,{className:"truncate",children:e.name}):i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(c.Spinner,{})})),a]})}));Ct.displayName="FileCard";const ke=500,be=1e4,ue={danger:"danger",warning:"warning",info:"base",success:"success"},Rr={boolean:"RiCheckboxCircleLine",date:"RiCalendarLine","multi-string":"RiListCheck",number:"RiHashtag",qr:"RiQrCodeLine","multi-select":"RiCheckboxLine",select:"RiMenuFoldLine",string:"RiInputField",text:"RiAlignJustify",upload:"RiUpload2Line",custom:"RiCodeSSlashLine",section:"RiFolderLine"};class wt{constructor(n){T(this,"type");T(this,"identifier");T(this,"description");const{description:e=null,identifier:r,type:o}=n;this.identifier=r,this.description=e,this.type=o}getId(){return this.identifier}static deserialize(n){throw new Error(`${this.name} must implement deserialize.`)}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{type:this.type,identifier:this.identifier,description:this.description}}}const G={label:"",description:"",required:!1};class k extends wt{constructor(e){const{label:r,required:o,image:a,fieldValidators:s=[],formValidators:l=[],...m}=e;super(m);T(this,"required");T(this,"formValidators");T(this,"fieldValidators");T(this,"label");T(this,"image");T(this,"onlyValidateAfterTouched",!0);this.label=r,this.required=o,this.image=a,this.fieldValidators=s,this.formValidators=l}static getFieldCreationSchema(){return[]}isBlank(e){return e==null||e===""}getValueFromChangeEvent(e){return e.target.value}getError(e,r){if(this.required&&this.isBlank(e))return"This field is required.";for(const o of this.getFieldValidators()){const a=o(e);if(a)return a}if(r)for(const o of this.getFormValidators()){const a=o(e,r);if(a)return a}}_serialize(){return{...super._serialize(),label:this.label,required:this.required,image:this.image}}getFieldValidators(){return[...this.fieldValidators]}getFormValidators(){return[...this.formValidators]}encodeValueToJson(e){return JSON.stringify(e)}decodeJsonToValue(e){return JSON.parse(e)}}T(k,"fieldTypeName"),T(k,"fieldTypeDescription");const X=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,onValuesChange:s,...l}=t,[m,u,f]=U.useField(e.getId()),{touched:h}=u,g=u.error??e.description,C=u.error?"danger":void 0,w=n??`${r}-${e.getId()}-input`,p=`${w}-label`,y=e.required?`${e.label} *`:e.label,x=d.useMemo(()=>({...m,onChange:S=>{f.setValue(S,!1).then(),s==null||s(e.getId(),S),(h||!e.onlyValidateAfterTouched)&&f.setError(e.getError(S))},onBlur:S=>{f.setTouched(!0,!1).then(),f.setError(e.getError(S))}}),[e,m,f,s,h]);return[{helpText:g,size:o,severity:C,inputId:w,labelId:p,label:y,showInputOnly:a,fieldProps:x,helpers:f,field:e,touched:h},{...l,"aria-labelledby":p}]},In=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),je=()=>d.useContext(In);function oe(t,n,{checkForDefaultPrevented:e=!0}={}){return function(o){if(t==null||t(o),e===!1||!o.defaultPrevented)return n==null?void 0:n(o)}}function xn(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function En(...t){return n=>{let e=!1;const r=t.map(o=>{const a=xn(o,n);return!e&&typeof a=="function"&&(e=!0),a});if(e)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():xn(t[o],null)}}}}function fe(...t){return v.useCallback(En(...t),t)}function ei(t,n){const e=v.createContext(n),r=a=>{const{children:s,...l}=a,m=v.useMemo(()=>l,Object.values(l));return i.jsx(e.Provider,{value:m,children:s})};r.displayName=t+"Provider";function o(a){const s=v.useContext(e);if(s)return s;if(n!==void 0)return n;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,o]}function ti(t,n=[]){let e=[];function r(a,s){const l=v.createContext(s),m=e.length;e=[...e,s];const u=h=>{var x;const{scope:g,children:C,...w}=h,p=((x=g==null?void 0:g[t])==null?void 0:x[m])||l,y=v.useMemo(()=>w,Object.values(w));return i.jsx(p.Provider,{value:y,children:C})};u.displayName=a+"Provider";function f(h,g){var p;const C=((p=g==null?void 0:g[t])==null?void 0:p[m])||l,w=v.useContext(C);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=e.map(s=>v.createContext(s));return function(l){const m=(l==null?void 0:l[t])||a;return v.useMemo(()=>({[`__scope${t}`]:{...l,[t]:m}}),[l,m])}};return o.scopeName=t,[r,ni(o,...n)]}function ni(...t){const n=t[0];if(t.length===1)return n;const e=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const s=r.reduce((l,{useScope:m,scopeName:u})=>{const h=m(a)[`__scope${u}`];return{...l,...h}},{});return v.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return e.scopeName=n.scopeName,e}var We=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},ri=v.useId||(()=>{}),ii=0;function It(t){const[n,e]=v.useState(ri());return We(()=>{e(r=>r??String(ii++))},[t]),t||(n?`radix-${n}`:"")}function he(t){const n=v.useRef(t);return v.useEffect(()=>{n.current=t}),v.useMemo(()=>(...e)=>{var r;return(r=n.current)==null?void 0:r.call(n,...e)},[])}function oi({prop:t,defaultProp:n,onChange:e=()=>{}}){const[r,o]=ai({defaultProp:n,onChange:e}),a=t!==void 0,s=a?t:r,l=he(e),m=v.useCallback(u=>{if(a){const h=typeof u=="function"?u(t):u;h!==t&&l(h)}else o(u)},[a,t,o,l]);return[s,m]}function ai({defaultProp:t,onChange:n}){const e=v.useState(t),[r]=e,o=v.useRef(r),a=he(n);return v.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),e}var xt=v.forwardRef((t,n)=>{const{children:e,...r}=t,o=v.Children.toArray(e),a=o.find(li);if(a){const s=a.props.children,l=o.map(m=>m===a?v.Children.count(s)>1?v.Children.only(null):v.isValidElement(s)?s.props.children:null:m);return i.jsx(Et,{...r,ref:n,children:v.isValidElement(s)?v.cloneElement(s,void 0,l):null})}return i.jsx(Et,{...r,ref:n,children:e})});xt.displayName="Slot";var Et=v.forwardRef((t,n)=>{const{children:e,...r}=t;if(v.isValidElement(e)){const o=di(e);return v.cloneElement(e,{...ci(r,e.props),ref:n?En(n,o):o})}return v.Children.count(e)>1?v.Children.only(null):null});Et.displayName="SlotClone";var si=({children:t})=>i.jsx(i.Fragment,{children:t});function li(t){return v.isValidElement(t)&&t.type===si}function ci(t,n){const e={...n};for(const r in n){const o=t[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?e[r]=(...l)=>{a(...l),o(...l)}:o&&(e[r]=o):r==="style"?e[r]={...o,...a}:r==="className"&&(e[r]=[o,a].filter(Boolean).join(" "))}return{...t,...e}}function di(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var ui=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],re=ui.reduce((t,n)=>{const e=v.forwardRef((r,o)=>{const{asChild:a,...s}=r,l=a?xt:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(l,{...s,ref:o})});return e.displayName=`Primitive.${n}`,{...t,[n]:e}},{});function fi(t,n){t&&Jr.flushSync(()=>t.dispatchEvent(n))}function hi(t,n=globalThis==null?void 0:globalThis.document){const e=he(t);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&e(o)};return n.addEventListener("keydown",r,{capture:!0}),()=>n.removeEventListener("keydown",r,{capture:!0})},[e,n])}var pi="DismissableLayer",St="dismissableLayer.update",mi="dismissableLayer.pointerDownOutside",gi="dismissableLayer.focusOutside",Sn,Tn=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nn=v.forwardRef((t,n)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:l,...m}=t,u=v.useContext(Tn),[f,h]=v.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,C]=v.useState({}),w=fe(n,F=>h(F)),p=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=p.indexOf(y),I=f?p.indexOf(f):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,S=I>=x,N=bi(F=>{const L=F.target,A=[...u.branches].some(O=>O.contains(L));!S||A||(o==null||o(F),s==null||s(F),F.defaultPrevented||l==null||l())},g),D=Ci(F=>{const L=F.target;[...u.branches].some(O=>O.contains(L))||(a==null||a(F),s==null||s(F),F.defaultPrevented||l==null||l())},g);return hi(F=>{I===u.layers.size-1&&(r==null||r(F),!F.defaultPrevented&&l&&(F.preventDefault(),l()))},g),v.useEffect(()=>{if(f)return e&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Sn=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Fn(),()=>{e&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Sn)}},[f,g,e,u]),v.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Fn())},[f,u]),v.useEffect(()=>{const F=()=>C({});return document.addEventListener(St,F),()=>document.removeEventListener(St,F)},[]),i.jsx(re.div,{...m,ref:w,style:{pointerEvents:b?S?"auto":"none":void 0,...t.style},onFocusCapture:oe(t.onFocusCapture,D.onFocusCapture),onBlurCapture:oe(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:oe(t.onPointerDownCapture,N.onPointerDownCapture)})});Nn.displayName=pi;var vi="DismissableLayerBranch",yi=v.forwardRef((t,n)=>{const e=v.useContext(Tn),r=v.useRef(null),o=fe(n,r);return v.useEffect(()=>{const a=r.current;if(a)return e.branches.add(a),()=>{e.branches.delete(a)}},[e.branches]),i.jsx(re.div,{...t,ref:o})});yi.displayName=vi;function bi(t,n=globalThis==null?void 0:globalThis.document){const e=he(t),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let m=function(){Ln(mi,e,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=m,n.addEventListener("click",o.current,{once:!0})):m()}else n.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{n.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(s),n.removeEventListener("pointerdown",a),n.removeEventListener("click",o.current)}},[n,e]),{onPointerDownCapture:()=>r.current=!0}}function Ci(t,n=globalThis==null?void 0:globalThis.document){const e=he(t),r=v.useRef(!1);return v.useEffect(()=>{const o=a=>{a.target&&!r.current&&Ln(gi,e,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,e]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Fn(){const t=new CustomEvent(St);document.dispatchEvent(t)}function Ln(t,n,e,{discrete:r}){const o=e.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:e});n&&o.addEventListener(t,n,{once:!0}),r?fi(o,a):o.dispatchEvent(a)}var Tt="focusScope.autoFocusOnMount",Nt="focusScope.autoFocusOnUnmount",Dn={bubbles:!1,cancelable:!0},wi="FocusScope",Mn=v.forwardRef((t,n)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=t,[l,m]=v.useState(null),u=he(o),f=he(a),h=v.useRef(null),g=fe(n,p=>m(p)),C=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let p=function(b){if(C.paused||!l)return;const S=b.target;l.contains(S)?h.current=S:ae(h.current,{select:!0})},y=function(b){if(C.paused||!l)return;const S=b.relatedTarget;S!==null&&(l.contains(S)||ae(h.current,{select:!0}))},x=function(b){if(document.activeElement===document.body)for(const N of b)N.removedNodes.length>0&&ae(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const I=new MutationObserver(x);return l&&I.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),I.disconnect()}}},[r,l,C.paused]),v.useEffect(()=>{if(l){On.add(C);const p=document.activeElement;if(!l.contains(p)){const x=new CustomEvent(Tt,Dn);l.addEventListener(Tt,u),l.dispatchEvent(x),x.defaultPrevented||(Ii(Ni(An(l)),{select:!0}),document.activeElement===p&&ae(l))}return()=>{l.removeEventListener(Tt,u),setTimeout(()=>{const x=new CustomEvent(Nt,Dn);l.addEventListener(Nt,f),l.dispatchEvent(x),x.defaultPrevented||ae(p??document.body,{select:!0}),l.removeEventListener(Nt,f),On.remove(C)},0)}}},[l,u,f,C]);const w=v.useCallback(p=>{if(!e&&!r||C.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,x=document.activeElement;if(y&&x){const I=p.currentTarget,[b,S]=xi(I);b&&S?!p.shiftKey&&x===S?(p.preventDefault(),e&&ae(b,{select:!0})):p.shiftKey&&x===b&&(p.preventDefault(),e&&ae(S,{select:!0})):x===I&&p.preventDefault()}},[e,r,C.paused]);return i.jsx(re.div,{tabIndex:-1,...s,ref:g,onKeyDown:w})});Mn.displayName=wi;function Ii(t,{select:n=!1}={}){const e=document.activeElement;for(const r of t)if(ae(r,{select:n}),document.activeElement!==e)return}function xi(t){const n=An(t),e=Pn(n,t),r=Pn(n.reverse(),t);return[e,r]}function An(t){const n=[],e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)n.push(e.currentNode);return n}function Pn(t,n){for(const e of t)if(!Ei(e,{upTo:n}))return e}function Ei(t,{upTo:n}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(n!==void 0&&t===n)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Si(t){return t instanceof HTMLInputElement&&"select"in t}function ae(t,{select:n=!1}={}){if(t&&t.focus){const e=document.activeElement;t.focus({preventScroll:!0}),t!==e&&Si(t)&&n&&t.select()}}var On=Ti();function Ti(){let t=[];return{add(n){const e=t[0];n!==e&&(e==null||e.pause()),t=Bn(t,n),t.unshift(n)},remove(n){var e;t=Bn(t,n),(e=t[0])==null||e.resume()}}}function Bn(t,n){const e=[...t],r=e.indexOf(n);return r!==-1&&e.splice(r,1),e}function Ni(t){return t.filter(n=>n.tagName!=="A")}var Fi="Portal",zn=v.forwardRef((t,n)=>{var l;const{container:e,...r}=t,[o,a]=v.useState(!1);We(()=>a(!0),[]);const s=e||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?gn.createPortal(i.jsx(re.div,{...r,ref:n}),s):null});zn.displayName=Fi;function Li(t,n){return v.useReducer((e,r)=>n[e][r]??e,t)}var qe=t=>{const{present:n,children:e}=t,r=Di(n),o=typeof e=="function"?e({present:r.isPresent}):v.Children.only(e),a=fe(r.ref,Mi(o));return typeof e=="function"||r.isPresent?v.cloneElement(o,{ref:a}):null};qe.displayName="Presence";function Di(t){const[n,e]=v.useState(),r=v.useRef({}),o=v.useRef(t),a=v.useRef("none"),s=t?"mounted":"unmounted",[l,m]=Li(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=He(r.current);a.current=l==="mounted"?u:"none"},[l]),We(()=>{const u=r.current,f=o.current;if(f!==t){const g=a.current,C=He(u);t?m("MOUNT"):C==="none"||(u==null?void 0:u.display)==="none"?m("UNMOUNT"):m(f&&g!==C?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,m]),We(()=>{if(n){let u;const f=n.ownerDocument.defaultView??window,h=C=>{const p=He(r.current).includes(C.animationName);if(C.target===n&&p&&(m("ANIMATION_END"),!o.current)){const y=n.style.animationFillMode;n.style.animationFillMode="forwards",u=f.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=y)})}},g=C=>{C.target===n&&(a.current=He(r.current))};return n.addEventListener("animationstart",g),n.addEventListener("animationcancel",h),n.addEventListener("animationend",h),()=>{f.clearTimeout(u),n.removeEventListener("animationstart",g),n.removeEventListener("animationcancel",h),n.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:v.useCallback(u=>{u&&(r.current=getComputedStyle(u)),e(u)},[])}}function He(t){return(t==null?void 0:t.animationName)||"none"}function Mi(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Ft=0;function Ai(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??_n()),document.body.insertAdjacentElement("beforeend",t[1]??_n()),Ft++,()=>{Ft===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),Ft--}},[])}function _n(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var R=function(){return R=Object.assign||function(n){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},R.apply(this,arguments)};function Vn(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]]);return e}function Pi(t,n,e){if(e||arguments.length===2)for(var r=0,o=n.length,a;r<o;r++)(a||!(r in n))&&(a||(a=Array.prototype.slice.call(n,0,r)),a[r]=n[r]);return t.concat(a||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;var Ge="right-scroll-bar-position",Xe="width-before-scroll-bar",Oi="with-scroll-bars-hidden",Bi="--removed-body-scroll-bar-size";function Lt(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function zi(t,n){var e=d.useState(function(){return{value:t,callback:n,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=n,e.facade}var _i=typeof window<"u"?v.useLayoutEffect:v.useEffect,Un=new WeakMap;function Vi(t,n){var e=zi(null,function(r){return t.forEach(function(o){return Lt(o,r)})});return _i(function(){var r=Un.get(e);if(r){var o=new Set(r),a=new Set(t),s=e.current;o.forEach(function(l){a.has(l)||Lt(l,null)}),a.forEach(function(l){o.has(l)||Lt(l,s)})}Un.set(e,t)},[t]),e}function Ui(t){return t}function $i(t,n){n===void 0&&(n=Ui);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:t},useMedium:function(a){var s=n(a,r);return e.push(s),function(){e=e.filter(function(l){return l!==s})}},assignSyncMedium:function(a){for(r=!0;e.length;){var s=e;e=[],s.forEach(a)}e={push:function(l){return a(l)},filter:function(){return e}}},assignMedium:function(a){r=!0;var s=[];if(e.length){var l=e;e=[],l.forEach(a),s=e}var m=function(){var f=s;s=[],f.forEach(a)},u=function(){return Promise.resolve().then(m)};u(),e={push:function(f){s.push(f),u()},filter:function(f){return s=s.filter(f),e}}}};return o}function ki(t){t===void 0&&(t={});var n=$i(null);return n.options=R({async:!0,ssr:!1},t),n}var $n=function(t){var n=t.sideCar,e=Vn(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=n.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,R({},e))};$n.isSideCarExport=!0;function ji(t,n){return t.useMedium(n),$n}var kn=ki(),Dt=function(){},Ke=v.forwardRef(function(t,n){var e=v.useRef(null),r=v.useState({onScrollCapture:Dt,onWheelCapture:Dt,onTouchMoveCapture:Dt}),o=r[0],a=r[1],s=t.forwardProps,l=t.children,m=t.className,u=t.removeScrollBar,f=t.enabled,h=t.shards,g=t.sideCar,C=t.noIsolation,w=t.inert,p=t.allowPinchZoom,y=t.as,x=y===void 0?"div":y,I=t.gapMode,b=Vn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=g,N=Vi([e,n]),D=R(R({},b),o);return v.createElement(v.Fragment,null,f&&v.createElement(S,{sideCar:kn,removeScrollBar:u,shards:h,noIsolation:C,inert:w,setCallbacks:a,allowPinchZoom:!!p,lockRef:e,gapMode:I}),s?v.cloneElement(v.Children.only(l),R(R({},D),{ref:N})):v.createElement(x,R({},D,{className:m,ref:N}),l))});Ke.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ke.classNames={fullWidth:Xe,zeroRight:Ge};var Wi=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qi(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=Wi();return n&&t.setAttribute("nonce",n),t}function Hi(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function Gi(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var Xi=function(){var t=0,n=null;return{add:function(e){t==0&&(n=qi())&&(Hi(n,e),Gi(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},Ki=function(){var t=Xi();return function(n,e){v.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&e])}},jn=function(){var t=Ki(),n=function(e){var r=e.styles,o=e.dynamic;return t(r,o),null};return n},Qi={left:0,top:0,right:0,gap:0},Mt=function(t){return parseInt(t||"",10)||0},Yi=function(t){var n=window.getComputedStyle(document.body),e=n[t==="padding"?"paddingLeft":"marginLeft"],r=n[t==="padding"?"paddingTop":"marginTop"],o=n[t==="padding"?"paddingRight":"marginRight"];return[Mt(e),Mt(r),Mt(o)]},Ji=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Qi;var n=Yi(t),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,r-e+n[2]-n[0])}},Zi=jn(),Ce="data-scroll-locked",Ri=function(t,n,e,r){var o=t.left,a=t.top,s=t.right,l=t.gap;return e===void 0&&(e="margin"),`
1
+ (function(x,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("react"),require("formik"),require("react-dom"),require("react-icons/ri"),require("lodash.get"),require("lodash.set"),require("@hello-pangea/dnd"),require("qr-scanner"),require("lodash.clonedeep"),require("@overmap-ai/core"),require("react-sketch-canvas")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","react","formik","react-dom","react-icons/ri","lodash.get","lodash.set","@hello-pangea/dnd","qr-scanner","lodash.clonedeep","@overmap-ai/core","react-sketch-canvas"],i):(x=typeof globalThis<"u"?globalThis:x||self,i(x.forms={},x.jsxRuntime,x.blocks,x.React,x.formik,x.ReactDOM,x.ri,x.get,x.set,x.dnd,x.QrScannerAPI,x.cloneDeep,x.core,x.reactSketchCanvas))})(this,function(x,i,c,d,U,gn,$,Q,yt,ie,Kr,Qr,de,Yr){"use strict";var aa=Object.defineProperty;var sa=(x,i,c)=>i in x?aa(x,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):x[i]=c;var T=(x,i,c)=>sa(x,typeof i!="symbol"?i+"":i,c);function vn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const v=vn(d),Jr=vn(gn),bt=d.memo(t=>{const{selectedColor:n,allColors:e,onFinish:r,trigger:o}=t,a=d.useCallback(s=>()=>{r(s)},[r]);return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{children:o}),i.jsx(c.Popover.Content,{size:"sm",children:i.jsx("div",{className:"grid w-max grid-cols-7 gap-x-1 gap-y-1",children:e.map(s=>i.jsx(c.IconButton,{onClick:a(s),style:{backgroundColor:s},type:"button",variant:"solid","aria-label":s,children:n===s&&i.jsx(c.RiIcon,{icon:"RiCheckLine"})},s))})})]})});bt.displayName="ColorPicker";function yn(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(e=yn(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Zr(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=yn(t))&&(r&&(r+=" "),r+=n);return r}const ye=Zr,bn=["image/jpeg","image/png","image/svg+xml"],Cn=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],wn=["application/pdf"],$e=d.memo(t=>{const{fileType:n}=t,e=d.useMemo(()=>Cn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileExcelLine"}):wn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFilePdfLine"}):bn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileImageLine"}):i.jsx(c.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});$e.displayName="FileIcon";const Ct=d.memo(d.forwardRef((t,n)=>{const{file:e,className:r,error:o,rightSlot:a,...s}=t;return i.jsxs("div",{className:ye(r,"flex h-8 w-full items-center gap-2 rounded-md border border-(--base-a6) bg-(--base-2) text-sm py-1 px-2 h-max",{"text-(--gray-11)":o}),ref:n,...s,children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):i.jsx($e,{fileType:(e==null?void 0:e.type)??""}),o||(e?i.jsx(c.Text,{className:"truncate",children:e.name}):i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(c.Spinner,{})})),a]})}));Ct.displayName="FileCard";const ke=500,be=1e4,ue={danger:"danger",warning:"warning",info:"base",success:"success"},Rr={boolean:"RiCheckboxCircleLine",date:"RiCalendarLine","multi-string":"RiListCheck",number:"RiHashtag",qr:"RiQrCodeLine","multi-select":"RiCheckboxLine",select:"RiMenuFoldLine",string:"RiInputField",text:"RiAlignJustify",upload:"RiUpload2Line",custom:"RiCodeSSlashLine",section:"RiFolderLine"};class wt{constructor(n){T(this,"type");T(this,"identifier");T(this,"description");const{description:e=null,identifier:r,type:o}=n;this.identifier=r,this.description=e,this.type=o}getId(){return this.identifier}static deserialize(n){throw new Error(`${this.name} must implement deserialize.`)}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{type:this.type,identifier:this.identifier,description:this.description}}}const G={label:"",description:"",required:!1};class k extends wt{constructor(e){const{label:r,required:o,image:a,fieldValidators:s=[],formValidators:l=[],...m}=e;super(m);T(this,"required");T(this,"formValidators");T(this,"fieldValidators");T(this,"label");T(this,"image");T(this,"onlyValidateAfterTouched",!0);this.label=r,this.required=o,this.image=a,this.fieldValidators=s,this.formValidators=l}static getFieldCreationSchema(){return[]}isBlank(e){return e==null||e===""}getValueFromChangeEvent(e){return e.target.value}getError(e,r){if(this.required&&this.isBlank(e))return"This field is required.";for(const o of this.getFieldValidators()){const a=o(e);if(a)return a}if(r)for(const o of this.getFormValidators()){const a=o(e,r);if(a)return a}}_serialize(){return{...super._serialize(),label:this.label,required:this.required,image:this.image}}getFieldValidators(){return[...this.fieldValidators]}getFormValidators(){return[...this.formValidators]}encodeValueToJson(e){return JSON.stringify(e)}decodeJsonToValue(e){return JSON.parse(e)}}T(k,"fieldTypeName"),T(k,"fieldTypeDescription");const X=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,onValuesChange:s,...l}=t,[m,u,f]=U.useField(e.getId()),{touched:h}=u,g=u.error??e.description,C=u.error?"danger":void 0,I=n??`${r}-${e.getId()}-input`,p=`${I}-label`,y=e.required?`${e.label} *`:e.label,E=d.useMemo(()=>({...m,onChange:S=>{f.setValue(S,!1).then(),s==null||s(e.getId(),S),(h||!e.onlyValidateAfterTouched)&&f.setError(e.getError(S))},onBlur:S=>{f.setTouched(!0,!1).then(),f.setError(e.getError(S))}}),[e,m,f,s,h]);return[{helpText:g,size:o,severity:C,inputId:I,labelId:p,label:y,showInputOnly:a,fieldProps:E,helpers:f,field:e,touched:h},{...l,"aria-labelledby":p}]},In=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),je=()=>d.useContext(In);function oe(t,n,{checkForDefaultPrevented:e=!0}={}){return function(o){if(t==null||t(o),e===!1||!o.defaultPrevented)return n==null?void 0:n(o)}}function xn(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function En(...t){return n=>{let e=!1;const r=t.map(o=>{const a=xn(o,n);return!e&&typeof a=="function"&&(e=!0),a});if(e)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():xn(t[o],null)}}}}function fe(...t){return v.useCallback(En(...t),t)}function ei(t,n){const e=v.createContext(n),r=a=>{const{children:s,...l}=a,m=v.useMemo(()=>l,Object.values(l));return i.jsx(e.Provider,{value:m,children:s})};r.displayName=t+"Provider";function o(a){const s=v.useContext(e);if(s)return s;if(n!==void 0)return n;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,o]}function ti(t,n=[]){let e=[];function r(a,s){const l=v.createContext(s),m=e.length;e=[...e,s];const u=h=>{var E;const{scope:g,children:C,...I}=h,p=((E=g==null?void 0:g[t])==null?void 0:E[m])||l,y=v.useMemo(()=>I,Object.values(I));return i.jsx(p.Provider,{value:y,children:C})};u.displayName=a+"Provider";function f(h,g){var p;const C=((p=g==null?void 0:g[t])==null?void 0:p[m])||l,I=v.useContext(C);if(I)return I;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=e.map(s=>v.createContext(s));return function(l){const m=(l==null?void 0:l[t])||a;return v.useMemo(()=>({[`__scope${t}`]:{...l,[t]:m}}),[l,m])}};return o.scopeName=t,[r,ni(o,...n)]}function ni(...t){const n=t[0];if(t.length===1)return n;const e=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const s=r.reduce((l,{useScope:m,scopeName:u})=>{const h=m(a)[`__scope${u}`];return{...l,...h}},{});return v.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return e.scopeName=n.scopeName,e}var We=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},ri=v.useId||(()=>{}),ii=0;function It(t){const[n,e]=v.useState(ri());return We(()=>{e(r=>r??String(ii++))},[t]),t||(n?`radix-${n}`:"")}function he(t){const n=v.useRef(t);return v.useEffect(()=>{n.current=t}),v.useMemo(()=>(...e)=>{var r;return(r=n.current)==null?void 0:r.call(n,...e)},[])}function oi({prop:t,defaultProp:n,onChange:e=()=>{}}){const[r,o]=ai({defaultProp:n,onChange:e}),a=t!==void 0,s=a?t:r,l=he(e),m=v.useCallback(u=>{if(a){const h=typeof u=="function"?u(t):u;h!==t&&l(h)}else o(u)},[a,t,o,l]);return[s,m]}function ai({defaultProp:t,onChange:n}){const e=v.useState(t),[r]=e,o=v.useRef(r),a=he(n);return v.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),e}var xt=v.forwardRef((t,n)=>{const{children:e,...r}=t,o=v.Children.toArray(e),a=o.find(li);if(a){const s=a.props.children,l=o.map(m=>m===a?v.Children.count(s)>1?v.Children.only(null):v.isValidElement(s)?s.props.children:null:m);return i.jsx(Et,{...r,ref:n,children:v.isValidElement(s)?v.cloneElement(s,void 0,l):null})}return i.jsx(Et,{...r,ref:n,children:e})});xt.displayName="Slot";var Et=v.forwardRef((t,n)=>{const{children:e,...r}=t;if(v.isValidElement(e)){const o=di(e);return v.cloneElement(e,{...ci(r,e.props),ref:n?En(n,o):o})}return v.Children.count(e)>1?v.Children.only(null):null});Et.displayName="SlotClone";var si=({children:t})=>i.jsx(i.Fragment,{children:t});function li(t){return v.isValidElement(t)&&t.type===si}function ci(t,n){const e={...n};for(const r in n){const o=t[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?e[r]=(...l)=>{a(...l),o(...l)}:o&&(e[r]=o):r==="style"?e[r]={...o,...a}:r==="className"&&(e[r]=[o,a].filter(Boolean).join(" "))}return{...t,...e}}function di(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var ui=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],re=ui.reduce((t,n)=>{const e=v.forwardRef((r,o)=>{const{asChild:a,...s}=r,l=a?xt:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(l,{...s,ref:o})});return e.displayName=`Primitive.${n}`,{...t,[n]:e}},{});function fi(t,n){t&&Jr.flushSync(()=>t.dispatchEvent(n))}function hi(t,n=globalThis==null?void 0:globalThis.document){const e=he(t);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&e(o)};return n.addEventListener("keydown",r,{capture:!0}),()=>n.removeEventListener("keydown",r,{capture:!0})},[e,n])}var pi="DismissableLayer",St="dismissableLayer.update",mi="dismissableLayer.pointerDownOutside",gi="dismissableLayer.focusOutside",Sn,Tn=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nn=v.forwardRef((t,n)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:l,...m}=t,u=v.useContext(Tn),[f,h]=v.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,C]=v.useState({}),I=fe(n,L=>h(L)),p=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),E=p.indexOf(y),w=f?p.indexOf(f):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,S=w>=E,N=bi(L=>{const F=L.target,M=[...u.branches].some(O=>O.contains(F));!S||M||(o==null||o(L),s==null||s(L),L.defaultPrevented||l==null||l())},g),D=Ci(L=>{const F=L.target;[...u.branches].some(O=>O.contains(F))||(a==null||a(L),s==null||s(L),L.defaultPrevented||l==null||l())},g);return hi(L=>{w===u.layers.size-1&&(r==null||r(L),!L.defaultPrevented&&l&&(L.preventDefault(),l()))},g),v.useEffect(()=>{if(f)return e&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Sn=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Fn(),()=>{e&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Sn)}},[f,g,e,u]),v.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Fn())},[f,u]),v.useEffect(()=>{const L=()=>C({});return document.addEventListener(St,L),()=>document.removeEventListener(St,L)},[]),i.jsx(re.div,{...m,ref:I,style:{pointerEvents:b?S?"auto":"none":void 0,...t.style},onFocusCapture:oe(t.onFocusCapture,D.onFocusCapture),onBlurCapture:oe(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:oe(t.onPointerDownCapture,N.onPointerDownCapture)})});Nn.displayName=pi;var vi="DismissableLayerBranch",yi=v.forwardRef((t,n)=>{const e=v.useContext(Tn),r=v.useRef(null),o=fe(n,r);return v.useEffect(()=>{const a=r.current;if(a)return e.branches.add(a),()=>{e.branches.delete(a)}},[e.branches]),i.jsx(re.div,{...t,ref:o})});yi.displayName=vi;function bi(t,n=globalThis==null?void 0:globalThis.document){const e=he(t),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let m=function(){Ln(mi,e,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=m,n.addEventListener("click",o.current,{once:!0})):m()}else n.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{n.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(s),n.removeEventListener("pointerdown",a),n.removeEventListener("click",o.current)}},[n,e]),{onPointerDownCapture:()=>r.current=!0}}function Ci(t,n=globalThis==null?void 0:globalThis.document){const e=he(t),r=v.useRef(!1);return v.useEffect(()=>{const o=a=>{a.target&&!r.current&&Ln(gi,e,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,e]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Fn(){const t=new CustomEvent(St);document.dispatchEvent(t)}function Ln(t,n,e,{discrete:r}){const o=e.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:e});n&&o.addEventListener(t,n,{once:!0}),r?fi(o,a):o.dispatchEvent(a)}var Tt="focusScope.autoFocusOnMount",Nt="focusScope.autoFocusOnUnmount",Dn={bubbles:!1,cancelable:!0},wi="FocusScope",Mn=v.forwardRef((t,n)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=t,[l,m]=v.useState(null),u=he(o),f=he(a),h=v.useRef(null),g=fe(n,p=>m(p)),C=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let p=function(b){if(C.paused||!l)return;const S=b.target;l.contains(S)?h.current=S:ae(h.current,{select:!0})},y=function(b){if(C.paused||!l)return;const S=b.relatedTarget;S!==null&&(l.contains(S)||ae(h.current,{select:!0}))},E=function(b){if(document.activeElement===document.body)for(const N of b)N.removedNodes.length>0&&ae(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const w=new MutationObserver(E);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),w.disconnect()}}},[r,l,C.paused]),v.useEffect(()=>{if(l){On.add(C);const p=document.activeElement;if(!l.contains(p)){const E=new CustomEvent(Tt,Dn);l.addEventListener(Tt,u),l.dispatchEvent(E),E.defaultPrevented||(Ii(Ni(An(l)),{select:!0}),document.activeElement===p&&ae(l))}return()=>{l.removeEventListener(Tt,u),setTimeout(()=>{const E=new CustomEvent(Nt,Dn);l.addEventListener(Nt,f),l.dispatchEvent(E),E.defaultPrevented||ae(p??document.body,{select:!0}),l.removeEventListener(Nt,f),On.remove(C)},0)}}},[l,u,f,C]);const I=v.useCallback(p=>{if(!e&&!r||C.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,E=document.activeElement;if(y&&E){const w=p.currentTarget,[b,S]=xi(w);b&&S?!p.shiftKey&&E===S?(p.preventDefault(),e&&ae(b,{select:!0})):p.shiftKey&&E===b&&(p.preventDefault(),e&&ae(S,{select:!0})):E===w&&p.preventDefault()}},[e,r,C.paused]);return i.jsx(re.div,{tabIndex:-1,...s,ref:g,onKeyDown:I})});Mn.displayName=wi;function Ii(t,{select:n=!1}={}){const e=document.activeElement;for(const r of t)if(ae(r,{select:n}),document.activeElement!==e)return}function xi(t){const n=An(t),e=Pn(n,t),r=Pn(n.reverse(),t);return[e,r]}function An(t){const n=[],e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)n.push(e.currentNode);return n}function Pn(t,n){for(const e of t)if(!Ei(e,{upTo:n}))return e}function Ei(t,{upTo:n}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(n!==void 0&&t===n)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Si(t){return t instanceof HTMLInputElement&&"select"in t}function ae(t,{select:n=!1}={}){if(t&&t.focus){const e=document.activeElement;t.focus({preventScroll:!0}),t!==e&&Si(t)&&n&&t.select()}}var On=Ti();function Ti(){let t=[];return{add(n){const e=t[0];n!==e&&(e==null||e.pause()),t=Bn(t,n),t.unshift(n)},remove(n){var e;t=Bn(t,n),(e=t[0])==null||e.resume()}}}function Bn(t,n){const e=[...t],r=e.indexOf(n);return r!==-1&&e.splice(r,1),e}function Ni(t){return t.filter(n=>n.tagName!=="A")}var Fi="Portal",zn=v.forwardRef((t,n)=>{var l;const{container:e,...r}=t,[o,a]=v.useState(!1);We(()=>a(!0),[]);const s=e||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?gn.createPortal(i.jsx(re.div,{...r,ref:n}),s):null});zn.displayName=Fi;function Li(t,n){return v.useReducer((e,r)=>n[e][r]??e,t)}var qe=t=>{const{present:n,children:e}=t,r=Di(n),o=typeof e=="function"?e({present:r.isPresent}):v.Children.only(e),a=fe(r.ref,Mi(o));return typeof e=="function"||r.isPresent?v.cloneElement(o,{ref:a}):null};qe.displayName="Presence";function Di(t){const[n,e]=v.useState(),r=v.useRef({}),o=v.useRef(t),a=v.useRef("none"),s=t?"mounted":"unmounted",[l,m]=Li(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=He(r.current);a.current=l==="mounted"?u:"none"},[l]),We(()=>{const u=r.current,f=o.current;if(f!==t){const g=a.current,C=He(u);t?m("MOUNT"):C==="none"||(u==null?void 0:u.display)==="none"?m("UNMOUNT"):m(f&&g!==C?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,m]),We(()=>{if(n){let u;const f=n.ownerDocument.defaultView??window,h=C=>{const p=He(r.current).includes(C.animationName);if(C.target===n&&p&&(m("ANIMATION_END"),!o.current)){const y=n.style.animationFillMode;n.style.animationFillMode="forwards",u=f.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=y)})}},g=C=>{C.target===n&&(a.current=He(r.current))};return n.addEventListener("animationstart",g),n.addEventListener("animationcancel",h),n.addEventListener("animationend",h),()=>{f.clearTimeout(u),n.removeEventListener("animationstart",g),n.removeEventListener("animationcancel",h),n.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:v.useCallback(u=>{u&&(r.current=getComputedStyle(u)),e(u)},[])}}function He(t){return(t==null?void 0:t.animationName)||"none"}function Mi(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Ft=0;function Ai(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??_n()),document.body.insertAdjacentElement("beforeend",t[1]??_n()),Ft++,()=>{Ft===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),Ft--}},[])}function _n(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var R=function(){return R=Object.assign||function(n){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},R.apply(this,arguments)};function Vn(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]]);return e}function Pi(t,n,e){if(e||arguments.length===2)for(var r=0,o=n.length,a;r<o;r++)(a||!(r in n))&&(a||(a=Array.prototype.slice.call(n,0,r)),a[r]=n[r]);return t.concat(a||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;var Ge="right-scroll-bar-position",Xe="width-before-scroll-bar",Oi="with-scroll-bars-hidden",Bi="--removed-body-scroll-bar-size";function Lt(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function zi(t,n){var e=d.useState(function(){return{value:t,callback:n,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=n,e.facade}var _i=typeof window<"u"?v.useLayoutEffect:v.useEffect,Un=new WeakMap;function Vi(t,n){var e=zi(null,function(r){return t.forEach(function(o){return Lt(o,r)})});return _i(function(){var r=Un.get(e);if(r){var o=new Set(r),a=new Set(t),s=e.current;o.forEach(function(l){a.has(l)||Lt(l,null)}),a.forEach(function(l){o.has(l)||Lt(l,s)})}Un.set(e,t)},[t]),e}function Ui(t){return t}function $i(t,n){n===void 0&&(n=Ui);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:t},useMedium:function(a){var s=n(a,r);return e.push(s),function(){e=e.filter(function(l){return l!==s})}},assignSyncMedium:function(a){for(r=!0;e.length;){var s=e;e=[],s.forEach(a)}e={push:function(l){return a(l)},filter:function(){return e}}},assignMedium:function(a){r=!0;var s=[];if(e.length){var l=e;e=[],l.forEach(a),s=e}var m=function(){var f=s;s=[],f.forEach(a)},u=function(){return Promise.resolve().then(m)};u(),e={push:function(f){s.push(f),u()},filter:function(f){return s=s.filter(f),e}}}};return o}function ki(t){t===void 0&&(t={});var n=$i(null);return n.options=R({async:!0,ssr:!1},t),n}var $n=function(t){var n=t.sideCar,e=Vn(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=n.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,R({},e))};$n.isSideCarExport=!0;function ji(t,n){return t.useMedium(n),$n}var kn=ki(),Dt=function(){},Ke=v.forwardRef(function(t,n){var e=v.useRef(null),r=v.useState({onScrollCapture:Dt,onWheelCapture:Dt,onTouchMoveCapture:Dt}),o=r[0],a=r[1],s=t.forwardProps,l=t.children,m=t.className,u=t.removeScrollBar,f=t.enabled,h=t.shards,g=t.sideCar,C=t.noIsolation,I=t.inert,p=t.allowPinchZoom,y=t.as,E=y===void 0?"div":y,w=t.gapMode,b=Vn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=g,N=Vi([e,n]),D=R(R({},b),o);return v.createElement(v.Fragment,null,f&&v.createElement(S,{sideCar:kn,removeScrollBar:u,shards:h,noIsolation:C,inert:I,setCallbacks:a,allowPinchZoom:!!p,lockRef:e,gapMode:w}),s?v.cloneElement(v.Children.only(l),R(R({},D),{ref:N})):v.createElement(E,R({},D,{className:m,ref:N}),l))});Ke.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ke.classNames={fullWidth:Xe,zeroRight:Ge};var Wi=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qi(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=Wi();return n&&t.setAttribute("nonce",n),t}function Hi(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function Gi(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var Xi=function(){var t=0,n=null;return{add:function(e){t==0&&(n=qi())&&(Hi(n,e),Gi(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},Ki=function(){var t=Xi();return function(n,e){v.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&e])}},jn=function(){var t=Ki(),n=function(e){var r=e.styles,o=e.dynamic;return t(r,o),null};return n},Qi={left:0,top:0,right:0,gap:0},Mt=function(t){return parseInt(t||"",10)||0},Yi=function(t){var n=window.getComputedStyle(document.body),e=n[t==="padding"?"paddingLeft":"marginLeft"],r=n[t==="padding"?"paddingTop":"marginTop"],o=n[t==="padding"?"paddingRight":"marginRight"];return[Mt(e),Mt(r),Mt(o)]},Ji=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Qi;var n=Yi(t),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,r-e+n[2]-n[0])}},Zi=jn(),Ce="data-scroll-locked",Ri=function(t,n,e,r){var o=t.left,a=t.top,s=t.right,l=t.gap;return e===void 0&&(e="margin"),`
2
2
  .`.concat(Oi,` {
3
3
  overflow: hidden `).concat(r,`;
4
4
  padding-right: `).concat(l,"px ").concat(r,`;
@@ -35,11 +35,11 @@
35
35
  body[`).concat(Ce,`] {
36
36
  `).concat(Bi,": ").concat(l,`px;
37
37
  }
38
- `)},Wn=function(){var t=parseInt(document.body.getAttribute(Ce)||"0",10);return isFinite(t)?t:0},eo=function(){v.useEffect(function(){return document.body.setAttribute(Ce,(Wn()+1).toString()),function(){var t=Wn()-1;t<=0?document.body.removeAttribute(Ce):document.body.setAttribute(Ce,t.toString())}},[])},to=function(t){var n=t.noRelative,e=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;eo();var a=v.useMemo(function(){return Ji(o)},[o]);return v.createElement(Zi,{styles:Ri(a,!n,o,e?"":"!important")})},At=!1;if(typeof window<"u")try{var Qe=Object.defineProperty({},"passive",{get:function(){return At=!0,!0}});window.addEventListener("test",Qe,Qe),window.removeEventListener("test",Qe,Qe)}catch{At=!1}var we=At?{passive:!1}:!1,no=function(t){return t.tagName==="TEXTAREA"},qn=function(t,n){if(!(t instanceof Element))return!1;var e=window.getComputedStyle(t);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!no(t)&&e[n]==="visible")},ro=function(t){return qn(t,"overflowY")},io=function(t){return qn(t,"overflowX")},Hn=function(t,n){var e=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Gn(t,r);if(o){var a=Xn(t,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==e.body);return!1},oo=function(t){var n=t.scrollTop,e=t.scrollHeight,r=t.clientHeight;return[n,e,r]},ao=function(t){var n=t.scrollLeft,e=t.scrollWidth,r=t.clientWidth;return[n,e,r]},Gn=function(t,n){return t==="v"?ro(n):io(n)},Xn=function(t,n){return t==="v"?oo(n):ao(n)},so=function(t,n){return t==="h"&&n==="rtl"?-1:1},lo=function(t,n,e,r,o){var a=so(t,window.getComputedStyle(n).direction),s=a*r,l=e.target,m=n.contains(l),u=!1,f=s>0,h=0,g=0;do{var C=Xn(t,l),w=C[0],p=C[1],y=C[2],x=p-y-a*w;(w||x)&&Gn(t,l)&&(h+=x,g+=w),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!m&&l!==document.body||m&&(n.contains(l)||n===l));return(f&&Math.abs(h)<1||!f&&Math.abs(g)<1)&&(u=!0),u},Ye=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Kn=function(t){return[t.deltaX,t.deltaY]},Qn=function(t){return t&&"current"in t?t.current:t},co=function(t,n){return t[0]===n[0]&&t[1]===n[1]},uo=function(t){return`
38
+ `)},Wn=function(){var t=parseInt(document.body.getAttribute(Ce)||"0",10);return isFinite(t)?t:0},eo=function(){v.useEffect(function(){return document.body.setAttribute(Ce,(Wn()+1).toString()),function(){var t=Wn()-1;t<=0?document.body.removeAttribute(Ce):document.body.setAttribute(Ce,t.toString())}},[])},to=function(t){var n=t.noRelative,e=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;eo();var a=v.useMemo(function(){return Ji(o)},[o]);return v.createElement(Zi,{styles:Ri(a,!n,o,e?"":"!important")})},At=!1;if(typeof window<"u")try{var Qe=Object.defineProperty({},"passive",{get:function(){return At=!0,!0}});window.addEventListener("test",Qe,Qe),window.removeEventListener("test",Qe,Qe)}catch{At=!1}var we=At?{passive:!1}:!1,no=function(t){return t.tagName==="TEXTAREA"},qn=function(t,n){if(!(t instanceof Element))return!1;var e=window.getComputedStyle(t);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!no(t)&&e[n]==="visible")},ro=function(t){return qn(t,"overflowY")},io=function(t){return qn(t,"overflowX")},Hn=function(t,n){var e=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Gn(t,r);if(o){var a=Xn(t,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==e.body);return!1},oo=function(t){var n=t.scrollTop,e=t.scrollHeight,r=t.clientHeight;return[n,e,r]},ao=function(t){var n=t.scrollLeft,e=t.scrollWidth,r=t.clientWidth;return[n,e,r]},Gn=function(t,n){return t==="v"?ro(n):io(n)},Xn=function(t,n){return t==="v"?oo(n):ao(n)},so=function(t,n){return t==="h"&&n==="rtl"?-1:1},lo=function(t,n,e,r,o){var a=so(t,window.getComputedStyle(n).direction),s=a*r,l=e.target,m=n.contains(l),u=!1,f=s>0,h=0,g=0;do{var C=Xn(t,l),I=C[0],p=C[1],y=C[2],E=p-y-a*I;(I||E)&&Gn(t,l)&&(h+=E,g+=I),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!m&&l!==document.body||m&&(n.contains(l)||n===l));return(f&&Math.abs(h)<1||!f&&Math.abs(g)<1)&&(u=!0),u},Ye=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Kn=function(t){return[t.deltaX,t.deltaY]},Qn=function(t){return t&&"current"in t?t.current:t},co=function(t,n){return t[0]===n[0]&&t[1]===n[1]},uo=function(t){return`
39
39
  .block-interactivity-`.concat(t,` {pointer-events: none;}
40
40
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
41
- `)},fo=0,Ie=[];function ho(t){var n=v.useRef([]),e=v.useRef([0,0]),r=v.useRef(),o=v.useState(fo++)[0],a=v.useState(jn)[0],s=v.useRef(t);v.useEffect(function(){s.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Pi([t.lockRef.current],(t.shards||[]).map(Qn),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=v.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!s.current.allowPinchZoom;var x=Ye(p),I=e.current,b="deltaX"in p?p.deltaX:I[0]-x[0],S="deltaY"in p?p.deltaY:I[1]-x[1],N,D=p.target,F=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in p&&F==="h"&&D.type==="range")return!1;var L=Hn(F,D);if(!L)return!0;if(L?N=F:(N=F==="v"?"h":"v",L=Hn(F,D)),!L)return!1;if(!r.current&&"changedTouches"in p&&(b||S)&&(r.current=N),!N)return!0;var A=r.current||N;return lo(A,y,p,A==="h"?b:S)},[]),m=v.useCallback(function(p){var y=p;if(!(!Ie.length||Ie[Ie.length-1]!==a)){var x="deltaY"in y?Kn(y):Ye(y),I=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&co(N.delta,x)})[0];if(I&&I.should){y.cancelable&&y.preventDefault();return}if(!I){var b=(s.current.shards||[]).map(Qn).filter(Boolean).filter(function(N){return N.contains(y.target)}),S=b.length>0?l(y,b[0]):!s.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),u=v.useCallback(function(p,y,x,I){var b={name:p,delta:y,target:x,should:I,shadowParent:po(x)};n.current.push(b),setTimeout(function(){n.current=n.current.filter(function(S){return S!==b})},1)},[]),f=v.useCallback(function(p){e.current=Ye(p),r.current=void 0},[]),h=v.useCallback(function(p){u(p.type,Kn(p),p.target,l(p,t.lockRef.current))},[]),g=v.useCallback(function(p){u(p.type,Ye(p),p.target,l(p,t.lockRef.current))},[]);v.useEffect(function(){return Ie.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",m,we),document.addEventListener("touchmove",m,we),document.addEventListener("touchstart",f,we),function(){Ie=Ie.filter(function(p){return p!==a}),document.removeEventListener("wheel",m,we),document.removeEventListener("touchmove",m,we),document.removeEventListener("touchstart",f,we)}},[]);var C=t.removeScrollBar,w=t.inert;return v.createElement(v.Fragment,null,w?v.createElement(a,{styles:uo(o)}):null,C?v.createElement(to,{gapMode:t.gapMode}):null)}function po(t){for(var n=null;t!==null;)t instanceof ShadowRoot&&(n=t.host,t=t.host),t=t.parentNode;return n}const mo=ji(kn,ho);var Yn=v.forwardRef(function(t,n){return v.createElement(Ke,R({},t,{ref:n,sideCar:mo}))});Yn.classNames=Ke.classNames;var go=function(t){if(typeof document>"u")return null;var n=Array.isArray(t)?t[0]:t;return n.ownerDocument.body},xe=new WeakMap,Je=new WeakMap,Ze={},Pt=0,Jn=function(t){return t&&(t.host||Jn(t.parentNode))},vo=function(t,n){return n.map(function(e){if(t.contains(e))return e;var r=Jn(e);return r&&t.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e})},yo=function(t,n,e,r){var o=vo(n,Array.isArray(t)?t:[t]);Ze[e]||(Ze[e]=new WeakMap);var a=Ze[e],s=[],l=new Set,m=new Set(o),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};o.forEach(u);var f=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(g){if(l.has(g))f(g);else try{var C=g.getAttribute(r),w=C!==null&&C!=="false",p=(xe.get(g)||0)+1,y=(a.get(g)||0)+1;xe.set(g,p),a.set(g,y),s.push(g),p===1&&w&&Je.set(g,!0),y===1&&g.setAttribute(e,"true"),w||g.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",g,x)}})};return f(n),l.clear(),Pt++,function(){s.forEach(function(h){var g=xe.get(h)-1,C=a.get(h)-1;xe.set(h,g),a.set(h,C),g||(Je.has(h)||h.removeAttribute(r),Je.delete(h)),C||h.removeAttribute(e)}),Pt--,Pt||(xe=new WeakMap,xe=new WeakMap,Je=new WeakMap,Ze={})}},bo=function(t,n,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=go(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),yo(r,o,e,"aria-hidden")):function(){return null}},Ot="Dialog",[Zn,la]=ti(Ot),[Co,Y]=Zn(Ot),Rn=t=>{const{__scopeDialog:n,children:e,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=t,l=v.useRef(null),m=v.useRef(null),[u=!1,f]=oi({prop:r,defaultProp:o,onChange:a});return i.jsx(Co,{scope:n,triggerRef:l,contentRef:m,contentId:It(),titleId:It(),descriptionId:It(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:s,children:e})};Rn.displayName=Ot;var er="DialogTrigger",tr=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(er,e),a=fe(n,o.triggerRef);return i.jsx(re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":_t(o.open),...r,ref:a,onClick:oe(t.onClick,o.onOpenToggle)})});tr.displayName=er;var Bt="DialogPortal",[wo,nr]=Zn(Bt,{forceMount:void 0}),rr=t=>{const{__scopeDialog:n,forceMount:e,children:r,container:o}=t,a=Y(Bt,n);return i.jsx(wo,{scope:n,forceMount:e,children:v.Children.map(r,s=>i.jsx(qe,{present:e||a.open,children:i.jsx(zn,{asChild:!0,container:o,children:s})}))})};rr.displayName=Bt;var Re="DialogOverlay",ir=v.forwardRef((t,n)=>{const e=nr(Re,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(Re,t.__scopeDialog);return a.modal?i.jsx(qe,{present:r||a.open,children:i.jsx(Io,{...o,ref:n})}):null});ir.displayName=Re;var Io=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(Re,e);return i.jsx(Yn,{as:xt,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(re.div,{"data-state":_t(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),pe="DialogContent",or=v.forwardRef((t,n)=>{const e=nr(pe,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(pe,t.__scopeDialog);return i.jsx(qe,{present:r||a.open,children:a.modal?i.jsx(xo,{...o,ref:n}):i.jsx(Eo,{...o,ref:n})})});or.displayName=pe;var xo=v.forwardRef((t,n)=>{const e=Y(pe,t.__scopeDialog),r=v.useRef(null),o=fe(n,e.contentRef,r);return v.useEffect(()=>{const a=r.current;if(a)return bo(a)},[]),i.jsx(ar,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oe(t.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=e.triggerRef.current)==null||s.focus()}),onPointerDownOutside:oe(t.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:oe(t.onFocusOutside,a=>a.preventDefault())})}),Eo=v.forwardRef((t,n)=>{const e=Y(pe,t.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return i.jsx(ar,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=t.onCloseAutoFocus)==null||s.call(t,a),a.defaultPrevented||(r.current||(l=e.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var m,u;(m=t.onInteractOutside)==null||m.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=a.target;((u=e.triggerRef.current)==null?void 0:u.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ar=v.forwardRef((t,n)=>{const{__scopeDialog:e,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=t,l=Y(pe,e),m=v.useRef(null),u=fe(n,m);return Ai(),i.jsxs(i.Fragment,{children:[i.jsx(Mn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:i.jsx(Nn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":_t(l.open),...s,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(No,{titleId:l.titleId}),i.jsx(Lo,{contentRef:m,descriptionId:l.descriptionId})]})]})}),zt="DialogTitle",So=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(zt,e);return i.jsx(re.h2,{id:o.titleId,...r,ref:n})});So.displayName=zt;var sr="DialogDescription",To=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(sr,e);return i.jsx(re.p,{id:o.descriptionId,...r,ref:n})});To.displayName=sr;var lr="DialogClose",cr=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(lr,e);return i.jsx(re.button,{type:"button",...r,ref:n,onClick:oe(t.onClick,()=>o.onOpenChange(!1))})});cr.displayName=lr;function _t(t){return t?"open":"closed"}var dr="DialogTitleWarning",[ca,ur]=ei(dr,{contentName:pe,titleName:zt,docsSlug:"dialog"}),No=({titleId:t})=>{const n=ur(dr),e=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
41
+ `)},fo=0,Ie=[];function ho(t){var n=v.useRef([]),e=v.useRef([0,0]),r=v.useRef(),o=v.useState(fo++)[0],a=v.useState(jn)[0],s=v.useRef(t);v.useEffect(function(){s.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Pi([t.lockRef.current],(t.shards||[]).map(Qn),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=v.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!s.current.allowPinchZoom;var E=Ye(p),w=e.current,b="deltaX"in p?p.deltaX:w[0]-E[0],S="deltaY"in p?p.deltaY:w[1]-E[1],N,D=p.target,L=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in p&&L==="h"&&D.type==="range")return!1;var F=Hn(L,D);if(!F)return!0;if(F?N=L:(N=L==="v"?"h":"v",F=Hn(L,D)),!F)return!1;if(!r.current&&"changedTouches"in p&&(b||S)&&(r.current=N),!N)return!0;var M=r.current||N;return lo(M,y,p,M==="h"?b:S)},[]),m=v.useCallback(function(p){var y=p;if(!(!Ie.length||Ie[Ie.length-1]!==a)){var E="deltaY"in y?Kn(y):Ye(y),w=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&co(N.delta,E)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var b=(s.current.shards||[]).map(Qn).filter(Boolean).filter(function(N){return N.contains(y.target)}),S=b.length>0?l(y,b[0]):!s.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),u=v.useCallback(function(p,y,E,w){var b={name:p,delta:y,target:E,should:w,shadowParent:po(E)};n.current.push(b),setTimeout(function(){n.current=n.current.filter(function(S){return S!==b})},1)},[]),f=v.useCallback(function(p){e.current=Ye(p),r.current=void 0},[]),h=v.useCallback(function(p){u(p.type,Kn(p),p.target,l(p,t.lockRef.current))},[]),g=v.useCallback(function(p){u(p.type,Ye(p),p.target,l(p,t.lockRef.current))},[]);v.useEffect(function(){return Ie.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",m,we),document.addEventListener("touchmove",m,we),document.addEventListener("touchstart",f,we),function(){Ie=Ie.filter(function(p){return p!==a}),document.removeEventListener("wheel",m,we),document.removeEventListener("touchmove",m,we),document.removeEventListener("touchstart",f,we)}},[]);var C=t.removeScrollBar,I=t.inert;return v.createElement(v.Fragment,null,I?v.createElement(a,{styles:uo(o)}):null,C?v.createElement(to,{gapMode:t.gapMode}):null)}function po(t){for(var n=null;t!==null;)t instanceof ShadowRoot&&(n=t.host,t=t.host),t=t.parentNode;return n}const mo=ji(kn,ho);var Yn=v.forwardRef(function(t,n){return v.createElement(Ke,R({},t,{ref:n,sideCar:mo}))});Yn.classNames=Ke.classNames;var go=function(t){if(typeof document>"u")return null;var n=Array.isArray(t)?t[0]:t;return n.ownerDocument.body},xe=new WeakMap,Je=new WeakMap,Ze={},Pt=0,Jn=function(t){return t&&(t.host||Jn(t.parentNode))},vo=function(t,n){return n.map(function(e){if(t.contains(e))return e;var r=Jn(e);return r&&t.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e})},yo=function(t,n,e,r){var o=vo(n,Array.isArray(t)?t:[t]);Ze[e]||(Ze[e]=new WeakMap);var a=Ze[e],s=[],l=new Set,m=new Set(o),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};o.forEach(u);var f=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(g){if(l.has(g))f(g);else try{var C=g.getAttribute(r),I=C!==null&&C!=="false",p=(xe.get(g)||0)+1,y=(a.get(g)||0)+1;xe.set(g,p),a.set(g,y),s.push(g),p===1&&I&&Je.set(g,!0),y===1&&g.setAttribute(e,"true"),I||g.setAttribute(r,"true")}catch(E){console.error("aria-hidden: cannot operate on ",g,E)}})};return f(n),l.clear(),Pt++,function(){s.forEach(function(h){var g=xe.get(h)-1,C=a.get(h)-1;xe.set(h,g),a.set(h,C),g||(Je.has(h)||h.removeAttribute(r),Je.delete(h)),C||h.removeAttribute(e)}),Pt--,Pt||(xe=new WeakMap,xe=new WeakMap,Je=new WeakMap,Ze={})}},bo=function(t,n,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=go(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),yo(r,o,e,"aria-hidden")):function(){return null}},Ot="Dialog",[Zn,la]=ti(Ot),[Co,Y]=Zn(Ot),Rn=t=>{const{__scopeDialog:n,children:e,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=t,l=v.useRef(null),m=v.useRef(null),[u=!1,f]=oi({prop:r,defaultProp:o,onChange:a});return i.jsx(Co,{scope:n,triggerRef:l,contentRef:m,contentId:It(),titleId:It(),descriptionId:It(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:s,children:e})};Rn.displayName=Ot;var er="DialogTrigger",tr=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(er,e),a=fe(n,o.triggerRef);return i.jsx(re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":_t(o.open),...r,ref:a,onClick:oe(t.onClick,o.onOpenToggle)})});tr.displayName=er;var Bt="DialogPortal",[wo,nr]=Zn(Bt,{forceMount:void 0}),rr=t=>{const{__scopeDialog:n,forceMount:e,children:r,container:o}=t,a=Y(Bt,n);return i.jsx(wo,{scope:n,forceMount:e,children:v.Children.map(r,s=>i.jsx(qe,{present:e||a.open,children:i.jsx(zn,{asChild:!0,container:o,children:s})}))})};rr.displayName=Bt;var Re="DialogOverlay",ir=v.forwardRef((t,n)=>{const e=nr(Re,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(Re,t.__scopeDialog);return a.modal?i.jsx(qe,{present:r||a.open,children:i.jsx(Io,{...o,ref:n})}):null});ir.displayName=Re;var Io=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(Re,e);return i.jsx(Yn,{as:xt,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(re.div,{"data-state":_t(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),pe="DialogContent",or=v.forwardRef((t,n)=>{const e=nr(pe,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(pe,t.__scopeDialog);return i.jsx(qe,{present:r||a.open,children:a.modal?i.jsx(xo,{...o,ref:n}):i.jsx(Eo,{...o,ref:n})})});or.displayName=pe;var xo=v.forwardRef((t,n)=>{const e=Y(pe,t.__scopeDialog),r=v.useRef(null),o=fe(n,e.contentRef,r);return v.useEffect(()=>{const a=r.current;if(a)return bo(a)},[]),i.jsx(ar,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oe(t.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=e.triggerRef.current)==null||s.focus()}),onPointerDownOutside:oe(t.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:oe(t.onFocusOutside,a=>a.preventDefault())})}),Eo=v.forwardRef((t,n)=>{const e=Y(pe,t.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return i.jsx(ar,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=t.onCloseAutoFocus)==null||s.call(t,a),a.defaultPrevented||(r.current||(l=e.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var m,u;(m=t.onInteractOutside)==null||m.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=a.target;((u=e.triggerRef.current)==null?void 0:u.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ar=v.forwardRef((t,n)=>{const{__scopeDialog:e,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=t,l=Y(pe,e),m=v.useRef(null),u=fe(n,m);return Ai(),i.jsxs(i.Fragment,{children:[i.jsx(Mn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:i.jsx(Nn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":_t(l.open),...s,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(No,{titleId:l.titleId}),i.jsx(Lo,{contentRef:m,descriptionId:l.descriptionId})]})]})}),zt="DialogTitle",So=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(zt,e);return i.jsx(re.h2,{id:o.titleId,...r,ref:n})});So.displayName=zt;var sr="DialogDescription",To=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(sr,e);return i.jsx(re.p,{id:o.descriptionId,...r,ref:n})});To.displayName=sr;var lr="DialogClose",cr=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(lr,e);return i.jsx(re.button,{type:"button",...r,ref:n,onClick:oe(t.onClick,()=>o.onOpenChange(!1))})});cr.displayName=lr;function _t(t){return t?"open":"closed"}var dr="DialogTitleWarning",[ca,ur]=ei(dr,{contentName:pe,titleName:zt,docsSlug:"dialog"}),No=({titleId:t})=>{const n=ur(dr),e=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
42
42
 
43
43
  If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
44
44
 
45
- For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},Fo="DialogDescriptionWarning",Lo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ur(Fo).contentName}}.`;return v.useEffect(()=>{var a;const o=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},Vt=Rn,Do=tr,Ut=rr,$t=ir,kt=or,fr=cr,et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},tt={exports:{}},Mo=tt.exports,hr;function Ao(){return hr||(hr=1,function(t,n){(function(e,r){r()})(Mo,function(){function e(u,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function r(u,f,h){var g=new XMLHttpRequest;g.open("GET",u),g.responseType="blob",g.onload=function(){m(g.response,f,h)},g.onerror=function(){console.error("could not download file")},g.send()}function o(u){var f=new XMLHttpRequest;f.open("HEAD",u,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function a(u){try{u.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(f)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof et=="object"&&et.global===et?et:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),m=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(u,f,h){var g=s.URL||s.webkitURL,C=document.createElement("a");f=f||u.name||"download",C.download=f,C.rel="noopener",typeof u=="string"?(C.href=u,C.origin===location.origin?a(C):o(C.href)?r(u,f,h):a(C,C.target="_blank")):(C.href=g.createObjectURL(u),setTimeout(function(){g.revokeObjectURL(C.href)},4e4),setTimeout(function(){a(C)},0))}:"msSaveOrOpenBlob"in navigator?function(u,f,h){if(f=f||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(e(u,h),f);else if(o(u))r(u,f,h);else{var g=document.createElement("a");g.href=u,g.target="_blank",setTimeout(function(){a(g)})}}:function(u,f,h,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof u=="string")return r(u,f,h);var C=u.type==="application/octet-stream",w=/constructor/i.test(s.HTMLElement)||s.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||C&&w||l)&&typeof FileReader<"u"){var y=new FileReader;y.onloadend=function(){var b=y.result;b=p?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=b:location=b,g=null},y.readAsDataURL(u)}else{var x=s.URL||s.webkitURL,I=x.createObjectURL(u);g?g.location=I:location.href=I,g=null,setTimeout(function(){x.revokeObjectURL(I)},4e4)}});s.saveAs=m.saveAs=m,t.exports=m})}(tt)),tt.exports}var jt=Ao();const Wt=d.memo(t=>{const{file:n,onClose:e}=t,r=d.useRef(null),o=d.useCallback(()=>{var l;if(!r.current)return;const s=document.createElement("canvas");s.width=r.current.width,s.height=r.current.height,(l=s.getContext("2d"))==null||l.drawImage(r.current,0,0,r.current.width,r.current.height),s.toBlob(m=>{m&&navigator.clipboard.write([new ClipboardItem({"image/png":m})])},"image/png")},[]),a=d.useCallback(()=>{jt.saveAs(n,n.name)},[n]);return i.jsx(Vt,{open:!0,onOpenChange:e,children:i.jsx(Ut,{children:i.jsx($t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":"",children:i.jsxs(kt,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(c.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{asChild:!0,children:i.jsx(c.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(c.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{asChild:!0,children:i.jsx(c.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(c.Separator,{orientation:"vertical",size:"sm"}),i.jsx(fr,{asChild:!0,children:i.jsx(c.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})]}),i.jsx("figure",{className:"size-full overflow-hidden p-4 flex justify-center items-center",children:i.jsx("img",{ref:r,className:"max-w-full max-h-full",src:URL.createObjectURL(n),alt:n.name})})]})})})})});Wt.displayName="ImageViewer";const pr=d.memo(t=>{const{children:n}=t,[e,r]=d.useState(null),o=d.useCallback(()=>{r(null)},[]),a=d.useCallback(m=>{r(m(o))},[o]),s=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=d.useMemo(()=>a,[a]);return i.jsxs(In.Provider,{value:l,children:[n,e&&i.jsx(Wt,{file:e.file,onClose:s})]})});pr.displayName="FileViewerProvider";const J=t=>{const{className:n,label:e,children:r,severity:o,inputId:a,labelId:s,image:l}=t,[m,u]=d.useState(void 0),f=je(),h=o?ue[o]:"base";d.useEffect(()=>{l instanceof Promise?l.then(u).catch(console.error):u(l)},[l]);const g=m?URL.createObjectURL(m):void 0,C=d.useCallback(()=>{m&&f(()=>({file:m}))},[f,m]);return i.jsxs("div",{className:"flex flex-col gap-1",children:[m&&i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:g,alt:m.name,onClick:C}),i.jsx("label",{className:ye(n,"flex flex-col gap-1 w-max"),htmlFor:a,children:i.jsx(c.Text,{accentColor:h,size:"sm",id:s,weight:"medium",children:e})}),r]})},qt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?ue[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,!!n&&i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(c.Text,{accentColor:o,size:"xs",children:n})})]})},Z=t=>{const{children:n,...e}=t;return i.jsx(qt,{...e,children:n})},Po=[!0,"true"],Ht=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onBlur:g,onChange:C}=u,w=a?null:l,p=a?"":m,y=Po.includes(u.value),x=d.useCallback(()=>{g(y)},[g,y]);return i.jsx(Z,{helpText:w,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,className:"items-center flex-row-reverse justify-end gap-2",children:i.jsx(c.Checkbox.Root,{id:n,name:h,value:y.toString(),checked:y,onCheckedChange:C,onBlur:x,size:"sm",accentColor:"primary",variant:"surface",...f,children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})})})})});Ht.displayName="BooleanInput";const mr={...G,type:"boolean"},Se=class Se extends k{constructor(e){super({...e,type:"boolean"});T(this,"onlyValidateAfterTouched",!1)}isBlank(e){return this.required&&!e}getValueFromChangeEvent(e){return typeof e=="boolean"?e:e.target.checked}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="boolean")throw new Error("Type mismatch.");return new Se(e)}getInput(e){return i.jsx(Ht,{...e,field:this})}};T(Se,"fieldTypeName","Checkbox"),T(Se,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),T(Se,"Icon",$.RiCheckboxCircleLine);let Ee=Se;const Gt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onChange:g,onBlur:C}=u,[w,p]=d.useState(!1),y=a?null:l,x=a?"":m,I=u.value?new Date(u.value):void 0,b=d.useCallback(N=>{N&&g(N.toISOString()),p(!1)},[g]),S=d.useCallback(N=>{p(N),N||C(u.value)},[u.value,C]);return i.jsx(Z,{helpText:y,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:x,image:a?void 0:s.image,children:i.jsxs(c.Popover.Root,{open:w,onOpenChange:S,children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:"sm",...f,children:[I?I.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd",i.jsx(c.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(c.Popover.Content,{align:"start",children:i.jsx(c.DayPicker,{required:!1,mode:"single",variant:"solid",selected:I,onSelect:b})})]})})})});Gt.displayName="DateInput";const gr={...G,type:"date"},Te=class Te extends k{constructor(e){super({...e,type:"date"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return e.target.value}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Te(e)}getInput(e){return i.jsx(Gt,{field:this,...e})}};T(Te,"fieldTypeName","Date"),T(Te,"fieldTypeDescription","Allows specifying a date."),T(Te,"Icon",$.RiCalendarLine);let nt=Te;const vr=d.memo(t=>{const{field:n,...e}=t,[{value:r}]=U.useField(n.options.clonedFieldIdentifier),o=d.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?ht(a):null},[n.options,r]);return Xt(o,e)});vr.displayName="FieldInputCloner";const Oo={...G,type:"custom"};class rt extends k{constructor(e,r){super({...e,type:"custom"});T(this,"Component");T(this,"options");this.options=e,this.Component=r}serialize(){throw new Error("Serializing only supported for public input types.")}getInput(e){const r=this.Component;return i.jsx(r,{field:this,...e})}}T(rt,"fieldTypeName","Custom"),T(rt,"fieldTypeDescription","Allows re-rendering of field already in the form");class Bo extends rt{constructor(n){super(n,vr)}}const Xt=(t,n)=>d.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),ze=(t,n)=>{const e=d.useMemo(()=>t.map(r=>i.jsx(d.Fragment,{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-4",children:e})};let it;const zo=new Uint8Array(16);function _o(){if(!it&&(it=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!it))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return it(zo)}const _=[];for(let t=0;t<256;++t)_.push((t+256).toString(16).slice(1));function Vo(t,n=0){return _[t[n+0]]+_[t[n+1]]+_[t[n+2]]+_[t[n+3]]+"-"+_[t[n+4]]+_[t[n+5]]+"-"+_[t[n+6]]+_[t[n+7]]+"-"+_[t[n+8]]+_[t[n+9]]+"-"+_[t[n+10]]+_[t[n+11]]+_[t[n+12]]+_[t[n+13]]+_[t[n+14]]+_[t[n+15]]}const yr={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Uo(t,n,e){if(yr.randomUUID&&!t)return yr.randomUUID();t=t||{};const r=t.random||(t.rng||_o)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Vo(r)}const me=t=>t.type==="section",ot=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),$o=t=>{if(!t)return;const n=t.fields;let e=[];const r=[];for(const o of n)o.type==="section"?(e.length>0&&(r.push(ot(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(ot("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function Kt(t,n,e){const r=Array.from(t),[o]=r.splice(n,1);if(!o)throw new Error("Could not find field to reorder.");return r.splice(e,0,o),r}function br(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function at(t,n){const e=Array.from(t);return e.splice(n,1),e}const Qt=()=>Uo(),Cr=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=Cr(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},wr=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),st=(t,n,e,r,o)=>{const a={...e,identifier:Qt()},s=Q(r,t);if(s===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(s))throw new Error("Parent path must point to an array.");const l=br(s,n,a);o(t,l).then()},ko=(t,n,e)=>{const r={...ot(),label:""};st("fields",t,r,n,e)},Yt=()=>{const{showError:t}=c.useToast(),n=d.useCallback((r,o,a,s,l,m)=>{const u=r[o];if(!u)throw new Error("Could not find section context.");let f=typeof u.conditionIndex<"u"?Math.max(u.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(f=Math.min(f,h.index-1));if(f!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}m("fields",Kt(l.fields,a,f))},[t]),e=d.useCallback((r,o,a,s,l,m,u)=>{var f;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)u(`fields.${o}.fields`,Kt(r.fields,a,m)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((f=s.condition)==null?void 0:f.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}u(`fields.${o}.fields`,at(r.fields,a)).then(),u(`fields.${l}.fields`,br(s.fields,m,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},Jt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),h=a?null:l,g=a?"":m,{name:C,onChange:w,onBlur:p}=u,y=d.useMemo(()=>Array.isArray(u.value)?u.value:[],[u.value]),x=`${n}-droppable`,{disabled:I}=f,[b,S]=d.useState(""),[N,D]=d.useState(""),F=N||h,L=d.useCallback(P=>{w(P),p(P)},[w,p]),A=d.useCallback(P=>{y.findIndex(q=>q===P.target.value.trim())>=0?D("All options must be unique"):P.target.value?D(""):D("Option cannot be empty"),S(P.target.value)},[S,y]),O=d.useCallback(()=>{if(N)return;if(!b.trim()){D("Option cannot be empty");return}const P=b.trim();L([...y,P]),S("")},[b,N,L,y]),H=d.useCallback(P=>{P.key==="Enter"&&(P.preventDefault(),O())},[O]),te=d.useCallback(P=>{L(at(y,P))},[y,L]),z=d.useCallback(P=>{if(!P.destination)return;const q=P.source.index,le=P.destination.index;L(Kt(y,q,le))},[L,y]),K=d.useCallback(()=>{p(y)},[p,y]);return i.jsx(ie.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Z,{helpText:F,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:(!I||y.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{value:b,onChange:A,onKeyDown:H,id:n,placeholder:s.placeholder,onBlur:K,name:C,...f})}),i.jsx(c.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!N||I,onClick:O,children:i.jsx(c.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(ie.Droppable,{droppableId:x,children:P=>i.jsxs("div",{className:"flex flex-col",...P.droppableProps,ref:P.innerRef,children:[y.map((q,le)=>i.jsx(ie.Draggable,{draggableId:`${q}-draggable`,index:le,isDragDisabled:I,children:({draggableProps:ne,dragHandleProps:ce,innerRef:Be})=>i.jsxs(c.Badge,{...ce,...ne,ref:Be,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{children:typeof q=="object"&&"label"in q?q.label:q}),i.jsx(c.IconButton,{size:"xs",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:I,onClick:()=>{te(le)},children:i.jsx(c.RiIcon,{icon:"RiCloseLargeLine"})})]})},q)),P.placeholder]})})]})})});Jt.displayName="MultiStringInput";const Ir={...G,type:"multi-string",minimum_length:0,maximum_length:null},Ne=class Ne extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});T(this,"minLength");T(this,"maxLength");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=a??"Press enter to add a new option"}getValueFromChangeEvent(e){if(Array.isArray(e))return e;throw new Error("Expected an array.")}getInput(e){return i.jsx(Jt,{field:this,...e})}serialize(){return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}isBlank(e){return super.isBlank(e)||e.length===0}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(Array.isArray(r)&&r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(Array.isArray(r)&&r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){if(e.type!=="multi-string")throw new Error("Type mismatch.");return new Ne(e)}};T(Ne,"fieldTypeName","Multi-string"),T(Ne,"fieldTypeDescription","Allows the user to provide multiple unique strings."),T(Ne,"Icon",$.RiListCheck);let _e=Ne;const Zt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=X(t),{name:C,onBlur:w,onChange:p,value:y}=u,x=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{const L=Number.parseFloat(F.target.value),A=Number.isNaN(L)?"":L;S(A),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(A))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(Z,{helpText:x,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,onChange:N,onBlur:D,value:b,type:"number",min:s.minimum,max:s.maximum,step:s.integers?1:.1,placeholder:s.placeholder,...g})})})})});Zt.displayName="NumberInput";const xr={...G,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},Er=t=>"fields"in t,ee=class ee extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:s="Enter a number",...l}=e;super({...l,type:"number"});T(this,"minimum");T(this,"maximum");T(this,"integers");T(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=s}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ee({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new ee({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`,formValidators:[this._validateMax(e)]}),showDirectly:!1},{field:new Ee({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(a=>{if(typeof a=="number"&&a>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super._serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}static deserialize(e){if(e.type!=="number")throw new Error("Type mismatch.");return new ee(e)}getInput(e){return i.jsx(Zt,{field:this,...e})}};T(ee,"fieldTypeName","Number"),T(ee,"fieldTypeDescription","Allows specifying a number within a given range."),T(ee,"Icon",$.RiHashtag),T(ee,"_validateMin",e=>(r,o)=>{const a=Er(o)?Q(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),T(ee,"_validateMax",e=>(r,o)=>{const a=Er(o)?Q(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let se=ee;const Rt=d.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:m,fieldProps:u},f]=X(t),{name:h,onBlur:g,onChange:C,value:w}=u,[p,y]=d.useState(!1),x=l?null:o,I=l?"":r,b=d.useCallback(D=>{C(D),y(!1)},[C]),S=d.useCallback(()=>{C("")},[C]),N=d.useCallback(D=>{y(D),D||g(w)},[g,w]);return i.jsx(Z,{helpText:x,severity:s,children:i.jsxs(J,{size:a,severity:s,inputId:n,labelId:e,label:I,image:l?void 0:m.image,className:"flex-col items-start justify-start gap-2",children:[i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(Vt,{open:p,onOpenChange:N,children:[i.jsx(Do,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",variant:"soft",size:"sm",accentColor:"base",...f,children:[i.jsx(c.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]})}),i.jsxs(Ut,{children:[i.jsx($t,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(kt,{className:"fixed inset-0",children:i.jsx(en,{onQrScan:b})})]})]}),w&&i.jsx(c.RiIcon,{icon:"RiCheckLine",className:"align-bottom text-(--primary-a11)"})]}),!!w&&i.jsx(c.Card,{className:"max-w-full w-max",size:"sm",children:i.jsxs("div",{className:"max-w-full w-max flex justify-between gap-2",children:[i.jsx("code",{className:"bg-(--base-a3) truncate text-sm",children:w}),i.jsx(c.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Rt.displayName="QrInput";const en=d.memo(t=>{const{onQrScan:n}=t,e=d.useRef(null),[r,o]=d.useState(!1);return d.useEffect(()=>{if(!e.current)return;const a=new Kr(e.current,s=>{const l=s.data;n(l),a.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});o(!0),a.start().finally(()=>{o(!1)})},[n]),i.jsxs("div",{className:"relative flex h-full w-full flex-col justify-center gap-2 bg-(--color-background)",children:[i.jsx("div",{className:"absolute top-0 flex w-full p-2",children:i.jsx(fr,{asChild:!0,children:i.jsx(c.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{className:"size-full",ref:e}),r&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(c.Spinner,{})})]})]})});en.displayName="QrScanner";const Sr={...G,type:"qr"},Fe=class Fe extends k{constructor(e){super({...e,type:"qr"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Fe(e)}getInput(e){return i.jsx(Rt,{...e,field:this})}};T(Fe,"fieldTypeName","QR"),T(Fe,"fieldTypeDescription","Used for scanning/reading QR codes."),T(Fe,"Icon",$.RiQrCodeLine);let lt=Fe;class Tr extends k{constructor(e){const{placeholder:r="",...o}=e;super(o);T(this,"options");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(s=>(typeof s=="string"&&(s={label:s,value:s}),a.add(s.label),s)),a.size!==e.options.length&&console.error(`${e.options.length-a.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,e.options)}_serialize(){return{...super._serialize(),options:this.options,placeholder:this.placeholder}}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new _e({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const jo=t=>t?Array.isArray(t)?t:[t]:[],tn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onChange:g,onBlur:C}=u,w=a?null:l,p=a?"":m,y=d.useMemo(()=>jo(u.value),[u.value]),x=d.useCallback(b=>{g(b),C(b)},[C,g]),I=d.useCallback(b=>{b||C(y)},[y,C]);return i.jsx(Z,{helpText:w,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{onOpenChange:I,align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",variant:"surface",type:"button",size:"sm",accentColor:"base",...f,children:[i.jsx("span",{className:"truncate",children:y.length>0?y.join(", "):s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsxs(c.Menu.MultiSelectGroup,{values:y,onValuesChange:x,children:[i.jsxs(c.Menu.SelectAllItem,{children:[i.jsx(c.Menu.CheckboxItemIndicator,{children:b=>b?i.jsx(c.RiIcon,{icon:"RiSubtractLine"}):i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(b=>i.jsxs(c.Menu.MultiSelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))]})})})]})})})});tn.displayName="MultiSelectInput";const Nr={...G,type:"multi-select",options:[]},Le=class Le extends Tr{constructor(n){const{placeholder:e="Select one or more...",...r}=n;super({...r,placeholder:e,type:"multi-select"})}getValueFromChangeEvent(n){if(Array.isArray(n))return n;throw new Error("Expected an array.")}isBlank(n){return super.isBlank(n)||n.length===0}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="multi-select")throw new Error("Type mismatch.");return new Le(n)}getInput(n){return i.jsx(tn,{field:this,...n})}};T(Le,"fieldTypeName","Multi-select"),T(Le,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),T(Le,"Icon",$.RiCheckboxLine);let Ve=Le;const nn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onChange:g,onBlur:C,value:w}=u,p=a?null:l,y=a?"":m,x=d.useCallback(b=>{b&&(g(b),C(b))},[C,g]),I=d.useMemo(()=>s.options.find(b=>b.value===w),[s.options,w]);return i.jsx(Z,{helpText:p,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:y,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:"sm",...f,children:[i.jsx("span",{className:"truncate",children:I?I.label:s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsx(c.Menu.SelectGroup,{required:!0,value:w,onValueChange:x,children:s.options.map(b=>i.jsxs(c.Menu.SelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))})})})]})})})});nn.displayName="SelectInput";const Fr={...G,type:"select",options:[]},De=class De extends Tr{constructor(n){const{placeholder:e="Select one...",...r}=n;super({...r,placeholder:e,type:"select"})}getValueFromChangeEvent(n){return typeof n=="string"?n:n.target.value}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="select")throw new Error("Type mismatch.");return new De(n)}getInput(n){return i.jsx(nn,{field:this,...n})}};T(De,"fieldTypeName","Dropdown"),T(De,"fieldTypeDescription","Allows the user to select a single option from a list of options."),T(De,"Icon",$.RiMenuFoldLine);let Ue=De;const Lr=t=>"fields"in t;class ct extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);T(this,"minLength");T(this,"maxLength");T(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):be,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,formValidators:[this._validateMin(e)],integers:!0}),showDirectly:!1},{field:new se({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:be,formValidators:[this._validateMax(e)],integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?null:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}}T(ct,"_validateMin",e=>(r,o)=>{const a=Lr(o)?Q(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),T(ct,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Lr(o)?Q(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const rn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=X(t),{name:C,onBlur:w,onChange:p,value:y}=u,x=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{S(F.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(F.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(Z,{helpText:x,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,value:b,type:s.inputType,placeholder:s.placeholder,onChange:N,onBlur:D,...g})})})})});rn.displayName="StringInput";const Dr={...G,type:"string",maximum_length:ke,input_type:"text"},Me=class Me extends ct{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(ke,e.maxLength):ke,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});T(this,"inputType");this.inputType=r}serialize(){return{...super._serialize(),input_type:this.inputType}}static deserialize(e){if(e.type!=="string")throw new Error("Type mismatch.");const{maximum_length:r,minimum_length:o,input_type:a,...s}=e;return new Me({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(rn,{field:this,...e})}};T(Me,"fieldTypeName","Short Text"),T(Me,"fieldTypeDescription",`Short text fields can hold up to ${ke} characters on a single line.`),T(Me,"Icon",$.RiInputField);let dt=Me;const on=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=X(t),{name:C,onBlur:w,onChange:p,value:y}=u,x=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{S(F.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(F.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(Z,{helpText:x,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.TextArea,{id:n,value:b,name:C,onChange:N,onBlur:D,className:"field-sizing-content min-h-12",placeholder:s.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:"sm",...g})})})});on.displayName="TextInput";const Mr={...G,type:"text",maximum_length:be},Ae=class Ae extends ct{constructor(n){const e=n.maxLength?Math.min(be,n.maxLength):be,r=n.minLength?Math.min(n.minLength,e):void 0;super({...n,maxLength:e,minLength:r,type:"text"})}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="text")throw new Error("Type mismatch.");const{maximum_length:e,minimum_length:r,...o}=n;return new Ae({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(on,{field:this,...n})}};T(Ae,"fieldTypeName","Paragraph"),T(Ae,"fieldTypeDescription",`Paragraph fields can hold up to ${be} characters and can have multiple lines.`),T(Ae,"Icon",$.RiAlignJustify);let ut=Ae;const Ar=d.memo(d.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,...l}=t;return i.jsxs("div",{className:ye(s,"relative flex h-[200px] w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...l,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(c.Spinner,{})}),i.jsx("div",{className:"-m-4 flex max-w-full grow items-center justify-center overflow-hidden bg-clip-padding",children:e&&!o&&i.jsx("img",{className:"max-w-full object-cover",src:URL.createObjectURL(e),alt:r??e.name})}),i.jsxs("div",{className:ye("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx($e,{fileType:e.type}),i.jsx(c.Text,{className:"truncate",size:"sm",children:o??(e==null?void 0:e.name)}),a]})]})})),Wo=t=>{const n=["byte","kilobyte","megabyte"];let e=t,r=0;for(;e>1e3&&r<n.length-1;)e/=1e3,r++;return new Intl.NumberFormat([],{maximumFractionDigits:Math.max(0,r-1),style:"unit",unit:n[r]}).format(e)},Pr=d.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:m},u]=X(t),{name:f,value:h,onChange:g,onBlur:C}=m;let[{label:w}]=X(t);w=s?"":w;const p=d.useRef(null),y=d.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),x=d.useCallback(()=>{var L;(L=p.current)==null||L.click()},[]),I=d.useCallback(()=>{if(!p.current)return;const L=p.current.files;if(!L){C([]);return}const A=Array.from(L),O=[...h,...A];g(O),C(O)},[C,g,h]),b=d.useCallback(L=>{const A=[...h];A.splice(L,1),g(A)},[h,g]);d.useEffect(()=>{if(!p.current)return;const L=new AbortController;return p.current.addEventListener("cancel",()=>{C([])},{signal:L.signal}),()=>{L.abort()}},[C,h]);const S=h?"Select new files":"Select files",N=h?"Select new file":"Select a file",D=l.maxFiles>1?S:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Z,{helpText:y,severity:o,children:i.jsxs(J,{size:r,severity:o,inputId:n,labelId:e,label:w,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(c.Button,{className:"w-max",size:"sm",variant:"soft",accentColor:"base",onClick:x,id:"upload-input-upload-button",type:"button",...u,children:[i.jsx(c.RiIcon,{icon:"RiUpload2Line"})," ",D]})}),i.jsx("input",{id:n,name:f,type:"file",ref:p,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,className:"hidden",onChange:I,value:""})]})}),Array.isArray(h)&&h.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:h.map((L,A)=>i.jsx(Or,{field:l,file:L,onRemove:()=>{b(A)},disabled:u.disabled},A))})]})});Pr.displayName="UploadInput";const Or=d.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=d.useState(null),l=je(),m=d.useMemo(()=>a&&e.getError([a]),[e,a]),{url:u,name:f}=d.useMemo(()=>{let p=null,y,x;return a!=null&&a.type.startsWith("image/")&&(p=URL.createObjectURL(a)),a?(y=a.name,x=Wo(a.size)):(y="Downloading...",x="..."),{url:p,name:y,size:x}},[a]);d.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=d.useCallback(p=>{if(p.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const y=new Blob([a]);jt.saveAs(y,f)},[f,a]),g=d.useCallback(p=>{p.stopPropagation(),r()},[r]),C=d.useCallback(()=>{a&&l(p=>({file:a,onDelete:o?void 0:()=>{r(),p()}}))},[o,r,l,a]),w=d.useMemo(()=>i.jsxs(c.ButtonGroup,{className:"flex grow justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(c.IconButton,{"aria-label":`Download ${f}`,type:"button",onClick:h,disabled:!a,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(c.IconButton,{type:"button","aria-label":`Remove ${f}`,disabled:o,onClick:g,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),[o,g,h,f,a]);return u?i.jsx(Ar,{className:"cursor-pointer",onClick:C,file:a,error:m??void 0,rightSlot:w}):i.jsx(Ct,{file:a,error:m??void 0,rightSlot:w})});Or.displayName="DisplayFile";const qo={...G,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Pe=class Pe extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});T(this,"extensions");T(this,"maxFileSize");T(this,"maxFiles");T(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}getValueFromChangeEvent(e){return Array.from(e.target.files||[])}isBlank(e){return super.isBlank(e)||e.length===0}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new se({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${ft}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:ft,integers:!0}),showDirectly:!1},{field:new Ve({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxFileSize??ft,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(s=>{if(s&&s.some(l=>l.size>o))return`Files must be at most ${r}MB.`}),e.push(s=>{if(s&&s.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super._serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}static deserialize(e){if(e.type!=="upload")throw new Error("Type mismatch.");return new Pe(e)}getInput(e){return i.jsx(Pr,{field:this,...e})}};T(Pe,"fieldTypeName","Upload"),T(Pe,"fieldTypeDescription","Allows a file to be uploaded."),T(Pe,"Icon",$.RiUpload2Line);let an=Pe;const sn={date:nt,number:se,boolean:Ee,select:Ue,string:dt,text:ut,custom:rt,upload:an,qr:lt,"multi-string":_e,"multi-select":Ve},Ho={date:gr,number:xr,boolean:mr,select:Fr,string:Dr,text:Mr,custom:Oo,upload:qo,qr:Sr,"multi-string":Ir,"multi-select":Nr},ft=50,Go=ft*1e3*1e3,ln=t=>{const n=t.type;return sn[n].deserialize(t)},ht=t=>t.type==="section"?j.deserialize(t):ln(t);function Br(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>ht(r)),meta:{readonly:e}}}function cn(t){const n=[];for(const e of t.fields)if(e instanceof j)for(const r of e.fields)n.push(r);else{if(!(e instanceof k))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Xo(t,n){const e=cn(t),r={};for(const o of e){const a=n[o.identifier]??null;a!==null?r[o.identifier]=o.decodeJsonToValue(a):r[o.identifier]=a}return r}function Ko(t,n){const e=cn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function pt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function dn(t,n){if(!t)return!0;if(pt(n)||pt(t.value))throw new Error("Conditions do not support file uploads");const e=Array.isArray(n)?n.map(o=>typeof o=="string"?o:o.value):n,r=Array.isArray(t.value)?t.value.map(o=>typeof o=="string"?o:o.value):t.value;if(Array.isArray(r)&&Array.isArray(e)){for(const o of r)if(!e.includes(o))return!1;return!0}return r===n}const zr=d.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:m}=U.useFormikContext(),u=s!=null&&s.identifier?Q(l,s.identifier):void 0,f=d.useMemo(()=>u===void 0||dn(s,u),[s,u]);d.useEffect(()=>{if(!f)for(const g of a)m(g.getId(),"").then()},[f,a,m]);const h=ze(a,e);return f?i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-4",children:[(r||o)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(c.Heading,{size:"md",children:r}),i.jsx(c.Text,{accentColor:"base",children:o})]}),i.jsx(c.Separator,{size:"full"})]}),h]})}):null});zr.displayName="FieldSectionLayout";const Oe=class Oe extends wt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});T(this,"label");T(this,"fields");T(this,"condition");this.fields=o,this.condition=a,this.label=r,s===!1&&(this.condition=null)}static getFieldCreationSchema(e,r=""){if(e.length===0)return[];const o=r&&`${r}.`;return[{field:new Ee({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new Oe({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Ue({label:"Field",description:"The field to use for the condition.",options:e.map(a=>!a.label||a.type==="upload"?null:{label:a.label,value:a.identifier}).filter(a=>!!a),identifier:`${o}condition.identifier`,required:!0}),new Bo({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const s=e.find(l=>l.identifier===a);return s?{...s,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:s.type!=="boolean"}:(console.error("Could not find field with identifier",a),null)}})]}),showDirectly:!1}]}static deserialize(e){if(e.type!=="section")throw new Error("Invalid type");if(!Array.isArray(e.fields))throw new Error(`Invalid fields: ${e.fields} (not an array)`);const r=e.fields.map(ln);return new Oe({...e,fields:r})}conditional(){return this.condition!==null}serialize(){return{...super._serialize(),label:this.label,condition:this.condition,conditional:this.conditional(),fields:this.fields.map(e=>e.serialize())}}getErrors(e){const r={};for(const o of this.fields){const a=o.getId(),s=o.getError(Q(e,a),e);s&&yt(r,o.getId(),s)}return r}getInput(e){return i.jsx(zr,{field:this,...e})}};T(Oe,"fieldTypeName","Section"),T(Oe,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let j=Oe;const ge=t=>Object.keys(t).length>0,mt=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof j){if(r.condition){const{identifier:o}=r.condition;if(!dn(r.condition,Q(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof k))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(Q(n,o),n);a&&yt(e,o,a)}if(ge(e))return e},Qo=[null,void 0],gt=(t,n)=>t.reduce((e,r)=>r instanceof j?{...e,...gt(r.fields,n)}:(Qo.includes(Q(e,r.getId()))&&yt(e,r.getId(),""),e),Qr(n)),Yo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},_r=d.memo(d.forwardRef((t,n)=>{const{schema:e,values:r={},onValuesChange:o,onSubmit:a=Yo,submitText:s="Submit",cancelText:l,onCancel:m,onDirty:u,onDirtyChange:f,hideTitle:h=!e.title,hideDescription:g,className:C,buttonProps:w}=t,{readonly:p}=e.meta,y=d.useMemo(()=>crypto.randomUUID(),[]),x=U.useFormik({initialValues:gt(e.fields,r),onSubmit:a,validate:F=>mt(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:I}=x,b=d.useMemo(()=>typeof e.title=="string"?i.jsx(c.Heading,{size:"md",children:e.title}):e.title,[e.title]),S=d.useMemo(()=>typeof e.description=="string"?i.jsx(c.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),N=d.useCallback((F,L)=>{o==null||o({...x.values,[F]:L},{[F]:L})},[x.values,o]),D=ze(e.fields,{formId:y,disabled:p,onValuesChange:N});return d.useEffect(()=>{I&&u&&u(),f&&f(I)},[I,u,f]),i.jsx(U.FormikProvider,{value:x,children:i.jsxs("form",{id:y,ref:n,className:ye(C,"flex flex-col gap-2"),onSubmit:x.handleSubmit,children:[!h&&i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-1",children:[b,!g&&S]})}),D,!p&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&i.jsxs(c.Button,{accentColor:ue.danger,...w,type:"button",onClick:m,children:[i.jsx(c.RiIcon,{icon:"RiCloseLine"}),l]}),i.jsxs(c.Button,{...w,type:"submit",disabled:!x.isValid,accentColor:"success",children:[i.jsx(c.RiIcon,{icon:"RiCheckLine"}),s]})]})]})})})),ve=d.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=U.useFormikContext(),[o,a,s]=U.useField(n),l=d.useMemo(()=>{const m=u=>{s.setValue(u,!1)};return e({value:o.value,meta:a,setValue:m,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});ve.displayName="PatchField";const Jo=d.memo(d.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:m,...u}=t,f=d.useMemo(()=>gt(r.fields,o),[r.fields,o]),h=d.useCallback(I=>{const b={};for(const S in I){const N=I[S];N!==f[S]&&N!==void 0&&(b[S]=N)}return b},[f]),g=d.useCallback(I=>{const b=h(I);l&&!ge(b)||a(b)},[h,a,l]),C=d.useCallback(I=>{const b=mt(r,I);if(b&&s(b),m){const S=h(I);m(ge(S))}return b},[r,m,s,h]),w=U.useFormik({initialValues:f,onSubmit:g,validate:C,validateOnBlur:!1,validateOnChange:!1}),p=d.useCallback(()=>{if(m){const I=h(w.values);ge(I)&&m(!0)}},[w.values,h,m]),{errors:y,resetForm:x}=w;return d.useEffect(()=>{ge(y)&&x({values:f,errors:{}})},[y,f,x]),i.jsx(U.FormikProvider,{value:w,children:i.jsx("form",{...u,ref:n,onSubmit:w.handleSubmit,onChange:p,children:e})})})),vt="form-builder",Zo=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],un={...sn,section:j},Ro=(t,n)=>{var r;const e={...t};switch(n.type){case"release":for(const o in e)e[o].disabled=!1;return e;case"hold":for(const o in e)(r=e[o])!=null&&r.conditionFields.has(n.fieldId)&&(e[o].disabled=!0);return e;case"update":return n.state}},ea=(t,n)=>{if(n)for(let e=0;e<t.length;e++){const r=t[e];if(r){for(const o of r.fields)if(o.identifier===n)return e}}},Vr=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const s=t[a];if(!s)throw new Error("Field is undefined.");const l=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,m=new Set(l);(r=s.condition)!=null&&r.identifier&&m.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:m,conditionIndex:ea(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},fn=d.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:s,upload:l}=t;if(e!=="section"&&!l)throw new Error("Upload function prop must be defined for non-section fields.");const{values:m}=U.useFormikContext(),u=d.useRef(null),f=d.useMemo(()=>{const h=[{Icon:$.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:$.RiDeleteBin7Fill,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:$.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var g;(g=u.current)==null||g.click()}}}),(r===void 0&&n!==m.fields.length-1||r!==void 0&&(r<m.fields.length-1||n!==m.fields[r].fields.length-1))&&h.unshift({Icon:$.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{s("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:$.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,m.fields]);return i.jsxs(i.Fragment,{children:[i.jsx(c.ButtonGroup,{className:"mx-2 hidden flex-col gap-0.5 sm:flex",variant:"ghost",accentColor:"base",size:"sm",children:f.map(h=>i.jsx(c.IconButton,{type:"button","aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsx(c.IconButton,{variant:"ghost",accentColor:"base","aria-label":"Actions menu",size:"sm",type:"button",children:i.jsx(c.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(c.Menu.Content,{children:f.map(h=>{var g;return i.jsxs(c.Menu.Item,{onClick:(g=h.buttonProps)==null?void 0:g.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:u,type:"file",accept:"image/*",onChange:l})]})});fn.displayName="FieldActions";const hn=d.memo(t=>{const{popoverInputs:n,hasError:e,...r}=t;return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...e&&{color:ue.danger},children:[i.jsx(c.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(c.Popover.Content,{size:"sm",...r,children:i.jsx("div",{className:"flex w-full max-w-[350px] flex-col",children:n})})]})});hn.displayName="FieldSettingsPopover";const Ur=(t=()=>null)=>d.useMemo(()=>Zo.map(n=>n.map(e=>{const r=sn[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),pn=d.memo(t=>{var Be,mn,Hr,Gr,Xr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=U.useFormikContext(),m=Ur(),u=je(),f=d.useRef(null),h=576,[g,C]=d.useState(f.current&&f.current.getBoundingClientRect().width>=h);d.useEffect(()=>{const M=f.current;if(M){const B=new ResizeObserver(W=>{W[0]&&C(W[0].contentRect.width>=h)});return B.observe(M),()=>{B.disconnect()}}},[]);const[w,p]=d.useState(void 0);d.useEffect(()=>{me(r)?p(void 0):r.image instanceof Promise?r.image.then(p).catch(console.error):p(r.image)},[r]);const y=w?URL.createObjectURL(w):void 0,x=d.useCallback(M=>{M.stopPropagation();const{image:B,...W}=r;s(`${n}.${e}`,W).then()},[e,r,n,s]);d.useEffect(()=>{me(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const I=d.useMemo(()=>{var M,B;return me(r)?(B=Cr(a.fields,(M=r.condition)==null?void 0:M.identifier))==null?void 0:B.label:void 0},[r,a.fields]),b=me(r)?Array.isArray((Be=r.condition)==null?void 0:Be.value)?"contains all of":"equals":void 0;let S;if(me(r)){if(pt((mn=r.condition)==null?void 0:mn.value))throw new Error("File values are not supported for conditions.");S=Array.isArray((Hr=r.condition)==null?void 0:Hr.value)?r.condition.value.map(M=>typeof M=="string"?M:M.label).join(", "):(Xr=(Gr=r.condition)==null?void 0:Gr.value)==null?void 0:Xr.toString()}const N=d.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),D=d.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),F=r.type,L=un[F],[A,O]=d.useMemo(()=>{let M=[],B=[];if(L===j){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const W=L.getFieldCreationSchema(o,`${n}.${e}`);M=M.concat(W.filter(V=>V.showDirectly).map(V=>V.field)),B=B.concat(W.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(L.prototype instanceof k))throw new Error(`Field must be an instance of BaseField. Got ${L.toString()}.`);const W=L.getFieldCreationSchema(`${n}.${e}`);g?(M=[...M,...W.filter(V=>V.showDirectly).map(V=>V.field)],B=[...B,...W.filter(V=>!V.showDirectly).map(V=>V.field)]):B=[...B,...W.map(V=>V.field)]}return[M,B]},[L,o,n,e,g]),H=ze(A,{formId:vt,disabled:!1,...L===j&&{size:"sm"}}),te=ze(O,{formId:vt,disabled:!1});let z=O.length>0;me(r)&&O.length>0&&(z=r.conditional);const K=O.some(M=>{const B=Q(l,L===j?`${n}.${e}.condition`:M.getId());return B&&(typeof B!="object"||ge(B))}),P=K?ue.danger:void 0,q=d.useMemo(()=>ht(r),[r]),le=Xt(q,{formId:vt,showInputOnly:!1}),ne=d.useMemo(()=>m.flat().find(M=>M.value===F),[m,F]),ce=d.useCallback(()=>{w&&u(()=>({file:w}))},[u,w]);return i.jsx("div",{className:"flex grow items-center w-full",ref:f,children:i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[L===j&&(A.length>0||z)&&i.jsxs("div",{className:"flex flex-col gap-2",children:[H,z&&i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(hn,{popoverInputs:te,hasError:K,align:"start"}),me(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":P,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:I})," ",b," ",i.jsx("strong",{children:S})]})})]})]}),L!==j&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(c.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[ne==null?void 0:ne.icon,ne==null?void 0:ne.children]}),i.jsx(ve,{name:`${n}.${e}.required`,render:({setValue:M,value:B})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.Checkbox.Root,{checked:B,onCheckedChange:M,size:"sm",children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(c.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),z&&i.jsx(hn,{popoverInputs:te,hasError:K,align:"end"})]}),w&&i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:y,alt:w.name,onClick:ce}),i.jsx(c.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:x,size:"sm",children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),i.jsx(ve,{name:`${n}.${e}.label`,render:({setValue:M,value:B})=>i.jsx("input",{className:"bg-transparent outline-none text-sm placeholder-(--base-a9)",placeholder:F==="section"?"Enter a section label (optional)":"Enter your question",value:B,onChange:W=>{M(W.target.value)},onInput:N,maxLength:200})}),i.jsx(ve,{name:`${n}.${e}.description`,render:({setValue:M,value:B})=>i.jsx("textarea",{className:"bg-transparent outline-none text-sm field-sizing-content grow placeholder-(--base-a9)",placeholder:`Enter a ${F==="section"?"section":"field"} description (optional)`,value:B,onChange:W=>{M(W.target.value)},onInput:D,maxLength:1e3})}),L!==j&&A.length>0&&i.jsx("div",{className:"w-full",children:H}),L!==j&&i.jsxs(c.Card,{className:"flex gap-4 bg-(--accent-a2) items-center",children:[i.jsxs(c.HoverCard.Root,{children:[i.jsx(c.HoverCard.Trigger,{asChild:!0,children:i.jsx(c.Badge,{icon:!0,size:"sm",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiEyeLine"})})}),i.jsx(c.HoverCard.Content,{className:"w-[225px]",size:"sm",align:"start",children:"This is a preview of the field as it will be rendered in the form."})]}),i.jsx("div",{className:"grow h-max",children:le})]})]})})});pn.displayName="FieldBuilder";const $r=d.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=U.useFormikContext(),{reorderField:l}=Yt(),{showInfo:m,showError:u}=c.useToast(),f=`fields.${r}.fields`,h=d.useMemo(()=>({index:e,parentPath:f,initial:n}),[n,e,f]),g=d.useCallback(()=>{const p=n.label||"Unlabelled field",y={...n,label:p};st(f,e+1,y,s,a),m({title:"Field duplicated",description:`The field "${p}" has been duplicated`})},[n,f,e,s,a,m]),C=d.useCallback(p=>{const y=r,x=s.fields[y];let I=r,b=p==="up"?e-1:e+1;p==="up"&&e===0?(I=r-1,b=s.fields[I].fields.length):p==="down"&&e===x.fields.length-1&&(I=r+1,b=0);const S=s.fields[I];l(x,y,e,S,I,b,a)},[r,s.fields,e,l,a]),w=d.useCallback(p=>{const{files:y}=p.target;if(!y||y.length!==1)return;const x=y.item(0);if(x){if(x.size>Go){u({title:"File upload error",description:`The file ${x.name} exceeded the maximum file size`});return}a(`${f}.${e}`,{...n,image:x}).then()}},[n,e,f,a,u]);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:p=>i.jsx(c.Card,{ref:p.innerRef,...p.draggableProps,...p.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(pn,{...h}),i.jsx(fn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:g,move:C,upload:w})]})})})});$r.displayName="FieldWithActions";const kr=d.memo(t=>{var S;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(S=r[n.identifier])==null?void 0:S.disabled,{setFieldValue:s,values:l}=U.useFormikContext(),m=c.useAlertDialog(),{reorderSection:u}=Yt(),{showInfo:f}=c.useToast(),h=d.useCallback((N,D)=>{for(const F of N){const L=D.indexOf(F);s(`fields.${L}.condition`,null).then(),s(`fields.${L}.conditional`,!1).then()}},[s]),g=d.useCallback(N=>{var L;const D=n.fields[N];if(!D)throw new Error("Could not find field to remove.");const F=[];for(const A of l.fields)((L=A.condition)==null?void 0:L.identifier)===D.identifier&&F.push(A);return{removing:D,affectedSections:F,action:()=>s(`fields.${e}.fields`,at(n.fields,N))}},[n.fields,l.fields,s,e]),C=d.useCallback(N=>{const{affectedSections:D,action:F,removing:L}=g(N),A=()=>{F().then(),h(D,l.fields)};if(D.length>0){const O=D.map(H=>H.label).join(", ");m({title:"Remove condition?",description:`${L.label} is being used as a condition, deleting it will remove the condition from the ${O} section(s).`,action:"Remove",onAction:A});return}A()},[g,h,l.fields,m]),w=d.useCallback(()=>{const D=n.fields.map((z,K)=>g(K)).flatMap(z=>z.affectedSections),F=D.length?"Remove fields and conditions?":"Remove fields?",L=n.fields.length,A=D.map(z=>z.label).join(", "),O=D.length?`Deleting this section will remove the ${L} field(s) it contains and will remove the conditions from following sections: ${A}`:`Deleting this section will remove the ${L} field(s) it contains.`,H=at(l.fields,e),te=()=>s("fields",H);if(D.length>0){m({title:F,description:O,action:"Remove",onAction:()=>{te().then(()=>{h(D,H)})}});return}te().then()},[n.fields,l.fields,e,g,s,m,h]),p=d.useCallback(N=>{const D=N==="up"?e-1:e+1;u(r,n.identifier,e,D,l,s)},[e,u,r,n.identifier,l,s]),y=d.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:wr(l.fields,e)}),[n,e,l.fields]),x=d.useCallback(()=>{const N=n.label||"Untitled section",D=n.fields.map(L=>({...L,identifier:Qt()})),F={...n,label:N,fields:D};st("fields",e+1,F,l,s),f({title:"Section duplicated",description:`The section "${N}" has been duplicated.`})},[n,e,l,s,f]),I=d.useCallback(N=>{st(`fields.${e}.fields`,n.fields.length,Ho[N],l,s)},[e,n.fields.length,l,s]),b=Ur(I);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:N=>i.jsx(c.Card,{ref:N.innerRef,...N.draggableProps,...N.dragHandleProps,variant:"outline",className:"mb-4 w-full",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i.jsxs("div",{className:"flex grow flex-col gap-2 w-full",children:[!o&&i.jsx(pn,{...y}),i.jsx(ie.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:D=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:D.innerRef,...D.droppableProps,children:[n.fields.map((F,L)=>i.jsx($r,{field:F,index:L,sectionIndex:e,remove:()=>{C(L)}},F.identifier)),D.placeholder,i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{type:"button",variant:"soft",size:"sm",children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(c.Menu.Content,{children:b.flat().map(F=>i.jsxs(c.Menu.Item,{onSelect:F.onSelect,children:[F.icon,F.children]},F.value))})]})]})})]}),!o&&i.jsx(fn,{index:e,type:n.type,remove:w,duplicate:x,move:p})]})})})});kr.displayName="FieldSectionWithActions";const jr=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},Wr=d.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=U.useFormikContext(),[o,a]=d.useReducer(Ro,e.fields,Vr),{reorderSection:s,reorderField:l}=Yt();d.useEffect(()=>{a({type:"update",state:Vr(e.fields)})},[a,e.fields]);const m=d.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),u=d.useCallback(h=>{const{source:g,destination:C,type:w,reason:p,draggableId:y}=h;if(a({type:"release"}),!C||p==="CANCEL")return;if(w==="ROOT"){s(o,y,g.index,C.index,e,r);return}if(w!=="SECTION")throw new Error("Unexpected droppable type.");const[x,I]=jr(e.fields,g.droppableId)??[],[b,S]=jr(e.fields,C.droppableId)??[];l(x,I,g.index,b,S,C.index,r)},[e,l,r,s,o]),f=d.useCallback(h=>{ko(h+1,e,r)},[e,r]);return i.jsx(ie.DragDropContext,{onDragStart:m,onDragEnd:u,children:i.jsx(ie.Droppable,{droppableId:"droppable",type:"ROOT",children:h=>i.jsxs("div",{className:"flex flex-col gap-0",ref:h.innerRef,...h.droppableProps,children:[e.fields.map((g,C)=>i.jsxs(d.Fragment,{children:[i.jsx(kr,{field:g,index:C,dropState:o,fieldsOnly:n}),!n&&C!==e.fields.length-1&&i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",size:"sm",accentColor:"base",onClick:()=>{f(C)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]})]},g.identifier)),i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:()=>{f(e.fields.length)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});Wr.displayName="FieldsEditor";const ta=()=>{alert("This is a form preview, your data will not be saved.")},na=d.memo(d.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:m=!1,showTabs:u=!0,tabsListClassName:f,hydrateRevisionWithImages:h}=t,{showError:g}=c.useToast(),C=d.useCallback(I=>{const b={};I.title||(b.title="Title is required."),(!I.fields||I.fields.length===0)&&(b.fields="At least one field is required.");let S=[];for(const[D,F]of I.fields.entries()){const A=un.section.getFieldCreationSchema(wr(I.fields,D),`fields.${D}`).map(O=>O.field);S=[...S,...A];for(const[O,H]of F.fields.entries()){const z=un[H.type].getFieldCreationSchema(`fields.${D}.fields.${O}`).map(K=>K.field);S=[...S,...z]}}const N=mt({fields:S},I);if(N&&(b.fields=N.fields),ge(b))return g({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),b},[g]),w=d.useMemo(()=>({title:a??"",description:"",fields:[{...ot(Qt()),label:""}]}),[a]),p=o?h(o):void 0,y=U.useFormik({initialValues:$o(p)??w,validate:C,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),x=d.useMemo(()=>Br(y.values),[y.values]);return i.jsx(c.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[u&&i.jsxs(c.Tabs.List,{className:ye("sticky top-0 z-[2000] flex bg-(--color-background)",f),children:[i.jsx(c.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(c.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(c.Tabs.Content,{value:"edit",children:[s&&i.jsxs(c.Text,{children:["Create your form using various field types. Sections can be"," ",i.jsx("strong",{children:"conditionally rendered"})," based on"," ",i.jsx("strong",{children:"answers to fields in preceding sections. "})]}),i.jsxs("form",{className:"mt-3 flex flex-col gap-2",id:vt,onSubmit:y.handleSubmit,children:[i.jsxs(U.FormikProvider,{value:y,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(ve,{name:"title",render:({setValue:I,value:b,meta:S})=>i.jsx(qt,{severity:"danger",helpText:S.error??null,children:i.jsx(c.Input.Root,{variant:"outline",size:"md",accentColor:S.error?ue.danger:"primary",children:i.jsx(c.Input.Field,{placeholder:"Form title",value:b,onChange:N=>{I(N.target.value)},maxLength:100})})})}),i.jsx(ve,{name:"description",render:({setValue:I,value:b})=>i.jsx(c.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:b,onChange:S=>{I(S.target.value)},resize:"vertical",maxLength:1e3,size:"md"})})]}),i.jsx(Wr,{fieldsOnly:m}),i.jsx("span",{"data-accent-color":ue.danger,className:"text-xs text-(--accent-a11)",children:typeof y.errors.fields=="string"&&y.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(c.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(c.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(c.Tabs.Content,{value:"preview",children:i.jsx(_r,{schema:x,onSubmit:ta,hideTitle:!l})})]})})})),ra=Object.values(de.Colors),ia=1;async function oa(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),s=new Image(r.width,r.height),l=new de.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),s.src=URL.createObjectURL(e),s.onload=async function(){o.drawImage(s,0,0,r.width,r.height);const m=t.toDataURL("image/jpeg",ia),u=await de.fileToBlob(m),f=new File([u],n.name,{type:"image/jpeg"});l.resolve(f)}},a.src=URL.createObjectURL(n),l}const qr=d.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:s}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const l=d.useRef(null),m=d.useRef(null),[u,f]=d.useState(de.Colors.red),[h,g]=d.useState(null),[C,w]=d.useState(!1),[p,y]=d.useState(!1),x=d.useRef(null),I=c.useSize(x);d.useEffect(()=>{const z=new Image;z.onload=function(){g({width:z.naturalWidth,height:z.naturalHeight})},z.src=URL.createObjectURL(n)},[n]),d.useEffect(()=>{!p&&(I!=null&&I.width)&&I.height&&y(!0)},[I,p]);const b=d.useCallback(async()=>{a||e();const z=l.current;if(!z)return;if(!h)throw new Error("Original image size not loaded yet");const K=await z.exportImage("png"),P=new Image(h.width,h.height);P.onload=async function(){const q=await de.fileToBlob(K),le=new File([q],n.name,{type:n.type}),ne=m.current,ce=await oa(ne,n,le,h);ce.objectURL=URL.createObjectURL(ce);const Be=await de.hashFile(n);await de.hashFile(ce)!==Be&&r(ce),w(!1),e()},w(!0),P.src=K},[a,n,e,r,h]),S=d.useCallback(()=>{o(n)},[n,o]),N=d.useCallback(()=>{e()},[e]),D=d.useCallback(()=>{s(!0)},[s]),F=d.useCallback(()=>{l.current&&l.current.redo()},[]),L=d.useCallback(()=>{l.current&&l.current.undo()},[]),A=d.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),O=d.useCallback(z=>{l.current&&l.current.eraseMode(z)},[]),H=d.useCallback(()=>{b()},[b]),te=d.useCallback(()=>{jt.saveAs(n,n.name)},[n]);return i.jsx(Vt,{open:!0,onOpenChange:e,children:i.jsxs(Ut,{children:[i.jsx($t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":""}),i.jsxs(kt,{className:"absolute inset-0 py-12","data-floating-content":"",children:[i.jsx(c.ButtonGroup,{className:"flex w-full gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",size:"md",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.IconButton,{"aria-label":"close",onClick:N,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})}),i.jsx(c.IconButton,{"aria-label":`Download ${n.name}`,onClick:te,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(bt,{selectedColor:u,allColors:ra,onFinish:f,trigger:i.jsx(c.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:u},children:" "})}),i.jsx(c.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:O,children:i.jsx(c.RiIcon,{icon:"RiEraserFill"})}),i.jsx(c.Separator,{orientation:"vertical",size:"full"}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:L,children:i.jsx(c.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:F,children:i.jsx(c.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(c.IconButton,{"aria-label":"undo all",onClick:A,children:i.jsx(c.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(c.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:H,children:i.jsx(c.RiIcon,{icon:"RiSaveLine"})}),i.jsx(c.IconButton,{"aria-label":"Delete attachment",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})}),h&&i.jsx("canvas",{id:"attachment-markup-canvas",className:"hidden",ref:m,width:h.width,height:h.height}),i.jsxs("div",{className:"relative size-full flex items-center justify-center p-4 overflow-hidden",children:[i.jsx("img",{className:"max-w-full max-h-full invisible absolute",alt:"Photo attachment",ref:x,src:n.objectURL}),C?i.jsx(c.Spinner,{}):i.jsx(Yr.ReactSketchCanvas,{className:"max-w-full max-h-full aspect-square",backgroundImage:n.objectURL,ref:l,onStroke:D,strokeColor:u},p?"1":"0")]})]})]})})});qr.displayName="AttachmentEditor",E.BaseField=k,E.BaseFormElement=wt,E.BooleanField=Ee,E.BooleanInput=Ht,E.ColorPicker=bt,E.DateField=nt,E.DateInput=Gt,E.FieldSection=j,E.FileCard=Ct,E.FileIcon=$e,E.FormBuilder=na,E.FormRenderer=_r,E.ImageCard=Ar,E.ImageMarkup=qr,E.ImageViewer=Wt,E.ImageViewerProvider=pr,E.InputWithHelpText=qt,E.InputWithLabel=J,E.InputWithLabelAndHelpText=Z,E.MultiSelectField=Ve,E.MultiSelectInput=tn,E.MultiStringField=_e,E.MultiStringInput=Jt,E.NumberField=se,E.NumberInput=Zt,E.PatchField=ve,E.PatchFormProvider=Jo,E.QrField=lt,E.QrInput=Rt,E.QrScanner=en,E.SUPPORTED_IMAGE_FILE_TYPES=bn,E.SUPPORTED_PDF_FILE_TYPES=wn,E.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=Cn,E.SelectField=Ue,E.SelectInput=nn,E.StringField=dt,E.StringInput=rn,E.TextField=ut,E.TextInput=on,E.decodeFormValues=Xo,E.deserialize=ht,E.deserializeField=ln,E.emptyBaseField=G,E.emptyBooleanField=mr,E.emptyDateField=gr,E.emptyMultiSelectField=Nr,E.emptyMultiStringField=Ir,E.emptyNumberField=xr,E.emptyQrField=Sr,E.emptySelectField=Fr,E.emptyStringField=Dr,E.emptyTextField=Mr,E.encodeFormValues=Ko,E.fieldIcons=Rr,E.flattenFields=cn,E.formRevisionToSchema=Br,E.initialFormValues=gt,E.isConditionMet=dn,E.useFieldInput=Xt,E.useFieldInputs=ze,E.useFormikInput=X,E.useImageViewer=je,E.validateForm=mt,E.valueIsFile=pt,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
45
+ For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},Fo="DialogDescriptionWarning",Lo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ur(Fo).contentName}}.`;return v.useEffect(()=>{var a;const o=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},Vt=Rn,Do=tr,Ut=rr,$t=ir,kt=or,fr=cr,et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},tt={exports:{}},Mo=tt.exports,hr;function Ao(){return hr||(hr=1,function(t,n){(function(e,r){r()})(Mo,function(){function e(u,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function r(u,f,h){var g=new XMLHttpRequest;g.open("GET",u),g.responseType="blob",g.onload=function(){m(g.response,f,h)},g.onerror=function(){console.error("could not download file")},g.send()}function o(u){var f=new XMLHttpRequest;f.open("HEAD",u,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function a(u){try{u.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(f)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof et=="object"&&et.global===et?et:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),m=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(u,f,h){var g=s.URL||s.webkitURL,C=document.createElement("a");f=f||u.name||"download",C.download=f,C.rel="noopener",typeof u=="string"?(C.href=u,C.origin===location.origin?a(C):o(C.href)?r(u,f,h):a(C,C.target="_blank")):(C.href=g.createObjectURL(u),setTimeout(function(){g.revokeObjectURL(C.href)},4e4),setTimeout(function(){a(C)},0))}:"msSaveOrOpenBlob"in navigator?function(u,f,h){if(f=f||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(e(u,h),f);else if(o(u))r(u,f,h);else{var g=document.createElement("a");g.href=u,g.target="_blank",setTimeout(function(){a(g)})}}:function(u,f,h,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof u=="string")return r(u,f,h);var C=u.type==="application/octet-stream",I=/constructor/i.test(s.HTMLElement)||s.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||C&&I||l)&&typeof FileReader<"u"){var y=new FileReader;y.onloadend=function(){var b=y.result;b=p?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=b:location=b,g=null},y.readAsDataURL(u)}else{var E=s.URL||s.webkitURL,w=E.createObjectURL(u);g?g.location=w:location.href=w,g=null,setTimeout(function(){E.revokeObjectURL(w)},4e4)}});s.saveAs=m.saveAs=m,t.exports=m})}(tt)),tt.exports}var jt=Ao();const Wt=d.memo(t=>{const{file:n,onClose:e}=t,r=d.useRef(null),o=d.useCallback(()=>{var l;if(!r.current)return;const s=document.createElement("canvas");s.width=r.current.width,s.height=r.current.height,(l=s.getContext("2d"))==null||l.drawImage(r.current,0,0,r.current.width,r.current.height),s.toBlob(m=>{m&&navigator.clipboard.write([new ClipboardItem({"image/png":m})])},"image/png")},[]),a=d.useCallback(()=>{jt.saveAs(n,n.name)},[n]);return i.jsx(Vt,{open:!0,onOpenChange:e,children:i.jsx(Ut,{children:i.jsx($t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":"",children:i.jsxs(kt,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(c.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{asChild:!0,children:i.jsx(c.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(c.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{asChild:!0,children:i.jsx(c.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(c.Separator,{orientation:"vertical",size:"sm"}),i.jsx(fr,{asChild:!0,children:i.jsx(c.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})]}),i.jsx("figure",{className:"size-full overflow-hidden p-4 flex justify-center items-center",children:i.jsx("img",{ref:r,className:"max-w-full max-h-full",src:URL.createObjectURL(n),alt:n.name})})]})})})})});Wt.displayName="ImageViewer";const pr=d.memo(t=>{const{children:n}=t,[e,r]=d.useState(null),o=d.useCallback(()=>{r(null)},[]),a=d.useCallback(m=>{r(m(o))},[o]),s=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=d.useMemo(()=>a,[a]);return i.jsxs(In.Provider,{value:l,children:[n,e&&i.jsx(Wt,{file:e.file,onClose:s})]})});pr.displayName="FileViewerProvider";const J=t=>{const{className:n,label:e,children:r,severity:o,inputId:a,labelId:s,image:l}=t,[m,u]=d.useState(void 0),f=je(),h=o?ue[o]:"base";d.useEffect(()=>{l instanceof Promise?l.then(u).catch(console.error):u(l)},[l]);const g=m?URL.createObjectURL(m):void 0,C=d.useCallback(()=>{m&&f(()=>({file:m}))},[f,m]);return i.jsxs("div",{className:"flex flex-col gap-1",children:[m&&i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:g,alt:m.name,onClick:C}),i.jsx("label",{className:ye(n,"flex flex-col gap-1 w-max max-w-full"),htmlFor:a,children:i.jsx(c.Text,{accentColor:h,size:"sm",id:s,weight:"medium",className:"text-wrap",children:e})}),r]})},qt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?ue[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,!!n&&i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(c.Text,{accentColor:o,size:"xs",children:n})})]})},Z=t=>{const{children:n,...e}=t;return i.jsx(qt,{...e,children:n})},Po=[!0,"true"],Ht=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onBlur:g,onChange:C}=u,I=a?null:l,p=a?"":m,y=Po.includes(u.value),E=d.useCallback(()=>{g(y)},[g,y]);return i.jsx(Z,{helpText:I,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,className:"items-center flex-row-reverse justify-end gap-2",children:i.jsx(c.Checkbox.Root,{id:n,name:h,value:y.toString(),checked:y,onCheckedChange:C,onBlur:E,size:"sm",accentColor:"primary",variant:"surface",...f,children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})})})})});Ht.displayName="BooleanInput";const mr={...G,type:"boolean"},Se=class Se extends k{constructor(e){super({...e,type:"boolean"});T(this,"onlyValidateAfterTouched",!1)}isBlank(e){return this.required&&!e}getValueFromChangeEvent(e){return typeof e=="boolean"?e:e.target.checked}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="boolean")throw new Error("Type mismatch.");return new Se(e)}getInput(e){return i.jsx(Ht,{...e,field:this})}};T(Se,"fieldTypeName","Checkbox"),T(Se,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),T(Se,"Icon",$.RiCheckboxCircleLine);let Ee=Se;const Gt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onChange:g,onBlur:C}=u,[I,p]=d.useState(!1),y=a?null:l,E=a?"":m,w=u.value?new Date(u.value):void 0,b=d.useCallback(N=>{N&&g(N.toISOString()),p(!1)},[g]),S=d.useCallback(N=>{p(N),N||C(u.value)},[u.value,C]);return i.jsx(Z,{helpText:y,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:E,image:a?void 0:s.image,children:i.jsxs(c.Popover.Root,{open:I,onOpenChange:S,children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:"sm",...f,children:[w?w.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd",i.jsx(c.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(c.Popover.Content,{align:"start",children:i.jsx(c.DayPicker,{required:!1,mode:"single",variant:"solid",selected:w,onSelect:b})})]})})})});Gt.displayName="DateInput";const gr={...G,type:"date"},Te=class Te extends k{constructor(e){super({...e,type:"date"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return e.target.value}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Te(e)}getInput(e){return i.jsx(Gt,{field:this,...e})}};T(Te,"fieldTypeName","Date"),T(Te,"fieldTypeDescription","Allows specifying a date."),T(Te,"Icon",$.RiCalendarLine);let nt=Te;const vr=d.memo(t=>{const{field:n,...e}=t,[{value:r}]=U.useField(n.options.clonedFieldIdentifier),o=d.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?ht(a):null},[n.options,r]);return Xt(o,e)});vr.displayName="FieldInputCloner";const Oo={...G,type:"custom"};class rt extends k{constructor(e,r){super({...e,type:"custom"});T(this,"Component");T(this,"options");this.options=e,this.Component=r}serialize(){throw new Error("Serializing only supported for public input types.")}getInput(e){const r=this.Component;return i.jsx(r,{field:this,...e})}}T(rt,"fieldTypeName","Custom"),T(rt,"fieldTypeDescription","Allows re-rendering of field already in the form");class Bo extends rt{constructor(n){super(n,vr)}}const Xt=(t,n)=>d.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),ze=(t,n)=>{const e=d.useMemo(()=>t.map(r=>i.jsx(d.Fragment,{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-4",children:e})};let it;const zo=new Uint8Array(16);function _o(){if(!it&&(it=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!it))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return it(zo)}const _=[];for(let t=0;t<256;++t)_.push((t+256).toString(16).slice(1));function Vo(t,n=0){return _[t[n+0]]+_[t[n+1]]+_[t[n+2]]+_[t[n+3]]+"-"+_[t[n+4]]+_[t[n+5]]+"-"+_[t[n+6]]+_[t[n+7]]+"-"+_[t[n+8]]+_[t[n+9]]+"-"+_[t[n+10]]+_[t[n+11]]+_[t[n+12]]+_[t[n+13]]+_[t[n+14]]+_[t[n+15]]}const yr={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Uo(t,n,e){if(yr.randomUUID&&!t)return yr.randomUUID();t=t||{};const r=t.random||(t.rng||_o)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Vo(r)}const me=t=>t.type==="section",ot=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),$o=t=>{if(!t)return;const n=t.fields;let e=[];const r=[];for(const o of n)o.type==="section"?(e.length>0&&(r.push(ot(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(ot("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function Kt(t,n,e){const r=Array.from(t),[o]=r.splice(n,1);if(!o)throw new Error("Could not find field to reorder.");return r.splice(e,0,o),r}function br(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function at(t,n){const e=Array.from(t);return e.splice(n,1),e}const Qt=()=>Uo(),Cr=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=Cr(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},wr=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),st=(t,n,e,r,o)=>{const a={...e,identifier:Qt()},s=Q(r,t);if(s===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(s))throw new Error("Parent path must point to an array.");const l=br(s,n,a);o(t,l).then()},ko=(t,n,e)=>{const r={...ot(),label:""};st("fields",t,r,n,e)},Yt=()=>{const{showError:t}=c.useToast(),n=d.useCallback((r,o,a,s,l,m)=>{const u=r[o];if(!u)throw new Error("Could not find section context.");let f=typeof u.conditionIndex<"u"?Math.max(u.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(f=Math.min(f,h.index-1));if(f!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}m("fields",Kt(l.fields,a,f))},[t]),e=d.useCallback((r,o,a,s,l,m,u)=>{var f;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)u(`fields.${o}.fields`,Kt(r.fields,a,m)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((f=s.condition)==null?void 0:f.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}u(`fields.${o}.fields`,at(r.fields,a)).then(),u(`fields.${l}.fields`,br(s.fields,m,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},Jt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),h=a?null:l,g=a?"":m,{name:C,onChange:I,onBlur:p}=u,y=d.useMemo(()=>Array.isArray(u.value)?u.value:[],[u.value]),E=`${n}-droppable`,{disabled:w}=f,[b,S]=d.useState(""),[N,D]=d.useState(""),L=N||h,F=d.useCallback(P=>{I(P),p(P)},[I,p]),M=d.useCallback(P=>{y.findIndex(q=>q===P.target.value.trim())>=0?D("All options must be unique"):P.target.value?D(""):D("Option cannot be empty"),S(P.target.value)},[S,y]),O=d.useCallback(()=>{if(N)return;if(!b.trim()){D("Option cannot be empty");return}const P=b.trim();F([...y,P]),S("")},[b,N,F,y]),H=d.useCallback(P=>{P.key==="Enter"&&(P.preventDefault(),O())},[O]),te=d.useCallback(P=>{F(at(y,P))},[y,F]),z=d.useCallback(P=>{if(!P.destination)return;const q=P.source.index,le=P.destination.index;F(Kt(y,q,le))},[F,y]),K=d.useCallback(()=>{p(y)},[p,y]);return i.jsx(ie.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Z,{helpText:L,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:(!w||y.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{value:b,onChange:M,onKeyDown:H,id:n,placeholder:s.placeholder,onBlur:K,name:C,...f})}),i.jsx(c.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!N||w,onClick:O,children:i.jsx(c.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(ie.Droppable,{droppableId:E,children:P=>i.jsxs("div",{className:"flex flex-col",...P.droppableProps,ref:P.innerRef,children:[y.map((q,le)=>i.jsx(ie.Draggable,{draggableId:`${q}-draggable`,index:le,isDragDisabled:w,children:({draggableProps:ne,dragHandleProps:ce,innerRef:Be})=>i.jsxs(c.Badge,{...ce,...ne,ref:Be,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{children:typeof q=="object"&&"label"in q?q.label:q}),i.jsx(c.IconButton,{size:"xs",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:w,onClick:()=>{te(le)},children:i.jsx(c.RiIcon,{icon:"RiCloseLargeLine"})})]})},q)),P.placeholder]})})]})})});Jt.displayName="MultiStringInput";const Ir={...G,type:"multi-string",minimum_length:0,maximum_length:null},Ne=class Ne extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});T(this,"minLength");T(this,"maxLength");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=a??"Press enter to add a new option"}getValueFromChangeEvent(e){if(Array.isArray(e))return e;throw new Error("Expected an array.")}getInput(e){return i.jsx(Jt,{field:this,...e})}serialize(){return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}isBlank(e){return super.isBlank(e)||e.length===0}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(Array.isArray(r)&&r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(Array.isArray(r)&&r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){if(e.type!=="multi-string")throw new Error("Type mismatch.");return new Ne(e)}};T(Ne,"fieldTypeName","Multi-string"),T(Ne,"fieldTypeDescription","Allows the user to provide multiple unique strings."),T(Ne,"Icon",$.RiListCheck);let _e=Ne;const Zt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=X(t),{name:C,onBlur:I,onChange:p,value:y}=u,E=a?null:l,w=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(L=>{const F=Number.parseFloat(L.target.value),M=Number.isNaN(F)?"":F;S(M),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(M))},[s,h,f]),D=d.useCallback(()=>{p(b),I(b)},[b,I,p]);return i.jsx(Z,{helpText:E,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:w,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,onChange:N,onBlur:D,value:b,type:"number",min:s.minimum,max:s.maximum,step:s.integers?1:.1,placeholder:s.placeholder,...g})})})})});Zt.displayName="NumberInput";const xr={...G,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},Er=t=>"fields"in t,ee=class ee extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:s="Enter a number",...l}=e;super({...l,type:"number"});T(this,"minimum");T(this,"maximum");T(this,"integers");T(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=s}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ee({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new ee({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`,formValidators:[this._validateMax(e)]}),showDirectly:!1},{field:new Ee({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(a=>{if(typeof a=="number"&&a>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super._serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}static deserialize(e){if(e.type!=="number")throw new Error("Type mismatch.");return new ee(e)}getInput(e){return i.jsx(Zt,{field:this,...e})}};T(ee,"fieldTypeName","Number"),T(ee,"fieldTypeDescription","Allows specifying a number within a given range."),T(ee,"Icon",$.RiHashtag),T(ee,"_validateMin",e=>(r,o)=>{const a=Er(o)?Q(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),T(ee,"_validateMax",e=>(r,o)=>{const a=Er(o)?Q(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let se=ee;const Rt=d.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:m,fieldProps:u},f]=X(t),{name:h,onBlur:g,onChange:C,value:I}=u,[p,y]=d.useState(!1),E=l?null:o,w=l?"":r,b=d.useCallback(D=>{C(D),y(!1)},[C]),S=d.useCallback(()=>{C("")},[C]),N=d.useCallback(D=>{y(D),D||g(I)},[g,I]);return i.jsx(Z,{helpText:E,severity:s,children:i.jsxs(J,{size:a,severity:s,inputId:n,labelId:e,label:w,image:l?void 0:m.image,className:"flex-col items-start justify-start gap-2",children:[i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(Vt,{open:p,onOpenChange:N,children:[i.jsx(Do,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",variant:"soft",size:"sm",accentColor:"base",...f,children:[i.jsx(c.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]})}),i.jsxs(Ut,{children:[i.jsx($t,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(kt,{className:"fixed inset-0",children:i.jsx(en,{onQrScan:b})})]})]}),I&&i.jsx(c.RiIcon,{icon:"RiCheckLine",className:"align-bottom text-(--primary-a11)"})]}),!!I&&i.jsx(c.Card,{className:"max-w-full w-max",size:"sm",children:i.jsxs("div",{className:"max-w-full w-max flex justify-between gap-2",children:[i.jsx("code",{className:"bg-(--base-a3) truncate text-sm",children:I}),i.jsx(c.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Rt.displayName="QrInput";const en=d.memo(t=>{const{onQrScan:n}=t,e=d.useRef(null),[r,o]=d.useState(!1);return d.useEffect(()=>{if(!e.current)return;const a=new Kr(e.current,s=>{const l=s.data;n(l),a.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});o(!0),a.start().finally(()=>{o(!1)})},[n]),i.jsxs("div",{className:"relative flex h-full w-full flex-col justify-center gap-2 bg-(--color-background)",children:[i.jsx("div",{className:"absolute top-0 flex w-full p-2",children:i.jsx(fr,{asChild:!0,children:i.jsx(c.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{className:"size-full",ref:e}),r&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(c.Spinner,{})})]})]})});en.displayName="QrScanner";const Sr={...G,type:"qr"},Fe=class Fe extends k{constructor(e){super({...e,type:"qr"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Fe(e)}getInput(e){return i.jsx(Rt,{...e,field:this})}};T(Fe,"fieldTypeName","QR"),T(Fe,"fieldTypeDescription","Used for scanning/reading QR codes."),T(Fe,"Icon",$.RiQrCodeLine);let lt=Fe;class Tr extends k{constructor(e){const{placeholder:r="",...o}=e;super(o);T(this,"options");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(s=>(typeof s=="string"&&(s={label:s,value:s}),a.add(s.label),s)),a.size!==e.options.length&&console.error(`${e.options.length-a.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,e.options)}_serialize(){return{...super._serialize(),options:this.options,placeholder:this.placeholder}}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new _e({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const jo=t=>t?Array.isArray(t)?t:[t]:[],tn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onChange:g,onBlur:C}=u,I=a?null:l,p=a?"":m,y=d.useMemo(()=>jo(u.value),[u.value]),E=d.useCallback(b=>{g(b),C(b)},[C,g]),w=d.useCallback(b=>{b||C(y)},[y,C]);return i.jsx(Z,{helpText:I,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{onOpenChange:w,align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",variant:"surface",type:"button",size:"sm",accentColor:"base",...f,children:[i.jsx("span",{className:"truncate",children:y.length>0?y.join(", "):s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsxs(c.Menu.MultiSelectGroup,{values:y,onValuesChange:E,children:[i.jsxs(c.Menu.SelectAllItem,{children:[i.jsx(c.Menu.CheckboxItemIndicator,{children:b=>b?i.jsx(c.RiIcon,{icon:"RiSubtractLine"}):i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(b=>i.jsxs(c.Menu.MultiSelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))]})})})]})})})});tn.displayName="MultiSelectInput";const Nr={...G,type:"multi-select",options:[]},Le=class Le extends Tr{constructor(n){const{placeholder:e="Select one or more...",...r}=n;super({...r,placeholder:e,type:"multi-select"})}getValueFromChangeEvent(n){if(Array.isArray(n))return n;throw new Error("Expected an array.")}isBlank(n){return super.isBlank(n)||n.length===0}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="multi-select")throw new Error("Type mismatch.");return new Le(n)}getInput(n){return i.jsx(tn,{field:this,...n})}};T(Le,"fieldTypeName","Multi-select"),T(Le,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),T(Le,"Icon",$.RiCheckboxLine);let Ve=Le;const nn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=X(t),{name:h,onChange:g,onBlur:C,value:I}=u,p=a?null:l,y=a?"":m,E=d.useCallback(b=>{b&&(g(b),C(b))},[C,g]),w=d.useMemo(()=>s.options.find(b=>b.value===I),[s.options,I]);return i.jsx(Z,{helpText:p,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:y,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:"sm",...f,children:[i.jsx("span",{className:"truncate",children:w?w.label:s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsx(c.Menu.SelectGroup,{required:!0,value:I,onValueChange:E,children:s.options.map(b=>i.jsxs(c.Menu.SelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))})})})]})})})});nn.displayName="SelectInput";const Fr={...G,type:"select",options:[]},De=class De extends Tr{constructor(n){const{placeholder:e="Select one...",...r}=n;super({...r,placeholder:e,type:"select"})}getValueFromChangeEvent(n){return typeof n=="string"?n:n.target.value}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="select")throw new Error("Type mismatch.");return new De(n)}getInput(n){return i.jsx(nn,{field:this,...n})}};T(De,"fieldTypeName","Dropdown"),T(De,"fieldTypeDescription","Allows the user to select a single option from a list of options."),T(De,"Icon",$.RiMenuFoldLine);let Ue=De;const Lr=t=>"fields"in t;class ct extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);T(this,"minLength");T(this,"maxLength");T(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):be,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,formValidators:[this._validateMin(e)],integers:!0}),showDirectly:!1},{field:new se({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:be,formValidators:[this._validateMax(e)],integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?null:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}}T(ct,"_validateMin",e=>(r,o)=>{const a=Lr(o)?Q(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),T(ct,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Lr(o)?Q(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const rn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=X(t),{name:C,onBlur:I,onChange:p,value:y}=u,E=a?null:l,w=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(L=>{S(L.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(L.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),I(b)},[b,I,p]);return i.jsx(Z,{helpText:E,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:w,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,className:"truncate",name:C,value:b,type:s.inputType,placeholder:s.placeholder,onChange:N,onBlur:D,...g})})})})});rn.displayName="StringInput";const Dr={...G,type:"string",maximum_length:ke,input_type:"text"},Me=class Me extends ct{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(ke,e.maxLength):ke,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});T(this,"inputType");this.inputType=r}serialize(){return{...super._serialize(),input_type:this.inputType}}static deserialize(e){if(e.type!=="string")throw new Error("Type mismatch.");const{maximum_length:r,minimum_length:o,input_type:a,...s}=e;return new Me({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(rn,{field:this,...e})}};T(Me,"fieldTypeName","Short Text"),T(Me,"fieldTypeDescription",`Short text fields can hold up to ${ke} characters on a single line.`),T(Me,"Icon",$.RiInputField);let dt=Me;const on=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=X(t),{name:C,onBlur:I,onChange:p,value:y}=u,E=a?null:l,w=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(L=>{S(L.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(L.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),I(b)},[b,I,p]);return i.jsx(Z,{helpText:E,severity:o,children:i.jsx(J,{size:r,severity:o,inputId:n,labelId:e,label:w,image:a?void 0:s.image,children:i.jsx(c.TextArea,{id:n,value:b,name:C,onChange:N,onBlur:D,className:"field-sizing-content min-h-12",placeholder:s.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:"sm",...g})})})});on.displayName="TextInput";const Mr={...G,type:"text",maximum_length:be},Ae=class Ae extends ct{constructor(n){const e=n.maxLength?Math.min(be,n.maxLength):be,r=n.minLength?Math.min(n.minLength,e):void 0;super({...n,maxLength:e,minLength:r,type:"text"})}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="text")throw new Error("Type mismatch.");const{maximum_length:e,minimum_length:r,...o}=n;return new Ae({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(on,{field:this,...n})}};T(Ae,"fieldTypeName","Paragraph"),T(Ae,"fieldTypeDescription",`Paragraph fields can hold up to ${be} characters and can have multiple lines.`),T(Ae,"Icon",$.RiAlignJustify);let ut=Ae;const Ar=d.memo(d.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,...l}=t;return i.jsxs("div",{className:ye(s,"relative flex h-[200px] w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...l,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(c.Spinner,{})}),i.jsx("div",{className:"-m-4 flex max-w-full grow items-center justify-center overflow-hidden bg-clip-padding",children:e&&!o&&i.jsx("img",{className:"max-w-full object-cover",src:URL.createObjectURL(e),alt:r??e.name})}),i.jsxs("div",{className:ye("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx($e,{fileType:e.type}),i.jsx(c.Text,{className:"truncate",size:"sm",children:o??(e==null?void 0:e.name)}),a]})]})})),Wo=t=>{const n=["byte","kilobyte","megabyte"];let e=t,r=0;for(;e>1e3&&r<n.length-1;)e/=1e3,r++;return new Intl.NumberFormat([],{maximumFractionDigits:Math.max(0,r-1),style:"unit",unit:n[r]}).format(e)},Pr=d.memo(t=>{var L;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:m},u]=X(t),{name:f,value:h,onChange:g,onBlur:C}=m;let[{label:I}]=X(t);I=s?"":I;const p=d.useRef(null),y=d.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),E=d.useCallback(()=>{var F;(F=p.current)==null||F.click()},[]),w=d.useCallback(()=>{if(!p.current)return;const F=p.current.files;if(!F){C([]);return}const M=Array.from(F),O=[...h,...M];g(O),C(O)},[C,g,h]),b=d.useCallback(F=>{const M=[...h];M.splice(F,1),g(M)},[h,g]);d.useEffect(()=>{if(!p.current)return;const F=new AbortController;return p.current.addEventListener("cancel",()=>{C([])},{signal:F.signal}),()=>{F.abort()}},[C,h]);const S=h?"Select new files":"Select files",N=h?"Select new file":"Select a file",D=l.maxFiles>1?S:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Z,{helpText:y,severity:o,children:i.jsxs(J,{size:r,severity:o,inputId:n,labelId:e,label:I,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(c.Button,{className:"w-max",size:"sm",variant:"soft",accentColor:"base",onClick:E,id:"upload-input-upload-button",type:"button",...u,children:[i.jsx(c.RiIcon,{icon:"RiUpload2Line"})," ",D]})}),i.jsx("input",{id:n,name:f,type:"file",ref:p,accept:(L=l.extensions)==null?void 0:L.join(","),multiple:l.maxFiles>1,className:"hidden",onChange:w,value:""})]})}),Array.isArray(h)&&h.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:h.map((F,M)=>i.jsx(Or,{field:l,file:F,onRemove:()=>{b(M)},disabled:u.disabled},M))})]})});Pr.displayName="UploadInput";const Or=d.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=d.useState(null),l=je(),m=d.useMemo(()=>a&&e.getError([a]),[e,a]),{url:u,name:f}=d.useMemo(()=>{let p=null,y,E;return a!=null&&a.type.startsWith("image/")&&(p=URL.createObjectURL(a)),a?(y=a.name,E=Wo(a.size)):(y="Downloading...",E="..."),{url:p,name:y,size:E}},[a]);d.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=d.useCallback(p=>{if(p.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const y=new Blob([a]);jt.saveAs(y,f)},[f,a]),g=d.useCallback(p=>{p.stopPropagation(),r()},[r]),C=d.useCallback(()=>{a&&l(p=>({file:a,onDelete:o?void 0:()=>{r(),p()}}))},[o,r,l,a]),I=d.useMemo(()=>i.jsxs(c.ButtonGroup,{className:"flex grow justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(c.IconButton,{"aria-label":`Download ${f}`,type:"button",onClick:h,disabled:!a,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(c.IconButton,{type:"button","aria-label":`Remove ${f}`,disabled:o,onClick:g,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),[o,g,h,f,a]);return u?i.jsx(Ar,{className:"cursor-pointer",onClick:C,file:a,error:m??void 0,rightSlot:I}):i.jsx(Ct,{file:a,error:m??void 0,rightSlot:I})});Or.displayName="DisplayFile";const qo={...G,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Pe=class Pe extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});T(this,"extensions");T(this,"maxFileSize");T(this,"maxFiles");T(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}getValueFromChangeEvent(e){return Array.from(e.target.files||[])}isBlank(e){return super.isBlank(e)||e.length===0}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new se({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${ft}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:ft,integers:!0}),showDirectly:!1},{field:new Ve({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxFileSize??ft,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(s=>{if(s&&s.some(l=>l.size>o))return`Files must be at most ${r}MB.`}),e.push(s=>{if(s&&s.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super._serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}static deserialize(e){if(e.type!=="upload")throw new Error("Type mismatch.");return new Pe(e)}getInput(e){return i.jsx(Pr,{field:this,...e})}};T(Pe,"fieldTypeName","Upload"),T(Pe,"fieldTypeDescription","Allows a file to be uploaded."),T(Pe,"Icon",$.RiUpload2Line);let an=Pe;const sn={date:nt,number:se,boolean:Ee,select:Ue,string:dt,text:ut,custom:rt,upload:an,qr:lt,"multi-string":_e,"multi-select":Ve},Ho={date:gr,number:xr,boolean:mr,select:Fr,string:Dr,text:Mr,custom:Oo,upload:qo,qr:Sr,"multi-string":Ir,"multi-select":Nr},ft=50,Go=ft*1e3*1e3,ln=t=>{const n=t.type;return sn[n].deserialize(t)},ht=t=>t.type==="section"?j.deserialize(t):ln(t);function Br(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>ht(r)),meta:{readonly:e}}}function cn(t){const n=[];for(const e of t.fields)if(e instanceof j)for(const r of e.fields)n.push(r);else{if(!(e instanceof k))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Xo(t,n){const e=cn(t),r={};for(const o of e){const a=n[o.identifier]??null;a!==null?r[o.identifier]=o.decodeJsonToValue(a):r[o.identifier]=a}return r}function Ko(t,n){const e=cn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function pt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function dn(t,n){if(!t)return!0;if(pt(n)||pt(t.value))throw new Error("Conditions do not support file uploads");const e=Array.isArray(n)?n.map(o=>typeof o=="string"?o:o.value):n,r=Array.isArray(t.value)?t.value.map(o=>typeof o=="string"?o:o.value):t.value;if(Array.isArray(r)&&Array.isArray(e)){for(const o of r)if(!e.includes(o))return!1;return!0}return r===n}const zr=d.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:m}=U.useFormikContext(),u=s!=null&&s.identifier?Q(l,s.identifier):void 0,f=d.useMemo(()=>u===void 0||dn(s,u),[s,u]);d.useEffect(()=>{if(!f)for(const g of a)m(g.getId(),"").then()},[f,a,m]);const h=ze(a,e);return f?i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-4",children:[(r||o)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(c.Heading,{size:"md",children:r}),i.jsx(c.Text,{accentColor:"base",children:o})]}),i.jsx(c.Separator,{size:"full"})]}),h]})}):null});zr.displayName="FieldSectionLayout";const Oe=class Oe extends wt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});T(this,"label");T(this,"fields");T(this,"condition");this.fields=o,this.condition=a,this.label=r,s===!1&&(this.condition=null)}static getFieldCreationSchema(e,r=""){if(e.length===0)return[];const o=r&&`${r}.`;return[{field:new Ee({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new Oe({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Ue({label:"Field",description:"The field to use for the condition.",options:e.map(a=>!a.label||a.type==="upload"?null:{label:a.label,value:a.identifier}).filter(a=>!!a),identifier:`${o}condition.identifier`,required:!0}),new Bo({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const s=e.find(l=>l.identifier===a);return s?{...s,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:s.type!=="boolean"}:(console.error("Could not find field with identifier",a),null)}})]}),showDirectly:!1}]}static deserialize(e){if(e.type!=="section")throw new Error("Invalid type");if(!Array.isArray(e.fields))throw new Error(`Invalid fields: ${e.fields} (not an array)`);const r=e.fields.map(ln);return new Oe({...e,fields:r})}conditional(){return this.condition!==null}serialize(){return{...super._serialize(),label:this.label,condition:this.condition,conditional:this.conditional(),fields:this.fields.map(e=>e.serialize())}}getErrors(e){const r={};for(const o of this.fields){const a=o.getId(),s=o.getError(Q(e,a),e);s&&yt(r,o.getId(),s)}return r}getInput(e){return i.jsx(zr,{field:this,...e})}};T(Oe,"fieldTypeName","Section"),T(Oe,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let j=Oe;const ge=t=>Object.keys(t).length>0,mt=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof j){if(r.condition){const{identifier:o}=r.condition;if(!dn(r.condition,Q(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof k))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(Q(n,o),n);a&&yt(e,o,a)}if(ge(e))return e},Qo=[null,void 0],gt=(t,n)=>t.reduce((e,r)=>r instanceof j?{...e,...gt(r.fields,n)}:(Qo.includes(Q(e,r.getId()))&&yt(e,r.getId(),""),e),Qr(n)),Yo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},_r=d.memo(d.forwardRef((t,n)=>{const{schema:e,values:r={},onValuesChange:o,onSubmit:a=Yo,submitText:s="Submit",cancelText:l,onCancel:m,onDirty:u,onDirtyChange:f,hideTitle:h=!e.title,hideDescription:g,className:C,buttonProps:I,enableReinitialize:p=!1}=t,{readonly:y}=e.meta,E=d.useMemo(()=>crypto.randomUUID(),[]),w=U.useFormik({initialValues:gt(e.fields,r),onSubmit:a,validate:F=>mt(e,F),validateOnBlur:!1,validateOnChange:!1,enableReinitialize:p}),{dirty:b}=w,S=d.useMemo(()=>typeof e.title=="string"?i.jsx(c.Heading,{size:"md",children:e.title}):e.title,[e.title]),N=d.useMemo(()=>typeof e.description=="string"?i.jsx(c.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),D=d.useCallback((F,M)=>{o==null||o({...w.values,[F]:M},{[F]:M})},[w.values,o]),L=ze(e.fields,{formId:E,disabled:y,onValuesChange:D});return d.useEffect(()=>{b&&u&&u(),f&&f(b)},[b,u,f]),i.jsx(U.FormikProvider,{value:w,children:i.jsxs("form",{id:E,ref:n,className:ye(C,"flex flex-col gap-2"),onSubmit:w.handleSubmit,children:[!h&&i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-1",children:[S,!g&&N]})}),L,!y&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&i.jsxs(c.Button,{accentColor:ue.danger,...I,type:"button",onClick:m,children:[i.jsx(c.RiIcon,{icon:"RiCloseLine"}),l]}),i.jsxs(c.Button,{...I,type:"submit",disabled:!w.isValid,accentColor:"success",children:[i.jsx(c.RiIcon,{icon:"RiCheckLine"}),s]})]})]})})})),ve=d.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=U.useFormikContext(),[o,a,s]=U.useField(n),l=d.useMemo(()=>{const m=u=>{s.setValue(u,!1)};return e({value:o.value,meta:a,setValue:m,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});ve.displayName="PatchField";const Jo=d.memo(d.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:m,...u}=t,f=d.useMemo(()=>gt(r.fields,o),[r.fields,o]),h=d.useCallback(w=>{const b={};for(const S in w){const N=w[S];N!==f[S]&&N!==void 0&&(b[S]=N)}return b},[f]),g=d.useCallback(w=>{const b=h(w);l&&!ge(b)||a(b)},[h,a,l]),C=d.useCallback(w=>{const b=mt(r,w);if(b&&s(b),m){const S=h(w);m(ge(S))}return b},[r,m,s,h]),I=U.useFormik({initialValues:f,onSubmit:g,validate:C,validateOnBlur:!1,validateOnChange:!1}),p=d.useCallback(()=>{if(m){const w=h(I.values);ge(w)&&m(!0)}},[I.values,h,m]),{errors:y,resetForm:E}=I;return d.useEffect(()=>{ge(y)&&E({values:f,errors:{}})},[y,f,E]),i.jsx(U.FormikProvider,{value:I,children:i.jsx("form",{...u,ref:n,onSubmit:I.handleSubmit,onChange:p,children:e})})})),vt="form-builder",Zo=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],un={...sn,section:j},Ro=(t,n)=>{var r;const e={...t};switch(n.type){case"release":for(const o in e)e[o].disabled=!1;return e;case"hold":for(const o in e)(r=e[o])!=null&&r.conditionFields.has(n.fieldId)&&(e[o].disabled=!0);return e;case"update":return n.state}},ea=(t,n)=>{if(n)for(let e=0;e<t.length;e++){const r=t[e];if(r){for(const o of r.fields)if(o.identifier===n)return e}}},Vr=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const s=t[a];if(!s)throw new Error("Field is undefined.");const l=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,m=new Set(l);(r=s.condition)!=null&&r.identifier&&m.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:m,conditionIndex:ea(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},fn=d.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:s,upload:l}=t;if(e!=="section"&&!l)throw new Error("Upload function prop must be defined for non-section fields.");const{values:m}=U.useFormikContext(),u=d.useRef(null),f=d.useMemo(()=>{const h=[{Icon:$.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:$.RiDeleteBin7Fill,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:$.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var g;(g=u.current)==null||g.click()}}}),(r===void 0&&n!==m.fields.length-1||r!==void 0&&(r<m.fields.length-1||n!==m.fields[r].fields.length-1))&&h.unshift({Icon:$.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{s("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:$.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,m.fields]);return i.jsxs(i.Fragment,{children:[i.jsx(c.ButtonGroup,{className:"mx-2 hidden flex-col gap-0.5 sm:flex",variant:"ghost",accentColor:"base",size:"sm",children:f.map(h=>i.jsx(c.IconButton,{type:"button","aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsx(c.IconButton,{variant:"ghost",accentColor:"base","aria-label":"Actions menu",size:"sm",type:"button",children:i.jsx(c.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(c.Menu.Content,{children:f.map(h=>{var g;return i.jsxs(c.Menu.Item,{onClick:(g=h.buttonProps)==null?void 0:g.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:u,type:"file",accept:"image/*",onChange:l})]})});fn.displayName="FieldActions";const hn=d.memo(t=>{const{popoverInputs:n,hasError:e,...r}=t;return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...e&&{color:ue.danger},children:[i.jsx(c.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(c.Popover.Content,{size:"sm",...r,children:i.jsx("div",{className:"flex w-full max-w-[350px] flex-col",children:n})})]})});hn.displayName="FieldSettingsPopover";const Ur=(t=()=>null)=>d.useMemo(()=>Zo.map(n=>n.map(e=>{const r=sn[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),pn=d.memo(t=>{var Be,mn,Hr,Gr,Xr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=U.useFormikContext(),m=Ur(),u=je(),f=d.useRef(null),h=576,[g,C]=d.useState(f.current&&f.current.getBoundingClientRect().width>=h);d.useEffect(()=>{const A=f.current;if(A){const B=new ResizeObserver(W=>{W[0]&&C(W[0].contentRect.width>=h)});return B.observe(A),()=>{B.disconnect()}}},[]);const[I,p]=d.useState(void 0);d.useEffect(()=>{me(r)?p(void 0):r.image instanceof Promise?r.image.then(p).catch(console.error):p(r.image)},[r]);const y=I?URL.createObjectURL(I):void 0,E=d.useCallback(A=>{A.stopPropagation();const{image:B,...W}=r;s(`${n}.${e}`,W).then()},[e,r,n,s]);d.useEffect(()=>{me(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const w=d.useMemo(()=>{var A,B;return me(r)?(B=Cr(a.fields,(A=r.condition)==null?void 0:A.identifier))==null?void 0:B.label:void 0},[r,a.fields]),b=me(r)?Array.isArray((Be=r.condition)==null?void 0:Be.value)?"contains all of":"equals":void 0;let S;if(me(r)){if(pt((mn=r.condition)==null?void 0:mn.value))throw new Error("File values are not supported for conditions.");S=Array.isArray((Hr=r.condition)==null?void 0:Hr.value)?r.condition.value.map(A=>typeof A=="string"?A:A.label).join(", "):(Xr=(Gr=r.condition)==null?void 0:Gr.value)==null?void 0:Xr.toString()}const N=d.useCallback(A=>{A.target.parentNode instanceof HTMLElement&&(A.target.parentNode.dataset.replicatedValue=A.target.value)},[]),D=d.useCallback(A=>{A.target.parentNode instanceof HTMLElement&&(A.target.parentNode.dataset.replicatedValue=A.target.value)},[]),L=r.type,F=un[L],[M,O]=d.useMemo(()=>{let A=[],B=[];if(F===j){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const W=F.getFieldCreationSchema(o,`${n}.${e}`);A=A.concat(W.filter(V=>V.showDirectly).map(V=>V.field)),B=B.concat(W.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(F.prototype instanceof k))throw new Error(`Field must be an instance of BaseField. Got ${F.toString()}.`);const W=F.getFieldCreationSchema(`${n}.${e}`);g?(A=[...A,...W.filter(V=>V.showDirectly).map(V=>V.field)],B=[...B,...W.filter(V=>!V.showDirectly).map(V=>V.field)]):B=[...B,...W.map(V=>V.field)]}return[A,B]},[F,o,n,e,g]),H=ze(M,{formId:vt,disabled:!1,...F===j&&{size:"sm"}}),te=ze(O,{formId:vt,disabled:!1});let z=O.length>0;me(r)&&O.length>0&&(z=r.conditional);const K=O.some(A=>{const B=Q(l,F===j?`${n}.${e}.condition`:A.getId());return B&&(typeof B!="object"||ge(B))}),P=K?ue.danger:void 0,q=d.useMemo(()=>ht(r),[r]),le=Xt(q,{formId:vt,showInputOnly:!1}),ne=d.useMemo(()=>m.flat().find(A=>A.value===L),[m,L]),ce=d.useCallback(()=>{I&&u(()=>({file:I}))},[u,I]);return i.jsx("div",{className:"flex grow items-center w-full",ref:f,children:i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[F===j&&(M.length>0||z)&&i.jsxs("div",{className:"flex flex-col gap-2",children:[H,z&&i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(hn,{popoverInputs:te,hasError:K,align:"start"}),me(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":P,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:w})," ",b," ",i.jsx("strong",{children:S})]})})]})]}),F!==j&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(c.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[ne==null?void 0:ne.icon,ne==null?void 0:ne.children]}),i.jsx(ve,{name:`${n}.${e}.required`,render:({setValue:A,value:B})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.Checkbox.Root,{checked:B,onCheckedChange:A,size:"sm",children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(c.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),z&&i.jsx(hn,{popoverInputs:te,hasError:K,align:"end"})]}),I&&i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:y,alt:I.name,onClick:ce}),i.jsx(c.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:E,size:"sm",children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),i.jsx(ve,{name:`${n}.${e}.label`,render:({setValue:A,value:B})=>i.jsx("input",{className:"bg-transparent outline-none text-sm placeholder-(--base-a9)",placeholder:L==="section"?"Enter a section label (optional)":"Enter your question",value:B,onChange:W=>{A(W.target.value)},onInput:N,maxLength:200})}),i.jsx(ve,{name:`${n}.${e}.description`,render:({setValue:A,value:B})=>i.jsx("textarea",{className:"bg-transparent outline-none text-sm field-sizing-content grow placeholder-(--base-a9)",placeholder:`Enter a ${L==="section"?"section":"field"} description (optional)`,value:B,onChange:W=>{A(W.target.value)},onInput:D,maxLength:1e3})}),F!==j&&M.length>0&&i.jsx("div",{className:"w-full",children:H}),F!==j&&i.jsxs(c.Card,{className:"flex gap-4 bg-(--accent-a2) items-center",children:[i.jsxs(c.HoverCard.Root,{children:[i.jsx(c.HoverCard.Trigger,{asChild:!0,children:i.jsx(c.Badge,{icon:!0,size:"sm",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiEyeLine"})})}),i.jsx(c.HoverCard.Content,{className:"w-[225px]",size:"sm",align:"start",children:"This is a preview of the field as it will be rendered in the form."})]}),i.jsx("div",{className:"grow h-max",children:le})]})]})})});pn.displayName="FieldBuilder";const $r=d.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=U.useFormikContext(),{reorderField:l}=Yt(),{showInfo:m,showError:u}=c.useToast(),f=`fields.${r}.fields`,h=d.useMemo(()=>({index:e,parentPath:f,initial:n}),[n,e,f]),g=d.useCallback(()=>{const p=n.label||"Unlabelled field",y={...n,label:p};st(f,e+1,y,s,a),m({title:"Field duplicated",description:`The field "${p}" has been duplicated`})},[n,f,e,s,a,m]),C=d.useCallback(p=>{const y=r,E=s.fields[y];let w=r,b=p==="up"?e-1:e+1;p==="up"&&e===0?(w=r-1,b=s.fields[w].fields.length):p==="down"&&e===E.fields.length-1&&(w=r+1,b=0);const S=s.fields[w];l(E,y,e,S,w,b,a)},[r,s.fields,e,l,a]),I=d.useCallback(p=>{const{files:y}=p.target;if(!y||y.length!==1)return;const E=y.item(0);if(E){if(E.size>Go){u({title:"File upload error",description:`The file ${E.name} exceeded the maximum file size`});return}a(`${f}.${e}`,{...n,image:E}).then()}},[n,e,f,a,u]);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:p=>i.jsx(c.Card,{ref:p.innerRef,...p.draggableProps,...p.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(pn,{...h}),i.jsx(fn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:g,move:C,upload:I})]})})})});$r.displayName="FieldWithActions";const kr=d.memo(t=>{var S;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(S=r[n.identifier])==null?void 0:S.disabled,{setFieldValue:s,values:l}=U.useFormikContext(),m=c.useAlertDialog(),{reorderSection:u}=Yt(),{showInfo:f}=c.useToast(),h=d.useCallback((N,D)=>{for(const L of N){const F=D.indexOf(L);s(`fields.${F}.condition`,null).then(),s(`fields.${F}.conditional`,!1).then()}},[s]),g=d.useCallback(N=>{var F;const D=n.fields[N];if(!D)throw new Error("Could not find field to remove.");const L=[];for(const M of l.fields)((F=M.condition)==null?void 0:F.identifier)===D.identifier&&L.push(M);return{removing:D,affectedSections:L,action:()=>s(`fields.${e}.fields`,at(n.fields,N))}},[n.fields,l.fields,s,e]),C=d.useCallback(N=>{const{affectedSections:D,action:L,removing:F}=g(N),M=()=>{L().then(),h(D,l.fields)};if(D.length>0){const O=D.map(H=>H.label).join(", ");m({title:"Remove condition?",description:`${F.label} is being used as a condition, deleting it will remove the condition from the ${O} section(s).`,action:"Remove",onAction:M});return}M()},[g,h,l.fields,m]),I=d.useCallback(()=>{const D=n.fields.map((z,K)=>g(K)).flatMap(z=>z.affectedSections),L=D.length?"Remove fields and conditions?":"Remove fields?",F=n.fields.length,M=D.map(z=>z.label).join(", "),O=D.length?`Deleting this section will remove the ${F} field(s) it contains and will remove the conditions from following sections: ${M}`:`Deleting this section will remove the ${F} field(s) it contains.`,H=at(l.fields,e),te=()=>s("fields",H);if(D.length>0){m({title:L,description:O,action:"Remove",onAction:()=>{te().then(()=>{h(D,H)})}});return}te().then()},[n.fields,l.fields,e,g,s,m,h]),p=d.useCallback(N=>{const D=N==="up"?e-1:e+1;u(r,n.identifier,e,D,l,s)},[e,u,r,n.identifier,l,s]),y=d.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:wr(l.fields,e)}),[n,e,l.fields]),E=d.useCallback(()=>{const N=n.label||"Untitled section",D=n.fields.map(F=>({...F,identifier:Qt()})),L={...n,label:N,fields:D};st("fields",e+1,L,l,s),f({title:"Section duplicated",description:`The section "${N}" has been duplicated.`})},[n,e,l,s,f]),w=d.useCallback(N=>{st(`fields.${e}.fields`,n.fields.length,Ho[N],l,s)},[e,n.fields.length,l,s]),b=Ur(w);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:N=>i.jsx(c.Card,{ref:N.innerRef,...N.draggableProps,...N.dragHandleProps,variant:"outline",className:"mb-4 w-full",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i.jsxs("div",{className:"flex grow flex-col gap-2 w-full",children:[!o&&i.jsx(pn,{...y}),i.jsx(ie.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:D=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:D.innerRef,...D.droppableProps,children:[n.fields.map((L,F)=>i.jsx($r,{field:L,index:F,sectionIndex:e,remove:()=>{C(F)}},L.identifier)),D.placeholder,i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{type:"button",variant:"soft",size:"sm",children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(c.Menu.Content,{children:b.flat().map(L=>i.jsxs(c.Menu.Item,{onSelect:L.onSelect,children:[L.icon,L.children]},L.value))})]})]})})]}),!o&&i.jsx(fn,{index:e,type:n.type,remove:I,duplicate:E,move:p})]})})})});kr.displayName="FieldSectionWithActions";const jr=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},Wr=d.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=U.useFormikContext(),[o,a]=d.useReducer(Ro,e.fields,Vr),{reorderSection:s,reorderField:l}=Yt();d.useEffect(()=>{a({type:"update",state:Vr(e.fields)})},[a,e.fields]);const m=d.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),u=d.useCallback(h=>{const{source:g,destination:C,type:I,reason:p,draggableId:y}=h;if(a({type:"release"}),!C||p==="CANCEL")return;if(I==="ROOT"){s(o,y,g.index,C.index,e,r);return}if(I!=="SECTION")throw new Error("Unexpected droppable type.");const[E,w]=jr(e.fields,g.droppableId)??[],[b,S]=jr(e.fields,C.droppableId)??[];l(E,w,g.index,b,S,C.index,r)},[e,l,r,s,o]),f=d.useCallback(h=>{ko(h+1,e,r)},[e,r]);return i.jsx(ie.DragDropContext,{onDragStart:m,onDragEnd:u,children:i.jsx(ie.Droppable,{droppableId:"droppable",type:"ROOT",children:h=>i.jsxs("div",{className:"flex flex-col gap-0",ref:h.innerRef,...h.droppableProps,children:[e.fields.map((g,C)=>i.jsxs(d.Fragment,{children:[i.jsx(kr,{field:g,index:C,dropState:o,fieldsOnly:n}),!n&&C!==e.fields.length-1&&i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",size:"sm",accentColor:"base",onClick:()=>{f(C)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]})]},g.identifier)),i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:()=>{f(e.fields.length)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});Wr.displayName="FieldsEditor";const ta=()=>{alert("This is a form preview, your data will not be saved.")},na=d.memo(d.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:m=!1,showTabs:u=!0,tabsListClassName:f,hydrateRevisionWithImages:h}=t,{showError:g}=c.useToast(),C=d.useCallback(w=>{const b={};w.title||(b.title="Title is required."),(!w.fields||w.fields.length===0)&&(b.fields="At least one field is required.");let S=[];for(const[D,L]of w.fields.entries()){const M=un.section.getFieldCreationSchema(wr(w.fields,D),`fields.${D}`).map(O=>O.field);S=[...S,...M];for(const[O,H]of L.fields.entries()){const z=un[H.type].getFieldCreationSchema(`fields.${D}.fields.${O}`).map(K=>K.field);S=[...S,...z]}}const N=mt({fields:S},w);if(N&&(b.fields=N.fields),ge(b))return g({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),b},[g]),I=d.useMemo(()=>({title:a??"",description:"",fields:[{...ot(Qt()),label:""}]}),[a]),p=o?h(o):void 0,y=U.useFormik({initialValues:$o(p)??I,validate:C,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=d.useMemo(()=>Br(y.values),[y.values]);return i.jsx(c.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[u&&i.jsxs(c.Tabs.List,{className:ye("sticky top-0 z-[2000] flex bg-(--color-background)",f),children:[i.jsx(c.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(c.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(c.Tabs.Content,{value:"edit",children:[s&&i.jsxs(c.Text,{children:["Create your form using various field types. Sections can be"," ",i.jsx("strong",{children:"conditionally rendered"})," based on"," ",i.jsx("strong",{children:"answers to fields in preceding sections. "})]}),i.jsxs("form",{className:"mt-3 flex flex-col gap-2",id:vt,onSubmit:y.handleSubmit,children:[i.jsxs(U.FormikProvider,{value:y,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(ve,{name:"title",render:({setValue:w,value:b,meta:S})=>i.jsx(qt,{severity:"danger",helpText:S.error??null,children:i.jsx(c.Input.Root,{variant:"outline",size:"md",accentColor:S.error?ue.danger:"primary",children:i.jsx(c.Input.Field,{placeholder:"Form title",value:b,onChange:N=>{w(N.target.value)},maxLength:100})})})}),i.jsx(ve,{name:"description",render:({setValue:w,value:b})=>i.jsx(c.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:b,onChange:S=>{w(S.target.value)},resize:"vertical",maxLength:1e3,size:"md"})})]}),i.jsx(Wr,{fieldsOnly:m}),i.jsx("span",{"data-accent-color":ue.danger,className:"text-xs text-(--accent-a11)",children:typeof y.errors.fields=="string"&&y.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(c.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(c.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(c.Tabs.Content,{value:"preview",children:i.jsx(_r,{schema:E,onSubmit:ta,hideTitle:!l})})]})})})),ra=Object.values(de.Colors),ia=1;async function oa(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),s=new Image(r.width,r.height),l=new de.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),s.src=URL.createObjectURL(e),s.onload=async function(){o.drawImage(s,0,0,r.width,r.height);const m=t.toDataURL("image/jpeg",ia),u=await de.fileToBlob(m),f=new File([u],n.name,{type:"image/jpeg"});l.resolve(f)}},a.src=URL.createObjectURL(n),l}const qr=d.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:s}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const l=d.useRef(null),m=d.useRef(null),[u,f]=d.useState(de.Colors.red),[h,g]=d.useState(null),[C,I]=d.useState(!1),[p,y]=d.useState(!1),E=d.useRef(null),w=c.useSize(E);d.useEffect(()=>{const z=new Image;z.onload=function(){g({width:z.naturalWidth,height:z.naturalHeight})},z.src=URL.createObjectURL(n)},[n]),d.useEffect(()=>{!p&&(w!=null&&w.width)&&w.height&&y(!0)},[w,p]);const b=d.useCallback(async()=>{a||e();const z=l.current;if(!z)return;if(!h)throw new Error("Original image size not loaded yet");const K=await z.exportImage("png"),P=new Image(h.width,h.height);P.onload=async function(){const q=await de.fileToBlob(K),le=new File([q],n.name,{type:n.type}),ne=m.current,ce=await oa(ne,n,le,h);ce.objectURL=URL.createObjectURL(ce);const Be=await de.hashFile(n);await de.hashFile(ce)!==Be&&r(ce),I(!1),e()},I(!0),P.src=K},[a,n,e,r,h]),S=d.useCallback(()=>{o(n)},[n,o]),N=d.useCallback(()=>{e()},[e]),D=d.useCallback(()=>{s(!0)},[s]),L=d.useCallback(()=>{l.current&&l.current.redo()},[]),F=d.useCallback(()=>{l.current&&l.current.undo()},[]),M=d.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),O=d.useCallback(z=>{l.current&&l.current.eraseMode(z)},[]),H=d.useCallback(()=>{b()},[b]),te=d.useCallback(()=>{jt.saveAs(n,n.name)},[n]);return i.jsx(Vt,{open:!0,onOpenChange:e,children:i.jsxs(Ut,{children:[i.jsx($t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":""}),i.jsxs(kt,{className:"absolute inset-0 py-12","data-floating-content":"",children:[i.jsx(c.ButtonGroup,{className:"flex w-full gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",size:"md",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.IconButton,{"aria-label":"close",onClick:N,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})}),i.jsx(c.IconButton,{"aria-label":`Download ${n.name}`,onClick:te,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(bt,{selectedColor:u,allColors:ra,onFinish:f,trigger:i.jsx(c.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:u},children:" "})}),i.jsx(c.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:O,children:i.jsx(c.RiIcon,{icon:"RiEraserFill"})}),i.jsx(c.Separator,{orientation:"vertical",size:"full"}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:F,children:i.jsx(c.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:L,children:i.jsx(c.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(c.IconButton,{"aria-label":"undo all",onClick:M,children:i.jsx(c.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(c.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:H,children:i.jsx(c.RiIcon,{icon:"RiSaveLine"})}),i.jsx(c.IconButton,{"aria-label":"Delete attachment",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})}),h&&i.jsx("canvas",{id:"attachment-markup-canvas",className:"hidden",ref:m,width:h.width,height:h.height}),i.jsxs("div",{className:"relative size-full flex items-center justify-center p-4 overflow-hidden",children:[i.jsx("img",{className:"max-w-full max-h-full invisible absolute",alt:"Photo attachment",ref:E,src:n.objectURL}),C?i.jsx(c.Spinner,{}):i.jsx(Yr.ReactSketchCanvas,{className:"max-w-full max-h-full aspect-square",backgroundImage:n.objectURL,ref:l,onStroke:D,strokeColor:u},p?"1":"0")]})]})]})})});qr.displayName="AttachmentEditor",x.BaseField=k,x.BaseFormElement=wt,x.BooleanField=Ee,x.BooleanInput=Ht,x.ColorPicker=bt,x.DateField=nt,x.DateInput=Gt,x.FieldSection=j,x.FileCard=Ct,x.FileIcon=$e,x.FormBuilder=na,x.FormRenderer=_r,x.ImageCard=Ar,x.ImageMarkup=qr,x.ImageViewer=Wt,x.ImageViewerProvider=pr,x.InputWithHelpText=qt,x.InputWithLabel=J,x.InputWithLabelAndHelpText=Z,x.MultiSelectField=Ve,x.MultiSelectInput=tn,x.MultiStringField=_e,x.MultiStringInput=Jt,x.NumberField=se,x.NumberInput=Zt,x.PatchField=ve,x.PatchFormProvider=Jo,x.QrField=lt,x.QrInput=Rt,x.QrScanner=en,x.SUPPORTED_IMAGE_FILE_TYPES=bn,x.SUPPORTED_PDF_FILE_TYPES=wn,x.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=Cn,x.SelectField=Ue,x.SelectInput=nn,x.StringField=dt,x.StringInput=rn,x.TextField=ut,x.TextInput=on,x.decodeFormValues=Xo,x.deserialize=ht,x.deserializeField=ln,x.emptyBaseField=G,x.emptyBooleanField=mr,x.emptyDateField=gr,x.emptyMultiSelectField=Nr,x.emptyMultiStringField=Ir,x.emptyNumberField=xr,x.emptyQrField=Sr,x.emptySelectField=Fr,x.emptyStringField=Dr,x.emptyTextField=Mr,x.encodeFormValues=Ko,x.fieldIcons=Rr,x.flattenFields=cn,x.formRevisionToSchema=Br,x.initialFormValues=gt,x.isConditionMet=dn,x.useFieldInput=Xt,x.useFieldInputs=ze,x.useFormikInput=X,x.useImageViewer=je,x.validateForm=mt,x.valueIsFile=pt,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@overmap-ai/forms",
3
3
  "private": false,
4
- "version": "1.0.17-blur-updates.3",
4
+ "version": "1.0.17-blur-updates.5",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/forms.umd.cjs",
7
7
  "module": "dist/forms.js",