@solercia/ui 0.4.0 → 0.5.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.
@@ -120,6 +120,16 @@ class SolInputComponent {
120
120
  */
121
121
  autocomplete = input(undefined, /* @ts-ignore */
122
122
  ...(ngDevMode ? [{ debugName: "autocomplete" }] : /* istanbul ignore next */ []));
123
+ /**
124
+ * Passthrough opcional al atributo `min` del `<input>` nativo (ola-09,
125
+ * P3b): fecha mínima seleccionable en `type="date"` — evita agendar al
126
+ * pasado desde el propio selector nativo. `undefined` por defecto — con
127
+ * `[attr.min]` Angular OMITE el atributo por completo, así que ningún
128
+ * consumidor existente cambia de comportamiento (mismo patrón aditivo de
129
+ * `autocomplete`, arriba).
130
+ */
131
+ min = input(undefined, /* @ts-ignore */
132
+ ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
123
133
  /* --- Internal state --- */
124
134
  value = signal('', /* @ts-ignore */
125
135
  ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
@@ -147,7 +157,7 @@ class SolInputComponent {
147
157
  this.isDisabled.set(isDisabled);
148
158
  }
149
159
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
150
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SolInputComponent, isStandalone: true, selector: "sol-input", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
160
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SolInputComponent, isStandalone: true, selector: "sol-input", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
151
161
  {
152
162
  provide: NG_VALUE_ACCESSOR,
153
163
  useExisting: forwardRef(() => SolInputComponent),
@@ -167,6 +177,7 @@ class SolInputComponent {
167
177
  [disabled]="disabled() || isDisabled()"
168
178
  [value]="value()"
169
179
  [attr.autocomplete]="autocomplete()"
180
+ [attr.min]="min()"
170
181
  (input)="onInputChange($event)"
171
182
  (blur)="onTouched()"
172
183
  />
@@ -198,6 +209,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
198
209
  [disabled]="disabled() || isDisabled()"
199
210
  [value]="value()"
200
211
  [attr.autocomplete]="autocomplete()"
212
+ [attr.min]="min()"
201
213
  (input)="onInputChange($event)"
202
214
  (blur)="onTouched()"
203
215
  />
@@ -206,7 +218,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
206
218
  }
207
219
  </div>
208
220
  `, styles: [":host{display:block}.sol-input-wrapper{display:flex;flex-direction:column;gap:var(--sol-space-xs)}.sol-input-label{font-family:var(--sol-font-family);font-size:var(--sol-font-size-sm, 12px);font-weight:500;color:var(--sol-color-text-secondary, #64748B);text-transform:uppercase;letter-spacing:.05em;line-height:1}.sol-input{width:100%;height:var(--sol-size-input-height);padding:0 var(--sol-space-sm);font-family:var(--sol-font-family);font-size:var(--sol-font-size-base);color:var(--sol-color-text-primary);background:var(--sol-input-bg, var(--sol-bg-surface));border:var(--sol-input-border, var(--sol-border-width-default) solid var(--sol-border-color-default));border-radius:var(--sol-input-radius, var(--sol-border-radius-md));box-shadow:var(--sol-input-shadow, none);outline:none;box-sizing:border-box;transition:border-color var(--sol-dur-fast, .15s) var(--sol-ease, ease),box-shadow var(--sol-dur-fast, .15s) var(--sol-ease, ease)}.sol-input::placeholder{color:var(--sol-color-text-muted)}.sol-input:focus{border:var(--sol-input-focus-border, var(--sol-border-width-default) solid var(--sol-color-primary));box-shadow:var(--sol-input-focus-ring, 0 0 0 2px color-mix(in srgb, var(--sol-color-primary) 20%, transparent))}.sol-input--error{border-color:var(--sol-color-danger)}.sol-input--error:focus{border-color:var(--sol-color-danger);box-shadow:0 0 0 2px color-mix(in srgb,var(--sol-color-danger) 20%,transparent)}.sol-input--disabled{opacity:.5;cursor:not-allowed}.sol-input-error{font-family:var(--sol-font-family);font-size:var(--sol-font-size-sm, 12px);color:var(--sol-color-danger);line-height:1.3}@media(max-width:640px){.sol-input{font-size:16px}}\n"] }]
209
- }], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }] } });
221
+ }], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }] } });
210
222
 
211
223
  /**
212
224
  * Icon Registry — inner SVG path content (without the <svg> wrapper).
@@ -593,6 +605,24 @@ const ICON_REGISTRY = {
593
605
  outline: `<path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" />`,
594
606
  fill: `<path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm8.706-1.442c1.146-.573 2.437.463 2.126 1.706l-.709 2.836.042-.02a.75.75 0 0 1 .67 1.34l-.04.022c-1.147.573-2.438-.463-2.127-1.706l.71-2.836-.042.02a.75.75 0 1 1-.671-1.34l.041-.022ZM12 9a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z" clip-rule="evenodd" />`,
595
607
  },
608
+ // ── Aportes de Solercia Command (0.5.0) — Heroicons v2, `d` copiados sin editar ──
609
+ // Los tres cierran el gap que Solercia Command documentó en su auditoría de UI
610
+ // (openspec, cambio 13, inventory.md: "Pendientes de aporte a la librería"), donde
611
+ // sobrevivían como SVG inline por no existir aquí.
612
+ // NOTA: `sitemap`, también pedido por esa auditoría, NO existe en Heroicons v2 y no se
613
+ // inventa path data (regla de la cabecera). Sigue pendiente como ícono propio.
614
+ 'arrow-left': {
615
+ outline: `<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" />`,
616
+ fill: `<path fill-rule="evenodd" d="M11.03 3.97a.75.75 0 0 1 0 1.06l-6.22 6.22H21a.75.75 0 0 1 0 1.5H4.81l6.22 6.22a.75.75 0 1 1-1.06 1.06l-7.5-7.5a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 0 1 1.06 0Z" clip-rule="evenodd" />`,
617
+ },
618
+ 'arrow-right-on-rectangle': {
619
+ outline: `<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0 0 13.5 3h-6a2.25 2.25 0 0 0-2.25 2.25v13.5A2.25 2.25 0 0 0 7.5 21h6a2.25 2.25 0 0 0 2.25-2.25V15m3 0 3-3m0 0-3-3m3 3H9" />`,
620
+ fill: `<path fill-rule="evenodd" d="M7.5 3.75A1.5 1.5 0 0 0 6 5.25v13.5a1.5 1.5 0 0 0 1.5 1.5h6a1.5 1.5 0 0 0 1.5-1.5V15a.75.75 0 0 1 1.5 0v3.75a3 3 0 0 1-3 3h-6a3 3 0 0 1-3-3V5.25a3 3 0 0 1 3-3h6a3 3 0 0 1 3 3V9A.75.75 0 0 1 15 9V5.25a1.5 1.5 0 0 0-1.5-1.5h-6Zm10.72 4.72a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a.75.75 0 0 1 0-1.5h10.94l-1.72-1.72a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />`,
621
+ },
622
+ flag: {
623
+ outline: `<path stroke-linecap="round" stroke-linejoin="round" d="M3 3v1.5M3 21v-6m0 0 2.77-.693a9 9 0 0 1 6.208.682l.108.054a9 9 0 0 0 6.086.71l3.114-.732a48.524 48.524 0 0 1-.005-10.499l-3.11.732a9 9 0 0 1-6.085-.711l-.108-.054a9 9 0 0 0-6.208-.682L3 4.5M3 15V4.5" />`,
624
+ fill: `<path fill-rule="evenodd" d="M3 2.25a.75.75 0 0 1 .75.75v.54l1.838-.46a9.75 9.75 0 0 1 6.725.738l.108.054A8.25 8.25 0 0 0 18 4.524l3.11-.732a.75.75 0 0 1 .917.81 47.784 47.784 0 0 0 .005 10.337.75.75 0 0 1-.574.812l-3.114.733a9.75 9.75 0 0 1-6.594-.77l-.108-.054a8.25 8.25 0 0 0-5.69-.625l-2.202.55V21a.75.75 0 0 1-1.5 0V3A.75.75 0 0 1 3 2.25Z" clip-rule="evenodd" />`,
625
+ },
596
626
  // ── CRM / Vocero — íconos propios sin equivalente Heroicons (11-a-solercia-ui, PR2) ──
597
627
  // Sin licencia MIT de terceros que reproducir: diseño propio, mismo patrón que la
598
628
  // sección de rich-editor (trazo stroke-linecap/linejoin round, viewBox 24×24 implícito
@@ -14365,6 +14395,1505 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
14365
14395
  `, styles: [":host{display:block;position:relative}.sol-flow-canvas{position:relative;width:100%;min-height:320px;overflow:hidden;background:var(--sol-bg-sunken, var(--sol-bg-page, #f8fafc));border-radius:var(--sol-border-radius-lg, 12px);touch-action:none;--sol-flow-canvas-hit-min: min(calc(44px / var(--sol-flow-canvas-zoom, 1)), 176px)}.sol-flow-canvas__world{position:absolute;inset:0;transform-origin:0 0;will-change:transform}.sol-flow-canvas__edges{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible}.sol-flow-canvas__edge-line{stroke:var(--sol-border-color-default, #94a3b8);stroke-width:2;fill:none}.sol-flow-canvas__edge-ghost{stroke:var(--sol-color-info, #3b82f6);stroke-width:2;stroke-dasharray:6 4;fill:none}.sol-flow-canvas__edge-arrow{fill:var(--sol-border-color-default, #94a3b8)}.sol-flow-canvas__edge-label{position:absolute;transform:translate(-50%,-50%);display:flex;align-items:center;gap:4px;background:var(--sol-bg-surface, #fff);border:1px solid var(--sol-border-color-default, #e2e8f0);border-radius:var(--sol-border-radius-full, 999px);padding:2px 8px;font-size:var(--sol-font-size-xs, 11px);color:var(--sol-color-text-secondary, #475569);z-index:2}.sol-flow-canvas__edge-remove{border:none;background:transparent;color:var(--sol-color-danger, #ef4444);cursor:pointer;font-size:var(--sol-font-size-sm, 13px);line-height:1;display:inline-flex;align-items:center;justify-content:center;flex:none;width:var(--sol-flow-canvas-hit-min, 44px);height:var(--sol-flow-canvas-hit-min, 44px);margin:calc((13px - var(--sol-flow-canvas-hit-min, 44px)) / 2)}.sol-flow-canvas__node{position:absolute;width:180px;display:flex;align-items:stretch;gap:4px;z-index:3;touch-action:none}.sol-flow-canvas__node-surface{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:var(--sol-flow-canvas-hit-min, 44px);text-align:left;padding:10px 12px;background:var(--sol-bg-surface, #fff);border:2px solid var(--sol-border-color-default, #e2e8f0);border-radius:var(--sol-border-radius-lg, 10px);box-shadow:var(--sol-shadow-sm, 0 1px 2px rgba(0, 0, 0, .06));cursor:grab;font-family:var(--sol-font-family);color:var(--sol-color-text-primary);transition:opacity .15s ease}.sol-flow-canvas__node-surface:focus-visible{outline:2px solid var(--sol-color-primary, #2563eb);outline-offset:2px}.sol-flow-canvas__node--selected .sol-flow-canvas__node-surface{border-color:var(--sol-color-primary, #2563eb)}.sol-flow-canvas__node--highlighted .sol-flow-canvas__node-surface{box-shadow:0 0 0 3px color-mix(in srgb,var(--sol-color-primary, #2563eb) 30%,transparent)}.sol-flow-canvas__node--connect-source .sol-flow-canvas__node-surface{border-style:dashed;border-color:var(--sol-color-info, #3b82f6)}.sol-flow-canvas__node--connect-valid-target .sol-flow-canvas__node-surface{border-style:dashed;border-color:var(--sol-color-success, #10b981);box-shadow:0 0 0 3px color-mix(in srgb,var(--sol-color-success, #10b981) 25%,transparent)}.sol-flow-canvas__node--connect-invalid-target .sol-flow-canvas__node-surface{opacity:.45}.sol-flow-canvas__node[data-visual-state=running] .sol-flow-canvas__node-surface{border-color:var(--sol-color-info, #3b82f6)}.sol-flow-canvas__node[data-visual-state=ok] .sol-flow-canvas__node-surface{border-color:var(--sol-color-success, #10b981)}.sol-flow-canvas__node[data-visual-state=error] .sol-flow-canvas__node-surface{border-color:var(--sol-color-danger, #ef4444)}.sol-flow-canvas__node-label{font-size:var(--sol-font-size-sm, 13px);font-weight:600}.sol-flow-canvas__node-connect-handle{align-self:center;flex:none;display:inline-flex;align-items:center;justify-content:center;min-width:var(--sol-flow-canvas-hit-min, 44px);min-height:var(--sol-flow-canvas-hit-min, 44px);border:1px solid var(--sol-border-color-default, #e2e8f0);border-radius:var(--sol-border-radius-md, 8px);background:var(--sol-bg-surface, #fff);color:var(--sol-color-text-secondary, #475569);cursor:pointer}.sol-flow-canvas__announce{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sol-flow-canvas__auto-layout{display:none;position:absolute;right:12px;bottom:12px;z-index:4;min-width:44px;min-height:44px;padding:0 16px;align-items:center;justify-content:center;border:1px solid var(--sol-border-color-default, #e2e8f0);border-radius:var(--sol-border-radius-full, 999px);background:var(--sol-bg-surface, #fff);color:var(--sol-color-text-primary);font-family:var(--sol-font-family);font-size:var(--sol-font-size-sm, 13px);font-weight:600;box-shadow:var(--sol-shadow-md, 0 4px 12px rgba(0, 0, 0, .12));cursor:pointer}.sol-flow-canvas__auto-layout:focus-visible{outline:2px solid var(--sol-color-primary, #2563eb);outline-offset:2px}@media(max-width:767px){.sol-flow-canvas__auto-layout{display:inline-flex}}\n"] }]
14366
14396
  }], ctorParameters: () => [], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], edges: [{ type: i0.Input, args: [{ isSignal: true, alias: "edges", required: false }] }], isReadonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], selectedId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedId", required: false }] }], highlightedNodeId: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightedNodeId", required: false }] }], nodeTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodeTemplate", required: false }] }], nodeMoved: [{ type: i0.Output, args: ["nodeMoved"] }], nodeSelected: [{ type: i0.Output, args: ["nodeSelected"] }], connectionCreated: [{ type: i0.Output, args: ["connectionCreated"] }], connectionRemoved: [{ type: i0.Output, args: ["connectionRemoved"] }], canvasHostRef: [{ type: i0.ViewChild, args: ['canvasHost', { isSignal: true }] }] } });
14367
14397
 
14398
+ /**
14399
+ * Profundidad máxima por defecto: 5 niveles visibles (raíz = nivel 1).
14400
+ *
14401
+ * Es una cota DURA heredada del árbol de jerarquía que originó este
14402
+ * componente: mantiene el DOM acotado (sin virtualización), evita sangrías
14403
+ * ilegibles en móvil y —lo más importante para un primitivo genérico— corta
14404
+ * la recursión si el consumidor pasa por error un grafo con ciclos.
14405
+ */
14406
+ const SOL_TREE_MAX_DEPTH = 5;
14407
+ /**
14408
+ * Marca el `<ng-template>` que pinta el CONTENIDO de cada nodo. Debe ser hijo
14409
+ * directo de `<sol-tree>`. Sin él, el árbol cae a un render por defecto que
14410
+ * muestra `node.label`.
14411
+ *
14412
+ * ```html
14413
+ * <sol-tree [nodes]="arbol()" (nodeSelected)="ir($event)">
14414
+ * <ng-template solTreeNodeDef let-node let-depth="depth">
14415
+ * <span>{{ node.label }}</span>
14416
+ * <sol-badge>{{ node.data?.metodologia }}</sol-badge>
14417
+ * </ng-template>
14418
+ * </sol-tree>
14419
+ * ```
14420
+ *
14421
+ * Nota de tipado: sin un input que ancle el genérico, TypeScript infiere
14422
+ * `T = unknown`, así que `node.data` llega como `unknown` y el consumidor lo
14423
+ * estrecha en su propio código. Es el mismo compromiso de `matTreeNodeDef`;
14424
+ * se prefirió eso antes que ensuciar la API con un input solo-para-inferencia.
14425
+ */
14426
+ class SolTreeNodeDefDirective {
14427
+ template = inject((TemplateRef));
14428
+ /** Tipa las variables `let-` del template (`let-node`, `let-depth`, …). */
14429
+ static ngTemplateContextGuard(_directive, _context) {
14430
+ return true;
14431
+ }
14432
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeNodeDefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
14433
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SolTreeNodeDefDirective, isStandalone: true, selector: "[solTreeNodeDef]", ngImport: i0 });
14434
+ }
14435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeNodeDefDirective, decorators: [{
14436
+ type: Directive,
14437
+ args: [{
14438
+ selector: '[solTreeNodeDef]',
14439
+ standalone: true,
14440
+ }]
14441
+ }] });
14442
+ /**
14443
+ * Estado compartido por TODOS los nodos de un mismo `sol-tree` (se provee en
14444
+ * `providers` del contenedor, así cada árbol tiene el suyo).
14445
+ *
14446
+ * `activeId` es el cursor del roving tabindex: solo el nodo activo lleva
14447
+ * `tabindex="0"`, el resto `-1`. Así el árbol completo es UNA sola parada de
14448
+ * Tab y las flechas mueven el foco adentro (patrón `tree` de la APG).
14449
+ */
14450
+ class SolTreeState {
14451
+ /** Id del único nodo que es parada de Tab. */
14452
+ activeId = signal(null, /* @ts-ignore */
14453
+ ...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
14454
+ /** Lo instala el contenedor en su constructor, antes de crear cualquier nodo. */
14455
+ owner;
14456
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
14457
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeState });
14458
+ }
14459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeState, decorators: [{
14460
+ type: Injectable
14461
+ }] });
14462
+ /**
14463
+ * Nodo recursivo del árbol: se renderiza a sí mismo para cada hijo, de modo
14464
+ * que el anidamiento ARIA (`treeitem` › `group` › `treeitem`) calza con el
14465
+ * DOM sin listas aplanadas.
14466
+ *
14467
+ * `role="treeitem"`, el `tabindex` y el manejo de teclado viven en el HOST
14468
+ * (no en un `<div>` interno): así este elemento es el que recibe el foco y
14469
+ * el que aparece en la consulta del roving tabindex de `moveFocus()`.
14470
+ *
14471
+ * Es una pieza INTERNA de `sol-tree`; no se usa suelta.
14472
+ */
14473
+ class SolTreeNodeComponent {
14474
+ /** Nodo que pinta esta instancia. */
14475
+ node = input.required(/* @ts-ignore */
14476
+ ...(ngDevMode ? [{ debugName: "node" }] : /* istanbul ignore next */ []));
14477
+ /** Profundidad base 0 (las raíces valen 0). */
14478
+ depth = input(0, /* @ts-ignore */
14479
+ ...(ngDevMode ? [{ debugName: "depth" }] : /* istanbul ignore next */ []));
14480
+ el = inject(ElementRef);
14481
+ state = inject(SolTreeState);
14482
+ i18n = inject(SOL_I18N);
14483
+ children = computed(() => this.node().children ?? [], /* @ts-ignore */
14484
+ ...(ngDevMode ? [{ debugName: "children" }] : /* istanbul ignore next */ []));
14485
+ hasChildren = computed(() => this.children().length > 0, /* @ts-ignore */
14486
+ ...(ngDevMode ? [{ debugName: "hasChildren" }] : /* istanbul ignore next */ []));
14487
+ expanded = computed(() => this.state.owner.expandedSet().has(this.node().id), /* @ts-ignore */
14488
+ ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
14489
+ indent = computed(() => this.state.owner.indent(), /* @ts-ignore */
14490
+ ...(ngDevMode ? [{ debugName: "indent" }] : /* istanbul ignore next */ []));
14491
+ nodeTemplate = computed(() => this.state.owner.nodeTemplate(), /* @ts-ignore */
14492
+ ...(ngDevMode ? [{ debugName: "nodeTemplate" }] : /* istanbul ignore next */ []));
14493
+ /** Corta la recursión en `maxDepth` niveles visibles (ver {@link SOL_TREE_MAX_DEPTH}). */
14494
+ canDescend = computed(() => this.depth() + 1 < this.state.owner.maxDepth(), /* @ts-ignore */
14495
+ ...(ngDevMode ? [{ debugName: "canDescend" }] : /* istanbul ignore next */ []));
14496
+ showChildren = computed(() => this.hasChildren() && this.expanded() && this.canDescend(), /* @ts-ignore */
14497
+ ...(ngDevMode ? [{ debugName: "showChildren" }] : /* istanbul ignore next */ []));
14498
+ /** Roving tabindex: solo el nodo activo es parada de Tab. */
14499
+ tabIndexValue = computed(() => this.state.activeId() === this.node().id ? 0 : -1, /* @ts-ignore */
14500
+ ...(ngDevMode ? [{ debugName: "tabIndexValue" }] : /* istanbul ignore next */ []));
14501
+ templateContext = computed(() => ({
14502
+ $implicit: this.node(),
14503
+ node: this.node(),
14504
+ depth: this.depth(),
14505
+ expanded: this.expanded(),
14506
+ hasChildren: this.hasChildren(),
14507
+ }), /* @ts-ignore */
14508
+ ...(ngDevMode ? [{ debugName: "templateContext" }] : /* istanbul ignore next */ []));
14509
+ /** `aria-label` del chevron: varía con el estado y con el nombre del nodo. */
14510
+ toggleAriaLabel = computed(() => {
14511
+ this.i18n.activeLang();
14512
+ const label = this.node().label;
14513
+ return this.expanded()
14514
+ ? this.text('shared.tree.collapseAria', `Contraer ${label}`, label)
14515
+ : this.text('shared.tree.expandAria', `Expandir ${label}`, label);
14516
+ }, /* @ts-ignore */
14517
+ ...(ngDevMode ? [{ debugName: "toggleAriaLabel" }] : /* istanbul ignore next */ []));
14518
+ onToggleClick(event) {
14519
+ // El clic en el chevron no debe burbujear hacia la fila del consumidor.
14520
+ event.stopPropagation();
14521
+ this.state.owner.toggle(this.node());
14522
+ }
14523
+ onFocus() {
14524
+ this.state.activeId.set(this.node().id);
14525
+ }
14526
+ /**
14527
+ * Teclado del patrón `tree` (idéntico al del árbol de jerarquía original):
14528
+ * Enter/Espacio activa —alterna si tiene hijos, selecciona si es hoja—,
14529
+ * ←/→ colapsa/expande y ↑/↓ mueven el foco entre los `treeitem` VISIBLES.
14530
+ *
14531
+ * Dos ajustes sobre el original, ambos deliberados:
14532
+ * 1. "Activar una hoja" ya no navega: emite `nodeSelected` y el consumidor
14533
+ * decide (requisito de acoplamiento cero al dominio).
14534
+ * 2. Solo actúa el `treeitem` REALMENTE enfocado. El original escuchaba en
14535
+ * el host sin filtrar el `target`, así que la tecla de un nodo anidado
14536
+ * burbujeaba y sus ancestros la volvían a procesar (con ↓ el foco
14537
+ * terminaba en el lugar equivocado); además, con esta guarda, escribir
14538
+ * con flechas dentro de un campo de la plantilla proyectada ya no mueve
14539
+ * el foco del árbol.
14540
+ */
14541
+ onKeydown(event) {
14542
+ if (event.target !== this.el.nativeElement)
14543
+ return;
14544
+ switch (event.key) {
14545
+ case 'Enter':
14546
+ case ' ':
14547
+ event.preventDefault();
14548
+ if (this.hasChildren()) {
14549
+ this.state.owner.toggle(this.node());
14550
+ }
14551
+ else {
14552
+ this.state.owner.select(this.node());
14553
+ }
14554
+ break;
14555
+ case 'ArrowRight':
14556
+ if (this.hasChildren() && !this.expanded()) {
14557
+ event.preventDefault();
14558
+ this.state.owner.toggle(this.node());
14559
+ }
14560
+ break;
14561
+ case 'ArrowLeft':
14562
+ if (this.hasChildren() && this.expanded()) {
14563
+ event.preventDefault();
14564
+ this.state.owner.toggle(this.node());
14565
+ }
14566
+ break;
14567
+ case 'ArrowDown':
14568
+ event.preventDefault();
14569
+ this.moveFocus(1);
14570
+ break;
14571
+ case 'ArrowUp':
14572
+ event.preventDefault();
14573
+ this.moveFocus(-1);
14574
+ break;
14575
+ }
14576
+ }
14577
+ /**
14578
+ * Mueve el foco al `treeitem` visible siguiente/anterior en orden del DOM.
14579
+ * Como los hijos colapsados no se renderizan, ese orden ya coincide con el
14580
+ * orden visual de arriba hacia abajo: no hace falta aplanar el árbol.
14581
+ */
14582
+ moveFocus(delta) {
14583
+ const container = this.el.nativeElement.closest('[role="tree"]');
14584
+ if (!container)
14585
+ return;
14586
+ const items = Array.from(container.querySelectorAll('[role="treeitem"]'));
14587
+ const index = items.indexOf(this.el.nativeElement);
14588
+ items[index + delta]?.focus();
14589
+ }
14590
+ /** Resuelve texto: clave i18n (si el host la traduce) → default es-CO. */
14591
+ text(key, fallback, label) {
14592
+ const translated = this.i18n.translate(key, { label });
14593
+ return translated && translated !== key ? translated : fallback;
14594
+ }
14595
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
14596
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SolTreeNodeComponent, isStandalone: true, selector: "sol-tree-node", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null }, depth: { classPropertyName: "depth", publicName: "depth", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "treeitem" }, listeners: { "keydown": "onKeydown($event)", "focus": "onFocus()" }, properties: { "attr.aria-expanded": "hasChildren() ? expanded() : null", "attr.aria-level": "depth() + 1", "attr.tabindex": "tabIndexValue()" }, classAttribute: "sol-tree__item" }, ngImport: i0, template: `
14597
+ <div class="sol-tree__row" [style.paddingLeft.px]="depth() * indent()">
14598
+ @if (hasChildren()) {
14599
+ <button
14600
+ type="button"
14601
+ class="sol-tree__toggle"
14602
+ tabindex="-1"
14603
+ [attr.aria-label]="toggleAriaLabel()"
14604
+ (click)="onToggleClick($event)"
14605
+ >
14606
+ <sol-icon [name]="expanded() ? 'chevron-down' : 'chevron-right'" size="sm" />
14607
+ </button>
14608
+ } @else {
14609
+ <span class="sol-tree__toggle-spacer" aria-hidden="true"></span>
14610
+ }
14611
+
14612
+ <div class="sol-tree__content">
14613
+ @if (nodeTemplate(); as tpl) {
14614
+ <ng-container
14615
+ [ngTemplateOutlet]="tpl"
14616
+ [ngTemplateOutletContext]="templateContext()"
14617
+ />
14618
+ } @else {
14619
+ <span class="sol-tree__label">{{ node().label }}</span>
14620
+ }
14621
+ </div>
14622
+ </div>
14623
+
14624
+ @if (showChildren()) {
14625
+ <div role="group" class="sol-tree__group">
14626
+ @for (child of children(); track child.id) {
14627
+ <sol-tree-node [node]="child" [depth]="depth() + 1" />
14628
+ }
14629
+ </div>
14630
+ }
14631
+ `, isInline: true, styles: [":host{display:block;border-radius:var(--sol-border-radius-lg, 12px);outline:none}:host(:focus-visible){outline:2px solid var(--sol-color-primary, #2563eb);outline-offset:2px}.sol-tree__row{display:flex;align-items:center;gap:var(--sol-space-sm, .5rem);min-width:0}.sol-tree__toggle,.sol-tree__toggle-spacer{flex:none;width:2.25rem;height:2.25rem}.sol-tree__toggle{display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;border-radius:var(--sol-border-radius-md, 8px);background:transparent;color:var(--sol-color-text-secondary, #6b7280);cursor:pointer;transition:background var(--sol-dur-fast, .12s) var(--sol-ease, ease),color var(--sol-dur-fast, .12s) var(--sol-ease, ease)}.sol-tree__toggle:hover{background:var(--sol-bg-sunken, rgba(0, 0, 0, .05));color:var(--sol-color-text-primary, #111827)}.sol-tree__content{flex:1 1 auto;min-width:0}.sol-tree__label{display:block;overflow:hidden;color:var(--sol-color-text-primary, #111827);font-family:var(--sol-font-family);font-size:var(--sol-font-size-base, 14px);text-overflow:ellipsis;white-space:nowrap}.sol-tree__group{display:flex;flex-direction:column;gap:var(--sol-space-sm, .5rem);margin-top:var(--sol-space-sm, .5rem)}@media(prefers-reduced-motion:reduce){.sol-tree__toggle{transition:none}}\n"], dependencies: [{ kind: "component", type: SolTreeNodeComponent, selector: "sol-tree-node", inputs: ["node", "depth"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: SolIconComponent, selector: "sol-icon", inputs: ["name", "size", "variant"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
14632
+ }
14633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeNodeComponent, decorators: [{
14634
+ type: Component,
14635
+ args: [{ selector: 'sol-tree-node', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet, SolIconComponent, SolTreeNodeComponent], host: {
14636
+ role: 'treeitem',
14637
+ class: 'sol-tree__item',
14638
+ '[attr.aria-expanded]': 'hasChildren() ? expanded() : null',
14639
+ '[attr.aria-level]': 'depth() + 1',
14640
+ '[attr.tabindex]': 'tabIndexValue()',
14641
+ '(keydown)': 'onKeydown($event)',
14642
+ '(focus)': 'onFocus()',
14643
+ }, template: `
14644
+ <div class="sol-tree__row" [style.paddingLeft.px]="depth() * indent()">
14645
+ @if (hasChildren()) {
14646
+ <button
14647
+ type="button"
14648
+ class="sol-tree__toggle"
14649
+ tabindex="-1"
14650
+ [attr.aria-label]="toggleAriaLabel()"
14651
+ (click)="onToggleClick($event)"
14652
+ >
14653
+ <sol-icon [name]="expanded() ? 'chevron-down' : 'chevron-right'" size="sm" />
14654
+ </button>
14655
+ } @else {
14656
+ <span class="sol-tree__toggle-spacer" aria-hidden="true"></span>
14657
+ }
14658
+
14659
+ <div class="sol-tree__content">
14660
+ @if (nodeTemplate(); as tpl) {
14661
+ <ng-container
14662
+ [ngTemplateOutlet]="tpl"
14663
+ [ngTemplateOutletContext]="templateContext()"
14664
+ />
14665
+ } @else {
14666
+ <span class="sol-tree__label">{{ node().label }}</span>
14667
+ }
14668
+ </div>
14669
+ </div>
14670
+
14671
+ @if (showChildren()) {
14672
+ <div role="group" class="sol-tree__group">
14673
+ @for (child of children(); track child.id) {
14674
+ <sol-tree-node [node]="child" [depth]="depth() + 1" />
14675
+ }
14676
+ </div>
14677
+ }
14678
+ `, styles: [":host{display:block;border-radius:var(--sol-border-radius-lg, 12px);outline:none}:host(:focus-visible){outline:2px solid var(--sol-color-primary, #2563eb);outline-offset:2px}.sol-tree__row{display:flex;align-items:center;gap:var(--sol-space-sm, .5rem);min-width:0}.sol-tree__toggle,.sol-tree__toggle-spacer{flex:none;width:2.25rem;height:2.25rem}.sol-tree__toggle{display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;border-radius:var(--sol-border-radius-md, 8px);background:transparent;color:var(--sol-color-text-secondary, #6b7280);cursor:pointer;transition:background var(--sol-dur-fast, .12s) var(--sol-ease, ease),color var(--sol-dur-fast, .12s) var(--sol-ease, ease)}.sol-tree__toggle:hover{background:var(--sol-bg-sunken, rgba(0, 0, 0, .05));color:var(--sol-color-text-primary, #111827)}.sol-tree__content{flex:1 1 auto;min-width:0}.sol-tree__label{display:block;overflow:hidden;color:var(--sol-color-text-primary, #111827);font-family:var(--sol-font-family);font-size:var(--sol-font-size-base, 14px);text-overflow:ellipsis;white-space:nowrap}.sol-tree__group{display:flex;flex-direction:column;gap:var(--sol-space-sm, .5rem);margin-top:var(--sol-space-sm, .5rem)}@media(prefers-reduced-motion:reduce){.sol-tree__toggle{transition:none}}\n"] }]
14679
+ }], propDecorators: { node: [{ type: i0.Input, args: [{ isSignal: true, alias: "node", required: true }] }], depth: [{ type: i0.Input, args: [{ isSignal: true, alias: "depth", required: false }] }] } });
14680
+ /**
14681
+ * `sol-tree` — árbol jerárquico genérico del design system.
14682
+ *
14683
+ * Sube a la librería el MECANISMO (recursión, ARIA `tree`/`treeitem`/`group`,
14684
+ * roving tabindex con flechas, expandir/colapsar, cota de profundidad) y deja
14685
+ * en la aplicación el CÓMO SE PINTA cada nodo, vía el `ng-template` marcado
14686
+ * con `solTreeNodeDef`. Cero conocimiento del dominio: ni rutas, ni `Router`,
14687
+ * ni badges, ni barras de avance.
14688
+ *
14689
+ * ```html
14690
+ * <sol-tree
14691
+ * [nodes]="arbol()"
14692
+ * [(expandedIds)]="expandidos"
14693
+ * (nodeSelected)="router.navigate(['/proyectos', $event.id])"
14694
+ * (nodeToggled)="persistir($event.expandedIds)"
14695
+ * >
14696
+ * <ng-template solTreeNodeDef let-node let-expanded="expanded">
14697
+ * <sol-card>{{ node.label }}</sol-card>
14698
+ * </ng-template>
14699
+ * </sol-tree>
14700
+ * ```
14701
+ *
14702
+ * Estados: si `nodes` llega vacío el árbol no pinta nada — el vacío legítimo,
14703
+ * la carga y el error son del consumidor (`sol-skeleton`, `sol-empty-state`).
14704
+ *
14705
+ * @typeParam T Tipo de la carga libre `data` de cada nodo.
14706
+ */
14707
+ class SolTreeComponent {
14708
+ i18n = inject(SOL_I18N);
14709
+ state = inject(SolTreeState);
14710
+ /** Raíces del bosque. Un árbol de una sola raíz es un arreglo de un elemento. */
14711
+ nodes = input.required(/* @ts-ignore */
14712
+ ...(ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []));
14713
+ /**
14714
+ * Ids expandidos, enlazable en dos vías `[(expandedIds)]`.
14715
+ *
14716
+ * `null` (default) = NO controlado: el árbol maneja la expansión solo y la
14717
+ * siembra con {@link defaultExpandedDepth}. Cualquier arreglo —incluido
14718
+ * `[]`— pasa a modo controlado: manda el consumidor y el árbol solo propone
14719
+ * el nuevo valor. Se eligió `null` en vez de `[]` como default justamente
14720
+ * para poder distinguir "no me controles" de "todo colapsado".
14721
+ */
14722
+ expandedIds = model(null, /* @ts-ignore */
14723
+ ...(ngDevMode ? [{ debugName: "expandedIds" }] : /* istanbul ignore next */ []));
14724
+ /**
14725
+ * Niveles que arrancan expandidos en modo no controlado. `1` (default)
14726
+ * expande las raíces, así el árbol nunca se ve como un muro de filas
14727
+ * colapsadas; `0` lo deja todo cerrado.
14728
+ */
14729
+ defaultExpandedDepth = input(1, /* @ts-ignore */
14730
+ ...(ngDevMode ? [{ debugName: "defaultExpandedDepth" }] : /* istanbul ignore next */ []));
14731
+ /** Niveles VISIBLES como máximo. Ver {@link SOL_TREE_MAX_DEPTH}. */
14732
+ maxDepth = input(SOL_TREE_MAX_DEPTH, /* @ts-ignore */
14733
+ ...(ngDevMode ? [{ debugName: "maxDepth" }] : /* istanbul ignore next */ []));
14734
+ /** Sangría en px que suma cada nivel. */
14735
+ indent = input(16, /* @ts-ignore */
14736
+ ...(ngDevMode ? [{ debugName: "indent" }] : /* istanbul ignore next */ []));
14737
+ /** Override del `aria-label` del contenedor `role="tree"`. */
14738
+ ariaLabel = input('', /* @ts-ignore */
14739
+ ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
14740
+ /** Se emite al activar un nodo hoja con Enter/Espacio, o al llamar {@link select}. */
14741
+ nodeSelected = output();
14742
+ /** Se emite en cada expandir/colapsar, con el set completo resultante. */
14743
+ nodeToggled = output();
14744
+ /** Plantilla de contenido proyectada (opcional: sin ella se pinta `node.label`). */
14745
+ nodeDef = contentChild(SolTreeNodeDefDirective, /* @ts-ignore */
14746
+ ...(ngDevMode ? [{ debugName: "nodeDef" }] : /* istanbul ignore next */ []));
14747
+ nodeTemplate = computed(() => this.nodeDef()?.template ?? null, /* @ts-ignore */
14748
+ ...(ngDevMode ? [{ debugName: "nodeTemplate" }] : /* istanbul ignore next */ []));
14749
+ /** Ids que la semilla dejaría expandidos con la profundidad actual. */
14750
+ seedIds = computed(() => collectExpandableIds(this.nodes(), this.defaultExpandedDepth()), /* @ts-ignore */
14751
+ ...(ngDevMode ? [{ debugName: "seedIds" }] : /* istanbul ignore next */ []));
14752
+ /**
14753
+ * Clave estructural de la semilla. Se compara como string (no por
14754
+ * identidad del arreglo) para que un `nodes` recreado con el MISMO
14755
+ * contenido no borre lo que el usuario ya expandió o colapsó a mano.
14756
+ */
14757
+ seedKey = computed(() => this.seedIds().join('|'), /* @ts-ignore */
14758
+ ...(ngDevMode ? [{ debugName: "seedKey" }] : /* istanbul ignore next */ []));
14759
+ /** Expansión interna (modo no controlado); se resiembra al cambiar el árbol. */
14760
+ autoExpanded = linkedSignal({ ...(ngDevMode ? { debugName: "autoExpanded" } : /* istanbul ignore next */ {}), source: this.seedKey,
14761
+ computation: () => untracked(() => new Set(this.seedIds())) });
14762
+ /** Set de expansión vigente: el del consumidor si controla, si no el interno. */
14763
+ expandedSet = computed(() => {
14764
+ const controlled = this.expandedIds();
14765
+ return controlled === null ? this.autoExpanded() : new Set(controlled);
14766
+ }, /* @ts-ignore */
14767
+ ...(ngDevMode ? [{ debugName: "expandedSet" }] : /* istanbul ignore next */ []));
14768
+ treeAriaLabel = computed(() => {
14769
+ this.i18n.activeLang();
14770
+ const override = this.ariaLabel().trim();
14771
+ if (override)
14772
+ return override;
14773
+ const translated = this.i18n.translate('shared.tree.ariaLabel');
14774
+ return translated && translated !== 'shared.tree.ariaLabel'
14775
+ ? translated
14776
+ : 'Árbol jerárquico';
14777
+ }, /* @ts-ignore */
14778
+ ...(ngDevMode ? [{ debugName: "treeAriaLabel" }] : /* istanbul ignore next */ []));
14779
+ constructor() {
14780
+ this.state.owner = this;
14781
+ // Roving tabindex: el árbol siempre tiene UNA parada de Tab. Se ancla en
14782
+ // la primera raíz y solo se reubica si el nodo activo desapareció del
14783
+ // árbol (recarga, filtro), nunca mientras el usuario navega con flechas.
14784
+ effect(() => {
14785
+ const roots = this.nodes();
14786
+ untracked(() => {
14787
+ const active = this.state.activeId();
14788
+ if (active !== null && containsId(roots, active))
14789
+ return;
14790
+ this.state.activeId.set(roots[0]?.id ?? null);
14791
+ });
14792
+ });
14793
+ }
14794
+ /** ¿Está expandido ese id? */
14795
+ isExpanded(id) {
14796
+ return this.expandedSet().has(id);
14797
+ }
14798
+ /** Alterna la expansión de un nodo (lo mismo que hace el chevron). */
14799
+ toggle(node) {
14800
+ this.setExpanded(node, !this.expandedSet().has(node.id));
14801
+ }
14802
+ /** Fija la expansión de un nodo y emite `nodeToggled`. */
14803
+ setExpanded(node, expanded) {
14804
+ const next = new Set(this.expandedSet());
14805
+ if (expanded) {
14806
+ next.add(node.id);
14807
+ }
14808
+ else {
14809
+ next.delete(node.id);
14810
+ }
14811
+ const ids = [...next];
14812
+ this.autoExpanded.set(next);
14813
+ if (this.expandedIds() !== null) {
14814
+ this.expandedIds.set(ids);
14815
+ }
14816
+ this.nodeToggled.emit({
14817
+ node: node,
14818
+ expanded,
14819
+ expandedIds: ids,
14820
+ });
14821
+ }
14822
+ /**
14823
+ * Emite `nodeSelected`. Es la puerta para que la plantilla proyectada
14824
+ * seleccione CUALQUIER nodo con un clic propio (`(click)="tree.select(node)"`
14825
+ * sobre una referencia `#tree`), no solo las hojas con Enter/Espacio.
14826
+ */
14827
+ select(node) {
14828
+ this.nodeSelected.emit(node);
14829
+ }
14830
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
14831
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SolTreeComponent, isStandalone: true, selector: "sol-tree", inputs: { nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: true, transformFunction: null }, expandedIds: { classPropertyName: "expandedIds", publicName: "expandedIds", isSignal: true, isRequired: false, transformFunction: null }, defaultExpandedDepth: { classPropertyName: "defaultExpandedDepth", publicName: "defaultExpandedDepth", isSignal: true, isRequired: false, transformFunction: null }, maxDepth: { classPropertyName: "maxDepth", publicName: "maxDepth", isSignal: true, isRequired: false, transformFunction: null }, indent: { classPropertyName: "indent", publicName: "indent", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expandedIds: "expandedIdsChange", nodeSelected: "nodeSelected", nodeToggled: "nodeToggled" }, providers: [SolTreeState], queries: [{ propertyName: "nodeDef", first: true, predicate: SolTreeNodeDefDirective, descendants: true, isSignal: true }], ngImport: i0, template: `
14832
+ <div role="tree" class="sol-tree" [attr.aria-label]="treeAriaLabel()">
14833
+ @for (root of nodes(); track root.id) {
14834
+ <sol-tree-node [node]="root" [depth]="0" />
14835
+ }
14836
+ </div>
14837
+ `, isInline: true, styles: [":host{display:block;width:100%}.sol-tree{display:flex;flex-direction:column;gap:var(--sol-space-sm, .5rem);font-family:var(--sol-font-family)}\n"], dependencies: [{ kind: "component", type: SolTreeNodeComponent, selector: "sol-tree-node", inputs: ["node", "depth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
14838
+ }
14839
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolTreeComponent, decorators: [{
14840
+ type: Component,
14841
+ args: [{ selector: 'sol-tree', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [SolTreeState], imports: [SolTreeNodeComponent], template: `
14842
+ <div role="tree" class="sol-tree" [attr.aria-label]="treeAriaLabel()">
14843
+ @for (root of nodes(); track root.id) {
14844
+ <sol-tree-node [node]="root" [depth]="0" />
14845
+ }
14846
+ </div>
14847
+ `, styles: [":host{display:block;width:100%}.sol-tree{display:flex;flex-direction:column;gap:var(--sol-space-sm, .5rem);font-family:var(--sol-font-family)}\n"] }]
14848
+ }], ctorParameters: () => [], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: true }] }], expandedIds: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandedIds", required: false }] }, { type: i0.Output, args: ["expandedIdsChange"] }], defaultExpandedDepth: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultExpandedDepth", required: false }] }], maxDepth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxDepth", required: false }] }], indent: [{ type: i0.Input, args: [{ isSignal: true, alias: "indent", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], nodeSelected: [{ type: i0.Output, args: ["nodeSelected"] }], nodeToggled: [{ type: i0.Output, args: ["nodeToggled"] }], nodeDef: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SolTreeNodeDefDirective), { isSignal: true }] }] } });
14849
+ /** Ids de los nodos con hijos que están por encima de `depth` (base 0). */
14850
+ function collectExpandableIds(nodes, depth, current = 0) {
14851
+ if (current >= depth)
14852
+ return [];
14853
+ const ids = [];
14854
+ for (const node of nodes) {
14855
+ const children = node.children ?? [];
14856
+ if (children.length === 0)
14857
+ continue;
14858
+ ids.push(node.id);
14859
+ ids.push(...collectExpandableIds(children, depth, current + 1));
14860
+ }
14861
+ return ids;
14862
+ }
14863
+ /** ¿Existe ese id en alguna parte del bosque? */
14864
+ function containsId(nodes, id) {
14865
+ for (const node of nodes) {
14866
+ if (node.id === id)
14867
+ return true;
14868
+ if (containsId(node.children ?? [], id))
14869
+ return true;
14870
+ }
14871
+ return false;
14872
+ }
14873
+
14874
+ const MINUTE_MS = 60_000;
14875
+ /**
14876
+ * `sol-notification-panel` — centro de notificaciones genérico y sin
14877
+ * acoplamiento al dominio.
14878
+ *
14879
+ * Extraído del `notification-panel` de `solercia-command`, que inyectaba
14880
+ * `NotificationsService` (se auto-alimentaba), inyectaba `Router` (navegaba
14881
+ * solo) e importaba `AppNotification`/`RULE_TYPE_LABELS` de `@entities`.
14882
+ * Aquí SUBE únicamente la presentación: la lista, el contador de no leídas,
14883
+ * los estados y las acciones. QUEDA en la aplicación de dónde salen los
14884
+ * datos y a dónde navega cada notificación — el panel no inyecta servicios
14885
+ * de datos, no llama HTTP y no navega: **emite**.
14886
+ *
14887
+ * ## Vacío ≠ error (deuda que este componente salda)
14888
+ *
14889
+ * El original mostraba "no hay notificaciones" también cuando la carga
14890
+ * fallaba (su `error:` solo apagaba el spinner), así que le mentía al
14891
+ * usuario. Aquí `state()` es excluyente y ordenado —
14892
+ * `loading` › `error` › `empty` › `content`— con `error` ANTES de `empty`:
14893
+ * una carga fallida deja `items` vacío, y si `empty` ganara volveríamos a
14894
+ * decir "no tienes notificaciones" cuando la verdad es "no pudimos saberlo".
14895
+ * Además el estado de error se pinta con estructura, tono y `role="alert"`
14896
+ * propios (nunca el `sol-empty-state`) y ofrece salida vía `retryRequested`.
14897
+ *
14898
+ * ## Fuente de verdad
14899
+ *
14900
+ * El panel NO guarda un espejo interno de `read`: lo pinta desde `items`.
14901
+ * Marcar como leída emite y espera que el consumidor reasigne `items` — así
14902
+ * la UI nunca afirma un cambio que el backend rechazó.
14903
+ *
14904
+ * Uso:
14905
+ * ```html
14906
+ * <sol-notification-panel
14907
+ * [items]="notificaciones()"
14908
+ * [loading]="cargando()"
14909
+ * [error]="fallo()"
14910
+ * [errorMessage]="mensajeDelBackend()"
14911
+ * (itemSelected)="abrir($event)"
14912
+ * (markedRead)="marcarLeida($event)"
14913
+ * (markedAllRead)="marcarTodas()"
14914
+ * (retryRequested)="recargar()"
14915
+ * (closed)="cerrar()"
14916
+ * />
14917
+ * ```
14918
+ */
14919
+ class SolNotificationPanelComponent {
14920
+ i18n = inject(SOL_I18N);
14921
+ /**
14922
+ * Notificaciones a mostrar. El panel NO las va a buscar: el consumidor es
14923
+ * la fuente de verdad. Tipado con `null | undefined` a propósito, para el
14924
+ * patrón `[items]="stream$ | async"` (misma lección que `sol-timeline`).
14925
+ */
14926
+ items = input([], /* @ts-ignore */
14927
+ ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
14928
+ /** `true` mientras la carga está en curso. Gana sobre cualquier otro estado. */
14929
+ loading = input(false, /* @ts-ignore */
14930
+ ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
14931
+ /** `true` cuando la carga falló. Gana sobre el vacío — nunca se confunden. */
14932
+ error = input(false, /* @ts-ignore */
14933
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
14934
+ /**
14935
+ * Detalle del error tal como lo reportó el consumidor (mensaje del
14936
+ * backend). Cuando viene, reemplaza la descripción genérica: un error
14937
+ * específico jamás debe degradarse a "algo salió mal".
14938
+ */
14939
+ errorMessage = input('', /* @ts-ignore */
14940
+ ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
14941
+ /**
14942
+ * Claves i18n del estado vacío. Son inputs (no constantes) para que un
14943
+ * consumidor que filtra la lista distinga "todavía no hay nada" de "no hay
14944
+ * resultados con este filtro" sin que la librería conozca filtro alguno.
14945
+ */
14946
+ emptyTitleKey = input('shared.notificationPanel.emptyTitle', /* @ts-ignore */
14947
+ ...(ngDevMode ? [{ debugName: "emptyTitleKey" }] : /* istanbul ignore next */ []));
14948
+ emptyDescriptionKey = input('shared.notificationPanel.emptyDescription', /* @ts-ignore */
14949
+ ...(ngDevMode ? [{ debugName: "emptyDescriptionKey" }] : /* istanbul ignore next */ []));
14950
+ /** Se activó una notificación. El consumidor decide a dónde lleva. */
14951
+ itemSelected = output();
14952
+ /** Se pidió marcar UNA notificación como leída. */
14953
+ markedRead = output();
14954
+ /** Se pidió marcar todas como leídas. */
14955
+ markedAllRead = output();
14956
+ /**
14957
+ * Se pidió reintentar la carga. Añadido sobre los cuatro outputs del
14958
+ * encargo: un estado de error sin salida es un callejón sin salida — el
14959
+ * usuario ve el fallo y no puede hacer nada desde el panel.
14960
+ */
14961
+ retryRequested = output();
14962
+ /** Se pidió cerrar el panel. */
14963
+ closed = output();
14964
+ /** Lista normalizada: `null`/`undefined` se tratan como vacía. */
14965
+ list = computed(() => this.items() ?? [], /* @ts-ignore */
14966
+ ...(ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []));
14967
+ /** Notificaciones sin leer. `read` ausente cuenta como NO leída. */
14968
+ unreadCount = computed(() => this.list().reduce((total, item) => total + (item.read ? 0 : 1), 0), /* @ts-ignore */
14969
+ ...(ngDevMode ? [{ debugName: "unreadCount" }] : /* istanbul ignore next */ []));
14970
+ /**
14971
+ * Estado excluyente. El orden es la corrección de fondo: `error` ANTES de
14972
+ * `empty`, porque una carga fallida también deja la lista vacía.
14973
+ */
14974
+ state = computed(() => {
14975
+ if (this.loading())
14976
+ return 'loading';
14977
+ if (this.error())
14978
+ return 'error';
14979
+ return this.list().length === 0 ? 'empty' : 'content';
14980
+ }, /* @ts-ignore */
14981
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
14982
+ /** Filas listas para pintar: la notificación + su tiempo relativo y tono. */
14983
+ rows = computed(() => {
14984
+ this.i18n.activeLang();
14985
+ const now = Date.now();
14986
+ return this.list().map((item) => ({
14987
+ item,
14988
+ timeLabel: this.formatRelativeTime(item.timestamp, now),
14989
+ tone: item.tone ?? 'neutral',
14990
+ }));
14991
+ }, /* @ts-ignore */
14992
+ ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
14993
+ // ---- copy propio del panel (claves fijas → `t()` reactivo) ----
14994
+ dialogAria = this.i18n.t('shared.notificationPanel.dialogAria');
14995
+ title = this.i18n.t('shared.notificationPanel.title');
14996
+ markAllReadLabel = this.i18n.t('shared.notificationPanel.markAllRead');
14997
+ closeLabel = this.i18n.t('shared.notificationPanel.close');
14998
+ markReadLabel = this.i18n.t('shared.notificationPanel.markRead');
14999
+ unreadDotLabel = this.i18n.t('shared.notificationPanel.unreadDot');
15000
+ errorTitle = this.i18n.t('shared.notificationPanel.errorTitle');
15001
+ retryLabel = this.i18n.t('shared.notificationPanel.retry');
15002
+ /** Etiqueta accesible del contador; el badge solo muestra el número. */
15003
+ unreadAria = computed(() => {
15004
+ this.i18n.activeLang();
15005
+ return this.i18n.translate('shared.notificationPanel.unreadCount', {
15006
+ count: this.unreadCount(),
15007
+ });
15008
+ }, /* @ts-ignore */
15009
+ ...(ngDevMode ? [{ debugName: "unreadAria" }] : /* istanbul ignore next */ []));
15010
+ /** Descripción del error: el mensaje real del consumidor si lo hay. */
15011
+ errorDescription = computed(() => {
15012
+ this.i18n.activeLang();
15013
+ const detail = this.errorMessage().trim();
15014
+ return detail || this.i18n.translate('shared.notificationPanel.errorDescription');
15015
+ }, /* @ts-ignore */
15016
+ ...(ngDevMode ? [{ debugName: "errorDescription" }] : /* istanbul ignore next */ []));
15017
+ /**
15018
+ * Formatea la marca de tiempo como texto relativo ("hace 2 h"). Devuelve
15019
+ * cadena vacía cuando falta o es inválida — el panel omite el tiempo en vez
15020
+ * de mostrar basura.
15021
+ */
15022
+ formatRelativeTime(value, now) {
15023
+ if (value === null || value === undefined)
15024
+ return '';
15025
+ const ms = value instanceof Date
15026
+ ? value.getTime()
15027
+ : typeof value === 'number'
15028
+ ? value
15029
+ : Date.parse(value);
15030
+ if (!Number.isFinite(ms))
15031
+ return '';
15032
+ const minutes = Math.floor((now - ms) / MINUTE_MS);
15033
+ if (minutes < 1)
15034
+ return this.i18n.translate('shared.notificationPanel.relativeTime.now');
15035
+ if (minutes < 60) {
15036
+ return this.i18n.translate('shared.notificationPanel.relativeTime.minutes', {
15037
+ count: minutes,
15038
+ });
15039
+ }
15040
+ const hours = Math.floor(minutes / 60);
15041
+ if (hours < 24) {
15042
+ return this.i18n.translate('shared.notificationPanel.relativeTime.hours', { count: hours });
15043
+ }
15044
+ return this.i18n.translate('shared.notificationPanel.relativeTime.days', {
15045
+ count: Math.floor(hours / 24),
15046
+ });
15047
+ }
15048
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolNotificationPanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
15049
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SolNotificationPanelComponent, isStandalone: true, selector: "sol-notification-panel", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, emptyTitleKey: { classPropertyName: "emptyTitleKey", publicName: "emptyTitleKey", isSignal: true, isRequired: false, transformFunction: null }, emptyDescriptionKey: { classPropertyName: "emptyDescriptionKey", publicName: "emptyDescriptionKey", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelected: "itemSelected", markedRead: "markedRead", markedAllRead: "markedAllRead", retryRequested: "retryRequested", closed: "closed" }, ngImport: i0, template: `
15050
+ <div class="sol-notification-panel" role="dialog" [attr.aria-label]="dialogAria()">
15051
+ <header class="sol-notification-panel__header">
15052
+ <div class="sol-notification-panel__heading">
15053
+ <h2 class="sol-notification-panel__title">{{ title() }}</h2>
15054
+ @if (unreadCount() > 0) {
15055
+ <span
15056
+ class="sol-notification-panel__unread"
15057
+ role="status"
15058
+ [attr.aria-label]="unreadAria()"
15059
+ >
15060
+ <sol-badge variant="info" size="sm">{{ unreadCount() }}</sol-badge>
15061
+ </span>
15062
+ }
15063
+ </div>
15064
+
15065
+ <div class="sol-notification-panel__header-actions">
15066
+ @if (unreadCount() > 0) {
15067
+ <sol-button
15068
+ variant="ghost"
15069
+ size="sm"
15070
+ class="sol-notification-panel__mark-all"
15071
+ (clicked)="markedAllRead.emit()"
15072
+ >
15073
+ {{ markAllReadLabel() }}
15074
+ </sol-button>
15075
+ }
15076
+ <sol-icon-button
15077
+ icon="x-mark"
15078
+ variant="ghost"
15079
+ size="touch"
15080
+ [ariaLabel]="closeLabel()"
15081
+ (clicked)="closed.emit()"
15082
+ />
15083
+ </div>
15084
+ </header>
15085
+
15086
+ <div class="sol-notification-panel__body" [attr.data-state]="state()">
15087
+ @switch (state()) {
15088
+ @case ('loading') {
15089
+ <div class="sol-notification-panel__loading">
15090
+ <sol-spinner size="md" />
15091
+ </div>
15092
+ }
15093
+
15094
+ @case ('error') {
15095
+ <div class="sol-notification-panel__error" role="alert">
15096
+ <span class="sol-notification-panel__error-icon" aria-hidden="true">
15097
+ <sol-icon name="exclamation-triangle" size="lg" />
15098
+ </span>
15099
+ <p class="sol-notification-panel__error-title">{{ errorTitle() }}</p>
15100
+ <p class="sol-notification-panel__error-description">{{ errorDescription() }}</p>
15101
+ <sol-button variant="secondary" size="sm" (clicked)="retryRequested.emit()">
15102
+ {{ retryLabel() }}
15103
+ </sol-button>
15104
+ </div>
15105
+ }
15106
+
15107
+ @case ('empty') {
15108
+ <sol-empty-state
15109
+ class="sol-notification-panel__empty"
15110
+ icon="bell"
15111
+ [titleKey]="emptyTitleKey()"
15112
+ [descriptionKey]="emptyDescriptionKey()"
15113
+ />
15114
+ }
15115
+
15116
+ @default {
15117
+ <ul class="sol-notification-panel__list" role="list">
15118
+ @for (row of rows(); track row.item.id) {
15119
+ <li
15120
+ class="sol-notification-panel__item"
15121
+ [class.sol-notification-panel__item--unread]="!row.item.read"
15122
+ >
15123
+ <button
15124
+ type="button"
15125
+ class="sol-notification-panel__content"
15126
+ (click)="itemSelected.emit(row.item)"
15127
+ >
15128
+ <span class="sol-notification-panel__item-title">
15129
+ @if (!row.item.read) {
15130
+ <span
15131
+ class="sol-notification-panel__dot"
15132
+ [attr.aria-label]="unreadDotLabel()"
15133
+ ></span>
15134
+ }
15135
+ {{ row.item.title }}
15136
+ </span>
15137
+
15138
+ @if (row.item.body) {
15139
+ <span class="sol-notification-panel__item-body">{{ row.item.body }}</span>
15140
+ }
15141
+
15142
+ @if (row.item.typeLabel || row.timeLabel) {
15143
+ <span class="sol-notification-panel__meta">
15144
+ @if (row.item.typeLabel) {
15145
+ <sol-badge [variant]="row.tone" size="sm">
15146
+ {{ row.item.typeLabel }}
15147
+ </sol-badge>
15148
+ }
15149
+ @if (row.timeLabel) {
15150
+ <span class="sol-notification-panel__time">{{ row.timeLabel }}</span>
15151
+ }
15152
+ </span>
15153
+ }
15154
+ </button>
15155
+
15156
+ @if (!row.item.read) {
15157
+ <sol-icon-button
15158
+ icon="check"
15159
+ variant="ghost"
15160
+ size="touch"
15161
+ class="sol-notification-panel__mark-read"
15162
+ [ariaLabel]="markReadLabel()"
15163
+ (clicked)="markedRead.emit(row.item)"
15164
+ />
15165
+ }
15166
+ </li>
15167
+ }
15168
+ </ul>
15169
+ }
15170
+ }
15171
+ </div>
15172
+ </div>
15173
+ `, isInline: true, styles: [":host{display:block;font-family:var(--sol-font-family, inherit)}.sol-notification-panel{display:flex;flex-direction:column;width:100%;overflow:hidden;border:var(--sol-border-width-default, 1px) solid var(--sol-border-color-default, #e2e8f0);border-radius:var(--sol-card-radius, var(--sol-border-radius-lg, 12px));background:var(--sol-card-bg, var(--sol-bg-surface, #fff));box-shadow:var(--sol-shadow-lg, 0 10px 25px rgb(15 23 42 / 12%))}.sol-notification-panel__header{display:flex;align-items:center;justify-content:space-between;gap:var(--sol-space-sm, 8px);padding:var(--sol-space-sm, 8px) var(--sol-space-md, 16px);border-bottom:var(--sol-border-width-default, 1px) solid var(--sol-border-color-default, #e2e8f0)}.sol-notification-panel__heading{display:inline-flex;align-items:center;gap:var(--sol-space-sm, 8px);min-width:0}.sol-notification-panel__title{margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--sol-font-size-base, .9375rem);font-weight:var(--sol-font-weight-bold, 600);color:var(--sol-color-text-primary, #0f172a)}.sol-notification-panel__unread{display:inline-flex}.sol-notification-panel__header-actions{display:inline-flex;align-items:center;gap:var(--sol-space-xs, 4px);flex-shrink:0}.sol-notification-panel__body{max-height:28rem;overflow-y:auto}.sol-notification-panel__loading{display:flex;align-items:center;justify-content:center;padding:var(--sol-space-xl, 40px) var(--sol-space-md, 16px)}.sol-notification-panel__error{display:flex;flex-direction:column;align-items:center;text-align:center;gap:var(--sol-space-xs, 4px);padding:var(--sol-space-xl, 40px) var(--sol-space-md, 16px);background:color-mix(in srgb,var(--sol-color-danger, #ef4444) 6%,transparent)}.sol-notification-panel__error-icon{display:inline-flex;color:var(--sol-color-danger, #ef4444);margin-bottom:var(--sol-space-xs, 4px)}.sol-notification-panel__error-title{margin:0;font-size:var(--sol-font-size-sm, .875rem);font-weight:var(--sol-font-weight-bold, 600);color:var(--sol-color-text-primary, #0f172a)}.sol-notification-panel__error-description{margin:0 0 var(--sol-space-sm, 8px);max-width:32ch;font-size:var(--sol-font-size-sm, .8125rem);color:var(--sol-color-text-muted, #64748b)}.sol-notification-panel__empty{display:block}.sol-notification-panel__list{margin:0;padding:0;list-style:none}.sol-notification-panel__item{display:flex;align-items:flex-start;gap:var(--sol-space-xs, 4px);padding-right:var(--sol-space-sm, 8px);border-bottom:var(--sol-border-width-default, 1px) solid var(--sol-border-color-default, #e2e8f0);transition:background-color var(--sol-dur-fast, .15s) var(--sol-ease, ease)}.sol-notification-panel__item:last-child{border-bottom:none}.sol-notification-panel__item:hover{background:var(--sol-bg-sunken, color-mix(in srgb, var(--sol-color-primary, #2563eb) 5%, transparent))}.sol-notification-panel__item--unread{background:color-mix(in srgb,var(--sol-color-info, #3b82f6) 7%,transparent)}.sol-notification-panel__content{display:grid;gap:2px;flex:1 1 auto;min-width:0;margin:0;padding:var(--sol-space-sm, 10px) var(--sol-space-md, 16px);border:none;background:transparent;font:inherit;text-align:left;cursor:pointer}.sol-notification-panel__content:focus-visible{outline:none;box-shadow:var( --sol-focus-ring, inset 0 0 0 2px color-mix(in srgb, var(--sol-color-primary, #2563eb) 45%, transparent) )}.sol-notification-panel__item-title{display:flex;align-items:center;gap:var(--sol-space-xs, 6px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--sol-font-size-sm, .875rem);font-weight:var(--sol-font-weight-normal, 500);color:var(--sol-color-text-primary, #0f172a)}.sol-notification-panel__item--unread .sol-notification-panel__item-title{font-weight:var(--sol-font-weight-bold, 600)}.sol-notification-panel__dot{width:7px;height:7px;flex-shrink:0;border-radius:var(--sol-border-radius-full, 9999px);background:var(--sol-color-info, #3b82f6)}.sol-notification-panel__item-body{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;font-size:var(--sol-font-size-sm, .75rem);color:var(--sol-color-text-muted, #64748b)}.sol-notification-panel__meta{display:flex;flex-wrap:wrap;align-items:center;gap:var(--sol-space-xs, 6px);margin-top:var(--sol-space-xs, 4px)}.sol-notification-panel__time{font-size:var(--sol-font-size-sm, .6875rem);color:var(--sol-color-text-secondary, #94a3b8)}.sol-notification-panel__mark-read{align-self:center;flex-shrink:0}@media(prefers-reduced-motion:reduce){.sol-notification-panel__item{transition:none}}\n"], dependencies: [{ kind: "component", type: SolBadgeComponent, selector: "sol-badge", inputs: ["variant", "size"] }, { kind: "component", type: SolButtonComponent, selector: "sol-button", inputs: ["variant", "size", "disabled", "type", "loading"], outputs: ["clicked"] }, { kind: "component", type: SolEmptyStateComponent, selector: "sol-empty-state", inputs: ["icon", "titleKey", "descriptionKey"] }, { kind: "component", type: SolIconComponent, selector: "sol-icon", inputs: ["name", "size", "variant"] }, { kind: "component", type: SolIconButtonComponent, selector: "sol-icon-button", inputs: ["icon", "ariaLabel", "type", "variant", "size", "disabled"], outputs: ["clicked"] }, { kind: "component", type: SolSpinnerComponent, selector: "sol-spinner", inputs: ["size", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
15174
+ }
15175
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolNotificationPanelComponent, decorators: [{
15176
+ type: Component,
15177
+ args: [{ selector: 'sol-notification-panel', standalone: true, imports: [
15178
+ SolBadgeComponent,
15179
+ SolButtonComponent,
15180
+ SolEmptyStateComponent,
15181
+ SolIconComponent,
15182
+ SolIconButtonComponent,
15183
+ SolSpinnerComponent,
15184
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: `
15185
+ <div class="sol-notification-panel" role="dialog" [attr.aria-label]="dialogAria()">
15186
+ <header class="sol-notification-panel__header">
15187
+ <div class="sol-notification-panel__heading">
15188
+ <h2 class="sol-notification-panel__title">{{ title() }}</h2>
15189
+ @if (unreadCount() > 0) {
15190
+ <span
15191
+ class="sol-notification-panel__unread"
15192
+ role="status"
15193
+ [attr.aria-label]="unreadAria()"
15194
+ >
15195
+ <sol-badge variant="info" size="sm">{{ unreadCount() }}</sol-badge>
15196
+ </span>
15197
+ }
15198
+ </div>
15199
+
15200
+ <div class="sol-notification-panel__header-actions">
15201
+ @if (unreadCount() > 0) {
15202
+ <sol-button
15203
+ variant="ghost"
15204
+ size="sm"
15205
+ class="sol-notification-panel__mark-all"
15206
+ (clicked)="markedAllRead.emit()"
15207
+ >
15208
+ {{ markAllReadLabel() }}
15209
+ </sol-button>
15210
+ }
15211
+ <sol-icon-button
15212
+ icon="x-mark"
15213
+ variant="ghost"
15214
+ size="touch"
15215
+ [ariaLabel]="closeLabel()"
15216
+ (clicked)="closed.emit()"
15217
+ />
15218
+ </div>
15219
+ </header>
15220
+
15221
+ <div class="sol-notification-panel__body" [attr.data-state]="state()">
15222
+ @switch (state()) {
15223
+ @case ('loading') {
15224
+ <div class="sol-notification-panel__loading">
15225
+ <sol-spinner size="md" />
15226
+ </div>
15227
+ }
15228
+
15229
+ @case ('error') {
15230
+ <div class="sol-notification-panel__error" role="alert">
15231
+ <span class="sol-notification-panel__error-icon" aria-hidden="true">
15232
+ <sol-icon name="exclamation-triangle" size="lg" />
15233
+ </span>
15234
+ <p class="sol-notification-panel__error-title">{{ errorTitle() }}</p>
15235
+ <p class="sol-notification-panel__error-description">{{ errorDescription() }}</p>
15236
+ <sol-button variant="secondary" size="sm" (clicked)="retryRequested.emit()">
15237
+ {{ retryLabel() }}
15238
+ </sol-button>
15239
+ </div>
15240
+ }
15241
+
15242
+ @case ('empty') {
15243
+ <sol-empty-state
15244
+ class="sol-notification-panel__empty"
15245
+ icon="bell"
15246
+ [titleKey]="emptyTitleKey()"
15247
+ [descriptionKey]="emptyDescriptionKey()"
15248
+ />
15249
+ }
15250
+
15251
+ @default {
15252
+ <ul class="sol-notification-panel__list" role="list">
15253
+ @for (row of rows(); track row.item.id) {
15254
+ <li
15255
+ class="sol-notification-panel__item"
15256
+ [class.sol-notification-panel__item--unread]="!row.item.read"
15257
+ >
15258
+ <button
15259
+ type="button"
15260
+ class="sol-notification-panel__content"
15261
+ (click)="itemSelected.emit(row.item)"
15262
+ >
15263
+ <span class="sol-notification-panel__item-title">
15264
+ @if (!row.item.read) {
15265
+ <span
15266
+ class="sol-notification-panel__dot"
15267
+ [attr.aria-label]="unreadDotLabel()"
15268
+ ></span>
15269
+ }
15270
+ {{ row.item.title }}
15271
+ </span>
15272
+
15273
+ @if (row.item.body) {
15274
+ <span class="sol-notification-panel__item-body">{{ row.item.body }}</span>
15275
+ }
15276
+
15277
+ @if (row.item.typeLabel || row.timeLabel) {
15278
+ <span class="sol-notification-panel__meta">
15279
+ @if (row.item.typeLabel) {
15280
+ <sol-badge [variant]="row.tone" size="sm">
15281
+ {{ row.item.typeLabel }}
15282
+ </sol-badge>
15283
+ }
15284
+ @if (row.timeLabel) {
15285
+ <span class="sol-notification-panel__time">{{ row.timeLabel }}</span>
15286
+ }
15287
+ </span>
15288
+ }
15289
+ </button>
15290
+
15291
+ @if (!row.item.read) {
15292
+ <sol-icon-button
15293
+ icon="check"
15294
+ variant="ghost"
15295
+ size="touch"
15296
+ class="sol-notification-panel__mark-read"
15297
+ [ariaLabel]="markReadLabel()"
15298
+ (clicked)="markedRead.emit(row.item)"
15299
+ />
15300
+ }
15301
+ </li>
15302
+ }
15303
+ </ul>
15304
+ }
15305
+ }
15306
+ </div>
15307
+ </div>
15308
+ `, styles: [":host{display:block;font-family:var(--sol-font-family, inherit)}.sol-notification-panel{display:flex;flex-direction:column;width:100%;overflow:hidden;border:var(--sol-border-width-default, 1px) solid var(--sol-border-color-default, #e2e8f0);border-radius:var(--sol-card-radius, var(--sol-border-radius-lg, 12px));background:var(--sol-card-bg, var(--sol-bg-surface, #fff));box-shadow:var(--sol-shadow-lg, 0 10px 25px rgb(15 23 42 / 12%))}.sol-notification-panel__header{display:flex;align-items:center;justify-content:space-between;gap:var(--sol-space-sm, 8px);padding:var(--sol-space-sm, 8px) var(--sol-space-md, 16px);border-bottom:var(--sol-border-width-default, 1px) solid var(--sol-border-color-default, #e2e8f0)}.sol-notification-panel__heading{display:inline-flex;align-items:center;gap:var(--sol-space-sm, 8px);min-width:0}.sol-notification-panel__title{margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--sol-font-size-base, .9375rem);font-weight:var(--sol-font-weight-bold, 600);color:var(--sol-color-text-primary, #0f172a)}.sol-notification-panel__unread{display:inline-flex}.sol-notification-panel__header-actions{display:inline-flex;align-items:center;gap:var(--sol-space-xs, 4px);flex-shrink:0}.sol-notification-panel__body{max-height:28rem;overflow-y:auto}.sol-notification-panel__loading{display:flex;align-items:center;justify-content:center;padding:var(--sol-space-xl, 40px) var(--sol-space-md, 16px)}.sol-notification-panel__error{display:flex;flex-direction:column;align-items:center;text-align:center;gap:var(--sol-space-xs, 4px);padding:var(--sol-space-xl, 40px) var(--sol-space-md, 16px);background:color-mix(in srgb,var(--sol-color-danger, #ef4444) 6%,transparent)}.sol-notification-panel__error-icon{display:inline-flex;color:var(--sol-color-danger, #ef4444);margin-bottom:var(--sol-space-xs, 4px)}.sol-notification-panel__error-title{margin:0;font-size:var(--sol-font-size-sm, .875rem);font-weight:var(--sol-font-weight-bold, 600);color:var(--sol-color-text-primary, #0f172a)}.sol-notification-panel__error-description{margin:0 0 var(--sol-space-sm, 8px);max-width:32ch;font-size:var(--sol-font-size-sm, .8125rem);color:var(--sol-color-text-muted, #64748b)}.sol-notification-panel__empty{display:block}.sol-notification-panel__list{margin:0;padding:0;list-style:none}.sol-notification-panel__item{display:flex;align-items:flex-start;gap:var(--sol-space-xs, 4px);padding-right:var(--sol-space-sm, 8px);border-bottom:var(--sol-border-width-default, 1px) solid var(--sol-border-color-default, #e2e8f0);transition:background-color var(--sol-dur-fast, .15s) var(--sol-ease, ease)}.sol-notification-panel__item:last-child{border-bottom:none}.sol-notification-panel__item:hover{background:var(--sol-bg-sunken, color-mix(in srgb, var(--sol-color-primary, #2563eb) 5%, transparent))}.sol-notification-panel__item--unread{background:color-mix(in srgb,var(--sol-color-info, #3b82f6) 7%,transparent)}.sol-notification-panel__content{display:grid;gap:2px;flex:1 1 auto;min-width:0;margin:0;padding:var(--sol-space-sm, 10px) var(--sol-space-md, 16px);border:none;background:transparent;font:inherit;text-align:left;cursor:pointer}.sol-notification-panel__content:focus-visible{outline:none;box-shadow:var( --sol-focus-ring, inset 0 0 0 2px color-mix(in srgb, var(--sol-color-primary, #2563eb) 45%, transparent) )}.sol-notification-panel__item-title{display:flex;align-items:center;gap:var(--sol-space-xs, 6px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--sol-font-size-sm, .875rem);font-weight:var(--sol-font-weight-normal, 500);color:var(--sol-color-text-primary, #0f172a)}.sol-notification-panel__item--unread .sol-notification-panel__item-title{font-weight:var(--sol-font-weight-bold, 600)}.sol-notification-panel__dot{width:7px;height:7px;flex-shrink:0;border-radius:var(--sol-border-radius-full, 9999px);background:var(--sol-color-info, #3b82f6)}.sol-notification-panel__item-body{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;font-size:var(--sol-font-size-sm, .75rem);color:var(--sol-color-text-muted, #64748b)}.sol-notification-panel__meta{display:flex;flex-wrap:wrap;align-items:center;gap:var(--sol-space-xs, 6px);margin-top:var(--sol-space-xs, 4px)}.sol-notification-panel__time{font-size:var(--sol-font-size-sm, .6875rem);color:var(--sol-color-text-secondary, #94a3b8)}.sol-notification-panel__mark-read{align-self:center;flex-shrink:0}@media(prefers-reduced-motion:reduce){.sol-notification-panel__item{transition:none}}\n"] }]
15309
+ }], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], emptyTitleKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyTitleKey", required: false }] }], emptyDescriptionKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyDescriptionKey", required: false }] }], itemSelected: [{ type: i0.Output, args: ["itemSelected"] }], markedRead: [{ type: i0.Output, args: ["markedRead"] }], markedAllRead: [{ type: i0.Output, args: ["markedAllRead"] }], retryRequested: [{ type: i0.Output, args: ["retryRequested"] }], closed: [{ type: i0.Output, args: ["closed"] }] } });
15310
+
15311
+ /** Prefijo del catálogo i18n donde viven los textos por defecto del componente. */
15312
+ const I18N_PREFIX = 'shared.scopeSwitcher';
15313
+ /**
15314
+ * `sol-scope-switcher` — selector genérico de ámbito activo.
15315
+ *
15316
+ * Presenta la lista de ámbitos disponibles con su etiqueta y su etiqueta
15317
+ * secundaria, marca cuál está activo y emite el elegido. Nada más.
15318
+ *
15319
+ * ## Frontera deliberada: esto es SOLO el selector visual
15320
+ *
15321
+ * El componente es un control puro y sin memoria. NO persiste la elección, NO
15322
+ * reinicia stores, NO recarga menús, NO reconecta sockets y NO toca cabeceras
15323
+ * HTTP: todo eso es política de la aplicación anfitriona, que reacciona a
15324
+ * `scopeSelected` y decide qué significa "cambiar de ámbito" en su dominio.
15325
+ * Meter cualquiera de esas responsabilidades aquí ataría `@solercia/ui` a un
15326
+ * backend y a un modelo de sesión concretos, que es justo lo que este refactor
15327
+ * evita.
15328
+ *
15329
+ * También es la aplicación —no el componente— la que decide si un cambio
15330
+ * prospera: mientras verifica el acceso puede pasar `disabled` para congelar
15331
+ * el control, y si falla puede pasar `status="error"` conservando `scopes` y
15332
+ * `activeScopeId` anteriores. En ese caso el selector sigue mostrando el
15333
+ * contexto vigente y suma una alerta debajo, sin quedar en un estado a medias.
15334
+ *
15335
+ * ## Un solo ámbito
15336
+ *
15337
+ * Con un único ámbito no se renderiza disparador ni panel: se muestra como
15338
+ * activo, en texto estático, sin obligar a elegir entre una sola opción.
15339
+ *
15340
+ * @typeParam TData Tipo de la carga libre `SolScope.data`.
15341
+ *
15342
+ * @example
15343
+ * ```html
15344
+ * <sol-scope-switcher
15345
+ * [scopes]="empresas()"
15346
+ * [activeScopeId]="empresaActivaId()"
15347
+ * [status]="estado()"
15348
+ * [disabled]="cambiando()"
15349
+ * (scopeSelected)="cambiarEmpresa($event)"
15350
+ * />
15351
+ * ```
15352
+ */
15353
+ class SolScopeSwitcherComponent {
15354
+ i18n = inject(SOL_I18N);
15355
+ hostEl = inject(ElementRef);
15356
+ // ── Entradas ────────────────────────────────────────────────────────────────
15357
+ /**
15358
+ * Ámbitos disponibles, en el orden en que deben listarse. Tolera `null` y
15359
+ * `undefined` para servir sin ceremonia al patrón asíncrono
15360
+ * (`[scopes]="stream$ | async"`), que emite vacío antes de traer datos.
15361
+ */
15362
+ scopes = input([], /* @ts-ignore */
15363
+ ...(ngDevMode ? [{ debugName: "scopes" }] : /* istanbul ignore next */ []));
15364
+ /**
15365
+ * Id del ámbito activo. `null` (o un id que ya no está en la lista) cae al
15366
+ * primer ámbito disponible: el backend suele aplicar ese mismo respaldo, y
15367
+ * mostrar un disparador en blanco sería mentirle al usuario sobre el
15368
+ * contexto en el que realmente está trabajando.
15369
+ */
15370
+ activeScopeId = input(null, /* @ts-ignore */
15371
+ ...(ngDevMode ? [{ debugName: "activeScopeId" }] : /* istanbul ignore next */ []));
15372
+ /** Estado del selector. La lista vacía se deriva de `scopes`, no de aquí. */
15373
+ status = input('idle', /* @ts-ignore */
15374
+ ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
15375
+ /**
15376
+ * Congela el disparador sin ocultar el contexto (p. ej. mientras la
15377
+ * aplicación verifica el acceso al ámbito recién elegido).
15378
+ */
15379
+ disabled = input(false, /* @ts-ignore */
15380
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
15381
+ /** Borde del disparador contra el que se alinea el panel. */
15382
+ align = input('end', /* @ts-ignore */
15383
+ ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
15384
+ /**
15385
+ * Mensaje de error ya resuelto. Sobrescribe el texto por defecto para que la
15386
+ * aplicación distinga "sin conexión" de "perdiste el acceso"; si viene vacío,
15387
+ * se usa la clave `shared.scopeSwitcher.error`.
15388
+ */
15389
+ errorMessage = input('', /* @ts-ignore */
15390
+ ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
15391
+ /** Texto del estado vacío. Vacío ⇒ clave `shared.scopeSwitcher.empty`. */
15392
+ emptyMessage = input('', /* @ts-ignore */
15393
+ ...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
15394
+ /** Texto del estado de carga. Vacío ⇒ clave `shared.scopeSwitcher.loading`. */
15395
+ loadingMessage = input('', /* @ts-ignore */
15396
+ ...(ngDevMode ? [{ debugName: "loadingMessage" }] : /* istanbul ignore next */ []));
15397
+ /** `aria-label` del disparador. Vacío ⇒ clave `shared.scopeSwitcher.trigger`. */
15398
+ triggerAriaLabel = input('', /* @ts-ignore */
15399
+ ...(ngDevMode ? [{ debugName: "triggerAriaLabel" }] : /* istanbul ignore next */ []));
15400
+ /** `aria-label` del panel. Vacío ⇒ clave `shared.scopeSwitcher.panel`. */
15401
+ panelAriaLabel = input('', /* @ts-ignore */
15402
+ ...(ngDevMode ? [{ debugName: "panelAriaLabel" }] : /* istanbul ignore next */ []));
15403
+ // ── Salidas ─────────────────────────────────────────────────────────────────
15404
+ /**
15405
+ * Emite el ámbito elegido, con su `data` intacta. El componente NO persiste,
15406
+ * NO recarga y NO reintenta: la aplicación decide qué hacer con el evento.
15407
+ *
15408
+ * No emite cuando el usuario vuelve a elegir el ámbito que ya estaba activo —
15409
+ * en el consumidor eso equivaldría a reiniciar todo el contexto sin motivo.
15410
+ */
15411
+ scopeSelected = output();
15412
+ /** Emite al abrir (`true`) y al cerrar (`false`) el panel. */
15413
+ openChange = output();
15414
+ // ── Estado interno ──────────────────────────────────────────────────────────
15415
+ /** Verdadero mientras el panel está desplegado. */
15416
+ isOpen = signal(false, /* @ts-ignore */
15417
+ ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
15418
+ /** Verdadero cuando el panel volteó hacia arriba (lo decide la directiva). */
15419
+ dropUp = signal(false, /* @ts-ignore */
15420
+ ...(ngDevMode ? [{ debugName: "dropUp" }] : /* istanbul ignore next */ []));
15421
+ /** Índice del ámbito enfocado por teclado; `-1` cuando el panel está cerrado. */
15422
+ highlightedIndex = signal(-1, /* @ts-ignore */
15423
+ ...(ngDevMode ? [{ debugName: "highlightedIndex" }] : /* istanbul ignore next */ []));
15424
+ /** Altura estimada del panel: umbral de volteo de `solFloatingPanel`. */
15425
+ panelFlipThreshold = 320;
15426
+ static nextId = 0;
15427
+ /** Id único que enlaza el disparador (`aria-controls`) con el panel portaleado. */
15428
+ panelId = `sol-scope-switcher-panel-${SolScopeSwitcherComponent.nextId++}`;
15429
+ triggerRef = viewChild('triggerBtn', /* @ts-ignore */
15430
+ ...(ngDevMode ? [{ debugName: "triggerRef" }] : /* istanbul ignore next */ []));
15431
+ panelRef = viewChild('panel', /* @ts-ignore */
15432
+ ...(ngDevMode ? [{ debugName: "panelRef" }] : /* istanbul ignore next */ []));
15433
+ optionRefs = viewChildren('optionBtn', /* @ts-ignore */
15434
+ ...(ngDevMode ? [{ debugName: "optionRefs" }] : /* istanbul ignore next */ []));
15435
+ // ── Derivados ───────────────────────────────────────────────────────────────
15436
+ /** Lista normalizada: `null`/`undefined` se comportan como lista vacía. */
15437
+ scopeList = computed(() => this.scopes() ?? [], /* @ts-ignore */
15438
+ ...(ngDevMode ? [{ debugName: "scopeList" }] : /* istanbul ignore next */ []));
15439
+ /** No hay ámbitos que listar. Es un estado legítimo, nunca un error. */
15440
+ isEmpty = computed(() => this.scopeList().length === 0, /* @ts-ignore */
15441
+ ...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
15442
+ /** Un único ámbito: se muestra como activo, sin obligar a elegir. */
15443
+ isSingle = computed(() => this.scopeList().length === 1, /* @ts-ignore */
15444
+ ...(ngDevMode ? [{ debugName: "isSingle" }] : /* istanbul ignore next */ []));
15445
+ /** El selector está reportando una falla. */
15446
+ hasError = computed(() => this.status() === 'error', /* @ts-ignore */
15447
+ ...(ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []));
15448
+ /** Id realmente vigente: el explícito si sigue en la lista, si no el primero. */
15449
+ effectiveActiveId = computed(() => {
15450
+ const list = this.scopeList();
15451
+ const explicit = this.activeScopeId();
15452
+ if (explicit != null && list.some((scope) => scope.id === explicit))
15453
+ return explicit;
15454
+ return list[0]?.id ?? null;
15455
+ }, /* @ts-ignore */
15456
+ ...(ngDevMode ? [{ debugName: "effectiveActiveId" }] : /* istanbul ignore next */ []));
15457
+ /** Ámbito activo resuelto, o `null` cuando la lista está vacía. */
15458
+ activeScope = computed(() => {
15459
+ const id = this.effectiveActiveId();
15460
+ return this.scopeList().find((scope) => scope.id === id) ?? null;
15461
+ }, /* @ts-ignore */
15462
+ ...(ngDevMode ? [{ debugName: "activeScope" }] : /* istanbul ignore next */ []));
15463
+ // ── Textos ──────────────────────────────────────────────────────────────────
15464
+ // Idioma "sobrescritura primero, clave después" (mismo idiom que sol-date-picker):
15465
+ // el consumidor puede pasar su propio texto, y si no, manda el catálogo i18n.
15466
+ loadingKey = this.i18n.t(`${I18N_PREFIX}.loading`);
15467
+ emptyKey = this.i18n.t(`${I18N_PREFIX}.empty`);
15468
+ errorKey = this.i18n.t(`${I18N_PREFIX}.error`);
15469
+ triggerAriaKey = this.i18n.t(`${I18N_PREFIX}.trigger`);
15470
+ panelAriaKey = this.i18n.t(`${I18N_PREFIX}.panel`);
15471
+ activeOptionAriaKey = this.i18n.t(`${I18N_PREFIX}.activeOption`);
15472
+ loadingText = computed(() => this.loadingMessage() || this.loadingKey(), /* @ts-ignore */
15473
+ ...(ngDevMode ? [{ debugName: "loadingText" }] : /* istanbul ignore next */ []));
15474
+ emptyText = computed(() => this.emptyMessage() || this.emptyKey(), /* @ts-ignore */
15475
+ ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
15476
+ errorText = computed(() => this.errorMessage() || this.errorKey(), /* @ts-ignore */
15477
+ ...(ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []));
15478
+ triggerAriaText = computed(() => this.triggerAriaLabel() || this.triggerAriaKey(), /* @ts-ignore */
15479
+ ...(ngDevMode ? [{ debugName: "triggerAriaText" }] : /* istanbul ignore next */ []));
15480
+ panelAriaText = computed(() => this.panelAriaLabel() || this.panelAriaKey(), /* @ts-ignore */
15481
+ ...(ngDevMode ? [{ debugName: "panelAriaText" }] : /* istanbul ignore next */ []));
15482
+ activeOptionAriaText = this.activeOptionAriaKey;
15483
+ constructor() {
15484
+ // Foco itinerante del listbox: la opción resaltada recibe el foco real (en
15485
+ // vez de simularlo con aria-activedescendant), así el lector de pantalla y
15486
+ // el foco visible del navegador cuentan siempre la misma historia. El
15487
+ // efecto depende de `optionRefs`, así que también corre en la primera
15488
+ // materialización del panel, no solo en los cambios de índice posteriores.
15489
+ effect(() => {
15490
+ if (!this.isOpen())
15491
+ return;
15492
+ const index = this.highlightedIndex();
15493
+ this.optionRefs()[index]?.nativeElement.focus();
15494
+ });
15495
+ }
15496
+ // ── Interacción ─────────────────────────────────────────────────────────────
15497
+ /** Abre o cierra el panel desde el disparador. */
15498
+ onTriggerClick() {
15499
+ if (this.isOpen()) {
15500
+ this.close();
15501
+ return;
15502
+ }
15503
+ this.open();
15504
+ }
15505
+ /** Teclado del disparador: abre con flechas/Enter/Espacio. */
15506
+ onTriggerKeydown(event) {
15507
+ switch (event.key) {
15508
+ case 'ArrowDown':
15509
+ case 'ArrowUp':
15510
+ case 'Enter':
15511
+ case ' ':
15512
+ event.preventDefault();
15513
+ this.open();
15514
+ break;
15515
+ default:
15516
+ break;
15517
+ }
15518
+ }
15519
+ /** Teclado del panel: navegación itinerante y selección. */
15520
+ onPanelKeydown(event) {
15521
+ const total = this.scopeList().length;
15522
+ if (total === 0)
15523
+ return;
15524
+ switch (event.key) {
15525
+ case 'ArrowDown':
15526
+ event.preventDefault();
15527
+ this.highlightedIndex.update((i) => (i + 1) % total);
15528
+ break;
15529
+ case 'ArrowUp':
15530
+ event.preventDefault();
15531
+ this.highlightedIndex.update((i) => (i - 1 + total) % total);
15532
+ break;
15533
+ case 'Home':
15534
+ event.preventDefault();
15535
+ this.highlightedIndex.set(0);
15536
+ break;
15537
+ case 'End':
15538
+ event.preventDefault();
15539
+ this.highlightedIndex.set(total - 1);
15540
+ break;
15541
+ case 'Enter':
15542
+ case ' ': {
15543
+ event.preventDefault();
15544
+ const scope = this.scopeList()[this.highlightedIndex()];
15545
+ if (scope)
15546
+ this.select(scope);
15547
+ break;
15548
+ }
15549
+ case 'Tab':
15550
+ // Tabular sale del selector: el panel se cierra en vez de dejar el foco
15551
+ // suelto en un nodo portaleado fuera del orden natural del documento.
15552
+ this.close();
15553
+ break;
15554
+ default:
15555
+ break;
15556
+ }
15557
+ }
15558
+ /** Elige un ámbito, cierra el panel y devuelve el foco al disparador. */
15559
+ select(scope) {
15560
+ const wasActive = scope.id === this.effectiveActiveId();
15561
+ this.close(true);
15562
+ if (wasActive)
15563
+ return;
15564
+ this.scopeSelected.emit(scope);
15565
+ }
15566
+ /** Escape cierra el panel y devuelve el foco al disparador. */
15567
+ onDocumentEscape() {
15568
+ if (!this.isOpen())
15569
+ return;
15570
+ this.close(true);
15571
+ }
15572
+ /**
15573
+ * Clic afuera. El panel vive portaleado en `document.body`, así que "dentro"
15574
+ * abarca tanto el host como el nodo portaleado.
15575
+ */
15576
+ onDocumentClick(event) {
15577
+ if (!this.isOpen())
15578
+ return;
15579
+ const target = event.target;
15580
+ const insideHost = this.hostEl.nativeElement.contains(target);
15581
+ const insidePanel = this.panelRef()?.nativeElement.contains(target) ?? false;
15582
+ if (!insideHost && !insidePanel)
15583
+ this.close();
15584
+ }
15585
+ // ── Ciclo del panel ─────────────────────────────────────────────────────────
15586
+ open() {
15587
+ if (this.disabled() || this.isOpen())
15588
+ return;
15589
+ const list = this.scopeList();
15590
+ const activeIndex = list.findIndex((scope) => scope.id === this.effectiveActiveId());
15591
+ // Arranca sobre el ámbito vigente (no en cero): el usuario ve de entrada
15592
+ // dónde está parado y llega al vecino con una sola flecha.
15593
+ this.highlightedIndex.set(activeIndex >= 0 ? activeIndex : 0);
15594
+ this.isOpen.set(true);
15595
+ this.openChange.emit(true);
15596
+ }
15597
+ close(returnFocus = false) {
15598
+ if (!this.isOpen())
15599
+ return;
15600
+ this.isOpen.set(false);
15601
+ this.highlightedIndex.set(-1);
15602
+ this.openChange.emit(false);
15603
+ if (returnFocus)
15604
+ this.triggerRef()?.nativeElement.focus();
15605
+ }
15606
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolScopeSwitcherComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
15607
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SolScopeSwitcherComponent, isStandalone: true, selector: "sol-scope-switcher", inputs: { scopes: { classPropertyName: "scopes", publicName: "scopes", isSignal: true, isRequired: false, transformFunction: null }, activeScopeId: { classPropertyName: "activeScopeId", publicName: "activeScopeId", isSignal: true, isRequired: false, transformFunction: null }, status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, loadingMessage: { classPropertyName: "loadingMessage", publicName: "loadingMessage", isSignal: true, isRequired: false, transformFunction: null }, triggerAriaLabel: { classPropertyName: "triggerAriaLabel", publicName: "triggerAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, panelAriaLabel: { classPropertyName: "panelAriaLabel", publicName: "panelAriaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { scopeSelected: "scopeSelected", openChange: "openChange" }, host: { listeners: { "document:keydown.escape": "onDocumentEscape()", "document:click": "onDocumentClick($event)" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["triggerBtn"], descendants: true, isSignal: true }, { propertyName: "panelRef", first: true, predicate: ["panel"], descendants: true, isSignal: true }, { propertyName: "optionRefs", predicate: ["optionBtn"], descendants: true, isSignal: true }], ngImport: i0, template: `
15608
+ @if (status() === 'loading') {
15609
+ <span class="sol-scope-switcher__loading" role="status">
15610
+ <sol-spinner size="sm" />
15611
+ <span class="sol-scope-switcher__loading-text">{{ loadingText() }}</span>
15612
+ </span>
15613
+ } @else {
15614
+ @if (isEmpty()) {
15615
+ <!-- Vacío legítimo: solo se pinta si NO hay error, para que "no tienes
15616
+ ámbitos" jamás se lea como "la consulta falló". -->
15617
+ @if (!hasError()) {
15618
+ <span class="sol-scope-switcher__empty">
15619
+ <sol-icon name="building" size="sm" class="sol-scope-switcher__empty-icon" />
15620
+ <span>{{ emptyText() }}</span>
15621
+ </span>
15622
+ }
15623
+ } @else if (isSingle()) {
15624
+ <span class="sol-scope-switcher__static" [attr.aria-label]="triggerAriaText()">
15625
+ @if (activeScope(); as scope) {
15626
+ @if (scope.icon) {
15627
+ <sol-icon [name]="scope.icon" size="sm" class="sol-scope-switcher__icon" />
15628
+ } @else {
15629
+ <sol-avatar [name]="scope.label" [imageUrl]="scope.imageUrl ?? null" size="sm" />
15630
+ }
15631
+ <span class="sol-scope-switcher__labels">
15632
+ <span class="sol-scope-switcher__label">{{ scope.label }}</span>
15633
+ @if (scope.sublabel) {
15634
+ <span class="sol-scope-switcher__sublabel">{{ scope.sublabel }}</span>
15635
+ }
15636
+ </span>
15637
+ }
15638
+ </span>
15639
+ } @else {
15640
+ <div class="sol-scope-switcher__host">
15641
+ <button
15642
+ #triggerBtn
15643
+ type="button"
15644
+ class="sol-scope-switcher__trigger"
15645
+ [class.sol-scope-switcher__trigger--open]="isOpen()"
15646
+ [disabled]="disabled()"
15647
+ aria-haspopup="listbox"
15648
+ [attr.aria-expanded]="isOpen()"
15649
+ [attr.aria-controls]="isOpen() ? panelId : null"
15650
+ [attr.aria-label]="triggerAriaText()"
15651
+ (click)="onTriggerClick()"
15652
+ (keydown)="onTriggerKeydown($event)"
15653
+ >
15654
+ @if (activeScope(); as scope) {
15655
+ @if (scope.icon) {
15656
+ <sol-icon [name]="scope.icon" size="sm" class="sol-scope-switcher__icon" />
15657
+ } @else {
15658
+ <sol-avatar [name]="scope.label" [imageUrl]="scope.imageUrl ?? null" size="sm" />
15659
+ }
15660
+ <span class="sol-scope-switcher__labels">
15661
+ <span class="sol-scope-switcher__label">{{ scope.label }}</span>
15662
+ @if (scope.sublabel) {
15663
+ <span class="sol-scope-switcher__sublabel">{{ scope.sublabel }}</span>
15664
+ }
15665
+ </span>
15666
+ }
15667
+ <sol-icon
15668
+ name="chevron-down"
15669
+ variant="fill"
15670
+ size="sm"
15671
+ class="sol-scope-switcher__arrow"
15672
+ [class.sol-scope-switcher__arrow--open]="isOpen()"
15673
+ />
15674
+ </button>
15675
+
15676
+ <!-- El panel se portalea a document.body con position:fixed vía la
15677
+ directiva compartida solFloatingPanel: el switcher suele vivir en
15678
+ un header con overflow, y sin el portal el panel quedaría
15679
+ recortado. El trigger queda enlazado por aria-controls porque
15680
+ ambos viven en árboles distintos del DOM. -->
15681
+ @if (isOpen()) {
15682
+ <div
15683
+ #panel
15684
+ [id]="panelId"
15685
+ class="sol-scope-switcher__panel"
15686
+ [class.sol-scope-switcher__panel--up]="dropUp()"
15687
+ role="listbox"
15688
+ [attr.aria-label]="panelAriaText()"
15689
+ [solFloatingPanel]="triggerBtn"
15690
+ [matchTriggerWidth]="false"
15691
+ [flipThreshold]="panelFlipThreshold"
15692
+ [align]="align()"
15693
+ (dropUpChange)="dropUp.set($event)"
15694
+ (keydown)="onPanelKeydown($event)"
15695
+ >
15696
+ @for (scope of scopeList(); track scope.id; let i = $index) {
15697
+ <button
15698
+ #optionBtn
15699
+ type="button"
15700
+ class="sol-scope-switcher__option"
15701
+ [class.sol-scope-switcher__option--active]="scope.id === effectiveActiveId()"
15702
+ role="option"
15703
+ tabindex="-1"
15704
+ [attr.aria-selected]="scope.id === effectiveActiveId()"
15705
+ (click)="select(scope)"
15706
+ >
15707
+ @if (scope.icon) {
15708
+ <sol-icon [name]="scope.icon" size="sm" class="sol-scope-switcher__icon" />
15709
+ } @else {
15710
+ <sol-avatar [name]="scope.label" [imageUrl]="scope.imageUrl ?? null" size="sm" />
15711
+ }
15712
+ <span class="sol-scope-switcher__labels">
15713
+ <span class="sol-scope-switcher__label">{{ scope.label }}</span>
15714
+ @if (scope.sublabel) {
15715
+ <span class="sol-scope-switcher__sublabel">{{ scope.sublabel }}</span>
15716
+ }
15717
+ </span>
15718
+ @if (scope.id === effectiveActiveId()) {
15719
+ <sol-icon
15720
+ name="check"
15721
+ size="sm"
15722
+ class="sol-scope-switcher__check"
15723
+ [attr.aria-label]="activeOptionAriaText()"
15724
+ />
15725
+ }
15726
+ </button>
15727
+ }
15728
+ </div>
15729
+ }
15730
+ </div>
15731
+ }
15732
+
15733
+ <!-- La alerta NO reemplaza al selector: convive con él para que un cambio
15734
+ fallido conserve el contexto anterior en pantalla (y se muestra sola
15735
+ cuando lo que falló fue la carga misma de la lista). -->
15736
+ @if (hasError()) {
15737
+ <p class="sol-scope-switcher__error" role="alert">
15738
+ <sol-icon name="exclamation-triangle" size="sm" class="sol-scope-switcher__error-icon" />
15739
+ <span>{{ errorText() }}</span>
15740
+ </p>
15741
+ }
15742
+ }
15743
+ `, isInline: true, styles: [":host{display:inline-block}:host,.sol-scope-switcher__panel{--sol-scope-switcher-bg: var(--sol-bg-surface, #ffffff);--sol-scope-switcher-text: var(--sol-color-text-primary, #1e293b);--sol-scope-switcher-muted: var(--sol-color-text-muted, #94a3b8);--sol-scope-switcher-border: var(--sol-border-color-default, #cbd5e1);--sol-scope-switcher-border-width: var(--sol-border-width-default, 1px);--sol-scope-switcher-accent: var(--sol-color-primary, #6366f1);--sol-scope-switcher-danger: var(--sol-color-danger, #ef4444);--sol-scope-switcher-radius: var(--sol-border-radius-md, .5rem);--sol-scope-switcher-height: var(--sol-size-input-height, 2.5rem);--sol-scope-switcher-gap: var(--sol-space-xs, .5rem);--sol-scope-switcher-padding-x: var(--sol-space-sm, .75rem);--sol-scope-switcher-font-size: var(--sol-font-size-base, .875rem);--sol-scope-switcher-sub-font-size: var(--sol-font-size-sm, .75rem);--sol-scope-switcher-weight: var(--sol-font-weight-bold, 600);--sol-scope-switcher-shadow: var(--sol-shadow-lg, 0 10px 25px rgba(0, 0, 0, .15));--sol-scope-switcher-hover: var(--sol-color-bg-hover, rgba(0, 0, 0, .04));--sol-scope-switcher-active-bg: color-mix(in srgb, var(--sol-color-primary, #6366f1) 12%, transparent);--sol-scope-switcher-focus-ring: 0 0 0 3px color-mix(in srgb, var(--sol-color-primary, #6366f1) 40%, transparent);--sol-scope-switcher-transition: var(--sol-dur-fast, .15s) var(--sol-ease, ease);--sol-scope-switcher-disabled-opacity: var(--sol-disabled-opacity, .55)}.sol-scope-switcher__host{position:relative;display:inline-block}.sol-scope-switcher__loading,.sol-scope-switcher__empty,.sol-scope-switcher__static{display:inline-flex;align-items:center;gap:var(--sol-scope-switcher-gap);min-height:var(--sol-scope-switcher-height);padding:0 var(--sol-scope-switcher-padding-x);font-size:var(--sol-scope-switcher-font-size);line-height:1.3}.sol-scope-switcher__loading,.sol-scope-switcher__empty{color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__empty-icon{flex-shrink:0;color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__static{color:var(--sol-scope-switcher-text);background:var(--sol-scope-switcher-bg);border:var(--sol-scope-switcher-border-width) solid var(--sol-scope-switcher-border);border-radius:var(--sol-scope-switcher-radius)}.sol-scope-switcher__trigger{display:inline-flex;align-items:center;gap:var(--sol-scope-switcher-gap);min-height:var(--sol-scope-switcher-height);max-width:100%;padding:0 var(--sol-scope-switcher-padding-x);font-family:inherit;font-size:var(--sol-scope-switcher-font-size);color:var(--sol-scope-switcher-text);text-align:left;background:var(--sol-scope-switcher-bg);border:var(--sol-scope-switcher-border-width) solid var(--sol-scope-switcher-border);border-radius:var(--sol-scope-switcher-radius);cursor:pointer;transition:background var(--sol-scope-switcher-transition),border-color var(--sol-scope-switcher-transition),box-shadow var(--sol-scope-switcher-transition)}.sol-scope-switcher__trigger:hover:not(:disabled){background:var(--sol-scope-switcher-hover)}.sol-scope-switcher__trigger:focus-visible{outline:none;border-color:var(--sol-scope-switcher-accent);box-shadow:var(--sol-scope-switcher-focus-ring)}.sol-scope-switcher__trigger--open{border-color:var(--sol-scope-switcher-accent)}.sol-scope-switcher__trigger:disabled{cursor:not-allowed;opacity:var(--sol-scope-switcher-disabled-opacity)}.sol-scope-switcher__arrow{flex-shrink:0;color:var(--sol-scope-switcher-muted);transition:transform var(--sol-scope-switcher-transition)}.sol-scope-switcher__arrow--open{transform:rotate(180deg)}.sol-scope-switcher__icon{flex-shrink:0;color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__labels{display:flex;flex-direction:column;min-width:0;flex:1}.sol-scope-switcher__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:var(--sol-scope-switcher-weight)}.sol-scope-switcher__sublabel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--sol-scope-switcher-sub-font-size);font-weight:400;color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__panel{position:absolute;top:calc(100% + 4px);left:0;display:flex;flex-direction:column;min-width:15rem;max-width:22rem;max-height:20rem;overflow-y:auto;padding:.25rem;background:var(--sol-scope-switcher-bg);border:var(--sol-scope-switcher-border-width) solid var(--sol-scope-switcher-border);border-radius:var(--sol-scope-switcher-radius);box-shadow:var(--sol-scope-switcher-shadow);animation:sol-scope-switcher-fade .12s ease-out}.sol-scope-switcher__panel--up{top:auto;bottom:calc(100% + 4px)}.sol-scope-switcher__option{display:flex;align-items:center;gap:var(--sol-scope-switcher-gap);width:100%;padding:.5rem .625rem;font-family:inherit;font-size:var(--sol-scope-switcher-font-size);color:var(--sol-scope-switcher-text);text-align:left;background:transparent;border:none;border-radius:calc(var(--sol-scope-switcher-radius) - 2px);cursor:pointer;transition:background var(--sol-scope-switcher-transition)}.sol-scope-switcher__option:hover{background:var(--sol-scope-switcher-hover)}.sol-scope-switcher__option:focus-visible{outline:none;box-shadow:var(--sol-scope-switcher-focus-ring)}.sol-scope-switcher__option--active{background:var(--sol-scope-switcher-active-bg)}.sol-scope-switcher__option--active .sol-scope-switcher__label{color:var(--sol-scope-switcher-accent)}.sol-scope-switcher__check{flex-shrink:0;color:var(--sol-scope-switcher-accent)}.sol-scope-switcher__error{display:flex;align-items:flex-start;gap:.375rem;margin:.25rem 0 0;font-size:var(--sol-scope-switcher-sub-font-size);line-height:1.4;color:var(--sol-scope-switcher-danger)}.sol-scope-switcher__error-icon{flex-shrink:0;color:var(--sol-scope-switcher-danger)}@keyframes sol-scope-switcher-fade{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.sol-scope-switcher__panel{animation:none}.sol-scope-switcher__arrow,.sol-scope-switcher__trigger,.sol-scope-switcher__option{transition:none}}\n"], dependencies: [{ kind: "component", type: SolAvatarComponent, selector: "sol-avatar", inputs: ["name", "imageUrl", "size"] }, { kind: "component", type: SolIconComponent, selector: "sol-icon", inputs: ["name", "size", "variant"] }, { kind: "component", type: SolSpinnerComponent, selector: "sol-spinner", inputs: ["size", "color"] }, { kind: "directive", type: SolFloatingPanelDirective, selector: "[solFloatingPanel]", inputs: ["solFloatingPanel", "gap", "flipThreshold", "matchTriggerWidth", "align"], outputs: ["dropUpChange"], exportAs: ["solFloatingPanel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
15744
+ }
15745
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SolScopeSwitcherComponent, decorators: [{
15746
+ type: Component,
15747
+ args: [{ selector: 'sol-scope-switcher', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
15748
+ SolAvatarComponent,
15749
+ SolIconComponent,
15750
+ SolSpinnerComponent,
15751
+ SolFloatingPanelDirective,
15752
+ ], template: `
15753
+ @if (status() === 'loading') {
15754
+ <span class="sol-scope-switcher__loading" role="status">
15755
+ <sol-spinner size="sm" />
15756
+ <span class="sol-scope-switcher__loading-text">{{ loadingText() }}</span>
15757
+ </span>
15758
+ } @else {
15759
+ @if (isEmpty()) {
15760
+ <!-- Vacío legítimo: solo se pinta si NO hay error, para que "no tienes
15761
+ ámbitos" jamás se lea como "la consulta falló". -->
15762
+ @if (!hasError()) {
15763
+ <span class="sol-scope-switcher__empty">
15764
+ <sol-icon name="building" size="sm" class="sol-scope-switcher__empty-icon" />
15765
+ <span>{{ emptyText() }}</span>
15766
+ </span>
15767
+ }
15768
+ } @else if (isSingle()) {
15769
+ <span class="sol-scope-switcher__static" [attr.aria-label]="triggerAriaText()">
15770
+ @if (activeScope(); as scope) {
15771
+ @if (scope.icon) {
15772
+ <sol-icon [name]="scope.icon" size="sm" class="sol-scope-switcher__icon" />
15773
+ } @else {
15774
+ <sol-avatar [name]="scope.label" [imageUrl]="scope.imageUrl ?? null" size="sm" />
15775
+ }
15776
+ <span class="sol-scope-switcher__labels">
15777
+ <span class="sol-scope-switcher__label">{{ scope.label }}</span>
15778
+ @if (scope.sublabel) {
15779
+ <span class="sol-scope-switcher__sublabel">{{ scope.sublabel }}</span>
15780
+ }
15781
+ </span>
15782
+ }
15783
+ </span>
15784
+ } @else {
15785
+ <div class="sol-scope-switcher__host">
15786
+ <button
15787
+ #triggerBtn
15788
+ type="button"
15789
+ class="sol-scope-switcher__trigger"
15790
+ [class.sol-scope-switcher__trigger--open]="isOpen()"
15791
+ [disabled]="disabled()"
15792
+ aria-haspopup="listbox"
15793
+ [attr.aria-expanded]="isOpen()"
15794
+ [attr.aria-controls]="isOpen() ? panelId : null"
15795
+ [attr.aria-label]="triggerAriaText()"
15796
+ (click)="onTriggerClick()"
15797
+ (keydown)="onTriggerKeydown($event)"
15798
+ >
15799
+ @if (activeScope(); as scope) {
15800
+ @if (scope.icon) {
15801
+ <sol-icon [name]="scope.icon" size="sm" class="sol-scope-switcher__icon" />
15802
+ } @else {
15803
+ <sol-avatar [name]="scope.label" [imageUrl]="scope.imageUrl ?? null" size="sm" />
15804
+ }
15805
+ <span class="sol-scope-switcher__labels">
15806
+ <span class="sol-scope-switcher__label">{{ scope.label }}</span>
15807
+ @if (scope.sublabel) {
15808
+ <span class="sol-scope-switcher__sublabel">{{ scope.sublabel }}</span>
15809
+ }
15810
+ </span>
15811
+ }
15812
+ <sol-icon
15813
+ name="chevron-down"
15814
+ variant="fill"
15815
+ size="sm"
15816
+ class="sol-scope-switcher__arrow"
15817
+ [class.sol-scope-switcher__arrow--open]="isOpen()"
15818
+ />
15819
+ </button>
15820
+
15821
+ <!-- El panel se portalea a document.body con position:fixed vía la
15822
+ directiva compartida solFloatingPanel: el switcher suele vivir en
15823
+ un header con overflow, y sin el portal el panel quedaría
15824
+ recortado. El trigger queda enlazado por aria-controls porque
15825
+ ambos viven en árboles distintos del DOM. -->
15826
+ @if (isOpen()) {
15827
+ <div
15828
+ #panel
15829
+ [id]="panelId"
15830
+ class="sol-scope-switcher__panel"
15831
+ [class.sol-scope-switcher__panel--up]="dropUp()"
15832
+ role="listbox"
15833
+ [attr.aria-label]="panelAriaText()"
15834
+ [solFloatingPanel]="triggerBtn"
15835
+ [matchTriggerWidth]="false"
15836
+ [flipThreshold]="panelFlipThreshold"
15837
+ [align]="align()"
15838
+ (dropUpChange)="dropUp.set($event)"
15839
+ (keydown)="onPanelKeydown($event)"
15840
+ >
15841
+ @for (scope of scopeList(); track scope.id; let i = $index) {
15842
+ <button
15843
+ #optionBtn
15844
+ type="button"
15845
+ class="sol-scope-switcher__option"
15846
+ [class.sol-scope-switcher__option--active]="scope.id === effectiveActiveId()"
15847
+ role="option"
15848
+ tabindex="-1"
15849
+ [attr.aria-selected]="scope.id === effectiveActiveId()"
15850
+ (click)="select(scope)"
15851
+ >
15852
+ @if (scope.icon) {
15853
+ <sol-icon [name]="scope.icon" size="sm" class="sol-scope-switcher__icon" />
15854
+ } @else {
15855
+ <sol-avatar [name]="scope.label" [imageUrl]="scope.imageUrl ?? null" size="sm" />
15856
+ }
15857
+ <span class="sol-scope-switcher__labels">
15858
+ <span class="sol-scope-switcher__label">{{ scope.label }}</span>
15859
+ @if (scope.sublabel) {
15860
+ <span class="sol-scope-switcher__sublabel">{{ scope.sublabel }}</span>
15861
+ }
15862
+ </span>
15863
+ @if (scope.id === effectiveActiveId()) {
15864
+ <sol-icon
15865
+ name="check"
15866
+ size="sm"
15867
+ class="sol-scope-switcher__check"
15868
+ [attr.aria-label]="activeOptionAriaText()"
15869
+ />
15870
+ }
15871
+ </button>
15872
+ }
15873
+ </div>
15874
+ }
15875
+ </div>
15876
+ }
15877
+
15878
+ <!-- La alerta NO reemplaza al selector: convive con él para que un cambio
15879
+ fallido conserve el contexto anterior en pantalla (y se muestra sola
15880
+ cuando lo que falló fue la carga misma de la lista). -->
15881
+ @if (hasError()) {
15882
+ <p class="sol-scope-switcher__error" role="alert">
15883
+ <sol-icon name="exclamation-triangle" size="sm" class="sol-scope-switcher__error-icon" />
15884
+ <span>{{ errorText() }}</span>
15885
+ </p>
15886
+ }
15887
+ }
15888
+ `, styles: [":host{display:inline-block}:host,.sol-scope-switcher__panel{--sol-scope-switcher-bg: var(--sol-bg-surface, #ffffff);--sol-scope-switcher-text: var(--sol-color-text-primary, #1e293b);--sol-scope-switcher-muted: var(--sol-color-text-muted, #94a3b8);--sol-scope-switcher-border: var(--sol-border-color-default, #cbd5e1);--sol-scope-switcher-border-width: var(--sol-border-width-default, 1px);--sol-scope-switcher-accent: var(--sol-color-primary, #6366f1);--sol-scope-switcher-danger: var(--sol-color-danger, #ef4444);--sol-scope-switcher-radius: var(--sol-border-radius-md, .5rem);--sol-scope-switcher-height: var(--sol-size-input-height, 2.5rem);--sol-scope-switcher-gap: var(--sol-space-xs, .5rem);--sol-scope-switcher-padding-x: var(--sol-space-sm, .75rem);--sol-scope-switcher-font-size: var(--sol-font-size-base, .875rem);--sol-scope-switcher-sub-font-size: var(--sol-font-size-sm, .75rem);--sol-scope-switcher-weight: var(--sol-font-weight-bold, 600);--sol-scope-switcher-shadow: var(--sol-shadow-lg, 0 10px 25px rgba(0, 0, 0, .15));--sol-scope-switcher-hover: var(--sol-color-bg-hover, rgba(0, 0, 0, .04));--sol-scope-switcher-active-bg: color-mix(in srgb, var(--sol-color-primary, #6366f1) 12%, transparent);--sol-scope-switcher-focus-ring: 0 0 0 3px color-mix(in srgb, var(--sol-color-primary, #6366f1) 40%, transparent);--sol-scope-switcher-transition: var(--sol-dur-fast, .15s) var(--sol-ease, ease);--sol-scope-switcher-disabled-opacity: var(--sol-disabled-opacity, .55)}.sol-scope-switcher__host{position:relative;display:inline-block}.sol-scope-switcher__loading,.sol-scope-switcher__empty,.sol-scope-switcher__static{display:inline-flex;align-items:center;gap:var(--sol-scope-switcher-gap);min-height:var(--sol-scope-switcher-height);padding:0 var(--sol-scope-switcher-padding-x);font-size:var(--sol-scope-switcher-font-size);line-height:1.3}.sol-scope-switcher__loading,.sol-scope-switcher__empty{color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__empty-icon{flex-shrink:0;color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__static{color:var(--sol-scope-switcher-text);background:var(--sol-scope-switcher-bg);border:var(--sol-scope-switcher-border-width) solid var(--sol-scope-switcher-border);border-radius:var(--sol-scope-switcher-radius)}.sol-scope-switcher__trigger{display:inline-flex;align-items:center;gap:var(--sol-scope-switcher-gap);min-height:var(--sol-scope-switcher-height);max-width:100%;padding:0 var(--sol-scope-switcher-padding-x);font-family:inherit;font-size:var(--sol-scope-switcher-font-size);color:var(--sol-scope-switcher-text);text-align:left;background:var(--sol-scope-switcher-bg);border:var(--sol-scope-switcher-border-width) solid var(--sol-scope-switcher-border);border-radius:var(--sol-scope-switcher-radius);cursor:pointer;transition:background var(--sol-scope-switcher-transition),border-color var(--sol-scope-switcher-transition),box-shadow var(--sol-scope-switcher-transition)}.sol-scope-switcher__trigger:hover:not(:disabled){background:var(--sol-scope-switcher-hover)}.sol-scope-switcher__trigger:focus-visible{outline:none;border-color:var(--sol-scope-switcher-accent);box-shadow:var(--sol-scope-switcher-focus-ring)}.sol-scope-switcher__trigger--open{border-color:var(--sol-scope-switcher-accent)}.sol-scope-switcher__trigger:disabled{cursor:not-allowed;opacity:var(--sol-scope-switcher-disabled-opacity)}.sol-scope-switcher__arrow{flex-shrink:0;color:var(--sol-scope-switcher-muted);transition:transform var(--sol-scope-switcher-transition)}.sol-scope-switcher__arrow--open{transform:rotate(180deg)}.sol-scope-switcher__icon{flex-shrink:0;color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__labels{display:flex;flex-direction:column;min-width:0;flex:1}.sol-scope-switcher__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:var(--sol-scope-switcher-weight)}.sol-scope-switcher__sublabel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--sol-scope-switcher-sub-font-size);font-weight:400;color:var(--sol-scope-switcher-muted)}.sol-scope-switcher__panel{position:absolute;top:calc(100% + 4px);left:0;display:flex;flex-direction:column;min-width:15rem;max-width:22rem;max-height:20rem;overflow-y:auto;padding:.25rem;background:var(--sol-scope-switcher-bg);border:var(--sol-scope-switcher-border-width) solid var(--sol-scope-switcher-border);border-radius:var(--sol-scope-switcher-radius);box-shadow:var(--sol-scope-switcher-shadow);animation:sol-scope-switcher-fade .12s ease-out}.sol-scope-switcher__panel--up{top:auto;bottom:calc(100% + 4px)}.sol-scope-switcher__option{display:flex;align-items:center;gap:var(--sol-scope-switcher-gap);width:100%;padding:.5rem .625rem;font-family:inherit;font-size:var(--sol-scope-switcher-font-size);color:var(--sol-scope-switcher-text);text-align:left;background:transparent;border:none;border-radius:calc(var(--sol-scope-switcher-radius) - 2px);cursor:pointer;transition:background var(--sol-scope-switcher-transition)}.sol-scope-switcher__option:hover{background:var(--sol-scope-switcher-hover)}.sol-scope-switcher__option:focus-visible{outline:none;box-shadow:var(--sol-scope-switcher-focus-ring)}.sol-scope-switcher__option--active{background:var(--sol-scope-switcher-active-bg)}.sol-scope-switcher__option--active .sol-scope-switcher__label{color:var(--sol-scope-switcher-accent)}.sol-scope-switcher__check{flex-shrink:0;color:var(--sol-scope-switcher-accent)}.sol-scope-switcher__error{display:flex;align-items:flex-start;gap:.375rem;margin:.25rem 0 0;font-size:var(--sol-scope-switcher-sub-font-size);line-height:1.4;color:var(--sol-scope-switcher-danger)}.sol-scope-switcher__error-icon{flex-shrink:0;color:var(--sol-scope-switcher-danger)}@keyframes sol-scope-switcher-fade{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.sol-scope-switcher__panel{animation:none}.sol-scope-switcher__arrow,.sol-scope-switcher__trigger,.sol-scope-switcher__option{transition:none}}\n"] }]
15889
+ }], ctorParameters: () => [], propDecorators: { scopes: [{ type: i0.Input, args: [{ isSignal: true, alias: "scopes", required: false }] }], activeScopeId: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeScopeId", required: false }] }], status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], loadingMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingMessage", required: false }] }], triggerAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "triggerAriaLabel", required: false }] }], panelAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelAriaLabel", required: false }] }], scopeSelected: [{ type: i0.Output, args: ["scopeSelected"] }], openChange: [{ type: i0.Output, args: ["openChange"] }], triggerRef: [{ type: i0.ViewChild, args: ['triggerBtn', { isSignal: true }] }], panelRef: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], optionRefs: [{ type: i0.ViewChildren, args: ['optionBtn', { isSignal: true }] }], onDocumentEscape: [{
15890
+ type: HostListener,
15891
+ args: ['document:keydown.escape']
15892
+ }], onDocumentClick: [{
15893
+ type: HostListener,
15894
+ args: ['document:click', ['$event']]
15895
+ }] } });
15896
+
14368
15897
  // Shared UI — atomic design system components
14369
15898
 
14370
15899
  /*
@@ -14375,5 +15904,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
14375
15904
  * Generated bundle index. Do not edit.
14376
15905
  */
14377
15906
 
14378
- export { DEFAULT_SCORE_THRESHOLDS, EMIT_TABLE, KANBAN_ADD_ACTION, KanbanReorderService, NEUTRAL_CALENDAR_COLOR, SOL_CALENDAR_COLOR, SOL_CHART_ENGINE, SOL_DEFAULT_THEME, SOL_I18N, SOL_TENANT_RESOLVER, SolAvatarComponent, SolBadgeComponent, SolButtonComponent, SolCalendarComponent, SolCalendarGridComponent, SolCalendarHeaderComponent, SolCardComponent, SolChartComponent, SolCheckboxComponent, SolChipComponent, SolChipGroupComponent, SolDataTableComponent, SolDatePickerComponent, SolDayPickerComponent, SolDrawerComponent, SolEmptyStateComponent, SolFileUploadComponent, SolFlowCanvasComponent, SolFormFieldComponent, SolIconButtonComponent, SolIconComponent, SolInputComponent, SolKanbanBoardComponent, SolKanbanCardComponent, SolKanbanColumnComponent, SolKanbanDragSourceComponent, SolMessageStatusComponent, SolModalComponent, SolNumberInputComponent, SolPageHeaderComponent, SolPaginationComponent, SolProgressBarComponent, SolRichEditorComponent, SolScoreBadgeComponent, SolSearchInputComponent, SolSelectComponent, SolSkeletonComponent, SolSpinnerComponent, SolStarRatingComponent, SolStepperComponent, SolTabsComponent, SolTextareaComponent, SolTimelineComponent, SolToggleComponent, SolTooltipComponent, SolTrendComponent, SolViewToggleComponent, SolVirtualScrollComponent, SolWizardComponent, SolWizardStepDirective, TCPDF_ALLOWED_STYLE_PROPERTIES, TCPDF_ALLOWED_TAGS, THEME_SOURCE, ThemeService, buildDayColumns, buildGoogleFontsUrl, collectUndatedNodes, computeAutoLayoutPositions, computeEventHeight, computeEventTop, computeGlobalRange, computeInitials, computeMonthAxisTicks, computeNowTop, createIdentitySolI18n, dayKey, defaultStatusToken, defaultTrendFormat, getWeekStart, hashToPaletteIndex, isRenderableTheme, isSafeBackgroundImage, isSafeCssColor, parseEventDate, positionRows, provideTheme, resolveCssVars, resolveScoreTone, resolveTrendDirection, sanitizeAssetUrl, sanitizeHtmlToTcpdf, serializeElementToTcpdfHtml };
15907
+ export { DEFAULT_SCORE_THRESHOLDS, EMIT_TABLE, KANBAN_ADD_ACTION, KanbanReorderService, NEUTRAL_CALENDAR_COLOR, SOL_CALENDAR_COLOR, SOL_CHART_ENGINE, SOL_DEFAULT_THEME, SOL_I18N, SOL_TENANT_RESOLVER, SOL_TREE_MAX_DEPTH, SolAvatarComponent, SolBadgeComponent, SolButtonComponent, SolCalendarComponent, SolCalendarGridComponent, SolCalendarHeaderComponent, SolCardComponent, SolChartComponent, SolCheckboxComponent, SolChipComponent, SolChipGroupComponent, SolDataTableComponent, SolDatePickerComponent, SolDayPickerComponent, SolDrawerComponent, SolEmptyStateComponent, SolFileUploadComponent, SolFlowCanvasComponent, SolFormFieldComponent, SolIconButtonComponent, SolIconComponent, SolInputComponent, SolKanbanBoardComponent, SolKanbanCardComponent, SolKanbanColumnComponent, SolKanbanDragSourceComponent, SolMessageStatusComponent, SolModalComponent, SolNotificationPanelComponent, SolNumberInputComponent, SolPageHeaderComponent, SolPaginationComponent, SolProgressBarComponent, SolRichEditorComponent, SolScopeSwitcherComponent, SolScoreBadgeComponent, SolSearchInputComponent, SolSelectComponent, SolSkeletonComponent, SolSpinnerComponent, SolStarRatingComponent, SolStepperComponent, SolTabsComponent, SolTextareaComponent, SolTimelineComponent, SolToggleComponent, SolTooltipComponent, SolTreeComponent, SolTreeNodeDefDirective, SolTrendComponent, SolViewToggleComponent, SolVirtualScrollComponent, SolWizardComponent, SolWizardStepDirective, TCPDF_ALLOWED_STYLE_PROPERTIES, TCPDF_ALLOWED_TAGS, THEME_SOURCE, ThemeService, buildDayColumns, buildGoogleFontsUrl, collectUndatedNodes, computeAutoLayoutPositions, computeEventHeight, computeEventTop, computeGlobalRange, computeInitials, computeMonthAxisTicks, computeNowTop, createIdentitySolI18n, dayKey, defaultStatusToken, defaultTrendFormat, getWeekStart, hashToPaletteIndex, isRenderableTheme, isSafeBackgroundImage, isSafeCssColor, parseEventDate, positionRows, provideTheme, resolveCssVars, resolveScoreTone, resolveTrendDirection, sanitizeAssetUrl, sanitizeHtmlToTcpdf, serializeElementToTcpdfHtml };
14379
15908
  //# sourceMappingURL=solercia-ui.mjs.map