import { n, B as BaseElement } from './base.component-813fc7cf.js';
|
import { e } from './custom-element-30fc6381.js';
|
import { i, r, x } from './query-assigned-elements-fea1f631.js';
|
import '@dh-software/furnview-icons';
|
|
var css_248z = i`:host{position:absolute;transform:translate(-50%,-50%)}`;
|
|
var __defProp = Object.defineProperty;
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
var __getProtoOf = Object.getPrototypeOf;
|
var __reflectGet = Reflect.get;
|
var __decorateClass = (decorators, target, key, kind) => {
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
if (decorator = decorators[i])
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
if (kind && result)
|
__defProp(target, key, result);
|
return result;
|
};
|
var __superStaticGet = (obj, member) => __reflectGet(__getProtoOf(obj), member, obj);
|
var __async = (__this, __arguments, generator) => {
|
return new Promise((resolve, reject) => {
|
var fulfilled = (value) => {
|
try {
|
step(generator.next(value));
|
} catch (e) {
|
reject(e);
|
}
|
};
|
var rejected = (value) => {
|
try {
|
step(generator.throw(value));
|
} catch (e) {
|
reject(e);
|
}
|
};
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
step((generator = generator.apply(__this, __arguments)).next());
|
});
|
};
|
let ExternalWidgetComponent = class extends BaseElement {
|
constructor() {
|
super(...arguments);
|
this._checkFrustum = false;
|
this._updateTimeout = 100;
|
}
|
firstUpdated(_changedProperties) {
|
super.firstUpdated(_changedProperties);
|
this.createUpdateScheduler();
|
}
|
disconnectedCallback() {
|
this.cancelUpdateScheduler();
|
super.disconnectedCallback();
|
}
|
render() {
|
return x`
|
<slot></slot>
|
`;
|
}
|
updated(_changedProperties) {
|
if (_changedProperties.has("_updateTimeout")) {
|
this.createUpdateScheduler();
|
}
|
super.updated(_changedProperties);
|
}
|
onUpdate() {
|
return __async(this, null, function* () {
|
if (this._positionVector) {
|
const position = yield CommunicationMessageService.getWidgetPosition(this._instanceIdents || [], this._positionVector, this.getBoundingClientRect());
|
if (position) {
|
this.style.top = position.y;
|
this.style.left = position.left ? position.x : "";
|
this.classList.remove("hidden");
|
if (!position.pointer && this._checkFrustum) {
|
this.classList.add("hidden");
|
}
|
}
|
}
|
});
|
}
|
createUpdateScheduler() {
|
if (this._timer) {
|
this.cancelUpdateScheduler();
|
}
|
this._timer = window.setInterval(this.onUpdate.bind(this), this._updateTimeout);
|
}
|
cancelUpdateScheduler() {
|
if (this._timer) {
|
window.clearInterval(this._timer);
|
this._timer = void 0;
|
}
|
}
|
};
|
ExternalWidgetComponent.styles = [__superStaticGet(ExternalWidgetComponent, "styles") || [], r(css_248z)];
|
__decorateClass([
|
n({ type: Array, reflect: true, attribute: "instance-idents" })
|
], ExternalWidgetComponent.prototype, "_instanceIdents", 2);
|
__decorateClass([
|
n({ type: Object, reflect: true, attribute: "position-vector" })
|
], ExternalWidgetComponent.prototype, "_positionVector", 2);
|
__decorateClass([
|
n({ type: Boolean, reflect: true, attribute: "check-frustum" })
|
], ExternalWidgetComponent.prototype, "_checkFrustum", 2);
|
__decorateClass([
|
n({ type: Number, reflect: true, attribute: "update-timeout" })
|
], ExternalWidgetComponent.prototype, "_updateTimeout", 2);
|
ExternalWidgetComponent = __decorateClass([
|
e("fv-external-widget")
|
], ExternalWidgetComponent);
|
|
export { ExternalWidgetComponent };
|