From 8c27095ad1b1d5c51fd1aaf913d992b283273f0a Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Sun, 31 Dec 2023 20:43:53 +0100 Subject: [PATCH] Adding the capability of create nodes. --- js-src/conquer/index.ts | 159 ++++++++++++-- js-src/conquer/interface.ts | 5 +- js-src/conquer/interface/login.ts | 3 + js-src/conquer/interface/new-node.ts | 94 ++++++++ js-src/conquer/login.ts | 24 +- js-src/conquer/map-node.ts | 62 +++++- js-src/conquer/map-state.ts | 1 + js-src/conquer/serializer.ts | 6 + js-src/conquer/websocket.ts | 4 +- .../generated/v1/packet/open-new-node_pb.d.ts | 29 --- .../generated/v1/packet/open-new-node_pb.js | 206 ------------------ lib/BurguillosInfo.pm | 4 +- lib/BurguillosInfo/Controller/ConquerNode.pm | 135 ++++++++++++ lib/BurguillosInfo/Controller/UserConquer.pm | 49 ++++- lib/BurguillosInfo/DB/Migrations.pm | 14 ++ lib/BurguillosInfo/Schema.pm | 2 + .../Schema/Result/ConquerNode.pm | 56 +++++ .../Schema/Result/ConquerUser.pm | 24 +- package.json | 3 +- proto/v1/packet/open-new-node.proto | 8 - public/css/styles.css | 25 ++- public/css/styles.scss | 28 ++- public/js/bundle.js | 78 ++++++- templates/conquer/index.html.ep | 21 +- tsconfig.json | 2 + 25 files changed, 734 insertions(+), 308 deletions(-) create mode 100644 js-src/conquer/serializer.ts delete mode 100644 js-src/generated/v1/packet/open-new-node_pb.d.ts delete mode 100644 js-src/generated/v1/packet/open-new-node_pb.js create mode 100644 lib/BurguillosInfo/Controller/ConquerNode.pm create mode 100644 lib/BurguillosInfo/Schema/Result/ConquerNode.pm delete mode 100644 proto/v1/packet/open-new-node.proto diff --git a/js-src/conquer/index.ts b/js-src/conquer/index.ts index 88284d5..3639b57 100644 --- a/js-src/conquer/index.ts +++ b/js-src/conquer/index.ts @@ -21,6 +21,8 @@ import CreateNode from '@burguillosinfo/conquer/create-node' import MapState from '@burguillosinfo/conquer/map-state' import MapNode from '@burguillosinfo/conquer/map-node' import NewNodeUI from '@burguillosinfo/conquer/interface/new-node' +import WebSocket from '@burguillosinfo/conquer/websocket' +import JsonSerializer from '@burguillosinfo/conquer/serializer'; type StylesInterface = Record @@ -28,6 +30,7 @@ export default class Conquer { private conquerContainer: HTMLDivElement private map: Map private currentLongitude: number + private intervalSendCoordinates: number | null = null; private currentLatitude: number private rotationOffset = 0 private heading = 0 @@ -45,6 +48,8 @@ export default class Conquer { private state: MapState = MapState.NOTHING private createNodeObject: CreateNode private serverNodes: Record = {} + private coordinate_1 = 0; + private coordinate_2 = 0; public getServerNodes(): Record { return this.serverNodes @@ -78,8 +83,11 @@ export default class Conquer { const conquer = new Conquer(conquerContainer) conquer.run() } + setCenterDisplaced(lat: number, lon: number) { if (this.firstSetCenter || !(this.state & MapState.FREE_MOVE)) { + this.coordinate_1 = lon; + this.coordinate_2 = lat; const olCoordinates = this.realCoordinatesToOl(lat, lon) const size = this.map.getSize() if (size === undefined) { @@ -112,24 +120,35 @@ export default class Conquer { const feature = new Feature({ geometry: new Point(coordinates) }) - console.log(coordinates) - const style = new Style({ - image: new CircleStyle({ - radius: 14, - fill: new Fill({color: 'white'}), - stroke: new Stroke({ - color: 'gray', - width: 2, - }) - }) + const newNodeUI = new NewNodeUI(coordinates) + const oldState = this.getState(); + newNodeUI.on('close', () => { + this.interfaceManager.remove(newNodeUI) + this.setState(oldState); }) - const mapNode = new MapNode(style, feature, `server-node-${++this.createNodeCounter}`) - this.getServerNodes()[mapNode.getId()] = mapNode - this.removeState(MapState.SELECT_WHERE_TO_CREATE_NODE) - this.refreshLayers() + this.interfaceManager.push(newNodeUI) + this.setState(MapState.FILLING_FORM_CREATE_NODE); + // const style = new Style({ + // image: new CircleStyle({ + // radius: 14, + // fill: new Fill({color: 'white'}), + // stroke: new Stroke({ + // color: 'gray', + // width: 2, + // }) + // }) + // }) + // const mapNode = new MapNode(style, feature, `server-node-${++this.createNodeCounter}`) + // this.getServerNodes()[mapNode.getId()] = mapNode + // this.removeState(MapState.SELECT_WHERE_TO_CREATE_NODE) + // this.refreshLayers() } + private isStateFillingFormCreateNode(): boolean { + return !!(this.getState() & MapState.FILLING_FORM_CREATE_NODE) + } + async onClickMap(event: MapEvent): Promise { if (this.isStateCreatingNode() && this.isStateSelectWhereToCreateNode()) { this.onClickWhereToCreateNode(event) @@ -194,13 +213,89 @@ export default class Conquer { } async onLoginSuccess(): Promise { - const currentPositionFeature = this.currentPositionFeature - if (currentPositionFeature === null) { - return + this.clearIntervalSendCoordinates(); + this.createIntervalSendCoordinates(); + this.clearIntervalPollNearbyNodes(); + this.createIntervalPollNearbyNodes(); + } + + private intervalPollNearbyNodes: number | null = null; + + private clearIntervalPollNearbyNodes(): void { + if (this.intervalPollNearbyNodes !== null) { + window.clearInterval(this.intervalPollNearbyNodes) + this.intervalPollNearbyNodes = null; } - this.map.on('click', (event: MapEvent) => { - this.onClickMap(event) - }) + } + + private getNearbyNodes(): void { + const urlNodes = new URL('/conquer/node/near', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port) + fetch(urlNodes).then(async (response) => { + let responseBody; + try { + responseBody = await response.json(); + } catch (error) { + console.error('Error parseando json: ' + responseBody); + console.error(error); + return; + } + if (response.status !== 200) { + console.error(responseBody.error); + return; + } + const serverNodes: Record = {}; + const nodes = JsonSerializer.deserialize(responseBody, MapNode); + if (!(nodes instanceof Array)) { + console.error('Received null instead of node list.'); + return; + } + for (const node of nodes) { + if (!(node instanceof MapNode)) { + console.error('Received node is not a MapNode.'); + continue; + } + serverNodes[node.getId()] = node; + } + this.serverNodes = serverNodes; + this.refreshLayers(); + }); + } + + private createIntervalPollNearbyNodes(): void { + this.intervalPollNearbyNodes = window.setInterval(() => { + this.getNearbyNodes(); + }, 10000) + } + + private createIntervalSendCoordinates(): void { + this.intervalSendCoordinates = window.setInterval(() => { + this.sendCoordinatesToServer(); + }, 10000); + } + + private sendCoordinatesToServer(): void { + const urlLog = new URL('/conquer/user/coordinates', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port) + fetch(urlLog, { + method: 'POST', + body: JSON.stringify([ + this.coordinate_1, + this.coordinate_2, + ]), + }).then(async (res) => { + let responseBody; + try { + responseBody = await res.json(); + } catch(error) { + console.error('Error parseando json: ' + responseBody); + console.error(error); + return; + } + if (res.status !== 200) { + console.error(responseBody.error); + } + }).catch((error) => { + console.error(error) + }); } private runPreStartState(): void { @@ -210,12 +305,27 @@ export default class Conquer { this.interfaceManager = interfaceManager const conquerLogin = new ConquerLogin(interfaceManager) conquerLogin.on('login', () => { - this.onLoginSuccess() - }) + this.onLoginSuccess(); + }); + conquerLogin.on('logout', () => { + this.onLogout(); + }); conquerLogin.start() this.conquerLogin = conquerLogin } + private onLogout(): void { + this.clearIntervalSendCoordinates(); + this.clearIntervalPollNearbyNodes(); + } + + private clearIntervalSendCoordinates(): void { + if (this.intervalSendCoordinates !== null) { + window.clearInterval(this.intervalSendCoordinates); + this.intervalSendCoordinates = null; + } + } + async run() { this.runPreStartState() this.setState(MapState.NORMAL) @@ -286,7 +396,7 @@ export default class Conquer { this.refreshLayers() } - private refreshLayers(): void { + private async refreshLayers(): Promise { if (this.currentPositionFeature === null) { return } @@ -305,7 +415,7 @@ export default class Conquer { const features = [this.currentPositionFeature] for (const key in this.getServerNodes()) { styles[key] = this.getServerNodes()[key].getStyle() - features.push(this.getServerNodes()[key].getNode()) + features.push(this.getServerNodes()[key].getFeature()) } const vectorLayer = new VectorLayer({ source: new VectorSource({ @@ -314,6 +424,7 @@ export default class Conquer { }) if (this.vectorLayer !== null) { this.map.removeLayer(this.vectorLayer) + this.vectorLayer = null; } vectorLayer.setStyle((feature) => { return styles[feature.getProperties().type] diff --git a/js-src/conquer/interface.ts b/js-src/conquer/interface.ts index c68adb1..fb46754 100644 --- a/js-src/conquer/interface.ts +++ b/js-src/conquer/interface.ts @@ -15,12 +15,14 @@ export default abstract class ConquerInterface { public run(): void { return } + public prune(): void { + this.callbacks = {}; return } protected getNodeFromTemplateId(id: string): HTMLElement { - const template = document.getElementById(id) + let template = document.getElementById(id) if (template === null) { Conquer.fail(`Unable to find template id ${id}.`) } @@ -28,6 +30,7 @@ export default abstract class ConquerInterface { if (!(finalNode instanceof HTMLElement)) { Conquer.fail('The node is not an Element.') } + finalNode.classList.remove('conquer-display-none') return finalNode } diff --git a/js-src/conquer/interface/login.ts b/js-src/conquer/interface/login.ts index 674cbeb..bcc55d3 100644 --- a/js-src/conquer/interface/login.ts +++ b/js-src/conquer/interface/login.ts @@ -25,6 +25,9 @@ export default class LoginUI extends ConquerInterface { } public run() { + this.conquerLogin.on('login', () => { + this.runCallbacks('close'); + }); this.storeRegisterElements() this.storeLoginElements() } diff --git a/js-src/conquer/interface/new-node.ts b/js-src/conquer/interface/new-node.ts index b0793e6..9c3a3d7 100644 --- a/js-src/conquer/interface/new-node.ts +++ b/js-src/conquer/interface/new-node.ts @@ -3,8 +3,102 @@ import Conquer from '@burguillosinfo/conquer' export default class NewNodeUI extends AbstractTopBarInterface { private coordinates: number[]; + public getSubmitButton(): HTMLElement { + const submitButton = this.getMainNode().querySelector('button.new-node-form-submit') + if (submitButton === null || !(submitButton instanceof HTMLElement)) { + Conquer.fail('SubmitButton is null'); + } + return submitButton; + } + public getErrorElement(): HTMLElement { + const errorElement = this.getMainNode().querySelector('p.conquer-error'); + if (errorElement === null || !(errorElement instanceof HTMLElement)) { + Conquer.fail('No error element set'); + } + return errorElement; + } + public getSelectNodeType(): HTMLSelectElement { + const selectElement = this.getMainNode().querySelector('select.conquer-node-type'); + if (selectElement === null || !(selectElement instanceof HTMLSelectElement)) { + Conquer.fail('SelectElementNodeType is null'); + } + return selectElement + } + public getInputNodeName(): HTMLInputElement { + const nodeName = this.getMainNode().querySelector('input.conquer-node-name') + if (nodeName === null || !(nodeName instanceof HTMLInputElement)) { + Conquer.fail('NodeName is null'); + } + return nodeName + } + public getTextAreaNodeDescription(): HTMLTextAreaElement { + const nodeDescription = this.getMainNode().querySelector('textarea.conquer-node-description') + if (nodeDescription === null || !(nodeDescription instanceof HTMLTextAreaElement)) { + Conquer.fail('NodeDescription is null'); + } + return nodeDescription + } constructor(coordinates: number[]) { super() this.coordinates = coordinates } + public run() { + const mainNode = this.getMainNode() + const form = this.getNodeFromTemplateId('conquer-new-node-form-creation-template') + mainNode.append(form) + this.getSubmitButton().addEventListener('click', (event) => { + event.preventDefault(); + this.onSubmit(); + }); + form.classList.remove('conquer-display-none') + mainNode.classList.remove('conquer-display-none') + } + + private setError(error: string): void { + const errorElement = this.getErrorElement(); + errorElement.classList.remove('conquer-display-none') + errorElement.innerText = error + } + + private onSubmit(): void { + const selectNodeType = this.getSelectNodeType(); + const inputNodeName = this.getInputNodeName(); + const textAreaNodeDescription = this.getTextAreaNodeDescription(); + const description = textAreaNodeDescription.value; + const nodeName = inputNodeName.value; + const selectedOptionsNodeType = selectNodeType.selectedOptions; + if (selectedOptionsNodeType.length < 1) { + this.setError('Debes selecionar un tipo de nodo.'); + return; + } + const selectedOptionNodeType = selectedOptionsNodeType[0]; + const nodeType = selectedOptionNodeType.value; + if (nodeName.length < 5) { + this.setError('Todos los nodos deben tener un nombre mayor a 4 caracteres.'); + return; + } + const urlNode = new URL('/conquer/node', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port) + fetch(urlNode, { + method: 'PUT', + body: JSON.stringify({ + description: description, + name: nodeName, + type: nodeType, + coordinates: this.coordinates, + }), + }).then(async (res) => { + let responseBody; + try { + responseBody = await res.json(); + } catch (error) { + this.setError( 'Respuesta erronea del servidor.'); + return; + } + if (res.status !== 200) { + this.setError(responseBody.error); + return; + } + this.runCallbacks('close') + }); + } } diff --git a/js-src/conquer/login.ts b/js-src/conquer/login.ts index e23d447..8fb2c95 100644 --- a/js-src/conquer/login.ts +++ b/js-src/conquer/login.ts @@ -7,7 +7,7 @@ export type ConquerLoginEventCallback = () => void export default class Login { private conquerLogin: HTMLDivElement private conquerInterfaceManager: ConquerInterfaceManager - private cachedIsLoggedIn = true + private cachedIsLoggedIn: boolean | null = null constructor(conquerInterfaceManager: ConquerInterfaceManager) { this.conquerInterfaceManager = conquerInterfaceManager @@ -49,9 +49,16 @@ export default class Login { private async loopCheckLogin(): Promise { window.setInterval(() => { this.isLogged().then((isLogged) => { - if (!isLogged && this.cachedIsLoggedIn) { + if (isLogged) { + if (this.cachedIsLoggedIn !== true) { + this.cachedIsLoggedIn = true; + this.onLoginSuccess(); + } + return; + } + if (this.cachedIsLoggedIn !== false) { + this.cachedIsLoggedIn = false; this.onLogout() - this.cachedIsLoggedIn = false } }) }, 5000) @@ -60,6 +67,12 @@ export default class Login { private async onLogout(): Promise { const interfaceManager = this.conquerInterfaceManager const loginUI = new LoginUI(this) + for (const callback of this.callbacks.logout) { + callback(); + } + loginUI.on('close', () => { + interfaceManager.remove(loginUI); + }) interfaceManager.push(loginUI) } @@ -71,9 +84,8 @@ export default class Login { this.callbacks[name].push(callback) } - private async onLoginSuccess(loginUI: LoginUI): Promise { + private async onLoginSuccess(): Promise { this.cachedIsLoggedIn = true - this.conquerInterfaceManager.remove(loginUI) for (const callback of this.callbacks.login) { callback() } @@ -105,7 +117,7 @@ export default class Login { loginUI.unsetLoginAndRegisterErrors() const isLogged = await this.isLogged() if (isLogged) { - this.onLoginSuccess(loginUI) + this.onLoginSuccess() } } diff --git a/js-src/conquer/map-node.ts b/js-src/conquer/map-node.ts index fd5deec..4b55faa 100644 --- a/js-src/conquer/map-node.ts +++ b/js-src/conquer/map-node.ts @@ -1,28 +1,66 @@ +import { JsonObject, JsonProperty } from 'typescript-json-serializer'; import Style from 'ol/style/Style' import Feature from 'ol/Feature' +import CircleStyle from 'ol/style/Circle' +import Point from 'ol/geom/Point' +import Fill from 'ol/style/Fill' +import Stroke from 'ol/style/Stroke' +@JsonObject() export default class MapNode { - private style: Style - private node: Feature - private id: string + private feature: Feature | null = null; - constructor(style: Style, node: Feature, id: string) { - this.style = style - this.node = node.clone() - this.id = id - this.node.setProperties({type: this.id}) + + constructor( + @JsonProperty() private uuid: string, + @JsonProperty() private coordinate_1: number, + @JsonProperty() private coordinate_2: number, + @JsonProperty() private type: string, + @JsonProperty() private name: string, + @JsonProperty() private description: string, + @JsonProperty() private kind: string, + ) { + } + + public getType(): string { + return this.type; + } + + public getName(): string { + return this.name; + } + + public getDescription(): string { + return this.description; } public getId(): string { - return this.id + return 'node-' + this.uuid; } - public getNode(): Feature { - return this.node + public getFeature(): Feature { + if (this.feature === null) { + console.log(this.coordinate_1); + console.log(this.coordinate_2); + this.feature = new Feature({ + geometry: new Point([this.coordinate_1, this.coordinate_2]), + type: 'node-' + this.uuid, + }) + } + return this.feature; } public getStyle(): Style { - return this.style + return new Style({ + image: new CircleStyle({ + radius: 14, + fill: new Fill({color: 'white'}), + stroke: new Stroke({ + color: 'gray', + width: 2, + }) + }) + }); } } diff --git a/js-src/conquer/map-state.ts b/js-src/conquer/map-state.ts index 0cfc05c..b5861ff 100644 --- a/js-src/conquer/map-state.ts +++ b/js-src/conquer/map-state.ts @@ -5,6 +5,7 @@ enum MapState { FREE_ROTATION = 0x4, CREATE_NODE = 0x8, SELECT_WHERE_TO_CREATE_NODE = 0x10, + FILLING_FORM_CREATE_NODE = 0x20, } export default MapState diff --git a/js-src/conquer/serializer.ts b/js-src/conquer/serializer.ts new file mode 100644 index 0000000..c1121c0 --- /dev/null +++ b/js-src/conquer/serializer.ts @@ -0,0 +1,6 @@ +import { JsonSerializer, throwError } from 'typescript-json-serializer'; + +export default new JsonSerializer({ + errorCallback: throwError, + additionalPropertiesPolicy: 'disallow', +}); diff --git a/js-src/conquer/websocket.ts b/js-src/conquer/websocket.ts index a24c836..e7c8f86 100644 --- a/js-src/conquer/websocket.ts +++ b/js-src/conquer/websocket.ts @@ -3,7 +3,7 @@ export default class ConquerWebSocket { private socketReady = false private getWebSocket(): WebSocket { - if (this.webSocket !== null) { + if (this.webSocket !== null && this.socketReady) { return this.webSocket } this.webSocket = new WebSocket(`wss://${window.location.hostname}:${window.location.port}/conquer/websocket`) @@ -18,7 +18,7 @@ export default class ConquerWebSocket { }) return this.webSocket } - + private onSocketOpen(event: Event) { this.socketReady = true } diff --git a/js-src/generated/v1/packet/open-new-node_pb.d.ts b/js-src/generated/v1/packet/open-new-node_pb.d.ts deleted file mode 100644 index f4c2615..0000000 --- a/js-src/generated/v1/packet/open-new-node_pb.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -// package: proto.v1.packet -// file: v1/packet/open-new-node.proto - -import * as jspb from "google-protobuf"; - -export class OpenNewNode extends jspb.Message { - getLatitude(): number; - setLatitude(value: number): void; - - getLongitude(): number; - setLongitude(value: number): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): OpenNewNode.AsObject; - static toObject(includeInstance: boolean, msg: OpenNewNode): OpenNewNode.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: OpenNewNode, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): OpenNewNode; - static deserializeBinaryFromReader(message: OpenNewNode, reader: jspb.BinaryReader): OpenNewNode; -} - -export namespace OpenNewNode { - export type AsObject = { - latitude: number, - longitude: number, - } -} - diff --git a/js-src/generated/v1/packet/open-new-node_pb.js b/js-src/generated/v1/packet/open-new-node_pb.js deleted file mode 100644 index ac80fed..0000000 --- a/js-src/generated/v1/packet/open-new-node_pb.js +++ /dev/null @@ -1,206 +0,0 @@ -// source: v1/packet/open-new-node.proto -/** - * @fileoverview - * @enhanceable - * @suppress {missingRequire} reports error on implicit type usages. - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -// GENERATED CODE -- DO NOT EDIT! -/* eslint-disable */ -// @ts-nocheck - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = - (typeof globalThis !== 'undefined' && globalThis) || - (typeof window !== 'undefined' && window) || - (typeof global !== 'undefined' && global) || - (typeof self !== 'undefined' && self) || - (function () { return this; }).call(null) || - Function('return this')(); - -goog.exportSymbol('proto.proto.v1.packet.OpenNewNode', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.proto.v1.packet.OpenNewNode = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.proto.v1.packet.OpenNewNode, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.proto.v1.packet.OpenNewNode.displayName = 'proto.proto.v1.packet.OpenNewNode'; -} - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.proto.v1.packet.OpenNewNode.prototype.toObject = function(opt_includeInstance) { - return proto.proto.v1.packet.OpenNewNode.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.proto.v1.packet.OpenNewNode} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.proto.v1.packet.OpenNewNode.toObject = function(includeInstance, msg) { - var f, obj = { - latitude: jspb.Message.getFloatingPointFieldWithDefault(msg, 1, 0.0), - longitude: jspb.Message.getFloatingPointFieldWithDefault(msg, 2, 0.0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.proto.v1.packet.OpenNewNode} - */ -proto.proto.v1.packet.OpenNewNode.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.proto.v1.packet.OpenNewNode; - return proto.proto.v1.packet.OpenNewNode.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.proto.v1.packet.OpenNewNode} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.proto.v1.packet.OpenNewNode} - */ -proto.proto.v1.packet.OpenNewNode.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readDouble()); - msg.setLatitude(value); - break; - case 2: - var value = /** @type {number} */ (reader.readDouble()); - msg.setLongitude(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.proto.v1.packet.OpenNewNode.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.proto.v1.packet.OpenNewNode.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.proto.v1.packet.OpenNewNode} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.proto.v1.packet.OpenNewNode.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getLatitude(); - if (f !== 0.0) { - writer.writeDouble( - 1, - f - ); - } - f = message.getLongitude(); - if (f !== 0.0) { - writer.writeDouble( - 2, - f - ); - } -}; - - -/** - * optional double latitude = 1; - * @return {number} - */ -proto.proto.v1.packet.OpenNewNode.prototype.getLatitude = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 1, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.proto.v1.packet.OpenNewNode} returns this - */ -proto.proto.v1.packet.OpenNewNode.prototype.setLatitude = function(value) { - return jspb.Message.setProto3FloatField(this, 1, value); -}; - - -/** - * optional double longitude = 2; - * @return {number} - */ -proto.proto.v1.packet.OpenNewNode.prototype.getLongitude = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 2, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.proto.v1.packet.OpenNewNode} returns this - */ -proto.proto.v1.packet.OpenNewNode.prototype.setLongitude = function(value) { - return jspb.Message.setProto3FloatField(this, 2, value); -}; - - -goog.object.extend(exports, proto.proto.v1.packet); diff --git a/lib/BurguillosInfo.pm b/lib/BurguillosInfo.pm index 226262f..dfd8fd2 100644 --- a/lib/BurguillosInfo.pm +++ b/lib/BurguillosInfo.pm @@ -88,10 +88,12 @@ sub startup ($self) { $r->get('/sitemap.xml')->to('Sitemap#sitemap'); $r->get('/robots.txt')->to('Robots#robots'); - # $r->get('/:post')->to('Page#post'); $r->get('/stats')->to('Metrics#stats'); $r->get('/conquer')->to('Conquer#index'); $r->put('/conquer/user')->to('UserConquer#create'); + $r->post('/conquer/user/coordinates')->to('UserConquer#setCoordinates'); + $r->put('/conquer/node')->to('ConquerNode#create'); + $r->get('/conquer/node/near')->to('ConquerNode#nearbyNodes'); $r->get('/conquer/user')->to('UserConquer#get_self'); $r->post('/conquer/user/login')->to('UserConquer#login'); $r->get('/conquer/tile///.png')->to('ConquerTile#tile'); diff --git a/lib/BurguillosInfo/Controller/ConquerNode.pm b/lib/BurguillosInfo/Controller/ConquerNode.pm new file mode 100644 index 0000000..7bee3c2 --- /dev/null +++ b/lib/BurguillosInfo/Controller/ConquerNode.pm @@ -0,0 +1,135 @@ +package BurguillosInfo::Controller::ConquerNode; + +use v5.34.1; + +use strict; +use warnings; + +use utf8; + +use Mojo::Base 'Mojolicious::Controller', '-signatures'; +use UUID::URandom qw/create_uuid_string/; + +sub create ($self) { + my $user = $self->current_user; + if ( !defined $user ) { + return $self->render( + status => 401, + json => { + error => 'No estás autenticado.', + } + ); + } + if ( !$user->is_admin ) { + return $self->render( + status => 403, + json => { + error => 'No tienes permiso para hacer eso.', + } + ); + } + my $input = $self->_expectJson; + if ( !defined $input ) { + return; + } + my $name = $input->{name}; + my $coordinates = $input->{coordinates}; + my $type = $input->{type}; + my $description = $input->{description}; + if ( ref $coordinates ne 'ARRAY' || scalar $coordinates->@* != 2 ) { + return $self->render( + status => 400, + json => { + error => 'Formato erroneo de coordenadas.', + } + ); + } + my ($coordinate_1, $coordinate_2) = $coordinates->@*; + if ( !defined $name && length $name < 5 ) { + return $self->render( + status => 400, + json => { + error => + 'Número incorrecto de carácteres en el nombre del nodo.', + } + ); + } + if ( !defined $description ) { + return $self->render( + status => 400, + json => { + error => 'La descripción puede estar vacía, ' + . 'pero debe existir, si ves este error ' + . 'desde la aplicación es un error de programación.', + } + ); + } + if ( !defined $type ) { + return $self->render( + status => 400, + json => { + error => 'Los nodos deben tener un tipo.' + } + ); + } + if ( $type ne 'normal' ) { + return $self->render( + status => 400, + json => { + error => 'Tipo de nodo no soportado.', + } + ); + } + my $uuid_node = create_uuid_string(); + my $node; + eval { + $node = BurguillosInfo::Schema->Schema->resultset('ConquerNode')->new( + { + uuid => $uuid_node, + description => $description, + name => $name, + type => $type, + coordinate_1 => $coordinate_1, + coordinate_2 => $coordinate_2 + } + ); + $node->insert; + }; + if ($@) { + warn $@; + return $self->render( + status => 500, + json => { + error => 'El servidor no pudo almacenar el nodo, reporta este error.', + } + ); + } + return $self->render( + status => 200, + json => $node->serialize, + ); +} + +sub nearbyNodes($self) { + my $user = $self->current_user; + if (!defined $user) { + return $self->render(status => 401, json => { + error => 'No estás loggeado.', + }); + } + my @nodes = BurguillosInfo::Schema->Schema->resultset('ConquerNode')->search({}); + @nodes = map { $_->serialize } @nodes; + return $self->render(json => \@nodes); +} + +sub _expectJson ($self) { + my $input; + eval { $input = $self->req->json; }; + if ($@) { + say STDERR $@; + $self->_renderError( 400, 'Se esperaba JSON.' ); + return; + } + return $input; +} +1; diff --git a/lib/BurguillosInfo/Controller/UserConquer.pm b/lib/BurguillosInfo/Controller/UserConquer.pm index 73d954a..3ac3d1a 100644 --- a/lib/BurguillosInfo/Controller/UserConquer.pm +++ b/lib/BurguillosInfo/Controller/UserConquer.pm @@ -21,12 +21,12 @@ my $username_maximum_chars = 15; my $password_minimum_chars = 8; my $password_maximum_chars = 4096; -sub get_self($self) { +sub get_self ($self) { my $user = $self->current_user; - if (!defined $user) { - return $self->_renderError(401, 'No estás loggeado.'); + if ( !defined $user ) { + return $self->_renderError( 401, 'No estás loggeado.' ); } - return $self->render(json => $user->serialize_to_owner, status => 200); + return $self->render( json => $user->serialize_to_owner, status => 200 ); } sub create ($self) { @@ -47,7 +47,7 @@ sub _expectJson ($self) { eval { $input = $self->req->json; }; if ($@) { say STDERR $@; - $self->_renderError(400, 'Se esperaba JSON.'); + $self->_renderError( 400, 'Se esperaba JSON.' ); return; } return $input; @@ -66,8 +66,8 @@ sub login ($self) { my @tentative_users = $resultset_conquer_user->search( { username => $username } ); my $tentative_user = $tentative_users[0]; - if (!defined $tentative_user) { - $self->_renderError(401, 'El usuario especificado no existe.'); + if ( !defined $tentative_user ) { + $self->_renderError( 401, 'El usuario especificado no existe.' ); return; } if ( !bcrypt_check( $password, $tentative_user->encrypted_password ) ) { @@ -84,6 +84,40 @@ sub login ($self) { ); } +sub setCoordinates ($self) { + my $input = $self->_expectJson; + my $user = $self->current_user; + if ( !defined $user ) { + return $self->render( + status => 401, + json => { + error => 'Debes estar loggeado para cambiar tus' + . ' coordenadas.', + } + ); + } + if ( !defined $input ) { + return; + } + if ( ref $input ne 'ARRAY' && scalar $input->@* == 2 ) { + return $self->render( + status => 400, + json => { + error => 'Mal formato de coordenadas, debe ser ' + . 'un array de exactamente 2 números reales.', + } + ); + } + $user->coordinates($input); + $user->update; + return $self->render( + status => 200, + json => { + ok => $JSON::true, + } + ); +} + sub _createUser ( $self, $username, $password ) { my $user; my $uuid = create_uuid_string(); @@ -97,6 +131,7 @@ sub _createUser ( $self, $username, $password ) { username => $username } ); + $user->coordinates( [ 0, 0 ] ); $user->insert; }; if ($@) { diff --git a/lib/BurguillosInfo/DB/Migrations.pm b/lib/BurguillosInfo/DB/Migrations.pm index e2c26a8..ff5677e 100644 --- a/lib/BurguillosInfo/DB/Migrations.pm +++ b/lib/BurguillosInfo/DB/Migrations.pm @@ -57,6 +57,20 @@ sub MIGRATIONS { is_admin BOOLEAN NOT NULL DEFAULT false, registration_date TIMESTAMP NOT NULL DEFAULT NOW() );', + 'CREATE TABLE conquer_node ( + uuid UUID NOT NULL PRIMARY KEY, + name TEXT NOT NULL, + type TEXT NOT NULL, + coordinate_1 REAL NOT NULL, + coordinate_2 REAL NOT NULL, + description TEXT NOT NULL + );', + 'CREATE INDEX index_conquer_node_coordinate_1 on conquer_node (coordinate_1);', + 'CREATE INDEX index_conquer_node_coordinate_2 on conquer_node (coordinate_2);', + 'ALTER TABLE conquer_user ADD COLUMN last_coordinate_1 REAL NOT NULL DEFAULT 0;', + 'ALTER TABLE conquer_user ALTER COLUMN last_coordinate_1 DROP DEFAULT;', + 'ALTER TABLE conquer_user ADD COLUMN last_coordinate_2 REAL NOT NULL DEFAULT 0;', + 'ALTER TABLE conquer_user ALTER COLUMN last_coordinate_2 DROP DEFAULT;', ); } diff --git a/lib/BurguillosInfo/Schema.pm b/lib/BurguillosInfo/Schema.pm index 1a772cf..acb62bb 100644 --- a/lib/BurguillosInfo/Schema.pm +++ b/lib/BurguillosInfo/Schema.pm @@ -20,6 +20,8 @@ my $schema; sub Schema ($class) { if ( !defined $schema ) { + use BurguillosInfo::DB; + BurguillosInfo::DB->connect; my $app = BurguillosInfo->new; my $config = $app->{config}; my $database_config = $config->{db}; diff --git a/lib/BurguillosInfo/Schema/Result/ConquerNode.pm b/lib/BurguillosInfo/Schema/Result/ConquerNode.pm new file mode 100644 index 0000000..6b05b16 --- /dev/null +++ b/lib/BurguillosInfo/Schema/Result/ConquerNode.pm @@ -0,0 +1,56 @@ +package BurguillosInfo::Schema::Result::ConquerNode; + +use v5.36.0; + +use strict; +use warnings; + +use parent 'DBIx::Class::Core'; + +use feature 'signatures'; + +__PACKAGE__->table('conquer_node'); +__PACKAGE__->load_components("TimeStamp"); + +__PACKAGE__->add_columns( + uuid => { + data_type => 'uuid', + is_nullable => 0, + }, + name => { + data_type => 'text', + is_nullable => 0, + default_value => \'0', + }, + coordinate_1 => { + data_type => 'real', + is_nullable => 0, + }, + coordinate_2 => { + data_type => 'real', + is_nullable => 0, + }, + type => { + data_type => 'text', + is_nullable => 0, + }, + description => { + data_type => 'text', + is_nullable => 0, + } +); + +sub serialize ($self) { + $self = $self->get_from_storage(); + return { + kind => 'ConquerNode', + uuid => $self->uuid, + name => $self->name, + description => $self->description, + type => $self->type, + coordinate_1 => $self->coordinate_1, + coordinate_2 => $self->coordinate_2, + }; +} +__PACKAGE__->set_primary_key('uuid'); +1; diff --git a/lib/BurguillosInfo/Schema/Result/ConquerUser.pm b/lib/BurguillosInfo/Schema/Result/ConquerUser.pm index 6354b5d..0d74832 100644 --- a/lib/BurguillosInfo/Schema/Result/ConquerUser.pm +++ b/lib/BurguillosInfo/Schema/Result/ConquerUser.pm @@ -39,9 +39,31 @@ __PACKAGE__->add_columns( data_type => 'boolean', is_nullable => 0, default_value => \'0', - } + }, + last_coordinate_1 => { + data_type => 'real', + is_nullable => 0, + default_value => \'0', + }, + last_coordinate_2 => { + data_type => 'real', + is_nullable => 0, + default_value => \'0', + }, ); +sub coordinates($self, $coordinates = undef) { + if (defined $coordinates) { + if (ref $coordinates ne 'ARRAY' || scalar $coordinates->@* != 2) { + die 'The second parameter of this subroutine ' + . 'must be an ARRAYREF of exactly two elements.'; + } + $self->last_coordinate_1($coordinates->[0]); + $self->last_coordinate_2($coordinates->[1]); + } + return [$self->last_coordinate_1, $self->last_coordinate_2]; +} + sub serialize_to_owner ($self) { $self = $self->get_from_storage(); return { diff --git a/package.json b/package.json index a83cf99..55a81f7 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "protoc-gen-js": "^3.21.2", "tablesort": "^5.3.0", "ts-loader": "^9.5.0", - "ts-protoc-gen": "^0.15.0" + "ts-protoc-gen": "^0.15.0", + "typescript-json-serializer": "^6.0.1" } } diff --git a/proto/v1/packet/open-new-node.proto b/proto/v1/packet/open-new-node.proto deleted file mode 100644 index 9eac479..0000000 --- a/proto/v1/packet/open-new-node.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -package proto.v1.packet; - -message OpenNewNode { - double latitude = 1; - double longitude = 2; -} diff --git a/public/css/styles.css b/public/css/styles.css index 9652173..d1b59a4 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -9,20 +9,41 @@ body { min-height: 100%; width: 100%; height: 100%; } - body p.conquer-register-error, body p.conquer-login-error, body p.conquer-login-success { + body p.conquer-register-error, body p.conquer-login-error, body p.conquer-login-success, body p.conquer-error { color: red; margin: 3px; font-size: 1.3rem; background: blanchedalmond; padding: 3px; border-radius: 10px; - border: solid 1px black; } + border: solid 1px black; + overflow-y: scroll; } + body form { + display: flex; + flex-direction: column; + width: 100%; } + body form label { + width: 100%; } + body form label input, body form label textarea, body form label select { + width: 100%; + border: none; + background-image: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + background: white; + box-shadow: none; + min-height: 2rem; + border-radius: 0.5rem; } + body form label textarea { + height: 100px; } body div.conquer-interface-element-padded { width: calc(100% - 60px); padding-left: 30px; padding-right: 30px; display: flex; justify-content: center; } + body div.conquer-interface-element-padded.conquer-display-none { + display: none; } body div.create-node-slide { display: flex; position: fixed; diff --git a/public/css/styles.scss b/public/css/styles.scss index 4116a26..544bc38 100644 --- a/public/css/styles.scss +++ b/public/css/styles.scss @@ -17,7 +17,7 @@ html { } body { - p.conquer-register-error, p.conquer-login-error, p.conquer-login-success { + p.conquer-register-error, p.conquer-login-error, p.conquer-login-success,p.conquer-error { color: red; margin: 3px; font-size: 1.3rem; @@ -25,6 +25,29 @@ body { padding: 3px; border-radius: 10px; border: solid 1px black; + overflow-y: scroll; + } + form { + display: flex; + flex-direction: column; + width: 100%; + label { + width: 100%; + input, textarea, select { + width: 100%; + border:none; + background-image:none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + background: white; + box-shadow: none; + min-height: 2rem; + border-radius: 0.5rem; + } + textarea { + height: 100px; + } + } } div.conquer-interface-element-padded { width: calc(100% - 60px); @@ -32,6 +55,9 @@ body { padding-right: 30px; display: flex; justify-content: center; + &.conquer-display-none { + display: none; + } } div.create-node-slide { display: flex; diff --git a/public/js/bundle.js b/public/js/bundle.js index 9d6b603..e8678d0 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -30,6 +30,16 @@ eval("!function(t,i){ true?module.exports=i():0}(this,function(){\"use strict\"; /***/ }), +/***/ "./node_modules/reflect-metadata/Reflect.js": +/*!**************************************************!*\ + !*** ./node_modules/reflect-metadata/Reflect.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { + +eval("/*! *****************************************************************************\nCopyright (C) Microsoft. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\nvar Reflect;\n(function (Reflect) {\n // Metadata Proposal\n // https://rbuckton.github.io/reflect-metadata/\n (function (factory) {\n var root = typeof __webpack_require__.g === \"object\" ? __webpack_require__.g :\n typeof self === \"object\" ? self :\n typeof this === \"object\" ? this :\n Function(\"return this;\")();\n var exporter = makeExporter(Reflect);\n if (typeof root.Reflect === \"undefined\") {\n root.Reflect = Reflect;\n }\n else {\n exporter = makeExporter(root.Reflect, exporter);\n }\n factory(exporter);\n function makeExporter(target, previous) {\n return function (key, value) {\n if (typeof target[key] !== \"function\") {\n Object.defineProperty(target, key, { configurable: true, writable: true, value: value });\n }\n if (previous)\n previous(key, value);\n };\n }\n })(function (exporter) {\n var hasOwn = Object.prototype.hasOwnProperty;\n // feature test for Symbol support\n var supportsSymbol = typeof Symbol === \"function\";\n var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== \"undefined\" ? Symbol.toPrimitive : \"@@toPrimitive\";\n var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== \"undefined\" ? Symbol.iterator : \"@@iterator\";\n var supportsCreate = typeof Object.create === \"function\"; // feature test for Object.create support\n var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support\n var downLevel = !supportsCreate && !supportsProto;\n var HashMap = {\n // create an object in dictionary mode (a.k.a. \"slow\" mode in v8)\n create: supportsCreate\n ? function () { return MakeDictionary(Object.create(null)); }\n : supportsProto\n ? function () { return MakeDictionary({ __proto__: null }); }\n : function () { return MakeDictionary({}); },\n has: downLevel\n ? function (map, key) { return hasOwn.call(map, key); }\n : function (map, key) { return key in map; },\n get: downLevel\n ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; }\n : function (map, key) { return map[key]; },\n };\n // Load global or shim versions of Map, Set, and WeakMap\n var functionPrototype = Object.getPrototypeOf(Function);\n var usePolyfill = typeof process === \"object\" && process[\"env\" + \"\"] && process[\"env\" + \"\"][\"REFLECT_METADATA_USE_MAP_POLYFILL\"] === \"true\";\n var _Map = !usePolyfill && typeof Map === \"function\" && typeof Map.prototype.entries === \"function\" ? Map : CreateMapPolyfill();\n var _Set = !usePolyfill && typeof Set === \"function\" && typeof Set.prototype.entries === \"function\" ? Set : CreateSetPolyfill();\n var _WeakMap = !usePolyfill && typeof WeakMap === \"function\" ? WeakMap : CreateWeakMapPolyfill();\n // [[Metadata]] internal slot\n // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots\n var Metadata = new _WeakMap();\n /**\n * Applies a set of decorators to a property of a target object.\n * @param decorators An array of decorators.\n * @param target The target object.\n * @param propertyKey (Optional) The property key to decorate.\n * @param attributes (Optional) The property descriptor for the target key.\n * @remarks Decorators are applied in reverse order.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Example = Reflect.decorate(decoratorsArray, Example);\n *\n * // property (on constructor)\n * Reflect.decorate(decoratorsArray, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.decorate(decoratorsArray, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Object.defineProperty(Example, \"staticMethod\",\n * Reflect.decorate(decoratorsArray, Example, \"staticMethod\",\n * Object.getOwnPropertyDescriptor(Example, \"staticMethod\")));\n *\n * // method (on prototype)\n * Object.defineProperty(Example.prototype, \"method\",\n * Reflect.decorate(decoratorsArray, Example.prototype, \"method\",\n * Object.getOwnPropertyDescriptor(Example.prototype, \"method\")));\n *\n */\n function decorate(decorators, target, propertyKey, attributes) {\n if (!IsUndefined(propertyKey)) {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsObject(target))\n throw new TypeError();\n if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))\n throw new TypeError();\n if (IsNull(attributes))\n attributes = undefined;\n propertyKey = ToPropertyKey(propertyKey);\n return DecorateProperty(decorators, target, propertyKey, attributes);\n }\n else {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsConstructor(target))\n throw new TypeError();\n return DecorateConstructor(decorators, target);\n }\n }\n exporter(\"decorate\", decorate);\n // 4.1.2 Reflect.metadata(metadataKey, metadataValue)\n // https://rbuckton.github.io/reflect-metadata/#reflect.metadata\n /**\n * A default metadata decorator factory that can be used on a class, class member, or parameter.\n * @param metadataKey The key for the metadata entry.\n * @param metadataValue The value for the metadata entry.\n * @returns A decorator function.\n * @remarks\n * If `metadataKey` is already defined for the target and target key, the\n * metadataValue for that key will be overwritten.\n * @example\n *\n * // constructor\n * @Reflect.metadata(key, value)\n * class Example {\n * }\n *\n * // property (on constructor, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticProperty;\n * }\n *\n * // property (on prototype, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * property;\n * }\n *\n * // method (on constructor)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticMethod() { }\n * }\n *\n * // method (on prototype)\n * class Example {\n * @Reflect.metadata(key, value)\n * method() { }\n * }\n *\n */\n function metadata(metadataKey, metadataValue) {\n function decorator(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))\n throw new TypeError();\n OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n return decorator;\n }\n exporter(\"metadata\", metadata);\n /**\n * Define a unique metadata entry on the target.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param metadataValue A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey (Optional) The property key for the target.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): Decorator {\n * return (target, key?) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n *\n */\n function defineMetadata(metadataKey, metadataValue, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n exporter(\"defineMetadata\", defineMetadata);\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasMetadata\", hasMetadata);\n /**\n * Gets a value indicating whether the target object has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasOwnMetadata\", hasOwnMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getMetadata\", getMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getOwnMetadata\", getOwnMetadata);\n /**\n * Gets the metadata keys defined on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryMetadataKeys(target, propertyKey);\n }\n exporter(\"getMetadataKeys\", getMetadataKeys);\n /**\n * Gets the unique metadata keys defined on the target object.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getOwnMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryOwnMetadataKeys(target, propertyKey);\n }\n exporter(\"getOwnMetadataKeys\", getOwnMetadataKeys);\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function deleteMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n var metadataMap = GetOrCreateMetadataMap(target, propertyKey, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n if (!metadataMap.delete(metadataKey))\n return false;\n if (metadataMap.size > 0)\n return true;\n var targetMetadata = Metadata.get(target);\n targetMetadata.delete(propertyKey);\n if (targetMetadata.size > 0)\n return true;\n Metadata.delete(target);\n return true;\n }\n exporter(\"deleteMetadata\", deleteMetadata);\n function DecorateConstructor(decorators, target) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsConstructor(decorated))\n throw new TypeError();\n target = decorated;\n }\n }\n return target;\n }\n function DecorateProperty(decorators, target, propertyKey, descriptor) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target, propertyKey, descriptor);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsObject(decorated))\n throw new TypeError();\n descriptor = decorated;\n }\n }\n return descriptor;\n }\n function GetOrCreateMetadataMap(O, P, Create) {\n var targetMetadata = Metadata.get(O);\n if (IsUndefined(targetMetadata)) {\n if (!Create)\n return undefined;\n targetMetadata = new _Map();\n Metadata.set(O, targetMetadata);\n }\n var metadataMap = targetMetadata.get(P);\n if (IsUndefined(metadataMap)) {\n if (!Create)\n return undefined;\n metadataMap = new _Map();\n targetMetadata.set(P, metadataMap);\n }\n return metadataMap;\n }\n // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata\n function OrdinaryHasMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return true;\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryHasMetadata(MetadataKey, parent, P);\n return false;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n return ToBoolean(metadataMap.has(MetadataKey));\n }\n // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata\n function OrdinaryGetMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return OrdinaryGetOwnMetadata(MetadataKey, O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryGetMetadata(MetadataKey, parent, P);\n return undefined;\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return undefined;\n return metadataMap.get(MetadataKey);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true);\n metadataMap.set(MetadataKey, MetadataValue);\n }\n // 3.1.6.1 OrdinaryMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys\n function OrdinaryMetadataKeys(O, P) {\n var ownKeys = OrdinaryOwnMetadataKeys(O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (parent === null)\n return ownKeys;\n var parentKeys = OrdinaryMetadataKeys(parent, P);\n if (parentKeys.length <= 0)\n return ownKeys;\n if (ownKeys.length <= 0)\n return parentKeys;\n var set = new _Set();\n var keys = [];\n for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {\n var key = ownKeys_1[_i];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {\n var key = parentKeys_1[_a];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n return keys;\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var keys = [];\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return keys;\n var keysObj = metadataMap.keys();\n var iterator = GetIterator(keysObj);\n var k = 0;\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n keys.length = k;\n return keys;\n }\n var nextValue = IteratorValue(next);\n try {\n keys[k] = nextValue;\n }\n catch (e) {\n try {\n IteratorClose(iterator);\n }\n finally {\n throw e;\n }\n }\n k++;\n }\n }\n // 6 ECMAScript Data Typ0es and Values\n // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values\n function Type(x) {\n if (x === null)\n return 1 /* Null */;\n switch (typeof x) {\n case \"undefined\": return 0 /* Undefined */;\n case \"boolean\": return 2 /* Boolean */;\n case \"string\": return 3 /* String */;\n case \"symbol\": return 4 /* Symbol */;\n case \"number\": return 5 /* Number */;\n case \"object\": return x === null ? 1 /* Null */ : 6 /* Object */;\n default: return 6 /* Object */;\n }\n }\n // 6.1.1 The Undefined Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type\n function IsUndefined(x) {\n return x === undefined;\n }\n // 6.1.2 The Null Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type\n function IsNull(x) {\n return x === null;\n }\n // 6.1.5 The Symbol Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type\n function IsSymbol(x) {\n return typeof x === \"symbol\";\n }\n // 6.1.7 The Object Type\n // https://tc39.github.io/ecma262/#sec-object-type\n function IsObject(x) {\n return typeof x === \"object\" ? x !== null : typeof x === \"function\";\n }\n // 7.1 Type Conversion\n // https://tc39.github.io/ecma262/#sec-type-conversion\n // 7.1.1 ToPrimitive(input [, PreferredType])\n // https://tc39.github.io/ecma262/#sec-toprimitive\n function ToPrimitive(input, PreferredType) {\n switch (Type(input)) {\n case 0 /* Undefined */: return input;\n case 1 /* Null */: return input;\n case 2 /* Boolean */: return input;\n case 3 /* String */: return input;\n case 4 /* Symbol */: return input;\n case 5 /* Number */: return input;\n }\n var hint = PreferredType === 3 /* String */ ? \"string\" : PreferredType === 5 /* Number */ ? \"number\" : \"default\";\n var exoticToPrim = GetMethod(input, toPrimitiveSymbol);\n if (exoticToPrim !== undefined) {\n var result = exoticToPrim.call(input, hint);\n if (IsObject(result))\n throw new TypeError();\n return result;\n }\n return OrdinaryToPrimitive(input, hint === \"default\" ? \"number\" : hint);\n }\n // 7.1.1.1 OrdinaryToPrimitive(O, hint)\n // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive\n function OrdinaryToPrimitive(O, hint) {\n if (hint === \"string\") {\n var toString_1 = O.toString;\n if (IsCallable(toString_1)) {\n var result = toString_1.call(O);\n if (!IsObject(result))\n return result;\n }\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n else {\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n var toString_2 = O.toString;\n if (IsCallable(toString_2)) {\n var result = toString_2.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n throw new TypeError();\n }\n // 7.1.2 ToBoolean(argument)\n // https://tc39.github.io/ecma262/2016/#sec-toboolean\n function ToBoolean(argument) {\n return !!argument;\n }\n // 7.1.12 ToString(argument)\n // https://tc39.github.io/ecma262/#sec-tostring\n function ToString(argument) {\n return \"\" + argument;\n }\n // 7.1.14 ToPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-topropertykey\n function ToPropertyKey(argument) {\n var key = ToPrimitive(argument, 3 /* String */);\n if (IsSymbol(key))\n return key;\n return ToString(key);\n }\n // 7.2 Testing and Comparison Operations\n // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations\n // 7.2.2 IsArray(argument)\n // https://tc39.github.io/ecma262/#sec-isarray\n function IsArray(argument) {\n return Array.isArray\n ? Array.isArray(argument)\n : argument instanceof Object\n ? argument instanceof Array\n : Object.prototype.toString.call(argument) === \"[object Array]\";\n }\n // 7.2.3 IsCallable(argument)\n // https://tc39.github.io/ecma262/#sec-iscallable\n function IsCallable(argument) {\n // NOTE: This is an approximation as we cannot check for [[Call]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.4 IsConstructor(argument)\n // https://tc39.github.io/ecma262/#sec-isconstructor\n function IsConstructor(argument) {\n // NOTE: This is an approximation as we cannot check for [[Construct]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.7 IsPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-ispropertykey\n function IsPropertyKey(argument) {\n switch (Type(argument)) {\n case 3 /* String */: return true;\n case 4 /* Symbol */: return true;\n default: return false;\n }\n }\n // 7.3 Operations on Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-objects\n // 7.3.9 GetMethod(V, P)\n // https://tc39.github.io/ecma262/#sec-getmethod\n function GetMethod(V, P) {\n var func = V[P];\n if (func === undefined || func === null)\n return undefined;\n if (!IsCallable(func))\n throw new TypeError();\n return func;\n }\n // 7.4 Operations on Iterator Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects\n function GetIterator(obj) {\n var method = GetMethod(obj, iteratorSymbol);\n if (!IsCallable(method))\n throw new TypeError(); // from Call\n var iterator = method.call(obj);\n if (!IsObject(iterator))\n throw new TypeError();\n return iterator;\n }\n // 7.4.4 IteratorValue(iterResult)\n // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue\n function IteratorValue(iterResult) {\n return iterResult.value;\n }\n // 7.4.5 IteratorStep(iterator)\n // https://tc39.github.io/ecma262/#sec-iteratorstep\n function IteratorStep(iterator) {\n var result = iterator.next();\n return result.done ? false : result;\n }\n // 7.4.6 IteratorClose(iterator, completion)\n // https://tc39.github.io/ecma262/#sec-iteratorclose\n function IteratorClose(iterator) {\n var f = iterator[\"return\"];\n if (f)\n f.call(iterator);\n }\n // 9.1 Ordinary Object Internal Methods and Internal Slots\n // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\n // 9.1.1.1 OrdinaryGetPrototypeOf(O)\n // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof\n function OrdinaryGetPrototypeOf(O) {\n var proto = Object.getPrototypeOf(O);\n if (typeof O !== \"function\" || O === functionPrototype)\n return proto;\n // TypeScript doesn't set __proto__ in ES5, as it's non-standard.\n // Try to determine the superclass constructor. Compatible implementations\n // must either set __proto__ on a subclass constructor to the superclass constructor,\n // or ensure each class has a valid `constructor` property on its prototype that\n // points back to the constructor.\n // If this is not the same as Function.[[Prototype]], then this is definately inherited.\n // This is the case when in ES6 or when using __proto__ in a compatible browser.\n if (proto !== functionPrototype)\n return proto;\n // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.\n var prototype = O.prototype;\n var prototypeProto = prototype && Object.getPrototypeOf(prototype);\n if (prototypeProto == null || prototypeProto === Object.prototype)\n return proto;\n // If the constructor was not a function, then we cannot determine the heritage.\n var constructor = prototypeProto.constructor;\n if (typeof constructor !== \"function\")\n return proto;\n // If we have some kind of self-reference, then we cannot determine the heritage.\n if (constructor === O)\n return proto;\n // we have a pretty good guess at the heritage.\n return constructor;\n }\n // naive Map shim\n function CreateMapPolyfill() {\n var cacheSentinel = {};\n var arraySentinel = [];\n var MapIterator = /** @class */ (function () {\n function MapIterator(keys, values, selector) {\n this._index = 0;\n this._keys = keys;\n this._values = values;\n this._selector = selector;\n }\n MapIterator.prototype[\"@@iterator\"] = function () { return this; };\n MapIterator.prototype[iteratorSymbol] = function () { return this; };\n MapIterator.prototype.next = function () {\n var index = this._index;\n if (index >= 0 && index < this._keys.length) {\n var result = this._selector(this._keys[index], this._values[index]);\n if (index + 1 >= this._keys.length) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n else {\n this._index++;\n }\n return { value: result, done: false };\n }\n return { value: undefined, done: true };\n };\n MapIterator.prototype.throw = function (error) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n throw error;\n };\n MapIterator.prototype.return = function (value) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n return { value: value, done: true };\n };\n return MapIterator;\n }());\n return /** @class */ (function () {\n function Map() {\n this._keys = [];\n this._values = [];\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n Object.defineProperty(Map.prototype, \"size\", {\n get: function () { return this._keys.length; },\n enumerable: true,\n configurable: true\n });\n Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };\n Map.prototype.get = function (key) {\n var index = this._find(key, /*insert*/ false);\n return index >= 0 ? this._values[index] : undefined;\n };\n Map.prototype.set = function (key, value) {\n var index = this._find(key, /*insert*/ true);\n this._values[index] = value;\n return this;\n };\n Map.prototype.delete = function (key) {\n var index = this._find(key, /*insert*/ false);\n if (index >= 0) {\n var size = this._keys.length;\n for (var i = index + 1; i < size; i++) {\n this._keys[i - 1] = this._keys[i];\n this._values[i - 1] = this._values[i];\n }\n this._keys.length--;\n this._values.length--;\n if (key === this._cacheKey) {\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n return true;\n }\n return false;\n };\n Map.prototype.clear = function () {\n this._keys.length = 0;\n this._values.length = 0;\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n };\n Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };\n Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };\n Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };\n Map.prototype[\"@@iterator\"] = function () { return this.entries(); };\n Map.prototype[iteratorSymbol] = function () { return this.entries(); };\n Map.prototype._find = function (key, insert) {\n if (this._cacheKey !== key) {\n this._cacheIndex = this._keys.indexOf(this._cacheKey = key);\n }\n if (this._cacheIndex < 0 && insert) {\n this._cacheIndex = this._keys.length;\n this._keys.push(key);\n this._values.push(undefined);\n }\n return this._cacheIndex;\n };\n return Map;\n }());\n function getKey(key, _) {\n return key;\n }\n function getValue(_, value) {\n return value;\n }\n function getEntry(key, value) {\n return [key, value];\n }\n }\n // naive Set shim\n function CreateSetPolyfill() {\n return /** @class */ (function () {\n function Set() {\n this._map = new _Map();\n }\n Object.defineProperty(Set.prototype, \"size\", {\n get: function () { return this._map.size; },\n enumerable: true,\n configurable: true\n });\n Set.prototype.has = function (value) { return this._map.has(value); };\n Set.prototype.add = function (value) { return this._map.set(value, value), this; };\n Set.prototype.delete = function (value) { return this._map.delete(value); };\n Set.prototype.clear = function () { this._map.clear(); };\n Set.prototype.keys = function () { return this._map.keys(); };\n Set.prototype.values = function () { return this._map.values(); };\n Set.prototype.entries = function () { return this._map.entries(); };\n Set.prototype[\"@@iterator\"] = function () { return this.keys(); };\n Set.prototype[iteratorSymbol] = function () { return this.keys(); };\n return Set;\n }());\n }\n // naive WeakMap shim\n function CreateWeakMapPolyfill() {\n var UUID_SIZE = 16;\n var keys = HashMap.create();\n var rootKey = CreateUniqueKey();\n return /** @class */ (function () {\n function WeakMap() {\n this._key = CreateUniqueKey();\n }\n WeakMap.prototype.has = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.has(table, this._key) : false;\n };\n WeakMap.prototype.get = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.get(table, this._key) : undefined;\n };\n WeakMap.prototype.set = function (target, value) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ true);\n table[this._key] = value;\n return this;\n };\n WeakMap.prototype.delete = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? delete table[this._key] : false;\n };\n WeakMap.prototype.clear = function () {\n // NOTE: not a real clear, just makes the previous data unreachable\n this._key = CreateUniqueKey();\n };\n return WeakMap;\n }());\n function CreateUniqueKey() {\n var key;\n do\n key = \"@@WeakMap@@\" + CreateUUID();\n while (HashMap.has(keys, key));\n keys[key] = true;\n return key;\n }\n function GetOrCreateWeakMapTable(target, create) {\n if (!hasOwn.call(target, rootKey)) {\n if (!create)\n return undefined;\n Object.defineProperty(target, rootKey, { value: HashMap.create() });\n }\n return target[rootKey];\n }\n function FillRandomBytes(buffer, size) {\n for (var i = 0; i < size; ++i)\n buffer[i] = Math.random() * 0xff | 0;\n return buffer;\n }\n function GenRandomBytes(size) {\n if (typeof Uint8Array === \"function\") {\n if (typeof crypto !== \"undefined\")\n return crypto.getRandomValues(new Uint8Array(size));\n if (typeof msCrypto !== \"undefined\")\n return msCrypto.getRandomValues(new Uint8Array(size));\n return FillRandomBytes(new Uint8Array(size), size);\n }\n return FillRandomBytes(new Array(size), size);\n }\n function CreateUUID() {\n var data = GenRandomBytes(UUID_SIZE);\n // mark as random - RFC 4122 § 4.4\n data[6] = data[6] & 0x4f | 0x40;\n data[8] = data[8] & 0xbf | 0x80;\n var result = \"\";\n for (var offset = 0; offset < UUID_SIZE; ++offset) {\n var byte = data[offset];\n if (offset === 4 || offset === 6 || offset === 8)\n result += \"-\";\n if (byte < 16)\n result += \"0\";\n result += byte.toString(16).toLowerCase();\n }\n return result;\n }\n }\n // uses a heuristic used by v8 and chakra to force an object into dictionary mode.\n function MakeDictionary(obj) {\n obj.__ = undefined;\n delete obj.__;\n return obj;\n }\n });\n})(Reflect || (Reflect = {}));\n\n\n//# sourceURL=webpack://BurguillosInfo/./node_modules/reflect-metadata/Reflect.js?"); + +/***/ }), + /***/ "./node_modules/tablesort/src/sorts/tablesort.number.js": /*!**************************************************************!*\ !*** ./node_modules/tablesort/src/sorts/tablesort.number.js ***! @@ -79,7 +89,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Conquer)\n/* harmony export */ });\n/* harmony import */ var ol_Map__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ol/Map */ \"./node_modules/ol/Map.js\");\n/* harmony import */ var ol_MapBrowserEvent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ol/MapBrowserEvent */ \"./node_modules/ol/MapBrowserEvent.js\");\n/* harmony import */ var ol_View__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ol/View */ \"./node_modules/ol/View.js\");\n/* harmony import */ var ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ol/proj/Projection.js */ \"./node_modules/ol/proj/Projection.js\");\n/* harmony import */ var ol_layer_Tile__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ol/layer/Tile */ \"./node_modules/ol/layer/Tile.js\");\n/* harmony import */ var ol_source_OSM__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ol/source/OSM */ \"./node_modules/ol/source/OSM.js\");\n/* harmony import */ var ol_proj__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ol/proj */ \"./node_modules/ol/proj.js\");\n/* harmony import */ var ol_Feature__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ol/Feature */ \"./node_modules/ol/Feature.js\");\n/* harmony import */ var ol_geom_Point__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ol/geom/Point */ \"./node_modules/ol/geom/Point.js\");\n/* harmony import */ var ol_layer_Vector__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ol/layer/Vector */ \"./node_modules/ol/layer/Vector.js\");\n/* harmony import */ var ol_source_Vector__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ol/source/Vector */ \"./node_modules/ol/source/Vector.js\");\n/* harmony import */ var ol_style_Stroke__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ol/style/Stroke */ \"./node_modules/ol/style/Stroke.js\");\n/* harmony import */ var ol_style_Fill__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ol/style/Fill */ \"./node_modules/ol/style/Fill.js\");\n/* harmony import */ var ol_style_Circle__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ol/style/Circle */ \"./node_modules/ol/style/Circle.js\");\n/* harmony import */ var ol_style_Style__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ol/style/Style */ \"./node_modules/ol/style/Style.js\");\n/* harmony import */ var _burguillosinfo_conquer_login__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/login */ \"./js-src/conquer/login.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer/interface-manager */ \"./js-src/conquer/interface-manager.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_self_player__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/self-player */ \"./js-src/conquer/interface/self-player.ts\");\n/* harmony import */ var _burguillosinfo_conquer_create_node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @burguillosinfo/conquer/create-node */ \"./js-src/conquer/create-node.ts\");\n/* harmony import */ var _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @burguillosinfo/conquer/map-state */ \"./js-src/conquer/map-state.ts\");\n/* harmony import */ var _burguillosinfo_conquer_map_node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @burguillosinfo/conquer/map-node */ \"./js-src/conquer/map-node.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nclass Conquer {\n getServerNodes() {\n return this.serverNodes;\n }\n getState() {\n return this.state;\n }\n setState(state) {\n this.state = state;\n this.refreshState();\n }\n removeState(state) {\n this.state &= ~state;\n this.refreshState();\n }\n addState(state) {\n this.state |= state;\n this.refreshState();\n }\n refreshState() {\n this.createNodeObject.refreshState();\n return;\n }\n static start() {\n const conquerContainer = document.querySelector(\".conquer-container\");\n if (conquerContainer === null || !(conquerContainer instanceof HTMLDivElement)) {\n Conquer.fail('.conquer-container is not a div.');\n }\n const conquer = new Conquer(conquerContainer);\n conquer.run();\n }\n setCenterDisplaced(lat, lon) {\n if (this.firstSetCenter || !(this.state & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].FREE_MOVE)) {\n const olCoordinates = this.realCoordinatesToOl(lat, lon);\n const size = this.map.getSize();\n if (size === undefined) {\n return;\n }\n this.map.getView().centerOn(olCoordinates, size, [size[0] / 2, size[1] - 60]);\n this.firstSetCenter = false;\n }\n }\n static fail(error) {\n alert('Error de interfaz');\n throw new Error(error);\n }\n isStateCreatingNode() {\n return !!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].CREATE_NODE);\n }\n isStateSelectWhereToCreateNode() {\n return !!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].SELECT_WHERE_TO_CREATE_NODE);\n }\n async onClickWhereToCreateNode(event) {\n if (!(event instanceof ol_MapBrowserEvent__WEBPACK_IMPORTED_MODULE_7__[\"default\"])) {\n return;\n }\n const pixel = event.pixel;\n const coordinates = this.map.getCoordinateFromPixel(pixel);\n const feature = new ol_Feature__WEBPACK_IMPORTED_MODULE_8__[\"default\"]({\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_9__[\"default\"](coordinates)\n });\n console.log(coordinates);\n const style = new ol_style_Style__WEBPACK_IMPORTED_MODULE_10__[\"default\"]({\n image: new ol_style_Circle__WEBPACK_IMPORTED_MODULE_11__[\"default\"]({\n radius: 14,\n fill: new ol_style_Fill__WEBPACK_IMPORTED_MODULE_12__[\"default\"]({ color: 'white' }),\n stroke: new ol_style_Stroke__WEBPACK_IMPORTED_MODULE_13__[\"default\"]({\n color: 'gray',\n width: 2,\n })\n })\n });\n const mapNode = new _burguillosinfo_conquer_map_node__WEBPACK_IMPORTED_MODULE_6__[\"default\"](style, feature, `server-node-${++this.createNodeCounter}`);\n this.getServerNodes()[mapNode.getId()] = mapNode;\n this.removeState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].SELECT_WHERE_TO_CREATE_NODE);\n this.refreshLayers();\n }\n async onClickMap(event) {\n if (this.isStateCreatingNode() && this.isStateSelectWhereToCreateNode()) {\n this.onClickWhereToCreateNode(event);\n }\n if (!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL)) {\n return;\n }\n if (this.vectorLayer === null) {\n return;\n }\n if (!(event instanceof ol_MapBrowserEvent__WEBPACK_IMPORTED_MODULE_7__[\"default\"])) {\n return;\n }\n if (event.dragging) {\n return;\n }\n const pixel = event.pixel;\n const features = this.map.getFeaturesAtPixel(pixel);\n const feature = features.length ? features[0] : undefined;\n if (feature === undefined) {\n return;\n }\n if (!(feature instanceof ol_Feature__WEBPACK_IMPORTED_MODULE_8__[\"default\"])) {\n return;\n }\n this.onClickFeature(feature);\n }\n async onClickSelf() {\n if (!(this.state & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL)) {\n return;\n }\n const selfPlayerUI = new _burguillosinfo_conquer_interface_self_player__WEBPACK_IMPORTED_MODULE_3__[\"default\"]();\n selfPlayerUI.on('close', () => {\n this.interfaceManager.remove(selfPlayerUI);\n });\n selfPlayerUI.on('createNodeStart', () => {\n this.addState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].CREATE_NODE);\n this.removeState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL);\n });\n this.interfaceManager.push(selfPlayerUI);\n this.selfPlayerUI = selfPlayerUI;\n }\n async onClickFeature(feature) {\n if (this.isFeatureEnabledMap[feature.getProperties().type] === undefined) {\n this.isFeatureEnabledMap[feature.getProperties().type] = true;\n }\n if (!this.isFeatureEnabledMap[feature.getProperties().type]) {\n return;\n }\n this.isFeatureEnabledMap[feature.getProperties().type] = false;\n window.setTimeout(() => {\n this.isFeatureEnabledMap[feature.getProperties().type] = true;\n }, 100);\n if (feature === this.currentPositionFeature) {\n this.onClickSelf();\n return;\n }\n }\n async onLoginSuccess() {\n const currentPositionFeature = this.currentPositionFeature;\n if (currentPositionFeature === null) {\n return;\n }\n this.map.on('click', (event) => {\n this.onClickMap(event);\n });\n }\n runPreStartState() {\n const createNodeObject = new _burguillosinfo_conquer_create_node__WEBPACK_IMPORTED_MODULE_4__[\"default\"](this);\n this.createNodeObject = createNodeObject;\n const interfaceManager = new _burguillosinfo_conquer_interface_manager__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n this.interfaceManager = interfaceManager;\n const conquerLogin = new _burguillosinfo_conquer_login__WEBPACK_IMPORTED_MODULE_1__[\"default\"](interfaceManager);\n conquerLogin.on('login', () => {\n this.onLoginSuccess();\n });\n conquerLogin.start();\n this.conquerLogin = conquerLogin;\n }\n async run() {\n this.runPreStartState();\n this.setState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL);\n const conquerContainer = this.conquerContainer;\n //layer.on('prerender', (evt) => {\n // // return\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D\n // context.filter = 'grayscale(80%) invert(100%) '\n // context.globalCompositeOperation = 'source-over'\n // }\n //})\n //layer.on('postrender', (evt) => {\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D\n // context.filter = 'none'\n // }\n //})\n ol_proj__WEBPACK_IMPORTED_MODULE_0__.useGeographic();\n const osm = new ol_source_OSM__WEBPACK_IMPORTED_MODULE_14__[\"default\"]();\n osm.setUrls([`${window.location.protocol}//${window.location.hostname}:${window.location.port}/conquer/tile/{z}/{x}/{y}.png`]);\n this.map = new ol_Map__WEBPACK_IMPORTED_MODULE_15__[\"default\"]({\n target: conquerContainer,\n layers: [\n new ol_layer_Tile__WEBPACK_IMPORTED_MODULE_16__[\"default\"]({\n source: osm\n })\n ],\n view: new ol_View__WEBPACK_IMPORTED_MODULE_17__[\"default\"]({\n zoom: 19,\n maxZoom: 22,\n }),\n });\n this.setLocationChangeTriggers();\n this.setRotationChangeTriggers();\n }\n setRotationChangeTriggers() {\n if (window.DeviceOrientationEvent) {\n window.addEventListener(\"deviceorientation\", (event) => {\n if (event.alpha !== null && event.beta !== null && event.gamma !== null) {\n this.onRotate(event.alpha, event.beta, event.gamma);\n }\n }, true);\n }\n }\n addCurrentLocationMarkerToMap(currentLatitude, currentLongitude) {\n const currentPositionFeature = new ol_Feature__WEBPACK_IMPORTED_MODULE_8__[\"default\"]({\n type: 'currentPositionFeature',\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_9__[\"default\"](this.realCoordinatesToOl(currentLatitude, currentLongitude))\n });\n this.currentPositionFeature = currentPositionFeature;\n }\n processLocation(location) {\n this.currentLatitude = location.coords.latitude;\n this.currentLongitude = location.coords.longitude;\n if (location.coords.heading !== null && (this.alpha != 0 || this.beta != 0 || this.gamma != 0) && !this.disableSetRotationOffset) {\n this.disableSetRotationOffset = true;\n this.heading = location.coords.heading;\n this.rotationOffset = this.compassHeading(this.alpha, this.beta, this.gamma) + (location.coords.heading * Math.PI * 2) / 360;\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n this.addCurrentLocationMarkerToMap(this.currentLatitude, this.currentLongitude);\n this.refreshLayers();\n }\n refreshLayers() {\n if (this.currentPositionFeature === null) {\n return;\n }\n const styles = {\n currentPositionFeature: new ol_style_Style__WEBPACK_IMPORTED_MODULE_10__[\"default\"]({\n image: new ol_style_Circle__WEBPACK_IMPORTED_MODULE_11__[\"default\"]({\n radius: 14,\n fill: new ol_style_Fill__WEBPACK_IMPORTED_MODULE_12__[\"default\"]({ color: 'white' }),\n stroke: new ol_style_Stroke__WEBPACK_IMPORTED_MODULE_13__[\"default\"]({\n color: 'blue',\n width: 2,\n })\n })\n })\n };\n const features = [this.currentPositionFeature];\n for (const key in this.getServerNodes()) {\n styles[key] = this.getServerNodes()[key].getStyle();\n features.push(this.getServerNodes()[key].getNode());\n }\n const vectorLayer = new ol_layer_Vector__WEBPACK_IMPORTED_MODULE_18__[\"default\"]({\n source: new ol_source_Vector__WEBPACK_IMPORTED_MODULE_19__[\"default\"]({\n features: features\n }),\n });\n if (this.vectorLayer !== null) {\n this.map.removeLayer(this.vectorLayer);\n }\n vectorLayer.setStyle((feature) => {\n return styles[feature.getProperties().type];\n });\n this.map.addLayer(vectorLayer);\n this.vectorLayer = vectorLayer;\n this.map.on('click', (event) => {\n this.onClickMap(event);\n });\n }\n setLocationChangeTriggers() {\n window.setInterval(() => {\n this.disableSetRotationOffset = false;\n }, 10000);\n this.currentPositionFeature = null;\n window.setTimeout(() => {\n window.setInterval(() => {\n navigator.geolocation.getCurrentPosition((location) => {\n this.processLocation(location);\n }, () => {\n return;\n }, {\n enableHighAccuracy: true,\n });\n }, 3000);\n }, 1000);\n // const initialLatitude = 37.58237\n //const initialLongitude = -5.96766\n const initialLongitude = 2.500845037550267;\n const initialLatitude = 48.81050698635832;\n this.setCenterDisplaced(initialLatitude, initialLongitude);\n this.addCurrentLocationMarkerToMap(initialLatitude, initialLongitude);\n this.refreshLayers();\n navigator.geolocation.watchPosition((location) => {\n this.processLocation(location);\n }, (err) => {\n return;\n }, {\n enableHighAccuracy: true,\n });\n }\n realCoordinatesToOl(lat, lon) {\n return ol_proj__WEBPACK_IMPORTED_MODULE_0__.transform([lon, lat], new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_20__[\"default\"]({ code: \"WGS84\" }), new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_20__[\"default\"]({ code: \"EPSG:900913\" }));\n }\n compassHeading(alpha, beta, gamma) {\n const alphaRad = alpha * (Math.PI / 180);\n return alphaRad;\n }\n logToServer(logValue) {\n const urlLog = new URL('/conquer/log', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n urlLog.searchParams.append('log', logValue);\n fetch(urlLog).then(() => {\n return;\n }).catch((error) => {\n console.error(error);\n });\n }\n onRotate(alpha, beta, gamma) {\n if (this.enabledOnRotate) {\n this.alpha = alpha;\n this.beta = beta;\n this.gamma = gamma;\n this.enabledOnRotate = false;\n if (this.firstSetRotation || !(this.state & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].FREE_ROTATION)) {\n this.map.getView().setRotation((this.compassHeading(alpha, beta, gamma) - this.rotationOffset));\n this.firstSetRotation = false;\n }\n window.setTimeout(() => {\n this.enabledOnRotate = true;\n }, 10);\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n }\n constructor(conquerContainer) {\n this.rotationOffset = 0;\n this.heading = 0;\n this.disableSetRotationOffset = false;\n this.vectorLayer = null;\n this.alpha = 0;\n this.beta = 0;\n this.gamma = 0;\n this.selfPlayerUI = null;\n this.firstSetCenter = true;\n this.firstSetRotation = true;\n this.state = _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NOTHING;\n this.serverNodes = {};\n this.createNodeCounter = 0;\n this.isFeatureEnabledMap = {};\n this.enabledOnRotate = true;\n this.conquerContainer = conquerContainer;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/index.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Conquer)\n/* harmony export */ });\n/* harmony import */ var ol_Map__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ol/Map */ \"./node_modules/ol/Map.js\");\n/* harmony import */ var ol_MapBrowserEvent__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ol/MapBrowserEvent */ \"./node_modules/ol/MapBrowserEvent.js\");\n/* harmony import */ var ol_View__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ol/View */ \"./node_modules/ol/View.js\");\n/* harmony import */ var ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ol/proj/Projection.js */ \"./node_modules/ol/proj/Projection.js\");\n/* harmony import */ var ol_layer_Tile__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ol/layer/Tile */ \"./node_modules/ol/layer/Tile.js\");\n/* harmony import */ var ol_source_OSM__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ol/source/OSM */ \"./node_modules/ol/source/OSM.js\");\n/* harmony import */ var ol_proj__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ol/proj */ \"./node_modules/ol/proj.js\");\n/* harmony import */ var ol_Feature__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ol/Feature */ \"./node_modules/ol/Feature.js\");\n/* harmony import */ var ol_geom_Point__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ol/geom/Point */ \"./node_modules/ol/geom/Point.js\");\n/* harmony import */ var ol_layer_Vector__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ol/layer/Vector */ \"./node_modules/ol/layer/Vector.js\");\n/* harmony import */ var ol_source_Vector__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ol/source/Vector */ \"./node_modules/ol/source/Vector.js\");\n/* harmony import */ var ol_style_Stroke__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ol/style/Stroke */ \"./node_modules/ol/style/Stroke.js\");\n/* harmony import */ var ol_style_Fill__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ol/style/Fill */ \"./node_modules/ol/style/Fill.js\");\n/* harmony import */ var ol_style_Circle__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ol/style/Circle */ \"./node_modules/ol/style/Circle.js\");\n/* harmony import */ var ol_style_Style__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ol/style/Style */ \"./node_modules/ol/style/Style.js\");\n/* harmony import */ var _burguillosinfo_conquer_login__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/login */ \"./js-src/conquer/login.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer/interface-manager */ \"./js-src/conquer/interface-manager.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_self_player__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/self-player */ \"./js-src/conquer/interface/self-player.ts\");\n/* harmony import */ var _burguillosinfo_conquer_create_node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @burguillosinfo/conquer/create-node */ \"./js-src/conquer/create-node.ts\");\n/* harmony import */ var _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @burguillosinfo/conquer/map-state */ \"./js-src/conquer/map-state.ts\");\n/* harmony import */ var _burguillosinfo_conquer_map_node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @burguillosinfo/conquer/map-node */ \"./js-src/conquer/map-node.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_new_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/new-node */ \"./js-src/conquer/interface/new-node.ts\");\n/* harmony import */ var _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @burguillosinfo/conquer/serializer */ \"./js-src/conquer/serializer.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nclass Conquer {\n getServerNodes() {\n return this.serverNodes;\n }\n getState() {\n return this.state;\n }\n setState(state) {\n this.state = state;\n this.refreshState();\n }\n removeState(state) {\n this.state &= ~state;\n this.refreshState();\n }\n addState(state) {\n this.state |= state;\n this.refreshState();\n }\n refreshState() {\n this.createNodeObject.refreshState();\n return;\n }\n static start() {\n const conquerContainer = document.querySelector(\".conquer-container\");\n if (conquerContainer === null || !(conquerContainer instanceof HTMLDivElement)) {\n Conquer.fail('.conquer-container is not a div.');\n }\n const conquer = new Conquer(conquerContainer);\n conquer.run();\n }\n setCenterDisplaced(lat, lon) {\n if (this.firstSetCenter || !(this.state & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].FREE_MOVE)) {\n this.coordinate_1 = lon;\n this.coordinate_2 = lat;\n const olCoordinates = this.realCoordinatesToOl(lat, lon);\n const size = this.map.getSize();\n if (size === undefined) {\n return;\n }\n this.map.getView().centerOn(olCoordinates, size, [size[0] / 2, size[1] - 60]);\n this.firstSetCenter = false;\n }\n }\n static fail(error) {\n alert('Error de interfaz');\n throw new Error(error);\n }\n isStateCreatingNode() {\n return !!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].CREATE_NODE);\n }\n isStateSelectWhereToCreateNode() {\n return !!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].SELECT_WHERE_TO_CREATE_NODE);\n }\n async onClickWhereToCreateNode(event) {\n if (!(event instanceof ol_MapBrowserEvent__WEBPACK_IMPORTED_MODULE_9__[\"default\"])) {\n return;\n }\n const pixel = event.pixel;\n const coordinates = this.map.getCoordinateFromPixel(pixel);\n const feature = new ol_Feature__WEBPACK_IMPORTED_MODULE_10__[\"default\"]({\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_11__[\"default\"](coordinates)\n });\n const newNodeUI = new _burguillosinfo_conquer_interface_new_node__WEBPACK_IMPORTED_MODULE_7__[\"default\"](coordinates);\n const oldState = this.getState();\n newNodeUI.on('close', () => {\n this.interfaceManager.remove(newNodeUI);\n this.setState(oldState);\n });\n this.interfaceManager.push(newNodeUI);\n this.setState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].FILLING_FORM_CREATE_NODE);\n // const style = new Style({\n // image: new CircleStyle({\n // radius: 14,\n // fill: new Fill({color: 'white'}),\n // stroke: new Stroke({\n // color: 'gray',\n // width: 2,\n // })\n // })\n // })\n // const mapNode = new MapNode(style, feature, `server-node-${++this.createNodeCounter}`)\n // this.getServerNodes()[mapNode.getId()] = mapNode\n // this.removeState(MapState.SELECT_WHERE_TO_CREATE_NODE)\n // this.refreshLayers()\n }\n isStateFillingFormCreateNode() {\n return !!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].FILLING_FORM_CREATE_NODE);\n }\n async onClickMap(event) {\n if (this.isStateCreatingNode() && this.isStateSelectWhereToCreateNode()) {\n this.onClickWhereToCreateNode(event);\n }\n if (!(this.getState() & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL)) {\n return;\n }\n if (this.vectorLayer === null) {\n return;\n }\n if (!(event instanceof ol_MapBrowserEvent__WEBPACK_IMPORTED_MODULE_9__[\"default\"])) {\n return;\n }\n if (event.dragging) {\n return;\n }\n const pixel = event.pixel;\n const features = this.map.getFeaturesAtPixel(pixel);\n const feature = features.length ? features[0] : undefined;\n if (feature === undefined) {\n return;\n }\n if (!(feature instanceof ol_Feature__WEBPACK_IMPORTED_MODULE_10__[\"default\"])) {\n return;\n }\n this.onClickFeature(feature);\n }\n async onClickSelf() {\n if (!(this.state & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL)) {\n return;\n }\n const selfPlayerUI = new _burguillosinfo_conquer_interface_self_player__WEBPACK_IMPORTED_MODULE_3__[\"default\"]();\n selfPlayerUI.on('close', () => {\n this.interfaceManager.remove(selfPlayerUI);\n });\n selfPlayerUI.on('createNodeStart', () => {\n this.addState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].CREATE_NODE);\n this.removeState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL);\n });\n this.interfaceManager.push(selfPlayerUI);\n this.selfPlayerUI = selfPlayerUI;\n }\n async onClickFeature(feature) {\n if (this.isFeatureEnabledMap[feature.getProperties().type] === undefined) {\n this.isFeatureEnabledMap[feature.getProperties().type] = true;\n }\n if (!this.isFeatureEnabledMap[feature.getProperties().type]) {\n return;\n }\n this.isFeatureEnabledMap[feature.getProperties().type] = false;\n window.setTimeout(() => {\n this.isFeatureEnabledMap[feature.getProperties().type] = true;\n }, 100);\n if (feature === this.currentPositionFeature) {\n this.onClickSelf();\n return;\n }\n }\n async onLoginSuccess() {\n this.clearIntervalSendCoordinates();\n this.createIntervalSendCoordinates();\n this.clearIntervalPollNearbyNodes();\n this.createIntervalPollNearbyNodes();\n }\n clearIntervalPollNearbyNodes() {\n if (this.intervalPollNearbyNodes !== null) {\n window.clearInterval(this.intervalPollNearbyNodes);\n this.intervalPollNearbyNodes = null;\n }\n }\n getNearbyNodes() {\n const urlNodes = new URL('/conquer/node/near', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n fetch(urlNodes).then(async (response) => {\n let responseBody;\n try {\n responseBody = await response.json();\n }\n catch (error) {\n console.error('Error parseando json: ' + responseBody);\n console.error(error);\n return;\n }\n if (response.status !== 200) {\n console.error(responseBody.error);\n return;\n }\n const serverNodes = {};\n const nodes = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_8__[\"default\"].deserialize(responseBody, _burguillosinfo_conquer_map_node__WEBPACK_IMPORTED_MODULE_6__[\"default\"]);\n if (!(nodes instanceof Array)) {\n console.error('Received null instead of node list.');\n return;\n }\n for (const node of nodes) {\n if (!(node instanceof _burguillosinfo_conquer_map_node__WEBPACK_IMPORTED_MODULE_6__[\"default\"])) {\n console.error('Received node is not a MapNode.');\n continue;\n }\n serverNodes[node.getId()] = node;\n }\n this.serverNodes = serverNodes;\n this.refreshLayers();\n });\n }\n createIntervalPollNearbyNodes() {\n this.intervalPollNearbyNodes = window.setInterval(() => {\n this.getNearbyNodes();\n }, 10000);\n }\n createIntervalSendCoordinates() {\n this.intervalSendCoordinates = window.setInterval(() => {\n this.sendCoordinatesToServer();\n }, 10000);\n }\n sendCoordinatesToServer() {\n const urlLog = new URL('/conquer/user/coordinates', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n fetch(urlLog, {\n method: 'POST',\n body: JSON.stringify([\n this.coordinate_1,\n this.coordinate_2,\n ]),\n }).then(async (res) => {\n let responseBody;\n try {\n responseBody = await res.json();\n }\n catch (error) {\n console.error('Error parseando json: ' + responseBody);\n console.error(error);\n return;\n }\n if (res.status !== 200) {\n console.error(responseBody.error);\n }\n }).catch((error) => {\n console.error(error);\n });\n }\n runPreStartState() {\n const createNodeObject = new _burguillosinfo_conquer_create_node__WEBPACK_IMPORTED_MODULE_4__[\"default\"](this);\n this.createNodeObject = createNodeObject;\n const interfaceManager = new _burguillosinfo_conquer_interface_manager__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n this.interfaceManager = interfaceManager;\n const conquerLogin = new _burguillosinfo_conquer_login__WEBPACK_IMPORTED_MODULE_1__[\"default\"](interfaceManager);\n conquerLogin.on('login', () => {\n this.onLoginSuccess();\n });\n conquerLogin.on('logout', () => {\n this.onLogout();\n });\n conquerLogin.start();\n this.conquerLogin = conquerLogin;\n }\n onLogout() {\n this.clearIntervalSendCoordinates();\n this.clearIntervalPollNearbyNodes();\n }\n clearIntervalSendCoordinates() {\n if (this.intervalSendCoordinates !== null) {\n window.clearInterval(this.intervalSendCoordinates);\n this.intervalSendCoordinates = null;\n }\n }\n async run() {\n this.runPreStartState();\n this.setState(_burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NORMAL);\n const conquerContainer = this.conquerContainer;\n //layer.on('prerender', (evt) => {\n // // return\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D\n // context.filter = 'grayscale(80%) invert(100%) '\n // context.globalCompositeOperation = 'source-over'\n // }\n //})\n //layer.on('postrender', (evt) => {\n // if (evt.context) {\n // const context = evt.context as CanvasRenderingContext2D\n // context.filter = 'none'\n // }\n //})\n ol_proj__WEBPACK_IMPORTED_MODULE_0__.useGeographic();\n const osm = new ol_source_OSM__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n osm.setUrls([`${window.location.protocol}//${window.location.hostname}:${window.location.port}/conquer/tile/{z}/{x}/{y}.png`]);\n this.map = new ol_Map__WEBPACK_IMPORTED_MODULE_13__[\"default\"]({\n target: conquerContainer,\n layers: [\n new ol_layer_Tile__WEBPACK_IMPORTED_MODULE_14__[\"default\"]({\n source: osm\n })\n ],\n view: new ol_View__WEBPACK_IMPORTED_MODULE_15__[\"default\"]({\n zoom: 19,\n maxZoom: 22,\n }),\n });\n this.setLocationChangeTriggers();\n this.setRotationChangeTriggers();\n }\n setRotationChangeTriggers() {\n if (window.DeviceOrientationEvent) {\n window.addEventListener(\"deviceorientation\", (event) => {\n if (event.alpha !== null && event.beta !== null && event.gamma !== null) {\n this.onRotate(event.alpha, event.beta, event.gamma);\n }\n }, true);\n }\n }\n addCurrentLocationMarkerToMap(currentLatitude, currentLongitude) {\n const currentPositionFeature = new ol_Feature__WEBPACK_IMPORTED_MODULE_10__[\"default\"]({\n type: 'currentPositionFeature',\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_11__[\"default\"](this.realCoordinatesToOl(currentLatitude, currentLongitude))\n });\n this.currentPositionFeature = currentPositionFeature;\n }\n processLocation(location) {\n this.currentLatitude = location.coords.latitude;\n this.currentLongitude = location.coords.longitude;\n if (location.coords.heading !== null && (this.alpha != 0 || this.beta != 0 || this.gamma != 0) && !this.disableSetRotationOffset) {\n this.disableSetRotationOffset = true;\n this.heading = location.coords.heading;\n this.rotationOffset = this.compassHeading(this.alpha, this.beta, this.gamma) + (location.coords.heading * Math.PI * 2) / 360;\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n this.addCurrentLocationMarkerToMap(this.currentLatitude, this.currentLongitude);\n this.refreshLayers();\n }\n async refreshLayers() {\n if (this.currentPositionFeature === null) {\n return;\n }\n const styles = {\n currentPositionFeature: new ol_style_Style__WEBPACK_IMPORTED_MODULE_16__[\"default\"]({\n image: new ol_style_Circle__WEBPACK_IMPORTED_MODULE_17__[\"default\"]({\n radius: 14,\n fill: new ol_style_Fill__WEBPACK_IMPORTED_MODULE_18__[\"default\"]({ color: 'white' }),\n stroke: new ol_style_Stroke__WEBPACK_IMPORTED_MODULE_19__[\"default\"]({\n color: 'blue',\n width: 2,\n })\n })\n })\n };\n const features = [this.currentPositionFeature];\n for (const key in this.getServerNodes()) {\n styles[key] = this.getServerNodes()[key].getStyle();\n features.push(this.getServerNodes()[key].getFeature());\n }\n const vectorLayer = new ol_layer_Vector__WEBPACK_IMPORTED_MODULE_20__[\"default\"]({\n source: new ol_source_Vector__WEBPACK_IMPORTED_MODULE_21__[\"default\"]({\n features: features\n }),\n });\n if (this.vectorLayer !== null) {\n this.map.removeLayer(this.vectorLayer);\n this.vectorLayer = null;\n }\n vectorLayer.setStyle((feature) => {\n return styles[feature.getProperties().type];\n });\n this.map.addLayer(vectorLayer);\n this.vectorLayer = vectorLayer;\n this.map.on('click', (event) => {\n this.onClickMap(event);\n });\n }\n setLocationChangeTriggers() {\n window.setInterval(() => {\n this.disableSetRotationOffset = false;\n }, 10000);\n this.currentPositionFeature = null;\n window.setTimeout(() => {\n window.setInterval(() => {\n navigator.geolocation.getCurrentPosition((location) => {\n this.processLocation(location);\n }, () => {\n return;\n }, {\n enableHighAccuracy: true,\n });\n }, 3000);\n }, 1000);\n // const initialLatitude = 37.58237\n //const initialLongitude = -5.96766\n const initialLongitude = 2.500845037550267;\n const initialLatitude = 48.81050698635832;\n this.setCenterDisplaced(initialLatitude, initialLongitude);\n this.addCurrentLocationMarkerToMap(initialLatitude, initialLongitude);\n this.refreshLayers();\n navigator.geolocation.watchPosition((location) => {\n this.processLocation(location);\n }, (err) => {\n return;\n }, {\n enableHighAccuracy: true,\n });\n }\n realCoordinatesToOl(lat, lon) {\n return ol_proj__WEBPACK_IMPORTED_MODULE_0__.transform([lon, lat], new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_22__[\"default\"]({ code: \"WGS84\" }), new ol_proj_Projection_js__WEBPACK_IMPORTED_MODULE_22__[\"default\"]({ code: \"EPSG:900913\" }));\n }\n compassHeading(alpha, beta, gamma) {\n const alphaRad = alpha * (Math.PI / 180);\n return alphaRad;\n }\n logToServer(logValue) {\n const urlLog = new URL('/conquer/log', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n urlLog.searchParams.append('log', logValue);\n fetch(urlLog).then(() => {\n return;\n }).catch((error) => {\n console.error(error);\n });\n }\n onRotate(alpha, beta, gamma) {\n if (this.enabledOnRotate) {\n this.alpha = alpha;\n this.beta = beta;\n this.gamma = gamma;\n this.enabledOnRotate = false;\n if (this.firstSetRotation || !(this.state & _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].FREE_ROTATION)) {\n this.map.getView().setRotation((this.compassHeading(alpha, beta, gamma) - this.rotationOffset));\n this.firstSetRotation = false;\n }\n window.setTimeout(() => {\n this.enabledOnRotate = true;\n }, 10);\n }\n this.setCenterDisplaced(this.currentLatitude, this.currentLongitude);\n }\n constructor(conquerContainer) {\n this.intervalSendCoordinates = null;\n this.rotationOffset = 0;\n this.heading = 0;\n this.disableSetRotationOffset = false;\n this.vectorLayer = null;\n this.alpha = 0;\n this.beta = 0;\n this.gamma = 0;\n this.selfPlayerUI = null;\n this.firstSetCenter = true;\n this.firstSetRotation = true;\n this.state = _burguillosinfo_conquer_map_state__WEBPACK_IMPORTED_MODULE_5__[\"default\"].NOTHING;\n this.serverNodes = {};\n this.coordinate_1 = 0;\n this.coordinate_2 = 0;\n this.createNodeCounter = 0;\n this.isFeatureEnabledMap = {};\n this.intervalPollNearbyNodes = null;\n this.enabledOnRotate = true;\n this.conquerContainer = conquerContainer;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/index.ts?"); /***/ }), @@ -101,7 +111,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ ConquerInterface)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n\nclass ConquerInterface {\n constructor() {\n this.alreadyGenerated = false;\n this.callbacks = {};\n }\n getNodes() {\n if (!this.alreadyGenerated) {\n this.nodes = this.generateNodes();\n this.alreadyGenerated = true;\n }\n return this.nodes;\n }\n run() {\n return;\n }\n prune() {\n return;\n }\n getNodeFromTemplateId(id) {\n const template = document.getElementById(id);\n if (template === null) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail(`Unable to find template id ${id}.`);\n }\n const finalNode = template.cloneNode(true);\n if (!(finalNode instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('The node is not an Element.');\n }\n return finalNode;\n }\n on(eventName, callback) {\n if (this.callbacks[eventName] === undefined) {\n this.callbacks[eventName] = [];\n }\n this.callbacks[eventName].push(callback);\n }\n runCallbacks(eventName) {\n const callbacks = this.callbacks[eventName];\n if (callbacks === undefined) {\n return;\n }\n for (const callback of callbacks) {\n callback();\n }\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ ConquerInterface)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n\nclass ConquerInterface {\n constructor() {\n this.alreadyGenerated = false;\n this.callbacks = {};\n }\n getNodes() {\n if (!this.alreadyGenerated) {\n this.nodes = this.generateNodes();\n this.alreadyGenerated = true;\n }\n return this.nodes;\n }\n run() {\n return;\n }\n prune() {\n this.callbacks = {};\n return;\n }\n getNodeFromTemplateId(id) {\n let template = document.getElementById(id);\n if (template === null) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail(`Unable to find template id ${id}.`);\n }\n const finalNode = template.cloneNode(true);\n if (!(finalNode instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('The node is not an Element.');\n }\n finalNode.classList.remove('conquer-display-none');\n return finalNode;\n }\n on(eventName, callback) {\n if (this.callbacks[eventName] === undefined) {\n this.callbacks[eventName] = [];\n }\n this.callbacks[eventName].push(callback);\n }\n runCallbacks(eventName) {\n const callbacks = this.callbacks[eventName];\n if (callbacks === undefined) {\n return;\n }\n for (const callback of callbacks) {\n callback();\n }\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface.ts?"); /***/ }), @@ -123,7 +133,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ LoginUI)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/interface */ \"./js-src/conquer/interface.ts\");\n\n\nclass LoginUI extends _burguillosinfo_conquer_interface__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n constructor(conquerLogin) {\n super();\n this.conquerLogin = conquerLogin;\n }\n run() {\n this.storeRegisterElements();\n this.storeLoginElements();\n }\n getLoginDiv() {\n const element = this.getNodes()[1];\n if (element === undefined || !(element instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Login is not a div.');\n }\n return element;\n }\n getOverlayDiv() {\n const element = this.getNodes()[0];\n if (element === undefined || !(element instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Overlay transparent is not a div.');\n }\n return element;\n }\n getRegisterDiv() {\n const element = this.getNodes()[2];\n if (element === undefined || !(element instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Register is not a div.');\n }\n return element;\n }\n generateNodes() {\n const resultArray = [];\n const overlay = this.getNodeFromTemplateId('conquer-overlay-transparent-template');\n overlay.classList.remove('conquer-display-none');\n resultArray.push(overlay);\n const login = this.getNodeFromTemplateId('conquer-login-template');\n login.classList.remove('conquer-display-none');\n if (!(login instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Login is required to be a Div.');\n }\n resultArray.push(login);\n const register = this.getNodeFromTemplateId('conquer-register-template');\n resultArray.push(register);\n return resultArray;\n }\n async storeRegisterElements() {\n const registerElement = this.getRegisterDiv();\n const conquerRegisterGoToLogin = registerElement.querySelector('.conquer-register-go-to-login');\n if (conquerRegisterGoToLogin === null || !(conquerRegisterGoToLogin instanceof HTMLAnchorElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Link to go to login from register is invalid.');\n }\n this.conquerRegisterGoToLogin = conquerRegisterGoToLogin;\n this.conquerRegisterGoToLogin.addEventListener('click', () => {\n this.goToLogin();\n });\n const conquerRegisterUsername = registerElement.querySelector('.conquer-register-username');\n if (conquerRegisterUsername === null || !(conquerRegisterUsername instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No username field in conquer register.');\n }\n this.conquerRegisterUsername = conquerRegisterUsername;\n const conquerRegisterPassword = registerElement.querySelector('.conquer-register-password');\n if (conquerRegisterPassword === null || !(conquerRegisterPassword instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No password field in conquer register.');\n }\n this.conquerRegisterPassword = conquerRegisterPassword;\n const conquerRegisterRepeatPassword = registerElement.querySelector('.conquer-register-repeat-password');\n if (conquerRegisterRepeatPassword === null || !(conquerRegisterRepeatPassword instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No repeat password field in conquer register.');\n }\n this.conquerRegisterRepeatPassword = conquerRegisterRepeatPassword;\n const conquerRegisterSubmit = registerElement.querySelector('.conquer-register-submit');\n if (conquerRegisterSubmit === null || !(conquerRegisterSubmit instanceof HTMLButtonElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No register submit button found.');\n }\n this.conquerRegisterSubmit = conquerRegisterSubmit;\n this.conquerRegisterSubmit.addEventListener('click', (event) => {\n event.preventDefault();\n const username = this.conquerRegisterUsername.value;\n const password = this.conquerRegisterPassword.value;\n const repeatPassword = this.conquerRegisterRepeatPassword.value;\n this.conquerLogin.onRegisterRequest(this, username, password, repeatPassword);\n });\n const conquerRegisterError = registerElement.querySelector('.conquer-register-error');\n if (conquerRegisterError === null || !(conquerRegisterError instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find the conquer error element.');\n }\n this.conquerRegisterError = conquerRegisterError;\n }\n storeLoginElements() {\n const loginElement = this.getLoginDiv();\n const conquerLoginGoToRegister = loginElement.querySelector('.conquer-login-go-to-register');\n if (conquerLoginGoToRegister === null || !(conquerLoginGoToRegister instanceof HTMLAnchorElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Link to go to register from login is invalid.');\n }\n this.conquerLoginGoToRegister = conquerLoginGoToRegister;\n this.conquerLoginGoToRegister.addEventListener('click', () => {\n this.goToRegister();\n });\n const conquerLoginError = loginElement.querySelector('.conquer-login-error');\n if (conquerLoginError === null || !(conquerLoginError instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login error.');\n }\n this.conquerLoginError = conquerLoginError;\n const conquerLoginSuccess = loginElement.querySelector('.conquer-login-success');\n if (conquerLoginSuccess === null || !(conquerLoginSuccess instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login success.');\n }\n this.conquerLoginSuccess = conquerLoginSuccess;\n const conquerLoginUsername = loginElement.querySelector('.conquer-login-username');\n if (conquerLoginUsername === null || !(conquerLoginUsername instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login username field.');\n }\n this.conquerLoginUsername = conquerLoginUsername;\n const conquerLoginPassword = loginElement.querySelector('.conquer-login-password');\n if (conquerLoginPassword === null || !(conquerLoginPassword instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login password field.');\n }\n this.conquerLoginPassword = conquerLoginPassword;\n const conquerLoginSubmit = loginElement.querySelector('.conquer-login-submit');\n if (conquerLoginSubmit === null || !(conquerLoginSubmit instanceof HTMLButtonElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find the submit button for the login.');\n }\n this.conquerLoginSubmit = conquerLoginSubmit;\n console.log(this.conquerLoginSubmit.parentNode?.parentNode);\n this.conquerLoginSubmit.addEventListener('click', (event) => {\n event.preventDefault();\n const username = this.conquerLoginUsername.value;\n const password = this.conquerLoginPassword.value;\n this.conquerLogin.onLoginRequested(this, username, password);\n });\n }\n async goToRegister() {\n await this.removeLoginRegisterCombo();\n const registerElement = this.getRegisterDiv();\n registerElement.classList.remove('conquer-display-none');\n }\n async removeLoginRegisterCombo() {\n const registerElement = this.getRegisterDiv();\n const overlayElement = this.getOverlayDiv();\n overlayElement.classList.add('conquer-display-none');\n const loginElement = this.getLoginDiv();\n loginElement.classList.add('conquer-display-none');\n registerElement.classList.add('conquer-display-none');\n }\n async addNewLoginSuccessText(message) {\n this.unsetLoginAndRegisterErrors();\n this.conquerLoginSuccess.innerText = message;\n this.conquerLoginSuccess.classList.remove('conquer-display-none');\n }\n async addNewLoginError(error) {\n this.unsetLoginAndRegisterErrors();\n this.conquerLoginSuccess.classList.add('conquer-display-none');\n this.conquerLoginError.innerText = error;\n this.conquerLoginError.classList.remove('conquer-display-none');\n }\n async addNewRegisterError(error) {\n this.unsetLoginAndRegisterErrors();\n this.conquerLoginSuccess.classList.add('conquer-display-none');\n this.conquerRegisterError.innerText = error;\n this.conquerRegisterError.classList.remove('conquer-display-none');\n }\n async unsetLoginAndRegisterErrors() {\n this.conquerRegisterError.classList.add('conquer-display-none');\n this.conquerLoginError.classList.add('conquer-display-none');\n }\n async goToLogin() {\n await this.removeLoginRegisterCombo();\n const loginElement = this.getLoginDiv();\n loginElement.classList.remove('conquer-display-none');\n }\n async addNewLoginRegisterError(message) {\n this.addNewRegisterError(message);\n this.addNewLoginError(message);\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/login.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ LoginUI)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/interface */ \"./js-src/conquer/interface.ts\");\n\n\nclass LoginUI extends _burguillosinfo_conquer_interface__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n constructor(conquerLogin) {\n super();\n this.conquerLogin = conquerLogin;\n }\n run() {\n this.conquerLogin.on('login', () => {\n this.runCallbacks('close');\n });\n this.storeRegisterElements();\n this.storeLoginElements();\n }\n getLoginDiv() {\n const element = this.getNodes()[1];\n if (element === undefined || !(element instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Login is not a div.');\n }\n return element;\n }\n getOverlayDiv() {\n const element = this.getNodes()[0];\n if (element === undefined || !(element instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Overlay transparent is not a div.');\n }\n return element;\n }\n getRegisterDiv() {\n const element = this.getNodes()[2];\n if (element === undefined || !(element instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Register is not a div.');\n }\n return element;\n }\n generateNodes() {\n const resultArray = [];\n const overlay = this.getNodeFromTemplateId('conquer-overlay-transparent-template');\n overlay.classList.remove('conquer-display-none');\n resultArray.push(overlay);\n const login = this.getNodeFromTemplateId('conquer-login-template');\n login.classList.remove('conquer-display-none');\n if (!(login instanceof HTMLDivElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Login is required to be a Div.');\n }\n resultArray.push(login);\n const register = this.getNodeFromTemplateId('conquer-register-template');\n resultArray.push(register);\n return resultArray;\n }\n async storeRegisterElements() {\n const registerElement = this.getRegisterDiv();\n const conquerRegisterGoToLogin = registerElement.querySelector('.conquer-register-go-to-login');\n if (conquerRegisterGoToLogin === null || !(conquerRegisterGoToLogin instanceof HTMLAnchorElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Link to go to login from register is invalid.');\n }\n this.conquerRegisterGoToLogin = conquerRegisterGoToLogin;\n this.conquerRegisterGoToLogin.addEventListener('click', () => {\n this.goToLogin();\n });\n const conquerRegisterUsername = registerElement.querySelector('.conquer-register-username');\n if (conquerRegisterUsername === null || !(conquerRegisterUsername instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No username field in conquer register.');\n }\n this.conquerRegisterUsername = conquerRegisterUsername;\n const conquerRegisterPassword = registerElement.querySelector('.conquer-register-password');\n if (conquerRegisterPassword === null || !(conquerRegisterPassword instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No password field in conquer register.');\n }\n this.conquerRegisterPassword = conquerRegisterPassword;\n const conquerRegisterRepeatPassword = registerElement.querySelector('.conquer-register-repeat-password');\n if (conquerRegisterRepeatPassword === null || !(conquerRegisterRepeatPassword instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No repeat password field in conquer register.');\n }\n this.conquerRegisterRepeatPassword = conquerRegisterRepeatPassword;\n const conquerRegisterSubmit = registerElement.querySelector('.conquer-register-submit');\n if (conquerRegisterSubmit === null || !(conquerRegisterSubmit instanceof HTMLButtonElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('No register submit button found.');\n }\n this.conquerRegisterSubmit = conquerRegisterSubmit;\n this.conquerRegisterSubmit.addEventListener('click', (event) => {\n event.preventDefault();\n const username = this.conquerRegisterUsername.value;\n const password = this.conquerRegisterPassword.value;\n const repeatPassword = this.conquerRegisterRepeatPassword.value;\n this.conquerLogin.onRegisterRequest(this, username, password, repeatPassword);\n });\n const conquerRegisterError = registerElement.querySelector('.conquer-register-error');\n if (conquerRegisterError === null || !(conquerRegisterError instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find the conquer error element.');\n }\n this.conquerRegisterError = conquerRegisterError;\n }\n storeLoginElements() {\n const loginElement = this.getLoginDiv();\n const conquerLoginGoToRegister = loginElement.querySelector('.conquer-login-go-to-register');\n if (conquerLoginGoToRegister === null || !(conquerLoginGoToRegister instanceof HTMLAnchorElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Link to go to register from login is invalid.');\n }\n this.conquerLoginGoToRegister = conquerLoginGoToRegister;\n this.conquerLoginGoToRegister.addEventListener('click', () => {\n this.goToRegister();\n });\n const conquerLoginError = loginElement.querySelector('.conquer-login-error');\n if (conquerLoginError === null || !(conquerLoginError instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login error.');\n }\n this.conquerLoginError = conquerLoginError;\n const conquerLoginSuccess = loginElement.querySelector('.conquer-login-success');\n if (conquerLoginSuccess === null || !(conquerLoginSuccess instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login success.');\n }\n this.conquerLoginSuccess = conquerLoginSuccess;\n const conquerLoginUsername = loginElement.querySelector('.conquer-login-username');\n if (conquerLoginUsername === null || !(conquerLoginUsername instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login username field.');\n }\n this.conquerLoginUsername = conquerLoginUsername;\n const conquerLoginPassword = loginElement.querySelector('.conquer-login-password');\n if (conquerLoginPassword === null || !(conquerLoginPassword instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find conquer login password field.');\n }\n this.conquerLoginPassword = conquerLoginPassword;\n const conquerLoginSubmit = loginElement.querySelector('.conquer-login-submit');\n if (conquerLoginSubmit === null || !(conquerLoginSubmit instanceof HTMLButtonElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Unable to find the submit button for the login.');\n }\n this.conquerLoginSubmit = conquerLoginSubmit;\n console.log(this.conquerLoginSubmit.parentNode?.parentNode);\n this.conquerLoginSubmit.addEventListener('click', (event) => {\n event.preventDefault();\n const username = this.conquerLoginUsername.value;\n const password = this.conquerLoginPassword.value;\n this.conquerLogin.onLoginRequested(this, username, password);\n });\n }\n async goToRegister() {\n await this.removeLoginRegisterCombo();\n const registerElement = this.getRegisterDiv();\n registerElement.classList.remove('conquer-display-none');\n }\n async removeLoginRegisterCombo() {\n const registerElement = this.getRegisterDiv();\n const overlayElement = this.getOverlayDiv();\n overlayElement.classList.add('conquer-display-none');\n const loginElement = this.getLoginDiv();\n loginElement.classList.add('conquer-display-none');\n registerElement.classList.add('conquer-display-none');\n }\n async addNewLoginSuccessText(message) {\n this.unsetLoginAndRegisterErrors();\n this.conquerLoginSuccess.innerText = message;\n this.conquerLoginSuccess.classList.remove('conquer-display-none');\n }\n async addNewLoginError(error) {\n this.unsetLoginAndRegisterErrors();\n this.conquerLoginSuccess.classList.add('conquer-display-none');\n this.conquerLoginError.innerText = error;\n this.conquerLoginError.classList.remove('conquer-display-none');\n }\n async addNewRegisterError(error) {\n this.unsetLoginAndRegisterErrors();\n this.conquerLoginSuccess.classList.add('conquer-display-none');\n this.conquerRegisterError.innerText = error;\n this.conquerRegisterError.classList.remove('conquer-display-none');\n }\n async unsetLoginAndRegisterErrors() {\n this.conquerRegisterError.classList.add('conquer-display-none');\n this.conquerLoginError.classList.add('conquer-display-none');\n }\n async goToLogin() {\n await this.removeLoginRegisterCombo();\n const loginElement = this.getLoginDiv();\n loginElement.classList.remove('conquer-display-none');\n }\n async addNewLoginRegisterError(message) {\n this.addNewRegisterError(message);\n this.addNewLoginError(message);\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/login.ts?"); + +/***/ }), + +/***/ "./js-src/conquer/interface/new-node.ts": +/*!**********************************************!*\ + !*** ./js-src/conquer/interface/new-node.ts ***! + \**********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ NewNodeUI)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/abstract-top-bar-interface */ \"./js-src/conquer/interface/abstract-top-bar-interface.ts\");\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n\n\nclass NewNodeUI extends _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n getSubmitButton() {\n const submitButton = this.getMainNode().querySelector('button.new-node-form-submit');\n if (submitButton === null || !(submitButton instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('SubmitButton is null');\n }\n return submitButton;\n }\n getErrorElement() {\n const errorElement = this.getMainNode().querySelector('p.conquer-error');\n if (errorElement === null || !(errorElement instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('No error element set');\n }\n return errorElement;\n }\n getSelectNodeType() {\n const selectElement = this.getMainNode().querySelector('select.conquer-node-type');\n if (selectElement === null || !(selectElement instanceof HTMLSelectElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('SelectElementNodeType is null');\n }\n return selectElement;\n }\n getInputNodeName() {\n const nodeName = this.getMainNode().querySelector('input.conquer-node-name');\n if (nodeName === null || !(nodeName instanceof HTMLInputElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('NodeName is null');\n }\n return nodeName;\n }\n getTextAreaNodeDescription() {\n const nodeDescription = this.getMainNode().querySelector('textarea.conquer-node-description');\n if (nodeDescription === null || !(nodeDescription instanceof HTMLTextAreaElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('NodeDescription is null');\n }\n return nodeDescription;\n }\n constructor(coordinates) {\n super();\n this.coordinates = coordinates;\n }\n run() {\n const mainNode = this.getMainNode();\n const form = this.getNodeFromTemplateId('conquer-new-node-form-creation-template');\n mainNode.append(form);\n this.getSubmitButton().addEventListener('click', (event) => {\n event.preventDefault();\n this.onSubmit();\n });\n form.classList.remove('conquer-display-none');\n mainNode.classList.remove('conquer-display-none');\n }\n setError(error) {\n const errorElement = this.getErrorElement();\n errorElement.classList.remove('conquer-display-none');\n errorElement.innerText = error;\n }\n onSubmit() {\n const selectNodeType = this.getSelectNodeType();\n const inputNodeName = this.getInputNodeName();\n const textAreaNodeDescription = this.getTextAreaNodeDescription();\n const description = textAreaNodeDescription.value;\n const nodeName = inputNodeName.value;\n const selectedOptionsNodeType = selectNodeType.selectedOptions;\n if (selectedOptionsNodeType.length < 1) {\n this.setError('Debes selecionar un tipo de nodo.');\n return;\n }\n const selectedOptionNodeType = selectedOptionsNodeType[0];\n const nodeType = selectedOptionNodeType.value;\n if (nodeName.length < 5) {\n this.setError('Todos los nodos deben tener un nombre mayor a 4 caracteres.');\n return;\n }\n const urlNode = new URL('/conquer/node', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n fetch(urlNode, {\n method: 'PUT',\n body: JSON.stringify({\n description: description,\n name: nodeName,\n type: nodeType,\n coordinates: this.coordinates,\n }),\n }).then(async (res) => {\n let responseBody;\n try {\n responseBody = await res.json();\n }\n catch (error) {\n this.setError('Respuesta erronea del servidor.');\n return;\n }\n if (res.status !== 200) {\n this.setError(responseBody.error);\n return;\n }\n this.runCallbacks('close');\n });\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/new-node.ts?"); /***/ }), @@ -145,7 +166,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Login)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_interface_login__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/login */ \"./js-src/conquer/interface/login.ts\");\n\nclass Login {\n constructor(conquerInterfaceManager) {\n this.cachedIsLoggedIn = true;\n this.callbacks = {};\n this.conquerInterfaceManager = conquerInterfaceManager;\n }\n async start() {\n this.loopCheckLogin();\n }\n async onRegisterRequest(loginUI, username, password, repeatPassword) {\n const urlUser = new URL('/conquer/user', window.location.protocol +\n '//' + window.location.hostname + ':' + window.location.port);\n let responseJson;\n let status;\n try {\n const response = await fetch(urlUser, {\n method: 'PUT',\n body: JSON.stringify({\n username: username,\n password: password,\n repeat_password: repeatPassword\n })\n });\n responseJson = await response.json();\n status = response.status;\n }\n catch (e) {\n console.error(e);\n loginUI.addNewRegisterError('El servidor ha enviado datos inesperados.');\n return;\n }\n if (status !== 200) {\n loginUI.addNewRegisterError(responseJson.error);\n return;\n }\n loginUI.addNewLoginSuccessText(`Usuario registrado ${username}.`);\n loginUI.goToLogin();\n }\n async loopCheckLogin() {\n window.setInterval(() => {\n this.isLogged().then((isLogged) => {\n if (!isLogged && this.cachedIsLoggedIn) {\n this.onLogout();\n this.cachedIsLoggedIn = false;\n }\n });\n }, 5000);\n }\n async onLogout() {\n const interfaceManager = this.conquerInterfaceManager;\n const loginUI = new _burguillosinfo_conquer_interface_login__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this);\n interfaceManager.push(loginUI);\n }\n async on(name, callback) {\n if (this.callbacks[name] === undefined) {\n this.callbacks[name] = [];\n }\n this.callbacks[name].push(callback);\n }\n async onLoginSuccess(loginUI) {\n this.cachedIsLoggedIn = true;\n this.conquerInterfaceManager.remove(loginUI);\n for (const callback of this.callbacks.login) {\n callback();\n }\n }\n async onLoginRequested(loginUI, username, password) {\n const urlUser = new URL('/conquer/user/login', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n let responseJson;\n let status;\n try {\n const response = await fetch(urlUser, {\n method: 'POST',\n body: JSON.stringify({\n username: username,\n password: password,\n })\n });\n responseJson = await response.json();\n status = response.status;\n }\n catch (e) {\n console.error(e);\n loginUI.addNewLoginError('El servidor ha enviado datos inesperados.');\n return;\n }\n if (status !== 200) {\n loginUI.addNewLoginError(responseJson.error);\n return;\n }\n loginUI.unsetLoginAndRegisterErrors();\n const isLogged = await this.isLogged();\n if (isLogged) {\n this.onLoginSuccess(loginUI);\n }\n }\n async isLogged() {\n const urlUser = new URL('/conquer/user', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n let status;\n try {\n const response = await fetch(urlUser);\n status = response.status;\n }\n catch {\n return false;\n }\n return status === 200;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/login.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Login)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_interface_login__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/login */ \"./js-src/conquer/interface/login.ts\");\n\nclass Login {\n constructor(conquerInterfaceManager) {\n this.cachedIsLoggedIn = null;\n this.callbacks = {};\n this.conquerInterfaceManager = conquerInterfaceManager;\n }\n async start() {\n this.loopCheckLogin();\n }\n async onRegisterRequest(loginUI, username, password, repeatPassword) {\n const urlUser = new URL('/conquer/user', window.location.protocol +\n '//' + window.location.hostname + ':' + window.location.port);\n let responseJson;\n let status;\n try {\n const response = await fetch(urlUser, {\n method: 'PUT',\n body: JSON.stringify({\n username: username,\n password: password,\n repeat_password: repeatPassword\n })\n });\n responseJson = await response.json();\n status = response.status;\n }\n catch (e) {\n console.error(e);\n loginUI.addNewRegisterError('El servidor ha enviado datos inesperados.');\n return;\n }\n if (status !== 200) {\n loginUI.addNewRegisterError(responseJson.error);\n return;\n }\n loginUI.addNewLoginSuccessText(`Usuario registrado ${username}.`);\n loginUI.goToLogin();\n }\n async loopCheckLogin() {\n window.setInterval(() => {\n this.isLogged().then((isLogged) => {\n if (isLogged) {\n if (this.cachedIsLoggedIn !== true) {\n this.cachedIsLoggedIn = true;\n this.onLoginSuccess();\n }\n return;\n }\n if (this.cachedIsLoggedIn !== false) {\n this.cachedIsLoggedIn = false;\n this.onLogout();\n }\n });\n }, 5000);\n }\n async onLogout() {\n const interfaceManager = this.conquerInterfaceManager;\n const loginUI = new _burguillosinfo_conquer_interface_login__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this);\n for (const callback of this.callbacks.logout) {\n callback();\n }\n loginUI.on('close', () => {\n interfaceManager.remove(loginUI);\n });\n interfaceManager.push(loginUI);\n }\n async on(name, callback) {\n if (this.callbacks[name] === undefined) {\n this.callbacks[name] = [];\n }\n this.callbacks[name].push(callback);\n }\n async onLoginSuccess() {\n this.cachedIsLoggedIn = true;\n for (const callback of this.callbacks.login) {\n callback();\n }\n }\n async onLoginRequested(loginUI, username, password) {\n const urlUser = new URL('/conquer/user/login', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n let responseJson;\n let status;\n try {\n const response = await fetch(urlUser, {\n method: 'POST',\n body: JSON.stringify({\n username: username,\n password: password,\n })\n });\n responseJson = await response.json();\n status = response.status;\n }\n catch (e) {\n console.error(e);\n loginUI.addNewLoginError('El servidor ha enviado datos inesperados.');\n return;\n }\n if (status !== 200) {\n loginUI.addNewLoginError(responseJson.error);\n return;\n }\n loginUI.unsetLoginAndRegisterErrors();\n const isLogged = await this.isLogged();\n if (isLogged) {\n this.onLoginSuccess();\n }\n }\n async isLogged() {\n const urlUser = new URL('/conquer/user', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n let status;\n try {\n const response = await fetch(urlUser);\n status = response.status;\n }\n catch {\n return false;\n }\n return status === 200;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/login.ts?"); /***/ }), @@ -156,7 +177,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ MapNode)\n/* harmony export */ });\nclass MapNode {\n constructor(style, node, id) {\n this.style = style;\n this.node = node.clone();\n this.id = id;\n this.node.setProperties({ type: this.id });\n }\n getId() {\n return this.id;\n }\n getNode() {\n return this.node;\n }\n getStyle() {\n return this.style;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/map-node.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! typescript-json-serializer */ \"./node_modules/typescript-json-serializer/dist/index.esm.js\");\n/* harmony import */ var ol_style_Style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ol/style/Style */ \"./node_modules/ol/style/Style.js\");\n/* harmony import */ var ol_Feature__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ol/Feature */ \"./node_modules/ol/Feature.js\");\n/* harmony import */ var ol_style_Circle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ol/style/Circle */ \"./node_modules/ol/style/Circle.js\");\n/* harmony import */ var ol_geom_Point__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ol/geom/Point */ \"./node_modules/ol/geom/Point.js\");\n/* harmony import */ var ol_style_Fill__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ol/style/Fill */ \"./node_modules/ol/style/Fill.js\");\n/* harmony import */ var ol_style_Stroke__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ol/style/Stroke */ \"./node_modules/ol/style/Stroke.js\");\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\nvar __param = (undefined && undefined.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};\n\n\n\n\n\n\n\nlet MapNode = class MapNode {\n constructor(uuid, coordinate_1, coordinate_2, type, name, description, kind) {\n this.uuid = uuid;\n this.coordinate_1 = coordinate_1;\n this.coordinate_2 = coordinate_2;\n this.type = type;\n this.name = name;\n this.description = description;\n this.kind = kind;\n this.feature = null;\n }\n getType() {\n return this.type;\n }\n getName() {\n return this.name;\n }\n getDescription() {\n return this.description;\n }\n getId() {\n return 'node-' + this.uuid;\n }\n getFeature() {\n if (this.feature === null) {\n console.log(this.coordinate_1);\n console.log(this.coordinate_2);\n this.feature = new ol_Feature__WEBPACK_IMPORTED_MODULE_1__[\"default\"]({\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_2__[\"default\"]([this.coordinate_1, this.coordinate_2]),\n type: 'node-' + this.uuid,\n });\n }\n return this.feature;\n }\n getStyle() {\n return new ol_style_Style__WEBPACK_IMPORTED_MODULE_3__[\"default\"]({\n image: new ol_style_Circle__WEBPACK_IMPORTED_MODULE_4__[\"default\"]({\n radius: 14,\n fill: new ol_style_Fill__WEBPACK_IMPORTED_MODULE_5__[\"default\"]({ color: 'white' }),\n stroke: new ol_style_Stroke__WEBPACK_IMPORTED_MODULE_6__[\"default\"]({\n color: 'gray',\n width: 2,\n })\n })\n });\n }\n};\nMapNode = __decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonObject)(),\n __param(0, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(1, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(2, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(3, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(4, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(5, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(6, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __metadata(\"design:paramtypes\", [String, Number, Number, String, String, String, String])\n], MapNode);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MapNode);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/map-node.ts?"); /***/ }), @@ -167,7 +188,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nvar MapState;\n(function (MapState) {\n MapState[MapState[\"NOTHING\"] = 0] = \"NOTHING\";\n MapState[MapState[\"NORMAL\"] = 1] = \"NORMAL\";\n MapState[MapState[\"FREE_MOVE\"] = 2] = \"FREE_MOVE\";\n MapState[MapState[\"FREE_ROTATION\"] = 4] = \"FREE_ROTATION\";\n MapState[MapState[\"CREATE_NODE\"] = 8] = \"CREATE_NODE\";\n MapState[MapState[\"SELECT_WHERE_TO_CREATE_NODE\"] = 16] = \"SELECT_WHERE_TO_CREATE_NODE\";\n})(MapState || (MapState = {}));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MapState);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/map-state.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nvar MapState;\n(function (MapState) {\n MapState[MapState[\"NOTHING\"] = 0] = \"NOTHING\";\n MapState[MapState[\"NORMAL\"] = 1] = \"NORMAL\";\n MapState[MapState[\"FREE_MOVE\"] = 2] = \"FREE_MOVE\";\n MapState[MapState[\"FREE_ROTATION\"] = 4] = \"FREE_ROTATION\";\n MapState[MapState[\"CREATE_NODE\"] = 8] = \"CREATE_NODE\";\n MapState[MapState[\"SELECT_WHERE_TO_CREATE_NODE\"] = 16] = \"SELECT_WHERE_TO_CREATE_NODE\";\n MapState[MapState[\"FILLING_FORM_CREATE_NODE\"] = 32] = \"FILLING_FORM_CREATE_NODE\";\n})(MapState || (MapState = {}));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MapState);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/map-state.ts?"); + +/***/ }), + +/***/ "./js-src/conquer/serializer.ts": +/*!**************************************!*\ + !*** ./js-src/conquer/serializer.ts ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! typescript-json-serializer */ \"./node_modules/typescript-json-serializer/dist/index.esm.js\");\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (new typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonSerializer({\n errorCallback: typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.throwError,\n additionalPropertiesPolicy: 'disallow',\n}));\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/serializer.ts?"); /***/ }), @@ -182,6 +214,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/typescript-json-serializer/dist/index.esm.js": +/*!*******************************************************************!*\ + !*** ./node_modules/typescript-json-serializer/dist/index.esm.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ JsonObject: () => (/* binding */ P),\n/* harmony export */ JsonProperty: () => (/* binding */ g),\n/* harmony export */ JsonSerializer: () => (/* binding */ v),\n/* harmony export */ JsonSerializerOptions: () => (/* binding */ d),\n/* harmony export */ isNullish: () => (/* binding */ l),\n/* harmony export */ logError: () => (/* binding */ y),\n/* harmony export */ throwError: () => (/* binding */ f)\n/* harmony export */ });\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ \"./node_modules/typescript-json-serializer/node_modules/tslib/tslib.es6.mjs\");\n/* harmony import */ var reflect_metadata__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! reflect-metadata */ \"./node_modules/reflect-metadata/Reflect.js\");\n/* harmony import */ var reflect_metadata__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reflect_metadata__WEBPACK_IMPORTED_MODULE_0__);\nvar r=function(){function e(){}return e.getBaseClass=function(e){return e?Reflect.getPrototypeOf(e):void 0},e.getJsonPropertiesMetadata=function(t,r){if(t){var i=\"\"+e.apiMap+(r||t.constructor.name);return Reflect.getMetadata(i,t)}},e.getParamTypes=function(t){return t?Reflect.getMetadata(e.designParamTypes,t):void 0},e.getJsonObjectMetadata=function(t){return t?Reflect.getMetadata(e.apiMapJsonObject,t):void 0},e.getType=function(t,r){return t?Reflect.getMetadata(e.designType,t,r):void 0},e.isJsonObject=function(t){return!!t&&Reflect.hasOwnMetadata(e.apiMapJsonObject,t)},e.setJsonPropertiesMetadata=function(t,r){if(r){var i=\"\"+e.apiMap+r.constructor.name;Reflect.defineMetadata(i,t,r)}},e.setJsonObject=function(t,r){r&&Reflect.defineMetadata(e.apiMapJsonObject,t,r)},e.setType=function(t,r,i){r&&t&&Reflect.defineMetadata(e.designType,t,r,i)},e.apiMap=\"api:map:\",e.apiMapJsonObject=e.apiMap+\"jsonObject\",e.designType=\"design:type\",e.designParamTypes=\"design:paramtypes\",e}(),i=function(e){return\"string\"==typeof e},o=function(e){return null!==e&&\"object\"==typeof e&&!n(e)},n=function(e){return Array.isArray(e)},a=function(e){return\"[object Date]\"===toString.call(e)},s=function(e){return r.isJsonObject(e)},l=function(e){return[null,void 0].includes(e)},u=function(e){return e instanceof Set},c=function(e){try{var t=JSON.parse(e);return\"object\"==typeof t?t:e}catch(t){return e}},p=function(e,t){return e.filter((function(e){return!t.some((function(t){return e===t}))}))},d=function(){this.errorCallback=y,this.nullishPolicy={undefined:\"remove\",null:\"allow\"},this.additionalPropertiesPolicy=\"remove\"},f=function(e){throw new Error(e)},y=function(e){console.error(e)},v=function(){function f(e){this.options=new d,this.options=(0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({},this.options),e)}return f.prototype.deserialize=function(e,t){return i(e)&&(e=c(e)),n(e)?this.deserializeObjectArray(e,t):o(e)?this.deserializeObject(e,t):void this.error(\"Fail to deserialize: value is not an Array nor an Object.\\nReceived: \"+JSON.stringify(e)+\".\")},f.prototype.deserializeObject=function(t,n){var a,s=this;if(null===t)return\"disallow\"===this.options.nullishPolicy.null&&this.error(\"Fail to deserialize: null is not assignable to type Object.\"),null;if(void 0!==t){if(i(t)&&(t=c(t)),o(t)){var u;if(function(e){if(\"function\"!=typeof e)return!1;try{Reflect.construct(String,[],e)}catch(e){return!1}return!0}(n)){var d=Object.create(n.prototype),f=r.getJsonObjectMetadata(d.constructor),y=null!==(a=null==f?void 0:f.constructorParams)&&void 0!==a?a:[];u=new(n.bind.apply(n,(0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)([void 0],y)))}else u=n;var v=this.getJsonPropertiesMetadata(u);if(!v)return u;var h=Object.keys(v);if(h.forEach((function(e){var r=v[e],i=s.deserializeProperty(u,e,t,r);s.checkRequiredProperty(r,u,e,i,t,!1);var o=u[e];i===o||(null!==i||void 0!==o)&&l(i)||(o=i),s.isAllowedProperty(e,o)&&(u[e]=o)})),\"remove\"===this.options.additionalPropertiesPolicy)return u;var P=p(Object.keys(t),h);return P.length?(\"disallow\"===this.options.additionalPropertiesPolicy?this.error(\"Additional properties detected in \"+JSON.stringify(t)+\": \"+P+\".\"):\"allow\"===this.options.additionalPropertiesPolicy&&P.forEach((function(e){return u[e]=t[e]})),u):u}this.error(\"Fail to deserialize: type '\"+typeof t+\"' is not assignable to type 'Object'.\\nReceived: \"+JSON.stringify(t))}else\"disallow\"===this.options.nullishPolicy.undefined&&this.error(\"Fail to deserialize: undefined is not assignable to type Object.\")},f.prototype.deserializeObjectArray=function(e,t){var r=this;if(null===e)return\"disallow\"===this.options.nullishPolicy.null&&this.error(\"Fail to deserialize: null is not assignable to type Array.\"),null;if(void 0!==e){if(i(e)&&(e=c(e)),n(e))return e.reduce((function(e,i){var o=r.deserializeObject(i,t);return(!l(o)||null===o&&\"remove\"!==r.options.nullishPolicy.null||void 0===o&&\"remove\"!==r.options.nullishPolicy.undefined)&&e.push(o),e}),[]);this.error(\"Fail to deserialize: type '\"+typeof e+\"' is not assignable to type 'Array'.\\nReceived: \"+JSON.stringify(e))}else\"disallow\"===this.options.nullishPolicy.undefined&&this.error(\"Fail to deserialize: undefined is not assignable to type Array.\")},f.prototype.serialize=function(e){return n(e)?this.serializeObjectArray(e):o(e)?this.serializeObject(e):void this.error(\"Fail to serialize: value is not an Array nor an Object.\\nReceived: \"+JSON.stringify(e)+\".\")},f.prototype.serializeObject=function(e){var t=this;if(null===e)return\"disallow\"===this.options.nullishPolicy.null&&this.error(\"Fail to serialize: null is not assignable to type Object.\"),null;if(void 0!==e){if(!o(e))return e;var r=this.getJsonPropertiesMetadata(e);if(!r)return e;var i={},a=Object.keys(e),s=Object.keys(r);if(s.forEach((function(o){var s=r[o];if(a.includes(o)){var l=void 0;s.beforeSerialize&&(l=e[o],e[o]=s.beforeSerialize(e[o],e));var u=t.serializeProperty(e,o,s);if(s.afterSerialize&&(u=s.afterSerialize(u,e)),e[o]=l||e[o],n(s.name))s.name.forEach((function(e){t.isAllowedProperty(e,u[e])&&(i[e]=u[e])}));else if(t.checkRequiredProperty(s,e,o,u,e),t.isAllowedProperty(o,u))if(s.isNameOverridden||void 0===t.options.formatPropertyName)i[s.name]=u;else{var c=t.options.formatPropertyName(s.name);i[c]=u}}else n(s.name)?s.name.forEach((function(e){t.isAllowedProperty(e,void 0)&&(i[e]=void 0)})):(t.checkRequiredProperty(s,e,o,void 0,e),t.isAllowedProperty(o,void 0)&&(i[s.name]=void 0))})),\"remove\"===this.options.additionalPropertiesPolicy)return i;var l=p(a,s);return l.length?(\"disallow\"===this.options.additionalPropertiesPolicy?this.error(\"Additional properties detected in \"+JSON.stringify(e)+\": \"+l+\".\"):\"allow\"===this.options.additionalPropertiesPolicy&&l.forEach((function(t){return i[t]=e[t]})),i):i}\"disallow\"===this.options.nullishPolicy.undefined&&this.error(\"Fail to serialize: undefined is not assignable to type Object.\")},f.prototype.serializeObjectArray=function(e){var t=this;if(null===e)return\"disallow\"===this.options.nullishPolicy.null&&this.error(\"Fail to serialize: null is not assignable to type Array.\"),null;if(void 0!==e){if(n(e))return e.reduce((function(e,r){var i=t.serializeObject(r);return(!l(i)||null===i&&\"remove\"!==t.options.nullishPolicy.null||void 0===i&&\"remove\"!==t.options.nullishPolicy.undefined)&&e.push(i),e}),[]);this.error(\"Fail to serialize: type '\"+typeof e+\"' is not assignable to type 'Array'.\\nReceived: \"+JSON.stringify(e)+\".\")}else\"disallow\"===this.options.nullishPolicy.undefined&&this.error(\"Fail to serialize: undefined is not assignable to type Array.\")},f.prototype.checkRequiredProperty=function(e,t,r,i,o,n){if(void 0===n&&(n=!0),e.required&&l(i)&&l(t[r])){var a=t.constructor.name;this.error(\"Fail to \"+(n?\"serialize\":\"deserialize\")+\": Property '\"+r+\"' is required in \"+a+\" \"+JSON.stringify(o)+\".\")}},f.prototype.deserializeProperty=function(e,t,i,o){if(!l(i)){var n=this.getDataSource(i,o,this.options.formatPropertyName);if(l(n))return n;var a,u=r.getType(e,t),c=this.getDataStructureInformation(u,e[t],o),p=c.isArrayProperty,d=c.isSetProperty,f=c.isMapProperty,y=c.isDictionaryProperty,v=o.type||u;o.beforeDeserialize&&(n=o.beforeDeserialize(n,e));var h=o.predicate;return y||f?(a=this.deserializeDictionary(n,v,h),f&&(a=new Map(Object.entries(a)))):p||d?(a=this.deserializeArray(n,v,h),d&&(a=new Set(a))):!s(v)&&!h||h&&!h(n,i)?a=this.deserializePrimitive(n,v.name):(v=o.predicate?o.predicate(n,i):v,a=this.deserializeObject(n,v)),o.afterDeserialize&&(a=o.afterDeserialize(a,e)),a}},f.prototype.deserializePrimitive=function(e,t){if(l(t))return e;if(typeof e===(t=t.toLowerCase()))return e;var r=\"Fail to deserialize: type '\"+typeof e+\"' is not assignable to type '\"+t+\"'.\\nReceived: \"+JSON.stringify(e);switch(t){case\"string\":var i=e.toString();return\"[object Object]\"===i?void this.error(r):i;case\"number\":return function(e){return\"number\"==typeof e}(e)?+e:void this.error(r);case\"boolean\":return void this.error(r);case\"date\":return function(e){return!a(e)&&!n(e)&&!isNaN(Date.parse(e))}(e)?new Date(e):void this.error(r);default:return e}},f.prototype.deserializeDictionary=function(e,t,r){var i=this;if(o(e)){var a={};return Object.keys(e).forEach((function(o){var s=e[o];a[o]=n(s)?s.map((function(o){return i.deserializeDictionaryProperty(e,o,t,r)})):i.deserializeDictionaryProperty(e,s,t,r)})),a}this.error(\"Fail to deserialize: type '\"+typeof e+\"' is not assignable to type 'Dictionary'.\\nReceived: \"+JSON.stringify(e)+\".\")},f.prototype.deserializeDictionaryProperty=function(e,t,r,i){var o=i?i(t,e):void 0;return s(r)||o?this.deserializeObject(t,o||r):this.deserializePrimitive(t,typeof t)},f.prototype.deserializeArray=function(e,t,r){var i=this;if(n(e))return e.reduce((function(o,n){var a;return s(t)||r?(t=r?r(n,e):t,a=i.deserializeObject(n,t)):a=i.deserializePrimitive(n,typeof n),(!l(a)||null===a&&\"remove\"!==i.options.nullishPolicy.null||void 0===a&&\"remove\"!==i.options.nullishPolicy.undefined)&&o.push(a),o}),[]);this.error(\"Fail to deserialize: type '\"+typeof e+\"' is not assignable to type 'Array'.\\nReceived: \"+JSON.stringify(e))},f.prototype.error=function(e){this.options.errorCallback&&this.options.errorCallback(e)},f.prototype.getClassesJsonPropertiesMetadata=function(e,t){return e?e.reduce((function(e,i){var o=r.getJsonPropertiesMetadata(t,i);return o&&e.push(o),e}),[]):[]},f.prototype.getDataSource=function(e,t,r){var i=t.name,o=t.isNameOverridden;if(n(i)){var a={};return i.forEach((function(t){return a[t]=e[t]})),a}return!o&&r?(i=r(i),e[i]):e[i]},f.prototype.getDataStructureInformation=function(e,t,r){var i,o,a,s,l;if(r.dataStructure)return{isArrayProperty:null!==(i=\"array\"===r.dataStructure)&&void 0!==i&&i,isDictionaryProperty:null!==(o=\"dictionary\"===r.dataStructure)&&void 0!==o&&o,isMapProperty:null!==(a=\"map\"===r.dataStructure)&&void 0!==a&&a,isSetProperty:null!==(s=\"set\"===r.dataStructure)&&void 0!==s&&s};var c,p=null===(l=null==e?void 0:e.name)||void 0===l?void 0:l.toLowerCase();return\"object\"===p?{isArrayProperty:n(t),isDictionaryProperty:!1,isMapProperty:(c=t,c instanceof Map),isSetProperty:u(t)}:{isArrayProperty:\"array\"===p,isDictionaryProperty:!1,isMapProperty:\"map\"===p,isSetProperty:\"set\"===p}},f.prototype.getJsonPropertiesMetadata=function(t){var i,o=(null!==(i=r.getJsonObjectMetadata(t.constructor))&&void 0!==i?i:{}).baseClassNames,n=r.getJsonPropertiesMetadata(t);if(!(n||o&&o.length))return n;if(o&&o.length){var a=this.getClassesJsonPropertiesMetadata(o,t);return this.mergeJsonPropertiesMetadata.apply(this,(0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)([],a),[n]))}return n},f.prototype.isAllowedProperty=function(e,t){if(l(t)){if(\"disallow\"===this.options.nullishPolicy[\"\"+t])return this.error(\"Disallowed \"+t+\" value detected: \"+e+\".\"),!1;if(\"remove\"===this.options.nullishPolicy[\"\"+t])return!1}return!0},f.prototype.mergeJsonPropertiesMetadata=function(){for(var e=[],r=0;r-1&&n.set(r,t[0])};s=o.exec(r);)u();return n},m=function(e,n){var a={name:e.toString()};return n?i(n)?(a.name=n,a.isNameOverridden=!0,a):(o(n)&&(a=(0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({},a),n),n.name&&(a.name=n.name,a.isNameOverridden=!0),function(e){if(!e)return!1;var t=r.getParamTypes(e),i=e.length;return(1===i||2===i)&&!t}(n.type)&&(delete a.type,a.predicate=n.type)),a):a};\n\n\n//# sourceURL=webpack://BurguillosInfo/./node_modules/typescript-json-serializer/dist/index.esm.js?"); + +/***/ }), + /***/ "./node_modules/ol/Collection.js": /*!***************************************!*\ !*** ./node_modules/ol/Collection.js ***! @@ -2061,6 +2104,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ VERSION: () => (/* binding */ VERSION),\n/* harmony export */ abstract: () => (/* binding */ abstract),\n/* harmony export */ getUid: () => (/* binding */ getUid)\n/* harmony export */ });\n/**\n * @module ol/util\n */\n\n/**\n * @return {never} Any return.\n */\nfunction abstract() {\n throw new Error('Unimplemented abstract method.');\n}\n\n/**\n * Counter for getUid.\n * @type {number}\n * @private\n */\nlet uidCounter_ = 0;\n\n/**\n * Gets a unique ID for an object. This mutates the object so that further calls\n * with the same object as a parameter returns the same value. Unique IDs are generated\n * as a strictly increasing sequence. Adapted from goog.getUid.\n *\n * @param {Object} obj The object to get the unique ID for.\n * @return {string} The unique ID for the object.\n * @api\n */\nfunction getUid(obj) {\n return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));\n}\n\n/**\n * OpenLayers version.\n * @type {string}\n */\nconst VERSION = '8.1.0';\n\n\n//# sourceURL=webpack://BurguillosInfo/./node_modules/ol/util.js?"); +/***/ }), + +/***/ "./node_modules/typescript-json-serializer/node_modules/tslib/tslib.es6.mjs": +/*!**********************************************************************************!*\ + !*** ./node_modules/typescript-json-serializer/node_modules/tslib/tslib.es6.mjs ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource),\n/* harmony export */ __assign: () => (/* binding */ __assign),\n/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator),\n/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator),\n/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues),\n/* harmony export */ __await: () => (/* binding */ __await),\n/* harmony export */ __awaiter: () => (/* binding */ __awaiter),\n/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet),\n/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn),\n/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet),\n/* harmony export */ __createBinding: () => (/* binding */ __createBinding),\n/* harmony export */ __decorate: () => (/* binding */ __decorate),\n/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources),\n/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate),\n/* harmony export */ __exportStar: () => (/* binding */ __exportStar),\n/* harmony export */ __extends: () => (/* binding */ __extends),\n/* harmony export */ __generator: () => (/* binding */ __generator),\n/* harmony export */ __importDefault: () => (/* binding */ __importDefault),\n/* harmony export */ __importStar: () => (/* binding */ __importStar),\n/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject),\n/* harmony export */ __metadata: () => (/* binding */ __metadata),\n/* harmony export */ __param: () => (/* binding */ __param),\n/* harmony export */ __propKey: () => (/* binding */ __propKey),\n/* harmony export */ __read: () => (/* binding */ __read),\n/* harmony export */ __rest: () => (/* binding */ __rest),\n/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers),\n/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName),\n/* harmony export */ __spread: () => (/* binding */ __spread),\n/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray),\n/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays),\n/* harmony export */ __values: () => (/* binding */ __values),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nfunction __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nvar __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nfunction __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nfunction __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nfunction __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nfunction __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nfunction __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nfunction __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nfunction __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nfunction __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nfunction __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nfunction __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nvar __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nfunction __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nfunction __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nfunction __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nfunction __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nfunction __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nfunction __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nfunction __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nfunction __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nfunction __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nfunction __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nfunction __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nfunction __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nfunction __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nfunction __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nfunction __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nfunction __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nfunction __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nfunction __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n});\n\n\n//# sourceURL=webpack://BurguillosInfo/./node_modules/typescript-json-serializer/node_modules/tslib/tslib.es6.mjs?"); + /***/ }) /******/ }); @@ -2114,6 +2168,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /******/ }; /******/ })(); /******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) diff --git a/templates/conquer/index.html.ep b/templates/conquer/index.html.ep index ae163da..a63548c 100644 --- a/templates/conquer/index.html.ep +++ b/templates/conquer/index.html.ep @@ -10,11 +10,30 @@
+
+
+

+ +
+ +
+ +
+ +
+
+
-
+
diff --git a/tsconfig.json b/tsconfig.json index ede1d4c..384acce 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,7 @@ { "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, "outDir": "./public/js/", "noImplicitAny": true, "module": "es2020",