@fluxhub/fluxhub-lib 19.0.183 → 19.0.185

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, forwardRef, EventEmitter, Input, Output, ViewChild, Component, Inject, Optional, Pipe, HostListener, Directive, ChangeDetectionStrategy, ViewEncapsulation, ViewContainerRef, HostBinding } from '@angular/core';
2
+ import { Injectable, forwardRef, EventEmitter, Input, Output, ViewChild, Component, Inject, Optional, Pipe, HostListener, Directive, ChangeDetectionStrategy, ViewEncapsulation, ViewContainerRef, ElementRef, ViewChildren, HostBinding } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common/http';
4
4
  import { HttpHeaders, HttpEventType, HttpErrorResponse } from '@angular/common/http';
5
5
  import { map, catchError, flatMap, debounceTime, switchMap, filter, take, tap } from 'rxjs/operators';
@@ -65,6 +65,8 @@ import { MatMenuModule } from '@angular/material/menu';
65
65
  import { ModuleRegistry, themeQuartz } from 'ag-grid-community';
66
66
  import * as i8$3 from '@angular/cdk/clipboard';
67
67
  import { ColorPickerDirective } from 'ngx-color-picker';
68
+ import * as i3$4 from '@angular/cdk/overlay';
69
+ import { OverlayModule } from '@angular/cdk/overlay';
68
70
  import * as i4$3 from 'ngx-quill';
69
71
  import { QuillModule, QuillEditorComponent, QuillViewComponent } from 'ngx-quill';
70
72
  import Quill from 'quill';
@@ -14992,6 +14994,751 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
14992
14994
  type: Output
14993
14995
  }] } });
14994
14996
 
