File size: 959 Bytes
6cdf82d
6d2a29b
6cdf82d
6d2a29b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6cdf82d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// --- Shared PHI Engine ---
window.PHI = {
  thresholds: { compression: 30, recovery: 50, expansion: 70 },

  getPhase(score) {
    const t = this.thresholds;
    if (score < t.compression) return 'Compression';
    if (score < t.recovery) return 'Recovery';
    if (score < t.expansion) return 'Expansion';
    return 'Exhaustion';
  },

  getRegime(score) {
    if (score < 30) return 'Risk-off';
    if (score < 50) return 'Neutral';
    if (score < 70) return 'Risk-on';
    return 'Extreme';
  },

  store(data) {
    localStorage.setItem('cryptoPulseData', JSON.stringify(data));
    localStorage.setItem('cryptoPulseTimestamp', Date.now());
  },

  read() {
    return JSON.parse(localStorage.getItem('cryptoPulseData') || 'null');
  },

  isStale(minutes = 5) {
    const ts = parseInt(localStorage.getItem('cryptoPulseTimestamp') || '0');
    return !ts || (Date.now() - ts > minutes * 60000);
  }
};

console.log('PHI engine loaded:', typeof PHI);