UNPKG

@realsee/dnalogel

Version:
265 lines (264 loc) 6.88 kB
import { SvelteComponent as le, init as ne, safe_not_equal as fe, append_styles as re, element as I, attr as N, set_style as y, insert as b, action_destroyer as ae, listen as C, noop as V, detach as d, run_all as ce, empty as S, space as se, text as q, append as O, set_data as U, HtmlTag as me } from "../../../vendor/svelte/internal/index.js"; import { svelteResizeObserver as ue } from "../../../shared-utils/svelte/resizeObserver.js"; function be(n) { re(n, "svelte-12pzct5", ".floorplan-plugin__room-label-item.svelte-12pzct5{position:absolute;display:flex;flex-flow:column;align-items:center;line-height:1;color:#fff;transform:translate(-50%, -50%);white-space:nowrap;will-change:opacity;transition:opacity 300ms}.floorplan-plugin__room-size.svelte-12pzct5{opacity:0.45}"); } function de(n) { let e, t = ( /*userConfigElement*/ n[8].outerHTML + "" ), l; return { c() { e = new me(!1), l = S(), e.a = l; }, m(o, i) { e.m(t, o, i), b(o, l, i); }, p(o, i) { i & /*userConfigElement*/ 256 && t !== (t = /*userConfigElement*/ o[8].outerHTML + "") && e.p(t); }, d(o) { o && d(l), o && e.d(); } }; } function _e(n) { let e, t, l = ( /*roomNameEnable*/ n[1] && j(n) ), o = ( /*roomAreaEnable*/ n[0] && M(n) ); return { c() { l && l.c(), e = se(), o && o.c(), t = S(); }, m(i, f) { l && l.m(i, f), b(i, e, f), o && o.m(i, f), b(i, t, f); }, p(i, f) { /*roomNameEnable*/ i[1] ? l ? l.p(i, f) : (l = j(i), l.c(), l.m(e.parentNode, e)) : l && (l.d(1), l = null), /*roomAreaEnable*/ i[0] ? o ? o.p(i, f) : (o = M(i), o.c(), o.m(t.parentNode, t)) : o && (o.d(1), o = null); }, d(i) { l && l.d(i), i && d(e), o && o.d(i), i && d(t); } }; } function j(n) { let e, t = ( /*room*/ n[2].name + "" ), l; return { c() { e = I("span"), l = q(t), N(e, "class", "floorplan-plugin__room-name"); }, m(o, i) { b(o, e, i), O(e, l); }, p(o, i) { i & /*room*/ 4 && t !== (t = /*room*/ o[2].name + "") && U(l, t); }, d(o) { o && d(e); } }; } function M(n) { let e, t; return { c() { e = I("span"), t = q( /*roomAreaSize*/ n[7] ), N(e, "class", "floorplan-plugin__room-size svelte-12pzct5"); }, m(l, o) { b(l, e, o), O(e, t); }, p(l, o) { o & /*roomAreaSize*/ 128 && U( t, /*roomAreaSize*/ l[7] ); }, d(l) { l && d(e); } }; } function he(n) { let e, t, l; function o(a, c) { if ( /*getLabelElement*/ a[3] === void 0 ) return _e; if ( /*userConfigElement*/ a[8] ) return de; } let i = o(n), f = i && i(n); return { c() { e = I("div"), f && f.c(), N(e, "class", "floorplan-plugin__room-label-item svelte-12pzct5"), y( e, "left", /*left*/ n[9] ), y( e, "top", /*top*/ n[10] ), y( e, "font-size", /*fontSize*/ n[11] ), y( e, "opacity", /*labelVisible*/ n[6] ? "1" : "0" ); }, m(a, c) { b(a, e, c), f && f.m(e, null), t || (l = [ ae(ue.call(null, e)), C( e, "clientWidth", /*clientWidth_handler*/ n[19] ), C( e, "clientHeight", /*clientHeight_handler*/ n[20] ) ], t = !0); }, p(a, [c]) { i === (i = o(a)) && f ? f.p(a, c) : (f && f.d(1), f = i && i(a), f && (f.c(), f.m(e, null))), c & /*labelVisible*/ 64 && y( e, "opacity", /*labelVisible*/ a[6] ? "1" : "0" ); }, i: V, o: V, d(a) { a && d(e), f && f.d(), t = !1, ce(l); } }; } function ye(n, e) { const t = n[0], l = n[1]; let o = !1; for (let i = 0, f = e.length - 1; i < e.length; f = i++) { const a = e[i][0], c = e[i][1], g = e[f][0], _ = e[f][1]; c > l != _ > l && t < (g - a) * (l - c) / (_ - c) + a && (o = !o); } return o; } function ge(n, e, t) { let l, o, i, f, a, { pxmm: c } = e, { roomAreaEnable: g } = e, { roomNameEnable: _ } = e, { room: s } = e, { hoveredRoom: z } = e, { getRoomAreaText: H } = e, { getLabelElement: h } = e, { adaptiveRoomLabelVisibleEnable: k } = e; function X(r, m) { if (m.width === 0 || m.height === 0) return () => !1; const Q = r.path.map(({ x: W, y: u }) => [W, u]), Z = r.roomLabel.position, { x, y: $ } = Z, { width: ee, height: te } = m, p = ee / 2, R = te / 2; return function(u) { const E = x * u, L = $ * u, oe = Q.map(([T, ie]) => [T * u, ie * u]); return [ [E + p, L - R], [E - p, L - R], [E - p, L + R], [E + p, L + R] ].every((T) => ye(T, oe)); }; } const Y = document.body.clientWidth, B = document.body.clientHeight, P = s.roomLabel, D = P.positionInImage.x * 100 + "%", F = P.positionInImage.y * 100 + "%", G = (Y < 500 || B < 500 ? 10 : 14) + "px"; let w = 0, A = 0, v = !1; z.subscribe(function(m) { t(16, v = !!m && m.id === s.id); }); const J = (r) => { t(4, w = r.detail); }, K = (r) => { t(5, A = r.detail); }; return n.$$set = (r) => { "pxmm" in r && t(12, c = r.pxmm), "roomAreaEnable" in r && t(0, g = r.roomAreaEnable), "roomNameEnable" in r && t(1, _ = r.roomNameEnable), "room" in r && t(2, s = r.room), "hoveredRoom" in r && t(13, z = r.hoveredRoom), "getRoomAreaText" in r && t(14, H = r.getRoomAreaText), "getLabelElement" in r && t(3, h = r.getLabelElement), "adaptiveRoomLabelVisibleEnable" in r && t(15, k = r.adaptiveRoomLabelVisibleEnable); }, n.$$.update = () => { n.$$.dirty & /*getLabelElement, room*/ 12 && t(8, l = h == null ? void 0 : h(s)), n.$$.dirty & /*room, getRoomAreaText*/ 16388 && t(7, o = s.size ? H(s.size) : ""), n.$$.dirty & /*clientWidth, clientHeight*/ 48 && t(18, i = { width: w, height: A }), n.$$.dirty & /*labelElementSize, room*/ 262148 && t(17, f = i ? X(s, i) : void 0), n.$$.dirty & /*adaptiveRoomLabelVisibleEnable, isHovered, isLabelInRoom, pxmm*/ 233472 && t(6, a = k ? v ? !0 : !!(f != null && f(c)) : !0); }, [ g, _, s, h, w, A, a, o, l, D, F, G, c, z, H, k, v, f, i, J, K ]; } class Le extends le { constructor(e) { super(), ne( this, e, ge, he, fe, { pxmm: 12, roomAreaEnable: 0, roomNameEnable: 1, room: 2, hoveredRoom: 13, getRoomAreaText: 14, getLabelElement: 3, adaptiveRoomLabelVisibleEnable: 15 }, be ); } } export { Le as RoomLabel };