"use strict";(self.webpackChunk_aidoop_aidoop_r=self.webpackChunk_aidoop_aidoop_r||[]).push([[3017],{63017:(e,t,i)=>{i.r(t);i(62392),i(49005),i(68677),i(43615),i(12313),i(77198);var a=i(16682),r=i(94430),n=i(28120),o=i(68784),d=i(27805),s=i(53421),l=i(77675),p=i(15633),c=i(36179),m=i(64026),u=i(51266);const h=document.querySelector('meta[name="application-name"]')?.content;class g extends((0,n.$)(l.h)((0,s.NC)(s.z2)(l.B4))){static get properties(){return{config:Object,menus:Array,mode:String}}static get styles(){return[p.Pn,r.iv`
        :host {
          display: flex;
          overflow-x: hidden;
          flex-direction: column;

          width: 100%;
        }
      `]}constructor(){super(),this.mode=(0,c.s2)()?"CARD":"GRID"}get context(){return{title:s.z2.t("text.addon-menu management"),actions:[{title:s.z2.t("button.reload"),action:()=>{this.onReload()},...p.jO.refresh},{title:s.z2.t("button.delete"),action:()=>{this.onDelete()},...p.jO.delete},{title:s.z2.t("button.save"),action:()=>{this.onCommit()},...p.jO.save}],exportable:{accept:["json"],name:"lite-menu-list",data:()=>this.grist.data}}}render(){return r.dy`
      <ox-grist .mode=${this.mode} .config=${this.config} .fetchHandler=${this.fetchHandler}>
        <div slot="headroom">
          <div id="filters">
            <ox-filters-form autofocus></ox-filters-form>
          </div>

          <div id="sorters">
            Sort
            <mwc-icon
              @click=${e=>{const t=e.currentTarget;this.renderRoot.querySelector("#sorter-control").open({right:0,top:t.offsetTop+t.offsetHeight})}}
              >expand_more</mwc-icon
            >
            <ox-popup id="sorter-control">
              <ox-sorters-control> </ox-sorters-control>
            </ox-popup>
          </div>

          <div id="modes">
            <mwc-icon @click=${()=>this.mode="GRID"} ?active=${"GRID"==this.mode}>grid_on</mwc-icon>
            <mwc-icon @click=${()=>this.mode="CARD"} ?active=${"CARD"==this.mode}>apps</mwc-icon>
          </div>
        </div>
      </ox-grist>
    `}stateChanged(e){this.menus=e.liteMenu?.menus}get grist(){return this.shadowRoot.querySelector("ox-grist")}async onCommit(){var e=this.grist,t=e.dirtyRecords.filter((e=>"M"==e.__dirty__)),i=e.dirtyRecords.filter((e=>"+"==e.__dirty__));await Promise.all(t.map((async e=>{var t=e.__origin__.id,i={name:e.name,description:e.description,appName:e.appName,parent:e.parent,rank:e.rank,active:e.active,type:e.type,value:e.value,icon:e.icon};return"group"==e.type&&(i={...i,parent:""}),await d.Lp.mutate({mutation:a.ZP`
            mutation ($id: String!, $patch: LiteMenuPatch!) {
              updateLiteMenu(id: $id, patch: $patch) {
                id
                name
              }
            }
          `,variables:{id:t,patch:i}})}))),await Promise.all(i.map((async e=>{var t={name:e.name,description:e.description,appName:e.appName,parent:e.parent,rank:e.rank,active:e.active,type:e.type,value:e.value,icon:e.icon};return await d.Lp.mutate({mutation:a.ZP`
            mutation ($liteMenu: NewLiteMenu!) {
              createLiteMenu(liteMenu: $liteMenu) {
                id
                name
              }
            }
          `,variables:{liteMenu:t}})}))),e.fetch(),(0,m.RX)()}onReload(){this.grist.fetch()}async onDelete(){var e=this.grist,t=e.selected;await Promise.all(t.map((async e=>{var t=e.id;return await d.Lp.mutate({mutation:a.ZP`
            mutation ($id: String!) {
              deleteLiteMenu(id: $id)
            }
          `,variables:{id:t}})}))),e.fetch(),(0,m.RX)()}async pageInitialized(){this.config={list:{thumbnail:"value",fields:["name","description"],details:["type","parent","rank","updatedAt"]},columns:[{type:"gutter",gutterName:"dirty"},{type:"gutter",gutterName:"sequence"},{type:"gutter",gutterName:"row-selector",multiple:!0},{type:"string",name:"id",hidden:!0},{type:"string",name:"name",header:s.z2.t("field.name"),record:{editable:!0},filter:"search",sortable:!0,width:120},{type:"string",name:"description",header:s.z2.t("field.description"),record:{align:"left",editable:!0},filter:"search",width:200},{type:"select",name:"appName",header:s.z2.t("field.app-name"),label:!0,record:{align:"left",editable:!0,options:["",h]},filter:{options:["",h],multiple:!1,operator:"eq"},width:200},{type:"select",name:"parent",label:!0,header:s.z2.t("field.parent-menu"),record:{editable:!0,options:()=>["",...this.menus.filter((e=>"group"!==e.type)).map((e=>e.name))]},sortable:!0,width:120},{type:"number",name:"rank",label:!0,header:s.z2.t("field.rank"),record:{align:"right",editable:!0},sortable:!0,width:60},{type:"select",name:"type",label:!0,header:s.z2.t("field.type"),record:{editable:!0,options:["","group","page","board","interactive-board"]},filter:{options:["","group","page","board","interactive-board"],multiple:!1,operator:"eq"},width:80},{type:"string",name:"value",header:s.z2.t("field.value"),record:{editable:!0,editor:function(e,t,i,a,r){var n="board"!==i.type&&"interactive-board"!==i.type?"string":"board";return(0,o.y$)(n)(e,t,i,a,r)},renderer:function(e,t,i,a,r){var n="board"!==i.type&&"interactive-board"!==i.type?"string":"board";return(0,o.Bp)(n)(e,t,i,a,r)}},width:140},{type:"string",name:"icon",header:s.z2.t("field.icon"),record:{editable:!0},sortable:!1,width:120},{type:"boolean",name:"active",label:!0,header:s.z2.t("field.active"),record:{editable:!0},filter:!0,sortable:!0,width:60},{type:"datetime",name:"updatedAt",header:s.z2.t("field.updated_at"),width:180},{type:"datetime",name:"createdAt",header:s.z2.t("field.created_at"),width:180}],rows:{selectable:{multiple:!0},handlers:{click:"select-row-toggle"}},sorters:[{name:"parent",desc:!1},{name:"rank",desc:!1}],pagination:{pages:[20,30,50,100,200]}},this.page=1,this.limit=50,await this.updateComplete,this.grist.fetch()}async pageUpdated(e,t){this.active&&(await this.updateComplete,this.grist.fetch())}async fetchHandler({filters:e=[],page:t,limit:i,sortings:r=[]}){const n=(await d.Lp.query({query:a.ZP`
          query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
            responses: liteMenus(filters: $filters, pagination: $pagination, sortings: $sortings) {
              items {
                id
                name
                description
                appName
                parent
                rank
                type
                value
                board {
                  id
                  name
                  description
                  thumbnail
                }
                icon
                active
                createdAt
                updatedAt
                creator {
                  id
                  name
                }
                updater {
                  id
                  name
                }
              }
              total
            }
          }
        `,variables:{filters:[...e,{name:"appName",operator:"in",value:["",h]}],pagination:{page:t,limit:i},sortings:r}})).data.responses;return{records:n.items,total:n.total}}liteMenuCreationCallback(e){u.warn("not implemented yet.")}}window.customElements.define("addon-menu-setting",g)}}]);