adminizer 4.6.0-build.207 → 4.6.0-build.209
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{field-renderer-BMcYzyqF.js → RelationDialogStack-ETpzjqa5.js} +139 -139
- package/assets/add-CvqQD6Pa.js +1 -0
- package/assets/add-group-DImyJrfv.js +1 -0
- package/assets/add-user-DfjWpDnG.js +1 -0
- package/assets/{app-7JBp0Pby.css → app-CPcnQ89K.css} +1 -1
- package/assets/app-layout-CCFuoBGb.js +1 -0
- package/assets/{app-sidebar-Dbgnlkew.js → app-sidebar-DEpxtufv.js} +1 -1
- package/assets/{app-sidebar-header-C3yisT8p.js → app-sidebar-header-BeiWUuCC.js} +1 -1
- package/assets/app.js +1596 -1596
- package/assets/{catalog-Ca9RdLCZ.js → catalog-DEzNeE3X.js} +2 -2
- package/assets/{dashboard-Bcz5b5w6.js → dashboard-DRt3eLcx.js} +2 -2
- package/assets/form-CP8HwSIz.js +1 -0
- package/assets/form-D9_qsBQO.js +1 -0
- package/assets/history-BNV1oHho.js +1 -0
- package/assets/home-B2sL7cw4.js +2 -0
- package/assets/list-B94jmpgr.js +1 -0
- package/assets/manifest.json +120 -126
- package/assets/{media-manager-CFiru23k.js → media-manager-CpMXDZ5y.js} +2 -2
- package/assets/module-CPe8opSY.js +1 -0
- package/assets/{nav-footer-TGTgvr59.js → nav-footer-Cgr3-a9q.js} +1 -1
- package/assets/{nav-main-CVTsAC3C.js → nav-main-CroFjRVi.js} +1 -1
- package/assets/{nav-user-F0xzKfK7.js → nav-user-DIuv8mfu.js} +1 -1
- package/assets/{notification-DYPjSRl4.js → notification-BjbG79fu.js} +11 -11
- package/assets/{theme-switcher-Jo-h4C2M.js → theme-switcher-2tPEnSJf.js} +1 -1
- package/assets/{user-info-D2tUt2LU.js → user-info-DtBK5Kh8.js} +1 -1
- package/assets/{user-menu-content-C9xtndj8.js → user-menu-content-bdKtg5yV.js} +1 -1
- package/assets/welcome-CFZVe2KA.js +1 -0
- package/helpers/inertiaAddHelper.js +12 -1
- package/interfaces/types.d.ts +2 -0
- package/package.json +3 -2
- package/ui/components/ui/dialog-stack.d.ts +1 -0
- package/ui/components/ui/dialog-stack.js +45 -12
- package/assets/DiffViewer-BpSpxX-x.js +0 -1
- package/assets/add-BP2bkvcF.js +0 -1
- package/assets/add-form-B39ytLc3.js +0 -1
- package/assets/add-group-DQi0lc1e.js +0 -1
- package/assets/add-user-CNcCmpvV.js +0 -1
- package/assets/app-layout-Bubi-NT8.js +0 -1
- package/assets/form-Biwt3wOg.js +0 -1
- package/assets/form-CivHwW3U.js +0 -1
- package/assets/history-DNn4VfTF.js +0 -1
- package/assets/home-BaGz7nwT.js +0 -2
- package/assets/list-dmqGUjt-.js +0 -1
- package/assets/module-B9a_e2wR.js +0 -1
- package/assets/welcome-BDZq6wiw.js +0 -1
- /package/assets/{field-renderer-DV8OITPR.css → RelationDialogStack-DV8OITPR.css} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as L,aV as G,u as z,j as e,aW as Q,s as X,B as k,aX as Z,w as K,x as ee,aY as te,N as B,O as R,E as se,Q as F,r as ae,aZ as re,ai as U,L as D,ao as oe,aq as ne,a_ as ie,a$ as ce}from"./app.js";import{Breadcrumbs as le}from"./breadcrumbs-CZZirDj8.js";import{NavUser as de}from"./nav-user-F0xzKfK7.js";import{ThemeSwitcher as ue}from"./theme-switcher-Jo-h4C2M.js";import{r as n}from"./handsontable-PxYdjN8c.js";import fe from"./material-icon-BXxpxGAd.js";const pe={"Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"},H=s=>{if(typeof s!="string")return!1;const c=s.trim().toLowerCase();return c.startsWith("<!doctype html")||c.startsWith("<html")||c.startsWith("<")},he=s=>({...s??{},_ts:Date.now()}),O=async(s,c,a,u)=>{var x,m,S,l;const f={...u,headers:{...pe,...(u==null?void 0:u.headers)??{}},params:he(u==null?void 0:u.params)};try{let o;s==="get"?o=await L.get(c,f):s==="post"?o=await L.post(c,a,f):s==="put"?o=await L.put(c,a,f):o=await L.delete(c,{...f,data:a});const p=String(((x=o.headers)==null?void 0:x["content-type"])??"").toLowerCase();if(p&&!p.includes("application/json")||H(o.data))throw new Error(`Expected JSON response from "${c}", but received "${p||"unknown"}". This usually means the session expired and server returned an HTML login page.`);return o}catch(o){if(o instanceof G){const p=String(((S=(m=o.response)==null?void 0:m.headers)==null?void 0:S["content-type"])??"").toLowerCase();if(H((l=o.response)==null?void 0:l.data)||p.includes("text/html"))throw new Error("Server returned HTML instead of JSON. Most likely auth session expired. Please reload the page and log in again.")}throw o}},y={getJson:(s,c)=>O("get",s,void 0,c),postJson:(s,c,a)=>O("post",s,c,a),putJson:(s,c,a)=>O("put",s,c,a),deleteJson:(s,c,a)=>O("delete",s,c,a)},W=n.createContext(void 0),Ae=({children:s})=>{const[c,a]=n.useState([]),[u,f]=n.useState([]),[x,m]=n.useState([]),[S,l]=n.useState(!1),[o,p]=n.useState(null),[j,A]=n.useState(""),v=z(),[g,C]=n.useState({}),M=[...u,...x],w=async()=>{try{const t=await y.getJson(`${window.routePrefix}/notifications/api`,{params:{unreadOnly:!0,limit:4}});a(t.data)}catch(t){console.error("Error fetching bell notifications:",t)}},d=async()=>{try{const t=await y.postJson(`${window.routePrefix}/notifications`);C(t.data)}catch(t){console.log(t)}},E=async()=>{await w()},b=async()=>{try{const t=await y.getJson(`${window.routePrefix}/notifications/api/get-classes`);t.data&&(p(t.data.activeServices),A(t.data.initTab))}catch(t){console.error("Error fetching tabs:",t)}},$=async(t,r)=>{try{if(!t){await P(r);return}const i=await y.postJson(`${window.routePrefix}/notifications/api/search`,{s:t,notificationClass:r});m(i.data)}catch(i){console.error("Error searching notifications:",i)}},P=async t=>{l(!0);try{const r=`${window.routePrefix}/notifications/api/${t}`,i=await y.getJson(r,{params:{limit:20,skip:0,unreadOnly:!1}});return f([]),m(i.data),i.data}catch(r){return console.error("Error fetching all notifications:",r),[]}finally{l(!1)}},T=async(t,r)=>{try{const i=`${window.routePrefix}/notifications/api/${t}`,h=await y.getJson(i,{params:{limit:20,skip:r,unreadOnly:!1}});return m(N=>[...N,...h.data]),h.data}catch(i){return console.error("Error paginating notifications:",i),[]}};n.useEffect(()=>{if(!v.props.notifications)return;d(),w();const t=new EventSource(`${window.routePrefix}/notifications/api/stream`);return t.addEventListener("connected",r=>{const i=JSON.parse(r.data);console.log("Connected event:",i),b()}),t.addEventListener("notification",r=>{const i=JSON.parse(r.data);f(h=>[i,...h]),a(h=>[i,...h].slice(0,4))}),t.onerror=()=>{console.error("SSE connection error")},()=>t.close()},[]);const I=async(t,r)=>{try{await y.putJson(`${window.routePrefix}/notifications/api/${t}/${r}/read`,{}),f(i=>i.map(h=>h.id===r?{...h,read:!0}:h)),m(i=>i.map(h=>h.id===r?{...h,read:!0}:h)),a([])}catch(i){console.error("Error marking as read:",i)}},J=async()=>{try{await y.putJson(`${window.routePrefix}/notifications/api/read-all`,{}),f(t=>t.map(r=>({...r,read:!0}))),m(t=>t.map(r=>({...r,read:!0}))),await w()}catch(t){console.error("Error marking all as read:",t)}},_=c.filter(t=>!t.read).length;return e.jsx(W.Provider,{value:{bellNotifications:c,allNotifications:M,unreadCount:_,getTabs:b,tabs:o,initTab:j,search:$,markAsRead:I,markAllAsRead:J,getLocale:d,messages:g,fetchAllNotifications:P,paginateNotifications:T,loading:S,refreshBellNotifications:E},children:s})},q=()=>{const s=n.useContext(W);if(s===void 0)throw new Error("useNotifications must be used within a NotificationProvider");return s};function me(){const{bellNotifications:s,markAsRead:c,unreadCount:a,refreshBellNotifications:u,messages:f}=q(),[x,m]=n.useState(!1),S=async(o,p)=>{m(!0);try{await c(o,p),await u()}catch(j){console.error("Error marking as read:",j)}finally{m(!1)}},l=o=>{const p=new Date,j=new Date(o),A=p.getTime()-j.getTime(),v=Math.floor(A/1e3),g=new Intl.RelativeTimeFormat("en",{numeric:"auto"});if(v<60)return g.format(-v,"second");const C=Math.floor(v/60);if(C<60)return g.format(-C,"minute");const M=Math.floor(C/60);if(M<24)return g.format(-M,"hour");const w=Math.floor(M/24);if(w<30)return g.format(-w,"day");const d=Math.floor(w/30);if(d<12)return g.format(-d,"month");const E=Math.floor(d/12);return g.format(-E,"year")};return e.jsxs(Q,{children:[e.jsx(X,{asChild:!0,className:"cursor-pointer data-[state=open]:bg-sidebar-accent",children:e.jsxs(k,{variant:"ghost",className:"relative",children:[e.jsx(Z,{}),a>0&&e.jsx("div",{className:"absolute top-1.5 right-1.5 size-1.5 rounded-full bg-destructive"})]})}),e.jsxs(K,{className:"z-[1002] p-2",align:"end",onCloseAutoFocus:o=>o.preventDefault(),children:[e.jsx(ee,{className:`${x?"opacity-50 pointer-events-none":""}`,children:s.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground",children:"No notifications"}):s.map(o=>e.jsxs("div",{children:[e.jsx(te,{asChild:!0,className:"cursor-pointer",onSelect:p=>{p.preventDefault(),ae.visit(`${window.routePrefix}/notifications?type=${o.notificationClass}`)},children:e.jsxs("div",{className:"grid grid-cols-[32px_250px] grid-rows-[auto_1fr] items-start gap-x-4 gap-y-2",children:[o.icon?e.jsx(fe,{name:o.icon.icon,style:{color:o.icon.iconColor},className:"!text-[32px]"}):e.jsx("div",{}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.title}),e.jsx("span",{className:"truncate",children:o.message})]}),e.jsxs("div",{className:"col-start-2 flex justify-between flex-nowrap items-center",children:[e.jsx("div",{className:"flex flex-nowrap gap-2 items-center",children:e.jsx("div",{children:l(o.createdAt)})}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsx(k,{variant:"ghost",size:"icon",className:"size-4",onClick:p=>{p.stopPropagation(),S(o.notificationClass,o.id)},children:e.jsx(se,{className:"text-primary"})})}),e.jsx(F,{side:"left",className:"z-[1003]",children:e.jsx("p",{children:f["Make read"]})})]})]})]})}),e.jsx(re,{})]},o.id))}),e.jsx(k,{variant:"secondary",asChild:!0,children:e.jsxs(U,{href:`${window.routePrefix}/notifications`,className:`w-full ${x?"opacity-50 pointer-events-none":""}`,children:[f["View All"],x&&e.jsx(D,{className:"h-4 w-4 animate-spin"})]})})]})]})}const xe=()=>{if(!(typeof window>"u"))return window.__adminizerAiAssistantState__??void 0},we=s=>{typeof window>"u"||(window.__adminizerAiAssistantState__=s)},V=n.createContext(void 0),Ee=({children:s})=>{const a=z().props.aiAssistant,u=n.useMemo(()=>xe(),[]),[f,x]=n.useState(()=>(u==null?void 0:u.isOpen)??!1),[m,S]=n.useState([]),[l,o]=n.useState(()=>(u==null?void 0:u.activeModel)??(a==null?void 0:a.defaultModel)??void 0),[p,j]=n.useState([]),[A,v]=n.useState(!1),[g,C]=n.useState(!1),[M,w]=n.useState(null),d=(a==null?void 0:a.enabled)??!1,E=n.useCallback(async()=>{if(d)try{v(!0);const{data:r}=await y.getJson(`${window.routePrefix}/api/ai-assistant/models`);S(r),o(i=>{var N;return i||(a!=null&&a.defaultModel&&r.some(Y=>Y.id===a.defaultModel)?a.defaultModel:(N=r[0])==null?void 0:N.id)})}catch(r){console.error("Failed to load AI assistant models",r),w("Unable to load AI assistant models")}finally{v(!1)}},[a==null?void 0:a.defaultModel,d]),b=n.useCallback(async r=>{if(!(!d||!r))try{v(!0);const{data:i}=await y.getJson(`${window.routePrefix}/api/ai-assistant/history/${r}`);j(i.history??[])}catch(i){console.error("Failed to load AI assistant history",i),w("Unable to load AI assistant history")}finally{v(!1)}},[d]);n.useEffect(()=>{if(!d){j([]);return}E()},[E,d]),n.useEffect(()=>{!d||!l||b(l)},[l,b,d]);const $=n.useCallback(r=>{o(r)},[]),P=n.useCallback(()=>x(!0),[]),T=n.useCallback(()=>x(!1),[]),I=n.useCallback(()=>x(r=>!r),[]),J=n.useCallback(async r=>{if(!d||!l)return;const i=r.trim();if(!i)return;const h={id:`tmp-${Date.now()}`,role:"user",content:i,timestamp:new Date().toISOString(),modelId:l};j(N=>[...N,h]),C(!0),w(null);try{const{data:N}=await y.postJson(`${window.routePrefix}/api/ai-assistant/query`,{modelId:l,message:i});j(N.history??[])}catch(N){console.error("Failed to send AI assistant message",N),w("Unable to reach AI assistant"),await b(l)}finally{C(!1)}},[l,b,d]),_=n.useCallback(async()=>{l&&await b(l)},[l,b]);n.useEffect(()=>{d||x(!1)},[d]),n.useEffect(()=>{we({isOpen:f,activeModel:l})},[l,f]);const t=n.useMemo(()=>({isEnabled:d,isOpen:f,openChat:P,closeChat:T,toggleChat:I,models:m,activeModel:l,setActiveModel:$,messages:p,loading:A,sending:g,error:M,sendMessage:J,refreshHistory:_}),[l,T,M,d,f,A,p,m,P,_,J,g,$,I]);return e.jsx(V.Provider,{value:t,children:s})},ge=()=>{const s=n.useContext(V);if(!s)throw new Error("useAiAssistant must be used within an AiAssistantProvider");return s};function ye(){const{isEnabled:s,isOpen:c,toggleChat:a,models:u,sending:f,loading:x}=ge();if(!s)return null;const m=u.length>0;return e.jsx(e.Fragment,{children:e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsx(k,{variant:"ghost",className:ne("relative",{"text-primary":c}),onClick:a,"aria-expanded":c,"aria-haspopup":"true","aria-controls":"ai-assistant-panel",disabled:!m&&x,children:f?e.jsx(D,{className:"size-4 animate-spin"}):e.jsx(oe,{className:"size-4"})})}),e.jsx(F,{side:"bottom",className:"z-[1002]",children:e.jsx("span",{children:"AI assistant"})})]})})}function je({breadcrumbs:s=[]}){const{tabs:c}=q(),a=z();return e.jsx("header",{className:"border-sidebar-border/50 flex h-16 shrink-0 items-center gap-2 border-b px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4",children:e.jsxs("div",{className:"flex justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"-ml-1"}),e.jsx(le,{breadcrumbs:s})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx(ye,{}),a.props.history&&e.jsx(U,{href:`${window.routePrefix}/history/view-all`,children:e.jsx(k,{variant:"ghost",size:"icon",className:"shrink-0",children:e.jsx(ce,{})})}),e.jsx(ue,{}),a.props.notifications&&(c===null?e.jsx("div",{className:"w-[40px] flex-none flex justify-center",children:e.jsx(D,{className:"size-4 animate-spin"})}):c.length?e.jsx(me,{}):null),e.jsx(de,{})]})]})})}const Pe=Object.freeze(Object.defineProperty({__proto__:null,AppSidebarHeader:je},Symbol.toStringTag,{value:"Module"}));export{je as A,Ae as N,ge as a,Ee as b,Pe as c,q as u};
|
|
1
|
+
import{h as L,aV as G,u as z,j as e,aW as Q,s as X,B as k,aX as Z,w as K,x as ee,aY as te,N as B,O as R,E as se,Q as F,r as ae,aZ as re,ai as U,L as D,ao as oe,aq as ne,a_ as ie,a$ as ce}from"./app.js";import{Breadcrumbs as le}from"./breadcrumbs-CZZirDj8.js";import{NavUser as de}from"./nav-user-DIuv8mfu.js";import{ThemeSwitcher as ue}from"./theme-switcher-2tPEnSJf.js";import{r as n}from"./handsontable-PxYdjN8c.js";import fe from"./material-icon-BXxpxGAd.js";const pe={"Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"},H=s=>{if(typeof s!="string")return!1;const c=s.trim().toLowerCase();return c.startsWith("<!doctype html")||c.startsWith("<html")||c.startsWith("<")},he=s=>({...s??{},_ts:Date.now()}),O=async(s,c,a,u)=>{var x,m,S,l;const f={...u,headers:{...pe,...(u==null?void 0:u.headers)??{}},params:he(u==null?void 0:u.params)};try{let o;s==="get"?o=await L.get(c,f):s==="post"?o=await L.post(c,a,f):s==="put"?o=await L.put(c,a,f):o=await L.delete(c,{...f,data:a});const p=String(((x=o.headers)==null?void 0:x["content-type"])??"").toLowerCase();if(p&&!p.includes("application/json")||H(o.data))throw new Error(`Expected JSON response from "${c}", but received "${p||"unknown"}". This usually means the session expired and server returned an HTML login page.`);return o}catch(o){if(o instanceof G){const p=String(((S=(m=o.response)==null?void 0:m.headers)==null?void 0:S["content-type"])??"").toLowerCase();if(H((l=o.response)==null?void 0:l.data)||p.includes("text/html"))throw new Error("Server returned HTML instead of JSON. Most likely auth session expired. Please reload the page and log in again.")}throw o}},y={getJson:(s,c)=>O("get",s,void 0,c),postJson:(s,c,a)=>O("post",s,c,a),putJson:(s,c,a)=>O("put",s,c,a),deleteJson:(s,c,a)=>O("delete",s,c,a)},W=n.createContext(void 0),Ae=({children:s})=>{const[c,a]=n.useState([]),[u,f]=n.useState([]),[x,m]=n.useState([]),[S,l]=n.useState(!1),[o,p]=n.useState(null),[j,A]=n.useState(""),v=z(),[g,C]=n.useState({}),M=[...u,...x],w=async()=>{try{const t=await y.getJson(`${window.routePrefix}/notifications/api`,{params:{unreadOnly:!0,limit:4}});a(t.data)}catch(t){console.error("Error fetching bell notifications:",t)}},d=async()=>{try{const t=await y.postJson(`${window.routePrefix}/notifications`);C(t.data)}catch(t){console.log(t)}},E=async()=>{await w()},b=async()=>{try{const t=await y.getJson(`${window.routePrefix}/notifications/api/get-classes`);t.data&&(p(t.data.activeServices),A(t.data.initTab))}catch(t){console.error("Error fetching tabs:",t)}},$=async(t,r)=>{try{if(!t){await P(r);return}const i=await y.postJson(`${window.routePrefix}/notifications/api/search`,{s:t,notificationClass:r});m(i.data)}catch(i){console.error("Error searching notifications:",i)}},P=async t=>{l(!0);try{const r=`${window.routePrefix}/notifications/api/${t}`,i=await y.getJson(r,{params:{limit:20,skip:0,unreadOnly:!1}});return f([]),m(i.data),i.data}catch(r){return console.error("Error fetching all notifications:",r),[]}finally{l(!1)}},T=async(t,r)=>{try{const i=`${window.routePrefix}/notifications/api/${t}`,h=await y.getJson(i,{params:{limit:20,skip:r,unreadOnly:!1}});return m(N=>[...N,...h.data]),h.data}catch(i){return console.error("Error paginating notifications:",i),[]}};n.useEffect(()=>{if(!v.props.notifications)return;d(),w();const t=new EventSource(`${window.routePrefix}/notifications/api/stream`);return t.addEventListener("connected",r=>{const i=JSON.parse(r.data);console.log("Connected event:",i),b()}),t.addEventListener("notification",r=>{const i=JSON.parse(r.data);f(h=>[i,...h]),a(h=>[i,...h].slice(0,4))}),t.onerror=()=>{console.error("SSE connection error")},()=>t.close()},[]);const I=async(t,r)=>{try{await y.putJson(`${window.routePrefix}/notifications/api/${t}/${r}/read`,{}),f(i=>i.map(h=>h.id===r?{...h,read:!0}:h)),m(i=>i.map(h=>h.id===r?{...h,read:!0}:h)),a([])}catch(i){console.error("Error marking as read:",i)}},J=async()=>{try{await y.putJson(`${window.routePrefix}/notifications/api/read-all`,{}),f(t=>t.map(r=>({...r,read:!0}))),m(t=>t.map(r=>({...r,read:!0}))),await w()}catch(t){console.error("Error marking all as read:",t)}},_=c.filter(t=>!t.read).length;return e.jsx(W.Provider,{value:{bellNotifications:c,allNotifications:M,unreadCount:_,getTabs:b,tabs:o,initTab:j,search:$,markAsRead:I,markAllAsRead:J,getLocale:d,messages:g,fetchAllNotifications:P,paginateNotifications:T,loading:S,refreshBellNotifications:E},children:s})},q=()=>{const s=n.useContext(W);if(s===void 0)throw new Error("useNotifications must be used within a NotificationProvider");return s};function me(){const{bellNotifications:s,markAsRead:c,unreadCount:a,refreshBellNotifications:u,messages:f}=q(),[x,m]=n.useState(!1),S=async(o,p)=>{m(!0);try{await c(o,p),await u()}catch(j){console.error("Error marking as read:",j)}finally{m(!1)}},l=o=>{const p=new Date,j=new Date(o),A=p.getTime()-j.getTime(),v=Math.floor(A/1e3),g=new Intl.RelativeTimeFormat("en",{numeric:"auto"});if(v<60)return g.format(-v,"second");const C=Math.floor(v/60);if(C<60)return g.format(-C,"minute");const M=Math.floor(C/60);if(M<24)return g.format(-M,"hour");const w=Math.floor(M/24);if(w<30)return g.format(-w,"day");const d=Math.floor(w/30);if(d<12)return g.format(-d,"month");const E=Math.floor(d/12);return g.format(-E,"year")};return e.jsxs(Q,{children:[e.jsx(X,{asChild:!0,className:"cursor-pointer data-[state=open]:bg-sidebar-accent",children:e.jsxs(k,{variant:"ghost",className:"relative",children:[e.jsx(Z,{}),a>0&&e.jsx("div",{className:"absolute top-1.5 right-1.5 size-1.5 rounded-full bg-destructive"})]})}),e.jsxs(K,{className:"z-[1002] p-2",align:"end",onCloseAutoFocus:o=>o.preventDefault(),children:[e.jsx(ee,{className:`${x?"opacity-50 pointer-events-none":""}`,children:s.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground",children:"No notifications"}):s.map(o=>e.jsxs("div",{children:[e.jsx(te,{asChild:!0,className:"cursor-pointer",onSelect:p=>{p.preventDefault(),ae.visit(`${window.routePrefix}/notifications?type=${o.notificationClass}`)},children:e.jsxs("div",{className:"grid grid-cols-[32px_250px] grid-rows-[auto_1fr] items-start gap-x-4 gap-y-2",children:[o.icon?e.jsx(fe,{name:o.icon.icon,style:{color:o.icon.iconColor},className:"!text-[32px]"}):e.jsx("div",{}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.title}),e.jsx("span",{className:"truncate",children:o.message})]}),e.jsxs("div",{className:"col-start-2 flex justify-between flex-nowrap items-center",children:[e.jsx("div",{className:"flex flex-nowrap gap-2 items-center",children:e.jsx("div",{children:l(o.createdAt)})}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsx(k,{variant:"ghost",size:"icon",className:"size-4",onClick:p=>{p.stopPropagation(),S(o.notificationClass,o.id)},children:e.jsx(se,{className:"text-primary"})})}),e.jsx(F,{side:"left",className:"z-[1003]",children:e.jsx("p",{children:f["Make read"]})})]})]})]})}),e.jsx(re,{})]},o.id))}),e.jsx(k,{variant:"secondary",asChild:!0,children:e.jsxs(U,{href:`${window.routePrefix}/notifications`,className:`w-full ${x?"opacity-50 pointer-events-none":""}`,children:[f["View All"],x&&e.jsx(D,{className:"h-4 w-4 animate-spin"})]})})]})]})}const xe=()=>{if(!(typeof window>"u"))return window.__adminizerAiAssistantState__??void 0},we=s=>{typeof window>"u"||(window.__adminizerAiAssistantState__=s)},V=n.createContext(void 0),Ee=({children:s})=>{const a=z().props.aiAssistant,u=n.useMemo(()=>xe(),[]),[f,x]=n.useState(()=>(u==null?void 0:u.isOpen)??!1),[m,S]=n.useState([]),[l,o]=n.useState(()=>(u==null?void 0:u.activeModel)??(a==null?void 0:a.defaultModel)??void 0),[p,j]=n.useState([]),[A,v]=n.useState(!1),[g,C]=n.useState(!1),[M,w]=n.useState(null),d=(a==null?void 0:a.enabled)??!1,E=n.useCallback(async()=>{if(d)try{v(!0);const{data:r}=await y.getJson(`${window.routePrefix}/api/ai-assistant/models`);S(r),o(i=>{var N;return i||(a!=null&&a.defaultModel&&r.some(Y=>Y.id===a.defaultModel)?a.defaultModel:(N=r[0])==null?void 0:N.id)})}catch(r){console.error("Failed to load AI assistant models",r),w("Unable to load AI assistant models")}finally{v(!1)}},[a==null?void 0:a.defaultModel,d]),b=n.useCallback(async r=>{if(!(!d||!r))try{v(!0);const{data:i}=await y.getJson(`${window.routePrefix}/api/ai-assistant/history/${r}`);j(i.history??[])}catch(i){console.error("Failed to load AI assistant history",i),w("Unable to load AI assistant history")}finally{v(!1)}},[d]);n.useEffect(()=>{if(!d){j([]);return}E()},[E,d]),n.useEffect(()=>{!d||!l||b(l)},[l,b,d]);const $=n.useCallback(r=>{o(r)},[]),P=n.useCallback(()=>x(!0),[]),T=n.useCallback(()=>x(!1),[]),I=n.useCallback(()=>x(r=>!r),[]),J=n.useCallback(async r=>{if(!d||!l)return;const i=r.trim();if(!i)return;const h={id:`tmp-${Date.now()}`,role:"user",content:i,timestamp:new Date().toISOString(),modelId:l};j(N=>[...N,h]),C(!0),w(null);try{const{data:N}=await y.postJson(`${window.routePrefix}/api/ai-assistant/query`,{modelId:l,message:i});j(N.history??[])}catch(N){console.error("Failed to send AI assistant message",N),w("Unable to reach AI assistant"),await b(l)}finally{C(!1)}},[l,b,d]),_=n.useCallback(async()=>{l&&await b(l)},[l,b]);n.useEffect(()=>{d||x(!1)},[d]),n.useEffect(()=>{we({isOpen:f,activeModel:l})},[l,f]);const t=n.useMemo(()=>({isEnabled:d,isOpen:f,openChat:P,closeChat:T,toggleChat:I,models:m,activeModel:l,setActiveModel:$,messages:p,loading:A,sending:g,error:M,sendMessage:J,refreshHistory:_}),[l,T,M,d,f,A,p,m,P,_,J,g,$,I]);return e.jsx(V.Provider,{value:t,children:s})},ge=()=>{const s=n.useContext(V);if(!s)throw new Error("useAiAssistant must be used within an AiAssistantProvider");return s};function ye(){const{isEnabled:s,isOpen:c,toggleChat:a,models:u,sending:f,loading:x}=ge();if(!s)return null;const m=u.length>0;return e.jsx(e.Fragment,{children:e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsx(k,{variant:"ghost",className:ne("relative",{"text-primary":c}),onClick:a,"aria-expanded":c,"aria-haspopup":"true","aria-controls":"ai-assistant-panel",disabled:!m&&x,children:f?e.jsx(D,{className:"size-4 animate-spin"}):e.jsx(oe,{className:"size-4"})})}),e.jsx(F,{side:"bottom",className:"z-[1002]",children:e.jsx("span",{children:"AI assistant"})})]})})}function je({breadcrumbs:s=[]}){const{tabs:c}=q(),a=z();return e.jsx("header",{className:"border-sidebar-border/50 flex h-16 shrink-0 items-center gap-2 border-b px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4",children:e.jsxs("div",{className:"flex justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"-ml-1"}),e.jsx(le,{breadcrumbs:s})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx(ye,{}),a.props.history&&e.jsx(U,{href:`${window.routePrefix}/history/view-all`,children:e.jsx(k,{variant:"ghost",size:"icon",className:"shrink-0",children:e.jsx(ce,{})})}),e.jsx(ue,{}),a.props.notifications&&(c===null?e.jsx("div",{className:"w-[40px] flex-none flex justify-center",children:e.jsx(D,{className:"size-4 animate-spin"})}):c.length?e.jsx(me,{}):null),e.jsx(de,{})]})]})})}const Pe=Object.freeze(Object.defineProperty({__proto__:null,AppSidebarHeader:je},Symbol.toStringTag,{value:"Module"}));export{je as A,Ae as N,ge as a,Ee as b,Pe as c,q as u};
|