@seatsyoo/angular 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tikyoo, S.L.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,304 @@
1
- # Temporary Holding Version
1
+ # @seatsyoo/angular
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ El visor de mapas de asientos de **Seatsyoo** como componente de Angular: el comprador ve el plano del recinto,
4
+ elige sus butacas (quedan retenidas a su nombre mientras paga) y ve en tiempo real lo que otros compran. Es el
5
+ visor de [`@seatsyoo/visor`](https://www.npmjs.com/package/@seatsyoo/visor) envuelto en un componente standalone,
6
+ `<seatsyoo-chart>`, con entradas, salidas y tipos de TypeScript.
7
+
8
+ *(English summary below.)*
9
+
10
+ ## Instalación
11
+
12
+ ```sh
13
+ npm install @seatsyoo/angular
14
+ # o: pnpm add @seatsyoo/angular · yarn add @seatsyoo/angular
15
+ ```
16
+
17
+ Funciona con Angular 17 o posterior, con zone.js o sin él (zoneless), y con renderizado en el servidor (SSR).
18
+ Con él se instala `@seatsyoo/visor`, su única dependencia.
19
+
20
+ ## Uso
21
+
22
+ ```ts
23
+ import { Component, signal } from "@angular/core";
24
+ import { SeatsyooChartComponent, type SelectedObject } from "@seatsyoo/angular";
25
+
26
+ @Component({
27
+ selector: "app-entradas",
28
+ standalone: true, // hace falta hasta Angular 18; desde la 19 es lo normal
29
+ imports: [SeatsyooChartComponent],
30
+ template: `
31
+ <!-- El visor ocupa todo el elemento: dale altura. -->
32
+ <seatsyoo-chart
33
+ style="height: 640px"
34
+ server="https://seatsyoo.example"
35
+ publicKey="pk_tu_clave_publica"
36
+ [event]="evento()"
37
+ (selectionChange)="seleccion.set($event)"
38
+ (holdExpired)="avisar('Se ha acabado el tiempo: vuelve a elegir.')"
39
+ (chartError)="avisar($event.message)"
40
+ />
41
+ <p>{{ seleccion().length }} butacas elegidas</p>
42
+ `,
43
+ })
44
+ export class EntradasComponent {
45
+ evento = signal("hamlet-2026-11-20");
46
+ seleccion = signal<SelectedObject[]>([]);
47
+ avisar(texto: string) {
48
+ alert(texto);
49
+ }
50
+ }
51
+ ```
52
+
53
+ En una aplicación con módulos (`NgModule`), añade `SeatsyooChartComponent` a los `imports` del módulo.
54
+
55
+ Al pagar, manda a tu servidor solo el evento y el token de retención, nunca la lista de lo elegido: tu servidor
56
+ pregunta a Seatsyoo qué retiene ese token, cobra eso y, con el pago confirmado, lo reserva (ver «Vender»). El token y
57
+ los métodos del visor están en la propiedad `chart` del componente:
58
+
59
+ ```ts
60
+ import { viewChild } from "@angular/core";
61
+
62
+ grafico = viewChild.required(SeatsyooChartComponent); // desde Angular 17.2; antes, @ViewChild
63
+
64
+ pagar() {
65
+ const visor = this.grafico().chart; // SeatingChart, o null si aún no está montado
66
+ if (!visor) return;
67
+ const caja = { evento: this.evento(), holdToken: visor.holdToken }; // nada más
68
+ // fetch("/caja", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(caja) })
69
+ }
70
+ ```
71
+
72
+ ### Entradas
73
+
74
+ Las mismas opciones que `render()` de `@seatsyoo/visor`, salvo `container` (es el propio elemento) y los avisos
75
+ (son salidas). Hacen falta `server` y qué enseñar: `event`, `season` (abonos), `link` (el enlace público de un plano,
76
+ solo para ver) o `document` (un plano ya cargado, solo para ver). Con `event` o `season`, también `publicKey`.
77
+
78
+ | Entrada | Qué hace |
79
+ | --- | --- |
80
+ | `server` | La dirección de Seatsyoo de tu cuenta (obligatoria). |
81
+ | `publicKey` | La clave pública de tu espacio. |
82
+ | `event` · `season` · `seasonEvents` · `link` · `document` | Qué se enseña. |
83
+ | `language` | `"es"` (por defecto) o `"en"`. |
84
+ | `maxSelected` | Plazas que se pueden elegir como mucho (10 por defecto; una mesa o un palco enteros cuentan 1). El servidor tiene sus propios topes, y ahí una mesa o un palco enteros cuentan todas sus plazas: ver «Topes de retención». |
85
+ | `pricing` · `currency` · `locale` | Los precios que pone tu web, por clave de categoría (`{ platea: 30 }`), su moneda y su formato. El visor los enseña en la ficha de cada butaca, en la leyenda y en el total, y salen en `price` de lo elegido: lo que cuesta cada unidad de `quantity` (por plaza; una mesa entera, con todas sus sillas), así que `price × quantity` es lo que suma el total del visor. Sin `pricing`, no hay precios (`price` es `null`). Seatsyoo no guarda precios: lo que se cobra lo calcula tu servidor. |
86
+ | `channels` | Canales de venta desde los que se compra. |
87
+ | `holdToken` | Un token de retención creado por tu servidor, en lugar de que el visor cree uno. |
88
+ | `session` | `"continue"` (por defecto) recupera la selección al recargar; `"start"` empieza de cero. |
89
+ | `mode` · `showLegend` · `showSelectionBar` · `floor` · `sectors` · `view3d` · `entrance` · `texts` | Cómo se ve y se usa el plano. |
90
+ | `theme` | `"light"` (por defecto), `"dark"` o `"auto"`. |
91
+ | `colorBy` | `"category"` (por defecto) o `"channel"`. |
92
+ | `statusStyles` · `marks` | Solo con `mode="manager"` (un panel de gestión): nombre, color e icono de cada estado (`StatusStyle`, que no es el formato de la API: ver «Estados propios y marcas»), y marcas sobre plazas que siguen libres, objeto → estado. |
93
+ | `load3d` | Cómo cargar la vista 3D (por defecto se pide al servidor). |
94
+
95
+ **Cuándo se vuelve a montar el visor.** Si cambia cualquier entrada salvo `theme`, `colorBy`, `statusStyles`, `marks`
96
+ y `load3d`, el visor se desmonta y se monta de nuevo con los valores nuevos (lo ya retenido sigue retenido: con
97
+ `session: "continue"`, el visor nuevo lo recupera). Las listas y los objetos (`pricing`, `channels`, `seasonEvents`,
98
+ `texts`, `document`) se comparan por valor: pasar otro objeto con lo mismo no vuelve a montar nada. `theme` y
99
+ `colorBy` se aplican al momento sin volver a montar, y `statusStyles` y `marks` también (`setStatusStyles`,
100
+ `setMarks`), solo si cambia su valor: se comparan como datos (da igual el prototipo, y una clave que vale `undefined`
101
+ es como si no estuviera), así que otro objeto con lo mismo no hace nada. Como con cualquier entrada de Angular, pasa
102
+ un objeto nuevo (cambiar el que ya pasaste, en el sitio, no llega al componente). De `load3d` se usa siempre la última
103
+ función (solo vuelve a montar si se pone o se quita).
104
+ Al volver a montarlo, el visor nuevo avisa otra vez al cargar: `selectionChange` con lo que tenga (nada, si es otro
105
+ evento) y `holdTokenChange` con su token o, si no tiene y el anterior sí, con `null`. Así lo que guardes de esas
106
+ salidas no se queda con lo del evento anterior.
107
+
108
+ Si vuelves a pasar al componente el token que te da `holdTokenChange` como `[holdToken]`, el visor se volverá a
109
+ montar cada vez que cambie: `holdToken` es para un token que crea tu servidor.
110
+
111
+ ### Salidas
112
+
113
+ Con nombres que no chocan con los eventos del DOM:
114
+
115
+ | Salida | Cuándo | Valor |
116
+ | --- | --- | --- |
117
+ | `ready` | El plano está pintado y los estados cargados. | `SeatingChart` |
118
+ | `selectionChange` | Cambia la selección. | `SelectedObject[]` |
119
+ | `objectSelect` · `objectDeselect` | Se elige o se quita un objeto. | `SelectedObject` |
120
+ | `holdExpired` | Se ha acabado el tiempo de la retención. | — |
121
+ | `holdTokenChange` | Cambia el token de retención (o deja de haberlo; también al volver a montar el visor, ver arriba). | `{ token, expiresAt } \| null` |
122
+ | `floorChange` | Se cambia de planta. | `{ id, name }` |
123
+ | `chartError` | Algo ha fallado (`invalid-options` si faltan opciones) o se ha llegado a un tope de retención (`hold-limit`, `hold-limit-ip`, `hold-rate-limited`: no es que el plano no cargue). Si nadie la escucha, sale en la consola. | `{ code, message }` |
124
+
125
+ ### `chart`
126
+
127
+ La instancia del visor (`SeatingChart`) o `null` (en el servidor, antes de montarlo o si las opciones no valen).
128
+ Métodos: `getSelection()`, `holdToken`, `holdExpiresAt`, `refreshHoldToken()`, `clearSelection()`,
129
+ `selectBestAvailable(n, categorías?)`, `statusOf(clave)`, `floors`, `setFloor(id)`, `show3d(clave?)`,
130
+ `zoomToFit()` y `refresh()`. No llames a `destroy()`: lo hace el componente al destruirse. Para cambiar el tema, el
131
+ color, los estilos o las marcas, usa sus entradas (no `setTheme`, `setStatusStyles`… directamente): el componente
132
+ compara con lo que aplicó él.
133
+
134
+ ### Vender
135
+
136
+ A tu servidor la página le manda el evento y el `holdToken`, nada más: nunca la lista de lo elegido. En la caja, tu
137
+ servidor pregunta a Seatsyoo qué retiene ese token (`GET /api/v1/events/{evento}/statuses?holdToken=…`: lo suyo lleva
138
+ `mine: true` y, en una zona de pie, `mq` con las plazas del token; `mq` solo viene si en la zona hay más de una plaza
139
+ ocupada, contando las de otros compradores, y si no viene es 1), calcula el importe con sus precios (precio × plazas:
140
+ una mesa entera cuenta todas sus sillas, como el total del visor) y guarda esa lista con el pedido, cada objeto con su
141
+ cantidad (`{ key, quantity: mq ?? 1 }`). Con el pago confirmado, reserva exactamente lo guardado
142
+ (`POST /api/v1/events/{evento}/actions/book` con `holdToken` y tu número de pedido, `orderId`), sin volver a preguntar.
143
+
144
+ No reserves una lista que mande la página: `book` reserva también objetos libres, así que cualquiera podría añadirle
145
+ butacas que no ha retenido, y saltarse los topes de retención. Es lo que hace la tienda de ejemplo de `@seatsyoo/node`
146
+ (`ejemplo/tienda.ts`: `POST /caja` con `{ evento, holdToken }` y `POST /pagar` con `{ holdToken }`) y lo que cuenta la
147
+ guía de integración de la documentación (**/docs/integracion**).
148
+
149
+ ### Topes de retención
150
+
151
+ Lo que el comprador retiene desde el visor tiene topes en el servidor. Al pasar uno, la butaca no se retiene y llega
152
+ el error a `chartError`:
153
+
154
+ | Código | Qué tope |
155
+ | --- | --- |
156
+ | `hold-limit` (409) | Las «Plazas por comprador» de tu espacio (`maxHoldPerToken`, 10 si no se cambia; lo da `GET /workspace`), por token y evento. Una mesa o un palco que se venden enteros cuentan todas sus plazas. |
157
+ | `hold-limit-ip` (409) | Lo retenido a la vez desde una misma conexión (IP) en un evento, sumando todas sus compras en curso: el 10 % del aforo, hasta 200, y nunca menos que `maxHoldPerToken`. |
158
+ | `hold-rate-limited` (429) | Lo que retiene una misma IP en poco tiempo: como mucho 600 plazas cada 10 minutos (soltar no cuenta). |
159
+
160
+ - `maxSelected` cuenta una mesa o un palco enteros como 1, y el servidor, con todas sus plazas: con
161
+ `maxSelected` y `maxHoldPerToken` en 10, dos mesas de 8 dan `hold-limit`. No pongas `maxSelected` por encima de
162
+ `maxHoldPerToken` y, si vendes mesas o palcos enteros, cuenta con ese error o sube el ajuste.
163
+ - `selectBestAvailable(n)` pide de 1 a 100 plazas, y nunca más que `maxHoldPerToken` (si no, `hold-limit` antes de
164
+ buscar).
165
+ - Un `holdToken` que crea tu servidor con la clave secreta (`POST /api/v1/hold-tokens`) no lleva IP: no cuenta para
166
+ `hold-limit-ip`. Lo que el comprador retiene con él desde el visor sí cuenta para `hold-limit` y `hold-rate-limited`.
167
+ - Lo que hace tu servidor con la clave secreta (retener, reservar) no tiene ninguno de estos topes.
168
+
169
+ Distingue el código en `chartError`: con un tope, el comprador no tiene que leer que el plano no ha cargado.
170
+
171
+ ### Estados propios y marcas (modo «manager»)
172
+
173
+ En un panel de gestión (modo `"manager"`), `statusStyles` dice cómo se ve cada estado y `marks`, qué plazas libres
174
+ llevan una marca. Se sacan de la API con la clave secreta, así que los pide tu servidor y se los da a la página:
175
+
176
+ - `marks` es tal cual el `marks` de `GET /api/v1/events/{evento}/marks` (`{ "marks": { "Platea-A-1":
177
+ "visibilidad-reducida" } }`): objeto → clave del estado.
178
+ - `statusStyles` sale del catálogo de `GET /api/v1/statuses` (`{ statuses, system }`; con `?event={evento}`, solo los
179
+ que valen para ese evento), pero no es el mismo formato: por la clave de cada estado, `{ name, color, icon }`, y el
180
+ icono cambia de forma. `{ type: "text", text }` pasa a `{ text }` y `{ type: "image", src }`, a `{ image: src }`;
181
+ `{ type: "preset", name }` es de la colección del panel, que no se publica: sin icono, o con un trazado tuyo de 24×24
182
+ (`{ path }`). De `system` (los estados de base que tu espacio ha cambiado), solo los que traen `color`, y nunca
183
+ `free`. Un estado de base con `color: null` no pasa, así que el visor lo pinta como siempre y también pierde el
184
+ nombre y el icono propios que le hayas puesto, aunque el panel sí los enseñe (en el modo «manager», «Reservado» en
185
+ vez de tu «Vendida»). Si los quieres, ponle color propio en el panel. Pasar el catálogo tal cual no compila en
186
+ TypeScript y, en JavaScript, rompe el pintado.
187
+
188
+ ```ts
189
+ import type { StatusStyle } from "@seatsyoo/angular";
190
+
191
+ /** Un icono del catálogo de estados (GET /api/v1/statuses). */
192
+ type IconoDeEstado = { type: "preset"; name: string } | { type: "text"; text: string } | { type: "image"; src: string };
193
+ /** Lo que responde GET /api/v1/statuses (lo que hace falta aquí). */
194
+ interface Catalogo {
195
+ statuses: { key: string; name: string; color: string; icon: IconoDeEstado | null }[];
196
+ system: { key: string; name: string | null; color: string | null; icon: IconoDeEstado | null }[];
197
+ }
198
+
199
+ function estilo(name: string | null, color: string, icon: IconoDeEstado | null): StatusStyle {
200
+ // «preset»: sin icono (o tu trazado de 24×24, { path: "M4 12h16" }).
201
+ const forma = icon?.type === "text" ? { text: icon.text } : icon?.type === "image" ? { image: icon.src } : null;
202
+ return { ...(name ? { name } : {}), color, ...(forma ? { icon: forma } : {}) };
203
+ }
204
+
205
+ /** De GET /api/v1/statuses a la opción statusStyles. */
206
+ export function estilosDeEstados({ statuses, system }: Catalogo): Record<string, StatusStyle> {
207
+ const estilos: Record<string, StatusStyle> = {};
208
+ for (const s of statuses) estilos[s.key] = estilo(s.name, s.color, s.icon);
209
+ // De los de base, solo los que tienen color propio: sin él se quedan como los pinta el visor, también con su nombre
210
+ // y su icono de siempre (los tuyos se pierden). «free» no se pinta con estilo.
211
+ for (const s of system) if (s.key !== "free" && s.color) estilos[s.key] = estilo(s.name, s.color, s.icon);
212
+ return estilos;
213
+ }
214
+ ```
215
+
216
+ Después, `<seatsyoo-chart mode="manager" … [statusStyles]="estilos" [marks]="marcas" />`, con `estilos =
217
+ estilosDeEstados(catalogo)` y las marcas tal cual; para cambiarlos, pasa objetos nuevos.
218
+
219
+ ### Zonas, zoneless y SSR
220
+
221
+ - El visor corre **fuera de la zona de Angular**: su cuenta atrás, sus peticiones y su tiempo real no lanzan la
222
+ detección de cambios. Las salidas se emiten **dentro**, así que tu plantilla se actualiza sola.
223
+ - Sin zone.js (zoneless, lo normal desde Angular 21) funciona igual: las salidas marcan la vista del padre.
224
+ - En el servidor (SSR) el elemento sale vacío y el visor no se crea ni pide nada; se monta en el navegador. El
225
+ elemento lleva `ngSkipHydration`: la hidratación no compara el DOM que añade el visor.
226
+
227
+ ## Desarrollo
228
+
229
+ En el repositorio de los SDK de Seatsyoo, con pnpm, desde la raíz:
230
+
231
+ ```sh
232
+ pnpm --filter @seatsyoo/angular build # dist/ con ng-packagr (formato de paquete de Angular)
233
+ pnpm --filter @seatsyoo/angular test # compila y prueba el componente compilado con el visor real
234
+ pnpm --filter @seatsyoo/angular typecheck # tipos de todo y el ejemplo (ejemplo/) con el compilador de Angular
235
+ ```
236
+
237
+ Lo que se publica es `dist/`, no esta carpeta. Con pnpm basta `pnpm pack` aquí: `publishConfig.directory` hace que se
238
+ empaquete `dist/` y `prepack` la compila antes. Con npm, que no entiende `publishConfig.directory`, `pnpm run build` y
239
+ después `npm pack ./dist` (empaquetar esta carpeta con npm se para con un aviso). `dist/package.json` lleva
240
+ `publishConfig.access: "public"`, así que el paquete sale público.
241
+
242
+ ---
243
+
244
+ ## Licencia
245
+
246
+ MIT (archivo `LICENSE`). El visor del que depende, `@seatsyoo/visor`, tiene su propia licencia: se usa gratis para
247
+ integrar Seatsyoo.
248
+
249
+ ## English
250
+
251
+ `@seatsyoo/angular` is the **Seatsyoo** seating chart as an Angular standalone component, `<seatsyoo-chart>`
252
+ (Angular 17+, with or without zone.js, SSR-safe). Install it with `npm install @seatsyoo/angular`, import
253
+ `SeatsyooChartComponent` and give the element a height:
254
+
255
+ ```html
256
+ <seatsyoo-chart style="height: 640px" server="https://seatsyoo.example" publicKey="pk_your_public_key"
257
+ event="hamlet-2026-11-20" (selectionChange)="selection = $event" />
258
+ ```
259
+
260
+ - **Inputs:** every `render()` option of `@seatsyoo/visor` except `container` and the callbacks (`server`,
261
+ `publicKey`, `event`, `season`, `seasonEvents`, `link`, `document`, `channels`, `pricing`, `currency`, `locale`,
262
+ `language`, `maxSelected`, `session`, `holdToken`, `mode`, `showLegend`, `showSelectionBar`, `floor`, `sectors`,
263
+ `view3d`, `entrance`, `texts`, `theme`, `colorBy`, `statusStyles`, `marks`, `load3d`). Changing any of them remounts the chart
264
+ (arrays and objects are compared by value), except `theme`, `colorBy`, `statusStyles` and `marks` (`"manager"`
265
+ mode), which are applied in place when their value changes (compared as data: the prototype doesn't matter and a
266
+ key set to `undefined` counts as missing; pass a new object, as with any Angular input), and `load3d`.
267
+ - **Prices:** Seatsyoo does not store prices. Pass yours with `pricing` (per category key, with `currency` and
268
+ `locale`): the chart shows them and they come in `price` of each selected object (`null` without `pricing`).
269
+ `price` is what each unit of `quantity` costs (per place; a whole table, all its chairs), so `price × quantity` adds
270
+ up to the chart's total.
271
+ - **Selling:** the page sends your server the event and the `holdToken`, nothing else. At checkout your server asks
272
+ Seatsyoo what that token holds (`GET /api/v1/events/{event}/statuses?holdToken=…`: `mine: true`, plus `mq` in a
273
+ standing area with the token's places, which only comes when more than one place is taken there, counting other
274
+ buyers'; when it is missing, it is 1), prices it (price × places: a whole table counts all its chairs, as in the
275
+ viewer's total) and stores that list with the order, each object with an explicit quantity
276
+ (`{ key, quantity: mq ?? 1 }`). Once paid, it books exactly that list (`POST …/actions/book` with
277
+ `holdToken` and your `orderId`). Never book a list sent by the page: `book` also books free objects, so anyone could
278
+ add seats they never held. The `@seatsyoo/node` example store (`ejemplo/tienda.ts`) does this; see
279
+ **/en/docs/integration**.
280
+ - **Hold limits** (errors in `chartError`): `hold-limit` (409, the workspace's "places per buyer", `maxHoldPerToken`, 10
281
+ by default, per token and event; a whole table or box counts all its places), `hold-limit-ip` (409, per connection
282
+ and event: 10% of the capacity, up to 200, never below `maxHoldPerToken`) and `hold-rate-limited` (429, 600 places
283
+ held per IP every 10 minutes). `maxSelected` counts a whole table or box as 1, so keep it at or below
284
+ `maxHoldPerToken` and expect `hold-limit` with whole tables. `selectBestAvailable(n)` takes 1 to 100 and never more
285
+ than `maxHoldPerToken`. A `holdToken` your server creates with the secret key has no IP, so it does not count for
286
+ `hold-limit-ip`, but what the buyer holds with it from the viewer still counts for `hold-limit` and
287
+ `hold-rate-limited`. Your server's own calls with the secret key have none of these limits. Tell the codes apart in
288
+ `chartError`: with a hold limit, the buyer should not read that the chart failed to load.
289
+ - **Custom statuses and marks** (`"manager"` mode): `marks` is the `marks` of `GET /api/v1/events/{event}/marks` as
290
+ is. `statusStyles` is not the shape of `GET /api/v1/statuses`: per status key, `{ name, color, icon }` with the icon
291
+ converted (`text` → `{ text }`, `image` → `{ image: src }`, `preset` → no icon or your own 24×24 `{ path }`); from
292
+ `system`, only entries with a `color`, never `free` (one with `color: null` stays exactly as the viewer draws it:
293
+ its own name and icon are lost too, even if the panel shows them; give it its own colour if you want them). Both
294
+ need the secret key: your server fetches them. The `estilosDeEstados` function above does the conversion.
295
+ - **Outputs:** `ready`, `selectionChange`, `objectSelect`, `objectDeselect`, `holdExpired`, `holdTokenChange`,
296
+ `floorChange` and `chartError` (`{ code, message }`; logged to the console when nobody listens). After a remount
297
+ the new chart reports its selection again and, if the previous chart had a hold token and the new one has none,
298
+ `holdTokenChange` emits `null` once it has loaded.
299
+ - **`chart`:** the `SeatingChart` instance (or `null`), with `getSelection()`, `holdToken`, `clearSelection()`,
300
+ `selectBestAvailable()`… The component calls `destroy()` when it is destroyed.
301
+ - The chart runs outside Angular's zone and outputs are emitted inside it. On the server nothing is created or
302
+ fetched; the chart mounts in the browser.
303
+
304
+ License: MIT. The viewer it depends on, `@seatsyoo/visor`, has its own license (free to use to integrate Seatsyoo).
@@ -0,0 +1,357 @@
1
+ import { isPlatformBrowser } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, NgZone, Output, PLATFORM_ID, inject } from "@angular/core";
4
+ import { SeatingChart } from "@seatsyoo/visor";
5
+ const OPCIONES_DE_IDENTIDAD = [
6
+ "server",
7
+ "publicKey",
8
+ "event",
9
+ "link",
10
+ "document",
11
+ "season",
12
+ "seasonEvents",
13
+ "channels",
14
+ "pricing",
15
+ "currency",
16
+ "locale",
17
+ "language",
18
+ "maxSelected",
19
+ "session",
20
+ "holdToken",
21
+ "mode",
22
+ "showLegend",
23
+ "showSelectionBar",
24
+ "floor",
25
+ "sectors",
26
+ "view3d",
27
+ "entrance",
28
+ "texts"
29
+ ];
30
+ function mismoValor(a, b) {
31
+ if (Object.is(a, b)) return true;
32
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
33
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
34
+ if (Array.isArray(a)) {
35
+ const lista = b;
36
+ return a.length === lista.length && a.every((v, i) => mismoValor(v, lista[i]));
37
+ }
38
+ if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
39
+ if (a instanceof Date) return a.getTime() === b.getTime();
40
+ const objA = a;
41
+ const objB = b;
42
+ const claves = (o) => Object.keys(o).filter((k) => o[k] !== void 0);
43
+ const clavesA = claves(objA);
44
+ if (clavesA.length !== claves(objB).length) return false;
45
+ return clavesA.every((k) => Object.prototype.hasOwnProperty.call(objB, k) && mismoValor(objA[k], objB[k]));
46
+ }
47
+ function cambiosDeIdentidad(antes, ahora) {
48
+ return OPCIONES_DE_IDENTIDAD.filter((k) => !mismoValor(antes[k], ahora[k]));
49
+ }
50
+ function copiaDeDatos(valor) {
51
+ if (Array.isArray(valor)) return valor.map((v) => copiaDeDatos(v));
52
+ if (valor !== null && typeof valor === "object") {
53
+ const entradas = Object.entries(valor).filter(([, v]) => v !== void 0);
54
+ return Object.fromEntries(entradas.map(([k, v]) => [k, copiaDeDatos(v)]));
55
+ }
56
+ return valor;
57
+ }
58
+ function enVivoDe(opciones) {
59
+ return {
60
+ theme: opciones.theme ?? "light",
61
+ colorBy: opciones.colorBy ?? "category",
62
+ statusStyles: copiaDeDatos(opciones.statusStyles ?? {}),
63
+ marks: copiaDeDatos(opciones.marks ?? {})
64
+ };
65
+ }
66
+ function aplicarEnVivo(visor, aplicadas, opciones) {
67
+ const tema = opciones.theme ?? "light";
68
+ if (tema !== aplicadas.theme) {
69
+ visor.setTheme(tema);
70
+ aplicadas.theme = tema;
71
+ }
72
+ const color = opciones.colorBy ?? "category";
73
+ if (color !== aplicadas.colorBy) {
74
+ visor.setColorBy(color);
75
+ aplicadas.colorBy = color;
76
+ }
77
+ const estilos = copiaDeDatos(opciones.statusStyles ?? {});
78
+ if (!mismoValor(estilos, aplicadas.statusStyles)) {
79
+ aplicadas.statusStyles = estilos;
80
+ visor.setStatusStyles(estilos);
81
+ }
82
+ const marcas = copiaDeDatos(opciones.marks ?? {});
83
+ if (!mismoValor(marcas, aplicadas.marks)) {
84
+ aplicadas.marks = marcas;
85
+ visor.setMarks(marcas);
86
+ }
87
+ }
88
+ var SeatsyooChartComponent = class SeatsyooChartComponent {
89
+ constructor() {
90
+ this.ready = new EventEmitter();
91
+ this.selectionChange = new EventEmitter();
92
+ this.objectSelect = new EventEmitter();
93
+ this.objectDeselect = new EventEmitter();
94
+ this.holdExpired = new EventEmitter();
95
+ this.holdTokenChange = new EventEmitter();
96
+ this.chartError = new EventEmitter();
97
+ this.floorChange = new EventEmitter();
98
+ this.elemento = inject(ElementRef);
99
+ this.zona = inject(NgZone);
100
+ this.enNavegador = isPlatformBrowser(inject(PLATFORM_ID));
101
+ this.visor = null;
102
+ this.montado = null;
103
+ this.enVivo = enVivoDe({});
104
+ this.montaje = 0;
105
+ this.destruido = false;
106
+ this.tokenAvisado = null;
107
+ }
108
+ get chart() {
109
+ return this.visor;
110
+ }
111
+ ngAfterViewInit() {
112
+ this.montar();
113
+ }
114
+ ngOnChanges() {
115
+ if (!this.montado || this.destruido) return;
116
+ if (this.hayQueVolverAMontar()) {
117
+ this.desmontar();
118
+ this.montar();
119
+ return;
120
+ }
121
+ const visor = this.visor;
122
+ if (!visor) return;
123
+ this.zona.runOutsideAngular(() => aplicarEnVivo(visor, this.enVivo, this.opcionesEnVivo()));
124
+ }
125
+ ngOnDestroy() {
126
+ this.destruido = true;
127
+ this.desmontar();
128
+ }
129
+ identidad() {
130
+ return Object.fromEntries(OPCIONES_DE_IDENTIDAD.map((k) => [k, this[k]]));
131
+ }
132
+ opcionesEnVivo() {
133
+ return {
134
+ theme: this.theme,
135
+ colorBy: this.colorBy,
136
+ statusStyles: this.statusStyles,
137
+ marks: this.marks
138
+ };
139
+ }
140
+ hayQueVolverAMontar() {
141
+ const antes = this.montado;
142
+ if (!antes) return false;
143
+ return cambiosDeIdentidad(antes.identidad, this.identidad()).length > 0 || antes.conLoad3d !== (this.load3d !== void 0);
144
+ }
145
+ montar() {
146
+ if (!this.enNavegador || this.destruido) return;
147
+ const montaje = ++this.montaje;
148
+ const identidad = this.identidad();
149
+ this.montado = {
150
+ identidad,
151
+ conLoad3d: this.load3d !== void 0
152
+ };
153
+ const enVivo = enVivoDe(this.opcionesEnVivo());
154
+ this.enVivo = enVivo;
155
+ const emitir = (salida, valor) => {
156
+ if (montaje !== this.montaje) return;
157
+ this.zona.run(() => salida.emit(valor));
158
+ };
159
+ let sinTokenPendiente = this.tokenAvisado !== null;
160
+ const avisarToken = (token) => {
161
+ if (montaje !== this.montaje) return;
162
+ sinTokenPendiente = false;
163
+ this.tokenAvisado = token;
164
+ this.zona.run(() => this.holdTokenChange.emit(token));
165
+ };
166
+ const avisarSinToken = () => {
167
+ if (sinTokenPendiente) avisarToken(null);
168
+ };
169
+ const opciones = {
170
+ ...quitarIndefinidos(identidad),
171
+ server: identidad.server,
172
+ container: this.elemento.nativeElement,
173
+ ...this.theme !== void 0 ? { theme: this.theme } : {},
174
+ ...this.colorBy !== void 0 ? { colorBy: this.colorBy } : {},
175
+ ...this.statusStyles !== void 0 ? { statusStyles: enVivo.statusStyles } : {},
176
+ ...this.marks !== void 0 ? { marks: enVivo.marks } : {},
177
+ ...this.load3d !== void 0 ? { load3d: () => (this.load3d ?? sinLoad3d)() } : {},
178
+ onReady: (visor) => {
179
+ avisarSinToken();
180
+ emitir(this.ready, visor);
181
+ },
182
+ onChange: (seleccion) => emitir(this.selectionChange, seleccion),
183
+ onSelect: (objeto) => emitir(this.objectSelect, objeto),
184
+ onDeselect: (objeto) => emitir(this.objectDeselect, objeto),
185
+ onHoldExpired: () => emitir(this.holdExpired, void 0),
186
+ onHoldTokenChange: (token) => avisarToken(token),
187
+ onFloorChange: (planta) => emitir(this.floorChange, planta),
188
+ onError: (error) => {
189
+ if (montaje !== this.montaje) return;
190
+ avisarSinToken();
191
+ this.avisarError(error);
192
+ }
193
+ };
194
+ try {
195
+ this.visor = this.zona.runOutsideAngular(() => new SeatingChart(opciones));
196
+ } catch (e) {
197
+ this.visor = null;
198
+ const error = {
199
+ code: "invalid-options",
200
+ message: e instanceof Error ? e.message : String(e)
201
+ };
202
+ queueMicrotask(() => {
203
+ if (montaje !== this.montaje) return;
204
+ avisarSinToken();
205
+ this.avisarError(error);
206
+ });
207
+ }
208
+ }
209
+ desmontar() {
210
+ this.montaje++;
211
+ const visor = this.visor;
212
+ this.visor = null;
213
+ if (visor) this.zona.runOutsideAngular(() => visor.destroy());
214
+ }
215
+ avisarError(error) {
216
+ if (tieneOyentes(this.chartError)) this.zona.run(() => this.chartError.emit(error));
217
+ else console.warn("[seatsyoo]", error.code, error.message);
218
+ }
219
+ static {
220
+ this.ɵfac = i0.ɵɵngDeclareFactory({
221
+ minVersion: "12.0.0",
222
+ version: "22.2.3",
223
+ ngImport: i0,
224
+ type: SeatsyooChartComponent,
225
+ deps: [],
226
+ target: i0.ɵɵFactoryTarget.Component
227
+ });
228
+ }
229
+ static {
230
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
231
+ minVersion: "14.0.0",
232
+ version: "22.2.3",
233
+ type: SeatsyooChartComponent,
234
+ isStandalone: true,
235
+ selector: "seatsyoo-chart",
236
+ inputs: {
237
+ server: "server",
238
+ publicKey: "publicKey",
239
+ event: "event",
240
+ link: "link",
241
+ document: "document",
242
+ season: "season",
243
+ seasonEvents: "seasonEvents",
244
+ channels: "channels",
245
+ pricing: "pricing",
246
+ currency: "currency",
247
+ locale: "locale",
248
+ language: "language",
249
+ maxSelected: "maxSelected",
250
+ session: "session",
251
+ holdToken: "holdToken",
252
+ mode: "mode",
253
+ showLegend: "showLegend",
254
+ showSelectionBar: "showSelectionBar",
255
+ floor: "floor",
256
+ sectors: "sectors",
257
+ view3d: "view3d",
258
+ entrance: "entrance",
259
+ texts: "texts",
260
+ theme: "theme",
261
+ colorBy: "colorBy",
262
+ statusStyles: "statusStyles",
263
+ marks: "marks",
264
+ load3d: "load3d"
265
+ },
266
+ outputs: {
267
+ ready: "ready",
268
+ selectionChange: "selectionChange",
269
+ objectSelect: "objectSelect",
270
+ objectDeselect: "objectDeselect",
271
+ holdExpired: "holdExpired",
272
+ holdTokenChange: "holdTokenChange",
273
+ chartError: "chartError",
274
+ floorChange: "floorChange"
275
+ },
276
+ host: { attributes: { "ngSkipHydration": "true" } },
277
+ usesOnChanges: true,
278
+ ngImport: i0,
279
+ template: "",
280
+ isInline: true,
281
+ styles: [":host{display:block}\n"],
282
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
283
+ });
284
+ }
285
+ };
286
+ i0.ɵɵngDeclareClassMetadata({
287
+ minVersion: "12.0.0",
288
+ version: "22.2.3",
289
+ ngImport: i0,
290
+ type: SeatsyooChartComponent,
291
+ decorators: [{
292
+ type: Component,
293
+ args: [{
294
+ selector: "seatsyoo-chart",
295
+ standalone: true,
296
+ template: "",
297
+ changeDetection: ChangeDetectionStrategy.OnPush,
298
+ host: { ngSkipHydration: "true" },
299
+ styles: [":host{display:block}\n"]
300
+ }]
301
+ }],
302
+ propDecorators: {
303
+ server: [{
304
+ type: Input,
305
+ args: [{ required: true }]
306
+ }],
307
+ publicKey: [{ type: Input }],
308
+ event: [{ type: Input }],
309
+ link: [{ type: Input }],
310
+ document: [{ type: Input }],
311
+ season: [{ type: Input }],
312
+ seasonEvents: [{ type: Input }],
313
+ channels: [{ type: Input }],
314
+ pricing: [{ type: Input }],
315
+ currency: [{ type: Input }],
316
+ locale: [{ type: Input }],
317
+ language: [{ type: Input }],
318
+ maxSelected: [{ type: Input }],
319
+ session: [{ type: Input }],
320
+ holdToken: [{ type: Input }],
321
+ mode: [{ type: Input }],
322
+ showLegend: [{ type: Input }],
323
+ showSelectionBar: [{ type: Input }],
324
+ floor: [{ type: Input }],
325
+ sectors: [{ type: Input }],
326
+ view3d: [{ type: Input }],
327
+ entrance: [{ type: Input }],
328
+ texts: [{ type: Input }],
329
+ theme: [{ type: Input }],
330
+ colorBy: [{ type: Input }],
331
+ statusStyles: [{ type: Input }],
332
+ marks: [{ type: Input }],
333
+ load3d: [{ type: Input }],
334
+ ready: [{ type: Output }],
335
+ selectionChange: [{ type: Output }],
336
+ objectSelect: [{ type: Output }],
337
+ objectDeselect: [{ type: Output }],
338
+ holdExpired: [{ type: Output }],
339
+ holdTokenChange: [{ type: Output }],
340
+ chartError: [{ type: Output }],
341
+ floorChange: [{ type: Output }]
342
+ }
343
+ });
344
+ function quitarIndefinidos(o) {
345
+ return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
346
+ }
347
+ function tieneOyentes(salida) {
348
+ const s = salida;
349
+ return s.observed ?? (s.observers?.length ?? 0) > 0;
350
+ }
351
+ function sinLoad3d() {
352
+ throw new Error("Seatsyoo: load3d ya no está definido");
353
+ }
354
+ const version = "1.0.0";
355
+ export { SeatsyooChartComponent, version };
356
+
357
+ //# sourceMappingURL=seatsyoo-angular.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seatsyoo-angular.mjs","names":[],"sources":["../../src/opciones.ts","../../src/seatsyoo-chart.component.ts","../../src/public-api.ts"],"sourcesContent":["// Qué opciones del visor obligan a volver a montarlo, cuáles se aplican en vivo y cómo se comparan.\nimport type { RenderOptions, SeatingChart } from \"@seatsyoo/visor\";\n\n/**\n * Opciones «de identidad»: deciden qué plano se carga y cómo se vende. Si cambia alguna (por valor, no por\n * referencia), el visor se desmonta y se vuelve a montar. Las de OPCIONES_EN_VIVO se aplican sin volver a montar.\n */\nexport const OPCIONES_DE_IDENTIDAD = [\n \"server\",\n \"publicKey\",\n \"event\",\n \"link\",\n \"document\",\n \"season\",\n \"seasonEvents\",\n \"channels\",\n \"pricing\",\n \"currency\",\n \"locale\",\n \"language\",\n \"maxSelected\",\n \"session\",\n \"holdToken\",\n \"mode\",\n \"showLegend\",\n \"showSelectionBar\",\n \"floor\",\n \"sectors\",\n \"view3d\",\n \"entrance\",\n \"texts\",\n] as const satisfies readonly (keyof RenderOptions)[];\n\nexport type OpcionDeIdentidad = (typeof OPCIONES_DE_IDENTIDAD)[number];\n\n/**\n * Opciones que se aplican al visor ya montado, sin volver a montarlo: theme y colorBy (setTheme y setColorBy) y, para\n * el modo «manager», los estilos de los estados y las marcas sobre plazas libres (setStatusStyles y setMarks). Se\n * comparan por valor, como las de identidad: un objeto nuevo con lo mismo no llama a nada.\n */\nexport const OPCIONES_EN_VIVO = [\"theme\", \"colorBy\", \"statusStyles\", \"marks\"] as const satisfies readonly (keyof RenderOptions)[];\n\n/**\n * Cada opción del visor tiene su regla en el componente (vuelve a montar; las de OPCIONES_EN_VIVO, en vivo; load3d,\n * aparte; los avisos son sus salidas). Si el visor gana una opción nueva, esto deja de compilar hasta decidir qué hace\n * el componente con ella: pasó con `entrance` y `texts`, que el componente ni recibía, y con `statusStyles` y `marks`\n * (en vivo: el visor tiene setStatusStyles y setMarks).\n */\ntype SinRegla = Exclude<\n keyof RenderOptions,\n OpcionDeIdentidad | (typeof OPCIONES_EN_VIVO)[number] | \"container\" | \"load3d\" | `on${string}`\n>;\ntype DebeSerNever<T extends never> = T;\nexport type TodasLasOpcionesTienenRegla = DebeSerNever<SinRegla>;\n\n/** Los valores de las opciones de identidad con los que se montó el visor. */\nexport type Identidad = { [K in OpcionDeIdentidad]: RenderOptions[K] };\n\n/**\n * Igualdad por valor de datos planos (lo que llega en las opciones: textos, números, listas y objetos con\n * datos). Dos listas u objetos son iguales si tienen lo mismo, aunque sean objetos distintos.\n */\nexport function mismoValor(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n if (Array.isArray(a)) {\n const lista = b as unknown[];\n return a.length === lista.length && a.every((v, i) => mismoValor(v, lista[i]));\n }\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n if (a instanceof Date) return a.getTime() === (b as Date).getTime();\n const objA = a as Record<string, unknown>;\n const objB = b as Record<string, unknown>;\n // Una propiedad que vale `undefined` cuenta como ausente: `{ a: 1 }` y `{ a: 1, b: undefined }` son lo mismo.\n const claves = (o: Record<string, unknown>) => Object.keys(o).filter((k) => o[k] !== undefined);\n const clavesA = claves(objA);\n if (clavesA.length !== claves(objB).length) return false;\n return clavesA.every((k) => Object.prototype.hasOwnProperty.call(objB, k) && mismoValor(objA[k], objB[k]));\n}\n\n/** Las opciones de identidad que han cambiado entre dos montajes (vacío si ninguna). */\nexport function cambiosDeIdentidad(antes: Identidad, ahora: Identidad): OpcionDeIdentidad[] {\n return OPCIONES_DE_IDENTIDAD.filter((k) => !mismoValor(antes[k], ahora[k]));\n}\n\n/**\n * Copia normalizada de datos tipo JSON (listas y objetos, a cualquier profundidad): los objetos salen con\n * Object.prototype (también un diccionario hecho con `Object.create(null)`) y sin las claves que valen `undefined`\n * (`{ color, icon: undefined }` es lo mismo que `{ color }`: el visor no pinta icono en los dos casos).\n *\n * Es la regla de statusStyles y marks, la misma en React, Vue y Angular: lo aplicado en vivo se guarda así copiado, lo\n * que llega se copia igual antes de compararlo, y el visor recibe esa copia. Así cambiarlo en el sitio también cuenta y\n * el visor no comparte el objeto de la página (setMarks repinta lo que difiere de lo que tenía, y si fuera el mismo\n * objeto ya cambiado no vería nada).\n */\nexport function copiaDeDatos<T>(valor: T): T {\n if (Array.isArray(valor)) return valor.map((v: unknown) => copiaDeDatos(v)) as T;\n if (valor !== null && typeof valor === \"object\") {\n const entradas = Object.entries(valor as Record<string, unknown>).filter(([, v]) => v !== undefined);\n return Object.fromEntries(entradas.map(([k, v]) => [k, copiaDeDatos(v)])) as T;\n }\n return valor;\n}\n\n/** Con qué valor de cada opción en vivo se montó el visor o se le cambió después (sin indicar, el de por defecto). */\nexport interface EnVivo {\n theme: NonNullable<RenderOptions[\"theme\"]>;\n colorBy: NonNullable<RenderOptions[\"colorBy\"]>;\n statusStyles: NonNullable<RenderOptions[\"statusStyles\"]>;\n marks: NonNullable<RenderOptions[\"marks\"]>;\n}\n\n/** Los valores de las opciones en vivo tal como llegan al componente (sin indicar, `undefined`). */\nexport type OpcionesEnVivo = { [K in (typeof OPCIONES_EN_VIVO)[number]]?: RenderOptions[K] };\n\n/**\n * Las opciones en vivo con que se monta un visor. Sin theme ni colorBy, los del visor por defecto; sin statusStyles ni\n * marks, ninguno (`{}`, que para el visor es lo mismo que no pasarlas).\n */\nexport function enVivoDe(opciones: OpcionesEnVivo): EnVivo {\n return {\n theme: opciones.theme ?? \"light\",\n colorBy: opciones.colorBy ?? \"category\",\n statusStyles: copiaDeDatos(opciones.statusStyles ?? {}),\n marks: copiaDeDatos(opciones.marks ?? {}),\n };\n}\n\n/** Los métodos del visor con que se aplican las opciones en vivo. */\nexport type VisorEnVivo = Pick<SeatingChart, \"setTheme\" | \"setColorBy\" | \"setStatusStyles\" | \"setMarks\">;\n\n/**\n * Lleva al visor montado las opciones en vivo que han cambiado (por valor) desde `aplicadas`, y las apunta en\n * `aplicadas`. Quitar una es volver a la de por defecto: el tema claro, el color por categoría, sin estilos ni marcas.\n */\nexport function aplicarEnVivo(visor: VisorEnVivo, aplicadas: EnVivo, opciones: OpcionesEnVivo): void {\n const tema = opciones.theme ?? \"light\";\n if (tema !== aplicadas.theme) {\n visor.setTheme(tema);\n aplicadas.theme = tema;\n }\n const color = opciones.colorBy ?? \"category\";\n if (color !== aplicadas.colorBy) {\n visor.setColorBy(color);\n aplicadas.colorBy = color;\n }\n // statusStyles y marks: la copia normalizada de lo que llega (copiaDeDatos) contra la de lo aplicado. Un\n // diccionario sin prototipo o con claves que valen undefined, con lo mismo, no llama a nada. Con las dos copias\n // normalizadas, mismoValor da lo mismo que `igual` en React y Vue.\n const estilos = copiaDeDatos(opciones.statusStyles ?? {});\n if (!mismoValor(estilos, aplicadas.statusStyles)) {\n aplicadas.statusStyles = estilos;\n visor.setStatusStyles(estilos);\n }\n const marcas = copiaDeDatos(opciones.marks ?? {});\n if (!mismoValor(marcas, aplicadas.marks)) {\n aplicadas.marks = marcas;\n visor.setMarks(marcas);\n }\n}\n","import { isPlatformBrowser } from \"@angular/common\";\nimport {\n type AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n EventEmitter,\n Input,\n NgZone,\n type OnChanges,\n type OnDestroy,\n Output,\n PLATFORM_ID,\n inject,\n} from \"@angular/core\";\nimport { type RenderOptions, SeatingChart, type SelectedObject } from \"@seatsyoo/visor\";\nimport {\n OPCIONES_DE_IDENTIDAD,\n type EnVivo,\n type Identidad,\n type OpcionesEnVivo,\n aplicarEnVivo,\n cambiosDeIdentidad,\n enVivoDe,\n} from \"./opciones\";\n\n/** El token de retención que avisa `holdTokenChange` (`null` al caducar o vaciar la selección). */\nexport type SeatsyooHoldToken = { token: string; expiresAt: Date } | null;\n\n/** Un error del visor: no se ha podido cargar el plano, retener una butaca… */\nexport interface SeatsyooChartError {\n code: string;\n message: string;\n}\n\n/** La planta que se enseña (planos de varias plantas). */\nexport interface SeatsyooFloor {\n id: string;\n name: string;\n}\n\n/**\n * El visor de mapas de asientos de Seatsyoo como componente de Angular.\n *\n * ```html\n * <seatsyoo-chart\n * style=\"display: block; height: 640px\"\n * server=\"https://seatsyoo.example\"\n * publicKey=\"pk_tu_clave_publica\"\n * event=\"hamlet-2026-11-20\"\n * (selectionChange)=\"seleccion = $event\"\n * />\n * ```\n *\n * - Solo se monta en el navegador: en el servidor (SSR) el elemento queda vacío y no se pide nada.\n * - El visor corre fuera de la zona de Angular (sus temporizadores y peticiones no lanzan la detección de\n * cambios); las salidas se emiten dentro. Funciona igual sin zone.js (zoneless).\n * - Si cambia una opción de identidad (el evento, la clave pública, los canales…, comparadas por valor), el\n * visor se desmonta y se vuelve a montar. `theme`, `colorBy`, `statusStyles` y `marks` se aplican sin volver a\n * montarlo (las dos últimas, comparadas por valor).\n * - Al destruir el componente se llama a `destroy()` del visor.\n */\n@Component({\n selector: \"seatsyoo-chart\",\n standalone: true,\n template: \"\",\n styles: [\":host { display: block; }\"],\n changeDetection: ChangeDetectionStrategy.OnPush,\n // El visor añade su propio DOM al elemento: la hidratación no tiene que compararlo con el del servidor.\n host: { ngSkipHydration: \"true\" },\n})\nexport class SeatsyooChartComponent implements OnChanges, AfterViewInit, OnDestroy {\n /** URL base del servidor de Seatsyoo, p. ej. https://seatsyoo.midominio.com */\n @Input({ required: true }) server!: RenderOptions[\"server\"];\n /** Clave pública del espacio (obligatoria salvo con `link` o `document`). */\n @Input() publicKey: RenderOptions[\"publicKey\"];\n /** Clave del evento que se vende. */\n @Input() event: RenderOptions[\"event\"];\n /** O la clave de un enlace público del plano: solo ver, sin retener ni vender. */\n @Input() link: RenderOptions[\"link\"];\n /** O el plano ya cargado: solo ver. */\n @Input() document: RenderOptions[\"document\"];\n /** O la clave de una temporada (abonos): el mismo asiento para todos sus eventos. */\n @Input() season: RenderOptions[\"season\"];\n /** Abono parcial: los eventos de la temporada que ha elegido el comprador. */\n @Input() seasonEvents: RenderOptions[\"seasonEvents\"];\n /** Canales de venta desde los que se compra. */\n @Input() channels: RenderOptions[\"channels\"];\n /**\n * Los precios que pone tu web, por clave de categoría (`{ platea: 30 }`): el visor los enseña en la ficha, la leyenda\n * y el total, y salen en `price` de lo elegido. Seatsyoo no guarda precios.\n */\n @Input() pricing: RenderOptions[\"pricing\"];\n /** Moneda de `pricing` (código ISO; si no, euros). */\n @Input() currency: RenderOptions[\"currency\"];\n @Input() locale: RenderOptions[\"locale\"];\n /** `\"es\"` (por defecto) o `\"en\"`. */\n @Input() language: RenderOptions[\"language\"];\n /** Plazas que se pueden elegir como mucho (10 por defecto). */\n @Input() maxSelected: RenderOptions[\"maxSelected\"];\n /** `\"continue\"` (por defecto) recupera la selección al recargar; `\"start\"` empieza de cero. */\n @Input() session: RenderOptions[\"session\"];\n /** Token de retención creado por tu servidor, en lugar de que el visor cree uno. */\n @Input() holdToken: RenderOptions[\"holdToken\"];\n /** `\"buyer\"` (por defecto) o `\"manager\"`. */\n @Input() mode: RenderOptions[\"mode\"];\n @Input() showLegend: RenderOptions[\"showLegend\"];\n @Input() showSelectionBar: RenderOptions[\"showSelectionBar\"];\n /** Planta que se muestra al abrir (id). */\n @Input() floor: RenderOptions[\"floor\"];\n /** Vista por sectores al ver el plano de lejos. */\n @Input() sectors: RenderOptions[\"sectors\"];\n /** Botón de la vista 3D (sí por defecto). */\n @Input() view3d: RenderOptions[\"view3d\"];\n /** Entrada animada al abrirse: el plano se descubre desde el escenario (no por defecto). */\n @Input() entrance: RenderOptions[\"entrance\"];\n /**\n * Textos del plano que se enseñan cambiados (por ejemplo, traducidos), por el texto tal como está en el plano:\n * `{ Platea: \"Stalls\" }`. Solo cambia lo que se ve: claves, selección y eventos siguen siendo los del plano.\n */\n @Input() texts: RenderOptions[\"texts\"];\n /** `\"light\"` (por defecto), `\"dark\"` o `\"auto\"`. Se aplica sin volver a montar el visor. */\n @Input() theme: RenderOptions[\"theme\"];\n /** Color base de los objetos: `\"category\"` (por defecto) o `\"channel\"`. Se aplica sin volver a montar. */\n @Input() colorBy: RenderOptions[\"colorBy\"];\n /**\n * Solo con `mode: \"manager\"`: nombre, color e icono de los estados, por su clave (los propios y los de base que se\n * quieran cambiar). Se aplica sin volver a montar (`setStatusStyles`), si cambia su valor.\n */\n @Input() statusStyles: RenderOptions[\"statusStyles\"];\n /**\n * Solo con `mode: \"manager\"`: marcas sobre plazas que siguen libres, objeto → estado (su aspecto, en `statusStyles`).\n * Se aplica sin volver a montar (`setMarks`), si cambia su valor.\n */\n @Input() marks: RenderOptions[\"marks\"];\n /**\n * Cómo cargar el módulo 3D (por defecto se pide al servidor). Se llama a la última función que se haya\n * pasado; solo vuelve a montar el visor si se pone o se quita.\n */\n @Input() load3d: RenderOptions[\"load3d\"];\n\n /** El visor está listo: plano pintado y estados cargados. */\n @Output() readonly ready = new EventEmitter<SeatingChart>();\n /** La selección ha cambiado (lo elegido, ya retenido). */\n @Output() readonly selectionChange = new EventEmitter<SelectedObject[]>();\n /** Se ha elegido un objeto. */\n @Output() readonly objectSelect = new EventEmitter<SelectedObject>();\n /** Se ha quitado un objeto de la selección. */\n @Output() readonly objectDeselect = new EventEmitter<SelectedObject>();\n /** Se ha acabado el tiempo de la retención: la selección se ha soltado. */\n @Output() readonly holdExpired = new EventEmitter<void>();\n /**\n * El token de retención ha cambiado (uno nuevo, otra caducidad o ninguno). Al volver a montar el visor, si el\n * nuevo no tiene token (otro evento, `session: \"start\"`…), avisa `null` cuando termina de cargar.\n */\n @Output() readonly holdTokenChange = new EventEmitter<SeatsyooHoldToken>();\n /** Error del visor. Si nadie lo escucha, sale como aviso en la consola. */\n @Output() readonly chartError = new EventEmitter<SeatsyooChartError>();\n /** Se ha cambiado de planta. */\n @Output() readonly floorChange = new EventEmitter<SeatsyooFloor>();\n\n private readonly elemento: ElementRef<HTMLElement> = inject(ElementRef);\n private readonly zona = inject(NgZone);\n private readonly enNavegador = isPlatformBrowser(inject(PLATFORM_ID));\n\n private visor: SeatingChart | null = null;\n /** Con qué opciones de identidad se montó (o se intentó montar) el visor; `null` si aún no. */\n private montado: { identidad: Identidad; conLoad3d: boolean } | null = null;\n /** Las opciones en vivo (tema, color, estilos y marcas) que tiene el visor montado. */\n private enVivo: EnVivo = enVivoDe({});\n /** Cada montaje tiene su número: los avisos de un visor ya desmontado no llegan a las salidas. */\n private montaje = 0;\n private destruido = false;\n /** El último token de retención avisado por `holdTokenChange` (de este visor o de uno anterior). */\n private tokenAvisado: SeatsyooHoldToken = null;\n\n /**\n * El visor montado (`null` en el servidor, antes de montarlo o si las opciones no valen). Sirve para llamar a\n * sus métodos: `getSelection()`, `holdToken`, `clearSelection()`, `selectBestAvailable()`…\n */\n get chart(): SeatingChart | null {\n return this.visor;\n }\n\n ngAfterViewInit(): void {\n this.montar();\n }\n\n ngOnChanges(): void {\n // Los primeros valores llegan antes de montar: ngAfterViewInit monta con todos ellos.\n if (!this.montado || this.destruido) return;\n if (this.hayQueVolverAMontar()) {\n this.desmontar();\n this.montar();\n return;\n }\n const visor = this.visor;\n if (!visor) return;\n // Solo lo que ha cambiado de valor: un objeto nuevo con los mismos estilos o marcas no repinta nada.\n this.zona.runOutsideAngular(() => aplicarEnVivo(visor, this.enVivo, this.opcionesEnVivo()));\n }\n\n ngOnDestroy(): void {\n this.destruido = true;\n this.desmontar();\n }\n\n private identidad(): Identidad {\n return Object.fromEntries(OPCIONES_DE_IDENTIDAD.map((k) => [k, this[k]])) as Identidad;\n }\n\n private opcionesEnVivo(): OpcionesEnVivo {\n return { theme: this.theme, colorBy: this.colorBy, statusStyles: this.statusStyles, marks: this.marks };\n }\n\n private hayQueVolverAMontar(): boolean {\n const antes = this.montado;\n if (!antes) return false;\n return cambiosDeIdentidad(antes.identidad, this.identidad()).length > 0 || antes.conLoad3d !== (this.load3d !== undefined);\n }\n\n private montar(): void {\n if (!this.enNavegador || this.destruido) return;\n const montaje = ++this.montaje;\n const identidad = this.identidad();\n this.montado = { identidad, conLoad3d: this.load3d !== undefined };\n // Con copias de statusStyles y marks: lo que se compara después y lo que tiene el visor no es el objeto de la página.\n const enVivo = enVivoDe(this.opcionesEnVivo());\n this.enVivo = enVivo;\n\n /** Emite una salida dentro de la zona de Angular, solo si este visor sigue montado. */\n const emitir = <T>(salida: EventEmitter<T>, valor: T): void => {\n if (montaje !== this.montaje) return;\n this.zona.run(() => salida.emit(valor));\n };\n // Al volver a montar (otra función, otros precios de la página…), el visor nuevo empieza sin token, y solo avisa\n // cuando el token cambia: si el anterior había avisado de uno, el padre se quedaría con él. Si el nuevo termina\n // de cargar (o falla) sin avisar de un token suyo (con `session: \"continue\"` recupera el que tuviera para ese\n // mismo evento), se avisa de que ya no hay: `null`, lo mismo que dice `chart.holdToken`.\n let sinTokenPendiente = this.tokenAvisado !== null;\n /** Avisa del token de este visor y apunta cuál es el último avisado. */\n const avisarToken = (token: SeatsyooHoldToken): void => {\n if (montaje !== this.montaje) return;\n sinTokenPendiente = false;\n this.tokenAvisado = token;\n this.zona.run(() => this.holdTokenChange.emit(token));\n };\n const avisarSinToken = (): void => {\n if (sinTokenPendiente) avisarToken(null);\n };\n const opciones: RenderOptions = {\n ...quitarIndefinidos(identidad),\n server: identidad.server,\n container: this.elemento.nativeElement,\n ...(this.theme !== undefined ? { theme: this.theme } : {}),\n ...(this.colorBy !== undefined ? { colorBy: this.colorBy } : {}),\n ...(this.statusStyles !== undefined ? { statusStyles: enVivo.statusStyles } : {}),\n ...(this.marks !== undefined ? { marks: enVivo.marks } : {}),\n // La función se lee al abrir la 3D: así vale la última que se haya pasado.\n ...(this.load3d !== undefined ? { load3d: () => (this.load3d ?? sinLoad3d)() } : {}),\n onReady: (visor) => {\n avisarSinToken();\n emitir(this.ready, visor);\n },\n onChange: (seleccion) => emitir(this.selectionChange, seleccion),\n onSelect: (objeto) => emitir(this.objectSelect, objeto),\n onDeselect: (objeto) => emitir(this.objectDeselect, objeto),\n onHoldExpired: () => emitir(this.holdExpired, undefined),\n onHoldTokenChange: (token) => avisarToken(token),\n onFloorChange: (planta) => emitir(this.floorChange, planta),\n onError: (error) => {\n if (montaje !== this.montaje) return;\n avisarSinToken();\n this.avisarError(error);\n },\n };\n try {\n this.visor = this.zona.runOutsideAngular(() => new SeatingChart(opciones));\n } catch (e) {\n // Opciones que no valen (sin evento, sin clave pública…): se avisa por chartError, después de esta\n // vuelta de la detección de cambios (emitir ahora cambiaría lo que el padre acaba de pintar).\n this.visor = null;\n const error = { code: \"invalid-options\", message: e instanceof Error ? e.message : String(e) };\n queueMicrotask(() => {\n if (montaje !== this.montaje) return;\n avisarSinToken();\n this.avisarError(error);\n });\n }\n }\n\n private desmontar(): void {\n this.montaje++;\n const visor = this.visor;\n this.visor = null;\n if (visor) this.zona.runOutsideAngular(() => visor.destroy());\n }\n\n private avisarError(error: SeatsyooChartError): void {\n if (tieneOyentes(this.chartError)) this.zona.run(() => this.chartError.emit(error));\n else console.warn(\"[seatsyoo]\", error.code, error.message);\n }\n}\n\n/** Las opciones sin las que valen `undefined` (el visor pone entonces las suyas por defecto). */\nfunction quitarIndefinidos<T extends object>(o: T): Partial<T> {\n return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as Partial<T>;\n}\n\n/** Si alguien escucha la salida (`observed` es de RxJS 7; con RxJS 6 se miran los `observers`). */\nfunction tieneOyentes(salida: object): boolean {\n const s = salida as unknown as { observed?: boolean; observers?: unknown[] };\n return s.observed ?? (s.observers?.length ?? 0) > 0;\n}\n\n/** No llega a llamarse: el visor se vuelve a montar sin `load3d` en cuanto se quita. */\nfunction sinLoad3d(): never {\n throw new Error(\"Seatsyoo: load3d ya no está definido\");\n}\n","// @seatsyoo/angular: el visor de mapas de asientos de Seatsyoo como componente de Angular.\nexport { SeatsyooChartComponent } from \"./seatsyoo-chart.component\";\nexport type { SeatsyooChartError, SeatsyooFloor, SeatsyooHoldToken } from \"./seatsyoo-chart.component\";\n// Los tipos del visor, para no tener que importarlos de @seatsyoo/visor.\nexport type { ChartDocument, Language, RenderOptions, SeatingChart, SelectedObject, StatusStyle, View3DModule } from \"@seatsyoo/visor\";\n\n/** Versión de este paquete. */\nexport const version = \"1.0.0\";\n"],"mappings":";;;;AAOA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACmD;AA+BrD,SAAgB,WAAW,GAAY,GAAU;CAC/C,IAAI,OAAO,GAAG,GAAG,CAAC,GAAG,OAAO;CAC5B,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM,OAAO;CACvF,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,IAAI,MAAM,QAAQ,CAAC,GAAG;EACpB,MAAM,QAAQ;EACd,OAAO,EAAE,WAAW,MAAM,UAAU,EAAE,OAAO,GAAG,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC;CAC/E;CACA,IAAI,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,GAAG,OAAO;CAClE,IAAI,aAAa,MAAM,OAAO,EAAE,QAAO,MAAQ,EAAW,QAAO;CACjE,MAAM,OAAO;CACb,MAAM,OAAO;CAEb,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CAAA;EAEA,aAAA,CAAA,EAAA,MAAA,OAAA,CAAA;EAKA,iBAAA,CAAA,EAAA,MAAA,OAAA,CAAA;EAEA,YAAA,CAAA,EAAA,MAAA,OAAA,CAAA;EAEA,aAAA,CAAA,EAAA,MAAA,OAAA,CAAA;;;AAkJH,SAAS,kBAAoC,GAAI;CAC/C,OAAO,OAAO,YAAY,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,OAAO,MAAM,MAAS,CAAC;AAChF;AAGA,SAAS,aAAa,QAAc;CAClC,MAAM,IAAI;CACV,OAAO,EAAE,aAAa,EAAE,WAAW,UAAU,KAAK;AACpD;AAGA,SAAS,YAAS;CAChB,MAAM,IAAI,MAAM,sCAAsC;AACxD;ACvTA,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@seatsyoo/angular",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Componente de Angular del visor de mapas de asientos de Seatsyoo: elegir butacas, retenerlas y venderlas en tiempo real.",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "seatsyoo",
8
+ "angular",
9
+ "mapa de asientos",
10
+ "butacas",
11
+ "entradas",
12
+ "seating chart",
13
+ "seat map",
14
+ "tickets"
15
+ ],
16
+ "type": "module",
17
+ "sideEffects": false,
18
+ "files": [
19
+ "fesm2022",
20
+ "types"
21
+ ],
22
+ "peerDependencies": {
23
+ "@angular/common": ">=17.0.0",
24
+ "@angular/core": ">=17.0.0"
25
+ },
26
+ "dependencies": {
27
+ "@seatsyoo/visor": "^1.0.0"
28
+ },
29
+ "module": "fesm2022/seatsyoo-angular.mjs",
30
+ "typings": "types/seatsyoo-angular.d.ts",
31
+ "exports": {
32
+ "./package.json": {
33
+ "default": "./package.json"
34
+ },
35
+ ".": {
36
+ "types": "./types/seatsyoo-angular.d.ts",
37
+ "default": "./fesm2022/seatsyoo-angular.mjs"
38
+ }
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ }
6
43
  }
