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