/*! For license information please see 2657.js.LICENSE.txt */
"use strict";(self.webpackChunk_aidoop_aidoop_r=self.webpackChunk_aidoop_aidoop_r||[]).push([[2657],{62657:(e,t,r)=>{r.r(t),r.d(t,{ThemeListPage:()=>v});var n=r(50493),o=r(68784),i=r(15633),a=r(77675),s=r(94430),u=r(44648),l=r(56765),c=r(28120),d=r(16682),p=r(69292),f=r(27805),h=r(53421),m=r(37077),g=r(64312),y=r(36179);let v=class extends((0,c.$)(a.h)((0,h.NC)(h.z2)((0,p.f)(a.B4)))){constructor(){super(...arguments),this.mode=(0,y.s2)()?"CARD":"GRID"}get context(){var e;return{title:h.z2.t("title.theme list"),search:{handler:e=>{this.grist.searchText=e},value:(null===(e=this.grist)||void 0===e?void 0:e.searchText)||""},filter:{handler:()=>{this.grist.toggleHeadroom()}},help:"board-service/theme",actions:[Object.assign({title:h.z2.t("button.save"),action:this._updateTheme.bind(this)},i.jO.save),Object.assign({title:h.z2.t("button.delete"),action:this._deleteTheme.bind(this)},i.jO.delete)]}}render(){const e=this.mode||((0,y.s2)()?"CARD":"GRID");return s.dy`
      <ox-grist .mode=${e} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
        <div slot="headroom">
          <div id="filters">
            <ox-filters-form autofocus without-search></ox-filters-form>
          </div>

          <div id="sorters">
            Sort
            <mwc-icon
              @click=${e=>{const t=e.currentTarget;this.sortersControl.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"==e}>grid_on</mwc-icon>
            <mwc-icon @click=${()=>this.mode="LIST"} ?active=${"LIST"==e}>format_list_bulleted</mwc-icon>
            <mwc-icon @click=${()=>this.mode="CARD"} ?active=${"CARD"==e}>apps</mwc-icon>
          </div>
        </div>
      </ox-grist>
    `}async pageInitialized(e){this.gristConfig={list:{fields:["name","description"],details:["type","updatedAt"]},columns:[{type:"gutter",gutterName:"sequence"},{type:"gutter",gutterName:"row-selector",multiple:!0},{type:"string",name:"name",header:h.z2.t("field.name"),record:{editable:!0},filter:"search",sortable:!0,width:150},{type:"string",name:"description",header:h.z2.t("field.description"),record:{editable:!0},filter:"search",width:200},{type:"checkbox",name:"active",header:h.z2.t("field.active"),record:{editable:!0},width:60},{type:"select",name:"type",header:h.z2.t("field.type"),record:{options:["","color-map","color-ranges","color","text"],editable:!0},width:120},{type:"object",name:"value",header:h.z2.t("field.value"),record:{editor:function(e,t,r,n,i){return(0,o.y$)(r.type||"text")(e,t,r,n,i)},renderer:function(e,t,r,n,i){return(0,o.Bp)(r.type||"text")(e,t,r,n,i)},editable:!0,options:{objectified:!0}},sortable:!0,width:180},{type:"resource-object",name:"updater",header:h.z2.t("field.updater"),record:{editable:!1},sortable:!0,width:120},{type:"datetime",name:"updatedAt",header:h.z2.t("field.updated_at"),record:{editable:!1},sortable:!0,width:180}],rows:{selectable:{multiple:!0}},sorters:[{name:"name"}]}}async pageUpdated(e,t){this.active}async fetchHandler({page:e=1,limit:t=100,sortings:r=[],filters:n=[]}){const o=await f.Lp.query({query:d.ZP`
        query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
          responses: themes(filters: $filters, pagination: $pagination, sortings: $sortings) {
            items {
              id
              name
              description
              active
              type
              value
              updater {
                id
                name
              }
              updatedAt
            }
            total
          }
        }
      `,variables:{filters:n,pagination:{page:e,limit:t},sortings:r}});return{total:o.data.responses.total||0,records:o.data.responses.items||[]}}async _deleteTheme(){if(confirm(h.z2.t("text.sure_to_x",{x:h.z2.t("text.delete")}))){const e=this.grist.selected.map((e=>e.id));if(e&&e.length>0){const[t,{error:r}]=(0,u.D)("\nmutation ($ids: [String!]!) {\n  deleteThemes(ids: $ids)\n}");(0,u.D)({variables:{ids:e}}),r||(this.grist.fetch(),(0,m.h4)({message:h.z2.t("text.info_x_successfully",{x:h.z2.t("text.delete")})}))}}}async _updateTheme(){let e=this.grist.dirtyRecords;if(e&&e.length){e=e.map((e=>{let t=e.id?{id:e.id}:{};const r=e.__dirtyfields__;for(let e in r)t[e]=r[e].after;return t.cuFlag=e.__dirty__,t}));const[t,{error:r}]=(0,u.D)("\nmutation ($patches: [ThemePatch!]!) {\n  updateMultipleTheme(patches: $patches) {\n    name\n  }\n}");t({variables:{patches:e}}),r||this.grist.fetch()}}};v.styles=[i.Ix,i.Pn,s.iv`
      :host {
        display: flex;

        width: 100%;

        --grid-record-emphasized-background-color: red;
        --grid-record-emphasized-color: yellow;
      }
    `],(0,n.gn)([(0,l.Cb)({type:Object}),(0,n.w6)("design:type",Object)],v.prototype,"gristConfig",void 0),(0,n.gn)([(0,l.Cb)({type:String}),(0,n.w6)("design:type",String)],v.prototype,"mode",void 0),(0,n.gn)([(0,l.IO)("ox-grist"),(0,n.w6)("design:type",o.Nw)],v.prototype,"grist",void 0),(0,n.gn)([(0,l.IO)("#sorter-control"),(0,n.w6)("design:type",g.WP)],v.prototype,"sortersControl",void 0),v=(0,n.gn)([(0,l.Mo)("theme-list-page")],v)},4619:(e,t)=>{var r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),u=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||h}function v(){}function b(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var _=b.prototype=new v;_.constructor=b,m(_,y.prototype),_.isPureReactComponent=!0;var w=Array.isArray,k=Object.prototype.hasOwnProperty,x={current:null},S={key:!0,ref:!0,__self:!0,__source:!0};function $(e,t,n){var o,i={},a=null,s=null;if(null!=t)for(o in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(a=""+t.key),t)k.call(t,o)&&!S.hasOwnProperty(o)&&(i[o]=t[o]);var u=arguments.length-2;if(1===u)i.children=n;else if(1<u){for(var l=Array(u),c=0;c<u;c++)l[c]=arguments[c+2];i.children=l}if(e&&e.defaultProps)for(o in u=e.defaultProps)void 0===i[o]&&(i[o]=u[o]);return{$$typeof:r,type:e,key:a,ref:s,props:i,_owner:x.current}}function C(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}var j=/\/+/g;function O(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function z(e,t,o,i,a){var s=typeof e;"undefined"!==s&&"boolean"!==s||(e=null);var u=!1;if(null===e)u=!0;else switch(s){case"string":case"number":u=!0;break;case"object":switch(e.$$typeof){case r:case n:u=!0}}if(u)return a=a(u=e),e=""===i?"."+O(u,0):i,w(a)?(o="",null!=e&&(o=e.replace(j,"$&/")+"/"),z(a,t,o,"",(function(e){return e}))):null!=a&&(C(a)&&(a=function(e,t){return{$$typeof:r,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(a,o+(!a.key||u&&u.key===a.key?"":(""+a.key).replace(j,"$&/")+"/")+e)),t.push(a)),1;if(u=0,i=""===i?".":i+":",w(e))for(var l=0;l<e.length;l++){var c=i+O(s=e[l],l);u+=z(s,t,o,c,a)}else if(c=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=f&&e[f]||e["@@iterator"])?e:null}(e),"function"==typeof c)for(e=c.call(e),l=0;!(s=e.next()).done;)u+=z(s=s.value,t,o,c=i+O(s,l++),a);else if("object"===s)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return u}function R(e,t,r){if(null==e)return e;var n=[],o=0;return z(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function T(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var D={current:null},M={transition:null};t.createContext=function(e){return(e={$$typeof:u,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},t.useCallback=function(e,t){return D.current.useCallback(e,t)},t.useContext=function(e){return D.current.useContext(e)},t.useEffect=function(e,t){return D.current.useEffect(e,t)},t.useRef=function(e){return D.current.useRef(e)},t.useState=function(e){return D.current.useState(e)}},44529:(e,t,r)=>{e.exports=r(4619)},44648:(e,t,r)=>{r.d(t,{D:()=>m});var n,o=r(50493),i=r(44529),a=r(19611),s=r(16361),u=r(33438);!function(e){e[e.Query=0]="Query",e[e.Mutation=1]="Mutation",e[e.Subscription=2]="Subscription"}(n||(n={}));var l=new Map;function c(e){var t;switch(e){case n.Query:t="Query";break;case n.Mutation:t="Mutation";break;case n.Subscription:t="Subscription"}return t}function d(e,t){var r=function(e){var t,r,o=l.get(e);if(o)return o;(0,u.kG)(!!e&&!!e.kind,59,e);for(var i=[],a=[],s=[],c=[],d=0,p=e.definitions;d<p.length;d++){var f=p[d];if("FragmentDefinition"!==f.kind){if("OperationDefinition"===f.kind)switch(f.operation){case"query":a.push(f);break;case"mutation":s.push(f);break;case"subscription":c.push(f)}}else i.push(f)}(0,u.kG)(!i.length||a.length||s.length||c.length,60),(0,u.kG)(a.length+s.length+c.length<=1,61,e,a.length,c.length,s.length),r=a.length?n.Query:n.Mutation,a.length||s.length||(r=n.Subscription);var h=a.length?a:s.length?s:c;(0,u.kG)(1===h.length,62,e,h.length);var m=h[0];t=m.variableDefinitions||[];var g={name:m.name&&"Name"===m.name.kind?m.name.value:"data",type:r,variables:t};return l.set(e,g),g}(e),o=c(t),i=c(r.type);(0,u.kG)(r.type===t,63,o,o,i)}var p=r(93869),f=r(42860).aS?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function h(){(0,u.kG)(!0,45);var e=i.createContext[f];return e||(Object.defineProperty(i.createContext,f,{value:e=i.createContext({}),enumerable:!1,writable:!1,configurable:!0}),e.displayName="ApolloContext"),e}function m(e,t){var r=function(e){var t=i.useContext(h()),r=e||t.client;return(0,u.kG)(!!r,49),r}(null==t?void 0:t.client);d(e,n.Mutation);var l=i.useState({called:!1,loading:!1,client:r}),c=l[0],f=l[1],m=i.useRef({result:c,mutationId:0,isMounted:!0,client:r,mutation:e,options:t});Object.assign(m.current,{client:r,options:t,mutation:e});var g=i.useCallback((function(e){void 0===e&&(e={});var t=m.current,r=t.options,n=t.mutation,i=(0,o.pi)((0,o.pi)({},r),{mutation:n}),u=e.client||m.current.client;m.current.result.loading||i.ignoreResults||!m.current.isMounted||f(m.current.result={loading:!0,error:void 0,data:void 0,called:!0,client:u});var l=++m.current.mutationId,c=(0,a.J)(i,e);return u.mutate(c).then((function(t){var r,n,o=t.data,i=t.errors,a=i&&i.length>0?new p.cA({graphQLErrors:i}):void 0,d=e.onError||(null===(r=m.current.options)||void 0===r?void 0:r.onError);if(a&&d&&d(a,c),l===m.current.mutationId&&!c.ignoreResults){var h={called:!0,loading:!1,data:o,error:a,client:u};m.current.isMounted&&!(0,s.D)(m.current.result,h)&&f(m.current.result=h)}var g=e.onCompleted||(null===(n=m.current.options)||void 0===n?void 0:n.onCompleted);return a||null==g||g(t.data,c),t})).catch((function(t){var r;if(l===m.current.mutationId&&m.current.isMounted){var n={loading:!1,error:t,data:void 0,called:!0,client:u};(0,s.D)(m.current.result,n)||f(m.current.result=n)}var o=e.onError||(null===(r=m.current.options)||void 0===r?void 0:r.onError);if(o)return o(t,c),{data:void 0,errors:t};throw t}))}),[]),y=i.useCallback((function(){m.current.isMounted&&f({called:!1,loading:!1,client:r})}),[]);return i.useEffect((function(){return m.current.isMounted=!0,function(){m.current.isMounted=!1}}),[]),[g,(0,o.pi)({reset:y},c)]}}}]);