@@ -0,0 +1,282 @@
1
+ import * as i0 from "@angular/core";
2
+ import { AfterViewInit, EventEmitter, OnChanges, OnDestroy } from "@angular/core";
3
+ import { ChartDocument, Language, RenderOptions, RenderOptions as RenderOptions$1, SeatingChart, SeatingChart as SeatingChart$1, SelectedObject, SelectedObject as SelectedObject$1, StatusStyle, View3DModule } from "@seatsyoo/visor";
4
+ /** El token de retención que avisa `holdTokenChange` (`null` al caducar o vaciar la selección). */
5
+ type SeatsyooHoldToken = {
6
+ token: string;
7
+ expiresAt: Date;
8
+ } | null;
9
+ /** Un error del visor: no se ha podido cargar el plano, retener una butaca… */
10
+ interface SeatsyooChartError {
11
+ code: string;
12
+ message: string;
13
+ }
14
+ /** La planta que se enseña (planos de varias plantas). */
15
+ interface SeatsyooFloor {
16
+ id: string;
17
+ name: string;
18
+ }
19
+ /**
20
+ * El visor de mapas de asientos de Seatsyoo como componente de Angular.
21
+ *
22
+ * ```html
23
+ * <seatsyoo-chart
24
+ * style="display: block; height: 640px"
25
+ * server="https://seatsyoo.example"
26
+ * publicKey="pk_tu_clave_publica"
27
+ * event="hamlet-2026-11-20"
28
+ * (selectionChange)="seleccion = $event"
29
+ * />
30
+ * ```
31
+ *
32
+ * - Solo se monta en el navegador: en el servidor (SSR) el elemento queda vacío y no se pide nada.
33
+ * - El visor corre fuera de la zona de Angular (sus temporizadores y peticiones no lanzan la detección de
34
+ * cambios); las salidas se emiten dentro. Funciona igual sin zone.js (zoneless).
35
+ * - Si cambia una opción de identidad (el evento, la clave pública, los canales…, comparadas por valor), el
36
+ * visor se desmonta y se vuelve a montar. `theme`, `colorBy`, `statusStyles` y `marks` se aplican sin volver a
37
+ * montarlo (las dos últimas, comparadas por valor).
38
+ * - Al destruir el componente se llama a `destroy()` del visor.
39
+ */
40
+ export declare class SeatsyooChartComponent implements OnChanges, AfterViewInit, OnDestroy {
41
+ /** URL base del servidor de Seatsyoo, p. ej. https://seatsyoo.midominio.com */
42
+ server: RenderOptions$1["server"];
43
+ /** Clave pública del espacio (obligatoria salvo con `link` o `document`). */
44
+ publicKey: RenderOptions$1["publicKey"];
45
+ /** Clave del evento que se vende. */
46
+ event: RenderOptions$1["event"];
47
+ /** O la clave de un enlace público del plano: solo ver, sin retener ni vender. */
48
+ link: RenderOptions$1["link"];
49
+ /** O el plano ya cargado: solo ver. */
50
+ document: RenderOptions$1["document"];
51
+ /** O la clave de una temporada (abonos): el mismo asiento para todos sus eventos. */
52
+ season: RenderOptions$1["season"];
53
+ /** Abono parcial: los eventos de la temporada que ha elegido el comprador. */
54
+ seasonEvents: RenderOptions$1["seasonEvents"];
55
+ /** Canales de venta desde los que se compra. */
56
+ channels: RenderOptions$1["channels"];
57
+ /**
58
+ * Los precios que pone tu web, por clave de categoría (`{ platea: 30 }`): el visor los enseña en la ficha, la leyenda
59
+ * y el total, y salen en `price` de lo elegido. Seatsyoo no guarda precios.
60
+ */
61
+ pricing: RenderOptions$1["pricing"];
62
+ /** Moneda de `pricing` (código ISO; si no, euros). */
63
+ currency: RenderOptions$1["currency"];
64
+ locale: RenderOptions$1["locale"];
65
+ /** `"es"` (por defecto) o `"en"`. */
66
+ language: RenderOptions$1["language"];
67
+ /** Plazas que se pueden elegir como mucho (10 por defecto). */
68
+ maxSelected: RenderOptions$1["maxSelected"];
69
+ /** `"continue"` (por defecto) recupera la selección al recargar; `"start"` empieza de cero. */
70
+ session: RenderOptions$1["session"];
71
+ /** Token de retención creado por tu servidor, en lugar de que el visor cree uno. */
72
+ holdToken: RenderOptions$1["holdToken"];
73
+ /** `"buyer"` (por defecto) o `"manager"`. */
74
+ mode: RenderOptions$1["mode"];
75
+ showLegend: RenderOptions$1["showLegend"];
76
+ showSelectionBar: RenderOptions$1["showSelectionBar"];
77
+ /** Planta que se muestra al abrir (id). */
78
+ floor: RenderOptions$1["floor"];
79
+ /** Vista por sectores al ver el plano de lejos. */
80
+ sectors: RenderOptions$1["sectors"];
81
+ /** Botón de la vista 3D (sí por defecto). */
82
+ view3d: RenderOptions$1["view3d"];
83
+ /** Entrada animada al abrirse: el plano se descubre desde el escenario (no por defecto). */
84
+ entrance: RenderOptions$1["entrance"];
85
+ /**
86
+ * Textos del plano que se enseñan cambiados (por ejemplo, traducidos), por el texto tal como está en el plano:
87
+ * `{ Platea: "Stalls" }`. Solo cambia lo que se ve: claves, selección y eventos siguen siendo los del plano.
88
+ */
89
+ texts: RenderOptions$1["texts"];
90
+ /** `"light"` (por defecto), `"dark"` o `"auto"`. Se aplica sin volver a montar el visor. */
91
+ theme: RenderOptions$1["theme"];
92
+ /** Color base de los objetos: `"category"` (por defecto) o `"channel"`. Se aplica sin volver a montar. */
93
+ colorBy: RenderOptions$1["colorBy"];
94
+ /**
95
+ * Solo con `mode: "manager"`: nombre, color e icono de los estados, por su clave (los propios y los de base que se
96
+ * quieran cambiar). Se aplica sin volver a montar (`setStatusStyles`), si cambia su valor.
97
+ */
98
+ statusStyles: RenderOptions$1["statusStyles"];
99
+ /**
100
+ * Solo con `mode: "manager"`: marcas sobre plazas que siguen libres, objeto → estado (su aspecto, en `statusStyles`).
101
+ * Se aplica sin volver a montar (`setMarks`), si cambia su valor.
102
+ */
103
+ marks: RenderOptions$1["marks"];
104
+ /**
105
+ * Cómo cargar el módulo 3D (por defecto se pide al servidor). Se llama a la última función que se haya
106
+ * pasado; solo vuelve a montar el visor si se pone o se quita.
107
+ */
108
+ load3d: RenderOptions$1["load3d"];
109
+ /** El visor está listo: plano pintado y estados cargados. */
110
+ readonly ready: EventEmitter<SeatingChart$1>;
111
+ /** La selección ha cambiado (lo elegido, ya retenido). */
112
+ readonly selectionChange: EventEmitter<SelectedObject$1[]>;
113
+ /** Se ha elegido un objeto. */
114
+ readonly objectSelect: EventEmitter<SelectedObject$1>;
115
+ /** Se ha quitado un objeto de la selección. */
116
+ readonly objectDeselect: EventEmitter<SelectedObject$1>;
117
+ /** Se ha acabado el tiempo de la retención: la selección se ha soltado. */
118
+ readonly holdExpired: EventEmitter<void>;
119
+ /**
120
+ * El token de retención ha cambiado (uno nuevo, otra caducidad o ninguno). Al volver a montar el visor, si el
121
+ * nuevo no tiene token (otro evento, `session: "start"`…), avisa `null` cuando termina de cargar.
122
+ */
123
+ readonly holdTokenChange: EventEmitter<SeatsyooHoldToken>;
124
+ /** Error del visor. Si nadie lo escucha, sale como aviso en la consola. */
125
+ readonly chartError: EventEmitter<SeatsyooChartError>;
126
+ /** Se ha cambiado de planta. */
127
+ readonly floorChange: EventEmitter<SeatsyooFloor>;
128
+ private readonly elemento;
129
+ private readonly zona;
130
+ private readonly enNavegador;
131
+ private visor;
132
+ /** Con qué opciones de identidad se montó (o se intentó montar) el visor; `null` si aún no. */
133
+ private montado;
134
+ /** Las opciones en vivo (tema, color, estilos y marcas) que tiene el visor montado. */
135
+ private enVivo;
136
+ /** Cada montaje tiene su número: los avisos de un visor ya desmontado no llegan a las salidas. */
137
+ private montaje;
138
+ private destruido;
139
+ /** El último token de retención avisado por `holdTokenChange` (de este visor o de uno anterior). */
140
+ private tokenAvisado;
141
+ /**
142
+ * El visor montado (`null` en el servidor, antes de montarlo o si las opciones no valen). Sirve para llamar a
143
+ * sus métodos: `getSelection()`, `holdToken`, `clearSelection()`, `selectBestAvailable()`…
144
+ */
145
+ get chart(): SeatingChart$1 | null;
146
+ ngAfterViewInit(): void;
147
+ ngOnChanges(): void;
148
+ ngOnDestroy(): void;
149
+ private identidad;
150
+ private opcionesEnVivo;
151
+ private hayQueVolverAMontar;
152
+ private montar;
153
+ private desmontar;
154
+ private avisarError;
155
+ static ɵfac: i0.ɵɵFactoryDeclaration<SeatsyooChartComponent, never>;
156
+ static ɵcmp: i0.ɵɵComponentDeclaration<SeatsyooChartComponent, "seatsyoo-chart", never, {
157
+ "server": {
158
+ "alias": "server";
159
+ "required": true;
160
+ };
161
+ "publicKey": {
162
+ "alias": "publicKey";
163
+ "required": false;
164
+ };
165
+ "event": {
166
+ "alias": "event";
167
+ "required": false;
168
+ };
169
+ "link": {
170
+ "alias": "link";
171
+ "required": false;
172
+ };
173
+ "document": {
174
+ "alias": "document";
175
+ "required": false;
176
+ };
177
+ "season": {
178
+ "alias": "season";
179
+ "required": false;
180
+ };
181
+ "seasonEvents": {
182
+ "alias": "seasonEvents";
183
+ "required": false;
184
+ };
185
+ "channels": {
186
+ "alias": "channels";
187
+ "required": false;
188
+ };
189
+ "pricing": {
190
+ "alias": "pricing";
191
+ "required": false;
192
+ };
193
+ "currency": {
194
+ "alias": "currency";
195
+ "required": false;
196
+ };
197
+ "locale": {
198
+ "alias": "locale";
199
+ "required": false;
200
+ };
201
+ "language": {
202
+ "alias": "language";
203
+ "required": false;
204
+ };
205
+ "maxSelected": {
206
+ "alias": "maxSelected";
207
+ "required": false;
208
+ };
209
+ "session": {
210
+ "alias": "session";
211
+ "required": false;
212
+ };
213
+ "holdToken": {
214
+ "alias": "holdToken";
215
+ "required": false;
216
+ };
217
+ "mode": {
218
+ "alias": "mode";
219
+ "required": false;
220
+ };
221
+ "showLegend": {
222
+ "alias": "showLegend";
223
+ "required": false;
224
+ };
225
+ "showSelectionBar": {
226
+ "alias": "showSelectionBar";
227
+ "required": false;
228
+ };
229
+ "floor": {
230
+ "alias": "floor";
231
+ "required": false;
232
+ };
233
+ "sectors": {
234
+ "alias": "sectors";
235
+ "required": false;
236
+ };
237
+ "view3d": {
238
+ "alias": "view3d";
239
+ "required": false;
240
+ };
241
+ "entrance": {
242
+ "alias": "entrance";
243
+ "required": false;
244
+ };
245
+ "texts": {
246
+ "alias": "texts";
247
+ "required": false;
248
+ };
249
+ "theme": {
250
+ "alias": "theme";
251
+ "required": false;
252
+ };
253
+ "colorBy": {
254
+ "alias": "colorBy";
255
+ "required": false;
256
+ };
257
+ "statusStyles": {
258
+ "alias": "statusStyles";
259
+ "required": false;
260
+ };
261
+ "marks": {
262
+ "alias": "marks";
263
+ "required": false;
264
+ };
265
+ "load3d": {
266
+ "alias": "load3d";
267
+ "required": false;
268
+ };
269
+ }, {
270
+ "ready": "ready";
271
+ "selectionChange": "selectionChange";
272
+ "objectSelect": "objectSelect";
273
+ "objectDeselect": "objectDeselect";
274
+ "holdExpired": "holdExpired";
275
+ "holdTokenChange": "holdTokenChange";
276
+ "chartError": "chartError";
277
+ "floorChange": "floorChange";
278
+ }, never, never, true, never>;
279
+ }
280
+ /** Versión de este paquete. */
281
+ export declare const version = "1.0.0";
282
+ export type { ChartDocument, Language, RenderOptions, SeatingChart, SeatsyooChartError, SeatsyooFloor, SeatsyooHoldToken, SelectedObject, StatusStyle, View3DModule };