web-mojo 2.1.1099 → 2.1.1101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.cjs.js +1 -1
- package/dist/admin.es.js +9 -9
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.es.js +3 -3
- package/dist/chunks/{ChatView-C7sLr2J4.js → ChatView-ZqTCdUZP.js} +2 -2
- package/dist/chunks/{ChatView-C7sLr2J4.js.map → ChatView-ZqTCdUZP.js.map} +1 -1
- package/dist/chunks/{ChatView-BMOwUJvp.js → ChatView-oka6O6VS.js} +6 -6
- package/dist/chunks/{ChatView-BMOwUJvp.js.map → ChatView-oka6O6VS.js.map} +1 -1
- package/dist/chunks/{Collection-DpdzB_n7.js → Collection-CsAk0UhA.js} +2 -2
- package/dist/chunks/{Collection-DpdzB_n7.js.map → Collection-CsAk0UhA.js.map} +1 -1
- package/dist/chunks/{ContextMenu-CLRRrCUp.js → ContextMenu-Dfdrnd0f.js} +2 -2
- package/dist/chunks/{ContextMenu-CLRRrCUp.js.map → ContextMenu-Dfdrnd0f.js.map} +1 -1
- package/dist/chunks/{Dialog-VNV1BoVO.js → Dialog-DRf1-ZSd.js} +3 -3
- package/dist/chunks/{Dialog-VNV1BoVO.js.map → Dialog-DRf1-ZSd.js.map} +1 -1
- package/dist/chunks/{Dialog-B2JUzeMM.js → Dialog-DwgF3hri.js} +2 -2
- package/dist/chunks/{Dialog-B2JUzeMM.js.map → Dialog-DwgF3hri.js.map} +1 -1
- package/dist/chunks/{FormView-DRiG4b10.js → FormView-DJBMpeMY.js} +36 -1
- package/dist/chunks/{FormView-DRiG4b10.js.map → FormView-DJBMpeMY.js.map} +1 -1
- package/dist/chunks/{FormView-D5FEA-Nu.js → FormView-DkBylHdd.js} +2 -2
- package/dist/chunks/{FormView-D5FEA-Nu.js.map → FormView-DkBylHdd.js.map} +1 -1
- package/dist/chunks/{ListView-B2gyVSMW.js → ListView-BGJG4GYH.js} +2 -2
- package/dist/chunks/{ListView-B2gyVSMW.js.map → ListView-BGJG4GYH.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-CYENExa2.js → MetricsMiniChartWidget-DRIJwI91.js} +2 -2
- package/dist/chunks/{MetricsMiniChartWidget-CYENExa2.js.map → MetricsMiniChartWidget-DRIJwI91.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-DNNWwpp0.js → MetricsMiniChartWidget-DlmsNmJy.js} +2 -2
- package/dist/chunks/{MetricsMiniChartWidget-DNNWwpp0.js.map → MetricsMiniChartWidget-DlmsNmJy.js.map} +1 -1
- package/dist/chunks/{PDFViewer-Ci7vFBlz.js → PDFViewer-BRy3UHth.js} +2 -2
- package/dist/chunks/{PDFViewer-Ci7vFBlz.js.map → PDFViewer-BRy3UHth.js.map} +1 -1
- package/dist/chunks/{PDFViewer-DG345H4m.js → PDFViewer-Cx3C0CHL.js} +2 -2
- package/dist/chunks/{PDFViewer-DG345H4m.js.map → PDFViewer-Cx3C0CHL.js.map} +1 -1
- package/dist/chunks/{TokenManager-BJa_JUI4.js → TokenManager-CWi9-XBF.js} +4 -4
- package/dist/chunks/{TokenManager-BJa_JUI4.js.map → TokenManager-CWi9-XBF.js.map} +1 -1
- package/dist/chunks/{TokenManager-DpzgbkN4.js → TokenManager-DVrApE_3.js} +2 -2
- package/dist/chunks/{TokenManager-DpzgbkN4.js.map → TokenManager-DVrApE_3.js.map} +1 -1
- package/dist/chunks/{version-CGkPXReu.js → version-Be_W-mxT.js} +4 -4
- package/dist/chunks/{version-CGkPXReu.js.map → version-Be_W-mxT.js.map} +1 -1
- package/dist/chunks/{version-Dv-LRsJ8.js → version-Ce-8QdEq.js} +2 -2
- package/dist/chunks/{version-Dv-LRsJ8.js.map → version-Ce-8QdEq.js.map} +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +5 -5
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +11 -11
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +4 -4
- package/dist/map.es.js +1 -1
- package/dist/timeline.es.js +2 -2
- package/package.json +1 -1
package/dist/docit.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/Dialog-B2JUzeMM.js"),e=require("./chunks/TokenManager-DpzgbkN4.js"),o=require("./chunks/Rest-BpDyhFfG.js"),i=require("./chunks/ContextMenu-DWau8gXS.js"),s=require("./chunks/Collection-B64LJ92k.js"),a=require("./chunks/version-Dv-LRsJ8.js");class DocNavSidebar extends o.View{constructor(t={}){super({className:"docit-sidebar-nav",tagName:"nav",...t}),this.singleBookMode=t.singleBookMode||!1,this.books=t.books,this.docPages=t.docPages,this.activeUser=t.activeUser,this.currentBook=null,this.currentDocPage=null}async onInit(){await super.onInit(),this.getApp().events.on("page:show",this._onPageShow.bind(this))}async _onPageShow({query:t}){const e=t.doc_book,o=t.doc_page,i=this.getApp();if(e){const t=this.books.findWhere({slug:e});!t||this.currentBook&&this.currentBook.id===t.id||(await i.setActiveBook(t),this.currentBook=i.currentBook)}else this.currentBook&&(await i.setActiveBook(null),this.currentBook=null);this.currentDocPage=o?this.docPages.findWhere({slug:o}):null,this.render()}getTemplate(){return'\n <div class="docit-nav-body pt-3">\n {{#currentBook}}\n {{#docPages.models}}\n <a href="#" class="docit-page-link {{#isActive}}active{{/isActive}}"\n data-action="select-page" data-page-slug="{{slug}}">\n <i class="{{#metadata.icon}}{{metadata.icon}}{{/metadata.icon}}{{^metadata.icon}}bi bi-file-earmark-text{{/metadata.icon}} me-2"></i>\n <span>{{title|capitalize}}</span>\n </a>\n {{/docPages.models}}\n {{^docPages.models}}\n <div class="docit-nav-empty"><p>No pages in this book.</p></div>\n {{/docPages.models}}\n {{/currentBook}}\n {{^currentBook}}\n {{#books.models}}\n <a href="#" class="docit-book-item" data-action="select-book" data-book-slug="{{slug}}">\n <i class="bi bi-book me-2"></i>\n <span class="book-title">{{title}}</span>\n <span class="badge bg-secondary ms-auto">{{page_count}}</span>\n </a>\n {{/books.models}}\n {{/currentBook}}\n </div>\n {{#currentBook}}\n <div class="docit-nav-footer">\n {{#canEdit}}\n <button class="btn btn-link w-100 mb-2" data-action="create-page">\n <i class="bi bi-plus-circle me-2"></i>\n Create New Page\n </button>\n {{/canEdit}}\n <button class="btn btn-link w-100" data-action="back-to-books">\n <i class="bi bi-arrow-left me-2"></i>\n Back to Books\n </button>\n </div>\n {{/currentBook}}\n {{^currentBook}}\n {{#canEdit}}\n <div class="docit-nav-footer">\n <button class="btn btn-link w-100" data-action="create-book">\n <i class="bi bi-plus-circle me-2"></i>\n Create New Book\n </button>\n </div>\n {{/canEdit}}\n {{/currentBook}}\n '}async onBeforeRender(){await super.onBeforeRender(),this.canEdit=this.getApp().canEdit(),this.docPages&&this.currentDocPage&&this.docPages.forEach(t=>{t.isActive=t.id===this.currentDocPage.id})}async onActionSelectBook(t,e){t.preventDefault();const o=e.dataset.bookSlug,i=this.books.findWhere({slug:o});if(i){await this.getApp().setActiveBook(i);const t=this.docPages.at(0),e={doc_book:i.get("slug")};t&&(e.doc_page=t.get("slug")),this.getApp().showPage("docs",e,{})}}onActionSelectPage(t,e){t.preventDefault();const o=e.dataset.pageSlug;this.currentBook&&o&&this.getApp().showPage("docs",{doc_book:this.currentBook.get("slug"),doc_page:o},{})}async onActionBackToBooks(t,e){t.preventDefault(),await this.getApp().setActiveBook(null),this.getApp().showPage("home")}async onActionCreateBook(){await this.getApp().createNewBook()}async onActionCreatePage(){this.currentBook&&await this.getApp().createNewPage(this.currentBook)}setBooks(t){this.books=t,this.render()}setDocPages(t){this.docPages=t,this.render()}setCurrentBook(t){this.currentBook=t,this.render(),this.getApp().topnav&&(t?this.getApp().topnav.setBrand(t.get("title")):this.getApp().topnav.setBrand("Documentation"))}setUser(t){this.activeUser=t,this.render()}}class DocHomePage extends i.Page{constructor(t={}){super({pageName:"home",title:"Documentation",className:"docit-home-page",...t})}async getTemplate(){return'\n <div class="docit-empty-state vh-100 d-flex flex-column align-items-center justify-content-center">\n <i class="bi bi-collection" style="font-size: 4rem;"></i>\n <h3 class="mt-4">Welcome to the Documentation Portal</h3>\n <p class="text-muted">Please select a book from the sidebar to get started.</p>\n </div>\n '}}class DocitBook extends s.Model{static endpoint="/api/docit/book";buildUrl(t=null){return this.get("slug")&&!this.id?`/api/docit/book/slug/${this.get("slug")}`:this.id?`/api/docit/book/${this.id}`:this.endpoint}}class DocitBookList extends s.Collection{constructor(t={}){super({ModelClass:DocitBook,endpoint:"/api/docit/book",...t})}parse(t){return t.data&&t.data.status?(this.meta={...this.meta,total:t.data.count||0,graph:t.data.graph},t.data.data||[]):super.parse(t)}}class DocitPage extends s.Model{static endpoint="/api/docit/page";buildUrl(t=null){return this.get("slug")&&!this.id?`/api/docit/page/slug/${this.get("slug")}`:this.id?`/api/docit/page/${this.id}`:this.endpoint}}class DocitPageList extends s.Collection{constructor(t={}){super({ModelClass:DocitPage,endpoint:"/api/docit/page",...t})}parse(t){return t.data&&t.data.status?(this.meta={...this.meta,total:t.data.count||0,graph:t.data.graph,book:t.data.book},t.data.data||[]):super.parse(t)}}class DocPage extends i.Page{constructor(t={}){super({pageName:"docs",title:"Documentation",className:"docit-page",...t}),this.bookModel=null,this.model=null}async onInit(){await super.onInit(),this.pageContextMenu=new i.ContextMenu({config:this.getPageContextMenuConfig(),containerId:"page-context-menu"}),this.addChild(this.pageContextMenu)}getPageContextMenuConfig(){return{icon:"bi-three-dots",buttonClass:"btn btn-outline-secondary btn-sm",items:[{label:"View History",action:"view-history",icon:"bi-clock-history"},{type:"divider"},{label:"Edit Page Content",action:"edit-page",icon:"bi-pencil"},{label:"Edit Page Info",action:"edit-page-info",icon:"bi-list-ol"},{type:"divider"},{label:"Edit Book Info",action:"edit-book",icon:"bi-book"},{type:"divider"},{label:"Delete Page",action:"delete-page",icon:"bi-trash",danger:!0}]}}async getTemplate(){return'\n <div class="docit-page-container position-relative">\n {{#loading}}\n <div class="docit-loading">\n <div class="spinner-border" role="status">\n <span class="visually-hidden">Loading...</span>\n </div>\n </div>\n {{/loading}}\n\n {{^loading}}\n {{#model|bool}}\n <div class="docit-page-toolbar">\n <div class="row">\n <div class="col d-flex justify-content-end">\n <div data-container="page-context-menu"></div>\n </div>\n </div>\n </div>\n <article class="docit-page-content">\n {{{model.html}}}\n </article>\n\n <nav class="docit-page-nav">\n {{#prevPage}}\n <a href="#" class="docit-nav-prev" data-action="navigate-to-page" data-page-slug="{{slug}}">\n <i class="bi bi-arrow-left"></i>\n <div>\n <small>Previous</small>\n <span>{{title}}</span>\n </div>\n </a>\n {{/prevPage}}\n {{^prevPage}}\n <div></div>\n {{/prevPage}}\n\n {{#nextPage}}\n <a href="#" class="docit-nav-next" data-action="navigate-to-page" data-page-slug="{{slug}}">\n <div>\n <small>Next</small>\n <span>{{title}}</span>\n </div>\n <i class="bi bi-arrow-right"></i>\n </a>\n {{/nextPage}}\n\n <div class="my-3">\n <span class="text-muted">Last updated: {{model.modified|datetime}}</span>\n </div>\n </nav>\n {{/model|bool}}\n\n {{^model|bool}}\n <div class="docit-empty-state">\n <i class="bi bi-file-earmark-text"></i>\n <h3>Select a page</h3>\n <p>Choose a page from the sidebar to view its content.</p>\n </div>\n {{/model|bool}}\n {{/loading}}\n </div>\n '}async onParams(t={},e={}){await super.onParams(t,e),this.loading=!0,await this.render();const o=this.getApp(),i=o.bookSlug||e.doc_book,s=e.doc_page;if(i)try{if(i){if(!o.currentBook||o.currentBook.get("slug")!==i){const t=new DocitBook({slug:i});await t.fetch(),await o.setActiveBook(t)}if(this.bookModel=o.currentBook,s)this.model=new DocitPage({slug:s}),await this.model.fetch({graph:"html"});else{const t=o.docPages.at(0);t?(this.model=new DocitPage({id:t.id}),await this.model.fetch({graph:"html"})):this.model=null}}else this.bookModel=null,this.model=null;this.canEdit=o.canEdit(),this.setupNavigation()}catch(a){console.error("Failed to load page:",a),this.showError("Failed to load documentation page"),this.model=null}finally{this.loading=!1,await this.render(),o.events.emit("docit:page-rendered",{book:this.bookModel,page:this.model})}else setTimeout(()=>{o.showPage("home")},100)}setupNavigation(){if(!this.model)return this.prevPage=null,void(this.nextPage=null);const t=this.getApp().docPages.models,e=t.findIndex(t=>t.id===this.model.id);this.prevPage=e>0?{slug:t[e-1].get("slug"),title:t[e-1].get("title")}:null,this.nextPage=e<t.length-1?{slug:t[e+1].get("slug"),title:t[e+1].get("title")}:null}async onActionNavigateToPage(t,e){t.preventDefault();const o=e.dataset.pageSlug;o&&this.getApp().showPage("docs",{},{doc_book:this.bookModel.get("slug"),doc_page:o})}async onActionEditPage(t,e){t.preventDefault(),this.model&&this.getApp().showPage("edit",{id:this.model.id,doc_book:this.bookModel.get("slug"),doc_page:this.model.get("slug")},{})}async onActionViewHistory(t,e){this.showInfo("Revision history coming soon.")}async onActionEditPageInfo(t,e){this.model&&this.getApp().showModelForm({model:this.model,fields:[{label:"Title",name:"title",type:"text"},{label:"Order Priority",name:"order_priority"},{label:"Slug",name:"slug"}]})}async onActionEditBook(t,e){if(this.model){const t=this.getApp().sidebar.currentBook;if(!t)return;this.getApp().showModelForm({model:t,fields:[{label:"Title",name:"title",type:"text"},{label:"Order Priority",name:"order_priority"},{label:"Slug",name:"slug"},{label:"Is Active",name:"is_active",type:"switch"}]})}}async onActionDeletePage(t,e){if(this.model&&await this.getApp().showConfirm({title:"Delete Page",body:`Are you sure you want to delete "${this.model.get("title")}"?`,confirmText:"Delete",confirmClass:"btn-danger"})){await this.model.destroy(),this.showSuccess("Page deleted."),await this.getApp().setActiveBook(this.bookModel);const t=this.getApp().docPages.at(0);t?this.getApp().showPage("docs",{},{doc_book:this.bookModel.get("slug"),doc_page:t.get("slug")}):this.getApp().showPage("docs",{},{doc_book:this.bookModel.get("slug")})}}async onAfterRender(){await super.onAfterRender(),"undefined"!=typeof Prism&&this.model&&Prism.highlightAll()}}class DocEditPage extends i.Page{constructor(t={}){super({pageName:"edit",title:"Edit Page",className:"docit-edit-page",...t}),this.model=null,this.editor=null,this.isDirty=!1}async getTemplate(){return'\n <div class="docit-edit-container vh-100">\n {{#loading}}\n <div class="docit-loading"><div class="spinner-border"></div></div>\n {{/loading}}\n\n {{^loading}}{{#model}}\n <header class="docit-edit-header">\n <div class="docit-edit-title-row">\n <h2>Editing: {{model.title}}</h2>\n <div class="docit-edit-actions">\n <button class="btn btn-outline-secondary" data-action="cancel-edit">Cancel</button>\n <button class="btn btn-success" data-action="save-page">\n <i class="bi bi-check-lg"></i> Save Changes\n </button>\n </div>\n </div>\n </header>\n <div class="docit-edit-body flex-grow-1">\n <div id="editor"></div>\n </div>\n {{/model}}\n {{^model}}\n <div class="docit-error-state">\n <h3>Page Not Found</h3>\n <p>The page you\'re trying to edit could not be found.</p>\n <button class="btn btn-primary" data-action="go-back">Go Back</button>\n </div>\n {{/model}}{{/loading}}\n </div>\n '}async onParams(t={},e={}){await super.onParams(t,e);let o=null;e.id?o=new DocitPage({id:e.id}):e.doc_page&&(o=new DocitPage({slug:e.doc_page})),this.model=o,this.model&&await this.model.fetch({graph:"detail"})}initEditor(){!this.editor&&this.element.querySelector("#editor")&&(this.editor=new toastui.Editor({el:this.element.querySelector("#editor"),height:"100%",initialEditType:"markdown",previewStyle:"tab",initialValue:this.model.get("content")||""}),this.editor.on("change",()=>{this.isDirty=!0}))}async onActionSavePage(){if(this.model&&this.editor){this.saving=!0,this.getApp().showLoading("saving...");try{const t=this.editor.getMarkdown();await this.model.save({content:t}),this.isDirty=!1,this.getApp().toast.success("Page saved successfully."),this.getApp().showPage("docs",this.query)}catch(t){console.error("Failed to save page:",t),this.getApp().toast.error("Failed to save page.")}finally{this.saving=!1,this.getApp().hideLoading()}}}async onActionCancelEdit(){this.getApp().showPage("docs",this.query)}onActionGoBack(){this.getApp().showPage("docs")}async onBeforeRender(){await super.onBeforeRender(),this.editor&&(this.editor.destroy(),this.editor=null)}async onAfterRender(){await super.onAfterRender(),this.model&&this.initEditor()}async onBeforeDestroy(){this.editor?.destroy(),await super.onBeforeDestroy()}}class DocItApp extends t.WebApp{constructor(t={}){super({name:t.title||"DocIt Portal",version:t.version||"1.0.0",debug:t.debug||!1,container:t.container||"#app",defaultRoute:"home",basePath:t.basePath||"",...t}),this.bookSlug=t.bookSlug||null,this.showBookNav=void 0!==t.showBookNav?t.showBookNav:!this.bookSlug,this.theme=t.theme||"light",this.editPermissions=t.permissions?.edit||["manage_docit"],this.sidebarConfig={showSearch:!0,defaultCollapsed:!1,...t.sidebar},this.books=new DocitBookList,this.books.params.sort="-order_priority",this.docPages=new DocitPageList,this.docPages.params.sort="-order_priority",this.toast=new i.ToastService,this.currentBook=null,this.sidebar=null,this.isDocItReady=!1,this.tokenManager=new e.TokenManager,this.activeUser=null}async start(){try{this.setupDocItLayout(),await this.setupTopNav(),await this.setupSidebar(),await this.checkAuthStatus(),this.registerDocItPages(),await super.start(),await this.loadInitialData(),this.isDocItReady=!0,this.events.emit("docit:ready",{app:this})}catch(t){throw console.error("Failed to start DocIt:",t),this.showError("Failed to initialize documentation portal"),t}}setupDocItLayout(){const t="string"==typeof this.container?document.querySelector(this.container):this.container;if(!t)throw new Error(`Container not found: ${this.container}`);t.classList.add("docit-app",`docit-theme-${this.theme}`),t.innerHTML='\n <div class="docit-app-layout">\n <div id="topnav-container"></div>\n <div class="docit-body-layout">\n <div class="docit-sidebar" id="docit-sidebar"></div>\n <div class="docit-main">\n <div class="docit-content" id="page-container"></div>\n </div>\n </div>\n </div>\n ',this.pageContainer="#page-container"}async setupTopNav(){this.topnav=new e.TopNav({containerId:"topnav-container",brand:this.name,theme:"navbar navbar-expand-lg bg-dark navbar-dark",showSidebarToggle:!1,displayMode:"brand",rightItems:[{id:"login",icon:"bi-box-arrow-in-right",href:"/examples/auth/",label:"Login"}],userMenu:{label:"User",icon:"bi-person-circle",items:[{label:"Profile",icon:"bi-person",action:"profile"},{divider:!0},{label:"Logout",icon:"bi-box-arrow-right",action:"logout"}]}}),await this.topnav.render()}onActionToggleSidebar(){document.querySelector(".docit-layout").classList.toggle("sidebar-collapsed")}async setupSidebar(){this.sidebar=new DocNavSidebar({containerId:"docit-sidebar",app:this,singleBookMode:!!this.bookSlug,showBookNav:this.showBookNav,books:this.books,docPages:this.docPages,activeUser:this.activeUser,...this.sidebarConfig}),await this.sidebar.render()}registerDocItPages(){this.registerPage("home",DocHomePage,{route:"/",permissions:null}),this.registerPage("docs",DocPage,{route:"/docs",permissions:null}),this.registerPage("edit",DocEditPage,{route:"/edit",permissions:this.editPermissions})}async loadInitialData(){try{if(this.bookSlug){const t=new DocitBook({slug:this.bookSlug});if(await t.fetch(),!t.id)throw new Error(`Book with slug '${this.bookSlug}' not found.`);this.books.add(t),await this.setActiveBook(t)}else await this.books.fetch({graph:"list"}),this.sidebar.render()}catch(t){console.error("Failed to load initial data:",t),this.showError("Failed to load documentation")}}async setActiveBook(t){this.currentBook&&t&&this.currentBook.id===t.id||(this.currentBook=t,this.docPages.reset(),t&&await this.docPages.fetch({book:t.get("id"),graph:"list"}),this.sidebar.setCurrentBook(t),this.sidebar.setDocPages(this.docPages),this.events.emit("docit:book-changed",{book:t}))}async saveDocPageContent(t,e){const o=this.docPages.get(t)||new DocitPage({id:t});o.set("content",e);const i=await o.save();if(!i.success||!i.data.status)throw new Error("Failed to save doc page");return o}canEdit(){const t=this.activeUser;return!!t&&this.editPermissions.some(e=>!!t.hasPermission&&t.hasPermission(e))}async checkAuthStatus(){try{const t=this.tokenManager.getTokenInstance();if(!t||!t.isValid())return void this.events.emit("auth:unauthorized",{app:this});if(t.isExpired())return void this.events.emit("auth:expired",{app:this});this.tokenManager.startAutoRefresh(this),this.rest.setAuthToken(t.token);const e=new i.User({id:t.getUserId()});await e.fetch(),this.setActiveUser(e)}catch(t){console.error("Failed to check auth status:",t),this.events.emit("auth:error",{error:t,app:this})}}setActiveUser(t){return this.activeUser=t,this.sidebar&&this.sidebar.setUser(t),this.topnav&&(this.topnav.setUser(t),this.tonnav.render()),this.events.emit("user:changed",{user:t,app:this}),this}clearActiveUser(){return this.activeUser=null,this.tokenManager.clearTokens(),this.rest.clearAuth(),this.sidebar&&this.sidebar.setUser(null),this.events.emit("user:cleared",{app:this}),this}async logout(){this.clearActiveUser(),this.books.reset(),this.docPages.reset(),this.currentBook=null,this.events.emit("auth:logout",{app:this}),window.location.reload()}async createNewBook(){const t=await this.showModelForm({title:"Create New Book",model:new DocitBook,fields:[{name:"title",label:"Title",required:!0},{name:"slug",label:"Slug",required:!0,helpText:"A URL-friendly identifier."}]});t&&t.success&&(this.books.add(t.data),this.sidebar.render(),this.showSuccess("Book created successfully."))}async createNewPage(t){if(!t)return;const e=await this.showForm({title:"Create New Page",fields:[{name:"title",label:"Title",required:!0},{name:"slug",label:"Slug",required:!0,helpText:"A URL-friendly identifier."}]});e&&e.slug&&(e.book=t.id);const o=new DocitPage,i=await o.save(e);i&&i.success&&(this.docPages.add(o),this.sidebar.render(),this.showPage("edit",{id:o.id,doc_book:t.get("slug"),doc_page:o.get("slug")},{}))}static create(t={}){return new DocItApp(t)}static createForBook(t,e={}){return new DocItApp({...e,bookSlug:t,showBookNav:!1})}}exports.WebApp=t.WebApp,exports.BUILD_TIME=a.BUILD_TIME,exports.VERSION=a.VERSION,exports.VERSION_INFO=a.VERSION_INFO,exports.VERSION_MAJOR=a.VERSION_MAJOR,exports.VERSION_MINOR=a.VERSION_MINOR,exports.VERSION_REVISION=a.VERSION_REVISION,exports.DocEditPage=DocEditPage,exports.DocHomePage=DocHomePage,exports.DocItApp=DocItApp,exports.DocNavSidebar=DocNavSidebar,exports.DocPage=DocPage,exports.DocitBook=DocitBook,exports.DocitBookList=DocitBookList,exports.DocitPage=DocitPage,exports.DocitPageList=DocitPageList;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/Dialog-DwgF3hri.js"),e=require("./chunks/TokenManager-DVrApE_3.js"),o=require("./chunks/Rest-BpDyhFfG.js"),i=require("./chunks/ContextMenu-DWau8gXS.js"),s=require("./chunks/Collection-B64LJ92k.js"),a=require("./chunks/version-Ce-8QdEq.js");class DocNavSidebar extends o.View{constructor(t={}){super({className:"docit-sidebar-nav",tagName:"nav",...t}),this.singleBookMode=t.singleBookMode||!1,this.books=t.books,this.docPages=t.docPages,this.activeUser=t.activeUser,this.currentBook=null,this.currentDocPage=null}async onInit(){await super.onInit(),this.getApp().events.on("page:show",this._onPageShow.bind(this))}async _onPageShow({query:t}){const e=t.doc_book,o=t.doc_page,i=this.getApp();if(e){const t=this.books.findWhere({slug:e});!t||this.currentBook&&this.currentBook.id===t.id||(await i.setActiveBook(t),this.currentBook=i.currentBook)}else this.currentBook&&(await i.setActiveBook(null),this.currentBook=null);this.currentDocPage=o?this.docPages.findWhere({slug:o}):null,this.render()}getTemplate(){return'\n <div class="docit-nav-body pt-3">\n {{#currentBook}}\n {{#docPages.models}}\n <a href="#" class="docit-page-link {{#isActive}}active{{/isActive}}"\n data-action="select-page" data-page-slug="{{slug}}">\n <i class="{{#metadata.icon}}{{metadata.icon}}{{/metadata.icon}}{{^metadata.icon}}bi bi-file-earmark-text{{/metadata.icon}} me-2"></i>\n <span>{{title|capitalize}}</span>\n </a>\n {{/docPages.models}}\n {{^docPages.models}}\n <div class="docit-nav-empty"><p>No pages in this book.</p></div>\n {{/docPages.models}}\n {{/currentBook}}\n {{^currentBook}}\n {{#books.models}}\n <a href="#" class="docit-book-item" data-action="select-book" data-book-slug="{{slug}}">\n <i class="bi bi-book me-2"></i>\n <span class="book-title">{{title}}</span>\n <span class="badge bg-secondary ms-auto">{{page_count}}</span>\n </a>\n {{/books.models}}\n {{/currentBook}}\n </div>\n {{#currentBook}}\n <div class="docit-nav-footer">\n {{#canEdit}}\n <button class="btn btn-link w-100 mb-2" data-action="create-page">\n <i class="bi bi-plus-circle me-2"></i>\n Create New Page\n </button>\n {{/canEdit}}\n <button class="btn btn-link w-100" data-action="back-to-books">\n <i class="bi bi-arrow-left me-2"></i>\n Back to Books\n </button>\n </div>\n {{/currentBook}}\n {{^currentBook}}\n {{#canEdit}}\n <div class="docit-nav-footer">\n <button class="btn btn-link w-100" data-action="create-book">\n <i class="bi bi-plus-circle me-2"></i>\n Create New Book\n </button>\n </div>\n {{/canEdit}}\n {{/currentBook}}\n '}async onBeforeRender(){await super.onBeforeRender(),this.canEdit=this.getApp().canEdit(),this.docPages&&this.currentDocPage&&this.docPages.forEach(t=>{t.isActive=t.id===this.currentDocPage.id})}async onActionSelectBook(t,e){t.preventDefault();const o=e.dataset.bookSlug,i=this.books.findWhere({slug:o});if(i){await this.getApp().setActiveBook(i);const t=this.docPages.at(0),e={doc_book:i.get("slug")};t&&(e.doc_page=t.get("slug")),this.getApp().showPage("docs",e,{})}}onActionSelectPage(t,e){t.preventDefault();const o=e.dataset.pageSlug;this.currentBook&&o&&this.getApp().showPage("docs",{doc_book:this.currentBook.get("slug"),doc_page:o},{})}async onActionBackToBooks(t,e){t.preventDefault(),await this.getApp().setActiveBook(null),this.getApp().showPage("home")}async onActionCreateBook(){await this.getApp().createNewBook()}async onActionCreatePage(){this.currentBook&&await this.getApp().createNewPage(this.currentBook)}setBooks(t){this.books=t,this.render()}setDocPages(t){this.docPages=t,this.render()}setCurrentBook(t){this.currentBook=t,this.render(),this.getApp().topnav&&(t?this.getApp().topnav.setBrand(t.get("title")):this.getApp().topnav.setBrand("Documentation"))}setUser(t){this.activeUser=t,this.render()}}class DocHomePage extends i.Page{constructor(t={}){super({pageName:"home",title:"Documentation",className:"docit-home-page",...t})}async getTemplate(){return'\n <div class="docit-empty-state vh-100 d-flex flex-column align-items-center justify-content-center">\n <i class="bi bi-collection" style="font-size: 4rem;"></i>\n <h3 class="mt-4">Welcome to the Documentation Portal</h3>\n <p class="text-muted">Please select a book from the sidebar to get started.</p>\n </div>\n '}}class DocitBook extends s.Model{static endpoint="/api/docit/book";buildUrl(t=null){return this.get("slug")&&!this.id?`/api/docit/book/slug/${this.get("slug")}`:this.id?`/api/docit/book/${this.id}`:this.endpoint}}class DocitBookList extends s.Collection{constructor(t={}){super({ModelClass:DocitBook,endpoint:"/api/docit/book",...t})}parse(t){return t.data&&t.data.status?(this.meta={...this.meta,total:t.data.count||0,graph:t.data.graph},t.data.data||[]):super.parse(t)}}class DocitPage extends s.Model{static endpoint="/api/docit/page";buildUrl(t=null){return this.get("slug")&&!this.id?`/api/docit/page/slug/${this.get("slug")}`:this.id?`/api/docit/page/${this.id}`:this.endpoint}}class DocitPageList extends s.Collection{constructor(t={}){super({ModelClass:DocitPage,endpoint:"/api/docit/page",...t})}parse(t){return t.data&&t.data.status?(this.meta={...this.meta,total:t.data.count||0,graph:t.data.graph,book:t.data.book},t.data.data||[]):super.parse(t)}}class DocPage extends i.Page{constructor(t={}){super({pageName:"docs",title:"Documentation",className:"docit-page",...t}),this.bookModel=null,this.model=null}async onInit(){await super.onInit(),this.pageContextMenu=new i.ContextMenu({config:this.getPageContextMenuConfig(),containerId:"page-context-menu"}),this.addChild(this.pageContextMenu)}getPageContextMenuConfig(){return{icon:"bi-three-dots",buttonClass:"btn btn-outline-secondary btn-sm",items:[{label:"View History",action:"view-history",icon:"bi-clock-history"},{type:"divider"},{label:"Edit Page Content",action:"edit-page",icon:"bi-pencil"},{label:"Edit Page Info",action:"edit-page-info",icon:"bi-list-ol"},{type:"divider"},{label:"Edit Book Info",action:"edit-book",icon:"bi-book"},{type:"divider"},{label:"Delete Page",action:"delete-page",icon:"bi-trash",danger:!0}]}}async getTemplate(){return'\n <div class="docit-page-container position-relative">\n {{#loading}}\n <div class="docit-loading">\n <div class="spinner-border" role="status">\n <span class="visually-hidden">Loading...</span>\n </div>\n </div>\n {{/loading}}\n\n {{^loading}}\n {{#model|bool}}\n <div class="docit-page-toolbar">\n <div class="row">\n <div class="col d-flex justify-content-end">\n <div data-container="page-context-menu"></div>\n </div>\n </div>\n </div>\n <article class="docit-page-content">\n {{{model.html}}}\n </article>\n\n <nav class="docit-page-nav">\n {{#prevPage}}\n <a href="#" class="docit-nav-prev" data-action="navigate-to-page" data-page-slug="{{slug}}">\n <i class="bi bi-arrow-left"></i>\n <div>\n <small>Previous</small>\n <span>{{title}}</span>\n </div>\n </a>\n {{/prevPage}}\n {{^prevPage}}\n <div></div>\n {{/prevPage}}\n\n {{#nextPage}}\n <a href="#" class="docit-nav-next" data-action="navigate-to-page" data-page-slug="{{slug}}">\n <div>\n <small>Next</small>\n <span>{{title}}</span>\n </div>\n <i class="bi bi-arrow-right"></i>\n </a>\n {{/nextPage}}\n\n <div class="my-3">\n <span class="text-muted">Last updated: {{model.modified|datetime}}</span>\n </div>\n </nav>\n {{/model|bool}}\n\n {{^model|bool}}\n <div class="docit-empty-state">\n <i class="bi bi-file-earmark-text"></i>\n <h3>Select a page</h3>\n <p>Choose a page from the sidebar to view its content.</p>\n </div>\n {{/model|bool}}\n {{/loading}}\n </div>\n '}async onParams(t={},e={}){await super.onParams(t,e),this.loading=!0,await this.render();const o=this.getApp(),i=o.bookSlug||e.doc_book,s=e.doc_page;if(i)try{if(i){if(!o.currentBook||o.currentBook.get("slug")!==i){const t=new DocitBook({slug:i});await t.fetch(),await o.setActiveBook(t)}if(this.bookModel=o.currentBook,s)this.model=new DocitPage({slug:s}),await this.model.fetch({graph:"html"});else{const t=o.docPages.at(0);t?(this.model=new DocitPage({id:t.id}),await this.model.fetch({graph:"html"})):this.model=null}}else this.bookModel=null,this.model=null;this.canEdit=o.canEdit(),this.setupNavigation()}catch(a){console.error("Failed to load page:",a),this.showError("Failed to load documentation page"),this.model=null}finally{this.loading=!1,await this.render(),o.events.emit("docit:page-rendered",{book:this.bookModel,page:this.model})}else setTimeout(()=>{o.showPage("home")},100)}setupNavigation(){if(!this.model)return this.prevPage=null,void(this.nextPage=null);const t=this.getApp().docPages.models,e=t.findIndex(t=>t.id===this.model.id);this.prevPage=e>0?{slug:t[e-1].get("slug"),title:t[e-1].get("title")}:null,this.nextPage=e<t.length-1?{slug:t[e+1].get("slug"),title:t[e+1].get("title")}:null}async onActionNavigateToPage(t,e){t.preventDefault();const o=e.dataset.pageSlug;o&&this.getApp().showPage("docs",{},{doc_book:this.bookModel.get("slug"),doc_page:o})}async onActionEditPage(t,e){t.preventDefault(),this.model&&this.getApp().showPage("edit",{id:this.model.id,doc_book:this.bookModel.get("slug"),doc_page:this.model.get("slug")},{})}async onActionViewHistory(t,e){this.showInfo("Revision history coming soon.")}async onActionEditPageInfo(t,e){this.model&&this.getApp().showModelForm({model:this.model,fields:[{label:"Title",name:"title",type:"text"},{label:"Order Priority",name:"order_priority"},{label:"Slug",name:"slug"}]})}async onActionEditBook(t,e){if(this.model){const t=this.getApp().sidebar.currentBook;if(!t)return;this.getApp().showModelForm({model:t,fields:[{label:"Title",name:"title",type:"text"},{label:"Order Priority",name:"order_priority"},{label:"Slug",name:"slug"},{label:"Is Active",name:"is_active",type:"switch"}]})}}async onActionDeletePage(t,e){if(this.model&&await this.getApp().showConfirm({title:"Delete Page",body:`Are you sure you want to delete "${this.model.get("title")}"?`,confirmText:"Delete",confirmClass:"btn-danger"})){await this.model.destroy(),this.showSuccess("Page deleted."),await this.getApp().setActiveBook(this.bookModel);const t=this.getApp().docPages.at(0);t?this.getApp().showPage("docs",{},{doc_book:this.bookModel.get("slug"),doc_page:t.get("slug")}):this.getApp().showPage("docs",{},{doc_book:this.bookModel.get("slug")})}}async onAfterRender(){await super.onAfterRender(),"undefined"!=typeof Prism&&this.model&&Prism.highlightAll()}}class DocEditPage extends i.Page{constructor(t={}){super({pageName:"edit",title:"Edit Page",className:"docit-edit-page",...t}),this.model=null,this.editor=null,this.isDirty=!1}async getTemplate(){return'\n <div class="docit-edit-container vh-100">\n {{#loading}}\n <div class="docit-loading"><div class="spinner-border"></div></div>\n {{/loading}}\n\n {{^loading}}{{#model}}\n <header class="docit-edit-header">\n <div class="docit-edit-title-row">\n <h2>Editing: {{model.title}}</h2>\n <div class="docit-edit-actions">\n <button class="btn btn-outline-secondary" data-action="cancel-edit">Cancel</button>\n <button class="btn btn-success" data-action="save-page">\n <i class="bi bi-check-lg"></i> Save Changes\n </button>\n </div>\n </div>\n </header>\n <div class="docit-edit-body flex-grow-1">\n <div id="editor"></div>\n </div>\n {{/model}}\n {{^model}}\n <div class="docit-error-state">\n <h3>Page Not Found</h3>\n <p>The page you\'re trying to edit could not be found.</p>\n <button class="btn btn-primary" data-action="go-back">Go Back</button>\n </div>\n {{/model}}{{/loading}}\n </div>\n '}async onParams(t={},e={}){await super.onParams(t,e);let o=null;e.id?o=new DocitPage({id:e.id}):e.doc_page&&(o=new DocitPage({slug:e.doc_page})),this.model=o,this.model&&await this.model.fetch({graph:"detail"})}initEditor(){!this.editor&&this.element.querySelector("#editor")&&(this.editor=new toastui.Editor({el:this.element.querySelector("#editor"),height:"100%",initialEditType:"markdown",previewStyle:"tab",initialValue:this.model.get("content")||""}),this.editor.on("change",()=>{this.isDirty=!0}))}async onActionSavePage(){if(this.model&&this.editor){this.saving=!0,this.getApp().showLoading("saving...");try{const t=this.editor.getMarkdown();await this.model.save({content:t}),this.isDirty=!1,this.getApp().toast.success("Page saved successfully."),this.getApp().showPage("docs",this.query)}catch(t){console.error("Failed to save page:",t),this.getApp().toast.error("Failed to save page.")}finally{this.saving=!1,this.getApp().hideLoading()}}}async onActionCancelEdit(){this.getApp().showPage("docs",this.query)}onActionGoBack(){this.getApp().showPage("docs")}async onBeforeRender(){await super.onBeforeRender(),this.editor&&(this.editor.destroy(),this.editor=null)}async onAfterRender(){await super.onAfterRender(),this.model&&this.initEditor()}async onBeforeDestroy(){this.editor?.destroy(),await super.onBeforeDestroy()}}class DocItApp extends t.WebApp{constructor(t={}){super({name:t.title||"DocIt Portal",version:t.version||"1.0.0",debug:t.debug||!1,container:t.container||"#app",defaultRoute:"home",basePath:t.basePath||"",...t}),this.bookSlug=t.bookSlug||null,this.showBookNav=void 0!==t.showBookNav?t.showBookNav:!this.bookSlug,this.theme=t.theme||"light",this.editPermissions=t.permissions?.edit||["manage_docit"],this.sidebarConfig={showSearch:!0,defaultCollapsed:!1,...t.sidebar},this.books=new DocitBookList,this.books.params.sort="-order_priority",this.docPages=new DocitPageList,this.docPages.params.sort="-order_priority",this.toast=new i.ToastService,this.currentBook=null,this.sidebar=null,this.isDocItReady=!1,this.tokenManager=new e.TokenManager,this.activeUser=null}async start(){try{this.setupDocItLayout(),await this.setupTopNav(),await this.setupSidebar(),await this.checkAuthStatus(),this.registerDocItPages(),await super.start(),await this.loadInitialData(),this.isDocItReady=!0,this.events.emit("docit:ready",{app:this})}catch(t){throw console.error("Failed to start DocIt:",t),this.showError("Failed to initialize documentation portal"),t}}setupDocItLayout(){const t="string"==typeof this.container?document.querySelector(this.container):this.container;if(!t)throw new Error(`Container not found: ${this.container}`);t.classList.add("docit-app",`docit-theme-${this.theme}`),t.innerHTML='\n <div class="docit-app-layout">\n <div id="topnav-container"></div>\n <div class="docit-body-layout">\n <div class="docit-sidebar" id="docit-sidebar"></div>\n <div class="docit-main">\n <div class="docit-content" id="page-container"></div>\n </div>\n </div>\n </div>\n ',this.pageContainer="#page-container"}async setupTopNav(){this.topnav=new e.TopNav({containerId:"topnav-container",brand:this.name,theme:"navbar navbar-expand-lg bg-dark navbar-dark",showSidebarToggle:!1,displayMode:"brand",rightItems:[{id:"login",icon:"bi-box-arrow-in-right",href:"/examples/auth/",label:"Login"}],userMenu:{label:"User",icon:"bi-person-circle",items:[{label:"Profile",icon:"bi-person",action:"profile"},{divider:!0},{label:"Logout",icon:"bi-box-arrow-right",action:"logout"}]}}),await this.topnav.render()}onActionToggleSidebar(){document.querySelector(".docit-layout").classList.toggle("sidebar-collapsed")}async setupSidebar(){this.sidebar=new DocNavSidebar({containerId:"docit-sidebar",app:this,singleBookMode:!!this.bookSlug,showBookNav:this.showBookNav,books:this.books,docPages:this.docPages,activeUser:this.activeUser,...this.sidebarConfig}),await this.sidebar.render()}registerDocItPages(){this.registerPage("home",DocHomePage,{route:"/",permissions:null}),this.registerPage("docs",DocPage,{route:"/docs",permissions:null}),this.registerPage("edit",DocEditPage,{route:"/edit",permissions:this.editPermissions})}async loadInitialData(){try{if(this.bookSlug){const t=new DocitBook({slug:this.bookSlug});if(await t.fetch(),!t.id)throw new Error(`Book with slug '${this.bookSlug}' not found.`);this.books.add(t),await this.setActiveBook(t)}else await this.books.fetch({graph:"list"}),this.sidebar.render()}catch(t){console.error("Failed to load initial data:",t),this.showError("Failed to load documentation")}}async setActiveBook(t){this.currentBook&&t&&this.currentBook.id===t.id||(this.currentBook=t,this.docPages.reset(),t&&await this.docPages.fetch({book:t.get("id"),graph:"list"}),this.sidebar.setCurrentBook(t),this.sidebar.setDocPages(this.docPages),this.events.emit("docit:book-changed",{book:t}))}async saveDocPageContent(t,e){const o=this.docPages.get(t)||new DocitPage({id:t});o.set("content",e);const i=await o.save();if(!i.success||!i.data.status)throw new Error("Failed to save doc page");return o}canEdit(){const t=this.activeUser;return!!t&&this.editPermissions.some(e=>!!t.hasPermission&&t.hasPermission(e))}async checkAuthStatus(){try{const t=this.tokenManager.getTokenInstance();if(!t||!t.isValid())return void this.events.emit("auth:unauthorized",{app:this});if(t.isExpired())return void this.events.emit("auth:expired",{app:this});this.tokenManager.startAutoRefresh(this),this.rest.setAuthToken(t.token);const e=new i.User({id:t.getUserId()});await e.fetch(),this.setActiveUser(e)}catch(t){console.error("Failed to check auth status:",t),this.events.emit("auth:error",{error:t,app:this})}}setActiveUser(t){return this.activeUser=t,this.sidebar&&this.sidebar.setUser(t),this.topnav&&(this.topnav.setUser(t),this.tonnav.render()),this.events.emit("user:changed",{user:t,app:this}),this}clearActiveUser(){return this.activeUser=null,this.tokenManager.clearTokens(),this.rest.clearAuth(),this.sidebar&&this.sidebar.setUser(null),this.events.emit("user:cleared",{app:this}),this}async logout(){this.clearActiveUser(),this.books.reset(),this.docPages.reset(),this.currentBook=null,this.events.emit("auth:logout",{app:this}),window.location.reload()}async createNewBook(){const t=await this.showModelForm({title:"Create New Book",model:new DocitBook,fields:[{name:"title",label:"Title",required:!0},{name:"slug",label:"Slug",required:!0,helpText:"A URL-friendly identifier."}]});t&&t.success&&(this.books.add(t.data),this.sidebar.render(),this.showSuccess("Book created successfully."))}async createNewPage(t){if(!t)return;const e=await this.showForm({title:"Create New Page",fields:[{name:"title",label:"Title",required:!0},{name:"slug",label:"Slug",required:!0,helpText:"A URL-friendly identifier."}]});e&&e.slug&&(e.book=t.id);const o=new DocitPage,i=await o.save(e);i&&i.success&&(this.docPages.add(o),this.sidebar.render(),this.showPage("edit",{id:o.id,doc_book:t.get("slug"),doc_page:o.get("slug")},{}))}static create(t={}){return new DocItApp(t)}static createForBook(t,e={}){return new DocItApp({...e,bookSlug:t,showBookNav:!1})}}exports.WebApp=t.WebApp,exports.BUILD_TIME=a.BUILD_TIME,exports.VERSION=a.VERSION,exports.VERSION_INFO=a.VERSION_INFO,exports.VERSION_MAJOR=a.VERSION_MAJOR,exports.VERSION_MINOR=a.VERSION_MINOR,exports.VERSION_REVISION=a.VERSION_REVISION,exports.DocEditPage=DocEditPage,exports.DocHomePage=DocHomePage,exports.DocItApp=DocItApp,exports.DocNavSidebar=DocNavSidebar,exports.DocPage=DocPage,exports.DocitBook=DocitBook,exports.DocitBookList=DocitBookList,exports.DocitPage=DocitPage,exports.DocitPageList=DocitPageList;
|
|
2
2
|
//# sourceMappingURL=docit.cjs.js.map
|
package/dist/docit.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { W as WebApp } from "./chunks/Dialog-
|
|
2
|
-
import { T as TokenManager, a as TopNav } from "./chunks/TokenManager-
|
|
1
|
+
import { W as WebApp } from "./chunks/Dialog-DRf1-ZSd.js";
|
|
2
|
+
import { T as TokenManager, a as TopNav } from "./chunks/TokenManager-CWi9-XBF.js";
|
|
3
3
|
import { V as View } from "./chunks/Rest-DpbPbmra.js";
|
|
4
|
-
import { P as Page, C as ContextMenu, T as ToastService, U as User } from "./chunks/ContextMenu-
|
|
5
|
-
import { M as Model, C as Collection } from "./chunks/Collection-
|
|
6
|
-
import { B, a, V, b, c, d } from "./chunks/version-
|
|
4
|
+
import { P as Page, C as ContextMenu, T as ToastService, U as User } from "./chunks/ContextMenu-Dfdrnd0f.js";
|
|
5
|
+
import { M as Model, C as Collection } from "./chunks/Collection-CsAk0UhA.js";
|
|
6
|
+
import { B, a, V, b, c, d } from "./chunks/version-Be_W-mxT.js";
|
|
7
7
|
class DocNavSidebar extends View {
|
|
8
8
|
constructor(options = {}) {
|
|
9
9
|
super({
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/version-Dv-LRsJ8.js"),t=require("./chunks/Rest-BpDyhFfG.js"),s=require("./chunks/ContextMenu-DWau8gXS.js"),i=require("./chunks/Dialog-B2JUzeMM.js"),a=require("./chunks/Collection-B64LJ92k.js"),n=require("./chunks/ChatView-C7sLr2J4.js"),r=require("./chunks/TokenManager-DpzgbkN4.js"),o=require("./chunks/ListView-BpGEatee.js"),l=require("./chunks/DataView-DESqBxT-.js"),c=require("./chunks/FormView-D5FEA-Nu.js"),d=require("./chunks/WebSocketClient-E08hfP5f.js");var h="undefined"!=typeof document?document.currentScript:null;const u={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},p=Object.freeze({silent:0,error:1,warn:2,info:3,log:3,debug:4,trace:5,all:5}),g=(()=>{try{if(void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:h&&"SCRIPT"===h.tagName.toUpperCase()&&h.src||new URL("index.cjs.js",document.baseURI).href}&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:h&&"SCRIPT"===h.tagName.toUpperCase()&&h.src||new URL("index.cjs.js",document.baseURI).href,1)&&u)return!1}catch{}if("undefined"!=typeof globalThis&&void 0!==globalThis.__DEV__)try{return!!globalThis.__DEV__}catch{}return!("undefined"==typeof process||!process||"object"!=typeof process.env||"string"!=typeof process.env.NODE_ENV)&&"production"!==process.env.NODE_ENV})(),m="undefined"!=typeof window&&"undefined"!=typeof document,b="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:global,v=b.console||{},f={};let w=!1,x=null;function y(e){if("number"==typeof e){const t=p.silent,s=p.trace;return Math.min(Math.max(e,t),s)}if("string"==typeof e){const t=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(p,t))return p[t]}return null}function S(e,t){const s=f[e]||v[e]||(()=>{});return function(...e){if(x>=t)return s.apply(v,e)}}const P={install(e={}){if(w)return e&&void 0!==e.level&&this.setLevel(e.level,{persist:!!e.persist}),this;if(!b||!v)return w=!0,this;x=function(e){const t=y(e);if(null!==t)return t;const s=function(){if(!m||"undefined"==typeof location||!location.search)return null;try{const e=new URLSearchParams(location.search),t=["logLevel","loglevel","mojoLog"];for(const s of t){const t=e.get(s);if(null!=t){const e=y(t);if(null!==e)return e}}}catch{}return null}();if(null!==s)return s;const i=function(){if(!m||!("localStorage"in b))return null;try{const e=b.localStorage.getItem("MOJO_LOG_LEVEL");if(null!=e){const t=y(e);if(null!==t)return t}}catch{}return null}();return null!==i?i:y(g?"debug":"warn")}(e.level);const t=function(){const e={...v},t={error:p.error,warn:p.warn,info:p.info,log:p.info,dir:p.info,table:p.info,debug:p.debug,group:p.debug,groupCollapsed:p.debug,groupEnd:p.debug,time:p.debug,timeEnd:p.debug,timeLog:p.debug,trace:p.trace};for(const s of Object.keys(t))f[s]=v[s]||(()=>{}),e[s]=S(s,t[s]);return f.assert=v.assert||(()=>{}),e.assert=function(){const e=f.assert||v.assert||(()=>{});return function(t,...s){if(!t)return x>=p.error?e.apply(v,[t,...s]):void 0}}(),e}();return b.console=t,w=!0,b.MOJOConsoleSilencer=this,this},uninstall(){if(!w)return this;try{b.console=v}catch{}return w=!1,this},setLevel(e,{persist:t=!1}={}){const s=y(e);return null===s||(x=s,t&&function(e){if(m&&"localStorage"in b)try{const t="string"==typeof e?e:null===e?null:Object.entries(p).find(([,t])=>t===e)?.[0]??null;t?b.localStorage.setItem("MOJO_LOG_LEVEL",t):b.localStorage.removeItem("MOJO_LOG_LEVEL")}catch{}}(e)),this},getLevel:()=>x,getLevelName(){const e=Object.entries(p).find(([,e])=>e===x);return e?e[0]:null},criticalOnly({persist:e=!1}={}){return this.setLevel("warn",{persist:e})},errorsOnly({persist:e=!1}={}){return this.setLevel("error",{persist:e})},silent({persist:e=!1}={}){return this.setLevel("silent",{persist:e})},verbose({persist:e=!1}={}){return this.setLevel(g?"debug":"info",{persist:e})},allowAll({persist:e=!1}={}){return this.setLevel("trace",{persist:e})},withTemporaryLevel(e,t){const s=x,i=y(e);if(null===i||"function"!=typeof t)return t?.();x=i;try{return t()}finally{x=s}},LEVELS:p};class Sidebar extends t.View{constructor(e={}){super({tagName:"nav",className:"sidebar",id:"sidebar",...e}),this.menus=/* @__PURE__ */new Map,this.activeMenuName=null,this.currentRoute=null,this.showToggle=e.showToggle,this.isCollapsed=!1,this.sidebarTheme=e.theme||"sidebar-light",this.customView=null,this.options.groupHeader&&(this.groupHeader=this.options.groupHeader),this.groupSelectorMode=e.groupSelectorMode||"inline",this.groupSelectorDialog=null,this.sidebarTheme&&this.addClass(this.sidebarTheme),this.initializeMenus(e),this.setupRouteListeners(),!1!==e.autoCollapseMobile&&this.setupResponsiveBehavior()}groupHeader="\n <div class=\"sidebar-group-header py-3\" data-action=\"show-group-search\">\n <div class='text-center fs-5 px-1 collapsed-hidden'>{{group.name}}</div>\n <div class='text-center fs-6 collapsed-hidden'>kind: {{group.kind}}</div>\n </div>\n ";async onInit(){await super.onInit();const e=this.getApp(),t=e?.router;if(t){const e=t.getCurrentPath();e&&this.autoSwitchToMenuForRoute(e)}this.initializeTooltips(),this.searchView=new r.SimpleSearchView({noAppend:!0,showExitButton:!0,headerText:"Select Group",containerId:"sidebar-search-container",Collection:s.GroupList,itemTemplate:'\n <div class="p-3 border-bottom">\n <div class="fw-semibold text-dark">{{name}}</div>\n <small class="text-muted">#{{id}} {{kind}}</small>\n </div>\n '}),this.addChild(this.searchView),this.searchView.on("item:selected",e=>{this.getApp().setActiveGroup(e.model)}),this.searchView.on("exit",e=>{this.hideGroupSearch()})}showGroupSearch(){"dialog"===this.groupSelectorMode?this.showGroupSearchDialog():(this.setClass("sidebar"),this.showSearch=!0,this.render())}hideGroupSearch(){"dialog"===this.groupSelectorMode?this.groupSelectorDialog&&this.groupSelectorDialog.hide():(this.setClass("sidebar"),this.showSearch=!1,this.render())}onActionShowGroupSearch(){this.showGroupSearch()}async showGroupSearchDialog(){const e=new s.GroupList,t=new r.SimpleSearchView({Collection:s.GroupList,collection:e,itemTemplate:'\n <div class="p-3 border-bottom">\n <div class="fw-semibold text-dark">{{name}}</div>\n <small class="text-muted">#{{id}} {{kind}}</small>\n </div>\n ',searchFields:["name"],headerText:"Select Group",searchPlaceholder:"Search groups...",headerIcon:"bi-building",showExitButton:!1});this.groupSelectorDialog=new i.Dialog({title:"Select Group",body:t,size:"md",scrollable:!0,noBodyPadding:!0,buttons:[],closeButton:!0}),t.on("item:selected",e=>{this.getApp().setActiveGroup(e.model),this.groupSelectorDialog&&this.groupSelectorDialog.hide()}),this.groupSelectorDialog.on("hidden",()=>{this.groupSelectorDialog.destroy(),this.groupSelectorDialog=null}),await this.groupSelectorDialog.render(!0,document.body),this.groupSelectorDialog.show()}autoSwitchToMenuForRoute(e){for(const[t,s]of this.menus)if((!s.groupKind||this.getApp().activeGroup)&&this.menuContainsRoute(s,e))return this._setActiveMenu(t),this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),this.render(),this.emit("menu-auto-switched",{menuName:t,route:e,config:s,sidebar:this}),!0;return!1}clearAllActiveStates(){for(const[e,t]of this.menus)for(const s of t.items||[])if(s.active=!1,s.children)for(const e of s.children)e.active=!1}setActiveItemByRoute(e){const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e);for(const[i,a]of this.menus)if(!a.groupKind||this.getApp().activeGroup)for(const e of a.items||[]){if(e.route){const i=t(e.route);if(this.routesMatch(s,i))return e.active=!0,this.activeMenuItem=e,!0}if(e.children)for(const i of e.children)if(i.route){const a=t(i.route);if(this.routesMatch(s,a))return i.active=!0,e.active=!0,!0}}return!1}menuContainsRoute(e,t){const s=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},i=s(t);for(const a of e.items||[]){if(a.route){const e=s(a.route);if(this.routesMatch(i,e))return!0}if(a.children)for(const e of a.children)if(e.route){const t=s(e.route);if(this.routesMatch(i,t))return!0}}return!1}routesMatch(e,t){return this.getApp().router.doRoutesMatch(e,t)}getTemplate(){return this.customView?'<div class="sidebar-container" id="sidebar-custom-view-container"></div>':this.showSearch?this.getSearchTemplate():this.getMenuTemplate()}getSearchTemplate(){return'\n <div class="sidebar-container" id="sidebar-search-container">\n </div>\n '}getMenuTemplate(){return'\n <div class="sidebar-container">\n {{#data.currentMenu}}\n \x3c!-- Header --\x3e\n {{#header}}\n <div class="sidebar-header">\n {{{header}}}\n {{#showToggle}}\n <button class="sidebar-toggle" data-action="toggle-sidebar"\n aria-label="Toggle Sidebar">\n <i class="bi bi-chevron-left toggle-icon"></i>\n <i class="bi bi-chevron-right toggle-icon"></i>\n </button>\n {{/showToggle}}\n </div>\n {{/header}}\n\n \x3c!-- Navigation Items --\x3e\n <div class="sidebar-body">\n <ul class="nav nav-pills flex-column sidebar-nav" id="sidebar-nav-menu">\n {{#items}}\n {{>nav-item}}\n {{/items}}\n </ul>\n </div>\n\n \x3c!-- Footer --\x3e\n {{#footer}}\n <div class="sidebar-footer">\n {{{footer}}}\n </div>\n {{/footer}}\n {{/data.currentMenu}}\n\n {{^data.currentMenu}}\n <div class="sidebar-empty">\n <p class="text-danger text-center">No menu configured</p>\n </div>\n {{/data.currentMenu}}\n </div>\n '}getPartials(){return{"nav-item":'\n {{#isDivider}}\n {{>nav-divider}}\n {{/isDivider}}\n {{#isSpacer}}\n {{>nav-spacer}}\n {{/isSpacer}}\n {{#isLabel}}\n {{>nav-label}}\n {{/isLabel}}\n\n {{^isDivider}}\n {{^isSpacer}}\n {{^isLabel}}\n <li class="nav-item">\n {{#hasChildren}}\n \x3c!-- Item with submenu --\x3e\n <a class="nav-link {{#active}}active{{/active}} has-children collapsed"\n data-bs-toggle="collapse"\n href="#collapse-{{id}}"\n role="button"\n aria-expanded="{{#active}}true{{/active}}{{^active}}false{{/active}}"\n data-action="toggle-submenu">\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n <i class="bi bi-chevron-down nav-arrow ms-auto"></i>\n </a>\n <div class="collapse {{#active}}show{{/active}}" id="collapse-{{id}}" data-bs-parent="#sidebar-nav-menu">\n <ul class="nav flex-column nav-submenu">\n {{#children}}\n <li class="nav-item">\n <a class="nav-link {{#active}}active{{/active}}"\n {{#action}}data-action="{{action}}"{{/action}}\n {{#href}}href="{{href}}"{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n </li>\n {{/children}}\n </ul>\n </div>\n {{/hasChildren}}\n {{^hasChildren}}\n \x3c!-- Simple item --\x3e\n <a class="nav-link {{#active}}active{{/active}} {{#disabled}}disabled{{/disabled}}"\n {{#action}}{{^disabled}}data-action="{{action}}"{{/disabled}}{{/action}}\n {{#href}}{{^disabled}}href="{{href}}"{{/disabled}}{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n {{/hasChildren}}\n </li>\n {{/isLabel}}\n {{/isSpacer}}\n {{/isDivider}}\n ',"nav-divider":'\n <li class="nav-divider-item">\n <hr class="nav-divider-line">\n </li>\n ',"nav-spacer":'\n <li class="nav-spacer-item"></li>\n ',"nav-label":'\n <li class="nav-item {{className}}">\n <div class="nav-text px-3">{{text}}</div>\n </li>\n '}}getGroupHeader(){return this.groupHeader}addMenu(e,t){return t.groupKind&&!t.header&&(t.header=this.getGroupHeader()),this.menus.set(e,{name:e,groupKind:t.groupKind||null,header:t.header||null,footer:t.footer||null,items:t.items||[],data:t.data||{},className:t.className||"sidebar sidebar-dark"}),this.activeMenuName||this._setActiveMenu(e),this}_setActiveMenu(e){this.showSearch=!1,this.activeMenuName=e;const t=this.getCurrentMenuConfig();t.className?this.setClass(t.className):this.setClass("sidebar")}async setActiveMenu(e){if(!this.menus.has(e))return console.warn(`Menu '${e}' not found`),this;const t=this.menus.get(e);if(!t.groupKind||(this.lastGroupMenu=t,this.getApp().activeGroup))return this._setActiveMenu(e),await this.render(),this.emit("menu-changed",{menuName:e,config:t,sidebar:this}),this;this.showGroupSearch()}getGroupMenu(e){if(!e)return console.warn("No group provided"),null;let t=this.lastGroupMenu,s=null;if(e._.kind)for(const[i,a]of this.menus){if(this._groupKindMatches(a.groupKind,e._.kind)){t=a;break}"any"===a.groupKind&&(s=a)}return t||s}_groupKindMatches(e,t){return!(!e||!t)&&(Array.isArray(e)?e.includes(t):e===t)}showMenuForGroup(e){if(!e)return void console.warn("No group provided");let t=this.getGroupMenu(e);if(t)return this._setActiveMenu(t.name),this.render(),this.emit("menu-changed",{menuName:t.name,config:t,sidebar:this}),this;console.warn(`No menu found for group kind: ${e.kind}`)}getMenuConfig(e){return this.menus.get(e)||null}getCurrentMenuConfig(){return this.activeMenuName?this.menus.get(this.activeMenuName):null}updateMenu(e,t){const s=this.menus.get(e);return s?(Object.assign(s,t),this.activeMenuName===e&&this.render(),this):(console.warn(`Menu '${e}' not found`),this)}removeMenu(e){if(this.menus.delete(e),this.activeMenuName===e){const e=Array.from(this.menus.keys());this.activeMenuName=e.length>0?e[0]:null,this.render()}return this}async onBeforeRender(){const e=this.getCurrentMenuConfig();if(!e)return{currentMenu:null};let t={version:this.getApp().version||null,group:this.getApp().activeGroup||null,user:this.getApp.activeUser||null};this.data={currentMenu:{header:this.renderTemplateString(e.header||"",t),footer:this.renderTemplateString(e.footer||"",t),items:this.processNavItems(e.items,e.groupKind),data:e.data,showToggle:this.showToggle}}}async onAfterRender(){this.isCollapsedState()?setTimeout(()=>this.initializeTooltips(),50):this.destroyTooltips()}setCustomView(e){return this.customView&&this.removeChild(this.customView.id),this.customView=e,e&&(e.containerId="sidebar-custom-view-container",this.addChild(e)),this.render(),this}clearCustomView(){return this.customView&&(this.removeChild(this.customView.id),this.customView=null),this.render(),this}processNavItems(e,t){const s=this.getApp(),i=s?.activeUser,a=s?.activeGroup,n=e=>{if(t&&a&&a.id){const t=e.includes("?")?"&":"?";return`${e}${t}group=${a.id}`}return e};return e.map((e,t)=>{if(""===e||"object"==typeof e&&e.divider)return{isDivider:!0,id:`divider-${t}`};if("object"==typeof e&&e.spacer)return{isSpacer:!0,id:`spacer-${t}`};const s={...e};if(s.permissions&&(!i||!i.hasPermission(s.permissions)))return null;if(s.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(s.requiresGroupKind,e))return null}if("label"===s.kind)return s.isLabel=!0,s.id||(s.id=`nav-label-${t}`),s;if(s.id||(s.id=`nav-${t}`),s.route)s.href=n(s.route);else if(s.page){const e=s.page.startsWith("/")?s.page:`/${s.page}`;s.href=n(e),s.route=s.href}return s.children?(s.children=s.children.map(e=>{const t={...e};if(t.permissions&&i&&!i.hasPermission(t.permissions))return null;if(t.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(t.requiresGroupKind,e))return null}if(t.route)t.href=n(t.route);else if(t.page){const e=t.page.startsWith("/")?t.page:`/${t.page}`;t.href=n(e),t.route=t.href}return t}).filter(e=>null!==e),s.hasChildren=!!(s.children&&s.children.length>0)):s.hasChildren=!1,s}).filter(e=>null!==e)}isItemActive(e){if(!e.route||!this.currentRoute)return!1;const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e.route),i=t(this.currentRoute);return"/"===s&&"/"===i||"/"!==s&&"/"!==i&&(i.startsWith(s)||i===s)}async updateActiveItem(e){return this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),await this.render(),this}async handleActionToggleSubmenu(e,t){const s=t.querySelector(".nav-arrow");s&&s.classList.toggle("rotated")}async handleActionToggleSidebar(e,t){this.toggleSidebar()}onActionShowGroupMenu(e,t,s){return this.setActiveMenu("group_default"),!1}async onActionDefault(e,t,s){const i=this.getCurrentMenuConfig();if(i){for(const a of i.items)if(a.action==e&&a.handler)return a.handler(e,t,s),!0;return!1}}getMenuNames(){return Array.from(this.menus.keys())}hasMenu(e){return this.menus.has(e)}clearMenus(){return this.menus.clear(),this.activeMenuName=null,this.render(),this}setMenuData(e){const t=this.getCurrentMenuConfig();return t&&(t.data={...t.data,...e},this.render()),this}getMenuData(){const e=this.getCurrentMenuConfig();return e?e.data:{}}setupRouteListeners(){const e=this.getApp();e&&e.events&&(e.events.on(["page:showing"],e=>{this.onRouteChanged(e)}),e.events.on("group:changed",e=>{this.showMenuForGroup(e.group)}),e.events.on("portal:user-changed",e=>{this.render()}))}onRouteChanged(e){if(e.page&&e.page.route){const t=e.page.route;if(this.activeMenuItem&&this.routesMatch(t,this.activeMenuItem.route))return;this.autoSwitchToMenuForRoute(t)||(this.clearAllActiveStates(),this.setActiveItemByRoute(t),this.updateActiveItem(t))}}toggleSidebar(){const e=document.querySelector(".portal-container");if(!e)return;this.hideAllTooltips();const t=e.classList.contains("collapse-sidebar");return e.classList.contains("hide-sidebar")?(e.classList.remove("hide-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):t?(e.classList.remove("collapse-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):(e.classList.add("collapse-sidebar"),this.isCollapsed=!0,setTimeout(()=>this.initializeTooltips(),150)),this}setSidebarState(e){const t=document.querySelector(".portal-container");if(!t)return this;switch(t.classList.remove("collapse-sidebar","hide-sidebar"),e){case"collapsed":t.classList.add("collapse-sidebar"),this.isCollapsed=!0;break;case"hidden":t.classList.add("hide-sidebar"),this.isCollapsed=!1;break;default:this.isCollapsed=!1}return this.isCollapsed?(this.hideAllTooltips(),setTimeout(()=>this.initializeTooltips(),100)):this.destroyTooltips(),this}initializeTooltips(){return this.destroyTooltips(),this.isCollapsedState()?(this.element.querySelectorAll(".sidebar-nav .nav-link").forEach(e=>{const t=e.querySelector(".nav-text");if(t&&t.textContent.trim()){const s=t.textContent.trim();if(e.setAttribute("data-bs-toggle","tooltip"),e.setAttribute("data-bs-placement","right"),e.setAttribute("data-bs-title",s),e.setAttribute("data-bs-container","body"),window.bootstrap&&window.bootstrap.Tooltip){const t=e.getAttribute("data-tooltip-theme"),s=e.getAttribute("data-tooltip-size");let i="";t&&(i+=`tooltip-${t} `),s&&(i+=`tooltip-${s}`);const a={placement:"right",container:"body",trigger:"hover",delay:{show:500,hide:100},fallbackPlacements:["top","bottom","left"]},n=i.trim();n&&(a.customClass=n);const r=new window.bootstrap.Tooltip(e,a);e._tooltipInstance=r,e.addEventListener("click",()=>{r.hide()}),e.addEventListener("blur",()=>{r.hide()})}}}),this.addTooltipHideListeners(),this):this}destroyTooltips(){return this.removeTooltipHideListeners(),this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&(t.hide(),t.dispose()),delete e._tooltipInstance,e.removeAttribute("data-bs-toggle"),e.removeAttribute("data-bs-placement"),e.removeAttribute("data-bs-title"),e.removeAttribute("data-bs-container")}),this}getSidebarState(){const e=document.querySelector(".portal-container");return e?e.classList.contains("hide-sidebar")?"hidden":e.classList.contains("collapse-sidebar")?"collapsed":"normal":"normal"}isCollapsedState(){return"collapsed"===this.getSidebarState()}setToggleEnabled(e){return this.showToggle=e,this.render(),this}initializeMenus(e){if(e.menus)for(const t of e.menus)this.addMenu(t.name,t);else e.menu&&(e.menu.name=e.menu.name||"default",this.addMenu(e.menu.name,e.menu))}addTooltipHideListeners(){this._tooltipScrollHandler=()=>this.hideAllTooltips(),this.element.addEventListener("scroll",this._tooltipScrollHandler,{passive:!0}),this._tooltipRouteHandler=()=>this.hideAllTooltips(),this.getApp(),this._tooltipBlurHandler=()=>this.hideAllTooltips(),window.addEventListener("blur",this._tooltipBlurHandler),this._tooltipEscapeHandler=e=>{"Escape"===e.key&&this.hideAllTooltips()},document.addEventListener("keydown",this._tooltipEscapeHandler)}removeTooltipHideListeners(){this._tooltipScrollHandler&&(this.element.removeEventListener("scroll",this._tooltipScrollHandler),delete this._tooltipScrollHandler),this._tooltipBlurHandler&&(window.removeEventListener("blur",this._tooltipBlurHandler),delete this._tooltipBlurHandler),this._tooltipEscapeHandler&&(document.removeEventListener("keydown",this._tooltipEscapeHandler),delete this._tooltipEscapeHandler)}hideAllTooltips(){this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&t.hide()}),document.querySelectorAll(".tooltip.show").forEach(e=>{e.remove()})}async onBeforeDestroy(){this.destroyTooltips(),await super.onBeforeDestroy()}setupResponsiveBehavior(){const e=()=>{const e=window.innerWidth<=768,t=document.querySelector(".portal-container");t&&(e?t.classList.add("sidebar-mobile"):t.classList.remove("sidebar-mobile","sidebar-open"))};e(),window.addEventListener("resize",e)}static createDefault(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!0,autoCollapseMobile:!0,...e})}static createMinimal(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!1,autoCollapseMobile:!1,...e})}setSidebarTheme(e){return this.removeClass("sidebar-light sidebar-dark sidebar-clean"),this.sidebarTheme=e,this.addClass(e),this}show(){return this.setSidebarState("normal")}hide(){return this.setSidebarState("hidden")}collapse(){return this.setSidebarState("collapsed")}expand(){return this.setSidebarState("normal")}pulseToggle(){const e=this.element.querySelector(".sidebar-toggle");if(e){e.classList.add("pulse");const t=()=>{e.classList.remove("pulse"),e.removeEventListener("click",t)};e.addEventListener("click",t,{once:!0}),setTimeout(t,3e3)}return this}addSimpleMenuItem(e,t,s,i="bi-circle"){const a=this.menus.get(e);return a&&(a.items=a.items||[],a.items.push({text:t,route:s,icon:i}),this.activeMenuName===e&&this.render()),this}setSimpleMenu(e,t,s){const i={name:e,header:t,items:s};return this.addMenu(e,i),this.setActiveMenu(e),this}}class PageHeader extends t.View{constructor(e={}){super({tagName:"div",className:"page-header",...e}),this.style=e.style||"default",this.size=e.size||"md",this.showIcon=!1!==e.showIcon,this.showDescription=!1!==e.showDescription,this.showBreadcrumbs=e.showBreadcrumbs||!1,this.currentPage=null}async getTemplate(){return"minimal"===this.style?this.getMinimalTemplate():"breadcrumb"===this.style?this.getBreadcrumbTemplate():this.getDefaultTemplate()}getDefaultTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-{{data.size}}">\n <div class="page-header-main">\n <div class="page-header-info">\n {{#data.showIcon}}\n {{#data.pageIcon}}\n <div class="page-icon">\n <i class="{{data.pageIcon}}"></i>\n </div>\n {{/data.pageIcon}}\n {{/data.showIcon}}\n \n <div class="page-title-group">\n <h1 class="page-title">{{data.pageTitle}}</h1>\n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n </div>\n\n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n </div>\n {{/data.hasPage}}\n '}getMinimalTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-minimal">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n </div>\n {{/data.hasPage}}\n '}getBreadcrumbTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-breadcrumb">\n {{#data.showBreadcrumbs}}\n <nav aria-label="breadcrumb">\n <ol class="breadcrumb mb-2">\n {{#data.breadcrumbs}}\n <li class="breadcrumb-item {{#active}}active{{/active}}">\n {{#href}}<a href="{{href}}">{{label}}</a>{{/href}}\n {{^href}}{{label}}{{/href}}\n </li>\n {{/data.breadcrumbs}}\n </ol>\n </nav>\n {{/data.showBreadcrumbs}}\n \n <div class="d-flex justify-content-between align-items-start">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n \n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n \n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted mt-2">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n {{/data.hasPage}}\n '}async onBeforeRender(){await super.onBeforeRender();const e=this.currentPage,t=!!e,s=e?.options?.headerActions||e?.headerActions||e?.constructor?.prototype?.headerActions||[];this.data={hasPage:t,pageTitle:e?.title||e?.name||"",pageIcon:e?.icon||e?.pageIcon||"",pageDescription:e?.description||"",showIcon:this.showIcon,showDescription:this.showDescription,showBreadcrumbs:this.showBreadcrumbs,breadcrumbs:e?.options?.breadcrumbs||e?.breadcrumbs||[],actions:s,hasActions:s.length>0,size:this.size}}setPage(e){this.currentPage=e,this.mounted&&this.render()}getPage(){return this.currentPage}async onActionDefault(e,t,s){return this.currentPage&&"function"==typeof this.currentPage.onHeaderAction?(await this.currentPage.onHeaderAction(e,t,s),!0):(this.emit("action",{action:e,event:t,element:s,page:this.currentPage}),!1)}}class DeniedPage extends s.Page{constructor(e={}){super({pageName:"Access Denied",route:"/denied",title:"Access Denied",pageIcon:"bi bi-shield-x",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-shield-x text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Access Denied</h2>\n <p class="text-muted">You don\'t have permission to access this page.</p>\n </div>\n\n {{#deniedPage}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body">\n <h6 class="card-subtitle mb-2 text-muted">Requested Page</h6>\n <h5 class="card-title">\n <i class="{{pageIcon}} me-2"></i>\n {{displayName}}\n </h5>\n {{#route}}\n <p class="card-text text-muted small">{{route}}</p>\n {{/route}}\n {{#description}}\n <p class="card-text">{{description}}</p>\n {{/description}}\n\n {{#requiredPermissions}}\n <div class="mt-3">\n <h6 class="mb-2">Required Permissions:</h6>\n {{#permissions}}\n <span class="badge bg-light text-dark me-1 mb-1">{{.}}</span>\n {{/permissions}}\n {{^permissions}}\n <span class="text-muted small">Authentication required</span>\n {{/permissions}}\n </div>\n {{/requiredPermissions}}\n </div>\n </div>\n {{/deniedPage}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n {{#showLogin}}\n <button type="button" class="btn btn-outline-primary" data-action="login">\n <i class="bi bi-box-arrow-in-right me-1"></i>\n Login\n </button>\n {{/showLogin}}\n </div>\n\n {{#currentUser}}\n <div class="text-center mt-4">\n <small class="text-muted">\n Logged in as <strong>{{username}}</strong>\n </small>\n </div>\n {{/currentUser}}\n </div>\n </div>\n </div>\n ',...e}),this.deniedPage=null,this.deniedPageOptions=null}async onParams(e={},t={}){await super.onParams(e,t),e.page?(this.deniedPage=e.page,this.deniedPageOptions=e.page.options||e.page.pageOptions||{}):t.page&&(this.deniedPageName=t.page)}setDeniedPage(e){return this.deniedPage=e,this.deniedPageOptions=e?.options||e?.pageOptions||{},this}async getViewData(){const e=this.getApp(),t=e?.activeUser||e?.getCurrentUser?.()||null;let s=null;if(this.deniedPage){const e=this.deniedPageOptions?.permissions||this.deniedPage.options?.permissions||this.deniedPage.pageOptions?.permissions;s={displayName:this.deniedPage.displayName||this.deniedPage.pageName||this.deniedPage.title||"Unknown Page",pageName:this.deniedPage.pageName,route:this.deniedPage.route,description:this.deniedPage.pageDescription||this.deniedPage.description,pageIcon:this.deniedPage.pageIcon||"bi bi-file-text",requiredPermissions:e?{permissions:Array.isArray(e)?e:[e]}:null}}else this.deniedPageName&&(s={displayName:this.deniedPageName,pageName:this.deniedPageName,pageIcon:"bi bi-file-text"});return{deniedPage:s,currentUser:t?{username:t.username||t.name||t.email||"Unknown User",name:t.name,email:t.email}:null,showLogin:!t}}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async handleActionLogin(e,t){e.preventDefault();const s=this.getApp();if(s)try{await s.showPage("login")}catch(i){try{await s.navigate("/login")}catch(a){this.emit("login-required",{returnUrl:this.deniedPage?.route||window.location.pathname}),setTimeout(()=>{s?.showInfo?.("Please contact your administrator for access.")},100)}}}async onEnter(){await super.onEnter();const e=this.deniedPage?.pageName||this.deniedPageName;e&&this.setMeta({title:`Access Denied - ${e}`}),console.warn("Access denied to page:",{page:this.deniedPage?.pageName||this.deniedPageName,route:this.deniedPage?.route,permissions:this.deniedPageOptions?.permissions,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPage(e,t){const s=new DeniedPage;return s.setDeniedPage(t),e.showPage(s)}}class NotFoundPage extends s.Page{constructor(e={}){super({pageName:"404",route:"/404",title:"404 - Page Not Found",pageIcon:"bi bi-search",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-search text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Page Not Found</h2>\n <p class="text-muted">The page you\'re looking for doesn\'t exist.</p>\n </div>\n\n {{#path}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body text-center">\n <h6 class="card-subtitle mb-2 text-muted">Requested Path</h6>\n <code class="text-primary">{{path}}</code>\n </div>\n </div>\n {{/path}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n </div>\n </div>\n </div>\n </div>\n ',...e}),this.path=null}async onParams(e={},t={}){await super.onParams(e,t),e.path&&(this.path=e.path),t.path&&(this.path=t.path)}setInfo(e){return this.path=e||null,this}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async onEnter(){await super.onEnter(),this.path&&this.setMeta({title:`404 - ${this.path} Not Found`}),console.warn("404 Not Found:",{path:this.path,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPath(e,t){const s=new NotFoundPage;return s.setInfo(t),s.render()}}class PortalApp extends i.WebApp{constructor(e={}){super(e),this.sidebarConfig=e.sidebar,this.topbarConfig=e.topbar||{},e.topnav&&!e.topbar&&(this.topbarConfig=e.topnav),this.showPageHeader=e.showPageHeader||!1,this.pageHeaderConfig=e.pageHeader||{},this.sidebar=null,this.topbar=null,this.topnav=null,this.pageHeader=null,this.tokenManager=new r.TokenManager,this.activeGroup=null,this.isMobile()?this.sidebarCollapsed=this.sidebarConfig.defaultCollapsed||!1:this.sidebarCollapsed=this.loadSidebarState()??(this.sidebarConfig.defaultCollapsed||!1),this.setupPageContainer(),this.toast=new s.ToastService,this.Dialog=i.Dialog,this.registerPage("denied",DeniedPage),this.registerPage("404",NotFoundPage)}async start(){await this.checkAuthStatus(),this.events.on("auth:unauthorized",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("auth:logout",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("browser:focus",()=>{this.activeUser&&this.tokenManager.checkAndRefreshTokens(this)}),this.events.on("portal:action",this.onPortalAction.bind(this)),this.activeUser&&await this.checkActiveGroup(),await this.setupRouter(),this.isStarted=!0,this.events.emit("app:ready",{app:this})}async checkAuthStatus(){const e=this.tokenManager.checkTokenStatus();if("logout"===e.action)return this.events.emit("auth:unauthorized",{app:this}),!1;if("refresh"===e.action&&!(await this.tokenManager.checkAndRefreshTokens(this)))return!1;const t=this.tokenManager.getTokenInstance();if(this.activeUser)return this.tokenManager.startAutoRefresh(this),!0;this.rest.setAuthToken(t.token);const i=new s.User({id:t.getUserId()}),a=await i.fetch();return a.success?(this.setActiveUser(i),this.tokenManager.startAutoRefresh(this),!0):(this.tokenManager.clearTokens(),this.events.emit("auth:unauthorized",{app:this,error:a.error}),!1)}async checkActiveGroup(){const e=new URLSearchParams(window.location.search).get("group"),t=e||this.loadActiveGroupId();if(t)try{const i=new s.Group({id:t}),a=await i.fetch();if(!a.success||!a.data.status)return this.clearActiveGroup(),void console.warn("Failed to load active group:",a.statusText);this.activeGroup=i,e&&this.saveActiveGroupId(t),this.activeUser&&(this.activeUser.member=new n.Member,await this.activeUser.member.fetchForGroup(i.id)),this.events.emit("group:loaded",{group:this.activeGroup})}catch(i){if(console.warn("Failed to load active group:",i),e&&!this.loadActiveGroupId())this.clearActiveGroupId();else if(e){const t=this.loadActiveGroupId();if(t&&t!==e)try{const e=new s.Group({id:t});await e.fetch(),this.activeGroup=e,this.events.emit("group:loaded",{group:this.activeGroup})}catch(a){console.warn("Fallback to stored group also failed:",a),this.clearActiveGroupId()}}}}async setActiveGroup(e){const t=this.activeGroup;this.activeGroup=e,e&&e.get("id")?this.saveActiveGroupId(e.get("id")):this.clearActiveGroupId(),this.activeUser&&(this.activeUser.member=new n.Member,await this.activeUser.member.fetchForGroup(e.id)),this.events.emit("group:changed",{group:e,previousGroup:t,app:this});const s=this.getCurrentPage();return s&&s.onGroupChange&&s.onGroupChange(e),this.router.updateUrl({group:e.id},{replace:!0}),this}getActiveGroup(){return this.activeGroup}async clearActiveGroup(){const e=this.activeGroup;return this.activeGroup=null,this.clearActiveGroupId(),this.events.emit("group:cleared",{previousGroup:e,app:this}),this}saveActiveGroupId(e){try{const t=this.getActiveGroupStorageKey();localStorage.setItem(t,e.toString())}catch(t){console.warn("Failed to save active group ID:",t)}}loadActiveGroupId(){try{const e=this.getActiveGroupStorageKey();return localStorage.getItem(e)}catch(e){return console.warn("Failed to load active group ID:",e),null}}clearActiveGroupId(){try{const e=this.getActiveGroupStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear active group ID:",e)}}getActiveGroupStorageKey(){return"active_group_id"}setPortalProfile(e){try{localStorage.setItem("portal_profile",e)}catch(t){console.warn("Failed to save portal profile:",t)}}needsGroupSelection(){return!this.activeGroup}setupPageContainer(){const e="string"==typeof this.container?document.querySelector(this.container):this.container;if(!e)throw new Error(`Portal container not found: ${this.container}`);const t=this.sidebarConfig&&Object.keys(this.sidebarConfig).length>0,s=this.topbarConfig&&Object.keys(this.topbarConfig).length>0,i=this.showPageHeader?'\n <div class="portal-content" id="portal-content">\n <div id="page-header"></div>\n <div id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n </div>\n ':'\n <div class="portal-content" id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n ';e.innerHTML=`\n <div class="portal-layout hide-sidebar">\n ${t?'<div id="portal-sidebar"></div>':""}\n <div class="portal-body">\n ${s?'<div id="portal-topnav"></div>':""}\n ${i}\n </div>\n </div>\n `,this.pageContainer="#page-container",e.classList.add("portal-container"),this.setupPortalComponents(),this.applySidebarState(e)}async setupPortalComponents(){await this.setupSidebar(),await this.setupTopbar(),await this.setupPageHeader(),this.setupPortalEvents()}async setupSidebar(){this.sidebarConfig&&0!==Object.keys(this.sidebarConfig).length&&(this.sidebar=new Sidebar({containerId:"portal-sidebar",...this.sidebarConfig}),await this.sidebar.render())}async setupTopbar(){this.topbarConfig&&0!==Object.keys(this.topbarConfig).length&&(this.topbar=new r.TopNav({containerId:"portal-topnav",brandText:this.topbarConfig.brand||this.brand||this.title,brandRoute:this.topbarConfig.brandRoute||"/",brandIcon:this.topbarConfig.brandIcon||this.brandIcon,navItems:this.topbarConfig.leftItems||[],rightItems:this.topbarConfig.rightItems||[],displayMode:this.topbarConfig.displayMode||"both",showSidebarToggle:this.topbarConfig.showSidebarToggle||!1,...this.topbarConfig}),await this.topbar.render(),this.topnav=this.topbar)}async setupPageHeader(){if(!this.showPageHeader)return;this.pageHeader=new PageHeader({containerId:"page-header",style:this.pageHeaderConfig.style||"default",showIcon:!1!==this.pageHeaderConfig.showIcon,showDescription:!1!==this.pageHeaderConfig.showDescription,showBreadcrumbs:this.pageHeaderConfig.showBreadcrumbs||!1,...this.pageHeaderConfig});const e=document.getElementById("page-header");e&&await this.pageHeader.render(!0,e)}setupPortalEvents(){if(document.addEventListener("click",e=>{e.target.closest('[data-action="toggle-sidebar"]')&&(e.preventDefault(),this.toggleSidebar())}),window.ResizeObserver){const e=new ResizeObserver(()=>{this.handleResponsive()});e.observe(document.body),this._resizeObserver=e}else this._resizeHandler=()=>this.handleResponsive(),window.addEventListener("resize",this._resizeHandler);this.handleResponsive()}toggleSidebar(){if(!this.sidebar)return;const e=document.querySelector(".portal-container"),t=this.isMobile();t?e.classList.toggle("hide-sidebar"):(e.classList.toggle("collapse-sidebar"),this.sidebarCollapsed=!this.sidebarCollapsed,this.saveSidebarState(this.sidebarCollapsed)),this.events.emit("sidebar:toggled",{collapsed:this.sidebarCollapsed,mobile:t})}handleResponsive(){const e=document.querySelector(".portal-container");if(!e)return;const t=this.isMobile();t?(e.classList.add("mobile-layout"),e.classList.contains("hide-sidebar")||e.classList.add("hide-sidebar")):e.classList.remove("mobile-layout","hide-sidebar"),this.events.emit("responsive:changed",{mobile:t})}getPortalContainer(){return document.querySelector(".portal-container")}isMobile(){return window.innerWidth<768}hasMobileLayout(){return this.getPortalContainer().classList.contains("mobile-layout")}async showPage(e,t={},s={},i={}){const a=await super.showPage(e,t,s,i);return this.hasMobileLayout()&&this.getPortalContainer().classList.add("hide-sidebar"),this.currentPage&&this.updateNavigation(this.currentPage),a}updateNavigation(e){this.sidebar&&this.sidebar.setActivePage&&this.sidebar.setActivePage(e.route),this.topbar&&this.topbar.setActivePage&&this.topbar.setActivePage(e.route),this.pageHeader&&this.pageHeader.setPage(e),this.events.emit("portal:page-changed",{page:e})}setActiveUser(e){this.activeUser=e,this.topbar&&this.topbar.setUser(e),this.events.emit("portal:user-changed",{user:e})}getActiveUser(){return this.activeUser}saveSidebarState(e){try{const t=this.getSidebarStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.warn("Failed to save sidebar state:",t)}}loadSidebarState(){try{const e=this.getSidebarStorageKey(),t=localStorage.getItem(e);return null!==t?JSON.parse(t):null}catch(e){return console.warn("Failed to load sidebar state:",e),null}}getSidebarStorageKey(){return`${this.title?this.title.replace(/\s+/g,"_").toLowerCase():"portal_app"}_sidebar_collapsed`}applySidebarState(e=null){e||(e=document.querySelector(".portal-container")),e&&(this.sidebarCollapsed?e.classList.add("collapse-sidebar"):e.classList.remove("collapse-sidebar"))}clearSidebarState(){try{const e=this.getSidebarStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear sidebar state:",e)}}async changePassword(){const e=await this.showForm({title:"Change Password",fields:[{name:"current_password",type:"password",label:"Current Password",required:!0,showToggle:!0,strengthMeter:!0,capsLockWarning:!0},{name:"new_password",type:"password",label:"New Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{autocomplete:"new-password"}},{name:"confirm_password",type:"password",label:"Confirm Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{}}],submitLabel:"Change Password"});e&&(e.new_password===e.confirm_password?200===(await this.activeUser.save(e)).status?this.toast.success("Password changed successfully"):this.toast.error("Failed to change password"):this.toast.error("Passwords do not match"))}onPortalAction(e){switch(e.action){case"logout":this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null);break;case"profile":this.showProfile();break;case"change-password":this.changePassword();break;default:console.warn(`Unknown portal action: ${e}`)}}async showProfile(){if(this.activeUser)try{const e=await i.Dialog.showModelForm({title:"Edit Profile",size:"lg",fileHandling:"base64",model:this.activeUser,fields:[{type:"header",text:"Profile Information",level:4,class:"text-primary mb-3"},{type:"group",columns:{xs:12,md:4},title:"Avatar",fields:[{type:"image",name:"avatar",size:"lg",imageSize:{width:200,height:200},placeholder:"Upload your avatar",help:"Square images work best"}]},{type:"group",columns:{xs:12,md:8},title:"Details",fields:[{type:"text",name:"display_name",label:"Display Name",required:!0,columns:12,placeholder:"Enter first name"},{type:"email",name:"email",label:"Email Address",required:!0,columns:8,placeholder:"your.email@example.com"},{type:"tel",name:"phone_number",label:"Phone Number",columns:4,placeholder:"(555) 123-4567"}]},{type:"group",columns:12,title:"Account Settings",class:"pt-3",fields:[{type:"select",name:"timezone",label:"Timezone",columns:6,options:[{value:"America/New_York",text:"Eastern Time"},{value:"America/Chicago",text:"Central Time"},{value:"America/Denver",text:"Mountain Time"},{value:"America/Los_Angeles",text:"Pacific Time"},{value:"UTC",text:"UTC"}]},{type:"select",name:"language",label:"Language",columns:6,options:[{value:"en",text:"English"},{value:"es",text:"Spanish"},{value:"fr",text:"French"},{value:"de",text:"German"}]},{type:"switch",name:"email_notifications",label:"Email Notifications",columns:4},{type:"switch",name:"two_factor_enabled",label:"Two-Factor Authentication",columns:4},{type:"switch",name:"profile_public",label:"Public Profile",columns:4}]}],submitText:"Save Profile",cancelText:"Cancel"});e&&e.success?this.showSuccess("Profile updated successfully!"):e&&e.success}catch(e){console.error("Error showing profile form:",e),this.showError("Failed to load profile form")}else this.showError("No user is currently logged in")}async destroy(){this.activeGroup=null,this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.topbar&&(await this.topbar.destroy(),this.topbar=null,this.topnav=null),this.sidebar&&(await this.sidebar.destroy(),this.sidebar=null),await super.destroy()}static create(e={}){return new PortalApp(e)}}const L=new class{constructor(){this.formatter=t.dataFormatter,this.compiledTemplates=/* @__PURE__ */new Map}render(e,s,i={}){return t.Mustache.render(e,s,i)}compile(e){const s=t.Mustache.parse(e);return this.compiledTemplates.set(e,s),s}renderCompiled(e,s,i={}){return t.Mustache.render(e,s,i)}clearCache(){this.compiledTemplates.clear(),t.Mustache.clearCache()}cache(e,t){return{key:e,template:t,compiled:this.compile(t)}}getCached(e){for(const[t,s]of this.compiledTemplates)if(t===e||s===e)return{key:e,template:t,compiled:s};return null}registerFormatter(e,t){return this.formatter.register(e,t),this}hasPipes(e){return/\{\{[{]?[^}|]+\|[^}]+\}[}]?\}/.test(e)}processData(e,t){const s={...e};for(const[i,a]of Object.entries(t))if(e&&"function"==typeof e.get)s[i]=e.get(`${i}|${a}`);else{const t=this.getValueFromPath(e,i);s[i]=this.formatter.pipe(t,a)}return s}getValueFromPath(e,t){if(!e||!t)return;if(e&&"function"==typeof e.get)return e.get(t);const s=t.split(".");let i=e;for(const a of s){if(null==i)return;i=!isNaN(a)&&Array.isArray(i)?i[parseInt(a)]:i[a]}return i}processTemplate(e,t){return{template:e,data:t}}};P.install({level:"warn"});const M="MOJO",A="web-mojo",T={FRAMEWORK_NAME:M,PACKAGE_NAME:A};exports.BUILD_TIME=e.BUILD_TIME,exports.VERSION=e.VERSION,exports.VERSION_INFO=e.VERSION_INFO,exports.VERSION_MAJOR=e.VERSION_MAJOR,exports.VERSION_MINOR=e.VERSION_MINOR,exports.VERSION_REVISION=e.VERSION_REVISION,exports.DataWrapper=t.DataWrapper,exports.EventDelegate=t.EventDelegate,exports.MOJOUtils=t.MOJOUtils,exports.Rest=t.rest,exports.View=t.View,exports.dataFormatter=t.dataFormatter,exports.ContextMenu=s.ContextMenu,exports.Group=s.Group,exports.GroupForms=s.GroupForms,exports.GroupList=s.GroupList,exports.Page=s.Page,exports.ToastService=s.ToastService,exports.User=s.User,exports.UserDataView=s.UserDataView,exports.UserDevice=s.UserDevice,exports.UserDeviceList=s.UserDeviceList,exports.UserDeviceLocation=s.UserDeviceLocation,exports.UserDeviceLocationList=s.UserDeviceLocationList,exports.UserForms=s.UserForms,exports.UserList=s.UserList,exports.Dialog=i.Dialog,exports.EventBus=i.EventBus,exports.Router=i.Router,exports.WebApp=i.WebApp,exports.Collection=a.Collection,exports.Model=a.Model,exports.BundleByOptions=n.BundleByOptions,exports.ChatInputView=n.ChatInputView,exports.ChatMessageView=n.ChatMessageView,exports.ChatView=n.ChatView,exports.CommonEventFields=n.CommonEventFields,exports.ComparatorOptions=n.ComparatorOptions,exports.EmailDomain=n.EmailDomain,exports.EmailDomainForms=n.EmailDomainForms,exports.EmailDomainList=n.EmailDomainList,exports.EmailTemplate=n.EmailTemplate,exports.EmailTemplateForms=n.EmailTemplateForms,exports.EmailTemplateList=n.EmailTemplateList,exports.File=n.File,exports.FileForms=n.FileForms,exports.FileList=n.FileList,exports.FileManager=n.FileManager,exports.FileManagerForms=n.FileManagerForms,exports.FileManagerList=n.FileManagerList,exports.FilePreviewView=n.FilePreviewView,exports.FileUpload=n.FileUpload,exports.GeoLocatedIP=n.GeoLocatedIP,exports.GeoLocatedIPList=n.GeoLocatedIPList,exports.Incident=n.Incident,exports.IncidentEvent=n.IncidentEvent,exports.IncidentEventForms=n.IncidentEventForms,exports.IncidentEventList=n.IncidentEventList,exports.IncidentForms=n.IncidentForms,exports.IncidentHistory=n.IncidentHistory,exports.IncidentHistoryList=n.IncidentHistoryList,exports.IncidentList=n.IncidentList,exports.IncidentRule=n.IncidentRule,exports.IncidentRuleList=n.IncidentRuleList,exports.IncidentRuleSet=n.IncidentRuleSet,exports.IncidentRuleSetList=n.IncidentRuleSetList,exports.IncidentStats=n.IncidentStats,exports.Job=n.Job,exports.JobEvent=n.JobEvent,exports.JobEventList=n.JobEventList,exports.JobForms=n.JobForms,exports.JobList=n.JobList,exports.JobLog=n.JobLog,exports.JobLogList=n.JobLogList,exports.JobRunner=n.JobRunner,exports.JobRunnerForms=n.JobRunnerForms,exports.JobRunnerList=n.JobRunnerList,exports.JobsEngineStats=n.JobsEngineStats,exports.Log=n.Log,exports.LogList=n.LogList,exports.Mailbox=n.Mailbox,exports.MailboxForms=n.MailboxForms,exports.MailboxList=n.MailboxList,exports.MatchByOptions=n.MatchByOptions,exports.Member=n.Member,exports.MemberForms=n.MemberForms,exports.MemberList=n.MemberList,exports.MetricsForms=n.MetricsForms,exports.MetricsPermission=n.MetricsPermission,exports.MetricsPermissionList=n.MetricsPermissionList,exports.ProgressView=n.ProgressView,exports.PushConfig=n.PushConfig,exports.PushConfigForms=n.PushConfigForms,exports.PushConfigList=n.PushConfigList,exports.PushDelivery=n.PushDelivery,exports.PushDeliveryList=n.PushDeliveryList,exports.PushDevice=n.PushDevice,exports.PushDeviceList=n.PushDeviceList,exports.PushTemplate=n.PushTemplate,exports.PushTemplateForms=n.PushTemplateForms,exports.PushTemplateList=n.PushTemplateList,exports.Rule=n.Rule,exports.RuleForms=n.RuleForms,exports.RuleList=n.RuleList,exports.RuleSet=n.RuleSet,exports.RuleSetForms=n.RuleSetForms,exports.RuleSetList=n.RuleSetList,exports.S3Bucket=n.S3Bucket,exports.S3BucketForms=n.S3BucketForms,exports.S3BucketList=n.S3BucketList,exports.SentMessage=n.SentMessage,exports.SentMessageForms=n.SentMessageForms,exports.SentMessageList=n.SentMessageList,exports.TabView=n.TabView,exports.TablePage=n.TablePage,exports.TableRow=n.TableRow,exports.TableView=n.TableView,exports.Ticket=n.Ticket,exports.TicketCategories=n.TicketCategories,exports.TicketForms=n.TicketForms,exports.TicketList=n.TicketList,exports.TicketNote=n.TicketNote,exports.TicketNoteList=n.TicketNoteList,exports.ValueTypeOptions=n.ValueTypeOptions,exports.SimpleSearchView=r.SimpleSearchView,exports.TokenManager=r.TokenManager,exports.TopNav=r.TopNav,exports.ListView=o.ListView,exports.ListViewItem=o.ListViewItem,exports.DataView=l.default,exports.FormView=c.FormView,exports.applyFileDropMixin=c.applyFileDropMixin,exports.WebSocketClient=d.WebSocketClient,exports.ConsoleSilencer=P,exports.FRAMEWORK_NAME=M,exports.MustacheFormatter=L,exports.PACKAGE_NAME=A,exports.PortalApp=PortalApp,exports.Sidebar=Sidebar,exports.default=T,exports.installConsoleSilencer=e=>P.install(e);
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/version-Ce-8QdEq.js"),t=require("./chunks/Rest-BpDyhFfG.js"),s=require("./chunks/ContextMenu-DWau8gXS.js"),i=require("./chunks/Dialog-DwgF3hri.js"),a=require("./chunks/Collection-B64LJ92k.js"),n=require("./chunks/ChatView-ZqTCdUZP.js"),r=require("./chunks/TokenManager-DVrApE_3.js"),o=require("./chunks/ListView-BpGEatee.js"),l=require("./chunks/DataView-DESqBxT-.js"),c=require("./chunks/FormView-DkBylHdd.js"),d=require("./chunks/WebSocketClient-E08hfP5f.js");var h="undefined"!=typeof document?document.currentScript:null;const u={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},p=Object.freeze({silent:0,error:1,warn:2,info:3,log:3,debug:4,trace:5,all:5}),g=(()=>{try{if(void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:h&&"SCRIPT"===h.tagName.toUpperCase()&&h.src||new URL("index.cjs.js",document.baseURI).href}&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:h&&"SCRIPT"===h.tagName.toUpperCase()&&h.src||new URL("index.cjs.js",document.baseURI).href,1)&&u)return!1}catch{}if("undefined"!=typeof globalThis&&void 0!==globalThis.__DEV__)try{return!!globalThis.__DEV__}catch{}return!("undefined"==typeof process||!process||"object"!=typeof process.env||"string"!=typeof process.env.NODE_ENV)&&"production"!==process.env.NODE_ENV})(),m="undefined"!=typeof window&&"undefined"!=typeof document,b="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:global,v=b.console||{},f={};let w=!1,x=null;function y(e){if("number"==typeof e){const t=p.silent,s=p.trace;return Math.min(Math.max(e,t),s)}if("string"==typeof e){const t=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(p,t))return p[t]}return null}function S(e,t){const s=f[e]||v[e]||(()=>{});return function(...e){if(x>=t)return s.apply(v,e)}}const P={install(e={}){if(w)return e&&void 0!==e.level&&this.setLevel(e.level,{persist:!!e.persist}),this;if(!b||!v)return w=!0,this;x=function(e){const t=y(e);if(null!==t)return t;const s=function(){if(!m||"undefined"==typeof location||!location.search)return null;try{const e=new URLSearchParams(location.search),t=["logLevel","loglevel","mojoLog"];for(const s of t){const t=e.get(s);if(null!=t){const e=y(t);if(null!==e)return e}}}catch{}return null}();if(null!==s)return s;const i=function(){if(!m||!("localStorage"in b))return null;try{const e=b.localStorage.getItem("MOJO_LOG_LEVEL");if(null!=e){const t=y(e);if(null!==t)return t}}catch{}return null}();return null!==i?i:y(g?"debug":"warn")}(e.level);const t=function(){const e={...v},t={error:p.error,warn:p.warn,info:p.info,log:p.info,dir:p.info,table:p.info,debug:p.debug,group:p.debug,groupCollapsed:p.debug,groupEnd:p.debug,time:p.debug,timeEnd:p.debug,timeLog:p.debug,trace:p.trace};for(const s of Object.keys(t))f[s]=v[s]||(()=>{}),e[s]=S(s,t[s]);return f.assert=v.assert||(()=>{}),e.assert=function(){const e=f.assert||v.assert||(()=>{});return function(t,...s){if(!t)return x>=p.error?e.apply(v,[t,...s]):void 0}}(),e}();return b.console=t,w=!0,b.MOJOConsoleSilencer=this,this},uninstall(){if(!w)return this;try{b.console=v}catch{}return w=!1,this},setLevel(e,{persist:t=!1}={}){const s=y(e);return null===s||(x=s,t&&function(e){if(m&&"localStorage"in b)try{const t="string"==typeof e?e:null===e?null:Object.entries(p).find(([,t])=>t===e)?.[0]??null;t?b.localStorage.setItem("MOJO_LOG_LEVEL",t):b.localStorage.removeItem("MOJO_LOG_LEVEL")}catch{}}(e)),this},getLevel:()=>x,getLevelName(){const e=Object.entries(p).find(([,e])=>e===x);return e?e[0]:null},criticalOnly({persist:e=!1}={}){return this.setLevel("warn",{persist:e})},errorsOnly({persist:e=!1}={}){return this.setLevel("error",{persist:e})},silent({persist:e=!1}={}){return this.setLevel("silent",{persist:e})},verbose({persist:e=!1}={}){return this.setLevel(g?"debug":"info",{persist:e})},allowAll({persist:e=!1}={}){return this.setLevel("trace",{persist:e})},withTemporaryLevel(e,t){const s=x,i=y(e);if(null===i||"function"!=typeof t)return t?.();x=i;try{return t()}finally{x=s}},LEVELS:p};class Sidebar extends t.View{constructor(e={}){super({tagName:"nav",className:"sidebar",id:"sidebar",...e}),this.menus=/* @__PURE__ */new Map,this.activeMenuName=null,this.currentRoute=null,this.showToggle=e.showToggle,this.isCollapsed=!1,this.sidebarTheme=e.theme||"sidebar-light",this.customView=null,this.options.groupHeader&&(this.groupHeader=this.options.groupHeader),this.groupSelectorMode=e.groupSelectorMode||"inline",this.groupSelectorDialog=null,this.sidebarTheme&&this.addClass(this.sidebarTheme),this.initializeMenus(e),this.setupRouteListeners(),!1!==e.autoCollapseMobile&&this.setupResponsiveBehavior()}groupHeader="\n <div class=\"sidebar-group-header py-3\" data-action=\"show-group-search\">\n <div class='text-center fs-5 px-1 collapsed-hidden'>{{group.name}}</div>\n <div class='text-center fs-6 collapsed-hidden'>kind: {{group.kind}}</div>\n </div>\n ";async onInit(){await super.onInit();const e=this.getApp(),t=e?.router;if(t){const e=t.getCurrentPath();e&&this.autoSwitchToMenuForRoute(e)}this.initializeTooltips(),this.searchView=new r.SimpleSearchView({noAppend:!0,showExitButton:!0,headerText:"Select Group",containerId:"sidebar-search-container",Collection:s.GroupList,itemTemplate:'\n <div class="p-3 border-bottom">\n <div class="fw-semibold text-dark">{{name}}</div>\n <small class="text-muted">#{{id}} {{kind}}</small>\n </div>\n '}),this.addChild(this.searchView),this.searchView.on("item:selected",e=>{this.getApp().setActiveGroup(e.model)}),this.searchView.on("exit",e=>{this.hideGroupSearch()})}showGroupSearch(){"dialog"===this.groupSelectorMode?this.showGroupSearchDialog():(this.setClass("sidebar"),this.showSearch=!0,this.render())}hideGroupSearch(){"dialog"===this.groupSelectorMode?this.groupSelectorDialog&&this.groupSelectorDialog.hide():(this.setClass("sidebar"),this.showSearch=!1,this.render())}onActionShowGroupSearch(){this.showGroupSearch()}async showGroupSearchDialog(){const e=new s.GroupList,t=new r.SimpleSearchView({Collection:s.GroupList,collection:e,itemTemplate:'\n <div class="p-3 border-bottom">\n <div class="fw-semibold text-dark">{{name}}</div>\n <small class="text-muted">#{{id}} {{kind}}</small>\n </div>\n ',searchFields:["name"],headerText:"Select Group",searchPlaceholder:"Search groups...",headerIcon:"bi-building",showExitButton:!1});this.groupSelectorDialog=new i.Dialog({title:"Select Group",body:t,size:"md",scrollable:!0,noBodyPadding:!0,buttons:[],closeButton:!0}),t.on("item:selected",e=>{this.getApp().setActiveGroup(e.model),this.groupSelectorDialog&&this.groupSelectorDialog.hide()}),this.groupSelectorDialog.on("hidden",()=>{this.groupSelectorDialog.destroy(),this.groupSelectorDialog=null}),await this.groupSelectorDialog.render(!0,document.body),this.groupSelectorDialog.show()}autoSwitchToMenuForRoute(e){for(const[t,s]of this.menus)if((!s.groupKind||this.getApp().activeGroup)&&this.menuContainsRoute(s,e))return this._setActiveMenu(t),this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),this.render(),this.emit("menu-auto-switched",{menuName:t,route:e,config:s,sidebar:this}),!0;return!1}clearAllActiveStates(){for(const[e,t]of this.menus)for(const s of t.items||[])if(s.active=!1,s.children)for(const e of s.children)e.active=!1}setActiveItemByRoute(e){const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e);for(const[i,a]of this.menus)if(!a.groupKind||this.getApp().activeGroup)for(const e of a.items||[]){if(e.route){const i=t(e.route);if(this.routesMatch(s,i))return e.active=!0,this.activeMenuItem=e,!0}if(e.children)for(const i of e.children)if(i.route){const a=t(i.route);if(this.routesMatch(s,a))return i.active=!0,e.active=!0,!0}}return!1}menuContainsRoute(e,t){const s=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},i=s(t);for(const a of e.items||[]){if(a.route){const e=s(a.route);if(this.routesMatch(i,e))return!0}if(a.children)for(const e of a.children)if(e.route){const t=s(e.route);if(this.routesMatch(i,t))return!0}}return!1}routesMatch(e,t){return this.getApp().router.doRoutesMatch(e,t)}getTemplate(){return this.customView?'<div class="sidebar-container" id="sidebar-custom-view-container"></div>':this.showSearch?this.getSearchTemplate():this.getMenuTemplate()}getSearchTemplate(){return'\n <div class="sidebar-container" id="sidebar-search-container">\n </div>\n '}getMenuTemplate(){return'\n <div class="sidebar-container">\n {{#data.currentMenu}}\n \x3c!-- Header --\x3e\n {{#header}}\n <div class="sidebar-header">\n {{{header}}}\n {{#showToggle}}\n <button class="sidebar-toggle" data-action="toggle-sidebar"\n aria-label="Toggle Sidebar">\n <i class="bi bi-chevron-left toggle-icon"></i>\n <i class="bi bi-chevron-right toggle-icon"></i>\n </button>\n {{/showToggle}}\n </div>\n {{/header}}\n\n \x3c!-- Navigation Items --\x3e\n <div class="sidebar-body">\n <ul class="nav nav-pills flex-column sidebar-nav" id="sidebar-nav-menu">\n {{#items}}\n {{>nav-item}}\n {{/items}}\n </ul>\n </div>\n\n \x3c!-- Footer --\x3e\n {{#footer}}\n <div class="sidebar-footer">\n {{{footer}}}\n </div>\n {{/footer}}\n {{/data.currentMenu}}\n\n {{^data.currentMenu}}\n <div class="sidebar-empty">\n <p class="text-danger text-center">No menu configured</p>\n </div>\n {{/data.currentMenu}}\n </div>\n '}getPartials(){return{"nav-item":'\n {{#isDivider}}\n {{>nav-divider}}\n {{/isDivider}}\n {{#isSpacer}}\n {{>nav-spacer}}\n {{/isSpacer}}\n {{#isLabel}}\n {{>nav-label}}\n {{/isLabel}}\n\n {{^isDivider}}\n {{^isSpacer}}\n {{^isLabel}}\n <li class="nav-item">\n {{#hasChildren}}\n \x3c!-- Item with submenu --\x3e\n <a class="nav-link {{#active}}active{{/active}} has-children collapsed"\n data-bs-toggle="collapse"\n href="#collapse-{{id}}"\n role="button"\n aria-expanded="{{#active}}true{{/active}}{{^active}}false{{/active}}"\n data-action="toggle-submenu">\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n <i class="bi bi-chevron-down nav-arrow ms-auto"></i>\n </a>\n <div class="collapse {{#active}}show{{/active}}" id="collapse-{{id}}" data-bs-parent="#sidebar-nav-menu">\n <ul class="nav flex-column nav-submenu">\n {{#children}}\n <li class="nav-item">\n <a class="nav-link {{#active}}active{{/active}}"\n {{#action}}data-action="{{action}}"{{/action}}\n {{#href}}href="{{href}}"{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n </li>\n {{/children}}\n </ul>\n </div>\n {{/hasChildren}}\n {{^hasChildren}}\n \x3c!-- Simple item --\x3e\n <a class="nav-link {{#active}}active{{/active}} {{#disabled}}disabled{{/disabled}}"\n {{#action}}{{^disabled}}data-action="{{action}}"{{/disabled}}{{/action}}\n {{#href}}{{^disabled}}href="{{href}}"{{/disabled}}{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n {{/hasChildren}}\n </li>\n {{/isLabel}}\n {{/isSpacer}}\n {{/isDivider}}\n ',"nav-divider":'\n <li class="nav-divider-item">\n <hr class="nav-divider-line">\n </li>\n ',"nav-spacer":'\n <li class="nav-spacer-item"></li>\n ',"nav-label":'\n <li class="nav-item {{className}}">\n <div class="nav-text px-3">{{text}}</div>\n </li>\n '}}getGroupHeader(){return this.groupHeader}addMenu(e,t){return t.groupKind&&!t.header&&(t.header=this.getGroupHeader()),this.menus.set(e,{name:e,groupKind:t.groupKind||null,header:t.header||null,footer:t.footer||null,items:t.items||[],data:t.data||{},className:t.className||"sidebar sidebar-dark"}),this.activeMenuName||this._setActiveMenu(e),this}_setActiveMenu(e){this.showSearch=!1,this.activeMenuName=e;const t=this.getCurrentMenuConfig();t.className?this.setClass(t.className):this.setClass("sidebar")}async setActiveMenu(e){if(!this.menus.has(e))return console.warn(`Menu '${e}' not found`),this;const t=this.menus.get(e);if(!t.groupKind||(this.lastGroupMenu=t,this.getApp().activeGroup))return this._setActiveMenu(e),await this.render(),this.emit("menu-changed",{menuName:e,config:t,sidebar:this}),this;this.showGroupSearch()}getGroupMenu(e){if(!e)return console.warn("No group provided"),null;let t=this.lastGroupMenu,s=null;if(e._.kind)for(const[i,a]of this.menus){if(this._groupKindMatches(a.groupKind,e._.kind)){t=a;break}"any"===a.groupKind&&(s=a)}return t||s}_groupKindMatches(e,t){return!(!e||!t)&&(Array.isArray(e)?e.includes(t):e===t)}showMenuForGroup(e){if(!e)return void console.warn("No group provided");let t=this.getGroupMenu(e);if(t)return this._setActiveMenu(t.name),this.render(),this.emit("menu-changed",{menuName:t.name,config:t,sidebar:this}),this;console.warn(`No menu found for group kind: ${e.kind}`)}getMenuConfig(e){return this.menus.get(e)||null}getCurrentMenuConfig(){return this.activeMenuName?this.menus.get(this.activeMenuName):null}updateMenu(e,t){const s=this.menus.get(e);return s?(Object.assign(s,t),this.activeMenuName===e&&this.render(),this):(console.warn(`Menu '${e}' not found`),this)}removeMenu(e){if(this.menus.delete(e),this.activeMenuName===e){const e=Array.from(this.menus.keys());this.activeMenuName=e.length>0?e[0]:null,this.render()}return this}async onBeforeRender(){const e=this.getCurrentMenuConfig();if(!e)return{currentMenu:null};let t={version:this.getApp().version||null,group:this.getApp().activeGroup||null,user:this.getApp.activeUser||null};this.data={currentMenu:{header:this.renderTemplateString(e.header||"",t),footer:this.renderTemplateString(e.footer||"",t),items:this.processNavItems(e.items,e.groupKind),data:e.data,showToggle:this.showToggle}}}async onAfterRender(){this.isCollapsedState()?setTimeout(()=>this.initializeTooltips(),50):this.destroyTooltips()}setCustomView(e){return this.customView&&this.removeChild(this.customView.id),this.customView=e,e&&(e.containerId="sidebar-custom-view-container",this.addChild(e)),this.render(),this}clearCustomView(){return this.customView&&(this.removeChild(this.customView.id),this.customView=null),this.render(),this}processNavItems(e,t){const s=this.getApp(),i=s?.activeUser,a=s?.activeGroup,n=e=>{if(t&&a&&a.id){const t=e.includes("?")?"&":"?";return`${e}${t}group=${a.id}`}return e};return e.map((e,t)=>{if(""===e||"object"==typeof e&&e.divider)return{isDivider:!0,id:`divider-${t}`};if("object"==typeof e&&e.spacer)return{isSpacer:!0,id:`spacer-${t}`};const s={...e};if(s.permissions&&(!i||!i.hasPermission(s.permissions)))return null;if(s.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(s.requiresGroupKind,e))return null}if("label"===s.kind)return s.isLabel=!0,s.id||(s.id=`nav-label-${t}`),s;if(s.id||(s.id=`nav-${t}`),s.route)s.href=n(s.route);else if(s.page){const e=s.page.startsWith("/")?s.page:`/${s.page}`;s.href=n(e),s.route=s.href}return s.children?(s.children=s.children.map(e=>{const t={...e};if(t.permissions&&i&&!i.hasPermission(t.permissions))return null;if(t.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(t.requiresGroupKind,e))return null}if(t.route)t.href=n(t.route);else if(t.page){const e=t.page.startsWith("/")?t.page:`/${t.page}`;t.href=n(e),t.route=t.href}return t}).filter(e=>null!==e),s.hasChildren=!!(s.children&&s.children.length>0)):s.hasChildren=!1,s}).filter(e=>null!==e)}isItemActive(e){if(!e.route||!this.currentRoute)return!1;const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e.route),i=t(this.currentRoute);return"/"===s&&"/"===i||"/"!==s&&"/"!==i&&(i.startsWith(s)||i===s)}async updateActiveItem(e){return this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),await this.render(),this}async handleActionToggleSubmenu(e,t){const s=t.querySelector(".nav-arrow");s&&s.classList.toggle("rotated")}async handleActionToggleSidebar(e,t){this.toggleSidebar()}onActionShowGroupMenu(e,t,s){return this.setActiveMenu("group_default"),!1}async onActionDefault(e,t,s){const i=this.getCurrentMenuConfig();if(i){for(const a of i.items)if(a.action==e&&a.handler)return a.handler(e,t,s),!0;return!1}}getMenuNames(){return Array.from(this.menus.keys())}hasMenu(e){return this.menus.has(e)}clearMenus(){return this.menus.clear(),this.activeMenuName=null,this.render(),this}setMenuData(e){const t=this.getCurrentMenuConfig();return t&&(t.data={...t.data,...e},this.render()),this}getMenuData(){const e=this.getCurrentMenuConfig();return e?e.data:{}}setupRouteListeners(){const e=this.getApp();e&&e.events&&(e.events.on(["page:showing"],e=>{this.onRouteChanged(e)}),e.events.on("group:changed",e=>{this.showMenuForGroup(e.group)}),e.events.on("portal:user-changed",e=>{this.render()}))}onRouteChanged(e){if(e.page&&e.page.route){const t=e.page.route;if(this.activeMenuItem&&this.routesMatch(t,this.activeMenuItem.route))return;this.autoSwitchToMenuForRoute(t)||(this.clearAllActiveStates(),this.setActiveItemByRoute(t),this.updateActiveItem(t))}}toggleSidebar(){const e=document.querySelector(".portal-container");if(!e)return;this.hideAllTooltips();const t=e.classList.contains("collapse-sidebar");return e.classList.contains("hide-sidebar")?(e.classList.remove("hide-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):t?(e.classList.remove("collapse-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):(e.classList.add("collapse-sidebar"),this.isCollapsed=!0,setTimeout(()=>this.initializeTooltips(),150)),this}setSidebarState(e){const t=document.querySelector(".portal-container");if(!t)return this;switch(t.classList.remove("collapse-sidebar","hide-sidebar"),e){case"collapsed":t.classList.add("collapse-sidebar"),this.isCollapsed=!0;break;case"hidden":t.classList.add("hide-sidebar"),this.isCollapsed=!1;break;default:this.isCollapsed=!1}return this.isCollapsed?(this.hideAllTooltips(),setTimeout(()=>this.initializeTooltips(),100)):this.destroyTooltips(),this}initializeTooltips(){return this.destroyTooltips(),this.isCollapsedState()?(this.element.querySelectorAll(".sidebar-nav .nav-link").forEach(e=>{const t=e.querySelector(".nav-text");if(t&&t.textContent.trim()){const s=t.textContent.trim();if(e.setAttribute("data-bs-toggle","tooltip"),e.setAttribute("data-bs-placement","right"),e.setAttribute("data-bs-title",s),e.setAttribute("data-bs-container","body"),window.bootstrap&&window.bootstrap.Tooltip){const t=e.getAttribute("data-tooltip-theme"),s=e.getAttribute("data-tooltip-size");let i="";t&&(i+=`tooltip-${t} `),s&&(i+=`tooltip-${s}`);const a={placement:"right",container:"body",trigger:"hover",delay:{show:500,hide:100},fallbackPlacements:["top","bottom","left"]},n=i.trim();n&&(a.customClass=n);const r=new window.bootstrap.Tooltip(e,a);e._tooltipInstance=r,e.addEventListener("click",()=>{r.hide()}),e.addEventListener("blur",()=>{r.hide()})}}}),this.addTooltipHideListeners(),this):this}destroyTooltips(){return this.removeTooltipHideListeners(),this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&(t.hide(),t.dispose()),delete e._tooltipInstance,e.removeAttribute("data-bs-toggle"),e.removeAttribute("data-bs-placement"),e.removeAttribute("data-bs-title"),e.removeAttribute("data-bs-container")}),this}getSidebarState(){const e=document.querySelector(".portal-container");return e?e.classList.contains("hide-sidebar")?"hidden":e.classList.contains("collapse-sidebar")?"collapsed":"normal":"normal"}isCollapsedState(){return"collapsed"===this.getSidebarState()}setToggleEnabled(e){return this.showToggle=e,this.render(),this}initializeMenus(e){if(e.menus)for(const t of e.menus)this.addMenu(t.name,t);else e.menu&&(e.menu.name=e.menu.name||"default",this.addMenu(e.menu.name,e.menu))}addTooltipHideListeners(){this._tooltipScrollHandler=()=>this.hideAllTooltips(),this.element.addEventListener("scroll",this._tooltipScrollHandler,{passive:!0}),this._tooltipRouteHandler=()=>this.hideAllTooltips(),this.getApp(),this._tooltipBlurHandler=()=>this.hideAllTooltips(),window.addEventListener("blur",this._tooltipBlurHandler),this._tooltipEscapeHandler=e=>{"Escape"===e.key&&this.hideAllTooltips()},document.addEventListener("keydown",this._tooltipEscapeHandler)}removeTooltipHideListeners(){this._tooltipScrollHandler&&(this.element.removeEventListener("scroll",this._tooltipScrollHandler),delete this._tooltipScrollHandler),this._tooltipBlurHandler&&(window.removeEventListener("blur",this._tooltipBlurHandler),delete this._tooltipBlurHandler),this._tooltipEscapeHandler&&(document.removeEventListener("keydown",this._tooltipEscapeHandler),delete this._tooltipEscapeHandler)}hideAllTooltips(){this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&t.hide()}),document.querySelectorAll(".tooltip.show").forEach(e=>{e.remove()})}async onBeforeDestroy(){this.destroyTooltips(),await super.onBeforeDestroy()}setupResponsiveBehavior(){const e=()=>{const e=window.innerWidth<=768,t=document.querySelector(".portal-container");t&&(e?t.classList.add("sidebar-mobile"):t.classList.remove("sidebar-mobile","sidebar-open"))};e(),window.addEventListener("resize",e)}static createDefault(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!0,autoCollapseMobile:!0,...e})}static createMinimal(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!1,autoCollapseMobile:!1,...e})}setSidebarTheme(e){return this.removeClass("sidebar-light sidebar-dark sidebar-clean"),this.sidebarTheme=e,this.addClass(e),this}show(){return this.setSidebarState("normal")}hide(){return this.setSidebarState("hidden")}collapse(){return this.setSidebarState("collapsed")}expand(){return this.setSidebarState("normal")}pulseToggle(){const e=this.element.querySelector(".sidebar-toggle");if(e){e.classList.add("pulse");const t=()=>{e.classList.remove("pulse"),e.removeEventListener("click",t)};e.addEventListener("click",t,{once:!0}),setTimeout(t,3e3)}return this}addSimpleMenuItem(e,t,s,i="bi-circle"){const a=this.menus.get(e);return a&&(a.items=a.items||[],a.items.push({text:t,route:s,icon:i}),this.activeMenuName===e&&this.render()),this}setSimpleMenu(e,t,s){const i={name:e,header:t,items:s};return this.addMenu(e,i),this.setActiveMenu(e),this}}class PageHeader extends t.View{constructor(e={}){super({tagName:"div",className:"page-header",...e}),this.style=e.style||"default",this.size=e.size||"md",this.showIcon=!1!==e.showIcon,this.showDescription=!1!==e.showDescription,this.showBreadcrumbs=e.showBreadcrumbs||!1,this.currentPage=null}async getTemplate(){return"minimal"===this.style?this.getMinimalTemplate():"breadcrumb"===this.style?this.getBreadcrumbTemplate():this.getDefaultTemplate()}getDefaultTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-{{data.size}}">\n <div class="page-header-main">\n <div class="page-header-info">\n {{#data.showIcon}}\n {{#data.pageIcon}}\n <div class="page-icon">\n <i class="{{data.pageIcon}}"></i>\n </div>\n {{/data.pageIcon}}\n {{/data.showIcon}}\n \n <div class="page-title-group">\n <h1 class="page-title">{{data.pageTitle}}</h1>\n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n </div>\n\n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n </div>\n {{/data.hasPage}}\n '}getMinimalTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-minimal">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n </div>\n {{/data.hasPage}}\n '}getBreadcrumbTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-breadcrumb">\n {{#data.showBreadcrumbs}}\n <nav aria-label="breadcrumb">\n <ol class="breadcrumb mb-2">\n {{#data.breadcrumbs}}\n <li class="breadcrumb-item {{#active}}active{{/active}}">\n {{#href}}<a href="{{href}}">{{label}}</a>{{/href}}\n {{^href}}{{label}}{{/href}}\n </li>\n {{/data.breadcrumbs}}\n </ol>\n </nav>\n {{/data.showBreadcrumbs}}\n \n <div class="d-flex justify-content-between align-items-start">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n \n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n \n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted mt-2">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n {{/data.hasPage}}\n '}async onBeforeRender(){await super.onBeforeRender();const e=this.currentPage,t=!!e,s=e?.options?.headerActions||e?.headerActions||e?.constructor?.prototype?.headerActions||[];this.data={hasPage:t,pageTitle:e?.title||e?.name||"",pageIcon:e?.icon||e?.pageIcon||"",pageDescription:e?.description||"",showIcon:this.showIcon,showDescription:this.showDescription,showBreadcrumbs:this.showBreadcrumbs,breadcrumbs:e?.options?.breadcrumbs||e?.breadcrumbs||[],actions:s,hasActions:s.length>0,size:this.size}}setPage(e){this.currentPage=e,this.mounted&&this.render()}getPage(){return this.currentPage}async onActionDefault(e,t,s){return this.currentPage&&"function"==typeof this.currentPage.onHeaderAction?(await this.currentPage.onHeaderAction(e,t,s),!0):(this.emit("action",{action:e,event:t,element:s,page:this.currentPage}),!1)}}class DeniedPage extends s.Page{constructor(e={}){super({pageName:"Access Denied",route:"/denied",title:"Access Denied",pageIcon:"bi bi-shield-x",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-shield-x text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Access Denied</h2>\n <p class="text-muted">You don\'t have permission to access this page.</p>\n </div>\n\n {{#deniedPage}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body">\n <h6 class="card-subtitle mb-2 text-muted">Requested Page</h6>\n <h5 class="card-title">\n <i class="{{pageIcon}} me-2"></i>\n {{displayName}}\n </h5>\n {{#route}}\n <p class="card-text text-muted small">{{route}}</p>\n {{/route}}\n {{#description}}\n <p class="card-text">{{description}}</p>\n {{/description}}\n\n {{#requiredPermissions}}\n <div class="mt-3">\n <h6 class="mb-2">Required Permissions:</h6>\n {{#permissions}}\n <span class="badge bg-light text-dark me-1 mb-1">{{.}}</span>\n {{/permissions}}\n {{^permissions}}\n <span class="text-muted small">Authentication required</span>\n {{/permissions}}\n </div>\n {{/requiredPermissions}}\n </div>\n </div>\n {{/deniedPage}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n {{#showLogin}}\n <button type="button" class="btn btn-outline-primary" data-action="login">\n <i class="bi bi-box-arrow-in-right me-1"></i>\n Login\n </button>\n {{/showLogin}}\n </div>\n\n {{#currentUser}}\n <div class="text-center mt-4">\n <small class="text-muted">\n Logged in as <strong>{{username}}</strong>\n </small>\n </div>\n {{/currentUser}}\n </div>\n </div>\n </div>\n ',...e}),this.deniedPage=null,this.deniedPageOptions=null}async onParams(e={},t={}){await super.onParams(e,t),e.page?(this.deniedPage=e.page,this.deniedPageOptions=e.page.options||e.page.pageOptions||{}):t.page&&(this.deniedPageName=t.page)}setDeniedPage(e){return this.deniedPage=e,this.deniedPageOptions=e?.options||e?.pageOptions||{},this}async getViewData(){const e=this.getApp(),t=e?.activeUser||e?.getCurrentUser?.()||null;let s=null;if(this.deniedPage){const e=this.deniedPageOptions?.permissions||this.deniedPage.options?.permissions||this.deniedPage.pageOptions?.permissions;s={displayName:this.deniedPage.displayName||this.deniedPage.pageName||this.deniedPage.title||"Unknown Page",pageName:this.deniedPage.pageName,route:this.deniedPage.route,description:this.deniedPage.pageDescription||this.deniedPage.description,pageIcon:this.deniedPage.pageIcon||"bi bi-file-text",requiredPermissions:e?{permissions:Array.isArray(e)?e:[e]}:null}}else this.deniedPageName&&(s={displayName:this.deniedPageName,pageName:this.deniedPageName,pageIcon:"bi bi-file-text"});return{deniedPage:s,currentUser:t?{username:t.username||t.name||t.email||"Unknown User",name:t.name,email:t.email}:null,showLogin:!t}}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async handleActionLogin(e,t){e.preventDefault();const s=this.getApp();if(s)try{await s.showPage("login")}catch(i){try{await s.navigate("/login")}catch(a){this.emit("login-required",{returnUrl:this.deniedPage?.route||window.location.pathname}),setTimeout(()=>{s?.showInfo?.("Please contact your administrator for access.")},100)}}}async onEnter(){await super.onEnter();const e=this.deniedPage?.pageName||this.deniedPageName;e&&this.setMeta({title:`Access Denied - ${e}`}),console.warn("Access denied to page:",{page:this.deniedPage?.pageName||this.deniedPageName,route:this.deniedPage?.route,permissions:this.deniedPageOptions?.permissions,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPage(e,t){const s=new DeniedPage;return s.setDeniedPage(t),e.showPage(s)}}class NotFoundPage extends s.Page{constructor(e={}){super({pageName:"404",route:"/404",title:"404 - Page Not Found",pageIcon:"bi bi-search",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-search text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Page Not Found</h2>\n <p class="text-muted">The page you\'re looking for doesn\'t exist.</p>\n </div>\n\n {{#path}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body text-center">\n <h6 class="card-subtitle mb-2 text-muted">Requested Path</h6>\n <code class="text-primary">{{path}}</code>\n </div>\n </div>\n {{/path}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n </div>\n </div>\n </div>\n </div>\n ',...e}),this.path=null}async onParams(e={},t={}){await super.onParams(e,t),e.path&&(this.path=e.path),t.path&&(this.path=t.path)}setInfo(e){return this.path=e||null,this}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async onEnter(){await super.onEnter(),this.path&&this.setMeta({title:`404 - ${this.path} Not Found`}),console.warn("404 Not Found:",{path:this.path,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPath(e,t){const s=new NotFoundPage;return s.setInfo(t),s.render()}}class PortalApp extends i.WebApp{constructor(e={}){super(e),this.sidebarConfig=e.sidebar,this.topbarConfig=e.topbar||{},e.topnav&&!e.topbar&&(this.topbarConfig=e.topnav),this.showPageHeader=e.showPageHeader||!1,this.pageHeaderConfig=e.pageHeader||{},this.sidebar=null,this.topbar=null,this.topnav=null,this.pageHeader=null,this.tokenManager=new r.TokenManager,this.activeGroup=null,this.isMobile()?this.sidebarCollapsed=this.sidebarConfig.defaultCollapsed||!1:this.sidebarCollapsed=this.loadSidebarState()??(this.sidebarConfig.defaultCollapsed||!1),this.setupPageContainer(),this.toast=new s.ToastService,this.Dialog=i.Dialog,this.registerPage("denied",DeniedPage),this.registerPage("404",NotFoundPage)}async start(){await this.checkAuthStatus(),this.events.on("auth:unauthorized",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("auth:logout",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("browser:focus",()=>{this.activeUser&&this.tokenManager.checkAndRefreshTokens(this)}),this.events.on("portal:action",this.onPortalAction.bind(this)),this.activeUser&&await this.checkActiveGroup(),await this.setupRouter(),this.isStarted=!0,this.events.emit("app:ready",{app:this})}async checkAuthStatus(){const e=this.tokenManager.checkTokenStatus();if("logout"===e.action)return this.events.emit("auth:unauthorized",{app:this}),!1;if("refresh"===e.action&&!(await this.tokenManager.checkAndRefreshTokens(this)))return!1;const t=this.tokenManager.getTokenInstance();if(this.activeUser)return this.tokenManager.startAutoRefresh(this),!0;this.rest.setAuthToken(t.token);const i=new s.User({id:t.getUserId()}),a=await i.fetch();return a.success?(this.setActiveUser(i),this.tokenManager.startAutoRefresh(this),!0):(this.tokenManager.clearTokens(),this.events.emit("auth:unauthorized",{app:this,error:a.error}),!1)}async checkActiveGroup(){const e=new URLSearchParams(window.location.search).get("group"),t=e||this.loadActiveGroupId();if(t)try{const i=new s.Group({id:t}),a=await i.fetch();if(!a.success||!a.data.status)return this.clearActiveGroup(),void console.warn("Failed to load active group:",a.statusText);this.activeGroup=i,e&&this.saveActiveGroupId(t),this.activeUser&&(this.activeUser.member=new n.Member,await this.activeUser.member.fetchForGroup(i.id)),this.events.emit("group:loaded",{group:this.activeGroup})}catch(i){if(console.warn("Failed to load active group:",i),e&&!this.loadActiveGroupId())this.clearActiveGroupId();else if(e){const t=this.loadActiveGroupId();if(t&&t!==e)try{const e=new s.Group({id:t});await e.fetch(),this.activeGroup=e,this.events.emit("group:loaded",{group:this.activeGroup})}catch(a){console.warn("Fallback to stored group also failed:",a),this.clearActiveGroupId()}}}}async setActiveGroup(e){const t=this.activeGroup;this.activeGroup=e,e&&e.get("id")?this.saveActiveGroupId(e.get("id")):this.clearActiveGroupId(),this.activeUser&&(this.activeUser.member=new n.Member,await this.activeUser.member.fetchForGroup(e.id)),this.events.emit("group:changed",{group:e,previousGroup:t,app:this});const s=this.getCurrentPage();return s&&s.onGroupChange&&s.onGroupChange(e),this.router.updateUrl({group:e.id},{replace:!0}),this}getActiveGroup(){return this.activeGroup}async clearActiveGroup(){const e=this.activeGroup;return this.activeGroup=null,this.clearActiveGroupId(),this.events.emit("group:cleared",{previousGroup:e,app:this}),this}saveActiveGroupId(e){try{const t=this.getActiveGroupStorageKey();localStorage.setItem(t,e.toString())}catch(t){console.warn("Failed to save active group ID:",t)}}loadActiveGroupId(){try{const e=this.getActiveGroupStorageKey();return localStorage.getItem(e)}catch(e){return console.warn("Failed to load active group ID:",e),null}}clearActiveGroupId(){try{const e=this.getActiveGroupStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear active group ID:",e)}}getActiveGroupStorageKey(){return"active_group_id"}setPortalProfile(e){try{localStorage.setItem("portal_profile",e)}catch(t){console.warn("Failed to save portal profile:",t)}}needsGroupSelection(){return!this.activeGroup}setupPageContainer(){const e="string"==typeof this.container?document.querySelector(this.container):this.container;if(!e)throw new Error(`Portal container not found: ${this.container}`);const t=this.sidebarConfig&&Object.keys(this.sidebarConfig).length>0,s=this.topbarConfig&&Object.keys(this.topbarConfig).length>0,i=this.showPageHeader?'\n <div class="portal-content" id="portal-content">\n <div id="page-header"></div>\n <div id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n </div>\n ':'\n <div class="portal-content" id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n ';e.innerHTML=`\n <div class="portal-layout hide-sidebar">\n ${t?'<div id="portal-sidebar"></div>':""}\n <div class="portal-body">\n ${s?'<div id="portal-topnav"></div>':""}\n ${i}\n </div>\n </div>\n `,this.pageContainer="#page-container",e.classList.add("portal-container"),this.setupPortalComponents(),this.applySidebarState(e)}async setupPortalComponents(){await this.setupSidebar(),await this.setupTopbar(),await this.setupPageHeader(),this.setupPortalEvents()}async setupSidebar(){this.sidebarConfig&&0!==Object.keys(this.sidebarConfig).length&&(this.sidebar=new Sidebar({containerId:"portal-sidebar",...this.sidebarConfig}),await this.sidebar.render())}async setupTopbar(){this.topbarConfig&&0!==Object.keys(this.topbarConfig).length&&(this.topbar=new r.TopNav({containerId:"portal-topnav",brandText:this.topbarConfig.brand||this.brand||this.title,brandRoute:this.topbarConfig.brandRoute||"/",brandIcon:this.topbarConfig.brandIcon||this.brandIcon,navItems:this.topbarConfig.leftItems||[],rightItems:this.topbarConfig.rightItems||[],displayMode:this.topbarConfig.displayMode||"both",showSidebarToggle:this.topbarConfig.showSidebarToggle||!1,...this.topbarConfig}),await this.topbar.render(),this.topnav=this.topbar)}async setupPageHeader(){if(!this.showPageHeader)return;this.pageHeader=new PageHeader({containerId:"page-header",style:this.pageHeaderConfig.style||"default",showIcon:!1!==this.pageHeaderConfig.showIcon,showDescription:!1!==this.pageHeaderConfig.showDescription,showBreadcrumbs:this.pageHeaderConfig.showBreadcrumbs||!1,...this.pageHeaderConfig});const e=document.getElementById("page-header");e&&await this.pageHeader.render(!0,e)}setupPortalEvents(){if(document.addEventListener("click",e=>{e.target.closest('[data-action="toggle-sidebar"]')&&(e.preventDefault(),this.toggleSidebar())}),window.ResizeObserver){const e=new ResizeObserver(()=>{this.handleResponsive()});e.observe(document.body),this._resizeObserver=e}else this._resizeHandler=()=>this.handleResponsive(),window.addEventListener("resize",this._resizeHandler);this.handleResponsive()}toggleSidebar(){if(!this.sidebar)return;const e=document.querySelector(".portal-container"),t=this.isMobile();t?e.classList.toggle("hide-sidebar"):(e.classList.toggle("collapse-sidebar"),this.sidebarCollapsed=!this.sidebarCollapsed,this.saveSidebarState(this.sidebarCollapsed)),this.events.emit("sidebar:toggled",{collapsed:this.sidebarCollapsed,mobile:t})}handleResponsive(){const e=document.querySelector(".portal-container");if(!e)return;const t=this.isMobile();t?(e.classList.add("mobile-layout"),e.classList.contains("hide-sidebar")||e.classList.add("hide-sidebar")):e.classList.remove("mobile-layout","hide-sidebar"),this.events.emit("responsive:changed",{mobile:t})}getPortalContainer(){return document.querySelector(".portal-container")}isMobile(){return window.innerWidth<768}hasMobileLayout(){return this.getPortalContainer().classList.contains("mobile-layout")}async showPage(e,t={},s={},i={}){const a=await super.showPage(e,t,s,i);return this.hasMobileLayout()&&this.getPortalContainer().classList.add("hide-sidebar"),this.currentPage&&this.updateNavigation(this.currentPage),a}updateNavigation(e){this.sidebar&&this.sidebar.setActivePage&&this.sidebar.setActivePage(e.route),this.topbar&&this.topbar.setActivePage&&this.topbar.setActivePage(e.route),this.pageHeader&&this.pageHeader.setPage(e),this.events.emit("portal:page-changed",{page:e})}setActiveUser(e){this.activeUser=e,this.topbar&&this.topbar.setUser(e),this.events.emit("portal:user-changed",{user:e})}getActiveUser(){return this.activeUser}saveSidebarState(e){try{const t=this.getSidebarStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.warn("Failed to save sidebar state:",t)}}loadSidebarState(){try{const e=this.getSidebarStorageKey(),t=localStorage.getItem(e);return null!==t?JSON.parse(t):null}catch(e){return console.warn("Failed to load sidebar state:",e),null}}getSidebarStorageKey(){return`${this.title?this.title.replace(/\s+/g,"_").toLowerCase():"portal_app"}_sidebar_collapsed`}applySidebarState(e=null){e||(e=document.querySelector(".portal-container")),e&&(this.sidebarCollapsed?e.classList.add("collapse-sidebar"):e.classList.remove("collapse-sidebar"))}clearSidebarState(){try{const e=this.getSidebarStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear sidebar state:",e)}}async changePassword(){const e=await this.showForm({title:"Change Password",fields:[{name:"current_password",type:"password",label:"Current Password",required:!0,showToggle:!0,strengthMeter:!0,capsLockWarning:!0},{name:"new_password",type:"password",label:"New Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{autocomplete:"new-password"}},{name:"confirm_password",type:"password",label:"Confirm Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{}}],submitLabel:"Change Password"});e&&(e.new_password===e.confirm_password?200===(await this.activeUser.save(e)).status?this.toast.success("Password changed successfully"):this.toast.error("Failed to change password"):this.toast.error("Passwords do not match"))}onPortalAction(e){switch(e.action){case"logout":this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null);break;case"profile":this.showProfile();break;case"change-password":this.changePassword();break;default:console.warn(`Unknown portal action: ${e}`)}}async showProfile(){if(this.activeUser)try{const e=await i.Dialog.showModelForm({title:"Edit Profile",size:"lg",fileHandling:"base64",model:this.activeUser,fields:[{type:"header",text:"Profile Information",level:4,class:"text-primary mb-3"},{type:"group",columns:{xs:12,md:4},title:"Avatar",fields:[{type:"image",name:"avatar",size:"lg",imageSize:{width:200,height:200},placeholder:"Upload your avatar",help:"Square images work best"}]},{type:"group",columns:{xs:12,md:8},title:"Details",fields:[{type:"text",name:"display_name",label:"Display Name",required:!0,columns:12,placeholder:"Enter first name"},{type:"email",name:"email",label:"Email Address",required:!0,columns:8,placeholder:"your.email@example.com"},{type:"tel",name:"phone_number",label:"Phone Number",columns:4,placeholder:"(555) 123-4567"}]},{type:"group",columns:12,title:"Account Settings",class:"pt-3",fields:[{type:"select",name:"timezone",label:"Timezone",columns:6,options:[{value:"America/New_York",text:"Eastern Time"},{value:"America/Chicago",text:"Central Time"},{value:"America/Denver",text:"Mountain Time"},{value:"America/Los_Angeles",text:"Pacific Time"},{value:"UTC",text:"UTC"}]},{type:"select",name:"language",label:"Language",columns:6,options:[{value:"en",text:"English"},{value:"es",text:"Spanish"},{value:"fr",text:"French"},{value:"de",text:"German"}]},{type:"switch",name:"email_notifications",label:"Email Notifications",columns:4},{type:"switch",name:"two_factor_enabled",label:"Two-Factor Authentication",columns:4},{type:"switch",name:"profile_public",label:"Public Profile",columns:4}]}],submitText:"Save Profile",cancelText:"Cancel"});e&&e.success?this.showSuccess("Profile updated successfully!"):e&&e.success}catch(e){console.error("Error showing profile form:",e),this.showError("Failed to load profile form")}else this.showError("No user is currently logged in")}async destroy(){this.activeGroup=null,this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.topbar&&(await this.topbar.destroy(),this.topbar=null,this.topnav=null),this.sidebar&&(await this.sidebar.destroy(),this.sidebar=null),await super.destroy()}static create(e={}){return new PortalApp(e)}}const L=new class{constructor(){this.formatter=t.dataFormatter,this.compiledTemplates=/* @__PURE__ */new Map}render(e,s,i={}){return t.Mustache.render(e,s,i)}compile(e){const s=t.Mustache.parse(e);return this.compiledTemplates.set(e,s),s}renderCompiled(e,s,i={}){return t.Mustache.render(e,s,i)}clearCache(){this.compiledTemplates.clear(),t.Mustache.clearCache()}cache(e,t){return{key:e,template:t,compiled:this.compile(t)}}getCached(e){for(const[t,s]of this.compiledTemplates)if(t===e||s===e)return{key:e,template:t,compiled:s};return null}registerFormatter(e,t){return this.formatter.register(e,t),this}hasPipes(e){return/\{\{[{]?[^}|]+\|[^}]+\}[}]?\}/.test(e)}processData(e,t){const s={...e};for(const[i,a]of Object.entries(t))if(e&&"function"==typeof e.get)s[i]=e.get(`${i}|${a}`);else{const t=this.getValueFromPath(e,i);s[i]=this.formatter.pipe(t,a)}return s}getValueFromPath(e,t){if(!e||!t)return;if(e&&"function"==typeof e.get)return e.get(t);const s=t.split(".");let i=e;for(const a of s){if(null==i)return;i=!isNaN(a)&&Array.isArray(i)?i[parseInt(a)]:i[a]}return i}processTemplate(e,t){return{template:e,data:t}}};P.install({level:"warn"});const M="MOJO",A="web-mojo",T={FRAMEWORK_NAME:M,PACKAGE_NAME:A};exports.BUILD_TIME=e.BUILD_TIME,exports.VERSION=e.VERSION,exports.VERSION_INFO=e.VERSION_INFO,exports.VERSION_MAJOR=e.VERSION_MAJOR,exports.VERSION_MINOR=e.VERSION_MINOR,exports.VERSION_REVISION=e.VERSION_REVISION,exports.DataWrapper=t.DataWrapper,exports.EventDelegate=t.EventDelegate,exports.MOJOUtils=t.MOJOUtils,exports.Rest=t.rest,exports.View=t.View,exports.dataFormatter=t.dataFormatter,exports.ContextMenu=s.ContextMenu,exports.Group=s.Group,exports.GroupForms=s.GroupForms,exports.GroupList=s.GroupList,exports.Page=s.Page,exports.ToastService=s.ToastService,exports.User=s.User,exports.UserDataView=s.UserDataView,exports.UserDevice=s.UserDevice,exports.UserDeviceList=s.UserDeviceList,exports.UserDeviceLocation=s.UserDeviceLocation,exports.UserDeviceLocationList=s.UserDeviceLocationList,exports.UserForms=s.UserForms,exports.UserList=s.UserList,exports.Dialog=i.Dialog,exports.EventBus=i.EventBus,exports.Router=i.Router,exports.WebApp=i.WebApp,exports.Collection=a.Collection,exports.Model=a.Model,exports.BundleByOptions=n.BundleByOptions,exports.ChatInputView=n.ChatInputView,exports.ChatMessageView=n.ChatMessageView,exports.ChatView=n.ChatView,exports.CommonEventFields=n.CommonEventFields,exports.ComparatorOptions=n.ComparatorOptions,exports.EmailDomain=n.EmailDomain,exports.EmailDomainForms=n.EmailDomainForms,exports.EmailDomainList=n.EmailDomainList,exports.EmailTemplate=n.EmailTemplate,exports.EmailTemplateForms=n.EmailTemplateForms,exports.EmailTemplateList=n.EmailTemplateList,exports.File=n.File,exports.FileForms=n.FileForms,exports.FileList=n.FileList,exports.FileManager=n.FileManager,exports.FileManagerForms=n.FileManagerForms,exports.FileManagerList=n.FileManagerList,exports.FilePreviewView=n.FilePreviewView,exports.FileUpload=n.FileUpload,exports.GeoLocatedIP=n.GeoLocatedIP,exports.GeoLocatedIPList=n.GeoLocatedIPList,exports.Incident=n.Incident,exports.IncidentEvent=n.IncidentEvent,exports.IncidentEventForms=n.IncidentEventForms,exports.IncidentEventList=n.IncidentEventList,exports.IncidentForms=n.IncidentForms,exports.IncidentHistory=n.IncidentHistory,exports.IncidentHistoryList=n.IncidentHistoryList,exports.IncidentList=n.IncidentList,exports.IncidentRule=n.IncidentRule,exports.IncidentRuleList=n.IncidentRuleList,exports.IncidentRuleSet=n.IncidentRuleSet,exports.IncidentRuleSetList=n.IncidentRuleSetList,exports.IncidentStats=n.IncidentStats,exports.Job=n.Job,exports.JobEvent=n.JobEvent,exports.JobEventList=n.JobEventList,exports.JobForms=n.JobForms,exports.JobList=n.JobList,exports.JobLog=n.JobLog,exports.JobLogList=n.JobLogList,exports.JobRunner=n.JobRunner,exports.JobRunnerForms=n.JobRunnerForms,exports.JobRunnerList=n.JobRunnerList,exports.JobsEngineStats=n.JobsEngineStats,exports.Log=n.Log,exports.LogList=n.LogList,exports.Mailbox=n.Mailbox,exports.MailboxForms=n.MailboxForms,exports.MailboxList=n.MailboxList,exports.MatchByOptions=n.MatchByOptions,exports.Member=n.Member,exports.MemberForms=n.MemberForms,exports.MemberList=n.MemberList,exports.MetricsForms=n.MetricsForms,exports.MetricsPermission=n.MetricsPermission,exports.MetricsPermissionList=n.MetricsPermissionList,exports.ProgressView=n.ProgressView,exports.PushConfig=n.PushConfig,exports.PushConfigForms=n.PushConfigForms,exports.PushConfigList=n.PushConfigList,exports.PushDelivery=n.PushDelivery,exports.PushDeliveryList=n.PushDeliveryList,exports.PushDevice=n.PushDevice,exports.PushDeviceList=n.PushDeviceList,exports.PushTemplate=n.PushTemplate,exports.PushTemplateForms=n.PushTemplateForms,exports.PushTemplateList=n.PushTemplateList,exports.Rule=n.Rule,exports.RuleForms=n.RuleForms,exports.RuleList=n.RuleList,exports.RuleSet=n.RuleSet,exports.RuleSetForms=n.RuleSetForms,exports.RuleSetList=n.RuleSetList,exports.S3Bucket=n.S3Bucket,exports.S3BucketForms=n.S3BucketForms,exports.S3BucketList=n.S3BucketList,exports.SentMessage=n.SentMessage,exports.SentMessageForms=n.SentMessageForms,exports.SentMessageList=n.SentMessageList,exports.TabView=n.TabView,exports.TablePage=n.TablePage,exports.TableRow=n.TableRow,exports.TableView=n.TableView,exports.Ticket=n.Ticket,exports.TicketCategories=n.TicketCategories,exports.TicketForms=n.TicketForms,exports.TicketList=n.TicketList,exports.TicketNote=n.TicketNote,exports.TicketNoteList=n.TicketNoteList,exports.ValueTypeOptions=n.ValueTypeOptions,exports.SimpleSearchView=r.SimpleSearchView,exports.TokenManager=r.TokenManager,exports.TopNav=r.TopNav,exports.ListView=o.ListView,exports.ListViewItem=o.ListViewItem,exports.DataView=l.default,exports.FormView=c.FormView,exports.applyFileDropMixin=c.applyFileDropMixin,exports.WebSocketClient=d.WebSocketClient,exports.ConsoleSilencer=P,exports.FRAMEWORK_NAME=M,exports.MustacheFormatter=L,exports.PACKAGE_NAME=A,exports.PortalApp=PortalApp,exports.Sidebar=Sidebar,exports.default=T,exports.installConsoleSilencer=e=>P.install(e);
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.es.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { B, a, V, b, c, d } from "./chunks/version-
|
|
1
|
+
import { B, a, V, b, c, d } from "./chunks/version-Be_W-mxT.js";
|
|
2
2
|
import { V as View, d as dataFormatter, a as Mustache } from "./chunks/Rest-DpbPbmra.js";
|
|
3
3
|
import { D, b as b2, M, r } from "./chunks/Rest-DpbPbmra.js";
|
|
4
|
-
import { G as GroupList, P as Page, T as ToastService, U as User, a as Group } from "./chunks/ContextMenu-
|
|
5
|
-
import { C, b as b3, e, f, g, h, i, d as d2, c as c2 } from "./chunks/ContextMenu-
|
|
6
|
-
import { D as Dialog, W as WebApp } from "./chunks/Dialog-
|
|
7
|
-
import { E, R } from "./chunks/Dialog-
|
|
8
|
-
import { C as C2, M as M2 } from "./chunks/Collection-
|
|
9
|
-
import { M as Member } from "./chunks/ChatView-
|
|
10
|
-
import { Z, e as e2, d as d3, C as C3, a1, $, E as E2, j, i as i2, q, s, r as r2, w, y, x, t, v, u, F, f as f2, au, av, B as B2, I, A, z, G, N, O, D as D2, K, L, H, J, Y, a2, a7, a8, a4, a3, a5, a6, aa, ac, ab, a9, ad, ae, k, m, l, _, ag, af, aj, ah, ai, P, ao, as, ap, aq, ar, ak, al, am, at, an, V as V2, X, W, R as R2, U, Q, S, h as h2, g as g2, n, p, o, c as c3, b as b4, a as a10, T, aw, aB, aA, ax, ay, az, a0 } from "./chunks/ChatView-
|
|
11
|
-
import { S as SimpleSearchView, T as TokenManager, a as TopNav } from "./chunks/TokenManager-
|
|
12
|
-
import { a as a11, L as L2 } from "./chunks/ListView-
|
|
4
|
+
import { G as GroupList, P as Page, T as ToastService, U as User, a as Group } from "./chunks/ContextMenu-Dfdrnd0f.js";
|
|
5
|
+
import { C, b as b3, e, f, g, h, i, d as d2, c as c2 } from "./chunks/ContextMenu-Dfdrnd0f.js";
|
|
6
|
+
import { D as Dialog, W as WebApp } from "./chunks/Dialog-DRf1-ZSd.js";
|
|
7
|
+
import { E, R } from "./chunks/Dialog-DRf1-ZSd.js";
|
|
8
|
+
import { C as C2, M as M2 } from "./chunks/Collection-CsAk0UhA.js";
|
|
9
|
+
import { M as Member } from "./chunks/ChatView-oka6O6VS.js";
|
|
10
|
+
import { Z, e as e2, d as d3, C as C3, a1, $, E as E2, j, i as i2, q, s, r as r2, w, y, x, t, v, u, F, f as f2, au, av, B as B2, I, A, z, G, N, O, D as D2, K, L, H, J, Y, a2, a7, a8, a4, a3, a5, a6, aa, ac, ab, a9, ad, ae, k, m, l, _, ag, af, aj, ah, ai, P, ao, as, ap, aq, ar, ak, al, am, at, an, V as V2, X, W, R as R2, U, Q, S, h as h2, g as g2, n, p, o, c as c3, b as b4, a as a10, T, aw, aB, aA, ax, ay, az, a0 } from "./chunks/ChatView-oka6O6VS.js";
|
|
11
|
+
import { S as SimpleSearchView, T as TokenManager, a as TopNav } from "./chunks/TokenManager-CWi9-XBF.js";
|
|
12
|
+
import { a as a11, L as L2 } from "./chunks/ListView-BGJG4GYH.js";
|
|
13
13
|
import { default as default2 } from "./chunks/DataView-QXyfcg2M.js";
|
|
14
|
-
import { F as F2, a as a12 } from "./chunks/FormView-
|
|
14
|
+
import { F as F2, a as a12 } from "./chunks/FormView-DJBMpeMY.js";
|
|
15
15
|
import { W as W2 } from "./chunks/WebSocketClient-DghNkEyO.js";
|
|
16
16
|
const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false };
|
|
17
17
|
const LEVELS = Object.freeze({
|