(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); import { S as SvelteElement, i as init, a as attribute_to_object, b as insert_dev, t as flush, s as safe_not_equal, d as dispatch_dev, v as validate_slots, w as validate_store, x as component_subscribe, g as getContext, o as onMount, y as empty, n as noop, p as detach_dev, q as binding_callbacks, f as element, h as space, B as text, j as add_location, k as attr_dev, l as append_dev, K as set_input_value, m as listen_dev, C as set_data_dev, r as run_all } from './index-998178c7.js'; import { w as writable } from './index-f9998ce7.js'; import { getData } from '../../../../../../../../../js/libraries/serverTools.js'; import '../../../../../../../../../js/components/select-component.js'; import '../../../../../../../../../js/components/switch-component.js'; /* src\profile\profile-groups.svelte generated by Svelte v3.52.0 */ const file = "src\\profile\\profile-groups.svelte"; // (115:4) {#if $loaded==1} function create_if_block(ctx) { let h2; let t1; let h30; let t3; let section0; let div2; let div1; let span0; let t5; let div0; let button0; let t6_value = /*getAddress*/ ctx[13](/*user_groups*/ ctx[1][0]) + ""; let t6; let t7; let object0; let t8; let div5; let div4; let span1; let t10; let div3; let button1; let t12; let input0; let t13; let button2; let object1; let t14; let div8; let div7; let span2; let t16; let div6; let button3; let t18; let input1; let t19; let button4; let object2; let t20; let h31; let t22; let section1; let mounted; let dispose; const block = { c: function create() { h2 = element("h2"); h2.textContent = "Groups"; t1 = space(); h30 = element("h3"); h30.textContent = "My group"; t3 = space(); section0 = element("section"); div2 = element("div"); div1 = element("div"); span0 = element("span"); span0.textContent = "Location:"; t5 = space(); div0 = element("div"); button0 = element("button"); t6 = text(t6_value); t7 = space(); object0 = element("object"); t8 = space(); div5 = element("div"); div4 = element("div"); span1 = element("span"); span1.textContent = "Members:"; t10 = space(); div3 = element("div"); button1 = element("button"); button1.textContent = "save"; t12 = space(); input0 = element("input"); t13 = space(); button2 = element("button"); object1 = element("object"); t14 = space(); div8 = element("div"); div7 = element("div"); span2 = element("span"); span2.textContent = "Contact:"; t16 = space(); div6 = element("div"); button3 = element("button"); button3.textContent = "save"; t18 = space(); input1 = element("input"); t19 = space(); button4 = element("button"); object2 = element("object"); t20 = space(); h31 = element("h3"); h31.textContent = "Requests"; t22 = space(); section1 = element("section"); add_location(h2, file, 116, 8, 2738); add_location(h30, file, 117, 8, 2763); add_location(span0, file, 121, 20, 2933); attr_dev(object0, "type", "image/svg+xml"); attr_dev(object0, "data", "/img/profile/icons/pencil.svg"); attr_dev(object0, "title", "pencil-icon"); attr_dev(object0, "class", "pencil"); add_location(object0, file, 124, 28, 3159); attr_dev(button0, "class", "change-field-button"); add_location(button0, file, 123, 24, 3033); attr_dev(div0, "class", "change-field-div"); add_location(div0, file, 122, 20, 2977); attr_dev(div1, "class", "change-field-line"); add_location(div1, file, 120, 16, 2880); add_location(div2, file, 119, 12, 2857); add_location(span1, file, 131, 20, 3466); attr_dev(button1, "class", "save-button"); add_location(button1, file, 133, 24, 3606); attr_dev(input0, "id", "membersInput"); attr_dev(input0, "class", "text-input"); attr_dev(input0, "type", "text"); add_location(input0, file, 134, 24, 3726); attr_dev(object1, "type", "image/svg+xml"); attr_dev(object1, "data", "/img/profile/icons/pencil.svg"); attr_dev(object1, "title", "pencil-icon"); attr_dev(object1, "class", "pencil"); add_location(object1, file, 136, 28, 4019); attr_dev(button2, "class", "text-input-pencil-button"); add_location(button2, file, 135, 24, 3910); attr_dev(div3, "class", "change-field-div input-pencil"); add_location(div3, file, 132, 20, 3509); attr_dev(div4, "class", "change-field-line"); add_location(div4, file, 130, 16, 3413); add_location(div5, file, 129, 12, 3390); add_location(span2, file, 143, 20, 4326); attr_dev(button3, "class", "save-button"); add_location(button3, file, 145, 24, 4466); attr_dev(input1, "id", "contactInput"); attr_dev(input1, "class", "text-input"); attr_dev(input1, "type", "text"); add_location(input1, file, 146, 24, 4586); attr_dev(object2, "type", "image/svg+xml"); attr_dev(object2, "data", "/img/profile/icons/pencil.svg"); attr_dev(object2, "title", "pencil-icon"); attr_dev(object2, "class", "pencil"); add_location(object2, file, 148, 28, 4879); attr_dev(button4, "class", "text-input-pencil-button"); add_location(button4, file, 147, 24, 4770); attr_dev(div6, "class", "change-field-div input-pencil"); add_location(div6, file, 144, 20, 4369); attr_dev(div7, "class", "change-field-line"); add_location(div7, file, 142, 16, 4273); add_location(div8, file, 141, 12, 4250); attr_dev(section0, "class", "entries-section"); add_location(section0, file, 118, 8, 2790); add_location(h31, file, 154, 8, 5126); attr_dev(section1, "class", "entries-section"); add_location(section1, file, 155, 8, 5153); }, m: function mount(target, anchor) { insert_dev(target, h2, anchor); insert_dev(target, t1, anchor); insert_dev(target, h30, anchor); insert_dev(target, t3, anchor); insert_dev(target, section0, anchor); append_dev(section0, div2); append_dev(div2, div1); append_dev(div1, span0); append_dev(div1, t5); append_dev(div1, div0); append_dev(div0, button0); append_dev(button0, t6); append_dev(button0, t7); append_dev(button0, object0); append_dev(section0, t8); append_dev(section0, div5); append_dev(div5, div4); append_dev(div4, span1); append_dev(div4, t10); append_dev(div4, div3); append_dev(div3, button1); /*button1_binding*/ ctx[17](button1); append_dev(div3, t12); append_dev(div3, input0); /*input0_binding*/ ctx[18](input0); set_input_value(input0, /*inputMembers*/ ctx[9]); append_dev(div3, t13); append_dev(div3, button2); append_dev(button2, object1); /*div3_binding*/ ctx[22](div3); append_dev(section0, t14); append_dev(section0, div8); append_dev(div8, div7); append_dev(div7, span2); append_dev(div7, t16); append_dev(div7, div6); append_dev(div6, button3); /*button3_binding*/ ctx[23](button3); append_dev(div6, t18); append_dev(div6, input1); /*input1_binding*/ ctx[24](input1); set_input_value(input1, /*inputContact*/ ctx[8]); append_dev(div6, t19); append_dev(div6, button4); append_dev(button4, object2); /*div6_binding*/ ctx[28](div6); /*section0_binding*/ ctx[29](section0); insert_dev(target, t20, anchor); insert_dev(target, h31, anchor); insert_dev(target, t22, anchor); insert_dev(target, section1, anchor); /*section1_binding*/ ctx[30](section1); if (!mounted) { dispose = [ listen_dev(button0, "click", /*launchChangeLocation*/ ctx[14], false, false, false), listen_dev(button1, "click", /*saveMembers*/ ctx[15], false, false, false), listen_dev(input0, "input", /*input0_input_handler*/ ctx[19]), listen_dev(input0, "click", /*click_handler*/ ctx[20], false, false, false), listen_dev(button2, "click", /*click_handler_1*/ ctx[21], false, false, false), listen_dev(button3, "click", saveContact, false, false, false), listen_dev(input1, "input", /*input1_input_handler*/ ctx[25]), listen_dev(input1, "click", /*click_handler_2*/ ctx[26], false, false, false), listen_dev(button4, "click", /*click_handler_3*/ ctx[27], false, false, false) ]; mounted = true; } }, p: function update(ctx, dirty) { if (dirty[0] & /*user_groups*/ 2 && t6_value !== (t6_value = /*getAddress*/ ctx[13](/*user_groups*/ ctx[1][0]) + "")) set_data_dev(t6, t6_value); if (dirty[0] & /*inputMembers*/ 512 && input0.value !== /*inputMembers*/ ctx[9]) { set_input_value(input0, /*inputMembers*/ ctx[9]); } if (dirty[0] & /*inputContact*/ 256 && input1.value !== /*inputContact*/ ctx[8]) { set_input_value(input1, /*inputContact*/ ctx[8]); } }, d: function destroy(detaching) { if (detaching) detach_dev(h2); if (detaching) detach_dev(t1); if (detaching) detach_dev(h30); if (detaching) detach_dev(t3); if (detaching) detach_dev(section0); /*button1_binding*/ ctx[17](null); /*input0_binding*/ ctx[18](null); /*div3_binding*/ ctx[22](null); /*button3_binding*/ ctx[23](null); /*input1_binding*/ ctx[24](null); /*div6_binding*/ ctx[28](null); /*section0_binding*/ ctx[29](null); if (detaching) detach_dev(t20); if (detaching) detach_dev(h31); if (detaching) detach_dev(t22); if (detaching) detach_dev(section1); /*section1_binding*/ ctx[30](null); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block.name, type: "if", source: "(115:4) {#if $loaded==1}", ctx }); return block; } // (114:0) {#key $loaded} function create_key_block(ctx) { let if_block_anchor; let if_block = /*$loaded*/ ctx[10] == 1 && create_if_block(ctx); const block = { c: function create() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m: function mount(target, anchor) { if (if_block) if_block.m(target, anchor); insert_dev(target, if_block_anchor, anchor); }, p: function update(ctx, dirty) { if (/*$loaded*/ ctx[10] == 1) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, d: function destroy(detaching) { if (if_block) if_block.d(detaching); if (detaching) detach_dev(if_block_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_key_block.name, type: "key", source: "(114:0) {#key $loaded}", ctx }); return block; } function create_fragment(ctx) { let previous_key = /*$loaded*/ ctx[10]; let key_block_anchor; let key_block = create_key_block(ctx); const block = { c: function create() { key_block.c(); key_block_anchor = empty(); this.c = noop; }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { key_block.m(target, anchor); insert_dev(target, key_block_anchor, anchor); }, p: function update(ctx, dirty) { if (dirty[0] & /*$loaded*/ 1024 && safe_not_equal(previous_key, previous_key = /*$loaded*/ ctx[10])) { key_block.d(1); key_block = create_key_block(ctx); key_block.c(); key_block.m(key_block_anchor.parentNode, key_block_anchor); } else { key_block.p(ctx, dirty); } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(key_block_anchor); key_block.d(detaching); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); return block; } function getContact(c) { if (c == null) { return "https://discord.gg/Qk8KUk787z"; } else { return c; } } function launchChangeMembers() { } function showSaveButton(button) { button.style.display = "initial"; } function saveContact() { } function instance($$self, $$props, $$invalidate) { let $content; let $loaded; let { $$slots: slots = {}, $$scope } = $$props; validate_slots('profile-groups', slots, []); let { groups = null } = $$props; // Main code let section; let user_groups; let content = writable({}); validate_store(content, 'content'); component_subscribe($$self, content, value => $$invalidate(31, $content = value)); let loaded = writable(0); validate_store(loaded, 'loaded'); component_subscribe($$self, loaded, value => $$invalidate(10, $loaded = value)); let membersInput; let saveMembersButton; let membersInputDiv; let contactInput; let saveContactButton; let contactInputDiv; let locale = "en"; let inputContact; let inputMembers; function groups_callback(response) { $$invalidate(1, user_groups = JSON.parse(response)); $$invalidate(8, inputContact = getContact(user_groups[0].contact)); $$invalidate(9, inputMembers = user_groups[0].members); loaded.update(val => { return val + 1; }); } getData("/xx/get_user_groups", groups_callback); function getAddress(g) { let location = [g.country, g.state, g.town].filter(x => x != null); return location.map(x => locale == "en" ? x : translate($content, x)).join(", "); } function launchChangeLocation() { showLocationOverlay(); } function resetMembersField() { $$invalidate(3, saveMembersButton.style.display = "none", saveMembersButton); } function resetContactField() { $$invalidate(6, saveContactButton.style.display = "none", saveContactButton); } function saveMembers() { let email = emailInput.value; if (AuthTools.checkEmail(email, emailMsg)) { if (email != user.email) { AuthTools.changeUser("email", email, user); } resetMembersField(); } } let showLocationOverlay = getContext("profile-component"); onMount(() => { document.addEventListener("click", function (event) { if (membersInputDiv.focused) { resetContactField(); } else if (contactInputDiv.focused) { resetMembersField(); } else { resetMembersField(); resetContactField(); } }); }); const writable_props = ['groups']; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(` was created with unknown prop '${key}'`); }); function button1_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { saveMembersButton = $$value; $$invalidate(3, saveMembersButton); }); } function input0_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { membersInput = $$value; $$invalidate(2, membersInput); }); } function input0_input_handler() { inputMembers = this.value; $$invalidate(9, inputMembers); } const click_handler = () => showSaveButton(saveMembersButton); const click_handler_1 = () => membersInput.focus(); function div3_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { membersInputDiv = $$value; $$invalidate(4, membersInputDiv); }); } function button3_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { saveContactButton = $$value; $$invalidate(6, saveContactButton); }); } function input1_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { contactInput = $$value; $$invalidate(5, contactInput); }); } function input1_input_handler() { inputContact = this.value; $$invalidate(8, inputContact); } const click_handler_2 = () => showSaveButton(saveContactButton); const click_handler_3 = () => contactInput.focus(); function div6_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { contactInputDiv = $$value; $$invalidate(7, contactInputDiv); }); } function section0_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { section = $$value; $$invalidate(0, section); }); } function section1_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { section = $$value; $$invalidate(0, section); }); } $$self.$$set = $$props => { if ('groups' in $$props) $$invalidate(16, groups = $$props.groups); }; $$self.$capture_state = () => ({ onMount, getContext, writable, getData, groups, section, user_groups, content, loaded, membersInput, saveMembersButton, membersInputDiv, contactInput, saveContactButton, contactInputDiv, locale, inputContact, inputMembers, groups_callback, getAddress, getContact, launchChangeLocation, launchChangeMembers, showSaveButton, resetMembersField, resetContactField, saveMembers, saveContact, showLocationOverlay, $content, $loaded }); $$self.$inject_state = $$props => { if ('groups' in $$props) $$invalidate(16, groups = $$props.groups); if ('section' in $$props) $$invalidate(0, section = $$props.section); if ('user_groups' in $$props) $$invalidate(1, user_groups = $$props.user_groups); if ('content' in $$props) $$invalidate(11, content = $$props.content); if ('loaded' in $$props) $$invalidate(12, loaded = $$props.loaded); if ('membersInput' in $$props) $$invalidate(2, membersInput = $$props.membersInput); if ('saveMembersButton' in $$props) $$invalidate(3, saveMembersButton = $$props.saveMembersButton); if ('membersInputDiv' in $$props) $$invalidate(4, membersInputDiv = $$props.membersInputDiv); if ('contactInput' in $$props) $$invalidate(5, contactInput = $$props.contactInput); if ('saveContactButton' in $$props) $$invalidate(6, saveContactButton = $$props.saveContactButton); if ('contactInputDiv' in $$props) $$invalidate(7, contactInputDiv = $$props.contactInputDiv); if ('locale' in $$props) locale = $$props.locale; if ('inputContact' in $$props) $$invalidate(8, inputContact = $$props.inputContact); if ('inputMembers' in $$props) $$invalidate(9, inputMembers = $$props.inputMembers); if ('showLocationOverlay' in $$props) showLocationOverlay = $$props.showLocationOverlay; }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [ section, user_groups, membersInput, saveMembersButton, membersInputDiv, contactInput, saveContactButton, contactInputDiv, inputContact, inputMembers, $loaded, content, loaded, getAddress, launchChangeLocation, saveMembers, groups, button1_binding, input0_binding, input0_input_handler, click_handler, click_handler_1, div3_binding, button3_binding, input1_binding, input1_input_handler, click_handler_2, click_handler_3, div6_binding, section0_binding, section1_binding ]; } class Profile_groups extends SvelteElement { constructor(options) { super(); this.shadowRoot.innerHTML = ``; init( this, { target: this.shadowRoot, props: attribute_to_object(this.attributes), customElement: true }, instance, create_fragment, safe_not_equal, { groups: 16 }, null, [-1, -1] ); if (options) { if (options.target) { insert_dev(options.target, this, options.anchor); } if (options.props) { this.$set(options.props); flush(); } } } static get observedAttributes() { return ["groups"]; } get groups() { return this.$$.ctx[16]; } set groups(groups) { this.$$set({ groups }); flush(); } } customElements.define("profile-groups", Profile_groups); export { Profile_groups as default };