const S = Symbol(); const FORM_STYLE = ` form { display: block; } form legend { margin: 16px 0; font-weight: bold; font-size: 20px; } form.inline div { display: flex; } form > div { display: block; margin-bottom: 1rem; } input, textarea { font-size: 16px; border: none; border-bottom-style: none; border-bottom-width: medium; border-bottom: 1px solid rgba(0,0,0,.1); border-radius: 2px; padding: 0; height: 36px; background: #fff; color: rgba(0,0,0,.8); font-size: 14px; box-shadow: none !important; display: block; width: 100%; height: calc(1.5em + 0.75rem + 2px); padding: .375rem .75rem; font-size: 1rem; font-weight: 400; line-height: 1.5; color: #495057; background-clip: padding-box; transition: border-color .15s ease-in-out , -webkit-box-shadow .15s ease-in-out; transition: border-color .15s ease-in-out , box-shadow .15s ease-in-out; transition: border-color .15s ease-in-out , box-shadow .15s ease-in-out , -webkit-box-shadow .15s ease-in-out; } input[type="text"], input[type="number"], input[type="email"], input[type="password"], textarea { width: calc(100% - 1.5rem - 2px); } label { color: #000; text-transform: uppercase; font-size: 12px; font-weight: 600; display: inline-block; margin-bottom: .5rem; } input[type="button"], input[type="submit"] { padding: 12px 16px; cursor: pointer; border: none; border-width: 1px; border-radius: 5px; font-size: 14px; font-weight: 400; box-shadow: 0 10px 20px -6px rgba(0,0,0,.12); position: relative; margin-bottom: 20px; transition: .3s; background: #46b5d1; color: #fff; display: inline-block; font-weight: 400; text-align: center; vertical-align: middle; user-select: none; padding: .375rem .75rem; font-size: 1rem; line-height: 1.5; transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out, width: auto; height: calc(1.5em + 0.75rem + 2px); padding: .375rem .75rem; } `; class PseudoForm extends HTMLElement { reportValidity() { return this[S].querySelector("form").reportValidity(); } checkValidity() { return this[S].querySelector("form").checkValidity(); } get elements() { return this[S].querySelector("form").elements; } } const fireFbReady = ()=>{ for (let c of (!0, a))c(); }; let a = []; customElements.define("form-navigation", class extends HTMLElement { static get observedAttributes() { return [ "next", "prev" ]; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`, c.querySelector("#prev").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.prev(); }), c.querySelector("#next").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.next(); }); } attributeChangedCallback(b, c, d) { if (c !== d) switch(b){ case "next": this[S].querySelector("#next").className = "hidden" === d ? "hidden" : ""; break; case "prev": this[S].querySelector("#prev").className = "hidden" === d ? "hidden" : ""; } } next() { this.dispatchEvent(new CustomEvent("form:next", { bubbles: !0, composed: !0, detail: this.parentElement })); } prev() { this.dispatchEvent(new CustomEvent("form:prev", { bubbles: !0, composed: !0, detail: this.parentElement })); } }); customElements.define("local-service", class extends HTMLElement { static get observedAttributes() { return [ "name", "service-id", "state" ]; } constructor(){ super(); let b = this[S] = this.attachShadow({ mode: "closed" }); b.innerHTML = `

`; } connectedCallback() { this[S].querySelector("#name").textContent = this.getAttribute("name"); } attributeChangedCallback(b, c, d) { if (c !== d && "name" === b) return this[S].querySelector("#name").textContent = d; } get name() { return this.getAttribute("name") || ""; } }); customElements.define("local-service-item", class extends HTMLElement { static get observedAttributes() { return [ "name", "price" ]; } constructor(){ super(); let b = this[S] = this.attachShadow({ mode: "closed" }); b.innerHTML = `

`; } connectedCallback() { this[S].querySelector("#name").textContent = this.getAttribute("name"), this[S].querySelector("#price").value = this.price(); } attributeChangedCallback(b, c, d) { if (c !== d) switch(b){ case "name": return this[S].querySelector("#name").textContent = d; case "price": return this[S].querySelector("#price").value = d; } } price(a) { let b = parseInt(a || this.getAttribute("price")); return isNaN(b) ? 0 : b; } }); customElements.define("local-services", class extends HTMLElement { static get observedAttributes() { return [ "filter" ]; } constructor(){ super(); let b = this[S] = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; { let c = b.querySelector("#filter"), d = null; c.addEventListener("change", (a)=>{ a.stopPropagation(), this.filter = a.target.value; }), c.addEventListener("keyup", (a)=>{ a.stopPropagation(); let b = a.target.value; d && clearTimeout(d), d = setTimeout(()=>{ this.filter = b, d = null; }, 1000 / 3); }); } } connectedCallback() { this.filter = this.getAttribute("filter"); } attributeChangedCallback(a, b, c) { if (b !== c && "filter" === a) return this.filter = c; } get filter() { return this.getAttribute("filter"); } set filter(a) { if (a && "" !== a) for (let b of (this.setAttribute("filter", a), this.querySelectorAll("local-service")))b.name && (b.name.includes(a) ? b.setAttribute("local-services-visible", "visible") : b.setAttribute("local-services-visible", "invisible")); else for (let c of (this.removeAttribute("filter"), this.querySelectorAll("local-service")))c.removeAttribute("local-services-visible"); } }); customElements.define("login-form", class extends HTMLElement { static get observedAttributes() { return []; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`; } connectedCallback() {} attributeChangedCallback(a, b, c) { if (b === c) return; } }); customElements.define("ow-account", class extends HTMLElement { static get observedAttributes() { return [ "mode", "id", "name", "email", "facebook-id" ]; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
Nie masz konta? Utwórz nowe
Masz konta? Zaloguj się
`, c.querySelector("#switch-login > a").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "login"; }), c.querySelector("#switch-register > a").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "register"; }); } connectedCallback() { "" === this.mode && (this.mode = "login"); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "mode": this.mode = c; break; case "id": this.id = c; break; case "name": this.name = c; break; case "email": this.email = c; break; case "facebook-id": this.facebook_id = c; } } get mode() { return this.getAttribute("mode") || ""; } set mode(a) { a = [ "login", "register", "display" ].includes(a) ? a : "login", this.setAttribute("mode", a); } get name() { return this.getAttribute("name") || ""; } set name(b) { this.setAttribute("name", b), this[S].querySelector("#display #name").value = b; } get email() { return this.getAttribute("email") || ""; } set email(b) { this.setAttribute("email", b), this[S].querySelector("#display #email").value = b; } get facebook_id() { return this.getAttribute("facebook-id"); } set facebook_id(b) { this.setAttribute("facebook-id", b), this[S].querySelector("#display #facebook_id").value = b; } }); customElements.define("ow-nav", class extends HTMLElement { constructor(){ super(); let b = this[S] = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; } }); customElements.define("ow-path", class extends HTMLElement { static get observedAttributes() { return [ "selected", "path" ]; } constructor(){ super(); let b = this[S] = this.attachShadow({ mode: "closed" }); b.innerHTML = ` `; } connectedCallback() { this.selected = this.getAttribute("selected"); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "selected": return this.selected = c; case "path": return this.path = c; } } get selected() { return "selected" === this.getAttribute("selected"); } set selected(a) { "selected" === a ? this.setAttribute("selected", "selected") : this.removeAttribute("selected"); } get path() { return this.getAttribute("path") || ""; } set path(b) { if (!b || "" === b) { this.removeAttribute("path"); return; } this.setAttribute("path", b), this[S].querySelector("a").setAttribute("href", b); } }); customElements.define("price-view", class extends HTMLElement { static get observedAttributes() { return [ "value", "currency" ]; } constructor(){ super(); let b = this[S] = this.attachShadow({ mode: "closed" }); b.innerHTML = ` `; } connectedCallback() { this[S].querySelector("#price").textContent = this.formatted; } attributeChangedCallback(a, b, c) { b !== c && "price" === a && (this.value = c); } get formatted() { let a = this.value, b = a % 100; return `${Math.ceil(a / 100)},${b < 10 ? `0${b}` : b}${this.currency}`; } get value() { let a = parseInt(this.getAttribute("value")); return isNaN(a) ? 0 : a; } set value(b) { this.setAttribute("value", b), this[S].querySelector("#price").textContent = this.formatted; } get currency() { return this.getAttribute("currency") || "PLN"; } }); customElements.define("price-input", class extends HTMLElement { static get observedAttributes() { return [ "value", "currency", "required", "name" ]; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`; let d = c.querySelector("#price"); d.addEventListener("change", (a)=>{ a.stopPropagation(), this.value = d.value; }); } connectedCallback() { this[S].querySelector("#currency").textContent = this.currency, this[S].querySelector("#price").value = this.value; } attributeChangedCallback(b, c, d) { if (c === d) return; let e = this[S].querySelector("#price"); switch(b){ case "price": this.value = d; break; case "currency": this.currency = d; break; case "required": d ? e.setAttribute("required", "required") : e.removeAttribute("required"); break; case "readonly": d ? e.setAttribute("readonly", "readonly") : e.removeAttribute("readonly"); break; case "name": this.setAttribute("name", d); } } get value() { return 100 * this[S].querySelector("#price").value; } set value(b) { this.setAttribute("value", b), this[S].querySelector("#price").value = b; } get currency() { return this.getAttribute("currency") || "PLN"; } set currency(b) { this.setAttribute("currency", b), this[S].querySelector("#currency").textContent = this.currency; } reportValidity() { return this[S].querySelector("input").reportValidity(); } get name() { return this.getAttribute("name"); } set name(a) { this.setAttribute("name", a); } }); customElements.define("register-basic-form", class extends PseudoForm { constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`; let d = c.querySelector("form"); d.addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(), c.querySelector("form-navigation").next(); }); } }); customElements.define("register-item-form-row", class extends PseudoForm { static get observedAttributes() { return [ "idx", "name" ]; } constructor(){ super(), this[S] = this.attachShadow({ mode: "closed" }), this.addEventListener("item:removed", ()=>{ this.setAttribute("removed", "removed"); let a = this.parentElement; this.remove(), a.dispatchEvent(new CustomEvent("item:removed", { bubbles: !0, composed: !0 })); }); } connectedCallback() { let c = this.getAttribute("idx"); this[S].innerHTML = `
`, this[S].querySelector("form").addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(), this.reportValidity(); }), this[S].querySelector(".remove").addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("item:removed", { bubbles: !0, composed: !1 })); }); } attributeChangedCallback(a, b, c) { b !== c && "idx" === a && this.updateNames(); } get inputs() { return [ d(this[S].querySelector(".item-name")), d(this[S].querySelector(".item-price")), ]; } updateNames() { let b = this.getAttribute("idx"); for (let c of this[S].querySelectorAll(".field")){ let d = c.id; c.querySelector("input, price-input").setAttribute("name", `items[${b}][${d}]`); } } get idx() { return this.getAttribute("idx"); } set idx(a) { this.setAttribute("idx", a); } reportValidity() { return super.reportValidity() && this[S].querySelector("price-input").reportValidity(); } }); let d = ({ name: a , value: b })=>({ name: a, value: b }); let d1 = (a)=>{ let b = 0; for (let c of a.querySelectorAll("register-item-form-row"))c.idx = b++; return b; }; customElements.define("register-items-form", class extends PseudoForm { static get observedAttributes() { return []; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`, this.addEventListener("item:removed", (a)=>{ a.stopPropagation(), d1(this); }), this.addEventListener("form:next", (a)=>{ for (let b of this.querySelectorAll("item-form-row"))b.reportValidity() || (a.stopPropagation(), a.preventDefault()); }), c.querySelector("#add-item").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.appendChild(document.createElement("register-item-form-row")), d1(this); }); } get inputs() { return [ ...this.querySelectorAll("register-item-form-row") ].map((a)=>a.inputs); } }); customElements.define("register-company-form", class extends PseudoForm { constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`, c.querySelector("form").addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(), c.querySelector("form-navigation").next(); }); } }); customElements.define("register-submit-form", class extends PseudoForm { constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`; } updateField(a, c) { this[S].querySelector(`[id="hidden-${a}"]`).value = c, this[S].querySelector(`[id="preview-${a}"]`).value = c; } setItems(a) { let c = this[S].querySelector("#items"); for (let d of (c.innerHTML = "", a)){ let e = c.appendChild(document.createElement("div")); e.className = "item-view"; let [f, g] = d; e.innerHTML = ` `; } } set accountType(a) { this[S].querySelector("#account_type").value = a; } }); customElements.define("register-user-type", class extends HTMLElement { constructor(){ super(); let a = this.attachShadow({ mode: "closed" }); a.innerHTML = `
`; let b = a.querySelector("#user"); b.addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("account:type:user", { bubbles: !0, composed: !0 })); }); let c = a.querySelector("#local-service"); c.addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("account:type:local-service", { bubbles: !0, composed: !0 })); }); } }); customElements.define("register-user-form", class extends HTMLElement { static get observedAttributes() { return [ "mode" ]; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`; let d = c.querySelector("form"); c.querySelector("#fb-icon").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "facebook", FB.login((a)=>{ "connected" === a.status && FB.api("/me?fields=id,name,email", ({ id: a , name: b , email: c , ...e })=>{ console.log(a, b, c, e), d.querySelector("#email").value = c, d.querySelector("#login").value = b, d.querySelector("#password").value = crypto.randomUUID(), d.querySelector("#facebook_id").value = a, d.submit(); }); }, { scope: "public_profile,email", return_scopes: !0 }); }), c.querySelector("#email-icon").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "email"; }); } connectedCallback() { this.mode = ""; } attributeChangedCallback(a, b, c) { b !== c && "mode" === a && ("email" === c || "facebook" === c || "" === c) && (this.mode = c); } get mode() { return this.getAttribute("mode") || ""; } set mode(a) { this.setAttribute("mode", a); } }); let c = (a, b)=>{ for (let c of (a.reportValidity(), a.elements))if ("" !== c.name && !c.reportValidity()) return !1; let d = a.inputs; if (d) b.setItems(d); else for (let e of a.elements)"" !== e.name && b.updateField(e.name, e.value); return !0; }; customElements.define("register-form", class extends HTMLElement { static get observedAttributes() { return [ "step" ]; } constructor(){ super(); let d = this[S] = this.attachShadow({ mode: "closed" }); d.innerHTML = `
`; let e = d.querySelector("#step-4"); this[S].addEventListener("account:type:user", (a)=>{ a.stopPropagation(), e.accountType = "User", this.step = 40; }), this[S].addEventListener("account:type:local-service", (a)=>{ a.stopPropagation(), e.accountType = "Business", this.step = 1; }), this[S].addEventListener("form:next", (a)=>{ a.stopPropagation(); let b = d.querySelector(`#step-${this.step}`); c(b, e) && (this.step = this.step + 1); }), this[S].addEventListener("form:prev", (a)=>{ a.stopPropagation(), this.step = this.step - 1; }), e.addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(); }); } connectedCallback() { this.step = 0; } attributeChangedCallback(a, b, c) { if (b === c) return; } get step() { let a = parseInt(this.getAttribute("step")); return isNaN(a) ? 1 : a; } set step(a) { a < 0 || this.setAttribute("step", a); } }); if (!document.querySelector("#facebook-jssdk")) { window.fbAsyncInit = ()=>{ FB.init({ appId: "1293538251053124", cookie: !0, xfbml: !0, version: "v14.0" }), FB.AppEvents.logPageView(), fireFbReady(); }; let b = document.createElement("script"); b.id = "facebook-jssdk", b.src = "https://connect.facebook.net/en_US/sdk.js", document.head.appendChild(b); }