| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import{j as n,u as Kt,a as nt,b as st,Q as cn,c as ln}from"./query-C_q0vuOo.js";import{a as ot,r as l,N as dn,b as at,u as De,L as Me,O as un,c as Qt,d as Y,e as fn,f as mn,g as pn,h as Nt,i as hn,j as gn}from"./react-C4-CelXw.js";import{B as Yt,R as vn,S as xn,A as bn,I as yn,a as wn,b as jn,c as Nn,M as Sn,d as Cn,C as En,L as _n,u as q,X as Rn,P as kn,e as Pn,f as St,T as An,$ as Tn}from"./ui-DsQixLUC.js";import{o as On,r as Dn,a as Mn,b as Xt,c as Zt,n as Jt,s as fe,u as er}from"./forms-DqymyfYA.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function r(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=r(o);fetch(o.href,a)}})();var tr,Ct=ot;tr=Ct.createRoot,Ct.hydrateRoot;function rr(e){var t,r,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=rr(e[t]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function nr(){for(var e,t,r=0,s="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=rr(e))&&(s&&(s+=" "),s+=t);return s}const it="-",Ln=e=>{const t=Fn(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:c=>{const i=c.split(it);return i[0]===""&&i.length!==1&&i.shift(),sr(i,t)||In(c)},getConflictingClassGroupIds:(c,i)=>{const d=r[c]||[];return i&&s[c]?[...d,...s[c]]:d}}},sr=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],s=t.nextPart.get(r),o=s?sr(e.slice(1),s):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(it);return t.validators.find(({validator:c})=>c(a))?.classGroupId},Et=/^\[(.+)\]$/,In=e=>{if(Et.test(e)){const t=Et.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},Fn=e=>{const{theme:t,prefix:r}=e,s={nextPart:new Map,validators:[]};return Bn(Object.entries(e.classGroups),r).forEach(([a,c])=>{Ye(c,s,a,t)}),s},Ye=(e,t,r,s)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:_t(t,o);a.classGroupId=r;return}if(typeof o=="function"){if(zn(o)){Ye(o(s),t,r,s);return}t.validators.push({validator:o,classGroupId:r});return}Object.entries(o).forEach(([a,c])=>{Ye(c,_t(t,a),r,s)})})},_t=(e,t)=>{let r=e;return t.split(it).forEach(s=>{r.nextPart.has(s)||r.nextPart.set(s,{nextPart:new Map,validators:[]}),r=r.nextPart.get(s)}),r},zn=e=>e.isThemeGetter,Bn=(e,t)=>t?e.map(([r,s])=>{const o=s.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([c,i])=>[t+c,i])):a);return[r,o]}):e,$n=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,s=new Map;const o=(a,c)=>{r.set(a,c),t++,t>e&&(t=0,s=r,r=new Map)};return{get(a){let c=r.get(a);if(c!==void 0)return c;if((c=s.get(a))!==void 0)return o(a,c),c},set(a,c){r.has(a)?r.set(a,c):o(a,c)}}},or="!",Wn=e=>{const{separator:t,experimentalParseClassName:r}=e,s=t.length===1,o=t[0],a=t.length,c=i=>{const d=[];let u=0,m=0,p;for(let v=0;v<i.length;v++){let b=i[v];if(u===0){if(b===o&&(s||i.slice(v,v+a)===t)){d.push(i.slice(m,v)),m=v+a;continue}if(b==="/"){p=v;continue}}b==="["?u++:b==="]"&&u--}const g=d.length===0?i:i.substring(m),h=g.startsWith(or),x=h?g.substring(1):g,f=p&&p>m?p-m:void 0;return{modifiers:d,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:f}};return r?i=>r({className:i,parseClassName:c}):c},Un=e=>{if(e.length<=1)return e;const t=[];let r=[];return e.forEach(s=>{s[0]==="["?(t.push(...r.sort(),s),r=[]):r.push(s)}),t.push(...r.sort()),t},Vn=e=>({cache:$n(e.cacheSize),parseClassName:Wn(e),...Ln(e)}),qn=/\s+/,Gn=(e,t)=>{const{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:o}=t,a=[],c=e.trim().split(qn);let i="";for(let d=c.length-1;d>=0;d-=1){const u=c[d],{modifiers:m,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:h}=r(u);let x=!!h,f=s(x?g.substring(0,h):g);if(!f){if(!x){i=u+(i.length>0?" "+i:i);continue}if(f=s(g),!f){i=u+(i.length>0?" "+i:i);continue}x=!1}const v=Un(m).join(":"),b=p?v+or:v,y=b+f;if(a.includes(y))continue;a.push(y);const j=o(f,x);for(let N=0;N<j.length;++N){const C=j[N];a.push(b+C)}i=u+(i.length>0?" "+i:i)}return i};function Hn(){let e=0,t,r,s="";for(;e<arguments.length;)(t=arguments[e++])&&(r=ar(t))&&(s&&(s+=" "),s+=r);return s}const ar=e=>{if(typeof e=="string")return e;let t,r="";for(let s=0;s<e.length;s++)e[s]&&(t=ar(e[s]))&&(r&&(r+=" "),r+=t);return r};function Kn(e,...t){let r,s,o,a=c;function c(d){const u=t.reduce((m,p)=>p(m),e());return r=Vn(u),s=r.cache.get,o=r.cache.set,a=i,i(d)}function i(d){const u=s(d);if(u)return u;const m=Gn(d,r);return o(d,m),m}return function(){return a(Hn.apply(null,arguments))}}const R=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},ir=/^\[(?:([a-z-]+):)?(.+)\]$/i,Qn=/^\d+\/\d+$/,Yn=new Set(["px","full","screen"]),Xn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Jn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,es=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ts=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,B=e=>ne(e)||Yn.has(e)||Qn.test(e),W=e=>ae(e,"length",ls),ne=e=>!!e&&!Number.isNaN(Number(e)),We=e=>ae(e,"number",ne),ce=e=>!!e&&Number.isInteger(Number(e)),rs=e=>e.endsWith("%")&&ne(e.slice(0,-1)),w=e=>ir.test(e),U=e=>Xn.test(e),ns=new Set(["length","size","percentage"]),ss=e=>ae(e,ns,cr),os=e=>ae(e,"position",cr),as=new Set(["image","url"]),is=e=>ae(e,as,us),cs=e=>ae(e,"",ds),le=()=>!0,ae=(e,t,r)=>{const s=ir.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):r(s[2]):!1},ls=e=>Zn.test(e)&&!Jn.test(e),cr=()=>!1,ds=e=>es.test(e),us=e=>ts.test(e),fs=()=>{const e=R("colors"),t=R("spacing"),r=R("blur"),s=R("brightness"),o=R("borderColor"),a=R("borderRadius"),c=R("borderSpacing"),i=R("borderWidth"),d=R("contrast"),u=R("grayscale"),m=R("hueRotate"),p=R("invert"),g=R("gap"),h=R("gradientColorStops"),x=R("gradientColorStopPositions"),f=R("inset"),v=R("margin"),b=R("opacity"),y=R("padding"),j=R("saturate"),N=R("scale"),C=R("sepia"),P=R("skew"),A=R("space"),$=R("translate"),E=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",w,t],S=()=>[w,t],bt=()=>["",B,W],ye=()=>["auto",ne,w],yt=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],we=()=>["solid","dashed","dotted","double","none"],wt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$e=()=>["start","end","center","between","around","evenly","stretch"],ie=()=>["","0",w],jt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[ne,w];return{cacheSize:500,separator:":",theme:{colors:[le],spacing:[B,W],blur:["none","",U,w],brightness:z(),borderColor:[e],borderRadius:["none","","full",U,w],borderSpacing:S(),borderWidth:bt(),contrast:z(),grayscale:ie(),hueRotate:z(),invert:ie(),gap:S(),gradientColorStops:[e],gradientColorStopPositions:[rs,W],inset:D(),margin:D(),opacity:z(),padding:S(),saturate:z(),scale:z(),sepia:ie(),skew:z(),space:S(),translate:S()},classGroups:{aspect:[{aspect:["auto","square","video",w]}],container:["container"],columns:[{columns:[U]}],"break-after":[{"break-after":jt()}],"break-before":[{"break-before":jt()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...yt(),w]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[f]}],"inset-x":[{"inset-x":[f]}],"inset-y":[{"inset-y":[f]}],start:[{start:[f]}],end:[{end:[f]}],top:[{top:[f]}],right:[{right:[f]}],bottom:[{bottom:[f]}],left:[{left:[f]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ce,w]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",w]}],grow:[{grow:ie()}],shrink:[{shrink:ie()}],order:[{order:["first","last","none",ce,w]}],"grid-cols":[{"grid-cols":[le]}],"col-start-end":[{col:["auto",{span:["full",ce,w]},w]}],"col-start":[{"col-start":ye()}],"col-end":[{"col-end":ye()}],"grid-rows":[{"grid-rows":[le]}],"row-start-end":[{row:["auto",{span:[ce,w]},w]}],"row-start":[{"row-start":ye()}],"row-end":[{"row-end":ye()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",w]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",w]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...$e()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...$e(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...$e(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[A]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[A]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",w,t]}],"min-w":[{"min-w":[w,t,"min","max","fit"]}],"max-w":[{"max-w":[w,t,"none","full","min","max","fit","prose",{screen:[U]},U]}],h:[{h:[w,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[w,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[w,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[w,t,"auto","min","max","fit"]}],"font-size":[{text:["base",U,W]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",We]}],"font-family":[{font:[le]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",w]}],"line-clamp":[{"line-clamp":["none",ne,We]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",B,w]}],"list-image":[{"list-image":["none",w]}],"list-style-type":[{list:["none","disc","decimal",w]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...we(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",B,W]}],"underline-offset":[{"underline-offset":["auto",B,w]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",w]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",w]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...yt(),os]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ss]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},is]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...we(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:we()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...we()]}],"outline-offset":[{"outline-offset":[B,w]}],"outline-w":[{outline:[B,W]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:bt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[B,W]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",U,cs]}],"shadow-color":[{shadow:[le]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...wt(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":wt()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[s]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",U,w]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[m]}],invert:[{invert:[p]}],saturate:[{saturate:[j]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[m]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[j]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",w]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",w]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",w]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[ce,w]}],"translate-x":[{"translate-x":[$]}],"translate-y":[{"translate-y":[$]}],"skew-x":[{"skew-x":[P]}],"skew-y":[{"skew-y":[P]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",w]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",w]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",w]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[B,W,We]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},ms=Kn(fs);function _(...e){return ms(nr(e))}let ct=null,lr=null;function Xe(e){ct=e.access,e.refresh}function dr(){ct=null}function Rt(){return ct}function ps(e){lr=e}function hs(){return lr}let de=null;async function gs(){return de||(de=(async()=>{try{const e=await fetch("/v1/auth/refresh",{method:"POST",credentials:"include"});if(!e.ok)return!1;const t=await e.json();return!t.access_token||!t.refresh_token?!1:(Xe({access:t.access_token,refresh:t.refresh_token}),!0)}catch{return!1}finally{de=null}})(),de)}class Le extends Error{status;body;constructor(t,r,s){super(s),this.status=t,this.body=r}}async function ur(e,t={}){const r=new Headers(t.headers),s=Rt();s&&!r.has("Authorization")&&r.set("Authorization",`Bearer ${s}`);const o=await fetch(e,{...t,headers:r,credentials:"include"});if(o.status!==401||t.skipRefresh)return o;if(!await gs()){dr();const d=hs();return d&&typeof window<"u"&&(window.location.href=d),o}const c=new Headers(t.headers),i=Rt();return i&&!c.has("Authorization")&&c.set("Authorization",`Bearer ${i}`),fetch(e,{...t,headers:c,credentials:"include"})}async function lt(e){const t=await ur(e);if(!t.ok){const r=await fr(t);throw new Le(t.status,r,`${t.status} ${t.statusText}`)}return t.json()}async function dt(e,t,r){const s=await ur(t,{method:e,headers:r?{"Content-Type":"application/json"}:void 0,body:r?JSON.stringify(r):void 0});if(!s.ok){const o=await fr(s);throw new Le(s.status,o,`${e} ${t} → ${s.status}`)}if(s.status!==204)return s.json()}async function fr(e){try{return await e.json()}catch{return null}}const mr=l.createContext(null);function X(){const e=l.useContext(mr);if(!e)throw new Error("useAuth must be used inside <AuthProvider>");return e}function vs({children:e}){const[t,r]=l.useState(null),[s,o]=l.useState(!0),[a,c]=l.useState(null),i=l.useCallback(async()=>{try{return await lt("/v1/auth/me")}catch(g){if(g instanceof Le&&g.status===401)return null;throw g}},[]);l.useEffect(()=>{let g=!1;return(async()=>{try{const h=await fetch("/v1/auth/refresh",{method:"POST",credentials:"include"});if(h.ok){const f=await h.json();f.access_token&&f.refresh_token&&Xe({access:f.access_token,refresh:f.refresh_token})}const x=await i();g||(r(x),c(null))}catch(h){g||(c(h instanceof Error?h.message:"unknown"),r(null))}finally{g||o(!1)}})(),()=>{g=!0}},[i]);const d=l.useCallback(async(g,h)=>{ps(window.location.pathname+window.location.search);const x=await fetch("/v1/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:g,password:h})});if(!x.ok){const b=(await x.json().catch(()=>null))?.message??`${x.status} ${x.statusText}`;throw new Error(b)}const f=await x.json();Xe({access:f.access_token,refresh:f.refresh_token}),r(f.user),c(null)},[]),u=l.useCallback(async()=>{try{await fetch("/v1/auth/logout",{method:"POST",credentials:"include"})}catch{}dr(),r(null)},[]),m=l.useCallback(async()=>{const g=await i();r(g)},[i]),p=l.useMemo(()=>({user:t,loading:s,bootError:a,login:d,logout:u,refresh:m}),[t,s,a,d,u,m]);return n.jsx(mr.Provider,{value:p,children:e})}function pr(e){return e==="super_admin"}function hr(e){return e==="super_admin"}function xs(e){return e==="super_admin"||e==="tenant_admin"}function kt(e){return e==="super_admin"||e==="tenant_admin"}function bs(e){return e==="super_admin"||e==="tenant_admin"||e==="viewer"}const ys=[{to:"/companies",label:"Companies",icon:Yt,show:e=>hr(e?.role)},{to:"/sources",label:"Sources",icon:vn,show:e=>kt(e?.role)},{to:"/telegram",label:"Telegram",icon:xn,show:e=>kt(e?.role)},{to:"/tail",label:"Live tail",icon:bn},{to:"/dlq",label:"DLQ",icon:yn,show:e=>bs(e?.role),badge:"M13c"},{to:"/audit",label:"Audit log",icon:wn,badge:"M13c"}];function ws(){const{user:e}=X(),t=ys.filter(r=>!r.show||r.show(e));return n.jsxs("aside",{className:"hidden w-56 shrink-0 border-r bg-card md:block",children:[n.jsx("nav",{className:"flex flex-col gap-0.5 p-3",children:t.map(r=>n.jsxs(dn,{to:r.to,className:({isActive:s})=>_("flex items-center justify-between rounded-md px-3 py-2 text-sm transition-colors",s?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(r.icon,{className:"h-4 w-4","aria-hidden":!0}),r.label]}),r.badge?n.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:r.badge}):null]},r.to))}),n.jsx("div",{className:"border-t p-3 text-xs text-muted-foreground",children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(jn,{className:"h-3.5 w-3.5"}),n.jsx("span",{children:"M13b W0 · SPA shell"})]})})]})}function Pt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function js(...e){return t=>{let r=!1;const s=e.map(o=>{const a=Pt(o,t);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let o=0;o<s.length;o++){const a=s[o];typeof a=="function"?a():Pt(e[o],null)}}}}function Z(...e){return l.useCallback(js(...e),e)}function ut(e){const t=l.forwardRef((r,s)=>{let{children:o,...a}=r,c=null,i=!1;const d=[];At(o)&&typeof je=="function"&&(o=je(o._payload)),l.Children.forEach(o,g=>{if(Rs(g)){i=!0;const h=g;let x="child"in h.props?h.props.child:h.props.children;At(x)&&typeof je=="function"&&(x=je(x._payload)),c=Cs(h,x),d.push(c?.props?.children)}else d.push(g)}),c?c=l.cloneElement(c,void 0,d):!i&&l.Children.count(o)===1&&l.isValidElement(o)&&(c=o);const u=c?_s(c):void 0,m=Z(s,u);if(!c){if(o||o===0)throw new Error(i?Ts(e):As(e));return o}const p=Es(a,c.props??{});return c.type!==l.Fragment&&(p.ref=s?m:u),l.cloneElement(c,p)});return t.displayName=`${e}.Slot`,t}var Ns=ut("Slot"),Ss=Symbol.for("radix.slottable"),Cs=(e,t)=>{if("child"in e.props){const r=e.props.child;return l.isValidElement(r)?l.cloneElement(r,void 0,e.props.children(r.props.children)):null}return l.isValidElement(t)?t:null};function Es(e,t){const r={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?r[s]=(...i)=>{const d=a(...i);return o(...i),d}:o&&(r[s]=o):s==="style"?r[s]={...o,...a}:s==="className"&&(r[s]=[o,a].filter(Boolean).join(" "))}return{...e,...r}}function _s(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Rs(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ss}var ks=Symbol.for("react.lazy");function At(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===ks&&"_payload"in e&&Ps(e._payload)}function Ps(e){return typeof e=="object"&&e!==null&&"then"in e}var As=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Ts=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,je=at[" use ".trim().toString()];const Tt=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ot=nr,gr=(e,t)=>r=>{var s;if(t?.variants==null)return Ot(e,r?.class,r?.className);const{variants:o,defaultVariants:a}=t,c=Object.keys(o).map(u=>{const m=r?.[u],p=a?.[u];if(m===null)return null;const g=Tt(m)||Tt(p);return o[u][g]}),i=r&&Object.entries(r).reduce((u,m)=>{let[p,g]=m;return g===void 0||(u[p]=g),u},{}),d=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((u,m)=>{let{class:p,className:g,...h}=m;return Object.entries(h).every(x=>{let[f,v]=x;return Array.isArray(v)?v.includes({...a,...i}[f]):{...a,...i}[f]===v})?[...u,p,g]:u},[]);return Ot(e,c,d,r?.class,r?.className)},Os=gr("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),k=l.forwardRef(({className:e,variant:t,size:r,asChild:s=!1,...o},a)=>{const c=s?Ns:"button";return n.jsx(c,{ref:a,className:_(Os({variant:t,size:r,className:e})),...o})});k.displayName="Button";const vr="ba.theme";function Ze(){if(typeof window>"u")return"system";const e=window.localStorage.getItem(vr);return e==="light"||e==="dark"||e==="system"?e:"system"}function Je(e){const t=document.documentElement,r=e==="dark"||e==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches;t.classList.toggle("dark",r),t.style.colorScheme=r?"dark":"light"}function Ds(){Je(Ze()),Ze()==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change",()=>{Je("system")})}function Ms(e){window.localStorage.setItem(vr,e),Je(e)}function Ls(){const[e,t]=l.useState(Ze),r=l.useCallback(s=>{Ms(s),t(s)},[]);return l.useEffect(()=>{if(e!=="system")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>t("system");return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[e]),{theme:e,setTheme:r}}function Is(){const{user:e,logout:t}=X(),{theme:r,setTheme:s}=Ls(),o=De(),[a,c]=l.useState(!1);if(!e)return null;const i=async()=>{await t(),o("/login",{replace:!0})};return n.jsxs("header",{className:"flex h-14 items-center justify-between border-b bg-card px-4",children:[n.jsxs(Me,{to:"/",className:"flex items-center gap-2",children:[n.jsx("span",{className:"inline-block h-6 w-6 rounded bg-primary","aria-hidden":!0}),n.jsx("span",{className:"text-sm font-semibold",children:"broad-announce"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[pr(e.role)?n.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:"all companies"}):e.tenant_slug?n.jsx("span",{className:"hidden rounded-md bg-muted px-2 py-1 text-xs sm:inline",children:e.tenant_slug}):null,n.jsxs(k,{variant:"ghost",size:"icon","aria-label":"Toggle theme",onClick:()=>{s(r==="light"?"dark":r==="dark"?"system":"light")},children:[r==="light"&&n.jsx(Nn,{className:"h-4 w-4"}),r==="dark"&&n.jsx(Sn,{className:"h-4 w-4"}),r==="system"&&n.jsx(Cn,{className:"h-4 w-4"})]}),n.jsxs("div",{className:"relative",children:[n.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>c(d=>!d),"aria-haspopup":"menu","aria-expanded":a,children:[n.jsxs("span",{className:"hidden text-right sm:block",children:[n.jsx("span",{className:"block text-xs font-medium",children:e.email}),n.jsx("span",{className:"block text-[10px] uppercase tracking-wider text-muted-foreground",children:e.role.replace("_"," ")})]}),n.jsx(En,{className:"h-4 w-4 opacity-60"})]}),a?n.jsx("div",{role:"menu",className:_("absolute right-0 top-full z-50 mt-1 w-48 rounded-md border bg-card p-1 shadow-md"),onMouseLeave:()=>c(!1),children:n.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center gap-2 rounded px-3 py-2 text-left text-sm hover:bg-accent",children:[n.jsx(_n,{className:"h-4 w-4"}),"Sign out"]})}):null]})]})]})}function Fs(){return n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx(Is,{}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx(ws,{}),n.jsx("main",{className:"flex-1 overflow-auto bg-background p-6",children:n.jsx(un,{})})]})]})}function zs({children:e}){const{user:t,loading:r}=X(),s=Qt();return r?n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t?n.jsx(n.Fragment,{children:e}):n.jsx(Y,{to:"/login",state:{from:s.pathname+s.search},replace:!0})}const M=l.forwardRef(({className:e,type:t,...r},s)=>n.jsx("input",{type:t,className:_("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...r}));M.displayName="Input";var Bs=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],F=Bs.reduce((e,t)=>{const r=ut(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:c,...i}=o,d=c?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...i,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function $s(e,t){e&&ot.flushSync(()=>e.dispatchEvent(t))}var Ws="Label",xr=l.forwardRef((e,t)=>n.jsx(F.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));xr.displayName=Ws;var br=xr;const T=l.forwardRef(({className:e,...t},r)=>n.jsx(br,{ref:r,className:_("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));T.displayName=br.displayName;const me=l.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:_("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));me.displayName="Card";const pe=l.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:_("flex flex-col space-y-1.5 p-6",e),...t}));pe.displayName="CardHeader";const he=l.forwardRef(({className:e,...t},r)=>n.jsx("h3",{ref:r,className:_("text-lg font-semibold leading-none tracking-tight",e),...t}));he.displayName="CardTitle";const Te=l.forwardRef(({className:e,...t},r)=>n.jsx("p",{ref:r,className:_("text-sm text-muted-foreground",e),...t}));Te.displayName="CardDescription";const ge=l.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:_("p-6 pt-0",e),...t}));ge.displayName="CardContent";const Us=l.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:_("flex items-center p-6 pt-0",e),...t}));Us.displayName="CardFooter";function Vs(){const{user:e,login:t,loading:r}=X(),s=De(),a=Qt().state,[c,i]=l.useState(""),[d,u]=l.useState(""),[m,p]=l.useState(!1),[g,h]=l.useState(null);if(r)return null;if(e){const f=a?.from??"/";return n.jsx(Y,{to:f,replace:!0})}const x=async f=>{f.preventDefault(),h(null),p(!0);try{await t(c,d),q.success("Signed in");const v=a?.from??"/";s(v,{replace:!0})}catch(v){const b=v instanceof Error?v.message:"Sign-in failed";h(b),q.error(b)}finally{p(!1)}};return n.jsx("div",{className:"flex h-full items-center justify-center bg-muted/30 p-4",children:n.jsxs(me,{className:"w-full max-w-sm",children:[n.jsxs(pe,{children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[n.jsx("span",{className:"inline-block h-6 w-6 rounded bg-primary","aria-hidden":!0}),n.jsx("span",{className:"text-sm font-semibold",children:"broad-announce"})]}),n.jsx(he,{children:"Sign in"}),n.jsx(Te,{children:"Operator console for the notification router."})]}),n.jsxs(ge,{children:[n.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"email",children:"Email"}),n.jsx(M,{id:"email",type:"email",autoComplete:"email",required:!0,value:c,onChange:f=>i(f.target.value),placeholder:"super@broad-announce.test",disabled:m})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"password",children:"Password"}),n.jsx(M,{id:"password",type:"password",autoComplete:"current-password",required:!0,value:d,onChange:f=>u(f.target.value),disabled:m})]}),g?n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null,n.jsx(k,{type:"submit",className:"w-full",disabled:m,children:m?"Signing in…":"Sign in"})]}),n.jsxs("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:["Bootstrap the first super-admin with"," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"scripts/bootstrap-super-admin.sh"}),"."]})]})]})})}function qs(){const{user:e}=X();if(!e)return n.jsx(Y,{to:"/login",replace:!0});switch(e.role){case"super_admin":return n.jsx(Y,{to:"/companies",replace:!0});case"tenant_admin":return n.jsx(Y,{to:"/sources",replace:!0});case"viewer":return n.jsx(Y,{to:"/dlq",replace:!0});default:return n.jsx(Y,{to:"/login",replace:!0})}}function Gs({title:e,description:t,action:r,icon:s,className:o}){return n.jsxs("div",{className:_("flex flex-col items-center justify-center gap-3 rounded-md border border-dashed bg-card p-10 text-center",o),children:[s?n.jsx("div",{className:"text-muted-foreground",children:s}):null,n.jsx("h3",{className:"text-base font-semibold",children:e}),t?n.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:t}):null,r?n.jsx("div",{className:"mt-2",children:r}):null]})}const yr=l.forwardRef(({className:e,...t},r)=>n.jsx("div",{className:"relative w-full overflow-auto",children:n.jsx("table",{ref:r,className:_("w-full caption-bottom text-sm",e),...t})}));yr.displayName="Table";const wr=l.forwardRef(({className:e,...t},r)=>n.jsx("thead",{ref:r,className:_("[&_tr]:border-b bg-muted/40",e),...t}));wr.displayName="TableHeader";const jr=l.forwardRef(({className:e,...t},r)=>n.jsx("tbody",{ref:r,className:_("[&_tr:last-child]:border-0",e),...t}));jr.displayName="TableBody";const et=l.forwardRef(({className:e,...t},r)=>n.jsx("tr",{ref:r,className:_("border-b transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",e),...t}));et.displayName="TableRow";const K=l.forwardRef(({className:e,...t},r)=>n.jsx("th",{ref:r,className:_("h-10 px-3 text-left align-middle text-xs font-medium uppercase tracking-wider text-muted-foreground",e),...t}));K.displayName="TableHead";const Q=l.forwardRef(({className:e,...t},r)=>n.jsx("td",{ref:r,className:_("p-3 align-middle",e),...t}));Q.displayName="TableCell";const Ie={list:e=>["tenants","list",e],detail:e=>["tenants","detail",e]};function Hs(e){const t=new URLSearchParams;e.q&&t.set("q",e.q),e.status&&t.set("status",e.status),e.limit&&t.set("limit",String(e.limit)),e.offset&&t.set("offset",String(e.offset));const r=t.toString();return r?`/v1/tenants?${r}`:"/v1/tenants"}function Ks(e){return Kt({queryKey:Ie.list(e),queryFn:()=>lt(Hs(e)),staleTime:15e3})}function Qs(e){return Kt({queryKey:Ie.detail(e),queryFn:()=>lt(`/v1/tenants/${e}`),enabled:!!e})}function Ys(){const e=nt();return st({mutationFn:t=>dt("POST","/v1/tenants",t),onSuccess:()=>{e.invalidateQueries({queryKey:["tenants","list"]})}})}function Xs(e){const t=nt();return st({mutationFn:r=>dt("PATCH",`/v1/tenants/${e}`,r),onSuccess:r=>{t.setQueryData(Ie.detail(e),r),t.invalidateQueries({queryKey:["tenants","list"]})}})}function Zs(e){const t=nt();return st({mutationFn:r=>dt("POST",`/v1/tenants/${e}/status`,{status:r}),onSuccess:r=>{t.setQueryData(Ie.detail(e),r),t.invalidateQueries({queryKey:["tenants","list"]})}})}function ke(e){if(e instanceof Le){const t=e.body;return t?.message??t?.error??e.message}return e instanceof Error?e.message:"Unknown error"}var Js=function(e,t){for(var r={};e.length;){var s=e[0],o=s.code,a=s.message,c=s.path.join(".");if(!r[c])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];r[c]={message:i.message,type:i.code}}else r[c]={message:a,type:o};if("unionErrors"in s&&s.unionErrors.forEach(function(m){return m.errors.forEach(function(p){return e.push(p)})}),t){var d=r[c].types,u=d&&d[s.code];r[c]=Mn(c,t,r,o,u?[].concat(u,s.message):s.message)}e.shift()}return r},Nr=function(e,t,r){return r===void 0&&(r={}),function(s,o,a){try{return Promise.resolve(function(c,i){try{var d=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](s,t)).then(function(u){return a.shouldUseNativeValidation&&On({},a),{errors:{},values:r.raw?s:u}})}catch(u){return i(u)}return d&&d.then?d.then(void 0,i):d}(0,function(c){if(function(i){return Array.isArray(i?.errors)}(c))return{values:{},errors:Dn(Js(c.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw c}))}catch(c){return Promise.reject(c)}}};function G(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function eo(e,t=[]){let r=[];function s(a,c){const i=l.createContext(c);i.displayName=a+"Context";const d=r.length;r=[...r,c];const u=p=>{const{scope:g,children:h,...x}=p,f=g?.[e]?.[d]||i,v=l.useMemo(()=>x,Object.values(x));return n.jsx(f.Provider,{value:v,children:h})};u.displayName=a+"Provider";function m(p,g){const h=g?.[e]?.[d]||i,x=l.useContext(h);if(x)return x;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=r.map(c=>l.createContext(c));return function(i){const d=i?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...i,[e]:d}}),[i,d])}};return o.scopeName=e,[s,to(o,...t)]}function to(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const c=s.reduce((i,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...i,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return r.scopeName=t.scopeName,r}var ve=globalThis?.document?l.useLayoutEffect:()=>{},ro=at[" useId ".trim().toString()]||(()=>{}),no=0;function Ue(e){const[t,r]=l.useState(ro());return ve(()=>{r(s=>s??String(no++))},[e]),e||(t?`radix-${t}`:"")}var so=at[" useInsertionEffect ".trim().toString()]||ve;function oo({prop:e,defaultProp:t,onChange:r=()=>{},caller:s}){const[o,a,c]=ao({defaultProp:t,onChange:r}),i=e!==void 0,d=i?e:o;{const m=l.useRef(e!==void 0);l.useEffect(()=>{const p=m.current;p!==i&&console.warn(`${s} is changing from ${p?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),m.current=i},[i,s])}const u=l.useCallback(m=>{if(i){const p=io(m)?m(e):m;p!==e&&c.current?.(p)}else a(m)},[i,e,a,c]);return[d,u]}function ao({defaultProp:e,onChange:t}){const[r,s]=l.useState(e),o=l.useRef(r),a=l.useRef(t);return so(()=>{a.current=t},[t]),l.useEffect(()=>{o.current!==r&&(a.current?.(r),o.current=r)},[r,o]),[r,s,a]}function io(e){return typeof e=="function"}function xe(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...r)=>t.current?.(...r),[])}function co(e,t=globalThis?.document){const r=xe(e);l.useEffect(()=>{const s=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[r,t])}var lo="DismissableLayer",tt="dismissableLayer.update",uo="dismissableLayer.pointerDownOutside",fo="dismissableLayer.focusOutside",Dt,ft=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Sr=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:i,onDismiss:d,...u}=e,m=l.useContext(ft),[p,g]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,x]=l.useState({}),f=Z(t,E=>g(E)),v=Array.from(m.layers),[b]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),j=p?v.indexOf(p):-1,N=m.layersWithOutsidePointerEventsDisabled.size>0,C=j>=y,P=l.useRef(!1),A=go(E=>{const O=E.target;if(!(O instanceof Node))return;const D=[...m.branches].some(S=>S.contains(O));!C||D||(a?.(E),i?.(E),E.defaultPrevented||d?.())},{ownerDocument:h,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:P,dismissableSurfaces:m.dismissableSurfaces}),$=vo(E=>{if(s&&P.current)return;const O=E.target;[...m.branches].some(S=>S.contains(O))||(c?.(E),i?.(E),E.defaultPrevented||d?.())},h);return co(E=>{j===m.layers.size-1&&(o?.(E),!E.defaultPrevented&&d&&(E.preventDefault(),d()))},h),l.useEffect(()=>{if(p)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(Dt=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),Mt(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(p),m.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Dt))}},[p,h,r,m]),l.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),Mt())},[p,m]),l.useEffect(()=>{const E=()=>x({});return document.addEventListener(tt,E),()=>document.removeEventListener(tt,E)},[]),n.jsx(F.div,{...u,ref:f,style:{pointerEvents:N?C?"auto":"none":void 0,...e.style},onFocusCapture:G(e.onFocusCapture,$.onFocusCapture),onBlurCapture:G(e.onBlurCapture,$.onBlurCapture),onPointerDownCapture:G(e.onPointerDownCapture,A.onPointerDownCapture)})});Sr.displayName=lo;var mo="DismissableLayerBranch",po=l.forwardRef((e,t)=>{const r=l.useContext(ft),s=l.useRef(null),o=Z(t,s);return l.useEffect(()=>{const a=s.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(F.div,{...e,ref:o})});po.displayName=mo;function ho(){const e=l.useContext(ft),[t,r]=l.useState(null);return l.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),r}function go(e,t){const{ownerDocument:r=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a}=t,c=xe(e),i=l.useRef(!1),d=l.useRef(!1),u=l.useRef(new Map),m=l.useRef(()=>{});return l.useEffect(()=>{function p(){d.current=!1,o.current=!1,u.current.clear()}function g(){return Array.from(u.current.values()).some(Boolean)}function h(y){if(!d.current)return;const j=y.target;j instanceof Node&&[...a].some(C=>C.contains(j))||u.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{d.current&&m.current()},0)}function x(y){d.current&&u.current.set(y.type,!1)}const f=y=>{if(y.target&&!i.current){let j=function(){r.removeEventListener("click",m.current);const C=g();p(),C||Cr(uo,c,N,{discrete:!0})};const N={originalEvent:y};d.current=!0,o.current=s&&y.button===0,u.current.clear(),!s||y.button!==0?j():(r.removeEventListener("click",m.current),m.current=j,r.addEventListener("click",m.current,{once:!0}))}else r.removeEventListener("click",m.current),p();i.current=!1},v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of v)r.addEventListener(y,h,!0),r.addEventListener(y,x);const b=window.setTimeout(()=>{r.addEventListener("pointerdown",f)},0);return()=>{window.clearTimeout(b),r.removeEventListener("pointerdown",f),r.removeEventListener("click",m.current);for(const y of v)r.removeEventListener(y,h,!0),r.removeEventListener(y,x)}},[r,c,s,o,a]),{onPointerDownCapture:()=>i.current=!0}}function vo(e,t=globalThis?.document){const r=xe(e),s=l.useRef(!1);return l.useEffect(()=>{const o=a=>{a.target&&!s.current&&Cr(fo,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Mt(){const e=new CustomEvent(tt);document.dispatchEvent(e)}function Cr(e,t,r,{discrete:s}){const o=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),s?$s(o,a):o.dispatchEvent(a)}var Ve="focusScope.autoFocusOnMount",qe="focusScope.autoFocusOnUnmount",Lt={bubbles:!1,cancelable:!0},xo="FocusScope",Er=l.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...c}=e,[i,d]=l.useState(null),u=xe(o),m=xe(a),p=l.useRef(null),g=Z(t,f=>d(f)),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(s){let f=function(j){if(h.paused||!i)return;const N=j.target;i.contains(N)?p.current=N:V(p.current,{select:!0})},v=function(j){if(h.paused||!i)return;const N=j.relatedTarget;N!==null&&(i.contains(N)||V(p.current,{select:!0}))},b=function(j){if(document.activeElement===document.body)for(const C of j)C.removedNodes.length>0&&V(i)};document.addEventListener("focusin",f),document.addEventListener("focusout",v);const y=new MutationObserver(b);return i&&y.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",f),document.removeEventListener("focusout",v),y.disconnect()}}},[s,i,h.paused]),l.useEffect(()=>{if(i){Ft.add(h);const f=document.activeElement;if(!i.contains(f)){const b=new CustomEvent(Ve,Lt);i.addEventListener(Ve,u),i.dispatchEvent(b),b.defaultPrevented||(bo(So(_r(i)),{select:!0}),document.activeElement===f&&V(i))}return()=>{i.removeEventListener(Ve,u),setTimeout(()=>{const b=new CustomEvent(qe,Lt);i.addEventListener(qe,m),i.dispatchEvent(b),b.defaultPrevented||V(f??document.body,{select:!0}),i.removeEventListener(qe,m),Ft.remove(h)},0)}}},[i,u,m,h]);const x=l.useCallback(f=>{if(!r&&!s||h.paused)return;const v=f.key==="Tab"&&!f.altKey&&!f.ctrlKey&&!f.metaKey,b=document.activeElement;if(v&&b){const y=f.currentTarget,[j,N]=yo(y);j&&N?!f.shiftKey&&b===N?(f.preventDefault(),r&&V(j,{select:!0})):f.shiftKey&&b===j&&(f.preventDefault(),r&&V(N,{select:!0})):b===y&&f.preventDefault()}},[r,s,h.paused]);return n.jsx(F.div,{tabIndex:-1,...c,ref:g,onKeyDown:x})});Er.displayName=xo;function bo(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(V(s,{select:t}),document.activeElement!==r)return}function yo(e){const t=_r(e),r=It(t,e),s=It(t.reverse(),e);return[r,s]}function _r(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function It(e,t){for(const r of e)if(!wo(r,{upTo:t}))return r}function wo(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function jo(e){return e instanceof HTMLInputElement&&"select"in e}function V(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&jo(e)&&t&&e.select()}}var Ft=No();function No(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=zt(e,t),e.unshift(t)},remove(t){e=zt(e,t),e[0]?.resume()}}}function zt(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function So(e){return e.filter(t=>t.tagName!=="A")}var Co="Portal",Rr=l.forwardRef((e,t)=>{const{container:r,...s}=e,[o,a]=l.useState(!1);ve(()=>a(!0),[]);const c=r||o&&globalThis?.document?.body;return c?ot.createPortal(n.jsx(F.div,{...s,ref:t}),c):null});Rr.displayName=Co;function Eo(e,t){return l.useReducer((r,s)=>t[r][s]??r,e)}var Fe=e=>{const{present:t,children:r}=e,s=_o(t),o=typeof r=="function"?r({present:s.isPresent}):l.Children.only(r),a=Ro(s.ref,ko(o));return typeof r=="function"||s.isPresent?l.cloneElement(o,{ref:a}):null};Fe.displayName="Presence";function _o(e){const[t,r]=l.useState(),s=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),c=e?"mounted":"unmounted",[i,d]=Eo(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=Ne(s.current);a.current=i==="mounted"?u:"none"},[i]),ve(()=>{const u=s.current,m=o.current;if(m!==e){const g=a.current,h=Ne(u);e?d("MOUNT"):h==="none"||u?.display==="none"?d("UNMOUNT"):d(m&&g!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),ve(()=>{if(t){let u;const m=t.ownerDocument.defaultView??window,p=h=>{const f=Ne(s.current).includes(CSS.escape(h.animationName));if(h.target===t&&f&&(d("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},g=h=>{h.target===t&&(a.current=Ne(s.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(u),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,r(u)},[])}}function Bt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ro(...e){const t=l.useRef(e);return t.current=e,l.useCallback(r=>{const s=t.current;let o=!1;const a=s.map(c=>{const i=Bt(c,r);return!o&&typeof i=="function"&&(o=!0),i});if(o)return()=>{for(let c=0;c<a.length;c++){const i=a[c];typeof i=="function"?i():Bt(s[c],null)}}},[])}function Ne(e){return e?.animationName||"none"}function ko(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Se=0,J=null;function Po(){l.useEffect(()=>{J||(J={start:$t(),end:$t()});const{start:e,end:t}=J;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Se++,()=>{Se===1&&(J?.start.remove(),J?.end.remove(),J=null),Se=Math.max(0,Se-1)}},[])}function $t(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var I=function(){return I=Object.assign||function(t){for(var r,s=1,o=arguments.length;s<o;s++){r=arguments[s];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},I.apply(this,arguments)};function kr(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function Ao(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var Pe="right-scroll-bar-position",Ae="width-before-scroll-bar",To="with-scroll-bars-hidden",Oo="--removed-body-scroll-bar-size";function Ge(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Do(e,t){var r=l.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(s){var o=r.value;o!==s&&(r.value=s,r.callback(s,o))}}}})[0];return r.callback=t,r.facade}var Mo=typeof window<"u"?l.useLayoutEffect:l.useEffect,Wt=new WeakMap;function Lo(e,t){var r=Do(null,function(s){return e.forEach(function(o){return Ge(o,s)})});return Mo(function(){var s=Wt.get(r);if(s){var o=new Set(s),a=new Set(e),c=r.current;o.forEach(function(i){a.has(i)||Ge(i,null)}),a.forEach(function(i){o.has(i)||Ge(i,c)})}Wt.set(r,e)},[e]),r}function Io(e){return e}function Fo(e,t){t===void 0&&(t=Io);var r=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(a){var c=t(a,s);return r.push(c),function(){r=r.filter(function(i){return i!==c})}},assignSyncMedium:function(a){for(s=!0;r.length;){var c=r;r=[],c.forEach(a)}r={push:function(i){return a(i)},filter:function(){return r}}},assignMedium:function(a){s=!0;var c=[];if(r.length){var i=r;r=[],i.forEach(a),c=r}var d=function(){var m=c;c=[],m.forEach(a)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(m){c.push(m),u()},filter:function(m){return c=c.filter(m),r}}}};return o}function zo(e){e===void 0&&(e={});var t=Fo(null);return t.options=I({async:!0,ssr:!1},e),t}var Pr=function(e){var t=e.sideCar,r=kr(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return l.createElement(s,I({},r))};Pr.isSideCarExport=!0;function Bo(e,t){return e.useMedium(t),Pr}var Ar=zo(),He=function(){},ze=l.forwardRef(function(e,t){var r=l.useRef(null),s=l.useState({onScrollCapture:He,onWheelCapture:He,onTouchMoveCapture:He}),o=s[0],a=s[1],c=e.forwardProps,i=e.children,d=e.className,u=e.removeScrollBar,m=e.enabled,p=e.shards,g=e.sideCar,h=e.noRelative,x=e.noIsolation,f=e.inert,v=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,j=e.gapMode,N=kr(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=g,P=Lo([r,t]),A=I(I({},N),o);return l.createElement(l.Fragment,null,m&&l.createElement(C,{sideCar:Ar,removeScrollBar:u,shards:p,noRelative:h,noIsolation:x,inert:f,setCallbacks:a,allowPinchZoom:!!v,lockRef:r,gapMode:j}),c?l.cloneElement(l.Children.only(i),I(I({},A),{ref:P})):l.createElement(y,I({},A,{className:d,ref:P}),i))});ze.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ze.classNames={fullWidth:Ae,zeroRight:Pe};var $o=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Wo(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=$o();return t&&e.setAttribute("nonce",t),e}function Uo(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vo(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var qo=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Wo())&&(Uo(t,r),Vo(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Go=function(){var e=qo();return function(t,r){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Tr=function(){var e=Go(),t=function(r){var s=r.styles,o=r.dynamic;return e(s,o),null};return t},Ho={left:0,top:0,right:0,gap:0},Ke=function(e){return parseInt(e||"",10)||0},Ko=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Ke(r),Ke(s),Ke(o)]},Qo=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ho;var t=Ko(e),r=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-r+t[2]-t[0])}},Yo=Tr(),se="data-scroll-locked",Xo=function(e,t,r,s){var o=e.left,a=e.top,c=e.right,i=e.gap;return r===void 0&&(r="margin"),`
- .`.concat(To,` {
- overflow: hidden `).concat(s,`;
- padding-right: `).concat(i,"px ").concat(s,`;
- }
- body[`).concat(se,`] {
- overflow: hidden `).concat(s,`;
- overscroll-behavior: contain;
- `).concat([t&&"position: relative ".concat(s,";"),r==="margin"&&`
- padding-left: `.concat(o,`px;
- padding-top: `).concat(a,`px;
- padding-right: `).concat(c,`px;
- margin-left:0;
- margin-top:0;
- margin-right: `).concat(i,"px ").concat(s,`;
- `),r==="padding"&&"padding-right: ".concat(i,"px ").concat(s,";")].filter(Boolean).join(""),`
- }
-
- .`).concat(Pe,` {
- right: `).concat(i,"px ").concat(s,`;
- }
-
- .`).concat(Ae,` {
- margin-right: `).concat(i,"px ").concat(s,`;
- }
-
- .`).concat(Pe," .").concat(Pe,` {
- right: 0 `).concat(s,`;
- }
-
- .`).concat(Ae," .").concat(Ae,` {
- margin-right: 0 `).concat(s,`;
- }
-
- body[`).concat(se,`] {
- `).concat(Oo,": ").concat(i,`px;
- }
- `)},Ut=function(){var e=parseInt(document.body.getAttribute(se)||"0",10);return isFinite(e)?e:0},Zo=function(){l.useEffect(function(){return document.body.setAttribute(se,(Ut()+1).toString()),function(){var e=Ut()-1;e<=0?document.body.removeAttribute(se):document.body.setAttribute(se,e.toString())}},[])},Jo=function(e){var t=e.noRelative,r=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;Zo();var a=l.useMemo(function(){return Qo(o)},[o]);return l.createElement(Yo,{styles:Xo(a,!t,o,r?"":"!important")})},rt=!1;if(typeof window<"u")try{var Ce=Object.defineProperty({},"passive",{get:function(){return rt=!0,!0}});window.addEventListener("test",Ce,Ce),window.removeEventListener("test",Ce,Ce)}catch{rt=!1}var ee=rt?{passive:!1}:!1,ea=function(e){return e.tagName==="TEXTAREA"},Or=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!ea(e)&&r[t]==="visible")},ta=function(e){return Or(e,"overflowY")},ra=function(e){return Or(e,"overflowX")},Vt=function(e,t){var r=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Dr(e,s);if(o){var a=Mr(e,s),c=a[1],i=a[2];if(c>i)return!0}s=s.parentNode}while(s&&s!==r.body);return!1},na=function(e){var t=e.scrollTop,r=e.scrollHeight,s=e.clientHeight;return[t,r,s]},sa=function(e){var t=e.scrollLeft,r=e.scrollWidth,s=e.clientWidth;return[t,r,s]},Dr=function(e,t){return e==="v"?ta(t):ra(t)},Mr=function(e,t){return e==="v"?na(t):sa(t)},oa=function(e,t){return e==="h"&&t==="rtl"?-1:1},aa=function(e,t,r,s,o){var a=oa(e,window.getComputedStyle(t).direction),c=a*s,i=r.target,d=t.contains(i),u=!1,m=c>0,p=0,g=0;do{if(!i)break;var h=Mr(e,i),x=h[0],f=h[1],v=h[2],b=f-v-a*x;(x||b)&&Dr(e,i)&&(p+=b,g+=x);var y=i.parentNode;i=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&i!==document.body||d&&(t.contains(i)||t===i));return(m&&Math.abs(p)<1||!m&&Math.abs(g)<1)&&(u=!0),u},Ee=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},qt=function(e){return[e.deltaX,e.deltaY]},Gt=function(e){return e&&"current"in e?e.current:e},ia=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ca=function(e){return`
- .block-interactivity-`.concat(e,` {pointer-events: none;}
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
- `)},la=0,te=[];function da(e){var t=l.useRef([]),r=l.useRef([0,0]),s=l.useRef(),o=l.useState(la++)[0],a=l.useState(Tr)[0],c=l.useRef(e);l.useEffect(function(){c.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var f=Ao([e.lockRef.current],(e.shards||[]).map(Gt),!0).filter(Boolean);return f.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),f.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=l.useCallback(function(f,v){if("touches"in f&&f.touches.length===2||f.type==="wheel"&&f.ctrlKey)return!c.current.allowPinchZoom;var b=Ee(f),y=r.current,j="deltaX"in f?f.deltaX:y[0]-b[0],N="deltaY"in f?f.deltaY:y[1]-b[1],C,P=f.target,A=Math.abs(j)>Math.abs(N)?"h":"v";if("touches"in f&&A==="h"&&P.type==="range")return!1;var $=window.getSelection(),E=$&&$.anchorNode,O=E?E===P||E.contains(P):!1;if(O)return!1;var D=Vt(A,P);if(!D)return!0;if(D?C=A:(C=A==="v"?"h":"v",D=Vt(A,P)),!D)return!1;if(!s.current&&"changedTouches"in f&&(j||N)&&(s.current=C),!C)return!0;var S=s.current||C;return aa(S,v,f,S==="h"?j:N)},[]),d=l.useCallback(function(f){var v=f;if(!(!te.length||te[te.length-1]!==a)){var b="deltaY"in v?qt(v):Ee(v),y=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&ia(C.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var j=(c.current.shards||[]).map(Gt).filter(Boolean).filter(function(C){return C.contains(v.target)}),N=j.length>0?i(v,j[0]):!c.current.noIsolation;N&&v.cancelable&&v.preventDefault()}}},[]),u=l.useCallback(function(f,v,b,y){var j={name:f,delta:v,target:b,should:y,shadowParent:ua(b)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(N){return N!==j})},1)},[]),m=l.useCallback(function(f){r.current=Ee(f),s.current=void 0},[]),p=l.useCallback(function(f){u(f.type,qt(f),f.target,i(f,e.lockRef.current))},[]),g=l.useCallback(function(f){u(f.type,Ee(f),f.target,i(f,e.lockRef.current))},[]);l.useEffect(function(){return te.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",d,ee),document.addEventListener("touchmove",d,ee),document.addEventListener("touchstart",m,ee),function(){te=te.filter(function(f){return f!==a}),document.removeEventListener("wheel",d,ee),document.removeEventListener("touchmove",d,ee),document.removeEventListener("touchstart",m,ee)}},[]);var h=e.removeScrollBar,x=e.inert;return l.createElement(l.Fragment,null,x?l.createElement(a,{styles:ca(o)}):null,h?l.createElement(Jo,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ua(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const fa=Bo(Ar,da);var Lr=l.forwardRef(function(e,t){return l.createElement(ze,I({},e,{ref:t,sideCar:fa}))});Lr.classNames=ze.classNames;var ma=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},re=new WeakMap,_e=new WeakMap,Re={},Qe=0,Ir=function(e){return e&&(e.host||Ir(e.parentNode))},pa=function(e,t){return t.map(function(r){if(e.contains(r))return r;var s=Ir(r);return s&&e.contains(s)?s:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},ha=function(e,t,r,s){var o=pa(t,Array.isArray(e)?e:[e]);Re[r]||(Re[r]=new WeakMap);var a=Re[r],c=[],i=new Set,d=new Set(o),u=function(p){!p||i.has(p)||(i.add(p),u(p.parentNode))};o.forEach(u);var m=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(g){if(i.has(g))m(g);else try{var h=g.getAttribute(s),x=h!==null&&h!=="false",f=(re.get(g)||0)+1,v=(a.get(g)||0)+1;re.set(g,f),a.set(g,v),c.push(g),f===1&&x&&_e.set(g,!0),v===1&&g.setAttribute(r,"true"),x||g.setAttribute(s,"true")}catch(b){console.error("aria-hidden: cannot operate on ",g,b)}})};return m(t),i.clear(),Qe++,function(){c.forEach(function(p){var g=re.get(p)-1,h=a.get(p)-1;re.set(p,g),a.set(p,h),g||(_e.has(p)||p.removeAttribute(s),_e.delete(p)),h||p.removeAttribute(r)}),Qe--,Qe||(re=new WeakMap,re=new WeakMap,_e=new WeakMap,Re={})}},ga=function(e,t,r){r===void 0&&(r="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=ma(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),ha(s,o,r,"aria-hidden")):function(){return null}},Be="Dialog",[Fr]=eo(Be),[va,L]=Fr(Be),zr=e=>{const{__scopeDialog:t,children:r,open:s,defaultOpen:o,onOpenChange:a,modal:c=!0}=e,i=l.useRef(null),d=l.useRef(null),[u,m]=oo({prop:s,defaultProp:o??!1,onChange:a,caller:Be});return n.jsx(va,{scope:t,triggerRef:i,contentRef:d,contentId:Ue(),titleId:Ue(),descriptionId:Ue(),open:u,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(p=>!p),[m]),modal:c,children:r})};zr.displayName=Be;var Br="DialogTrigger",$r=l.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=L(Br,r),a=Z(t,o.triggerRef);return n.jsx(F.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":ht(o.open),...s,ref:a,onClick:G(e.onClick,o.onOpenToggle)})});$r.displayName=Br;var mt="DialogPortal",[xa,Wr]=Fr(mt,{forceMount:void 0}),Ur=e=>{const{__scopeDialog:t,forceMount:r,children:s,container:o}=e,a=L(mt,t);return n.jsx(xa,{scope:t,forceMount:r,children:l.Children.map(s,c=>n.jsx(Fe,{present:r||a.open,children:n.jsx(Rr,{asChild:!0,container:o,children:c})}))})};Ur.displayName=mt;var Oe="DialogOverlay",Vr=l.forwardRef((e,t)=>{const r=Wr(Oe,e.__scopeDialog),{forceMount:s=r.forceMount,...o}=e,a=L(Oe,e.__scopeDialog);return a.modal?n.jsx(Fe,{present:s||a.open,children:n.jsx(ya,{...o,ref:t})}):null});Vr.displayName=Oe;var ba=ut("DialogOverlay.RemoveScroll"),ya=l.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=L(Oe,r),a=ho(),c=Z(t,a);return n.jsx(Lr,{as:ba,allowPinchZoom:!0,shards:[o.contentRef],children:n.jsx(F.div,{"data-state":ht(o.open),...s,ref:c,style:{pointerEvents:"auto",...s.style}})})}),oe="DialogContent",qr=l.forwardRef((e,t)=>{const r=Wr(oe,e.__scopeDialog),{forceMount:s=r.forceMount,...o}=e,a=L(oe,e.__scopeDialog);return n.jsx(Fe,{present:s||a.open,children:a.modal?n.jsx(wa,{...o,ref:t}):n.jsx(ja,{...o,ref:t})})});qr.displayName=oe;var wa=l.forwardRef((e,t)=>{const r=L(oe,e.__scopeDialog),s=l.useRef(null),o=Z(t,r.contentRef,s);return l.useEffect(()=>{const a=s.current;if(a)return ga(a)},[]),n.jsx(Gr,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:G(e.onCloseAutoFocus,a=>{a.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&a.preventDefault()}),onFocusOutside:G(e.onFocusOutside,a=>a.preventDefault())})}),ja=l.forwardRef((e,t)=>{const r=L(oe,e.__scopeDialog),s=l.useRef(!1),o=l.useRef(!1);return n.jsx(Gr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||r.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=a.target;r.triggerRef.current?.contains(c)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Gr=l.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...c}=e,i=L(oe,r);return Po(),n.jsx(n.Fragment,{children:n.jsx(Er,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:n.jsx(Sr,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":ht(i.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>i.onOpenChange(!1)})})})}),Hr="DialogTitle",Kr=l.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=L(Hr,r);return n.jsx(F.h2,{id:o.titleId,...s,ref:t})});Kr.displayName=Hr;var Qr="DialogDescription",Yr=l.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=L(Qr,r);return n.jsx(F.p,{id:o.descriptionId,...s,ref:t})});Yr.displayName=Qr;var Xr="DialogClose",pt=l.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=L(Xr,r);return n.jsx(F.button,{type:"button",...s,ref:t,onClick:G(e.onClick,()=>o.onOpenChange(!1))})});pt.displayName=Xr;function ht(e){return e?"open":"closed"}const Zr=zr,Jr=$r,Na=Ur,Sa=pt,en=l.forwardRef(({className:e,...t},r)=>n.jsx(Vr,{ref:r,className:_("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));en.displayName="DialogOverlay";const gt=l.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(Na,{children:[n.jsx(en,{}),n.jsxs(qr,{ref:s,className:_("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg sm:rounded-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","max-h-[90vh] overflow-y-auto",e),...r,children:[t,n.jsxs(pt,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[n.jsx(Rn,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gt.displayName="DialogContent";function tn({className:e,...t}){return n.jsx("div",{className:_("flex flex-col gap-1.5 text-left",e),...t})}function rn({className:e,...t}){return n.jsx("div",{className:_("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end sm:gap-2",e),...t})}const vt=l.forwardRef(({className:e,...t},r)=>n.jsx(Kr,{ref:r,className:_("text-lg font-semibold leading-none tracking-tight",e),...t}));vt.displayName="DialogTitle";const xt=l.forwardRef(({className:e,...t},r)=>n.jsx(Yr,{ref:r,className:_("text-sm text-muted-foreground",e),...t}));xt.displayName="DialogDescription";const Ca=/^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/,Ea=Xt({slug:fe().min(2,"Slug must be 2–64 characters").max(64,"Slug must be 2–64 characters").regex(Ca,"Lowercase letters, digits, and dashes only"),display_name:fe().min(1,"Display name is required"),contact_email:fe().email("Enter a valid email"),rate_limit_per_sec:Jt({invalid_type_error:"Enter a number"}).int("Whole number only").min(1,"Must be at least 1").max(1e6,"Must be at most 1,000,000"),fcm_shared:Zt()});function Ht(){const[e,t]=l.useState(!1),r=De(),s=Ys(),o=er({resolver:Nr(Ea),defaultValues:{slug:"",display_name:"",contact_email:"",rate_limit_per_sec:1e4,fcm_shared:!0}});l.useEffect(()=>{e&&o.reset()},[e,o]);const a=o.handleSubmit(async c=>{const i={slug:c.slug.trim(),display_name:c.display_name.trim(),contact_email:c.contact_email.trim(),rate_limit_per_sec:c.rate_limit_per_sec,fcm_shared:c.fcm_shared};try{const d=await s.mutateAsync(i);q.success(`Created ${d.display_name}`),t(!1),r(`/companies/${d.id}`)}catch(d){const u=ke(d);q.error(u),u.toLowerCase().includes("slug")&&o.setError("slug",{message:u})}});return n.jsxs(Zr,{open:e,onOpenChange:t,children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(k,{children:[n.jsx(kn,{className:"h-4 w-4"}),"New company"]})}),n.jsxs(gt,{children:[n.jsxs(tn,{children:[n.jsx(vt,{children:"New company"}),n.jsx(xt,{children:"The slug becomes part of every event this tenant sends (and shows up in the audit log). Choose carefully — it cannot be changed after creation."})]}),n.jsxs("form",{onSubmit:a,className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"slug",children:"Slug"}),n.jsx(M,{id:"slug",placeholder:"acme-corp",autoComplete:"off",...o.register("slug"),"aria-invalid":!!o.formState.errors.slug}),o.formState.errors.slug?n.jsx("p",{className:"text-xs text-destructive",children:o.formState.errors.slug.message}):n.jsx("p",{className:"text-xs text-muted-foreground",children:"2–64 chars, lowercase + digits + dashes."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"rate_limit_per_sec",children:"Rate limit (events/sec)"}),n.jsx(M,{id:"rate_limit_per_sec",type:"number",min:1,max:1e6,...o.register("rate_limit_per_sec",{valueAsNumber:!0}),"aria-invalid":!!o.formState.errors.rate_limit_per_sec}),o.formState.errors.rate_limit_per_sec?n.jsx("p",{className:"text-xs text-destructive",children:o.formState.errors.rate_limit_per_sec.message}):null]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"display_name",children:"Display name"}),n.jsx(M,{id:"display_name",placeholder:"Acme Corporation",...o.register("display_name"),"aria-invalid":!!o.formState.errors.display_name}),o.formState.errors.display_name?n.jsx("p",{className:"text-xs text-destructive",children:o.formState.errors.display_name.message}):null]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"contact_email",children:"Contact email"}),n.jsx(M,{id:"contact_email",type:"email",placeholder:"ops@acme.example",autoComplete:"off",...o.register("contact_email"),"aria-invalid":!!o.formState.errors.contact_email}),o.formState.errors.contact_email?n.jsx("p",{className:"text-xs text-destructive",children:o.formState.errors.contact_email.message}):null]}),n.jsxs("div",{className:"flex items-start gap-2 rounded-md border bg-muted/40 p-3",children:[n.jsx("input",{id:"fcm_shared",type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-input",...o.register("fcm_shared")}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(T,{htmlFor:"fcm_shared",className:"cursor-pointer",children:"Use shared FCM pool"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Default. Only turn this off for high-volume tenants that need a dedicated sender ID (M13b W3 territory)."})]})]}),n.jsxs(rn,{children:[n.jsx(k,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:s.isPending,children:"Cancel"}),n.jsx(k,{type:"submit",disabled:s.isPending,children:s.isPending?"Creating…":"Create company"})]})]})]})]})}const _a=gr("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground",success:"border-transparent bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300",warning:"border-transparent bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300",danger:"border-transparent bg-rose-100 text-rose-800 dark:bg-rose-900/30 dark:text-rose-300",muted:"border-transparent bg-muted text-muted-foreground"}},defaultVariants:{variant:"default"}}),nn=l.forwardRef(({className:e,variant:t,...r},s)=>n.jsx("span",{ref:s,className:_(_a({variant:t}),e),...r}));nn.displayName="Badge";const Ra={active:"Active",suspended:"Suspended",archived:"Archived"},ka={active:"success",suspended:"warning",archived:"muted"};function Pa(e){return Ra[e]??e}function Aa(e){return ka[e]??"muted"}function sn({status:e}){return n.jsx(nn,{variant:Aa(e),children:Pa(e)})}function on(e){return e>=1e6?`${(e/1e6).toFixed(1)}M/s`:e>=1e3?`${(e/1e3).toFixed(1)}k/s`:`${e}/s`}function ue(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const Ta=[{value:"",label:"All"},{value:"active",label:"Active"},{value:"suspended",label:"Suspended"},{value:"archived",label:"Archived"}];function Oa(){const[e,t]=fn(),[r,s]=l.useState(e.get("q")??""),o=e.get("status")??"",{user:a}=X(),c=hr(a?.role);l.useEffect(()=>{const h=setTimeout(()=>{const x=new URLSearchParams(e);r.trim()?x.set("q",r.trim()):x.delete("q"),t(x,{replace:!0})},300);return()=>clearTimeout(h)},[r]);const i=l.useMemo(()=>({q:e.get("q")??void 0,status:o||void 0,limit:100}),[e,o]),{data:d,isPending:u,isError:m,error:p,refetch:g}=Ks(i);return n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Companies"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the tenants that send events to the router."})]}),c?n.jsx(Ht,{}):null]}),n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[n.jsxs("div",{className:"relative flex-1 sm:max-w-sm",children:[n.jsx(Pn,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(M,{placeholder:"Search by slug or name",className:"pl-8",value:r,onChange:h=>s(h.target.value),"aria-label":"Search companies"})]}),n.jsx("div",{className:"flex gap-1",children:Ta.map(h=>{const x=o===h.value;return n.jsx(k,{variant:x?"secondary":"ghost",size:"sm",onClick:()=>{const f=new URLSearchParams(e);h.value?f.set("status",h.value):f.delete("status"),t(f,{replace:!0})},children:h.label},h.value)})})]}),m?n.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[n.jsx("p",{className:"font-medium",children:"Failed to load companies."}),n.jsx("p",{className:"mt-1 text-xs opacity-80",children:p instanceof Error?p.message:"Unknown error"}),n.jsx(k,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>g(),children:"Retry"})]}):null,u?n.jsx("div",{className:"rounded-md border bg-card p-8 text-center text-sm text-muted-foreground",children:"Loading…"}):d&&d.items.length===0?n.jsx(Gs,{icon:n.jsx(Yt,{className:"h-8 w-8"}),title:"No companies yet",description:c?"Create the first company to start routing events.":"You will see your company here once it has been set up.",action:c?n.jsx(Ht,{}):null}):d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"rounded-md border bg-card",children:n.jsxs(yr,{children:[n.jsx(wr,{children:n.jsxs(et,{children:[n.jsx(K,{children:"Name"}),n.jsx(K,{children:"Slug"}),n.jsx(K,{children:"Status"}),n.jsx(K,{className:"text-right",children:"Rate limit"}),n.jsx(K,{children:"FCM"}),n.jsx(K,{children:"Created"})]})}),n.jsx(jr,{children:d.items.map(h=>n.jsxs(et,{children:[n.jsx(Q,{children:n.jsx(Me,{to:`/companies/${h.id}`,className:"font-medium text-foreground hover:underline",children:h.display_name})}),n.jsx(Q,{children:n.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:h.slug})}),n.jsx(Q,{children:n.jsx(sn,{status:h.status})}),n.jsx(Q,{className:"text-right tabular-nums",children:on(h.rate_limit_per_sec)}),n.jsx(Q,{className:"text-xs text-muted-foreground",children:h.fcm_shared?"shared":"dedicated"}),n.jsx(Q,{className:"text-xs text-muted-foreground",children:ue(h.created_at)})]},h.id))})]})}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing ",d.items.length," of ",d.total]})]}):null]})}const Da=Xt({display_name:fe().min(1,"Display name is required"),contact_email:fe().email("Enter a valid email"),rate_limit_per_sec:Jt({invalid_type_error:"Enter a number"}).int("Whole number only").min(1).max(1e6),fcm_shared:Zt()}),Ma={display_name:"",contact_email:"",rate_limit_per_sec:1e4,fcm_shared:!0};function La(){const{id:e=""}=mn(),t=De(),{user:r}=X(),s=pr(r?.role),o=xs(r?.role),a=Qs(e),c=Xs(e),i=Zs(e),d=er({resolver:Nr(Da),defaultValues:Ma});if(l.useEffect(()=>{const g=a.data;g&&(d.setValue("display_name",g.display_name),d.setValue("contact_email",g.contact_email),d.setValue("rate_limit_per_sec",g.rate_limit_per_sec),d.setValue("fcm_shared",g.fcm_shared))},[a.data,d]),!o)return n.jsx("div",{className:"rounded-md border bg-card p-6 text-sm text-muted-foreground",children:"You do not have access to this company."});if(a.isError){const g=ke(a.error);return n.jsxs("div",{className:"space-y-3",children:[n.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>t("/companies"),children:[n.jsx(St,{className:"h-4 w-4"}),"Back"]}),n.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:g})]})}if(!a.data)return n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading…"});const u=a.data,m=d.handleSubmit(async g=>{try{await c.mutateAsync({display_name:g.display_name.trim(),contact_email:g.contact_email.trim(),rate_limit_per_sec:g.rate_limit_per_sec,fcm_shared:g.fcm_shared}),q.success("Saved")}catch(h){q.error(ke(h))}}),p=async g=>{try{await i.mutateAsync(g),q.success(`Status set to ${g}`)}catch(h){q.error(ke(h))}};return n.jsxs("div",{className:"flex flex-col gap-6",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs(k,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>t("/companies"),children:[n.jsx(St,{className:"h-4 w-4"}),"Back to companies"]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:u.display_name}),n.jsx(sn,{status:u.status})]}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:u.slug}),n.jsx("span",{className:"mx-2 opacity-50",children:"·"}),"created ",ue(u.created_at)]})]}),n.jsxs("div",{className:"grid gap-6 md:grid-cols-3",children:[n.jsxs(me,{className:"md:col-span-2",children:[n.jsxs(pe,{children:[n.jsx(he,{children:"Details"}),n.jsx(Te,{children:s?"All fields are editable.":"Display name and contact email are editable. Other fields require a super-admin."})]}),n.jsx(ge,{children:n.jsxs("form",{onSubmit:m,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"display_name",children:"Display name"}),n.jsx(M,{id:"display_name",...d.register("display_name"),"aria-invalid":!!d.formState.errors.display_name}),d.formState.errors.display_name?n.jsx("p",{className:"text-xs text-destructive",children:d.formState.errors.display_name.message}):null]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"contact_email",children:"Contact email"}),n.jsx(M,{id:"contact_email",type:"email",autoComplete:"off",...d.register("contact_email"),"aria-invalid":!!d.formState.errors.contact_email}),d.formState.errors.contact_email?n.jsx("p",{className:"text-xs text-destructive",children:d.formState.errors.contact_email.message}):null]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{htmlFor:"rate_limit_per_sec",children:"Rate limit"}),n.jsx(M,{id:"rate_limit_per_sec",type:"number",min:1,max:1e6,disabled:!s,...d.register("rate_limit_per_sec",{valueAsNumber:!0}),"aria-invalid":!!d.formState.errors.rate_limit_per_sec}),d.formState.errors.rate_limit_per_sec?n.jsx("p",{className:"text-xs text-destructive",children:d.formState.errors.rate_limit_per_sec.message}):null]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(T,{children:"FCM pool"}),n.jsxs("label",{className:"flex items-center gap-2 rounded-md border bg-muted/40 p-2 text-sm",children:[n.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-input",disabled:!s,...d.register("fcm_shared")}),"Use shared FCM pool"]})]})]}),n.jsx("div",{className:"flex justify-end",children:n.jsx(k,{type:"submit",disabled:c.isPending,children:c.isPending?"Saving…":"Save changes"})})]})})]}),n.jsxs("div",{className:"space-y-4",children:[s?n.jsxs(me,{children:[n.jsxs(pe,{children:[n.jsx(he,{children:"Status"}),n.jsx(Te,{children:"Suspending stops new ingest immediately. Archiving is permanent and is only used to retire a tenant."})]}),n.jsxs(ge,{className:"space-y-2",children:[u.status==="active"?n.jsx(k,{variant:"outline",className:"w-full",disabled:i.isPending,onClick:()=>void p("suspended"),children:"Suspend"}):u.status==="suspended"?n.jsx(k,{variant:"default",className:"w-full",disabled:i.isPending,onClick:()=>void p("active"),children:"Activate"}):null,u.status!=="archived"?n.jsx(Ia,{onConfirm:()=>void p("archived"),pending:i.isPending}):n.jsx("p",{className:"rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground",children:"Archived. Status changes are not allowed."})]})]}):null,n.jsxs(me,{children:[n.jsx(pe,{children:n.jsx(he,{className:"text-base",children:"Metadata"})}),n.jsxs(ge,{className:"space-y-2 text-sm",children:[n.jsx(H,{label:"ID",value:n.jsx("code",{className:"text-xs",children:u.id})}),n.jsx(H,{label:"Slug",value:n.jsx("code",{className:"text-xs",children:u.slug})}),n.jsx(H,{label:"Rate limit",value:on(u.rate_limit_per_sec)}),n.jsx(H,{label:"FCM",value:u.fcm_shared?"shared":"dedicated"}),n.jsx(H,{label:"Created",value:ue(u.created_at)}),n.jsx(H,{label:"Updated",value:ue(u.updated_at)}),u.archived_at?n.jsx(H,{label:"Archived",value:ue(u.archived_at)}):null]})]})]})]})]})}function H({label:e,value:t}){return n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e}),n.jsx("span",{className:"text-right",children:t})]})}function Ia({onConfirm:e,pending:t}){return n.jsxs(Zr,{children:[n.jsx(Jr,{asChild:!0,children:n.jsx(k,{variant:"destructive",className:"w-full",disabled:t,children:"Archive…"})}),n.jsxs(gt,{children:[n.jsxs(tn,{children:[n.jsxs(vt,{className:"flex items-center gap-2",children:[n.jsx(An,{className:"h-4 w-4 text-destructive"}),"Archive this company?"]}),n.jsxs(xt,{children:["Archiving is ",n.jsx("strong",{children:"permanent"}),": the tenant cannot be reactivated, and new events will be rejected. Existing rows (deliveries, audit, DLQ) are kept for compliance but are not surfaced in the UI."]})]}),n.jsxs(rn,{children:[n.jsx(Sa,{asChild:!0,children:n.jsx(k,{variant:"ghost",disabled:t,children:"Cancel"})}),n.jsx(k,{variant:"destructive",disabled:t,onClick:e,children:t?"Archiving…":"Archive company"})]})]})]})}function Fa(){return n.jsxs(pn,{children:[n.jsx(Nt,{index:!0,element:n.jsx(Oa,{})}),n.jsx(Nt,{path:":id",element:n.jsx(La,{})})]})}function be({title:e,description:t,badge:r,children:s,className:o}){return n.jsx("div",{className:_("mx-auto max-w-2xl py-12",o),children:n.jsxs("div",{className:"rounded-lg border bg-card p-8 shadow-sm",children:[n.jsx("div",{className:"mb-4 flex items-center gap-2",children:n.jsx("span",{className:"rounded-md bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:r??"coming soon"})}),n.jsx("h2",{className:"mb-2 text-2xl font-semibold tracking-tight",children:e}),t?n.jsx("p",{className:"mb-6 text-sm text-muted-foreground",children:t}):null,s]})})}function za(){return n.jsx(be,{title:"Sources",badge:"M13b W2",description:"Per-company sources with HMAC + API key, rate limits, allowed IPs, quarantine badge, one-time secrets modal.",children:n.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[n.jsx("li",{children:"List + filter by company / type / status"}),n.jsx("li",{children:"Create form with auto-generated HMAC + API key"}),n.jsx("li",{children:`One-time secrets modal (forces "I've saved them")`}),n.jsx("li",{children:"Cert lifecycle (mTLS) — folded in from M14-ui"})]})})}function Ba(){return n.jsx(be,{title:"Telegram bots",badge:"M13b W3",description:"Per-company bot config, invite codes, bindings table. Bot token is never displayed after save.",children:n.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[n.jsx("li",{children:"Set / rotate bot token (encrypted at rest in admind)"}),n.jsx("li",{children:"Generate invite codes with magic link"}),n.jsx("li",{children:"List bindings: chat_id → individual_id mapping"})]})})}function $a(){return n.jsx(be,{title:"Live tail",badge:"M13c",description:"SSE feed of incoming alerts, filterable by company / severity / source / text. Replaces the per-company dump that lives on /v1/tail today.",children:n.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[n.jsx("li",{children:"EventSource('/v1/tail/stream') with auth via short-lived SSE token"}),n.jsx("li",{children:"Filter bar (severity, source, search) + pause-on-scroll-up"}),n.jsx("li",{children:"Click row → modal with full payload + dedupe history"})]})})}function Wa(){return n.jsxs(be,{title:"DLQ",badge:"M13c",description:"React replacement for cmd/admind/ui/dlq.html. Same list/replay/discard flow plus filters and audit hooks.",children:[n.jsxs("p",{className:"mb-4 text-sm text-muted-foreground",children:["Until the React surface ships, the M8 HTML UI is still served at"," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"/dlq"})," by the admind binary."]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Per-channel admin endpoints (",n.jsx("code",{children:"/v1/admin/dlq"})," on deliverd-fcm and deliverd-telegram, JWT-gated) are also available for ops who want to inspect a single channel."]})]})}function Ua(){return n.jsx(be,{title:"Audit log",badge:"M13c",description:"Read-only table of audit_log rows, filterable by actor / action / entity / time.",children:n.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[n.jsx("li",{children:"Filter bar: actor (user_id), action, entity_type, time range"}),n.jsx("li",{children:"Row expand: full JSON payload"}),n.jsx("li",{children:"Export to CSV (super-admin only)"})]})})}function Va(){return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"404"}),n.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-tight",children:"Page not found"}),n.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The route you followed isn't part of the admin console."}),n.jsx(k,{asChild:!0,className:"mt-6",children:n.jsx(Me,{to:"/",children:"Back to dashboard"})})]})})}function qa(){return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"403"}),n.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-tight",children:"Forbidden"}),n.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Your role doesn't grant access to this page."}),n.jsx(k,{asChild:!0,className:"mt-6",children:n.jsx(Me,{to:"/",children:"Back to dashboard"})})]})})}const Ga=hn([{path:"/login",element:n.jsx(Vs,{})},{path:"/forbidden",element:n.jsx(qa,{})},{element:n.jsx(zs,{children:n.jsx(Fs,{})}),children:[{path:"/",element:n.jsx(qs,{})},{path:"/companies/*",element:n.jsx(Fa,{})},{path:"/sources/*",element:n.jsx(za,{})},{path:"/telegram/*",element:n.jsx(Ba,{})},{path:"/tail",element:n.jsx($a,{})},{path:"/dlq",element:n.jsx(Wa,{})},{path:"/audit",element:n.jsx(Ua,{})}]},{path:"*",element:n.jsx(Va,{})}]);Ds();const Ha=new cn({defaultOptions:{queries:{staleTime:3e4,retry:1,refetchOnWindowFocus:!0}}}),an=document.getElementById("root");if(!an)throw new Error("#root element not found in index.html");tr(an).render(n.jsx(l.StrictMode,{children:n.jsx(ln,{client:Ha,children:n.jsxs(vs,{children:[n.jsx(gn,{router:Ga}),n.jsx(Tn,{position:"top-right",richColors:!0})]})})}));
|