14997
+ /**
14998
+ * Elenco curato di icone FontAwesome FREE (versione 6).
14999
+ * Sono incluse SOLO icone disponibili nel set gratuito:
15000
+ * - stile "solid" -> classe `fa-solid fa-<name>`
15001
+ * - stile "brands" -> classe `fa-brands fa-<name>`
15002
+ *
15003
+ * L'app consumante deve avere il CSS di FontAwesome caricato (CDN o pacchetto),
15004
+ * esattamente come per le altre icone usate nel portale.
15005
+ *
15006
+ * Per estendere la lista basta aggiungere il nome (senza prefisso `fa-`)
15007
+ * all'array corretto.
15008
+ */
15009
+ /** Icone "solid" free (nome senza prefisso). */
15010
+ const FA_SOLID_ICONS = [
15011
+ // Generali / UI
15012
+ 'house', 'house-chimney', 'home', 'user', 'users', 'user-plus', 'user-minus',
15013
+ 'user-gear', 'user-check', 'user-xmark', 'user-tie', 'user-group', 'user-clock',
15014
+ 'address-book', 'address-card', 'id-card', 'id-badge', 'circle-user',
15015
+ 'gear', 'gears', 'sliders', 'wrench', 'screwdriver-wrench', 'toolbox', 'hammer',
15016
+ 'magnifying-glass', 'magnifying-glass-plus', 'magnifying-glass-minus',
15017
+ 'filter', 'filter-circle-xmark', 'sort', 'sort-up', 'sort-down',
15018
+ 'bars', 'bars-staggered', 'ellipsis', 'ellipsis-vertical', 'grip', 'grip-vertical',
15019
+ 'list', 'list-ul', 'list-ol', 'list-check', 'table', 'table-list', 'table-cells',
15020
+ 'table-columns', 'border-all', 'th', 'th-large', 'th-list',
15021
+ // Azioni
15022
+ 'plus', 'minus', 'xmark', 'check', 'check-double', 'ban', 'circle-plus',
15023
+ 'circle-minus', 'circle-xmark', 'circle-check', 'square-plus', 'square-minus',
15024
+ 'square-check', 'pen', 'pen-to-square', 'pencil', 'eraser', 'trash', 'trash-can',
15025
+ 'copy', 'paste', 'scissors', 'clone', 'save', 'floppy-disk', 'print',
15026
+ 'download', 'upload', 'cloud-arrow-down', 'cloud-arrow-up', 'file-export',
15027
+ 'file-import', 'share', 'share-nodes', 'reply', 'reply-all', 'forward',
15028
+ 'rotate', 'rotate-left', 'rotate-right', 'arrows-rotate', 'repeat', 'shuffle',
15029
+ 'lock', 'lock-open', 'unlock', 'key', 'shield', 'shield-halved', 'fingerprint',
15030
+ 'eye', 'eye-slash', 'thumbtack', 'bookmark', 'star', 'star-half', 'heart',
15031
+ 'flag', 'flag-checkered', 'bell', 'bell-slash', 'bullhorn', 'comment',
15032
+ 'comments', 'comment-dots', 'message', 'envelope', 'envelope-open',
15033
+ 'paper-plane', 'inbox', 'at', 'reply', 'phone', 'phone-slash', 'mobile',
15034
+ 'mobile-screen', 'fax', 'headset', 'voicemail',
15035
+ // Frecce / navigazione
15036
+ 'arrow-up', 'arrow-down', 'arrow-left', 'arrow-right', 'arrow-up-right-from-square',
15037
+ 'up-down', 'left-right', 'arrows-up-down-left-right', 'angle-up', 'angle-down',
15038
+ 'angle-left', 'angle-right', 'angles-up', 'angles-down', 'angles-left',
15039
+ 'angles-right', 'chevron-up', 'chevron-down', 'chevron-left', 'chevron-right',
15040
+ 'caret-up', 'caret-down', 'caret-left', 'caret-right', 'location-dot',
15041
+ 'location-arrow', 'location-crosshairs', 'map', 'map-pin', 'map-location-dot',
15042
+ 'compass', 'route', 'signs-post', 'diamond-turn-right',
15043
+ // File / documenti
15044
+ 'file', 'file-lines', 'file-pdf', 'file-word', 'file-excel', 'file-powerpoint',
15045
+ 'file-image', 'file-video', 'file-audio', 'file-zipper', 'file-code',
15046
+ 'file-csv', 'file-invoice', 'file-invoice-dollar', 'file-contract',
15047
+ 'file-signature', 'file-circle-check', 'file-circle-xmark', 'folder',
15048
+ 'folder-open', 'folder-plus', 'folder-tree', 'paperclip', 'book', 'book-open',
15049
+ 'newspaper', 'clipboard', 'clipboard-list', 'clipboard-check', 'note-sticky',
15050
+ // Business / commerce
15051
+ 'briefcase', 'building', 'building-columns', 'industry', 'warehouse', 'store',
15052
+ 'shop', 'cart-shopping', 'cart-plus', 'basket-shopping', 'bag-shopping',
15053
+ 'credit-card', 'money-bill', 'money-bill-wave', 'money-check', 'money-check-dollar',
15054
+ 'wallet', 'sack-dollar', 'coins', 'cash-register', 'receipt', 'tag', 'tags',
15055
+ 'percent', 'dollar-sign', 'euro-sign', 'sterling-sign', 'chart-line',
15056
+ 'chart-bar', 'chart-column', 'chart-pie', 'chart-area', 'chart-simple',
15057
+ 'arrow-trend-up', 'arrow-trend-down', 'scale-balanced', 'handshake', 'gem',
15058
+ 'crown', 'award', 'trophy', 'medal', 'ribbon', 'certificate',
15059
+ // Tempo / calendario
15060
+ 'calendar', 'calendar-days', 'calendar-check', 'calendar-xmark', 'calendar-plus',
15061
+ 'calendar-week', 'clock', 'clock-rotate-left', 'hourglass', 'hourglass-half',
15062
+ 'stopwatch', 'business-time', 'history',
15063
+ // Multimedia
15064
+ 'play', 'pause', 'stop', 'forward-step', 'backward-step', 'forward-fast',
15065
+ 'backward-fast', 'circle-play', 'circle-pause', 'circle-stop', 'volume-high',
15066
+ 'volume-low', 'volume-xmark', 'music', 'image', 'images', 'camera', 'video',
15067
+ 'film', 'photo-film', 'microphone', 'microphone-slash', 'podcast',
15068
+ // Tech / dispositivi
15069
+ 'desktop', 'laptop', 'tablet', 'keyboard', 'mouse', 'computer', 'server',
15070
+ 'database', 'hard-drive', 'memory', 'microchip', 'sim-card', 'plug', 'battery-full',
15071
+ 'battery-half', 'battery-empty', 'wifi', 'signal', 'tower-broadcast', 'satellite-dish',
15072
+ 'cloud', 'network-wired', 'sitemap', 'code', 'code-branch', 'code-compare',
15073
+ 'terminal', 'bug', 'robot', 'qrcode', 'barcode',
15074
+ // Persone / stati
15075
+ 'circle-info', 'info', 'circle-question', 'question', 'circle-exclamation',
15076
+ 'triangle-exclamation', 'exclamation', 'lightbulb', 'fire', 'bolt', 'snowflake',
15077
+ 'sun', 'moon', 'cloud-sun', 'cloud-moon', 'umbrella', 'temperature-half',
15078
+ // Trasporti / luoghi
15079
+ 'car', 'truck', 'truck-fast', 'van-shuttle', 'bus', 'train', 'plane',
15080
+ 'plane-departure', 'plane-arrival', 'ship', 'bicycle', 'motorcycle', 'taxi',
15081
+ 'gas-pump', 'road', 'traffic-light', 'anchor', 'globe', 'earth-europe',
15082
+ 'earth-americas', 'flag-usa', 'mountain', 'tree', 'leaf', 'seedling',
15083
+ // Salute / scienza
15084
+ 'heart-pulse', 'stethoscope', 'user-doctor', 'hospital', 'pills', 'capsules',
15085
+ 'syringe', 'notes-medical', 'kit-medical', 'flask', 'vial', 'microscope',
15086
+ 'dna', 'atom', 'brain', 'tooth', 'bone',
15087
+ // Cibo / vario
15088
+ 'utensils', 'mug-hot', 'mug-saucer', 'wine-glass', 'martini-glass', 'beer-mug-empty',
15089
+ 'pizza-slice', 'burger', 'cake-candles', 'cookie', 'ice-cream', 'apple-whole',
15090
+ 'gift', 'gifts', 'box', 'boxes-stacked', 'box-open', 'pallet', 'dolly',
15091
+ // Simboli / misc
15092
+ 'circle', 'square', 'check-circle', 'circle-half-stroke', 'asterisk', 'hashtag',
15093
+ 'infinity', 'palette', 'paint-roller', 'paintbrush', 'fill-drip', 'eye-dropper',
15094
+ 'wand-magic-sparkles', 'puzzle-piece', 'cubes', 'cube', 'layer-group', 'clone',
15095
+ 'object-group', 'crop', 'expand', 'compress', 'maximize', 'minimize',
15096
+ 'arrows-left-right-to-line', 'up-right-and-down-left-from-center', 'language',
15097
+ 'spell-check', 'font', 'bold', 'italic', 'underline', 'align-left', 'align-center',
15098
+ 'align-right', 'align-justify', 'indent', 'outdent', 'quote-left', 'quote-right',
15099
+ 'link', 'link-slash', 'power-off', 'right-to-bracket', 'right-from-bracket',
15100
+ 'arrow-right-to-bracket', 'arrow-right-from-bracket', 'door-open', 'door-closed',
15101
+ 'circle-notch', 'spinner', 'gauge', 'gauge-high', 'tachograph-digital',
15102
+ 'temperature-high', 'toggle-on', 'toggle-off', 'wrench', 'broom', 'recycle',
15103
+ 'arrows-spin', 'graduation-cap', 'school', 'chalkboard', 'chalkboard-user',
15104
+ 'person', 'person-walking', 'person-running', 'child', 'baby', 'wheelchair',
15105
+ 'hand', 'hand-point-up', 'hand-point-right', 'thumbs-up', 'thumbs-down',
15106
+ 'face-smile', 'face-frown', 'face-meh', 'smile', 'frown'
15107
+ ];
15108
+ /** Icone "brands" free (loghi, nome senza prefisso). */
15109
+ const FA_BRAND_ICONS = [
15110
+ 'angular', 'react', 'vuejs', 'node-js', 'js', 'html5', 'css3', 'css3-alt',
15111
+ 'sass', 'less', 'bootstrap', 'npm', 'yarn', 'docker', 'git', 'git-alt',
15112
+ 'github', 'gitlab', 'bitbucket', 'jenkins', 'java', 'python', 'php', 'laravel',
15113
+ 'symfony', 'wordpress', 'wordpress-simple', 'drupal', 'joomla', 'shopify',
15114
+ 'magento', 'stripe', 'paypal', 'cc-visa', 'cc-mastercard', 'cc-amex',
15115
+ 'cc-paypal', 'cc-stripe', 'amazon', 'aws', 'google', 'google-drive',
15116
+ 'google-play', 'microsoft', 'windows', 'apple', 'android', 'linux', 'ubuntu',
15117
+ 'redhat', 'centos', 'fedora', 'suse',
15118
+ 'facebook', 'facebook-f', 'facebook-messenger', 'instagram', 'twitter',
15119
+ 'x-twitter', 'linkedin', 'linkedin-in', 'youtube', 'whatsapp', 'telegram',
15120
+ 'tiktok', 'pinterest', 'reddit', 'tumblr', 'snapchat', 'discord', 'slack',
15121
+ 'skype', 'twitch', 'vimeo', 'spotify', 'soundcloud', 'figma', 'sketch',
15122
+ 'invision', 'dribbble', 'behance', 'medium', 'dev', 'stack-overflow',
15123
+ 'stack-exchange', 'codepen', 'jsfiddle', 'free-code-camp', 'trello', 'jira',
15124
+ 'confluence', 'atlassian', 'salesforce', 'hubspot', 'mailchimp', 'wix',
15125
+ 'squarespace', 'cloudflare', 'digital-ocean', 'firefox', 'chrome', 'edge',
15126
+ 'safari', 'opera', 'internet-explorer', 'app-store', 'app-store-ios',
15127
+ 'steam', 'playstation', 'xbox', 'unity', 'cc-discover', 'bitcoin', 'ethereum'
15128
+ ];
15129
+
15130
+ const FH_ICON_PICKER_VALUE_ACCESSOR = {
15131
+ provide: NG_VALUE_ACCESSOR,
15132
+ useExisting: forwardRef(() => FHIconPickerComponent),
15133
+ multi: true,
15134
+ };
15135
+ /**
15136
+ * FHIconPicker — selettore di icone FontAwesome (solo set FREE).
15137
+ *
15138
+ * Ispirato a https://github.com/tech-advantage/ngx-icon-picker ma:
15139
+ * - standalone, ControlValueAccessor (usabile con [(ngModel)])
15140
+ * - nessuna dipendenza npm aggiuntiva: rende le icone via classi CSS,
15141
+ * quindi richiede che l'app abbia caricato il CSS di FontAwesome 6.
15142
+ * - popup di selezione via CDK Overlay con ricerca, tab Tutte/Solid/Brands,
15143
+ * navigazione da tastiera (frecce / Invio / Esc) e icone recenti.
15144
+ *
15145
+ * VALORE EMESSO (ngModel / change): per default è il **nome testuale** dell'icona,
15146
+ * es. "fa-bookmark" (formato 'name'). Configurabile con [valueFormat]:
15147
+ * - 'name' -> "fa-bookmark" (default)
15148
+ * - 'plain' -> "bookmark"
15149
+ * - 'class' -> "fa-solid fa-bookmark" (classe CSS completa)
15150
+ *
15151
+ * In input accetta tutti i formati (nome, nome con prefisso, sintassi FA5
15152
+ * "fas fa-x"/"fa fa-x", classe completa) e li normalizza internamente.
15153
+ *
15154
+ * Esempio:
15155
+ * <FHIconPicker [(ngModel)]="obj.icona" [label]="'Icona'" [enabled]="canEdit"
15156
+ * (change)="onIconChange($event)"></FHIconPicker>
15157
+ */
15158
+ class FHIconPickerComponent {
15159
+ cdr;
15160
+ label = '';
15161
+ placeholder = 'Seleziona icona';
15162
+ enabled = true;
15163
+ hidden = false;
15164
+ required = false;
15165
+ error = '';
15166
+ /** Mostra il pulsante per azzerare la selezione. */
15167
+ allowClear = true;
15168
+ /** Tab attiva all'apertura: 'all' | 'solid' | 'brands'. */
15169
+ defaultStyle = 'all';
15170
+ /** Vista iniziale del popup: 'grid' | 'list'. */
15171
+ defaultView = 'grid';
15172
+ /** Formato del valore emesso: 'name' (fa-bookmark) | 'plain' (bookmark) | 'class'. */
15173
+ valueFormat = 'name';
15174
+ /** Quante icone recenti memorizzare (0 = disattiva). */
15175
+ recentCount = 12;
15176
+ /** Emette il nome dell'icona nel formato configurato (valueFormat). */
15177
+ change = new EventEmitter();
15178
+ /** Banana-in-a-box: supporto a [(icon)] oltre a [(ngModel)]. */
15179
+ iconChange = new EventEmitter();
15180
+ searchBox;
15181
+ triggerRef;
15182
+ gridRef;
15183
+ cells;
15184
+ static RECENT_KEY = 'fh_icon_picker_recent';
15185
+ /** Classe CSS completa dell'icona selezionata (uso interno per il rendering). */
15186
+ _value = '';
15187
+ /** Valore "di output" (nel formato configurato) mostrato nel trigger. */
15188
+ outValue = '';
15189
+ panelOpen = false;
15190
+ panelWidth = 380;
15191
+ search = '';
15192
+ activeStyle = 'all';
15193
+ view = 'grid';
15194
+ highlightIndex = -1;
15195
+ allSolid = [];
15196
+ allBrands = [];
15197
+ allIcons = [];
15198
+ styleByName = new Map();
15199
+ filtered = [];
15200
+ recent = [];
15201
+ overlayPositions = [
15202
+ { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 6 },
15203
+ { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -6 },
15204
+ ];
15205
+ constructor(cdr) {
15206
+ this.cdr = cdr;
15207
+ }
15208
+ ngOnInit() {
15209
+ this.allSolid = FA_SOLID_ICONS.map(n => ({ name: n, cls: `fa-solid fa-${n}`, style: 'solid' }));
15210
+ this.allBrands = FA_BRAND_ICONS.map(n => ({ name: n, cls: `fa-brands fa-${n}`, style: 'brands' }));
15211
+ this.allIcons = [...this.allSolid, ...this.allBrands];
15212
+ // mappa nome -> stile (brands prevale sui nomi propri dei loghi)
15213
+ this.allSolid.forEach(i => this.styleByName.set(i.name, 'solid'));
15214
+ this.allBrands.forEach(i => this.styleByName.set(i.name, 'brands'));
15215
+ this.activeStyle = this.defaultStyle;
15216
+ this.view = this.defaultView;
15217
+ this.loadRecent();
15218
+ this.applyFilter();
15219
+ }
15220
+ get currentSet() {
15221
+ if (this.activeStyle === 'brands')
15222
+ return this.allBrands;
15223
+ if (this.activeStyle === 'solid')
15224
+ return this.allSolid;
15225
+ return this.allIcons;
15226
+ }
15227
+ // ---- apertura / chiusura popup ----
15228
+ togglePanel() {
15229
+ if (!this.enabled)
15230
+ return;
15231
+ this.panelOpen ? this.closePanel() : this.openPanel();
15232
+ }
15233
+ openPanel() {
15234
+ if (this._value?.includes('fa-brands'))
15235
+ this.activeStyle = 'brands';
15236
+ else if (this._value?.includes('fa-solid') && this.activeStyle === 'brands')
15237
+ this.activeStyle = 'all';
15238
+ this.panelWidth = Math.max(340, this.triggerRef?.nativeElement?.offsetWidth || 380);
15239
+ this.search = '';
15240
+ this.applyFilter();
15241
+ this.highlightIndex = this.filtered.findIndex(i => i.cls === this._value);
15242
+ this.panelOpen = true;
15243
+ this.cdr.detectChanges();
15244
+ setTimeout(() => {
15245
+ this.searchBox?.nativeElement?.focus();
15246
+ this.scrollHighlightIntoView();
15247
+ }, 50);
15248
+ }
15249
+ closePanel() {
15250
+ if (!this.panelOpen)
15251
+ return;
15252
+ this.panelOpen = false;
15253
+ this.onTouched();
15254
+ this.cdr.detectChanges();
15255
+ }
15256
+ setStyle(style) {
15257
+ this.activeStyle = style;
15258
+ this.applyFilter();
15259
+ this.highlightIndex = this.filtered.length ? 0 : -1;
15260
+ }
15261
+ setView(v) {
15262
+ this.view = v;
15263
+ this.cdr.detectChanges();
15264
+ setTimeout(() => this.scrollHighlightIntoView(), 0);
15265
+ }
15266
+ applyFilter() {
15267
+ const q = (this.search || '').trim().toLowerCase();
15268
+ const base = this.currentSet;
15269
+ this.filtered = !q ? base : base.filter(i => i.name.indexOf(q) !== -1);
15270
+ if (this.highlightIndex >= this.filtered.length)
15271
+ this.highlightIndex = this.filtered.length - 1;
15272
+ }
15273
+ selectIcon(cls) {
15274
+ this.setVal(cls);
15275
+ this.pushRecent(cls);
15276
+ this.closePanel();
15277
+ }
15278
+ clear(ev) {
15279
+ ev?.stopPropagation();
15280
+ this.setVal('');
15281
+ }
15282
+ setVal(cls) {
15283
+ this._value = cls;
15284
+ this.outValue = this.toOutput(cls);
15285
+ this.onChange(this.outValue);
15286
+ this.change.emit(this.outValue);
15287
+ this.iconChange.emit(this.outValue);
15288
+ }
15289
+ /** Nome di output per una classe completa (usato per i tooltip dei recenti). */
15290
+ outOf(cls) { return this.toOutput(cls); }
15291
+ trackByIcon(_, item) { return item.cls; }
15292
+ // ---- navigazione da tastiera ----
15293
+ onPanelKeydown(ev) {
15294
+ const step = this.view === 'list' ? 1 : this.computeColumns();
15295
+ let idx = this.highlightIndex;
15296
+ switch (ev.key) {
15297
+ case 'Escape':
15298
+ ev.preventDefault();
15299
+ this.closePanel();
15300
+ return;
15301
+ case 'ArrowRight':
15302
+ idx = Math.min(this.filtered.length - 1, idx + 1);
15303
+ break;
15304
+ case 'ArrowLeft':
15305
+ idx = Math.max(0, idx - 1);
15306
+ break;
15307
+ case 'ArrowDown':
15308
+ idx = Math.min(this.filtered.length - 1, idx + step);
15309
+ break;
15310
+ case 'ArrowUp':
15311
+ idx = idx - step;
15312
+ if (idx < 0)
15313
+ idx = this.highlightIndex;
15314
+ break;
15315
+ case 'Enter':
15316
+ if (this.highlightIndex >= 0 && this.filtered[this.highlightIndex]) {
15317
+ ev.preventDefault();
15318
+ this.selectIcon(this.filtered[this.highlightIndex].cls);
15319
+ }
15320
+ return;
15321
+ default: return;
15322
+ }
15323
+ ev.preventDefault();
15324
+ if (idx < 0)
15325
+ idx = 0;
15326
+ this.highlightIndex = idx;
15327
+ this.scrollHighlightIntoView();
15328
+ }
15329
+ computeColumns() {
15330
+ const grid = this.gridRef?.nativeElement;
15331
+ if (!grid)
15332
+ return 4;
15333
+ const w = grid.clientWidth - 20;
15334
+ return Math.max(1, Math.floor(w / 88));
15335
+ }
15336
+ scrollHighlightIntoView() {
15337
+ setTimeout(() => {
15338
+ const arr = this.cells?.toArray();
15339
+ if (arr && arr[this.highlightIndex]) {
15340
+ arr[this.highlightIndex].nativeElement.scrollIntoView({ block: 'nearest' });
15341
+ }
15342
+ }, 0);
15343
+ }
15344
+ // ---- recenti ----
15345
+ loadRecent() {
15346
+ if (this.recentCount <= 0) {
15347
+ this.recent = [];
15348
+ return;
15349
+ }
15350
+ try {
15351
+ const raw = localStorage.getItem(FHIconPickerComponent.RECENT_KEY);
15352
+ this.recent = raw ? JSON.parse(raw).slice(0, this.recentCount) : [];
15353
+ }
15354
+ catch {
15355
+ this.recent = [];
15356
+ }
15357
+ }
15358
+ pushRecent(cls) {
15359
+ if (this.recentCount <= 0 || !cls)
15360
+ return;
15361
+ this.recent = [cls, ...this.recent.filter(r => r !== cls)].slice(0, this.recentCount);
15362
+ try {
15363
+ localStorage.setItem(FHIconPickerComponent.RECENT_KEY, JSON.stringify(this.recent));
15364
+ }
15365
+ catch { /* ignore */ }
15366
+ }
15367
+ // ---- API pubblica ----
15368
+ /** Ritorna il valore nel formato configurato (es. "fa-bookmark"). */
15369
+ getValue() { return this.outValue; }
15370
+ /** Ritorna SEMPRE la classe CSS completa (es. "fa-solid fa-bookmark"). */
15371
+ getCssClass() { return this._value; }
15372
+ /** Imposta l'icona da qualsiasi formato (nome, fa-name, fas fa-name, classe completa). */
15373
+ setValue(value) {
15374
+ this._value = this.toFullClass(value);
15375
+ this.outValue = this.toOutput(this._value);
15376
+ this.cdr.detectChanges();
15377
+ }
15378
+ /** Azzera la selezione. */
15379
+ reset() { this._value = ''; this.outValue = ''; this.cdr.detectChanges(); }
15380
+ // ---- ControlValueAccessor ----
15381
+ writeValue(value) {
15382
+ this._value = this.toFullClass(value);
15383
+ this.outValue = this.toOutput(this._value);
15384
+ this.cdr.detectChanges();
15385
+ }
15386
+ /**
15387
+ * Estrae nome + stile da una stringa in qualsiasi formato:
15388
+ * "fa-solid fa-house", "fas fa-house", "fa fa-house", "fa-house", "house".
15389
+ */
15390
+ parse(value) {
15391
+ let name = '';
15392
+ let style = null;
15393
+ if (value && typeof value === 'string') {
15394
+ const tokens = value.trim().toLowerCase().split(/\s+/).filter(Boolean);
15395
+ for (const t of tokens) {
15396
+ if (t === 'fas')
15397
+ style = 'solid';
15398
+ else if (t === 'fab')
15399
+ style = 'brands';
15400
+ else if (t === 'far')
15401
+ style = 'regular';
15402
+ else if (t === 'fal')
15403
+ style = 'light';
15404
+ else if (t === 'fa') { /* generico FA4/5 */ }
15405
+ else if (/^fa-(solid|regular|brands|light|thin|duotone)$/.test(t))
15406
+ style = t.slice(3);
15407
+ else if (t.indexOf('fa-') === 0)
15408
+ name = t.slice(3);
15409
+ else if (/^[a-z0-9-]+$/.test(t))
15410
+ name = t;
15411
+ }
15412
+ }
15413
+ if (!style)
15414
+ style = this.styleByName.get(name) || 'solid';
15415
+ return { name, style };
15416
+ }
15417
+ /** Normalizza un valore in classe CSS completa per il rendering. */
15418
+ toFullClass(value) {
15419
+ const { name, style } = this.parse(value);
15420
+ return name ? `fa-${style} fa-${name}` : '';
15421
+ }
15422
+ /** Converte una classe completa nel formato di output configurato. */
15423
+ toOutput(fullClass) {
15424
+ if (!fullClass)
15425
+ return '';
15426
+ if (this.valueFormat === 'class')
15427
+ return fullClass;
15428
+ const { name } = this.parse(fullClass);
15429
+ if (!name)
15430
+ return '';
15431
+ return this.valueFormat === 'plain' ? name : `fa-${name}`;
15432
+ }
15433
+ onChange = (_) => { };
15434
+ onTouched = () => { };
15435
+ registerOnChange(fn) { this.onChange = fn; }
15436
+ registerOnTouched(fn) { this.onTouched = fn; }
15437
+ setDisabledState(isDisabled) { this.enabled = !isDisabled; }
15438
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHIconPickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
15439
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.17", type: FHIconPickerComponent, isStandalone: true, selector: "FHIconPicker", inputs: { label: "label", placeholder: "placeholder", enabled: "enabled", hidden: "hidden", required: "required", error: "error", allowClear: "allowClear", defaultStyle: "defaultStyle", defaultView: "defaultView", valueFormat: "valueFormat", recentCount: "recentCount" }, outputs: { change: "change", iconChange: "iconChange" }, providers: [FH_ICON_PICKER_VALUE_ACCESSOR], viewQueries: [{ propertyName: "searchBox", first: true, predicate: ["searchBox"], descendants: true }, { propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true, read: ElementRef }, { propertyName: "gridRef", first: true, predicate: ["grid"], descendants: true }, { propertyName: "cells", predicate: ["cell"], descendants: true }], ngImport: i0, template: `
15440
+ <div class="fh-icon-picker" *ngIf="!hidden">
15441
+ <label *ngIf="label" class="fh-ip-label">
15442
+ {{ label | translate }}<span *ngIf="required" class="fh-ip-req"> *</span>
15443
+ </label>
15444
+
15445
+ <div class="fh-ip-trigger-row">
15446
+ <button type="button" class="fh-ip-trigger"
15447
+ [class.disabled]="!enabled"
15448
+ [class.error]="!!error"
15449
+ [class.open]="panelOpen"
15450
+ [disabled]="!enabled"
15451
+ #trigger
15452
+ (click)="togglePanel()">
15453
+ <span class="fh-ip-preview" [class.empty]="!_value">
15454
+ <i *ngIf="_value" [class]="_value"></i>
15455
+ <i *ngIf="!_value" class="fa-regular fa-image fh-ip-placeholder-icon"></i>
15456
+ </span>
15457
+ <span class="fh-ip-text" [class.muted]="!_value">
15458
+ {{ _value ? outValue : (placeholder | translate) }}
15459
+ </span>
15460
+ <i class="fa-solid fa-caret-down fh-ip-caret"></i>
15461
+ </button>
15462
+
15463
+ <button type="button" class="fh-ip-clear" *ngIf="_value && enabled && allowClear"
15464
+ [title]="'ANNULLA' | translate"
15465
+ (click)="clear($event)">
15466
+ <i class="fa-solid fa-xmark"></i>
15467
+ </button>
15468
+ </div>
15469
+
15470
+ <div class="fh-ip-error" *ngIf="error">{{ error | translate }}</div>
15471
+
15472
+ <!-- Popup di selezione (dentro lo stesso scope di #trigger) -->
15473
+ <ng-template
15474
+ cdkConnectedOverlay
15475
+ [cdkConnectedOverlayOrigin]="trigger"
15476
+ [cdkConnectedOverlayOpen]="panelOpen"
15477
+ [cdkConnectedOverlayHasBackdrop]="true"
15478
+ cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
15479
+ [cdkConnectedOverlayPositions]="overlayPositions"
15480
+ (backdropClick)="closePanel()"
15481
+ (detach)="closePanel()">
15482
+
15483
+ <div class="fh-ip-panel" [style.width.px]="panelWidth" (keydown)="onPanelKeydown($event)">
15484
+ <div class="fh-ip-toolbar">
15485
+ <div class="fh-ip-search">
15486
+ <i class="fa-solid fa-magnifying-glass"></i>
15487
+ <input #searchBox type="text" [(ngModel)]="search"
15488
+ (ngModelChange)="applyFilter()"
15489
+ [placeholder]="('CERCA' | translate) + '...'">
15490
+ <i class="fa-solid fa-xmark fh-ip-search-clear" *ngIf="search"
15491
+ (click)="search=''; applyFilter()"></i>
15492
+ </div>
15493
+ <div class="fh-ip-tabs">
15494
+ <button type="button" [class.active]="activeStyle==='all'"
15495
+ (click)="setStyle('all')">{{ 'Tutte' }}</button>
15496
+ <button type="button" [class.active]="activeStyle==='solid'"
15497
+ (click)="setStyle('solid')">{{ 'Solid' }}</button>
15498
+ <button type="button" [class.active]="activeStyle==='brands'"
15499
+ (click)="setStyle('brands')">{{ 'Brands' }}</button>
15500
+ </div>
15501
+ <div class="fh-ip-view">
15502
+ <button type="button" [class.active]="view==='grid'" [title]="'Griglia'"
15503
+ (click)="setView('grid')"><i class="fa-solid fa-table-cells-large"></i></button>
15504
+ <button type="button" [class.active]="view==='list'" [title]="'Elenco'"
15505
+ (click)="setView('list')"><i class="fa-solid fa-list"></i></button>
15506
+ </div>
15507
+ </div>
15508
+
15509
+ <!-- Recenti -->
15510
+ <div class="fh-ip-recent" *ngIf="!search && recent.length">
15511
+ <span class="fh-ip-section-lbl">{{ 'Recenti' }}</span>
15512
+ <div class="fh-ip-recent-row">
15513
+ <button type="button" class="fh-ip-recent-cell"
15514
+ *ngFor="let r of recent"
15515
+ [class.selected]="r === _value"
15516
+ [title]="outOf(r)"
15517
+ (click)="selectIcon(r)">
15518
+ <i [class]="r"></i>
15519
+ </button>
15520
+ </div>
15521
+ </div>
15522
+
15523
+ <!-- GRIGLIA -->
15524
+ <div class="fh-ip-grid" #grid *ngIf="view==='grid'">
15525
+ <button type="button" class="fh-ip-cell" #cell
15526
+ *ngFor="let ic of filtered; let i = index; trackBy: trackByIcon"
15527
+ [class.selected]="ic.cls === _value"
15528
+ [class.highlight]="i === highlightIndex"
15529
+ [title]="'fa-' + ic.name"
15530
+ (mouseenter)="highlightIndex = i"
15531
+ (click)="selectIcon(ic.cls)">
15532
+ <i [class]="ic.cls"></i>
15533
+ <span class="fh-ip-cell-name">fa-{{ ic.name }}</span>
15534
+ </button>
15535
+
15536
+ <div class="fh-ip-empty" *ngIf="filtered.length === 0">
15537
+ <i class="fa-regular fa-face-frown"></i>
15538
+ <span>{{ 'Nessuna icona trovata' }}</span>
15539
+ </div>
15540
+ </div>
15541
+
15542
+ <!-- ELENCO -->
15543
+ <div class="fh-ip-list" #grid *ngIf="view==='list'">
15544
+ <button type="button" class="fh-ip-row" #cell
15545
+ *ngFor="let ic of filtered; let i = index; trackBy: trackByIcon"
15546
+ [class.selected]="ic.cls === _value"
15547
+ [class.highlight]="i === highlightIndex"
15548
+ (mouseenter)="highlightIndex = i"
15549
+ (click)="selectIcon(ic.cls)">
15550
+ <span class="fh-ip-row-ico"><i [class]="ic.cls"></i></span>
15551
+ <span class="fh-ip-row-name">fa-{{ ic.name }}</span>
15552
+ <i class="fa-solid fa-check fh-ip-row-check" *ngIf="ic.cls === _value"></i>
15553
+ </button>
15554
+
15555
+ <div class="fh-ip-empty" *ngIf="filtered.length === 0">
15556
+ <i class="fa-regular fa-face-frown"></i>
15557
+ <span>{{ 'Nessuna icona trovata' }}</span>
15558
+ </div>
15559
+ </div>
15560
+
15561
+ <div class="fh-ip-footer">
15562
+ <span class="fh-ip-count">{{ filtered.length }} {{ 'icone' }}</span>
15563
+ <span class="fh-ip-hint"><kbd>↑↓←→</kbd> {{ 'naviga' }} · <kbd>↵</kbd> {{ 'scegli' }} · <kbd>esc</kbd> {{ 'chiudi' }}</span>
15564
+ </div>
15565
+ </div>
15566
+ </ng-template>
15567
+ </div>
15568
+ `, isInline: true, styles: [":host{display:block}.fh-icon-picker{display:flex;flex-direction:column;gap:4px}.fh-ip-label{font-size:12px;font-weight:600;color:#5b6168}.fh-ip-req{color:#d32f2f}.fh-ip-trigger-row{display:flex;align-items:stretch;gap:6px}.fh-ip-trigger{flex:1 1 auto;display:flex;align-items:center;gap:10px;min-height:40px;padding:6px 12px;cursor:pointer;background:#fff;border:1.5px solid #d7dbe0;border-radius:8px;text-align:left;transition:border-color .15s ease,box-shadow .15s ease;font-size:14px;color:#161212;overflow:hidden}.fh-ip-trigger:hover:not(.disabled){border-color:#9aa1a9}.fh-ip-trigger.open,.fh-ip-trigger:focus-visible{outline:none;border-color:#2196f3;box-shadow:0 0 0 3px #2196f326}.fh-ip-trigger.open .fh-ip-caret{transform:rotate(180deg)}.fh-ip-trigger.disabled{background:#f4f5f6;color:#9aa1a9;cursor:not-allowed;opacity:.8}.fh-ip-trigger.error{border-color:#d32f2f}.fh-ip-preview{flex:0 0 auto;width:28px;height:28px;display:flex;align-items:center;justify-content:center;border-radius:6px;background:#eef2f6;font-size:16px;color:#2196f3}.fh-ip-preview.empty{color:#b6bcc3;background:#f4f5f6}.fh-ip-placeholder-icon{font-size:14px}.fh-ip-text{flex:1 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:monospace;font-size:13px}.fh-ip-text.muted{color:#9aa1a9;font-family:inherit;font-style:italic}.fh-ip-caret{flex:0 0 auto;color:#9aa1a9;font-size:12px;transition:transform .2s ease}.fh-ip-clear{flex:0 0 auto;width:40px;border:1.5px solid #d7dbe0;border-radius:8px;background:#fff;cursor:pointer;color:#6b7178;transition:all .15s ease}.fh-ip-clear:hover{border-color:#d32f2f;color:#d32f2f;background:#fff5f5}.fh-ip-error{font-size:12px;color:#d32f2f}.fh-ip-panel{background:#fff;border:1px solid #e0e3e7;border-radius:12px;box-shadow:0 12px 32px #0000002e;overflow:hidden;display:flex;flex-direction:column;max-height:460px}.fh-ip-toolbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid #eef0f2;flex:0 0 auto;flex-wrap:wrap}.fh-ip-search{flex:1 1 150px;display:flex;align-items:center;gap:8px;background:#f4f5f6;border-radius:8px;padding:6px 10px;color:#6b7178}.fh-ip-search input{flex:1 1 auto;border:none;background:transparent;outline:none;font-size:14px;color:#161212;min-width:0}.fh-ip-search-clear{cursor:pointer}.fh-ip-search-clear:hover{color:#d32f2f}.fh-ip-tabs{display:flex;gap:4px;flex:0 0 auto}.fh-ip-tabs button{border:1px solid #d7dbe0;background:#fff;color:#5b6168;padding:6px 11px;border-radius:8px;cursor:pointer;font-size:12px;font-weight:600;transition:all .15s ease}.fh-ip-tabs button:hover{border-color:#9aa1a9}.fh-ip-tabs button.active{background:#2196f3;border-color:#2196f3;color:#fff}.fh-ip-view{display:flex;gap:2px;flex:0 0 auto}.fh-ip-view button{width:32px;height:32px;border:1px solid #d7dbe0;background:#fff;color:#8a9098;cursor:pointer;border-radius:8px;transition:all .15s ease}.fh-ip-view button:hover{border-color:#9aa1a9;color:#5b6168}.fh-ip-view button.active{background:#eef6fe;border-color:#2196f3;color:#2196f3}.fh-ip-recent{padding:8px 12px 4px;border-bottom:1px dashed #eef0f2;flex:0 0 auto}.fh-ip-section-lbl{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#9aa1a9}.fh-ip-recent-row{display:flex;gap:4px;margin-top:6px;flex-wrap:wrap}.fh-ip-recent-cell{width:34px;height:34px;display:flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:8px;background:#f4f5f6;cursor:pointer;color:#3a3f45;font-size:16px;transition:all .12s ease}.fh-ip-recent-cell:hover{background:#eef6fe;border-color:#bfe0fb}.fh-ip-recent-cell.selected{background:#e3f2fd;border-color:#2196f3;color:#1565c0}.fh-ip-grid{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:10px;display:grid;grid-template-columns:repeat(auto-fill,minmax(82px,1fr));gap:6px;align-content:start;scroll-behavior:smooth}.fh-ip-cell{display:flex;flex-direction:column;align-items:center;gap:6px;padding:10px 4px 6px;border:1px solid transparent;border-radius:8px;background:transparent;cursor:pointer;transition:all .12s ease;color:#3a3f45;overflow:hidden}.fh-ip-cell i{font-size:22px}.fh-ip-cell:hover,.fh-ip-cell.highlight{background:#eef6fe;border-color:#bfe0fb}.fh-ip-cell.selected{background:#e3f2fd;border-color:#2196f3;color:#1565c0}.fh-ip-cell.highlight{box-shadow:0 0 0 2px #2196f340}.fh-ip-cell-name{font-size:10px;color:#8a9098;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fh-ip-cell.selected .fh-ip-cell-name{color:#1976d2}.fh-ip-list{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:6px;display:flex;flex-direction:column;scroll-behavior:smooth}.fh-ip-row{display:flex;align-items:center;gap:12px;width:100%;padding:8px 12px;border:1px solid transparent;border-radius:8px;background:transparent;cursor:pointer;transition:all .1s ease;color:#3a3f45;text-align:left}.fh-ip-row-ico{flex:0 0 auto;width:26px;text-align:center;font-size:18px;color:#5b6168}.fh-ip-row-name{flex:1 1 auto;font-family:monospace;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fh-ip-row-check{flex:0 0 auto;color:#2196f3}.fh-ip-row:hover,.fh-ip-row.highlight{background:#eef6fe}.fh-ip-row.selected{background:#e3f2fd;color:#1565c0}.fh-ip-row.selected .fh-ip-row-ico{color:#1565c0}.fh-ip-empty{grid-column:1 / -1;display:flex;flex-direction:column;align-items:center;gap:10px;padding:36px 0;color:#9aa1a9}.fh-ip-empty i{font-size:30px}.fh-ip-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-top:1px solid #eef0f2;font-size:11px;color:#9aa1a9;flex:0 0 auto}.fh-ip-count{font-weight:600}.fh-ip-hint{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fh-ip-hint kbd{background:#f0f1f3;border:1px solid #dcdfe3;border-radius:4px;padding:0 4px;font-family:monospace;font-size:10px;color:#6b7178}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i5$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i3$4.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }] });
15569
+ }
15570
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHIconPickerComponent, decorators: [{
15571
+ type: Component,
15572
+ args: [{ standalone: true, imports: [CommonModule, FormsModule, OverlayModule, TranslateModule], selector: "FHIconPicker", providers: [FH_ICON_PICKER_VALUE_ACCESSOR], template: `
15573
+ <div class="fh-icon-picker" *ngIf="!hidden">
15574
+ <label *ngIf="label" class="fh-ip-label">
15575
+ {{ label | translate }}<span *ngIf="required" class="fh-ip-req"> *</span>
15576
+ </label>
15577
+
15578
+ <div class="fh-ip-trigger-row">
15579
+ <button type="button" class="fh-ip-trigger"
15580
+ [class.disabled]="!enabled"
15581
+ [class.error]="!!error"
15582
+ [class.open]="panelOpen"
15583
+ [disabled]="!enabled"
15584
+ #trigger
15585
+ (click)="togglePanel()">
15586
+ <span class="fh-ip-preview" [class.empty]="!_value">
15587
+ <i *ngIf="_value" [class]="_value"></i>
15588
+ <i *ngIf="!_value" class="fa-regular fa-image fh-ip-placeholder-icon"></i>
15589
+ </span>
15590
+ <span class="fh-ip-text" [class.muted]="!_value">
15591
+ {{ _value ? outValue : (placeholder | translate) }}
15592
+ </span>
15593
+ <i class="fa-solid fa-caret-down fh-ip-caret"></i>
15594
+ </button>
15595
+
15596
+ <button type="button" class="fh-ip-clear" *ngIf="_value && enabled && allowClear"
15597
+ [title]="'ANNULLA' | translate"
15598
+ (click)="clear($event)">
15599
+ <i class="fa-solid fa-xmark"></i>
15600
+ </button>
15601
+ </div>
15602
+
15603
+ <div class="fh-ip-error" *ngIf="error">{{ error | translate }}</div>
15604
+
15605
+ <!-- Popup di selezione (dentro lo stesso scope di #trigger) -->
15606
+ <ng-template
15607
+ cdkConnectedOverlay
15608
+ [cdkConnectedOverlayOrigin]="trigger"
15609
+ [cdkConnectedOverlayOpen]="panelOpen"
15610
+ [cdkConnectedOverlayHasBackdrop]="true"
15611
+ cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
15612
+ [cdkConnectedOverlayPositions]="overlayPositions"
15613
+ (backdropClick)="closePanel()"
15614
+ (detach)="closePanel()">
15615
+
15616
+ <div class="fh-ip-panel" [style.width.px]="panelWidth" (keydown)="onPanelKeydown($event)">
15617
+ <div class="fh-ip-toolbar">
15618
+ <div class="fh-ip-search">
15619
+ <i class="fa-solid fa-magnifying-glass"></i>
15620
+ <input #searchBox type="text" [(ngModel)]="search"
15621
+ (ngModelChange)="applyFilter()"
15622
+ [placeholder]="('CERCA' | translate) + '...'">
15623
+ <i class="fa-solid fa-xmark fh-ip-search-clear" *ngIf="search"
15624
+ (click)="search=''; applyFilter()"></i>
15625
+ </div>
15626
+ <div class="fh-ip-tabs">
15627
+ <button type="button" [class.active]="activeStyle==='all'"
15628
+ (click)="setStyle('all')">{{ 'Tutte' }}</button>
15629
+ <button type="button" [class.active]="activeStyle==='solid'"
15630
+ (click)="setStyle('solid')">{{ 'Solid' }}</button>
15631
+ <button type="button" [class.active]="activeStyle==='brands'"
15632
+ (click)="setStyle('brands')">{{ 'Brands' }}</button>
15633
+ </div>
15634
+ <div class="fh-ip-view">
15635
+ <button type="button" [class.active]="view==='grid'" [title]="'Griglia'"
15636
+ (click)="setView('grid')"><i class="fa-solid fa-table-cells-large"></i></button>
15637
+ <button type="button" [class.active]="view==='list'" [title]="'Elenco'"
15638
+ (click)="setView('list')"><i class="fa-solid fa-list"></i></button>
15639
+ </div>
15640
+ </div>
15641
+
15642
+ <!-- Recenti -->
15643
+ <div class="fh-ip-recent" *ngIf="!search && recent.length">
15644
+ <span class="fh-ip-section-lbl">{{ 'Recenti' }}</span>
15645
+ <div class="fh-ip-recent-row">
15646
+ <button type="button" class="fh-ip-recent-cell"
15647
+ *ngFor="let r of recent"
15648
+ [class.selected]="r === _value"
15649
+ [title]="outOf(r)"
15650
+ (click)="selectIcon(r)">
15651
+ <i [class]="r"></i>
15652
+ </button>
15653
+ </div>
15654
+ </div>
15655
+
15656
+ <!-- GRIGLIA -->
15657
+ <div class="fh-ip-grid" #grid *ngIf="view==='grid'">
15658
+ <button type="button" class="fh-ip-cell" #cell
15659
+ *ngFor="let ic of filtered; let i = index; trackBy: trackByIcon"
15660
+ [class.selected]="ic.cls === _value"
15661
+ [class.highlight]="i === highlightIndex"
15662
+ [title]="'fa-' + ic.name"
15663
+ (mouseenter)="highlightIndex = i"
15664
+ (click)="selectIcon(ic.cls)">
15665
+ <i [class]="ic.cls"></i>
15666
+ <span class="fh-ip-cell-name">fa-{{ ic.name }}</span>
15667
+ </button>
15668
+
15669
+ <div class="fh-ip-empty" *ngIf="filtered.length === 0">
15670
+ <i class="fa-regular fa-face-frown"></i>
15671
+ <span>{{ 'Nessuna icona trovata' }}</span>
15672
+ </div>
15673
+ </div>
15674
+
15675
+ <!-- ELENCO -->
15676
+ <div class="fh-ip-list" #grid *ngIf="view==='list'">
15677
+ <button type="button" class="fh-ip-row" #cell
15678
+ *ngFor="let ic of filtered; let i = index; trackBy: trackByIcon"
15679
+ [class.selected]="ic.cls === _value"
15680
+ [class.highlight]="i === highlightIndex"
15681
+ (mouseenter)="highlightIndex = i"
15682
+ (click)="selectIcon(ic.cls)">
15683
+ <span class="fh-ip-row-ico"><i [class]="ic.cls"></i></span>
15684
+ <span class="fh-ip-row-name">fa-{{ ic.name }}</span>
15685
+ <i class="fa-solid fa-check fh-ip-row-check" *ngIf="ic.cls === _value"></i>
15686
+ </button>
15687
+
15688
+ <div class="fh-ip-empty" *ngIf="filtered.length === 0">
15689
+ <i class="fa-regular fa-face-frown"></i>
15690
+ <span>{{ 'Nessuna icona trovata' }}</span>
15691
+ </div>
15692
+ </div>
15693
+
15694
+ <div class="fh-ip-footer">
15695
+ <span class="fh-ip-count">{{ filtered.length }} {{ 'icone' }}</span>
15696
+ <span class="fh-ip-hint"><kbd>↑↓←→</kbd> {{ 'naviga' }} · <kbd>↵</kbd> {{ 'scegli' }} · <kbd>esc</kbd> {{ 'chiudi' }}</span>
15697
+ </div>
15698
+ </div>
15699
+ </ng-template>
15700
+ </div>
15701
+ `, styles: [":host{display:block}.fh-icon-picker{display:flex;flex-direction:column;gap:4px}.fh-ip-label{font-size:12px;font-weight:600;color:#5b6168}.fh-ip-req{color:#d32f2f}.fh-ip-trigger-row{display:flex;align-items:stretch;gap:6px}.fh-ip-trigger{flex:1 1 auto;display:flex;align-items:center;gap:10px;min-height:40px;padding:6px 12px;cursor:pointer;background:#fff;border:1.5px solid #d7dbe0;border-radius:8px;text-align:left;transition:border-color .15s ease,box-shadow .15s ease;font-size:14px;color:#161212;overflow:hidden}.fh-ip-trigger:hover:not(.disabled){border-color:#9aa1a9}.fh-ip-trigger.open,.fh-ip-trigger:focus-visible{outline:none;border-color:#2196f3;box-shadow:0 0 0 3px #2196f326}.fh-ip-trigger.open .fh-ip-caret{transform:rotate(180deg)}.fh-ip-trigger.disabled{background:#f4f5f6;color:#9aa1a9;cursor:not-allowed;opacity:.8}.fh-ip-trigger.error{border-color:#d32f2f}.fh-ip-preview{flex:0 0 auto;width:28px;height:28px;display:flex;align-items:center;justify-content:center;border-radius:6px;background:#eef2f6;font-size:16px;color:#2196f3}.fh-ip-preview.empty{color:#b6bcc3;background:#f4f5f6}.fh-ip-placeholder-icon{font-size:14px}.fh-ip-text{flex:1 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:monospace;font-size:13px}.fh-ip-text.muted{color:#9aa1a9;font-family:inherit;font-style:italic}.fh-ip-caret{flex:0 0 auto;color:#9aa1a9;font-size:12px;transition:transform .2s ease}.fh-ip-clear{flex:0 0 auto;width:40px;border:1.5px solid #d7dbe0;border-radius:8px;background:#fff;cursor:pointer;color:#6b7178;transition:all .15s ease}.fh-ip-clear:hover{border-color:#d32f2f;color:#d32f2f;background:#fff5f5}.fh-ip-error{font-size:12px;color:#d32f2f}.fh-ip-panel{background:#fff;border:1px solid #e0e3e7;border-radius:12px;box-shadow:0 12px 32px #0000002e;overflow:hidden;display:flex;flex-direction:column;max-height:460px}.fh-ip-toolbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid #eef0f2;flex:0 0 auto;flex-wrap:wrap}.fh-ip-search{flex:1 1 150px;display:flex;align-items:center;gap:8px;background:#f4f5f6;border-radius:8px;padding:6px 10px;color:#6b7178}.fh-ip-search input{flex:1 1 auto;border:none;background:transparent;outline:none;font-size:14px;color:#161212;min-width:0}.fh-ip-search-clear{cursor:pointer}.fh-ip-search-clear:hover{color:#d32f2f}.fh-ip-tabs{display:flex;gap:4px;flex:0 0 auto}.fh-ip-tabs button{border:1px solid #d7dbe0;background:#fff;color:#5b6168;padding:6px 11px;border-radius:8px;cursor:pointer;font-size:12px;font-weight:600;transition:all .15s ease}.fh-ip-tabs button:hover{border-color:#9aa1a9}.fh-ip-tabs button.active{background:#2196f3;border-color:#2196f3;color:#fff}.fh-ip-view{display:flex;gap:2px;flex:0 0 auto}.fh-ip-view button{width:32px;height:32px;border:1px solid #d7dbe0;background:#fff;color:#8a9098;cursor:pointer;border-radius:8px;transition:all .15s ease}.fh-ip-view button:hover{border-color:#9aa1a9;color:#5b6168}.fh-ip-view button.active{background:#eef6fe;border-color:#2196f3;color:#2196f3}.fh-ip-recent{padding:8px 12px 4px;border-bottom:1px dashed #eef0f2;flex:0 0 auto}.fh-ip-section-lbl{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#9aa1a9}.fh-ip-recent-row{display:flex;gap:4px;margin-top:6px;flex-wrap:wrap}.fh-ip-recent-cell{width:34px;height:34px;display:flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:8px;background:#f4f5f6;cursor:pointer;color:#3a3f45;font-size:16px;transition:all .12s ease}.fh-ip-recent-cell:hover{background:#eef6fe;border-color:#bfe0fb}.fh-ip-recent-cell.selected{background:#e3f2fd;border-color:#2196f3;color:#1565c0}.fh-ip-grid{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:10px;display:grid;grid-template-columns:repeat(auto-fill,minmax(82px,1fr));gap:6px;align-content:start;scroll-behavior:smooth}.fh-ip-cell{display:flex;flex-direction:column;align-items:center;gap:6px;padding:10px 4px 6px;border:1px solid transparent;border-radius:8px;background:transparent;cursor:pointer;transition:all .12s ease;color:#3a3f45;overflow:hidden}.fh-ip-cell i{font-size:22px}.fh-ip-cell:hover,.fh-ip-cell.highlight{background:#eef6fe;border-color:#bfe0fb}.fh-ip-cell.selected{background:#e3f2fd;border-color:#2196f3;color:#1565c0}.fh-ip-cell.highlight{box-shadow:0 0 0 2px #2196f340}.fh-ip-cell-name{font-size:10px;color:#8a9098;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fh-ip-cell.selected .fh-ip-cell-name{color:#1976d2}.fh-ip-list{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:6px;display:flex;flex-direction:column;scroll-behavior:smooth}.fh-ip-row{display:flex;align-items:center;gap:12px;width:100%;padding:8px 12px;border:1px solid transparent;border-radius:8px;background:transparent;cursor:pointer;transition:all .1s ease;color:#3a3f45;text-align:left}.fh-ip-row-ico{flex:0 0 auto;width:26px;text-align:center;font-size:18px;color:#5b6168}.fh-ip-row-name{flex:1 1 auto;font-family:monospace;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fh-ip-row-check{flex:0 0 auto;color:#2196f3}.fh-ip-row:hover,.fh-ip-row.highlight{background:#eef6fe}.fh-ip-row.selected{background:#e3f2fd;color:#1565c0}.fh-ip-row.selected .fh-ip-row-ico{color:#1565c0}.fh-ip-empty{grid-column:1 / -1;display:flex;flex-direction:column;align-items:center;gap:10px;padding:36px 0;color:#9aa1a9}.fh-ip-empty i{font-size:30px}.fh-ip-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-top:1px solid #eef0f2;font-size:11px;color:#9aa1a9;flex:0 0 auto}.fh-ip-count{font-weight:600}.fh-ip-hint{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fh-ip-hint kbd{background:#f0f1f3;border:1px solid #dcdfe3;border-radius:4px;padding:0 4px;font-family:monospace;font-size:10px;color:#6b7178}\n"] }]
15702
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { label: [{
15703
+ type: Input
15704
+ }], placeholder: [{
15705
+ type: Input
15706
+ }], enabled: [{
15707
+ type: Input
15708
+ }], hidden: [{
15709
+ type: Input
15710
+ }], required: [{
15711
+ type: Input
15712
+ }], error: [{
15713
+ type: Input
15714
+ }], allowClear: [{
15715
+ type: Input
15716
+ }], defaultStyle: [{
15717
+ type: Input
15718
+ }], defaultView: [{
15719
+ type: Input
15720
+ }], valueFormat: [{
15721
+ type: Input
15722
+ }], recentCount: [{
15723
+ type: Input
15724
+ }], change: [{
15725
+ type: Output
15726
+ }], iconChange: [{
15727
+ type: Output
15728
+ }], searchBox: [{
15729
+ type: ViewChild,
15730
+ args: ['searchBox']
15731
+ }], triggerRef: [{
15732
+ type: ViewChild,
15733
+ args: ['trigger', { read: ElementRef }]
15734
+ }], gridRef: [{
15735
+ type: ViewChild,
15736
+ args: ['grid']
15737
+ }], cells: [{
15738
+ type: ViewChildren,
15739
+ args: ['cell']
15740
+ }] } });
15741
+
14995
15742
  class WkfService {
14996
15743
  http;
14997
15744
  app_s;
@@ -35481,6 +36228,831 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
35481
36228
  /** Estensioni con icona dedicata (set "square-o"). */
35482
36229
  const KNOWN_EXT = "3G2|3GA|3GP|7Z|AA|AAC|AC|ACCDB|ACCDT|ADN|AI|AIF|AIFC|AIFF|AIT|AMR|ANI|APK|APP|APPLESCRIPT|ASAX|ASC|ASCX|ASF|ASH|ASHX|ASMX|ASP|ASPX|ASX|AU|AUP|AVI|AXD|AZE|BAK|BASH|BAT|BIN|BLANK|BMP|BOWERRC|BPG|BROWSER|BZ2|C|CAB|CAD|CAF|CAL|CD|CER|CFG|CFM|CFML|CGI|CLASS|CMD|CODEKIT|COFFEE|COFFEELINTIGNORE|COM|COMPILE|CONF|CONFIG|CPP|CPTX|CR2|CRDOWNLOAD|CRT|CRYPT|CS|CSH|CSON|CSPROJ|CSS|CSV|CUE|DAT|DB|DBF|DEB|DGN|DIST|DIZ|DLL|DMG|DNG|DOC|DOCB|DOCM|DOCX|DOT|DOTM|DOTX|DOWNLOAD|DPJ|DS_STORE|DTD|DWG|DXF|EDITORCONFIG|EL|ENC|EOT|EPS|EPUB|ESLINTIGNORE|EXE|F4V|FAX|FB2|FLA|FLAC|FLV|FOLDER|GADGET|GDP|GEM|GIF|GITATTRIBUTES|GITIGNORE|GO|GPG|GZ|H|HANDLEBARS|HBS|HEIC|HS|HSL|HTM|HTML|IBOOKS|ICNS|ICO|ICS|IDX|IFF|IFO|IMAGE|IMG|IN|INDD|INF|INI|ISO|J2|JAR|JAVA|JPE|JPEG|JPG|JS|JSON|JSP|JSX|KEY|KF8|KMK|KSH|KUP|LESS|LEX|LICX|LISP|LIT|LNK|LOCK|LOG|LUA|M|M2V|M3U|M3U8|M4|M4A|M4R|M4V|MAP|MASTER|MC|MD|MDB|MDF|ME|MI|MID|MIDI|MK|MKV|MM|MO|MOBI|MOD|MOV|MP2|MP3|MP4|MPA|MPD|MPE|MPEG|MPG|MPGA|MPP|MPT|MSI|MSU|NEF|NES|NFO|NIX|NPMIGNORE|ODB|ODS|ODT|OGG|OGV|OST|OTF|OTT|OVA|OVF|P12|P7B|PAGES|PART|PCD|PDB|PDF|PEM|PFX|PGP|PH|PHAR|PHP|PKG|PL|PLIST|PM|PNG|PO|POM|POT|POTX|PPS|PPSX|PPT|PPTM|PPTX|PROP|PS|PS1|PSD|PSP|PST|PUB|PY|PYC|QT|RA|RAM|RAR|RAW|RB|RDF|RESX|RETRY|RM|ROM|RPM|RSA|RSS|RTF|RU|RUB|SASS|SCSS|SDF|SED|SH|SITEMAP|SKIN|SLDM|SLDX|SLN|SOL|SQL|SQLITE|STEP|STL|SVG|SWD|SWF|SWIFT|SYS|TAR|TCSH|TEX|TFIGNORE|TGA|TGZ|TIF|TIFF|TMP|TORRENT|TS|TSV|TTF|TWIG|TXT|UDF|VB|VBPROJ|VBS|VCD|VCS|VDI|VDX|VMDK|VOB|VSCODEIGNORE|VSD|VSS|VST|VSX|VTX|WAR|WAV|WBK|WEBINFO|WEBM|WEBP|WMA|WMF|WMV|WOFF|WOFF2|WPS|WSF|XAML|XCF|XLM|XLS|XLSM|XLSX|XLT|XLTM|XLTX|XML|XPI|XPS|XRB|XSD|XSL|XSPF|XZ|YAML|YML|Z|ZIP|ZSH";
35483
36230
 
36231
+ /**
36232
+ * Client del layer AI di FluxHub.
36233
+ *
36234
+ * Parla con un backend OpenAI-compatible (/v1/chat/completions o una route FluxHub
36235
+ * che fa da proxy verso il Cheshire Cat / Gemma). Supporta streaming SSE e risposta
36236
+ * singola. L'identita' utente viene inoltrata col JWT FluxHub: scoping e retrieval
36237
+ * sono enforced server-side (vedi architettura, sez. 10-11).
36238
+ *
36239
+ * Usa fetch() invece di HttpClient per gestire nativamente lo streaming SSE e per
36240
+ * avere pieno controllo sugli header (la chiamata AI puo' usare una chiave dedicata).
36241
+ */
36242
+ class FHAiService {
36243
+ appService;
36244
+ /** Path di default (relativo ad API_ENDPOINT) della route AI sul backend FluxHub. */
36245
+ defaultPath = "ai/chat";
36246
+ constructor(appService) {
36247
+ this.appService = appService;
36248
+ }
36249
+ /** Costruisce l'URL effettivo dell'endpoint. */
36250
+ resolveUrl(opts) {
36251
+ if (opts?.endpoint)
36252
+ return opts.endpoint;
36253
+ const base = this.appService.API_ENDPOINT || "";
36254
+ const path = opts?.path ?? this.defaultPath;
36255
+ return base + path;
36256
+ }
36257
+ /** Costruisce gli header (Content-Type, JWT FluxHub, API key AI, custom). */
36258
+ buildHeaders(opts) {
36259
+ const headers = { "Content-Type": "application/json" };
36260
+ if (opts?.forwardAuth !== false) {
36261
+ const token = localStorage.getItem(this.appService.COMPANY_KEY + "token");
36262
+ if (token && token !== "ZZ")
36263
+ headers["Authorization"] = `Bearer ${token}`;
36264
+ }
36265
+ if (opts?.apiKey)
36266
+ headers["x-api-key"] = opts.apiKey;
36267
+ if (opts?.headers)
36268
+ Object.assign(headers, opts.headers);
36269
+ return headers;
36270
+ }
36271
+ /** Corpo della richiesta (OpenAI-compatible). */
36272
+ buildBody(messages, stream, opts) {
36273
+ const body = {
36274
+ messages: messages
36275
+ .filter((m) => !m.loading)
36276
+ .map((m) => ({ role: m.role, content: m.content })),
36277
+ stream,
36278
+ };
36279
+ if (opts?.model)
36280
+ body.model = opts.model;
36281
+ // Contesto di scoping: inviato come metadata (il backend lo valida vs identita').
36282
+ if (opts?.context)
36283
+ body.metadata = { ...opts.context };
36284
+ return JSON.stringify(body);
36285
+ }
36286
+ /**
36287
+ * Conversazione in streaming. Emette un FHAiChunk per ogni delta di testo;
36288
+ * l'ultimo ha done=true ed eventuali sources.
36289
+ */
36290
+ chatStream(messages, opts) {
36291
+ const url = this.resolveUrl(opts);
36292
+ const headers = this.buildHeaders(opts);
36293
+ const body = this.buildBody(messages, true, opts);
36294
+ return new Observable((observer) => {
36295
+ const controller = new AbortController();
36296
+ let text = "";
36297
+ fetch(url, { method: "POST", headers, body, signal: controller.signal })
36298
+ .then(async (resp) => {
36299
+ if (!resp.ok || !resp.body) {
36300
+ throw new Error(`AI endpoint ${resp.status} ${resp.statusText}`);
36301
+ }
36302
+ const reader = resp.body.getReader();
36303
+ const decoder = new TextDecoder();
36304
+ let buffer = "";
36305
+ // eslint-disable-next-line no-constant-condition
36306
+ while (true) {
36307
+ const { done, value } = await reader.read();
36308
+ if (done)
36309
+ break;
36310
+ buffer += decoder.decode(value, { stream: true });
36311
+ // Le SSE sono separate da newline; ogni evento e' una riga "data: ..."
36312
+ const lines = buffer.split("\n");
36313
+ buffer = lines.pop() ?? "";
36314
+ for (const raw of lines) {
36315
+ const line = raw.trim();
36316
+ if (!line || !line.startsWith("data:"))
36317
+ continue;
36318
+ const payload = line.slice(5).trim();
36319
+ if (payload === "[DONE]") {
36320
+ observer.next({ delta: "", text, done: true });
36321
+ observer.complete();
36322
+ return;
36323
+ }
36324
+ const delta = this.extractDelta(payload);
36325
+ if (delta) {
36326
+ text += delta;
36327
+ observer.next({ delta, text, done: false });
36328
+ }
36329
+ }
36330
+ }
36331
+ // Stream chiuso senza [DONE]
36332
+ observer.next({ delta: "", text, done: true });
36333
+ observer.complete();
36334
+ })
36335
+ .catch((err) => {
36336
+ if (controller.signal.aborted)
36337
+ return;
36338
+ observer.error(err);
36339
+ });
36340
+ return () => controller.abort();
36341
+ });
36342
+ }
36343
+ /**
36344
+ * Conversazione non-streaming: risolve con il testo completo e le sorgenti.
36345
+ */
36346
+ chatOnce(messages, opts) {
36347
+ const url = this.resolveUrl(opts);
36348
+ const headers = this.buildHeaders(opts);
36349
+ const body = this.buildBody(messages, false, opts);
36350
+ return new Observable((observer) => {
36351
+ const controller = new AbortController();
36352
+ fetch(url, { method: "POST", headers, body, signal: controller.signal })
36353
+ .then(async (resp) => {
36354
+ if (!resp.ok)
36355
+ throw new Error(`AI endpoint ${resp.status} ${resp.statusText}`);
36356
+ const data = await resp.json();
36357
+ observer.next({
36358
+ content: this.extractContent(data),
36359
+ sources: this.extractSources(data),
36360
+ });
36361
+ observer.complete();
36362
+ })
36363
+ .catch((err) => {
36364
+ if (controller.signal.aborted)
36365
+ return;
36366
+ observer.error(err);
36367
+ });
36368
+ return () => controller.abort();
36369
+ });
36370
+ }
36371
+ // ---- Parsing flessibile (OpenAI / Cheshire Cat / shape semplice) ----
36372
+ /** Estrae il delta di testo da un evento SSE (OpenAI: choices[].delta.content). */
36373
+ extractDelta(payload) {
36374
+ try {
36375
+ const json = JSON.parse(payload);
36376
+ return (json?.choices?.[0]?.delta?.content ??
36377
+ json?.choices?.[0]?.text ??
36378
+ json?.delta ??
36379
+ json?.content ??
36380
+ "");
36381
+ }
36382
+ catch {
36383
+ // Backend che streamma testo grezzo riga per riga
36384
+ return payload;
36385
+ }
36386
+ }
36387
+ /** Estrae il testo completo dalla risposta non-streaming. */
36388
+ extractContent(data) {
36389
+ return (data?.choices?.[0]?.message?.content ??
36390
+ data?.choices?.[0]?.text ??
36391
+ data?.content ??
36392
+ data?.text ??
36393
+ data?.message ??
36394
+ "");
36395
+ }
36396
+ /** Estrae le sorgenti RAG (Cheshire Cat: why.memory.declarative; o sources/citations). */
36397
+ extractSources(data) {
36398
+ const declarative = data?.why?.memory?.declarative;
36399
+ if (Array.isArray(declarative) && declarative.length) {
36400
+ return declarative.map((d) => ({
36401
+ title: d?.metadata?.source ?? d?.metadata?.title ?? "Documento",
36402
+ snippet: d?.page_content ?? d?.content,
36403
+ score: d?.score,
36404
+ }));
36405
+ }
36406
+ const raw = data?.sources ?? data?.citations;
36407
+ if (Array.isArray(raw) && raw.length) {
36408
+ return raw.map((s) => ({
36409
+ title: s?.title ?? s?.source ?? "Documento",
36410
+ snippet: s?.snippet ?? s?.content,
36411
+ score: s?.score,
36412
+ url: s?.url,
36413
+ }));
36414
+ }
36415
+ return undefined;
36416
+ }
36417
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiService, deps: [{ token: AppService }], target: i0.ɵɵFactoryTarget.Injectable });
36418
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiService, providedIn: "root" });
36419
+ }
36420
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiService, decorators: [{
36421
+ type: Injectable,
36422
+ args: [{ providedIn: "root" }]
36423
+ }], ctorParameters: () => [{ type: AppService }] });
36424
+
36425
+ /**
36426
+ * Pannello chat AI riusabile di FluxHub.
36427
+ *
36428
+ * Conversazione con un backend OpenAI-compatible (proxy Prologika -> Cheshire Cat ->
36429
+ * Gemma) via FHAiService. Renderizza testo markdown, citazioni RAG, ha schermata di
36430
+ * benvenuto con suggerimenti e supporta streaming token-by-token.
36431
+ *
36432
+ * Tutto configurabile via @Input (endpoint, contesto azienda/ruolo, testi, tema) per
36433
+ * riuso cross-cliente, in linea con gli altri componenti standard della libreria.
36434
+ *
36435
+ * Esempio:
36436
+ * <FHAiChat [context]="{azienda:'Bormioli', ruolo:'sales'}"
36437
+ * [accent]="'#16afc7'"
36438
+ * welcomeTitle="Assistente Bormioli"></FHAiChat>
36439
+ */
36440
+ class FHAiChatComponent {
36441
+ ai;
36442
+ sanitizer;
36443
+ // ---- Tema ----
36444
+ accent = "#16afc7";
36445
+ accentDark = "#0e8ba0";
36446
+ get _a() { return this.accent; }
36447
+ get _ad() { return this.accentDark; }
36448
+ // ---- Header / testi ----
36449
+ showHeader = true;
36450
+ title = "Assistente AI";
36451
+ subtitle = "";
36452
+ tagLabel = "";
36453
+ welcomeTitle = "Come posso aiutarti?";
36454
+ welcomeSubtitle = "Fammi una domanda sui tuoi dati.";
36455
+ suggestions = [];
36456
+ placeholder = "Scrivi un messaggio...";
36457
+ showHint = true;
36458
+ // ---- Backend ----
36459
+ /** URL completo dell'endpoint AI. Se vuoto: AppService.API_ENDPOINT + path. */
36460
+ endpoint = "";
36461
+ /** Path relativo all'API_ENDPOINT (default route AI sul backend FluxHub). */
36462
+ path = "ai/chat";
36463
+ /** Modello da richiedere (di norma deciso lato server). */
36464
+ model = "";
36465
+ /** Abilita lo streaming token-by-token (SSE). */
36466
+ stream = true;
36467
+ /** API key del servizio AI (di norma NON serve lato browser). */
36468
+ apiKey = "";
36469
+ /** Inoltra il JWT FluxHub come Authorization Bearer. */
36470
+ forwardAuth = true;
36471
+ /** Contesto di scoping {azienda, ruolo, persona} (informativo + metadata). */
36472
+ context = null;
36473
+ /** Messaggio di sistema iniziale opzionale (di norma lo costruisce il backend). */
36474
+ systemPrompt = "";
36475
+ // ---- Output ----
36476
+ messageSent = new EventEmitter();
36477
+ responseReceived = new EventEmitter();
36478
+ errored = new EventEmitter();
36479
+ scroller;
36480
+ messages = [];
36481
+ userInput = "";
36482
+ busy = false;
36483
+ errorMsg = "";
36484
+ sub;
36485
+ constructor(ai, sanitizer) {
36486
+ this.ai = ai;
36487
+ this.sanitizer = sanitizer;
36488
+ }
36489
+ ngOnDestroy() {
36490
+ this.sub?.unsubscribe();
36491
+ }
36492
+ onKeyDown(ev) {
36493
+ if (ev.key === "Enter" && !ev.shiftKey) {
36494
+ ev.preventDefault();
36495
+ this.send();
36496
+ }
36497
+ }
36498
+ autoGrow(ta) {
36499
+ ta.style.height = "auto";
36500
+ ta.style.height = Math.min(ta.scrollHeight, 140) + "px";
36501
+ }
36502
+ sendSuggestion(text) {
36503
+ this.userInput = text;
36504
+ this.send();
36505
+ }
36506
+ send() {
36507
+ const text = this.userInput.trim();
36508
+ if (!text || this.busy)
36509
+ return;
36510
+ this.errorMsg = "";
36511
+ this.userInput = "";
36512
+ this.messageSent.emit(text);
36513
+ this.messages.push({ role: "user", content: text, ts: Date.now() });
36514
+ const botMsg = { role: "assistant", content: "", loading: true, ts: Date.now() };
36515
+ this.messages.push(botMsg);
36516
+ this.busy = true;
36517
+ this.scrollSoon();
36518
+ // Messaggi inviati: system (se presente) + storico (senza i placeholder)
36519
+ const payload = [];
36520
+ if (this.systemPrompt)
36521
+ payload.push({ role: "system", content: this.systemPrompt });
36522
+ payload.push(...this.messages.filter((m) => !m.loading));
36523
+ const opts = {
36524
+ endpoint: this.endpoint || undefined,
36525
+ path: this.path,
36526
+ model: this.model || undefined,
36527
+ stream: this.stream,
36528
+ apiKey: this.apiKey || undefined,
36529
+ forwardAuth: this.forwardAuth,
36530
+ context: this.context || undefined,
36531
+ };
36532
+ if (this.stream) {
36533
+ this.sub = this.ai.chatStream(payload, opts).subscribe({
36534
+ next: (chunk) => {
36535
+ botMsg.content = chunk.text;
36536
+ botMsg.loading = !chunk.done;
36537
+ if (chunk.sources)
36538
+ botMsg.sources = chunk.sources;
36539
+ this.scrollSoon();
36540
+ },
36541
+ error: (err) => this.fail(botMsg, err),
36542
+ complete: () => this.finish(botMsg),
36543
+ });
36544
+ }
36545
+ else {
36546
+ this.sub = this.ai.chatOnce(payload, opts).subscribe({
36547
+ next: (res) => {
36548
+ botMsg.content = res.content;
36549
+ botMsg.sources = res.sources;
36550
+ },
36551
+ error: (err) => this.fail(botMsg, err),
36552
+ complete: () => this.finish(botMsg),
36553
+ });
36554
+ }
36555
+ }
36556
+ stop() {
36557
+ this.sub?.unsubscribe();
36558
+ const last = this.messages[this.messages.length - 1];
36559
+ if (last && last.role === "assistant") {
36560
+ last.loading = false;
36561
+ if (!last.content)
36562
+ last.content = "_(interrotto)_";
36563
+ }
36564
+ this.busy = false;
36565
+ }
36566
+ clear() {
36567
+ this.sub?.unsubscribe();
36568
+ this.messages = [];
36569
+ this.busy = false;
36570
+ this.errorMsg = "";
36571
+ }
36572
+ finish(botMsg) {
36573
+ botMsg.loading = false;
36574
+ this.busy = false;
36575
+ this.responseReceived.emit(botMsg);
36576
+ this.scrollSoon();
36577
+ }
36578
+ fail(botMsg, err) {
36579
+ const msg = err?.message || "Errore di comunicazione con il servizio AI.";
36580
+ botMsg.loading = false;
36581
+ if (!botMsg.content) {
36582
+ // rimuovo il placeholder vuoto, mostro l'errore nella barra
36583
+ this.messages = this.messages.filter((m) => m !== botMsg);
36584
+ }
36585
+ this.errorMsg = msg;
36586
+ this.busy = false;
36587
+ this.errored.emit(msg);
36588
+ }
36589
+ scrollSoon() {
36590
+ setTimeout(() => {
36591
+ const el = this.scroller?.nativeElement;
36592
+ if (el)
36593
+ el.scrollTop = el.scrollHeight;
36594
+ }, 30);
36595
+ }
36596
+ /** Rende il markdown (sottoinsieme) in HTML sicuro: escape -> formattazione. */
36597
+ render(content) {
36598
+ return this.sanitizer.bypassSecurityTrustHtml(formatMarkdown(content));
36599
+ }
36600
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiChatComponent, deps: [{ token: FHAiService }, { token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
36601
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.17", type: FHAiChatComponent, isStandalone: true, selector: "FHAiChat", inputs: { accent: "accent", accentDark: "accentDark", showHeader: "showHeader", title: "title", subtitle: "subtitle", tagLabel: "tagLabel", welcomeTitle: "welcomeTitle", welcomeSubtitle: "welcomeSubtitle", suggestions: "suggestions", placeholder: "placeholder", showHint: "showHint", endpoint: "endpoint", path: "path", model: "model", stream: "stream", apiKey: "apiKey", forwardAuth: "forwardAuth", context: "context", systemPrompt: "systemPrompt" }, outputs: { messageSent: "messageSent", responseReceived: "responseReceived", errored: "errored" }, host: { properties: { "style.--fh-ai-accent": "this._a", "style.--fh-ai-accent-dark": "this._ad" } }, viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true }], ngImport: i0, template: `
36602
+ <div class="ai-chat">
36603
+ <!-- Header -->
36604
+ <div class="ai-head" *ngIf="showHeader">
36605
+ <div class="ai-head-left">
36606
+ <i class="material-symbols-outlined ai-head-icon">smart_toy</i>
36607
+ <div>
36608
+ <div class="ai-head-title">{{ title }}</div>
36609
+ <div class="ai-head-sub" *ngIf="subtitle">{{ subtitle }}</div>
36610
+ </div>
36611
+ </div>
36612
+ <div class="ai-head-right">
36613
+ <span class="ai-tag" *ngIf="tagLabel">{{ tagLabel }}</span>
36614
+ <button type="button" class="ai-icon-btn" *ngIf="messages.length > 0"
36615
+ title="Nuova conversazione" (click)="clear()">
36616
+ <i class="material-symbols-outlined">add</i>
36617
+ </button>
36618
+ </div>
36619
+ </div>
36620
+
36621
+ <!-- Messaggi -->
36622
+ <div class="ai-messages" #scroller>
36623
+ <!-- Welcome -->
36624
+ <div class="ai-welcome" *ngIf="messages.length === 0">
36625
+ <i class="material-symbols-outlined ai-welcome-icon">smart_toy</i>
36626
+ <div class="ai-welcome-title">{{ welcomeTitle }}</div>
36627
+ <div class="ai-welcome-sub">{{ welcomeSubtitle }}</div>
36628
+ <div class="ai-suggestions" *ngIf="suggestions?.length">
36629
+ <button type="button" class="ai-suggestion" *ngFor="let s of suggestions"
36630
+ (click)="sendSuggestion(s)">{{ s }}</button>
36631
+ </div>
36632
+ </div>
36633
+
36634
+ <div class="ai-msg" *ngFor="let m of messages"
36635
+ [class.ai-msg-user]="m.role === 'user'"
36636
+ [class.ai-msg-bot]="m.role === 'assistant'">
36637
+ <div class="ai-avatar">
36638
+ <i class="material-symbols-outlined">{{ m.role === 'user' ? 'person' : 'smart_toy' }}</i>
36639
+ </div>
36640
+ <div class="ai-bubble">
36641
+ <div class="ai-typing" *ngIf="m.loading && !m.content">
36642
+ <span></span><span></span><span></span>
36643
+ </div>
36644
+ <div class="ai-text" *ngIf="m.content" [innerHTML]="render(m.content)"></div>
36645
+
36646
+ <!-- Sorgenti RAG -->
36647
+ <div class="ai-sources" *ngIf="m.sources?.length">
36648
+ <div class="ai-sources-head">
36649
+ <i class="material-symbols-outlined">menu_book</i> Fonti
36650
+ </div>
36651
+ <div class="ai-source" *ngFor="let src of m.sources"
36652
+ [title]="src.snippet || ''">
36653
+ <i class="material-symbols-outlined">description</i>
36654
+ <span class="ai-source-title">{{ src.title }}</span>
36655
+ <span class="ai-source-score" *ngIf="src.score != null">{{ (src.score * 100) | number:'1.0-0' }}%</span>
36656
+ </div>
36657
+ </div>
36658
+ </div>
36659
+ </div>
36660
+ </div>
36661
+
36662
+ <!-- Errore -->
36663
+ <div class="ai-error" *ngIf="errorMsg">{{ errorMsg }}</div>
36664
+
36665
+ <!-- Input -->
36666
+ <div class="ai-input-area">
36667
+ <div class="ai-input-box" [class.focused]="false">
36668
+ <textarea #ta class="ai-input" rows="1"
36669
+ [(ngModel)]="userInput"
36670
+ [disabled]="busy"
36671
+ [placeholder]="placeholder"
36672
+ (keydown)="onKeyDown($event)"
36673
+ (input)="autoGrow(ta)"></textarea>
36674
+ <button type="button" class="ai-send" *ngIf="!busy"
36675
+ [disabled]="!userInput.trim()" (click)="send()" title="Invia">
36676
+ <i class="material-symbols-outlined">send</i>
36677
+ </button>
36678
+ <button type="button" class="ai-send ai-stop" *ngIf="busy" (click)="stop()" title="Interrompi">
36679
+ <i class="material-symbols-outlined">stop</i>
36680
+ </button>
36681
+ </div>
36682
+ <div class="ai-hint" *ngIf="showHint">Invio per inviare · Shift+Invio per andare a capo</div>
36683
+ </div>
36684
+ </div>
36685
+ `, isInline: true, styles: [":host{display:block;height:100%}.ai-chat{height:100%;box-sizing:border-box;display:flex;flex-direction:column;background:#fff;border:1px solid rgba(22,18,18,.1);border-radius:10px;overflow:hidden}.ai-head{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-top:3px solid var(--fh-ai-accent, #16afc7);border-bottom:1px solid rgba(22,18,18,.07)}.ai-head-left{display:flex;align-items:center;gap:10px}.ai-head-icon{font-size:22px;color:var(--fh-ai-accent, #16afc7)}.ai-head-title{font-family:Plus Jakarta Sans,sans-serif;font-size:14px;font-weight:800;color:#161212}.ai-head-sub{font-family:Inter,sans-serif;font-size:11px;color:#8c8585;margin-top:1px}.ai-head-right{display:flex;align-items:center;gap:8px}.ai-tag{display:inline-block;padding:3px 10px;border-radius:999px;font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.03em;background:#1612120f;color:#443d3d}.ai-icon-btn{display:flex;border:1px solid rgba(22,18,18,.12);background:transparent;border-radius:8px;width:30px;height:30px;align-items:center;justify-content:center;cursor:pointer;color:#5c5454}.ai-icon-btn:hover{background:#1612120d}.ai-icon-btn i{font-size:18px}.ai-messages{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:18px;display:flex;flex-direction:column;gap:14px;background:#f8fafc}.ai-welcome{margin:auto;display:flex;flex-direction:column;align-items:center;text-align:center;padding:20px;gap:6px}.ai-welcome-icon{font-size:40px;color:var(--fh-ai-accent, #16afc7)}.ai-welcome-title{font-family:Plus Jakarta Sans,sans-serif;font-size:16px;font-weight:700;color:#161212}.ai-welcome-sub{font-family:Inter,sans-serif;font-size:13px;color:#6b6363;margin-bottom:8px}.ai-suggestions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;max-width:560px}.ai-suggestion{padding:9px 14px;background:#fff;color:#443d3d;border:1px solid rgba(22,18,18,.12);border-radius:999px;font-family:Inter,sans-serif;font-size:12.5px;cursor:pointer;transition:all .15s ease}.ai-suggestion:hover{border-color:var(--fh-ai-accent, #16afc7);color:var(--fh-ai-accent-dark, #0e8ba0);background:#16afc70f}.ai-msg{display:flex;gap:10px;max-width:88%}.ai-msg-user{align-self:flex-end;flex-direction:row-reverse}.ai-msg-bot{align-self:flex-start}.ai-avatar{flex:0 0 auto;width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center}.ai-msg-user .ai-avatar{background:var(--fh-ai-accent, #16afc7);color:#fff}.ai-msg-bot .ai-avatar{background:#fff;color:var(--fh-ai-accent, #16afc7);border:1px solid rgba(22,175,199,.35)}.ai-avatar i{font-size:18px}.ai-bubble{padding:10px 14px;border-radius:12px;font-family:Inter,sans-serif;font-size:13.5px;line-height:1.6}.ai-msg-user .ai-bubble{background:var(--fh-ai-accent, #16afc7);color:#fff;border-bottom-right-radius:4px}.ai-msg-bot .ai-bubble{background:#fff;color:#1e293b;border:1px solid rgba(22,18,18,.1);border-bottom-left-radius:4px}.ai-text{word-wrap:break-word}.ai-text ::ng-deep p{margin:0 0 8px}.ai-text ::ng-deep p:last-child{margin-bottom:0}.ai-text ::ng-deep ul,.ai-text ::ng-deep ol{margin:4px 0 8px;padding-left:20px}.ai-text ::ng-deep li{margin-bottom:3px}.ai-text ::ng-deep code{background:#1612120f;padding:1px 5px;border-radius:4px;font-family:Cascadia Code,Fira Code,monospace;font-size:.85em}.ai-text ::ng-deep pre{background:#1e293b;color:#7dd3fc;padding:10px 12px;border-radius:8px;overflow-x:auto;margin:6px 0}.ai-text ::ng-deep pre code{background:transparent;padding:0;color:inherit}.ai-text ::ng-deep strong{font-weight:700}.ai-text ::ng-deep a{color:var(--fh-ai-accent-dark, #0e8ba0);text-decoration:underline}.ai-msg-user .ai-text ::ng-deep a{color:#fff}.ai-text ::ng-deep table{border-collapse:collapse;width:100%;margin:6px 0;font-size:.92em}.ai-text ::ng-deep th,.ai-text ::ng-deep td{border:1px solid rgba(22,18,18,.12);padding:5px 8px;text-align:left}.ai-text ::ng-deep th{background:#1612120a;font-weight:600}.ai-sources{margin-top:10px;border-top:1px dashed rgba(22,18,18,.12);padding-top:8px}.ai-sources-head{display:flex;align-items:center;gap:5px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:#8c8585;margin-bottom:5px}.ai-sources-head i{font-size:14px}.ai-source{display:flex;align-items:center;gap:6px;font-size:12px;color:#5c5454;padding:2px 0}.ai-source i{font-size:15px;color:var(--fh-ai-accent, #16afc7);flex:0 0 auto}.ai-source-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-source-score{flex:0 0 auto;font-size:11px;font-weight:600;color:#a39b9b}.ai-typing{display:flex;gap:4px;padding:3px 0}.ai-typing span{width:7px;height:7px;border-radius:50%;background:#b9c2cc;animation:ai-typing 1.4s infinite}.ai-typing span:nth-child(2){animation-delay:.2s}.ai-typing span:nth-child(3){animation-delay:.4s}@keyframes ai-typing{0%,60%,to{transform:translateY(0);opacity:.4}30%{transform:translateY(-5px);opacity:1}}.ai-error{flex:0 0 auto;margin:0 18px;padding:8px 12px;background:#fef2f2;border:1px solid #fecaca;color:#dc2626;border-radius:8px;font-size:12.5px}.ai-input-area{flex:0 0 auto;padding:14px 16px;border-top:1px solid rgba(22,18,18,.07);background:#fff}.ai-input-box{display:flex;align-items:flex-end;gap:8px;background:#f1f5f9;border:1px solid rgba(22,18,18,.12);border-radius:12px;padding:4px;transition:border-color .15s ease,box-shadow .15s ease}.ai-input-box:focus-within{border-color:var(--fh-ai-accent, #16afc7);box-shadow:0 0 0 3px #16afc71f}.ai-input{flex:1 1 auto;background:transparent;border:none;outline:none;resize:none;font-family:Inter,sans-serif;font-size:13.5px;color:#1e293b;padding:9px 10px;max-height:140px;min-height:22px}.ai-input::placeholder{color:#a39b9b}.ai-send{flex:0 0 auto;width:38px;height:38px;display:flex;align-items:center;justify-content:center;border:none;border-radius:8px;cursor:pointer;color:#fff;background:linear-gradient(135deg,var(--fh-ai-accent, #16afc7) 0%,var(--fh-ai-accent-dark, #0e8ba0) 130%);transition:filter .15s ease}.ai-send:hover:not(:disabled){filter:brightness(1.07)}.ai-send:disabled{background:#cbd5e1;cursor:not-allowed}.ai-send i{font-size:19px}.ai-stop{background:#64748b}.ai-hint{text-align:center;font-size:10.5px;color:#a39b9b;margin-top:6px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i5.DecimalPipe, name: "number" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i5$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
36686
+ }
36687
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiChatComponent, decorators: [{
36688
+ type: Component,
36689
+ args: [{ selector: "FHAiChat", standalone: true, imports: [CommonModule, FormsModule], template: `
36690
+ <div class="ai-chat">
36691
+ <!-- Header -->
36692
+ <div class="ai-head" *ngIf="showHeader">
36693
+ <div class="ai-head-left">
36694
+ <i class="material-symbols-outlined ai-head-icon">smart_toy</i>
36695
+ <div>
36696
+ <div class="ai-head-title">{{ title }}</div>
36697
+ <div class="ai-head-sub" *ngIf="subtitle">{{ subtitle }}</div>
36698
+ </div>
36699
+ </div>
36700
+ <div class="ai-head-right">
36701
+ <span class="ai-tag" *ngIf="tagLabel">{{ tagLabel }}</span>
36702
+ <button type="button" class="ai-icon-btn" *ngIf="messages.length > 0"
36703
+ title="Nuova conversazione" (click)="clear()">
36704
+ <i class="material-symbols-outlined">add</i>
36705
+ </button>
36706
+ </div>
36707
+ </div>
36708
+
36709
+ <!-- Messaggi -->
36710
+ <div class="ai-messages" #scroller>
36711
+ <!-- Welcome -->
36712
+ <div class="ai-welcome" *ngIf="messages.length === 0">
36713
+ <i class="material-symbols-outlined ai-welcome-icon">smart_toy</i>
36714
+ <div class="ai-welcome-title">{{ welcomeTitle }}</div>
36715
+ <div class="ai-welcome-sub">{{ welcomeSubtitle }}</div>
36716
+ <div class="ai-suggestions" *ngIf="suggestions?.length">
36717
+ <button type="button" class="ai-suggestion" *ngFor="let s of suggestions"
36718
+ (click)="sendSuggestion(s)">{{ s }}</button>
36719
+ </div>
36720
+ </div>
36721
+
36722
+ <div class="ai-msg" *ngFor="let m of messages"
36723
+ [class.ai-msg-user]="m.role === 'user'"
36724
+ [class.ai-msg-bot]="m.role === 'assistant'">
36725
+ <div class="ai-avatar">
36726
+ <i class="material-symbols-outlined">{{ m.role === 'user' ? 'person' : 'smart_toy' }}</i>
36727
+ </div>
36728
+ <div class="ai-bubble">
36729
+ <div class="ai-typing" *ngIf="m.loading && !m.content">
36730
+ <span></span><span></span><span></span>
36731
+ </div>
36732
+ <div class="ai-text" *ngIf="m.content" [innerHTML]="render(m.content)"></div>
36733
+
36734
+ <!-- Sorgenti RAG -->
36735
+ <div class="ai-sources" *ngIf="m.sources?.length">
36736
+ <div class="ai-sources-head">
36737
+ <i class="material-symbols-outlined">menu_book</i> Fonti
36738
+ </div>
36739
+ <div class="ai-source" *ngFor="let src of m.sources"
36740
+ [title]="src.snippet || ''">
36741
+ <i class="material-symbols-outlined">description</i>
36742
+ <span class="ai-source-title">{{ src.title }}</span>
36743
+ <span class="ai-source-score" *ngIf="src.score != null">{{ (src.score * 100) | number:'1.0-0' }}%</span>
36744
+ </div>
36745
+ </div>
36746
+ </div>
36747
+ </div>
36748
+ </div>
36749
+
36750
+ <!-- Errore -->
36751
+ <div class="ai-error" *ngIf="errorMsg">{{ errorMsg }}</div>
36752
+
36753
+ <!-- Input -->
36754
+ <div class="ai-input-area">
36755
+ <div class="ai-input-box" [class.focused]="false">
36756
+ <textarea #ta class="ai-input" rows="1"
36757
+ [(ngModel)]="userInput"
36758
+ [disabled]="busy"
36759
+ [placeholder]="placeholder"
36760
+ (keydown)="onKeyDown($event)"
36761
+ (input)="autoGrow(ta)"></textarea>
36762
+ <button type="button" class="ai-send" *ngIf="!busy"
36763
+ [disabled]="!userInput.trim()" (click)="send()" title="Invia">
36764
+ <i class="material-symbols-outlined">send</i>
36765
+ </button>
36766
+ <button type="button" class="ai-send ai-stop" *ngIf="busy" (click)="stop()" title="Interrompi">
36767
+ <i class="material-symbols-outlined">stop</i>
36768
+ </button>
36769
+ </div>
36770
+ <div class="ai-hint" *ngIf="showHint">Invio per inviare · Shift+Invio per andare a capo</div>
36771
+ </div>
36772
+ </div>
36773
+ `, styles: [":host{display:block;height:100%}.ai-chat{height:100%;box-sizing:border-box;display:flex;flex-direction:column;background:#fff;border:1px solid rgba(22,18,18,.1);border-radius:10px;overflow:hidden}.ai-head{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-top:3px solid var(--fh-ai-accent, #16afc7);border-bottom:1px solid rgba(22,18,18,.07)}.ai-head-left{display:flex;align-items:center;gap:10px}.ai-head-icon{font-size:22px;color:var(--fh-ai-accent, #16afc7)}.ai-head-title{font-family:Plus Jakarta Sans,sans-serif;font-size:14px;font-weight:800;color:#161212}.ai-head-sub{font-family:Inter,sans-serif;font-size:11px;color:#8c8585;margin-top:1px}.ai-head-right{display:flex;align-items:center;gap:8px}.ai-tag{display:inline-block;padding:3px 10px;border-radius:999px;font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.03em;background:#1612120f;color:#443d3d}.ai-icon-btn{display:flex;border:1px solid rgba(22,18,18,.12);background:transparent;border-radius:8px;width:30px;height:30px;align-items:center;justify-content:center;cursor:pointer;color:#5c5454}.ai-icon-btn:hover{background:#1612120d}.ai-icon-btn i{font-size:18px}.ai-messages{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:18px;display:flex;flex-direction:column;gap:14px;background:#f8fafc}.ai-welcome{margin:auto;display:flex;flex-direction:column;align-items:center;text-align:center;padding:20px;gap:6px}.ai-welcome-icon{font-size:40px;color:var(--fh-ai-accent, #16afc7)}.ai-welcome-title{font-family:Plus Jakarta Sans,sans-serif;font-size:16px;font-weight:700;color:#161212}.ai-welcome-sub{font-family:Inter,sans-serif;font-size:13px;color:#6b6363;margin-bottom:8px}.ai-suggestions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;max-width:560px}.ai-suggestion{padding:9px 14px;background:#fff;color:#443d3d;border:1px solid rgba(22,18,18,.12);border-radius:999px;font-family:Inter,sans-serif;font-size:12.5px;cursor:pointer;transition:all .15s ease}.ai-suggestion:hover{border-color:var(--fh-ai-accent, #16afc7);color:var(--fh-ai-accent-dark, #0e8ba0);background:#16afc70f}.ai-msg{display:flex;gap:10px;max-width:88%}.ai-msg-user{align-self:flex-end;flex-direction:row-reverse}.ai-msg-bot{align-self:flex-start}.ai-avatar{flex:0 0 auto;width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center}.ai-msg-user .ai-avatar{background:var(--fh-ai-accent, #16afc7);color:#fff}.ai-msg-bot .ai-avatar{background:#fff;color:var(--fh-ai-accent, #16afc7);border:1px solid rgba(22,175,199,.35)}.ai-avatar i{font-size:18px}.ai-bubble{padding:10px 14px;border-radius:12px;font-family:Inter,sans-serif;font-size:13.5px;line-height:1.6}.ai-msg-user .ai-bubble{background:var(--fh-ai-accent, #16afc7);color:#fff;border-bottom-right-radius:4px}.ai-msg-bot .ai-bubble{background:#fff;color:#1e293b;border:1px solid rgba(22,18,18,.1);border-bottom-left-radius:4px}.ai-text{word-wrap:break-word}.ai-text ::ng-deep p{margin:0 0 8px}.ai-text ::ng-deep p:last-child{margin-bottom:0}.ai-text ::ng-deep ul,.ai-text ::ng-deep ol{margin:4px 0 8px;padding-left:20px}.ai-text ::ng-deep li{margin-bottom:3px}.ai-text ::ng-deep code{background:#1612120f;padding:1px 5px;border-radius:4px;font-family:Cascadia Code,Fira Code,monospace;font-size:.85em}.ai-text ::ng-deep pre{background:#1e293b;color:#7dd3fc;padding:10px 12px;border-radius:8px;overflow-x:auto;margin:6px 0}.ai-text ::ng-deep pre code{background:transparent;padding:0;color:inherit}.ai-text ::ng-deep strong{font-weight:700}.ai-text ::ng-deep a{color:var(--fh-ai-accent-dark, #0e8ba0);text-decoration:underline}.ai-msg-user .ai-text ::ng-deep a{color:#fff}.ai-text ::ng-deep table{border-collapse:collapse;width:100%;margin:6px 0;font-size:.92em}.ai-text ::ng-deep th,.ai-text ::ng-deep td{border:1px solid rgba(22,18,18,.12);padding:5px 8px;text-align:left}.ai-text ::ng-deep th{background:#1612120a;font-weight:600}.ai-sources{margin-top:10px;border-top:1px dashed rgba(22,18,18,.12);padding-top:8px}.ai-sources-head{display:flex;align-items:center;gap:5px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:#8c8585;margin-bottom:5px}.ai-sources-head i{font-size:14px}.ai-source{display:flex;align-items:center;gap:6px;font-size:12px;color:#5c5454;padding:2px 0}.ai-source i{font-size:15px;color:var(--fh-ai-accent, #16afc7);flex:0 0 auto}.ai-source-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-source-score{flex:0 0 auto;font-size:11px;font-weight:600;color:#a39b9b}.ai-typing{display:flex;gap:4px;padding:3px 0}.ai-typing span{width:7px;height:7px;border-radius:50%;background:#b9c2cc;animation:ai-typing 1.4s infinite}.ai-typing span:nth-child(2){animation-delay:.2s}.ai-typing span:nth-child(3){animation-delay:.4s}@keyframes ai-typing{0%,60%,to{transform:translateY(0);opacity:.4}30%{transform:translateY(-5px);opacity:1}}.ai-error{flex:0 0 auto;margin:0 18px;padding:8px 12px;background:#fef2f2;border:1px solid #fecaca;color:#dc2626;border-radius:8px;font-size:12.5px}.ai-input-area{flex:0 0 auto;padding:14px 16px;border-top:1px solid rgba(22,18,18,.07);background:#fff}.ai-input-box{display:flex;align-items:flex-end;gap:8px;background:#f1f5f9;border:1px solid rgba(22,18,18,.12);border-radius:12px;padding:4px;transition:border-color .15s ease,box-shadow .15s ease}.ai-input-box:focus-within{border-color:var(--fh-ai-accent, #16afc7);box-shadow:0 0 0 3px #16afc71f}.ai-input{flex:1 1 auto;background:transparent;border:none;outline:none;resize:none;font-family:Inter,sans-serif;font-size:13.5px;color:#1e293b;padding:9px 10px;max-height:140px;min-height:22px}.ai-input::placeholder{color:#a39b9b}.ai-send{flex:0 0 auto;width:38px;height:38px;display:flex;align-items:center;justify-content:center;border:none;border-radius:8px;cursor:pointer;color:#fff;background:linear-gradient(135deg,var(--fh-ai-accent, #16afc7) 0%,var(--fh-ai-accent-dark, #0e8ba0) 130%);transition:filter .15s ease}.ai-send:hover:not(:disabled){filter:brightness(1.07)}.ai-send:disabled{background:#cbd5e1;cursor:not-allowed}.ai-send i{font-size:19px}.ai-stop{background:#64748b}.ai-hint{text-align:center;font-size:10.5px;color:#a39b9b;margin-top:6px}\n"] }]
36774
+ }], ctorParameters: () => [{ type: FHAiService }, { type: i1.DomSanitizer }], propDecorators: { accent: [{
36775
+ type: Input
36776
+ }], accentDark: [{
36777
+ type: Input
36778
+ }], _a: [{
36779
+ type: HostBinding,
36780
+ args: ["style.--fh-ai-accent"]
36781
+ }], _ad: [{
36782
+ type: HostBinding,
36783
+ args: ["style.--fh-ai-accent-dark"]
36784
+ }], showHeader: [{
36785
+ type: Input
36786
+ }], title: [{
36787
+ type: Input
36788
+ }], subtitle: [{
36789
+ type: Input
36790
+ }], tagLabel: [{
36791
+ type: Input
36792
+ }], welcomeTitle: [{
36793
+ type: Input
36794
+ }], welcomeSubtitle: [{
36795
+ type: Input
36796
+ }], suggestions: [{
36797
+ type: Input
36798
+ }], placeholder: [{
36799
+ type: Input
36800
+ }], showHint: [{
36801
+ type: Input
36802
+ }], endpoint: [{
36803
+ type: Input
36804
+ }], path: [{
36805
+ type: Input
36806
+ }], model: [{
36807
+ type: Input
36808
+ }], stream: [{
36809
+ type: Input
36810
+ }], apiKey: [{
36811
+ type: Input
36812
+ }], forwardAuth: [{
36813
+ type: Input
36814
+ }], context: [{
36815
+ type: Input
36816
+ }], systemPrompt: [{
36817
+ type: Input
36818
+ }], messageSent: [{
36819
+ type: Output
36820
+ }], responseReceived: [{
36821
+ type: Output
36822
+ }], errored: [{
36823
+ type: Output
36824
+ }], scroller: [{
36825
+ type: ViewChild,
36826
+ args: ["scroller"]
36827
+ }] } });
36828
+ /**
36829
+ * Formattatore markdown minimale e dependency-free.
36830
+ * Esegue PRIMA l'escape di &,<,> (anti-XSS), poi applica la formattazione su testo sicuro.
36831
+ */
36832
+ function formatMarkdown(input) {
36833
+ if (!input)
36834
+ return "";
36835
+ let s = input.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
36836
+ // Code block ```...```
36837
+ const blocks = [];
36838
+ s = s.replace(/```(?:[a-zA-Z]+)?\n?([\s\S]*?)```/g, (_m, code) => {
36839
+ blocks.push(`<pre><code>${code.replace(/\n$/, "")}</code></pre>`);
36840
+ return `BLOCK${blocks.length - 1}`;
36841
+ });
36842
+ // Inline code `...`
36843
+ s = s.replace(/`([^`]+)`/g, "<code>$1</code>");
36844
+ // Bold **...**
36845
+ s = s.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
36846
+ // Italic *...*
36847
+ s = s.replace(/(^|[^*])\*([^*\n]+)\*/g, "$1<em>$2</em>");
36848
+ // Link [testo](url)
36849
+ s = s.replace(/\[([^\]]+)\]\((https?:[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>');
36850
+ // Liste: righe che iniziano con "- " o "* " o "N. "
36851
+ const lines = s.split("\n");
36852
+ const out = [];
36853
+ let inUl = false;
36854
+ let inOl = false;
36855
+ const closeLists = () => {
36856
+ if (inUl) {
36857
+ out.push("</ul>");
36858
+ inUl = false;
36859
+ }
36860
+ if (inOl) {
36861
+ out.push("</ol>");
36862
+ inOl = false;
36863
+ }
36864
+ };
36865
+ for (const line of lines) {
36866
+ const ul = line.match(/^\s*[-*]\s+(.*)$/);
36867
+ const ol = line.match(/^\s*\d+\.\s+(.*)$/);
36868
+ if (ul) {
36869
+ if (inOl) {
36870
+ out.push("</ol>");
36871
+ inOl = false;
36872
+ }
36873
+ if (!inUl) {
36874
+ out.push("<ul>");
36875
+ inUl = true;
36876
+ }
36877
+ out.push(`<li>${ul[1]}</li>`);
36878
+ }
36879
+ else if (ol) {
36880
+ if (inUl) {
36881
+ out.push("</ul>");
36882
+ inUl = false;
36883
+ }
36884
+ if (!inOl) {
36885
+ out.push("<ol>");
36886
+ inOl = true;
36887
+ }
36888
+ out.push(`<li>${ol[1]}</li>`);
36889
+ }
36890
+ else {
36891
+ closeLists();
36892
+ out.push(line);
36893
+ }
36894
+ }
36895
+ closeLists();
36896
+ s = out.join("\n");
36897
+ // Paragrafi / a-capo: doppia newline -> blocco, singola -> <br>
36898
+ s = s
36899
+ .split(/\n{2,}/)
36900
+ .map((blk) => {
36901
+ if (/^<(ul|ol|pre|h\d|table)/.test(blk.trim()))
36902
+ return blk;
36903
+ return `<p>${blk.replace(/\n/g, "<br>")}</p>`;
36904
+ })
36905
+ .join("");
36906
+ // Ripristino i code block
36907
+ s = s.replace(/BLOCK(\d+)/g, (_m, i) => blocks[+i]);
36908
+ return s;
36909
+ }
36910
+
36911
+ /**
36912
+ * Launcher AI flottante ("drop-anywhere") di FluxHub: un FAB in basso a destra che
36913
+ * apre/chiude un pannello con dentro <FHAiChat>. Si inserisce in qualunque pagina
36914
+ * del portale per dare accesso all'assistente senza occupare layout.
36915
+ *
36916
+ * Inoltra al chat gli @Input principali (endpoint, contesto, tema, testi).
36917
+ *
36918
+ * Esempio:
36919
+ * <FHAiAssistant [context]="{azienda:'COEM', ruolo:'manager'}"
36920
+ * [accent]="'#16afc7'"
36921
+ * welcomeTitle="Assistente COEM"></FHAiAssistant>
36922
+ */
36923
+ class FHAiAssistantComponent {
36924
+ // ---- Tema ----
36925
+ accent = "#16afc7";
36926
+ accentDark = "#0e8ba0";
36927
+ get _a() { return this.accent; }
36928
+ get _ad() { return this.accentDark; }
36929
+ // ---- FAB ----
36930
+ icon = "smart_toy";
36931
+ openLabel = "Assistente AI";
36932
+ showLabel = true;
36933
+ /** 'floating' = popover ancorato al FAB; 'right' = drawer a tutta altezza. */
36934
+ dock = "floating";
36935
+ /** Apre il pannello all'avvio. */
36936
+ startOpen = false;
36937
+ // ---- Pass-through al chat ----
36938
+ title = "Assistente AI";
36939
+ subtitle = "";
36940
+ tagLabel = "";
36941
+ welcomeTitle = "Come posso aiutarti?";
36942
+ welcomeSubtitle = "Fammi una domanda sui tuoi dati.";
36943
+ suggestions = [];
36944
+ placeholder = "Scrivi un messaggio...";
36945
+ endpoint = "";
36946
+ path = "ai/chat";
36947
+ model = "";
36948
+ stream = true;
36949
+ apiKey = "";
36950
+ forwardAuth = true;
36951
+ context = null;
36952
+ systemPrompt = "";
36953
+ open = false;
36954
+ ngOnInit() {
36955
+ this.open = this.startOpen;
36956
+ }
36957
+ toggle() {
36958
+ this.open = !this.open;
36959
+ }
36960
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiAssistantComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
36961
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.17", type: FHAiAssistantComponent, isStandalone: true, selector: "FHAiAssistant", inputs: { accent: "accent", accentDark: "accentDark", icon: "icon", openLabel: "openLabel", showLabel: "showLabel", dock: "dock", startOpen: "startOpen", title: "title", subtitle: "subtitle", tagLabel: "tagLabel", welcomeTitle: "welcomeTitle", welcomeSubtitle: "welcomeSubtitle", suggestions: "suggestions", placeholder: "placeholder", endpoint: "endpoint", path: "path", model: "model", stream: "stream", apiKey: "apiKey", forwardAuth: "forwardAuth", context: "context", systemPrompt: "systemPrompt" }, host: { properties: { "style.--fh-ai-accent": "this._a", "style.--fh-ai-accent-dark": "this._ad" } }, ngImport: i0, template: `
36962
+ <!-- Pannello -->
36963
+ <div class="ai-fab-panel" *ngIf="open" [class.docked]="dock !== 'floating'">
36964
+ <FHAiChat
36965
+ [accent]="accent" [accentDark]="accentDark"
36966
+ [title]="title" [subtitle]="subtitle" [tagLabel]="tagLabel"
36967
+ [welcomeTitle]="welcomeTitle" [welcomeSubtitle]="welcomeSubtitle"
36968
+ [suggestions]="suggestions" [placeholder]="placeholder"
36969
+ [endpoint]="endpoint" [path]="path" [model]="model" [stream]="stream"
36970
+ [apiKey]="apiKey" [forwardAuth]="forwardAuth" [context]="context"
36971
+ [systemPrompt]="systemPrompt">
36972
+ </FHAiChat>
36973
+ </div>
36974
+
36975
+ <!-- FAB -->
36976
+ <button type="button" class="ai-fab" (click)="toggle()" [title]="open ? 'Chiudi assistente' : openLabel">
36977
+ <i class="material-symbols-outlined">{{ open ? 'close' : icon }}</i>
36978
+ <span class="ai-fab-label" *ngIf="!open && showLabel">{{ openLabel }}</span>
36979
+ </button>
36980
+ `, isInline: true, styles: [":host{position:fixed;right:24px;bottom:24px;z-index:1200}.ai-fab{display:flex;align-items:center;gap:8px;height:54px;min-width:54px;padding:0 18px;border:none;border-radius:999px;cursor:pointer;color:#fff;background:linear-gradient(135deg,var(--fh-ai-accent, #16afc7) 0%,var(--fh-ai-accent-dark, #0e8ba0) 130%);box-shadow:0 8px 24px #0e233c47;transition:filter .15s ease,transform .15s ease;margin-left:auto}.ai-fab:hover{filter:brightness(1.07);transform:translateY(-1px)}.ai-fab i{font-size:24px}.ai-fab-label{font-family:Plus Jakarta Sans,sans-serif;font-size:14px;font-weight:700;white-space:nowrap}.ai-fab-panel{position:absolute;right:0;bottom:70px;width:400px;max-width:calc(100vw - 48px);height:600px;max-height:calc(100vh - 130px);border-radius:12px;overflow:hidden;box-shadow:0 18px 50px #0e233c52;animation:ai-fab-in .18s ease}.ai-fab-panel.docked{position:fixed;top:0;right:0;bottom:0;width:420px;max-width:100vw;height:100vh;max-height:100vh;border-radius:0}@keyframes ai-fab-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@media (max-width: 520px){.ai-fab-panel{width:calc(100vw - 48px);height:calc(100vh - 130px)}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FHAiChatComponent, selector: "FHAiChat", inputs: ["accent", "accentDark", "showHeader", "title", "subtitle", "tagLabel", "welcomeTitle", "welcomeSubtitle", "suggestions", "placeholder", "showHint", "endpoint", "path", "model", "stream", "apiKey", "forwardAuth", "context", "systemPrompt"], outputs: ["messageSent", "responseReceived", "errored"] }] });
36981
+ }
36982
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: FHAiAssistantComponent, decorators: [{
36983
+ type: Component,
36984
+ args: [{ selector: "FHAiAssistant", standalone: true, imports: [CommonModule, FHAiChatComponent], template: `
36985
+ <!-- Pannello -->
36986
+ <div class="ai-fab-panel" *ngIf="open" [class.docked]="dock !== 'floating'">
36987
+ <FHAiChat
36988
+ [accent]="accent" [accentDark]="accentDark"
36989
+ [title]="title" [subtitle]="subtitle" [tagLabel]="tagLabel"
36990
+ [welcomeTitle]="welcomeTitle" [welcomeSubtitle]="welcomeSubtitle"
36991
+ [suggestions]="suggestions" [placeholder]="placeholder"
36992
+ [endpoint]="endpoint" [path]="path" [model]="model" [stream]="stream"
36993
+ [apiKey]="apiKey" [forwardAuth]="forwardAuth" [context]="context"
36994
+ [systemPrompt]="systemPrompt">
36995
+ </FHAiChat>
36996
+ </div>
36997
+
36998
+ <!-- FAB -->
36999
+ <button type="button" class="ai-fab" (click)="toggle()" [title]="open ? 'Chiudi assistente' : openLabel">
37000
+ <i class="material-symbols-outlined">{{ open ? 'close' : icon }}</i>
37001
+ <span class="ai-fab-label" *ngIf="!open && showLabel">{{ openLabel }}</span>
37002
+ </button>
37003
+ `, styles: [":host{position:fixed;right:24px;bottom:24px;z-index:1200}.ai-fab{display:flex;align-items:center;gap:8px;height:54px;min-width:54px;padding:0 18px;border:none;border-radius:999px;cursor:pointer;color:#fff;background:linear-gradient(135deg,var(--fh-ai-accent, #16afc7) 0%,var(--fh-ai-accent-dark, #0e8ba0) 130%);box-shadow:0 8px 24px #0e233c47;transition:filter .15s ease,transform .15s ease;margin-left:auto}.ai-fab:hover{filter:brightness(1.07);transform:translateY(-1px)}.ai-fab i{font-size:24px}.ai-fab-label{font-family:Plus Jakarta Sans,sans-serif;font-size:14px;font-weight:700;white-space:nowrap}.ai-fab-panel{position:absolute;right:0;bottom:70px;width:400px;max-width:calc(100vw - 48px);height:600px;max-height:calc(100vh - 130px);border-radius:12px;overflow:hidden;box-shadow:0 18px 50px #0e233c52;animation:ai-fab-in .18s ease}.ai-fab-panel.docked{position:fixed;top:0;right:0;bottom:0;width:420px;max-width:100vw;height:100vh;max-height:100vh;border-radius:0}@keyframes ai-fab-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@media (max-width: 520px){.ai-fab-panel{width:calc(100vw - 48px);height:calc(100vh - 130px)}}\n"] }]
37004
+ }], propDecorators: { accent: [{
37005
+ type: Input
37006
+ }], accentDark: [{
37007
+ type: Input
37008
+ }], _a: [{
37009
+ type: HostBinding,
37010
+ args: ["style.--fh-ai-accent"]
37011
+ }], _ad: [{
37012
+ type: HostBinding,
37013
+ args: ["style.--fh-ai-accent-dark"]
37014
+ }], icon: [{
37015
+ type: Input
37016
+ }], openLabel: [{
37017
+ type: Input
37018
+ }], showLabel: [{
37019
+ type: Input
37020
+ }], dock: [{
37021
+ type: Input
37022
+ }], startOpen: [{
37023
+ type: Input
37024
+ }], title: [{
37025
+ type: Input
37026
+ }], subtitle: [{
37027
+ type: Input
37028
+ }], tagLabel: [{
37029
+ type: Input
37030
+ }], welcomeTitle: [{
37031
+ type: Input
37032
+ }], welcomeSubtitle: [{
37033
+ type: Input
37034
+ }], suggestions: [{
37035
+ type: Input
37036
+ }], placeholder: [{
37037
+ type: Input
37038
+ }], endpoint: [{
37039
+ type: Input
37040
+ }], path: [{
37041
+ type: Input
37042
+ }], model: [{
37043
+ type: Input
37044
+ }], stream: [{
37045
+ type: Input
37046
+ }], apiKey: [{
37047
+ type: Input
37048
+ }], forwardAuth: [{
37049
+ type: Input
37050
+ }], context: [{
37051
+ type: Input
37052
+ }], systemPrompt: [{
37053
+ type: Input
37054
+ }] } });
37055
+
35484
37056
  /*
35485
37057
  * Public API Surface of fluxhublib
35486
37058
  */
@@ -35489,5 +37061,5 @@ const KNOWN_EXT = "3G2|3GA|3GP|7Z|AA|AAC|AC|ACCDB|ACCDT|ADN|AI|AIF|AIFC|AIFF|AIT
35489
37061
  * Generated bundle index. Do not edit.
35490
37062
  */
35491
37063
 
35492
- export { AppMakerService, AppService, ApprovaGridComponent, AuthHttpRequestInterceptor, AuthenticationService, BpmnEditorComponent, CheckboxEditorComponent, ComboBoxEditorComponent, CurrencyComponent, DialogBaseComponent, FHAutoCompleteComponent, FHCheckBoxComponent, FHColorPickerComponent, FHComboboxComponent, FHConfirmValues, FHCurrencyFormatterDirective, FHCurrencyPipe, FHDatePickerComponent, FHDateRangePickerComponent, FHFieldPickListComponent, FHFilterComboboxComponent, FHFormBuilderComponent, FHFormExecuterComponent, FHFormToolBarComponent, FHGridComponent, FHGridJSONComponent, FHGridToolBarComponent, FHGuard, FHHelpButtonComponent, FHHomeDocsComponent, FHHomeLauncherComponent, FHHomeStatsComponent, FHHomeTodoComponent, FHImageViewerComponent, FHListComponent, FHLogPanelComponent, FHMultiComboboxComponent, FHNotesPanelComponent, FHNumericFieldComponent, FHPickFieldComponent, FHPickUsersComponent, FHRichTextComponent, FHRoleManagerComponent, FHTableManagerComponent, FHTextAreaComponent, FHTextInputComponent, FHTimePickerComponent, FHToolBarCustomAction, FHToolbarCommandType, FHUploadComponent, FHUploadPanelComponent, FHUploadPanelS3Component, FHUploadS3Component, FHUserFieldComponent, FHWinAppLogsComponent, FHWinAskBigTextComponent, FHWinAskButtonsComponent, FHWinAskNumberComponent, FHWinAskRichTextComponent, FHWinAskTextComponent, FHWinAutoComplete, FHWinComboComponent, FHWinConfirmComponent, FHWinErrorComponent, FHWinGridSelection, FHWinInfoComponent, FHWinListComponent, FHWinMappaComponent, FHWinOutputComponent, FHWinPicklistComponent, FHWinSalvaAnnulla, FHWinSelectByGridComponent, FHWinShowEmail, FHWinShowEmailS3, FHWinShowImage, FHWinShowLog, FHWinShowLogDett, FHWinTimeSlider, FHWinUploadComponent, FHWinUserInfo, FHWinUserPickerComponent, FHWinWaitComponent, FHWorkflowForm, FHWorkflowHeaderBar, FHWorkflowView, FSInput, FSResult, FileService, GridService, LocalDBService, MonthYearPickerComponent, NumericEditorComponent, OdbcService, OfficeAutomatorService, OfficeOperation, OfficeResult, QGParam, QGResult, QParam, QResult, QueryOpenService, QueryService, RegistrationService, ReplaceLineBreaks, SafePipe, TextAreaEditorComponent, UtilityService, WkfService, YearPickerComponent, createButtonCommand, createCheckboxCommand, createSpacerCommand, createTableManagerCommand, fh_win_translate };
37064
+ export { AppMakerService, AppService, ApprovaGridComponent, AuthHttpRequestInterceptor, AuthenticationService, BpmnEditorComponent, CheckboxEditorComponent, ComboBoxEditorComponent, CurrencyComponent, DialogBaseComponent, FHAiAssistantComponent, FHAiChatComponent, FHAiService, FHAutoCompleteComponent, FHCheckBoxComponent, FHColorPickerComponent, FHComboboxComponent, FHConfirmValues, FHCurrencyFormatterDirective, FHCurrencyPipe, FHDatePickerComponent, FHDateRangePickerComponent, FHFieldPickListComponent, FHFilterComboboxComponent, FHFormBuilderComponent, FHFormExecuterComponent, FHFormToolBarComponent, FHGridComponent, FHGridJSONComponent, FHGridToolBarComponent, FHGuard, FHHelpButtonComponent, FHHomeDocsComponent, FHHomeLauncherComponent, FHHomeStatsComponent, FHHomeTodoComponent, FHIconPickerComponent, FHImageViewerComponent, FHListComponent, FHLogPanelComponent, FHMultiComboboxComponent, FHNotesPanelComponent, FHNumericFieldComponent, FHPickFieldComponent, FHPickUsersComponent, FHRichTextComponent, FHRoleManagerComponent, FHTableManagerComponent, FHTextAreaComponent, FHTextInputComponent, FHTimePickerComponent, FHToolBarCustomAction, FHToolbarCommandType, FHUploadComponent, FHUploadPanelComponent, FHUploadPanelS3Component, FHUploadS3Component, FHUserFieldComponent, FHWinAppLogsComponent, FHWinAskBigTextComponent, FHWinAskButtonsComponent, FHWinAskNumberComponent, FHWinAskRichTextComponent, FHWinAskTextComponent, FHWinAutoComplete, FHWinComboComponent, FHWinConfirmComponent, FHWinErrorComponent, FHWinGridSelection, FHWinInfoComponent, FHWinListComponent, FHWinMappaComponent, FHWinOutputComponent, FHWinPicklistComponent, FHWinSalvaAnnulla, FHWinSelectByGridComponent, FHWinShowEmail, FHWinShowEmailS3, FHWinShowImage, FHWinShowLog, FHWinShowLogDett, FHWinTimeSlider, FHWinUploadComponent, FHWinUserInfo, FHWinUserPickerComponent, FHWinWaitComponent, FHWorkflowForm, FHWorkflowHeaderBar, FHWorkflowView, FSInput, FSResult, FileService, GridService, LocalDBService, MonthYearPickerComponent, NumericEditorComponent, OdbcService, OfficeAutomatorService, OfficeOperation, OfficeResult, QGParam, QGResult, QParam, QResult, QueryOpenService, QueryService, RegistrationService, ReplaceLineBreaks, SafePipe, TextAreaEditorComponent, UtilityService, WkfService, YearPickerComponent, createButtonCommand, createCheckboxCommand, createSpacerCommand, createTableManagerCommand, fh_win_translate };
35493
37065
  //# sourceMappingURL=fluxhub-fluxhub-lib.mjs.map