@lattice-php/lattice 0.34.0 → 0.35.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./chunks/subscriptions-BV4g0s0U.js","./chunks/react-SIfiwpqq.js","./chunks/jsx-runtime-CN5ucv1d.js","./chunks/use-effect-dispatcher-CJXFkAv1.js","./chunks/locale-GyqtaX1O.js","./chunks/instance-C4O1XWa6.js","./chunks/timezone-CyoBch3a.js","./chunks/translatable-DLw4h3x8.js","./chunks/dist-DqlcM-vw.js","./chunks/chart-view-CR1X2aGE.js","./chunks/materialize-CWqnSEHR.js","./chunks/test-id-Dh3L6Gfh.js","./chunks/number-BvVKQqOG.js","./chunks/with-selector-zFUY-tQj.js","./chunks/date-picker-field-B4Xzow-A.js","./chunks/dist-ci5ng714.js","./chunks/time-picker-kbhOHEPd.js","./chunks/rich-editor-field-JM3jBEV1.js","./chunks/icon-button-D3AltHNz.js","./chunks/notifications-echo-uU87iJAV.js","./chunks/page-props-BHNNVkgJ.js","./chunks/shared-props-B_wT1GcG.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i,s as a}from"./chunks/locale-GyqtaX1O.js";import{n as o,t as s}from"./chunks/jsx-runtime-CN5ucv1d.js";import{a as c,c as l,d as u,f as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x}from"./chunks/use-effect-dispatcher-CJXFkAv1.js";import{n as S,t as C}from"./chunks/materialize-CWqnSEHR.js";import{o as w,r as T,s as E}from"./chunks/instance-C4O1XWa6.js";import{a as D,i as O,n as k,r as A}from"./chunks/timezone-CyoBch3a.js";import{t as j}from"./chunks/shared-props-B_wT1GcG.js";import{i as M,n as N,r as P,t as F}from"./chunks/test-id-Dh3L6Gfh.js";import{_ as I,b as L,g as R,h as ee,i as te,n as ne,r as re,t as z,v as B,y as ie}from"./chunks/dist-ci5ng714.js";import{n as ae,t as oe}from"./chunks/translatable-DLw4h3x8.js";import{$ as se,A as ce,B as le,C as ue,D as de,E as fe,F as pe,G as V,H as me,I as he,J as ge,K as H,L as _e,M as ve,N as ye,O as be,P as xe,Q as Se,R as Ce,S as we,T as Te,U as Ee,V as De,W as Oe,X as ke,Y as Ae,Z as je,_ as Me,a as Ne,at as Pe,b as Fe,c as Ie,ct as U,d as Le,dt as W,et as Re,f as ze,g as Be,h as Ve,i as He,it as Ue,j as We,k as Ge,l as Ke,lt as qe,m as Je,n as Ye,nt as Xe,o as Ze,ot as Qe,p as $e,q as et,r as tt,rt as nt,s as rt,st as it,t as at,tt as ot,u as st,ut as ct,v as lt,w as ut,x as dt,y as ft,z as pt}from"./chunks/icon-button-D3AltHNz.js";import{a as mt,c as G,i as ht,l as gt,n as _t,o as vt,r as yt,s as bt,t as xt}from"./chunks/time-picker-kbhOHEPd.js";import{a as St,i as Ct,n as wt,o as Tt,r as Et,t as Dt}from"./chunks/number-BvVKQqOG.js";var Ot=`X-Lattice-Ref`,kt=new Map;function At(e){return kt.get(e)??e}function jt(e,t){kt.set(e,t)}function Mt(e){let t=At(e);return t?{[Ot]:t}:{}}function Nt(e=``,t={}){return{...r(),...Mt(e),...t}}var Pt=class extends Error{response;constructor(e){super(`HTTP ${e.status}`),this.response=e}};function Ft(){let e=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):``}var It=1e4,Lt=new Map,Rt=new Map;function zt(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":Ft()}}var Bt=`/lattice/refs/refresh`;function Vt(e){Bt=e}var Ht=new Map;async function Ut(e){let t=Ht.get(e);if(t)return t;let n=Gt(Bt,{method:`POST`,body:JSON.stringify({ref:At(e)})}).then(t=>(jt(e,t.ref),t.ref)).catch(()=>null).finally(()=>{Ht.delete(e)});return Ht.set(e,n),n}async function Wt(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:Nt(n,{...zt(s),...r})}),l=await c();if(n!==``&&l.status===403&&await Ut(n)!==null&&(l=await c()),i&&!l.ok)throw new Pt(l);return l}async function Gt(e,t){return(await Wt(e,t)).json()}function Kt(e){return[e.source,e.audience,[...e.scopes].sort().join(` `)].join(``)}function qt(e){Lt.delete(Kt(e))}async function Jt(e){let t=Kt(e),n=Lt.get(t);if(n&&n.expiresAt>Date.now()+It)return n.token;let r=Rt.get(t);if(r)return r;let i=Gt(e.tokenEndpoint,{method:`POST`,ref:e.ref,body:JSON.stringify({nodeId:e.nodeId,nodeType:e.nodeType,audience:e.audience,scopes:e.scopes})}).then(e=>(Lt.set(t,{token:e,expiresAt:Date.now()+Math.max(0,e.expiresIn)*1e3}),e)).finally(()=>{Rt.delete(t)});return Rt.set(t,i),i}function Yt(e){return e.status===401||e.status===403}async function Xt(e,t,n){let{headers:i,...a}=t;return fetch(e,{...a,credentials:`omit`,headers:{Accept:`application/json`,...r(),...i,Authorization:`${n.tokenType} ${n.accessToken}`}})}async function Zt(e,t){let{remote:n,throwOnError:r=!0,...i}=t,a=await Jt(n),o=await Xt(e,i,a);if(Yt(o)&&(qt(n),a=await Jt(n),o=await Xt(e,i,a)),r&&!o.ok)throw new Pt(o);return o}async function Qt(e,t){return(await Zt(e,t)).json()}var K=e(t(),1),$t=`modulepreload`,en=function(e,t){return new URL(e,t).href},tn={},nn=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=en(t,n),t=s(t),t in tn)return;tn[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`:$t,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)})},rn=[`light`,`dark`,`system`],{subscribe:an,notify:on}=i(),sn=`system`;function cn(e){ln(e)}function ln(e){return rn.some(t=>t===e)}var un=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,dn=(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`},fn=()=>{if(typeof window>`u`)return`system`;let e=localStorage.getItem(`appearance`);return ln(e)?e:`system`},pn=e=>e===`dark`||e===`system`&&un(),mn=e=>{if(typeof document>`u`)return;let t=pn(e);document.documentElement.classList.toggle(`dark`,t),document.documentElement.style.colorScheme=t?`dark`:`light`},hn=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),gn=()=>{mn(sn),on()};function _n(e){sn=e,localStorage.setItem(`appearance`,e),dn(`appearance`,e),mn(e),on()}function vn(){typeof window>`u`||(localStorage.getItem(`appearance`)||(localStorage.setItem(`appearance`,`system`),dn(`appearance`,`system`)),sn=fn(),mn(sn),hn()?.addEventListener(`change`,gn))}function q(e){return{component:e,mode:`eager`}}function yn(e){return e}function bn(...e){return e.reduce((e,t)=>({components:{...e.components,...t.components},columns:{...e.columns,...t.columns},effects:{...e.effects,...t.effects}}),{components:{},columns:{},effects:{}})}function xn(e,...t){let n=bn(...t);return{components:{...e.components,...n.components},columns:{...e.columns,...n.columns},effects:{...e.effects,...n.effects}}}function Sn(e,t,n={}){let{enabled:r=!0}=n,i=(0,K.useRef)(t);i.current=t,(0,K.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 Cn({preserveScroll:e=!0,preserveState:t=!0}){return Sn(a.localeChange,n=>{let r=n.detail?.locale;typeof r==`string`&&r!==``&&m.visit(window.location.href,{preserveScroll:e,preserveState:t})}),null}function wn(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`):[]}function Tn(e,t){return e.key??e.id??`${e.type}-${t}`}var En=(0,K.createContext)(!1);function Dn(){return(0,K.useContext)(En)}var J=s();function On(){return(0,J.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,J.jsx)(`rect`,{height:`18`,rx:`2`,strokeDasharray:`4 3`,width:`18`,x:`3`,y:`3`}),(0,J.jsx)(`path`,{d:`M12 8v4`}),(0,J.jsx)(`path`,{d:`M12 16h.01`})]})}function kn({node:e}){e.type;let t=`Missing component: ${e.type}`;return(0,J.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,J.jsx)(On,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:t})]})}function Y({nodes:e}){return e.map((e,t)=>(0,J.jsx)(jn,{node:e},Tn(e,t)))}function An({node:e}){return(0,J.jsx)(jn,{node:e})}var jn=(0,K.memo)(function({node:e}){let t=Dn(),n=y()[e.type];if(t&&e.props?.hideWhenCollapsed===!0)return null;if(!n)return(0,J.jsx)(kn,{node:e});let r=n.component,i=e.schema?.length?(0,J.jsx)(Y,{nodes:e.schema}):null,a=(0,J.jsx)(r,{node:e,children:i});return n.mode===`lazy`?(0,J.jsx)(K.Suspense,{fallback:null,children:a}):a}),Mn=[`primary`,`secondary`,`success`,`info`,`warning`,`danger`];function Nn(e){return Mn.some(t=>t===e)}function Pn(e){let t=typeof e==`string`||oe(e)?e:null;return t===``?null:t}function Fn(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 In(e){if(typeof e!=`object`||!e)return null;let t=e,n=Pn(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:Nn(t.variant)?t.variant:`success`}}function Ln(e){return Fn(a.toast,In,e)}function Rn(e){if(typeof e!=`object`||!e)return null;let t=e,n=Pn(t.message);return n===null?null:{action:t.action??null,dismissible:t.dismissible!==!1,message:n,title:typeof t.title==`string`||oe(t.title)?t.title:null,unique:typeof t.unique==`string`?t.unique:null,variant:Nn(t.variant)?t.variant:`info`}}function zn(e){return Fn(a.callout,Rn,e)}function Bn(e){return Fn(a.retractCallout,e=>{let t=e?.unique;return typeof t==`string`?t:null},e)}var Vn=Object.defineProperty,X=(e,t)=>Vn(e,`name`,{value:t,configurable:!0});function Hn(e){let t=e+`CollectionProvider`,[n,r]=ct(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=X(e=>{let{scope:t,children:n}=e,r=K.useRef(null),a=K.useRef(new Map).current;return(0,J.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=ee(s),l=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=R(t,i.collectionRef);return(0,J.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ee(u),p=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),s=R(t,o),c=a(u,n);return K.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,J.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return K.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 X(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}X(Hn,`createCollection`);var Un=new WeakMap,Wn=class e extends Map{static{X(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Un.set(this,!0)}set(e,t){return Un.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=qn(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=Gn(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Gn(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Gn(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 Gn(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Kn(e,t);return n===-1?void 0:e[n]}X(Gn,`at`);function Kn(e,t){let n=e.length,r=qn(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}X(Kn,`toSafeIndex`);function qn(e){return e!==e||e===0?0:Math.trunc(e)}X(qn,`toSafeInteger`);function Jn(e){let t=e+`CollectionProvider`,[n,r]=ct(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Wn,setItemMap:X(()=>void 0,`setItemMap`)}),o=X(({state:e,...t})=>e?(0,J.jsx)(c,{...t,state:e}):(0,J.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=X(e=>{let t=h();return(0,J.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=X(e=>{let{scope:t,children:n,state:r}=e,a=K.useRef(null),[o,s]=K.useState(null),c=R(a,s),[l,u]=r;return K.useEffect(()=>{if(!o)return;let e=Qn(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,J.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=ee(l),d=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=R(t,i.collectionRef);return(0,J.jsx)(u,{ref:o,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=ee(f),m=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),[s,c]=K.useState(null),l=R(t,o,c),{setItemMap:u}=a(f,n),d=K.useRef(i);Yn(d.current,i)||(d.current=i);let m=d.current;return K.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Zn):(t.set(s,{...e,element:s}),t.toSorted(Zn)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Wn(e)))}},[s,m,u]),(0,J.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return K.useState(new Wn)}X(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return X(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}X(Jn,`createCollection`);function Yn(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}X(Yn,`shallowEqual`);function Xn(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}X(Xn,`isElementPreceding`);function Zn(e,t){return!e[1].element||!t[1].element?0:Xn(e[1].element,t[1].element)?-1:1}X(Zn,`sortByDocumentPosition`);function Qn(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}X(Qn,`getChildListObserver`);var $n=Object.defineProperty,er=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),tr=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`}),nr=K.forwardRef(er(function(e,t){return(0,J.jsx)(U.span,{...e,ref:t,style:{...tr,...e.style}})},`VisuallyHidden`)),rr=e(o(),1),ir=Object.defineProperty,Z=(e,t)=>ir(e,`name`,{value:t,configurable:!0}),ar=`ToastProvider`,[or,sr,cr]=Hn(`Toast`),[lr,ur]=ct(`Toast`,[cr]),[dr,fr]=lr(ar),pr=Z(e=>{let{__scopeToast:t,label:n=`Notification`,duration:r=5e3,swipeDirection:i=`right`,swipeThreshold:a=50,announcerContainer:o,children:s}=e,[c,l]=K.useState(null),[u,d]=K.useState(0),f=K.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${ar}\`. Expected non-empty \`string\`.`),(0,J.jsx)(or.Provider,{scope:t,children:(0,J.jsx)(dr,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:u,viewport:c,onViewportChange:l,onToastAdd:K.useCallback(()=>d(e=>e+1),[]),onToastRemove:K.useCallback(()=>d(e=>e-1),[]),isClosePausedRef:f,announcerContainer:o,children:s})})},`ToastProvider`),mr=`ToastViewport`,hr=[`F8`],gr=`toast.viewportPause`,_r=`toast.viewportResume`,vr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,hotkey:r=hr,label:i=`Notifications ({hotkey})`,...a}=e,o=fr(mr,n),s=sr(n),c=K.useRef(null),l=K.useRef(null),u=K.useRef(null),d=K.useRef(null),f=R(t,d,o.onViewportChange),p=r.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),m=o.toastCount>0;K.useEffect(()=>{let e=Z(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]),K.useEffect(()=>{let e=c.current,t=d.current;if(m&&e&&t){let n=Z(()=>{if(!o.isClosePausedRef.current){let e=new CustomEvent(gr);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},`handlePause`),r=Z(()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(_r);t.dispatchEvent(e),o.isClosePausedRef.current=!1}},`handleResume`),i=Z(t=>{e.contains(t.relatedTarget)||r()},`handleFocusOutResume`),a=Z(()=>{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=K.useCallback(({tabbingDirection:e})=>{let t=s().map(t=>{let n=t.ref.current,r=[n,...Br(n)];return e===`forwards`?r:r.reverse()});return(e===`forwards`?t.reverse():t).flat()},[s]);return K.useEffect(()=>{let e=d.current;if(e){let t=Z(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);Vr(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,J.jsxs)(nt,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,J.jsx)(br,{ref:l,onFocusFromOutsideViewport:()=>{Vr(h({tabbingDirection:`forwards`}))}}),(0,J.jsx)(or.Slot,{scope:n,children:(0,J.jsx)(U.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,J.jsx)(br,{ref:u,onFocusFromOutsideViewport:()=>{Vr(h({tabbingDirection:`backwards`}))}})]})},`ToastViewport`)),yr=`ToastFocusProxy`,br=K.forwardRef(Z(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=fr(yr,n);return(0,J.jsx)(nr,{tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})},`ToastFocusProxy`)),xr=`Toast`,Sr=`toast.swipeStart`,Cr=`toast.swipeMove`,wr=`toast.swipeCancel`,Tr=`toast.swipeEnd`,Er=K.forwardRef(Z(function(e,t){let{forceMount:n,open:r,defaultOpen:i,onOpenChange:a,...o}=e,[s,c]=se({prop:r,defaultProp:i??!0,onChange:a,caller:xr});return(0,J.jsx)(Re,{present:n||s,children:(0,J.jsx)(kr,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:it(e.onPause),onResume:it(e.onResume),onSwipeStart:W(e.onSwipeStart,e=>{e.currentTarget.setAttribute(`data-swipe`,`start`)}),onSwipeMove:W(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:W(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:W(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`)),[Dr,Or]=lr(xr,{onClose(){}}),kr=K.forwardRef(Z(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=fr(xr,n),g=sr(n),[_,v]=K.useState(null),y=R(t,v),b=K.useRef(null),x=K.useRef(null),S=i||h.duration,C=K.useRef(0),w=K.useRef(S),T=K.useRef(0),{onToastAdd:E,onToastRemove:D}=h,O=it(()=>{_?.contains(document.activeElement)&&h.viewport?.focus(),o()}),k=K.useCallback(e=>{!e||e===1/0||(window.clearTimeout(T.current),C.current=new Date().getTime(),T.current=window.setTimeout(O,e))},[O]);K.useEffect(()=>{let e=h.viewport;if(e){let t=Z(()=>{k(w.current),l?.()},`handleResume`),n=Z(()=>{let e=new Date().getTime()-C.current;w.current-=e,window.clearTimeout(T.current),c?.()},`handlePause`);return e.addEventListener(gr,n),e.addEventListener(_r,t),()=>{e.removeEventListener(gr,n),e.removeEventListener(_r,t)}}},[h.viewport,S,c,l,k]),K.useEffect(()=>{a&&!h.isClosePausedRef.current&&k(S)},[a,S,h.isClosePausedRef,k]),K.useEffect(()=>()=>{window.clearTimeout(T.current)},[]),K.useEffect(()=>(E(),()=>D()),[E,D]);let A=K.useMemo(()=>_?Fr(_):null,[_]);return h.viewport?(0,J.jsxs)(J.Fragment,{children:[A&&(0,J.jsx)(Ar,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,children:A}),(0,J.jsx)(Dr,{scope:n,onClose:O,children:rr.createPortal((0,J.jsx)(or.ItemSlot,{scope:n,children:(0,J.jsx)(Pe,{asChild:!0,onEscapeKeyDown:W(s,e=>{g().some(t=>t.ref.current?.contains(e.target))||O()}),children:(0,J.jsx)(U.li,{tabIndex:0,"data-state":a?`open`:`closed`,"data-swipe-direction":h.swipeDirection,...m,ref:y,style:{userSelect:`none`,touchAction:`none`,...e.style},onKeyDown:W(e.onKeyDown,e=>{e.key===`Escape`&&(s?.(e.nativeEvent),e.nativeEvent.defaultPrevented||O())}),onPointerDown:W(e.onPointerDown,e=>{e.button===0&&(b.current={x:e.clientX,y:e.clientY})}),onPointerMove:W(e.onPointerMove,e=>{if(!b.current)return;let t=e.clientX-b.current.x,n=e.clientY-b.current.y,r=!!x.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?(x.current=l,Ir(Cr,d,f,{discrete:!1})):Lr(l,h.swipeDirection,c)?(x.current=l,Ir(Sr,u,f,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(n)>c)&&(b.current=null)}),onPointerUp:W(e.onPointerUp,e=>{let t=x.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),x.current=null,b.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};Lr(t,h.swipeDirection,h.swipeThreshold)?Ir(Tr,p,r,{discrete:!0}):Ir(wr,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null},`ToastImpl`)),Ar=Z(e=>{let{__scopeToast:t,children:n,...r}=e,i=fr(xr,t),[a,o]=K.useState(!1),[s,c]=K.useState(!1);return Rr(()=>o(!0)),K.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,J.jsx)(ot,{asChild:!0,container:i.announcerContainer||void 0,children:(0,J.jsx)(nr,{...r,children:a&&(0,J.jsxs)(J.Fragment,{children:[i.label,` `,n]})})})},`ToastAnnounce`),jr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e;return(0,J.jsx)(U.div,{...r,ref:t})},`ToastTitle`)),Mr=`ToastClose`,Nr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e,i=Or(Mr,n);return(0,J.jsx)(Pr,{asChild:!0,children:(0,J.jsx)(U.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,i.onClose)})})},`ToastClose`)),Pr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,altText:r,...i}=e;return(0,J.jsx)(U.div,{"data-radix-toast-announce-exclude":``,"data-radix-toast-announce-alt":r||void 0,...i,ref:t})},`ToastAnnounceExclude`));function Fr(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),zr(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(...Fr(e))}}),t}Z(Fr,`getAnnounceTextContent`);function Ir(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?qe(i,a):i.dispatchEvent(a)}Z(Ir,`handleAndDispatchCustomEvent`);var Lr=Z((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 Rr(e=()=>{}){let t=it(e);Xe(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}Z(Rr,`useNextFrame`);function zr(e){return e.nodeType===e.ELEMENT_NODE}Z(zr,`isHTMLElement`);function Br(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Z(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}Z(Br,`getTabbableCandidates`);function Vr(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}Z(Vr,`focusFirst`);var Hr=pr,Ur=vr,Wr=Er,Gr=jr,Kr=Nr;function qr({value:e,dateStyle:t=`medium`,timeStyle:r=`short`}){let{locale:i}=n(),{timezone:a}=k();if(e==null||e===``)return null;let o={locale:i,timeZone:a},s=A(e,{dateStyle:t,timeStyle:r},o),c=Jr(e),l=O(e,o);return(0,J.jsx)(`time`,{dateTime:c??void 0,title:l||void 0,children:s})}function Jr(e){return D(e)?.toISOString()??null}var Yr={primary:{accent:`border-l-lt-primary`,icon:(0,J.jsx)(B,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-primary`})},secondary:{accent:`border-l-lt-secondary`,icon:(0,J.jsx)(B,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-muted-fg`})},success:{accent:`border-l-lt-success`,icon:(0,J.jsx)(B,{name:`circle-check`,className:`size-lt-icon-lg shrink-0 text-lt-success`})},info:{accent:`border-l-lt-info`,icon:(0,J.jsx)(B,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-info`})},warning:{accent:`border-l-lt-warning`,icon:(0,J.jsx)(B,{name:`circle-alert`,className:`size-lt-icon-lg shrink-0 text-lt-warning`})},danger:{accent:`border-l-lt-danger`,icon:(0,J.jsx)(B,{name:`circle-x`,className:`size-lt-icon-lg shrink-0 text-lt-danger`})}},Xr=0;function Zr({duration:e=4e3}){let{t}=E(`lattice`),[n,r]=(0,K.useState)([]);function i(e){r(t=>t.filter(t=>t.id!==e))}return(0,K.useEffect)(()=>Ln(e=>{r(t=>[...t,{...e,id:Xr++}])}),[]),(0,J.jsxs)(Hr,{duration:e,swipeDirection:`down`,children:[n.map(n=>(0,J.jsxs)(Wr,{className:L(`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`,Yr[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:[Yr[n.variant].icon,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsx)(Gr,{className:`text-sm text-lt-fg`,children:ae(n.message,t)}),n.action?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,J.jsx)(An,{node:n.action})}):null]}),n.dismissible?(0,J.jsx)(Kr,{"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,J.jsx)(B,{name:`x`,className:`size-lt-icon-md`})}):null]},n.id)),(0,J.jsx)(Ur,{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 Qr=0,$r=()=>{let{t:e}=E(`lattice`),[t,n]=(0,K.useState)([]);(0,K.useEffect)(()=>zn(e=>{n(t=>[...e.unique?t.filter(t=>t.unique!==e.unique):t,{...e,id:Qr++}])}),[]),(0,K.useEffect)(()=>m.on(`navigate`,()=>{n(e=>e.filter(e=>!e.unique))}),[]),(0,K.useEffect)(()=>Bn(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,J.jsx)(`div`,{className:`flex w-full flex-col gap-2`,children:t.map(t=>(0,J.jsxs)(`div`,{role:`status`,"data-test":`callout-${t.variant}`,className:L(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg`,Yr[t.variant].accent),children:[Yr[t.variant].icon,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[t.title?(0,J.jsx)(`p`,{className:`text-sm font-medium text-lt-fg`,children:ae(t.title,e)}):null,(0,J.jsx)(`p`,{className:`text-sm text-lt-fg`,children:ae(t.message,e)}),t.action?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,J.jsx)(An,{node:t.action})}):null]}),t.dismissible?(0,J.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,J.jsx)(B,{name:`x`,className:`size-lt-icon-md`})}):null]},t.id))})},ei=({node:e})=>{let{t}=E(`lattice`),n=d().props.lattice?.breadcrumbs??[];return n.length===0?null:(0,J.jsx)(`nav`,{"aria-label":t(`common.breadcrumb`,`Breadcrumb`),"data-lattice-component":F(e),children:(0,J.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,J.jsxs)(K.Fragment,{children:[(0,J.jsx)(`li`,{children:r?(0,J.jsx)(`span`,{"aria-current":`page`,className:`text-lt-fg`,children:e.title}):(0,J.jsx)(x,{className:`hover:text-lt-fg`,href:e.href,children:e.title})}),r?null:(0,J.jsx)(`li`,{"aria-hidden":`true`,children:`/`})]},e.href)})})})};function ti({align:e=`start`,children:t,className:n,placement:r=`bottom`,testId:i,trigger:a,triggerClassName:o,triggerLabel:s}){let[c,l]=(0,K.useState)(!1),u=d().url;return(0,K.useEffect)(()=>l(!1),[u]),(0,J.jsxs)(Oe,{open:c,onOpenChange:l,children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(`button`,{"aria-label":s,className:L(`w-full`,o),"data-test":i,title:s,type:`button`,children:a})}),(0,J.jsx)(V,{align:e,className:L(`min-w-56 p-1`,n),role:`menu`,side:r,children:(0,J.jsx)(En.Provider,{value:!1,children:t})})]})}var ni=({children:e,node:t})=>{let n=t.key??`dropdown`;return(0,J.jsx)(ti,{placement:t.props.placement,testId:n,triggerClassName:`w-auto`,trigger:(0,J.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,J.jsx)(An,{node:e},e.key??`${e.type}-${t}`))}),children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})})},ri=({children:e,node:t})=>(0,J.jsx)(`nav`,{"data-lattice-component":F(t),children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})}),ii=(0,K.createContext)(null),ai=`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 oi({affix:e,className:t}){return e.icon?(0,J.jsx)(I,{className:L(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,J.jsx)(`span`,{className:L(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function si(e,t){return(e??[]).some(e=>e.props?.href===t||si(e.schema,t))}var ci=({children:e,node:t})=>{let n=Dn(),{icon:r,label:i,prefix:a,suffix:o}=t.props,s=i??``,c=!!r,l=r??a?.icon??null,u=d().url.split(`?`)[0],f=N(`menu`,t),p=te(t.props),m=r?(0,J.jsx)(I,{className:`size-lt-icon-md shrink-0`,icon:r}):(0,J.jsxs)(J.Fragment,{children:[a?(0,J.jsx)(oi,{affix:a}):null,n?(0,J.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:s}):(0,J.jsx)(`span`,{children:s}),o?(0,J.jsx)(oi,{affix:o,className:`ml-auto`}):null]}),h=L(ai,`w-full`,n&&`group relative justify-center`,c&&`justify-center`),g=({onClick:e,processing:t})=>(0,J.jsx)(`button`,{"aria-label":n||c?s:void 0,className:h,"data-test":f,disabled:t,onClick:e,type:`button`,children:m});if(p.kind===`action`)return(0,J.jsx)(`li`,{children:(0,J.jsx)(ne,{action:p.action,children:g})});if(p.kind===`effects`)return(0,J.jsx)(`li`,{children:g({onClick:p.onClick,processing:!1})});if(p.kind===`navigate`){let e=u===p.href;return(0,J.jsx)(`li`,{children:(0,J.jsx)(x,{"aria-current":e?`page`:void 0,"aria-label":n||c?s:void 0,as:p.method===`get`?void 0:`button`,className:L(h,e&&`bg-lt-muted font-medium`),"data-test":f,href:p.href,method:p.method,children:m})})}return e?n?(0,J.jsx)(ui,{icon:l,label:s,testId:f,children:e}):(0,J.jsx)(li,{content:m,defaultOpen:si(t.schema,u),testId:f,children:e}):n?null:(0,J.jsx)(`li`,{children:(0,J.jsx)(`span`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:m})})};function li({children:e,content:t,defaultOpen:n,testId:r}){let[i,a]=(0,K.useState)(n);return(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(`button`,{"aria-expanded":i,className:L(ai,`w-full`),"data-test":r,onClick:()=>a(e=>!e),type:`button`,children:[t,(0,J.jsx)(B,{name:`chevron-right`,className:L(`ml-auto size-lt-icon-md shrink-0 transition-transform`,i&&`rotate-90`)})]}),i?(0,J.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1 pl-3`,children:e}):null]})}function ui({children:e,icon:t,label:n,testId:r}){return(0,J.jsx)(`li`,{children:(0,J.jsx)(ti,{className:`min-w-48`,placement:`right`,testId:r,trigger:t?(0,J.jsx)(I,{className:`size-lt-icon-md shrink-0`,icon:t}):(0,J.jsx)(`span`,{children:n}),triggerClassName:L(ai,`justify-center`),triggerLabel:n,children:(0,J.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`li`,{className:`px-3 py-1.5 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:n}),e]})})})}var di=()=>(0,J.jsx)(J.Fragment,{children:(0,K.useContext)(ii)});function fi(e,t){return typeof window>`u`||typeof window.matchMedia!=`function`?t:window.matchMedia(e).matches}function pi(e,t=!1){let[n,r]=(0,K.useState)(()=>fi(e,t));return(0,K.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}function mi(e,t,n={}){let{enabled:r=!0,parse:i,serialize:a}=n,o=()=>typeof t==`function`?t():t,[s,c]=(0,K.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,K.useRef)(s);l.current=s;let u=(0,K.useRef)({enabled:r,key:e,serialize:a});return u.current={enabled:r,key:e,serialize:a},[s,(0,K.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}},[])]}function hi(e,t,n){let[r,i]=mi(e,t,{enabled:n,parse:e=>e===`true`,serialize:String});return[r,(0,K.useCallback)(()=>i(e=>!e),[i])]}var gi=`(min-width: 768px)`;function _i(e,t){let n=e.detail?.target;return n==null||n===t}var vi=yn({components:{breadcrumbs:q(ei),callouts:q($r),dropdown:q(ni),menu:q(ri),"menu-item":q(ci),outlet:q(di),sidebar:q(({children:e,node:t})=>{let n=t.props.collapsible,r=t.props.rememberState,i=F(t),o=`lattice:sidebar:${i??`default`}`,s=pi(gi,!0),[c,l]=hi(o,!1,n&&r),[u,d]=(0,K.useState)(!1);Sn(a.toggleSidebar,e=>{_i(e,i)&&(window.matchMedia?.(gi).matches??!0?n&&l():d(e=>!e))}),(0,K.useEffect)(()=>m.on(`navigate`,()=>d(!1)),[]),Sn(`keydown`,e=>{e.key===`Escape`&&d(!1)},{enabled:u});let f=n&&c&&s;return(0,J.jsxs)(En.Provider,{value:f,children:[u?(0,J.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,J.jsx)(`aside`,{className:L(`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]`,u?`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:q(({children:e,node:t})=>{let n=t.props.sticky;return(0,J.jsx)(`header`,{"data-lattice-component":F(t),className:L(`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 yi({children:e}){let t=d().props.lattice.layout;return t?(0,J.jsx)(ii.Provider,{value:e,children:(0,J.jsx)(Y,{nodes:t.schema})}):(0,J.jsx)(J.Fragment,{children:e})}var bi=(0,K.lazy)(()=>nn(()=>import(`./chunks/subscriptions-BV4g0s0U.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),xi=class extends K.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 Si({listeners:e}){return e.length===0?null:(0,J.jsx)(xi,{children:(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(bi,{listeners:e})})})}function Ci({lattice:e}){let t=(0,J.jsx)(Y,{nodes:e.schema});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{title:e.title??void 0}),(0,J.jsx)(Si,{listeners:e.listeners}),e.container===`centered`?(0,J.jsx)(`main`,{className:`min-h-svh bg-lt-bg text-lt-fg`,children:(0,J.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,J.jsx)(`div`,{"data-test":`lattice-default-container`,className:L(`w-full`,{"px-4 py-6":e.layout!==null}),children:t})]})}function wi(e){return t=>{if(t===`lattice/page`)return{default:Ci};let n=e[`./Pages/${t}.tsx`]??e[`./pages/${t}.tsx`];if(n)return n();throw Error(`Page not found: ${t}`)}}function Ti({defaultLayout:e}={}){return(t,n)=>t===`lattice/page`?n.props.lattice?.layout?yi:null:e?.(t,n)??null}function Ei(e,t){return{...t,headers:Nt(``,t.headers)}}var Di=!1;function Oi(){Di||(Di=!0,_.onRequest(e=>{let t=e.headers?.[Ot];return e.headers&&typeof t==`string`&&t!==``&&(e.headers[Ot]=At(t)),e}))}var ki=Object.defineProperty,Q=(e,t)=>ki(e,`name`,{value:t,configurable:!0}),Ai=`Dialog`,[ji,Mi]=ct(Ai),[Ni,Pi]=ji(Ai),Fi=Q(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=K.useRef(null),c=K.useRef(null),[l,u]=se({prop:r,defaultProp:i??!1,onChange:a,caller:Ai}),[d,f]=K.useState(0),[p,m]=K.useState(0);return(0,J.jsx)(Ni,{scope:t,triggerRef:s,contentRef:c,contentId:ke(),titleId:ke(),descriptionId:ke(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:K.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Ii=`DialogPortal`,[Li,Ri]=ji(Ii,{forceMount:void 0}),zi=Q(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Pi(Ii,t);return(0,J.jsx)(Li,{scope:t,forceMount:n,children:K.Children.map(r,e=>(0,J.jsx)(Re,{present:n||a.open,children:(0,J.jsx)(ot,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Bi=`DialogOverlay`,Vi=K.forwardRef(Q(function(e,t){let n=Ri(Bi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Pi(Bi,e.__scopeDialog);return a.modal?(0,J.jsx)(Re,{present:r||a.open,children:(0,J.jsx)(Ui,{...i,ref:t})}):null},`DialogOverlay`)),Hi=ee(`DialogOverlay.RemoveScroll`),Ui=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Bi,n),a=Qe(),o=R(t,a);return(0,J.jsx)(et,{as:Hi,allowPinchZoom:!0,shards:[i.contentRef],children:(0,J.jsx)(U.div,{"data-state":ta(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Wi=`DialogContent`,Gi=K.forwardRef(Q(function(e,t){let n=Ri(Wi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Pi(Wi,e.__scopeDialog);return(0,J.jsx)(Re,{present:r||a.open,children:a.modal?(0,J.jsx)(Ki,{...i,ref:t}):(0,J.jsx)(qi,{...i,ref:t})})},`DialogContent`)),Ki=K.forwardRef(Q(function(e,t){let n=Pi(Wi,e.__scopeDialog),r=K.useRef(null),i=R(t,n.contentRef,r);return K.useEffect(()=>{let e=r.current;if(e)return ge(e)},[]),(0,J.jsx)(Ji,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:W(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),qi=K.forwardRef(Q(function(e,t){let n=Pi(Wi,e.__scopeDialog),r=K.useRef(!1),i=K.useRef(!1);return(0,J.jsx)(Ji,{...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`)),Ji=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Pi(Wi,n);return Se(),(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(je,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,J.jsx)(Ue,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":ta(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Yi=`DialogTitle`,Xi=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Yi,n),{setTitleCount:a}=i;return Xe(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,J.jsx)(U.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Zi=`DialogDescription`,Qi=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Zi,n),{setDescriptionCount:a}=i;return Xe(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,J.jsx)(U.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),$i=`DialogClose`,ea=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi($i,n);return(0,J.jsx)(U.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function ta(e){return e?`open`:`closed`}Q(ta,`getState`);var na=z(`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 max-h-[min(680px,calc(100vh-2rem))] -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`}},defaultVariants:{placement:`center`,width:`lg`}});function ra(e){return(0,J.jsx)(Fi,{"data-slot":`dialog`,...e})}function ia(e){return(0,J.jsx)(ea,{"data-slot":`dialog-close`,...e})}function aa({className:e,...t}){return(0,J.jsx)(Xi,{className:L(`text-lg font-semibold leading-none tracking-tight`,e),"data-slot":`dialog-title`,...t})}function oa({className:e,...t}){return(0,J.jsx)(Qi,{className:L(`text-sm text-lt-muted-fg`,e),"data-slot":`dialog-description`,...t})}function sa({children:e,className:t,placement:n=`center`,width:r=`lg`,...i}){return(0,J.jsxs)(zi,{children:[(0,J.jsx)(Vi,{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,J.jsx)(Gi,{className:L(na({placement:n,width:r}),t),"data-slot":`dialog-content`,...i,children:e})]})}function ca({closeLabel:e,description:t,title:n}){return(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[(0,J.jsx)(aa,{children:n}),t?(0,J.jsx)(oa,{children:t}):null]}),(0,J.jsx)(ia,{asChild:!0,children:(0,J.jsx)(G,{"aria-label":e,"data-test":`dialog-close`,size:`icon`,emphasis:`ghost`,children:(0,J.jsx)(B,{name:`x`,"aria-hidden":`true`,className:`size-lt-icon-md`})})})]})}function la({className:e,...t}){let{t:n}=E(`lattice`);return(0,J.jsx)(B,{name:`loader-2`,role:`status`,"aria-label":n(`common.loading`,`Loading`),"aria-hidden":!1,className:L(`animate-spin`,e),...t})}function ua({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,J.jsx)(ra,{open:!0,onOpenChange:e=>{e||l()},children:(0,J.jsxs)(sa,{...t?{}:{"aria-describedby":void 0},width:`md`,onEscapeKeyDown:u,onInteractOutside:u,children:[(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[(0,J.jsx)(aa,{children:e}),t&&(0,J.jsx)(oa,{children:t})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,J.jsx)(G,{type:`button`,emphasis:`outline`,"data-test":`confirm-cancel`,disabled:o,onClick:l,children:r}),(0,J.jsxs)(G,{type:`button`,emphasis:a,variant:i,"data-test":`confirm-accept`,disabled:o||s,onClick:c,children:[o&&(0,J.jsx)(la,{}),n]})]})]})})}async function da(e,t){try{let n=await e(),r=await n.json().catch(()=>({}));return t(v(r.effects)),n.ok}catch(e){return h(e),!1}}function fa({className:e,...t}){return(0,J.jsx)(`div`,{"aria-hidden":`true`,className:L(`animate-pulse rounded-lt-sm bg-lt-muted`,e),"data-slot":`skeleton`,...t})}var pa=(0,K.createContext)({});function ma({nodes:e,children:t}){return(0,J.jsx)(pa.Provider,{value:e,children:t})}function ha(e){let t=(0,K.useContext)(pa),n=pt(e).name??``,r=ut(),i=n&&r?r.errorKey(n):n;return i&&t[i]||n&&t[n]||e}var ga=typeof window>`u`?K.useEffect:K.useLayoutEffect;function _a(e,t,n,r){return Wt(e,{method:`POST`,ref:t,signal:r,body:JSON.stringify(n),throwOnError:!1}).then(e=>e.ok?e.json():null)}function va(e){return e.templates}function ya(e,t){let n=va(e);return n?n.find(e=>e.type===t.type)?.schema??[]:e.schema??[]}function ba(e,t){return e.startsWith(`@`)?e.slice(1):t===null?e:xe(t,e)}function xa(e,t,n,r=0,i={}){let a=pt(e);if(!a.editablePrefill||!a.name)return null;let o=fe(i);return{path:t===null?a.name:xe(t,a.name),overrideKey:n===null?a.name:Te(n,o,r,a.name),resetOn:(a.prefillResetOn??[]).map(e=>ba(e,t)),refreshOn:(a.prefillRefreshOn??[]).map(e=>ba(e,t))}}function Sa(e,t){let n=[],r=(e,i=null,a=null,o=null,s=0,c={})=>{for(let l of e??[]){if(Ce.has(l.type)){let e=pt(l).name;if(e){let n=xe(i,e),o=xe(a,e),s=pe(t,n);(Array.isArray(s)?s:[]).forEach((e,t)=>{r(ya(l,e),xe(n,t),xe(o,fe(e)??t),o,t,e)})}continue}let e=xa(l,i,o,s,c);e&&n.push(e),r(l.schema,i,a,o,s,c)}};return r(e),n}function Ca(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(pe(e.values,a),pe(t.values,n))})}).map(e=>e.overrideKey)}function wa(e,t){return e.filter(e=>{let n=pe(t,e.path);return n!=null&&n!==``}).map(e=>e.overrideKey)}function Ta(e,t){let n=new Set(t.map(e=>e.overrideKey));return new Set([...e].filter(e=>n.has(e)))}function Ea(e,t,n){let r=Fe(),i=we(),[a,o]=(0,K.useState)({}),s=(0,K.useMemo)(()=>Sa(n,r),[n,r]),c=(0,K.useRef)(new Set),l=(0,K.useRef)(new Set),u=(0,K.useRef)(r),d=(0,K.useRef)(s),f=(0,K.useRef)(s);f.current=s,ga(()=>{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 wa(t,r))c.current.add(e);for(let e of t)l.current.add(e.overrideKey)},[s,r]);let p=(0,K.useCallback)(e=>{c.current.add(e)},[]),m=(0,K.useMemo)(()=>{let e=new Set,t=!1;return le(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,K.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=>pe(r,e)));return(0,K.useEffect)(()=>{if(h.length===0&&!m.any)return;let n=u.current;u.current=r;for(let e of Ca({targets:d.current,values:n},{targets:f.current,values:r}))c.current.delete(e);d.current=f.current,c.current=Ta(c.current,f.current);let a=new AbortController,s=window.setTimeout(()=>{_a(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 Da(e){let t={labels:{},values:{}};return le(e,e=>{e.name&&(e.label&&(t.labels[e.name]=e.label),e.value!==void 0&&(t.values[e.name]=e.value))}),t}function Oa(e,t){return e===t||e.startsWith(`${t}.`)}function ka(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=Array.isArray(r)?r[0]:r;return t}function Aa(e,t){let n=(0,K.useRef)(e);n.current=e;let r=(0,K.useRef)(null),i=(0,K.useCallback)(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);return(0,K.useEffect)(()=>i,[i]),(0,K.useMemo)(()=>{let e=(...e)=>{i(),r.current=setTimeout(()=>{r.current=null,n.current(...e)},t)};return e.cancel=i,e},[i,t])}function ja(e,t,n){let[r,i]=(0,K.useState)(null);return(0,K.useEffect)(()=>{if(!n){i(null);return}let r=new AbortController;return Wt(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 Ma(){return(0,J.jsxs)(`div`,{className:`space-y-4`,"data-lattice-action-form-loading":!0,children:[(0,J.jsx)(fa,{className:`h-4 w-24`}),(0,J.jsx)(fa,{className:`h-10 w-full`}),(0,J.jsx)(fa,{className:`h-10 w-full`})]})}function Na({cancelLabel:e,componentRef:t,endpoint:n,extraData:r,fieldLabels:i,formNode:a,method:o,onClose:s,onSuccess:c,precognitive:l,submitLabel:u}){let d=Fe(),f=(0,K.useRef)(d);f.current=d;let p=(0,K.useRef)(r);p.current=r;let{nodes:m,markUserEdit:g}=Ea(n,t,a.schema),_=b(),[y,x]=(0,K.useState)({}),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(!1),E=(0,K.useCallback)(e=>Wt(n,{body:JSON.stringify({...f.current,...p.current}),method:o,ref:t,headers:e,throwOnError:!1}),[t,n,o]),D=(0,K.useCallback)(e=>{x(t=>t[e]===void 0?t:{...t,[e]:void 0})},[]),O=Aa(e=>{E({Precognition:`true`,"Precognition-Validate-Only":e}).then(async t=>{if(t.status===422){let e=await t.json();x(t=>({...t,...ka(e.errors)}));return}D(e)}).catch(()=>{})},250),k=(0,K.useCallback)(e=>{l&&O(e)},[l,O]),A=(0,K.useCallback)(()=>{},[]),j=(0,K.useCallback)((e,t)=>{T(!0),E({Precognition:`true`,"Precognition-Validate-Only":e.join(`,`)}).then(async n=>{if(n.status===422){let e=await n.json();x(t=>({...t,...ka(e.errors)})),t?.onValidationError?.();return}if(!n.ok){t?.onValidationError?.();return}let r=e.filter(e=>!e.includes(`*`));x(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!r.some(t=>Oa(e,t))))),t?.onSuccess?.()}).catch(()=>t?.onValidationError?.()).finally(()=>T(!1))},[E]),M=(0,K.useCallback)(()=>{C(!0),E().then(async e=>{let t=await e.json().catch(()=>({}));if(_(v(t.effects)),e.status===422&&t.errors){x(ka(t.errors));return}e.ok&&c(t)}).catch(e=>h(e)).finally(()=>C(!1))},[_,c,E]),N=(0,K.useMemo)(()=>({action:n,clearErrors:D,componentRef:t,errors:y,fieldLabels:i,precognitive:l,processing:S,touch:A,validate:k,validateFields:j,validating:w}),[D,t,n,y,i,l,S,A,k,j,w]);return(0,J.jsx)(me,{value:N,children:(0,J.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,J.jsx)(De,{value:{markUserEdit:g},children:(0,J.jsx)(ma,{nodes:m,children:(0,J.jsx)(Y,{nodes:a.schema??[]})})}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,J.jsx)(G,{"data-test":`action-form-cancel`,disabled:S,onClick:s,type:`button`,emphasis:`ghost`,children:e}),a.props?.submitButton!==!1&&(0,J.jsxs)(G,{"data-test":`action-form-submit`,disabled:S,type:`submit`,children:[S&&(0,J.jsx)(la,{}),u]})]})]})})}function Pa({formNode:e,...t}){let n=!!e.props?.precognitive,{labels:r,values:i}=(0,K.useMemo)(()=>{let{labels:t,values:n}=Da(e.schema);return{labels:t,values:{...n,...e.props?.state}}},[e]);return(0,J.jsx)(lt,{initial:i,children:(0,J.jsx)(Na,{fieldLabels:r,formNode:e,precognitive:n,...t})})}function Fa({description:e,formNode:t,onClose:n,placement:r,title:i,width:a,...o}){let{t:s}=E(`lattice`);return(0,J.jsx)(ra,{open:!0,onOpenChange:e=>{e||n()},children:(0,J.jsxs)(sa,{...e?{}:{"aria-describedby":void 0},placement:r,width:a,children:[(0,J.jsx)(ca,{closeLabel:s(`common.close`,`Close`),description:e,title:i}),(0,J.jsx)(`div`,{className:`mt-6`,children:t?(0,J.jsx)(Pa,{formNode:t,onClose:n,...o}):(0,J.jsx)(Ma,{})})]})})}function Ia(e){return e.props.label??w(`lattice`,`common.action.run`,`Run action`)}function La(e){let t=e.props.endpoint??``,n=e.props.ref??``,r=e.props.method??`post`,i=Ia(e),{variant:a,emphasis:o}=e.props,s=e.props.confirmation,c=e.props.form,l=e.props.lazyForm===!0,u=!!c||l,[d,f]=(0,K.useState)(!1),p=b(),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),y=ja(t,n,_&&l),x=l?y:c,S=async()=>{if(!t)return;if(r===`get`){m.visit(t,{headers:Nt(n)}),g(!1);return}f(!0);let e=await da(()=>Wt(t,{method:r,ref:n,throwOnError:!1}),p);f(!1),e&&g(!1)},C=()=>{if(u){v(!0);return}if(s){g(!0);return}S()},T=s?.title??i,E=s?.confirmLabel??i,D=s?.cancelLabel??w(`lattice`,`common.cancel`,`Cancel`);return{processing:d,requestSubmit:C,overlays:(0,J.jsxs)(J.Fragment,{children:[h&&s&&(0,J.jsx)(ua,{title:T,description:s.description??void 0,confirmLabel:E,cancelLabel:D,confirmVariant:a,confirmEmphasis:o,processing:d,confirmDisabled:!t,onConfirm:()=>void S(),onCancel:()=>g(!1)}),_&&u&&(0,J.jsx)(Fa,{cancelLabel:D,componentRef:n,description:s?.description??void 0,endpoint:t,formNode:x,method:r,onClose:()=>v(!1),onSuccess:()=>{v(!1)},placement:e.props.modalSide??`center`,submitLabel:E,title:T,width:e.props.modalWidth??void 0})]})}}function Ra({action:e,children:t}){let{processing:n,requestSubmit:r,overlays:i}=La(e);return(0,J.jsxs)(J.Fragment,{children:[t({onClick:r,processing:n}),i]})}function za({children:e}){return(0,J.jsx)(re,{render:e=>(0,J.jsx)(Ra,{action:e.action,children:e.children}),children:e})}function Ba(){let e=b();(0,K.useEffect)(()=>m.on(`flash`,t=>{let n=v(t.detail?.flash?.latticeEffects);n.length>0&&e(n)}),[e])}function Va({onAppearanceChange:e}){return Sn(a.appearanceChange,t=>{let n=t.detail?.value;ln(n)&&e?.(n)},{enabled:!!e}),null}var Ha={href:``};function Ua({children:e,registry:t,sprite:n=Ha,toaster:r=!0}){return Ba(),(0,J.jsx)(f.Provider,{value:t,children:(0,J.jsx)(za,{children:(0,J.jsxs)(ie,{sprite:n,children:[e,(0,J.jsx)(Va,{onAppearanceChange:_n}),r?(0,J.jsx)(Zr,{}):null]})})})}var Wa=yn({components:{action:q(({node:e})=>{let t=e.props.endpoint??``,n=e.props.icon,r=Ia(e),i=Je(),{variant:a,emphasis:o}=e.props,{processing:s,requestSubmit:c,overlays:l}=La(e),u=e.key??P(`action`,e.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(G,{className:i?$e: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,J.jsx)(la,{className:i?`size-lt-icon-sm`:void 0}):n&&(0,J.jsx)(I,{className:i?`size-lt-icon-sm`:`size-lt-icon-md`,icon:n}),r]}),l]})}),"action.group":q(({children:e,node:t})=>{let{t:n}=E(`lattice`),r=t.props.label??n(`common.action-group.label`,`Actions`),i=t.props.orientation;return i?(0,J.jsx)(`div`,{"aria-label":r,className:L(`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,J.jsx)(`div`,{className:`inline-flex`,"data-lattice-component":t.id,children:(0,J.jsxs)(Ie,{children:[(0,J.jsx)(Le,{asChild:!0,children:(0,J.jsx)(G,{"aria-label":r,className:`size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg`,"data-test":F(t),size:`icon`,type:`button`,emphasis:`ghost`,children:(0,J.jsx)(B,{name:`more-horizontal`,"aria-hidden":`true`,className:`size-lt-icon-md`})})}),(0,J.jsx)(Ke,{align:`end`,"aria-label":r,className:`min-w-44 gap-0.5 p-1.5`,sideOffset:8,children:(0,J.jsx)(ze,{children:e})})]})})})},name:`lattice/action`});function Ga(e){try{return JSON.parse(e)}catch{return null}}function Ka(e){return async function*(t){let n=await e(t);if(!n.ok||!n.body)throw Error(`Chat stream failed (${n.status})`);yield*Ya(n.body)}}var qa=Ka(({url:e,body:t,signal:n})=>Wt(e,{method:`POST`,signal:n,headers:{Accept:`application/x-ndjson`},body:JSON.stringify(t),throwOnError:!1}));function Ja(e){return Ka(({url:t,body:n,signal:r})=>Zt(t,{remote:e,method:`POST`,signal:r,headers:{Accept:`application/x-ndjson`,"Content-Type":`application/json`},body:JSON.stringify(n),throwOnError:!1}))}async function*Ya(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=Ga(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=Ga(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var Xa=0;function Za(){return Xa+=1,`chat-${Xa}`}function Qa(e){return e instanceof DOMException&&e.name===`AbortError`}function $a(e){return e instanceof Error?e.message:String(e)}function eo(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function to(e,t){if(!eo(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 no({endpoint:e,transport:t=qa,initialMessages:n=[],generateId:r=Za}){let[i,a]=(0,K.useState)(n),[o,s]=(0,K.useState)(`idle`),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=(0,K.useRef)(i);f.current=i;let p=(0,K.useCallback)(e=>{f.current=e,a(e)},[]),m=(0,K.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(to(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(Qa(e)){s(`idle`);return}l($a(e)),s(`error`)}},[p,e,r,t]),h=(0,K.useCallback)(e=>{let t=e.trim();t!==``&&(d.current=t,m(f.current,t))},[m]),g=(0,K.useCallback)(()=>{u.current?.abort(),s(`idle`)},[]),_=(0,K.useCallback)(()=>{let e=d.current;if(e===null)return;let t=f.current,n=eo(t)?t.slice(0,-2):t;m(n,e)},[m]);return(0,K.useEffect)(()=>()=>{u.current?.abort()},[]),{messages:i,status:o,error:c,sendMessage:h,setMessages:p,stop:g,regenerate:_}}function ro({message:e}){let t=e.role===`user`;return(0,J.jsx)(`div`,{className:L(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":M(`chat-message-${e.role}`),children:(0,J.jsx)(`div`,{className:L(`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,J.jsx)(An,{node:e},e.key??t))})})}function io({messages:e}){let t=(0,K.useRef)(null),n=e.at(-1),r=n?.parts.at(-1)===void 0?0:JSON.stringify(n.parts.at(-1)).length;return(0,K.useEffect)(()=>{t.current&&typeof t.current.scrollIntoView==`function`&&t.current.scrollIntoView({behavior:`smooth`})},[e.length,r]),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 overflow-y-auto p-3`,"data-test":M(`chat-messages`),children:[e.map(e=>(0,J.jsx)(ro,{message:e},e.id)),(0,J.jsx)(`div`,{ref:t})]})}function ao({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=E(`lattice`),[i,a]=(0,K.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,J.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-lt-border p-3`,children:[(0,J.jsx)(`textarea`,{"aria-label":r(`common.chat.input-label`,`Message input`),className:L(`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-test":M(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,J.jsx)(G,{"data-test":M(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var oo=yn({name:`lattice/chat`,components:{"chat.box":q(({node:e})=>{let t=e.props,{t:n}=E(`lattice`),r=(0,K.useMemo)(()=>t.remote?Ja(t.remote):qa,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=no({endpoint:t.streamEndpoint??``,transport:r}),l=(0,K.useRef)(!1),u=(0,K.useCallback)(async()=>{if(l.current||!t.historyEndpoint)return;if(l.current=!0,t.remote){let e=await Qt(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await Wt(t.historyEndpoint,{throwOnError:!1});if(!e.ok)return;let n=await e.json();c(n.messages)},[t.historyEndpoint,t.remote,c]);(0,K.useEffect)(()=>{u().catch(()=>{})},[u]);let d=a===`submitted`||a===`streaming`||!t.streamEndpoint;return(0,J.jsxs)(`div`,{className:L(`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":M(`chat-box`),children:[(0,J.jsx)(`div`,{className:`flex items-center border-b border-lt-border px-3 py-2`,children:(0,J.jsx)(`span`,{className:`text-sm font-medium text-lt-fg`,children:t.title??n(`common.chat.title`,`Chat`)})}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,J.jsx)(io,{messages:i})}),o?(0,J.jsx)(`div`,{className:`border-t border-lt-danger/40 px-3 py-2 text-xs text-lt-danger`,children:o}):null,(0,J.jsx)(ao,{disabled:d,onSubmit:s,placeholder:t.placeholder??void 0})]})}),"chat.part.text":q(({node:e})=>(0,J.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.props.text})),"chat.part.tool-call":q(({node:e})=>(0,J.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":M(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}}),so={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 co(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function lo(){return(0,J.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,J.jsx)(`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}),(0,J.jsx)(`circle`,{cx:`12`,cy:`7`,r:`4`})]})}var uo=({node:e})=>{let{src:t,name:n,size:r}=e.props,i=n??void 0;return(0,J.jsx)(`span`,{"data-slot":`avatar`,role:t?void 0:`img`,"aria-label":t?void 0:i,className:L(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,so[r]),children:t?(0,J.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?co(n):(0,J.jsx)(lo,{})})};function fo({color:e,className:t,style:n,...r}){let i=Tt(Et(e??void 0)??St(`gray`));return(0,J.jsx)(`span`,{"data-slot":`badge`,className:L(`lt-badge`,i.className,t),style:{...i.style,...n},...r})}var po=({node:e})=>(0,J.jsx)(fo,{color:e.props.color,children:e.props.label});function mo({className:e,...t}){return(0,J.jsx)(`article`,{"data-slot":`card`,className:L(`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 ho({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-header`,className:L(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function go({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-title`,className:L(`font-semibold leading-none`,e),...t})}function _o({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-description`,className:L(`text-sm text-lt-muted-fg`,e),...t})}function vo({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-content`,className:L(`px-lt-gutter`,e),...t})}var yo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props;return(0,J.jsxs)(mo,{"data-lattice-component":F(t),children:[(n||r)&&(0,J.jsxs)(ho,{children:[n&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(go,{children:n}),(0,J.jsx)(rt,{content:i})]}),r&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(_o,{children:r}),!n&&(0,J.jsx)(rt,{content:i})]})]}),e&&(0,J.jsx)(vo,{className:`flex flex-col gap-6`,children:e})]})},bo=(0,K.lazy)(()=>nn(()=>import(`./chunks/chart-view-CR1X2aGE.js`),__vite__mapDeps([9,1,4,2,10,6,11,12,13]),import.meta.url)),xo=({children:e,node:t})=>(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(bo,{node:t,children:e})}),So=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=wn(t.props.trigger),i=F(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=hi(a,t.props.collapsed===!1,n);return(0,J.jsxs)(`div`,{"data-slot":`collapsible`,"data-lattice-component":i,children:[(0,J.jsxs)(`div`,{"aria-controls":o,"aria-expanded":s,"data-test":P(`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,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,J.jsx)(Y,{nodes:r}),t.props.tooltip&&(0,J.jsx)(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,J.jsx)(rt,{content:t.props.tooltip})})]}),(0,J.jsx)(B,{name:`chevron-down`,className:L(`size-lt-icon-md shrink-0 text-lt-muted-fg transition-transform`,!s&&`-rotate-90`)})]}),s&&e&&(0,J.jsx)(`div`,{id:o,className:`flex flex-col gap-4 pt-2`,children:e})]})};function Co(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 wo=({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,K.useState)(!1);if(a.length===0)return(0,J.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":F(t),role:n?`group`:void 0,style:Co(i,r),children:e});let c=i===`bottom-start`||i===`bottom-end`,l=i===`top-start`||i===`bottom-start`;return(0,J.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)]`,"data-lattice-component":F(t),role:n?`group`:void 0,style:Co(i,r),children:(0,J.jsxs)(`div`,{className:L(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,J.jsx)(`button`,{"aria-expanded":o,className:L(`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,J.jsx)(An,{node:e},e.key??`${e.type}-${t}`))}),(0,J.jsx)(`div`,{className:o?`block`:`hidden`,children:e})]})})},To={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},Eo=({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,i=To[e.props.size],[o,s]=(0,K.useState)(()=>e.schema??[]),[c,l]=(0,K.useState)(!n),[u,d]=(0,K.useState)(n&&t!==``),f=(0,K.useCallback)(async()=>{if(t){d(!0);try{let e=await Gt(t,{ref:r});s(wn(e.schema)),l(!0)}finally{d(!1)}}},[t,r]);return(0,K.useEffect)(()=>{!n||c||f()},[c,n,f]),(0,K.useEffect)(()=>{function t(t){t.detail?.component===e.id&&f()}return window.addEventListener(a.reloadComponent,t),()=>window.removeEventListener(a.reloadComponent,t)},[f,e.id]),(0,K.useEffect)(()=>{function e(){c&&f()}return window.addEventListener(a.localeChange,e),()=>window.removeEventListener(a.localeChange,e)},[c,f]),(0,J.jsx)(`div`,{"data-lattice-fragment":e.id,style:u&&o.length===0?{minHeight:i}:void 0,children:u&&o.length===0?(0,J.jsx)(fa,{className:`w-full`,style:{height:i}}):(0,J.jsx)(Y,{nodes:o})})},Do=({children:e,node:t})=>{let n=Math.min(Math.max(t.props.columns??1,1),4);return(0,J.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":F(t),className:L(`grid gap-x-4 gap-y-6`,n>=2&&`md:grid-cols-2`,n>=3&&`lg:grid-cols-3`,n>=4&&`xl:grid-cols-4`),children:e})};async function Oo(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function ko({value:e,label:t,testId:n,className:r}){let{t:i}=E(`lattice`),[a,o]=(0,K.useState)(!1);(0,K.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1500);return()=>window.clearTimeout(e)},[a]);function s(){Oo(e),o(!0)}let c=a?i(`common.copied-value`,`Copied {{label}}`,{label:t}):i(`common.copy-value`,`Copy {{label}}`,{label:t});return(0,J.jsxs)(`button`,{type:`button`,"data-test":n,className:L(`inline-flex items-center gap-1 rounded-lt-sm border border-lt-border px-2 py-1 text-xs`,r),"aria-label":c,onClick:s,children:[(0,J.jsx)(B,{name:a?`check`:`copy`,className:`size-lt-icon-xs`}),a?i(`common.copied`,`Copied`):i(`common.copy`,`Copy`)]})}function Ao({value:e,label:t,testId:n,children:r}){return(0,J.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[r??e,(0,J.jsx)(ko,{value:e,label:t,testId:n})]})}var jo=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=L(`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,J.jsxs)(J.Fragment,{children:[t,(0,J.jsx)(rt,{content:n})]}),o;switch(r){case 1:o=(0,J.jsx)(`h1`,{className:i,children:a});break;case 2:o=(0,J.jsx)(`h2`,{className:i,children:a});break;case 3:o=(0,J.jsx)(`h3`,{className:i,children:a});break;case 4:o=(0,J.jsx)(`h4`,{className:i,children:a});break;case 5:o=(0,J.jsx)(`h5`,{className:i,children:a});break;default:o=(0,J.jsx)(`h6`,{className:i,children:a})}return e.props.copyable?(0,J.jsx)(Ao,{value:t,label:t,children:o}):o},Mo={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`},No=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,J.jsx)(I,{icon:t,className:L(Mo[n],i)}),o=Et(r);return o?(0,J.jsx)(`span`,{className:`contents`,style:{color:Ct(o)},children:a}):a};function Po({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=E(`lattice`),[c,l]=(0,K.useState)(!1),u=(0,J.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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"data-test":o,className:`cursor-zoom-in`,"aria-label":d,onClick:()=>l(!0),children:u}),(0,J.jsx)(ra,{open:c,onOpenChange:l,children:(0,J.jsxs)(sa,{"aria-describedby":void 0,className:`max-h-[90vh] w-auto max-w-[90vw] border-none bg-transparent p-0 shadow-none`,children:[(0,J.jsx)(aa,{className:`sr-only`,children:t||d}),(0,J.jsx)(`img`,{alt:t,src:e,"data-slot":`image-lightbox`,className:`max-h-[90vh] max-w-[90vw] rounded-lt object-contain`}),(0,J.jsx)(ia,{asChild:!0,children:(0,J.jsx)(G,{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 Fo=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,J.jsx)(Po,{alt:n??``,className:L(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:F(e),width:r??void 0})};function Io(e,t){let n=e.detail?.modal;return n==null||n===t}var Lo=({children:e,node:t})=>{let{t:n}=E(`lattice`),r=t.props.title??n(`common.dialog`,`Dialog`),i=t.props.description,o=t.props.closeLabel,[s,c]=(0,K.useState)(t.props.open===!0),l=(0,K.useRef)(null),u=(0,K.useRef)(s);return(0,K.useEffect)(()=>{t.props.open===!0&&c(!0)},[t.props.open]),(0,K.useEffect)(()=>{function e(e){t.id&&Io(e,t.id)&&(l.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(!0))}function n(e){(!t.id||Io(e,t.id))&&c(!1)}return window.addEventListener(a.openModal,e),window.addEventListener(a.closeModal,n),()=>{window.removeEventListener(a.openModal,e),window.removeEventListener(a.closeModal,n)}},[t.id]),(0,K.useEffect)(()=>{if(u.current&&!s){let e=l.current;e&&requestAnimationFrame(()=>e.focus())}u.current=s},[s]),(0,J.jsx)(ra,{open:s,onOpenChange:c,children:(0,J.jsxs)(sa,{...i?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,children:[(0,J.jsx)(ca,{closeLabel:o,description:i,title:r}),(0,J.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},Ro={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`},zo={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},Bo={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`},Vo=({node:e})=>{let{value:t,max:r,shape:i,showValue:a,color:o,size:s}=e.props,{locale:c}=n(),l=Ct(Et(o)??St(`primary`)),u=r>0?Math.min(Math.max(t,0),r):0,d=r>0?u/r:0,f=new Intl.NumberFormat(c,{maximumFractionDigits:0,style:`percent`}).format(d),p={"aria-valuemax":r,"aria-valuemin":0,"aria-valuenow":u,"aria-valuetext":f,role:`progressbar`};if(i===`circle`){let e=zo[s],t=Math.max(3,e/10),n=(e-t)/2,r=2*Math.PI*n;return(0,J.jsxs)(`div`,{...p,className:`relative inline-flex`,"data-lattice-progress":`circle`,children:[(0,J.jsxs)(`svg`,{className:`-rotate-90`,height:e,width:e,children:[(0,J.jsx)(`circle`,{className:`text-lt-muted`,cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeWidth:t}),(0,J.jsx)(`circle`,{cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeDasharray:r,strokeDashoffset:r*(1-d),strokeLinecap:`round`,strokeWidth:t,style:{color:l}})]}),a&&(0,J.jsx)(`span`,{className:L(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,Bo[s]),children:f})]})}return(0,J.jsxs)(`div`,{className:`flex w-full items-center gap-2`,"data-lattice-progress":`bar`,children:[(0,J.jsx)(`div`,{...p,className:L(`w-full overflow-hidden rounded-full bg-lt-muted`,Ro[s]),children:(0,J.jsx)(`div`,{className:`h-full rounded-full`,style:{background:l,width:`${d*100}%`}})}),a&&(0,J.jsx)(`span`,{className:`shrink-0 text-lt-muted-fg text-sm tabular-nums`,children:f})]})},Ho=({node:e})=>(0,J.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),Uo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=wn(t.props.headerActions),c=F(t),[l,u]=hi(`lattice:section:${c??`default`}`,t.props.collapsed===!0,a&&o),d=a&&l,f=!!(n||r||s.length>0||a);return(0,J.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,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-lt-gutter`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[a&&(0,J.jsx)(`button`,{"aria-expanded":!d,"aria-label":d?`Expand section`:`Collapse section`,"data-test":P(`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,J.jsx)(B,{name:`chevron-down`,className:L(`size-lt-icon-md transition-transform`,d&&`-rotate-90`)})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[n&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(`div`,{className:`font-semibold leading-none`,children:n}),(0,J.jsx)(rt,{content:i})]}),r&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(`div`,{className:`text-sm text-lt-muted-fg`,children:r}),!n&&(0,J.jsx)(rt,{content:i})]})]})]}),s.length>0&&(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,J.jsx)(Y,{nodes:s})})]}),!d&&e&&(0,J.jsx)(`div`,{className:`flex flex-col gap-6 px-lt-gutter`,children:e})]})};function Wo(e){return L(`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 Go({ariaLabel:e,autoFocus:t=!1,disabled:n=!1,name:r,onSelect:i,options:a,tabIndex:o,value:s}){let c=(0,K.useRef)(null);return(0,K.useEffect)(()=>{if(!t)return;let e=c.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,J.jsx)(`div`,{"aria-label":e,className:`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,ref:c,role:`radiogroup`,children:a.map(e=>{let t=s===e.value;return(0,J.jsx)(`button`,{"aria-checked":t,"data-test":`${r}-${e.value}`,className:L(Wo(t),n&&`cursor-not-allowed opacity-60`),disabled:n,onClick:()=>i(e.value),role:`radio`,tabIndex:o,type:`button`,children:e.label},e.value)})})}var Ko=({node:e})=>{let{options:t,name:n,emits:r}=e.props,[i,a]=(0,K.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,J.jsx)(Go,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},qo=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:L(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},Jo={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},Yo={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},Xo={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},Zo={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`},Qo={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},$o={full:`h-full`,screen:`min-h-screen`},es={end:`ml-auto`,start:`mr-auto`},ts=({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,J.jsx)(`div`,{"data-slot":`stack`,"data-lattice-component":F(t),className:L(l?L(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?Yo[n]??Yo.stretch:Jo[n]??Jo.stretch,Xo[i]??Xo.md,Zo[a]??Zo.full,o?Qo[o]:null,s?$o[s]:null,c?es[c]:null),children:e})},ns=(0,K.createContext)(null);function rs(){return(0,K.useContext)(ns)||{activeValue:``,setActiveValue:()=>{}}}function is(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 as(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 os(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 ss(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 cs=({children:e,node:t})=>{let{t:n}=E(`lattice`),r=(0,K.useMemo)(()=>is(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`,u=t.props.activeValue,d=t.props.defaultValue??i,f=(0,K.useRef)(null),[p,h]=(0,K.useState)(()=>u||(as(a,r)??d)||i),g=(0,K.useCallback)(e=>{if(e.confirm?.required){m.visit(ss(a,e.value),{preserveScroll:!0});return}h(e.value),os(a,e.value)},[a]),_=(0,K.useCallback)(e=>{let t=r.find(t=>t.value===e);t&&g(t)},[g,r]),v=(0,K.useMemo)(()=>({activeValue:p,setActiveValue:_}),[p,_]);function y(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(f.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,J.jsx)(ns.Provider,{value:v,children:(0,J.jsxs)(`div`,{className:L(`gap-6`,s?L(`flex`,c===`end`&&`flex-row-reverse`):`grid`),"data-lattice-tabs":t.key??t.id,children:[(0,J.jsx)(`div`,{"aria-label":n(`common.tabs`,`Tabs`),"aria-orientation":o,className:L(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&L(`inline-flex w-fit max-w-full overflow-x-auto`,{"justify-self-center":c===`center`,"justify-self-end":c===`end`})),ref:f,role:`tablist`,children:r.map(e=>{let t=p===e.value;return(0,J.jsx)(`button`,{"aria-controls":`${e.value}-panel`,"aria-selected":t,"data-test":`tab-${e.value}`,className:L(Wo(t),s&&`text-left`,l&&`flex-1`),id:`${e.value}-tab`,onClick:()=>g(e),onKeyDown:y,role:`tab`,tabIndex:t?0:-1,type:`button`,children:e.label},e.value)})}),(0,J.jsx)(`div`,{className:L(`min-w-0`,s&&`flex-1`),children:e})]})})},ls=({children:e,node:t})=>{let{activeValue:n}=rs(),r=t.props.value,i=n===r,[a,o]=(0,K.useState)(i);return(0,K.useEffect)(()=>{i&&o(!0)},[i]),(0,J.jsx)(`section`,{"aria-labelledby":`${r}-tab`,className:L(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},us={center:`text-center`,left:`text-left`},ds={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`},fs=yn({components:{avatar:q(uo),badge:q(po),button:q(gt),card:q(yo),chart:q(xo),collapsible:q(So),"floating-panel":q(wo),fragment:q(Eo),grid:q(Do),heading:q(jo),icon:q(No),image:q(Fo),link:q(Ze),modal:q(Lo),progress:q(Vo),"raw-block":q(Ho),section:q(Uo),"segmented-control":q(Ko),separator:q(qo),stack:q(ts),tab:q(ls),tabs:q(cs),text:q(({node:e})=>{let t=e.props.align??`left`,n=Ct(Et(e.props.color)??St(`muted`)),r=(0,J.jsx)(`p`,{className:L(`m-0`,`max-w-2xl`,us[t]??us.left,ds[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,J.jsx)(Ao,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:q(({node:e})=>{let t=e.props.content,n=wn(e.props.trigger);return t?n.length===0?(0,J.jsx)(rt,{content:t}):(0,J.jsxs)(Oe,{children:[(0,J.jsx)(H,{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,J.jsx)(Y,{nodes:n})}),(0,J.jsx)(V,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},name:`lattice/ui`});function ps({addLabel:e,options:t,onSelect:n}){return(0,J.jsxs)(Ie,{children:[(0,J.jsx)(Le,{asChild:!0,children:(0,J.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,J.jsx)(B,{name:`plus`}),e]})}),(0,J.jsx)(Ke,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,J.jsx)(st,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var ms={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function hs(e,t){return(e??gs(t.removable)).map(e=>_s(e,t)).filter(e=>e!==null)}function gs(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function _s(e,t){if(e.type===`duplicate`){let n=ms.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=ms.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 vs(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 ys({actions:e}){let{t}=E(`lattice`);if(e.length===0)return null;if(e.length===1){let t=e[0];return(0,J.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-test":`row-action-${t.key}`,className:vs(t.danger),onClick:t.onClick,children:(0,J.jsx)(B,{name:t.icon})})}return(0,J.jsxs)(Ie,{children:[(0,J.jsx)(Le,{asChild:!0,children:(0,J.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,J.jsx)(B,{name:`more-horizontal`})})}),(0,J.jsx)(Ke,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,J.jsx)(st,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function bs({path:e,rows:t,rowKey:n}){return(0,J.jsx)(J.Fragment,{children:t.map((t,r)=>(0,J.jsx)(`input`,{type:`hidden`,name:_e(xe(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function xs({label:e,testId:t,onClick:n,children:r}){return(0,J.jsx)(`button`,{type:`button`,"aria-label":e,"data-test":t,className:`text-lt-muted-fg hover:text-lt-fg`,onClick:n,children:r})}var Ss=(0,K.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}=E(`lattice`);return(0,J.jsxs)(`div`,{"data-test":`repeater-${e}-row-${t}`,className:`rounded-lt border border-lt-border bg-lt-surface p-4`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-lt-muted-fg`,children:i}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[a&&!o&&(0,J.jsx)(xs,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,J.jsx)(B,{name:`arrow-up`})}),a&&!s&&(0,J.jsx)(xs,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,J.jsx)(B,{name:`arrow-down`})}),(0,J.jsx)(ys,{actions:hs(l,{index:t,removable:c,onRemove:d,onDuplicate:p,t:m})})]})]}),(0,J.jsx)(ue,{base:e,index:t,row:n,onChange:(e,n)=>u(t,e,n),children:(0,J.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,J.jsx)(An,{node:e},Tn(e,t)))})})]})}),Cs={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}},ws=1024;function Ts(e){return Cs[e].track}function Es(e){return Cs[e.width].minPx}function Ds(e){return Cs[e.width].defaultPx}function Os({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?Ts(e.width):`${Math.min(ws,Math.max(Es(e),t))}px`}),...n].join(` `)}var ks=[];function As({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=ks,showIndicator:i=!1,storageKey:a,trailingTracks:o=ks}){let s=(0,K.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=mi(a??``,{},{enabled:!!a,parse:e=>Ms(e,t),serialize:e=>Ns(e,s)}),u=(0,K.useRef)(c),d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useCallback)(e=>Os({columns:t,leadingTracks:r,trailingTracks:o,overrides:n?e:{}}),[t,n,r,o]),m=(0,K.useMemo)(()=>p(c),[c,p]),h=(0,K.useCallback)(e=>{let t=f.current;t&&(t.style.gridTemplateColumns=e,t.style.setProperty(`--lattice-table-columns`,e))},[]),g=(0,K.useCallback)(e=>{u.current=e,l(e),h(p(e))},[h,l,p]),_=(0,K.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??1024,Math.max(Es(t),n))}),[]),v=(0,K.useCallback)((e,t,n)=>{g(_(u.current,e,t,n))},[g,_]),y=(0,K.useCallback)(e=>{let t={...u.current};delete t[e.key],g(t)},[g]),b=(0,K.useCallback)(()=>{g({})},[g]),x=n&&Object.values(c).some(e=>typeof e==`number`),S=(0,K.useCallback)(e=>u.current[e.key]??Ds(e),[]);return{getResizeHandleProps:(0,K.useCallback)(a=>{let s=ws,c=Es(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>js({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 js({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return ws;let s=[...i,...a].reduce((e,t)=>e+Fs(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+Es(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(ws,Math.max(Es(e),d))}function Ms(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=Ps(n,t);if(Object.keys(r).length===0)throw Error(`stored column widths hold no usable overrides`);return r}function Ns(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 Ps(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(ws,Math.max(Es(r),t)))}return n}function Fs(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])*Is():0}function Is(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}var Ls=`3rem`,Rs=`3rem`,zs=[Ls],Bs=[Rs],Vs=`(min-width: 768px)`;function Hs(){return pi(Vs,!0)}function Us(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 Ws=(0,K.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:_}=E(`lattice`);return(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[l&&!a&&(0,J.jsx)(xs,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,J.jsx)(B,{name:`arrow-up`})}),l&&!o&&(0,J.jsx)(xs,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,J.jsx)(B,{name:`arrow-down`})})]}),(0,J.jsx)(ue,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,J.jsx)(Ve,{children:i?(0,J.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,J.jsx)(An,{node:e},Tn(e,t)))}):r.map((e,t)=>(0,J.jsx)(`div`,{children:(0,J.jsx)(An,{node:e})},Tn(e,t)))})}),(0,J.jsx)(`div`,{className:`flex items-center`,children:(0,J.jsx)(ys,{actions:hs(d,{index:t,removable:u,onRemove:m,onDuplicate:h,t:_})})})]})});function Gs({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}=E(`lattice`),m=Hs(),h=(0,K.useMemo)(()=>t.map(e=>({key:e.name,label:e.label,width:e.columnWidth})),[t]),{getResizeHandleProps:g,gridTemplateColumns:_,hasOverrides:v,resizeRootRef:y,resetColumns:b}=As({columns:h,enabled:d,columnGapPx:12,leadingTracks:zs,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Bs});return m?(0,J.jsxs)(`div`,{className:`relative`,children:[v&&(0,J.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:b,title:p(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,J.jsx)(B,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`div`,{ref:y,className:`flex min-w-max flex-col gap-2`,style:{"--lattice-table-columns":_},children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[var(--lattice-table-columns)] items-center gap-x-3`,children:[(0,J.jsx)(`div`,{}),t.map((e,t)=>(0,J.jsxs)(`div`,{className:`relative min-w-0 pr-3 text-xs font-medium text-lt-muted-fg`,children:[e.label,d&&(0,J.jsx)(`div`,{...g(h[t])})]},e.name)),(0,J.jsx)(`div`,{})]}),n.map(d=>(0,J.jsx)(Ws,{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,J.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,J.jsx)(`div`,{ref:e=>u?.(t.key,e),"data-flip-key":t.key,children:(0,J.jsx)(Ss,{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 Ks=180;function qs(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Js(e){let t=(0,K.useRef)(new Map),n=(0,K.useRef)(new Map),r=(0,K.useCallback)((e,n)=>{n?t.current.set(e,n):t.current.delete(e)},[]);return ga(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),qs()||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 ${Ks}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function Ys(e,t){let n=ut(),r=n?n.errorKey(e):e,i=we(),a=ft(r),o=Array.isArray(a)?a:ve(a,t),s=Ge(o);ga(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,K.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:ve(n,t)))},[i,r,t]);return{path:r,rows:s,onField:(0,K.useCallback)((e,t,n)=>c(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),[c]),onRemove:(0,K.useCallback)(e=>c(t=>We(t,e)),[c]),onMove:(0,K.useCallback)((e,t)=>c(n=>ce(n,e,e+t)),[c]),onDuplicate:(0,K.useCallback)(e=>c(t=>be(t,e)),[c]),append:(0,K.useCallback)(e=>c(t=>[...t,ye(e)]),[c])}}var Xs=[],Zs=({node:e})=>{let t=e.props,n=t.name,r=va(e)??[],{errors:i}=Ee(),{hidden:a,required:o}=Ye(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=Ys(n,t.defaultItems??0),{t:m}=E(`lattice`),h=Js(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??Xs,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,J.jsx)(He,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:s,required:o,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(bs,{path:s,rows:c,rowKey:de}),(0,J.jsx)(bs,{path:s,rows:c,rowKey:`type`}),v?(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Gs,{base:s,columns:Us(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,J.jsx)(`div`,{ref:e=>h(a,e),"data-flip-key":a,children:i?(0,J.jsx)(Ss,{base:s,index:r,row:e,template:i.schema??Xs,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,J.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,J.jsxs)(`span`,{children:[`Unknown block: `,String(e.type)]}),(0,J.jsx)(ys,{actions:hs(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,J.jsx)(ps,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},Qs=Object.defineProperty,$s=(e,t)=>Qs(e,`name`,{value:t,configurable:!0}),ec=`Checkbox`,[tc,nc]=ct(ec),[rc,ic]=tc(ec);function ac(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]=se({prop:n,defaultProp:i??!1,onChange:c,caller:ec}),[m,h]=K.useState(null),[g,_]=K.useState(null),v=K.useRef(!1),[y,b]=K.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:!mc(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,J.jsx)(rc,{scope:t,...S,children:pc(d)?d(S):r})}$s(ac,`CheckboxProvider`);var oc=`CheckboxTrigger`,sc=K.forwardRef($s(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}=ic(oc,e),g=R(i,u),_=K.useRef(c);return K.useEffect(()=>{let e=a?.form;if(e){let t=$s(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,J.jsx)(U.button,{type:`button`,role:`checkbox`,"aria-checked":mc(c)?`mixed`:c,"aria-required":l,"data-state":hc(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:W(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:W(n,e=>{p(),d(e=>mc(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),cc=K.forwardRef($s(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,J.jsx)(ac,{__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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(sc,{...d,ref:t,__scopeCheckbox:n}),e&&(0,J.jsx)(fc,{__scopeCheckbox:n})]})})},`Checkbox`)),lc=`CheckboxIndicator`,uc=K.forwardRef($s(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=ic(lc,n);return(0,J.jsx)(Re,{present:r||mc(a.checked)||a.checked===!0,children:(0,J.jsx)(U.span,{"data-state":hc(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),dc=`CheckboxBubbleInput`,fc=K.forwardRef($s(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}=ic(dc,e),g=R(r,h),_=Ae(i),v=K.useRef(!1),y=K.useRef(s),b=K.useRef(o);K.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=mc(s),n.call(e,!mc(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=K.useRef(!mc(s)&&s);return(0,J.jsx)(U.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:W(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function pc(e){return typeof e==`function`}$s(pc,`isFunction`);function mc(e){return e===`indeterminate`}$s(mc,`isIndeterminate`);function hc(e){return mc(e)?`indeterminate`:e?`checked`:`unchecked`}$s(hc,`getState`);function gc({className:e,...t}){return(0,J.jsx)(cc,{"data-slot":`checkbox`,className:L(`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,J.jsx)(uc,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,J.jsx)(B,{name:`check`,className:`size-lt-icon-sm`})})})}function _c(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function vc(e,t){let n=ut(),r=ft(e),i=n?n.getValue(e):r,a=we();(0,K.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var yc=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=Ye(e),i=e.props.name,a=ut(),{fieldIdPrefix:o}=Ee(),s=_c(a?a.scopedName(i):i,o),c=ft(i),l=a?a.getValue(i):c,{commit:u}=Me(),d=tt(e.props.value),f=l===void 0?d:tt(l);return vc(i,d),t?null:(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,J.jsx)(gc,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":M(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,J.jsx)(Ne,{htmlFor:s,children:e.props.label})]}),e.props.helperText&&(0,J.jsx)(`p`,{className:`mt-1 pl-7 text-sm text-lt-muted-fg`,children:e.props.helperText})]})};function bc(e){let{errors:t,fieldIdPrefix:n}=Ee(),r=ut(),i=Ye(e),a=pt(e),o=a.name??``,s=ft(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=_c(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=Me(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:M(o),value:u,error:t[f],commit:g,change:_,blur:v}}var xc=({node:e})=>{let t=ha(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=bc(e),f=(0,K.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return vc(n,m||void 0),s||f.length===0?null:(0,J.jsxs)(He,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,name:r,required:c,children:[(0,J.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,J.jsx)(Go,{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 Sc(){return(Sc=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 Cc(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 wc(e){var t=(0,K.useRef)(e),n=(0,K.useRef)(function(e){t.current&&t.current(e)});return t.current=e,n.current}var Tc=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},Ec=function(e){return`touches`in e},Dc=function(e){return e&&e.ownerDocument.defaultView||self},Oc=function(e,t,n){var r=e.getBoundingClientRect(),i=Ec(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:Tc((i.pageX-(r.left+Dc(e).pageXOffset))/r.width),top:Tc((i.pageY-(r.top+Dc(e).pageYOffset))/r.height)}},kc=function(e){!Ec(e)&&e.preventDefault()},Ac=K.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=Cc(e,[`onMove`,`onKey`,`onEnd`]),a=(0,K.useRef)(null),o=wc(t),s=wc(n),c=wc(r),l=(0,K.useRef)(null),u=(0,K.useRef)(!1),d=(0,K.useMemo)(function(){var e=function(e){kc(e),(Ec(e)?e.touches.length>0:e.buttons>0)&&a.current?o(Oc(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=Dc(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&&(kc(t),!function(e,t){return t&&!Ec(e)}(t,u.current)&&r)){if(Ec(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(Oc(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,K.useEffect)(function(){return h},[h]),K.createElement(`div`,Sc({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),jc=function(e){return e.filter(Boolean).join(` `)},Mc=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=jc([`react-colorful__pointer`,e.className]);return K.createElement(`div`,{className:a,style:{top:100*i+`%`,left:100*n+`%`}},K.createElement(`div`,{className:`react-colorful__pointer-fill`,style:{backgroundColor:t}}))},$=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 Nc=function(e){return Vc(Pc(e))},Pc=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?$(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?$(parseInt(e.substring(6,8),16)/255,2):1}},Fc=function(e){return Bc(Rc(e))},Ic=function(e){var t=e.s,n=e.v,r=e.a,i=(200-t)*n/100;return{h:$(e.h),s:$(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:$(i/2),a:$(r,2)}},Lc=function(e){var t=Ic(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Rc=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:$(255*[r,s,o,o,c,r][l]),g:$(255*[c,r,r,s,o,o][l]),b:$(255*[o,o,c,r,r,s][l]),a:$(i,2)}},zc=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Bc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?zc($(255*i)):``;return`#`+zc(t)+zc(n)+zc(r)+a},Vc=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:$(60*(s<0?s+6:s)),s:$(a?o/a*100:0),v:$(a/255*100),a:i}},Hc=K.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=jc([`react-colorful__hue`,e.className]);return K.createElement(`div`,{className:i},K.createElement(Ac,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:Tc(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":$(t),"aria-valuemax":`360`,"aria-valuemin":`0`},K.createElement(Mc,{className:`react-colorful__hue-pointer`,left:t/360,color:Lc({h:t,s:100,v:100,a:1})})))}),Uc=K.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:Lc({h:t.h,s:100,v:100,a:1})};return K.createElement(`div`,{className:`react-colorful__saturation`,style:i},K.createElement(Ac,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:Tc(t.s+100*e.left,0,100),v:Tc(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+$(t.s)+`%, Brightness `+$(t.v)+`%`},K.createElement(Mc,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:Lc(t)})))}),Wc=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},Gc=function(e,t){return e.toLowerCase()===t.toLowerCase()||Wc(Pc(e),Pc(t))};function Kc(e,t,n,r){var i=wc(n),a=wc(r),o=(0,K.useState)(function(){return e.toHsva(t)}),s=o[0],c=o[1],l=(0,K.useRef)({color:t,hsva:s}),u=(0,K.useRef)(!1);return(0,K.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,K.useEffect)(function(){var t;Wc(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,K.useCallback)(function(e){c(function(t){return Object.assign({},t,e)})},[]),(0,K.useCallback)(function(){u.current&&(u.current=!1,a(l.current.color))},[a])]}var qc,Jc=typeof window<`u`?K.useLayoutEffect:K.useEffect,Yc=function(){return qc||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},Xc=new WeakMap,Zc=function(e){Jc(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(!Xc.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=Yc();o&&a.setAttribute(`nonce`,o),Xc.set(r,a),i.appendChild(a)}}},[])},Qc=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=Cc(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,K.useRef)(null);Zc(c);var l=Kc(n,i,a,o),u=l[0],d=l[1],f=l[2],p=jc([`react-colorful`,t]);return K.createElement(`div`,Sc({},s,{ref:c,className:p}),K.createElement(Uc,{hsva:u,onChange:d,onChangeEnd:f}),K.createElement(Hc,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},$c={defaultColor:`000`,toHsva:Nc,fromHsva:function(e){return Fc({h:e.h,s:e.s,v:e.v,a:1})},equal:Gc},el=function(e){return K.createElement(Qc,Sc({},e,{colorModel:$c}))};function tl(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 nl({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,K.useState)(null),s=tl(e)??`#6b7280`;return(0,J.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,J.jsx)(el,{className:`!w-full`,color:s,onChange:t}),n.length>0&&(0,J.jsx)(`div`,{"aria-label":i,className:`flex flex-wrap gap-1.5`,role:`listbox`,children:n.map(e=>{let n=tl(e)??e;return(0,J.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:L(`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,J.jsx)(mt,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=tl(n);o(n),r!==null&&t(r)},value:a??s})]})}function rl({node:e,label:t,children:n}){let r=bc(e);return r.hidden?null:(0,J.jsx)(He,{error:r.error,helperText:pt(e).helperText??void 0,tooltip:pt(e).tooltip??void 0,label:t,name:r.name,required:r.required,children:n(r)})}var il=({node:e})=>{let t=e.props;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a})=>{let o=tl(n);return(0,J.jsxs)(Oe,{children:[(0,J.jsx)(`input`,{name:e,type:`hidden`,value:o??``}),(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(`button`,{className:L(bt(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,id:e,type:`button`,children:o?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 shrink-0 rounded-full border border-lt-border`,style:{background:o}}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:o})]}):(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,J.jsx)(V,{className:`p-3`,children:(0,J.jsx)(nl,{onChange:e=>a(e),palette:t.palette,value:o??`#6b7280`})})]})}})},al=(0,K.lazy)(async()=>{let{DatePickerField:e}=await nn(async()=>{let{DatePickerField:e}=await import(`./chunks/date-picker-field-B4Xzow-A.js`);return{DatePickerField:e}},__vite__mapDeps([14,1,4,2,15,3,11,16]),import.meta.url);return{default:e}});function ol(e){return(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(al,{...e})})}var sl=({node:e})=>{let t=e.props;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s})=>(0,J.jsx)(ol,{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})})},cl=({node:e})=>{let t=e.props,{timezone:n}=k();return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c})=>(0,J.jsx)(ol,{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 ll({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 ul(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return Wt(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function dl(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var fl=({node:e})=>{let{t}=E(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=Ye(e),{action:s,componentRef:c,errors:l}=Ee(),u=n.name,d=ut(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=Fe(),g=we(),_=(0,K.useId)(),v=(0,K.useRef)(null),y=(0,K.useRef)(new Set),b=a||o,x=n.signed,S=n.multiple,C=S?`${f}[]`:f,w=(0,K.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,D]=(0,K.useState)(w),[O,k]=(0,K.useState)([]);(0,K.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){dl(d.getValue(u),t)||d.setValue(u,t);return}g(u,t)},[T,S,u,d,g,x]),(0,K.useEffect)(()=>{!x||d||g(`${u}__removed`,O)},[u,O,d,g,x]),(0,K.useEffect)(()=>()=>{y.current.forEach(e=>URL.revokeObjectURL(e)),y.current.clear()},[]);let A=(0,K.useMemo)(()=>T.filter(e=>e.file&&!e.existing).map(e=>e.file),[T]);(0,K.useEffect)(()=>{if(x||!v.current)return;let e=new DataTransfer;A.forEach(t=>e.items.add(t)),v.current.files=e.files},[A,x]);function j(e){if(!n.image)return;let t=URL.createObjectURL(e);return y.current.add(t),t}function N(e){!e.url||!y.current.has(e.url)||(URL.revokeObjectURL(e.url),y.current.delete(e.url))}async function P(e,t){let n=()=>{D(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))},r=await ul(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 ll({url:i.url,method:i.method.toUpperCase(),body:t,headers:i.headers,onProgress:t=>D(n=>n.map(n=>n.id===e.id?{...n,progress:t}:n))});D(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`ready`:`error`,key:i.key,progress:100}:t))}catch{n()}}function F(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:j(e),existing:!1}));if(!S&&(T.forEach(N),!d)){let e=T.filter(e=>e.existing&&e.token).map(e=>e.token);e.length>0&&k(t=>[...t,...e])}D(e=>S?[...e,...n]:n),x&&n.forEach((e,n)=>void P(e,t[n]))}function I(e){let t=T.find(t=>t.id===e);t&&N(t),t?.existing&&t.token&&!d&&k(e=>[...e,t.token]),D(t=>t.filter(t=>t.id!==e))}return r?null:(0,J.jsx)(He,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:u,required:i,children:(0,J.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":M(u),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),F(e.dataTransfer.files)},children:[(0,J.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,J.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,J.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,J.jsx)(`img`,{alt:e.name,className:`size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover`,"data-test":M(`${u}-preview`),src:e.url}):null,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate`,"data-test":M(`${u}-item`),children:e.name}),e.status===`uploading`&&(0,J.jsxs)(`span`,{className:`text-xs text-lt-muted-fg`,children:[e.progress,`%`]}),e.status===`error`&&(0,J.jsx)(`span`,{className:`text-xs text-lt-danger`,children:t(`form.file-upload.failed`,`Failed`)})]}),(!e.existing||!d)&&(0,J.jsx)(at,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":M(e.existing?`${u}-remove-existing`:`${u}-remove`),disabled:b,onClick:()=>I(e.id)}),x&&!e.existing&&e.key&&e.status===`ready`&&(0,J.jsx)(`input`,{"data-test":M(`${u}-uploaded`),name:C,type:`hidden`,value:e.key})]},e.id))}),!d&&O.map(e=>(0,J.jsx)(`input`,{name:`${u}__removed[]`,type:`hidden`,value:e},e)),(0,J.jsx)(`input`,{accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":M(`${u}-input`),id:_,multiple:S,name:x?void 0:C,onChange:e=>{F(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function pl({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=Ee(),c=Object.entries(a).filter(([,e])=>!!e).map(([e,t])=>({label:o[e]??e,message:t})),l=c.length>0;return(0,J.jsxs)(`span`,{className:`group relative inline-flex flex-col`,children:[(0,J.jsxs)(G,{"data-lattice-form":i,"data-test":`form-submit`,disabled:s||l,emphasis:r,type:`submit`,variant:n,children:[s&&(0,J.jsx)(la,{}),e]}),l&&(0,J.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,J.jsx)(`p`,{className:`mb-1 font-medium text-lt-fg`,children:t}),(0,J.jsx)(`ul`,{className:`space-y-1`,children:c.map(e=>(0,J.jsxs)(`li`,{className:`text-lt-muted-fg`,children:[(0,J.jsx)(`span`,{className:`font-medium text-lt-fg`,children:e.label}),` — `,e.message]},e.label))})]})]})}var ml={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function hl({componentId:e,reset:t}){let n=dt();return Sn(a.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function gl({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}=Ea(e,n,r),p=(0,K.useMemo)(()=>({markUserEdit:f}),[f]);return(0,J.jsx)(De,{value:p,children:(0,J.jsx)(ma,{nodes:d,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,J.jsx)(`div`,{className:`flex gap-3 ${ml[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,J.jsx)(pl,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},Tn(e,t)):(0,J.jsx)(An,{node:e},Tn(e,t))):(0,J.jsx)(pl,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function _l(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var vl=({children:e,node:t})=>{let n=(0,K.useMemo)(()=>({...Da(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,J.jsx)(lt,{initial:n,children:(0,J.jsx)(yl,{node:t,children:e})})};function yl({children:e,node:t}){let{t:n}=E(`lattice`),r=t.props,i=r.action??`#`,a=r.errorBag,o=r.ref??``,s=r.method??`post`,c=r.precognitive,u=r.resetOnError??!1,d=r.resetOnSuccess??[],f=(0,K.useMemo)(()=>Da(t.schema).labels,[t.schema]),p=r.submitButton,m=r.submitButtons??void 0,h=r.submitJustify??void 0,g=r.submitLabel??n(`form.submit`,`Submit`),_=r.submitVariant??void 0,v=r.submitEmphasis??void 0,y=r.validationSummaryLabel,b=r.validationTimeout??void 0,x=dt(),S=e=>{let t=_l(e);t!==!1&&x(t)},C=(0,K.useRef)(null),w=(0,K.useRef)(`idle`),[T,D]=(0,K.useState)(0);return(0,K.useEffect)(()=>{T>0&&w.current===`renewing`&&C.current?.submit()},[T]),(0,J.jsx)(l,{ref:C,action:i,"data-slot":`form`,"data-lattice-component":t.id,errorBag:a,method:s,resetOnError:u,resetOnSuccess:d,validationTimeout:c?b:void 0,headers:Nt(o),className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,onStart:()=>{w.current=w.current===`renewing`?`retried`:`idle`},onSuccess:()=>S(d),onError:()=>S(u),onHttpException:e=>{if(e.status===403&&o!==``&&w.current!==`retried`)return w.current=`renewing`,Ut(o).finally(()=>D(e=>e+1)),!1},children:({clearErrors:n,errors:a,processing:s,reset:l,touch:u,validate:d,validating:b})=>(0,J.jsxs)(me,{value:{action:i,clearErrors:e=>n(e),componentId:t.id,componentRef:o,errors:a,fieldLabels:f,precognitive:c,processing:s,touch:e=>u(...e),validate:e=>d(e),validateFields:(e,t)=>d({only:e,...t}),validating:b},children:[(0,J.jsx)(hl,{componentId:t.id,reset:l}),r.status&&(0,J.jsx)(`div`,{className:`text-center text-sm font-medium text-lt-success`,children:r.status}),(0,J.jsx)(gl,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:p,submitButtons:m,submitEmphasis:v,submitJustify:h,submitLabel:g,submitVariant:_,summaryLabel:y,children:e})]})})}var bl=({node:e})=>{let t=ut(),n=e.props.name,r=t?t.getValue(n):e.props.value;return(0,J.jsx)(`input`,{defaultValue:typeof r==`string`?r:``,name:t?t.scopedName(n):n,type:`hidden`})};function xl({affix:e,side:t,squared:n=!1}){return(0,J.jsx)(`span`,{"data-slot":`affix-${t}`,className:L(`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,J.jsx)(I,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function Sl({prefix:e,suffix:t,end:n,children:r}){return!e&&!t&&!n?r(``):(0,J.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,J.jsx)(xl,{affix:e,side:`start`}):null,(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(L(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,J.jsx)(xl,{affix:t,side:`end`,squared:!!n}):null,n]})}var Cl=({node:e})=>{let t=e.props;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>{let s=e=>o(e.target.value);return t.slider?(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`input`,{"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,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`range`,value:r}),(0,J.jsx)(`output`,{className:`w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg`,children:r})]}):(0,J.jsx)(Sl,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,J.jsx)(mt,{autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},wl=Object.defineProperty,Tl=Object.defineProperties,El=Object.getOwnPropertyDescriptors,Dl=Object.getOwnPropertySymbols,Ol=Object.prototype.hasOwnProperty,kl=Object.prototype.propertyIsEnumerable,Al=(e,t,n)=>t in e?wl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jl=(e,t)=>{for(var n in t||={})Ol.call(t,n)&&Al(e,n,t[n]);if(Dl)for(var n of Dl(t))kl.call(t,n)&&Al(e,n,t[n]);return e},Ml=(e,t)=>Tl(e,El(t)),Nl=(e,t)=>{var n={};for(var r in e)Ol.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Dl)for(var r of Dl(e))t.indexOf(r)<0&&kl.call(e,r)&&(n[r]=e[r]);return n};function Pl(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function Fl(e){let t=K.useRef();return K.useEffect(()=>{t.current=e}),t.current}var Il=18,Ll=40,Rl=`${Ll}px`,zl=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function Bl({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=K.useState(!1),[o,s]=K.useState(!1),[c,l]=K.useState(!1),u=K.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=K.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-Il,f=u;document.querySelectorAll(zl).length===0&&document.elementFromPoint(d,f)===r||(a(!0),l(!0))},[e,t,c,n]);return K.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){let e=window.innerWidth-t.getBoundingClientRect().right;s(e>=Ll)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),K.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:Rl}}var Vl=K.createContext({}),Hl=K.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=Wl,render:h,children:g}=n,_=Nl(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`render`,`children`]),v;let[y,b]=K.useState(typeof _.defaultValue==`string`?_.defaultValue:``),x=r??y,S=Fl(x),C=K.useCallback(e=>{i?.(e),b(e)},[i]),w=K.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),T=K.useRef(null),E=K.useRef(null),D=K.useRef({value:x,onChange:C,isIOS:typeof window<`u`&&((v=window==null?void 0:window.CSS)?.supports)?.call(v,`-webkit-touch-callout`,`none`)}),O=K.useRef({prev:[T.current?.selectionStart,T.current?.selectionEnd,T.current?.selectionDirection]});K.useImperativeHandle(t,()=>T.current,[]),K.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;`;Ul(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Ul(e.sheet,`[data-input-otp]:autofill { ${t} }`),Ul(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Ul(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; } }`),Ul(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]=K.useState(!1),[j,M]=K.useState(!1),[N,P]=K.useState(null),[F,I]=K.useState(null);K.useEffect(()=>{Pl(()=>{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]),K.useEffect(()=>{S!==void 0&&x!==S&&S.length<a&&x.length===a&&u?.(x)},[a,u,S,x]);let L=Bl({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),R=K.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]),ee=K.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]),te=K.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]),ne=K.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),re=K.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]),z=K.useMemo(()=>K.createElement(`input`,Ml(jl({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:re,maxLength:a,value:x,ref:T,onPaste:e=>{var t;te(e),(t=_.onPaste)==null||t.call(_,e)},onChange:R,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;ee(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[R,ee,te,l,re,a,F,N,_,w?.source,x]),B=K.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]),ie=K.useMemo(()=>h?h(B):K.createElement(Vl.Provider,{value:B},g),[g,B,h]);return K.createElement(K.Fragment,null,m!==null&&K.createElement(`noscript`,null,K.createElement(`style`,null,m)),K.createElement(`div`,{ref:E,"data-input-otp-container":!0,style:ne,className:p},ie,K.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},z)))});Hl.displayName=`Input`;function Ul(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var Wl=`
|
|
2
|
+
import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i,s as a}from"./chunks/locale-GyqtaX1O.js";import{n as o,t as s}from"./chunks/jsx-runtime-CN5ucv1d.js";import{a as c,c as l,d as u,f as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x}from"./chunks/use-effect-dispatcher-CJXFkAv1.js";import{n as S,t as C}from"./chunks/materialize-CWqnSEHR.js";import{o as w,r as T,s as E}from"./chunks/instance-C4O1XWa6.js";import{a as D,i as O,n as k,r as A}from"./chunks/timezone-CyoBch3a.js";import{t as j}from"./chunks/shared-props-B_wT1GcG.js";import{i as M,n as N,r as P,t as F}from"./chunks/test-id-Dh3L6Gfh.js";import{_ as I,b as L,g as R,h as ee,i as te,n as ne,r as re,t as z,v as B,y as ie}from"./chunks/dist-ci5ng714.js";import{n as ae,t as oe}from"./chunks/translatable-DLw4h3x8.js";import{$ as se,A as ce,B as le,C as ue,D as de,E as fe,F as pe,G as V,H as me,I as he,J as ge,K as _e,L as ve,M as ye,N as be,O as xe,P as Se,Q as Ce,R as we,S as Te,T as Ee,U as De,V as Oe,W as ke,X as Ae,Y as je,Z as Me,_ as Ne,a as Pe,at as Fe,b as Ie,c as Le,ct as H,d as Re,dt as U,et as ze,f as Be,g as Ve,h as He,i as Ue,it as We,j as Ge,k as Ke,l as qe,lt as Je,m as Ye,n as Xe,nt as Ze,o as Qe,ot as $e,p as et,q as tt,r as nt,rt,s as it,st as at,t as ot,tt as st,u as ct,ut as lt,v as ut,w as dt,x as ft,y as pt,z as mt}from"./chunks/icon-button-D3AltHNz.js";import{a as ht,c as W,i as gt,l as _t,n as vt,o as yt,r as bt,s as xt,t as St}from"./chunks/time-picker-kbhOHEPd.js";import{a as Ct,i as wt,n as Tt,o as Et,r as Dt,t as Ot}from"./chunks/number-BvVKQqOG.js";var kt=`X-Lattice-Ref`,At=new Map;function jt(e){return At.get(e)??e}function Mt(e,t){At.set(e,t)}function Nt(e){let t=jt(e);return t?{[kt]:t}:{}}function Pt(e=``,t={}){return{...r(),...Nt(e),...t}}var Ft=class extends Error{response;constructor(e){super(`HTTP ${e.status}`),this.response=e}};function It(){let e=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):``}var Lt=1e4,Rt=new Map,zt=new Map;function Bt(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":It()}}var Vt=`/lattice/refs/refresh`;function Ht(e){Vt=e}var Ut=new Map;async function Wt(e){let t=Ut.get(e);if(t)return t;let n=Kt(Vt,{method:`POST`,body:JSON.stringify({ref:jt(e)})}).then(t=>(Mt(e,t.ref),t.ref)).catch(()=>null).finally(()=>{Ut.delete(e)});return Ut.set(e,n),n}async function Gt(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:Pt(n,{...Bt(s),...r})}),l=await c();if(n!==``&&l.status===403&&await Wt(n)!==null&&(l=await c()),i&&!l.ok)throw new Ft(l);return l}async function Kt(e,t){return(await Gt(e,t)).json()}function qt(e){return[e.source,e.audience,[...e.scopes].sort().join(` `)].join(``)}function Jt(e){Rt.delete(qt(e))}async function Yt(e){let t=qt(e),n=Rt.get(t);if(n&&n.expiresAt>Date.now()+Lt)return n.token;let r=zt.get(t);if(r)return r;let i=Kt(e.tokenEndpoint,{method:`POST`,ref:e.ref,body:JSON.stringify({nodeId:e.nodeId,nodeType:e.nodeType,audience:e.audience,scopes:e.scopes})}).then(e=>(Rt.set(t,{token:e,expiresAt:Date.now()+Math.max(0,e.expiresIn)*1e3}),e)).finally(()=>{zt.delete(t)});return zt.set(t,i),i}function Xt(e){return e.status===401||e.status===403}async function Zt(e,t,n){let{headers:i,...a}=t;return fetch(e,{...a,credentials:`omit`,headers:{Accept:`application/json`,...r(),...i,Authorization:`${n.tokenType} ${n.accessToken}`}})}async function Qt(e,t){let{remote:n,throwOnError:r=!0,...i}=t,a=await Yt(n),o=await Zt(e,i,a);if(Xt(o)&&(Jt(n),a=await Yt(n),o=await Zt(e,i,a)),r&&!o.ok)throw new Ft(o);return o}async function $t(e,t){return(await Qt(e,t)).json()}var G=e(t(),1),en=`modulepreload`,tn=function(e,t){return new URL(e,t).href},nn={},rn=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=tn(t,n),t=s(t),t in nn)return;nn[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`:en,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)})},an=[`light`,`dark`,`system`],{subscribe:on,notify:sn}=i(),cn=`system`;function ln(e){un(e)}function un(e){return an.some(t=>t===e)}var dn=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,fn=(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`},pn=()=>{if(typeof window>`u`)return`system`;let e=localStorage.getItem(`appearance`);return un(e)?e:`system`},mn=e=>e===`dark`||e===`system`&&dn(),hn=e=>{if(typeof document>`u`)return;let t=mn(e);document.documentElement.classList.toggle(`dark`,t),document.documentElement.style.colorScheme=t?`dark`:`light`},gn=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),_n=()=>{hn(cn),sn()};function vn(e){cn=e,localStorage.setItem(`appearance`,e),fn(`appearance`,e),hn(e),sn()}function yn(){typeof window>`u`||(localStorage.getItem(`appearance`)||(localStorage.setItem(`appearance`,`system`),fn(`appearance`,`system`)),cn=pn(),hn(cn),gn()?.addEventListener(`change`,_n))}function K(e){return{component:e,mode:`eager`}}function bn(e){return e}function xn(...e){return e.reduce((e,t)=>({components:{...e.components,...t.components},columns:{...e.columns,...t.columns},effects:{...e.effects,...t.effects}}),{components:{},columns:{},effects:{}})}function Sn(e,...t){let n=xn(...t);return{components:{...e.components,...n.components},columns:{...e.columns,...n.columns},effects:{...e.effects,...n.effects}}}function Cn(e,t,n={}){let{enabled:r=!0}=n,i=(0,G.useRef)(t);i.current=t,(0,G.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 wn({preserveScroll:e=!0,preserveState:t=!0}){return Cn(a.localeChange,n=>{let r=n.detail?.locale;typeof r==`string`&&r!==``&&m.visit(window.location.href,{preserveScroll:e,preserveState:t})}),null}function Tn(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`):[]}function En(e,t){return e.key??e.id??`${e.type}-${t}`}var Dn=(0,G.createContext)(!1);function On(){return(0,G.useContext)(Dn)}var q=s();function kn(){return(0,q.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,q.jsx)(`rect`,{height:`18`,rx:`2`,strokeDasharray:`4 3`,width:`18`,x:`3`,y:`3`}),(0,q.jsx)(`path`,{d:`M12 8v4`}),(0,q.jsx)(`path`,{d:`M12 16h.01`})]})}function An({node:e}){e.type;let t=`Missing component: ${e.type}`;return(0,q.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,q.jsx)(kn,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]})}function J({nodes:e}){return e.map((e,t)=>(0,q.jsx)(jn,{node:e},En(e,t)))}function Y({node:e}){return(0,q.jsx)(jn,{node:e})}var jn=(0,G.memo)(function({node:e}){let t=On(),n=y()[e.type];if(t&&e.props?.hideWhenCollapsed===!0)return null;if(!n)return(0,q.jsx)(An,{node:e});let r=n.component,i=e.schema?.length?(0,q.jsx)(J,{nodes:e.schema}):null,a=(0,q.jsx)(r,{node:e,children:i});return n.mode===`lazy`?(0,q.jsx)(G.Suspense,{fallback:null,children:a}):a}),Mn=[`primary`,`secondary`,`success`,`info`,`warning`,`danger`];function Nn(e){return Mn.some(t=>t===e)}function Pn(e){let t=typeof e==`string`||oe(e)?e:null;return t===``?null:t}function Fn(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 In(e){if(typeof e!=`object`||!e)return null;let t=e,n=Pn(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:Nn(t.variant)?t.variant:`success`}}function Ln(e){return Fn(a.toast,In,e)}function Rn(e){if(typeof e!=`object`||!e)return null;let t=e,n=Pn(t.message);return n===null?null:{action:t.action??null,dismissible:t.dismissible!==!1,message:n,title:typeof t.title==`string`||oe(t.title)?t.title:null,unique:typeof t.unique==`string`?t.unique:null,variant:Nn(t.variant)?t.variant:`info`}}function zn(e){return Fn(a.callout,Rn,e)}function Bn(e){return Fn(a.retractCallout,e=>{let t=e?.unique;return typeof t==`string`?t:null},e)}var Vn=Object.defineProperty,X=(e,t)=>Vn(e,`name`,{value:t,configurable:!0});function Hn(e){let t=e+`CollectionProvider`,[n,r]=lt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=X(e=>{let{scope:t,children:n}=e,r=G.useRef(null),a=G.useRef(new Map).current;return(0,q.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=ee(s),l=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=R(t,i.collectionRef);return(0,q.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ee(u),p=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),s=R(t,o),c=a(u,n);return G.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,q.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return G.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 X(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}X(Hn,`createCollection`);var Un=new WeakMap,Wn=class e extends Map{static{X(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Un.set(this,!0)}set(e,t){return Un.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=qn(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=Gn(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Gn(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Gn(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 Gn(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Kn(e,t);return n===-1?void 0:e[n]}X(Gn,`at`);function Kn(e,t){let n=e.length,r=qn(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}X(Kn,`toSafeIndex`);function qn(e){return e!==e||e===0?0:Math.trunc(e)}X(qn,`toSafeInteger`);function Jn(e){let t=e+`CollectionProvider`,[n,r]=lt(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Wn,setItemMap:X(()=>void 0,`setItemMap`)}),o=X(({state:e,...t})=>e?(0,q.jsx)(c,{...t,state:e}):(0,q.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=X(e=>{let t=h();return(0,q.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=X(e=>{let{scope:t,children:n,state:r}=e,a=G.useRef(null),[o,s]=G.useState(null),c=R(a,s),[l,u]=r;return G.useEffect(()=>{if(!o)return;let e=Qn(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,q.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=ee(l),d=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=R(t,i.collectionRef);return(0,q.jsx)(u,{ref:o,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=ee(f),m=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),[s,c]=G.useState(null),l=R(t,o,c),{setItemMap:u}=a(f,n),d=G.useRef(i);Yn(d.current,i)||(d.current=i);let m=d.current;return G.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Zn):(t.set(s,{...e,element:s}),t.toSorted(Zn)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Wn(e)))}},[s,m,u]),(0,q.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return G.useState(new Wn)}X(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return X(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}X(Jn,`createCollection`);function Yn(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}X(Yn,`shallowEqual`);function Xn(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}X(Xn,`isElementPreceding`);function Zn(e,t){return!e[1].element||!t[1].element?0:Xn(e[1].element,t[1].element)?-1:1}X(Zn,`sortByDocumentPosition`);function Qn(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}X(Qn,`getChildListObserver`);var $n=Object.defineProperty,er=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),tr=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`}),nr=G.forwardRef(er(function(e,t){return(0,q.jsx)(H.span,{...e,ref:t,style:{...tr,...e.style}})},`VisuallyHidden`)),rr=e(o(),1),ir=Object.defineProperty,Z=(e,t)=>ir(e,`name`,{value:t,configurable:!0}),ar=`ToastProvider`,[or,sr,cr]=Hn(`Toast`),[lr,ur]=lt(`Toast`,[cr]),[dr,fr]=lr(ar),pr=Z(e=>{let{__scopeToast:t,label:n=`Notification`,duration:r=5e3,swipeDirection:i=`right`,swipeThreshold:a=50,announcerContainer:o,children:s}=e,[c,l]=G.useState(null),[u,d]=G.useState(0),f=G.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${ar}\`. Expected non-empty \`string\`.`),(0,q.jsx)(or.Provider,{scope:t,children:(0,q.jsx)(dr,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:u,viewport:c,onViewportChange:l,onToastAdd:G.useCallback(()=>d(e=>e+1),[]),onToastRemove:G.useCallback(()=>d(e=>e-1),[]),isClosePausedRef:f,announcerContainer:o,children:s})})},`ToastProvider`),mr=`ToastViewport`,hr=[`F8`],gr=`toast.viewportPause`,_r=`toast.viewportResume`,vr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,hotkey:r=hr,label:i=`Notifications ({hotkey})`,...a}=e,o=fr(mr,n),s=sr(n),c=G.useRef(null),l=G.useRef(null),u=G.useRef(null),d=G.useRef(null),f=R(t,d,o.onViewportChange),p=r.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),m=o.toastCount>0;G.useEffect(()=>{let e=Z(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]),G.useEffect(()=>{let e=c.current,t=d.current;if(m&&e&&t){let n=Z(()=>{if(!o.isClosePausedRef.current){let e=new CustomEvent(gr);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},`handlePause`),r=Z(()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(_r);t.dispatchEvent(e),o.isClosePausedRef.current=!1}},`handleResume`),i=Z(t=>{e.contains(t.relatedTarget)||r()},`handleFocusOutResume`),a=Z(()=>{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=G.useCallback(({tabbingDirection:e})=>{let t=s().map(t=>{let n=t.ref.current,r=[n,...Br(n)];return e===`forwards`?r:r.reverse()});return(e===`forwards`?t.reverse():t).flat()},[s]);return G.useEffect(()=>{let e=d.current;if(e){let t=Z(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);Vr(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,q.jsxs)(rt,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,q.jsx)(br,{ref:l,onFocusFromOutsideViewport:()=>{Vr(h({tabbingDirection:`forwards`}))}}),(0,q.jsx)(or.Slot,{scope:n,children:(0,q.jsx)(H.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,q.jsx)(br,{ref:u,onFocusFromOutsideViewport:()=>{Vr(h({tabbingDirection:`backwards`}))}})]})},`ToastViewport`)),yr=`ToastFocusProxy`,br=G.forwardRef(Z(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=fr(yr,n);return(0,q.jsx)(nr,{tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})},`ToastFocusProxy`)),xr=`Toast`,Sr=`toast.swipeStart`,Cr=`toast.swipeMove`,wr=`toast.swipeCancel`,Tr=`toast.swipeEnd`,Er=G.forwardRef(Z(function(e,t){let{forceMount:n,open:r,defaultOpen:i,onOpenChange:a,...o}=e,[s,c]=se({prop:r,defaultProp:i??!0,onChange:a,caller:xr});return(0,q.jsx)(ze,{present:n||s,children:(0,q.jsx)(kr,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:at(e.onPause),onResume:at(e.onResume),onSwipeStart:U(e.onSwipeStart,e=>{e.currentTarget.setAttribute(`data-swipe`,`start`)}),onSwipeMove:U(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:U(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:U(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`)),[Dr,Or]=lr(xr,{onClose(){}}),kr=G.forwardRef(Z(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=fr(xr,n),g=sr(n),[_,v]=G.useState(null),y=R(t,v),b=G.useRef(null),x=G.useRef(null),S=i||h.duration,C=G.useRef(0),w=G.useRef(S),T=G.useRef(0),{onToastAdd:E,onToastRemove:D}=h,O=at(()=>{_?.contains(document.activeElement)&&h.viewport?.focus(),o()}),k=G.useCallback(e=>{!e||e===1/0||(window.clearTimeout(T.current),C.current=new Date().getTime(),T.current=window.setTimeout(O,e))},[O]);G.useEffect(()=>{let e=h.viewport;if(e){let t=Z(()=>{k(w.current),l?.()},`handleResume`),n=Z(()=>{let e=new Date().getTime()-C.current;w.current-=e,window.clearTimeout(T.current),c?.()},`handlePause`);return e.addEventListener(gr,n),e.addEventListener(_r,t),()=>{e.removeEventListener(gr,n),e.removeEventListener(_r,t)}}},[h.viewport,S,c,l,k]),G.useEffect(()=>{a&&!h.isClosePausedRef.current&&k(S)},[a,S,h.isClosePausedRef,k]),G.useEffect(()=>()=>{window.clearTimeout(T.current)},[]),G.useEffect(()=>(E(),()=>D()),[E,D]);let A=G.useMemo(()=>_?Fr(_):null,[_]);return h.viewport?(0,q.jsxs)(q.Fragment,{children:[A&&(0,q.jsx)(Ar,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,children:A}),(0,q.jsx)(Dr,{scope:n,onClose:O,children:rr.createPortal((0,q.jsx)(or.ItemSlot,{scope:n,children:(0,q.jsx)(Fe,{asChild:!0,onEscapeKeyDown:U(s,e=>{g().some(t=>t.ref.current?.contains(e.target))||O()}),children:(0,q.jsx)(H.li,{tabIndex:0,"data-state":a?`open`:`closed`,"data-swipe-direction":h.swipeDirection,...m,ref:y,style:{userSelect:`none`,touchAction:`none`,...e.style},onKeyDown:U(e.onKeyDown,e=>{e.key===`Escape`&&(s?.(e.nativeEvent),e.nativeEvent.defaultPrevented||O())}),onPointerDown:U(e.onPointerDown,e=>{e.button===0&&(b.current={x:e.clientX,y:e.clientY})}),onPointerMove:U(e.onPointerMove,e=>{if(!b.current)return;let t=e.clientX-b.current.x,n=e.clientY-b.current.y,r=!!x.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?(x.current=l,Ir(Cr,d,f,{discrete:!1})):Lr(l,h.swipeDirection,c)?(x.current=l,Ir(Sr,u,f,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(n)>c)&&(b.current=null)}),onPointerUp:U(e.onPointerUp,e=>{let t=x.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),x.current=null,b.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};Lr(t,h.swipeDirection,h.swipeThreshold)?Ir(Tr,p,r,{discrete:!0}):Ir(wr,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null},`ToastImpl`)),Ar=Z(e=>{let{__scopeToast:t,children:n,...r}=e,i=fr(xr,t),[a,o]=G.useState(!1),[s,c]=G.useState(!1);return Rr(()=>o(!0)),G.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,q.jsx)(st,{asChild:!0,container:i.announcerContainer||void 0,children:(0,q.jsx)(nr,{...r,children:a&&(0,q.jsxs)(q.Fragment,{children:[i.label,` `,n]})})})},`ToastAnnounce`),jr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e;return(0,q.jsx)(H.div,{...r,ref:t})},`ToastTitle`)),Mr=`ToastClose`,Nr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e,i=Or(Mr,n);return(0,q.jsx)(Pr,{asChild:!0,children:(0,q.jsx)(H.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,i.onClose)})})},`ToastClose`)),Pr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,altText:r,...i}=e;return(0,q.jsx)(H.div,{"data-radix-toast-announce-exclude":``,"data-radix-toast-announce-alt":r||void 0,...i,ref:t})},`ToastAnnounceExclude`));function Fr(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),zr(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(...Fr(e))}}),t}Z(Fr,`getAnnounceTextContent`);function Ir(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?Je(i,a):i.dispatchEvent(a)}Z(Ir,`handleAndDispatchCustomEvent`);var Lr=Z((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 Rr(e=()=>{}){let t=at(e);Ze(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}Z(Rr,`useNextFrame`);function zr(e){return e.nodeType===e.ELEMENT_NODE}Z(zr,`isHTMLElement`);function Br(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Z(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}Z(Br,`getTabbableCandidates`);function Vr(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}Z(Vr,`focusFirst`);var Hr=pr,Ur=vr,Wr=Er,Gr=jr,Kr=Nr;function qr({value:e,dateStyle:t=`medium`,timeStyle:r=`short`}){let{locale:i}=n(),{timezone:a}=k();if(e==null||e===``)return null;let o={locale:i,timeZone:a},s=A(e,{dateStyle:t,timeStyle:r},o),c=Jr(e),l=O(e,o);return(0,q.jsx)(`time`,{dateTime:c??void 0,title:l||void 0,children:s})}function Jr(e){return D(e)?.toISOString()??null}var Yr={primary:{accent:`border-l-lt-primary`,icon:(0,q.jsx)(B,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-primary`})},secondary:{accent:`border-l-lt-secondary`,icon:(0,q.jsx)(B,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-muted-fg`})},success:{accent:`border-l-lt-success`,icon:(0,q.jsx)(B,{name:`circle-check`,className:`size-lt-icon-lg shrink-0 text-lt-success`})},info:{accent:`border-l-lt-info`,icon:(0,q.jsx)(B,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-info`})},warning:{accent:`border-l-lt-warning`,icon:(0,q.jsx)(B,{name:`circle-alert`,className:`size-lt-icon-lg shrink-0 text-lt-warning`})},danger:{accent:`border-l-lt-danger`,icon:(0,q.jsx)(B,{name:`circle-x`,className:`size-lt-icon-lg shrink-0 text-lt-danger`})}},Xr=0;function Zr({duration:e=4e3}){let{t}=E(`lattice`),[n,r]=(0,G.useState)([]);function i(e){r(t=>t.filter(t=>t.id!==e))}return(0,G.useEffect)(()=>Ln(e=>{r(t=>[...t,{...e,id:Xr++}])}),[]),(0,q.jsxs)(Hr,{duration:e,swipeDirection:`down`,children:[n.map(n=>(0,q.jsxs)(Wr,{className:L(`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`,Yr[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:[Yr[n.variant].icon,(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,q.jsx)(Gr,{className:`text-sm text-lt-fg`,children:ae(n.message,t)}),n.action?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(Y,{node:n.action})}):null]}),n.dismissible?(0,q.jsx)(Kr,{"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,q.jsx)(B,{name:`x`,className:`size-lt-icon-md`})}):null]},n.id)),(0,q.jsx)(Ur,{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 Qr=0,$r=()=>{let{t:e}=E(`lattice`),[t,n]=(0,G.useState)([]);(0,G.useEffect)(()=>zn(e=>{n(t=>[...e.unique?t.filter(t=>t.unique!==e.unique):t,{...e,id:Qr++}])}),[]),(0,G.useEffect)(()=>m.on(`navigate`,()=>{n(e=>e.filter(e=>!e.unique))}),[]),(0,G.useEffect)(()=>Bn(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,q.jsx)(`div`,{className:`flex w-full flex-col gap-2`,children:t.map(t=>(0,q.jsxs)(`div`,{role:`status`,"data-test":`callout-${t.variant}`,className:L(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg`,Yr[t.variant].accent),children:[Yr[t.variant].icon,(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[t.title?(0,q.jsx)(`p`,{className:`text-sm font-medium text-lt-fg`,children:ae(t.title,e)}):null,(0,q.jsx)(`p`,{className:`text-sm text-lt-fg`,children:ae(t.message,e)}),t.action?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(Y,{node:t.action})}):null]}),t.dismissible?(0,q.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,q.jsx)(B,{name:`x`,className:`size-lt-icon-md`})}):null]},t.id))})},ei=({node:e})=>{let{t}=E(`lattice`),n=d().props.lattice?.breadcrumbs??[];return n.length===0?null:(0,q.jsx)(`nav`,{"aria-label":t(`common.breadcrumb`,`Breadcrumb`),"data-lattice-component":F(e),children:(0,q.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,q.jsxs)(G.Fragment,{children:[(0,q.jsx)(`li`,{children:r?(0,q.jsx)(`span`,{"aria-current":`page`,className:`text-lt-fg`,children:e.title}):(0,q.jsx)(x,{className:`hover:text-lt-fg`,href:e.href,children:e.title})}),r?null:(0,q.jsx)(`li`,{"aria-hidden":`true`,children:`/`})]},e.href)})})})};function ti({align:e=`start`,children:t,className:n,placement:r=`bottom`,testId:i,trigger:a,triggerClassName:o,triggerLabel:s}){let[c,l]=(0,G.useState)(!1),u=d().url;return(0,G.useEffect)(()=>l(!1),[u]),(0,q.jsxs)(ke,{open:c,onOpenChange:l,children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{"aria-label":s,className:L(`w-full`,o),"data-test":i,title:s,type:`button`,children:a})}),(0,q.jsx)(V,{align:e,className:L(`min-w-56 p-1`,n),role:`menu`,side:r,children:(0,q.jsx)(Dn.Provider,{value:!1,children:t})})]})}var ni=({children:e,node:t})=>{let n=t.key??`dropdown`;return(0,q.jsx)(ti,{placement:t.props.placement,testId:n,triggerClassName:`w-auto`,trigger:(0,q.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,q.jsx)(Y,{node:e},e.key??`${e.type}-${t}`))}),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})})},ri=({children:e,node:t})=>(0,q.jsx)(`nav`,{"data-lattice-component":F(t),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})}),ii=(0,G.createContext)(null),ai=`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 oi({affix:e,className:t}){return e.icon?(0,q.jsx)(I,{className:L(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,q.jsx)(`span`,{className:L(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function si(e,t){return(e??[]).some(e=>e.props?.href===t||si(e.schema,t))}var ci=({children:e,node:t})=>{let n=On(),{icon:r,label:i,prefix:a,suffix:o}=t.props,s=i??``,c=!!r,l=r??a?.icon??null,u=d().url.split(`?`)[0],f=N(`menu`,t),p=te(t.props),m=r?(0,q.jsx)(I,{className:`size-lt-icon-md shrink-0`,icon:r}):(0,q.jsxs)(q.Fragment,{children:[a?(0,q.jsx)(oi,{affix:a}):null,n?(0,q.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:s}):(0,q.jsx)(`span`,{children:s}),o?(0,q.jsx)(oi,{affix:o,className:`ml-auto`}):null]}),h=L(ai,`w-full`,n&&`group relative justify-center`,c&&`justify-center`),g=({onClick:e,processing:t})=>(0,q.jsx)(`button`,{"aria-label":n||c?s:void 0,className:h,"data-test":f,disabled:t,onClick:e,type:`button`,children:m});if(p.kind===`action`)return(0,q.jsx)(`li`,{children:(0,q.jsx)(ne,{action:p.action,children:g})});if(p.kind===`effects`)return(0,q.jsx)(`li`,{children:g({onClick:p.onClick,processing:!1})});if(p.kind===`navigate`){let e=u===p.href;return(0,q.jsx)(`li`,{children:(0,q.jsx)(x,{"aria-current":e?`page`:void 0,"aria-label":n||c?s:void 0,as:p.method===`get`?void 0:`button`,className:L(h,e&&`bg-lt-muted font-medium`),"data-test":f,href:p.href,method:p.method,children:m})})}return e?n?(0,q.jsx)(ui,{icon:l,label:s,testId:f,children:e}):(0,q.jsx)(li,{content:m,defaultOpen:si(t.schema,u),testId:f,children:e}):n?null:(0,q.jsx)(`li`,{children:(0,q.jsx)(`span`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:m})})};function li({children:e,content:t,defaultOpen:n,testId:r}){let[i,a]=(0,G.useState)(n);return(0,q.jsxs)(`li`,{children:[(0,q.jsxs)(`button`,{"aria-expanded":i,className:L(ai,`w-full`),"data-test":r,onClick:()=>a(e=>!e),type:`button`,children:[t,(0,q.jsx)(B,{name:`chevron-right`,className:L(`ml-auto size-lt-icon-md shrink-0 transition-transform`,i&&`rotate-90`)})]}),i?(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1 pl-3`,children:e}):null]})}function ui({children:e,icon:t,label:n,testId:r}){return(0,q.jsx)(`li`,{children:(0,q.jsx)(ti,{className:`min-w-48`,placement:`right`,testId:r,trigger:t?(0,q.jsx)(I,{className:`size-lt-icon-md shrink-0`,icon:t}):(0,q.jsx)(`span`,{children:n}),triggerClassName:L(ai,`justify-center`),triggerLabel:n,children:(0,q.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`li`,{className:`px-3 py-1.5 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:n}),e]})})})}var di=()=>(0,q.jsx)(q.Fragment,{children:(0,G.useContext)(ii)});function fi(e,t){return typeof window>`u`||typeof window.matchMedia!=`function`?t:window.matchMedia(e).matches}function pi(e,t=!1){let[n,r]=(0,G.useState)(()=>fi(e,t));return(0,G.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}function mi(e,t,n={}){let{enabled:r=!0,parse:i,serialize:a}=n,o=()=>typeof t==`function`?t():t,[s,c]=(0,G.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,G.useRef)(s);l.current=s;let u=(0,G.useRef)({enabled:r,key:e,serialize:a});return u.current={enabled:r,key:e,serialize:a},[s,(0,G.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}},[])]}function hi(e,t,n){let[r,i]=mi(e,t,{enabled:n,parse:e=>e===`true`,serialize:String});return[r,(0,G.useCallback)(()=>i(e=>!e),[i])]}var gi=`(min-width: 768px)`;function _i(e,t){let n=e.detail?.target;return n==null||n===t}var vi=bn({components:{breadcrumbs:K(ei),callouts:K($r),dropdown:K(ni),menu:K(ri),"menu-item":K(ci),outlet:K(di),sidebar:K(({children:e,node:t})=>{let n=t.props.collapsible,r=t.props.rememberState,i=F(t),o=`lattice:sidebar:${i??`default`}`,s=pi(gi,!0),[c,l]=hi(o,!1,n&&r),[u,d]=(0,G.useState)(!1);Cn(a.toggleSidebar,e=>{_i(e,i)&&(window.matchMedia?.(gi).matches??!0?n&&l():d(e=>!e))}),(0,G.useEffect)(()=>m.on(`navigate`,()=>d(!1)),[]),Cn(`keydown`,e=>{e.key===`Escape`&&d(!1)},{enabled:u});let f=n&&c&&s;return(0,q.jsxs)(Dn.Provider,{value:f,children:[u?(0,q.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,q.jsx)(`aside`,{className:L(`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]`,u?`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:K(({children:e,node:t})=>{let n=t.props.sticky;return(0,q.jsx)(`header`,{"data-lattice-component":F(t),className:L(`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 yi({children:e}){let t=d().props.lattice.layout;return t?(0,q.jsx)(ii.Provider,{value:e,children:(0,q.jsx)(J,{nodes:t.schema})}):(0,q.jsx)(q.Fragment,{children:e})}var bi=(0,G.lazy)(()=>rn(()=>import(`./chunks/subscriptions-BV4g0s0U.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),xi=class extends G.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 Si({listeners:e}){return e.length===0?null:(0,q.jsx)(xi,{children:(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(bi,{listeners:e})})})}function Ci({lattice:e}){let t=(0,q.jsx)(J,{nodes:e.schema});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(p,{title:e.title??void 0}),(0,q.jsx)(Si,{listeners:e.listeners}),e.container===`centered`?(0,q.jsx)(`main`,{className:`min-h-svh bg-lt-bg text-lt-fg`,children:(0,q.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,q.jsx)(`div`,{"data-test":`lattice-default-container`,className:L(`w-full`,{"px-4 py-6":e.layout!==null}),children:t})]})}function wi(e){return t=>{if(t===`lattice/page`)return{default:Ci};let n=e[`./Pages/${t}.tsx`]??e[`./pages/${t}.tsx`];if(n)return n();throw Error(`Page not found: ${t}`)}}function Ti({defaultLayout:e}={}){return(t,n)=>t===`lattice/page`?n.props.lattice?.layout?yi:null:e?.(t,n)??null}function Ei(e,t){return{...t,headers:Pt(``,t.headers)}}var Di=!1;function Oi(){Di||(Di=!0,_.onRequest(e=>{let t=e.headers?.[kt];return e.headers&&typeof t==`string`&&t!==``&&(e.headers[kt]=jt(t)),e}))}var ki=Object.defineProperty,Q=(e,t)=>ki(e,`name`,{value:t,configurable:!0}),Ai=`Dialog`,[ji,Mi]=lt(Ai),[Ni,Pi]=ji(Ai),Fi=Q(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=G.useRef(null),c=G.useRef(null),[l,u]=se({prop:r,defaultProp:i??!1,onChange:a,caller:Ai}),[d,f]=G.useState(0),[p,m]=G.useState(0);return(0,q.jsx)(Ni,{scope:t,triggerRef:s,contentRef:c,contentId:Ae(),titleId:Ae(),descriptionId:Ae(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:G.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Ii=`DialogPortal`,[Li,Ri]=ji(Ii,{forceMount:void 0}),zi=Q(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Pi(Ii,t);return(0,q.jsx)(Li,{scope:t,forceMount:n,children:G.Children.map(r,e=>(0,q.jsx)(ze,{present:n||a.open,children:(0,q.jsx)(st,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Bi=`DialogOverlay`,Vi=G.forwardRef(Q(function(e,t){let n=Ri(Bi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Pi(Bi,e.__scopeDialog);return a.modal?(0,q.jsx)(ze,{present:r||a.open,children:(0,q.jsx)(Ui,{...i,ref:t})}):null},`DialogOverlay`)),Hi=ee(`DialogOverlay.RemoveScroll`),Ui=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Bi,n),a=$e(),o=R(t,a);return(0,q.jsx)(tt,{as:Hi,allowPinchZoom:!0,shards:[i.contentRef],children:(0,q.jsx)(H.div,{"data-state":ta(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Wi=`DialogContent`,Gi=G.forwardRef(Q(function(e,t){let n=Ri(Wi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Pi(Wi,e.__scopeDialog);return(0,q.jsx)(ze,{present:r||a.open,children:a.modal?(0,q.jsx)(Ki,{...i,ref:t}):(0,q.jsx)(qi,{...i,ref:t})})},`DialogContent`)),Ki=G.forwardRef(Q(function(e,t){let n=Pi(Wi,e.__scopeDialog),r=G.useRef(null),i=R(t,n.contentRef,r);return G.useEffect(()=>{let e=r.current;if(e)return ge(e)},[]),(0,q.jsx)(Ji,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:U(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:U(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),qi=G.forwardRef(Q(function(e,t){let n=Pi(Wi,e.__scopeDialog),r=G.useRef(!1),i=G.useRef(!1);return(0,q.jsx)(Ji,{...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`)),Ji=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Pi(Wi,n);return Ce(),(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Me,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(We,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":ta(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Yi=`DialogTitle`,Xi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Yi,n),{setTitleCount:a}=i;return Ze(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,q.jsx)(H.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Zi=`DialogDescription`,Qi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Zi,n),{setDescriptionCount:a}=i;return Ze(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,q.jsx)(H.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),$i=`DialogClose`,ea=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi($i,n);return(0,q.jsx)(H.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function ta(e){return e?`open`:`closed`}Q(ta,`getState`);var na=z(`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 max-h-[min(680px,calc(100vh-2rem))] -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`}},defaultVariants:{placement:`center`,width:`lg`}});function ra(e){return(0,q.jsx)(Fi,{"data-slot":`dialog`,...e})}function ia(e){return(0,q.jsx)(ea,{"data-slot":`dialog-close`,...e})}function aa({className:e,...t}){return(0,q.jsx)(Xi,{className:L(`text-lg font-semibold leading-none tracking-tight`,e),"data-slot":`dialog-title`,...t})}function oa({className:e,...t}){return(0,q.jsx)(Qi,{className:L(`text-sm text-lt-muted-fg`,e),"data-slot":`dialog-description`,...t})}function sa({children:e,className:t,placement:n=`center`,width:r=`lg`,...i}){return(0,q.jsxs)(zi,{children:[(0,q.jsx)(Vi,{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,q.jsx)(Gi,{className:L(na({placement:n,width:r}),t),"data-slot":`dialog-content`,...i,children:e})]})}function ca({closeLabel:e,description:t,title:n}){return(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(aa,{children:n}),t?(0,q.jsx)(oa,{children:t}):null]}),(0,q.jsx)(ia,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":e,"data-test":`dialog-close`,size:`icon`,emphasis:`ghost`,children:(0,q.jsx)(B,{name:`x`,"aria-hidden":`true`,className:`size-lt-icon-md`})})})]})}function la({className:e,...t}){let{t:n}=E(`lattice`);return(0,q.jsx)(B,{name:`loader-2`,role:`status`,"aria-label":n(`common.loading`,`Loading`),"aria-hidden":!1,className:L(`animate-spin`,e),...t})}function ua({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,q.jsx)(ra,{open:!0,onOpenChange:e=>{e||l()},children:(0,q.jsxs)(sa,{...t?{}:{"aria-describedby":void 0},width:`md`,onEscapeKeyDown:u,onInteractOutside:u,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(aa,{children:e}),t&&(0,q.jsx)(oa,{children:t})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,q.jsx)(W,{type:`button`,emphasis:`outline`,"data-test":`confirm-cancel`,disabled:o,onClick:l,children:r}),(0,q.jsxs)(W,{type:`button`,emphasis:a,variant:i,"data-test":`confirm-accept`,disabled:o||s,onClick:c,children:[o&&(0,q.jsx)(la,{}),n]})]})]})})}async function da(e,t){try{let n=await e(),r=await n.json().catch(()=>({}));return t(v(r.effects)),n.ok}catch(e){return h(e),!1}}function fa({className:e,...t}){return(0,q.jsx)(`div`,{"aria-hidden":`true`,className:L(`animate-pulse rounded-lt-sm bg-lt-muted`,e),"data-slot":`skeleton`,...t})}var pa=(0,G.createContext)({});function ma({nodes:e,children:t}){return(0,q.jsx)(pa.Provider,{value:e,children:t})}function ha(e){let t=(0,G.useContext)(pa),n=mt(e).name??``,r=dt(),i=n&&r?r.errorKey(n):n;return i&&t[i]||n&&t[n]||e}var ga=typeof window>`u`?G.useEffect:G.useLayoutEffect;function _a(e,t,n,r){return Gt(e,{method:`POST`,ref:t,signal:r,body:JSON.stringify(n),throwOnError:!1}).then(e=>e.ok?e.json():null)}function va(e){return e.templates}function ya(e,t){let n=va(e);return n?n.find(e=>e.type===t.type)?.schema??[]:e.schema??[]}function ba(e,t){return e.startsWith(`@`)?e.slice(1):t===null?e:Se(t,e)}function xa(e,t,n,r=0,i={}){let a=mt(e);if(!a.editablePrefill||!a.name)return null;let o=fe(i);return{path:t===null?a.name:Se(t,a.name),overrideKey:n===null?a.name:Ee(n,o,r,a.name),resetOn:(a.prefillResetOn??[]).map(e=>ba(e,t)),refreshOn:(a.prefillRefreshOn??[]).map(e=>ba(e,t))}}function Sa(e,t){let n=[],r=(e,i=null,a=null,o=null,s=0,c={})=>{for(let l of e??[]){if(we.has(l.type)){let e=mt(l).name;if(e){let n=Se(i,e),o=Se(a,e),s=pe(t,n);(Array.isArray(s)?s:[]).forEach((e,t)=>{r(ya(l,e),Se(n,t),Se(o,fe(e)??t),o,t,e)})}continue}let e=xa(l,i,o,s,c);e&&n.push(e),r(l.schema,i,a,o,s,c)}};return r(e),n}function Ca(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(pe(e.values,a),pe(t.values,n))})}).map(e=>e.overrideKey)}function wa(e,t){return e.filter(e=>{let n=pe(t,e.path);return n!=null&&n!==``}).map(e=>e.overrideKey)}function Ta(e,t){let n=new Set(t.map(e=>e.overrideKey));return new Set([...e].filter(e=>n.has(e)))}function Ea(e,t,n){let r=Ie(),i=Te(),[a,o]=(0,G.useState)({}),s=(0,G.useMemo)(()=>Sa(n,r),[n,r]),c=(0,G.useRef)(new Set),l=(0,G.useRef)(new Set),u=(0,G.useRef)(r),d=(0,G.useRef)(s),f=(0,G.useRef)(s);f.current=s,ga(()=>{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 wa(t,r))c.current.add(e);for(let e of t)l.current.add(e.overrideKey)},[s,r]);let p=(0,G.useCallback)(e=>{c.current.add(e)},[]),m=(0,G.useMemo)(()=>{let e=new Set,t=!1;return le(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,G.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=>pe(r,e)));return(0,G.useEffect)(()=>{if(h.length===0&&!m.any)return;let n=u.current;u.current=r;for(let e of Ca({targets:d.current,values:n},{targets:f.current,values:r}))c.current.delete(e);d.current=f.current,c.current=Ta(c.current,f.current);let a=new AbortController,s=window.setTimeout(()=>{_a(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 Da(e){let t={labels:{},values:{}};return le(e,e=>{e.name&&(e.label&&(t.labels[e.name]=e.label),e.value!==void 0&&(t.values[e.name]=e.value))}),t}function Oa(e,t){return e===t||e.startsWith(`${t}.`)}function ka(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=Array.isArray(r)?r[0]:r;return t}function Aa(e,t){let n=(0,G.useRef)(e);n.current=e;let r=(0,G.useRef)(null),i=(0,G.useCallback)(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);return(0,G.useEffect)(()=>i,[i]),(0,G.useMemo)(()=>{let e=(...e)=>{i(),r.current=setTimeout(()=>{r.current=null,n.current(...e)},t)};return e.cancel=i,e},[i,t])}function ja(e,t,n){let[r,i]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!n){i(null);return}let r=new AbortController;return Gt(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 Ma(){return(0,q.jsxs)(`div`,{className:`space-y-4`,"data-lattice-action-form-loading":!0,children:[(0,q.jsx)(fa,{className:`h-4 w-24`}),(0,q.jsx)(fa,{className:`h-10 w-full`}),(0,q.jsx)(fa,{className:`h-10 w-full`})]})}function Na({cancelLabel:e,componentRef:t,endpoint:n,extraData:r,fieldLabels:i,formNode:a,method:o,onClose:s,onSuccess:c,precognitive:l,submitLabel:u}){let d=Ie(),f=(0,G.useRef)(d);f.current=d;let p=(0,G.useRef)(r);p.current=r;let{nodes:m,markUserEdit:g}=Ea(n,t,a.schema),_=b(),[y,x]=(0,G.useState)({}),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(!1),E=(0,G.useCallback)(e=>Gt(n,{body:JSON.stringify({...f.current,...p.current}),method:o,ref:t,headers:e,throwOnError:!1}),[t,n,o]),D=(0,G.useCallback)(e=>{x(t=>t[e]===void 0?t:{...t,[e]:void 0})},[]),O=Aa(e=>{E({Precognition:`true`,"Precognition-Validate-Only":e}).then(async t=>{if(t.status===422){let e=await t.json();x(t=>({...t,...ka(e.errors)}));return}D(e)}).catch(()=>{})},250),k=(0,G.useCallback)(e=>{l&&O(e)},[l,O]),A=(0,G.useCallback)(()=>{},[]),j=(0,G.useCallback)((e,t)=>{T(!0),E({Precognition:`true`,"Precognition-Validate-Only":e.join(`,`)}).then(async n=>{if(n.status===422){let e=await n.json();x(t=>({...t,...ka(e.errors)})),t?.onValidationError?.();return}if(!n.ok){t?.onValidationError?.();return}let r=e.filter(e=>!e.includes(`*`));x(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!r.some(t=>Oa(e,t))))),t?.onSuccess?.()}).catch(()=>t?.onValidationError?.()).finally(()=>T(!1))},[E]),M=(0,G.useCallback)(()=>{C(!0),E().then(async e=>{let t=await e.json().catch(()=>({}));if(_(v(t.effects)),e.status===422&&t.errors){x(ka(t.errors));return}e.ok&&c(t)}).catch(e=>h(e)).finally(()=>C(!1))},[_,c,E]),N=(0,G.useMemo)(()=>({action:n,clearErrors:D,componentRef:t,errors:y,fieldLabels:i,precognitive:l,processing:S,touch:A,validate:k,validateFields:j,validating:w}),[D,t,n,y,i,l,S,A,k,j,w]);return(0,q.jsx)(me,{value:N,children:(0,q.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,q.jsx)(Oe,{value:{markUserEdit:g},children:(0,q.jsx)(ma,{nodes:m,children:(0,q.jsx)(J,{nodes:a.schema??[]})})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,q.jsx)(W,{"data-test":`action-form-cancel`,disabled:S,onClick:s,type:`button`,emphasis:`ghost`,children:e}),a.props?.submitButton!==!1&&(0,q.jsxs)(W,{"data-test":`action-form-submit`,disabled:S,type:`submit`,children:[S&&(0,q.jsx)(la,{}),u]})]})]})})}function Pa({formNode:e,...t}){let n=!!e.props?.precognitive,{labels:r,values:i}=(0,G.useMemo)(()=>{let{labels:t,values:n}=Da(e.schema);return{labels:t,values:{...n,...e.props?.state}}},[e]);return(0,q.jsx)(ut,{initial:i,children:(0,q.jsx)(Na,{fieldLabels:r,formNode:e,precognitive:n,...t})})}function Fa({description:e,formNode:t,onClose:n,placement:r,title:i,width:a,...o}){let{t:s}=E(`lattice`);return(0,q.jsx)(ra,{open:!0,onOpenChange:e=>{e||n()},children:(0,q.jsxs)(sa,{...e?{}:{"aria-describedby":void 0},placement:r,width:a,children:[(0,q.jsx)(ca,{closeLabel:s(`common.close`,`Close`),description:e,title:i}),(0,q.jsx)(`div`,{className:`mt-6`,children:t?(0,q.jsx)(Pa,{formNode:t,onClose:n,...o}):(0,q.jsx)(Ma,{})})]})})}function Ia(e){return e.props.label??w(`lattice`,`common.action.run`,`Run action`)}function La(e){let t=e.props.endpoint??``,n=e.props.ref??``,r=e.props.method??`post`,i=Ia(e),{variant:a,emphasis:o}=e.props,s=e.props.confirmation,c=e.props.form,l=e.props.lazyForm===!0,u=!!c||l,[d,f]=(0,G.useState)(!1),p=b(),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),y=ja(t,n,_&&l),x=l?y:c,S=async()=>{if(!t)return;if(r===`get`){m.visit(t,{headers:Pt(n)}),g(!1);return}f(!0);let e=await da(()=>Gt(t,{method:r,ref:n,throwOnError:!1}),p);f(!1),e&&g(!1)},C=()=>{if(u){v(!0);return}if(s){g(!0);return}S()},T=s?.title??i,E=s?.confirmLabel??i,D=s?.cancelLabel??w(`lattice`,`common.cancel`,`Cancel`);return{processing:d,requestSubmit:C,overlays:(0,q.jsxs)(q.Fragment,{children:[h&&s&&(0,q.jsx)(ua,{title:T,description:s.description??void 0,confirmLabel:E,cancelLabel:D,confirmVariant:a,confirmEmphasis:o,processing:d,confirmDisabled:!t,onConfirm:()=>void S(),onCancel:()=>g(!1)}),_&&u&&(0,q.jsx)(Fa,{cancelLabel:D,componentRef:n,description:s?.description??void 0,endpoint:t,formNode:x,method:r,onClose:()=>v(!1),onSuccess:()=>{v(!1)},placement:e.props.modalSide??`center`,submitLabel:E,title:T,width:e.props.modalWidth??void 0})]})}}function Ra({action:e,children:t}){let{processing:n,requestSubmit:r,overlays:i}=La(e);return(0,q.jsxs)(q.Fragment,{children:[t({onClick:r,processing:n}),i]})}function za({children:e}){return(0,q.jsx)(re,{render:e=>(0,q.jsx)(Ra,{action:e.action,children:e.children}),children:e})}function Ba(){let e=b();(0,G.useEffect)(()=>m.on(`flash`,t=>{let n=v(t.detail?.flash?.latticeEffects);n.length>0&&e(n)}),[e])}function Va({onAppearanceChange:e}){return Cn(a.appearanceChange,t=>{let n=t.detail?.value;un(n)&&e?.(n)},{enabled:!!e}),null}var Ha={href:``};function Ua({children:e,registry:t,sprite:n=Ha,toaster:r=!0}){return Ba(),(0,q.jsx)(f.Provider,{value:t,children:(0,q.jsx)(za,{children:(0,q.jsxs)(ie,{sprite:n,children:[e,(0,q.jsx)(Va,{onAppearanceChange:vn}),r?(0,q.jsx)(Zr,{}):null]})})})}var Wa=bn({components:{action:K(({node:e})=>{let t=e.props.endpoint??``,n=e.props.icon,r=Ia(e),i=Ye(),{variant:a,emphasis:o}=e.props,{processing:s,requestSubmit:c,overlays:l}=La(e),u=e.key??P(`action`,e.id);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(W,{className:i?et: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,q.jsx)(la,{className:i?`size-lt-icon-sm`:void 0}):n&&(0,q.jsx)(I,{className:i?`size-lt-icon-sm`:`size-lt-icon-md`,icon:n}),r]}),l]})}),"action.group":K(({children:e,node:t})=>{let{t:n}=E(`lattice`),r=t.props.label??n(`common.action-group.label`,`Actions`),i=t.props.orientation;return i?(0,q.jsx)(`div`,{"aria-label":r,className:L(`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,q.jsx)(`div`,{className:`inline-flex`,"data-lattice-component":t.id,children:(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":r,className:`size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg`,"data-test":F(t),size:`icon`,type:`button`,emphasis:`ghost`,children:(0,q.jsx)(B,{name:`more-horizontal`,"aria-hidden":`true`,className:`size-lt-icon-md`})})}),(0,q.jsx)(qe,{align:`end`,"aria-label":r,className:`min-w-44 gap-0.5 p-1.5`,sideOffset:8,children:(0,q.jsx)(Be,{children:e})})]})})})},name:`lattice/action`});function Ga(e){try{return JSON.parse(e)}catch{return null}}function Ka(e){return async function*(t){let n=await e(t);if(!n.ok||!n.body)throw Error(`Chat stream failed (${n.status})`);yield*Ya(n.body)}}var qa=Ka(({url:e,body:t,signal:n})=>Gt(e,{method:`POST`,signal:n,headers:{Accept:`application/x-ndjson`},body:JSON.stringify(t),throwOnError:!1}));function Ja(e){return Ka(({url:t,body:n,signal:r})=>Qt(t,{remote:e,method:`POST`,signal:r,headers:{Accept:`application/x-ndjson`,"Content-Type":`application/json`},body:JSON.stringify(n),throwOnError:!1}))}async function*Ya(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=Ga(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=Ga(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var Xa=0;function Za(){return Xa+=1,`chat-${Xa}`}function Qa(e){return e instanceof DOMException&&e.name===`AbortError`}function $a(e){return e instanceof Error?e.message:String(e)}function eo(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function to(e,t){if(!eo(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 no({endpoint:e,transport:t=qa,initialMessages:n=[],generateId:r=Za}){let[i,a]=(0,G.useState)(n),[o,s]=(0,G.useState)(`idle`),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)(i);f.current=i;let p=(0,G.useCallback)(e=>{f.current=e,a(e)},[]),m=(0,G.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(to(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(Qa(e)){s(`idle`);return}l($a(e)),s(`error`)}},[p,e,r,t]),h=(0,G.useCallback)(e=>{let t=e.trim();t!==``&&(d.current=t,m(f.current,t))},[m]),g=(0,G.useCallback)(()=>{u.current?.abort(),s(`idle`)},[]),_=(0,G.useCallback)(()=>{let e=d.current;if(e===null)return;let t=f.current,n=eo(t)?t.slice(0,-2):t;m(n,e)},[m]);return(0,G.useEffect)(()=>()=>{u.current?.abort()},[]),{messages:i,status:o,error:c,sendMessage:h,setMessages:p,stop:g,regenerate:_}}function ro({message:e}){let t=e.role===`user`;return(0,q.jsx)(`div`,{className:L(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":M(`chat-message-${e.role}`),children:(0,q.jsx)(`div`,{className:L(`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,q.jsx)(Y,{node:e},e.key??t))})})}function io({messages:e}){let t=(0,G.useRef)(null),n=e.at(-1),r=n?.parts.at(-1)===void 0?0:JSON.stringify(n.parts.at(-1)).length;return(0,G.useEffect)(()=>{t.current&&typeof t.current.scrollIntoView==`function`&&t.current.scrollIntoView({behavior:`smooth`})},[e.length,r]),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 overflow-y-auto p-3`,"data-test":M(`chat-messages`),children:[e.map(e=>(0,q.jsx)(ro,{message:e},e.id)),(0,q.jsx)(`div`,{ref:t})]})}function ao({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=E(`lattice`),[i,a]=(0,G.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,q.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-lt-border p-3`,children:[(0,q.jsx)(`textarea`,{"aria-label":r(`common.chat.input-label`,`Message input`),className:L(`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-test":M(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,q.jsx)(W,{"data-test":M(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var oo=bn({name:`lattice/chat`,components:{"chat.box":K(({node:e})=>{let t=e.props,{t:n}=E(`lattice`),r=(0,G.useMemo)(()=>t.remote?Ja(t.remote):qa,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=no({endpoint:t.streamEndpoint??``,transport:r}),l=(0,G.useRef)(!1),u=(0,G.useCallback)(async()=>{if(l.current||!t.historyEndpoint)return;if(l.current=!0,t.remote){let e=await $t(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await Gt(t.historyEndpoint,{throwOnError:!1});if(!e.ok)return;let n=await e.json();c(n.messages)},[t.historyEndpoint,t.remote,c]);(0,G.useEffect)(()=>{u().catch(()=>{})},[u]);let d=a===`submitted`||a===`streaming`||!t.streamEndpoint;return(0,q.jsxs)(`div`,{className:L(`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":M(`chat-box`),children:[(0,q.jsx)(`div`,{className:`flex items-center border-b border-lt-border px-3 py-2`,children:(0,q.jsx)(`span`,{className:`text-sm font-medium text-lt-fg`,children:t.title??n(`common.chat.title`,`Chat`)})}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,q.jsx)(io,{messages:i})}),o?(0,q.jsx)(`div`,{className:`border-t border-lt-danger/40 px-3 py-2 text-xs text-lt-danger`,children:o}):null,(0,q.jsx)(ao,{disabled:d,onSubmit:s,placeholder:t.placeholder??void 0})]})}),"chat.part.text":K(({node:e})=>(0,q.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.props.text})),"chat.part.tool-call":K(({node:e})=>(0,q.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":M(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}}),so={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 co(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function lo(){return(0,q.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,q.jsx)(`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`7`,r:`4`})]})}var uo=({node:e})=>{let{src:t,name:n,size:r}=e.props,i=n??void 0;return(0,q.jsx)(`span`,{"data-slot":`avatar`,role:t?void 0:`img`,"aria-label":t?void 0:i,className:L(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,so[r]),children:t?(0,q.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?co(n):(0,q.jsx)(lo,{})})};function fo({color:e,className:t,style:n,...r}){let i=Et(Dt(e??void 0)??Ct(`gray`));return(0,q.jsx)(`span`,{"data-slot":`badge`,className:L(`lt-badge`,i.className,t),style:{...i.style,...n},...r})}var po=({node:e})=>(0,q.jsx)(fo,{color:e.props.color,children:e.props.label});function mo({className:e,...t}){return(0,q.jsx)(`article`,{"data-slot":`card`,className:L(`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 ho({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-header`,className:L(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function go({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-title`,className:L(`font-semibold leading-none`,e),...t})}function _o({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-description`,className:L(`text-sm text-lt-muted-fg`,e),...t})}function vo({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-content`,className:L(`px-lt-gutter`,e),...t})}var yo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props;return(0,q.jsxs)(mo,{"data-lattice-component":F(t),children:[(n||r)&&(0,q.jsxs)(ho,{children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(go,{children:n}),(0,q.jsx)(it,{content:i})]}),r&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(_o,{children:r}),!n&&(0,q.jsx)(it,{content:i})]})]}),e&&(0,q.jsx)(vo,{className:`flex flex-col gap-6`,children:e})]})},bo=(0,G.lazy)(()=>rn(()=>import(`./chunks/chart-view-CR1X2aGE.js`),__vite__mapDeps([9,1,4,2,10,6,11,12,13]),import.meta.url)),xo=({children:e,node:t})=>(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(bo,{node:t,children:e})}),So=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=Tn(t.props.trigger),i=F(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=hi(a,t.props.collapsed===!1,n);return(0,q.jsxs)(`div`,{"data-slot":`collapsible`,"data-lattice-component":i,children:[(0,q.jsxs)(`div`,{"aria-controls":o,"aria-expanded":s,"data-test":P(`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,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,q.jsx)(J,{nodes:r}),t.props.tooltip&&(0,q.jsx)(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,q.jsx)(it,{content:t.props.tooltip})})]}),(0,q.jsx)(B,{name:`chevron-down`,className:L(`size-lt-icon-md shrink-0 text-lt-muted-fg transition-transform`,!s&&`-rotate-90`)})]}),s&&e&&(0,q.jsx)(`div`,{id:o,className:`flex flex-col gap-4 pt-2`,children:e})]})};function Co(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 wo=({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,G.useState)(!1);if(a.length===0)return(0,q.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":F(t),role:n?`group`:void 0,style:Co(i,r),children:e});let c=i===`bottom-start`||i===`bottom-end`,l=i===`top-start`||i===`bottom-start`;return(0,q.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)]`,"data-lattice-component":F(t),role:n?`group`:void 0,style:Co(i,r),children:(0,q.jsxs)(`div`,{className:L(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,q.jsx)(`button`,{"aria-expanded":o,className:L(`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,q.jsx)(Y,{node:e},e.key??`${e.type}-${t}`))}),(0,q.jsx)(`div`,{className:o?`block`:`hidden`,children:e})]})})},To={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},Eo=({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,i=To[e.props.size],[o,s]=(0,G.useState)(()=>e.schema??[]),[c,l]=(0,G.useState)(!n),[u,d]=(0,G.useState)(n&&t!==``),f=(0,G.useCallback)(async()=>{if(t){d(!0);try{let e=await Kt(t,{ref:r});s(Tn(e.schema)),l(!0)}finally{d(!1)}}},[t,r]);return(0,G.useEffect)(()=>{!n||c||f()},[c,n,f]),(0,G.useEffect)(()=>{function t(t){t.detail?.component===e.id&&f()}return window.addEventListener(a.reloadComponent,t),()=>window.removeEventListener(a.reloadComponent,t)},[f,e.id]),(0,G.useEffect)(()=>{function e(){c&&f()}return window.addEventListener(a.localeChange,e),()=>window.removeEventListener(a.localeChange,e)},[c,f]),(0,q.jsx)(`div`,{"data-lattice-fragment":e.id,style:u&&o.length===0?{minHeight:i}:void 0,children:u&&o.length===0?(0,q.jsx)(fa,{className:`w-full`,style:{height:i}}):(0,q.jsx)(J,{nodes:o})})};function Do(e,t,n){let r=Object.entries(e??{});if(r.length!==0)return Object.fromEntries(r.map(([e,r])=>[`${t}-${e}`,n(r)]))}var Oo=e=>typeof e==`number`?`repeat(${e}, minmax(0, 1fr))`:e,ko=e=>e===`full`?`1 / -1`:`span ${e} / span ${e}`,Ao=({node:e})=>(0,q.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":F(e),className:`lt-grid grid gap-x-4 gap-y-6`,style:Do(e.props.columns,`--lt-grid-cols`,Oo),children:(e.schema??[]).map((e,t)=>(0,q.jsx)(`div`,{"data-slot":`grid-item`,style:Do(e.props?.columnSpan,`--lt-col-span`,ko),children:(0,q.jsx)(Y,{node:e})},En(e,t)))});async function jo(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function Mo({value:e,label:t,testId:n,className:r}){let{t:i}=E(`lattice`),[a,o]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1500);return()=>window.clearTimeout(e)},[a]);function s(){jo(e),o(!0)}let c=a?i(`common.copied-value`,`Copied {{label}}`,{label:t}):i(`common.copy-value`,`Copy {{label}}`,{label:t});return(0,q.jsxs)(`button`,{type:`button`,"data-test":n,className:L(`inline-flex items-center gap-1 rounded-lt-sm border border-lt-border px-2 py-1 text-xs`,r),"aria-label":c,onClick:s,children:[(0,q.jsx)(B,{name:a?`check`:`copy`,className:`size-lt-icon-xs`}),a?i(`common.copied`,`Copied`):i(`common.copy`,`Copy`)]})}function No({value:e,label:t,testId:n,children:r}){return(0,q.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[r??e,(0,q.jsx)(Mo,{value:e,label:t,testId:n})]})}var Po=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=L(`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,q.jsxs)(q.Fragment,{children:[t,(0,q.jsx)(it,{content:n})]}),o;switch(r){case 1:o=(0,q.jsx)(`h1`,{className:i,children:a});break;case 2:o=(0,q.jsx)(`h2`,{className:i,children:a});break;case 3:o=(0,q.jsx)(`h3`,{className:i,children:a});break;case 4:o=(0,q.jsx)(`h4`,{className:i,children:a});break;case 5:o=(0,q.jsx)(`h5`,{className:i,children:a});break;default:o=(0,q.jsx)(`h6`,{className:i,children:a})}return e.props.copyable?(0,q.jsx)(No,{value:t,label:t,children:o}):o},Fo={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`},Io=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,q.jsx)(I,{icon:t,className:L(Fo[n],i)}),o=Dt(r);return o?(0,q.jsx)(`span`,{className:`contents`,style:{color:wt(o)},children:a}):a};function Lo({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=E(`lattice`),[c,l]=(0,G.useState)(!1),u=(0,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"data-test":o,className:`cursor-zoom-in`,"aria-label":d,onClick:()=>l(!0),children:u}),(0,q.jsx)(ra,{open:c,onOpenChange:l,children:(0,q.jsxs)(sa,{"aria-describedby":void 0,className:`max-h-[90vh] w-auto max-w-[90vw] border-none bg-transparent p-0 shadow-none`,children:[(0,q.jsx)(aa,{className:`sr-only`,children:t||d}),(0,q.jsx)(`img`,{alt:t,src:e,"data-slot":`image-lightbox`,className:`max-h-[90vh] max-w-[90vw] rounded-lt object-contain`}),(0,q.jsx)(ia,{asChild:!0,children:(0,q.jsx)(W,{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 Ro=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,q.jsx)(Lo,{alt:n??``,className:L(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:F(e),width:r??void 0})};function zo(e,t){let n=e.detail?.modal;return n==null||n===t}var Bo=({children:e,node:t})=>{let{t:n}=E(`lattice`),r=t.props.title??n(`common.dialog`,`Dialog`),i=t.props.description,o=t.props.closeLabel,[s,c]=(0,G.useState)(t.props.open===!0),l=(0,G.useRef)(null),u=(0,G.useRef)(s);return(0,G.useEffect)(()=>{t.props.open===!0&&c(!0)},[t.props.open]),(0,G.useEffect)(()=>{function e(e){t.id&&zo(e,t.id)&&(l.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(!0))}function n(e){(!t.id||zo(e,t.id))&&c(!1)}return window.addEventListener(a.openModal,e),window.addEventListener(a.closeModal,n),()=>{window.removeEventListener(a.openModal,e),window.removeEventListener(a.closeModal,n)}},[t.id]),(0,G.useEffect)(()=>{if(u.current&&!s){let e=l.current;e&&requestAnimationFrame(()=>e.focus())}u.current=s},[s]),(0,q.jsx)(ra,{open:s,onOpenChange:c,children:(0,q.jsxs)(sa,{...i?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,children:[(0,q.jsx)(ca,{closeLabel:o,description:i,title:r}),(0,q.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},Vo={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`},Ho={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},Uo={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`},Wo=({node:e})=>{let{value:t,max:r,shape:i,showValue:a,color:o,size:s}=e.props,{locale:c}=n(),l=wt(Dt(o)??Ct(`primary`)),u=r>0?Math.min(Math.max(t,0),r):0,d=r>0?u/r:0,f=new Intl.NumberFormat(c,{maximumFractionDigits:0,style:`percent`}).format(d),p={"aria-valuemax":r,"aria-valuemin":0,"aria-valuenow":u,"aria-valuetext":f,role:`progressbar`};if(i===`circle`){let e=Ho[s],t=Math.max(3,e/10),n=(e-t)/2,r=2*Math.PI*n;return(0,q.jsxs)(`div`,{...p,className:`relative inline-flex`,"data-lattice-progress":`circle`,children:[(0,q.jsxs)(`svg`,{className:`-rotate-90`,height:e,width:e,children:[(0,q.jsx)(`circle`,{className:`text-lt-muted`,cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeWidth:t}),(0,q.jsx)(`circle`,{cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeDasharray:r,strokeDashoffset:r*(1-d),strokeLinecap:`round`,strokeWidth:t,style:{color:l}})]}),a&&(0,q.jsx)(`span`,{className:L(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,Uo[s]),children:f})]})}return(0,q.jsxs)(`div`,{className:`flex w-full items-center gap-2`,"data-lattice-progress":`bar`,children:[(0,q.jsx)(`div`,{...p,className:L(`w-full overflow-hidden rounded-full bg-lt-muted`,Vo[s]),children:(0,q.jsx)(`div`,{className:`h-full rounded-full`,style:{background:l,width:`${d*100}%`}})}),a&&(0,q.jsx)(`span`,{className:`shrink-0 text-lt-muted-fg text-sm tabular-nums`,children:f})]})},Go=({node:e})=>(0,q.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),Ko=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=Tn(t.props.headerActions),c=F(t),[l,u]=hi(`lattice:section:${c??`default`}`,t.props.collapsed===!0,a&&o),d=a&&l,f=!!(n||r||s.length>0||a);return(0,q.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,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-lt-gutter`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[a&&(0,q.jsx)(`button`,{"aria-expanded":!d,"aria-label":d?`Expand section`:`Collapse section`,"data-test":P(`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,q.jsx)(B,{name:`chevron-down`,className:L(`size-lt-icon-md transition-transform`,d&&`-rotate-90`)})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(`div`,{className:`font-semibold leading-none`,children:n}),(0,q.jsx)(it,{content:i})]}),r&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(`div`,{className:`text-sm text-lt-muted-fg`,children:r}),!n&&(0,q.jsx)(it,{content:i})]})]})]}),s.length>0&&(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,q.jsx)(J,{nodes:s})})]}),!d&&e&&(0,q.jsx)(`div`,{className:`flex flex-col gap-6 px-lt-gutter`,children:e})]})};function qo(e){return L(`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 Jo({ariaLabel:e,autoFocus:t=!1,disabled:n=!1,name:r,onSelect:i,options:a,tabIndex:o,value:s}){let c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!t)return;let e=c.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,q.jsx)(`div`,{"aria-label":e,className:`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,ref:c,role:`radiogroup`,children:a.map(e=>{let t=s===e.value;return(0,q.jsx)(`button`,{"aria-checked":t,"data-test":`${r}-${e.value}`,className:L(qo(t),n&&`cursor-not-allowed opacity-60`),disabled:n,onClick:()=>i(e.value),role:`radio`,tabIndex:o,type:`button`,children:e.label},e.value)})})}var Yo=({node:e})=>{let{options:t,name:n,emits:r}=e.props,[i,a]=(0,G.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,q.jsx)(Jo,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},Xo=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:L(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},Zo={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},Qo={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},$o={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},es={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`},ts={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},ns={full:`h-full`,screen:`min-h-screen`},rs={end:`ml-auto`,start:`mr-auto`},is=({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,q.jsx)(`div`,{"data-slot":`stack`,"data-lattice-component":F(t),className:L(l?L(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?Qo[n]??Qo.stretch:Zo[n]??Zo.stretch,$o[i]??$o.md,es[a]??es.full,o?ts[o]:null,s?ns[s]:null,c?rs[c]:null),children:e})},as=(0,G.createContext)(null);function os(){return(0,G.useContext)(as)||{activeValue:``,setActiveValue:()=>{}}}function ss(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 cs(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 ls(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 us(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 ds=({children:e,node:t})=>{let{t:n}=E(`lattice`),r=(0,G.useMemo)(()=>ss(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`,u=t.props.activeValue,d=t.props.defaultValue??i,f=(0,G.useRef)(null),[p,h]=(0,G.useState)(()=>u||(cs(a,r)??d)||i),g=(0,G.useCallback)(e=>{if(e.confirm?.required){m.visit(us(a,e.value),{preserveScroll:!0});return}h(e.value),ls(a,e.value)},[a]),_=(0,G.useCallback)(e=>{let t=r.find(t=>t.value===e);t&&g(t)},[g,r]),v=(0,G.useMemo)(()=>({activeValue:p,setActiveValue:_}),[p,_]);function y(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(f.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,q.jsx)(as.Provider,{value:v,children:(0,q.jsxs)(`div`,{className:L(`gap-6`,s?L(`flex`,c===`end`&&`flex-row-reverse`):`grid`),"data-lattice-tabs":t.key??t.id,children:[(0,q.jsx)(`div`,{"aria-label":n(`common.tabs`,`Tabs`),"aria-orientation":o,className:L(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&L(`inline-flex w-fit max-w-full overflow-x-auto`,{"justify-self-center":c===`center`,"justify-self-end":c===`end`})),ref:f,role:`tablist`,children:r.map(e=>{let t=p===e.value;return(0,q.jsx)(`button`,{"aria-controls":`${e.value}-panel`,"aria-selected":t,"data-test":`tab-${e.value}`,className:L(qo(t),s&&`text-left`,l&&`flex-1`),id:`${e.value}-tab`,onClick:()=>g(e),onKeyDown:y,role:`tab`,tabIndex:t?0:-1,type:`button`,children:e.label},e.value)})}),(0,q.jsx)(`div`,{className:L(`min-w-0`,s&&`flex-1`),children:e})]})})},fs=({children:e,node:t})=>{let{activeValue:n}=os(),r=t.props.value,i=n===r,[a,o]=(0,G.useState)(i);return(0,G.useEffect)(()=>{i&&o(!0)},[i]),(0,q.jsx)(`section`,{"aria-labelledby":`${r}-tab`,className:L(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},ps={center:`text-center`,left:`text-left`},ms={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`},hs=bn({components:{avatar:K(uo),badge:K(po),button:K(_t),card:K(yo),chart:K(xo),collapsible:K(So),"floating-panel":K(wo),fragment:K(Eo),grid:K(Ao),heading:K(Po),icon:K(Io),image:K(Ro),link:K(Qe),modal:K(Bo),progress:K(Wo),"raw-block":K(Go),section:K(Ko),"segmented-control":K(Yo),separator:K(Xo),stack:K(is),tab:K(fs),tabs:K(ds),text:K(({node:e})=>{let t=e.props.align??`left`,n=wt(Dt(e.props.color)??Ct(`muted`)),r=(0,q.jsx)(`p`,{className:L(`m-0`,`max-w-2xl`,ps[t]??ps.left,ms[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,q.jsx)(No,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:K(({node:e})=>{let t=e.props.content,n=Tn(e.props.trigger);return t?n.length===0?(0,q.jsx)(it,{content:t}):(0,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{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,q.jsx)(J,{nodes:n})}),(0,q.jsx)(V,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},name:`lattice/ui`});function gs({addLabel:e,options:t,onSelect:n}){return(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{asChild:!0,children:(0,q.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,q.jsx)(B,{name:`plus`}),e]})}),(0,q.jsx)(qe,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,q.jsx)(ct,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var _s={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function vs(e,t){return(e??ys(t.removable)).map(e=>bs(e,t)).filter(e=>e!==null)}function ys(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function bs(e,t){if(e.type===`duplicate`){let n=_s.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=_s.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 xs(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 Ss({actions:e}){let{t}=E(`lattice`);if(e.length===0)return null;if(e.length===1){let t=e[0];return(0,q.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-test":`row-action-${t.key}`,className:xs(t.danger),onClick:t.onClick,children:(0,q.jsx)(B,{name:t.icon})})}return(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{asChild:!0,children:(0,q.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,q.jsx)(B,{name:`more-horizontal`})})}),(0,q.jsx)(qe,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,q.jsx)(ct,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function Cs({path:e,rows:t,rowKey:n}){return(0,q.jsx)(q.Fragment,{children:t.map((t,r)=>(0,q.jsx)(`input`,{type:`hidden`,name:ve(Se(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function ws({label:e,testId:t,onClick:n,children:r}){return(0,q.jsx)(`button`,{type:`button`,"aria-label":e,"data-test":t,className:`text-lt-muted-fg hover:text-lt-fg`,onClick:n,children:r})}var Ts=(0,G.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}=E(`lattice`);return(0,q.jsxs)(`div`,{"data-test":`repeater-${e}-row-${t}`,className:`rounded-lt border border-lt-border bg-lt-surface p-4`,children:[(0,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-lt-muted-fg`,children:i}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[a&&!o&&(0,q.jsx)(ws,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,q.jsx)(B,{name:`arrow-up`})}),a&&!s&&(0,q.jsx)(ws,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,q.jsx)(B,{name:`arrow-down`})}),(0,q.jsx)(Ss,{actions:vs(l,{index:t,removable:c,onRemove:d,onDuplicate:p,t:m})})]})]}),(0,q.jsx)(ue,{base:e,index:t,row:n,onChange:(e,n)=>u(t,e,n),children:(0,q.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,q.jsx)(Y,{node:e},En(e,t)))})})]})}),Es={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}},Ds=1024;function Os(e){return Es[e].track}function ks(e){return Es[e.width].minPx}function As(e){return Es[e.width].defaultPx}function js({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?Os(e.width):`${Math.min(Ds,Math.max(ks(e),t))}px`}),...n].join(` `)}var Ms=[];function Ns({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=Ms,showIndicator:i=!1,storageKey:a,trailingTracks:o=Ms}){let s=(0,G.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=mi(a??``,{},{enabled:!!a,parse:e=>Fs(e,t),serialize:e=>Is(e,s)}),u=(0,G.useRef)(c),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useCallback)(e=>js({columns:t,leadingTracks:r,trailingTracks:o,overrides:n?e:{}}),[t,n,r,o]),m=(0,G.useMemo)(()=>p(c),[c,p]),h=(0,G.useCallback)(e=>{let t=f.current;t&&(t.style.gridTemplateColumns=e,t.style.setProperty(`--lattice-table-columns`,e))},[]),g=(0,G.useCallback)(e=>{u.current=e,l(e),h(p(e))},[h,l,p]),_=(0,G.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??1024,Math.max(ks(t),n))}),[]),v=(0,G.useCallback)((e,t,n)=>{g(_(u.current,e,t,n))},[g,_]),y=(0,G.useCallback)(e=>{let t={...u.current};delete t[e.key],g(t)},[g]),b=(0,G.useCallback)(()=>{g({})},[g]),x=n&&Object.values(c).some(e=>typeof e==`number`),S=(0,G.useCallback)(e=>u.current[e.key]??As(e),[]);return{getResizeHandleProps:(0,G.useCallback)(a=>{let s=Ds,c=ks(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>Ps({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 Ps({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return Ds;let s=[...i,...a].reduce((e,t)=>e+Rs(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+ks(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(Ds,Math.max(ks(e),d))}function Fs(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=Ls(n,t);if(Object.keys(r).length===0)throw Error(`stored column widths hold no usable overrides`);return r}function Is(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 Ls(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(Ds,Math.max(ks(r),t)))}return n}function Rs(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])*zs():0}function zs(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}var Bs=`3rem`,Vs=`3rem`,Hs=[Bs],Us=[Vs],Ws=`(min-width: 768px)`;function Gs(){return pi(Ws,!0)}function Ks(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 qs=(0,G.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:_}=E(`lattice`);return(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[l&&!a&&(0,q.jsx)(ws,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,q.jsx)(B,{name:`arrow-up`})}),l&&!o&&(0,q.jsx)(ws,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,q.jsx)(B,{name:`arrow-down`})})]}),(0,q.jsx)(ue,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,q.jsx)(He,{children:i?(0,q.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,q.jsx)(Y,{node:e},En(e,t)))}):r.map((e,t)=>(0,q.jsx)(`div`,{children:(0,q.jsx)(Y,{node:e})},En(e,t)))})}),(0,q.jsx)(`div`,{className:`flex items-center`,children:(0,q.jsx)(Ss,{actions:vs(d,{index:t,removable:u,onRemove:m,onDuplicate:h,t:_})})})]})});function Js({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}=E(`lattice`),m=Gs(),h=(0,G.useMemo)(()=>t.map(e=>({key:e.name,label:e.label,width:e.columnWidth})),[t]),{getResizeHandleProps:g,gridTemplateColumns:_,hasOverrides:v,resizeRootRef:y,resetColumns:b}=Ns({columns:h,enabled:d,columnGapPx:12,leadingTracks:Hs,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Us});return m?(0,q.jsxs)(`div`,{className:`relative`,children:[v&&(0,q.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:b,title:p(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,q.jsx)(B,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`div`,{ref:y,className:`flex min-w-max flex-col gap-2`,style:{"--lattice-table-columns":_},children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-[var(--lattice-table-columns)] items-center gap-x-3`,children:[(0,q.jsx)(`div`,{}),t.map((e,t)=>(0,q.jsxs)(`div`,{className:`relative min-w-0 pr-3 text-xs font-medium text-lt-muted-fg`,children:[e.label,d&&(0,q.jsx)(`div`,{...g(h[t])})]},e.name)),(0,q.jsx)(`div`,{})]}),n.map(d=>(0,q.jsx)(qs,{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,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,q.jsx)(`div`,{ref:e=>u?.(t.key,e),"data-flip-key":t.key,children:(0,q.jsx)(Ts,{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 Ys=180;function Xs(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Zs(e){let t=(0,G.useRef)(new Map),n=(0,G.useRef)(new Map),r=(0,G.useCallback)((e,n)=>{n?t.current.set(e,n):t.current.delete(e)},[]);return ga(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),Xs()||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 ${Ys}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function Qs(e,t){let n=dt(),r=n?n.errorKey(e):e,i=Te(),a=pt(r),o=Array.isArray(a)?a:ye(a,t),s=Ke(o);ga(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,G.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:ye(n,t)))},[i,r,t]);return{path:r,rows:s,onField:(0,G.useCallback)((e,t,n)=>c(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),[c]),onRemove:(0,G.useCallback)(e=>c(t=>Ge(t,e)),[c]),onMove:(0,G.useCallback)((e,t)=>c(n=>ce(n,e,e+t)),[c]),onDuplicate:(0,G.useCallback)(e=>c(t=>xe(t,e)),[c]),append:(0,G.useCallback)(e=>c(t=>[...t,be(e)]),[c])}}var $s=[],ec=({node:e})=>{let t=e.props,n=t.name,r=va(e)??[],{errors:i}=De(),{hidden:a,required:o}=Xe(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=Qs(n,t.defaultItems??0),{t:m}=E(`lattice`),h=Zs(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??$s,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,q.jsx)(Ue,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:s,required:o,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(Cs,{path:s,rows:c,rowKey:de}),(0,q.jsx)(Cs,{path:s,rows:c,rowKey:`type`}),v?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Js,{base:s,columns:Ks(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,q.jsx)(`div`,{ref:e=>h(a,e),"data-flip-key":a,children:i?(0,q.jsx)(Ts,{base:s,index:r,row:e,template:i.schema??$s,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,q.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,q.jsxs)(`span`,{children:[`Unknown block: `,String(e.type)]}),(0,q.jsx)(Ss,{actions:vs(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,q.jsx)(gs,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},tc=Object.defineProperty,nc=(e,t)=>tc(e,`name`,{value:t,configurable:!0}),rc=`Checkbox`,[ic,ac]=lt(rc),[oc,sc]=ic(rc);function cc(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]=se({prop:n,defaultProp:i??!1,onChange:c,caller:rc}),[m,h]=G.useState(null),[g,_]=G.useState(null),v=G.useRef(!1),[y,b]=G.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:!_c(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,q.jsx)(oc,{scope:t,...S,children:gc(d)?d(S):r})}nc(cc,`CheckboxProvider`);var lc=`CheckboxTrigger`,uc=G.forwardRef(nc(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}=sc(lc,e),g=R(i,u),_=G.useRef(c);return G.useEffect(()=>{let e=a?.form;if(e){let t=nc(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,q.jsx)(H.button,{type:`button`,role:`checkbox`,"aria-checked":_c(c)?`mixed`:c,"aria-required":l,"data-state":vc(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:U(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:U(n,e=>{p(),d(e=>_c(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),dc=G.forwardRef(nc(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,q.jsx)(cc,{__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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(uc,{...d,ref:t,__scopeCheckbox:n}),e&&(0,q.jsx)(hc,{__scopeCheckbox:n})]})})},`Checkbox`)),fc=`CheckboxIndicator`,pc=G.forwardRef(nc(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=sc(fc,n);return(0,q.jsx)(ze,{present:r||_c(a.checked)||a.checked===!0,children:(0,q.jsx)(H.span,{"data-state":vc(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),mc=`CheckboxBubbleInput`,hc=G.forwardRef(nc(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}=sc(mc,e),g=R(r,h),_=je(i),v=G.useRef(!1),y=G.useRef(s),b=G.useRef(o);G.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=_c(s),n.call(e,!_c(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=G.useRef(!_c(s)&&s);return(0,q.jsx)(H.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:U(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function gc(e){return typeof e==`function`}nc(gc,`isFunction`);function _c(e){return e===`indeterminate`}nc(_c,`isIndeterminate`);function vc(e){return _c(e)?`indeterminate`:e?`checked`:`unchecked`}nc(vc,`getState`);function yc({className:e,...t}){return(0,q.jsx)(dc,{"data-slot":`checkbox`,className:L(`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,q.jsx)(pc,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,q.jsx)(B,{name:`check`,className:`size-lt-icon-sm`})})})}function bc(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function xc(e,t){let n=dt(),r=pt(e),i=n?n.getValue(e):r,a=Te();(0,G.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var Sc=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=Xe(e),i=e.props.name,a=dt(),{fieldIdPrefix:o}=De(),s=bc(a?a.scopedName(i):i,o),c=pt(i),l=a?a.getValue(i):c,{commit:u}=Ne(),d=nt(e.props.value),f=l===void 0?d:nt(l);return xc(i,d),t?null:(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,q.jsx)(yc,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":M(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,q.jsx)(Pe,{htmlFor:s,children:e.props.label})]}),e.props.helperText&&(0,q.jsx)(`p`,{className:`mt-1 pl-7 text-sm text-lt-muted-fg`,children:e.props.helperText})]})};function Cc(e){let{errors:t,fieldIdPrefix:n}=De(),r=dt(),i=Xe(e),a=mt(e),o=a.name??``,s=pt(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=bc(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=Ne(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:M(o),value:u,error:t[f],commit:g,change:_,blur:v}}var wc=({node:e})=>{let t=ha(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=Cc(e),f=(0,G.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return xc(n,m||void 0),s||f.length===0?null:(0,q.jsxs)(Ue,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,name:r,required:c,children:[(0,q.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,q.jsx)(Jo,{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 Tc(){return(Tc=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 Ec(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 Dc(e){var t=(0,G.useRef)(e),n=(0,G.useRef)(function(e){t.current&&t.current(e)});return t.current=e,n.current}var Oc=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},kc=function(e){return`touches`in e},Ac=function(e){return e&&e.ownerDocument.defaultView||self},jc=function(e,t,n){var r=e.getBoundingClientRect(),i=kc(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:Oc((i.pageX-(r.left+Ac(e).pageXOffset))/r.width),top:Oc((i.pageY-(r.top+Ac(e).pageYOffset))/r.height)}},Mc=function(e){!kc(e)&&e.preventDefault()},Nc=G.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=Ec(e,[`onMove`,`onKey`,`onEnd`]),a=(0,G.useRef)(null),o=Dc(t),s=Dc(n),c=Dc(r),l=(0,G.useRef)(null),u=(0,G.useRef)(!1),d=(0,G.useMemo)(function(){var e=function(e){Mc(e),(kc(e)?e.touches.length>0:e.buttons>0)&&a.current?o(jc(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=Ac(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&&(Mc(t),!function(e,t){return t&&!kc(e)}(t,u.current)&&r)){if(kc(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(jc(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,G.useEffect)(function(){return h},[h]),G.createElement(`div`,Tc({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),Pc=function(e){return e.filter(Boolean).join(` `)},Fc=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=Pc([`react-colorful__pointer`,e.className]);return G.createElement(`div`,{className:a,style:{top:100*i+`%`,left:100*n+`%`}},G.createElement(`div`,{className:`react-colorful__pointer-fill`,style:{backgroundColor:t}}))},$=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 Ic=function(e){return Wc(Lc(e))},Lc=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?$(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?$(parseInt(e.substring(6,8),16)/255,2):1}},Rc=function(e){return Uc(Vc(e))},zc=function(e){var t=e.s,n=e.v,r=e.a,i=(200-t)*n/100;return{h:$(e.h),s:$(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:$(i/2),a:$(r,2)}},Bc=function(e){var t=zc(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Vc=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:$(255*[r,s,o,o,c,r][l]),g:$(255*[c,r,r,s,o,o][l]),b:$(255*[o,o,c,r,r,s][l]),a:$(i,2)}},Hc=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Uc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?Hc($(255*i)):``;return`#`+Hc(t)+Hc(n)+Hc(r)+a},Wc=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:$(60*(s<0?s+6:s)),s:$(a?o/a*100:0),v:$(a/255*100),a:i}},Gc=G.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=Pc([`react-colorful__hue`,e.className]);return G.createElement(`div`,{className:i},G.createElement(Nc,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:Oc(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":$(t),"aria-valuemax":`360`,"aria-valuemin":`0`},G.createElement(Fc,{className:`react-colorful__hue-pointer`,left:t/360,color:Bc({h:t,s:100,v:100,a:1})})))}),Kc=G.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:Bc({h:t.h,s:100,v:100,a:1})};return G.createElement(`div`,{className:`react-colorful__saturation`,style:i},G.createElement(Nc,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:Oc(t.s+100*e.left,0,100),v:Oc(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+$(t.s)+`%, Brightness `+$(t.v)+`%`},G.createElement(Fc,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:Bc(t)})))}),qc=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},Jc=function(e,t){return e.toLowerCase()===t.toLowerCase()||qc(Lc(e),Lc(t))};function Yc(e,t,n,r){var i=Dc(n),a=Dc(r),o=(0,G.useState)(function(){return e.toHsva(t)}),s=o[0],c=o[1],l=(0,G.useRef)({color:t,hsva:s}),u=(0,G.useRef)(!1);return(0,G.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,G.useEffect)(function(){var t;qc(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,G.useCallback)(function(e){c(function(t){return Object.assign({},t,e)})},[]),(0,G.useCallback)(function(){u.current&&(u.current=!1,a(l.current.color))},[a])]}var Xc,Zc=typeof window<`u`?G.useLayoutEffect:G.useEffect,Qc=function(){return Xc||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},$c=new WeakMap,el=function(e){Zc(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(!$c.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=Qc();o&&a.setAttribute(`nonce`,o),$c.set(r,a),i.appendChild(a)}}},[])},tl=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=Ec(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,G.useRef)(null);el(c);var l=Yc(n,i,a,o),u=l[0],d=l[1],f=l[2],p=Pc([`react-colorful`,t]);return G.createElement(`div`,Tc({},s,{ref:c,className:p}),G.createElement(Kc,{hsva:u,onChange:d,onChangeEnd:f}),G.createElement(Gc,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},nl={defaultColor:`000`,toHsva:Ic,fromHsva:function(e){return Rc({h:e.h,s:e.s,v:e.v,a:1})},equal:Jc},rl=function(e){return G.createElement(tl,Tc({},e,{colorModel:nl}))};function il(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 al({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,G.useState)(null),s=il(e)??`#6b7280`;return(0,q.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,q.jsx)(rl,{className:`!w-full`,color:s,onChange:t}),n.length>0&&(0,q.jsx)(`div`,{"aria-label":i,className:`flex flex-wrap gap-1.5`,role:`listbox`,children:n.map(e=>{let n=il(e)??e;return(0,q.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:L(`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,q.jsx)(ht,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=il(n);o(n),r!==null&&t(r)},value:a??s})]})}function ol({node:e,label:t,children:n}){let r=Cc(e);return r.hidden?null:(0,q.jsx)(Ue,{error:r.error,helperText:mt(e).helperText??void 0,tooltip:mt(e).tooltip??void 0,label:t,name:r.name,required:r.required,children:n(r)})}var sl=({node:e})=>{let t=e.props;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a})=>{let o=il(n);return(0,q.jsxs)(ke,{children:[(0,q.jsx)(`input`,{name:e,type:`hidden`,value:o??``}),(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{className:L(xt(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,id:e,type:`button`,children:o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 shrink-0 rounded-full border border-lt-border`,style:{background:o}}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:o})]}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,q.jsx)(V,{className:`p-3`,children:(0,q.jsx)(al,{onChange:e=>a(e),palette:t.palette,value:o??`#6b7280`})})]})}})},cl=(0,G.lazy)(async()=>{let{DatePickerField:e}=await rn(async()=>{let{DatePickerField:e}=await import(`./chunks/date-picker-field-B4Xzow-A.js`);return{DatePickerField:e}},__vite__mapDeps([14,1,4,2,15,3,11,16]),import.meta.url);return{default:e}});function ll(e){return(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(cl,{...e})})}var ul=({node:e})=>{let t=e.props;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s})=>(0,q.jsx)(ll,{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})})},dl=({node:e})=>{let t=e.props,{timezone:n}=k();return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c})=>(0,q.jsx)(ll,{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 fl({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 pl(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return Gt(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function ml(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var hl=({node:e})=>{let{t}=E(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=Xe(e),{action:s,componentRef:c,errors:l}=De(),u=n.name,d=dt(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=Ie(),g=Te(),_=(0,G.useId)(),v=(0,G.useRef)(null),y=(0,G.useRef)(new Set),b=a||o,x=n.signed,S=n.multiple,C=S?`${f}[]`:f,w=(0,G.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,D]=(0,G.useState)(w),[O,k]=(0,G.useState)([]);(0,G.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){ml(d.getValue(u),t)||d.setValue(u,t);return}g(u,t)},[T,S,u,d,g,x]),(0,G.useEffect)(()=>{!x||d||g(`${u}__removed`,O)},[u,O,d,g,x]),(0,G.useEffect)(()=>()=>{y.current.forEach(e=>URL.revokeObjectURL(e)),y.current.clear()},[]);let A=(0,G.useMemo)(()=>T.filter(e=>e.file&&!e.existing).map(e=>e.file),[T]);(0,G.useEffect)(()=>{if(x||!v.current)return;let e=new DataTransfer;A.forEach(t=>e.items.add(t)),v.current.files=e.files},[A,x]);function j(e){if(!n.image)return;let t=URL.createObjectURL(e);return y.current.add(t),t}function N(e){!e.url||!y.current.has(e.url)||(URL.revokeObjectURL(e.url),y.current.delete(e.url))}async function P(e,t){let n=()=>{D(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))},r=await pl(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 fl({url:i.url,method:i.method.toUpperCase(),body:t,headers:i.headers,onProgress:t=>D(n=>n.map(n=>n.id===e.id?{...n,progress:t}:n))});D(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`ready`:`error`,key:i.key,progress:100}:t))}catch{n()}}function F(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:j(e),existing:!1}));if(!S&&(T.forEach(N),!d)){let e=T.filter(e=>e.existing&&e.token).map(e=>e.token);e.length>0&&k(t=>[...t,...e])}D(e=>S?[...e,...n]:n),x&&n.forEach((e,n)=>void P(e,t[n]))}function I(e){let t=T.find(t=>t.id===e);t&&N(t),t?.existing&&t.token&&!d&&k(e=>[...e,t.token]),D(t=>t.filter(t=>t.id!==e))}return r?null:(0,q.jsx)(Ue,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:u,required:i,children:(0,q.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":M(u),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),F(e.dataTransfer.files)},children:[(0,q.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,q.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,q.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,q.jsx)(`img`,{alt:e.name,className:`size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover`,"data-test":M(`${u}-preview`),src:e.url}):null,(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate`,"data-test":M(`${u}-item`),children:e.name}),e.status===`uploading`&&(0,q.jsxs)(`span`,{className:`text-xs text-lt-muted-fg`,children:[e.progress,`%`]}),e.status===`error`&&(0,q.jsx)(`span`,{className:`text-xs text-lt-danger`,children:t(`form.file-upload.failed`,`Failed`)})]}),(!e.existing||!d)&&(0,q.jsx)(ot,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":M(e.existing?`${u}-remove-existing`:`${u}-remove`),disabled:b,onClick:()=>I(e.id)}),x&&!e.existing&&e.key&&e.status===`ready`&&(0,q.jsx)(`input`,{"data-test":M(`${u}-uploaded`),name:C,type:`hidden`,value:e.key})]},e.id))}),!d&&O.map(e=>(0,q.jsx)(`input`,{name:`${u}__removed[]`,type:`hidden`,value:e},e)),(0,q.jsx)(`input`,{accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":M(`${u}-input`),id:_,multiple:S,name:x?void 0:C,onChange:e=>{F(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function gl({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=De(),c=Object.entries(a).filter(([,e])=>!!e).map(([e,t])=>({label:o[e]??e,message:t})),l=c.length>0;return(0,q.jsxs)(`span`,{className:`group relative inline-flex flex-col`,children:[(0,q.jsxs)(W,{"data-lattice-form":i,"data-test":`form-submit`,disabled:s||l,emphasis:r,type:`submit`,variant:n,children:[s&&(0,q.jsx)(la,{}),e]}),l&&(0,q.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,q.jsx)(`p`,{className:`mb-1 font-medium text-lt-fg`,children:t}),(0,q.jsx)(`ul`,{className:`space-y-1`,children:c.map(e=>(0,q.jsxs)(`li`,{className:`text-lt-muted-fg`,children:[(0,q.jsx)(`span`,{className:`font-medium text-lt-fg`,children:e.label}),` — `,e.message]},e.label))})]})]})}var _l={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function vl({componentId:e,reset:t}){let n=ft();return Cn(a.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function yl({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}=Ea(e,n,r),p=(0,G.useMemo)(()=>({markUserEdit:f}),[f]);return(0,q.jsx)(Oe,{value:p,children:(0,q.jsx)(ma,{nodes:d,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,q.jsx)(`div`,{className:`flex gap-3 ${_l[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,q.jsx)(gl,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},En(e,t)):(0,q.jsx)(Y,{node:e},En(e,t))):(0,q.jsx)(gl,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function bl(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var xl=({children:e,node:t})=>{let n=(0,G.useMemo)(()=>({...Da(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,q.jsx)(ut,{initial:n,children:(0,q.jsx)(Sl,{node:t,children:e})})};function Sl({children:e,node:t}){let{t:n}=E(`lattice`),r=t.props,i=r.action??`#`,a=r.errorBag,o=r.ref??``,s=r.method??`post`,c=r.precognitive,u=r.resetOnError??!1,d=r.resetOnSuccess??[],f=(0,G.useMemo)(()=>Da(t.schema).labels,[t.schema]),p=r.submitButton,m=r.submitButtons??void 0,h=r.submitJustify??void 0,g=r.submitLabel??n(`form.submit`,`Submit`),_=r.submitVariant??void 0,v=r.submitEmphasis??void 0,y=r.validationSummaryLabel,b=r.validationTimeout??void 0,x=ft(),S=e=>{let t=bl(e);t!==!1&&x(t)},C=(0,G.useRef)(null),w=(0,G.useRef)(`idle`),[T,D]=(0,G.useState)(0);return(0,G.useEffect)(()=>{T>0&&w.current===`renewing`&&C.current?.submit()},[T]),(0,q.jsx)(l,{ref:C,action:i,"data-slot":`form`,"data-lattice-component":t.id,errorBag:a,method:s,resetOnError:u,resetOnSuccess:d,validationTimeout:c?b:void 0,headers:Pt(o),className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,onStart:()=>{w.current=w.current===`renewing`?`retried`:`idle`},onSuccess:()=>S(d),onError:()=>S(u),onHttpException:e=>{if(e.status===403&&o!==``&&w.current!==`retried`)return w.current=`renewing`,Wt(o).finally(()=>D(e=>e+1)),!1},children:({clearErrors:n,errors:a,processing:s,reset:l,touch:u,validate:d,validating:b})=>(0,q.jsxs)(me,{value:{action:i,clearErrors:e=>n(e),componentId:t.id,componentRef:o,errors:a,fieldLabels:f,precognitive:c,processing:s,touch:e=>u(...e),validate:e=>d(e),validateFields:(e,t)=>d({only:e,...t}),validating:b},children:[(0,q.jsx)(vl,{componentId:t.id,reset:l}),r.status&&(0,q.jsx)(`div`,{className:`text-center text-sm font-medium text-lt-success`,children:r.status}),(0,q.jsx)(yl,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:p,submitButtons:m,submitEmphasis:v,submitJustify:h,submitLabel:g,submitVariant:_,summaryLabel:y,children:e})]})})}var Cl=({node:e})=>{let t=dt(),n=e.props.name,r=t?t.getValue(n):e.props.value;return(0,q.jsx)(`input`,{defaultValue:typeof r==`string`?r:``,name:t?t.scopedName(n):n,type:`hidden`})};function wl({affix:e,side:t,squared:n=!1}){return(0,q.jsx)(`span`,{"data-slot":`affix-${t}`,className:L(`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,q.jsx)(I,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function Tl({prefix:e,suffix:t,end:n,children:r}){return!e&&!t&&!n?r(``):(0,q.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,q.jsx)(wl,{affix:e,side:`start`}):null,(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(L(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,q.jsx)(wl,{affix:t,side:`end`,squared:!!n}):null,n]})}var El=({node:e})=>{let t=e.props;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>{let s=e=>o(e.target.value);return t.slider?(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`input`,{"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,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`range`,value:r}),(0,q.jsx)(`output`,{className:`w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg`,children:r})]}):(0,q.jsx)(Tl,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,q.jsx)(ht,{autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},Dl=Object.defineProperty,Ol=Object.defineProperties,kl=Object.getOwnPropertyDescriptors,Al=Object.getOwnPropertySymbols,jl=Object.prototype.hasOwnProperty,Ml=Object.prototype.propertyIsEnumerable,Nl=(e,t,n)=>t in e?Dl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pl=(e,t)=>{for(var n in t||={})jl.call(t,n)&&Nl(e,n,t[n]);if(Al)for(var n of Al(t))Ml.call(t,n)&&Nl(e,n,t[n]);return e},Fl=(e,t)=>Ol(e,kl(t)),Il=(e,t)=>{var n={};for(var r in e)jl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Al)for(var r of Al(e))t.indexOf(r)<0&&Ml.call(e,r)&&(n[r]=e[r]);return n};function Ll(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function Rl(e){let t=G.useRef();return G.useEffect(()=>{t.current=e}),t.current}var zl=18,Bl=40,Vl=`${Bl}px`,Hl=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function Ul({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=G.useState(!1),[o,s]=G.useState(!1),[c,l]=G.useState(!1),u=G.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=G.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-zl,f=u;document.querySelectorAll(Hl).length===0&&document.elementFromPoint(d,f)===r||(a(!0),l(!0))},[e,t,c,n]);return G.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){let e=window.innerWidth-t.getBoundingClientRect().right;s(e>=Bl)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),G.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:Vl}}var Wl=G.createContext({}),Gl=G.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=ql,render:h,children:g}=n,_=Il(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`render`,`children`]),v;let[y,b]=G.useState(typeof _.defaultValue==`string`?_.defaultValue:``),x=r??y,S=Rl(x),C=G.useCallback(e=>{i?.(e),b(e)},[i]),w=G.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),T=G.useRef(null),E=G.useRef(null),D=G.useRef({value:x,onChange:C,isIOS:typeof window<`u`&&((v=window==null?void 0:window.CSS)?.supports)?.call(v,`-webkit-touch-callout`,`none`)}),O=G.useRef({prev:[T.current?.selectionStart,T.current?.selectionEnd,T.current?.selectionDirection]});G.useImperativeHandle(t,()=>T.current,[]),G.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;`;Kl(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Kl(e.sheet,`[data-input-otp]:autofill { ${t} }`),Kl(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Kl(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; } }`),Kl(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]=G.useState(!1),[j,M]=G.useState(!1),[N,P]=G.useState(null),[F,I]=G.useState(null);G.useEffect(()=>{Ll(()=>{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]),G.useEffect(()=>{S!==void 0&&x!==S&&S.length<a&&x.length===a&&u?.(x)},[a,u,S,x]);let L=Ul({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),R=G.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]),ee=G.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]),te=G.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]),ne=G.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),re=G.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]),z=G.useMemo(()=>G.createElement(`input`,Fl(Pl({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:re,maxLength:a,value:x,ref:T,onPaste:e=>{var t;te(e),(t=_.onPaste)==null||t.call(_,e)},onChange:R,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;ee(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[R,ee,te,l,re,a,F,N,_,w?.source,x]),B=G.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]),ie=G.useMemo(()=>h?h(B):G.createElement(Wl.Provider,{value:B},g),[g,B,h]);return G.createElement(G.Fragment,null,m!==null&&G.createElement(`noscript`,null,G.createElement(`style`,null,m)),G.createElement(`div`,{ref:E,"data-input-otp-container":!0,style:ne,className:p},ie,G.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},z)))});Gl.displayName=`Input`;function Kl(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var ql=`
|
|
4
4
|
[data-input-otp] {
|
|
5
5
|
--nojs-bg: white !important;
|
|
6
6
|
--nojs-fg: black !important;
|
|
@@ -19,4 +19,4 @@ import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i,s a
|
|
|
19
19
|
--nojs-bg: black !important;
|
|
20
20
|
--nojs-fg: white !important;
|
|
21
21
|
}
|
|
22
|
-
}`,Gl=`^\\d+$`;function Kl({char:e,hasFakeCaret:t,isActive:n}){return(0,J.jsxs)(`div`,{className:L(`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,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(`div`,{className:`bg-lt-fg h-5 w-px animate-pulse`})}):null]})}function ql({length:e,containerClassName:t,pattern:n=Gl,...r}){return(0,J.jsx)(Hl,{maxLength:e,pattern:n,containerClassName:L(`flex items-center gap-2 has-[:disabled]:opacity-50`,t),render:({slots:e})=>(0,J.jsx)(`div`,{className:`flex items-center`,children:e.map((e,t)=>(0,J.jsx)(Kl,{...e},t))}),...r})}var Jl=({node:e})=>{let t=e.props;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,J.jsx)(ql,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a||i,id:e,length:t.length,name:e,onChange:e=>o(e),value:r})})};function Yl({className:e,ref:t,...n}){let[r,i]=(0,K.useState)(!1);return(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(mt,{type:r?`text`:`password`,className:L(`pr-10`,e),ref:t,...n}),(0,J.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,J.jsx)(B,{name:`eye-off`,className:`size-lt-icon-md`}):(0,J.jsx)(B,{name:`eye`,className:`size-lt-icon-md`})})]})}var Xl=({node:e})=>{let t=e.props,{errors:n}=Ee(),r=bc(e),{commit:i}=Me(),a=ut(),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,J.jsxs)(`div`,{className:`grid gap-6`,children:[(0,J.jsx)(He,{error:r.error,helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,labelAction:t.labelAction??void 0,name:r.name,required:r.required,children:(0,J.jsx)(Sl,{prefix:t.prefix,suffix:t.suffix,children:e=>(0,J.jsx)(Yl,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:e,"data-test":r.testId,disabled:r.disabled,id:r.name,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,J.jsx)(He,{error:n[l],label:o.label??`Confirm password`,name:c,required:r.required,children:(0,J.jsx)(Yl,{autoComplete:`new-password`,"data-test":M(s),disabled:r.disabled,id:c,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})})]})},Zl=[],Ql=({node:e})=>{let t=e.props,n=t.name,{errors:r}=Ee(),{hidden:i,required:a}=Ye(e),{path:o,rows:s,onField:c,onRemove:l,onMove:u,onDuplicate:d,append:f}=Ys(n,t.defaultItems??1),p=e.schema??Zl,m=Js(s.map(e=>String(e.rowId??``)).join(`,`)),h=t.maxItems!=null&&s.length>=t.maxItems,g=t.minItems!=null&&s.length<=t.minItems,_=t.layout===`table`,v=t.itemLabels,y=e=>{let n=v?.[e];return typeof n==`string`&&n!==``?n:t.itemLabel?`${t.itemLabel} ${e+1}`:`#${e+1}`};if(i)return null;let b=s.map((e,t)=>({key:String(e.rowId??t),index:t,row:e,template:p,span:!1,heading:y(t)}));return(0,J.jsx)(He,{error:r[o],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:o,required:a,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(bs,{path:o,rows:s,rowKey:de}),_?(0,J.jsx)(Gs,{base:o,columns:Us(p),rows:b,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,J.jsx)(`div`,{ref:e=>m(r,e),"data-flip-key":r,children:(0,J.jsx)(Ss,{base:o,index:n,row:e,template:p,heading:y(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,J.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,J.jsx)(B,{name:`plus`}),t.addLabel??`Add`]})]})})},$l=250;function eu({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:p,searchPlaceholder:m,selected:h,showSearch:g=!0,testId:_,trigger:v,triggerClassName:y,triggerProps:b}){let{t:x}=E(`lattice`),[S,C]=(0,K.useState)(``);function w(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?C(``):k()}let T=d.some(e=>e.label.toLowerCase()===S.trim().toLowerCase()),D=Aa(e=>s?.(e),$l);(0,K.useEffect)(()=>{if(!(!s||!l))return D(S),()=>D.cancel()},[S,s,l,D]);let O=s?d:d.filter(e=>e.label.toLowerCase().includes(S.toLowerCase()));function k(){C(``),u(!1)}function A(e){c(e),i||k()}return(0,J.jsxs)(Oe,{open:l,onOpenChange:e=>e?u(!0):k(),children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:y,...b,children:v})}),(0,J.jsxs)(V,{align:`start`,className:L(`w-[var(--radix-popover-trigger-width)] overflow-hidden p-0`,e),children:[g&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-lt-border px-3 py-2`,children:[(0,J.jsx)(`input`,{"aria-label":p??x(`form.search-options`,`Search options`),"data-slot":`combobox-search`,"data-test":_?`${_}-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(`,`)){w(n);return}C(n)},onKeyDown:e=>{t&&e.key===`Enter`&&S.trim()!==``&&(e.preventDefault(),w(S))},placeholder:m,value:S}),r&&(0,J.jsx)(B,{name:`loader-2`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0 animate-spin text-lt-muted-fg`})]}),(0,J.jsxs)(`div`,{className:`max-h-60 overflow-y-auto p-1`,role:`listbox`,children:[t&&S.trim()!==``&&!T&&(0,J.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":_?`${_}-create`:void 0,onClick:()=>w(S),type:`button`,children:[(0,J.jsx)(B,{name:`plus`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`}),x(`form.create-option`,`Create "{{label}}"`,{label:S.trim()})]}),O.length===0&&!(t&&S.trim()!==``&&!T)?(0,J.jsx)(`p`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:n}):O.map(e=>{let t=h.includes(e.value);return(0,J.jsxs)(`button`,{"aria-label":f?e.label:void 0,"aria-selected":t,className:L(`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":_?`${_}-option-${e.value}`:void 0,"data-value":e.value,onClick:()=>A(e.value),role:`option`,type:`button`,children:[f?(0,J.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:f(e)}):e.label,t&&(0,J.jsx)(B,{name:`check`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`})]},e.value)})]})]})]})}function tu(e,t){let n=e??t;return Array.isArray(n)?n.map(String):n==null||n===``?[]:[String(n)]}var nu=({node:e})=>{let{t}=E(`lattice`),n=e.props,{action:r,componentRef:i,errors:a,fieldIdPrefix:o,searchOptions:s}=Ee(),{hidden:c,required:l,readOnly:u,disabled:d}=Ye(e),{change:f,blur:p}=Me(),m=ha(e),h=n.name,g=ut(),_=_c(g?g.scopedName(h):h,o),v=g?g.errorKey(h):h,y=v,b=n.placeholder||`Select…`,x=n.multiple,C=n.searchable,w=n.creatable,T=(0,K.useMemo)(()=>m.props.options??[],[m.props]),D=m.props.optionSchema,O=ft(h),k=Fe(),A=(0,K.useRef)(k);A.current=k;let j=g?g.getValue(h):O,M=(0,K.useMemo)(()=>tu(j,n.value),[j,n.value]),N=(0,K.useRef)(M);N.current=M;let[P,F]=(0,K.useState)(!1),[I,R]=(0,K.useState)(null),[ee,te]=(0,K.useState)(!1),ne=(0,K.useRef)(null),re=(0,K.useMemo)(()=>{let e=new Map;for(let t of[...T,...I??[]])e.set(t.value,t);return e},[T,I]),z=e=>re.get(e)?.label??e,ie=e=>Et(re.get(e)?.data?.color),ae=u||d,oe=(0,K.useCallback)(e=>{if(ne.current?.abort(),e.trim()===``){R(null),te(!1);return}let t=new AbortController;if(ne.current=t,te(!0),s){s(y,e,A.current,t.signal).then(e=>{R(e),te(!1)}).catch(()=>{});return}_a(r,i,{...A.current,_sub:`search`,_target:y,_q:e},t.signal).then(e=>{R(e?.options??[]),te(!1)}).catch(()=>{})},[r,i,y,s]);function se(e){f(h,x?e:e[0]??``)}function ce(e){if(x){let t=N.current.includes(e)?N.current.filter(t=>t!==e):[...N.current,e];N.current=t,se(t);return}N.current=[e],se([e])}function le(e){se(M.filter(t=>t!==e))}function ue(e){if(!x){N.current=[e],se([e]);return}if(!N.current.includes(e)){let t=[...N.current,e];N.current=t,se(t)}}if(c)return null;let de=C?I??T:T,fe=D?.length?e=>(0,J.jsx)(Y,{nodes:S(D,{...e.data,label:e.label,value:e.value})}):void 0;return(0,J.jsxs)(He,{error:a[v],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:_,required:l,children:[x?M.map(e=>(0,J.jsx)(`input`,{name:`${_}[]`,type:`hidden`,value:e},e)):(0,J.jsx)(`input`,{name:_,type:`hidden`,value:M[0]??``}),(0,J.jsxs)(`div`,{children:[x&&M.length>0&&(0,J.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1`,children:M.map(e=>{let n=ie(e);return(0,J.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,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full`,style:{background:Ct(n)}}),z(e),!ae&&(0,J.jsx)(`button`,{"aria-label":t(`form.remove-option`,`Remove {{label}}`,{label:z(e)}),"data-test":`select-${h}-remove-${e}`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-xs`,onClick:()=>le(e),type:`button`,children:(0,J.jsx)(B,{name:`x`})})]},e)})}),(0,J.jsx)(eu,{creatable:w,emptyLabel:n.emptyLabel??void 0,loading:ee,multiple:x,onCommit:ue,onCreate:ue,onSearch:C?oe:void 0,onSelect:ce,open:P&&!ae,onOpenChange:e=>{F(e),e||p(h)},options:de,renderOption:fe,searchPlaceholder:n.searchPlaceholder??void 0,showSearch:!!(C||w),selected:M,testId:`select-${h}`,trigger:(0,J.jsxs)(J.Fragment,{children:[!x&&M.length>0?(0,J.jsx)(`span`,{children:z(M[0])}):(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:b}),(0,J.jsx)(B,{name:`chevrons-up-down`,className:`size-lt-icon-md shrink-0 text-lt-muted-fg`})]}),triggerClassName:L(bt(),`flex items-center justify-between gap-2 text-left`,ae&&`cursor-not-allowed opacity-60`),triggerProps:{"aria-haspopup":`listbox`,autoFocus:n.autoFocus??void 0,"data-test":`select-${h}`,disabled:ae,id:_,tabIndex:n.tabIndex??void 0}})]})]})};function ru({className:e,...t}){return(0,J.jsx)(`textarea`,{"data-slot":`textarea`,className:L(`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 iu=({node:e})=>{let t=e.props;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,J.jsx)(ru,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a,id:e,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})})},au=({node:e})=>{let t=e.props;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,J.jsx)(Sl,{prefix:t.prefix,suffix:t.suffix,end:t.copyable?(0,J.jsx)(ko,{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:s=>(0,J.jsx)(mt,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:s,"data-test":n,disabled:a,id:e,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,tabIndex:t.tabIndex??void 0,type:t.type??`text`,value:r})})})},ou=({node:e})=>{let t=e.props,n=ht(t.step),r=t.label??t.name;return(0,J.jsx)(rl,{node:e,label:t.label??``,children:({name:e,testId:i,value:a,readOnly:o,disabled:s,commit:c,blur:l})=>(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(mt,{"aria-label":r,autoFocus:t.autoFocus??!1,"data-test":i,disabled:s,id:e,name:e,onBlur:()=>{let e=yt(a);e&&c(_t(e,n)),l()},onChange:e=>c(e.target.value),readOnly:o,tabIndex:t.tabIndex??void 0,type:`text`,value:a}),(0,J.jsxs)(Oe,{children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(G,{"aria-label":`Open ${r} time picker`,disabled:s||o,size:`icon`,type:`button`,variant:`secondary`,children:(0,J.jsx)(B,{name:`clock`,className:`size-lt-icon-md`,"aria-hidden":`true`})})}),(0,J.jsx)(V,{className:`p-2`,children:(0,J.jsx)(xt,{value:yt(a),onChange:e=>c(_t(e,n)),step:t.step,min:t.min,max:t.max,disabled:s,readOnly:o,testId:`${i}-picker`})})]})]})})},su=({node:e})=>{let{hidden:t,required:n,readOnly:r,disabled:i}=Ye(e),a=e.props,o=a.name,s=ut(),{errors:c,fieldIdPrefix:l}=Ee(),u=_c(s?s.scopedName(o):o,l),d=s?s.errorKey(o):o,f=ft(o),p=s?s.getValue(o):f,m=tt(a.value),h=p===void 0?m:tt(p),g=r||i,{commit:_}=Me();return vc(o,m),t?null:(0,J.jsxs)(He,{error:c[d],helperText:a.helperText??void 0,tooltip:a.tooltip??void 0,label:a.label??``,name:u,required:n,children:[(0,J.jsx)(`input`,{disabled:g,name:u,type:`hidden`,value:h?`1`:`0`}),(0,J.jsx)(`button`,{"aria-checked":h,"aria-label":a.label??o,autoFocus:a.autoFocus??!1,className:L(`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":h?`checked`:`unchecked`,"data-test":M(o),disabled:g,id:u,name:u,onClick:()=>_(o,!h),role:`switch`,tabIndex:a.tabIndex??void 0,type:`button`,children:(0,J.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":h?`checked`:`unchecked`})})]})};function cu(e){let t=[],n=e=>{let r=pt(e).name;if(r&&t.push(r),!(r&&Ce.has(e.type)))for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function lu(e){let t=[],n=e=>{let r=pt(e).name;if(r&&t.push(r,`${r}.*`),r&&Ce.has(e.type)){for(let n of cu(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 uu(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=>Oa(t,e)))&&r.add(t)}),r}function du(e,t){let n=uu(e,t);return n.size>0?Math.min(...n):null}var fu=(0,K.createContext)({activeName:``});function pu(e){let t=(e.schema??[]).filter(e=>e.type===`wizard-step`);return{items:t.map(e=>e.props),nodes:t}}var mu=({children:e,node:t})=>{let{t:n}=E(`lattice`),{errors:r,processing:i,touch:a,validateFields:o,validating:s}=Ee(),{items:c,nodes:l}=(0,K.useMemo)(()=>pu(t),[t]),u=(0,K.useMemo)(()=>l.map(e=>cu(e)),[l]),d=t.props.orientation===`vertical`,[f,p]=(0,K.useState)(0),[m,h]=(0,K.useState)(()=>new Set([0])),[g,_]=(0,K.useState)(()=>new Set),v=(0,K.useMemo)(()=>uu(u,r),[u,r]),y=f===c.length-1,b=e=>{p(e),h(t=>new Set(t).add(e))},x=()=>{_(e=>new Set(e).add(f)),y||b(f+1)},S=()=>{let e=l[f],t=e?lu(e):[];if(t.length===0){x();return}a(t),o(t,{onSuccess:x})},C=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(C.current&&!i){let e=du(u,r);e!==null&&e!==f&&b(e)}C.current=i},[i,r,u,f]);let w=(0,K.useMemo)(()=>({activeName:c[f]?.name??``}),[c,f]);return(0,J.jsx)(fu.Provider,{value:w,children:(0,J.jsxs)(`div`,{className:L(`gap-6`,d?`flex`:`grid`),"data-slot":`wizard`,children:[(0,J.jsx)(`ol`,{"aria-label":n(`form.wizard.steps`,`Steps`),className:L(`gap-1`,d?`flex w-56 shrink-0 flex-col`:`flex flex-wrap`),children:c.map((e,t)=>{let n=t===f,r=g.has(t),i=v.has(t);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{"aria-current":n?`step`:void 0,className:L(`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`,!m.has(t)&&`cursor-not-allowed opacity-60`),"data-error":i||void 0,"data-test":`wizard-rail-${e.name}`,disabled:!m.has(t),id:`wizard-step-${e.name}-trigger`,onClick:()=>b(t),type:`button`,children:[(0,J.jsx)(`span`,{className:L(`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,J.jsx)(B,{className:`size-lt-icon-sm`,name:`check`}):t+1}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block truncate`,children:e.label}),d&&e.description&&(0,J.jsx)(`span`,{className:`block truncate text-xs text-lt-muted-fg`,children:e.description})]})]})},e.name)})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-6`,children:[e,(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(G,{"data-test":`wizard-back`,disabled:f===0||i,onClick:()=>b(f-1),type:`button`,emphasis:`outline`,children:n(`form.wizard.back`,`Back`)}),y?(0,J.jsxs)(G,{"data-test":`wizard-finish`,disabled:i,type:`submit`,children:[i&&(0,J.jsx)(la,{}),n(`form.wizard.finish`,`Finish`)]}):(0,J.jsxs)(G,{"data-test":`wizard-next`,disabled:i||s,onClick:S,type:`button`,children:[s&&(0,J.jsx)(la,{}),n(`form.wizard.next`,`Next`)]})]})]})]})})},hu=({children:e,node:t})=>{let{activeName:n}=(0,K.useContext)(fu),r=t.props.name,i=n===r,[a,o]=(0,K.useState)(i);return(0,K.useEffect)(()=>{i&&o(!0)},[i]),(0,J.jsx)(`section`,{"aria-labelledby":`wizard-step-${r}-trigger`,className:L(`space-y-8`,!i&&`hidden`),hidden:!i,id:`wizard-step-${r}-panel`,children:a?e:null})},gu=(0,K.lazy)(()=>nn(()=>import(`./chunks/rich-editor-field-JM3jBEV1.js`),__vite__mapDeps([17,1,2,5,4,6,15,3,11,18,13]),import.meta.url)),_u=yn({components:{form:q(vl),"field.builder":q(Zs),"field.checkbox":q(yc),"field.choice":q(xc),"field.color-picker":q(il),"field.date-input":q(sl),"field.date-time-input":q(cl),"field.file-upload":q(fl),"field.hidden-input":q(bl),"field.number-input":q(Cl),"field.otp":q(Jl),"field.password-input":q(Xl),"field.repeater":q(Ql),"field.rich-editor":q(({children:e,node:t})=>(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(gu,{node:t,children:e})})),"field.select":q(nu),"field.textarea":q(iu),"field.text-input":q(au),"field.time-input":q(ou),"field.toggle":q(su),wizard:q(mu),"wizard-step":q(hu)},name:`lattice/form`});function vu(e,t=1){return Gt(`${e}?page=${t}`)}function yu(e,t){return Gt(`${e}/${t}/read`,{method:`PATCH`})}function bu(e){return Gt(`${e}/read-all`,{method:`POST`})}function xu(e,t){return Gt(`${e}/${t}`,{method:`DELETE`})}function Su(e){return Gt(e,{method:`DELETE`})}function Cu(e,t){return e.some(e=>e.id===t.id)?e:[t,...e]}function wu(e,t){return e.map(e=>e.id===t?{...e,isRead:!0}:e)}function Tu(e,t){return e.filter(e=>e.id!==t)}function Eu({endpoint:e,pollingInterval:t}){let[n,r]=(0,K.useState)([]),[i,a]=(0,K.useState)(0),[o,s]=(0,K.useState)(`loading`),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),f=(0,K.useRef)(1),p=(0,K.useRef)(c);p.current=c;let m=(0,K.useRef)(!1),h=(0,K.useCallback)(async()=>{try{let t=await vu(e,1);f.current=1,r(t.notifications),a(t.unreadCount),l(t.hasMore),s(`idle`)}catch{s(`error`)}},[e]);return(0,K.useEffect)(()=>{h()},[h]),(0,K.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,K.useCallback)(()=>{if(m.current||!p.current)return;m.current=!0;let t=f.current+1;vu(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,K.useCallback)(t=>{r(e=>wu(e,t)),a(e=>Math.max(0,e-1)),yu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),markAllRead:(0,K.useCallback)(()=>{r(e=>e.map(e=>({...e,isRead:!0}))),a(0),bu(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),dismiss:(0,K.useCallback)(t=>{r(e=>Tu(e,t)),xu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),clearAll:(0,K.useCallback)(()=>{r([]),a(0),Su(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),receive:(0,K.useCallback)(e=>{r(t=>{let n=Cu(t,e);return n!==t&&a(e=>e+1),n})},[])}}function Du(){let{t:e}=E(`lattice`);return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-lt-muted-fg`,children:[(0,J.jsx)(B,{name:`bell`,className:`size-lt-icon-lg`}),(0,J.jsx)(`p`,{className:`text-sm`,children:e(`notifications.empty`,`No notifications yet`)})]})}var Ou={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 ku({notification:e,onMarkRead:t,onDismiss:n}){let{t:r}=E(`lattice`),i=ae(e.title,r),a=ae(e.body,r),o=(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsx)(`p`,{className:`truncate text-sm font-medium text-lt-fg`,children:i}):null,a?(0,J.jsx)(`p`,{className:`text-sm text-lt-muted-fg`,children:a}):null]});return(0,J.jsxs)(`li`,{className:L(`flex gap-3 px-3 py-3`,!e.isRead&&`bg-lt-muted/40`),"data-test":`notification`,children:[e.icon?(0,J.jsx)(I,{icon:e.icon,className:L(`mt-0.5 size-lt-icon-md`,e.variant?Ou[e.variant]:void 0)}):null,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e.href?(0,J.jsx)(x,{href:e.href,className:`block`,"data-test":`notification-link`,onClick:()=>t(e.id),children:o}):o,e.actions.length>0?(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.actions.map((e,t)=>(0,J.jsx)(An,{node:e},e.key??e.id??`action-${t}`))}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.isRead?null:(0,J.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,J.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 Au({notifications:e,status:t,hasMore:n,onMarkRead:r,onDismiss:i,onLoadMore:a}){let{t:o}=E(`lattice`);return t===`loading`&&e.length===0?(0,J.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,J.jsx)(fa,{className:`h-12 w-full`}),(0,J.jsx)(fa,{className:`h-12 w-full`}),(0,J.jsx)(fa,{className:`h-12 w-full`})]}):e.length===0?(0,J.jsx)(Du,{}):(0,J.jsxs)(`div`,{className:`max-h-96 overflow-y-auto`,children:[(0,J.jsx)(`ul`,{className:`divide-y divide-lt-border`,children:e.map(e=>(0,J.jsx)(ku,{notification:e,onMarkRead:r,onDismiss:i},e.id))}),n?(0,J.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 ju=(0,K.lazy)(()=>nn(()=>import(`./chunks/notifications-echo-uU87iJAV.js`).then(e=>({default:e.NotificationsEcho})),__vite__mapDeps([19,8,1]),import.meta.url)),Mu=class extends K.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}},Nu=yn({name:`lattice/notifications`,components:{notifications:q(({node:e})=>{let{t}=E(`lattice`),n=Eu({endpoint:e.props.endpoint,pollingInterval:e.props.pollingInterval}),r=t(`notifications.label`,`Notifications`),i=(0,J.jsxs)(`span`,{className:`relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted`,children:[(0,J.jsx)(B,{name:`bell`,className:`size-lt-icon-md`}),n.unreadCount>0?(0,J.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,J.jsxs)(`div`,{className:`w-80`,"data-test":`notifications-panel`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-lt-border px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:t(`notifications.heading`,`Notifications`)}),n.unreadCount>0?(0,J.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,J.jsx)(Au,{notifications:n.notifications,status:n.status,hasMore:n.hasMore,onMarkRead:n.markRead,onDismiss:n.dismiss,onLoadMore:n.loadMore})]});return(0,J.jsxs)(J.Fragment,{children:[e.props.channel?(0,J.jsx)(Mu,{children:(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(ju,{channel:e.props.channel,onReceive:e=>n.receive(e)})})}):null,e.props.slideOut?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,onClick:()=>n.setOpen(!0),children:i}),(0,J.jsx)(ra,{open:n.open,onOpenChange:n.setOpen,children:(0,J.jsxs)(sa,{"aria-describedby":void 0,className:`p-0`,placement:`end`,width:`sm`,children:[(0,J.jsx)(aa,{className:`sr-only`,children:r}),a]})})]}):(0,J.jsxs)(Oe,{open:n.open,onOpenChange:n.setOpen,children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,children:i})}),(0,J.jsx)(V,{align:`end`,className:`p-0`,children:a})]})]})})}});function Pu(e){return e==null?``:String(e)}function Fu({props:e}){let{t}=E(`lattice`),[n,r]=(0,K.useState)([]),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!e.remote||!e.dataEndpoint){r([]),s(!1);return}let t=!1;return a(null),s(!0),Qt(e.dataEndpoint,{remote:e.remote}).then(e=>{t||r(e.data??[])}).catch(e=>{t||a(e instanceof Error?e.message:String(e))}).finally(()=>{t||s(!1)}),()=>{t=!0}},[e.dataEndpoint,e.remote]),i?(0,J.jsx)(`div`,{className:`rounded-lt border border-lt-danger/40 p-3 text-sm`,children:i}):o||!e.remote?(0,J.jsx)(`div`,{className:`rounded-lt border border-lt-border p-3 text-sm`,children:t(`common.remote.data-list.loading`,`Loading...`)}):(0,J.jsxs)(`div`,{className:`rounded-lt border border-lt-border bg-lt-bg`,children:[(0,J.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,J.jsxs)(`div`,{className:`divide-y divide-lt-border`,children:[n.map((t,n)=>(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(Y,{nodes:S(e.schema,t)})},Pu(t.id)||n)),n.length===0?(0,J.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 Iu=yn({components:{"remote.data-list":q(({node:e})=>(0,J.jsx)(Fu,{props:{...e.props,schema:e.schema}}))},name:`lattice/remote`});function Lu({columns:e,storageKey:t}){let n=(0,K.useMemo)(()=>e.filter(e=>e.props.toggleable),[e]),r=(0,K.useMemo)(()=>n.map(e=>e.key),[n]),[i,a]=mi(t??``,{},{enabled:!!t,parse:e=>zu(e,r),serialize:e=>Bu(e,r)}),o=(0,K.useCallback)(e=>e.props.toggleable?i[e.key]??!e.props.hiddenByDefault:!0,[i]),s=(0,K.useMemo)(()=>e.filter(e=>o(e)),[e,o]),c=(0,K.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[a]),l=(0,K.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 Ru(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 zu(e,t){let n=JSON.parse(e)?.overrides;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`unexpected stored column visibility shape`);return Ru(n,t)}function Bu(e,t){let n=Ru(e,t);return Object.keys(n).length===0?null:JSON.stringify({overrides:n})}function Vu(){let[e,t]=(0,K.useState)(()=>new Set);return{isExpanded:(0,K.useCallback)(t=>e.has(t),[e]),toggle:(0,K.useCallback)(e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[])}}var Hu={start:`text-start`,center:`text-center`,end:`text-end`},Uu={start:`justify-start`,center:`justify-center`,end:`justify-end`},Wu={start:`justify-items-start`,center:`justify-items-center`,end:`justify-items-end`},Gu=e=>Hu[e],Ku=e=>Uu[e],qu=e=>Wu[e];function Ju(e){return(e??[]).flatMap(e=>{if(e.type===`action.group`)return[];let t=e.props;return t.endpoint?[{id:e.id??``,label:Ia(e),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 Yu(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 Xu(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 Zu(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}var Qu={mode:`none`,currentPage:null,lastPage:null,perPage:null,total:null,from:null,to:null,hasMore:!1,nextPage:null};function $u(e){return typeof e!=`object`||!e||Array.isArray(e)?Qu:e}function ed(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:Yu(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:id(t.tableFilters),tableFilterIndicators:ad(t.tableFilterIndicators),search:typeof t.search==`string`?t.search:``,mode:nd(t.mode)}}var td=new Set([`none`,`simple`,`table`,`infinite`]);function nd(e){return typeof e==`string`&&td.has(e)?e:null}function rd(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`||e===`infinite`):[]}function id(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 ad(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 od(e,t){let n=e.id??e.uuid??e.key??t;return String(n)}function sd(e){return Array.isArray(e.actions)?e.actions:[]}function cd(e){let t=e.detail;return typeof t==`object`&&t&&!Array.isArray(t)?t:null}function ld(e){return e==null||e===``}function ud(e){return ld(e)?!0:Array.isArray(e)?e.every(ud):typeof e==`object`&&e?Object.values(e).every(ud):!1}function dd(e){return!ud(e)}function fd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pd(e){return fd(e)?e:{}}function md(e,t){return e.sorts.find(e=>e.key===t.key)}function hd(e){if(e?.direction===`asc`)return`ascending`;if(e?.direction===`desc`)return`descending`}function gd(e,t){let n=new URL(e,window.location.origin);return t.filters.length>0&&n.searchParams.set(`filter`,Cd(t)),t.sorts.length>0&&n.searchParams.set(`sort`,wd(t)),t.search!==``&&n.searchParams.set(`q`,t.search),_d(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 _d(e,t){for(let[n,r]of Object.entries(vd(t)))xd(e,`tf[${n}]`,r)}function vd(e){let t={};for(let[n,r]of Object.entries(e)){let e=yd(r);e!==void 0&&(t[n]=e)}return t}function yd(e){if(ld(e)||Array.isArray(e)||typeof e!=`object`)return;let t=Object.entries(e).map(([e,t])=>[e,bd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}function bd(e){if(!ld(e)){if(Array.isArray(e)){let t=e.map(bd).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,bd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}return String(e)}}function xd(e,t,n){if(Array.isArray(n)){for(let r of n)xd(e,`${t}[]`,r);return}if(typeof n==`object`&&n){for(let[r,i]of Object.entries(n))xd(e,`${t}[${r}]`,i);return}e.searchParams.append(t,String(n))}function Sd(e){let t={};e.filters.length>0&&(t.filter=Cd(e)),e.sorts.length>0&&(t.sort=wd(e));let n=vd(e.tableFilters);return Object.keys(n).length>0&&(t.tf=n),e.search!==``&&(t.q=e.search),t}function Cd(e){return e.filters.map(e=>`${e.field}:${e.operator}:${encodeURIComponent(e.value)}`).join(`,`)}function wd(e){return e.sorts.map(e=>e.direction===`desc`?`-${e.key}`:e.key).join(`,`)}var Td={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`},Ed=new Set([`empty`,`filled`]);function Dd(e){return w(`lattice`,`table.operators.${e}`,Td[e]??e)}function Od(e){return e===`desc`?`descending`:`ascending`}function kd(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 Ad(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 jd(e){return e.map(e=>({key:e.key,label:e.props.label,width:Md(e)}))}function Md(e){return e.props.width??`md`}function Nd(e,t,n=!1){return{leadingTracks:[...n?[`2.5rem`]:[],...t?[`3rem`]:[]],trailingTracks:e?[`10rem`]:[]}}function Pd(e){let t=(0,K.useMemo)(()=>Xu(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,o=(0,K.useMemo)(()=>ed(e.props?.query),[e.props?.query]),s=(0,K.useMemo)(()=>Zu(e.props?.data),[e.props?.data]),c=(0,K.useMemo)(()=>$u(e.props?.pagination),[e.props?.pagination]),[l,u]=(0,K.useState)(s),[d,f]=(0,K.useState)(c),[p,m]=(0,K.useState)(o),[h,g]=(0,K.useState)(i),[_,v]=(0,K.useState)(!i),y=(0,K.useRef)(null),b=d.currentPage??p.page,x=(d.mode??`table`)===`infinite`,S=(0,K.useCallback)(async(e,t=!1)=>{if(n){g(!0);try{let i=await Gt(gd(n,e),{ref:r}),a=ed(i.query),o=Zu(i.data);u(e=>t?[...e,...o]:o),f($u(i.pagination)),m(a),v(!0)}finally{g(!1)}}},[n,r]);function C(e){S({...p,page:1,sorts:kd(p.sorts,e)})}function w(e){S({...p,page:1,sorts:p.sorts.filter(t=>t.key!==e.key)})}function T(e){let t={...p,filters:e,page:1};m(t),S(t)}function E(e){T([...p.filters,e])}function D(e,t){T(p.filters.map((n,r)=>r===e?t:n))}function O(e){T(p.filters.filter((t,n)=>n!==e))}function k(e,t){T([...p.filters.filter(t=>t.field!==e),...t])}function A(e,t){let n={...p.tableFilters};ud(t)||!fd(t)?delete n[e]:n[e]=t;let r={...p,tableFilters:n,tableFilterIndicators:p.tableFilterIndicators.filter(t=>t.filter!==e),page:1};m(r),S(r)}function j(){let e={...p,filters:[],tableFilters:{},tableFilterIndicators:[],search:``,page:1};m(e),S(e)}function M(e){let t={...p,search:e,page:1};m(t),S(t)}let N=(0,K.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 Wt(`${a.pathname}${a.search}`,{ref:r,signal:i,throwOnError:!1});return o.ok?(await o.json()).options??[]:[]},[n,r]);function P(e){S({...p,page:e})}function F(e){let t=c.mode??`table`,n={...p,perPage:e===`infinite`?p.perPage:e,mode:e===`infinite`?`infinite`:t===`infinite`?`table`:null,page:1};m(n),S(n)}let I=(0,K.useCallback)(()=>{h||!d.hasMore||S({...p,page:d.nextPage??b+1},!0)},[b,S,d.hasMore,d.nextPage,h,p]);return(0,K.useEffect)(()=>{u(s),f(c),m(o),g(i),v(!i)},[s,c,o,i]),(0,K.useEffect)(()=>{!i||_||S(p)},[_,i,S,p]),Sn(a.reloadComponent,t=>{t.detail?.component===e.id&&S(p)}),(0,K.useEffect)(()=>{if(!x||!d.hasMore||h||!y.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&I()},{rootMargin:`240px`});return e.observe(y.current),()=>e.disconnect()},[x,I,d.hasMore,h]),{columns:t,rows:l,pagination:d,query:p,filters:p.filters,tableFilters:p.tableFilters,search:p.search,addFilter:E,updateFilter:D,removeFilter:O,replaceColumnFilters:k,setTableFilter:A,resetFilters:j,setSearch:M,searchFilterOptions:N,processing:h,hasLoaded:_,infiniteLoaderRef:y,sort:C,clearSort:w,goToPage:P,setPerPage:F,loadMore:I}}function Fd(e){let[t,n]=(0,K.useState)(()=>new Set),[r,i]=(0,K.useState)(!1),a=e.join(` `);(0,K.useEffect)(()=>{n(new Set),i(!1)},[a]);let o=(0,K.useCallback)(e=>{i(!1),n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,K.useCallback)(()=>{i(!1),n(t=>t.size===e.length?new Set:new Set(e))},[e]),c=(0,K.useCallback)(()=>i(!0),[]),l=(0,K.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 Id({actions:e,selectedKeys:t,allMatching:n,total:r,query:i,canSelectAllMatching:a,onSelectAllMatching:o,onCompleted:s}){let{t:c}=E(`lattice`),[l,u]=(0,K.useState)(!1),d=b(),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),g=()=>n?{allMatching:!0,...i}:{selected:t};async function _(e){u(!0);let t=await da(()=>Wt(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,J.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,J.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,J.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,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>(0,J.jsxs)(G,{type:`button`,"data-test":P(`bulk-action`,e.id),variant:e.variant,emphasis:e.emphasis,disabled:l,onClick:()=>v(e),children:[l&&(0,J.jsx)(la,{}),e.label]},e.id))}),f?.confirmation&&(0,J.jsx)(ua,{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,J.jsx)(Fa,{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 Ld({className:e,density:t,children:n,ref:r,...i}){return(0,J.jsx)(`select`,{ref:r,"data-slot":`native-select`,className:L(bt({density:t}),`cursor-pointer`,e),...i,children:n})}function Rd(e){return e===!0||e===1||e===`1`||e===`true`}function zd({filter:e,value:t,processing:n,bare:r=!1,onChange:i,onSearch:a}){let{t:o}=E(`lattice`),s=e.schema??[];return s.length===0?(0,J.jsx)(Hd,{filter:e,value:t,processing:n,onChange:i}):(0,J.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(Bd,{filter:e,schema:s,value:t,processing:n,bare:r,onChange:i,onSearch:a})}),dd(t)&&(0,J.jsx)(at,{size:`md`,icon:`x`,label:o(`table.filter.clear`,`Clear {{label}} filter`,{label:e.props.label??``}),disabled:n,onClick:()=>i(void 0)})]})}function Bd({filter:e,schema:t,value:n,processing:r,bare:i,onChange:a,onSearch:o}){let s=(0,K.useMemo)(()=>pd(n),[n]),c=(0,K.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,J.jsx)(`div`,{"aria-disabled":r,className:L(`grid gap-3`,r&&`pointer-events-none opacity-60`),children:(0,J.jsx)(Y,{nodes:t})});return(0,J.jsx)(me,{value:c,children:(0,J.jsx)(De,{value:{markUserEdit:()=>{}},children:(0,J.jsx)(ma,{nodes:{},children:(0,J.jsx)(lt,{initial:s,children:(0,J.jsx)(Vd,{onChange:a,children:i?(0,J.jsx)(Ve,{children:l}):l})})})})})}function Vd({children:e,onChange:t}){let n=Fe(),r=we(),i=(0,K.useRef)(n);i.current=n;let a=(0,K.useCallback)((e,n)=>{let a=typeof n==`function`?n(pe(i.current,e)):n,o=he(i.current,e,a);i.current=o,r(e,a),t(o)},[t,r]),o=(0,K.useMemo)(()=>({blur:()=>{},change:a,commit:a}),[a]);return(0,J.jsx)(Be,{value:o,children:e})}function Hd({filter:e,value:t,processing:n,onChange:r}){let i=Rd(pd(t).value);return(0,J.jsxs)(`label`,{className:`flex h-lt-control-md cursor-pointer items-center gap-2 text-sm`,children:[(0,J.jsx)(gc,{"aria-label":e.props.label??void 0,"data-test":`table-filter-${e.key}`,checked:i,disabled:n,onCheckedChange:e=>r(e===!0?{value:`1`}:void 0)}),(0,J.jsx)(`span`,{children:e.props.label})]})}function Ud({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}=E(`lattice`),[d,f]=(0,K.useState)(n),p=o??u(`table.filter.filter-by`,`Filter {{label}}`,{label:t}),m=a?`rounded-r-none`:``;return(0,K.useEffect)(()=>{f(n)},[n]),e===`boolean`?(0,J.jsxs)(Ld,{density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:n,onChange:e=>c(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:u(`table.filter.all`,`All`)}),(0,J.jsx)(`option`,{value:`true`,children:u(`table.filter.true`,`True`)}),(0,J.jsx)(`option`,{value:`false`,children:u(`table.filter.false`,`False`)})]}):e===`date`?(0,J.jsx)(mt,{type:`date`,density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:d,onChange:e=>{f(e.target.value),c(e.target.value)}}):(0,J.jsxs)(`div`,{className:`relative flex w-full min-w-0 items-center`,children:[i&&(0,J.jsx)(B,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2 size-lt-icon-md text-lt-muted-fg`}),(0,J.jsx)(mt,{type:e===`number`?`number`:`text`,density:`compact`,"aria-label":p,"data-test":s,className:L(m,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,J.jsx)(at,{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 Wd({column:e,clauses:t,processing:n,onAdd:r,onUpdate:i,onRemove:a,onReplace:o,onSearch:s}){let{t:c}=E(`lattice`),{filter:l,label:u}=e.props,d=u??e.key;if(!l)return null;if(l.control===`filter.select`)return(0,J.jsx)(Kd,{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,J.jsxs)(`div`,{className:`flex min-w-0 max-w-80 items-stretch`,children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(Ud,{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,J.jsxs)(Oe,{children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(at,{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,J.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,J.jsx)(V,{align:`start`,className:`w-80 p-4`,children:(0,J.jsx)(Xd,{column:e,clauses:t,operators:p,defaultOperator:m,processing:n,onAdd:r,onUpdate:i,onRemove:a})})]})]})}function Gd(e){return Array.isArray(e)?e.join(`,`):typeof e==`string`?e:``}function Kd({column:e,clauses:t,processing:n,onReplace:r,onSearch:i}){let{filter:a,label:o}=e.props;if(!a)return null;let s=a.multiple,c=a.defaultOperator,l=a.clauseOptions??[],u=Jd(t.map(e=>e.clause),l),d=t.find(e=>e.clause.operator===c)??t[0],f=u?u.value:s?d?.clause.value?d.clause.value.split(`,`):[]:d?.clause.value??``,p={key:e.key,type:`filter.select`,props:{label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null},schema:[{type:`field.select`,key:e.key,props:{name:`value`,label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null}}]};function m(t){let n=Gd(pd(t).value);if(n===``){r(e.key,[]);return}let i=l.find(e=>e.value===n);if(i){r(e.key,qd(e.key,i));return}r(e.key,[{field:e.key,operator:c,value:n}])}return(0,J.jsx)(zd,{filter:p,value:{value:f},processing:n,bare:!0,onChange:m,onSearch:i?(e,t,n)=>i(t,n):void 0})}function qd(e,t){return t.clauses.map(t=>({field:e,operator:t.operator,value:t.value}))}function Jd(e,t){return t.find(t=>Yd(e,qd(``,t)))}function Yd(e,t){return e.length===t.length&&t.every(t=>e.some(e=>e.operator===t.operator&&e.value===t.value))}function Xd({column:e,clauses:t,operators:n,defaultOperator:r,processing:i,onAdd:a,onUpdate:o,onRemove:s}){let{t:c}=E(`lattice`),l=e.props.filter?.type??`text`,[u,d]=(0,K.useState)(r),[f,p]=(0,K.useState)(t.length===0);return(0,J.jsxs)(`div`,{className:`grid gap-3`,children:[t.map(t=>(0,J.jsx)(Zd,{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,J.jsx)(Zd,{column:e,type:l,operators:n,clause:{field:e.key,operator:u,value:``},processing:i,onOperator:t=>{if(Ed.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,J.jsx)(`div`,{className:`border-t border-lt-border pt-3`,children:(0,J.jsx)(G,{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 Zd({column:e,type:t,operators:n,clause:r,processing:i,onOperator:a,onValue:o,onRemove:s}){let{t:c}=E(`lattice`),l=e.props.label??e.key,u=Ed.has(r.operator);return(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.length>1?(0,J.jsx)(Ld,{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,J.jsx)(`option`,{value:e,children:Dd(e)},e))}):(0,J.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:Dd(r.operator)}),(0,J.jsx)(G,{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,J.jsx)(Ud,{type:t,label:l,ariaLabel:c(`table.filter.value`,`{{label}} filter value`,{label:l}),value:r.value,processing:i,onCommit:o,onClear:()=>o(``)})]})}function Qd({sort:e}){return e?.direction===`asc`?(0,J.jsx)(B,{name:`arrow-up`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):e?.direction===`desc`?(0,J.jsx)(B,{name:`arrow-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):(0,J.jsx)(B,{name:`chevrons-up-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0 opacity-50`})}function $d({column:e,processing:t,resizeHandleProps:n,sort:r,query:i}){let a=md(i,e),{t:o}=E(`lattice`),{align:s,label:c,sortable:l}=e.props;return(0,J.jsxs)(`div`,{"aria-sort":hd(a),className:L(`relative min-w-0 px-4 py-3 pr-5 align-middle font-semibold text-lt-fg`,Gu(s)),role:`columnheader`,children:[l?(0,J.jsxs)(`button`,{type:`button`,"aria-label":o(`table.sort.column`,`Sort {{label}}`,{label:c}),className:L(`flex w-full items-center gap-1.5 font-semibold`,Ku(s)),"data-test":`sort-${e.key}`,disabled:t,onClick:()=>r(e),children:[(0,J.jsx)(`span`,{className:L(`min-w-0 flex-1 truncate`,Gu(s)),children:c}),(0,J.jsx)(Qd,{sort:a})]}):(0,J.jsx)(`span`,{className:L(`block truncate`,Gu(s)),children:c}),n&&(0,J.jsx)(`div`,{...n})]})}function ef({columns:e,hasHidden:t,isVisible:n,onReset:r,onToggle:i,processing:a,visibleColumnCount:o}){let{t:s}=E(`lattice`),c=s(`table.columns.label`,`Columns`);return(0,J.jsxs)(Oe,{children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(at,{size:`sm`,icon:`columns-3`,label:c,"data-test":`table-columns-menu`,disabled:a})}),(0,J.jsx)(V,{align:`end`,className:`w-64 p-4`,children:(0,J.jsxs)(`div`,{className:`grid gap-3`,children:[e.map(e=>{let t=n(e),r=t&&o<=1;return(0,J.jsxs)(`label`,{className:`flex items-center gap-2 text-base text-lt-fg`,children:[(0,J.jsx)(gc,{"data-test":`table-column-toggle-${e.key}`,checked:t,disabled:r,onCheckedChange:t=>i(e.key,t===!0)}),(0,J.jsx)(`span`,{children:e.props.label??e.key})]},e.key)}),t&&(0,J.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 tf({clauses:e,columnsByKey:t,indicators:n,processing:r,onRemoveClause:i,onChange:a,onReset:o}){let{t:s}=E(`lattice`);return e.length===0&&n.length===0?null:(0,J.jsx)(`div`,{className:`border-b border-lt-border px-4 py-3`,children:(0,J.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=Ed.has(e.operator);return(0,J.jsx)(nf,{label:`${a} ${Dd(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,J.jsx)(nf,{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,J.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 nf({label:e,value:t,removeTestId:n,removeLabel:r,processing:i,onRemove:a}){return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lt-sm bg-lt-muted px-2 py-1`,children:[(0,J.jsx)(`span`,{children:t===``?(0,J.jsx)(`span`,{className:`font-semibold`,children:e}):(0,J.jsxs)(J.Fragment,{children:[`${e}: `,(0,J.jsx)(`span`,{className:`font-semibold`,children:t})]})}),(0,J.jsx)(at,{size:`xs`,icon:`x`,label:r,"data-test":n,disabled:i,onClick:a})]})}function rf({filters:e,values:t,processing:n,onChange:r,onSearch:i}){let{t:a}=E(`lattice`),o=e.filter(e=>dd(t[e.key])),s=a(`table.filter.filters`,`Filters`);return(0,J.jsxs)(Oe,{children:[(0,J.jsx)(H,{asChild:!0,children:(0,J.jsx)(at,{size:`sm`,icon:`filter`,label:s,"data-test":`table-filters-menu`,disabled:n,children:o.length>0&&(0,J.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,J.jsx)(V,{align:`end`,className:`w-80 p-4`,children:(0,J.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,J.jsx)(`div`,{className:`grid gap-1`,children:(0,J.jsx)(zd,{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 af({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}=E(`lattice`);return(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.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,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.per-page`,`Rows per page`)}),(0,J.jsx)(Ld,{"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,J.jsx)(`option`,{value:String(e),children:e===`infinite`?f(`table.pagination.infinite`,`Infinite`):e},String(e)))})]})]}),r===`infinite`?(0,J.jsx)(`div`,{ref:o,className:`flex items-center gap-2`,children:e.hasMore?(0,J.jsx)(G,{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,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.all-loaded`,`All rows loaded`)})}):r===`simple`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):r===`table`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),a.map(e=>(0,J.jsx)(G,{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,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):null]})}function of({columnsByKey:e,query:t,processing:n,onClear:r}){let{t:i}=E(`lattice`);return(0,J.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,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`${a+1}. ${o}`}),(0,J.jsx)(B,{name:s,role:`img`,"aria-hidden":!1,"aria-label":Od(t.direction),className:`size-lt-icon-sm text-lt-muted-fg`}),(0,J.jsx)(at,{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 sf=300;function cf({value:e,onSearch:t}){let{t:n}=E(`lattice`),[r,i]=(0,K.useState)(e),a=(0,K.useRef)(e);(0,K.useEffect)(()=>{e!==a.current&&(a.current=e,i(e))},[e]);function o(e){a.current=e,t(e)}let s=Aa(o,sf);function c(e){i(e),s(e)}function l(){s.cancel(),i(``),o(``)}let u=n(`table.search.placeholder`,`Search`);return(0,J.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,J.jsx)(B,{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,J.jsx)(mt,{type:`search`,"data-test":`table-search`,value:r,placeholder:u,"aria-label":u,onChange:e=>c(e.target.value),className:L(`px-8`,`[&::-webkit-search-cancel-button]:hidden`)}),r!==``&&(0,J.jsx)(at,{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})]})}function lf(e){return e}function uf(e,t,n){if(e==null)return``;let r=t?.props?.date;return r?A(e,r,n):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function df(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 ff=({column:e,props:t,value:n})=>{let r=uf(n,e);return r===``?null:(0,J.jsx)(fo,{color:t.colors?.[String(n)],children:r})},pf=({value:e})=>{let{t}=E(`lattice`),n=Rd(e);return(0,J.jsx)(`span`,{"aria-label":n?t(`common.yes`,`Yes`):t(`common.no`,`No`),role:`img`,children:(0,J.jsx)(B,{name:n?`check`:`x`,className:L(`size-lt-icon-md`,n?`text-lt-success`:`text-lt-muted-fg`)})})},mf=({props:e,value:t})=>{let n=e.icons?.[String(t)]??e.icon??void 0;if(!n)return null;let r=Et(e.colors?.[String(t)]),i=r?Tt(r):void 0;return(0,J.jsx)(`span`,{"aria-label":String(t),className:L(`lt-cell-icon`,i?.className),style:i?.style,children:(0,J.jsx)(I,{className:`size-lt-icon-md`,icon:n})})},hf=({column:e,props:t,value:n})=>{let r=typeof n==`string`?n:``;if(r===``)return null;let i=t.size??32;return(0,J.jsx)(Po,{alt:e.props.label??``,className:L(`object-cover`,t.circular?`rounded-full`:`rounded-lt-sm`),height:i,previewable:t.previewable,src:r,testId:`preview-${e.key}`,width:i})};function gf({children:e,column:t,copyable:n,value:r}){return n?(0,J.jsx)(Ao,{value:r,label:t.props.label??t.key,testId:`copy-${t.key}`,children:e}):e}function _f({column:e,copyable:t,format:r,value:i}){let{locale:a}=n();return wt(i)===null?(0,J.jsx)(`span`,{children:uf(i,e)}):(0,J.jsx)(gf,{column:e,copyable:t,value:String(i),children:(0,J.jsx)(`span`,{className:`tabular-nums`,children:Dt(i,r,a)})})}var vf=({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,J.jsx)(_f,{column:e,copyable:t.copyable,value:r,format:{kind:`number`,notation:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:a,unit:null}})},yf=({column:e,props:t,value:n})=>(0,J.jsx)(_f,{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}}),bf=({column:e,row:t})=>(0,J.jsx)(`div`,{className:`grid gap-1`,children:(0,J.jsx)(Y,{nodes:S(e.schema,t)})}),xf=e=>e.props.multiple?(0,J.jsx)(Cf,{...e}):e.props.badge?(0,J.jsx)(wf,{...e}):(0,J.jsx)(Tf,{...e});function Sf({label:e,color:t}){return e===``?null:(0,J.jsx)(fo,{color:t,children:e})}function Cf({column:e,props:t,value:n}){let r=Array.isArray(n)?n:[];return r.length===0?null:t.badge?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map((t,n)=>{let r=t;return(0,J.jsx)(Sf,{label:uf(r.value,e),color:r.color},n)})}):(0,J.jsx)(`span`,{children:r.map(t=>uf(t,e)).join(`, `)})}function wf({column:e,props:t,row:n,value:r}){let i=t.badge.colorKey;return(0,J.jsx)(Sf,{label:uf(r,e),color:String(n[i]??``)})}function Tf({column:e,props:t,row:n,value:r}){let i=e.props.date,a=df(e,n,r),o=uf(r,e),s=a?(0,J.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,J.jsx)(qr,{value:r,dateStyle:i.dateStyle,timeStyle:i.timeStyle}):(0,J.jsx)(gf,{column:e,copyable:t.copyable,value:o,children:s})}var Ef={"column.badge":lf(ff),"column.boolean":lf(pf),"column.icon":lf(mf),"column.image":lf(hf),"column.money":lf(vf),"column.number":lf(yf),"column.stack":lf(bf),"column.text":lf(xf)};function Df({column:e,row:t}){let n=g()[e.type]??Ef[e.type]??Ef[`column.text`];return(0,J.jsx)(n,{column:e,props:e.props,row:t,value:t[e.key]})}var Of=bn(fs,Wa,_u,vi,yn({components:{table:q(({node:e})=>{let{t}=E(`lattice`),{columns:n,rows:r,pagination:i,query:a,filters:o,tableFilters:s,search:c,addFilter:l,updateFilter:u,removeFilter:d,replaceColumnFilters:f,setTableFilter:p,resetFilters:m,setSearch:h,searchFilterOptions:g,processing:_,hasLoaded:v,infiniteLoaderRef:y,sort:b,clearSort:x,goToPage:S,setPerPage:C,loadMore:w}=Pd(e),T=(0,K.useMemo)(()=>Ju(e.props?.bulkActions),[e.props?.bulkActions]),D=T.length>0,O=(0,K.useMemo)(()=>r.map((e,t)=>({row:e,actions:sd(e),detail:cd(e),key:od(e,t)})),[r]),k=Fd(O.map(e=>e.key)),{isExpanded:A,toggle:j}=Vu(),M=O.some(e=>e.detail!=null),N=(0,K.useMemo)(()=>new Map(n.map(e=>[e.key,e])),[n]),P=F(e),{hasToggleableColumns:I,hasHidden:R,isVisible:ee,resetVisibility:te,setColumnVisible:ne,toggleableColumns:re,visibleColumns:z}=Lu({columns:n,storageKey:P?`lattice:table-column-visibility:${P}`:void 0}),ie=i.currentPage??a.page,ae=i.lastPage??ie,oe=i.mode??`table`,se=(0,K.useMemo)(()=>rd(e.props?.perPageOptions),[e.props?.perPageOptions]),ce=Ad(ie,ae),le=i.hasMore??ie<ae,ue=O.some(e=>e.actions.length>0),de=e.props?.striped===!0,fe=z.some(e=>e.props.filter!=null),pe=o.map((e,t)=>({clause:e,index:t})),V=(0,K.useMemo)(()=>Array.isArray(e.props?.filters)?e.props.filters:[],[e.props?.filters]),me=V.length>0,he=ue||me||I,ge=(0,K.useMemo)(()=>jd(z),[z]),H=(0,K.useMemo)(()=>Nd(he,D,M),[he,D,M]),_e=e.props?.resizableColumns===!0,ve=F(e),{getResizeHandleProps:ye,gridTemplateColumns:be,hasOverrides:xe,resizeRootRef:Se,resetColumns:Ce}=As({columns:ge,enabled:_e,leadingTracks:H.leadingTracks,showIndicator:e.props?.resizeIndicator===!0,storageKey:_e&&ve?`lattice:table-columns:${ve}`:void 0,trailingTracks:H.trailingTracks});return(0,J.jsxs)(`div`,{"data-slot":`table`,"data-lattice-component":e.id,className:`relative`,children:[xe&&(0,J.jsx)(`button`,{"aria-label":t(`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:Ce,title:t(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,J.jsx)(B,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,J.jsxs)(`div`,{"data-slot":`table-scroll`,className:`overflow-x-auto rounded-lt-sm border border-lt-border`,children:[e.props?.searchable&&(0,J.jsx)(`div`,{"data-slot":`table-toolbar`,className:`flex items-center gap-2 border-b border-lt-border px-4 py-2`,children:(0,J.jsx)(cf,{value:c,onSearch:h})}),(0,J.jsx)(tf,{clauses:o,columnsByKey:N,indicators:a.tableFilterIndicators,processing:_,onRemoveClause:d,onChange:p,onReset:m}),D&&k.active&&(0,J.jsx)(Id,{actions:T,selectedKeys:k.selectedKeys,allMatching:k.allMatching,total:i.total??void 0,query:Sd(a),canSelectAllMatching:k.allVisibleSelected&&!k.allMatching&&i.total!=null&&i.total>k.selectedKeys.length,onSelectAllMatching:k.selectAllMatching,onCompleted:k.clear}),a.sorts.length>0&&(0,J.jsx)(of,{columnsByKey:N,query:a,processing:_,onClear:x}),(0,J.jsxs)(`div`,{ref:Se,className:`min-w-full text-base`,role:`table`,style:{"--lattice-table-columns":be},children:[(0,J.jsxs)(`div`,{"data-slot":`table-header`,className:`border-b border-lt-border bg-lt-muted/50`,role:`rowgroup`,children:[(0,J.jsxs)(`div`,{className:`hidden min-w-full md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[M&&(0,J.jsx)(`div`,{className:`px-2 py-3`,role:`columnheader`,"aria-hidden":`true`}),D&&(0,J.jsx)(`div`,{className:`flex items-center px-4 py-3`,role:`columnheader`,children:(0,J.jsx)(gc,{"aria-label":t(`table.select-all-rows`,`Select all rows`),"data-test":`select-all`,checked:k.allSelected,onCheckedChange:()=>k.toggleAll()})}),z.map((e,t)=>(0,J.jsx)($d,{column:e,processing:_,resizeHandleProps:_e?ye(ge[t]):void 0,sort:b,query:a},e.key)),he&&(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2 align-middle font-semibold text-lt-fg`,role:`columnheader`,children:[me&&(0,J.jsx)(rf,{filters:V,values:s,processing:_,onChange:p,onSearch:g}),I&&(0,J.jsx)(ef,{columns:re,isVisible:ee,visibleColumnCount:z.length,hasHidden:R,onToggle:ne,onReset:te,processing:_}),ue&&(0,J.jsx)(`span`,{className:`sr-only`,children:e.props?.actionsLabel??t(`table.actions`,`Actions`)})]})]}),fe&&(0,J.jsxs)(`div`,{className:`hidden min-w-full border-t border-lt-border md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[M&&(0,J.jsx)(`div`,{className:`px-2 py-2`,role:`cell`}),D&&(0,J.jsx)(`div`,{className:`px-4 py-2`,role:`cell`}),z.map(e=>(0,J.jsx)(`div`,{className:`min-w-0 px-2 py-2`,role:`cell`,children:e.props.filter!=null&&(0,J.jsx)(Wd,{column:e,clauses:pe.filter(t=>t.clause.field===e.key),processing:_,onAdd:l,onUpdate:u,onRemove:d,onReplace:f,onSearch:(t,n)=>g(`column:${e.key}`,t,n)})},e.key)),he&&(0,J.jsx)(`div`,{className:`px-4 py-2`,role:`cell`})]})]}),(0,J.jsx)(`div`,{role:`rowgroup`,children:v?O.length===0?(0,J.jsx)(`div`,{"data-slot":`table-empty`,className:`p-8 text-center text-lt-muted-fg`,role:`row`,children:(0,J.jsx)(`div`,{role:`cell`,children:e.props?.emptyLabel??t(`table.empty`,`No results`)})}):O.map(({row:n,actions:r,detail:i,key:a})=>{let o=i!=null&&A(a),s=`${F(e)??`table`}-row-detail-${a}`;return(0,J.jsxs)(K.Fragment,{children:[(0,J.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:[M&&(0,J.jsx)(`div`,{className:`flex items-center px-2 py-lt-cell-y`,role:`cell`,children:i&&(0,J.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:()=>j(a),children:(0,J.jsx)(B,{name:`chevron-down`,"aria-hidden":`true`,className:L(`size-lt-icon-md transition-transform`,!o&&`-rotate-90`)})})}),D&&(0,J.jsx)(`div`,{className:`flex items-center px-lt-cell-x py-lt-cell-y`,role:`cell`,children:(0,J.jsx)(gc,{"aria-label":t(`table.select-row`,`Select row {{key}}`,{key:a}),"data-test":`select-row-${a}`,checked:k.isSelected(a),onCheckedChange:()=>k.toggle(a)})}),z.map(e=>(0,J.jsxs)(`div`,{"data-slot":`table-cell`,className:L(`grid min-w-0 gap-1 overflow-hidden px-lt-cell-x py-lt-cell-y align-middle`,Gu(e.props.align),qu(e.props.align)),role:`cell`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium text-lt-muted-fg md:hidden`,children:e.props.label}),(0,J.jsx)(`div`,{"data-slot":`table-cell-content`,className:`min-w-0 max-w-full overflow-hidden truncate`,children:(0,J.jsx)(Df,{column:e,row:n})})]},e.key)),he&&(0,J.jsx)(`div`,{className:L(`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,J.jsx)(An,{node:e},e.key??e.id??t))})]}),o&&i&&(0,J.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,J.jsx)(Y,{nodes:[i]})})]},a)}):(0,J.jsx)(`div`,{className:`p-4 text-lt-muted-fg`,role:`row`,children:(0,J.jsx)(`div`,{role:`cell`,children:t(`table.loading`,`Loading rows...`)})})})]}),v&&(0,J.jsx)(af,{pagination:i,currentPage:ie,processing:_,mode:oe,hasNextPage:le,visiblePages:ce,infiniteLoaderRef:y,perPageOptions:se,perPageValue:oe===`infinite`?`infinite`:a.perPage,onPerPage:C,onPage:S,onLoadMore:w})]})]})})},name:`lattice/table`}),oo,Nu,Iu);function kf(e,t){if(t.length===0)return e;let n=new Set([...e.namespaces??[`lattice`],...t.map(e=>e.namespace)]);return{...e,namespaces:[...n]}}function Af({ready:e,children:t}){let[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let t=!0,n=()=>{t&&r(!0)};return e.then(n,n),()=>{t=!1}},[e]),n?t:null}function jf({registry:e,plugins:t,sprite:n,pages:r={},defaultLayout:i,strictMode:a=!0,i18n:o,boot:s,wrap:l,...d}={}){let f=e??Of,p=t&&t.length>0?xn(f,...t):f;c(p),Oi();let m=o!==!1,h=t?.flatMap(e=>e.i18n?[e.i18n]:[])??[],g=m?kf(o??{},h):{},_=d.defaults?.visitOptions,v=m?{...d.defaults,visitOptions:(e,t)=>Ei(e,_?.(e,t)??t)}:d.defaults,y=u({...d,defaults:v,strictMode:a,resolve:wi(r),layout:Ti({defaultLayout:i}),withApp:(e,{ssr:t,page:r})=>{let i=[],a=r.props.lattice,o=!1;if(C(a)&&cn(a.appearance),!t){o=document.getElementById(d.id??`app`)?.hasAttribute(`data-server-rendered`)===!0,C(a)&&C(a.urls)&&typeof a.urls.refreshRef==`string`&&Vt(a.urls.refreshRef),m&&j(r.props)!==void 0&&i.push(nn(()=>import(`./chunks/page-props-BHNNVkgJ.js`).then(e=>e.configureI18nFromPageProps(r.props,g)),__vite__mapDeps([20,4,1,5,6,21,10]),import.meta.url));let e=s?.({page:r});e&&i.push(e)}let c=(0,J.jsxs)(J.Fragment,{children:[e,m?(0,J.jsx)(Cn,{}):null]}),u=(0,J.jsx)(Ua,{registry:p,sprite:n,children:l?l(c):c});return i.length===0?u:o?(T(Promise.all(i)),u):(0,J.jsx)(Af,{ready:Promise.all(i),children:u})}});return vn(),y}function Mf(){return console.warn(`[lattice] The data-lattice-config script holds invalid JSON; booting with defaults.`),{}}function Nf(e){let t=e.querySelector(`script[data-lattice-config]`);if(!t?.textContent)return{};try{let e=JSON.parse(t.textContent);return typeof e!=`object`||!e||Array.isArray(e)?Mf():e}catch{return Mf()}}var Pf=Nf(document);async function Ff(){if(Pf.refreshRefUrl&&Vt(Pf.refreshRefUrl),Pf.echo)try{let{configureEcho:e}=await nn(async()=>{let{configureEcho:e}=await import(`./chunks/dist-DqlcM-vw.js`);return{configureEcho:e}},__vite__mapDeps([8,1]),import.meta.url);e(Pf.echo)}catch(e){console.warn(`[lattice] Failed to load the realtime chunk; continuing without Echo.`,e)}jf({...Pf.spriteUrl?{sprite:{href:Pf.spriteUrl}}:{},defaults:{visitOptions:Ei}})}Ff();
|
|
22
|
+
}`,Jl=`^\\d+$`;function Yl({char:e,hasFakeCaret:t,isActive:n}){return(0,q.jsxs)(`div`,{className:L(`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,q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,q.jsx)(`div`,{className:`bg-lt-fg h-5 w-px animate-pulse`})}):null]})}function Xl({length:e,containerClassName:t,pattern:n=Jl,...r}){return(0,q.jsx)(Gl,{maxLength:e,pattern:n,containerClassName:L(`flex items-center gap-2 has-[:disabled]:opacity-50`,t),render:({slots:e})=>(0,q.jsx)(`div`,{className:`flex items-center`,children:e.map((e,t)=>(0,q.jsx)(Yl,{...e},t))}),...r})}var Zl=({node:e})=>{let t=e.props;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,q.jsx)(Xl,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a||i,id:e,length:t.length,name:e,onChange:e=>o(e),value:r})})};function Ql({className:e,ref:t,...n}){let[r,i]=(0,G.useState)(!1);return(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(ht,{type:r?`text`:`password`,className:L(`pr-10`,e),ref:t,...n}),(0,q.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,q.jsx)(B,{name:`eye-off`,className:`size-lt-icon-md`}):(0,q.jsx)(B,{name:`eye`,className:`size-lt-icon-md`})})]})}var $l=({node:e})=>{let t=e.props,{errors:n}=De(),r=Cc(e),{commit:i}=Ne(),a=dt(),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,q.jsxs)(`div`,{className:`grid gap-6`,children:[(0,q.jsx)(Ue,{error:r.error,helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,labelAction:t.labelAction??void 0,name:r.name,required:r.required,children:(0,q.jsx)(Tl,{prefix:t.prefix,suffix:t.suffix,children:e=>(0,q.jsx)(Ql,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:e,"data-test":r.testId,disabled:r.disabled,id:r.name,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,q.jsx)(Ue,{error:n[l],label:o.label??`Confirm password`,name:c,required:r.required,children:(0,q.jsx)(Ql,{autoComplete:`new-password`,"data-test":M(s),disabled:r.disabled,id:c,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})})]})},eu=[],tu=({node:e})=>{let t=e.props,n=t.name,{errors:r}=De(),{hidden:i,required:a}=Xe(e),{path:o,rows:s,onField:c,onRemove:l,onMove:u,onDuplicate:d,append:f}=Qs(n,t.defaultItems??1),p=e.schema??eu,m=Zs(s.map(e=>String(e.rowId??``)).join(`,`)),h=t.maxItems!=null&&s.length>=t.maxItems,g=t.minItems!=null&&s.length<=t.minItems,_=t.layout===`table`,v=t.itemLabels,y=e=>{let n=v?.[e];return typeof n==`string`&&n!==``?n:t.itemLabel?`${t.itemLabel} ${e+1}`:`#${e+1}`};if(i)return null;let b=s.map((e,t)=>({key:String(e.rowId??t),index:t,row:e,template:p,span:!1,heading:y(t)}));return(0,q.jsx)(Ue,{error:r[o],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:o,required:a,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(Cs,{path:o,rows:s,rowKey:de}),_?(0,q.jsx)(Js,{base:o,columns:Ks(p),rows:b,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,q.jsx)(`div`,{ref:e=>m(r,e),"data-flip-key":r,children:(0,q.jsx)(Ts,{base:o,index:n,row:e,template:p,heading:y(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,q.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,q.jsx)(B,{name:`plus`}),t.addLabel??`Add`]})]})})},nu=250;function ru({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:p,searchPlaceholder:m,selected:h,showSearch:g=!0,testId:_,trigger:v,triggerClassName:y,triggerProps:b}){let{t:x}=E(`lattice`),[S,C]=(0,G.useState)(``);function w(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?C(``):k()}let T=d.some(e=>e.label.toLowerCase()===S.trim().toLowerCase()),D=Aa(e=>s?.(e),nu);(0,G.useEffect)(()=>{if(!(!s||!l))return D(S),()=>D.cancel()},[S,s,l,D]);let O=s?d:d.filter(e=>e.label.toLowerCase().includes(S.toLowerCase()));function k(){C(``),u(!1)}function A(e){c(e),i||k()}return(0,q.jsxs)(ke,{open:l,onOpenChange:e=>e?u(!0):k(),children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:y,...b,children:v})}),(0,q.jsxs)(V,{align:`start`,className:L(`w-[var(--radix-popover-trigger-width)] overflow-hidden p-0`,e),children:[g&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-lt-border px-3 py-2`,children:[(0,q.jsx)(`input`,{"aria-label":p??x(`form.search-options`,`Search options`),"data-slot":`combobox-search`,"data-test":_?`${_}-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(`,`)){w(n);return}C(n)},onKeyDown:e=>{t&&e.key===`Enter`&&S.trim()!==``&&(e.preventDefault(),w(S))},placeholder:m,value:S}),r&&(0,q.jsx)(B,{name:`loader-2`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0 animate-spin text-lt-muted-fg`})]}),(0,q.jsxs)(`div`,{className:`max-h-60 overflow-y-auto p-1`,role:`listbox`,children:[t&&S.trim()!==``&&!T&&(0,q.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":_?`${_}-create`:void 0,onClick:()=>w(S),type:`button`,children:[(0,q.jsx)(B,{name:`plus`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`}),x(`form.create-option`,`Create "{{label}}"`,{label:S.trim()})]}),O.length===0&&!(t&&S.trim()!==``&&!T)?(0,q.jsx)(`p`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:n}):O.map(e=>{let t=h.includes(e.value);return(0,q.jsxs)(`button`,{"aria-label":f?e.label:void 0,"aria-selected":t,className:L(`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":_?`${_}-option-${e.value}`:void 0,"data-value":e.value,onClick:()=>A(e.value),role:`option`,type:`button`,children:[f?(0,q.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:f(e)}):e.label,t&&(0,q.jsx)(B,{name:`check`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`})]},e.value)})]})]})]})}function iu(e,t){let n=e??t;return Array.isArray(n)?n.map(String):n==null||n===``?[]:[String(n)]}var au=({node:e})=>{let{t}=E(`lattice`),n=e.props,{action:r,componentRef:i,errors:a,fieldIdPrefix:o,searchOptions:s}=De(),{hidden:c,required:l,readOnly:u,disabled:d}=Xe(e),{change:f,blur:p}=Ne(),m=ha(e),h=n.name,g=dt(),_=bc(g?g.scopedName(h):h,o),v=g?g.errorKey(h):h,y=v,b=n.placeholder||`Select…`,x=n.multiple,C=n.searchable,w=n.creatable,T=(0,G.useMemo)(()=>m.props.options??[],[m.props]),D=m.props.optionSchema,O=pt(h),k=Ie(),A=(0,G.useRef)(k);A.current=k;let j=g?g.getValue(h):O,M=(0,G.useMemo)(()=>iu(j,n.value),[j,n.value]),N=(0,G.useRef)(M);N.current=M;let[P,F]=(0,G.useState)(!1),[I,R]=(0,G.useState)(null),[ee,te]=(0,G.useState)(!1),ne=(0,G.useRef)(null),re=(0,G.useMemo)(()=>{let e=new Map;for(let t of[...T,...I??[]])e.set(t.value,t);return e},[T,I]),z=e=>re.get(e)?.label??e,ie=e=>Dt(re.get(e)?.data?.color),ae=u||d,oe=(0,G.useCallback)(e=>{if(ne.current?.abort(),e.trim()===``){R(null),te(!1);return}let t=new AbortController;if(ne.current=t,te(!0),s){s(y,e,A.current,t.signal).then(e=>{R(e),te(!1)}).catch(()=>{});return}_a(r,i,{...A.current,_sub:`search`,_target:y,_q:e},t.signal).then(e=>{R(e?.options??[]),te(!1)}).catch(()=>{})},[r,i,y,s]);function se(e){f(h,x?e:e[0]??``)}function ce(e){if(x){let t=N.current.includes(e)?N.current.filter(t=>t!==e):[...N.current,e];N.current=t,se(t);return}N.current=[e],se([e])}function le(e){se(M.filter(t=>t!==e))}function ue(e){if(!x){N.current=[e],se([e]);return}if(!N.current.includes(e)){let t=[...N.current,e];N.current=t,se(t)}}if(c)return null;let de=C?I??T:T,fe=D?.length?e=>(0,q.jsx)(J,{nodes:S(D,{...e.data,label:e.label,value:e.value})}):void 0;return(0,q.jsxs)(Ue,{error:a[v],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:_,required:l,children:[x?M.map(e=>(0,q.jsx)(`input`,{name:`${_}[]`,type:`hidden`,value:e},e)):(0,q.jsx)(`input`,{name:_,type:`hidden`,value:M[0]??``}),(0,q.jsxs)(`div`,{children:[x&&M.length>0&&(0,q.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1`,children:M.map(e=>{let n=ie(e);return(0,q.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,q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full`,style:{background:wt(n)}}),z(e),!ae&&(0,q.jsx)(`button`,{"aria-label":t(`form.remove-option`,`Remove {{label}}`,{label:z(e)}),"data-test":`select-${h}-remove-${e}`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-xs`,onClick:()=>le(e),type:`button`,children:(0,q.jsx)(B,{name:`x`})})]},e)})}),(0,q.jsx)(ru,{creatable:w,emptyLabel:n.emptyLabel??void 0,loading:ee,multiple:x,onCommit:ue,onCreate:ue,onSearch:C?oe:void 0,onSelect:ce,open:P&&!ae,onOpenChange:e=>{F(e),e||p(h)},options:de,renderOption:fe,searchPlaceholder:n.searchPlaceholder??void 0,showSearch:!!(C||w),selected:M,testId:`select-${h}`,trigger:(0,q.jsxs)(q.Fragment,{children:[!x&&M.length>0?(0,q.jsx)(`span`,{children:z(M[0])}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:b}),(0,q.jsx)(B,{name:`chevrons-up-down`,className:`size-lt-icon-md shrink-0 text-lt-muted-fg`})]}),triggerClassName:L(xt(),`flex items-center justify-between gap-2 text-left`,ae&&`cursor-not-allowed opacity-60`),triggerProps:{"aria-haspopup":`listbox`,autoFocus:n.autoFocus??void 0,"data-test":`select-${h}`,disabled:ae,id:_,tabIndex:n.tabIndex??void 0}})]})]})};function ou({className:e,...t}){return(0,q.jsx)(`textarea`,{"data-slot":`textarea`,className:L(`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`,yt,`aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger`,e),...t})}var su=({node:e})=>{let t=e.props;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,q.jsx)(ou,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a,id:e,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})})},cu=({node:e})=>{let t=e.props;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,q.jsx)(Tl,{prefix:t.prefix,suffix:t.suffix,end:t.copyable?(0,q.jsx)(Mo,{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:s=>(0,q.jsx)(ht,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:s,"data-test":n,disabled:a,id:e,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,tabIndex:t.tabIndex??void 0,type:t.type??`text`,value:r})})})},lu=({node:e})=>{let t=e.props,n=gt(t.step),r=t.label??t.name;return(0,q.jsx)(ol,{node:e,label:t.label??``,children:({name:e,testId:i,value:a,readOnly:o,disabled:s,commit:c,blur:l})=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(ht,{"aria-label":r,autoFocus:t.autoFocus??!1,"data-test":i,disabled:s,id:e,name:e,onBlur:()=>{let e=bt(a);e&&c(vt(e,n)),l()},onChange:e=>c(e.target.value),readOnly:o,tabIndex:t.tabIndex??void 0,type:`text`,value:a}),(0,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":`Open ${r} time picker`,disabled:s||o,size:`icon`,type:`button`,variant:`secondary`,children:(0,q.jsx)(B,{name:`clock`,className:`size-lt-icon-md`,"aria-hidden":`true`})})}),(0,q.jsx)(V,{className:`p-2`,children:(0,q.jsx)(St,{value:bt(a),onChange:e=>c(vt(e,n)),step:t.step,min:t.min,max:t.max,disabled:s,readOnly:o,testId:`${i}-picker`})})]})]})})},uu=({node:e})=>{let{hidden:t,required:n,readOnly:r,disabled:i}=Xe(e),a=e.props,o=a.name,s=dt(),{errors:c,fieldIdPrefix:l}=De(),u=bc(s?s.scopedName(o):o,l),d=s?s.errorKey(o):o,f=pt(o),p=s?s.getValue(o):f,m=nt(a.value),h=p===void 0?m:nt(p),g=r||i,{commit:_}=Ne();return xc(o,m),t?null:(0,q.jsxs)(Ue,{error:c[d],helperText:a.helperText??void 0,tooltip:a.tooltip??void 0,label:a.label??``,name:u,required:n,children:[(0,q.jsx)(`input`,{disabled:g,name:u,type:`hidden`,value:h?`1`:`0`}),(0,q.jsx)(`button`,{"aria-checked":h,"aria-label":a.label??o,autoFocus:a.autoFocus??!1,className:L(`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":h?`checked`:`unchecked`,"data-test":M(o),disabled:g,id:u,name:u,onClick:()=>_(o,!h),role:`switch`,tabIndex:a.tabIndex??void 0,type:`button`,children:(0,q.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":h?`checked`:`unchecked`})})]})};function du(e){let t=[],n=e=>{let r=mt(e).name;if(r&&t.push(r),!(r&&we.has(e.type)))for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function fu(e){let t=[],n=e=>{let r=mt(e).name;if(r&&t.push(r,`${r}.*`),r&&we.has(e.type)){for(let n of du(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 pu(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=>Oa(t,e)))&&r.add(t)}),r}function mu(e,t){let n=pu(e,t);return n.size>0?Math.min(...n):null}var hu=(0,G.createContext)({activeName:``});function gu(e){let t=(e.schema??[]).filter(e=>e.type===`wizard-step`);return{items:t.map(e=>e.props),nodes:t}}var _u=({children:e,node:t})=>{let{t:n}=E(`lattice`),{errors:r,processing:i,touch:a,validateFields:o,validating:s}=De(),{items:c,nodes:l}=(0,G.useMemo)(()=>gu(t),[t]),u=(0,G.useMemo)(()=>l.map(e=>du(e)),[l]),d=t.props.orientation===`vertical`,[f,p]=(0,G.useState)(0),[m,h]=(0,G.useState)(()=>new Set([0])),[g,_]=(0,G.useState)(()=>new Set),v=(0,G.useMemo)(()=>pu(u,r),[u,r]),y=f===c.length-1,b=e=>{p(e),h(t=>new Set(t).add(e))},x=()=>{_(e=>new Set(e).add(f)),y||b(f+1)},S=()=>{let e=l[f],t=e?fu(e):[];if(t.length===0){x();return}a(t),o(t,{onSuccess:x})},C=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(C.current&&!i){let e=mu(u,r);e!==null&&e!==f&&b(e)}C.current=i},[i,r,u,f]);let w=(0,G.useMemo)(()=>({activeName:c[f]?.name??``}),[c,f]);return(0,q.jsx)(hu.Provider,{value:w,children:(0,q.jsxs)(`div`,{className:L(`gap-6`,d?`flex`:`grid`),"data-slot":`wizard`,children:[(0,q.jsx)(`ol`,{"aria-label":n(`form.wizard.steps`,`Steps`),className:L(`gap-1`,d?`flex w-56 shrink-0 flex-col`:`flex flex-wrap`),children:c.map((e,t)=>{let n=t===f,r=g.has(t),i=v.has(t);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{"aria-current":n?`step`:void 0,className:L(`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`,!m.has(t)&&`cursor-not-allowed opacity-60`),"data-error":i||void 0,"data-test":`wizard-rail-${e.name}`,disabled:!m.has(t),id:`wizard-step-${e.name}-trigger`,onClick:()=>b(t),type:`button`,children:[(0,q.jsx)(`span`,{className:L(`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,q.jsx)(B,{className:`size-lt-icon-sm`,name:`check`}):t+1}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block truncate`,children:e.label}),d&&e.description&&(0,q.jsx)(`span`,{className:`block truncate text-xs text-lt-muted-fg`,children:e.description})]})]})},e.name)})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-6`,children:[e,(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(W,{"data-test":`wizard-back`,disabled:f===0||i,onClick:()=>b(f-1),type:`button`,emphasis:`outline`,children:n(`form.wizard.back`,`Back`)}),y?(0,q.jsxs)(W,{"data-test":`wizard-finish`,disabled:i,type:`submit`,children:[i&&(0,q.jsx)(la,{}),n(`form.wizard.finish`,`Finish`)]}):(0,q.jsxs)(W,{"data-test":`wizard-next`,disabled:i||s,onClick:S,type:`button`,children:[s&&(0,q.jsx)(la,{}),n(`form.wizard.next`,`Next`)]})]})]})]})})},vu=({children:e,node:t})=>{let{activeName:n}=(0,G.useContext)(hu),r=t.props.name,i=n===r,[a,o]=(0,G.useState)(i);return(0,G.useEffect)(()=>{i&&o(!0)},[i]),(0,q.jsx)(`section`,{"aria-labelledby":`wizard-step-${r}-trigger`,className:L(`space-y-8`,!i&&`hidden`),hidden:!i,id:`wizard-step-${r}-panel`,children:a?e:null})},yu=(0,G.lazy)(()=>rn(()=>import(`./chunks/rich-editor-field-JM3jBEV1.js`),__vite__mapDeps([17,1,2,5,4,6,15,3,11,18,13]),import.meta.url)),bu=bn({components:{form:K(xl),"field.builder":K(ec),"field.checkbox":K(Sc),"field.choice":K(wc),"field.color-picker":K(sl),"field.date-input":K(ul),"field.date-time-input":K(dl),"field.file-upload":K(hl),"field.hidden-input":K(Cl),"field.number-input":K(El),"field.otp":K(Zl),"field.password-input":K($l),"field.repeater":K(tu),"field.rich-editor":K(({children:e,node:t})=>(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(yu,{node:t,children:e})})),"field.select":K(au),"field.textarea":K(su),"field.text-input":K(cu),"field.time-input":K(lu),"field.toggle":K(uu),wizard:K(_u),"wizard-step":K(vu)},name:`lattice/form`});function xu(e,t=1){return Kt(`${e}?page=${t}`)}function Su(e,t){return Kt(`${e}/${t}/read`,{method:`PATCH`})}function Cu(e){return Kt(`${e}/read-all`,{method:`POST`})}function wu(e,t){return Kt(`${e}/${t}`,{method:`DELETE`})}function Tu(e){return Kt(e,{method:`DELETE`})}function Eu(e,t){return e.some(e=>e.id===t.id)?e:[t,...e]}function Du(e,t){return e.map(e=>e.id===t?{...e,isRead:!0}:e)}function Ou(e,t){return e.filter(e=>e.id!==t)}function ku({endpoint:e,pollingInterval:t}){let[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(`loading`),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(1),p=(0,G.useRef)(c);p.current=c;let m=(0,G.useRef)(!1),h=(0,G.useCallback)(async()=>{try{let t=await xu(e,1);f.current=1,r(t.notifications),a(t.unreadCount),l(t.hasMore),s(`idle`)}catch{s(`error`)}},[e]);return(0,G.useEffect)(()=>{h()},[h]),(0,G.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,G.useCallback)(()=>{if(m.current||!p.current)return;m.current=!0;let t=f.current+1;xu(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,G.useCallback)(t=>{r(e=>Du(e,t)),a(e=>Math.max(0,e-1)),Su(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),markAllRead:(0,G.useCallback)(()=>{r(e=>e.map(e=>({...e,isRead:!0}))),a(0),Cu(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),dismiss:(0,G.useCallback)(t=>{r(e=>Ou(e,t)),wu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),clearAll:(0,G.useCallback)(()=>{r([]),a(0),Tu(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),receive:(0,G.useCallback)(e=>{r(t=>{let n=Eu(t,e);return n!==t&&a(e=>e+1),n})},[])}}function Au(){let{t:e}=E(`lattice`);return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-lt-muted-fg`,children:[(0,q.jsx)(B,{name:`bell`,className:`size-lt-icon-lg`}),(0,q.jsx)(`p`,{className:`text-sm`,children:e(`notifications.empty`,`No notifications yet`)})]})}var ju={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 Mu({notification:e,onMarkRead:t,onDismiss:n}){let{t:r}=E(`lattice`),i=ae(e.title,r),a=ae(e.body,r),o=(0,q.jsxs)(q.Fragment,{children:[i?(0,q.jsx)(`p`,{className:`truncate text-sm font-medium text-lt-fg`,children:i}):null,a?(0,q.jsx)(`p`,{className:`text-sm text-lt-muted-fg`,children:a}):null]});return(0,q.jsxs)(`li`,{className:L(`flex gap-3 px-3 py-3`,!e.isRead&&`bg-lt-muted/40`),"data-test":`notification`,children:[e.icon?(0,q.jsx)(I,{icon:e.icon,className:L(`mt-0.5 size-lt-icon-md`,e.variant?ju[e.variant]:void 0)}):null,(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e.href?(0,q.jsx)(x,{href:e.href,className:`block`,"data-test":`notification-link`,onClick:()=>t(e.id),children:o}):o,e.actions.length>0?(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.actions.map((e,t)=>(0,q.jsx)(Y,{node:e},e.key??e.id??`action-${t}`))}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.isRead?null:(0,q.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,q.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 Nu({notifications:e,status:t,hasMore:n,onMarkRead:r,onDismiss:i,onLoadMore:a}){let{t:o}=E(`lattice`);return t===`loading`&&e.length===0?(0,q.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,q.jsx)(fa,{className:`h-12 w-full`}),(0,q.jsx)(fa,{className:`h-12 w-full`}),(0,q.jsx)(fa,{className:`h-12 w-full`})]}):e.length===0?(0,q.jsx)(Au,{}):(0,q.jsxs)(`div`,{className:`max-h-96 overflow-y-auto`,children:[(0,q.jsx)(`ul`,{className:`divide-y divide-lt-border`,children:e.map(e=>(0,q.jsx)(Mu,{notification:e,onMarkRead:r,onDismiss:i},e.id))}),n?(0,q.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 Pu=(0,G.lazy)(()=>rn(()=>import(`./chunks/notifications-echo-uU87iJAV.js`).then(e=>({default:e.NotificationsEcho})),__vite__mapDeps([19,8,1]),import.meta.url)),Fu=class extends G.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}},Iu=bn({name:`lattice/notifications`,components:{notifications:K(({node:e})=>{let{t}=E(`lattice`),n=ku({endpoint:e.props.endpoint,pollingInterval:e.props.pollingInterval}),r=t(`notifications.label`,`Notifications`),i=(0,q.jsxs)(`span`,{className:`relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted`,children:[(0,q.jsx)(B,{name:`bell`,className:`size-lt-icon-md`}),n.unreadCount>0?(0,q.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,q.jsxs)(`div`,{className:`w-80`,"data-test":`notifications-panel`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-lt-border px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:t(`notifications.heading`,`Notifications`)}),n.unreadCount>0?(0,q.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,q.jsx)(Nu,{notifications:n.notifications,status:n.status,hasMore:n.hasMore,onMarkRead:n.markRead,onDismiss:n.dismiss,onLoadMore:n.loadMore})]});return(0,q.jsxs)(q.Fragment,{children:[e.props.channel?(0,q.jsx)(Fu,{children:(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(Pu,{channel:e.props.channel,onReceive:e=>n.receive(e)})})}):null,e.props.slideOut?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,onClick:()=>n.setOpen(!0),children:i}),(0,q.jsx)(ra,{open:n.open,onOpenChange:n.setOpen,children:(0,q.jsxs)(sa,{"aria-describedby":void 0,className:`p-0`,placement:`end`,width:`sm`,children:[(0,q.jsx)(aa,{className:`sr-only`,children:r}),a]})})]}):(0,q.jsxs)(ke,{open:n.open,onOpenChange:n.setOpen,children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,children:i})}),(0,q.jsx)(V,{align:`end`,className:`p-0`,children:a})]})]})})}});function Lu(e){return e==null?``:String(e)}function Ru({props:e}){let{t}=E(`lattice`),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(!e.remote||!e.dataEndpoint){r([]),s(!1);return}let t=!1;return a(null),s(!0),$t(e.dataEndpoint,{remote:e.remote}).then(e=>{t||r(e.data??[])}).catch(e=>{t||a(e instanceof Error?e.message:String(e))}).finally(()=>{t||s(!1)}),()=>{t=!0}},[e.dataEndpoint,e.remote]),i?(0,q.jsx)(`div`,{className:`rounded-lt border border-lt-danger/40 p-3 text-sm`,children:i}):o||!e.remote?(0,q.jsx)(`div`,{className:`rounded-lt border border-lt-border p-3 text-sm`,children:t(`common.remote.data-list.loading`,`Loading...`)}):(0,q.jsxs)(`div`,{className:`rounded-lt border border-lt-border bg-lt-bg`,children:[(0,q.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,q.jsxs)(`div`,{className:`divide-y divide-lt-border`,children:[n.map((t,n)=>(0,q.jsx)(`div`,{className:`px-3 py-2`,children:(0,q.jsx)(J,{nodes:S(e.schema,t)})},Lu(t.id)||n)),n.length===0?(0,q.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 zu=bn({components:{"remote.data-list":K(({node:e})=>(0,q.jsx)(Ru,{props:{...e.props,schema:e.schema}}))},name:`lattice/remote`});function Bu({columns:e,storageKey:t}){let n=(0,G.useMemo)(()=>e.filter(e=>e.props.toggleable),[e]),r=(0,G.useMemo)(()=>n.map(e=>e.key),[n]),[i,a]=mi(t??``,{},{enabled:!!t,parse:e=>Hu(e,r),serialize:e=>Uu(e,r)}),o=(0,G.useCallback)(e=>e.props.toggleable?i[e.key]??!e.props.hiddenByDefault:!0,[i]),s=(0,G.useMemo)(()=>e.filter(e=>o(e)),[e,o]),c=(0,G.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[a]),l=(0,G.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 Vu(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 Hu(e,t){let n=JSON.parse(e)?.overrides;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`unexpected stored column visibility shape`);return Vu(n,t)}function Uu(e,t){let n=Vu(e,t);return Object.keys(n).length===0?null:JSON.stringify({overrides:n})}function Wu(){let[e,t]=(0,G.useState)(()=>new Set);return{isExpanded:(0,G.useCallback)(t=>e.has(t),[e]),toggle:(0,G.useCallback)(e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[])}}var Gu={start:`text-start`,center:`text-center`,end:`text-end`},Ku={start:`justify-start`,center:`justify-center`,end:`justify-end`},qu={start:`justify-items-start`,center:`justify-items-center`,end:`justify-items-end`},Ju=e=>Gu[e],Yu=e=>Ku[e],Xu=e=>qu[e];function Zu(e){return(e??[]).flatMap(e=>{if(e.type===`action.group`)return[];let t=e.props;return t.endpoint?[{id:e.id??``,label:Ia(e),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 Qu(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 $u(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 ed(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}var td={mode:`none`,currentPage:null,lastPage:null,perPage:null,total:null,from:null,to:null,hasMore:!1,nextPage:null};function nd(e){return typeof e!=`object`||!e||Array.isArray(e)?td:e}function rd(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:Qu(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:sd(t.tableFilters),tableFilterIndicators:cd(t.tableFilterIndicators),search:typeof t.search==`string`?t.search:``,mode:ad(t.mode)}}var id=new Set([`none`,`simple`,`table`,`infinite`]);function ad(e){return typeof e==`string`&&id.has(e)?e:null}function od(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`||e===`infinite`):[]}function sd(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 cd(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 ld(e,t){let n=e.id??e.uuid??e.key??t;return String(n)}function ud(e){return Array.isArray(e.actions)?e.actions:[]}function dd(e){let t=e.detail;return typeof t==`object`&&t&&!Array.isArray(t)?t:null}function fd(e){return e==null||e===``}function pd(e){return fd(e)?!0:Array.isArray(e)?e.every(pd):typeof e==`object`&&e?Object.values(e).every(pd):!1}function md(e){return!pd(e)}function hd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gd(e){return hd(e)?e:{}}function _d(e,t){return e.sorts.find(e=>e.key===t.key)}function vd(e){if(e?.direction===`asc`)return`ascending`;if(e?.direction===`desc`)return`descending`}function yd(e,t){let n=new URL(e,window.location.origin);return t.filters.length>0&&n.searchParams.set(`filter`,Ed(t)),t.sorts.length>0&&n.searchParams.set(`sort`,Dd(t)),t.search!==``&&n.searchParams.set(`q`,t.search),bd(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 bd(e,t){for(let[n,r]of Object.entries(xd(t)))wd(e,`tf[${n}]`,r)}function xd(e){let t={};for(let[n,r]of Object.entries(e)){let e=Sd(r);e!==void 0&&(t[n]=e)}return t}function Sd(e){if(fd(e)||Array.isArray(e)||typeof e!=`object`)return;let t=Object.entries(e).map(([e,t])=>[e,Cd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}function Cd(e){if(!fd(e)){if(Array.isArray(e)){let t=e.map(Cd).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,Cd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}return String(e)}}function wd(e,t,n){if(Array.isArray(n)){for(let r of n)wd(e,`${t}[]`,r);return}if(typeof n==`object`&&n){for(let[r,i]of Object.entries(n))wd(e,`${t}[${r}]`,i);return}e.searchParams.append(t,String(n))}function Td(e){let t={};e.filters.length>0&&(t.filter=Ed(e)),e.sorts.length>0&&(t.sort=Dd(e));let n=xd(e.tableFilters);return Object.keys(n).length>0&&(t.tf=n),e.search!==``&&(t.q=e.search),t}function Ed(e){return e.filters.map(e=>`${e.field}:${e.operator}:${encodeURIComponent(e.value)}`).join(`,`)}function Dd(e){return e.sorts.map(e=>e.direction===`desc`?`-${e.key}`:e.key).join(`,`)}var Od={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`},kd=new Set([`empty`,`filled`]);function Ad(e){return w(`lattice`,`table.operators.${e}`,Od[e]??e)}function jd(e){return e===`desc`?`descending`:`ascending`}function Md(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 Nd(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 Pd(e){return e.map(e=>({key:e.key,label:e.props.label,width:Fd(e)}))}function Fd(e){return e.props.width??`md`}function Id(e,t,n=!1){return{leadingTracks:[...n?[`2.5rem`]:[],...t?[`3rem`]:[]],trailingTracks:e?[`10rem`]:[]}}function Ld(e){let t=(0,G.useMemo)(()=>$u(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,o=(0,G.useMemo)(()=>rd(e.props?.query),[e.props?.query]),s=(0,G.useMemo)(()=>ed(e.props?.data),[e.props?.data]),c=(0,G.useMemo)(()=>nd(e.props?.pagination),[e.props?.pagination]),[l,u]=(0,G.useState)(s),[d,f]=(0,G.useState)(c),[p,m]=(0,G.useState)(o),[h,g]=(0,G.useState)(i),[_,v]=(0,G.useState)(!i),y=(0,G.useRef)(null),b=d.currentPage??p.page,x=(d.mode??`table`)===`infinite`,S=(0,G.useCallback)(async(e,t=!1)=>{if(n){g(!0);try{let i=await Kt(yd(n,e),{ref:r}),a=rd(i.query),o=ed(i.data);u(e=>t?[...e,...o]:o),f(nd(i.pagination)),m(a),v(!0)}finally{g(!1)}}},[n,r]);function C(e){S({...p,page:1,sorts:Md(p.sorts,e)})}function w(e){S({...p,page:1,sorts:p.sorts.filter(t=>t.key!==e.key)})}function T(e){let t={...p,filters:e,page:1};m(t),S(t)}function E(e){T([...p.filters,e])}function D(e,t){T(p.filters.map((n,r)=>r===e?t:n))}function O(e){T(p.filters.filter((t,n)=>n!==e))}function k(e,t){T([...p.filters.filter(t=>t.field!==e),...t])}function A(e,t){let n={...p.tableFilters};pd(t)||!hd(t)?delete n[e]:n[e]=t;let r={...p,tableFilters:n,tableFilterIndicators:p.tableFilterIndicators.filter(t=>t.filter!==e),page:1};m(r),S(r)}function j(){let e={...p,filters:[],tableFilters:{},tableFilterIndicators:[],search:``,page:1};m(e),S(e)}function M(e){let t={...p,search:e,page:1};m(t),S(t)}let N=(0,G.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 Gt(`${a.pathname}${a.search}`,{ref:r,signal:i,throwOnError:!1});return o.ok?(await o.json()).options??[]:[]},[n,r]);function P(e){S({...p,page:e})}function F(e){let t=c.mode??`table`,n={...p,perPage:e===`infinite`?p.perPage:e,mode:e===`infinite`?`infinite`:t===`infinite`?`table`:null,page:1};m(n),S(n)}let I=(0,G.useCallback)(()=>{h||!d.hasMore||S({...p,page:d.nextPage??b+1},!0)},[b,S,d.hasMore,d.nextPage,h,p]);return(0,G.useEffect)(()=>{u(s),f(c),m(o),g(i),v(!i)},[s,c,o,i]),(0,G.useEffect)(()=>{!i||_||S(p)},[_,i,S,p]),Cn(a.reloadComponent,t=>{t.detail?.component===e.id&&S(p)}),(0,G.useEffect)(()=>{if(!x||!d.hasMore||h||!y.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&I()},{rootMargin:`240px`});return e.observe(y.current),()=>e.disconnect()},[x,I,d.hasMore,h]),{columns:t,rows:l,pagination:d,query:p,filters:p.filters,tableFilters:p.tableFilters,search:p.search,addFilter:E,updateFilter:D,removeFilter:O,replaceColumnFilters:k,setTableFilter:A,resetFilters:j,setSearch:M,searchFilterOptions:N,processing:h,hasLoaded:_,infiniteLoaderRef:y,sort:C,clearSort:w,goToPage:P,setPerPage:F,loadMore:I}}function Rd(e){let[t,n]=(0,G.useState)(()=>new Set),[r,i]=(0,G.useState)(!1),a=e.join(` `);(0,G.useEffect)(()=>{n(new Set),i(!1)},[a]);let o=(0,G.useCallback)(e=>{i(!1),n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,G.useCallback)(()=>{i(!1),n(t=>t.size===e.length?new Set:new Set(e))},[e]),c=(0,G.useCallback)(()=>i(!0),[]),l=(0,G.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 zd({actions:e,selectedKeys:t,allMatching:n,total:r,query:i,canSelectAllMatching:a,onSelectAllMatching:o,onCompleted:s}){let{t:c}=E(`lattice`),[l,u]=(0,G.useState)(!1),d=b(),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),g=()=>n?{allMatching:!0,...i}:{selected:t};async function _(e){u(!0);let t=await da(()=>Gt(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,q.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,q.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,q.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,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>(0,q.jsxs)(W,{type:`button`,"data-test":P(`bulk-action`,e.id),variant:e.variant,emphasis:e.emphasis,disabled:l,onClick:()=>v(e),children:[l&&(0,q.jsx)(la,{}),e.label]},e.id))}),f?.confirmation&&(0,q.jsx)(ua,{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,q.jsx)(Fa,{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 Bd({className:e,density:t,children:n,ref:r,...i}){return(0,q.jsx)(`select`,{ref:r,"data-slot":`native-select`,className:L(xt({density:t}),`cursor-pointer`,e),...i,children:n})}function Vd(e){return e===!0||e===1||e===`1`||e===`true`}function Hd({filter:e,value:t,processing:n,bare:r=!1,onChange:i,onSearch:a}){let{t:o}=E(`lattice`),s=e.schema??[];return s.length===0?(0,q.jsx)(Gd,{filter:e,value:t,processing:n,onChange:i}):(0,q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(Ud,{filter:e,schema:s,value:t,processing:n,bare:r,onChange:i,onSearch:a})}),md(t)&&(0,q.jsx)(ot,{size:`md`,icon:`x`,label:o(`table.filter.clear`,`Clear {{label}} filter`,{label:e.props.label??``}),disabled:n,onClick:()=>i(void 0)})]})}function Ud({filter:e,schema:t,value:n,processing:r,bare:i,onChange:a,onSearch:o}){let s=(0,G.useMemo)(()=>gd(n),[n]),c=(0,G.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,q.jsx)(`div`,{"aria-disabled":r,className:L(`grid gap-3`,r&&`pointer-events-none opacity-60`),children:(0,q.jsx)(J,{nodes:t})});return(0,q.jsx)(me,{value:c,children:(0,q.jsx)(Oe,{value:{markUserEdit:()=>{}},children:(0,q.jsx)(ma,{nodes:{},children:(0,q.jsx)(ut,{initial:s,children:(0,q.jsx)(Wd,{onChange:a,children:i?(0,q.jsx)(He,{children:l}):l})})})})})}function Wd({children:e,onChange:t}){let n=Ie(),r=Te(),i=(0,G.useRef)(n);i.current=n;let a=(0,G.useCallback)((e,n)=>{let a=typeof n==`function`?n(pe(i.current,e)):n,o=he(i.current,e,a);i.current=o,r(e,a),t(o)},[t,r]),o=(0,G.useMemo)(()=>({blur:()=>{},change:a,commit:a}),[a]);return(0,q.jsx)(Ve,{value:o,children:e})}function Gd({filter:e,value:t,processing:n,onChange:r}){let i=Vd(gd(t).value);return(0,q.jsxs)(`label`,{className:`flex h-lt-control-md cursor-pointer items-center gap-2 text-sm`,children:[(0,q.jsx)(yc,{"aria-label":e.props.label??void 0,"data-test":`table-filter-${e.key}`,checked:i,disabled:n,onCheckedChange:e=>r(e===!0?{value:`1`}:void 0)}),(0,q.jsx)(`span`,{children:e.props.label})]})}function Kd({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}=E(`lattice`),[d,f]=(0,G.useState)(n),p=o??u(`table.filter.filter-by`,`Filter {{label}}`,{label:t}),m=a?`rounded-r-none`:``;return(0,G.useEffect)(()=>{f(n)},[n]),e===`boolean`?(0,q.jsxs)(Bd,{density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:n,onChange:e=>c(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:u(`table.filter.all`,`All`)}),(0,q.jsx)(`option`,{value:`true`,children:u(`table.filter.true`,`True`)}),(0,q.jsx)(`option`,{value:`false`,children:u(`table.filter.false`,`False`)})]}):e===`date`?(0,q.jsx)(ht,{type:`date`,density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:d,onChange:e=>{f(e.target.value),c(e.target.value)}}):(0,q.jsxs)(`div`,{className:`relative flex w-full min-w-0 items-center`,children:[i&&(0,q.jsx)(B,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2 size-lt-icon-md text-lt-muted-fg`}),(0,q.jsx)(ht,{type:e===`number`?`number`:`text`,density:`compact`,"aria-label":p,"data-test":s,className:L(m,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,q.jsx)(ot,{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 qd({column:e,clauses:t,processing:n,onAdd:r,onUpdate:i,onRemove:a,onReplace:o,onSearch:s}){let{t:c}=E(`lattice`),{filter:l,label:u}=e.props,d=u??e.key;if(!l)return null;if(l.control===`filter.select`)return(0,q.jsx)(Yd,{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,q.jsxs)(`div`,{className:`flex min-w-0 max-w-80 items-stretch`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(Kd,{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,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(ot,{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,q.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,q.jsx)(V,{align:`start`,className:`w-80 p-4`,children:(0,q.jsx)($d,{column:e,clauses:t,operators:p,defaultOperator:m,processing:n,onAdd:r,onUpdate:i,onRemove:a})})]})]})}function Jd(e){return Array.isArray(e)?e.join(`,`):typeof e==`string`?e:``}function Yd({column:e,clauses:t,processing:n,onReplace:r,onSearch:i}){let{filter:a,label:o}=e.props;if(!a)return null;let s=a.multiple,c=a.defaultOperator,l=a.clauseOptions??[],u=Zd(t.map(e=>e.clause),l),d=t.find(e=>e.clause.operator===c)??t[0],f=u?u.value:s?d?.clause.value?d.clause.value.split(`,`):[]:d?.clause.value??``,p={key:e.key,type:`filter.select`,props:{label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null},schema:[{type:`field.select`,key:e.key,props:{name:`value`,label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null}}]};function m(t){let n=Jd(gd(t).value);if(n===``){r(e.key,[]);return}let i=l.find(e=>e.value===n);if(i){r(e.key,Xd(e.key,i));return}r(e.key,[{field:e.key,operator:c,value:n}])}return(0,q.jsx)(Hd,{filter:p,value:{value:f},processing:n,bare:!0,onChange:m,onSearch:i?(e,t,n)=>i(t,n):void 0})}function Xd(e,t){return t.clauses.map(t=>({field:e,operator:t.operator,value:t.value}))}function Zd(e,t){return t.find(t=>Qd(e,Xd(``,t)))}function Qd(e,t){return e.length===t.length&&t.every(t=>e.some(e=>e.operator===t.operator&&e.value===t.value))}function $d({column:e,clauses:t,operators:n,defaultOperator:r,processing:i,onAdd:a,onUpdate:o,onRemove:s}){let{t:c}=E(`lattice`),l=e.props.filter?.type??`text`,[u,d]=(0,G.useState)(r),[f,p]=(0,G.useState)(t.length===0);return(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[t.map(t=>(0,q.jsx)(ef,{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,q.jsx)(ef,{column:e,type:l,operators:n,clause:{field:e.key,operator:u,value:``},processing:i,onOperator:t=>{if(kd.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,q.jsx)(`div`,{className:`border-t border-lt-border pt-3`,children:(0,q.jsx)(W,{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 ef({column:e,type:t,operators:n,clause:r,processing:i,onOperator:a,onValue:o,onRemove:s}){let{t:c}=E(`lattice`),l=e.props.label??e.key,u=kd.has(r.operator);return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.length>1?(0,q.jsx)(Bd,{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,q.jsx)(`option`,{value:e,children:Ad(e)},e))}):(0,q.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:Ad(r.operator)}),(0,q.jsx)(W,{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,q.jsx)(Kd,{type:t,label:l,ariaLabel:c(`table.filter.value`,`{{label}} filter value`,{label:l}),value:r.value,processing:i,onCommit:o,onClear:()=>o(``)})]})}function tf({sort:e}){return e?.direction===`asc`?(0,q.jsx)(B,{name:`arrow-up`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):e?.direction===`desc`?(0,q.jsx)(B,{name:`arrow-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):(0,q.jsx)(B,{name:`chevrons-up-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0 opacity-50`})}function nf({column:e,processing:t,resizeHandleProps:n,sort:r,query:i}){let a=_d(i,e),{t:o}=E(`lattice`),{align:s,label:c,sortable:l}=e.props;return(0,q.jsxs)(`div`,{"aria-sort":vd(a),className:L(`relative min-w-0 px-4 py-3 pr-5 align-middle font-semibold text-lt-fg`,Ju(s)),role:`columnheader`,children:[l?(0,q.jsxs)(`button`,{type:`button`,"aria-label":o(`table.sort.column`,`Sort {{label}}`,{label:c}),className:L(`flex w-full items-center gap-1.5 font-semibold`,Yu(s)),"data-test":`sort-${e.key}`,disabled:t,onClick:()=>r(e),children:[(0,q.jsx)(`span`,{className:L(`min-w-0 flex-1 truncate`,Ju(s)),children:c}),(0,q.jsx)(tf,{sort:a})]}):(0,q.jsx)(`span`,{className:L(`block truncate`,Ju(s)),children:c}),n&&(0,q.jsx)(`div`,{...n})]})}function rf({columns:e,hasHidden:t,isVisible:n,onReset:r,onToggle:i,processing:a,visibleColumnCount:o}){let{t:s}=E(`lattice`),c=s(`table.columns.label`,`Columns`);return(0,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(ot,{size:`sm`,icon:`columns-3`,label:c,"data-test":`table-columns-menu`,disabled:a})}),(0,q.jsx)(V,{align:`end`,className:`w-64 p-4`,children:(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[e.map(e=>{let t=n(e),r=t&&o<=1;return(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-base text-lt-fg`,children:[(0,q.jsx)(yc,{"data-test":`table-column-toggle-${e.key}`,checked:t,disabled:r,onCheckedChange:t=>i(e.key,t===!0)}),(0,q.jsx)(`span`,{children:e.props.label??e.key})]},e.key)}),t&&(0,q.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 af({clauses:e,columnsByKey:t,indicators:n,processing:r,onRemoveClause:i,onChange:a,onReset:o}){let{t:s}=E(`lattice`);return e.length===0&&n.length===0?null:(0,q.jsx)(`div`,{className:`border-b border-lt-border px-4 py-3`,children:(0,q.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=kd.has(e.operator);return(0,q.jsx)(of,{label:`${a} ${Ad(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,q.jsx)(of,{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,q.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 of({label:e,value:t,removeTestId:n,removeLabel:r,processing:i,onRemove:a}){return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lt-sm bg-lt-muted px-2 py-1`,children:[(0,q.jsx)(`span`,{children:t===``?(0,q.jsx)(`span`,{className:`font-semibold`,children:e}):(0,q.jsxs)(q.Fragment,{children:[`${e}: `,(0,q.jsx)(`span`,{className:`font-semibold`,children:t})]})}),(0,q.jsx)(ot,{size:`xs`,icon:`x`,label:r,"data-test":n,disabled:i,onClick:a})]})}function sf({filters:e,values:t,processing:n,onChange:r,onSearch:i}){let{t:a}=E(`lattice`),o=e.filter(e=>md(t[e.key])),s=a(`table.filter.filters`,`Filters`);return(0,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(ot,{size:`sm`,icon:`filter`,label:s,"data-test":`table-filters-menu`,disabled:n,children:o.length>0&&(0,q.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,q.jsx)(V,{align:`end`,className:`w-80 p-4`,children:(0,q.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,q.jsx)(`div`,{className:`grid gap-1`,children:(0,q.jsx)(Hd,{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 cf({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}=E(`lattice`);return(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,q.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,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.per-page`,`Rows per page`)}),(0,q.jsx)(Bd,{"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,q.jsx)(`option`,{value:String(e),children:e===`infinite`?f(`table.pagination.infinite`,`Infinite`):e},String(e)))})]})]}),r===`infinite`?(0,q.jsx)(`div`,{ref:o,className:`flex items-center gap-2`,children:e.hasMore?(0,q.jsx)(W,{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,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.all-loaded`,`All rows loaded`)})}):r===`simple`?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):r===`table`?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),a.map(e=>(0,q.jsx)(W,{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,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):null]})}function lf({columnsByKey:e,query:t,processing:n,onClear:r}){let{t:i}=E(`lattice`);return(0,q.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,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`${a+1}. ${o}`}),(0,q.jsx)(B,{name:s,role:`img`,"aria-hidden":!1,"aria-label":jd(t.direction),className:`size-lt-icon-sm text-lt-muted-fg`}),(0,q.jsx)(ot,{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 uf=300;function df({value:e,onSearch:t}){let{t:n}=E(`lattice`),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(e);(0,G.useEffect)(()=>{e!==a.current&&(a.current=e,i(e))},[e]);function o(e){a.current=e,t(e)}let s=Aa(o,uf);function c(e){i(e),s(e)}function l(){s.cancel(),i(``),o(``)}let u=n(`table.search.placeholder`,`Search`);return(0,q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,q.jsx)(B,{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,q.jsx)(ht,{type:`search`,"data-test":`table-search`,value:r,placeholder:u,"aria-label":u,onChange:e=>c(e.target.value),className:L(`px-8`,`[&::-webkit-search-cancel-button]:hidden`)}),r!==``&&(0,q.jsx)(ot,{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})]})}function ff(e){return e}function pf(e,t,n){if(e==null)return``;let r=t?.props?.date;return r?A(e,r,n):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function mf(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 hf=({column:e,props:t,value:n})=>{let r=pf(n,e);return r===``?null:(0,q.jsx)(fo,{color:t.colors?.[String(n)],children:r})},gf=({value:e})=>{let{t}=E(`lattice`),n=Vd(e);return(0,q.jsx)(`span`,{"aria-label":n?t(`common.yes`,`Yes`):t(`common.no`,`No`),role:`img`,children:(0,q.jsx)(B,{name:n?`check`:`x`,className:L(`size-lt-icon-md`,n?`text-lt-success`:`text-lt-muted-fg`)})})},_f=({props:e,value:t})=>{let n=e.icons?.[String(t)]??e.icon??void 0;if(!n)return null;let r=Dt(e.colors?.[String(t)]),i=r?Et(r):void 0;return(0,q.jsx)(`span`,{"aria-label":String(t),className:L(`lt-cell-icon`,i?.className),style:i?.style,children:(0,q.jsx)(I,{className:`size-lt-icon-md`,icon:n})})},vf=({column:e,props:t,value:n})=>{let r=typeof n==`string`?n:``;if(r===``)return null;let i=t.size??32;return(0,q.jsx)(Lo,{alt:e.props.label??``,className:L(`object-cover`,t.circular?`rounded-full`:`rounded-lt-sm`),height:i,previewable:t.previewable,src:r,testId:`preview-${e.key}`,width:i})};function yf({children:e,column:t,copyable:n,value:r}){return n?(0,q.jsx)(No,{value:r,label:t.props.label??t.key,testId:`copy-${t.key}`,children:e}):e}function bf({column:e,copyable:t,format:r,value:i}){let{locale:a}=n();return Tt(i)===null?(0,q.jsx)(`span`,{children:pf(i,e)}):(0,q.jsx)(yf,{column:e,copyable:t,value:String(i),children:(0,q.jsx)(`span`,{className:`tabular-nums`,children:Ot(i,r,a)})})}var xf=({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,q.jsx)(bf,{column:e,copyable:t.copyable,value:r,format:{kind:`number`,notation:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:a,unit:null}})},Sf=({column:e,props:t,value:n})=>(0,q.jsx)(bf,{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}}),Cf=({column:e,row:t})=>(0,q.jsx)(`div`,{className:`grid gap-1`,children:(0,q.jsx)(J,{nodes:S(e.schema,t)})}),wf=e=>e.props.multiple?(0,q.jsx)(Ef,{...e}):e.props.badge?(0,q.jsx)(Df,{...e}):(0,q.jsx)(Of,{...e});function Tf({label:e,color:t}){return e===``?null:(0,q.jsx)(fo,{color:t,children:e})}function Ef({column:e,props:t,value:n}){let r=Array.isArray(n)?n:[];return r.length===0?null:t.badge?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map((t,n)=>{let r=t;return(0,q.jsx)(Tf,{label:pf(r.value,e),color:r.color},n)})}):(0,q.jsx)(`span`,{children:r.map(t=>pf(t,e)).join(`, `)})}function Df({column:e,props:t,row:n,value:r}){let i=t.badge.colorKey;return(0,q.jsx)(Tf,{label:pf(r,e),color:String(n[i]??``)})}function Of({column:e,props:t,row:n,value:r}){let i=e.props.date,a=mf(e,n,r),o=pf(r,e),s=a?(0,q.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,q.jsx)(qr,{value:r,dateStyle:i.dateStyle,timeStyle:i.timeStyle}):(0,q.jsx)(yf,{column:e,copyable:t.copyable,value:o,children:s})}var kf={"column.badge":ff(hf),"column.boolean":ff(gf),"column.icon":ff(_f),"column.image":ff(vf),"column.money":ff(xf),"column.number":ff(Sf),"column.stack":ff(Cf),"column.text":ff(wf)};function Af({column:e,row:t}){let n=g()[e.type]??kf[e.type]??kf[`column.text`];return(0,q.jsx)(n,{column:e,props:e.props,row:t,value:t[e.key]})}var jf=xn(hs,Wa,bu,vi,bn({components:{table:K(({node:e})=>{let{t}=E(`lattice`),{columns:n,rows:r,pagination:i,query:a,filters:o,tableFilters:s,search:c,addFilter:l,updateFilter:u,removeFilter:d,replaceColumnFilters:f,setTableFilter:p,resetFilters:m,setSearch:h,searchFilterOptions:g,processing:_,hasLoaded:v,infiniteLoaderRef:y,sort:b,clearSort:x,goToPage:S,setPerPage:C,loadMore:w}=Ld(e),T=(0,G.useMemo)(()=>Zu(e.props?.bulkActions),[e.props?.bulkActions]),D=T.length>0,O=(0,G.useMemo)(()=>r.map((e,t)=>({row:e,actions:ud(e),detail:dd(e),key:ld(e,t)})),[r]),k=Rd(O.map(e=>e.key)),{isExpanded:A,toggle:j}=Wu(),M=O.some(e=>e.detail!=null),N=(0,G.useMemo)(()=>new Map(n.map(e=>[e.key,e])),[n]),P=F(e),{hasToggleableColumns:I,hasHidden:R,isVisible:ee,resetVisibility:te,setColumnVisible:ne,toggleableColumns:re,visibleColumns:z}=Bu({columns:n,storageKey:P?`lattice:table-column-visibility:${P}`:void 0}),ie=i.currentPage??a.page,ae=i.lastPage??ie,oe=i.mode??`table`,se=(0,G.useMemo)(()=>od(e.props?.perPageOptions),[e.props?.perPageOptions]),ce=Nd(ie,ae),le=i.hasMore??ie<ae,ue=O.some(e=>e.actions.length>0),de=e.props?.striped===!0,fe=z.some(e=>e.props.filter!=null),pe=o.map((e,t)=>({clause:e,index:t})),V=(0,G.useMemo)(()=>Array.isArray(e.props?.filters)?e.props.filters:[],[e.props?.filters]),me=V.length>0,he=ue||me||I,ge=(0,G.useMemo)(()=>Pd(z),[z]),_e=(0,G.useMemo)(()=>Id(he,D,M),[he,D,M]),ve=e.props?.resizableColumns===!0,ye=F(e),{getResizeHandleProps:be,gridTemplateColumns:xe,hasOverrides:Se,resizeRootRef:Ce,resetColumns:we}=Ns({columns:ge,enabled:ve,leadingTracks:_e.leadingTracks,showIndicator:e.props?.resizeIndicator===!0,storageKey:ve&&ye?`lattice:table-columns:${ye}`:void 0,trailingTracks:_e.trailingTracks});return(0,q.jsxs)(`div`,{"data-slot":`table`,"data-lattice-component":e.id,className:`relative`,children:[Se&&(0,q.jsx)(`button`,{"aria-label":t(`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:we,title:t(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,q.jsx)(B,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,q.jsxs)(`div`,{"data-slot":`table-scroll`,className:`overflow-x-auto rounded-lt-sm border border-lt-border`,children:[e.props?.searchable&&(0,q.jsx)(`div`,{"data-slot":`table-toolbar`,className:`flex items-center gap-2 border-b border-lt-border px-4 py-2`,children:(0,q.jsx)(df,{value:c,onSearch:h})}),(0,q.jsx)(af,{clauses:o,columnsByKey:N,indicators:a.tableFilterIndicators,processing:_,onRemoveClause:d,onChange:p,onReset:m}),D&&k.active&&(0,q.jsx)(zd,{actions:T,selectedKeys:k.selectedKeys,allMatching:k.allMatching,total:i.total??void 0,query:Td(a),canSelectAllMatching:k.allVisibleSelected&&!k.allMatching&&i.total!=null&&i.total>k.selectedKeys.length,onSelectAllMatching:k.selectAllMatching,onCompleted:k.clear}),a.sorts.length>0&&(0,q.jsx)(lf,{columnsByKey:N,query:a,processing:_,onClear:x}),(0,q.jsxs)(`div`,{ref:Ce,className:`min-w-full text-base`,role:`table`,style:{"--lattice-table-columns":xe},children:[(0,q.jsxs)(`div`,{"data-slot":`table-header`,className:`border-b border-lt-border bg-lt-muted/50`,role:`rowgroup`,children:[(0,q.jsxs)(`div`,{className:`hidden min-w-full md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[M&&(0,q.jsx)(`div`,{className:`px-2 py-3`,role:`columnheader`,"aria-hidden":`true`}),D&&(0,q.jsx)(`div`,{className:`flex items-center px-4 py-3`,role:`columnheader`,children:(0,q.jsx)(yc,{"aria-label":t(`table.select-all-rows`,`Select all rows`),"data-test":`select-all`,checked:k.allSelected,onCheckedChange:()=>k.toggleAll()})}),z.map((e,t)=>(0,q.jsx)(nf,{column:e,processing:_,resizeHandleProps:ve?be(ge[t]):void 0,sort:b,query:a},e.key)),he&&(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2 align-middle font-semibold text-lt-fg`,role:`columnheader`,children:[me&&(0,q.jsx)(sf,{filters:V,values:s,processing:_,onChange:p,onSearch:g}),I&&(0,q.jsx)(rf,{columns:re,isVisible:ee,visibleColumnCount:z.length,hasHidden:R,onToggle:ne,onReset:te,processing:_}),ue&&(0,q.jsx)(`span`,{className:`sr-only`,children:e.props?.actionsLabel??t(`table.actions`,`Actions`)})]})]}),fe&&(0,q.jsxs)(`div`,{className:`hidden min-w-full border-t border-lt-border md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[M&&(0,q.jsx)(`div`,{className:`px-2 py-2`,role:`cell`}),D&&(0,q.jsx)(`div`,{className:`px-4 py-2`,role:`cell`}),z.map(e=>(0,q.jsx)(`div`,{className:`min-w-0 px-2 py-2`,role:`cell`,children:e.props.filter!=null&&(0,q.jsx)(qd,{column:e,clauses:pe.filter(t=>t.clause.field===e.key),processing:_,onAdd:l,onUpdate:u,onRemove:d,onReplace:f,onSearch:(t,n)=>g(`column:${e.key}`,t,n)})},e.key)),he&&(0,q.jsx)(`div`,{className:`px-4 py-2`,role:`cell`})]})]}),(0,q.jsx)(`div`,{role:`rowgroup`,children:v?O.length===0?(0,q.jsx)(`div`,{"data-slot":`table-empty`,className:`p-8 text-center text-lt-muted-fg`,role:`row`,children:(0,q.jsx)(`div`,{role:`cell`,children:e.props?.emptyLabel??t(`table.empty`,`No results`)})}):O.map(({row:n,actions:r,detail:i,key:a})=>{let o=i!=null&&A(a),s=`${F(e)??`table`}-row-detail-${a}`;return(0,q.jsxs)(G.Fragment,{children:[(0,q.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:[M&&(0,q.jsx)(`div`,{className:`flex items-center px-2 py-lt-cell-y`,role:`cell`,children:i&&(0,q.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:()=>j(a),children:(0,q.jsx)(B,{name:`chevron-down`,"aria-hidden":`true`,className:L(`size-lt-icon-md transition-transform`,!o&&`-rotate-90`)})})}),D&&(0,q.jsx)(`div`,{className:`flex items-center px-lt-cell-x py-lt-cell-y`,role:`cell`,children:(0,q.jsx)(yc,{"aria-label":t(`table.select-row`,`Select row {{key}}`,{key:a}),"data-test":`select-row-${a}`,checked:k.isSelected(a),onCheckedChange:()=>k.toggle(a)})}),z.map(e=>(0,q.jsxs)(`div`,{"data-slot":`table-cell`,className:L(`grid min-w-0 gap-1 overflow-hidden px-lt-cell-x py-lt-cell-y align-middle`,Ju(e.props.align),Xu(e.props.align)),role:`cell`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium text-lt-muted-fg md:hidden`,children:e.props.label}),(0,q.jsx)(`div`,{"data-slot":`table-cell-content`,className:`min-w-0 max-w-full overflow-hidden truncate`,children:(0,q.jsx)(Af,{column:e,row:n})})]},e.key)),he&&(0,q.jsx)(`div`,{className:L(`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,q.jsx)(Y,{node:e},e.key??e.id??t))})]}),o&&i&&(0,q.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,q.jsx)(J,{nodes:[i]})})]},a)}):(0,q.jsx)(`div`,{className:`p-4 text-lt-muted-fg`,role:`row`,children:(0,q.jsx)(`div`,{role:`cell`,children:t(`table.loading`,`Loading rows...`)})})})]}),v&&(0,q.jsx)(cf,{pagination:i,currentPage:ie,processing:_,mode:oe,hasNextPage:le,visiblePages:ce,infiniteLoaderRef:y,perPageOptions:se,perPageValue:oe===`infinite`?`infinite`:a.perPage,onPerPage:C,onPage:S,onLoadMore:w})]})]})})},name:`lattice/table`}),oo,Iu,zu);function Mf(e,t){if(t.length===0)return e;let n=new Set([...e.namespaces??[`lattice`],...t.map(e=>e.namespace)]);return{...e,namespaces:[...n]}}function Nf({ready:e,children:t}){let[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{let t=!0,n=()=>{t&&r(!0)};return e.then(n,n),()=>{t=!1}},[e]),n?t:null}function Pf({registry:e,plugins:t,sprite:n,pages:r={},defaultLayout:i,strictMode:a=!0,i18n:o,boot:s,wrap:l,...d}={}){let f=e??jf,p=t&&t.length>0?Sn(f,...t):f;c(p),Oi();let m=o!==!1,h=t?.flatMap(e=>e.i18n?[e.i18n]:[])??[],g=m?Mf(o??{},h):{},_=d.defaults?.visitOptions,v=m?{...d.defaults,visitOptions:(e,t)=>Ei(e,_?.(e,t)??t)}:d.defaults,y=u({...d,defaults:v,strictMode:a,resolve:wi(r),layout:Ti({defaultLayout:i}),withApp:(e,{ssr:t,page:r})=>{let i=[],a=r.props.lattice,o=!1;if(C(a)&&ln(a.appearance),!t){o=document.getElementById(d.id??`app`)?.hasAttribute(`data-server-rendered`)===!0,C(a)&&C(a.urls)&&typeof a.urls.refreshRef==`string`&&Ht(a.urls.refreshRef),m&&j(r.props)!==void 0&&i.push(rn(()=>import(`./chunks/page-props-BHNNVkgJ.js`).then(e=>e.configureI18nFromPageProps(r.props,g)),__vite__mapDeps([20,4,1,5,6,21,10]),import.meta.url));let e=s?.({page:r});e&&i.push(e)}let c=(0,q.jsxs)(q.Fragment,{children:[e,m?(0,q.jsx)(wn,{}):null]}),u=(0,q.jsx)(Ua,{registry:p,sprite:n,children:l?l(c):c});return i.length===0?u:o?(T(Promise.all(i)),u):(0,q.jsx)(Nf,{ready:Promise.all(i),children:u})}});return yn(),y}function Ff(){return console.warn(`[lattice] The data-lattice-config script holds invalid JSON; booting with defaults.`),{}}function If(e){let t=e.querySelector(`script[data-lattice-config]`);if(!t?.textContent)return{};try{let e=JSON.parse(t.textContent);return typeof e!=`object`||!e||Array.isArray(e)?Ff():e}catch{return Ff()}}var Lf=If(document);async function Rf(){if(Lf.refreshRefUrl&&Ht(Lf.refreshRefUrl),Lf.echo)try{let{configureEcho:e}=await rn(async()=>{let{configureEcho:e}=await import(`./chunks/dist-DqlcM-vw.js`);return{configureEcho:e}},__vite__mapDeps([8,1]),import.meta.url);e(Lf.echo)}catch(e){console.warn(`[lattice] Failed to load the realtime chunk; continuing without Echo.`,e)}Pf({...Lf.spriteUrl?{sprite:{href:Lf.spriteUrl}}:{},defaults:{visitOptions:Ei}})}Rf();
|