UNPKG

@platformos/pos-cli

Version:
8 lines (7 loc) 27 kB
import{S as He,i as ze,s as Je,d as _,E as me,o as H,p as O,b as ee,c as o,I as ve,J as _e,z as u,e as v,f as b,h as A,L as pe,g as fe,j as p,k as M,M as he,t as ce,W as xe,C as Ue,x as Ke,a9 as Ct,O as Ye,Y as qe,X as et,R as Ce,H as ye,V as $t,K as ue,l as Qe,a5 as yt,N as we,a as De,n as Ze,F as Ie,D as Pt,ae as rt,G as wt,v as It,m as Dt,u as Nt,q as jt,r as Lt,P as it,ag as Ot,Q as Oe}from"../chunks/n7YEDvJi.js";import{g as St}from"../chunks/D0QH3NT1.js";import{e as Se}from"../chunks/DMhVG_ro.js";import"../chunks/IHki7fMi.js";import{g as Ut}from"../chunks/DafkoIUS.js";import{s as re}from"../chunks/Bp_ajb_u.js";import{q as kt}from"../chunks/iVSWiVfi.js";import{p as At}from"../chunks/DjNrOAme.js";import{u as Ae}from"../chunks/CNoDK8-a.js";import{c as Mt,T as Rt}from"../chunks/B9_cNKsK.js";import{I as Ne}from"../chunks/DHO4ENnJ.js";import{p as Vt}from"../chunks/6Lnq5zID.js";import{t as Bt}from"../chunks/x4PJc0Qf.js";import{N as Ft}from"../chunks/CYamOUSl.js";function qt(l){let e,a,t,s,r,n,f,i,h,m;return n=new Ne({props:{icon:"x",size:"22"}}),{c(){e=p("form"),a=p("input"),t=M(),s=p("button"),r=p("i"),he(n.$$.fragment),f=ce(` Delete user`),this.h()},l(c){e=v(c,"FORM",{});var E=b(e);a=v(E,"INPUT",{type:!0,name:!0}),t=A(E),s=v(E,"BUTTON",{class:!0});var T=b(s);r=v(T,"I",{class:!0});var C=b(r);pe(n.$$.fragment,C),C.forEach(_),f=fe(T,` Delete user`),T.forEach(_),E.forEach(_),this.h()},h(){u(a,"type","hidden"),u(a,"name","id"),a.value=l[0],u(r,"class","svelte-ooaugn"),u(s,"class","danger")},m(c,E){ee(c,e,E),o(e,a),o(e,t),o(e,s),o(s,r),ve(n,r,null),o(s,f),l[3](e),i=!0,h||(m=_e(e,"submit",l[2]),h=!0)},p(c,[E]){(!i||E&1)&&(a.value=c[0])},i(c){i||(O(n.$$.fragment,c),i=!0)},o(c){H(n.$$.fragment,c),i=!1},d(c){c&&_(e),me(n),l[3](null),h=!1,m()}}}function Ht(l,e,a){let{id:t}=e,s,r=xe();const n=async i=>{if(i.preventDefault(),confirm("Are you sure you want to delete this user?")){r("close");const m=new FormData(s).get("id");(await Ae.delete(m)).errors?re.notification.create("error",`Record ${m} could not be deleted`):(re.notification.create("success",`Record ${m} deleted`),r("success"))}};function f(i){Ue[i?"unshift":"push"](()=>{s=i,a(1,s)})}return l.$$set=i=>{"id"in i&&a(0,t=i.id)},[t,s,n,f]}class zt extends He{constructor(e){super(),ze(this,e,Ht,qt,Je,{id:0})}}function Jt(l){let e,a,t,s,r,n,f;return s=new zt({props:{id:l[0].id}}),s.$on("success",l[3]),s.$on("close",l[4]),{c(){e=p("menu"),a=p("ul"),t=p("li"),he(s.$$.fragment),this.h()},l(i){e=v(i,"MENU",{class:!0});var h=b(e);a=v(h,"UL",{});var m=b(a);t=v(m,"LI",{class:!0});var c=b(t);pe(s.$$.fragment,c),c.forEach(_),m.forEach(_),h.forEach(_),this.h()},h(){u(t,"class","svelte-8i1sxu"),u(e,"class","content-context svelte-8i1sxu")},m(i,h){ee(i,e,h),o(e,a),o(a,t),ve(s,t,null),r=!0,n||(f=[_e(window,"keyup",l[2]),Ct(Mt.call(null,e,l[5]))],n=!0)},p(i,[h]){const m={};h&1&&(m.id=i[0].id),s.$set(m)},i(i){r||(O(s.$$.fragment,i),r=!0)},o(i){H(s.$$.fragment,i),r=!1},d(i){i&&_(e),me(s),n=!1,Ke(f)}}}function Kt(l,e,a){let{record:t}=e;const s=xe(),r=h=>{h.key==="Escape"&&s("close")},n=()=>s("reload"),f=()=>s("close"),i=()=>s("close");return l.$$set=h=>{"record"in h&&a(0,t=h.record)},[t,s,r,n,f,i]}class Gt extends He{constructor(e){super(),ze(this,e,Kt,Jt,Je,{record:0})}}function ot(l,e,a){const t=l.slice();return t[13]=e[a],t}function ut(l,e,a){const t=l.slice();t[16]=e[a];const s=t[1]!==null?Vt(t[1].properties[t[16].name],t[16].attribute_type):{type:t[16].attribute_type,value:""};return t[17]=s,t}function ft(l){let e,a=`<dir><label for="password" class="svelte-26svji">Password <div class="type svelte-26svji">string</div></label></dir> <div><input type="password" name="password" id="password" class="svelte-26svji"/></div>`;return{c(){e=p("fieldset"),e.innerHTML=a,this.h()},l(t){e=v(t,"FIELDSET",{class:!0,"data-svelte-h":!0}),ue(e)!=="svelte-1u8xex3"&&(e.innerHTML=a),this.h()},h(){u(e,"class","svelte-26svji")},m(t,s){ee(t,e,s)},d(t){t&&_(e)}}}function Wt(l){let e=l[16].attribute_type+"",a,t,s,r,n;return{c(){a=ce(e),t=M(),s=p("input"),this.h()},l(f){a=fe(f,e),t=A(f),s=v(f,"INPUT",{type:!0,name:!0,class:!0}),this.h()},h(){u(s,"type","hidden"),u(s,"name",r=l[16].name+"[type]"),s.value=n=l[16].attribute_type,u(s,"class","svelte-26svji")},m(f,i){ee(f,a,i),ee(f,t,i),ee(f,s,i)},p(f,i){i&1&&e!==(e=f[16].attribute_type+"")&&De(a,e),i&1&&r!==(r=f[16].name+"[type]")&&u(s,"name",r),i&1&&n!==(n=f[16].attribute_type)&&(s.value=n)},i:Ze,o:Ze,d(f){f&&(_(a),_(t),_(s))}}}function Xt(l){let e,a;return e=new Rt({props:{name:l[16].name+"[type]",options:[{value:"string",label:"string"},{value:"json",label:"json"}],checked:l[17].type==="json"?"json":"string"}}),{c(){he(e.$$.fragment)},l(t){pe(e.$$.fragment,t)},m(t,s){ve(e,t,s),a=!0},p(t,s){const r={};s&1&&(r.name=t[16].name+"[type]"),s&3&&(r.checked=t[17].type==="json"?"json":"string"),e.$set(r)},i(t){a||(O(e.$$.fragment,t),a=!0)},o(t){H(e.$$.fragment,t),a=!1},d(t){me(e,t)}}}function Yt(l){let e,a,t,s;return{c(){e=p("textarea"),this.h()},l(r){e=v(r,"TEXTAREA",{rows:!0,name:!0,id:!0,class:!0}),b(e).forEach(_),this.h()},h(){u(e,"rows","1"),u(e,"name",a=l[16].name+"[value]"),u(e,"id",t="edit_"+l[16].name),e.value=s=l[17].type==="json"||l[17].type==="jsonEscaped"?JSON.stringify(l[17].value,void 0,2):l[17].value,u(e,"class","svelte-26svji")},m(r,n){ee(r,e,n)},p(r,n){n&1&&a!==(a=r[16].name+"[value]")&&u(e,"name",a),n&1&&t!==(t="edit_"+r[16].name)&&u(e,"id",t),n&3&&s!==(s=r[17].type==="json"||r[17].type==="jsonEscaped"?JSON.stringify(r[17].value,void 0,2):r[17].value)&&(e.value=s)},d(r){r&&_(e)}}}function Qt(l){let e,a,t,s,r,n,f,i,h,m;return{c(){e=p("select"),a=p("option"),t=p("option"),s=ce("true"),n=p("option"),f=ce("false"),this.h()},l(c){e=v(c,"SELECT",{name:!0,id:!0});var E=b(e);a=v(E,"OPTION",{class:!0}),b(a).forEach(_),t=v(E,"OPTION",{});var T=b(t);s=fe(T,"true"),T.forEach(_),n=v(E,"OPTION",{});var C=b(n);f=fe(C,"false"),C.forEach(_),E.forEach(_),this.h()},h(){a.__value="",Ie(a,a.__value),u(a,"class","value-null"),t.__value="true",Ie(t,t.__value),t.selected=r=l[17].value==="true",n.__value="false",Ie(n,n.__value),n.selected=i=l[17].value==="false",u(e,"name",h=l[16].name+"[value]"),u(e,"id",m="edit_"+l[16].name)},m(c,E){ee(c,e,E),o(e,a),o(e,t),o(t,s),o(e,n),o(n,f)},p(c,E){E&3&&r!==(r=c[17].value==="true")&&(t.selected=r),E&3&&i!==(i=c[17].value==="false")&&(n.selected=i),E&1&&h!==(h=c[16].name+"[value]")&&u(e,"name",h),E&1&&m!==(m="edit_"+c[16].name)&&u(e,"id",m)},d(c){c&&_(e)}}}function ct(l){let e=l[5][l[16].name].message+"",a;return{c(){a=ce(e)},l(t){a=fe(t,e)},m(t,s){ee(t,a,s)},p(t,s){s&33&&e!==(e=t[5][t[16].name].message+"")&&De(a,e)},d(t){t&&_(a)}}}function dt(l){let e,a,t,s=l[16].name+"",r,n,f,i,h,m,c,E,T,C,F,P;const k=[Xt,Wt],y=[];function z($,B){return $[16].attribute_type==="string"?0:1}h=z(l),m=y[h]=k[h](l);function S($,B){return $[16].attribute_type==="boolean"?Qt:Yt}let R=S(l),J=R(l),U=l[5][l[16].name]&&ct(l);return{c(){e=p("fieldset"),a=p("dir"),t=p("label"),r=ce(s),n=p("br"),f=M(),i=p("div"),m.c(),E=M(),T=p("div"),J.c(),C=M(),F=p("div"),U&&U.c(),this.h()},l($){e=v($,"FIELDSET",{class:!0});var B=b(e);a=v(B,"DIR",{});var K=b(a);t=v(K,"LABEL",{for:!0,class:!0});var q=b(t);r=fe(q,s),n=v(q,"BR",{}),f=A(q),i=v(q,"DIV",{class:!0});var V=b(i);m.l(V),V.forEach(_),q.forEach(_),K.forEach(_),E=A(B),T=v(B,"DIV",{});var W=b(T);J.l(W),C=A(W),F=v(W,"DIV",{role:!0,class:!0});var I=b(F);U&&U.l(I),I.forEach(_),W.forEach(_),B.forEach(_),this.h()},h(){u(i,"class","type svelte-26svji"),u(t,"for",c="edit_"+l[16].name),u(t,"class","svelte-26svji"),u(F,"role","alert"),u(F,"class","svelte-26svji"),u(e,"class","svelte-26svji")},m($,B){ee($,e,B),o(e,a),o(a,t),o(t,r),o(t,n),o(t,f),o(t,i),y[h].m(i,null),o(e,E),o(e,T),J.m(T,null),o(T,C),o(T,F),U&&U.m(F,null),P=!0},p($,B){(!P||B&1)&&s!==(s=$[16].name+"")&&De(r,s);let K=h;h=z($),h===K?y[h].p($,B):(Ce(),H(y[K],1,1,()=>{y[K]=null}),ye(),m=y[h],m?m.p($,B):(m=y[h]=k[h]($),m.c()),O(m,1),m.m(i,null)),(!P||B&1&&c!==(c="edit_"+$[16].name))&&u(t,"for",c),R===(R=S($))&&J?J.p($,B):(J.d(1),J=R($),J&&(J.c(),J.m(T,C))),$[5][$[16].name]?U?U.p($,B):(U=ct($),U.c(),U.m(F,null)):U&&(U.d(1),U=null)},i($){P||(O(m),P=!0)},o($){H(m),P=!1},d($){$&&_(e),y[h].d(),J.d(),U&&U.d()}}}function _t(l){let e,a=(l[13].message??JSON.stringify(l[13]))+"",t,s;return{c(){e=p("li"),t=ce(a),s=M(),this.h()},l(r){e=v(r,"LI",{class:!0});var n=b(e);t=fe(n,a),s=A(n),n.forEach(_),this.h()},h(){u(e,"class","svelte-26svji")},m(r,n){ee(r,e,n),o(e,t),o(e,s)},p(r,n){n&16&&a!==(a=(r[13].message??JSON.stringify(r[13]))+"")&&De(t,a)},d(r){r&&_(e)}}}function Zt(l){let e;return{c(){e=ce("Edit user")},l(a){e=fe(a,"Edit user")},m(a,t){ee(a,e,t)},d(a){a&&_(e)}}}function xt(l){let e;return{c(){e=ce("Create user")},l(a){e=fe(a,"Create user")},m(a,t){ee(a,e,t)},d(a){a&&_(e)}}}function el(l){let e,a,t,s,r,n=`<label for="email" class="svelte-26svji">Email <div class="type svelte-26svji">string</div></label>`,f,i,h,m,c,E,T,C,F,P,k,y,z="Cancel",S,R,J,U,$,B,K,q,V=l[1]===null&&ft(),W=Se(l[0]),I=[];for(let d=0;d<W.length;d+=1)I[d]=dt(ut(l,W,d));const w=d=>H(I[d],1,1,()=>{I[d]=null});let L=Se(l[4]),N=[];for(let d=0;d<L.length;d+=1)N[d]=_t(ot(l,L,d));function se(d,j){return d[1]===null?xt:Zt}let ge=se(l),ae=ge(l);return U=new Ne({props:{icon:"arrowRight"}}),{c(){e=p("dialog"),a=p("div"),t=p("form"),s=p("fieldset"),r=p("dir"),r.innerHTML=n,f=M(),i=p("div"),h=p("input"),c=M(),V&&V.c(),E=M();for(let d=0;d<I.length;d+=1)I[d].c();T=M(),C=p("div"),F=p("ul");for(let d=0;d<N.length;d+=1)N[d].c();P=M(),k=p("fieldset"),y=p("button"),y.textContent=z,S=M(),R=p("button"),ae.c(),J=M(),he(U.$$.fragment),this.h()},l(d){e=v(d,"DIALOG",{class:!0});var j=b(e);a=v(j,"DIV",{class:!0});var g=b(a);t=v(g,"FORM",{class:!0});var G=b(t);s=v(G,"FIELDSET",{class:!0});var de=b(s);r=v(de,"DIR",{"data-svelte-h":!0}),ue(r)!=="svelte-r4cqvg"&&(r.innerHTML=n),f=A(de),i=v(de,"DIV",{});var Ee=b(i);h=v(Ee,"INPUT",{type:!0,name:!0,id:!0,class:!0}),Ee.forEach(_),de.forEach(_),c=A(G),V&&V.l(G),E=A(G);for(let oe=0;oe<I.length;oe+=1)I[oe].l(G);T=A(G),C=v(G,"DIV",{class:!0});var X=b(C);F=v(X,"UL",{class:!0,"aria-live":!0});var ne=b(F);for(let oe=0;oe<N.length;oe+=1)N[oe].l(ne);ne.forEach(_),P=A(X),k=v(X,"FIELDSET",{class:!0});var ie=b(k);y=v(ie,"BUTTON",{type:!0,class:!0,"data-svelte-h":!0}),ue(y)!=="svelte-15a47u9"&&(y.textContent=z),S=A(ie),R=v(ie,"BUTTON",{type:!0,class:!0});var le=b(R);ae.l(le),J=A(le),pe(U.$$.fragment,le),le.forEach(_),ie.forEach(_),X.forEach(_),G.forEach(_),g.forEach(_),j.forEach(_),this.h()},h(){u(h,"type","email"),u(h,"name","email"),u(h,"id","email"),h.value=m=l[1]!==null?l[1].email:"",u(h,"class","svelte-26svji"),u(s,"class","svelte-26svji"),u(F,"class","error svelte-26svji"),u(F,"aria-live","assertive"),u(y,"type","button"),u(y,"class","button"),u(R,"type","submit"),u(R,"class","button"),u(k,"class","actions svelte-26svji"),u(C,"class","footer svelte-26svji"),u(t,"class","svelte-26svji"),u(a,"class","content content-context svelte-26svji"),u(e,"class","svelte-26svji")},m(d,j){ee(d,e,j),o(e,a),o(a,t),o(t,s),o(s,r),o(s,f),o(s,i),o(i,h),o(t,c),V&&V.m(t,null),o(t,E);for(let g=0;g<I.length;g+=1)I[g]&&I[g].m(t,null);o(t,T),o(t,C),o(C,F);for(let g=0;g<N.length;g+=1)N[g]&&N[g].m(F,null);o(C,P),o(C,k),o(k,y),o(k,S),o(k,R),ae.m(R,null),o(R,J),ve(U,R,null),l[10](t),l[11](e),B=!0,K||(q=[_e(y,"click",l[9]),_e(t,"submit",$t(l[8]))],K=!0)},p(d,[j]){if((!B||j&2&&m!==(m=d[1]!==null?d[1].email:"")&&h.value!==m)&&(h.value=m),d[1]===null?V||(V=ft(),V.c(),V.m(t,E)):V&&(V.d(1),V=null),j&35){W=Se(d[0]);let g;for(g=0;g<W.length;g+=1){const G=ut(d,W,g);I[g]?(I[g].p(G,j),O(I[g],1)):(I[g]=dt(G),I[g].c(),O(I[g],1),I[g].m(t,T))}for(Ce(),g=W.length;g<I.length;g+=1)w(g);ye()}if(j&16){L=Se(d[4]);let g;for(g=0;g<L.length;g+=1){const G=ot(d,L,g);N[g]?N[g].p(G,j):(N[g]=_t(G),N[g].c(),N[g].m(F,null))}for(;g<N.length;g+=1)N[g].d(1);N.length=L.length}ge!==(ge=se(d))&&(ae.d(1),ae=ge(d),ae&&(ae.c(),ae.m(R,J)))},i(d){if(!B){for(let j=0;j<W.length;j+=1)O(I[j]);O(U.$$.fragment,d),d&&et(()=>{B&&($||($=qe(e,l[7],{},!0)),$.run(1))}),B=!0}},o(d){I=I.filter(Boolean);for(let j=0;j<I.length;j+=1)H(I[j]);H(U.$$.fragment,d),d&&($||($=qe(e,l[7],{},!1)),$.run(0)),B=!1},d(d){d&&_(e),V&&V.d(),Ye(I,d),Ye(N,d),ae.d(),me(U),l[10](null),l[11](null),d&&$&&$.end(),K=!1,Ke(q)}}}function tl(l,e,a){let t;Qe(l,re,P=>a(6,t=P));let s,r,n=[],f={},{userProperties:i}=e,{userToEdit:h}=e;const m=xe(),c=function(P,{delay:k=0,duration:y=150}){return{delay:k,duration:y,css:z=>{const S=kt(z);return`opacity: ${S}; transform: scale(${S});`}}};yt(()=>{setTimeout(()=>{s.showModal()},10)}),document.addEventListener("keydown",P=>{P.key==="Escape"&&(P.preventDefault(),we(re,t.user=void 0,t))},{once:!0});const E=async P=>{P.preventDefault();const k=new FormData(r);a(5,f={});for(const y of k.entries())if(y[0].endsWith("[type]")&&(y[1]==="json"||y[1]==="array")){const z=y[0].replace("[type]",""),S=k.get(z+"[value]");S!==""&&!Bt(S)&&a(5,f[z]={property:z,message:`Not a valid ${y[1]}`},f)}if(Object.keys(f).length)await tick(),document.querySelector('[role="alert"]:not(:empty)').scrollIntoView({behavior:"smooth",block:"center"});else if(h===null){const y=k.get("email"),z=k.get("password");k.delete("email"),k.delete("password");const S=await Ae.create(y,z,k);S.errors?a(4,n=S.errors):(we(re,t.user=void 0,t),re.notification.create("success",`User ${S.user.id} created`),m("success"))}else{const y=k.get("email");k.delete("email");const z=await Ae.edit(h.id,y,k);z.errors?a(4,n=z.errors):(we(re,t.user=void 0,t),re.notification.create("success",`User ${z.user_update.id} edited`),m("success"))}},T=()=>we(re,t.user=void 0,t);function C(P){Ue[P?"unshift":"push"](()=>{r=P,a(3,r)})}function F(P){Ue[P?"unshift":"push"](()=>{s=P,a(2,s)})}return l.$$set=P=>{"userProperties"in P&&a(0,i=P.userProperties),"userToEdit"in P&&a(1,h=P.userToEdit)},[i,h,s,r,n,f,t,c,E,T,C,F]}class ll extends He{constructor(e){super(),ze(this,e,tl,el,Je,{userProperties:0,userToEdit:1})}}const{document:Xe}=St;function mt(l,e,a){const t=l.slice();return t[28]=e[a],t}function vt(l){let e,a,t="Clear filters",s,r,n,f,i,h;return r=new Ne({props:{icon:"x",size:"14"}}),{c(){e=p("button"),a=p("span"),a.textContent=t,s=M(),he(r.$$.fragment),this.h()},l(m){e=v(m,"BUTTON",{type:!0,class:!0});var c=b(e);a=v(c,"SPAN",{class:!0,"data-svelte-h":!0}),ue(a)!=="svelte-ki22n5"&&(a.textContent=t),s=A(c),pe(r.$$.fragment,c),c.forEach(_),this.h()},h(){u(a,"class","label svelte-1g093it"),u(e,"type","button"),u(e,"class","clear svelte-1g093it")},m(m,c){ee(m,e,c),o(e,a),o(e,s),ve(r,e,null),f=!0,i||(h=_e(e,"click",l[10]),i=!0)},p:Ze,i(m){f||(O(r.$$.fragment,m),m&&et(()=>{f&&(n||(n=qe(e,l[8],{},!0)),n.run(1))}),f=!0)},o(m){H(r.$$.fragment,m),m&&(n||(n=qe(e,l[8],{},!1)),n.run(0)),f=!1},d(m){m&&_(e),me(r),m&&n&&n.end(),i=!1,h()}}}function pt(l){let e,a,t=Se(l[1]),s=[];for(let n=0;n<t.length;n+=1)s[n]=gt(mt(l,t,n));const r=n=>H(s[n],1,1,()=>{s[n]=null});return{c(){e=p("tbody");for(let n=0;n<s.length;n+=1)s[n].c()},l(n){e=v(n,"TBODY",{});var f=b(e);for(let i=0;i<s.length;i+=1)s[i].l(f);f.forEach(_)},m(n,f){ee(n,e,f);for(let i=0;i<s.length;i+=1)s[i]&&s[i].m(e,null);a=!0},p(n,f){if(f&690){t=Se(n[1]);let i;for(i=0;i<t.length;i+=1){const h=mt(n,t,i);s[i]?(s[i].p(h,f),O(s[i],1)):(s[i]=gt(h),s[i].c(),O(s[i],1),s[i].m(e,null))}for(Ce(),i=t.length;i<s.length;i+=1)r(i);ye()}},i(n){if(!a){for(let f=0;f<t.length;f+=1)O(s[f]);a=!0}},o(n){s=s.filter(Boolean);for(let f=0;f<s.length;f+=1)H(s[f]);a=!1},d(n){n&&_(e),Ye(s,n)}}}function ht(l){let e,a;return e=new Gt({props:{record:l[28]}}),e.$on("reload",l[21]),e.$on("close",l[22]),{c(){he(e.$$.fragment)},l(t){pe(e.$$.fragment,t)},m(t,s){ve(e,t,s),a=!0},p(t,s){const r={};s&2&&(r.record=t[28]),e.$set(r)},i(t){a||(O(e.$$.fragment,t),a=!0)},o(t){H(e.$$.fragment,t),a=!1},d(t){me(e,t)}}}function gt(l){let e,a,t,s,r,n,f,i,h="More options",m,c,E,T,C,F="Edit user",P,k,y,z,S,R,J=l[28].id+"",U,$,B,K,q,V=l[28].email+"",W,I,w,L,N,se;c=new Ne({props:{icon:"navigationMenuVertical",size:"16"}});function ge(){return l[19](l[28])}k=new Ne({props:{icon:"pencil",size:"16"}});function ae(){return l[20](l[28])}let d=l[4].id===l[28].id&&ht(l);return{c(){e=p("tr"),a=p("td"),t=p("span"),s=p("div"),r=p("div"),n=p("div"),f=p("button"),i=p("span"),i.textContent=h,m=M(),he(c.$$.fragment),E=M(),T=p("button"),C=p("span"),C.textContent=F,P=M(),he(k.$$.fragment),y=M(),d&&d.c(),z=M(),S=p("td"),R=p("a"),U=ce(J),B=M(),K=p("td"),q=p("a"),W=ce(V),w=M(),this.h()},l(j){e=v(j,"TR",{class:!0});var g=b(e);a=v(g,"TD",{class:!0});var G=b(a);t=v(G,"SPAN",{class:!0});var de=b(t);s=v(de,"DIV",{class:!0});var Ee=b(s);r=v(Ee,"DIV",{class:!0});var X=b(r);n=v(X,"DIV",{class:!0});var ne=b(n);f=v(ne,"BUTTON",{class:!0});var ie=b(f);i=v(ie,"SPAN",{class:!0,"data-svelte-h":!0}),ue(i)!=="svelte-1agpmtc"&&(i.textContent=h),m=A(ie),pe(c.$$.fragment,ie),ie.forEach(_),E=A(ne),T=v(ne,"BUTTON",{class:!0,title:!0});var le=b(T);C=v(le,"SPAN",{class:!0,"data-svelte-h":!0}),ue(C)!=="svelte-1bbczt2"&&(C.textContent=F),P=A(le),pe(k.$$.fragment,le),le.forEach(_),ne.forEach(_),y=A(X),d&&d.l(X),X.forEach(_),Ee.forEach(_),de.forEach(_),G.forEach(_),z=A(g),S=v(g,"TD",{class:!0});var oe=b(S);R=v(oe,"A",{href:!0,class:!0});var je=b(R);U=fe(je,J),je.forEach(_),oe.forEach(_),B=A(g),K=v(g,"TD",{class:!0});var Pe=b(K);q=v(Pe,"A",{href:!0,class:!0});var $e=b(q);W=fe($e,V),$e.forEach(_),Pe.forEach(_),w=A(g),g.forEach(_),this.h()},h(){u(i,"class","label"),u(f,"class","button compact more svelte-1g093it"),Oe(f,"active",l[4].id===l[28].id),u(C,"class","label"),u(T,"class","button compact edit"),u(T,"title","Edit user"),u(n,"class","combo"),u(r,"class","inner-menu svelte-1g093it"),u(s,"class","menu svelte-1g093it"),u(t,"class","svelte-1g093it"),u(a,"class","svelte-1g093it"),u(R,"href",$="/users/"+l[28].id+"?"+l[5].url.searchParams.toString()),u(R,"class","svelte-1g093it"),u(S,"class","table-id svelte-1g093it"),u(q,"href",I="/users/"+l[28].id+"?"+l[5].url.searchParams.toString()),u(q,"class","svelte-1g093it"),u(K,"class","svelte-1g093it"),u(e,"class","svelte-1g093it"),Oe(e,"active",l[5].params.id==l[28].id),Oe(e,"context",l[4].id===l[28].id)},m(j,g){ee(j,e,g),o(e,a),o(a,t),o(t,s),o(s,r),o(r,n),o(n,f),o(f,i),o(f,m),ve(c,f,null),o(n,E),o(n,T),o(T,C),o(T,P),ve(k,T,null),o(r,y),d&&d.m(r,null),o(e,z),o(e,S),o(S,R),o(R,U),o(e,B),o(e,K),o(K,q),o(q,W),o(e,w),L=!0,N||(se=[_e(f,"click",ge),_e(T,"click",ae)],N=!0)},p(j,g){l=j,(!L||g&18)&&Oe(f,"active",l[4].id===l[28].id),l[4].id===l[28].id?d?(d.p(l,g),g&18&&O(d,1)):(d=ht(l),d.c(),O(d,1),d.m(r,null)):d&&(Ce(),H(d,1,1,()=>{d=null}),ye()),(!L||g&2)&&J!==(J=l[28].id+"")&&De(U,J),(!L||g&34&&$!==($="/users/"+l[28].id+"?"+l[5].url.searchParams.toString()))&&u(R,"href",$),(!L||g&2)&&V!==(V=l[28].email+"")&&De(W,V),(!L||g&34&&I!==(I="/users/"+l[28].id+"?"+l[5].url.searchParams.toString()))&&u(q,"href",I),(!L||g&34)&&Oe(e,"active",l[5].params.id==l[28].id),(!L||g&18)&&Oe(e,"context",l[4].id===l[28].id)},i(j){L||(O(c.$$.fragment,j),O(k.$$.fragment,j),O(d),L=!0)},o(j){H(c.$$.fragment,j),H(k.$$.fragment,j),H(d),L=!1},d(j){j&&_(e),me(c),me(k),d&&d.d(),N=!1,Ke(se)}}}function bt(l){let e;const a=l[13].default,t=Dt(a,l,l[12],null);return{c(){t&&t.c()},l(s){t&&t.l(s)},m(s,r){t&&t.m(s,r),e=!0},p(s,r){t&&t.p&&(!e||r&4096)&&Nt(t,a,s,s[12],e?Lt(a,s[12],r,null):jt(s[12]),null)},i(s){e||(O(t,s),e=!0)},o(s){H(t,s),e=!1},d(s){t&&t.d(s)}}}function Et(l){let e,a;return e=new ll({props:{userProperties:l[2],userToEdit:l[6].user}}),e.$on("success",l[26]),{c(){he(e.$$.fragment)},l(t){pe(e.$$.fragment,t)},m(t,s){ve(e,t,s),a=!0},p(t,s){const r={};s&4&&(r.userProperties=t[2]),s&64&&(r.userToEdit=t[6].user),e.$set(r)},i(t){a||(O(e.$$.fragment,t),a=!0)},o(t){H(e.$$.fragment,t),a=!1},d(t){me(e,t)}}}function sl(l){var st;let e,a,t,s,r,n,f,i="Filter by",h,m,c,E,T="email",C,F="id",P,k,y,z,S,R,J="Apply filter",U,$,B,K,q,V,W='<tr class="svelte-1g093it"><th class="menu svelte-1g093it"></th> <th class="table-id svelte-1g093it">ID</th> <th class="svelte-1g093it">Email</th></tr>',I,w,L,N,se,ge="Page:",ae,d,j,g,G=l[3].totalPages+"",de,Ee,X,ne,ie,le,oe="Create a new user",je,Pe,$e,Ge,tt;Xe.title=e="Users"+((st=l[6].online)!=null&&st.MPKIT_URL?": "+l[6].online.MPKIT_URL.replace("https://",""):"");let Y=l[3].value&&vt(l);$=new Ne({props:{icon:"arrowRight"}});let Q=l[1]&&pt(l);function Tt(D){l[23](D)}let lt={form:"filters",name:"page",min:1,max:l[3].totalPages,step:1,decreaseLabel:"Previous page",increaseLabel:"Next page",style:"navigation"};l[3].page!==void 0&&(lt.value=l[3].page),d=new Ft({props:lt}),Ue.push(()=>Pt(d,"value",Tt)),d.$on("input",l[24]),ne=new Ne({props:{icon:"plus"}});let Z=l[5].params.id&&bt(l),x=l[6].user!==void 0&&Et(l);return{c(){a=M(),t=p("div"),s=p("section"),r=p("nav"),n=p("form"),f=p("label"),f.textContent=i,h=M(),m=p("fieldset"),c=p("select"),E=p("option"),E.textContent=T,C=p("option"),C.textContent=F,P=M(),k=p("input"),y=M(),Y&&Y.c(),z=M(),S=p("button"),R=p("span"),R.textContent=J,U=M(),he($.$$.fragment),B=M(),K=p("article"),q=p("table"),V=p("thead"),V.innerHTML=W,I=M(),Q&&Q.c(),w=M(),L=p("nav"),N=p("div"),se=p("label"),se.textContent=ge,ae=M(),he(d.$$.fragment),g=ce(` of `),de=ce(G),Ee=M(),X=p("button"),he(ne.$$.fragment),ie=M(),le=p("span"),le.textContent=oe,je=M(),Z&&Z.c(),Pe=M(),x&&x.c(),this.h()},l(D){It("svelte-mcmxo",Xe.head).forEach(_),a=A(D),t=v(D,"DIV",{class:!0});var be=b(t);s=v(be,"SECTION",{class:!0});var ke=b(s);r=v(ke,"NAV",{class:!0});var at=b(r);n=v(at,"FORM",{action:!0,id:!0,class:!0});var Me=b(n);f=v(Me,"LABEL",{for:!0,"data-svelte-h":!0}),ue(f)!=="svelte-rbwhex"&&(f.textContent=i),h=A(Me),m=v(Me,"FIELDSET",{class:!0});var Te=b(m);c=v(Te,"SELECT",{id:!0,name:!0,class:!0});var We=b(c);E=v(We,"OPTION",{"data-svelte-h":!0}),ue(E)!=="svelte-51kto6"&&(E.textContent=T),C=v(We,"OPTION",{"data-svelte-h":!0}),ue(C)!=="svelte-ns3pfu"&&(C.textContent=F),We.forEach(_),P=A(Te),k=v(Te,"INPUT",{type:!0,name:!0,class:!0}),y=A(Te),Y&&Y.l(Te),z=A(Te),S=v(Te,"BUTTON",{type:!0,class:!0});var Re=b(S);R=v(Re,"SPAN",{class:!0,"data-svelte-h":!0}),ue(R)!=="svelte-ctu7wl"&&(R.textContent=J),U=A(Re),pe($.$$.fragment,Re),Re.forEach(_),Te.forEach(_),Me.forEach(_),at.forEach(_),B=A(ke),K=v(ke,"ARTICLE",{class:!0});var nt=b(K);q=v(nt,"TABLE",{class:!0});var Ve=b(q);V=v(Ve,"THEAD",{class:!0,"data-svelte-h":!0}),ue(V)!=="svelte-17vx132"&&(V.innerHTML=W),I=A(Ve),Q&&Q.l(Ve),Ve.forEach(_),nt.forEach(_),w=A(ke),L=v(ke,"NAV",{class:!0});var Be=b(L);N=v(Be,"DIV",{});var Le=b(N);se=v(Le,"LABEL",{for:!0,"data-svelte-h":!0}),ue(se)!=="svelte-1r8oyu6"&&(se.textContent=ge),ae=A(Le),pe(d.$$.fragment,Le),g=fe(Le,` of `),de=fe(Le,G),Le.forEach(_),Ee=A(Be),X=v(Be,"BUTTON",{class:!0,title:!0});var Fe=b(X);pe(ne.$$.fragment,Fe),ie=A(Fe),le=v(Fe,"SPAN",{class:!0,"data-svelte-h":!0}),ue(le)!=="svelte-vjukmr"&&(le.textContent=oe),Fe.forEach(_),Be.forEach(_),ke.forEach(_),je=A(be),Z&&Z.l(be),Pe=A(be),x&&x.l(be),be.forEach(_),this.h()},h(){u(f,"for","filters_attribute"),E.__value="email",Ie(E,E.__value),C.__value="id",Ie(C,C.__value),u(c,"id","filters_attribute"),u(c,"name","attribute"),u(c,"class","svelte-1g093it"),l[3].attribute===void 0&&et(()=>l[14].call(c)),u(k,"type","text"),u(k,"name","value"),u(k,"class","svelte-1g093it"),u(R,"class","label svelte-1g093it"),u(S,"type","submit"),u(S,"class","button svelte-1g093it"),u(m,"class","search svelte-1g093it"),u(n,"action",""),u(n,"id","filters"),u(n,"class","svelte-1g093it"),u(r,"class","filters svelte-1g093it"),u(V,"class","svelte-1g093it"),u(q,"class","svelte-1g093it"),u(K,"class","contetnt"),u(se,"for","page"),u(le,"class","label"),u(X,"class","button"),u(X,"title","Create user"),u(L,"class","pagination svelte-1g093it"),u(s,"class","container svelte-1g093it"),u(t,"class","page svelte-1g093it")},m(D,te){ee(D,a,te),ee(D,t,te),o(t,s),o(s,r),o(r,n),o(n,f),o(n,h),o(n,m),o(m,c),o(c,E),o(c,C),rt(c,l[3].attribute,!0),o(m,P),o(m,k),Ie(k,l[3].value),o(m,y),Y&&Y.m(m,null),o(m,z),o(m,S),o(S,R),o(S,U),ve($,S,null),l[17](n),o(s,B),o(s,K),o(K,q),o(q,V),o(q,I),Q&&Q.m(q,null),o(s,w),o(s,L),o(L,N),o(N,se),o(N,ae),ve(d,N,null),o(N,g),o(N,de),o(L,Ee),o(L,X),ve(ne,X,null),o(X,ie),o(X,le),o(t,je),Z&&Z.m(t,null),o(t,Pe),x&&x.m(t,null),$e=!0,Ge||(tt=[_e(c,"change",l[14]),_e(c,"change",l[15]),_e(k,"input",l[16]),_e(n,"submit",l[18]),_e(X,"click",$t(l[25]))],Ge=!0)},p(D,[te]){var ke;(!$e||te&64)&&e!==(e="Users"+((ke=D[6].online)!=null&&ke.MPKIT_URL?": "+D[6].online.MPKIT_URL.replace("https://",""):""))&&(Xe.title=e),te&8&&rt(c,D[3].attribute),te&8&&k.value!==D[3].value&&Ie(k,D[3].value),D[3].value?Y?(Y.p(D,te),te&8&&O(Y,1)):(Y=vt(D),Y.c(),O(Y,1),Y.m(m,z)):Y&&(Ce(),H(Y,1,1,()=>{Y=null}),ye()),D[1]?Q?(Q.p(D,te),te&2&&O(Q,1)):(Q=pt(D),Q.c(),O(Q,1),Q.m(q,null)):Q&&(Ce(),H(Q,1,1,()=>{Q=null}),ye());const be={};te&8&&(be.max=D[3].totalPages),!j&&te&8&&(j=!0,be.value=D[3].page,wt(()=>j=!1)),d.$set(be),(!$e||te&8)&&G!==(G=D[3].totalPages+"")&&De(de,G),D[5].params.id?Z?(Z.p(D,te),te&32&&O(Z,1)):(Z=bt(D),Z.c(),O(Z,1),Z.m(t,Pe)):Z&&(Ce(),H(Z,1,1,()=>{Z=null}),ye()),D[6].user!==void 0?x?(x.p(D,te),te&64&&O(x,1)):(x=Et(D),x.c(),O(x,1),x.m(t,null)):x&&(Ce(),H(x,1,1,()=>{x=null}),ye())},i(D){$e||(O(Y),O($.$$.fragment,D),O(Q),O(d.$$.fragment,D),O(ne.$$.fragment,D),O(Z),O(x),$e=!0)},o(D){H(Y),H($.$$.fragment,D),H(Q),H(d.$$.fragment,D),H(ne.$$.fragment,D),H(Z),H(x),$e=!1},d(D){D&&(_(a),_(t)),Y&&Y.d(),me($),l[17](null),Q&&Q.d(),me(d),me(ne),Z&&Z.d(),x&&x.d(),Ge=!1,Ke(tt)}}}function al(l,e,a){let t,s;Qe(l,At,w=>a(5,t=w)),Qe(l,re,w=>a(6,s=w));let{$$slots:r={},$$scope:n}=e,f,i=[],h=null,m={page:1,attribute:"email",value:""},c={page:1,totalPages:1,attribute:"email",value:"",...Object.fromEntries(t.url.searchParams)};we(re,s.user=void 0,s);let E={id:null};const T=function(){const w=Object.fromEntries(t.url.searchParams);Ae.get(w).then(L=>{a(1,i=L.results),a(3,c.totalPages=L.total_pages,c)})},C=function(w,{delay:L=0,duration:N=150}){return{delay:L,duration:N,css:se=>`scale: ${kt(se)};`}},F=function(w=null){h===null?Ae.getCustomProperties().then(L=>{a(2,h=L),we(re,s.user=w,s)}).catch(()=>{re.notification.create("error","Could not load table properties. Please try again later.")}):we(re,s.user=w,s)},P=async function(){a(3,c=structuredClone(m)),await it(),f.requestSubmit()},k=async function(w){w.preventDefault();const L=t.url.searchParams,N=new URLSearchParams(new FormData(w.target));L.get("value")!==N.get("value")&&(N.set("page",1),a(3,c.page=1,c)),await Ut(document.location.pathname+"?"+N.toString()),await it(),await T()};function y(){c.attribute=Ot(this),a(3,c)}const z=()=>a(3,c.value="",c);function S(){c.value=this.value,a(3,c)}function R(w){Ue[w?"unshift":"push"](()=>{f=w,a(0,f)})}const J=w=>k(w),U=w=>a(4,E.id=w.id,E),$=w=>{F(w)},B=()=>T(),K=()=>a(4,E.id=null,E);function q(w){l.$$.not_equal(c.page,w)&&(c.page=w,a(3,c))}const V=w=>{f.requestSubmit(w.detail.submitter)},W=()=>F(),I=()=>T();return l.$$set=w=>{"$$scope"in w&&a(12,n=w.$$scope)},T(),[f,i,h,c,E,t,s,T,C,F,P,k,n,r,y,z,S,R,J,U,$,B,K,q,V,W,I]}class bl extends He{constructor(e){super(),ze(this,e,al,sl,Je,{})}}export{bl as component};