PageSourceSearch

https://skygard.ai/assets/Settings-yu7DRKHN.js

js skygard.ai collected 2026-10-05 14:40:15 UTC 46,537 bytes, 177 lines download raw bytes

1import{j as t,r,c as L,F as E,am as pe,an as H,ao as ke,ap as ge,aq as Ae,ar as Ee,as as fe,at as De,S as $e,B as Re,K as Oe,au as Ie,av as qe,a4 as Le,aw as Pe}from"./index-JXkNRss8.js";function C({label:e,value:a,onChange:s,placeholder:n,type:l="text",min:c,max:i,step:m,disabled:d}){return t.jsxs("label",{className:"grid gap-1 text-sm",children:[t.jsx("span",{className:"text-brand-textDim",children:e}),t.jsx("input",{type:l,className:"bg-black/20 border border-white/10 rounded-md px-3 py-2 outline-none text-sm placeholder:text-white/50",value:a,onChange:p=>s(p.target.value),placeholder:n,min:c,max:i,step:m,disabled:d})]})}function Te(e){return t.jsx(C,{...e,type:"password"})}function Z({label:e,value:a,onChange:s,options:n}){return t.jsxs("label",{className:"grid gap-1 text-sm",children:[t.jsx("span",{className:"text-brand-textDim",children:e}),t.jsx("select",{value:a,onChange:l=>s(l.target.value),className:"bg-black/20 border border-white/10 rounded-md px-3 py-2 outline-none text-sm",children:n.map(l=>t.jsx("option",{value:l,children:l},l))})]})}function A({label:e,desc:a,enabled:s,onChange:n}){return t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("button",{onClick:()=>n(!s),className:["relative inline-flex h-6 w-11 items-center rounded-full transition",s?"bg-emerald-500/60":"bg-white/15"].join(" "),"aria-pressed":s,children:t.jsx("span",{className:["inline-block h-4 w-4 transform rounded-full bg-white transition",s?"translate-x-6":"translate-x-1"].join(" ")})}),t.jsxs("div",{className:"text-sm",children:[t.jsx("div",{className:"font-medium",children:e}),a&&t.jsx("div",{className:"text-brand-textDim",children:a})]})]})}function xe({enabled:e,onChange:a}){return t.jsx("button",{onClick:()=>a(!e),className:["relative inline-flex h-5 w-9 items-center rounded-full transition",e?"bg-emerald-500/60":"bg-white/15"].join(" "),"aria-pressed":e,children:t.jsx("span",{className:["inline-block h-3.5 w-3.5 transform rounded-full bg-white transition",e?"translate-x-5":"translate-x-1"].join(" ")})})}function F({label:e,value:a,onChange:s,disabled:n}){return t.jsxs("label",{className:"grid gap-1 text-sm",children:[t.jsx("span",{className:"text-brand-textDim",children:e}),t.jsx("input",{type:"time",value:a,onChange:l=>s(l.target.value),className:"bg-black/20 border border-white/10 rounded-md px-3 py-2 outline-none text-sm",disabled:n})]})}function V({label:e,value:a}){return t.jsxs("div",{className:"flex items-center justify-between bg-white/[0.03] border border-white/10 rounded-md px-3 py-2 text-sm",children:[t.jsx("span",{className:"text-brand-textDim",children:e}),t.jsx("span",{className:"text-white",children:a})]})}const he=r.createContext(null);function ze({value:e,children:a}){return t.jsx(he.Provider,{value:e,children:a})}function te(){return r.useContext(he)}async function Me(e){return(await L.get("/api/settings/all/",{signal:e})).data}async function K(e){return(await L.get("/api/settings/snapshot/",{signal:e})).data}async function G(e){return(await L.patch("/api/settings/snapshot/",e)).data}async function Fe(e){const{data:a}=await L.patch("/api/settings/general/",e);return a}async function Ue(e){const{data:a}=await L.patch("/api/settings/devices/",e);return a}async function Be(e){const{data:a}=await L.patch("/api/settings/integrations/",e);return a}async function He(){const{data:e}=await L.post("/api/settings/integrations/rotate_api_key/",{});return e}let Ke={data:""},Ge=e=>typeof window=="object"?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||Ke,We=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Je=/\/\*[^]*?\*\/|  +/g,ae=/\n+/g,I=(e,a)=>{let s="",n="",l="";for(let c in e){let i=e[c];c[0]=="@"?c[1]=="i"?s=c+" "+i+";":n+=c[1]=="f"?I(i,c):c+"{"+I(i,c[1]=="k"?"":a)+"}":typeof i=="object"?n+=I(i,a?a.replace(/([^,])+/g,m=>c.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,d=>/&/.test(d)?d.replace(/&/g,m):m?m+" "+d:d)):c):i!=null&&(c=/^--/.test(c)?c:c.replace(/[A-Z]/g,"-$&").toLowerCase(),l+=I.p?I.p(c,i):c+":"+i+";")}return s+(a&&l?a+"{"+l+"}":l)+n},R={},be=e=>{if(typeof e=="object"){let a="";for(let s in e)a+=s+be(e[s]);return a}return e},Ye=(e,a,s,n,l)=>{let c=be(e),i=R[c]||(R[c]=(d=>{let p=0,g=11;for(;p<d.length;
1)g=101*g+d.charCodeAt(p++)>>>0;return"go"+g})(c));if(!R[i]){let d=c!==e?e:(p=>{let g,u,h=[{}];for(;g=We.exec(p.replace(Je,""));)g[4]?h.shift():g[3]?(u=g[3].replace(ae," ").trim(),h.unshift(h[0][u]=h[0][u]||{})):h[0][g[1]]=g[2].replace(ae," ").trim();return h[0]})(e);R[i]=I(l?{["@keyframes "+i]:d}:d,s?"":"."+i)}let m=s&&R.g?R.g:null;return s&&(R.g=R[i]),((d,p,g,u)=>{u?p.data=p.data.replace(u,d):p.data.indexOf(d)===-1&&(p.data=g?d+p.data:p.data+d)})(R[i],a,n,m),i},Qe=(e,a,s)=>e.reduce((n,l,c)=>{let i=a[c];if(i&&i.call){let m=i(s),d=m&&m.props&&m.props.className||/^go/.test(m)&&m;i=d?"."+d:m&&typeof m=="object"?m.props?"":I(m,""):m===!1?"":m}return n+l+(i??"")},"");function W(e){let a=this||{},s=e.call?e(a.p):e;return Ye(s.unshift?s.raw?Qe(s,[].slice.call(arguments,1),a.p):s.reduce((n,l)=>Object.assign(n,l&&l.call?l(a.p):l),{}):s,Ge(a.target),a.g,a.o,a.k)}let ye,X,ee;W.bind({g:1});let O=W.bind({k:1});function Ve(e,a,s,n){I.p=a,ye=e,X=s,ee=n}function q(e,a){let s=this||{};return function(){let n=arguments;function l(c,i){let m=Object.assign({},c),d=m.className||l.className;s.p=Object.assign({theme:X&&X()},m),s.o=/ *go\d+/.test(d),m.className=W.apply(s,n)+(d?" "+d:"");let p=e;return e[0]&&(p=m.as||e,delete m.as),ee&&p[0]&&ee(m),ye(p,m)}return a?a(l):l}}var Ze=e=>typeof e=="function",U=(e,a)=>Ze(e)?e(a):e,Xe=(()=>{let e=0;return()=>(++e).toString()})(),je=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let a=matchMedia("(prefers-reduced-motion: reduce)");e=!a||a.matches}return e}})(),et=20,se="default",ve=(e,a)=>{let{toastLimit:s}=e.settings;switch(a.type){case 0:return{...e,toasts:[a.toast,...e.toasts].slice(0,s)};case 1:return{...e,toasts:e.toasts.map(i=>i.id===a.toast.id?{...i,...a.toast}:i)};case 2:let{toast:n}=a;return ve(e,{type:e.toasts.find(i=>i.id===n.id)?1:0,toast:n});case 3:let{toastId:l}=a;return{...e,toasts:e.toasts.map(i=>i.id===l||l===void 0?{...i,dismissed:!0,visible:!1}:i)};case 4:return a.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(i=>i.id!==a.toastId)};case 5:return{...e,pausedAt:a.time};case 6:let c=a.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(i=>({...i,pauseDuration:i.pauseDuration+c}))}}},M=[],Ne={toasts:[],pausedAt:void 0,settings:{toastLimit:et}},$={},Se=(e,a=se)=>{$[a]=ve($[a]||Ne,e),M.forEach(([s,n])=>{s===a&&n($[a])})},we=e=>Object.keys($).forEach(a=>Se(e,a)),tt=e=>Object.keys($).find(a=>$[a].toasts.some(s=>s.id===e)),J=(e=se)=>a=>{Se(a,e)},st={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},at=(e={},a=se)=>{let[s,n]=r.useState($[a]||Ne),l=r.useRef($[a]);r.useEffect(()=>(l.current!==$[a]&&n($[a]),M.push([a,n]),()=>{let i=M.findIndex(([m])=>m===a);i>-1&&M.splice(i,1)}),[a]);let c=s.toasts.map(i=>{var m,d,p;return{...e,...e[i.type],...i,removeDelay:i.removeDelay||((m=e[i.type])==null?void 0:m.removeDelay)||e?.removeDelay,duration:i.duration||((d=e[i.type])==null?void 0:d.duration)||e?.duration||st[i.type],style:{...e.style,...(p=e[i.type])==null?void 0:p.style,...i.style}}});return{...s,toasts:c}},nt=(e,a="blank",s)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:a,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...s,id:s?.id||Xe()}),P=e=>(a,s)=>{let n=nt(a,e,s);return J(n.toasterId||tt(n.id))({type:2,toast:n}),n.id},y=(e,a)=>P("blank")(e,a);y.error=P("error");y.success=P("success");y.loading=P("loading");y.custom=P("custom");y.dismiss=(e,a)=>{let s={type:3,toastId:e};a?J(a)(s):we(s)};y.dismissAll=e=>y.dismiss(void 0,e);y.remove=(e,a)=>{let s={type:4,toastId:e};a?J(a)(s):we(s)};y.removeAll=e=>y.remove(void 0,e);y.promise=(e,a,s)=>{let n=y.loading(a.loading,{...s,...s?.loading});return typeof e=="function"&&(e=e()),e.then(l=>{let c=a.success?U(a.success,l):void 0;return c?y.success(c,{id:n,...s,...s?.success}):y.dismiss(n),l}).catch(l=>{let c=a.error?U(a.error,l):void 0;c?y.error(c,{id:n,...s,...s?.error}):y.dismiss(n)}),e};var it=1e3,rt=(e,a="default")=>{let{toasts:s,pausedAt:n}=at(e,a),l=r.useRef(new Map).current,c=r.useCallback((u,h=it)=>{if(l.has(u))return;let x=setTimeout(()=>{l.delete(u),i({type:4,toastId:u})},h);l.set(u,x)},[]);r.useEffect(()=>{if(n)return;let u=Date.now(),h=s.map(x=>
1{if(x.duration===1/0)return;let S=(x.duration||0)+x.pauseDuration-(u-x.createdAt);if(S<0){x.visible&&y.dismiss(x.id);return}return setTimeout(()=>y.dismiss(x.id,a),S)});return()=>{h.forEach(x=>x&&clearTimeout(x))}},[s,n,a]);let i=r.useCallback(J(a),[a]),m=r.useCallback(()=>{i({type:5,time:Date.now()})},[i]),d=r.useCallback((u,h)=>{i({type:1,toast:{id:u,height:h}})},[i]),p=r.useCallback(()=>{n&&i({type:6,time:Date.now()})},[n,i]),g=r.useCallback((u,h)=>{let{reverseOrder:x=!1,gutter:S=8,defaultPosition:N}=h||{},w=s.filter(k=>(k.position||N)===(u.position||N)&&k.height),b=w.findIndex(k=>k.id===u.id),_=w.filter((k,j)=>j<b&&k.visible).length;return w.filter(k=>k.visible).slice(...x?[_+1]:[0,_]).reduce((k,j)=>k+(j.height||0)+S,0)},[s]);return r.useEffect(()=>{s.forEach(u=>{if(u.dismissed)c(u.id,u.removeDelay);else{let h=l.get(u.id);h&&(clearTimeout(h),l.delete(u.id))}})},[s,c]),{toasts:s,handlers:{updateHeight:d,startPause:m,endPause:p,calculateOffset:g}}},lt=O`
2from {
3  transform: scale(0) rotate(45deg);
4	opacity: 0;
5}
6to {
7 transform: scale(1) rotate(45deg);
8  opacity: 1;
9}`,ot=O`
10from {
11  transform: scale(0);
12  opacity: 0;
13}
14to {
15  transform: scale(1);
16  opacity: 1;
17}`,ct=O`
18from {
19  transform: scale(0) rotate(90deg);
20	opacity: 0;
21}
22to {
23  transform: scale(1) rotate(90deg);
24	opacity: 1;
25}`,dt=q("div")`
26  width: 20px;
27  opacity: 0;
28  height: 20px;
29  border-radius: 10px;
30  background: ${e=>e.primary||"#ff4b4b"};
31  position: relative;
32  transform: rotate(45deg);
33
34  animation: ${lt} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
35    forwards;
36  animation-delay: 100ms;
37
38  &:after,
39  &:before {
40    content: '';
41    animation: ${ot} 0.15s ease-out forwards;
42    animation-delay: 150ms;
43    position: absolute;
44    border-radius: 3px;
45    opacity: 0;
46    background: ${e=>e.secondary||"#fff"};
47    bottom: 9px;
48    left: 4px;
49    height: 2px;
50    width: 12px;
51  }
52
53  &:before {
54    animation: ${ct} 0.15s ease-out forwards;
55    animation-delay: 180ms;
56    transform: rotate(90deg);
57  }
58`,ut=O`
59  from {
60    transform: rotate(0deg);
61  }
62  to {
63    transform: rotate(360deg);
64  }
65`,mt=q("div")`
66  width: 12px;
67  height: 12px;
68  box-sizing: border-box;
69  border: 2px solid;
70  border-radius: 100%;
71  border-color: ${e=>e.secondary||"#e0e0e0"};
72  border-right-color: ${e=>e.primary||"#616161"};
73  animation: ${ut} 1s linear infinite;
74`,pt=O`
75from {
76  transform: scale(0) rotate(45deg);
77	opacity: 0;
78}
79to {
80  transform: scale(1) rotate(45deg);
81	opacity: 1;
82}`,gt=O`
830% {
84	height: 0;
85	width: 0;
86	opacity: 0;
87}
8840% {
89  height: 0;
90	width: 6px;
91	opacity: 1;
92}
93100% {
94  opacity: 1;
95  height: 10px;
96}`,ft=q("div")`
97  width: 20px;
98  opacity: 0;
99  height: 20px;
100  border-radius: 10px;
101  background: ${e=>e.primary||"#61d345"};
102  position: relative;
103  transform: rotate(45deg);
104
105  animation: ${pt} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
106    forwards;
107  animation-delay: 100ms;
108  &:after {
109    content: '';
110    box-sizing: border-box;
111    animation: ${gt} 0.2s ease-out forwards;
112    opacity: 0;
113    animation-delay: 200ms;
114    position: absolute;
115    border-right: 2px solid;
116    border-bottom: 2px solid;
117    border-color: ${e=>e.secondary||"#fff"};
118    bottom: 6px;
119    left: 6px;
120    height: 10px;
121    width: 6px;
122  }
123`,xt=q("div")`
124  position: absolute;
125`,ht=q("div")`
126  position: relative;
127  display: flex;
128  justify-content: center;
129  align-items: center;
130  min-width: 20px;
131  min-height: 20px;
132`,bt=O`
133from {
134  transform: scale(0.6);
135  opacity: 0.4;
136}
137to {
138  transform: scale(1);
139  opacity: 1;
140}`,yt=q("div")`
141  position: relative;
142  transform: scale(0.6);
143  opacity: 0.4;
144  min-width: 20px;
145  animation: ${bt} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
146    forwards;
147`,jt=({toast:e})=>{let{icon:a,type:s,iconTheme:n}=e;return a!==void 0?typeof a=="string"?r.createElement(yt,null,a):a:s==="blank"?null:r.createElement(ht,null,r.createElement(mt,{...n}),s!=="loading"&&r.createElement(xt,null,s==="error"?r.createElement(dt,{...n}):r.createElement(ft,{...n})))},vt=e=>`
1480% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;}
149100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
150`,Nt=e=>`
1510% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
152100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;}
153`,St="0%{opacity:0;} 100%{opacity:1;}",wt="0%{opacity:1;} 100%{opacity:0;}",_t=q("div")`
154  display: flex;
155  align-items: center;
156  background: #fff;
157  color: #363636;
158  line-height: 1.3;
159  will-change: transform;
160  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05);
161  max-width: 350px;
162  pointer-events: auto;
163  padding: 8px 10px;
164  border-radius: 8px;
165`,Ct=q("div")`
166  display: flex;
167  justify-content: center;
168  margin: 4px 10px;
169  color: inherit;
170  flex: 1 1 auto;
171  white-space: pre-line;
172`,kt=(e,a)=>{let s=e.includes("top")?1:-1,[n,l]=je()?[St,wt]:[vt(s),Nt(s)];return{animation:a?`${O(n)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${O(l)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},At=r.memo(({toast:e,position:a,style:s,children:n})=>{let l=e.height?kt(e.position||a||"top-center",e.visible):{opacity:0},c=r.createElement(jt,{toast:e}),i=r.createElement(Ct,{...e.ariaProps},U(e.message,e));return r.createElement(_t,{className:e.className,style:{...l,...s,...e.style}},typeof n=="function"?n({icon:c,message:i}):r.createElement(r.Fragment,null,c,i))});Ve(r.createElement);var Et=({id:e,className:a,style:s,onHeightUpdate:n,children:l})=>{let c=r.useCallback(i=>{if(i){let m=()=>{let d=i.getBoundingClientRect().height;n(e,d)};m(),new MutationObserver(m).observe(i,{subtree:!0,childList:!0,characterData:!0})}},[e,n]);return r.createElement("div",{ref:c,className:a,style:s},l)},Dt=(e,a)=>{let s=e.includes("top"),n=s?{top:0}:{bottom:0},l=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:je()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${a*(s?1:-1)}px)`,...n,...l}},$t=W`
173  z-index: 9999;
174  > * {
175    pointer-events: auto;
176  }
177`,z=16,Rt=({reverseOrder:e,position:a="top-center",toastOptions:s,gutter:n,children:l,toasterId:c,containerStyle:i,containerClassName:m})=>{let{toasts:d,handlers:p}=rt(s,c);return r.createElement("div",{"data-rht-toaster":c||"",style:{position:"fixed",zIndex:9999,top:z,left:z,right:z,bottom:z,pointerEvents:"none",...i},className:m,onMouseEnter:p.startPause,onMouseLeave:p.endPause},d.map(g=>{let u=g.position||a,h=p.calculateOffset(g,{reverseOrder:e,gutter:n,defaultPosition:a}),x=Dt(u,h);return r.createElement(Et,{id:g.id,key:g.id,onHeightUpdate:p.updateHeight,className:g.visible?$t:"",style:x},g.type==="custom"?U(g.message,g):l?l(g):r.createElement(At,{toast:g,position:u}))}))};function Ot(){const e=te(),[a,s]=r.useState("SkyGard Demo Org"),[n,l]=r.useState("America/Los_Angeles"),[c,i]=r.useState("imperial"),[m,d]=r.useState(!1);r.useEffect(()=>{e?.general&&(s(e.general.org_name),l(e.general.timezone),i(e.general.units))},[e?.general]);const p=e?.general,g=r.useMemo(()=>p?a!==p.org_name||n!==p.timezone||c!==p.units:!1,[p,a,n,c]);async function u(){if(!p||m)return;d(!0);const x={org_name:a,timezone:n,units:c};try{await Fe(x),y.success("General settings saved")}catch(S){const N=S?.response?.status===404?"Endpoint not ready (404).":S?.response?.data?.detail||String(S?.message||"Save failed");y.error(N)}finally{d(!1)}}function h(){p&&(s(p.org_name),l(p.timezone),i(p.units),y("Changes discarded",{icon:"↩️"}))}return t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsx("h3",{className:"font-semibold",children:"General"}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(C,{label:"Organization Name",value:a,onChange:s}),t.jsx(Z,{label:"Timezone",value:n,onChange:l,options:["America/Los_Angeles","America/Denver","America/Chicago","America/New_York","UTC"]}),t.jsx(Z,{label:"Units",value:c,onChange:x=>i(x),options:["imperial","metric"]})]}),t.jsxs("div",{className:"flex gap-2 mt-4",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:u,disabled:!g||m||!p,children:m?"Saving…":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:h,disabled:!g||m||!p,children:"Cancel"})]})]})}function It(){const e=te(),[a,s]=r.useState(!0),[n,l]=r.useState(30),[c,i]=r.useState("Main Yard"),[m,d]=r.useState(!1),[p,g]=r.useState(!1);r.useEffect(()=>{e?.devices&&(s(e.devices.auto_update),l(e.devices.telemetry_interval_sec),i(e.devices.default_site_name),d(e.devices.geofence_enabled))},[e?.devices]);const u=e?.devices,h=r.useMemo(()=>u?a!==u.auto_update||n!==u.telemetry_interval_sec||c!==u.default_site_name||m!==u.geofence_enabled:!1,[u,a,n,c,m]);async function x(){if(!(!u||p)){g(!0);try{await Ue({auto_update:a,telemetry_interval_sec:n,default_site_name:c,geofence_enabled:m}),y.success("Device defaults saved")}catch(N){const w=N?.response?.status===404?"Devices endpoint not ready (404).":N?.response?.data?.detail||String(N?.message||"Save failed");y.error(w)}finally{g(!1)}}}function S(){u&&(s(u.auto_update),l(u.telemetry_interval_sec),i(u.default_site_name),d(u.geofence_enabled),y("Changes discarded",{icon:"↩️"}))}return t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"font-semibold",children:"Devices — Defaults"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:x,disabled:!h||p||!u,children:p?"Saving…":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:S,disabled:!h||p||!u,children:"Cancel"})]})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"Auto-update firmware",enabled:a,onChange:s}),t.jsx(C,{label:"Telemetry interval (sec)",value:String(n),onChange:N=>l(Number(N)||0)}),t.jsx(C,{label:"Default Site",value:c,onChange:i})]}),t.jsx(A,{label:"Enable default geofence",enabled:m,onChange:d,desc:"Apply a default geofence to newly added devices."})]})}function B(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(l=>B(l)).join(",")}]`;const a=e;return`{${Object.keys(a).sort().map(l=>`${JSON.stringify(l)}:${B(a[l])}`).join(",")}}`}function Y(e,a){return B(e)===B(a)}const qt=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:7,label:"Sun"}];function Lt(e){return{name:`Schedule ${e}`,enabled:!0,days:[1,2,3,4,5],start:"22:00",end:"07:00",timezone:"America/Los_Angeles"}}function ne(e){const a=e?.response?.data?.detail;
177return e?.response?.status===400&&typeof a=="string"&&a.includes("Multiple organizations")}function ie(e){if(!e)return[];if(typeof e=="string")return[e];if(Array.isArray(e))return e.map(a=>String(a));if(typeof e=="object"){const a=[];return Object.entries(e).forEach(([s,n])=>{Array.isArray(n)?n.forEach(l=>a.push(`${s}: ${String(l)}`)):typeof n=="string"?a.push(`${s}: ${n}`):n!=null&&a.push(`${s}: ${JSON.stringify(n)}`)}),a}return[String(e)]}function Pt(e){return e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function Tt(){const[e,a]=r.useState(null),[s,n]=r.useState(null),[l,c]=r.useState(null),[i,m]=r.useState(!0),[d,p]=r.useState(!1),[g,u]=r.useState(!1),[h,x]=r.useState([]);r.useEffect(()=>{const o=new AbortController;return m(!0),K(o.signal).then(f=>{a(f.rules),n(f.rules),u(!1),x([])}).catch(f=>{f?.name!=="CanceledError"&&(ne(f)?(u(!0),x([])):x(ie(f?.response?.data)))}).finally(()=>{m(!1)}),()=>o.abort()},[]);const S=r.useMemo(()=>!e||!s?!1:!Y(s,e),[e,s]);async function N(){if(!(!s||d||g)){p(!0),x([]);try{const o=await G({rules:s});a(o.rules),n(o.rules),c(new Date),y.success("Rules settings saved")}catch(o){ne(o)&&u(!0);const f=ie(o?.response?.data);x(f),y.error(f[0]||"Save failed")}finally{p(!1)}}}function w(){e&&(n(e),x([]))}function b(o,f){n(v=>{if(!v)return v;const T=v.schedules.map((D,Q)=>Q===o?{...D,...f}:D);return{...v,schedules:T}})}function _(o,f){n(v=>{if(!v)return v;const T=v.schedules.map((D,Q)=>{if(Q!==o)return D;const _e=D.days.includes(f)?D.days.filter(Ce=>Ce!==f):[...D.days,f].sort();return{...D,days:_e}});return{...v,schedules:T}})}function k(){n(o=>{if(!o)return o;const f=Lt(o.schedules.length+1);return{...o,schedules:[...o.schedules,f]}})}function j(o){n(f=>{if(!f)return f;const v=f.schedules.filter((T,D)=>D!==o);return{...f,schedules:v}})}return i?t.jsx("section",{className:"sg-card p-5",children:"Loading rules settings..."}):!s||!e?t.jsx("section",{className:"sg-card p-5 text-rose-300",children:"Failed to load rules settings."}):t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold",children:"Rules"}),l&&t.jsxs("div",{className:"text-xs text-brand-textDim",children:["Saved at ",Pt(l)]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:N,disabled:!S||d||g,children:d?"Saving...":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:w,disabled:!S||d,children:"Reset"})]})]}),g&&t.jsx("div",{className:"rounded-md border border-amber-400/40 bg-amber-500/10 p-3 text-sm text-amber-100",children:"Select an organization to edit settings."}),h.length>0&&t.jsxs("div",{className:"rounded-md border border-rose-400/40 bg-rose-500/10 p-3 text-sm text-rose-200",children:[t.jsx("div",{className:"font-semibold",children:"Please fix the following:"}),t.jsx("ul",{className:"list-disc pl-4",children:h.map((o,f)=>t.jsx("li",{children:o},f))})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"Offline alerts",desc:"Alert when devices go offline",enabled:s.offline_rule.enabled,onChange:o=>n({...s,offline_rule:{...s.offline_rule,enabled:o}})}),t.jsx(C,{label:"Offline after (minutes)",value:String(s.offline_rule.offline_after_minutes),onChange:o=>n({...s,offline_rule:{...s.offline_rule,offline_after_minutes:Number(o)||0}}),type:"number",min:1,max:240}),t.jsx("div",{className:"hidden sm:block"})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"Low battery alerts",desc:"Warn when devices drop below threshold",enabled:s.battery_rule.enabled,onChange:o=>n({...s,battery_rule:{...s.battery_rule,enabled:o}})}),t.jsx(C,{label:"Low battery threshold (%)",value:String(s.battery_rule.low_battery_percent),onChange:o=>n({...s,battery_rule:{...s.battery_rule,low_battery_percent:Number(o)||0}}),type:"number",min:1,max:100}),t.jsx("div",{className:"hidden sm:block"})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"High temperature alerts",desc:"Warn when temperature exceeds threshold",enabled:s.temp_rule.enabled,onChange:o=>n({...s,temp_rule:{...s.temp_rule,enabled:o}})}),t.jsx(C,{label:"High temperature (C)",value:String(s.temp_rule.high_temp_c),onChange:o=>n({...s,temp_rule:{...s.temp_rule,high_temp_c:Number(o)||0}}),type:"number",min:-20,max:150}),t.jsx("div",{className:"hidden sm:block"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold",children:"Schedules"}),t.jsx("p",{className:"text-sm text-brand-textDim",children:"Schedules gate alerting windows."})]}),t.jsxs("button",{className:"px-3 py-1.5 text-xs rounded-full bg-brand-panel/60 hover:bg-brand-panel inline-flex items-center gap-2",onClick:k,children:[t.jsx(E,{icon:pe,className:"h-3.5 w-3.5"}),"Add schedule"]})]}),s.schedules.length===0&&t.jsx("div",{className:"text-sm text-brand-textDim",children:"No schedules defined yet."}),t.jsx("div",{className:"grid gap-4",children:s.schedules.map((o,f)=>t.jsxs("div",{className:"border border-white/10 rounded-lg p-4 grid gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm font-medium",children:["Schedule ",f+1]}),t.jsxs("button",{className:"px-2 py-1 text-[11px] rounded-full bg-rose-500/20 text-rose-200",onClick:()=>j(f),children:[t.jsx(E,{icon:H,className:"h-3 w-3 mr-1"}),"Remove"]})]}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsx(C,{label:"Name",value:o.name,onChange:v=>b(f,{name:v})}),t.jsx(C,{label:"Timezone",value:o.timezone,onChange:v=>b(f,{timezone:v}),placeholder:"America/Los_Angeles"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(xe,{enabled:o.enabled,onChange:v=>b(f,{enabled:v})}),t.jsx("span",{className:"text-sm",children:"Enabled"})]})]}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsx(F,{label:"Start",value:o.start,onCh
177ange:v=>b(f,{start:v})}),t.jsx(F,{label:"End",value:o.end,onChange:v=>b(f,{end:v})}),t.jsxs("div",{className:"grid gap-1 text-sm",children:[t.jsx("span",{className:"text-brand-textDim",children:"Days"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:qt.map(v=>t.jsxs("label",{className:"inline-flex items-center gap-1 text-xs",children:[t.jsx("input",{type:"checkbox",checked:o.days.includes(v.value),onChange:()=>_(f,v.value)}),v.label]},v.value))})]})]})]},f))})]})}const zt=["info","warning","critical"];function re(e){return e.split(",").map(a=>a.trim()).filter(a=>a.length>0)}function le(e){const a=e?.response?.data?.detail;return e?.response?.status===400&&typeof a=="string"&&a.includes("Multiple organizations")}function oe(e){if(!e)return[];if(typeof e=="string")return[e];if(Array.isArray(e))return e.map(a=>String(a));if(typeof e=="object"){const a=[];return Object.entries(e).forEach(([s,n])=>{Array.isArray(n)?n.forEach(l=>a.push(`${s}: ${String(l)}`)):typeof n=="string"?a.push(`${s}: ${n}`):n!=null&&a.push(`${s}: ${JSON.stringify(n)}`)}),a}return[String(e)]}function Mt(e){return e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function Ft(){const[e,a]=r.useState(null),[s,n]=r.useState(null),[l,c]=r.useState(""),[i,m]=r.useState(""),[d,p]=r.useState(null),[g,u]=r.useState(!0),[h,x]=r.useState(!1),[S,N]=r.useState(!1),[w,b]=r.useState([]);r.useEffect(()=>{const o=new AbortController;return u(!0),K(o.signal).then(f=>{const v=f.notifications;a(v),n(v),c(v.email_recipients.join(", ")),m(v.sms_recipients.join(", ")),N(!1),b([])}).catch(f=>{f?.name!=="CanceledError"&&(le(f)?(N(!0),b([])):b(oe(f?.response?.data)))}).finally(()=>{u(!1)}),()=>o.abort()},[]);const _=r.useMemo(()=>!e||!s?!1:!Y(s,e),[e,s]);async function k(){if(!(!s||h||S)){x(!0),b([]);try{const f=(await G({notifications:s})).notifications;a(f),n(f),c(f.email_recipients.join(", ")),m(f.sms_recipients.join(", ")),p(new Date),y.success("Notification settings saved")}catch(o){le(o)&&N(!0);const f=oe(o?.response?.data);b(f),y.error(f[0]||"Save failed")}finally{x(!1)}}}function j(){e&&(n(e),c(e.email_recipients.join(", ")),m(e.sms_recipients.join(", ")),b([]))}return g?t.jsx("section",{className:"sg-card p-5",children:"Loading notification settings..."}):!s||!e?t.jsx("section",{className:"sg-card p-5 text-rose-300",children:"Failed to load notification settings."}):t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold",children:"Notifications"}),d&&t.jsxs("div",{className:"text-xs text-brand-textDim",children:["Saved at ",Mt(d)]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:k,disabled:!_||h||S,children:h?"Saving...":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:j,disabled:!_||h,children:"Reset"})]})]}),S&&t.jsx("div",{className:"rounded-md border border-amber-400/40 bg-amber-500/10 p-3 text-sm text-amber-100",children:"Select an organization to edit settings."}),w.length>0&&t.jsxs("div",{className:"rounded-md border border-rose-400/40 bg-rose-500/10 p-3 text-sm text-rose-200",children:[t.jsx("div",{className:"font-semibold",children:"Please fix the following:"}),t.jsx("ul",{className:"list-disc pl-4",children:w.map((o,f)=>t.jsx("li",{children:o},f))})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"Email alerts",enabled:s.email_enabled,onChange:o=>n({...s,email_enabled:o})}),t.jsx(A,{label:"SMS alerts",desc:"Coming soon",enabled:s.sms_enabled,onChange:o=>n({...s,sms_enabled:o})}),t.jsx(Z,{label:"Minimum severity",value:s.alert_severity_min,onChange:o=>n({...s,alert_severity_min:o}),options:zt})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsx(C,{label:"Email recipients (comma-separated)",value:l,onChange:o=>{c(o),n({...s,email_recipients:re(o)})},placeholder:"[email protected], [email protected]"}),t.jsx(C,{label:"SMS recipients (comma-separated)",value:i,onChange:o=>{m(o),n({...s,sms_recipients:re(o)})},placeholder:"+15551234567, +15557654321",disabled:!s.sms_enabled})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"Quiet hours",enabled:s.quiet_hours.enabled,onChange:o=>n({...s,quiet_hours:{...s.quiet_hours,enabled:o}})}),t.jsx(F,{label:"Quiet hours start",value:s.quiet_hours.start,onCh
177ange:o=>n({...s,quiet_hours:{...s.quiet_hours,start:o}}),disabled:!s.quiet_hours.enabled}),t.jsx(F,{label:"Quiet hours end",value:s.quiet_hours.end,onChange:o=>n({...s,quiet_hours:{...s.quiet_hours,end:o}}),disabled:!s.quiet_hours.enabled})]}),t.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:t.jsx(C,{label:"Quiet hours timezone",value:s.quiet_hours.timezone,onChange:o=>n({...s,quiet_hours:{...s.quiet_hours,timezone:o}}),placeholder:"America/Los_Angeles",disabled:!s.quiet_hours.enabled})})]})}function Ut(){const[e,a]=r.useState([{id:"u1",label:"Carmen (Worker)",type:"person",trusted:!0},{id:"v1",label:"Blue F-150 (Fleet)",type:"vehicle",trusted:!0},{id:"u2",label:"Unknown Male #17",type:"person",trusted:!1}]),[s,n]=r.useState(30),[l,c]=r.useState(60),[i,m]=r.useState(!1);return t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"font-semibold",children:"Recognition Directory"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{className:"px-3 py-1.5 text-xs rounded-full bg-brand-panel/60 hover:bg-brand-panel inline-flex items-center gap-2",children:[t.jsx(E,{icon:ke,className:"h-3.5 w-3.5"}),"Import CSV"]}),t.jsxs("button",{className:"px-3 py-1.5 text-xs rounded-full bg-brand-panel/60 hover:bg-brand-panel inline-flex items-center gap-2",children:[t.jsx(E,{icon:ge,className:"h-3.5 w-3.5"}),"Export"]}),t.jsxs("button",{className:"px-3 py-1.5 text-xs rounded-full bg-white/10 inline-flex items-center gap-2",onClick:()=>a(d=>[...d,{id:`i${d.length+1}`,label:"New Identity",type:"person",trusted:!1}]),children:[t.jsx(E,{icon:pe,className:"h-3.5 w-3.5"}),"Add"]})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"text-left text-brand-textDim",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3",children:"Label"}),t.jsx("th",{className:"px-4 py-3",children:"Type"}),t.jsx("th",{className:"px-4 py-3",children:"Trusted"}),t.jsx("th",{className:"px-4 py-3",children:"Manage"})]})}),t.jsx("tbody",{children:e.map(d=>t.jsxs("tr",{className:"border-t border-white/5",children:[t.jsx("td",{className:"px-4 py-3",children:d.label}),t.jsx("td",{className:"px-4 py-3 capitalize",children:d.type}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(xe,{enabled:d.trusted,onChange:p=>a(g=>g.map(u=>u.id===d.id?{...u,trusted:p}:u))})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("button",{className:"px-2 py-1 text-[11px] rounded-full bg-rose-500/20 text-rose-200",onClick:()=>a(p=>p.filter(g=>g.id!==d.id)),children:[t.jsx(E,{icon:H,className:"h-3 w-3 mr-1"}),"Remove"]})})]},d.id))})]})}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(C,{label:"Face data retention (days)",value:String(s),onChange:d=>n(Number(d)||0)}),t.jsx(C,{label:"License plate data retention (days)",value:String(l),onChange:d=>c(Number(d)||0)}),t.jsx(A,{label:"Blur unknown faces in thumbnails",enabled:i,onChange:m})]})]})}function Bt(){const e=te(),[a,s]=r.useState("https://hooks.example.com/skygard"),[n,l]=r.useState("skg_live_xxx..."),[c,i]=r.useState(!1),[m,d]=r.useState(!1),[p,g]=r.useState(!1);r.useEffect(()=>{e?.integrations&&(s(e.integrations.webhook_url),l(e.integrations.api_key_masked),i(e.integrations.slack_on))},[e?.integrations]);const u=e?.integrations,h=r.useMemo(()=>u?a!==u.webhook_url||n!==u.api_key_masked||c!==u.slack_on:!1,[u,a,n,c]);async function x(){if(!(!u||m)){d(!0);try{await Be({webhook_url:a,api_key_masked:n,slack_on:c}),y.success("Integrations saved")}catch(w){const b=w?.response?.status===404?"Integrations endpoint not ready (404).":w?.response?.data?.detail||String(w?.message||"Save failed");y.error(b)}finally{d(!1)}}}async function S(){if(!p){g(!0);try{const w=await He();w?.api_key_masked&&l(w.api_key_masked),y.success("API key rotated")}catch(w){const b=w?.response?.status===404?"Rotate endpoint not ready (404).":w?.response?.data?.detail||String(w?.message||"Rotation failed");y.error(b)}finally{g(!1)}}}function N(){u&&(s(u.webhook_url),l(u.api_key_masked),i(u.slack_on),y("Changes discarded",{icon:"↩️"}))}return t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"font-semibold",children:"Integrations"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:x,disabled:!h||m||!u,children:m?"Saving…":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:N,disabled:!h||m||!u,children:"Cancel"})]})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsx(C,{label:"Webhook URL",value:a,onChange:s}),t.jsx(Te,{label:"API Key",value:n,onChange:l})]}),t.jsx(A,{label:"Slack notifications",enabled:c,onChange:i}),t.jsx("div",{className:"flex gap-2 mt-4",children:t.jsxs("button",{className:"sg-btn",onClick:S,disabled:p,children:[t.jsx(E,{icon:Ae,className:"h-3.5 w-3.5 mr-1"}),p?"Rotating…":"Rotate API Key"]})})]})}function Ht(e){return e.split(",").map(a=>a.trim()).filter(a=>a.length>0)}function ce(e){const a=e?.response?.data?.detail;
177return e?.response?.status===400&&typeof a=="string"&&a.includes("Multiple organizations")}function de(e){if(!e)return[];if(typeof e=="string")return[e];if(Array.isArray(e))return e.map(a=>String(a));if(typeof e=="object"){const a=[];return Object.entries(e).forEach(([s,n])=>{Array.isArray(n)?n.forEach(l=>a.push(`${s}: ${String(l)}`)):typeof n=="string"?a.push(`${s}: ${n}`):n!=null&&a.push(`${s}: ${JSON.stringify(n)}`)}),a}return[String(e)]}function Kt(e){return e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function Gt(){const[e,a]=r.useState(null),[s,n]=r.useState(null),[l,c]=r.useState(""),[i,m]=r.useState(null),[d,p]=r.useState(!0),[g,u]=r.useState(!1),[h,x]=r.useState(!1),[S,N]=r.useState([]),[w]=r.useState([{id:"r-admin",name:"Admin",members:2,perms:["All"]},{id:"r-ops",name:"Operator",members:4,perms:["View","Acknowledge","Control devices"]}]);r.useEffect(()=>{const j=new AbortController;return p(!0),K(j.signal).then(o=>{const f=o.security;a(f),n(f),c(f.ip_allowlist.join(", ")),x(!1),N([])}).catch(o=>{o?.name!=="CanceledError"&&(ce(o)?(x(!0),N([])):N(de(o?.response?.data)))}).finally(()=>{p(!1)}),()=>j.abort()},[]);const b=r.useMemo(()=>!e||!s?!1:!Y(s,e),[e,s]);async function _(){if(!(!s||g||h)){u(!0),N([]);try{const o=(await G({security:s})).security;a(o),n(o),c(o.ip_allowlist.join(", ")),m(new Date),y.success("Security settings saved")}catch(j){ce(j)&&x(!0);const o=de(j?.response?.data);N(o),y.error(o[0]||"Save failed")}finally{u(!1)}}}function k(){e&&(n(e),c(e.ip_allowlist.join(", ")),N([]))}return d?t.jsx("section",{className:"sg-card p-5",children:"Loading security settings..."}):!s||!e?t.jsx("section",{className:"sg-card p-5 text-rose-300",children:"Failed to load security settings."}):t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold",children:"Security & Access"}),i&&t.jsxs("div",{className:"text-xs text-brand-textDim",children:["Saved at ",Kt(i)]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:_,disabled:!b||g||h,children:g?"Saving...":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:k,disabled:!b||g,children:"Reset"})]})]}),h&&t.jsx("div",{className:"rounded-md border border-amber-400/40 bg-amber-500/10 p-3 text-sm text-amber-100",children:"Select an organization to edit settings."}),S.length>0&&t.jsxs("div",{className:"rounded-md border border-rose-400/40 bg-rose-500/10 p-3 text-sm text-rose-200",children:[t.jsx("div",{className:"font-semibold",children:"Please fix the following:"}),t.jsx("ul",{className:"list-disc pl-4",children:S.map((j,o)=>t.jsx("li",{children:j},o))})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(A,{label:"Require MFA",enabled:s.mfa_required,onChange:j=>n({...s,mfa_required:j})}),t.jsx(C,{label:"Session timeout (minutes)",value:String(s.session_timeout_minutes),onChange:j=>n({...s,session_timeout_minutes:Number(j)||0}),type:"number",min:5,max:1440}),t.jsx(C,{label:"API key rotation (days)",value:String(s.api_key_rotation_days),onChange:j=>n({...s,api_key_rotation_days:Number(j)||0}),type:"number",min:1,max:3650})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsx(A,{label:"Enable IP allowlist",enabled:s.ip_allowlist_enabled,onChange:j=>n({...s,ip_allowlist_enabled:j})}),t.jsx(C,{label:"Allowed IPs/CIDRs (comma-separated)",value:l,onChange:j=>{c(j),n({...s,ip_allowlist:Ht(j)})},placeholder:"10.0.0.0/24, 203.0.113.5",disabled:!s.ip_allowlist_enabled})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs("button",{className:"px-3 py-1.5 text-xs rounded-full bg-brand-panel/60 hover:bg-brand-panel inline-flex items-center gap-2",children:[t.jsx(E,{icon:Ee,className:"h-3.5 w-3.5"}),"Invite User"]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"text-left text-brand-textDim",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3",children:"Role"}),t.jsx("th",{className:"px-4 py-3",children:"Members"}),t.jsx("th",{className:"px-4 py-3",children:"Permissions"}),t.jsx("th",{className:"px-4 py-3",children:"Manage"})]})}),t.jsx("tbody",{children:w.map(j=>t.jsxs("tr",{className:"border-t border-white/5",children:[t.jsx("td",{className:"px-4 py-3",children:j.name}),t.jsx("td",{className:"px-4 py-3",children:j.members}),t.jsx("td",{className:"px-4 py-3",children:j.perms.join(", ")}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"px-2 py-1 text-[11px] rounded-full bg-white/10",children:"Edit"}),t.jsxs("button",{className:"px-2 py-1 text-[11px] rounded-full bg-rose-500/20 text-rose-200",children:[t.jsx(E,{icon:H,className:"h-3 w-3 mr-1"}),"Remove"]})]})})]},j.id))})]})})]})}function ue(e){const a=e?.response?.data?.detail;
177return e?.response?.status===400&&typeof a=="string"&&a.includes("Multiple organizations")}function me(e){if(!e)return[];if(typeof e=="string")return[e];if(Array.isArray(e))return e.map(a=>String(a));if(typeof e=="object"){const a=[];return Object.entries(e).forEach(([s,n])=>{Array.isArray(n)?n.forEach(l=>a.push(`${s}: ${String(l)}`)):typeof n=="string"?a.push(`${s}: ${n}`):n!=null&&a.push(`${s}: ${JSON.stringify(n)}`)}),a}return[String(e)]}function Wt(e){return e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function Jt(){const[e,a]=r.useState(null),[s,n]=r.useState(null),[l,c]=r.useState(null),[i,m]=r.useState(!0),[d,p]=r.useState(!1),[g,u]=r.useState(!1),[h,x]=r.useState([]);r.useEffect(()=>{const b=new AbortController;return m(!0),K(b.signal).then(_=>{const k=_.retention;a(k),n(k),u(!1),x([])}).catch(_=>{_?.name!=="CanceledError"&&(ue(_)?(u(!0),x([])):x(me(_?.response?.data)))}).finally(()=>{m(!1)}),()=>b.abort()},[]);const S=r.useMemo(()=>!e||!s?!1:!Y(s,e),[e,s]);async function N(){if(!(!s||d||g)){p(!0),x([]);try{const _=(await G({retention:s})).retention;a(_),n(_),c(new Date),y.success("Data retention settings saved")}catch(b){ue(b)&&u(!0);const _=me(b?.response?.data);x(_),y.error(_[0]||"Save failed")}finally{p(!1)}}}function w(){e&&(n(e),x([]))}return i?t.jsx("section",{className:"sg-card p-5",children:"Loading data retention settings..."}):!s||!e?t.jsx("section",{className:"sg-card p-5 text-rose-300",children:"Failed to load data retention settings."}):t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold",children:"Data & Privacy"}),l&&t.jsxs("div",{className:"text-xs text-brand-textDim",children:["Saved at ",Wt(l)]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{className:"sg-btn sg-btn-primary disabled:opacity-50",onClick:N,disabled:!S||d||g,children:d?"Saving...":"Save"}),t.jsx("button",{className:"sg-btn disabled:opacity-50",onClick:w,disabled:!S||d,children:"Reset"})]})]}),g&&t.jsx("div",{className:"rounded-md border border-amber-400/40 bg-amber-500/10 p-3 text-sm text-amber-100",children:"Select an organization to edit settings."}),h.length>0&&t.jsxs("div",{className:"rounded-md border border-rose-400/40 bg-rose-500/10 p-3 text-sm text-rose-200",children:[t.jsx("div",{className:"font-semibold",children:"Please fix the following:"}),t.jsx("ul",{className:"list-disc pl-4",children:h.map((b,_)=>t.jsx("li",{children:b},_))})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[t.jsx(C,{label:"Telemetry retention (days)",value:String(s.telemetry_days),onChange:b=>n({...s,telemetry_days:Number(b)||0}),type:"number",min:1,max:3650}),t.jsx(C,{label:"Media retention (days)",value:String(s.media_days),onChange:b=>n({...s,media_days:Number(b)||0}),type:"number",min:1,max:3650}),t.jsx(C,{label:"Audit retention (days)",value:String(s.audit_days),onChange:b=>n({...s,audit_days:Number(b)||0}),type:"number",min:1,max:3650})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsx(A,{label:"Allow data exports",desc:"Policy only - exports are coming soon",enabled:s.export_enabled,onChange:b=>n({...s,export_enabled:b})}),t.jsx(A,{label:"Allow deletion requests",desc:"Policy only - review workflow coming soon",enabled:s.deletion_requests_enabled,onChange:b=>n({...s,deletion_requests_enabled:b})})]}),t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsxs("button",{className:"sg-btn",disabled:!s.export_enabled,children:[t.jsx(E,{icon:ge,className:"h-3.5 w-3.5 mr-1"}),"Export Data"]}),t.jsxs("button",{className:"sg-btn",disabled:!s.deletion_requests_enabled,children:[t.jsx(E,{icon:H,className:"h-3.5 w-3.5 mr-1"}),"Request Deletion"]})]})]})}function Yt(){const e=r.useMemo(()=>({name:"Pro",devices:25,price:"$99/mo"}),[]);return t.jsxs("section",{className:"sg-card p-5 grid gap-5",children:[t.jsx("h3",{className:"font-semibold",children:"Billing"}),t.jsxs("div",{className:"grid sm:grid-cols-3 gap-3 text-sm",children:[t.jsx(V,{label:"Plan",value:e.name}),t.jsx(V,{label:"Included Devices",value:String(e.devices)}),t.jsx(V,{label:"Price",value:e.price})]}),t.jsx("div",{className:"flex gap-2 mt-4",children:t.jsxs("button",{className:"sg-btn sg-btn-primary",children:[t.jsx(E,{icon:fe,className:"h-3.5 w-3.5 mr-1"}),"Manage Subscription"]})})]})}function Qt(){const[e,a]=r.useState(null),[s,n]=r.useState("idle"),[l,c]=r.useState(null);r.useEffect(()=>{const p=new AbortController;return n("loading"),Me(p.signal).then(g=>{a(g),n("success")}
177).catch(g=>{g?.name!=="CanceledError"&&(c(g),n("error"))}),()=>p.abort()},[]);const i=s==="loading",m=s==="error",d=s==="success";return r.useMemo(()=>({data:e,status:s,isLoading:i,isError:m,isSuccess:d,error:l}),[e,s,i,m,d,l])}const Vt=[{key:"general",title:"General",icon:De},{key:"devices",title:"Devices",icon:$e},{key:"rules",title:"Rules",icon:Re},{key:"alerts",title:"Alerts",icon:Oe},{key:"recognition",title:"Recognition",icon:Ie},{key:"integrations",title:"Integrations",icon:qe},{key:"security",title:"Security",icon:Le},{key:"data",title:"Data & Privacy",icon:Pe},{key:"billing",title:"Billing",icon:fe}];function es(){const[e,a]=r.useState("general"),{data:s,isLoading:n,isError:l,error:c}=Qt();return t.jsxs("div",{className:"grid gap-6",children:[t.jsx(Rt,{position:"top-right"}),t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("h1",{className:"text-2xl font-semibold",children:"Settings"})}),n&&t.jsx("div",{className:"sg-card p-3 text-sm text-brand-textDim",children:"Loading settings…"}),l&&t.jsxs("div",{className:"sg-card p-3 text-sm text-rose-300",children:["Failed to load settings. ",String(c??"")]}),t.jsx("nav",{className:"sg-card p-2 flex flex-wrap gap-2 mb-2",children:Vt.map(i=>{const m=e===i.key;return t.jsxs("button",{onClick:()=>a(i.key),className:["px-3 py-1.5 rounded-full text-sm inline-flex items-center gap-2",m?"bg-white/10 text-white":"bg-brand-panel/60 text-white/80 hover:bg-brand-panel"].join(" "),title:i.title,children:[t.jsx(E,{icon:i.icon,className:"h-4 w-4"}),i.title]},i.key)})}),t.jsxs(ze,{value:s,children:[e==="general"&&t.jsx(Ot,{}),e==="devices"&&t.jsx(It,{}),e==="rules"&&t.jsx(Tt,{}),e==="alerts"&&t.jsx(Ft,{}),e==="recognition"&&t.jsx(Ut,{}),e==="integrations"&&t.jsx(Bt,{}),e==="security"&&t.jsx(Gt,{}),e==="data"&&t.jsx(Jt,{}),e==="billing"&&t.jsx(Yt,{})]})]})}export{es as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.