@lattice-php/lattice 0.46.0 → 0.47.0
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/types/generated.d.ts +3 -3
- package/dist-standalone/chunks/badge-oZDK5bxm.js +1 -0
- package/dist-standalone/chunks/{chart-view-DghsYabe.js → chart-view-DhCVr5fn.js} +2 -2
- package/dist-standalone/chunks/color-CXV-Y5Qv.js +1 -0
- package/dist-standalone/chunks/date-picker-field-Ds1A1ipK.js +1 -0
- package/dist-standalone/chunks/{registry-context-BdTXNnGL.js → dist-DbKexmtw.js} +1 -1
- package/dist-standalone/chunks/dist-DlQDeTRF.js +106 -0
- package/dist-standalone/chunks/field-BQzK42M4.js +1 -0
- package/dist-standalone/chunks/format-context-CxuxddW6.js +1 -0
- package/dist-standalone/chunks/input-DAZtm5hT.js +1 -0
- package/dist-standalone/chunks/registry-context-Q5KtSmdi.js +1 -0
- package/dist-standalone/chunks/rich-editor-field-BsezbAas.js +53 -0
- package/dist-standalone/chunks/runtime-Bi4uPw0x.js +27 -0
- package/dist-standalone/chunks/{subscriptions-BICQU9ps.js → subscriptions-WYT4UqqY.js} +1 -1
- package/dist-standalone/chunks/{time-picker-CAwU5Rl-.js → time-picker-CMZqQpOJ.js} +1 -1
- package/dist-standalone/chunks/toolbar-button-DUDNmNDx.js +1 -0
- package/dist-standalone/chunks/translatable-D6DlHH6Q.js +1 -0
- package/dist-standalone/chunks/use-dependent-field-zJUDiN2l.js +41 -0
- package/dist-standalone/lattice.js +1 -1
- package/dist-standalone/manifest.json +1 -1
- package/dist-standalone/runtime.js +1 -1
- package/package.json +6 -6
- package/dist-standalone/chunks/date-picker-field-CaRIypsW.js +0 -1
- package/dist-standalone/chunks/format-context-DCYPeoEM.js +0 -1
- package/dist-standalone/chunks/rich-editor-field-DnkT5hlA.js +0 -158
- package/dist-standalone/chunks/runtime-5aZwKnpP.js +0 -27
- package/dist-standalone/chunks/toolbar-button-BmtWFTk1.js +0 -41
- package/dist-standalone/chunks/translatable-YXSlt1CF.js +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./date-picker-field-Ds1A1ipK.js","./rolldown-runtime-hePW80VL.js","./react-CwJFpaho.js","./react-dom-Dl-LT-t1.js","./floating-ui.dom-CO6FyQ6K.js","./clsx-CjueKrWZ.js","./jsx-runtime-NZYk81nU.js","./time-picker-CMZqQpOJ.js","./locale-BZOrJtMq.js","./input-DAZtm5hT.js","./field-BQzK42M4.js","./instance-D6cXaqIT.js","./timezone-Ckl1gbqB.js","./use-dependent-field-zJUDiN2l.js","./dist-DbKexmtw.js","./debounce-CBXrtDuZ.js","./badge-oZDK5bxm.js","./color-CXV-Y5Qv.js","./dist-DlQDeTRF.js","./w3c-keyname-BOAvb0qz.js","./with-selector-Cse0iXU1.js","./rich-editor-field-BsezbAas.js","./registry-context-Q5KtSmdi.js","./toolbar-button-DUDNmNDx.js","./notifications-echo-BLO9_g1w.js","./dist-D2qBbka0.js","./code-block-view-CetAq3Rk.js","./chart-view-DhCVr5fn.js","./materialize-CWqnSEHR.js","./format-context-CxuxddW6.js","./subscriptions-WYT4UqqY.js","./translatable-D6DlHH6Q.js","./page-props-DZ15iP5k.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{t as n}from"./react-CwJFpaho.js";import{n as r,t as i}from"./materialize-CWqnSEHR.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-DbKexmtw.js";import{t as f}from"./react-dom-Dl-LT-t1.js";import{_ as p,f as m,g as h,h as g,m as _,p as v,u as y}from"./floating-ui.dom-CO6FyQ6K.js";import{t as b}from"./jsx-runtime-NZYk81nU.js";import{a as x,i as S,n as C,r as w,t as T}from"./time-picker-CMZqQpOJ.js";import{a as E,i as D,n as O,o as k,r as A,s as j}from"./format-context-CxuxddW6.js";import{a as M,n as N,o as P,s as F}from"./locale-BZOrJtMq.js";import{i as I,n as L,r as ee,t as te}from"./registry-context-Q5KtSmdi.js";import{a as ne,i as re,n as ie,s as R,t as ae}from"./translatable-D6DlHH6Q.js";import{c as z,i as oe,n as se,s as B}from"./instance-D6cXaqIT.js";import{a as ce,i as le,o as ue,r as de}from"./timezone-Ckl1gbqB.js";import{r as fe}from"./page-props-DZ15iP5k.js";import{$ as pe,A as me,B as he,C as ge,D as _e,E as ve,F as ye,G as be,H as xe,I as Se,J as Ce,K as we,L as Te,M as Ee,N as De,P as Oe,Q as ke,R as Ae,S as je,T as Me,U as Ne,V as Pe,W as Fe,X as Ie,Y as Le,Z as Re,_ as ze,a as Be,at as Ve,b as He,c as Ue,ct as V,d as We,et as Ge,f as Ke,g as qe,h as Je,i as Ye,it as Xe,j as Ze,k as Qe,l as $e,m as et,n as tt,nt as H,o as nt,ot as rt,p as it,q as at,r as ot,rt as st,s as ct,st as lt,t as ut,tt as dt,u as ft,v as pt,w as mt,x as ht,y as gt,z as _t}from"./use-dependent-field-zJUDiN2l.js";import{n as vt,r as yt,t as bt}from"./input-DAZtm5hT.js";import{s as xt}from"./toolbar-button-DUDNmNDx.js";import{i as St,n as Ct,r as wt,t as Tt}from"./color-CXV-Y5Qv.js";import{n as Et,t as Dt}from"./badge-oZDK5bxm.js";var U=e(n(),1),Ot=`modulepreload`,kt=function(e,t){return new URL(e,t).href},At={},jt=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=kt(t,n),t=s(t),t in At)return;At[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ot,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function W(e){return{component:e,mode:`eager`}}function Mt(e){let t=e;return{component:(0,U.lazy)(t),load:t,mode:`lazy`}}var Nt=e=>jt(()=>import(e),[],import.meta.url);function Pt(e){return e===void 0||i(e)&&Object.values(e).every(e=>i(e)&&(e.mode===`eager`&&typeof e.component==`function`||e.mode===`lazy`&&i(e.component)&&typeof e.load==`function`))}function Ft(e){return e===void 0||i(e)&&Object.values(e).every(e=>i(e))}function It(e,t){let n=i(e)?e.default:void 0;if(!i(n)||typeof n.name!=`string`||n.name.trim()===``||!Pt(n.components)||!Ft(n.extensions)||n.i18n!==void 0&&(!i(n.i18n)||typeof n.i18n.namespace!=`string`||n.i18n.namespace.trim()===``))throw TypeError(`[lattice] Plugin module [${t}] must default export a Plugin object.`);return n}function Lt(e,t=Nt){return Promise.all(e.map(async e=>It(await t(e),e)))}function Rt(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n??{}))t[e]={...t[e],...r};return t}function zt(...e){return e.reduce((e,t)=>({components:{...e.components,...t.components},extensions:Rt(e.extensions,t.extensions)}),{components:{},extensions:{}})}function Bt(e,...t){return zt({name:`registry`,...e},...t)}var G=e(b(),1),Vt=(0,U.createContext)([]);function Ht({children:e,renderer:t}){let n=(0,U.useContext)(Vt),r=(0,U.useMemo)(()=>[t,...n],[n,t]);return(0,G.jsx)(Vt.Provider,{value:r,children:e})}function K({className:e,icon:t}){let n=(0,U.useContext)(Vt),{ids:r}=h();for(let r of n){let n=r({className:e,icon:t});if(n!=null&&n!==!1)return n}return r&&!r.includes(t)?(0,G.jsx)(Ut,{className:e}):(0,G.jsx)(_,{className:e,name:t})}function Ut({className:e}){return(0,G.jsxs)(`svg`,{"aria-hidden":`true`,className:p(`size-lt-icon-md text-lt-muted-fg`,e),"data-lattice-missing-icon":``,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,G.jsx)(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),(0,G.jsx)(`path`,{d:`M12 17h.01`})]})}var Wt=e(f(),1),Gt=(0,U.createContext)(null);function Kt(e){return e.type===`action`||e.type===`action.bulk`}function qt({children:e,render:t}){return(0,G.jsx)(Gt.Provider,{value:t,children:e})}function Jt(){return(0,U.useContext)(Gt)}function Yt({action:e,children:t}){let n=Jt();if(!n)throw Error(`Action triggers require an ActionTriggerProvider.`);return(0,G.jsx)(G.Fragment,{children:n({action:e,children:t})})}function Xt(e){let t=re(),n=e.action??null,r=e.effects??[];if(n){if(!Kt(n))throw Error(`Clickable action nodes must have type [action] or [action.bulk].`);return{kind:`action`,action:n}}return r.length>0?{kind:`effects`,onClick:()=>t(R(r))}:e.href!=null&&e.href!==``?{kind:`navigate`,href:e.href,method:e.method??`get`}:{kind:`none`}}var Zt=({node:e})=>{let{label:t,icon:n}=e.props,r=e.props.variant??null,i=e.props.emphasis??`solid`,a=D(e),o=Xt(e.props),s=n?`icon`:`md`,c=n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{className:`size-lt-icon-md`,icon:n}),t?(0,G.jsx)(`span`,{className:`sr-only`,children:t}):null]}):t,u=({onClick:e,processing:t})=>(0,G.jsx)(x,{"data-test":a,disabled:t,emphasis:i,onClick:e,size:s,variant:r,children:c});return o.kind===`navigate`?(0,G.jsx)(x,{asChild:!0,"data-test":a,emphasis:i,variant:r,size:s,children:(0,G.jsx)(l,{href:o.href,method:o.method,children:c})}):o.kind===`action`?(0,G.jsx)(Yt,{action:o.action,children:u}):o.kind===`effects`?u({onClick:o.onClick,processing:!1}):(0,G.jsx)(x,{"data-test":a,emphasis:i,size:s,type:e.props.buttonType,variant:r,children:c})};function Qt(e,t,n={}){let{enabled:r=!0}=n,i=(0,U.useRef)(t);i.current=t,(0,U.useEffect)(()=>{if(!r||typeof window>`u`)return;let t=e=>i.current(e);return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e,r])}function $t({preserveScroll:e=!0,preserveState:t=!0}){return Qt(F.localeChange,n=>{let r=n.detail?.locale;typeof r==`string`&&r!==``&&u.visit(window.location.href,{preserveScroll:e,preserveState:t})}),null}function en({namespace:e=`lattice`,label:t}={}){let{t:n,locale:r,locales:i,setLocale:a}=z(e),o=i.length>0?i:[r],s=t??(e=>n(`language.${e}`,e));return{locale:r,locales:o,options:o.map(e=>({value:e,label:s(e),active:e===r})),setLocale:a}}function tn({value:e,dateStyle:t=`medium`,timeStyle:n=`short`}){let{locale:r}=M(),{timezone:i}=de();if(e==null||e===``)return null;let a={locale:r,timeZone:i},o=le(e,{dateStyle:t,timeStyle:n},a),s=nn(e),c=ce(e,a);return(0,G.jsx)(`time`,{dateTime:s??void 0,title:c||void 0,children:o})}function nn(e){return ue(e)?.toISOString()??null}function rn({className:e,...t}){let{t:n}=z(se);return(0,G.jsx)(_,{name:`loader-2`,role:`status`,"aria-label":n(`common.loading`,`Loading`),"aria-hidden":!1,className:p(`animate-spin`,e),...t})}var an=(0,U.createContext)(!1),on=`flex h-lt-control-sm w-full items-center justify-start gap-2 rounded-lt-sm px-2.5 text-left text-sm font-normal text-lt-popover-fg no-underline decoration-transparent shadow-none transition-colors hover:bg-lt-accent/70 hover:text-lt-popover-fg focus-visible:bg-lt-accent/70 focus-visible:text-lt-popover-fg focus-visible:ring-0 focus-visible:outline-none disabled:pointer-events-none disabled:text-lt-disabled-fg [&_svg]:size-lt-icon-sm [&_svg]:text-lt-muted-fg`;function sn({children:e}){return(0,G.jsx)(an.Provider,{value:!0,children:e})}function cn(){return(0,U.useContext)(an)}var ln=Object.defineProperty,q=(e,t)=>ln(e,`name`,{value:t,configurable:!0}),un=`Dialog`,[dn,fn]=lt(un),[pn,mn]=dn(un),hn=q(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=U.useRef(null),c=U.useRef(null),[l,u]=Xe({prop:r,defaultProp:i??!1,onChange:a,caller:un}),[d,f]=U.useState(0),[p,m]=U.useState(0);return(0,G.jsx)(pn,{scope:t,triggerRef:s,contentRef:c,contentId:Ve(),titleId:Ve(),descriptionId:Ve(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:U.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),gn=`DialogPortal`,[_n,vn]=dn(gn,{forceMount:void 0}),yn=q(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=mn(gn,t);return(0,G.jsx)(_n,{scope:t,forceMount:n,children:U.Children.map(r,e=>(0,G.jsx)(Ce,{present:n||a.open,children:(0,G.jsx)(Le,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),bn=`DialogOverlay`,xn=U.forwardRef(q(function(e,t){let n=vn(bn,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mn(bn,e.__scopeDialog);return a.modal?(0,G.jsx)(Ce,{present:r||a.open,children:(0,G.jsx)(Cn,{...i,ref:t})}):null},`DialogOverlay`)),Sn=m(`DialogOverlay.RemoveScroll`),Cn=U.forwardRef(q(function(e,t){let{__scopeDialog:n,...r}=e,i=mn(bn,n),a=Ge(),o=v(t,a);return(0,G.jsx)(we,{as:Sn,allowPinchZoom:!0,shards:[i.contentRef],children:(0,G.jsx)(H.div,{"data-state":Fn(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),wn=`DialogContent`,Tn=U.forwardRef(q(function(e,t){let n=vn(wn,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mn(wn,e.__scopeDialog);return(0,G.jsx)(Ce,{present:r||a.open,children:a.modal?(0,G.jsx)(En,{...i,ref:t}):(0,G.jsx)(Dn,{...i,ref:t})})},`DialogContent`)),En=U.forwardRef(q(function(e,t){let n=mn(wn,e.__scopeDialog),r=U.useRef(null),i=v(t,n.contentRef,r);return U.useEffect(()=>{let e=r.current;if(e)return be(e)},[]),(0,G.jsx)(On,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:V(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:V(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:V(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Dn=U.forwardRef(q(function(e,t){let n=mn(wn,e.__scopeDialog),r=U.useRef(!1),i=U.useRef(!1);return(0,G.jsx)(On,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),On=U.forwardRef(q(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=mn(wn,n);return at(),(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Ie,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,G.jsx)(ke,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Fn(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),kn=`DialogTitle`,An=U.forwardRef(q(function(e,t){let{__scopeDialog:n,...r}=e,i=mn(kn,n),{setTitleCount:a}=i;return rt(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,G.jsx)(H.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),jn=`DialogDescription`,Mn=U.forwardRef(q(function(e,t){let{__scopeDialog:n,...r}=e,i=mn(jn,n),{setDescriptionCount:a}=i;return rt(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,G.jsx)(H.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Nn=`DialogClose`,Pn=U.forwardRef(q(function(e,t){let{__scopeDialog:n,...r}=e,i=mn(Nn,n);return(0,G.jsx)(H.button,{type:`button`,...r,ref:t,onClick:V(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Fn(e){return e?`open`:`closed`}q(Fn,`getState`);var In=y(`fixed z-lt-modal w-full overflow-y-auto bg-lt-bg p-6 shadow-lt-lg`,{variants:{placement:{center:`left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-lt border border-lt-border data-[state=open]:animate-lt-dialog-in data-[state=closed]:animate-lt-dialog-out`,start:`inset-y-0 start-0 border-e border-lt-border data-[state=open]:animate-lt-sheet-in-start data-[state=closed]:animate-lt-sheet-out-start`,end:`inset-y-0 end-0 border-s border-lt-border data-[state=open]:animate-lt-sheet-in-end data-[state=closed]:animate-lt-sheet-out-end`},width:{sm:`max-w-sm`,md:`max-w-md`,lg:`max-w-lg`,xl:`max-w-xl`,"2xl":`max-w-2xl`,"3xl":`max-w-3xl`},height:{sm:``,md:``,lg:``,xl:``,"2xl":``,"3xl":``}},compoundVariants:[{placement:`center`,height:`sm`,class:`max-h-[min(480px,calc(100vh-2rem))]`},{placement:`center`,height:`md`,class:`max-h-[min(600px,calc(100vh-2rem))]`},{placement:`center`,height:`lg`,class:`max-h-[min(680px,calc(100vh-2rem))]`},{placement:`center`,height:`xl`,class:`max-h-[min(820px,calc(100vh-2rem))]`},{placement:`center`,height:`2xl`,class:`max-h-[min(920px,calc(100vh-2rem))]`},{placement:`center`,height:`3xl`,class:`max-h-[min(1040px,calc(100vh-2rem))]`}],defaultVariants:{placement:`center`,width:`lg`,height:`lg`}});function Ln(e){return(0,G.jsx)(hn,{"data-slot":`dialog`,...e})}function Rn(e){return(0,G.jsx)(Pn,{"data-slot":`dialog-close`,...e})}function zn({className:e,...t}){return(0,G.jsx)(An,{className:p(`text-lg font-semibold leading-none tracking-tight`,e),"data-slot":`dialog-title`,...t})}function Bn({className:e,...t}){return(0,G.jsx)(Mn,{className:p(`text-sm text-lt-muted-fg`,e),"data-slot":`dialog-description`,...t})}function Vn({children:e,className:t,placement:n=`center`,width:r=`lg`,height:i=`lg`,...a}){return(0,G.jsxs)(yn,{children:[(0,G.jsx)(xn,{className:`fixed inset-0 z-lt-overlay bg-lt-overlay data-[state=open]:animate-lt-fade-in data-[state=closed]:animate-lt-fade-out`,"data-slot":`dialog-overlay`}),(0,G.jsx)(Tn,{className:p(In({placement:n,width:r,height:i}),t),"data-slot":`dialog-content`,...a,children:e})]})}function Hn({closeLabel:e,description:t,title:n}){return(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(zn,{children:n}),t?(0,G.jsx)(Bn,{children:t}):null]}),(0,G.jsx)(Rn,{asChild:!0,children:(0,G.jsx)(x,{"aria-label":e,"data-test":`dialog-close`,size:`icon`,emphasis:`ghost`,children:(0,G.jsx)(_,{name:`x`,"aria-hidden":`true`,className:`size-lt-icon-md`})})})]})}function Un({title:e,description:t,confirmLabel:n,cancelLabel:r=`Cancel`,confirmVariant:i=null,confirmEmphasis:a=null,processing:o=!1,confirmDisabled:s=!1,onConfirm:c,onCancel:l}){let u=e=>{o&&e.preventDefault()};return(0,G.jsx)(Ln,{open:!0,onOpenChange:e=>{e||l()},children:(0,G.jsxs)(Vn,{...t?{}:{"aria-describedby":void 0},width:`md`,onEscapeKeyDown:u,onInteractOutside:u,children:[(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(zn,{children:e}),t&&(0,G.jsx)(Bn,{children:t})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,G.jsx)(x,{type:`button`,emphasis:`outline`,"data-test":`confirm-cancel`,disabled:o,onClick:l,children:r}),(0,G.jsxs)(x,{type:`button`,emphasis:a,variant:i,"data-test":`confirm-accept`,disabled:o||s,onClick:c,children:[o&&(0,G.jsx)(rn,{}),n]})]})]})})}var Wn=`X-Lattice-Ref`,Gn=new Map;function Kn(e){return Gn.get(e)??e}function qn(e,t){Gn.set(e,t)}function Jn(e){let t=Kn(e);return t?{[Wn]:t}:{}}var Yn=()=>({});function Xn(e){Yn=e}function Zn(e={}){return{...Yn(),...e}}function Qn(e=``,t={}){return{...Zn(),...Jn(e),...t}}var $n=class extends Error{response;constructor(e){super(`HTTP ${e.status}`),this.response=e}};function er(){let e=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):``}var tr=1e4,nr=new Map,rr=new Map;function ir(e){return e===void 0||e===`GET`||e===`HEAD`?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`,"X-XSRF-TOKEN":er()}}var ar=`/lattice/refs/refresh`;function or(e){ar=e}var sr=new Map;async function cr(e){let t=sr.get(e);if(t)return t;let n=lr(ar,{method:`POST`,body:JSON.stringify({ref:Kn(e)})}).then(t=>(qn(e,t.ref),t.ref)).catch(()=>null).finally(()=>{sr.delete(e)});return sr.set(e,n),n}async function J(e,t={}){let{ref:n=``,headers:r,throwOnError:i=!0,method:a,...o}=t,s=a?.toUpperCase(),c=()=>fetch(e,{credentials:`same-origin`,...o,method:s,headers:Qn(n,{...ir(s),...r})}),l=await c();if(n!==``&&l.status===403&&await cr(n)!==null&&(l=await c()),i&&!l.ok)throw new $n(l);return l}async function lr(e,t){return(await J(e,t)).json()}function ur(e){return[e.source,e.audience,[...e.scopes].sort().join(` `)].join(``)}function dr(e){nr.delete(ur(e))}async function fr(e){let t=ur(e),n=nr.get(t);if(n&&n.expiresAt>Date.now()+tr)return n.token;let r=rr.get(t);if(r)return r;let i=lr(e.tokenEndpoint,{method:`POST`,ref:e.ref,body:JSON.stringify({nodeId:e.nodeId,nodeType:e.nodeType,audience:e.audience,scopes:e.scopes})}).then(e=>(nr.set(t,{token:e,expiresAt:Date.now()+Math.max(0,e.expiresIn)*1e3}),e)).finally(()=>{rr.delete(t)});return rr.set(t,i),i}function pr(e){return e.status===401||e.status===403}async function mr(e,t,n){let{headers:r,...i}=t;return fetch(e,{...i,credentials:`omit`,headers:Zn({Accept:`application/json`,...r,Authorization:`${n.tokenType} ${n.accessToken}`})})}async function hr(e,t){let{remote:n,throwOnError:r=!0,...i}=t,a=await fr(n),o=await mr(e,i,a);if(pr(o)&&(dr(n),a=await fr(n),o=await mr(e,i,a)),r&&!o.ok)throw new $n(o);return o}async function gr(e,t){return(await hr(e,t)).json()}async function _r(e,t){try{let n=await e(),r=await n.json().catch(()=>({}));return t(R(r.effects)),n.ok}catch(e){return ne(e),!1}}function vr({className:e,...t}){return(0,G.jsx)(`div`,{"aria-hidden":`true`,className:p(`animate-pulse rounded-lt-sm bg-lt-muted`,e),"data-slot":`skeleton`,...t})}function yr(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`):[]}function br(e,t){return e.key??e.id??`${e.type}-${t}`}var xr=(0,U.createContext)(!1);function Sr(){return(0,U.useContext)(xr)}function Cr(){return(0,G.jsxs)(`svg`,{"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:[(0,G.jsx)(`rect`,{height:`18`,rx:`2`,strokeDasharray:`4 3`,width:`18`,x:`3`,y:`3`}),(0,G.jsx)(`path`,{d:`M12 8v4`}),(0,G.jsx)(`path`,{d:`M12 16h.01`})]})}function wr({node:e}){e.type;let t=`Missing component: ${e.type}`;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 align-middle text-lt-muted-fg`,"data-lattice-missing-component":e.type,title:t,children:[(0,G.jsx)(Cr,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:t})]})}function Y({nodes:e}){return e.map((e,t)=>(0,G.jsx)(Tr,{node:e},br(e,t)))}function X({node:e}){return(0,G.jsx)(Tr,{node:e})}var Tr=(0,U.memo)(function({node:e}){let t=Sr(),n=ee()[e.type];if(t&&e.props?.hideWhenCollapsed===!0)return null;if(!n)return(0,G.jsx)(wr,{node:e});let r=n.component,i=e.schema?.length?(0,G.jsx)(Y,{nodes:e.schema}):null,a=(0,G.jsx)(r,{node:e,children:i});return n.mode===`lazy`?(0,G.jsx)(U.Suspense,{fallback:null,children:a}):a}),Er=(0,U.createContext)({});function Dr({nodes:e,children:t}){return(0,G.jsx)(Er.Provider,{value:e,children:t})}function Or(e){let t=(0,U.useContext)(Er),n=he(e).name??``,r=mt(),i=n&&r?r.errorKey(n):n;return i&&t[i]||n&&t[n]||e}var kr=typeof window>`u`?U.useEffect:U.useLayoutEffect;function Ar(e,t,n,r){return J(e,{method:`POST`,ref:t,signal:r,body:JSON.stringify(n),throwOnError:!1}).then(e=>e.ok?e.json():null)}function jr(e){let t=e.props.templates;return t?.length?t:void 0}function Mr(e,t){let n=jr(e);return n?n.find(e=>e.type===t.type)?.schema??[]:e.schema??[]}function Nr(e,t){return e.startsWith(`@`)?e.slice(1):t===null?e:ye(t,e)}function Pr(e,t,n,r=0,i={}){let a=he(e);if(!a.editablePrefill||!a.name)return null;let o=ve(i);return{path:t===null?a.name:ye(t,a.name),overrideKey:n===null?a.name:Me(n,o,r,a.name),resetOn:(a.prefillResetOn??[]).map(e=>Nr(e,t)),refreshOn:(a.prefillRefreshOn??[]).map(e=>Nr(e,t))}}function Fr(e,t){let n=[],r=(e,i=null,a=null,o=null,s=0,c={})=>{for(let l of e??[]){if(_t.has(l.type)){let e=he(l).name;if(e){let n=ye(i,e),o=ye(a,e),s=Se(t,n);(Array.isArray(s)?s:[]).forEach((e,t)=>{r(Mr(l,e),ye(n,t),ye(o,ve(e)??t),o,t,e)})}continue}let e=Pr(l,i,o,s,c);e&&n.push(e),r(l.schema,i,a,o,s,c)}};return r(e),n}function Ir(e,t){let n=new Map(e.targets.map(e=>[e.overrideKey,e]));return t.targets.filter(r=>{let i=n.get(r.overrideKey);return r.resetOn.some((n,r)=>{let a=i?.resetOn[r]??n;return!Object.is(Se(e.values,a),Se(t.values,n))})}).map(e=>e.overrideKey)}function Lr(e,t){return e.filter(e=>{let n=Se(t,e.path);return n!=null&&n!==``}).map(e=>e.overrideKey)}function Rr(e,t){let n=new Set(t.map(e=>e.overrideKey));return new Set([...e].filter(e=>n.has(e)))}function zr(e,t,n){let r=He(),i=je(),[a,o]=(0,U.useState)({}),s=(0,U.useMemo)(()=>Fr(n,r),[n,r]),c=(0,U.useRef)(new Set),l=(0,U.useRef)(new Set),u=(0,U.useRef)(r),d=(0,U.useRef)(s),f=(0,U.useRef)(s);f.current=s,kr(()=>{let e=new Set(s.map(e=>e.overrideKey));l.current=new Set([...l.current].filter(t=>e.has(t)));let t=s.filter(e=>!l.current.has(e.overrideKey));for(let e of Lr(t,r))c.current.add(e);for(let e of t)l.current.add(e.overrideKey)},[s,r]);let p=(0,U.useCallback)(e=>{c.current.add(e)},[]),m=(0,U.useMemo)(()=>{let e=new Set,t=!1;return Pe(n,n=>{if(Array.isArray(n.dependsOnKeys))for(let t of n.dependsOnKeys)e.add(String(t));n.dependsOnAny&&(t=!0)}),{keys:[...e],any:t}},[n]),h=(0,U.useMemo)(()=>{let e=new Set(m.keys);for(let t of s){for(let n of t.resetOn)e.add(n);for(let n of t.refreshOn)e.add(n)}return[...e]},[m.keys,s]),g=m.any?r:JSON.stringify(h.map(e=>Se(r,e)));return(0,U.useEffect)(()=>{if(h.length===0&&!m.any)return;let n=u.current;u.current=r;for(let e of Ir({targets:d.current,values:n},{targets:f.current,values:r}))c.current.delete(e);d.current=f.current,c.current=Rr(c.current,f.current);let a=new AbortController,s=window.setTimeout(()=>{Ar(e,t,{_sub:`resolve`,...r},a.signal).then(e=>{if(!e)return;for(let[t,n]of Object.entries(e.values??{}))i(t,n);let t=new Map(f.current.map(e=>[e.path,e]));for(let[n,r]of Object.entries(e.prefill??{})){let e=t.get(n);e&&!c.current.has(e.overrideKey)&&i(n,r)}e.fields&&o(e.fields)}).catch(()=>{})},250);return()=>{window.clearTimeout(s),a.abort()}},[g,e,t,m.any,i]),{nodes:a,markUserEdit:p}}function Br(e){let t={labels:{},values:{}};return Pe(e,e=>{e.name&&(e.label&&(t.labels[e.name]=e.label),e.value!==void 0&&(t.values[e.name]=e.value))}),t}function Vr(e,t){return e===t||e.startsWith(`${t}.`)}function Hr(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=Array.isArray(r)?r[0]:r;return t}function Ur(e,t){let n=(0,U.useRef)(e);n.current=e;let r=(0,U.useRef)(null),i=(0,U.useCallback)(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);return(0,U.useEffect)(()=>i,[i]),(0,U.useMemo)(()=>{let e=(...e)=>{i(),r.current=setTimeout(()=>{r.current=null,n.current(...e)},t)};return e.cancel=i,e},[i,t])}function Wr(e,t,n){let[r,i]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!n){i(null);return}let r=new AbortController;return J(e,{body:JSON.stringify({_sub:`schema`}),ref:t,method:`POST`,signal:r.signal,throwOnError:!1}).then(e=>e.ok?e.json():null).then(e=>i(e)).catch(()=>{}),()=>r.abort()},[n,e,t]),r}function Gr(){return(0,G.jsxs)(`div`,{className:`space-y-4`,"data-lattice-action-form-loading":!0,children:[(0,G.jsx)(vr,{className:`h-4 w-24`}),(0,G.jsx)(vr,{className:`h-10 w-full`}),(0,G.jsx)(vr,{className:`h-10 w-full`})]})}function Kr({cancelLabel:e,componentRef:t,endpoint:n,extraData:r,fieldLabels:i,formNode:a,method:o,onClose:s,onSuccess:c,precognitive:l,submitLabel:u}){let d=He(),f=(0,U.useRef)(d);f.current=d;let p=(0,U.useRef)(r);p.current=r;let{nodes:m,markUserEdit:h}=zr(n,t,a.schema),g=re(),[_,v]=(0,U.useState)({}),[y,b]=(0,U.useState)(!1),[S,C]=(0,U.useState)(!1),w=(0,U.useCallback)(e=>J(n,{body:JSON.stringify({...f.current,...p.current}),method:o,ref:t,headers:e,throwOnError:!1}),[t,n,o]),T=(0,U.useCallback)(e=>{v(t=>t[e]===void 0?t:{...t,[e]:void 0})},[]),E=Ur(e=>{w({Precognition:`true`,"Precognition-Validate-Only":e}).then(async t=>{if(t.status===422){let e=await t.json();v(t=>({...t,...Hr(e.errors)}));return}T(e)}).catch(()=>{})},250),D=(0,U.useCallback)(e=>{l&&E(e)},[l,E]),O=(0,U.useCallback)(()=>{},[]),k=(0,U.useCallback)((e,t)=>{C(!0),w({Precognition:`true`,"Precognition-Validate-Only":e.join(`,`)}).then(async n=>{if(n.status===422){let e=await n.json();v(t=>({...t,...Hr(e.errors)})),t?.onValidationError?.();return}if(!n.ok){t?.onValidationError?.();return}let r=e.filter(e=>!e.includes(`*`));v(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!r.some(t=>Vr(e,t))))),t?.onSuccess?.()}).catch(()=>t?.onValidationError?.()).finally(()=>C(!1))},[w]),A=(0,U.useCallback)(()=>{b(!0),w().then(async e=>{let t=await e.json().catch(()=>({}));if(g(R(t.effects)),e.status===422&&t.errors){v(Hr(t.errors));return}e.ok&&c(t)}).catch(e=>ne(e)).finally(()=>b(!1))},[g,c,w]),j=(0,U.useMemo)(()=>({action:n,clearErrors:T,componentRef:t,errors:_,fieldLabels:i,precognitive:l,processing:y,touch:O,validate:D,validateFields:k,validating:S}),[T,t,n,_,i,l,y,O,D,k,S]);return(0,G.jsx)(Ne,{value:j,children:(0,G.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,G.jsx)(xe,{value:{markUserEdit:h},children:(0,G.jsx)(Dr,{nodes:m,children:(0,G.jsx)(Y,{nodes:a.schema??[]})})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,G.jsx)(x,{"data-test":`action-form-cancel`,disabled:y,onClick:s,type:`button`,emphasis:`ghost`,children:e}),a.props?.submitButton!==!1&&(0,G.jsxs)(x,{"data-test":`action-form-submit`,disabled:y,type:`submit`,children:[y&&(0,G.jsx)(rn,{}),u]})]})]})})}function qr({formNode:e,...t}){let n=!!e.props?.precognitive,{labels:r,values:i}=(0,U.useMemo)(()=>{let{labels:t,values:n}=Br(e.schema);return{labels:t,values:{...n,...e.props?.state}}},[e]);return(0,G.jsx)(pt,{initial:i,children:(0,G.jsx)(Kr,{fieldLabels:r,formNode:e,precognitive:n,...t})})}function Jr({description:e,formNode:t,onClose:n,placement:r,title:i,width:a,...o}){let{t:s}=z(`lattice`);return(0,G.jsx)(Ln,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(Vn,{...e?{}:{"aria-describedby":void 0},placement:r,width:a,children:[(0,G.jsx)(Hn,{closeLabel:s(`common.close`,`Close`),description:e,title:i}),(0,G.jsx)(`div`,{className:`mt-6`,children:t?(0,G.jsx)(qr,{formNode:t,onClose:n,...o}):(0,G.jsx)(Gr,{})})]})})}function Yr(e){return e.props.label??B(`lattice`,`common.action.run`,`Run action`)}function Xr(e){let t=e.props.endpoint??``,n=e.props.ref??``,r=e.props.method??`post`,i=Yr(e),{variant:a,emphasis:o}=e.props,s=e.props.confirmation,c=e.props.form,l=e.props.lazyForm===!0,d=!!c||l,[f,p]=(0,U.useState)(!1),m=re(),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),y=Wr(t,n,_&&l),b=l?y:c,x=async()=>{if(!t)return;if(r===`get`){u.visit(t,{headers:Qn(n)}),g(!1);return}p(!0);let e=await _r(()=>J(t,{method:r,ref:n,throwOnError:!1}),m);p(!1),e&&g(!1)},S=()=>{if(d){v(!0);return}if(s){g(!0);return}x()},C=s?.title??i,w=s?.confirmLabel??i,T=s?.cancelLabel??B(`lattice`,`common.cancel`,`Cancel`);return{processing:f,requestSubmit:S,overlays:(0,G.jsxs)(G.Fragment,{children:[h&&s&&(0,G.jsx)(Un,{title:C,description:s.description??void 0,confirmLabel:w,cancelLabel:T,confirmVariant:a,confirmEmphasis:o,processing:f,confirmDisabled:!t,onConfirm:()=>void x(),onCancel:()=>g(!1)}),_&&d&&(0,G.jsx)(Jr,{cancelLabel:T,componentRef:n,description:s?.description??void 0,endpoint:t,formNode:b,method:r,onClose:()=>v(!1),onSuccess:()=>{v(!1)},placement:e.props.modalSide??`center`,submitLabel:w,title:C,width:e.props.modalWidth??void 0})]})}}var Zr={components:{action:W(({node:e})=>{let t=e.props.endpoint??``,n=e.props.icon,r=Yr(e),i=cn(),{variant:a,emphasis:o}=e.props,{processing:s,requestSubmit:c,overlays:l}=Xr(e),u=e.key??k(`action`,e.id);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(x,{className:i?on:void 0,"data-lattice-component":e.id,"data-test":u,disabled:s||!t,onClick:c,type:`button`,emphasis:i?`ghost`:o,variant:i?null:a,children:[s?(0,G.jsx)(rn,{className:i?`size-lt-icon-sm`:void 0}):n&&(0,G.jsx)(K,{className:i?`size-lt-icon-sm`:`size-lt-icon-md`,icon:n}),r]}),l]})}),"action.group":W(({children:e,node:t})=>{let{t:n}=z(`lattice`),r=t.props.label??n(`common.action-group.label`,`Actions`),i=t.props.orientation;return i?(0,G.jsx)(`div`,{"aria-label":r,className:p(`inline-flex max-w-full gap-1`,i===`vertical`?`flex-col items-stretch`:`flex-row flex-wrap items-center`),"data-lattice-component":t.id,role:`group`,children:e}):(0,G.jsx)(`div`,{className:`inline-flex`,"data-lattice-component":t.id,children:(0,G.jsxs)(ct,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsx)(x,{"aria-label":r,className:`size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg`,"data-test":D(t),size:`icon`,type:`button`,emphasis:`ghost`,children:(0,G.jsx)(_,{name:`more-horizontal`,"aria-hidden":`true`,className:`size-lt-icon-md`})})}),(0,G.jsx)(Ue,{align:`end`,"aria-label":r,className:`min-w-44 gap-0.5 p-1.5`,sideOffset:8,children:(0,G.jsx)(sn,{children:e})})]})})})},name:`lattice/action`};function Qr(e){try{return JSON.parse(e)}catch{return null}}function $r(e){return async function*(t){let n=await e(t);if(!n.ok||!n.body)throw Error(`Chat stream failed (${n.status})`);yield*ni(n.body)}}var ei=$r(({url:e,body:t,signal:n})=>J(e,{method:`POST`,signal:n,headers:{Accept:`application/x-ndjson`},body:JSON.stringify(t),throwOnError:!1}));function ti(e){return $r(({url:t,body:n,signal:r})=>hr(t,{remote:e,method:`POST`,signal:r,headers:{Accept:`application/x-ndjson`,"Content-Type":`application/json`},body:JSON.stringify(n),throwOnError:!1}))}async function*ni(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
3
|
+
`);r=a.pop()??``;for(let e of a){if(e.trim()===``)continue;let t=Qr(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=Qr(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var ri=0;function ii(){return ri+=1,`chat-${ri}`}function ai(e){return e instanceof DOMException&&e.name===`AbortError`}function oi(e){return e instanceof Error?e.message:String(e)}function si(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function ci(e,t){if(!si(e))return e;let n=e.length-1,r=e[n];if(t.type===`text`){let i=[...r.parts],a=i.length-1,o=i[a];o!==void 0&&o.type===`chat.part.text`?i[a]={type:`chat.part.text`,props:{text:`${o.props.text}${t.value}`}}:i.push({type:`chat.part.text`,props:{text:t.value}});let s=[...e];return s[n]={...r,parts:i},s}if(t.type===`part`){let i=[...e];return i[n]={...r,parts:[...r.parts,t.part]},i}return e}function li({endpoint:e,transport:t=ei,initialMessages:n=[],generateId:r=ii}){let[i,a]=(0,U.useState)(n),[o,s]=(0,U.useState)(`idle`),[c,l]=(0,U.useState)(null),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(i);f.current=i;let p=(0,U.useCallback)(e=>{f.current=e,a(e)},[]),m=(0,U.useCallback)(async(n,i)=>{u.current?.abort();let a=new AbortController;u.current=a,l(null),s(`submitted`);let o={id:r(),role:`user`,parts:[{type:`chat.part.text`,props:{text:i}}]},c={id:r(),role:`assistant`,parts:[]};p([...n,o,c]),s(`streaming`);try{for await(let n of t({url:e,body:{message:i},signal:a.signal})){if(n.type===`done`){s(`idle`);continue}if(n.type===`error`){l(n.message??`Chat failed`),s(`error`);continue}p(ci(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(ai(e)){s(`idle`);return}l(oi(e)),s(`error`)}},[p,e,r,t]),h=(0,U.useCallback)(e=>{let t=e.trim();t!==``&&(d.current=t,m(f.current,t))},[m]),g=(0,U.useCallback)(()=>{u.current?.abort(),s(`idle`)},[]),_=(0,U.useCallback)(()=>{let e=d.current;if(e===null)return;let t=f.current,n=si(t)?t.slice(0,-2):t;m(n,e)},[m]);return(0,U.useEffect)(()=>()=>{u.current?.abort()},[]),{messages:i,status:o,error:c,sendMessage:h,setMessages:p,stop:g,regenerate:_}}function ui({message:e}){let t=e.role===`user`;return(0,G.jsx)(`div`,{className:p(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":j(`chat-message-${e.role}`),children:(0,G.jsx)(`div`,{className:p(`max-w-[80%] rounded-lt px-3 py-2 text-sm`,t?`bg-lt-primary text-lt-primary-fg`:`bg-lt-muted text-lt-fg`),children:e.parts.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??t))})})}function di({messages:e}){let t=(0,U.useRef)(null),n=e.at(-1),r=n?.parts.at(-1)===void 0?0:JSON.stringify(n.parts.at(-1)).length;return(0,U.useEffect)(()=>{t.current&&typeof t.current.scrollIntoView==`function`&&t.current.scrollIntoView({behavior:`smooth`})},[e.length,r]),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 overflow-y-auto p-3`,"data-test":j(`chat-messages`),children:[e.map(e=>(0,G.jsx)(ui,{message:e},e.id)),(0,G.jsx)(`div`,{ref:t})]})}function fi({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=z(`lattice`),[i,a]=(0,U.useState)(``);function o(){let n=i.trim();n===``||t||(e(n),a(``))}function s(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),o())}return(0,G.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-lt-border p-3`,children:[(0,G.jsx)(`textarea`,{"aria-label":r(`common.chat.input-label`,`Message input`),className:p(`min-h-[2.5rem] flex-1 resize-none rounded-lt-sm border border-lt-input bg-lt-bg px-3 py-2 text-sm text-lt-fg placeholder:text-lt-muted-fg focus:outline-none focus:ring-[length:var(--lt-ring-width)] focus:ring-lt-ring/50 disabled:bg-lt-disabled disabled:text-lt-disabled-fg`),"data-slot":`prompt-input`,"data-test":j(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,G.jsx)(x,{"data-test":j(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var pi={name:`lattice/chat`,components:{"chat.box":W(({node:e})=>{let t=e.props,{t:n}=z(`lattice`),r=(0,U.useMemo)(()=>t.remote?ti(t.remote):ei,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=li({endpoint:t.streamEndpoint??``,transport:r}),l=(0,U.useRef)(!1),u=(0,U.useCallback)(async()=>{if(l.current||!t.historyEndpoint)return;if(l.current=!0,t.remote){let e=await gr(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await J(t.historyEndpoint,{throwOnError:!1});if(!e.ok)return;let n=await e.json();c(n.messages)},[t.historyEndpoint,t.remote,c]);(0,U.useEffect)(()=>{u().catch(()=>{})},[u]);let d=a===`submitted`||a===`streaming`||!t.streamEndpoint;return(0,G.jsxs)(`div`,{className:p(`flex flex-col overflow-hidden border border-lt-border bg-lt-bg`,t.fill?`sticky top-0 h-full min-h-[28rem] w-full`:`h-[28rem] w-80 rounded-lt shadow-lt-lg`),"data-test":j(`chat-box`),children:[(0,G.jsx)(`div`,{className:`flex items-center border-b border-lt-border px-3 py-2`,children:(0,G.jsx)(`span`,{className:`text-sm font-medium text-lt-fg`,children:t.title??n(`common.chat.title`,`Chat`)})}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,G.jsx)(di,{messages:i})}),o?(0,G.jsx)(`div`,{className:`border-t border-lt-danger/40 px-3 py-2 text-xs text-lt-danger`,children:o}):null,(0,G.jsx)(fi,{disabled:d,onSubmit:s,placeholder:t.placeholder??void 0})]})}),"chat.part.text":W(({node:e})=>(0,G.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.props.text})),"chat.part.tool-call":W(({node:e})=>(0,G.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-1 rounded-lt-sm bg-lt-muted px-2 py-0.5 font-mono text-xs text-lt-muted-fg`,"data-test":j(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}};function mi({addLabel:e,options:t,onSelect:n}){return(0,G.jsxs)(ct,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-test":`builder-add`,className:`inline-flex items-center gap-1.5 self-start rounded-lt-sm border border-lt-border px-3 py-1.5 text-sm hover:bg-lt-accent [&_svg]:size-lt-icon-sm`,children:[(0,G.jsx)(_,{name:`plus`}),e]})}),(0,G.jsx)(Ue,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,G.jsx)($e,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var hi={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function gi(e,t){return(e??_i(t.removable)).map(e=>vi(e,t)).filter(e=>e!==null)}function _i(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function vi(e,t){if(e.type===`duplicate`){let n=hi.duplicate;return{key:e.key,label:e.label??t.t(n.key,n.fallback),icon:e.icon??n.icon,danger:e.danger,onClick:()=>t.onDuplicate(t.index)}}if(e.type===`remove`){if(!t.removable)return null;let n=hi.remove;return{key:e.key,label:e.label??t.t(n.key,n.fallback),icon:e.icon??n.icon,danger:e.danger,onClick:()=>t.onRemove(t.index)}}return null}function yi(e){return e?`text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm`:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm`}function bi({actions:e}){let{t}=z(`lattice`);if(e.length===0)return null;if(e.length===1){let t=e[0];return(0,G.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-test":`row-action-${t.key}`,className:yi(t.danger),onClick:t.onClick,children:(0,G.jsx)(_,{name:t.icon})})}return(0,G.jsxs)(ct,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":t(`common.action-group.label`,`Actions`),"data-test":`row-actions-menu`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm`,children:(0,G.jsx)(_,{name:`more-horizontal`})})}),(0,G.jsx)(Ue,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,G.jsx)($e,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function xi({path:e,rows:t,rowKey:n}){return(0,G.jsx)(G.Fragment,{children:t.map((t,r)=>(0,G.jsx)(`input`,{type:`hidden`,name:Ae(ye(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function Si({label:e,testId:t,onClick:n,children:r}){return(0,G.jsx)(`button`,{type:`button`,"aria-label":e,"data-test":t,className:`text-lt-muted-fg hover:text-lt-fg`,onClick:n,children:r})}var Ci=(0,U.memo)(function({base:e,index:t,row:n,template:r,heading:i,reorderable:a,isFirst:o,isLast:s,removable:c,rowActions:l,onField:u,onRemove:d,onMove:f,onDuplicate:p}){let{t:m}=z(`lattice`);return(0,G.jsxs)(`div`,{"data-test":`repeater-${e}-row-${t}`,className:`rounded-lt border border-lt-border bg-lt-surface p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-lt-muted-fg`,children:i}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[a&&!o&&(0,G.jsx)(Si,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,G.jsx)(_,{name:`arrow-up`})}),a&&!s&&(0,G.jsx)(Si,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,G.jsx)(_,{name:`arrow-down`})}),(0,G.jsx)(bi,{actions:gi(l,{index:t,removable:c,onRemove:d,onDuplicate:p,t:m})})]})]}),(0,G.jsx)(ge,{base:e,index:t,row:n,onChange:(e,n)=>u(t,e,n),children:(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,G.jsx)(X,{node:e},br(e,t)))})})]})}),wi={xs:{track:`minmax(4rem, 0.35fr)`,minPx:64,defaultPx:96},sm:{track:`minmax(6rem, 0.5fr)`,minPx:96,defaultPx:128},md:{track:`minmax(8rem, 1fr)`,minPx:128,defaultPx:176},lg:{track:`minmax(12rem, 1.5fr)`,minPx:192,defaultPx:240},xl:{track:`minmax(16rem, 2fr)`,minPx:256,defaultPx:320}},Ti=1024;function Ei(e){return wi[e].track}function Di(e){return wi[e.width].minPx}function Oi(e){return wi[e.width].defaultPx}function ki({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?Ei(e.width):`${Math.min(Ti,Math.max(Di(e),t))}px`}),...n].join(` `)}function Ai(e,t,n={}){let{enabled:r=!0,parse:i,serialize:a}=n,o=()=>typeof t==`function`?t():t,[s,c]=(0,U.useState)(()=>{if(!r||typeof window>`u`)return o();let t;try{t=window.localStorage.getItem(e)}catch{return o()}if(t===null)return o();try{return i?i(t):JSON.parse(t)}catch{try{window.localStorage.removeItem(e)}catch{return o()}return o()}}),l=(0,U.useRef)(s);l.current=s;let u=(0,U.useRef)({enabled:r,key:e,serialize:a});return u.current={enabled:r,key:e,serialize:a},[s,(0,U.useCallback)(e=>{let t=typeof e==`function`?e(l.current):e;l.current=t,c(t);let{enabled:n,key:r,serialize:i}=u.current;if(!(!n||typeof window>`u`))try{let e=i?i(t):JSON.stringify(t);e===null?window.localStorage.removeItem(r):window.localStorage.setItem(r,e)}catch{return}},[])]}var ji=[];function Mi({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=ji,showIndicator:i=!1,storageKey:a,trailingTracks:o=ji}){let s=(0,U.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=Ai(a??``,{},{enabled:!!a,parse:e=>Pi(e,t),serialize:e=>Fi(e,s)}),u=(0,U.useRef)(c),d=(0,U.useRef)(null),f=(0,U.useRef)(null),p=(0,U.useCallback)(e=>ki({columns:t,leadingTracks:r,trailingTracks:o,overrides:n?e:{}}),[t,n,r,o]),m=(0,U.useMemo)(()=>p(c),[c,p]),h=(0,U.useCallback)(e=>{let t=f.current;t&&(t.style.gridTemplateColumns=e,t.style.setProperty(`--lattice-table-columns`,e))},[]),g=(0,U.useCallback)(e=>{u.current=e,l(e),h(p(e))},[h,l,p]),_=(0,U.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??1024,Math.max(Di(t),n))}),[]),v=(0,U.useCallback)((e,t,n)=>{g(_(u.current,e,t,n))},[g,_]),y=(0,U.useCallback)(e=>{let t={...u.current};delete t[e.key],g(t)},[g]),b=(0,U.useCallback)(()=>{g({})},[g]),x=n&&Object.values(c).some(e=>typeof e==`number`),S=(0,U.useCallback)(e=>u.current[e.key]??Oi(e),[]);return{getResizeHandleProps:(0,U.useCallback)(a=>{let s=Ti,c=Di(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>Ni({column:a,columnGapPx:e,columns:t,grid:f.current??n.parentElement?.parentElement,leadingTracks:r,trailingTracks:o}),C=(e,t)=>v(a,l+t,x(e)),w=(e,t)=>{let n=d.current;n?.key===a.key&&(d.current=null,n.overrides!==null&&g(n.overrides),t&&e.currentTarget.releasePointerCapture?.(e.pointerId))};return{"aria-label":`Resize ${m}`,"aria-orientation":`vertical`,"aria-valuemax":s,"aria-valuemin":c,"aria-valuenow":l,className:`absolute inset-y-0 right-0 hidden w-2 cursor-col-resize touch-none items-stretch justify-center md:flex after:my-1 after:w-px ${b} hover:after:bg-lt-border focus-visible:outline-none focus-visible:after:bg-lt-ring`,onDoubleClick:()=>y(a),onKeyDown:e=>{if(!n)return;let t=e.shiftKey?32:8;if(e.key===`ArrowLeft`&&(e.preventDefault(),C(e.currentTarget,-t)),e.key===`ArrowRight`&&(e.preventDefault(),C(e.currentTarget,t)),e.key===`Home`&&(e.preventDefault(),v(a,c)),e.key===`End`){e.preventDefault();let t=x(e.currentTarget);v(a,t,t)}(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),y(a))},onPointerDown:e=>{if(!n)return;let t=e.currentTarget.parentElement?.getBoundingClientRect().width??0;d.current={key:a.key,maxWidth:x(e.currentTarget),overrides:null,startWidth:t>0?t:l,startX:e.clientX},e.currentTarget.setPointerCapture?.(e.pointerId),e.preventDefault()},onPointerMove:e=>{let t=d.current;if(!n||t?.key!==a.key)return;let r=_(u.current,a,t.startWidth+e.clientX-t.startX,t.maxWidth);t.overrides=r,u.current=r,h(p(r))},onPointerUp:e=>{w(e,!0)},onPointerCancel:e=>{w(e,!0)},onLostPointerCapture:e=>{w(e,!1)},role:`separator`,tabIndex:0}},[e,t,S,n,r,h,g,_,y,v,i,p,o]),gridTemplateColumns:m,hasOverrides:x,resizeRootRef:f,resetColumns:b,resetColumnWidth:y}}function Ni({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return Ti;let s=[...i,...a].reduce((e,t)=>e+Li(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+Di(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(Ti,Math.max(Di(e),d))}function Pi(e,t){let n=JSON.parse(e)?.overrides;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`unexpected stored column widths shape`);let r=Ii(n,t);if(Object.keys(r).length===0)throw Error(`stored column widths hold no usable overrides`);return r}function Fi(e,t){let n={},r=new Set(t);for(let[t,i]of Object.entries(e))r.has(t)&&typeof i==`number`&&Number.isFinite(i)&&(n[t]=i);return Object.keys(n).length===0?null:JSON.stringify({overrides:n})}function Ii(e,t){let n={};for(let r of t){let t=e[r.key];typeof t!=`number`||!Number.isFinite(t)||(n[r.key]=Math.min(Ti,Math.max(Di(r),t)))}return n}function Li(e){let t=e.trim(),n=t.match(/^([0-9.]+)px$/);if(n)return Number.parseFloat(n[1]);let r=t.match(/^([0-9.]+)rem$/);return r?Number.parseFloat(r[1])*Ri():0}function Ri(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}function zi(e,t){return typeof window>`u`||typeof window.matchMedia!=`function`?t:window.matchMedia(e).matches}function Bi(e,t=!1){let[n,r]=(0,U.useState)(()=>zi(e,t));return(0,U.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}var Vi=`3rem`,Hi=`3rem`,Ui=[Vi],Wi=[Hi],Gi=`(min-width: 768px)`;function Ki(){return Bi(Gi,!0)}function qi(e){return e.map(e=>{let t=e.props;return{name:String(t.name),label:String(t.label??t.name),columnWidth:t.columnWidth??`md`}})}var Ji=(0,U.memo)(function({base:e,index:t,row:n,template:r,span:i,isFirst:a,isLast:o,columnCount:s,flipKey:c,reorderable:l,removable:u,rowActions:d,onField:f,onMove:p,onRemove:m,onDuplicate:h,registerRow:g}){let{t:v}=z(`lattice`);return(0,G.jsxs)(`div`,{ref:e=>g?.(c,e),"data-flip-key":c,"data-test":`table-row-${e}-${t}`,className:`grid grid-cols-[var(--lattice-table-columns)] items-start gap-x-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[l&&!a&&(0,G.jsx)(Si,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,G.jsx)(_,{name:`arrow-up`})}),l&&!o&&(0,G.jsx)(Si,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,G.jsx)(_,{name:`arrow-down`})})]}),(0,G.jsx)(ge,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,G.jsx)(Je,{children:i?(0,G.jsx)(`div`,{"data-test":`table-row-${e}-${t}-span`,className:`flex flex-col gap-2`,style:{gridColumn:`span ${s}`},children:r.map((e,t)=>(0,G.jsx)(X,{node:e},br(e,t)))}):r.map((e,t)=>(0,G.jsx)(`div`,{children:(0,G.jsx)(X,{node:e})},br(e,t)))})}),(0,G.jsx)(`div`,{className:`flex items-center`,children:(0,G.jsx)(bi,{actions:gi(d,{index:t,removable:u,onRemove:m,onDuplicate:h,t:v})})})]})});function Yi({base:e,columns:t,rows:n,reorderable:r,removable:i,rowActions:a,onField:o,onMove:s,onRemove:c,onDuplicate:l,registerRow:u,resizableColumns:d=!1,resizeIndicator:f=!1}){let{t:p}=z(`lattice`),m=Ki(),h=(0,U.useMemo)(()=>t.map(e=>({key:e.name,label:e.label,width:e.columnWidth})),[t]),{getResizeHandleProps:g,gridTemplateColumns:v,hasOverrides:y,resizeRootRef:b,resetColumns:x}=Mi({columns:h,enabled:d,columnGapPx:12,leadingTracks:Ui,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Wi});return m?(0,G.jsxs)(`div`,{className:`relative`,children:[y&&(0,G.jsx)(`button`,{"aria-label":p(`table.reset-column-widths`,`Reset column widths`),className:`absolute right-1 top-1 z-10 hidden rounded-lt-sm p-1 text-lt-muted-fg hover:text-lt-fg md:inline-flex`,"data-test":`table-reset-columns`,onClick:x,title:p(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,G.jsx)(_,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`div`,{ref:b,className:`flex min-w-max flex-col gap-2`,style:{"--lattice-table-columns":v},children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-[var(--lattice-table-columns)] items-center gap-x-3`,children:[(0,G.jsx)(`div`,{}),t.map((e,t)=>(0,G.jsxs)(`div`,{className:`relative min-w-0 pr-3 text-xs font-medium text-lt-muted-fg`,children:[e.label,d&&(0,G.jsx)(`div`,{...g(h[t])})]},e.name)),(0,G.jsx)(`div`,{})]}),n.map(d=>(0,G.jsx)(Ji,{base:e,index:d.index,row:d.row,template:d.template,span:d.span,isFirst:d.index===0,isLast:d.index===n.length-1,columnCount:t.length,flipKey:d.key,reorderable:r,removable:i(d.index),rowActions:a,onField:o,onMove:s,onRemove:c,onDuplicate:l,registerRow:u},d.key))]})})]}):(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,G.jsx)(`div`,{ref:e=>u?.(t.key,e),"data-flip-key":t.key,children:(0,G.jsx)(Ci,{base:e,index:t.index,row:t.row,template:t.template,heading:t.heading??`#${t.index+1}`,reorderable:r,isFirst:t.index===0,isLast:t.index===n.length-1,removable:i(t.index),rowActions:a,onField:o,onRemove:c,onMove:s,onDuplicate:l})},t.key))})}var Xi=180;function Zi(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Qi(e){let t=(0,U.useRef)(new Map),n=(0,U.useRef)(new Map),r=(0,U.useCallback)((e,n)=>{n?t.current.set(e,n):t.current.delete(e)},[]);return kr(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),Zi()||t.current.forEach((t,i)=>{let a=n.current.get(i),o=r.get(i);if(a&&o){let n=a.top-o.top;n&&(t.style.transform=`translateY(${n}px)`,e.push(requestAnimationFrame(()=>{t.style.transition=`transform ${Xi}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function $i(e,t){let n=mt(),r=n?n.errorKey(e):e,i=je(),a=gt(r),o=Array.isArray(a)?a:De(a,t),s=me(o);kr(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,U.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:De(n,t)))},[i,r,t]);return{path:r,rows:s,onField:(0,U.useCallback)((e,t,n)=>c(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),[c]),onRemove:(0,U.useCallback)(e=>c(t=>Ee(t,e)),[c]),onMove:(0,U.useCallback)((e,t)=>c(n=>Ze(n,e,e+t)),[c]),onDuplicate:(0,U.useCallback)(e=>c(t=>Qe(t,e)),[c]),append:(0,U.useCallback)(e=>c(t=>[...t,Oe(e)]),[c])}}var ea=[],ta=({node:e})=>{let t=e.props,n=t.name,r=t.templates,{errors:i}=Fe(),{hidden:a,required:o}=ut(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=$i(n,t.defaultItems??0),{t:m}=z(`lattice`),h=Qi(c.map(e=>String(e.rowId??``)).join(`,`)),g=t.maxItems!=null&&c.length>=t.maxItems,_=t.minItems!=null&&c.length<=t.minItems,v=t.layout===`table`,y=e=>r.find(t=>t.type===e),b=r.map(e=>({type:e.type,label:e.label}));if(a)return null;let x=r[0],S=c.map((e,t)=>{let n=y(e.type),r=!!n&&!!x&&n.type===x.type;return{key:String(e.rowId??t),index:t,row:e,template:n?.schema??ea,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,G.jsx)(ot,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,id:s,required:o,children:e=>(0,G.jsxs)(`div`,{...e,className:`flex flex-col gap-3`,role:`group`,children:[(0,G.jsx)(xi,{path:s,rows:c,rowKey:_e}),(0,G.jsx)(xi,{path:s,rows:c,rowKey:`type`}),v?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Yi,{base:s,columns:qi(x?.schema??[]),rows:S,reorderable:t.reorderable??!1,removable:()=>!_,rowActions:t.rowActions,onField:l,onMove:d,onRemove:u,onDuplicate:f,registerRow:h,resizableColumns:t.resizableColumns===!0,resizeIndicator:t.resizeIndicator===!0})}):c.map((e,r)=>{let i=y(e.type),a=String(e.rowId??r);return(0,G.jsx)(`div`,{ref:e=>h(a,e),"data-flip-key":a,children:i?(0,G.jsx)(Ci,{base:s,index:r,row:e,template:i.schema??ea,heading:i.label,reorderable:t.reorderable??!1,isFirst:r===0,isLast:r===c.length-1,removable:!_,rowActions:t.rowActions,onField:l,onRemove:u,onMove:d,onDuplicate:f}):(0,G.jsxs)(`div`,{"data-test":`repeater-${n}-row-${r}`,className:`flex items-center justify-between rounded-lt border border-dashed border-lt-border p-4 text-sm text-lt-muted-fg`,children:[(0,G.jsxs)(`span`,{children:[`Unknown block: `,String(e.type)]}),(0,G.jsx)(bi,{actions:gi(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,G.jsx)(mi,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},na=Object.defineProperty,ra=(e,t)=>na(e,`name`,{value:t,configurable:!0}),ia=`Checkbox`,[aa,oa]=lt(ia),[sa,ca]=aa(ia);function la(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Xe({prop:n,defaultProp:i??!1,onChange:c,caller:ia}),[m,h]=U.useState(null),[g,_]=U.useState(null),v=U.useRef(!1),[y,b]=U.useReducer(e=>e+1,0),x=!m||!!o||!!m.closest(`form`),S={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:!va(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,G.jsx)(sa,{scope:t,...S,children:_a(d)?d(S):r})}ra(la,`CheckboxProvider`);var ua=`CheckboxTrigger`,da=U.forwardRef(ra(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=ca(ua,e),g=v(i,u),_=U.useRef(c);return U.useEffect(()=>{let e=a?.form;if(e){let t=ra(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,G.jsx)(H.button,{type:`button`,role:`checkbox`,"aria-checked":va(c)?`mixed`:c,"aria-required":l,"data-state":ya(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:V(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:V(n,e=>{p(),d(e=>va(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),fa=U.forwardRef(ra(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,G.jsx)(la,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(da,{...d,ref:t,__scopeCheckbox:n}),e&&(0,G.jsx)(ga,{__scopeCheckbox:n})]})})},`Checkbox`)),pa=`CheckboxIndicator`,ma=U.forwardRef(ra(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=ca(pa,n);return(0,G.jsx)(Ce,{present:r||va(a.checked)||a.checked===!0,children:(0,G.jsx)(H.span,{"data-state":ya(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),ha=`CheckboxBubbleInput`,ga=U.forwardRef(ra(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=ca(ha,e),g=v(r,h),_=et(i),y=U.useRef(!1),b=U.useRef(s),x=U.useRef(o);U.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=va(s),n.call(e,!va(s)&&s),e.dispatchEvent(t),y.current=!1}},[m,s,a,o]);let S=U.useRef(!va(s)&&s);return(0,G.jsx)(H.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:V(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function _a(e){return typeof e==`function`}ra(_a,`isFunction`);function va(e){return e===`indeterminate`}ra(va,`isIndeterminate`);function ya(e){return va(e)?`indeterminate`:e?`checked`:`unchecked`}ra(ya,`getState`);function ba({className:e,...t}){return(0,G.jsx)(fa,{"data-slot":`checkbox`,className:p(`peer border-lt-input data-[state=checked]:bg-lt-primary data-[state=checked]:text-lt-primary-fg data-[state=checked]:border-lt-primary focus-visible:border-lt-ring focus-visible:ring-lt-ring/50 aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger size-4 shrink-0 rounded-lt-xs border shadow-lt-xs transition-shadow outline-none focus-visible:ring-[length:var(--lt-ring-width)] disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg disabled:data-[state=checked]:bg-lt-disabled disabled:data-[state=checked]:text-lt-disabled-fg disabled:data-[state=checked]:border-lt-disabled`,e),...t,children:(0,G.jsx)(ma,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,G.jsx)(_,{name:`check`,className:`size-lt-icon-sm`})})})}function xa(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function Sa(e,t){let n=mt(),r=gt(e),i=n?n.getValue(e):r,a=je();(0,U.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var Ca=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=ut(e),i=e.props.name,a=mt(),{fieldIdPrefix:o}=Fe(),s=xa(a?a.scopedName(i):i,o),c=gt(i),l=a?a.getValue(i):c,{commit:u}=ze(),d=tt(e.props.value),f=l===void 0?d:tt(l);return Sa(i,d),t?null:(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,G.jsx)(ba,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":j(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,G.jsx)(Ye,{htmlFor:s,children:e.props.label})]}),e.props.helperText&&(0,G.jsx)(`p`,{className:`mt-1 pl-7 text-sm text-lt-muted-fg`,children:e.props.helperText})]})};function wa(e){return p(`whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors`,e?`bg-lt-bg text-lt-fg shadow-lt-xs`:`text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg`)}function Ta({ariaLabel:e,autoFocus:t=!1,className:n,disabled:r=!1,name:i,onSelect:a,options:o,tabIndex:s,value:c,...l}){let u=(0,U.useRef)(null);return(0,U.useEffect)(()=>{if(!t)return;let e=u.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,G.jsx)(`div`,{...l,"aria-label":e,className:p(`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,n),ref:u,role:`radiogroup`,children:o.map(e=>{let t=c===e.value;return(0,G.jsx)(`button`,{"aria-checked":t,"data-test":`${i}-${e.value}`,className:p(wa(t),r&&`cursor-not-allowed opacity-60`),disabled:r,onClick:()=>a(e.value),role:`radio`,tabIndex:s,type:`button`,children:e.label},e.value)})})}function Ea(e){let{errors:t,fieldIdPrefix:n}=Fe(),r=mt(),i=ut(e),a=he(e),o=a.name??``,s=gt(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=xa(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=ze(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:j(o),value:u,error:t[f],commit:g,change:_,blur:v}}var Da=({node:e})=>{let t=Or(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=Ea(e),f=(0,U.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return Sa(n,m||void 0),s||f.length===0?null:(0,G.jsx)(ot,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,id:r,required:c,children:t=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,G.jsx)(Ta,{...t,ariaLabel:e.props.label??void 0,autoFocus:e.props.autoFocus??void 0,disabled:l||u,name:i??`segment`,onSelect:d,options:f,tabIndex:e.props.tabIndex??void 0,value:m})]})})};function Oa(){return(Oa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function ka(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}function Aa(e){var t=(0,U.useRef)(e),n=(0,U.useRef)(function(e){t.current&&t.current(e)});return t.current=e,n.current}var ja=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},Ma=function(e){return`touches`in e},Na=function(e){return e&&e.ownerDocument.defaultView||self},Pa=function(e,t,n){var r=e.getBoundingClientRect(),i=Ma(t)?function(e,t){for(var n=0;n<e.length;n++)if(e[n].identifier===t)return e[n];return e[0]}(t.touches,n):t;return{left:ja((i.pageX-(r.left+Na(e).pageXOffset))/r.width),top:ja((i.pageY-(r.top+Na(e).pageYOffset))/r.height)}},Fa=function(e){!Ma(e)&&e.preventDefault()},Ia=U.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=ka(e,[`onMove`,`onKey`,`onEnd`]),a=(0,U.useRef)(null),o=Aa(t),s=Aa(n),c=Aa(r),l=(0,U.useRef)(null),u=(0,U.useRef)(!1),d=(0,U.useMemo)(function(){var e=function(e){Fa(e),(Ma(e)?e.touches.length>0:e.buttons>0)&&a.current?o(Pa(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=Na(a.current),o=n?i.addEventListener:i.removeEventListener;o(r?`touchmove`:`mousemove`,e),o(r?`touchend`:`mouseup`,t)}return[function(e){var t=e.nativeEvent,r=a.current;if(r&&(Fa(t),!function(e,t){return t&&!Ma(e)}(t,u.current)&&r)){if(Ma(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(Pa(r,t,l.current)),n(!0)}},function(e){var t=e.which||e.keyCode;t<37||t>40||(e.preventDefault(),s({left:t===39?.05:t===37?-.05:0,top:t===40?.05:t===38?-.05:0}))},function(e){var t=e.which||e.keyCode;t>=37&&t<=40&&c()},n]},[s,o,c]),f=d[0],p=d[1],m=d[2],h=d[3];return(0,U.useEffect)(function(){return h},[h]),U.createElement(`div`,Oa({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),La=function(e){return e.filter(Boolean).join(` `)},Ra=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=La([`react-colorful__pointer`,e.className]);return U.createElement(`div`,{className:a,style:{top:100*i+`%`,left:100*n+`%`}},U.createElement(`div`,{className:`react-colorful__pointer-fill`,style:{backgroundColor:t}}))},Z=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n};360/(2*Math.PI);var za=function(e){return qa(Ba(e))},Ba=function(e){return e[0]===`#`&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Z(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?Z(parseInt(e.substring(6,8),16)/255,2):1}},Va=function(e){return Ka(Wa(e))},Ha=function(e){var t=e.s,n=e.v,r=e.a,i=(200-t)*n/100;return{h:Z(e.h),s:Z(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:Z(i/2),a:Z(r,2)}},Ua=function(e){var t=Ha(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Wa=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:Z(255*[r,s,o,o,c,r][l]),g:Z(255*[c,r,r,s,o,o][l]),b:Z(255*[o,o,c,r,r,s][l]),a:Z(i,2)}},Ga=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Ka=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?Ga(Z(255*i)):``;return`#`+Ga(t)+Ga(n)+Ga(r)+a},qa=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:Z(60*(s<0?s+6:s)),s:Z(a?o/a*100:0),v:Z(a/255*100),a:i}},Ja=U.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=La([`react-colorful__hue`,e.className]);return U.createElement(`div`,{className:i},U.createElement(Ia,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:ja(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":Z(t),"aria-valuemax":`360`,"aria-valuemin":`0`},U.createElement(Ra,{className:`react-colorful__hue-pointer`,left:t/360,color:Ua({h:t,s:100,v:100,a:1})})))}),Ya=U.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:Ua({h:t.h,s:100,v:100,a:1})};return U.createElement(`div`,{className:`react-colorful__saturation`,style:i},U.createElement(Ia,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:ja(t.s+100*e.left,0,100),v:ja(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+Z(t.s)+`%, Brightness `+Z(t.v)+`%`},U.createElement(Ra,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:Ua(t)})))}),Xa=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},Za=function(e,t){return e.toLowerCase()===t.toLowerCase()||Xa(Ba(e),Ba(t))};function Qa(e,t,n,r){var i=Aa(n),a=Aa(r),o=(0,U.useState)(function(){return e.toHsva(t)}),s=o[0],c=o[1],l=(0,U.useRef)({color:t,hsva:s}),u=(0,U.useRef)(!1);return(0,U.useEffect)(function(){if(!e.equal(t,l.current.color)){var n=e.toHsva(t);l.current={hsva:n,color:t},c(n),u.current=!1}},[t,e]),(0,U.useEffect)(function(){var t;Xa(s,l.current.hsva)||e.equal(t=e.fromHsva(s),l.current.color)||(l.current={hsva:s,color:t},i(t),u.current=!0)},[s,e,i]),[s,(0,U.useCallback)(function(e){c(function(t){return Object.assign({},t,e)})},[]),(0,U.useCallback)(function(){u.current&&(u.current=!1,a(l.current.color))},[a])]}var $a,eo=typeof window<`u`?U.useLayoutEffect:U.useEffect,to=function(){return $a||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},no=new WeakMap,ro=function(e){eo(function(){var t=e.current;if(typeof document<`u`&&t){var n=t.getRootNode?t.getRootNode():t.ownerDocument,r=n&&(`head`in n||`host`in n)?n:t.ownerDocument;if(!no.has(r)){var i=`head`in r?r.head:r,a=(i.ownerDocument||document).createElement(`style`);a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`;var o=to();o&&a.setAttribute(`nonce`,o),no.set(r,a),i.appendChild(a)}}},[])},io=function(e){var t=e.className,n=e.colorModel,r=e.color,i=r===void 0?n.defaultColor:r,a=e.onChange,o=e.onChangeEnd,s=ka(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,U.useRef)(null);ro(c);var l=Qa(n,i,a,o),u=l[0],d=l[1],f=l[2],p=La([`react-colorful`,t]);return U.createElement(`div`,Oa({},s,{ref:c,className:p}),U.createElement(Ya,{hsva:u,onChange:d,onChangeEnd:f}),U.createElement(Ja,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},ao={defaultColor:`000`,toHsva:za,fromHsva:function(e){return Va({h:e.h,s:e.s,v:e.v,a:1})},equal:Za},oo=function(e){return U.createElement(io,Oa({},e,{colorModel:ao}))};function so(e){let t=e.trim().replace(/^#/,``).toLowerCase();return/^[0-9a-f]{6}$/.test(t)?`#${t}`:/^[0-9a-f]{3}$/.test(t)?`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:null}function co({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,U.useState)(null),s=so(e)??`#6b7280`;return(0,G.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,G.jsx)(oo,{className:`!w-full`,color:s,onChange:t}),n.length>0&&(0,G.jsx)(`div`,{"aria-label":i,className:`flex flex-wrap gap-1.5`,role:`listbox`,children:n.map(e=>{let n=so(e)??e;return(0,G.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:p(`size-6 shrink-0 rounded-full border border-lt-border`,n===s&&`ring-2 ring-lt-ring ring-offset-1`),onClick:()=>t(n),role:`option`,style:{background:e},type:`button`},e)})}),(0,G.jsx)(bt,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=so(n);o(n),r!==null&&t(r)},value:a??s})]})}function lo({node:e,label:t,children:n}){let r=Ea(e);return r.hidden?null:(0,G.jsx)(ot,{error:r.error,helperText:he(e).helperText??void 0,tooltip:he(e).tooltip??void 0,label:t,id:r.name,required:r.required,children:e=>n(r,e)})}var uo=({node:e})=>{let t=e.props;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a},o)=>{let s=so(n);return(0,G.jsxs)(We,{children:[(0,G.jsx)(`input`,{name:e,type:`hidden`,value:s??``}),(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(`button`,{...o,className:p(yt(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,type:`button`,children:s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 shrink-0 rounded-full border border-lt-border`,style:{background:s}}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:s})]}):(0,G.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,G.jsx)(Ke,{className:`p-3`,children:(0,G.jsx)(co,{onChange:e=>a(e),palette:t.palette,value:s??`#6b7280`})})]})}})},fo=(0,U.lazy)(async()=>{let{DatePickerField:e}=await jt(async()=>{let{DatePickerField:e}=await import(`./date-picker-field-Ds1A1ipK.js`);return{DatePickerField:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url);return{default:e}});function po(e){return(0,G.jsx)(U.Suspense,{fallback:null,children:(0,G.jsx)(fo,{...e})})}var mo=({node:e})=>{let t=e.props;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s},c)=>(0,G.jsx)(po,{controlProps:c,autoFocus:t.autoFocus??!1,disabled:a,label:t.label??t.name,max:t.max||void 0,min:t.min||void 0,mode:`date`,name:e,onBlur:s,onChange:o,readOnly:i,tabIndex:t.tabIndex??void 0,testId:n??t.name,value:r})})},ho=({node:e})=>{let t=e.props,{timezone:n}=de();return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c},l)=>(0,G.jsx)(po,{controlProps:l,autoFocus:t.autoFocus??!1,disabled:o,label:t.label??t.name,max:t.max,min:t.min,mode:`date-time`,name:e,onBlur:c,onChange:s,readOnly:a,step:t.step,tabIndex:t.tabIndex??void 0,testId:r??t.name,timezone:n,value:i})})};function go({url:e,method:t,body:n,headers:r,onProgress:i}){return new Promise((a,o)=>{let s=new XMLHttpRequest;s.open(t,e,!0),Object.entries(r).forEach(([e,t])=>s.setRequestHeader(e,String(t))),s.upload.onprogress=e=>{e.lengthComputable&&i?.(Math.round(e.loaded/e.total*100))},s.onload=()=>{try{a(new Response(s.responseText||null,{status:s.status||500}))}catch{o(Error(`Upload to ${e} returned an unusable response`))}},s.onerror=()=>o(Error(`Upload to ${e} failed`)),s.send(n)})}function _o(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return J(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function vo(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var yo=({node:e})=>{let{t}=z(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=ut(e),{action:s,componentRef:c,errors:l}=Fe(),u=n.name,d=mt(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=He(),g=je(),_=(0,U.useId)(),v=(0,U.useRef)(null),y=(0,U.useRef)(new Set),b=a||o,x=n.signed,S=n.multiple,C=S?`${f}[]`:f,w=(0,U.useMemo)(()=>(n.files??[]).map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,status:`ready`,progress:100,key:e.key,url:e.url,token:e.token,existing:!0})),[n.files]),[T,E]=(0,U.useState)(w),[D,O]=(0,U.useState)([]);(0,U.useEffect)(()=>{if(!x)return;let e=T.filter(e=>!e.existing&&e.key&&e.status===`ready`).map(e=>e.key),t=S?e:e[0]??``;if(d){vo(d.getValue(u),t)||d.setValue(u,t);return}g(u,t)},[T,S,u,d,g,x]),(0,U.useEffect)(()=>{!x||d||g(`${u}__removed`,D)},[u,D,d,g,x]),(0,U.useEffect)(()=>()=>{y.current.forEach(e=>URL.revokeObjectURL(e)),y.current.clear()},[]);let k=(0,U.useMemo)(()=>T.filter(e=>e.file&&!e.existing).map(e=>e.file),[T]);(0,U.useEffect)(()=>{if(x||!v.current)return;let e=new DataTransfer;k.forEach(t=>e.items.add(t)),v.current.files=e.files},[k,x]);function A(e){if(!n.image)return;let t=URL.createObjectURL(e);return y.current.add(t),t}function M(e){!e.url||!y.current.has(e.url)||(URL.revokeObjectURL(e.url),y.current.delete(e.url))}async function N(e,t){let n=()=>{E(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))},r=await _o(s,{ref:c,target:m,filename:t.name,contentType:t.type,values:h});if(!r.ok){n();return}let i=await r.json();try{let n=await go({url:i.url,method:i.method.toUpperCase(),body:t,headers:i.headers,onProgress:t=>E(n=>n.map(n=>n.id===e.id?{...n,progress:t}:n))});E(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`ready`:`error`,key:i.key,progress:100}:t))}catch{n()}}function P(e){if(!e||b)return;let t=Array.from(e),n=t.map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,status:x?`uploading`:`ready`,progress:0,file:e,url:A(e),existing:!1}));if(!S&&(T.forEach(M),!d)){let e=T.filter(e=>e.existing&&e.token).map(e=>e.token);e.length>0&&O(t=>[...t,...e])}E(e=>S?[...e,...n]:n),x&&n.forEach((e,n)=>void N(e,t[n]))}function F(e){let t=T.find(t=>t.id===e);t&&M(t),t?.existing&&t.token&&!d&&O(e=>[...e,t.token]),E(t=>t.filter(t=>t.id!==e))}return r?null:(0,G.jsx)(ot,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,id:_,required:i,children:e=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lt-sm border border-dashed border-lt-border bg-lt-surface px-4 py-6`,"data-test":j(u),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),P(e.dataTransfer.files)},children:[(0,G.jsx)(`button`,{className:`text-sm text-lt-muted-fg`,disabled:b,onClick:()=>v.current?.click(),type:`button`,children:t(`form.file-upload.dropzone`,`Drop files here or click to browse`)}),(0,G.jsx)(`ul`,{className:n.image?`grid grid-cols-1 gap-3 sm:grid-cols-2`:`flex flex-col gap-2`,children:T.map(e=>(0,G.jsxs)(`li`,{className:n.image?`flex min-w-0 items-center gap-3 rounded-lt-sm border border-lt-border bg-lt-bg p-2 text-sm`:`flex items-center justify-between gap-3 text-sm`,children:[n.image&&e.url?(0,G.jsx)(`img`,{alt:e.name,className:`size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover`,"data-test":j(`${u}-preview`),src:e.url}):null,(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate`,"data-test":j(`${u}-item`),children:e.name}),e.status===`uploading`&&(0,G.jsxs)(`span`,{className:`text-xs text-lt-muted-fg`,children:[e.progress,`%`]}),e.status===`error`&&(0,G.jsx)(`span`,{className:`text-xs text-lt-danger`,children:t(`form.file-upload.failed`,`Failed`)})]}),(!e.existing||!d)&&(0,G.jsx)(xt,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":j(e.existing?`${u}-remove-existing`:`${u}-remove`),disabled:b,onClick:()=>F(e.id)}),x&&!e.existing&&e.key&&e.status===`ready`&&(0,G.jsx)(`input`,{"data-test":j(`${u}-uploaded`),name:C,type:`hidden`,value:e.key})]},e.id))}),!d&&D.map(e=>(0,G.jsx)(`input`,{name:`${u}__removed[]`,type:`hidden`,value:e},e)),(0,G.jsx)(`input`,{...e,accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":j(`${u}-input`),multiple:S,name:x?void 0:C,onChange:e=>{P(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function bo({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=Fe(),c=Object.entries(a).filter(([,e])=>!!e).map(([e,t])=>({label:o[e]??e,message:t})),l=c.length>0;return(0,G.jsxs)(`span`,{className:`group relative inline-flex flex-col`,children:[(0,G.jsxs)(x,{"data-lattice-form":i,"data-test":`form-submit`,disabled:s||l,emphasis:r,type:`submit`,variant:n,children:[s&&(0,G.jsx)(rn,{}),e]}),l&&(0,G.jsxs)(`div`,{className:`pointer-events-none absolute bottom-full left-1/2 z-lt-popover mb-2 w-max max-w-xs -translate-x-1/2 rounded-lt border border-lt-border bg-lt-surface p-3 text-left text-sm opacity-0 shadow-lt-md transition-opacity group-hover:opacity-100`,role:`tooltip`,children:[(0,G.jsx)(`p`,{className:`mb-1 font-medium text-lt-fg`,children:t}),(0,G.jsx)(`ul`,{className:`space-y-1`,children:c.map(e=>(0,G.jsxs)(`li`,{className:`text-lt-muted-fg`,children:[(0,G.jsx)(`span`,{className:`font-medium text-lt-fg`,children:e.label}),` — `,e.message]},e.label))})]})]})}var xo={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function So({componentId:e,reset:t}){let n=ht();return Qt(F.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function Co({action:e,children:t,componentRef:n,nodes:r,shouldRenderSubmitButton:i,submitButtons:a,submitEmphasis:o,submitJustify:s,submitLabel:c,submitVariant:l,summaryLabel:u}){let{nodes:d,markUserEdit:f}=zr(e,n,r),p=(0,U.useMemo)(()=>({markUserEdit:f}),[f]);return(0,G.jsx)(xe,{value:p,children:(0,G.jsx)(Dr,{nodes:d,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,G.jsx)(`div`,{className:`flex gap-3 ${xo[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,G.jsx)(bo,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},br(e,t)):(0,G.jsx)(X,{node:e},br(e,t))):(0,G.jsx)(bo,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function wo(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var To=({children:e,node:t})=>{let n=(0,U.useMemo)(()=>({...Br(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,G.jsx)(pt,{initial:n,children:(0,G.jsx)(Eo,{node:t,children:e})})};function Eo({children:e,node:t}){let{t:n}=z(`lattice`),r=t.props,i=r.action??`#`,a=r.errorBag,o=r.ref??``,s=r.method??`post`,c=r.precognitive,l=r.fullWidth,u=r.resetOnError??!1,f=r.resetOnSuccess??[],m=(0,U.useMemo)(()=>Br(t.schema).labels,[t.schema]),h=r.submitButton,g=r.submitButtons??void 0,_=r.submitJustify??void 0,v=r.submitLabel??n(`form.submit`,`Submit`),y=r.submitVariant??void 0,b=r.submitEmphasis??void 0,x=r.validationSummaryLabel,S=r.validationTimeout??void 0,C=ht(),w=e=>{let t=wo(e);t!==!1&&C(t)},T=(0,U.useRef)(null),E=(0,U.useRef)(`idle`),[D,O]=(0,U.useState)(0);return(0,U.useEffect)(()=>{D>0&&E.current===`renewing`&&T.current?.submit()},[D]),(0,G.jsx)(d,{ref:T,action:i,"data-slot":`form`,"data-lattice-component":t.id,errorBag:a,method:s,resetOnError:u,resetOnSuccess:f,validationTimeout:c?S:void 0,headers:Qn(o),className:p(`flex w-full flex-col gap-6`,!l&&`mx-auto max-w-2xl`),onStart:()=>{E.current=E.current===`renewing`?`retried`:`idle`},onSuccess:()=>w(f),onError:()=>w(u),onHttpException:e=>{if(e.status===403&&o!==``&&E.current!==`retried`)return E.current=`renewing`,cr(o).finally(()=>O(e=>e+1)),!1},children:({clearErrors:n,errors:a,processing:s,reset:l,touch:u,validate:d,validating:f})=>(0,G.jsxs)(Ne,{value:{action:i,clearErrors:e=>n(e),componentId:t.id,componentRef:o,errors:a,fieldLabels:m,precognitive:c,processing:s,touch:e=>u(...e),validate:e=>d(e),validateFields:(e,t)=>d({only:e,...t}),validating:f},children:[(0,G.jsx)(So,{componentId:t.id,reset:l}),r.status&&(0,G.jsx)(`div`,{className:`text-center text-sm font-medium text-lt-success`,children:r.status}),(0,G.jsx)(Co,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:h,submitButtons:g,submitEmphasis:b,submitJustify:_,submitLabel:v,submitVariant:y,summaryLabel:x,children:e})]})})}var Do=({node:e})=>{let t=mt(),n=e.props.name,r=t?t.getValue(n):e.props.value;return(0,G.jsx)(`input`,{defaultValue:typeof r==`string`?r:``,name:t?t.scopedName(n):n,type:`hidden`})};function Oo({affix:e,side:t,squared:n=!1}){return(0,G.jsx)(`span`,{"data-slot":`affix-${t}`,className:p(`inline-flex h-lt-control-md shrink-0 items-center border border-lt-input bg-lt-muted px-3 text-base whitespace-nowrap text-lt-muted-fg`,`group-has-[:focus-visible]:border-lt-ring`,t===`start`?`rounded-l-lt-sm border-r-0`:`rounded-r-lt-sm border-l-0`,n&&`rounded-r-none border-r-0`),children:e.icon?(0,G.jsx)(K,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function ko({prefix:e,suffix:t,end:n,children:r}){return!e&&!t&&!n?r(``):(0,G.jsxs)(`div`,{className:`group flex w-full rounded-lt-sm transition-[color,box-shadow] has-[:focus-visible]:ring-[length:var(--lt-ring-width)] has-[:focus-visible]:ring-lt-ring/50`,"data-slot":`affix-group`,children:[e?(0,G.jsx)(Oo,{affix:e,side:`start`}):null,(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(p(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,G.jsx)(Oo,{affix:t,side:`end`,squared:!!n}):null,n]})}var Ao=({node:e})=>{let t=e.props;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o},s)=>{let c=e=>o(e.target.value);return t.slider?(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`input`,{...s,"aria-label":t.label??``,className:`h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:accent-lt-disabled`,"data-test":n,disabled:a||i,max:t.max??void 0,min:t.min??void 0,name:e,onChange:c,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`range`,value:r}),(0,G.jsx)(`output`,{className:`w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg`,children:r})]}):(0,G.jsx)(ko,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,G.jsx)(bt,{...s,autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,max:t.max??void 0,min:t.min??void 0,name:e,onChange:c,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},jo=Object.defineProperty,Mo=Object.defineProperties,No=Object.getOwnPropertyDescriptors,Po=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,Io=Object.prototype.propertyIsEnumerable,Lo=(e,t,n)=>t in e?jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ro=(e,t)=>{for(var n in t||={})Fo.call(t,n)&&Lo(e,n,t[n]);if(Po)for(var n of Po(t))Io.call(t,n)&&Lo(e,n,t[n]);return e},zo=(e,t)=>Mo(e,No(t)),Bo=(e,t)=>{var n={};for(var r in e)Fo.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Po)for(var r of Po(e))t.indexOf(r)<0&&Io.call(e,r)&&(n[r]=e[r]);return n};function Vo(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function Ho(e){let t=U.useRef();return U.useEffect(()=>{t.current=e}),t.current}var Uo=18,Wo=40,Go=`${Wo}px`,Ko=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function qo({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=U.useState(!1),[o,s]=U.useState(!1),[c,l]=U.useState(!1),u=U.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=U.useCallback(()=>{let r=e.current,i=t.current;if(!r||!i||c||n===`none`)return;let o=r,s=o.getBoundingClientRect().left+o.offsetWidth,u=o.getBoundingClientRect().top+o.offsetHeight/2,d=s-Uo,f=u;document.querySelectorAll(Ko).length===0&&document.elementFromPoint(d,f)===r||(a(!0),l(!0))},[e,t,c,n]);return U.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){let e=window.innerWidth-t.getBoundingClientRect().right;s(e>=Wo)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),U.useEffect(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(d,0),a=setTimeout(d,2e3),o=setTimeout(d,5e3),s=setTimeout(()=>{l(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n,d]),{hasPWMBadge:i,willPushPWMBadge:u,PWM_BADGE_SPACE_WIDTH:Go}}var Jo=U.createContext({}),Yo=U.forwardRef((e,t)=>{var n=e,{value:r,onChange:i,maxLength:a,textAlign:o=`left`,pattern:s,placeholder:c,inputMode:l=`numeric`,onComplete:u,pushPasswordManagerStrategy:d=`increase-width`,pasteTransformer:f,containerClassName:p,noScriptCSSFallback:m=Zo,render:h,children:g}=n,_=Bo(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`render`,`children`]),v;let[y,b]=U.useState(typeof _.defaultValue==`string`?_.defaultValue:``),x=r??y,S=Ho(x),C=U.useCallback(e=>{i?.(e),b(e)},[i]),w=U.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),T=U.useRef(null),E=U.useRef(null),D=U.useRef({value:x,onChange:C,isIOS:typeof window<`u`&&((v=window==null?void 0:window.CSS)?.supports)?.call(v,`-webkit-touch-callout`,`none`)}),O=U.useRef({prev:[T.current?.selectionStart,T.current?.selectionEnd,T.current?.selectionDirection]});U.useImperativeHandle(t,()=>T.current,[]),U.useEffect(()=>{let e=T.current,t=E.current;if(!e||!t)return;D.current.value!==e.value&&D.current.onChange(e.value),O.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection];function n(){if(document.activeElement!==e){P(null),I(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=O.current.prev,s=-1,c=-1,l;if(a.length!==0&&t!==null&&n!==null){let e=t===n,r=t===a.length&&a.length<i;if(e&&!r){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&T.current.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l??r;P(u),I(d),O.current.prev=[u,d,f]}if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&M(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;Xo(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Xo(e.sheet,`[data-input-otp]:autofill { ${t} }`),Xo(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Xo(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),Xo(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=new ResizeObserver(r);return i.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i.disconnect()}},[]);let[k,A]=U.useState(!1),[j,M]=U.useState(!1),[N,P]=U.useState(null),[F,I]=U.useState(null);U.useEffect(()=>{Vo(()=>{var e;(e=T.current)==null||e.dispatchEvent(new Event(`input`));let t=T.current?.selectionStart,n=T.current?.selectionEnd,r=T.current?.selectionDirection;t!==null&&n!==null&&(P(t),I(n),O.current.prev=[t,n,r])})},[x,j]),U.useEffect(()=>{S!==void 0&&x!==S&&S.length<a&&x.length===a&&u?.(x)},[a,u,S,x]);let L=qo({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),ee=U.useCallback(e=>{let t=e.currentTarget.value.slice(0,a);if(t.length>0&&w&&!w.test(t)){e.preventDefault();return}typeof S==`string`&&t.length<S.length&&document.dispatchEvent(new Event(`selectionchange`)),C(t)},[a,C,S,w]),te=U.useCallback(()=>{var e;if(T.current){let t=Math.min(T.current.value.length,a-1),n=T.current.value.length;(e=T.current)==null||e.setSelectionRange(t,n),P(t),I(n)}M(!0)},[a]),ne=U.useCallback(e=>{let t=T.current;if(!f&&(!D.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),r=f?f(n):n;e.preventDefault();let i=T.current?.selectionStart,o=T.current?.selectionEnd,s=(i===o?x.slice(0,i)+r+x.slice(i):x.slice(0,i)+r+x.slice(o)).slice(0,a);if(s.length>0&&w&&!w.test(s))return;t.value=s,C(s);let c=Math.min(s.length,a-1),l=s.length;t.setSelectionRange(c,l),P(c),I(l)},[a,C,w,x]),re=U.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),ie=U.useMemo(()=>({position:`absolute`,inset:0,width:L.willPushPWMBadge?`calc(100% + ${L.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:L.willPushPWMBadge?`inset(0 ${L.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:`100%`,display:`flex`,textAlign:o,opacity:`1`,color:`transparent`,pointerEvents:`all`,background:`transparent`,caretColor:`transparent`,border:`0 solid transparent`,outline:`0 solid transparent`,boxShadow:`none`,lineHeight:`1`,letterSpacing:`-.5em`,fontSize:`var(--root-height)`,fontFamily:`monospace`,fontVariantNumeric:`tabular-nums`}),[L.PWM_BADGE_SPACE_WIDTH,L.willPushPWMBadge,o]),R=U.useMemo(()=>U.createElement(`input`,zo(Ro({autoComplete:_.autoComplete||`one-time-code`},_),{"data-input-otp":!0,"data-input-otp-placeholder-shown":x.length===0||void 0,"data-input-otp-mss":N,"data-input-otp-mse":F,inputMode:l,pattern:w?.source,"aria-placeholder":c,style:ie,maxLength:a,value:x,ref:T,onPaste:e=>{var t;ne(e),(t=_.onPaste)==null||t.call(_,e)},onChange:ee,onMouseOver:e=>{var t;A(!0),(t=_.onMouseOver)==null||t.call(_,e)},onMouseLeave:e=>{var t;A(!1),(t=_.onMouseLeave)==null||t.call(_,e)},onFocus:e=>{var t;te(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[ee,te,ne,l,ie,a,F,N,_,w?.source,x]),ae=U.useMemo(()=>({slots:Array.from({length:a}).map((e,t)=>{let n=j&&N!==null&&F!==null&&(N===F&&t===N||t>=N&&t<F),r=x[t]===void 0?null:x[t];return{char:r,placeholderChar:x[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:j,isHovering:!_.disabled&&k}),[j,k,a,F,N,_.disabled,x]),z=U.useMemo(()=>h?h(ae):U.createElement(Jo.Provider,{value:ae},g),[g,ae,h]);return U.createElement(U.Fragment,null,m!==null&&U.createElement(`noscript`,null,U.createElement(`style`,null,m)),U.createElement(`div`,{ref:E,"data-input-otp-container":!0,style:re,className:p},z,U.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},R)))});Yo.displayName=`Input`;function Xo(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var Zo=`
|
|
4
|
+
[data-input-otp] {
|
|
5
|
+
--nojs-bg: white !important;
|
|
6
|
+
--nojs-fg: black !important;
|
|
7
|
+
|
|
8
|
+
background-color: var(--nojs-bg) !important;
|
|
9
|
+
color: var(--nojs-fg) !important;
|
|
10
|
+
caret-color: var(--nojs-fg) !important;
|
|
11
|
+
letter-spacing: .25em !important;
|
|
12
|
+
text-align: center !important;
|
|
13
|
+
border: 1px solid var(--nojs-fg) !important;
|
|
14
|
+
border-radius: 4px !important;
|
|
15
|
+
width: 100% !important;
|
|
16
|
+
}
|
|
17
|
+
@media (prefers-color-scheme: dark) {
|
|
18
|
+
[data-input-otp] {
|
|
19
|
+
--nojs-bg: black !important;
|
|
20
|
+
--nojs-fg: white !important;
|
|
21
|
+
}
|
|
22
|
+
}`,Qo=`^\\d+$`;function $o({char:e,hasFakeCaret:t,isActive:n}){return(0,G.jsxs)(`div`,{className:p(`relative flex h-lt-control-md w-10 items-center justify-center border-y border-r border-lt-input text-base shadow-lt-xs transition-all first:rounded-l-lt-sm first:border-l last:rounded-r-lt-sm`,n&&`z-10 border-lt-ring ring-lt-ring/50 ring-[length:var(--lt-ring-width)]`),children:[e,t?(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,G.jsx)(`div`,{className:`bg-lt-fg h-5 w-px animate-pulse`})}):null]})}function es({length:e,containerClassName:t,pattern:n=Qo,...r}){return(0,G.jsx)(Yo,{maxLength:e,pattern:n,containerClassName:p(`flex items-center gap-2 has-[:disabled]:opacity-50`,t),render:({slots:e})=>(0,G.jsx)(`div`,{className:`flex items-center`,children:e.map((e,t)=>(0,G.jsx)($o,{...e},t))}),...r})}var ts=({node:e})=>{let t=e.props;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o},s)=>(0,G.jsx)(es,{...s,autoFocus:t.autoFocus??!1,"data-test":n,disabled:a||i,length:t.length,name:e,onChange:e=>o(e),value:r})})};function ns({className:e,ref:t,...n}){let[r,i]=(0,U.useState)(!1);return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(bt,{type:r?`text`:`password`,className:p(`pr-10`,e),ref:t,...n}),(0,G.jsx)(`button`,{type:`button`,"data-test":typeof n.name==`string`?`${n.name}-visibility`:`password-visibility`,onClick:()=>i(e=>!e),className:`absolute inset-y-0 right-0 flex items-center rounded-r-lt-sm px-3 text-lt-muted-fg hover:text-lt-fg focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-lt-ring/50 focus-visible:outline-none`,"aria-label":r?`Hide password`:`Show password`,tabIndex:-1,children:r?(0,G.jsx)(_,{name:`eye-off`,className:`size-lt-icon-md`}):(0,G.jsx)(_,{name:`eye`,className:`size-lt-icon-md`})})]})}var rs=({node:e})=>{let t=e.props,{errors:n}=Fe(),r=Ea(e),{commit:i}=ze(),a=mt(),o=t.confirmation,s=o?.name??`${r.localName}_confirmation`,c=a?a.scopedName(s):s,l=a?a.errorKey(s):s,u=(t.passwordRules??``)||void 0;return r.hidden?null:(0,G.jsxs)(`div`,{className:`grid gap-6`,children:[(0,G.jsx)(ot,{error:r.error,helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,labelAction:t.labelAction??void 0,id:r.name,required:r.required,children:e=>(0,G.jsx)(ko,{prefix:t.prefix,suffix:t.suffix,children:n=>(0,G.jsx)(ns,{...e,autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:n,"data-test":r.testId,disabled:r.disabled,name:r.name,onChange:e=>{r.commit(e.target.value)},placeholder:t.placeholder??``,passwordrules:u,readOnly:r.readOnly,tabIndex:t.tabIndex??void 0,value:r.value})})}),o&&(0,G.jsx)(ot,{error:n[l],label:o.label??`Confirm password`,id:c,required:r.required,children:e=>(0,G.jsx)(ns,{...e,autoComplete:`new-password`,"data-test":j(s),disabled:r.disabled,name:c,onChange:e=>{i(s,e.target.value)},placeholder:o.placeholder??o.label??`Confirm password`,passwordrules:u,readOnly:r.readOnly,tabIndex:t.tabIndex??void 0})})]})},is=[],as=({node:e})=>{let t=e.props,n=t.name,{errors:r}=Fe(),{hidden:i,required:a}=ut(e),{path:o,rows:s,onField:c,onRemove:l,onMove:u,onDuplicate:d,append:f}=$i(n,t.defaultItems??1),p=e.schema??is,m=Qi(s.map(e=>String(e.rowId??``)).join(`,`)),h=t.maxItems!=null&&s.length>=t.maxItems,g=t.minItems!=null&&s.length<=t.minItems,v=t.layout===`table`,y=t.itemLabels,b=e=>{let n=y?.[e];return typeof n==`string`&&n!==``?n:t.itemLabel?`${t.itemLabel} ${e+1}`:`#${e+1}`};if(i)return null;let x=s.map((e,t)=>({key:String(e.rowId??t),index:t,row:e,template:p,span:!1,heading:b(t)}));return(0,G.jsx)(ot,{error:r[o],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,id:o,required:a,children:e=>(0,G.jsxs)(`div`,{...e,className:`flex flex-col gap-3`,role:`group`,children:[(0,G.jsx)(xi,{path:o,rows:s,rowKey:_e}),v?(0,G.jsx)(Yi,{base:o,columns:qi(p),rows:x,reorderable:t.reorderable??!1,removable:()=>!g,rowActions:t.rowActions,onField:c,onMove:u,onRemove:l,onDuplicate:d,registerRow:m,resizableColumns:t.resizableColumns===!0,resizeIndicator:t.resizeIndicator===!0}):s.map((e,n)=>{let r=String(e.rowId??n);return(0,G.jsx)(`div`,{ref:e=>m(r,e),"data-flip-key":r,children:(0,G.jsx)(Ci,{base:o,index:n,row:e,template:p,heading:b(n),reorderable:t.reorderable??!1,isFirst:n===0,isLast:n===s.length-1,removable:!g,rowActions:t.rowActions,onField:c,onRemove:l,onMove:u,onDuplicate:d})},r)}),!h&&(0,G.jsxs)(`button`,{type:`button`,"data-test":`repeater-${n}-add`,className:`inline-flex items-center gap-1.5 self-start rounded-lt-sm border border-lt-border px-3 py-1.5 text-sm hover:bg-lt-accent [&_svg]:size-lt-icon-sm`,onClick:()=>f({}),children:[(0,G.jsx)(_,{name:`plus`}),t.addLabel??`Add`]})]})})},os=250;function ss({contentClassName:e,creatable:t=!1,emptyLabel:n,loading:r=!1,multiple:i=!1,onCommit:a,onCreate:o,onSearch:s,onSelect:c,open:l,onOpenChange:u,options:d,renderOption:f,searchLabel:m,searchPlaceholder:h,selected:g,showSearch:v=!0,testId:y,trigger:b,triggerClassName:x,triggerProps:S}){let{t:C}=z(`lattice`),[w,T]=(0,U.useState)(``);function E(e){let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of t){let t=d.find(t=>t.label.toLowerCase()===e.toLowerCase());t?(a??c)(t.value):o?.(e)}i?T(``):A()}let D=d.some(e=>e.label.toLowerCase()===w.trim().toLowerCase()),O=Ur(e=>s?.(e),os);(0,U.useEffect)(()=>{if(!(!s||!l))return O(w),()=>O.cancel()},[w,s,l,O]);let k=s?d:d.filter(e=>e.label.toLowerCase().includes(w.toLowerCase()));function A(){T(``),u(!1)}function j(e){c(e),i||A()}return(0,G.jsxs)(We,{open:l,onOpenChange:e=>e?u(!0):A(),children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:x,...S,children:b})}),(0,G.jsxs)(Ke,{align:`start`,className:p(`w-[var(--radix-popover-trigger-width)] overflow-hidden p-0`,e),children:[v&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-lt-border px-3 py-2`,children:[(0,G.jsx)(`input`,{"aria-label":m??C(`form.search-options`,`Search options`),"data-slot":`combobox-search`,"data-test":y?`${y}-search`:void 0,className:`w-full bg-transparent text-sm outline-none placeholder:text-lt-muted-fg`,onChange:e=>{let n=e.target.value;if(t&&n.includes(`,`)){E(n);return}T(n)},onKeyDown:e=>{t&&e.key===`Enter`&&w.trim()!==``&&(e.preventDefault(),E(w))},placeholder:h,value:w}),r&&(0,G.jsx)(_,{name:`loader-2`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0 animate-spin text-lt-muted-fg`})]}),(0,G.jsxs)(`div`,{className:`max-h-60 overflow-y-auto p-1`,role:`listbox`,children:[t&&w.trim()!==``&&!D&&(0,G.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded-lt-sm px-3 py-1.5 text-left text-sm transition-colors hover:bg-lt-accent hover:text-lt-accent-fg`,"data-test":y?`${y}-create`:void 0,onClick:()=>E(w),type:`button`,children:[(0,G.jsx)(_,{name:`plus`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`}),C(`form.create-option`,`Create "{{label}}"`,{label:w.trim()})]}),k.length===0&&!(t&&w.trim()!==``&&!D)?(0,G.jsx)(`p`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:n}):k.map(e=>{let t=g.includes(e.value);return(0,G.jsxs)(`button`,{"aria-label":f?e.label:void 0,"aria-selected":t,className:p(`flex w-full items-center justify-between gap-2 rounded-lt-sm px-3 py-1.5 text-left text-sm transition-colors hover:bg-lt-accent hover:text-lt-accent-fg`,t&&`bg-lt-accent/60`),"data-slot":`combobox-option`,"data-test":y?`${y}-option-${e.value}`:void 0,"data-value":e.value,onClick:()=>j(e.value),role:`option`,type:`button`,children:[f?(0,G.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:f(e)}):e.label,t&&(0,G.jsx)(_,{name:`check`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`})]},e.value)})]})]})]})}function cs(e,t){let n=e??t;return Array.isArray(n)?n.map(String):n==null||n===``?[]:[String(n)]}var ls=({node:e})=>{let{t}=z(`lattice`),n=e.props,{action:i,componentRef:a,errors:o,fieldIdPrefix:s,searchOptions:c}=Fe(),{hidden:l,required:u,readOnly:d,disabled:f}=ut(e),{change:m,blur:h}=ze(),g=Or(e),v=n.name,y=mt(),b=xa(y?y.scopedName(v):v,s),x=y?y.errorKey(v):v,S=x,C=n.placeholder||`Select…`,w=n.multiple,T=n.searchable,E=n.creatable,D=(0,U.useMemo)(()=>g.props.options,[g.props]),O=g.props.optionSchema,k=gt(v),A=He(),j=(0,U.useRef)(A);j.current=A;let M=y?y.getValue(v):k,N=(0,U.useMemo)(()=>cs(M,n.value),[M,n.value]),P=(0,U.useRef)(N);P.current=N;let[F,I]=(0,U.useState)(!1),[L,ee]=(0,U.useState)(null),[te,ne]=(0,U.useState)(!1),re=(0,U.useRef)(null),ie=(0,U.useMemo)(()=>{let e=new Map;for(let t of[...D,...L??[]])e.set(t.value,t);return e},[D,L]),R=e=>ie.get(e)?.label??e,ae=e=>Tt(ie.get(e)?.data?.color),oe=d||f,se=(0,U.useCallback)(e=>{if(re.current?.abort(),e.trim()===``){ee(null),ne(!1);return}let t=new AbortController;if(re.current=t,ne(!0),c){c(S,e,j.current,t.signal).then(e=>{ee(e),ne(!1)}).catch(()=>{});return}Ar(i,a,{...j.current,_sub:`search`,_target:S,_q:e},t.signal).then(e=>{ee(e?.options??[]),ne(!1)}).catch(()=>{})},[i,a,S,c]);function B(e){m(v,w?e:e[0]??``)}function ce(e){if(w){let t=P.current.includes(e)?P.current.filter(t=>t!==e):[...P.current,e];P.current=t,B(t);return}P.current=[e],B([e])}function le(e){B(N.filter(t=>t!==e))}function ue(e){if(!w){P.current=[e],B([e]);return}if(!P.current.includes(e)){let t=[...P.current,e];P.current=t,B(t)}}if(l)return null;let de=T?L??D:D,fe=O?.length?e=>(0,G.jsx)(Y,{nodes:r(O,{...e.data,label:e.label,value:e.value})}):void 0;return(0,G.jsx)(ot,{error:o[x],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,id:b,required:u,children:e=>(0,G.jsxs)(G.Fragment,{children:[w?N.map(e=>(0,G.jsx)(`input`,{name:`${b}[]`,type:`hidden`,value:e},e)):(0,G.jsx)(`input`,{name:b,type:`hidden`,value:N[0]??``}),(0,G.jsxs)(`div`,{children:[w&&N.length>0&&(0,G.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1`,children:N.map(e=>{let n=ae(e);return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lt-sm bg-lt-muted px-2 py-0.5 text-xs`,children:[n&&(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full`,style:{background:Ct(n)}}),R(e),!oe&&(0,G.jsx)(`button`,{"aria-label":t(`form.remove-option`,`Remove {{label}}`,{label:R(e)}),"data-test":`select-${v}-remove-${e}`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-xs`,onClick:()=>le(e),type:`button`,children:(0,G.jsx)(_,{name:`x`})})]},e)})}),(0,G.jsx)(ss,{creatable:E,emptyLabel:n.emptyLabel??void 0,loading:te,multiple:w,onCommit:ue,onCreate:ue,onSearch:T?se:void 0,onSelect:ce,open:F&&!oe,onOpenChange:e=>{I(e),e||h(v)},options:de,renderOption:fe,searchPlaceholder:n.searchPlaceholder??void 0,showSearch:!!(T||E),selected:N,testId:`select-${v}`,trigger:(0,G.jsxs)(G.Fragment,{children:[!w&&N.length>0?(0,G.jsx)(`span`,{children:R(N[0])}):(0,G.jsx)(`span`,{className:`text-lt-muted-fg`,children:C}),(0,G.jsx)(_,{name:`chevrons-up-down`,className:`size-lt-icon-md shrink-0 text-lt-muted-fg`})]}),triggerClassName:p(yt(),`flex items-center justify-between gap-2 text-left`,oe&&`cursor-not-allowed opacity-60`),triggerProps:{...e,"aria-haspopup":`listbox`,autoFocus:n.autoFocus??void 0,"data-test":`select-${v}`,disabled:oe,tabIndex:n.tabIndex??void 0}})]})]})})};function us({className:e,...t}){return(0,G.jsx)(`textarea`,{"data-slot":`textarea`,className:p(`border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-lt-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg`,vt,`aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger`,e),...t})}var ds=({node:e})=>{let t=e.props;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o},s)=>(0,G.jsx)(us,{...s,autoFocus:t.autoFocus??!1,"data-test":n,disabled:a,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,rows:t.rows??void 0,tabIndex:t.tabIndex??void 0,value:r})})};async function fs(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function ps({value:e,label:t,testId:n,className:r,iconOnly:i=!1,children:a}){let{t:o}=z(se),[s,c]=(0,U.useState)(!1);(0,U.useEffect)(()=>{if(!s)return;let e=window.setTimeout(()=>c(!1),1500);return()=>window.clearTimeout(e)},[s]);async function l(){await fs(e)&&c(!0)}let u=s?o(`common.copied-value`,`Copied {{label}}`,{label:t}):o(`common.copy-value`,`Copy {{label}}`,{label:t});return i?(0,G.jsx)(xt,{icon:s?`check`:`copy`,label:u,"data-test":n,className:r,onClick:()=>void l()}):(0,G.jsx)(x,{type:`button`,size:`sm`,emphasis:`outline`,icon:s?`check`:`copy`,"data-test":n,className:r,"aria-label":u,onClick:()=>void l(),children:s?o(`common.copied`,`Copied`):a??o(`common.copy`,`Copy`)})}function ms({value:e,label:t,testId:n,children:r}){return(0,G.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[r??e,(0,G.jsx)(ps,{value:e,label:t,testId:n})]})}var hs=({node:e})=>{let t=e.props;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o},s)=>(0,G.jsx)(ko,{prefix:t.prefix,suffix:t.suffix,end:t.copyable?(0,G.jsx)(ps,{className:`h-lt-control-md gap-1.5 rounded-l-none rounded-r-lt-sm border-l-0 border-lt-input px-3 group-has-[:focus-visible]:border-lt-ring`,label:t.label??e,testId:`${n}-copy`,value:r}):null,children:c=>(0,G.jsx)(bt,{...s,autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:c,"data-test":n,disabled:a,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,tabIndex:t.tabIndex??void 0,type:t.type??`text`,value:r})})})},gs=({node:e})=>{let t=e.props,n=S(t.step),r=t.label??t.name;return(0,G.jsx)(lo,{node:e,label:t.label??``,children:({name:e,testId:i,value:a,readOnly:o,disabled:s,commit:c,blur:l},u)=>(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(bt,{...u,"aria-label":r,autoFocus:t.autoFocus??!1,"data-test":i,disabled:s,name:e,onBlur:()=>{let e=w(a);e&&c(C(e,n)),l()},onChange:e=>c(e.target.value),readOnly:o,tabIndex:t.tabIndex??void 0,type:`text`,value:a}),(0,G.jsxs)(We,{children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(x,{"aria-label":`Open ${r} time picker`,disabled:s||o,size:`icon`,type:`button`,variant:`secondary`,children:(0,G.jsx)(_,{name:`clock`,className:`size-lt-icon-md`,"aria-hidden":`true`})})}),(0,G.jsx)(Ke,{className:`p-2`,children:(0,G.jsx)(T,{value:w(a),onChange:e=>c(C(e,n)),step:t.step,min:t.min,max:t.max,disabled:s,readOnly:o,testId:`${i}-picker`})})]})]})})},_s=({node:e})=>{let{hidden:t,required:n,readOnly:r,disabled:i}=ut(e),a=e.props,o=a.name,s=mt(),{errors:c,fieldIdPrefix:l}=Fe(),u=xa(s?s.scopedName(o):o,l),d=s?s.errorKey(o):o,f=gt(o),m=s?s.getValue(o):f,h=tt(a.value),g=m===void 0?h:tt(m),_=r||i,{commit:v}=ze();return Sa(o,h),t?null:(0,G.jsx)(ot,{error:c[d],helperText:a.helperText??void 0,tooltip:a.tooltip??void 0,label:a.label??``,id:u,required:n,children:e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{disabled:_,name:u,type:`hidden`,value:g?`1`:`0`}),(0,G.jsx)(`button`,{...e,"aria-checked":g,"aria-label":a.label??o,autoFocus:a.autoFocus??!1,className:p(`inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-lt-muted p-0.5 shadow-lt-xs transition-colors outline-none focus-visible:border-lt-ring focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-lt-ring/50 disabled:cursor-not-allowed disabled:bg-lt-disabled data-[state=checked]:bg-lt-primary disabled:data-[state=checked]:bg-lt-disabled`),"data-state":g?`checked`:`unchecked`,"data-test":j(o),disabled:_,name:u,onClick:()=>v(o,!g),role:`switch`,tabIndex:a.tabIndex??void 0,type:`button`,children:(0,G.jsx)(`span`,{className:`size-5 rounded-full bg-lt-bg shadow-lt-sm transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`,"data-state":g?`checked`:`unchecked`})})]})})};function vs(e){let t=[],n=e=>{let r=he(e).name;if(r&&t.push(r),!(r&&_t.has(e.type)))for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function ys(e){let t=[],n=e=>{let r=he(e).name;if(r&&t.push(r,`${r}.*`),r&&_t.has(e.type)){for(let n of vs(e))t.push(`${r}.*.${n}`);return}for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function bs(e,t){let n=Object.keys(t).filter(e=>!!t[e]),r=new Set;return e.forEach((e,t)=>{n.some(t=>e.some(e=>Vr(t,e)))&&r.add(t)}),r}function xs(e,t){let n=bs(e,t);return n.size>0?Math.min(...n):null}var Ss=(0,U.createContext)({activeName:``});function Cs(e){let t=(e.schema??[]).filter(e=>e.type===`wizard-step`);return{items:t.map(e=>e.props),nodes:t}}var ws=({children:e,node:t})=>{let{t:n}=z(`lattice`),{errors:r,processing:i,touch:a,validateFields:o,validating:s}=Fe(),{items:c,nodes:l}=(0,U.useMemo)(()=>Cs(t),[t]),u=(0,U.useMemo)(()=>l.map(e=>vs(e)),[l]),d=t.props.orientation===`vertical`,[f,m]=(0,U.useState)(0),[h,g]=(0,U.useState)(()=>new Set([0])),[v,y]=(0,U.useState)(()=>new Set),b=(0,U.useMemo)(()=>bs(u,r),[u,r]),S=f===c.length-1,C=e=>{m(e),g(t=>new Set(t).add(e))},w=()=>{y(e=>new Set(e).add(f)),S||C(f+1)},T=()=>{let e=l[f],t=e?ys(e):[];if(t.length===0){w();return}a(t),o(t,{onSuccess:w})},E=(0,U.useRef)(!1);(0,U.useEffect)(()=>{if(E.current&&!i){let e=xs(u,r);e!==null&&e!==f&&C(e)}E.current=i},[i,r,u,f]);let D=(0,U.useMemo)(()=>({activeName:c[f]?.name??``}),[c,f]);return(0,G.jsx)(Ss.Provider,{value:D,children:(0,G.jsxs)(`div`,{className:p(`gap-6`,d?`flex`:`grid`),"data-slot":`wizard`,children:[(0,G.jsx)(`ol`,{"aria-label":n(`form.wizard.steps`,`Steps`),className:p(`gap-1`,d?`flex w-56 shrink-0 flex-col`:`flex flex-wrap`),children:c.map((e,t)=>{let n=t===f,r=v.has(t),i=b.has(t);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{"aria-current":n?`step`:void 0,className:p(`flex w-full items-center gap-2 rounded-lt px-3 py-2 text-left text-sm`,n?`bg-lt-muted font-medium text-lt-fg`:`text-lt-muted-fg`,!h.has(t)&&`cursor-not-allowed opacity-60`),"data-error":i||void 0,"data-test":`wizard-rail-${e.name}`,disabled:!h.has(t),id:`wizard-step-${e.name}-trigger`,onClick:()=>C(t),type:`button`,children:[(0,G.jsx)(`span`,{className:p(`flex size-5 shrink-0 items-center justify-center rounded-full border text-xs`,i?`border-lt-danger text-lt-danger`:r?`border-lt-primary bg-lt-primary text-lt-primary-fg`:`border-lt-border`),children:r&&!i?(0,G.jsx)(_,{className:`size-lt-icon-sm`,name:`check`}):t+1}),(0,G.jsxs)(`span`,{className:`min-w-0`,children:[(0,G.jsx)(`span`,{className:`block truncate`,children:e.label}),d&&e.description&&(0,G.jsx)(`span`,{className:`block truncate text-xs text-lt-muted-fg`,children:e.description})]})]})},e.name)})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-6`,children:[e,(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(x,{"data-test":`wizard-back`,disabled:f===0||i,onClick:()=>C(f-1),type:`button`,emphasis:`outline`,children:n(`form.wizard.back`,`Back`)}),S?(0,G.jsxs)(x,{"data-test":`wizard-finish`,disabled:i,type:`submit`,children:[i&&(0,G.jsx)(rn,{}),n(`form.wizard.finish`,`Finish`)]}):(0,G.jsxs)(x,{"data-test":`wizard-next`,disabled:i||s,onClick:T,type:`button`,children:[s&&(0,G.jsx)(rn,{}),n(`form.wizard.next`,`Next`)]})]})]})]})})},Ts=({children:e,node:t})=>{let{activeName:n}=(0,U.useContext)(Ss),r=t.props.name,i=n===r,[a,o]=(0,U.useState)(i);return(0,U.useEffect)(()=>{i&&o(!0)},[i]),(0,G.jsx)(`section`,{"aria-labelledby":`wizard-step-${r}-trigger`,className:p(`space-y-8`,!i&&`hidden`),hidden:!i,id:`wizard-step-${r}-panel`,children:a?e:null})},Es=(0,U.lazy)(()=>jt(()=>import(`./field-BQzK42M4.js`),__vite__mapDeps([10,1,2,4,5,6,11,8,12,13,14,15,3,9,16,17,18,19,20]),import.meta.url)),Ds=({children:e,node:t})=>(0,G.jsx)(U.Suspense,{fallback:null,children:(0,G.jsx)(Es,{node:t,children:e})}),Os=(0,U.lazy)(()=>jt(()=>import(`./rich-editor-field-BsezbAas.js`),__vite__mapDeps([21,1,2,4,5,6,22,11,8,12,13,14,15,3,23,18,19,20]),import.meta.url)),ks={components:{form:W(To),"field.builder":W(ta),"field.checkbox":W(Ca),"field.choice":W(Da),"field.color-picker":W(uo),"field.date-input":W(mo),"field.date-time-input":W(ho),"field.file-upload":W(yo),"field.hidden-input":W(Do),"field.number-input":W(Ao),"field.otp":W(ts),"field.password-input":W(rs),"field.pattern-input":W(Ds),"field.repeater":W(as),"field.rich-editor":W(({children:e,node:t})=>(0,G.jsx)(U.Suspense,{fallback:null,children:(0,G.jsx)(Os,{node:t,children:e})})),"field.select":W(ls),"field.textarea":W(ds),"field.text-input":W(hs),"field.time-input":W(gs),"field.toggle":W(_s),wizard:W(ws),"wizard-step":W(Ts)},name:`lattice/form`},As={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},js={components:{fragment:W(({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,i=As[e.props.size],[a,o]=(0,U.useState)(()=>e.schema??[]),[s,c]=(0,U.useState)(!n),[l,u]=(0,U.useState)(n&&t!==``),d=(0,U.useCallback)(async()=>{if(t){u(!0);try{let e=await lr(t,{ref:r});o(yr(e.schema)),c(!0)}finally{u(!1)}}},[t,r]);return(0,U.useEffect)(()=>{!n||s||d()},[s,n,d]),(0,U.useEffect)(()=>{function t(t){t.detail?.component===e.id&&d()}return window.addEventListener(F.reloadComponent,t),()=>window.removeEventListener(F.reloadComponent,t)},[d,e.id]),(0,U.useEffect)(()=>{function e(){s&&d()}return window.addEventListener(F.localeChange,e),()=>window.removeEventListener(F.localeChange,e)},[s,d]),(0,G.jsx)(`div`,{"data-lattice-fragment":e.id,style:l&&a.length===0?{minHeight:i}:void 0,children:l&&a.length===0?(0,G.jsx)(vr,{className:`w-full`,style:{height:i}}):(0,G.jsx)(Y,{nodes:a})})})},name:`lattice/fragments`},Ms=({node:e})=>{let{t}=z(`lattice`),n=a().props.lattice?.breadcrumbs??[];return n.length===0?null:(0,G.jsx)(`nav`,{"aria-label":t(`common.breadcrumb`,`Breadcrumb`),className:`px-4 pt-4`,"data-lattice-component":D(e),children:(0,G.jsx)(`ol`,{className:`flex items-center gap-2 text-sm text-lt-muted-fg`,children:n.map((e,t)=>{let r=t===n.length-1;return(0,G.jsxs)(U.Fragment,{children:[(0,G.jsx)(`li`,{children:r?(0,G.jsx)(`span`,{"aria-current":`page`,className:`text-lt-fg`,children:e.title}):(0,G.jsx)(l,{className:`hover:text-lt-fg`,href:e.href,children:e.title})}),r?null:(0,G.jsx)(`li`,{"aria-hidden":`true`,children:`/`})]},e.href)})})})},Ns=[`primary`,`secondary`,`success`,`info`,`warning`,`danger`];function Ps(e){return Ns.some(t=>t===e)}function Fs(e){let t=typeof e==`string`||ae(e)?e:null;return t===``?null:t}function Is(e,t,n){let r=e=>{let r=t(e.detail);r!==null&&n(r)};return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}function Ls(e){if(typeof e!=`object`||!e)return null;let t=e,n=Fs(t.message);return n===null?null:{action:t.action??null,dismissible:t.dismissible!==!1,duration:typeof t.duration==`number`?t.duration:null,message:n,persistent:t.persistent===!0,variant:Ps(t.variant)?t.variant:`success`}}function Rs(e){return Is(F.toast,Ls,e)}function zs(e){if(typeof e!=`object`||!e)return null;let t=e,n=Fs(t.message);return n===null?null:{action:t.action??null,dismissible:t.dismissible!==!1,message:n,title:typeof t.title==`string`||ae(t.title)?t.title:null,unique:typeof t.unique==`string`?t.unique:null,variant:Ps(t.variant)?t.variant:`info`}}function Bs(e){return Is(F.callout,zs,e)}function Vs(e){return Is(F.retractCallout,e=>{let t=e?.unique;return typeof t==`string`?t:null},e)}var Hs=Object.defineProperty,Q=(e,t)=>Hs(e,`name`,{value:t,configurable:!0});function Us(e){let t=e+`CollectionProvider`,[n,r]=lt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Q(e=>{let{scope:t,children:n}=e,r=U.useRef(null),a=U.useRef(new Map).current;return(0,G.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=m(s),l=U.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=v(t,i.collectionRef);return(0,G.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=m(u),p=U.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=U.useRef(null),s=v(t,o),c=a(u,n);return U.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,G.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function h(t){let n=a(e+`CollectionConsumer`,t);return U.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return Q(h,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},h,r]}Q(Us,`createCollection`);var Ws=new WeakMap,Gs=class e extends Map{static{Q(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Ws.set(this,!0)}set(e,t){return Ws.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=Js(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=Ks(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Ks(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Ks(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function Ks(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=qs(e,t);return n===-1?void 0:e[n]}Q(Ks,`at`);function qs(e,t){let n=e.length,r=Js(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Q(qs,`toSafeIndex`);function Js(e){return e!==e||e===0?0:Math.trunc(e)}Q(Js,`toSafeInteger`);function Ys(e){let t=e+`CollectionProvider`,[n,r]=lt(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Gs,setItemMap:Q(()=>void 0,`setItemMap`)}),o=Q(({state:e,...t})=>e?(0,G.jsx)(c,{...t,state:e}):(0,G.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Q(e=>{let t=g();return(0,G.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Q(e=>{let{scope:t,children:n,state:r}=e,a=U.useRef(null),[o,s]=U.useState(null),c=v(a,s),[l,u]=r;return U.useEffect(()=>{if(!o)return;let e=$s(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,G.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=m(l),d=U.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=v(t,i.collectionRef);return(0,G.jsx)(u,{ref:o,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=m(f),h=U.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=U.useRef(null),[s,c]=U.useState(null),l=v(t,o,c),{setItemMap:u}=a(f,n),d=U.useRef(i);Xs(d.current,i)||(d.current=i);let m=d.current;return U.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Qs):(t.set(s,{...e,element:s}),t.toSorted(Qs)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Gs(e)))}},[s,m,u]),(0,G.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});h.displayName=f;function g(){return U.useState(new Gs)}Q(g,`useInitCollection`);function _(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Q(_,`useCollection`),[{Provider:o,Slot:d,ItemSlot:h},{createCollectionScope:r,useCollection:_,useInitCollection:g}]}Q(Ys,`createCollection`);function Xs(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}Q(Xs,`shallowEqual`);function Zs(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Q(Zs,`isElementPreceding`);function Qs(e,t){return!e[1].element||!t[1].element?0:Zs(e[1].element,t[1].element)?-1:1}Q(Qs,`sortByDocumentPosition`);function $s(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Q($s,`getChildListObserver`);var ec=Object.defineProperty,tc=(e,t)=>ec(e,`name`,{value:t,configurable:!0}),nc=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),rc=U.forwardRef(tc(function(e,t){return(0,G.jsx)(H.span,{...e,ref:t,style:{...nc,...e.style}})},`VisuallyHidden`)),ic=Object.defineProperty,$=(e,t)=>ic(e,`name`,{value:t,configurable:!0}),ac=`ToastProvider`,[oc,sc,cc]=Us(`Toast`),[lc,uc]=lt(`Toast`,[cc]),[dc,fc]=lc(ac),pc=$(e=>{let{__scopeToast:t,label:n=`Notification`,duration:r=5e3,swipeDirection:i=`right`,swipeThreshold:a=50,announcerContainer:o,children:s}=e,[c,l]=U.useState(null),[u,d]=U.useState(0),f=U.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${ac}\`. Expected non-empty \`string\`.`),(0,G.jsx)(oc.Provider,{scope:t,children:(0,G.jsx)(dc,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:u,viewport:c,onViewportChange:l,onToastAdd:U.useCallback(()=>d(e=>e+1),[]),onToastRemove:U.useCallback(()=>d(e=>e-1),[]),isClosePausedRef:f,announcerContainer:o,children:s})})},`ToastProvider`),mc=`ToastViewport`,hc=[`F8`],gc=`toast.viewportPause`,_c=`toast.viewportResume`,vc=U.forwardRef($(function(e,t){let{__scopeToast:n,hotkey:r=hc,label:i=`Notifications ({hotkey})`,...a}=e,o=fc(mc,n),s=sc(n),c=U.useRef(null),l=U.useRef(null),u=U.useRef(null),d=U.useRef(null),f=v(t,d,o.onViewportChange),p=r.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),m=o.toastCount>0;U.useEffect(()=>{let e=$(e=>{r.length!==0&&r.every(t=>e[t]||e.code===t)&&d.current?.focus()},`handleKeyDown`);return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),U.useEffect(()=>{let e=c.current,t=d.current;if(m&&e&&t){let n=$(()=>{if(!o.isClosePausedRef.current){let e=new CustomEvent(gc);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},`handlePause`),r=$(()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(_c);t.dispatchEvent(e),o.isClosePausedRef.current=!1}},`handleResume`),i=$(t=>{e.contains(t.relatedTarget)||r()},`handleFocusOutResume`),a=$(()=>{e.contains(document.activeElement)||r()},`handlePointerLeaveResume`);return e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,i),e.addEventListener(`pointermove`,n),e.addEventListener(`pointerleave`,a),window.addEventListener(`blur`,n),window.addEventListener(`focus`,r),()=>{e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,i),e.removeEventListener(`pointermove`,n),e.removeEventListener(`pointerleave`,a),window.removeEventListener(`blur`,n),window.removeEventListener(`focus`,r)}}},[m,o.isClosePausedRef]);let h=U.useCallback(({tabbingDirection:e})=>{let t=s().map(t=>{let n=t.ref.current,r=[n,...Bc(n)];return e===`forwards`?r:r.reverse()});return(e===`forwards`?t.reverse():t).flat()},[s]);return U.useEffect(()=>{let e=d.current;if(e){let t=$(t=>{let n=t.altKey||t.ctrlKey||t.metaKey;if(t.key===`Tab`&&!n){let n=document.activeElement,r=t.shiftKey;if(t.target===e&&r){l.current?.focus();return}let i=h({tabbingDirection:r?`backwards`:`forwards`}),a=i.findIndex(e=>e===n);Vc(i.slice(a+1))?t.preventDefault():r?l.current?.focus():u.current?.focus()}},`handleKeyDown`);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}},[s,h]),(0,G.jsxs)(Re,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,G.jsx)(bc,{ref:l,onFocusFromOutsideViewport:()=>{Vc(h({tabbingDirection:`forwards`}))}}),(0,G.jsx)(oc.Slot,{scope:n,children:(0,G.jsx)(H.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,G.jsx)(bc,{ref:u,onFocusFromOutsideViewport:()=>{Vc(h({tabbingDirection:`backwards`}))}})]})},`ToastViewport`)),yc=`ToastFocusProxy`,bc=U.forwardRef($(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=fc(yc,n);return(0,G.jsx)(rc,{tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})},`ToastFocusProxy`)),xc=`Toast`,Sc=`toast.swipeStart`,Cc=`toast.swipeMove`,wc=`toast.swipeCancel`,Tc=`toast.swipeEnd`,Ec=U.forwardRef($(function(e,t){let{forceMount:n,open:r,defaultOpen:i,onOpenChange:a,...o}=e,[s,c]=Xe({prop:r,defaultProp:i??!0,onChange:a,caller:xc});return(0,G.jsx)(Ce,{present:n||s,children:(0,G.jsx)(kc,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:dt(e.onPause),onResume:dt(e.onResume),onSwipeStart:V(e.onSwipeStart,e=>{e.currentTarget.setAttribute(`data-swipe`,`start`)}),onSwipeMove:V(e.onSwipeMove,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`move`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-y`,`${n}px`)}),onSwipeCancel:V(e.onSwipeCancel,e=>{e.currentTarget.setAttribute(`data-swipe`,`cancel`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-y`)}),onSwipeEnd:V(e.onSwipeEnd,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`end`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-y`,`${n}px`),c(!1)})})})},`Toast`)),[Dc,Oc]=lc(xc,{onClose(){}}),kc=U.forwardRef($(function(e,t){let{__scopeToast:n,type:r=`foreground`,duration:i,open:a,onClose:o,onEscapeKeyDown:s,onPause:c,onResume:l,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:p,...m}=e,h=fc(xc,n),g=sc(n),[_,y]=U.useState(null),b=v(t,y),x=U.useRef(null),S=U.useRef(null),C=i||h.duration,w=U.useRef(0),T=U.useRef(C),E=U.useRef(0),{onToastAdd:D,onToastRemove:O}=h,k=dt(()=>{_?.contains(document.activeElement)&&h.viewport?.focus(),o()}),A=U.useCallback(e=>{!e||e===1/0||(window.clearTimeout(E.current),w.current=new Date().getTime(),E.current=window.setTimeout(k,e))},[k]);U.useEffect(()=>{let e=h.viewport;if(e){let t=$(()=>{A(T.current),l?.()},`handleResume`),n=$(()=>{let e=new Date().getTime()-w.current;T.current-=e,window.clearTimeout(E.current),c?.()},`handlePause`);return e.addEventListener(gc,n),e.addEventListener(_c,t),()=>{e.removeEventListener(gc,n),e.removeEventListener(_c,t)}}},[h.viewport,C,c,l,A]),U.useEffect(()=>{a&&!h.isClosePausedRef.current&&A(C)},[a,C,h.isClosePausedRef,A]),U.useEffect(()=>()=>{window.clearTimeout(E.current)},[]),U.useEffect(()=>(D(),()=>O()),[D,O]);let j=U.useMemo(()=>_?Fc(_):null,[_]);return h.viewport?(0,G.jsxs)(G.Fragment,{children:[j&&(0,G.jsx)(Ac,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,children:j}),(0,G.jsx)(Dc,{scope:n,onClose:k,children:Wt.createPortal((0,G.jsx)(oc.ItemSlot,{scope:n,children:(0,G.jsx)(pe,{asChild:!0,onEscapeKeyDown:V(s,e=>{g().some(t=>t.ref.current?.contains(e.target))||k()}),children:(0,G.jsx)(H.li,{tabIndex:0,"data-state":a?`open`:`closed`,"data-swipe-direction":h.swipeDirection,...m,ref:b,style:{userSelect:`none`,touchAction:`none`,...e.style},onKeyDown:V(e.onKeyDown,e=>{e.key===`Escape`&&(s?.(e.nativeEvent),e.nativeEvent.defaultPrevented||k())}),onPointerDown:V(e.onPointerDown,e=>{e.button===0&&(x.current={x:e.clientX,y:e.clientY})}),onPointerMove:V(e.onPointerMove,e=>{if(!x.current)return;let t=e.clientX-x.current.x,n=e.clientY-x.current.y,r=!!S.current,i=[`left`,`right`].includes(h.swipeDirection),a=[`left`,`up`].includes(h.swipeDirection)?Math.min:Math.max,o=i?a(0,t):0,s=i?0:a(0,n),c=e.pointerType===`touch`?10:2,l={x:o,y:s},f={originalEvent:e,delta:l};r?(S.current=l,Ic(Cc,d,f,{discrete:!1})):Lc(l,h.swipeDirection,c)?(S.current=l,Ic(Sc,u,f,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(n)>c)&&(x.current=null)}),onPointerUp:V(e.onPointerUp,e=>{let t=S.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),S.current=null,x.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};Lc(t,h.swipeDirection,h.swipeThreshold)?Ic(Tc,p,r,{discrete:!0}):Ic(wc,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null},`ToastImpl`)),Ac=$(e=>{let{__scopeToast:t,children:n,...r}=e,i=fc(xc,t),[a,o]=U.useState(!1),[s,c]=U.useState(!1);return Rc(()=>o(!0)),U.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,G.jsx)(Le,{asChild:!0,container:i.announcerContainer||void 0,children:(0,G.jsx)(rc,{...r,children:a&&(0,G.jsxs)(G.Fragment,{children:[i.label,` `,n]})})})},`ToastAnnounce`),jc=U.forwardRef($(function(e,t){let{__scopeToast:n,...r}=e;return(0,G.jsx)(H.div,{...r,ref:t})},`ToastTitle`)),Mc=`ToastClose`,Nc=U.forwardRef($(function(e,t){let{__scopeToast:n,...r}=e,i=Oc(Mc,n);return(0,G.jsx)(Pc,{asChild:!0,children:(0,G.jsx)(H.button,{type:`button`,...r,ref:t,onClick:V(e.onClick,i.onClose)})})},`ToastClose`)),Pc=U.forwardRef($(function(e,t){let{__scopeToast:n,altText:r,...i}=e;return(0,G.jsx)(H.div,{"data-radix-toast-announce-exclude":``,"data-radix-toast-announce-alt":r||void 0,...i,ref:t})},`ToastAnnounceExclude`));function Fc(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),zc(e)){let n=e.ariaHidden||e.hidden||e.style.display===`none`,r=e.dataset.radixToastAnnounceExclude===``;if(!n)if(r){let n=e.dataset.radixToastAnnounceAlt;n&&t.push(n)}else t.push(...Fc(e))}}),t}$(Fc,`getAnnounceTextContent`);function Ic(e,t,n,{discrete:r}){let i=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?st(i,a):i.dispatchEvent(a)}$(Ic,`handleAndDispatchCustomEvent`);var Lc=$((e,t,n=0)=>{let r=Math.abs(e.x),i=Math.abs(e.y),a=r>i;return t===`left`||t===`right`?a&&r>n:!a&&i>n},`isDeltaInDirection`);function Rc(e=()=>{}){let t=dt(e);rt(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}$(Rc,`useNextFrame`);function zc(e){return e.nodeType===e.ELEMENT_NODE}$(zc,`isHTMLElement`);function Bc(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:$(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}$(Bc,`getTabbableCandidates`);function Vc(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}$(Vc,`focusFirst`);var Hc=pc,Uc=vc,Wc=Ec,Gc=jc,Kc=Nc,qc={primary:{accent:`border-l-lt-primary`,icon:(0,G.jsx)(_,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-primary`})},secondary:{accent:`border-l-lt-secondary`,icon:(0,G.jsx)(_,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-muted-fg`})},success:{accent:`border-l-lt-success`,icon:(0,G.jsx)(_,{name:`circle-check`,className:`size-lt-icon-lg shrink-0 text-lt-success`})},info:{accent:`border-l-lt-info`,icon:(0,G.jsx)(_,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-info`})},warning:{accent:`border-l-lt-warning`,icon:(0,G.jsx)(_,{name:`circle-alert`,className:`size-lt-icon-lg shrink-0 text-lt-warning`})},danger:{accent:`border-l-lt-danger`,icon:(0,G.jsx)(_,{name:`circle-x`,className:`size-lt-icon-lg shrink-0 text-lt-danger`})}},Jc=0;function Yc({duration:e=4e3}){let{t}=z(`lattice`),[n,r]=(0,U.useState)([]);function i(e){r(t=>t.filter(t=>t.id!==e))}return(0,U.useEffect)(()=>Rs(e=>{r(t=>[...t,{...e,id:Jc++}])}),[]),(0,G.jsxs)(Hc,{duration:e,swipeDirection:`down`,children:[n.map(n=>(0,G.jsxs)(Wc,{className:p(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg shadow-lt-lg`,qc[n.variant].accent,`data-[state=open]:animate-lt-toast-in data-[state=closed]:animate-lt-toast-out`,`data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=cancel]:translate-y-0 data-[swipe=cancel]:transition-transform`),"data-test":`toast-${n.variant}`,duration:n.persistent?1/0:n.duration??e,onOpenChange:e=>{e||i(n.id)},children:[qc[n.variant].icon,(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,G.jsx)(Gc,{className:`text-sm text-lt-fg`,children:ie(n.message,t)}),n.action?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,G.jsx)(X,{node:n.action})}):null]}),n.dismissible?(0,G.jsx)(Kc,{"aria-label":t(`common.dismiss`,`Dismiss`),className:`shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,"data-test":`toast-dismiss`,children:(0,G.jsx)(_,{name:`x`,className:`size-lt-icon-md`})}):null]},n.id)),(0,G.jsx)(Uc,{className:`fixed inset-x-0 bottom-0 z-lt-toast mx-auto flex w-full max-w-sm flex-col gap-2 p-4 outline-none`})]})}var Xc=0,Zc=()=>{let{t:e}=z(`lattice`),[t,n]=(0,U.useState)([]);(0,U.useEffect)(()=>Bs(e=>{n(t=>[...e.unique?t.filter(t=>t.unique!==e.unique):t,{...e,id:Xc++}])}),[]),(0,U.useEffect)(()=>u.on(`navigate`,()=>{n(e=>e.filter(e=>!e.unique))}),[]),(0,U.useEffect)(()=>Vs(e=>{n(t=>t.filter(t=>t.unique!==e))}),[]);function r(e){n(t=>t.filter(t=>t.id!==e))}return t.length===0?null:(0,G.jsx)(`div`,{className:`flex w-full flex-col gap-2`,children:t.map(t=>(0,G.jsxs)(`div`,{role:`status`,"data-test":`callout-${t.variant}`,className:p(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg`,qc[t.variant].accent),children:[qc[t.variant].icon,(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[t.title?(0,G.jsx)(`p`,{className:`text-sm font-medium text-lt-fg`,children:ie(t.title,e)}):null,(0,G.jsx)(`p`,{className:`text-sm text-lt-fg`,children:ie(t.message,e)}),t.action?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,G.jsx)(X,{node:t.action})}):null]}),t.dismissible?(0,G.jsx)(`button`,{type:`button`,"aria-label":e(`common.dismiss`,`Dismiss`),"data-test":`callout-dismiss`,className:`shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,onClick:()=>r(t.id),children:(0,G.jsx)(_,{name:`x`,className:`size-lt-icon-md`})}):null]},t.id))})};function Qc({align:e=`start`,children:t,className:n,placement:r=`bottom`,testId:i,trigger:o,triggerClassName:s,triggerLabel:c}){let[l,u]=(0,U.useState)(!1),d=a().url;return(0,U.useEffect)(()=>u(!1),[d]),(0,G.jsxs)(We,{open:l,onOpenChange:u,children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(`button`,{"aria-label":c,className:p(`w-full`,s),"data-test":i,title:c,type:`button`,children:o})}),(0,G.jsx)(Ke,{align:e,className:p(`min-w-56 p-1`,n),role:`menu`,side:r,children:(0,G.jsx)(xr.Provider,{value:!1,children:t})})]})}var $c=({children:e,node:t})=>{let n=t.key??`dropdown`;return(0,G.jsx)(Qc,{placement:t.props.placement,testId:n,triggerClassName:`w-auto`,trigger:(0,G.jsx)(`span`,{className:`flex min-w-0 items-center rounded-lt-sm px-2 py-1.5 text-sm hover:bg-lt-muted`,children:t.props.trigger.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??`${e.type}-${t}`))}),children:(0,G.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})})},el=({children:e,node:t})=>(0,G.jsx)(`nav`,{"data-lattice-component":D(t),children:(0,G.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})}),tl=(0,U.createContext)(null),nl=`flex items-center gap-2 rounded-lt-sm px-3 py-2 text-base font-medium text-lt-fg transition-colors hover:bg-lt-muted`;function rl({affix:e,className:t}){return e.icon?(0,G.jsx)(K,{className:p(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,G.jsx)(`span`,{className:p(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function il(e,t){return(e??[]).some(e=>e.props?.href===t||il(e.schema,t))}var al=({children:e,node:t})=>{let n=Sr(),{icon:r,label:i,prefix:o,suffix:s}=t.props,c=i??``,u=!!r,d=r??o?.icon??null,f=a().url.split(`?`)[0],m=E(`menu`,t),h=Xt(t.props),g=r?(0,G.jsx)(K,{className:`size-lt-icon-md shrink-0`,icon:r}):(0,G.jsxs)(G.Fragment,{children:[o?(0,G.jsx)(rl,{affix:o}):null,n?(0,G.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 left-full z-lt-popover ml-2 hidden -translate-y-1/2 rounded-lt-sm border border-lt-border bg-lt-popover px-2 py-1 text-sm whitespace-nowrap text-lt-popover-fg shadow-lt-md group-hover:block`,role:`tooltip`,children:c}):(0,G.jsx)(`span`,{children:c}),s?(0,G.jsx)(rl,{affix:s,className:`ml-auto`}):null]}),_=p(nl,`w-full`,n&&`group relative justify-center`,u&&`justify-center`),v=({onClick:e,processing:t})=>(0,G.jsx)(`button`,{"aria-label":n||u?c:void 0,className:_,"data-test":m,disabled:t,onClick:e,type:`button`,children:g});if(h.kind===`action`)return(0,G.jsx)(`li`,{children:(0,G.jsx)(Yt,{action:h.action,children:v})});if(h.kind===`effects`)return(0,G.jsx)(`li`,{children:v({onClick:h.onClick,processing:!1})});if(h.kind===`navigate`){let e=f===h.href;return(0,G.jsx)(`li`,{children:(0,G.jsx)(l,{"aria-current":e?`page`:void 0,"aria-label":n||u?c:void 0,as:h.method===`get`?void 0:`button`,className:p(_,e&&`bg-lt-muted font-medium`),"data-test":m,href:h.href,method:h.method,children:g})})}return e?n?(0,G.jsx)(sl,{icon:d,label:c,testId:m,children:e}):(0,G.jsx)(ol,{content:g,defaultOpen:il(t.schema,f),testId:m,children:e}):n?null:(0,G.jsx)(`li`,{children:(0,G.jsx)(`span`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:g})})};function ol({children:e,content:t,defaultOpen:n,testId:r}){let[i,a]=(0,U.useState)(n);return(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`button`,{"aria-expanded":i,className:p(nl,`w-full`),"data-test":r,onClick:()=>a(e=>!e),type:`button`,children:[t,(0,G.jsx)(_,{name:`chevron-right`,className:p(`ml-auto size-lt-icon-md shrink-0 transition-transform`,i&&`rotate-90`)})]}),i?(0,G.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1 pl-3`,children:e}):null]})}function sl({children:e,icon:t,label:n,testId:r}){return(0,G.jsx)(`li`,{children:(0,G.jsx)(Qc,{className:`min-w-48`,placement:`right`,testId:r,trigger:t?(0,G.jsx)(K,{className:`size-lt-icon-md shrink-0`,icon:t}):(0,G.jsx)(`span`,{children:n}),triggerClassName:p(nl,`justify-center`),triggerLabel:n,children:(0,G.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`li`,{className:`px-3 py-1.5 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:n}),e]})})})}var cl=()=>(0,G.jsx)(G.Fragment,{children:(0,U.useContext)(tl)});function ll(e,t,n){let[r,i]=Ai(e,t,{enabled:n,parse:e=>e===`true`,serialize:String});return[r,(0,U.useCallback)(()=>i(e=>!e),[i])]}var ul=`(min-width: 768px)`;function dl(e,t){let n=e.detail?.target;return n==null||n===t}var fl={components:{breadcrumbs:W(Ms),callouts:W(Zc),dropdown:W($c),menu:W(el),"menu-item":W(al),outlet:W(cl),sidebar:W(({children:e,node:t})=>{let n=t.props.collapsible,r=t.props.rememberState,i=D(t),a=`lattice:sidebar:${i??`default`}`,o=Bi(ul,!0),[s,c]=ll(a,!1,n&&r),[l,d]=(0,U.useState)(!1);Qt(F.toggleSidebar,e=>{dl(e,i)&&(window.matchMedia?.(ul).matches??!0?n&&c():d(e=>!e))}),(0,U.useEffect)(()=>u.on(`navigate`,()=>d(!1)),[]),Qt(`keydown`,e=>{e.key===`Escape`&&d(!1)},{enabled:l});let f=n&&s&&o;return(0,G.jsxs)(xr.Provider,{value:f,children:[l?(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`fixed inset-0 z-lt-overlay bg-lt-overlay md:hidden`,"data-test":`sidebar-backdrop`,onClick:()=>d(!1)}):null,(0,G.jsx)(`aside`,{className:p(`fixed inset-y-0 left-0 z-lt-modal flex h-svh w-72 max-w-[80vw] shrink-0 flex-col gap-4 border-r border-lt-border bg-lt-bg p-4 transition-transform`,`md:sticky md:top-0 md:z-auto md:max-w-none md:translate-x-0 md:transition-[width]`,l?`translate-x-0`:`-translate-x-full`,f?`md:w-16 md:overflow-visible`:`md:w-64 md:overflow-x-hidden md:overflow-y-auto`),"data-collapsed":f?`true`:`false`,"data-lattice-component":i,"data-test":`sidebar`,children:e})]})}),topbar:W(({children:e,node:t})=>{let n=t.props.sticky;return(0,G.jsx)(`header`,{"data-lattice-component":D(t),className:p(`flex h-14 w-full items-center gap-2 border-b border-lt-border bg-lt-bg px-4 text-lt-fg`,n&&`sticky top-0 z-lt-sticky`),children:e})})},name:`lattice/layout`};function pl(e,t=1){return lr(`${e}?page=${t}`)}function ml(e,t){return lr(`${e}/${t}/read`,{method:`PATCH`})}function hl(e){return lr(`${e}/read-all`,{method:`POST`})}function gl(e,t){return lr(`${e}/${t}`,{method:`DELETE`})}function _l(e){return lr(e,{method:`DELETE`})}function vl(e,t){return e.some(e=>e.id===t.id)?e:[t,...e]}function yl(e,t){return e.map(e=>e.id===t?{...e,isRead:!0}:e)}function bl(e,t){return e.filter(e=>e.id!==t)}function xl({endpoint:e,pollingInterval:t}){let[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(0),[o,s]=(0,U.useState)(`loading`),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(!1),f=(0,U.useRef)(1),p=(0,U.useRef)(c);p.current=c;let m=(0,U.useRef)(!1),h=(0,U.useCallback)(async()=>{try{let t=await pl(e,1);f.current=1,r(t.notifications),a(t.unreadCount),l(t.hasMore),s(`idle`)}catch{s(`error`)}},[e]);return(0,U.useEffect)(()=>{h()},[h]),(0,U.useEffect)(()=>{if(!t||t<=0)return;let e=setInterval(()=>void h(),t*1e3);return()=>clearInterval(e)},[h,t]),{notifications:n,unreadCount:i,status:o,hasMore:c,open:u,setOpen:d,loadMore:(0,U.useCallback)(()=>{if(m.current||!p.current)return;m.current=!0;let t=f.current+1;pl(e,t).then(e=>{f.current=t,r(t=>[...t,...e.notifications]),l(e.hasMore)}).catch(()=>void h()).finally(()=>{m.current=!1})},[e,h]),markRead:(0,U.useCallback)(t=>{r(e=>yl(e,t)),a(e=>Math.max(0,e-1)),ml(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),markAllRead:(0,U.useCallback)(()=>{r(e=>e.map(e=>({...e,isRead:!0}))),a(0),hl(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),dismiss:(0,U.useCallback)(t=>{r(e=>bl(e,t)),gl(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),clearAll:(0,U.useCallback)(()=>{r([]),a(0),_l(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),receive:(0,U.useCallback)(e=>{r(t=>{let n=vl(t,e);return n!==t&&a(e=>e+1),n})},[])}}function Sl(){let{t:e}=z(`lattice`);return(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-lt-muted-fg`,children:[(0,G.jsx)(_,{name:`bell`,className:`size-lt-icon-lg`}),(0,G.jsx)(`p`,{className:`text-sm`,children:e(`notifications.empty`,`No notifications yet`)})]})}var Cl={primary:`text-lt-primary`,secondary:`text-lt-muted-fg`,success:`text-lt-success`,info:`text-lt-info`,warning:`text-lt-warning`,danger:`text-lt-danger`};function wl({notification:e,onMarkRead:t,onDismiss:n}){let{t:r}=z(`lattice`),i=ie(e.title,r),a=ie(e.body,r),o=(0,G.jsxs)(G.Fragment,{children:[i?(0,G.jsx)(`p`,{className:`truncate text-sm font-medium text-lt-fg`,children:i}):null,a?(0,G.jsx)(`p`,{className:`text-sm text-lt-muted-fg`,children:a}):null]});return(0,G.jsxs)(`li`,{className:p(`flex gap-3 px-3 py-3`,!e.isRead&&`bg-lt-muted/40`),"data-test":`notification`,children:[e.icon?(0,G.jsx)(K,{icon:e.icon,className:p(`mt-0.5 size-lt-icon-md`,e.variant?Cl[e.variant]:void 0)}):null,(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e.href?(0,G.jsx)(l,{href:e.href,className:`block`,"data-test":`notification-link`,onClick:()=>t(e.id),children:o}):o,e.actions.length>0?(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.actions.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??e.id??`action-${t}`))}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.isRead?null:(0,G.jsx)(`button`,{type:`button`,className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:()=>t(e.id),children:r(`notifications.mark-read`,`Mark read`)}),(0,G.jsx)(`button`,{type:`button`,"aria-label":r(`notifications.dismiss`,`Dismiss`),className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:()=>n(e.id),children:r(`notifications.dismiss`,`Dismiss`)})]})]})}function Tl({notifications:e,status:t,hasMore:n,onMarkRead:r,onDismiss:i,onLoadMore:a}){let{t:o}=z(`lattice`);return t===`loading`&&e.length===0?(0,G.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,G.jsx)(vr,{className:`h-12 w-full`}),(0,G.jsx)(vr,{className:`h-12 w-full`}),(0,G.jsx)(vr,{className:`h-12 w-full`})]}):e.length===0?(0,G.jsx)(Sl,{}):(0,G.jsxs)(`div`,{className:`max-h-96 overflow-y-auto`,children:[(0,G.jsx)(`ul`,{className:`divide-y divide-lt-border`,children:e.map(e=>(0,G.jsx)(wl,{notification:e,onMarkRead:r,onDismiss:i},e.id))}),n?(0,G.jsx)(`button`,{type:`button`,className:`w-full py-2 text-sm text-lt-muted-fg hover:text-lt-fg`,onClick:a,children:o(`notifications.load-more`,`Load more`)}):null]})}var El=(0,U.lazy)(()=>jt(()=>import(`./notifications-echo-BLO9_g1w.js`).then(e=>({default:e.NotificationsEcho})),__vite__mapDeps([24,25,1,2]),import.meta.url)),Dl=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){console.warn(`[lattice] The notifications bell declares a realtime channel but Echo is unavailable. Install @laravel/echo-react and call configureEcho().`)}render(){return this.state.failed?null:this.props.children}},Ol={name:`lattice/notifications`,components:{notifications:W(({node:e})=>{let{t}=z(`lattice`),n=xl({endpoint:e.props.endpoint,pollingInterval:e.props.pollingInterval}),r=t(`notifications.label`,`Notifications`),i=(0,G.jsxs)(`span`,{className:`relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted`,children:[(0,G.jsx)(_,{name:`bell`,className:`size-lt-icon-md`}),n.unreadCount>0?(0,G.jsx)(`span`,{"data-test":`notifications-badge`,className:`absolute -right-0.5 -top-0.5 inline-flex min-w-4 items-center justify-center rounded-lt-full bg-lt-danger px-1 py-0 text-[10px] font-medium text-lt-danger-fg`,children:n.unreadCount}):null]}),a=(0,G.jsxs)(`div`,{className:`w-80`,"data-test":`notifications-panel`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-lt-border px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:t(`notifications.heading`,`Notifications`)}),n.unreadCount>0?(0,G.jsx)(`button`,{type:`button`,className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:n.markAllRead,children:t(`notifications.mark-all-read`,`Mark all read`)}):null]}),(0,G.jsx)(Tl,{notifications:n.notifications,status:n.status,hasMore:n.hasMore,onMarkRead:n.markRead,onDismiss:n.dismiss,onLoadMore:n.loadMore})]});return(0,G.jsxs)(G.Fragment,{children:[e.props.channel?(0,G.jsx)(Dl,{children:(0,G.jsx)(U.Suspense,{fallback:null,children:(0,G.jsx)(El,{channel:e.props.channel,onReceive:e=>n.receive(e)})})}):null,e.props.slideOut?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,onClick:()=>n.setOpen(!0),children:i}),(0,G.jsx)(Ln,{open:n.open,onOpenChange:n.setOpen,children:(0,G.jsxs)(Vn,{"aria-describedby":void 0,className:`p-0`,placement:`end`,width:`sm`,children:[(0,G.jsx)(zn,{className:`sr-only`,children:r}),a]})})]}):(0,G.jsxs)(We,{open:n.open,onOpenChange:n.setOpen,children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,children:i})}),(0,G.jsx)(Ke,{align:`end`,className:`p-0`,children:a})]})]})})}};function kl(e){return e==null?``:String(e)}function Al({props:e}){let{t}=z(`lattice`),[n,i]=(0,U.useState)([]),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{if(!e.remote||!e.dataEndpoint){i([]),c(!1);return}let t=!1;return o(null),c(!0),gr(e.dataEndpoint,{remote:e.remote}).then(e=>{t||i(e.data??[])}).catch(e=>{t||o(e instanceof Error?e.message:String(e))}).finally(()=>{t||c(!1)}),()=>{t=!0}},[e.dataEndpoint,e.remote]),a?(0,G.jsx)(`div`,{className:`rounded-lt border border-lt-danger/40 p-3 text-sm`,children:a}):s||!e.remote?(0,G.jsx)(`div`,{className:`rounded-lt border border-lt-border p-3 text-sm`,children:t(`common.remote.data-list.loading`,`Loading...`)}):(0,G.jsxs)(`div`,{className:`rounded-lt border border-lt-border bg-lt-bg`,children:[(0,G.jsx)(`div`,{className:`border-b border-lt-border px-3 py-2 text-sm font-medium`,children:t(`common.remote.data-list.title`,`Remote data`)}),(0,G.jsxs)(`div`,{className:`divide-y divide-lt-border`,children:[n.map((t,n)=>(0,G.jsx)(`div`,{className:`px-3 py-2`,children:(0,G.jsx)(Y,{nodes:r(e.schema,t)})},kl(t.id)||n)),n.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:e.emptyLabel??t(`common.remote.data-list.empty`,`No data`)}):null]})]})}var jl={components:{"remote.data-list":W(({node:e})=>(0,G.jsx)(Al,{props:{...e.props,schema:e.schema}}))},name:`lattice/remote`};function Ml(e){return e==null||e===``}function Nl(e){return Ml(e)?!0:Array.isArray(e)?e.every(Nl):typeof e==`object`&&e?Object.values(e).every(Nl):!1}function Pl(e){return!Nl(e)}function Fl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Il(e){return Fl(e)?e:{}}function Ll(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.field==`string`&&typeof e.operator==`string`&&typeof e.value==`string`):[]}function Rl(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`key`in e&&`props`in e&&typeof e.key==`string`&&typeof e.props==`object`&&e.props!==null&&typeof e.props.label==`string`):[]}function zl(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}var Bl={mode:`none`,currentPage:null,lastPage:null,perPage:null,total:null,from:null,to:null,hasMore:!1,nextPage:null};function Vl(e){return typeof e!=`object`||!e||Array.isArray(e)?Bl:e}function Hl(e){if(typeof e!=`object`||!e||Array.isArray(e))return{filters:[],sorts:[],page:1,perPage:25,tableFilters:{},tableFilterIndicators:[],search:``,mode:null};let t=e;return{filters:Ll(t.filters),sorts:Array.isArray(t.sorts)?t.sorts:[],page:typeof t.page==`number`?t.page:1,perPage:typeof t.perPage==`number`?t.perPage:25,tableFilters:Kl(t.tableFilters),tableFilterIndicators:ql(t.tableFilterIndicators),search:typeof t.search==`string`?t.search:``,mode:Wl(t.mode)}}var Ul=new Set([`none`,`simple`,`table`,`infinite`]);function Wl(e){return typeof e==`string`&&Ul.has(e)?e:null}function Gl(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`||e===`infinite`):[]}function Kl(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`object`&&e[1]!==null&&!Array.isArray(e[1])))}function ql(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.filter==`string`&&typeof e.label==`string`&&typeof e.value==`string`):[]}function Jl(e,t){let n=e.id??e.uuid??e.key??t;return String(n)}function Yl(e){return Array.isArray(e.actions)?e.actions:[]}function Xl(e){let t=e.detail;return typeof t==`object`&&t&&!Array.isArray(t)?t:null}function Zl(e,t){return e.sorts.find(e=>e.key===t.key)}function Ql(e){if(e?.direction===`asc`)return`ascending`;if(e?.direction===`desc`)return`descending`}function $l(e,t){let n=new URL(e,window.location.origin);return t.filters.length>0&&n.searchParams.set(`filter`,ou(t)),t.sorts.length>0&&n.searchParams.set(`sort`,su(t)),t.search!==``&&n.searchParams.set(`q`,t.search),eu(n,t.tableFilters),n.searchParams.set(`page`,String(t.page)),n.searchParams.set(`per_page`,String(t.perPage)),t.mode!=null&&n.searchParams.set(`mode`,t.mode),`${n.pathname}${n.search}`}function eu(e,t){for(let[n,r]of Object.entries(tu(t)))iu(e,`tf[${n}]`,r)}function tu(e){let t={};for(let[n,r]of Object.entries(e)){let e=nu(r);e!==void 0&&(t[n]=e)}return t}function nu(e){if(Ml(e)||Array.isArray(e)||typeof e!=`object`)return;let t=Object.entries(e).map(([e,t])=>[e,ru(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}function ru(e){if(!Ml(e)){if(Array.isArray(e)){let t=e.map(ru).filter(e=>e!==void 0);return t.length>0?t:void 0}if(typeof e==`object`){if(e===null)return;let t=Object.entries(e).map(([e,t])=>[e,ru(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}return String(e)}}function iu(e,t,n){if(Array.isArray(n)){for(let r of n)iu(e,`${t}[]`,r);return}if(typeof n==`object`&&n){for(let[r,i]of Object.entries(n))iu(e,`${t}[${r}]`,i);return}e.searchParams.append(t,String(n))}function au(e){let t={};e.filters.length>0&&(t.filter=ou(e)),e.sorts.length>0&&(t.sort=su(e));let n=tu(e.tableFilters);return Object.keys(n).length>0&&(t.tf=n),e.search!==``&&(t.q=e.search),t}function ou(e){return e.filters.map(e=>`${e.field}:${e.operator}:${encodeURIComponent(e.value)}`).join(`,`)}function su(e){return e.sorts.map(e=>e.direction===`desc`?`-${e.key}`:e.key).join(`,`)}var cu={contains:`contains`,starts_with:`starts with`,ends_with:`ends with`,eq:`equals`,neq:`not equals`,gt:`>`,gte:`≥`,lt:`<`,lte:`≤`,in:`in`,not_in:`not in`,before:`before`,after:`after`,empty:`is empty`,filled:`is not empty`},lu=new Set([`empty`,`filled`]);function uu(e){return B(`lattice`,`table.operators.${e}`,cu[e]??e)}function du(e){return e===`desc`?`descending`:`ascending`}function fu(e,t){if(!t.props.sortable)return e;let n=e.find(e=>e.key===t.key),r=e.filter(e=>e.key!==t.key);return n?n.direction===`asc`?[...r,{key:t.key,direction:`desc`}]:r:[...e,{key:t.key,direction:`asc`}]}function pu(e,t){if(t<=5)return Array.from({length:t},(e,t)=>t+1);let n=Math.max(1,Math.min(e-2,t-4));return Array.from({length:5},(e,t)=>n+t)}function mu(e){return e.map(e=>({key:e.key,label:e.props.label,width:hu(e)}))}function hu(e){return e.props.width??`md`}function gu(e,t,n=!1){return{leadingTracks:[...n?[`2.5rem`]:[],...t?[`3rem`]:[]],trailingTracks:e?[`10rem`]:[]}}function _u(e){let t=(0,U.useMemo)(()=>Rl(e.props?.columns),[e.props?.columns]),n=typeof e.props?.endpoint==`string`?e.props.endpoint:null,r=typeof e.props?.ref==`string`?e.props.ref:``,i=e.props?.lazy===!0,a=(0,U.useMemo)(()=>Hl(e.props?.query),[e.props?.query]),o=(0,U.useMemo)(()=>zl(e.props?.data),[e.props?.data]),s=(0,U.useMemo)(()=>Vl(e.props?.pagination),[e.props?.pagination]),[c,l]=(0,U.useState)(o),[u,d]=(0,U.useState)(s),[f,p]=(0,U.useState)(a),[m,h]=(0,U.useState)(i),[g,_]=(0,U.useState)(!i),v=(0,U.useRef)(null),y=u.currentPage??f.page,b=(u.mode??`table`)===`infinite`,x=(0,U.useCallback)(async(e,t=!1)=>{if(n){h(!0);try{let i=await lr($l(n,e),{ref:r}),a=Hl(i.query),o=zl(i.data);l(e=>t?[...e,...o]:o),d(Vl(i.pagination)),p(a),_(!0)}finally{h(!1)}}},[n,r]);function S(e){x({...f,page:1,sorts:fu(f.sorts,e)})}function C(e){x({...f,page:1,sorts:f.sorts.filter(t=>t.key!==e.key)})}function w(e){let t={...f,filters:e,page:1};p(t),x(t)}function T(e){w([...f.filters,e])}function E(e,t){w(f.filters.map((n,r)=>r===e?t:n))}function D(e){w(f.filters.filter((t,n)=>n!==e))}function O(e,t){w([...f.filters.filter(t=>t.field!==e),...t])}function k(e,t){let n={...f.tableFilters};Nl(t)||!Fl(t)?delete n[e]:n[e]=t;let r={...f,tableFilters:n,tableFilterIndicators:f.tableFilterIndicators.filter(t=>t.filter!==e),page:1};p(r),x(r)}function A(){let e={...f,filters:[],tableFilters:{},tableFilterIndicators:[],search:``,page:1};p(e),x(e)}function j(e){let t={...f,search:e,page:1};p(t),x(t)}let M=(0,U.useCallback)(async(e,t,i)=>{if(!n)return[];let a=new URL(n,window.location.origin);a.searchParams.set(`_sub`,`search`),a.searchParams.set(`_target`,e),a.searchParams.set(`_q`,t);let o=await J(`${a.pathname}${a.search}`,{ref:r,signal:i,throwOnError:!1});return o.ok?(await o.json()).options??[]:[]},[n,r]);function N(e){x({...f,page:e})}function P(e){let t=s.mode??`table`,n={...f,perPage:e===`infinite`?f.perPage:e,mode:e===`infinite`?`infinite`:t===`infinite`?`table`:null,page:1};p(n),x(n)}let I=(0,U.useCallback)(()=>{m||!u.hasMore||x({...f,page:u.nextPage??y+1},!0)},[y,x,u.hasMore,u.nextPage,m,f]);return(0,U.useEffect)(()=>{l(o),d(s),p(a),h(i),_(!i)},[o,s,a,i]),(0,U.useEffect)(()=>{!i||g||x(f)},[g,i,x,f]),Qt(F.reloadComponent,t=>{t.detail?.component===e.id&&x(f)}),(0,U.useEffect)(()=>{if(!b||!u.hasMore||m||!v.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&I()},{rootMargin:`240px`});return e.observe(v.current),()=>e.disconnect()},[b,I,u.hasMore,m]),{columns:t,rows:c,pagination:u,query:f,filters:f.filters,tableFilters:f.tableFilters,search:f.search,addFilter:T,updateFilter:E,removeFilter:D,replaceColumnFilters:O,setTableFilter:k,resetFilters:A,setSearch:j,searchFilterOptions:M,processing:m,hasLoaded:g,infiniteLoaderRef:v,sort:S,clearSort:C,goToPage:N,setPerPage:P,loadMore:I}}function vu(e){let[t,n]=(0,U.useState)(()=>new Set),[r,i]=(0,U.useState)(!1),a=e.join(` `);(0,U.useEffect)(()=>{n(new Set),i(!1)},[a]);let o=(0,U.useCallback)(e=>{i(!1),n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,U.useCallback)(()=>{i(!1),n(t=>t.size===e.length?new Set:new Set(e))},[e]),c=(0,U.useCallback)(()=>i(!0),[]),l=(0,U.useCallback)(()=>{i(!1),n(new Set)},[]),u=e.filter(e=>t.has(e)),d=e.length>0&&u.length===e.length;return{selectedKeys:u,allMatching:r,allVisibleSelected:d,allSelected:r||d,active:r||u.length>0,isSelected:e=>r||t.has(e),toggle:o,toggleAll:s,selectAllMatching:c,clear:l}}function yu({columns:e,storageKey:t}){let n=(0,U.useMemo)(()=>e.filter(e=>e.props.toggleable),[e]),r=(0,U.useMemo)(()=>n.map(e=>e.key),[n]),[i,a]=Ai(t??``,{},{enabled:!!t,parse:e=>xu(e,r),serialize:e=>Su(e,r)}),o=(0,U.useCallback)(e=>e.props.toggleable?i[e.key]??!e.props.hiddenByDefault:!0,[i]),s=(0,U.useMemo)(()=>e.filter(e=>o(e)),[e,o]),c=(0,U.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[a]),l=(0,U.useCallback)(()=>a({}),[a]),u=n.length>0;return{hasHidden:n.some(e=>!o(e)),hasToggleableColumns:u,isVisible:o,resetVisibility:l,setColumnVisible:c,toggleableColumns:n,visibleColumns:s}}function bu(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))n.has(t)&&typeof i==`boolean`&&(r[t]=i);return r}function xu(e,t){let n=JSON.parse(e)?.overrides;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`unexpected stored column visibility shape`);return bu(n,t)}function Su(e,t){let n=bu(e,t);return Object.keys(n).length===0?null:JSON.stringify({overrides:n})}function Cu(){let[e,t]=(0,U.useState)(()=>new Set);return{isExpanded:(0,U.useCallback)(t=>e.has(t),[e]),toggle:(0,U.useCallback)(e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[])}}var wu={start:`text-start`,center:`text-center`,end:`text-end`},Tu={start:`justify-start`,center:`justify-center`,end:`justify-end`},Eu={start:`justify-items-start`,center:`justify-items-center`,end:`justify-items-end`},Du=e=>wu[e],Ou=e=>Tu[e],ku=e=>Eu[e];function Au(e){return(e??[]).flatMap(e=>{if(e.type!==`action`&&e.type!==`action.bulk`)return[];let t=e.props;return t?.endpoint?[{id:e.id??``,label:t.label??B(`lattice`,`common.action.run`,`Run action`),method:t.method??`post`,endpoint:t.endpoint,ref:t.ref??``,variant:t.variant,emphasis:t.emphasis,confirmation:t.confirmation,form:t.form,modalSide:t.modalSide,modalWidth:t.modalWidth}]:[]})}function ju({actions:e,selectedKeys:t,allMatching:n,total:r,query:i,canSelectAllMatching:a,onSelectAllMatching:o,onCompleted:s}){let{t:c}=z(`lattice`),[l,u]=(0,U.useState)(!1),d=re(),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),g=()=>n?{allMatching:!0,...i}:{selected:t};async function _(e){u(!0);let t=await _r(()=>J(e.endpoint,{method:e.method,ref:e.ref,body:JSON.stringify(g()),throwOnError:!1}),d);u(!1),t&&(p(null),s())}function v(e){if(e.form){h(e);return}if(e.confirmation){p(e);return}_(e)}let y=n?r??t.length:t.length;return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-lt-border bg-lt-muted/50 p-4 text-sm`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n?c(`table.bulk.all-selected`,`All {{count}} selected`,{count:y}):c(`table.bulk.selected`,`{{count}} selected`,{count:y})}),a&&(0,G.jsx)(`button`,{type:`button`,"data-test":`bulk-select-all-matching`,className:`font-medium text-lt-primary underline underline-offset-2`,onClick:o,children:c(`table.bulk.select-all-matching`,`Select all {{total}} matching`,{total:r})}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>(0,G.jsxs)(x,{type:`button`,"data-test":k(`bulk-action`,e.id),variant:e.variant,emphasis:e.emphasis,disabled:l,onClick:()=>v(e),children:[l&&(0,G.jsx)(rn,{}),e.label]},e.id))}),f?.confirmation&&(0,G.jsx)(Un,{title:f.confirmation.title??f.label,description:f.confirmation.description??void 0,confirmLabel:f.confirmation.confirmLabel??f.label,cancelLabel:f.confirmation.cancelLabel??c(`common.cancel`,`Cancel`),confirmVariant:f.variant,confirmEmphasis:f.emphasis,processing:l,onConfirm:()=>void _(f),onCancel:()=>p(null)}),m?.form&&(0,G.jsx)(Jr,{cancelLabel:m.confirmation?.cancelLabel??c(`common.cancel`,`Cancel`),componentRef:m.ref,description:m.confirmation?.description??void 0,endpoint:m.endpoint,extraData:g(),formNode:m.form,method:m.method,onClose:()=>h(null),onSuccess:()=>{h(null),s()},placement:m.modalSide??`center`,submitLabel:m.confirmation?.confirmLabel??m.label,title:m.confirmation?.title??m.label,width:m.modalWidth??void 0})]})}function Mu(e){return e===!0||e===1||e===`1`||e===`true`}function Nu({filter:e,value:t,processing:n,bare:r=!1,onChange:i,onSearch:a}){let{t:o}=z(`lattice`),s=e.schema??[];return s.length===0?(0,G.jsx)(Iu,{filter:e,value:t,processing:n,onChange:i}):(0,G.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(Pu,{filter:e,schema:s,value:t,processing:n,bare:r,onChange:i,onSearch:a})}),Pl(t)&&(0,G.jsx)(xt,{size:`md`,icon:`x`,label:o(`table.filter.clear`,`Clear {{label}} filter`,{label:e.props.label}),disabled:n,onClick:()=>i(void 0)})]})}function Pu({filter:e,schema:t,value:n,processing:r,bare:i,onChange:a,onSearch:o}){let s=(0,U.useMemo)(()=>Il(n),[n]),c=(0,U.useMemo)(()=>({action:`#`,clearErrors:()=>{},componentId:`table-filter-${e.key}`,componentRef:``,errors:{},fieldIdPrefix:`table-filter-${e.key}`,fieldLabels:{},precognitive:!1,processing:r,searchOptions:(e,t,n,r)=>o?o(e,t,r):Promise.resolve([]),touch:()=>{},validate:()=>{},validateFields:()=>{},validating:!1}),[e.key,o,r]),l=(0,G.jsx)(`div`,{"aria-disabled":r,className:p(`grid gap-3`,r&&`pointer-events-none opacity-60`),children:(0,G.jsx)(Y,{nodes:t})});return(0,G.jsx)(Ne,{value:c,children:(0,G.jsx)(xe,{value:{markUserEdit:()=>{}},children:(0,G.jsx)(Dr,{nodes:{},children:(0,G.jsx)(pt,{initial:s,children:(0,G.jsx)(Fu,{onChange:a,children:i?(0,G.jsx)(Je,{children:l}):l})})})})})}function Fu({children:e,onChange:t}){let n=He(),r=je(),i=(0,U.useRef)(n);i.current=n;let a=(0,U.useCallback)((e,n)=>{let a=typeof n==`function`?n(Se(i.current,e)):n,o=Te(i.current,e,a);i.current=o,r(e,a),t(o)},[t,r]),o=(0,U.useMemo)(()=>({blur:()=>{},change:a,commit:a}),[a]);return(0,G.jsx)(qe,{value:o,children:e})}function Iu({filter:e,value:t,processing:n,onChange:r}){let i=Mu(Il(t).value);return(0,G.jsxs)(`label`,{className:`flex h-lt-control-md cursor-pointer items-center gap-2 text-sm`,children:[(0,G.jsx)(ba,{"aria-label":e.props.label,"data-test":`table-filter-${e.key}`,checked:i,disabled:n,onCheckedChange:e=>r(e===!0?{value:`1`}:void 0)}),(0,G.jsx)(`span`,{children:e.props.label})]})}function Lu({type:e,label:t,value:n,processing:r,withSearchIcon:i=!1,grouped:a=!1,ariaLabel:o,testId:s,onCommit:c,onClear:l}){let{t:u}=z(`lattice`),[d,f]=(0,U.useState)(n),m=o??u(`table.filter.filter-by`,`Filter {{label}}`,{label:t}),h=a?`rounded-r-none`:``;return(0,U.useEffect)(()=>{f(n)},[n]),e===`boolean`?(0,G.jsxs)(Et,{density:`compact`,"aria-label":m,"data-test":s,className:h,disabled:r,value:n,onChange:e=>c(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:u(`table.filter.all`,`All`)}),(0,G.jsx)(`option`,{value:`true`,children:u(`table.filter.true`,`True`)}),(0,G.jsx)(`option`,{value:`false`,children:u(`table.filter.false`,`False`)})]}):e===`date`?(0,G.jsx)(bt,{type:`date`,density:`compact`,"aria-label":m,"data-test":s,className:h,disabled:r,value:d,onChange:e=>{f(e.target.value),c(e.target.value)}}):(0,G.jsxs)(`div`,{className:`relative flex w-full min-w-0 items-center`,children:[i&&(0,G.jsx)(_,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2 size-lt-icon-md text-lt-muted-fg`}),(0,G.jsx)(bt,{type:e===`number`?`number`:`text`,density:`compact`,"aria-label":m,"data-test":s,className:p(h,i&&`pl-8`,l&&`pr-8`),disabled:r,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c(d)},onBlur:()=>{d!==n&&c(d)}}),l&&d!==``&&(0,G.jsx)(xt,{size:`xs`,icon:`x`,label:u(`table.filter.clear`,`Clear {{label}} filter`,{label:t}),"data-test":s?`${s}-clear`:void 0,className:`absolute right-1 size-6`,disabled:r,onClick:l})]})}function Ru({column:e,clauses:t,processing:n,onAdd:r,onUpdate:i,onRemove:a,onReplace:o,onSearch:s}){let{t:c}=z(`lattice`),{filter:l,label:u}=e.props,d=u??e.key;if(!l)return null;if(l.control===`filter.select`)return(0,G.jsx)(Bu,{column:e,clauses:t,processing:n,onReplace:o,onSearch:s});let f=l.type??`text`,p=l.operators??[],m=l.defaultOperator??p[0]??`eq`,h=t.find(e=>e.clause.operator===m)??t[0];function g(t){if(t===``){h&&a(h.index);return}h?i(h.index,{...h.clause,value:t}):r({field:e.key,operator:m,value:t})}return(0,G.jsxs)(`div`,{className:`flex min-w-0 max-w-80 items-stretch`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(Lu,{type:f,label:d,value:h?.clause.value??``,processing:n,withSearchIcon:f===`text`||f===`number`,grouped:!0,testId:`filter-${e.key}-value`,onCommit:g,onClear:h?()=>a(h.index):void 0})}),(0,G.jsxs)(We,{children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(xt,{emphasis:`segmented`,size:`md`,icon:`filter`,label:c(`table.filter.column-filters`,`{{label}} filters`,{label:d}),"data-test":`filter-${e.key}`,disabled:n,children:t.length>0&&(0,G.jsx)(`span`,{className:`absolute -right-1.5 -top-1.5 inline-flex size-4 items-center justify-center rounded-full bg-lt-primary text-xs font-medium text-lt-primary-fg`,children:t.length})})}),(0,G.jsx)(Ke,{align:`start`,className:`w-80 p-4`,children:(0,G.jsx)(Wu,{column:e,clauses:t,operators:p,defaultOperator:m,processing:n,onAdd:r,onUpdate:i,onRemove:a})})]})]})}function zu(e){return Array.isArray(e)?e.join(`,`):typeof e==`string`?e:``}function Bu({column:e,clauses:t,processing:n,onReplace:r,onSearch:i}){let{filter:a,label:o}=e.props,s=o??e.key;if(!a)return null;let c=a.multiple,l=a.defaultOperator,u=a.clauseOptions??[],d=Hu(t.map(e=>e.clause),u),f=t.find(e=>e.clause.operator===l)??t[0],p=d?d.value:c?f?.clause.value?f.clause.value.split(`,`):[]:f?.clause.value??``,m={key:e.key,type:`filter.select`,props:{label:s,options:a.options,multiple:c,searchable:a.searchable,placeholder:null},schema:[{type:`field.select`,key:e.key,props:{name:`value`,label:s,options:a.options,multiple:c,searchable:a.searchable,placeholder:null}}]};function h(t){let n=zu(Il(t).value);if(n===``){r(e.key,[]);return}let i=u.find(e=>e.value===n);if(i){r(e.key,Vu(e.key,i));return}r(e.key,[{field:e.key,operator:l,value:n}])}return(0,G.jsx)(Nu,{filter:m,value:{value:p},processing:n,bare:!0,onChange:h,onSearch:i?(e,t,n)=>i(t,n):void 0})}function Vu(e,t){return t.clauses.map(t=>({field:e,operator:t.operator,value:t.value}))}function Hu(e,t){return t.find(t=>Uu(e,Vu(``,t)))}function Uu(e,t){return e.length===t.length&&t.every(t=>e.some(e=>e.operator===t.operator&&e.value===t.value))}function Wu({column:e,clauses:t,operators:n,defaultOperator:r,processing:i,onAdd:a,onUpdate:o,onRemove:s}){let{t:c}=z(`lattice`),l=e.props.filter?.type??`text`,[u,d]=(0,U.useState)(r),[f,p]=(0,U.useState)(t.length===0);return(0,G.jsxs)(`div`,{className:`grid gap-3`,children:[t.map(t=>(0,G.jsx)(Gu,{column:e,type:l,operators:n,clause:t.clause,processing:i,onOperator:e=>o(t.index,{...t.clause,operator:e}),onValue:e=>e===``?s(t.index):o(t.index,{...t.clause,value:e}),onRemove:()=>s(t.index)},t.index)),f&&(0,G.jsx)(Gu,{column:e,type:l,operators:n,clause:{field:e.key,operator:u,value:``},processing:i,onOperator:t=>{if(lu.has(t)){a({field:e.key,operator:t,value:``}),d(r),p(!1);return}d(t)},onValue:t=>{t!==``&&(a({field:e.key,operator:u,value:t}),d(r),p(!1))},onRemove:()=>p(!1)}),(0,G.jsx)(`div`,{className:`border-t border-lt-border pt-3`,children:(0,G.jsx)(x,{variant:`secondary`,icon:`plus`,"data-test":`filter-${e.key}-add`,className:`w-full`,disabled:i,onClick:()=>p(!0),children:c(`table.filter.add`,`Add filter`)})})]})}function Gu({column:e,type:t,operators:n,clause:r,processing:i,onOperator:a,onValue:o,onRemove:s}){let{t:c}=z(`lattice`),l=e.props.label??e.key,u=lu.has(r.operator);return(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.length>1?(0,G.jsx)(Et,{density:`compact`,"aria-label":c(`table.filter.operator`,`{{label}} operator`,{label:l}),"data-test":`filter-${e.key}-operator`,className:`flex-1`,disabled:i,value:r.operator,onChange:e=>a(e.target.value),children:n.map(e=>(0,G.jsx)(`option`,{value:e,children:uu(e)},e))}):(0,G.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:uu(r.operator)}),(0,G.jsx)(x,{emphasis:`outline`,size:`icon`,icon:`trash-2`,"aria-label":c(`table.filter.remove`,`Remove {{label}} filter`,{label:l}),"data-test":`filter-${e.key}-remove`,disabled:i,onClick:s})]}),!u&&(0,G.jsx)(Lu,{type:t,label:l,ariaLabel:c(`table.filter.value`,`{{label}} filter value`,{label:l}),value:r.value,processing:i,onCommit:o,onClear:()=>o(``)})]})}function Ku({sort:e}){return e?.direction===`asc`?(0,G.jsx)(_,{name:`arrow-up`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):e?.direction===`desc`?(0,G.jsx)(_,{name:`arrow-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):(0,G.jsx)(_,{name:`chevrons-up-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0 opacity-50`})}function qu({bottomBordered:e,column:t,processing:n,resizeHandleProps:r,sort:i,query:a}){let o=Zl(a,t),{t:s}=z(`lattice`),{align:c,label:l,sortable:u}=t.props;return(0,G.jsxs)(`div`,{"aria-sort":Ql(o),className:p(`relative min-w-0 bg-lt-muted/50 px-4 py-3 pr-5 align-middle font-semibold text-lt-fg`,e&&`border-b border-lt-border`,Du(c)),role:`columnheader`,children:[u?(0,G.jsxs)(`button`,{type:`button`,"aria-label":s(`table.sort.column`,`Sort {{label}}`,{label:l}),className:p(`flex w-full items-center gap-1.5 font-semibold`,Ou(c)),"data-test":`sort-${t.key}`,disabled:n,onClick:()=>i(t),children:[(0,G.jsx)(`span`,{className:p(`min-w-0 flex-1 truncate`,Du(c)),children:l}),(0,G.jsx)(Ku,{sort:o})]}):(0,G.jsx)(`span`,{className:p(`block truncate`,Du(c)),children:l}),r&&(0,G.jsx)(`div`,{...r})]})}function Ju({columns:e,hasHidden:t,isVisible:n,onReset:r,onToggle:i,processing:a,visibleColumnCount:o}){let{t:s}=z(`lattice`),c=s(`table.columns.label`,`Columns`);return(0,G.jsxs)(We,{children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(xt,{size:`sm`,icon:`columns-3`,label:c,"data-test":`table-columns-menu`,disabled:a})}),(0,G.jsx)(Ke,{align:`end`,className:`w-64 p-4`,children:(0,G.jsxs)(`div`,{className:`grid gap-3`,children:[e.map(e=>{let t=n(e),r=t&&o<=1;return(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-base text-lt-fg`,children:[(0,G.jsx)(ba,{"data-test":`table-column-toggle-${e.key}`,checked:t,disabled:r,onCheckedChange:t=>i(e.key,t===!0)}),(0,G.jsx)(`span`,{children:e.props.label??e.key})]},e.key)}),t&&(0,G.jsx)(`button`,{type:`button`,"data-test":`table-columns-reset`,className:`mt-1 justify-self-start text-sm text-lt-muted-fg hover:text-lt-fg`,onClick:r,children:s(`table.columns.reset`,`Reset`)})]})})]})}function Yu({clauses:e,columnsByKey:t,indicators:n,processing:r,onRemoveClause:i,onChange:a,onReset:o}){let{t:s}=z(`lattice`);return e.length===0&&n.length===0?null:(0,G.jsx)(`div`,{className:`border-b border-lt-border px-4 py-3`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[e.map((e,n)=>{let a=t.get(e.field)?.props.label??e.field,o=lu.has(e.operator);return(0,G.jsx)(Xu,{label:`${a} ${uu(e.operator)}`,value:o?``:e.value,removeTestId:`filter-chip-${e.field}-remove`,removeLabel:s(`table.filter.remove`,`Remove {{label}} filter`,{label:a}),processing:r,onRemove:()=>i(n)},`${e.field}-${e.operator}-${n}`)}),n.map(e=>(0,G.jsx)(Xu,{label:e.label,value:e.value,removeTestId:`table-filter-chip-${e.filter}-remove`,removeLabel:s(`table.filter.remove`,`Remove {{label}} filter`,{label:e.label}),processing:r,onRemove:()=>a(e.filter,void 0)},`${e.filter}:${e.label}:${e.value}`)),(0,G.jsx)(`button`,{type:`button`,"data-test":`table-filters-reset`,className:`text-lt-muted-fg underline-offset-2 hover:underline disabled:text-lt-disabled-fg`,disabled:r,onClick:o,children:s(`table.filter.reset-all`,`Reset all`)})]})})}function Xu({label:e,value:t,removeTestId:n,removeLabel:r,processing:i,onRemove:a}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lt-sm bg-lt-muted px-2 py-1`,children:[(0,G.jsx)(`span`,{children:t===``?(0,G.jsx)(`span`,{className:`font-semibold`,children:e}):(0,G.jsxs)(G.Fragment,{children:[`${e}: `,(0,G.jsx)(`span`,{className:`font-semibold`,children:t})]})}),(0,G.jsx)(xt,{size:`xs`,icon:`x`,label:r,"data-test":n,disabled:i,onClick:a})]})}function Zu({filters:e,values:t,processing:n,onChange:r,onSearch:i}){let{t:a}=z(`lattice`),o=e.filter(e=>Pl(t[e.key])),s=a(`table.filter.filters`,`Filters`);return(0,G.jsxs)(We,{children:[(0,G.jsx)(it,{asChild:!0,children:(0,G.jsx)(xt,{size:`sm`,icon:`filter`,label:s,"data-test":`table-filters-menu`,disabled:n,children:o.length>0&&(0,G.jsx)(`span`,{className:`absolute -right-1 -top-1 inline-flex size-3.5 items-center justify-center rounded-full bg-lt-primary text-[10px] font-medium leading-none text-lt-primary-fg`,children:o.length})})}),(0,G.jsx)(Ke,{align:`end`,className:`w-80 p-4`,children:(0,G.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,G.jsx)(`div`,{className:`grid gap-1`,children:(0,G.jsx)(Nu,{filter:e,value:t[e.key],processing:n,onChange:t=>r(e.key,t),onSearch:i?(t,n,r)=>i(`filter:${e.key}.${t}`,n,r):void 0})},e.key))})})]})}function Qu({pagination:e,currentPage:t,processing:n,mode:r,hasNextPage:i,visiblePages:a,infiniteLoaderRef:o,perPageOptions:s,perPageValue:c,onPerPage:l,onPage:u,onLoadMore:d}){let{t:f}=z(`lattice`);return(0,G.jsxs)(`div`,{"data-slot":`table-pagination`,className:`flex items-center justify-between gap-3 border-t border-lt-border p-4 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`span`,{children:e.total==null?f(`table.pagination.page`,`Page {{page}}`,{page:t}):f(`table.pagination.showing`,`Showing {{from}}-{{to}} of {{total}}`,{from:e.from??0,to:e.to??0,total:e.total})}),s.length>0&&r!==`none`&&(0,G.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.per-page`,`Rows per page`)}),(0,G.jsx)(Et,{"data-test":`pagination-per-page`,disabled:n,value:String(c),onChange:e=>l(e.target.value===`infinite`?`infinite`:Number(e.target.value)),children:s.map(e=>(0,G.jsx)(`option`,{value:String(e),children:e===`infinite`?f(`table.pagination.infinite`,`Infinite`):e},String(e)))})]})]}),r===`infinite`?(0,G.jsx)(`div`,{ref:o,className:`flex items-center gap-2`,children:e.hasMore?(0,G.jsx)(x,{emphasis:`outline`,"data-test":`pagination-load-more`,disabled:n,onClick:d,children:n?f(`table.pagination.loading`,`Loading...`):f(`table.pagination.load-more`,`Load more`)}):(0,G.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.all-loaded`,`All rows loaded`)})}):r===`simple`?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(x,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),(0,G.jsx)(x,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):r===`table`?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(x,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),a.map(e=>(0,G.jsx)(x,{emphasis:`outline`,size:`icon`,"data-test":`pagination-page-${e}`,disabled:n||e===t,"aria-current":e===t?`page`:void 0,"aria-label":f(`table.pagination.page`,`Page {{page}}`,{page:e}),onClick:()=>u(e),children:e},e)),(0,G.jsx)(x,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):null]})}function $u({columnsByKey:e,query:t,processing:n,onClear:r}){let{t:i}=z(`lattice`);return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 border-b border-lt-border px-4 py-2.5 text-sm`,children:t.sorts.map((t,a)=>{let o=e.get(t.key)?.props.label??t.key,s=t.direction===`desc`?`arrow-down`:`arrow-up`;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`${a+1}. ${o}`}),(0,G.jsx)(_,{name:s,role:`img`,"aria-hidden":!1,"aria-label":du(t.direction),className:`size-lt-icon-sm text-lt-muted-fg`}),(0,G.jsx)(xt,{size:`xs`,icon:`x`,label:i(`table.sort.clear`,`Clear {{label}} sort`,{label:o}),"data-test":`clear-${t.key}-sort`,disabled:n,onClick:()=>r(t)})]},t.key)})})}var ed=300;function td({value:e,onSearch:t}){let{t:n}=z(`lattice`),[r,i]=(0,U.useState)(e),a=(0,U.useRef)(e);(0,U.useEffect)(()=>{e!==a.current&&(a.current=e,i(e))},[e]);function o(e){a.current=e,t(e)}let s=Ur(o,ed);function c(e){i(e),s(e)}function l(){s.cancel(),i(``),o(``)}let u=n(`table.search.placeholder`,`Search`);return(0,G.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,G.jsx)(_,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 size-lt-icon-sm -translate-y-1/2 text-lt-muted-fg`}),(0,G.jsx)(bt,{type:`search`,"data-test":`table-search`,value:r,placeholder:u,"aria-label":u,onChange:e=>c(e.target.value),className:p(`px-8`,`[&::-webkit-search-cancel-button]:hidden`)}),r!==``&&(0,G.jsx)(xt,{size:`xs`,icon:`x`,label:n(`table.search.clear`,`Clear search`),"data-test":`table-search-clear`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,onClick:l})]})}var nd=`table.columns`;function rd(){return I(nd)}function id(e){return e}function ad(e,t,n){if(e==null)return``;let r=t?.props?.date;if(r)return le(e,r,n);let i=(t?.props)?.options?.find(t=>t.value===String(e))?.label;return i===void 0?typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e):i}function od(e,t,n){let r=e.props.link;if(!r)return null;let i=r.href??String(n??``);return i===``?null:i.replace(/\{([^}]+)\}/g,(e,r)=>encodeURIComponent(String(r===`value`?n??``:t[r]??``)))}var sd=({column:e,props:t,value:n})=>{let r=ad(n,e);return r===``?null:(0,G.jsx)(Dt,{color:t.colors?.[String(n)],children:r})},cd=({value:e})=>{let{t}=z(`lattice`),n=Mu(e);return(0,G.jsx)(`span`,{"aria-label":n?t(`common.yes`,`Yes`):t(`common.no`,`No`),role:`img`,children:(0,G.jsx)(_,{name:n?`check`:`x`,className:p(`size-lt-icon-md`,n?`text-lt-success`:`text-lt-muted-fg`)})})},ld=({props:e,value:t})=>{let n=e.icons?.[String(t)]??e.icon??void 0;if(!n)return null;let r=Tt(e.colors?.[String(t)]),i=r?St(r):void 0;return(0,G.jsx)(`span`,{"aria-label":String(t),className:p(`lt-cell-icon`,i?.className),style:i?.style,children:(0,G.jsx)(K,{className:`size-lt-icon-md`,icon:n})})};function ud({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=z(se),[c,l]=(0,U.useState)(!1),u=(0,G.jsx)(`img`,{alt:t,src:e,width:r,height:i,className:a,style:r?{width:r,height:i}:void 0});if(!n)return u;let d=s(`common.image.open-preview`,`View image`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,"data-test":o,className:`cursor-zoom-in`,"aria-label":d,onClick:()=>l(!0),children:u}),(0,G.jsx)(Ln,{open:c,onOpenChange:l,children:(0,G.jsxs)(Vn,{"aria-describedby":void 0,className:`max-h-[90vh] w-auto max-w-[90vw] border-none bg-transparent p-0 shadow-none`,children:[(0,G.jsx)(zn,{className:`sr-only`,children:t||d}),(0,G.jsx)(`img`,{alt:t,src:e,"data-slot":`image-lightbox`,className:`max-h-[90vh] max-w-[90vw] rounded-lt object-contain`}),(0,G.jsx)(Rn,{asChild:!0,children:(0,G.jsx)(x,{icon:`x`,"aria-label":s(`common.close`,`Close`),"data-test":`lightbox-close`,size:`icon`,emphasis:`ghost`,className:`absolute top-2 right-2 bg-lt-bg/80 hover:bg-lt-bg`})})]})})]})}var dd=({column:e,props:t,value:n})=>{let r=typeof n==`string`?n:``;if(r===``)return null;let i=t.size??32;return(0,G.jsx)(ud,{alt:e.props.label??``,className:p(`object-cover`,t.circular?`rounded-full`:`rounded-lt-sm`),height:i,previewable:t.previewable,src:r,testId:`preview-${e.key}`,width:i})};function fd({children:e,column:t,copyable:n,value:r}){return n?(0,G.jsx)(ms,{value:r,label:t.props.label??t.key,testId:`copy-${t.key}`,children:e}):e}function pd({column:e,copyable:t,format:n,value:r}){let{locale:i}=M();return A(r)===null?(0,G.jsx)(`span`,{children:ad(r,e)}):(0,G.jsx)(fd,{column:e,copyable:t,value:String(r),children:(0,G.jsx)(`span`,{className:`tabular-nums`,children:O(r,n,i)})})}var md=({column:e,props:t,row:n,value:r})=>{let i=t.currencyField?n[t.currencyField]:void 0,a=t.currency??(typeof i==`string`?i:null);return(0,G.jsx)(pd,{column:e,copyable:t.copyable,value:r,format:{kind:`number`,notation:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:a,unit:null}})},hd=({column:e,props:t,value:n})=>(0,G.jsx)(pd,{column:e,copyable:t.copyable,value:n,format:{kind:`number`,notation:t.compact?`compact`:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:null,unit:t.unit}}),gd=({column:e,row:t})=>(0,G.jsx)(`div`,{className:`grid gap-1`,children:(0,G.jsx)(Y,{nodes:r(e.schema,t)})}),_d=e=>e.props.multiple?(0,G.jsx)(yd,{...e}):e.props.badge?(0,G.jsx)(bd,{...e}):(0,G.jsx)(xd,{...e});function vd({label:e,color:t}){return e===``?null:(0,G.jsx)(Dt,{color:t,children:e})}function yd({column:e,props:t,value:n}){let r=Array.isArray(n)?n:[];return r.length===0?null:t.badge?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map((t,n)=>{let r=t;return(0,G.jsx)(vd,{label:ad(r.value,e),color:r.color},n)})}):(0,G.jsx)(`span`,{children:r.map(t=>ad(t,e)).join(`, `)})}function bd({column:e,props:t,row:n,value:r}){let i=t.badge.colorKey;return(0,G.jsx)(vd,{label:ad(r,e),color:String(n[i]??``)})}function xd({column:e,props:t,row:n,value:r}){let i=e.props.date,a=od(e,n,r),o=ad(r,e),s=a?(0,G.jsx)(`a`,{className:`underline underline-offset-2`,href:a,rel:t.link?.external?`noreferrer`:void 0,target:t.link?.external?`_blank`:void 0,children:o}):o;return i&&!a&&!t.copyable&&r!=null?(0,G.jsx)(tn,{value:r,dateStyle:i.dateStyle,timeStyle:i.timeStyle}):(0,G.jsx)(fd,{column:e,copyable:t.copyable,value:o,children:s})}var Sd={"column.badge":id(sd),"column.boolean":id(cd),"column.icon":id(ld),"column.image":id(dd),"column.money":id(md),"column.number":id(hd),"column.stack":id(gd),"column.text":id(_d)};function Cd({column:e,row:t}){let n=rd()[e.type]??Sd[e.type]??Sd[`column.text`];return(0,G.jsx)(n,{column:e,props:e.props,row:t,value:t[e.key]})}var wd={components:{table:W(({node:e})=>{let{t}=z(`lattice`),{columns:n,rows:r,pagination:i,query:a,filters:o,tableFilters:s,search:c,addFilter:l,updateFilter:u,removeFilter:d,replaceColumnFilters:f,setTableFilter:m,resetFilters:h,setSearch:g,searchFilterOptions:v,processing:y,hasLoaded:b,infiniteLoaderRef:x,sort:S,clearSort:C,goToPage:w,setPerPage:T,loadMore:E}=_u(e),O=(0,U.useMemo)(()=>Au(e.props?.bulkActions),[e.props?.bulkActions]),k=O.length>0,A=(0,U.useMemo)(()=>r.map((e,t)=>({row:e,actions:Yl(e),detail:Xl(e),key:Jl(e,t)})),[r]),j=vu(A.map(e=>e.key)),{isExpanded:M,toggle:N}=Cu(),P=A.some(e=>e.detail!=null),F=(0,U.useMemo)(()=>new Map(n.map(e=>[e.key,e])),[n]),I=D(e),{hasToggleableColumns:L,hasHidden:ee,isVisible:te,resetVisibility:ne,setColumnVisible:re,toggleableColumns:ie,visibleColumns:R}=yu({columns:n,storageKey:I?`lattice:table-column-visibility:${I}`:void 0}),ae=i.currentPage??a.page,oe=i.lastPage??ae,se=i.mode??`table`,B=(0,U.useMemo)(()=>Gl(e.props?.perPageOptions),[e.props?.perPageOptions]),ce=pu(ae,oe),le=i.hasMore??ae<oe,ue=A.some(e=>e.actions.length>0),de=e.props?.striped===!0,fe=R.some(e=>e.props.filter!=null),pe=o.map((e,t)=>({clause:e,index:t})),me=(0,U.useMemo)(()=>Array.isArray(e.props?.filters)?e.props.filters:[],[e.props?.filters]),he=me.length>0,ge=ue,_e=(0,U.useMemo)(()=>Array.isArray(e.props?.toolbar)?e.props.toolbar:[],[e.props?.toolbar]),ve=(0,U.useMemo)(()=>mu(R),[R]),ye=(0,U.useMemo)(()=>gu(ge,k,P),[ge,k,P]),be=e.props?.resizableColumns===!0,xe=D(e),{getResizeHandleProps:Se,gridTemplateColumns:Ce,hasOverrides:we,resizeRootRef:Te,resetColumns:Ee}=Mi({columns:ve,enabled:be,leadingTracks:ye.leadingTracks,showIndicator:e.props?.resizeIndicator===!0,storageKey:be&&xe?`lattice:table-columns:${xe}`:void 0,trailingTracks:ye.trailingTracks}),De=e.props?.searchable===!0||_e.length>0||he||L||we;return(0,G.jsx)(`div`,{"data-slot":`table`,"data-lattice-component":e.id,className:`relative min-w-0`,children:(0,G.jsxs)(`div`,{"data-slot":`table-scroll`,className:`rounded-lt-sm border border-lt-border`,children:[De&&(0,G.jsxs)(`div`,{"data-slot":`table-toolbar`,className:`flex items-center gap-2 border-b border-lt-border px-4 py-2`,children:[e.props?.searchable&&(0,G.jsx)(td,{value:c,onSearch:g}),(0,G.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[he&&(0,G.jsx)(Zu,{filters:me,values:s,processing:y,onChange:m,onSearch:v}),L&&(0,G.jsx)(Ju,{columns:ie,isVisible:te,visibleColumnCount:R.length,hasHidden:ee,onToggle:re,onReset:ne,processing:y}),we&&(0,G.jsx)(`button`,{"aria-label":t(`table.reset-column-widths`,`Reset column widths`),className:`hidden rounded-lt-sm p-1 text-lt-muted-fg hover:text-lt-fg md:inline-flex`,"data-test":`table-reset-columns`,onClick:Ee,title:t(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,G.jsx)(_,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),_e.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??e.id??t))]})]}),(0,G.jsx)(Yu,{clauses:o,columnsByKey:F,indicators:a.tableFilterIndicators,processing:y,onRemoveClause:d,onChange:m,onReset:h}),k&&j.active&&(0,G.jsx)(ju,{actions:O,selectedKeys:j.selectedKeys,allMatching:j.allMatching,total:i.total??void 0,query:au(a),canSelectAllMatching:j.allVisibleSelected&&!j.allMatching&&i.total!=null&&i.total>j.selectedKeys.length,onSelectAllMatching:j.selectAllMatching,onCompleted:j.clear}),a.sorts.length>0&&(0,G.jsx)($u,{columnsByKey:F,query:a,processing:y,onClear:C}),(0,G.jsx)(`div`,{"data-slot":`table-grid-scroll`,className:`relative overflow-x-auto`,children:(0,G.jsxs)(`div`,{ref:Te,className:`min-w-full text-base`,role:`table`,style:{"--lattice-table-columns":Ce},children:[(0,G.jsxs)(`div`,{"data-slot":`table-header`,role:`rowgroup`,children:[(0,G.jsxs)(`div`,{className:`hidden min-w-full md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[P&&(0,G.jsx)(`div`,{className:p(`bg-lt-muted/50 px-2 py-3`,!fe&&`border-b border-lt-border`),role:`columnheader`,"aria-hidden":`true`}),k&&(0,G.jsx)(`div`,{className:p(`flex items-center bg-lt-muted/50 px-4 py-3`,!fe&&`border-b border-lt-border`),role:`columnheader`,children:(0,G.jsx)(ba,{"aria-label":t(`table.select-all-rows`,`Select all rows`),"data-test":`select-all`,checked:j.allSelected,onCheckedChange:()=>j.toggleAll()})}),R.map((e,t)=>(0,G.jsx)(qu,{column:e,processing:y,resizeHandleProps:be?Se(ve[t]):void 0,sort:S,query:a,bottomBordered:!fe},e.key)),ge&&(0,G.jsx)(`div`,{className:p(`flex items-center justify-end gap-2 bg-lt-muted/50 px-4 py-2 align-middle font-semibold text-lt-fg`,!fe&&`border-b border-lt-border`),role:`columnheader`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:e.props?.actionsLabel??t(`table.actions`,`Actions`)})})]}),fe&&(0,G.jsxs)(`div`,{className:`hidden min-w-full md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[P&&(0,G.jsx)(`div`,{className:`border-t border-b border-lt-border bg-lt-muted/50 px-2 py-2`,role:`cell`}),k&&(0,G.jsx)(`div`,{className:`border-t border-b border-lt-border bg-lt-muted/50 px-4 py-2`,role:`cell`}),R.map(e=>(0,G.jsx)(`div`,{className:`min-w-0 border-t border-b border-lt-border bg-lt-muted/50 px-2 py-2`,role:`cell`,children:e.props.filter!=null&&(0,G.jsx)(Ru,{column:e,clauses:pe.filter(t=>t.clause.field===e.key),processing:y,onAdd:l,onUpdate:u,onRemove:d,onReplace:f,onSearch:(t,n)=>v(`column:${e.key}`,t,n)})},e.key)),ge&&(0,G.jsx)(`div`,{className:`border-t border-b border-lt-border bg-lt-muted/50 px-4 py-2`,role:`cell`})]})]}),(0,G.jsx)(`div`,{role:`rowgroup`,children:b?A.length===0?(0,G.jsx)(`div`,{"data-slot":`table-empty`,className:`p-8 text-center text-lt-muted-fg`,role:`row`,children:(0,G.jsx)(`div`,{role:`cell`,children:e.props?.emptyLabel??t(`table.empty`,`No results`)})}):A.map(({row:n,actions:r,detail:i,key:a})=>{let o=i!=null&&M(a),s=`${D(e)??`table`}-row-detail-${a}`;return(0,G.jsxs)(U.Fragment,{children:[(0,G.jsxs)(`div`,{"data-slot":`table-row`,className:`grid grid-cols-1 border-b border-lt-border last:border-b-0 md:grid-cols-[var(--lattice-table-columns)] ${de?`odd:bg-lt-muted/30`:``}`,role:`row`,children:[P&&(0,G.jsx)(`div`,{className:`flex items-center px-2 py-lt-cell-y`,role:`cell`,children:i&&(0,G.jsx)(`button`,{type:`button`,"data-test":`row-expand-${a}`,"aria-expanded":o,"aria-controls":s,"aria-label":t(`table.row-detail.toggle`,`Toggle detail`),className:`inline-flex size-6 items-center justify-center rounded-lt-sm text-lt-muted-fg hover:bg-lt-muted hover:text-lt-fg`,onClick:()=>N(a),children:(0,G.jsx)(_,{name:`chevron-down`,"aria-hidden":`true`,className:p(`size-lt-icon-md transition-transform`,!o&&`-rotate-90`)})})}),k&&(0,G.jsx)(`div`,{className:`flex items-center px-lt-cell-x py-lt-cell-y`,role:`cell`,children:(0,G.jsx)(ba,{"aria-label":t(`table.select-row`,`Select row {{key}}`,{key:a}),"data-test":`select-row-${a}`,checked:j.isSelected(a),onCheckedChange:()=>j.toggle(a)})}),R.map(e=>(0,G.jsxs)(`div`,{"data-slot":`table-cell`,className:p(`grid min-w-0 content-center gap-1 overflow-hidden px-lt-cell-x py-lt-cell-y`,Du(e.props.align),ku(e.props.align)),role:`cell`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium text-lt-muted-fg md:hidden`,children:e.props.label}),(0,G.jsx)(`div`,{"data-slot":`table-cell-content`,className:`min-w-0 max-w-full overflow-hidden truncate`,children:(0,G.jsx)(Cd,{column:e,row:n})})]},e.key)),ge&&(0,G.jsx)(`div`,{className:p(`items-center justify-start gap-2 px-lt-cell-x py-lt-cell-y md:justify-end`,r.length>0?`flex`:`hidden md:flex`),role:`cell`,children:r.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??e.id??t))})]}),o&&i&&(0,G.jsx)(`div`,{id:s,role:`region`,"data-slot":`table-row-detail`,className:`border-b border-lt-border bg-lt-muted/20 px-lt-cell-x py-lt-cell-y`,children:(0,G.jsx)(Y,{nodes:[i]})})]},a)}):(0,G.jsx)(`div`,{className:`p-4 text-lt-muted-fg`,role:`row`,children:(0,G.jsx)(`div`,{role:`cell`,children:t(`table.loading`,`Loading rows...`)})})})]})}),b&&(0,G.jsx)(Qu,{pagination:i,currentPage:ae,processing:y,mode:se,hasNextPage:le,visiblePages:ce,infiniteLoaderRef:x,perPageOptions:B,perPageValue:se===`infinite`?`infinite`:a.perPage,onPerPage:T,onPage:w,onLoadMore:E})]})})})},name:`lattice/table`};function Td({className:e,...t}){return(0,G.jsx)(`article`,{"data-slot":`card`,className:p(`flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-lt-gutter text-lt-surface-fg shadow-lt-sm`,e),...t})}function Ed({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-header`,className:p(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function Dd({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-title`,className:p(`font-semibold leading-none`,e),...t})}function Od({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-description`,className:p(`text-sm text-lt-muted-fg`,e),...t})}function kd({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-content`,className:p(`px-lt-gutter`,e),...t})}var Ad=({children:e,node:t})=>{let{title:n,description:r,tooltip:i,headerActions:a}=t.props,o=a??[];return(0,G.jsxs)(Td,{"data-lattice-component":D(t),children:[(n||r||o.length>0)&&(0,G.jsxs)(Ed,{children:[(n||o.length>0)&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center`,children:[n&&(0,G.jsx)(Dd,{children:n}),n&&(0,G.jsx)(nt,{content:i})]}),o.length>0&&(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:o.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??e.id??t))})]}),r&&(0,G.jsxs)(`div`,{className:`flex items-center`,children:[(0,G.jsx)(Od,{children:r}),!n&&(0,G.jsx)(nt,{content:i})]})]}),e&&(0,G.jsx)(kd,{className:`flex flex-col gap-6`,children:e})]})},jd=(0,U.lazy)(()=>jt(()=>import(`./code-block-view-CetAq3Rk.js`),__vite__mapDeps([26,1,2,6,19]),import.meta.url));function Md({"aria-label":e,children:t,className:n,copyable:r=!1,language:i=`text`,lineNumbers:a=!1,maxHeight:o=null,role:s=e?`region`:void 0,wrap:c=!1,...l}){let u=(0,G.jsx)(`pre`,{className:p(`max-w-full overflow-auto p-3 font-lt-mono text-xs`,c&&`whitespace-pre-wrap wrap-anywhere`),style:{maxHeight:o??void 0},children:a?(0,G.jsx)(`code`,{className:`grid grid-cols-[auto_1fr]`,children:t.split(`
|
|
23
|
+
`).map((e,t)=>(0,G.jsxs)(U.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`mr-3 border-r border-lt-border pr-3 text-right text-lt-muted-fg select-none`,children:t+1}),(0,G.jsx)(`span`,{children:e||``})]},t))}):t});return(0,G.jsxs)(`div`,{"data-slot":`code-block`,"aria-label":e,role:s,...l,className:p(`relative max-w-full overflow-hidden rounded-lt-sm bg-lt-muted text-lt-fg`,n),children:[r?(0,G.jsx)(ps,{value:t,label:e??`code`,iconOnly:!0,className:`absolute top-3 right-6 z-10 bg-lt-bg/80 hover:bg-lt-bg`}):null,(0,G.jsx)(U.Suspense,{fallback:u,children:(0,G.jsx)(jd,{language:i,lineNumbers:a,maxHeight:o,wrap:c,children:t})})]})}var Nd=({node:e})=>(0,G.jsx)(Md,{copyable:e.props.copyable,language:e.props.language,lineNumbers:e.props.lineNumbers,maxHeight:e.props.maxHeight,wrap:e.props.wrap,children:e.props.code});function Pd(){let e=re();(0,U.useEffect)(()=>u.on(`flash`,t=>{let n=R(t.detail?.flash?.latticeEffects);n.length>0&&e(n)}),[e])}var Fd={xs:`size-6 text-[0.5rem]`,sm:`size-8 text-xs`,md:`size-10 text-sm`,lg:`size-12 text-base`,xl:`size-16 text-lg`,"2xl":`size-20 text-xl`,"3xl":`size-24 text-2xl`,"4xl":`size-32 text-3xl`};function Id(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function Ld(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`size-[60%]`,children:[(0,G.jsx)(`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`7`,r:`4`})]})}var Rd=({node:e})=>{let{src:t,name:n,size:r}=e.props,i=n??void 0;return(0,G.jsx)(`span`,{"data-slot":`avatar`,role:t?void 0:`img`,"aria-label":t?void 0:i,className:p(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,Fd[r]),children:t?(0,G.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?Id(n):(0,G.jsx)(Ld,{})})},zd=({node:e})=>(0,G.jsx)(Dt,{color:e.props.color,children:e.props.label}),Bd=(0,U.lazy)(()=>jt(()=>import(`./chart-view-DhCVr5fn.js`),__vite__mapDeps([27,1,2,28,15,3,5,6,29,8,12,17,20]),import.meta.url)),Vd=({children:e,node:t})=>(0,G.jsx)(U.Suspense,{fallback:null,children:(0,G.jsx)(Bd,{node:t,children:e})}),Hd=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=yr(t.props.trigger),i=D(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=ll(a,t.props.collapsed===!1,n);return(0,G.jsxs)(`div`,{"data-slot":`collapsible`,"data-lattice-component":i,children:[(0,G.jsxs)(`div`,{"aria-controls":o,"aria-expanded":s,"data-test":k(`collapsible-toggle`,i)??`collapsible-toggle-default`,className:`flex w-full cursor-pointer items-center justify-between gap-4 rounded-lt-sm py-2 text-left text-lt-fg transition-colors hover:bg-lt-muted`,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},role:`button`,tabIndex:0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(Y,{nodes:r}),t.props.tooltip&&(0,G.jsx)(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,G.jsx)(nt,{content:t.props.tooltip})})]}),(0,G.jsx)(_,{name:`chevron-down`,className:p(`size-lt-icon-md shrink-0 text-lt-muted-fg transition-transform`,!s&&`-rotate-90`)})]}),s&&e&&(0,G.jsx)(`div`,{id:o,className:`flex flex-col gap-4 pt-2`,children:e})]})};function Ud(e,t){return e===`top-start`?{left:t,top:t}:e===`top-end`?{right:t,top:t}:e===`bottom-start`?{bottom:t,left:t}:{bottom:t,right:t}}var Wd=({children:e,node:t})=>{let n=t.props.label??void 0,r=Math.max(0,t.props.offset??16),i=t.props.placement??`bottom-end`,a=t.props.trigger??[],[o,s]=(0,U.useState)(!1);if(a.length===0)return(0,G.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-lt-md`,"data-lattice-component":D(t),role:n?`group`:void 0,style:Ud(i,r),children:e});let c=i===`bottom-start`||i===`bottom-end`,l=i===`top-start`||i===`bottom-start`;return(0,G.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)]`,"data-lattice-component":D(t),role:n?`group`:void 0,style:Ud(i,r),children:(0,G.jsxs)(`div`,{className:p(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,G.jsx)(`button`,{"aria-expanded":o,className:p(`inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-lt-md hover:bg-lt-muted`,l?`self-start`:`self-end`),"data-test":t.key?`${t.key}-trigger`:void 0,onClick:()=>s(e=>!e),type:`button`,children:a.map((e,t)=>(0,G.jsx)(X,{node:e},e.key??`${e.type}-${t}`))}),(0,G.jsx)(`div`,{className:o?`block`:`hidden`,children:e})]})})};function Gd(e,t,n){let r=Object.entries(e??{});if(r.length!==0)return Object.fromEntries(r.map(([e,r])=>[`${t}-${e}`,n(r)]))}var Kd=e=>typeof e==`number`?`repeat(${e}, minmax(0, 1fr))`:e,qd=e=>e===`full`?`1 / -1`:`span ${e} / span ${e}`,Jd=({node:e})=>(0,G.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":D(e),className:`lt-grid grid gap-x-4 gap-y-6`,style:Gd(e.props.columns,`--lt-grid-cols`,Kd),children:(e.schema??[]).map((e,t)=>(0,G.jsx)(`div`,{"data-slot":`grid-item`,style:Gd(e.props?.columnSpan,`--lt-col-span`,qd),children:(0,G.jsx)(X,{node:e})},br(e,t)))}),Yd=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=p(`max-w-3xl font-semibold tracking-normal text-balance text-lt-fg`,r===1&&`text-2xl font-bold leading-tight`,r===2&&`text-xl`,r>2&&`text-base`),a=(0,G.jsxs)(G.Fragment,{children:[t,(0,G.jsx)(nt,{content:n})]}),o;switch(r){case 1:o=(0,G.jsx)(`h1`,{className:i,children:a});break;case 2:o=(0,G.jsx)(`h2`,{className:i,children:a});break;case 3:o=(0,G.jsx)(`h3`,{className:i,children:a});break;case 4:o=(0,G.jsx)(`h4`,{className:i,children:a});break;case 5:o=(0,G.jsx)(`h5`,{className:i,children:a});break;default:o=(0,G.jsx)(`h6`,{className:i,children:a})}return e.props.copyable?(0,G.jsx)(ms,{value:t,label:t,children:o}):o},Xd={xs:`size-lt-icon-xs`,sm:`size-lt-icon-sm`,md:`size-lt-icon-md`,lg:`size-lt-icon-lg`,xl:`size-lt-icon-xl`,"2xl":`size-lt-icon-2xl`,"3xl":`size-lt-icon-3xl`,"4xl":`size-lt-icon-4xl`},Zd=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,G.jsx)(K,{icon:t,className:p(Xd[n],i)}),o=Tt(r);return o?(0,G.jsx)(`span`,{className:`contents`,style:{color:Ct(o)},children:a}):a},Qd=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,G.jsx)(ud,{alt:n??``,className:p(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:D(e),width:r??void 0})},$d=`text-lt-fg underline decoration-lt-border underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-lt-border`;function ef({affix:e,className:t}){return e.icon?(0,G.jsx)(K,{className:p(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,G.jsx)(`span`,{className:p(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function tf({icon:e,isMenuItem:t,label:n,prefix:r,suffix:i}){return e?(0,G.jsx)(K,{className:`size-lt-icon-md shrink-0`,icon:e}):t?(0,G.jsxs)(G.Fragment,{children:[r?(0,G.jsx)(ef,{affix:r}):null,(0,G.jsx)(`span`,{children:n}),i?(0,G.jsx)(ef,{affix:i,className:`ml-auto`}):null]}):r||i?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 align-baseline`,children:[r?(0,G.jsx)(ef,{affix:r}):null,(0,G.jsx)(`span`,{children:n}),i?(0,G.jsx)(ef,{affix:i}):null]}):n}function nf(e,t,n){if(!(!t?.text&&!n?.text))return[t?.text,e,n?.text].filter(e=>!!e).join(` `)}var rf=({node:e})=>{let t=cn(),{icon:n,label:r,prefix:i,suffix:a}=e.props,o=r??``,s=Xt(e.props),c=t?on:void 0,l=D(e),u=(0,G.jsx)(tf,{icon:n,isMenuItem:t,label:o,prefix:i,suffix:a}),d=n?o:nf(o,i,a),f=({onClick:e,processing:t})=>(0,G.jsx)(`button`,{"aria-label":d,className:p($d,c),"data-test":l,disabled:t,onClick:e,type:`button`,children:u});return s.kind===`action`?(0,G.jsx)(Yt,{action:s.action,children:f}):s.kind===`effects`?f({onClick:s.onClick,processing:!1}):(0,G.jsx)(Be,{"aria-label":d,className:c,"data-test":l,href:s.kind===`navigate`?s.href:`#`,method:s.kind===`navigate`?s.method:`get`,tabIndex:e.props.tabIndex??void 0,children:u})};function af(e,t){let n=e.detail?.modal;return n==null||n===t}var of=({children:e,node:t})=>{let{t:n}=z(se),r=t.props.title??n(`common.dialog`,`Dialog`),i=t.props.description,a=t.props.closeLabel,[o,s]=(0,U.useState)(t.props.open===!0),c=(0,U.useRef)(null),l=(0,U.useRef)(o);return(0,U.useEffect)(()=>{t.props.open===!0&&s(!0)},[t.props.open]),(0,U.useEffect)(()=>{function e(e){t.id&&af(e,t.id)&&(c.current=document.activeElement instanceof HTMLElement?document.activeElement:null,s(!0))}function n(e){(!t.id||af(e,t.id))&&s(!1)}return window.addEventListener(F.openModal,e),window.addEventListener(F.closeModal,n),()=>{window.removeEventListener(F.openModal,e),window.removeEventListener(F.closeModal,n)}},[t.id]),(0,U.useEffect)(()=>{if(l.current&&!o){let e=c.current;e&&requestAnimationFrame(()=>e.focus())}l.current=o},[o]),(0,G.jsx)(Ln,{open:o,onOpenChange:s,children:(0,G.jsxs)(Vn,{...i?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,height:t.props.height,children:[(0,G.jsx)(Hn,{closeLabel:a,description:i,title:r}),(0,G.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},sf={xs:`h-1`,sm:`h-1.5`,md:`h-2.5`,lg:`h-3`,xl:`h-4`,"2xl":`h-5`,"3xl":`h-6`,"4xl":`h-8`},cf={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},lf={xs:`text-[0.5rem]`,sm:`text-[0.625rem]`,md:`text-xs`,lg:`text-sm`,xl:`text-base`,"2xl":`text-lg`,"3xl":`text-xl`,"4xl":`text-2xl`},uf=({node:e})=>{let{value:t,max:n,shape:r,showValue:i,color:a,size:o}=e.props,{locale:s}=M(),c=Ct(Tt(a)??wt(`primary`)),l=n>0?Math.min(Math.max(t,0),n):0,u=n>0?l/n:0,d=new Intl.NumberFormat(s,{maximumFractionDigits:0,style:`percent`}).format(u),f={"aria-valuemax":n,"aria-valuemin":0,"aria-valuenow":l,"aria-valuetext":d,role:`progressbar`};if(r===`circle`){let e=cf[o],t=Math.max(3,e/10),n=(e-t)/2,r=2*Math.PI*n;return(0,G.jsxs)(`div`,{...f,className:`relative inline-flex`,"data-lattice-progress":`circle`,children:[(0,G.jsxs)(`svg`,{className:`-rotate-90`,height:e,width:e,children:[(0,G.jsx)(`circle`,{className:`text-lt-muted`,cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeWidth:t}),(0,G.jsx)(`circle`,{cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeDasharray:r,strokeDashoffset:r*(1-u),strokeLinecap:`round`,strokeWidth:t,style:{color:c}})]}),i&&(0,G.jsx)(`span`,{className:p(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,lf[o]),children:d})]})}return(0,G.jsxs)(`div`,{className:`flex w-full items-center gap-2`,"data-lattice-progress":`bar`,children:[(0,G.jsx)(`div`,{...f,className:p(`w-full overflow-hidden rounded-full bg-lt-muted`,sf[o]),children:(0,G.jsx)(`div`,{className:`h-full rounded-full`,style:{background:c,width:`${u*100}%`}})}),i&&(0,G.jsx)(`span`,{className:`shrink-0 text-lt-muted-fg text-sm tabular-nums`,children:d})]})},df=({node:e})=>(0,G.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),ff=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=yr(t.props.headerActions),c=D(t),[l,u]=ll(`lattice:section:${c??`default`}`,t.props.collapsed===!0,a&&o),d=a&&l,f=!!(n||r||s.length>0||a);return(0,G.jsxs)(`section`,{"data-slot":`section`,className:`flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-lt-gutter text-lt-surface-fg shadow-lt-sm`,"data-lattice-component":c,children:[f&&(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-lt-gutter`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[a&&(0,G.jsx)(`button`,{"aria-expanded":!d,"aria-label":d?`Expand section`:`Collapse section`,"data-test":k(`section-toggle`,c)??`section-toggle-default`,className:`mt-0.5 inline-flex shrink-0 items-center rounded-lt-sm p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,onClick:u,type:`button`,children:(0,G.jsx)(_,{name:`chevron-down`,className:p(`size-lt-icon-md transition-transform`,d&&`-rotate-90`)})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[n&&(0,G.jsxs)(`div`,{className:`flex items-center`,children:[(0,G.jsx)(`div`,{className:`font-semibold leading-none`,children:n}),(0,G.jsx)(nt,{content:i})]}),r&&(0,G.jsxs)(`div`,{className:`flex items-center`,children:[(0,G.jsx)(`div`,{className:`text-sm text-lt-muted-fg`,children:r}),!n&&(0,G.jsx)(nt,{content:i})]})]})]}),s.length>0&&(0,G.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,G.jsx)(Y,{nodes:s})})]}),!d&&e&&(0,G.jsx)(`div`,{className:`flex flex-col gap-6 px-lt-gutter`,children:e})]})},pf=({node:e})=>{let{options:t,name:n,emits:r}=e.props,[i,a]=(0,U.useState)(e.props.value||t[0]?.value||``);if(t.length===0)return null;function o(e){a(e),r&&window.dispatchEvent(new CustomEvent(r,{detail:{name:n,value:e}}))}return(0,G.jsx)(Ta,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},mf=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:p(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},hf={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},gf={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},_f={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},vf={auto:`w-auto`,fill:`min-w-0 flex-1`,full:`w-full`,lg:`mx-auto w-full max-w-4xl`,md:`mx-auto w-full max-w-2xl`,sm:`mx-auto w-full max-w-md`},yf={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},bf={full:`h-full`,screen:`min-h-screen`},xf={end:`ml-auto`,start:`mr-auto`},Sf=({children:e,node:t})=>{let n=t.props.align??`stretch`,r=t.props.direction??`column`,i=t.props.gap??`md`,a=t.props.width??`full`,o=t.props.justify,s=t.props.height,c=t.props.float,l=r===`row`||o!=null;return(0,G.jsx)(`div`,{"data-slot":`stack`,"data-lattice-component":D(t),className:p(l?p(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?gf[n]??gf.stretch:hf[n]??hf.stretch,_f[i]??_f.md,vf[a]??vf.full,o?yf[o]:null,s?bf[s]:null,c?xf[c]:null),children:e})},Cf=(0,U.createContext)(null);function wf(){return(0,U.useContext)(Cf)||{activeValue:``,setActiveValue:()=>{}}}function Tf(e){return(e.schema??[]).filter(e=>e.type===`tab`).map(e=>{let t=e.props;return{confirm:t.confirm?{required:t.confirm.required}:void 0,label:t.label,value:t.value}}).filter(e=>e.value!==``)}function Ef(e,t){if(typeof window>`u`)return null;let n=new URLSearchParams(window.location.search).get(e);return!n||!t.some(e=>e.value===n)?null:n}function Df(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href);n.searchParams.set(e,t),window.history.replaceState(window.history.state,``,`${n.pathname}${n.search}${n.hash}`)}function Of(e,t){if(typeof window>`u`)return``;let n=new URL(window.location.href);return n.searchParams.set(e,t),`${n.pathname}${n.search}${n.hash}`}var kf=({children:e,node:t})=>{let{t:n}=z(se),r=(0,U.useMemo)(()=>Tf(t),[t]),i=r[0]?.value??``,a=t.props.queryKey,o=t.props.orientation,s=o===`vertical`,c=t.props.alignment,l=!s&&c===`stretch`,d=t.props.activeValue,f=t.props.defaultValue??i,m=(0,U.useRef)(null),[h,g]=(0,U.useState)(()=>d||(Ef(a,r)??f)||i),_=(0,U.useCallback)(e=>{if(e.confirm?.required){u.visit(Of(a,e.value),{preserveScroll:!0});return}g(e.value),Df(a,e.value)},[a]),v=(0,U.useCallback)(e=>{let t=r.find(t=>t.value===e);t&&_(t)},[_,r]),y=(0,U.useMemo)(()=>({activeValue:h,setActiveValue:v}),[h,v]);function b(e){let t=s?`ArrowDown`:`ArrowRight`,n=s?`ArrowUp`:`ArrowLeft`;if(e.key!==t&&e.key!==n&&e.key!==`Home`&&e.key!==`End`)return;let r=Array.from(m.current?.querySelectorAll(`[role="tab"]`)??[]);if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement),a;if(e.key===`Home`)a=0;else if(e.key===`End`)a=r.length-1;else{let n=e.key===t?1:-1;a=((i<0?0:i)+n+r.length)%r.length}r[a]?.focus()}return(0,G.jsx)(Cf.Provider,{value:y,children:(0,G.jsxs)(`div`,{className:p(`gap-6`,s?p(`flex`,c===`end`&&`flex-row-reverse`):`grid`),"data-lattice-tabs":t.key??t.id,children:[(0,G.jsx)(`div`,{"aria-label":n(`common.tabs`,`Tabs`),"aria-orientation":o,className:p(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&p(`inline-flex w-fit max-w-full overflow-x-auto`,{"justify-self-center":c===`center`,"justify-self-end":c===`end`})),ref:m,role:`tablist`,children:r.map(e=>{let t=h===e.value;return(0,G.jsx)(`button`,{"aria-controls":`${e.value}-panel`,"aria-selected":t,"data-test":`tab-${e.value}`,className:p(wa(t),s&&`text-left`,l&&`flex-1`),id:`${e.value}-tab`,onClick:()=>_(e),onKeyDown:b,role:`tab`,tabIndex:t?0:-1,type:`button`,children:e.label},e.value)})}),(0,G.jsx)(`div`,{className:p(`min-w-0`,s&&`flex-1`),children:e})]})})},Af=({children:e,node:t})=>{let{activeValue:n}=wf(),r=t.props.value,i=n===r,[a,o]=(0,U.useState)(i);return(0,U.useEffect)(()=>{i&&o(!0)},[i]),(0,G.jsx)(`section`,{"aria-labelledby":`${r}-tab`,className:p(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},jf={center:`text-center`,left:`text-left`},Mf={xs:`text-xs leading-5`,sm:`text-sm leading-6`,md:`text-base leading-7`,lg:`text-lg leading-8`,xl:`text-xl leading-8`,"2xl":`text-2xl leading-9`,"3xl":`text-3xl leading-10`,"4xl":`text-4xl leading-none`},Nf=zt({components:{avatar:W(Rd),badge:W(zd),button:W(Zt),card:W(Ad),chart:W(Vd),"code-block":W(Nd),collapsible:W(Hd),"floating-panel":W(Wd),grid:W(Jd),heading:W(Yd),icon:W(Zd),image:W(Qd),link:W(rf),modal:W(of),progress:W(uf),"raw-block":W(df),section:W(ff),"segmented-control":W(pf),separator:W(mf),stack:W(Sf),tab:W(Af),tabs:W(kf),text:W(({node:e})=>{let t=e.props.align??`left`,n=Ct(Tt(e.props.color)??wt(`muted`)),r=(0,G.jsx)(`p`,{className:p(`m-0`,`max-w-2xl`,jf[t]??jf.left,Mf[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,G.jsx)(ms,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:W(({node:e})=>{let t=e.props.content,n=yr(e.props.trigger);return t?n.length===0?(0,G.jsx)(nt,{content:t}):(0,G.jsxs)(We,{children:[(0,G.jsx)(it,{type:`button`,className:`inline-flex items-center rounded-lt-sm outline-none focus-visible:ring-lt-ring/50 focus-visible:ring-[length:var(--lt-ring-width)]`,children:(0,G.jsx)(Y,{nodes:n})}),(0,G.jsx)(Ke,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},i18n:{namespace:se},name:`lattice/ui`},js,Zr,ks,fl,wd,pi,Ol,jl),Pf=[`light`,`dark`,`system`],{subscribe:Ff,notify:If}=P(),Lf=`system`,Rf=`system`;function zf(e){Bf(e)&&(Rf=e)}function Bf(e){return Pf.some(t=>t===e)}var Vf=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,Hf=(e,t,n=365)=>{if(typeof document>`u`)return;let r=n*24*60*60;document.cookie=`${e}=${t};path=/;max-age=${r};SameSite=Lax`},Uf=()=>{if(typeof window>`u`)return`system`;let e=localStorage.getItem(`appearance`);return Bf(e)?e:`system`},Wf=e=>e===`dark`||e===`system`&&Vf(),Gf=()=>Vf()?`dark`:`light`,Kf=e=>{if(typeof document>`u`)return;let t=Wf(e);document.documentElement.classList.toggle(`dark`,t),document.documentElement.style.colorScheme=t?`dark`:`light`},qf=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),Jf=()=>{Kf(Lf),If()};function Yf(e){Lf=e,localStorage.setItem(`appearance`,e),Hf(`appearance`,e),Kf(e),If()}function Xf(){typeof window>`u`||(localStorage.getItem(`appearance`)||(localStorage.setItem(`appearance`,`system`),Hf(`appearance`,`system`)),Lf=Uf(),Kf(Lf),qf()?.addEventListener(`change`,Jf))}function Zf(){let e=(0,U.useSyncExternalStore)(Ff,()=>Lf,()=>Rf),t=(0,U.useSyncExternalStore)(Ff,Gf,()=>`light`);return{appearance:e,resolvedAppearance:e===`system`?t:e,updateAppearance:Yf}}function Qf({children:e}){let t=a().props.lattice.layout;return t?(0,G.jsx)(tl.Provider,{value:e,children:(0,G.jsx)(Y,{nodes:t.schema})}):(0,G.jsx)(G.Fragment,{children:e})}var $f=(0,U.lazy)(()=>jt(()=>import(`./subscriptions-WYT4UqqY.js`),__vite__mapDeps([30,1,2,6,31,14,15,3,8,22,11,12,25]),import.meta.url)),ep=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){console.warn(`[lattice] Real-time listeners are declared but Echo is unavailable. Install @laravel/echo-react and call configureEcho().`)}render(){return this.state.failed?null:this.props.children}};function tp({listeners:e}){return e.length===0?null:(0,G.jsx)(ep,{children:(0,G.jsx)(U.Suspense,{fallback:null,children:(0,G.jsx)($f,{listeners:e})})})}function np({lattice:e}){let t=(0,G.jsx)(Y,{nodes:e.schema});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{title:e.title??void 0}),(0,G.jsx)(tp,{listeners:e.listeners}),e.container===`centered`?(0,G.jsx)(`main`,{className:`min-h-svh bg-lt-bg text-lt-fg`,children:(0,G.jsx)(`div`,{"data-test":`lattice-centered-container`,className:`mx-auto flex min-h-svh w-full max-w-6xl flex-col justify-center px-6 py-12 sm:px-8 lg:px-10`,children:t})}):(0,G.jsx)(`div`,{"data-test":`lattice-default-container`,className:p(`w-full`,{"px-4 py-6":e.layout!==null}),children:t})]})}var rp=`lattice/page`;function ip(e){return t=>{if(t===`lattice/page`)return{default:np};let n=e[`./Pages/${t}.tsx`]??e[`./pages/${t}.tsx`];if(n)return n();throw Error(`Page not found: ${t}`)}}function ap({defaultLayout:e}={}){return(t,n)=>t===`lattice/page`?n.props.lattice?.layout?Qf:null:e?.(t,n)??null}function op(e,t){return{...t,headers:Qn(``,t.headers)}}var sp=!1;function cp(){sp||(sp=!0,c.onRequest(e=>{let t=e.headers?.[Wn];return e.headers&&typeof t==`string`&&t!==``&&(e.headers[Wn]=Kn(t)),e}))}function lp({action:e,children:t}){let{processing:n,requestSubmit:r,overlays:i}=Xr(e);return(0,G.jsxs)(G.Fragment,{children:[t({onClick:r,processing:n}),i]})}function up({children:e}){return(0,G.jsx)(qt,{render:e=>(0,G.jsx)(lp,{action:e.action,children:e.children}),children:e})}function dp({onAppearanceChange:e}){return Qt(F.appearanceChange,t=>{let n=t.detail?.value;Bf(n)&&e?.(n)},{enabled:!!e}),null}var fp={href:``};function pp({children:e,registry:t,sprite:n=fp,toaster:r=!0}){return Pd(),(0,G.jsx)(te.Provider,{value:t,children:(0,G.jsx)(up,{children:(0,G.jsxs)(g,{sprite:n,children:[e,(0,G.jsx)(dp,{onAppearanceChange:Yf}),r?(0,G.jsx)(Yc,{}):null]})})})}function mp(e,t){let n=new Set([...e.namespaces??[`lattice`,`lattice-ui`],...t.map(e=>e.namespace)]);return{...e,namespaces:[...n]}}function hp({ready:e,children:t}){let[n,r]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{let t=!0,n=()=>{t&&r(!0)};return e.then(n,n),()=>{t=!1}},[e]),n?t:null}function gp({registry:e,plugins:t,sprite:n,pages:r={},defaultLayout:a,strictMode:s=!0,i18n:c,boot:l,wrap:u,...d}={}){let f=e??Nf,p=t&&t.length>0?Bt(f,...t):f;L(p),Xn(N),cp();let m=c!==!1,h=t?.flatMap(e=>e.i18n?[e.i18n]:[])??[],g=m?mp(c??{},h):{},_=d.defaults?.visitOptions,v=m?{...d.defaults,visitOptions:(e,t)=>op(e,_?.(e,t)??t)}:d.defaults,y=o({...d,defaults:v,strictMode:s,resolve:ip(r),layout:ap({defaultLayout:a}),withApp:(e,{ssr:t,page:r})=>{let a=[],o=r.props.lattice,s=!1;if(i(o)&&zf(o.appearance),!t){s=document.getElementById(d.id??`app`)?.hasAttribute(`data-server-rendered`)===!0,i(o)&&i(o.urls)&&typeof o.urls.refreshRef==`string`&&or(o.urls.refreshRef),m&&fe(r.props)!==void 0&&a.push(jt(()=>import(`./page-props-DZ15iP5k.js`).then(e=>e.n).then(e=>e.configureI18nFromPageProps(r.props,g)),__vite__mapDeps([32,1,28,8,2,11,12]),import.meta.url));let e=l?.({page:r});e&&a.push(e)}let c=(0,G.jsxs)(G.Fragment,{children:[e,m?(0,G.jsx)($t,{}):null]}),f=(0,G.jsx)(pp,{registry:p,sprite:n,children:u?u(c):c});return a.length===0?f:s?(oe(Promise.all(a)),f):(0,G.jsx)(hp,{ready:Promise.all(a),children:f})}});return Xf(),y}L(Nf);function _p({registry:e=Nf,...t}){return(0,G.jsx)(pp,{...t,registry:e})}function vp(e){if(Array.isArray(e))return e}function yp(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function bp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xp(e,t){if(e){if(typeof e==`string`)return bp(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bp(e,t):void 0}}function Sp(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
24
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cp(e,t){return vp(e)||yp(e,t)||xp(e,t)||Sp()}var wp=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bind=void 0;function t(e,t){var n=t.type,r=t.listener,i=t.options;return e.addEventListener(n,r,i),function(){e.removeEventListener(n,r,i)}}e.bind=t})),Tp=t((e=>{var t=e&&e.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=void 0;var n=wp();function r(e){if(e!==void 0)return typeof e==`boolean`?{capture:e}:e}function i(e,n){return n==null?e:t(t({},e),{options:t(t({},r(n)),r(e.options))})}function a(e,t,r){var a=t.map(function(t){var a=i(t,r);return(0,n.bind)(e,a)});return function(){a.forEach(function(e){return e()})}}e.bindAll=a})),Ep=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var t=wp();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return t.bind}});var n=Tp();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return n.bindAll}})}))(),Dp=`data-pdnd-honey-pot`;function Op(e){return e instanceof Element&&e.hasAttribute(`data-pdnd-honey-pot`)}function kp(e){var t=Cp(document.elementsFromPoint(e.x,e.y),2),n=t[0],r=t[1];return n?Op(n)?r??null:n:null}function Ap(e){"@babel/helpers - typeof";return Ap=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ap(e)}function jp(e,t){if(Ap(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ap(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Mp(e){var t=jp(e,`string`);return Ap(t)==`symbol`?t:t+``}function Np(e,t,n){return(t=Mp(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Pp=2147483647,Fp={inset:`unset`,border:`none`,padding:0,margin:0,overflow:`visible`,color:`inherit`,background:`transparent`,width:`auto`,height:`auto`};function Ip(e){var t=null;return function(){if(!t){var n=[...arguments];t={result:e.apply(this,n)}}return t.result}}var Lp=Ip(function(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype.showPopover==`function`});function Rp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Rp(Object(n),!0).forEach(function(t){Np(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rp(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Bp=2,Vp=Bp/2;function Hp(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function Up(e){return{x:e.x-Vp,y:e.y-Vp}}function Wp(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function Gp(e){return{x:Math.min(e.x,window.innerWidth-Bp),y:Math.min(e.y,window.innerHeight-Bp)}}function Kp(e){var t=e.client,n=Gp(Wp(Up(Hp(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:Bp,height:Bp})}function qp(e){var t=e.clientRect;return{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`}}function Jp(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function Yp(e){var t=e.initial,n=document.createElement(`div`);n.setAttribute(Dp,`true`),Lp()&&n.setAttribute(`popover`,`manual`);var r=Kp({client:t});Object.assign(n.style,zp(zp({position:`fixed`},Lp()?Fp:{zIndex:Pp}),{},{backgroundColor:`transparent`,padding:0,margin:0,boxSizing:`border-box`,pointerEvents:`auto`},qp({clientRect:r}))),document.body.appendChild(n),Lp()&&n.showPopover();var i=(0,Ep.bind)(window,{type:`pointermove`,listener:function(e){r=Kp({client:{x:e.clientX,y:e.clientY}}),Object.assign(n.style,qp({clientRect:r}))},options:{capture:!0}});return function(e){var t=e.current;if(i(),Jp({client:t,clientRect:r})){n.remove();return}function a(){o(),n.remove()}var o=(0,Ep.bindAll)(window,[{type:`pointerdown`,listener:a},{type:`pointermove`,listener:a},{type:`focusin`,listener:a},{type:`focusout`,listener:a},{type:`dragstart`,listener:a},{type:`dragenter`,listener:a},{type:`dragover`,listener:a}],{capture:!0})}}function Xp(){var e=null;function t(){return e=null,(0,Ep.bind)(window,{type:`pointermove`,listener:function(t){e={x:t.clientX,y:t.clientY}},options:{capture:!0}})}function n(){var t=null;return function(n){var r=n.eventName,i=n.payload;if(r===`onDragStart`){var a=i.location.initial.input;t=Yp({initial:e??{x:a.clientX,y:a.clientY}})}if(r===`onDrop`){var o,s=i.location.current.input;(o=t)==null||o({current:{x:s.clientX,y:s.clientY}}),t=null,e=null}}}return{bindEvents:t,getOnPostDispatch:n}}function Zp(e){if(Array.isArray(e))return bp(e)}function Qp(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function $p(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
25
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function em(e){return Zp(e)||Qp(e)||xp(e)||$p()}var tm=Ip(function(){return navigator.userAgent.includes(`Firefox`)}),nm=Ip(function(){var e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)}),rm={isLeavingWindow:Symbol(`leaving`),isEnteringWindow:Symbol(`entering`)};function im(e){var t=e.dragLeave;return nm()?t.hasOwnProperty(rm.isLeavingWindow):!1}(function(){if(typeof window>`u`||!nm())return;function e(){return{enterCount:0,isOverWindow:!1}}var t=e();function n(){t=e()}(0,Ep.bindAll)(window,[{type:`dragstart`,listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:`drop`,listener:n},{type:`dragend`,listener:n},{type:`dragenter`,listener:function(e){!t.isOverWindow&&t.enterCount===0&&(e[rm.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:`dragleave`,listener:function(e){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(e[rm.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function am(e){return`nodeName`in e}function om(e){return am(e)&&e.ownerDocument!==document}function sm(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n===`dragleave`?nm()?im({dragLeave:t}):r==null?!0:tm()?om(r):r instanceof HTMLIFrameElement:!1}function cm(e){var t=e.onDragEnd;return[{type:`pointermove`,listener:function(){var e=0;return function(){if(e<20){e++;return}t()}}()},{type:`pointerdown`,listener:t}]}function lm(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var um=function(e){var t=[],n=null,r=function(){t=[...arguments],!n&&(n=requestAnimationFrame(function(){n=null,e.apply(void 0,t)}))};return r.cancel=function(){n&&=(cancelAnimationFrame(n),null)},r}(function(e){return e()}),dm=function(){var e=null;function t(t){e={frameId:requestAnimationFrame(function(){e=null,t()}),fn:t}}function n(){e&&=(cancelAnimationFrame(e.frameId),e.fn(),null)}return{schedule:t,flush:n}}();function fm(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function a(e){r(e),i={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var r=e.nativeSetDragImage,o={current:n,previous:i,initial:n};a({eventName:`onGenerateDragPreview`,payload:{source:t,location:o,nativeSetDragImage:r}}),dm.schedule(function(){a({eventName:`onDragStart`,payload:{source:t,location:o}})})},dragUpdate:function(e){var r=e.current;dm.flush(),um.cancel(),a({eventName:`onDropTargetChange`,payload:{source:t,location:{initial:n,previous:i,current:r}}})},drag:function(e){var r=e.current;um(function(){dm.flush(),a({eventName:`onDrag`,payload:{source:t,location:{initial:n,previous:i,current:r}}})})},drop:function(e){var r=e.current,o=e.updatedSourcePayload;dm.flush(),um.cancel(),a({eventName:`onDrop`,payload:{source:o??t,location:{current:r,previous:i,initial:n}}})}}}var pm={isActive:!1};function mm(){return!pm.isActive}function hm(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function gm(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function _m(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!mm())return;var a=ym({event:t,dragType:n,getDropTargetsOver:r});pm.isActive=!0;var o={current:a};vm({event:t,current:a.dropTargets});var s=fm({source:n.payload,dispatchEvent:i,initial:a});function c(e){var t=gm({current:o.current.dropTargets,next:e.dropTargets});o.current=e,t&&s.dragUpdate({current:o.current})}function l(e){var t=lm(e),i=r({target:Op(e.target)?kp({x:t.clientX,y:t.clientY}):e.target,input:t,source:n.payload,current:o.current.dropTargets});i.length&&(e.preventDefault(),vm({event:e,current:i})),c({dropTargets:i,input:t})}function u(){o.current.dropTargets.length&&c({dropTargets:[],input:o.current.input}),s.drop({current:o.current,updatedSourcePayload:null}),d()}function d(){pm.isActive=!1,f()}var f=(0,Ep.bindAll)(window,[{type:`dragover`,listener:function(e){l(e),s.drag({current:o.current})}},{type:`dragenter`,listener:l},{type:`dragleave`,listener:function(e){sm({dragLeave:e})&&(c({input:o.current.input,dropTargets:[]}),n.startedFrom===`external`&&u())}},{type:`drop`,listener:function(e){if(o.current={dropTargets:o.current.dropTargets,input:lm(e)},!o.current.dropTargets.length){u();return}e.preventDefault(),vm({event:e,current:o.current.dropTargets}),s.drop({current:o.current,updatedSourcePayload:n.type===`external`?n.getDropPayload(e):null}),d()}},{type:`dragend`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:lm(e)},u()}}].concat(em(cm({onDragEnd:u}))),{capture:!0});s.start({nativeSetDragImage:hm(t)})}function vm(e){var t=e.event,n=e.current[0]?.dropEffect;n!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=n)}function ym(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=lm(t);return n.startedFrom===`external`?{input:i,dropTargets:[]}:{input:i,dropTargets:r({input:i,source:n.payload,target:t.target,current:[]})}}var bm={canStart:mm,start:_m},xm=new Map;function Sm(e){var t=e.typeKey,n=e.mount,r=xm.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return xm.set(t,i),i}function Cm(e){var t=Sm(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),xm.delete(e.typeKey))}}function wm(){var e=[...arguments];return function(){e.forEach(function(e){return e()})}}function Tm(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function Em(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Dm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Em(Object(n),!0).forEach(function(t){Np(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Em(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Om(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=km(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
26
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function km(e,t){if(e){if(typeof e==`string`)return Am(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Am(e,t):void 0}}function Am(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function jm(e){return e.slice(0).reverse()}function Mm(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i=`data-drop-target-for-${t}`,a=`[${i}]`;function o(e){return r.set(e.element,e),function(){return r.delete(e.element)}}function s(e){return Ip(wm(Tm(e.element,{attribute:i,value:`true`}),o(e)))}function c(e){var t=e.source,i=e.target,o=e.input,s=e.result,l=s===void 0?[]:s;if(i==null)return l;if(!(i instanceof Element))return i instanceof Node?c({source:t,target:i.parentElement,input:o,result:l}):l;var u=i.closest(a);if(u==null)return l;var d=r.get(u);if(d==null)return l;var f={input:o,source:t,element:d.element};if(d.canDrop&&!d.canDrop(f))return c({source:t,target:d.element.parentElement,input:o,result:l});var p=d.getData?.call(d,f)??{},m=d.getDropEffect?.call(d,f)??n,h={data:p,element:d.element,dropEffect:m,isActiveDueToStickiness:!1};return c({source:t,target:d.element.parentElement,input:o,result:[].concat(em(l),[h])})}function l(e){var t=e.eventName,n=e.payload,i=Om(n.location.current.dropTargets),a;try{for(i.s();!(a=i.n()).done;){var o,s=a.value,c=r.get(s.element),l=Dm(Dm({},n),{},{self:s});c==null||(o=c[t])==null||o.call(c,l)}}catch(e){i.e(e)}finally{i.f()}}var u={onGenerateDragPreview:l,onDrag:l,onDragStart:l,onDrop:l,onDropTargetChange:function(e){var t=e.payload,n=new Set(t.location.current.dropTargets.map(function(e){return e.element})),i=new Set,a=Om(t.location.previous.dropTargets),o;try{for(a.s();!(o=a.n()).done;){var s,c=o.value;i.add(c.element);var l=r.get(c.element),u=n.has(c.element),d=Dm(Dm({},t),{},{self:c});if(l==null||(s=l.onDropTargetChange)==null||s.call(l,d),!u){var f;l==null||(f=l.onDragLeave)==null||f.call(l,d)}}}catch(e){a.e(e)}finally{a.f()}var p=Om(t.location.current.dropTargets),m;try{for(p.s();!(m=p.n()).done;){var h,g,_=m.value;if(!i.has(_.element)){var v=Dm(Dm({},t),{},{self:_}),y=r.get(_.element);y==null||(h=y.onDropTargetChange)==null||h.call(y,v),y==null||(g=y.onDragEnter)==null||g.call(y,v)}}}catch(e){p.e(e)}finally{p.f()}}};function d(e){u[e.eventName](e)}function f(e){var t=e.source,n=e.target,i=e.input,a=e.current,o=c({source:t,target:n,input:i});if(o.length>=a.length)return o;for(var s=jm(a),l=jm(o),u=[],d=0;d<s.length;d++){var f,p=s[d],m=l[d];if(m!=null){u.push(m);continue}var h=u[d-1],g=s[d-1];if(h?.element!==g?.element)break;var _=r.get(p.element);if(!_)break;var v={input:i,source:t,element:_.element};if(_.canDrop&&!_.canDrop(v)||!((f=_.getIsSticky)!=null&&f.call(_,v)))break;u.push(Dm(Dm({},p),{},{isActiveDueToStickiness:!0}))}return jm(u)}return{dropTargetForConsumers:s,getIsOver:f,dispatchEvent:d}}function Nm(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Pm(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
27
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function Pm(e,t){if(e){if(typeof e==`string`)return Fm(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fm(e,t):void 0}}function Fm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Im(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Lm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Im(Object(n),!0).forEach(function(t){Np(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Im(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Rm(){var e=new Set,t=null;function n(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}function r(r){var i=Lm({},r);e.add(i),n(i);function a(){e.delete(i),t&&t.active.delete(i)}return Ip(a)}function i(r){var i=r.eventName,a=r.payload;if(i===`onGenerateDragPreview`){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var o=Nm(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;n(c)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var l=Array.from(t.active),u=0,d=l;u<d.length;u++){var f=d[u];if(t.active.has(f)){var p;(p=f[i])==null||p.call(f,a)}}i===`onDrop`&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function zm(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,a=e.defaultDropEffect,o=Rm(),s=Mm({typeKey:t,defaultDropEffect:a});function c(e){r?.(e),s.dispatchEvent(e),o.dispatchEvent(e),i?.(e)}function l(e){var t=e.event,n=e.dragType;bm.start({event:t,dragType:n,getDropTargetsOver:s.getIsOver,dispatchEvent:c})}function u(){function e(){return n({canStart:bm.canStart,start:l})}return Cm({typeKey:t,mount:e})}return{registerUsage:u,dropTarget:s.dropTargetForConsumers,monitor:o.monitorForConsumers}}var Bm=Ip(function(){return navigator.userAgent.toLocaleLowerCase().includes(`android`)}),Vm=`pdnd:android-fallback`,Hm=`text/plain`,Um=`application/vnd.pdnd`,Wm=new WeakMap;function Gm(e){return Wm.set(e.element,e),function(){Wm.delete(e.element)}}var Km=Xp(),qm=zm({typeKey:`element`,defaultDropEffect:`move`,mount:function(e){return wm(Km.bindEvents(),(0,Ep.bind)(document,{type:`dragstart`,listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var n=t.target;if(n instanceof HTMLElement){var r=Wm.get(n);if(r){var i=lm(t),a={element:r.element,dragHandle:r.dragHandle??null,input:i};if(r.canDrag&&!r.canDrag(a)){t.preventDefault();return}if(r.dragHandle){var o=kp({x:i.clientX,y:i.clientY});if(!r.dragHandle.contains(o)){t.preventDefault();return}}var s=r.getInitialDataForExternal?.call(r,a)??null;if(s)for(var c=0,l=Object.entries(s);c<l.length;c++){var u=Cp(l[c],2),d=u[0],f=u[1];t.dataTransfer.setData(d,f??``)}Bm()&&!t.dataTransfer.types.includes(`text/plain`)&&!t.dataTransfer.types.includes(`text/uri-list`)&&t.dataTransfer.setData(Hm,Vm),t.dataTransfer.setData(Um,``);var p={type:`element`,payload:{element:r.element,dragHandle:r.dragHandle??null,data:r.getInitialData?.call(r,a)??{}},startedFrom:`internal`};e.start({event:t,dragType:p})}}}}}))},dispatchEventToSource:function(e){var t,n,r=e.eventName,i=e.payload;(t=Wm.get(i.source.element))==null||(n=t[r])==null||n.call(t,i)},onPostDispatch:Km.getOnPostDispatch()}),Jm=qm.dropTarget;qm.monitor;function Ym(e){return Ip(wm(qm.registerUsage(),Gm(e),Tm(e.element,{attribute:`draggable`,value:`true`})))}function Xm(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Zm(e,t){if(e==null)return{};var n,r,i=Xm(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Qm(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(function(n){return Object.is(e[n],t[n])})}function $m(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qm,t=null;return function(n){return t&&e(t.value,n)||(t={value:n}),t.value}}var eh=[`block`];function th(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?th(Object(n),!0).forEach(function(t){Np(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):th(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rh=Symbol(`tree-item-instruction`);function ih(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function ah(e){var t=e.client,n=e.borderBox,r=n.height/4;return t.y<=n.top+r?`reorder-above`:t.y>=n.bottom-r?`reorder-below`:`make-child`}function oh(e){var t=e.element,n=e.input,r=e.currentLevel,i=e.indentPerLevel,a=e.mode,o={x:n.clientX,y:n.clientY},s=t.getBoundingClientRect();if(a===`standard`)return{type:ah({borderBox:s,client:o}),indentPerLevel:i,currentLevel:r};var c=ih(s);if(a===`expanded`){var l=ah({borderBox:s,client:o});return{type:l===`reorder-above`?l:`make-child`,indentPerLevel:i,currentLevel:r}}var u=i*r;if(o.x<s.left+u){if(o.y<c.y)return{type:`reorder-above`,indentPerLevel:i,currentLevel:r};var d=(o.x-s.left)/i;return{type:`reparent`,desiredLevel:Math.max(Math.floor(d),0),indentPerLevel:i,currentLevel:r}}return{type:ah({borderBox:s,client:o}),indentPerLevel:i,currentLevel:r}}function sh(e,t){return e.type===t.type?e.type===`instruction-blocked`&&t.type===`instruction-blocked`?sh(e.desired,t.desired):Qm(e,t):!1}var ch=$m(sh);function lh(e){var t=e.desired,n=e.block;return n!=null&&n.includes(t.type)&&t.type!==`instruction-blocked`?{type:`instruction-blocked`,desired:t}:t}function uh(e,t){var n=t.block,r=ch(lh({desired:oh(Zm(t,eh)),block:n}));return nh(nh({},e),{},Np({},rh,r))}function dh(e){return e[rh]??null}var fh=1e3,ph=null,mh=`1px`,hh={width:mh,height:mh,padding:`0`,position:`absolute`,border:`0`,clip:`rect(${mh}, ${mh}, ${mh}, ${mh})`,overflow:`hidden`,whiteSpace:`nowrap`,marginTop:`-${mh}`,pointerEvents:`none`};function gh(){var e=document.createElement(`div`);return e.setAttribute(`role`,`status`),Object.assign(e.style,hh),document.body.append(e),e}function _h(){return ph===null&&(ph=gh()),ph}var vh=null;function yh(){vh!==null&&clearTimeout(vh),vh=null}function bh(e){_h(),yh(),vh=setTimeout(function(){vh=null;var t=_h();t.textContent=e},fh)}export{or as $,Bs as A,mi as B,Au as C,tl as D,fl as E,lo as F,jr as G,li as H,ba as I,xr as J,X as K,$i as L,fs as M,_o as N,Zc as O,go as P,lr as Q,Ai as R,rd as S,_u as T,Ur as U,pi as V,Mr as W,_r as X,Sr as Y,J as Z,Yf as _,Lt as _t,Jm as a,Ln as at,ud as b,gp as c,tn as ct,ip as d,K as dt,er as et,rp as f,Ht as ft,Xf as g,Mt as gt,Qf as h,Bt as ht,Ym as i,Un as it,Rs as j,Yc as k,dp as l,en as lt,tp as m,W as mt,uh as n,Wn as nt,wm as o,Vn as ot,op as p,zt as pt,Y as q,dh as r,Jn as rt,_p as s,Hn as st,bh as t,Qn as tt,ap as u,$t as ut,Zf as v,jt as vt,vu as w,id as x,Nf as y,xi as z};
|