kryptheon 0.1.72 → 0.1.74

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.
@@ -0,0 +1,722 @@
1
+ // The first-time guide on the dashboard. Served from 127.0.0.1 with the page.
2
+ //
3
+ // The room goes dark and one part of the page is lit - the box to type in, the
4
+ // button to press - and the person does it with their own hand. The guide
5
+ // moves on only when the page says it happened: the address saved, a
6
+ // recording held, a run finished. Like the page, it writes nothing as HTML:
7
+ // every node is made with createElement and filled with textContent, and it
8
+ // reads only what the page itself shows. It sends nothing anywhere; where it
9
+ // stands is kept in this browser's own storage.
10
+
11
+ (function () {
12
+ 'use strict';
13
+
14
+ var KEY = 'kryptheon.guide.v1';
15
+ var state = null;
16
+ var busy = false;
17
+ var on = false;
18
+ var at = null;
19
+ var seen = {};
20
+ // The set-up is not optional (owner, 2026-11-20): no close, no Esc. Only a run opened from "Guide me" can be closed.
21
+ var optional = false;
22
+ var stepSince = 0;
23
+ var STUCK_MS = 180000;
24
+ var frame = 0;
25
+ var still = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
26
+
27
+ function el(tag, cls, text) {
28
+ var node = document.createElement(tag);
29
+ if (cls) node.className = cls;
30
+ if (text !== undefined && text !== null) node.textContent = String(text);
31
+ return node;
32
+ }
33
+ function clear(node) { while (node.firstChild) node.removeChild(node.firstChild); }
34
+ function byId(id) { return document.getElementById(id); }
35
+ function read() {
36
+ try { return JSON.parse(window.localStorage.getItem(KEY) || '{}') || {}; } catch (e) { return {}; }
37
+ }
38
+ function keep(more) {
39
+ var now = read();
40
+ Object.keys(more).forEach(function (k) { now[k] = more[k]; });
41
+ try { window.localStorage.setItem(KEY, JSON.stringify(now)); } catch (e) { /* kept for this visit only */ }
42
+ }
43
+
44
+ /* ---------------------------------- the look ---------------------------------- */
45
+
46
+ var css = el('style');
47
+ css.textContent = [
48
+ '.kt-block { position: fixed; z-index: 9000; background: transparent; }',
49
+ '.kt-lens { position: fixed; z-index: 9001; pointer-events: none; border-radius: 10px;',
50
+ ' box-shadow: 0 0 0 2px #ff4d00, 0 0 34px 6px rgba(255, 110, 30, 0.55), 0 0 0 200vmax rgba(9, 7, 5, 0.86);',
51
+ ' transition: left .55s cubic-bezier(.16,1,.3,1), top .55s cubic-bezier(.16,1,.3,1), width .55s cubic-bezier(.16,1,.3,1), height .55s cubic-bezier(.16,1,.3,1), border-radius .55s; }',
52
+ '.kt-lens.kt-none { left: 50% !important; top: 42% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 200vmax rgba(9, 7, 5, 0.86); }',
53
+ '.kt-lens::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid rgba(255, 160, 90, 0.9); animation: kt-breathe 1.8s ease-in-out infinite; }',
54
+ '.kt-lens.kt-none::after { display: none; }',
55
+ '@keyframes kt-breathe { 50% { inset: -9px; opacity: 0; } }',
56
+ // the fake zoom: the lit part steps forward a little, as on a stage
57
+ '.kt-lit { transform: scale(1.025); transform-origin: center; transition: transform .6s cubic-bezier(.16,1,.3,1); }',
58
+ '.kt-card { position: fixed; z-index: 9002; width: min(400px, calc(100vw - 28px)); padding: 20px 20px 16px; background: #fffaf6; color: #12161d; border-radius: 14px;',
59
+ ' box-shadow: 0 24px 70px rgba(0,0,0,.45), 0 0 0 1px rgba(255,77,0,.25); font: 15px/1.5 var(--display); transition: left .5s cubic-bezier(.16,1,.3,1), top .5s cubic-bezier(.16,1,.3,1), opacity .3s; }',
60
+ '.kt-card.kt-mid { width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; }',
61
+ '.kt-step { font: 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #ff4d00; display: flex; justify-content: space-between; gap: 10px; }',
62
+ '.kt-bar { display: flex; gap: 4px; margin: 10px 0 12px; } .kt-bar i { flex: 1; height: 3px; border-radius: 3px; background: rgba(18,22,29,.12); } .kt-bar i.on { background: #ff4d00; }',
63
+ '.kt-card h2 { margin: 0 0 8px; font: 900 26px/1 var(--display); font-stretch: 70%; text-transform: uppercase; letter-spacing: -.01em; }',
64
+ '.kt-card h2 em { font-style: normal; color: #ff4d00; }',
65
+ '.kt-card p { margin: 0 0 10px; color: rgba(18,22,29,.72); }',
66
+ '.kt-wait { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; font: 12px/1.4 var(--mono); color: #c23a00; }',
67
+ '.kt-wait::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #ff4d00; border-right-color: transparent; animation: kt-spin .8s linear infinite; flex: none; }',
68
+ '@keyframes kt-spin { to { transform: rotate(360deg); } }',
69
+ '.kt-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }',
70
+ '.kt-btn { height: 40px; padding: 0 18px; border-radius: 9px; font: 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; border: 1px solid #12161d; background: transparent; color: #12161d; cursor: pointer; }',
71
+ '.kt-btn.kt-go { background: #ff4d00; border-color: #ff4d00; color: #fff; } .kt-btn.kt-go:hover { background: #c23a00; }',
72
+ '.kt-skip { margin-left: auto; font: 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: rgba(18,22,29,.5); background: none; border: 0; cursor: pointer; text-decoration: underline; }',
73
+ '.kt-guide-btn { margin-right: 4px; }',
74
+ '.kt-red { margin: 2px 0 10px; color: #d11a1a; font-weight: 800; }',
75
+ '.kt-nav { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(18,22,29,.08); }',
76
+ '.kt-nav .kt-btn { height: 32px; padding: 0 12px; font-size: 10px; }',
77
+ // while the guide is on: the run panel steps back unless it is the part lit, and the page\'s short notes stay readable
78
+ '.kt-on .job:not(.kt-lit) { opacity: .1; pointer-events: none; transition: opacity .4s; }',
79
+ '.kt-on .toast { z-index: 9003; }',
80
+ // what a recording looks like, played before the person presses Record
81
+ '.kt-demo { position: relative; height: 150px; margin: 4px 0 12px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid rgba(18,22,29,.14); }',
82
+ '.kt-demo-top { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; background: #f2f4f1; border-bottom: 1px solid rgba(18,22,29,.1); font: 10px/1 var(--mono); letter-spacing: .1em; color: rgba(18,22,29,.6); }',
83
+ '.kt-rec { width: 8px; height: 8px; border-radius: 50%; background: #e5221b; animation: kt-blink 1s steps(1) infinite; } @keyframes kt-blink { 50% { opacity: .2; } }',
84
+ '.kt-demo-page { position: absolute; left: 0; right: 0; top: 24px; bottom: 26px; display: grid; place-items: center; opacity: 0; animation: kt-page 9s infinite; }',
85
+ '.kt-demo-page b { display: block; font: 900 15px/1 var(--display); text-transform: uppercase; margin-bottom: 8px; text-align: center; }',
86
+ '.kt-demo-page span { display: inline-block; padding: 7px 14px; border-radius: 7px; background: #12161d; color: #fff; font: 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }',
87
+ '.kt-demo-page:nth-of-type(3) { animation-delay: 3s; } .kt-demo-page:nth-of-type(4) { animation-delay: 6s; }',
88
+ '@keyframes kt-page { 0% { opacity: 0; } 4%, 30% { opacity: 1; } 34%, 100% { opacity: 0; } }',
89
+ '.kt-cursor { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: rgba(255,77,0,.85); box-shadow: 0 0 0 5px rgba(255,77,0,.25); top: 70%; left: 20%; animation: kt-move 3s ease-in-out infinite; }',
90
+ '@keyframes kt-move { 0% { top: 75%; left: 18%; } 45% { top: 62%; left: 52%; } 55% { top: 62%; left: 52%; transform: scale(.7); } 65% { transform: scale(1); } 100% { top: 75%; left: 18%; } }',
91
+ '.kt-demo-log { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; display: flex; align-items: center; gap: 10px; padding: 0 9px; background: #12161d; color: #ffb48c; font: 10px/1 var(--mono); letter-spacing: .08em; overflow: hidden; white-space: nowrap; }',
92
+ '.kt-demo-log i { font-style: normal; opacity: 0; animation: kt-log 9s infinite; } .kt-demo-log i:nth-child(2) { animation-delay: 3s; } .kt-demo-log i:nth-child(3) { animation-delay: 6s; }',
93
+ '@keyframes kt-log { 0%, 12% { opacity: 0; } 16%, 96% { opacity: 1; } 100% { opacity: 0; } }',
94
+ // the end
95
+ '.kt-sparks { position: fixed; inset: 0; z-index: 9001; pointer-events: none; }',
96
+ '.kt-list { list-style: none; margin: 6px 0 12px; padding: 0; display: grid; gap: 8px; }',
97
+ '.kt-list li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px solid rgba(18,22,29,.1); }',
98
+ '.kt-list li > span { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #fff0e6; color: #ff4d00; font: 700 12px/1 var(--mono); }',
99
+ '.kt-list b { display: block; font-size: 14px; } .kt-list small { color: rgba(18,22,29,.65); font-size: 13px; }',
100
+ '.kt-list .kt-btn { height: 30px; padding: 0 10px; margin-top: 6px; font-size: 10px; }',
101
+ '.kt-h { margin: 14px 0 4px; font: 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: rgba(18,22,29,.55); }',
102
+ '.kt-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }',
103
+ '.kt-plan { padding: 12px; border-radius: 10px; background: #fff; border: 1px solid rgba(18,22,29,.12); font-size: 13px; }',
104
+ '.kt-plan.kt-best { border: 2px solid #ff4d00; }',
105
+ '.kt-plan b { display: block; font: 900 18px/1 var(--display); text-transform: uppercase; } .kt-plan strong { display: block; margin: 6px 0; font-size: 20px; }',
106
+ '.kt-plan ul { margin: 0; padding-left: 16px; color: rgba(18,22,29,.72); }',
107
+ '@media (max-width: 520px) { .kt-plans { grid-template-columns: 1fr; } .kt-card h2 { font-size: 22px; } }',
108
+ '@media (prefers-reduced-motion: reduce) { .kt-lens, .kt-card, .kt-lit { transition: none; } .kt-lens::after, .kt-demo-page, .kt-cursor, .kt-demo-log i, .kt-rec { animation: none; } .kt-demo-page:nth-of-type(2), .kt-demo-log i { opacity: 1; } }',
109
+ ].join('\n');
110
+ document.head.appendChild(css);
111
+
112
+ var blocks = ['top', 'left', 'right', 'bottom'].map(function () {
113
+ var b = el('div', 'kt-block');
114
+ b.hidden = true;
115
+ document.body.appendChild(b);
116
+ return b;
117
+ });
118
+ var lens = el('div', 'kt-lens kt-none');
119
+ lens.hidden = true;
120
+ document.body.appendChild(lens);
121
+ var card = el('div', 'kt-card');
122
+ card.hidden = true;
123
+ card.setAttribute('role', 'dialog');
124
+ card.setAttribute('aria-live', 'polite');
125
+ document.body.appendChild(card);
126
+ var lit = null;
127
+
128
+ /* ------------------------------ what the page holds ------------------------------ */
129
+
130
+ function recordStep() {
131
+ var steps = (state && state.steps) || [];
132
+ for (var i = 0; i < steps.length; i++) if (steps[i].action && steps[i].action.kind === 'record') return steps[i];
133
+ return null;
134
+ }
135
+ function recordings() { var s = recordStep(); return s ? (s.count || (s.state === 'done' ? 1 : 0)) : 0; }
136
+ function hasAddress() { return !!(state && state.app && state.app.address); }
137
+ function findings() { return (state && state.findings) || []; }
138
+ function needsPassword() { return !!(state && state.passwordsNeeded && state.passwordsNeeded.length); }
139
+ function needsConnect() {
140
+ var f = findings()[0];
141
+ return !!(f && !f.fixPrompt && f.promptLock && f.promptLock.reason === 'connect' && !(state.account && state.account.connected));
142
+ }
143
+ function plan() { return (state && state.account && state.account.connected && state.account.plan) || 'starter'; }
144
+ function view(id) { if ((location.hash || '#dashboard').replace('#', '') !== id) location.hash = id; }
145
+ function q(sel) { return document.querySelector(sel); }
146
+ function visible(node) { return node && !node.hidden && node.getClientRects().length > 0; }
147
+ function stepRow(match) {
148
+ var rows = document.querySelectorAll('#steps .step');
149
+ for (var i = 0; i < rows.length; i++) if (match.test(rows[i].textContent || '')) return rows[i];
150
+ return null;
151
+ }
152
+
153
+ /* --------------------------------- the steps --------------------------------- */
154
+
155
+ // main: counted in "Step n of 7". Each says what to light, what to say, and
156
+ // when it is done - read from the page, never assumed.
157
+ var BASE = ['app', 'record', 'check', 'findings', 'fix', 'recheck', 'keep'];
158
+ // Connect leads when this dashboard is not tied to an account yet - the code may have come with the person from kryptheon.tech
159
+ var MAIN = BASE.slice();
160
+ function connected() { return !!(state && state.account && state.account.connected); }
161
+ var STEPS = {
162
+ hello: {
163
+ target: function () { return null; },
164
+ show: function (c) {
165
+ title(c, 'Let\'s set up ', 'your app', ' together');
166
+ c.appendChild(el('p', null, MAIN.length + ' short steps. Only the part you need lights up - you do each one with your own hand, and the guide moves on when it sees it done.'));
167
+ c.appendChild(el('p', null, 'About 5 minutes. Your app has to be open in the browser at its usual address.'));
168
+ row(c, [go('Start', function () { move(MAIN[0]); })], true);
169
+ },
170
+ },
171
+ connect: {
172
+ view: 'dashboard',
173
+ target: function () { return q('#accountBox .field-row') || byId('accountCard'); },
174
+ enter: function () { seen.connectWhy = ''; },
175
+ show: function (c) {
176
+ var box = q('#accountBox input');
177
+ var filled = !!(box && /^kd_/.test(box.value));
178
+ title(c, 'Connect your ', 'account', '');
179
+ c.appendChild(el('p', null, filled
180
+ ? 'Your connect code came with you from kryptheon.tech - it is already in the box. Press Connect.'
181
+ : 'Copy your connect code from kryptheon.tech - the tab you came from, or Your account - paste it here and press Connect.'));
182
+ if (seen.connectWhy) {
183
+ // refused: what kryptheon.tech said, and where a working code comes from
184
+ c.appendChild(el('p', 'kt-red', 'Not accepted: ' + seen.connectWhy));
185
+ c.appendChild(el('p', null, 'Get a fresh code on kryptheon.tech: your dashboard there, On your computer, Get my connect code. Paste it here and press Connect. A new code replaces the old one.'));
186
+ var get = el('a', 'kt-btn kt-go', 'Get my connect code');
187
+ get.href = 'https://kryptheon.tech/dashboard/#computer';
188
+ get.target = '_blank';
189
+ get.rel = 'noopener noreferrer';
190
+ get.style.display = 'inline-flex';
191
+ get.style.alignItems = 'center';
192
+ get.style.textDecoration = 'none';
193
+ c.appendChild(get);
194
+ } else {
195
+ c.appendChild(el('p', null, 'It ties this dashboard to your plan: Starter opens 5 fix prompts a month, Pro and Studio open every one.'));
196
+ }
197
+ waiting(c, 'Waiting for you to press Connect');
198
+ row(c, [plain('I will connect later', function () { move('app'); })]);
199
+ },
200
+ done: function () { return connected(); },
201
+ next: 'app',
202
+ },
203
+ app: {
204
+ view: 'dashboard',
205
+ target: function () { return q('#appBox .field-row') || byId('appCard'); },
206
+ enter: function () { seen.hadAddress = hasAddress(); },
207
+ show: function (c) {
208
+ title(c, 'Paste your ', 'app\'s address', '');
209
+ c.appendChild(el('p', null, hasAddress()
210
+ ? 'Saved: ' + state.app.address + '. Change it here if this is not the address you open your app at.'
211
+ : 'The address you open your app at - for a Lovable app it ends in .lovable.app. Paste it in the box and press Save the address.'));
212
+ if (hasAddress()) row(c, [go('Next', function () { move('record'); })]);
213
+ else waiting(c, 'Waiting for you to press Save the address');
214
+ },
215
+ done: function () { return hasAddress() && !seen.hadAddress; },
216
+ next: 'record',
217
+ },
218
+ record: {
219
+ view: 'dashboard',
220
+ target: function () { var b = q('#steps [data-action="record"]'); return b ? (b.closest('.controls') || b.closest('.step') || b) : stepRow(/Record your main flows/); },
221
+ enter: function () { seen.recordings = recordings(); seen.recordRan = false; },
222
+ show: function (c) {
223
+ if (busy) {
224
+ title(c, 'Recording ', 'now', '');
225
+ c.appendChild(el('p', null, 'Your app opened in a new window. Use it once like a customer: sign up or log in, then the main thing your app does. Then close that window.'));
226
+ waiting(c, 'Kryptheon is watching every step');
227
+ return;
228
+ }
229
+ title(c, 'Press ', 'Record', '');
230
+ c.appendChild(el('p', null, 'This is what happens: your app opens in a new window, you use it like a customer, and Kryptheon writes down every step - so it can do the same after every change and see what broke.'));
231
+ c.appendChild(demo());
232
+ if (recordings() > 0 && seen.recordings > 0) row(c, [go('I have recorded - next', function () { move('check'); })]);
233
+ else waiting(c, 'Waiting for you to press Record');
234
+ },
235
+ done: function () { return recordings() > seen.recordings; },
236
+ next: 'check',
237
+ },
238
+ // Not counted in the steps: a detour after recording when the recording signed in. Its password is never
239
+ // kept in the file, so until it is typed the recording replays nothing and every check comes back empty.
240
+ password: {
241
+ view: 'dashboard',
242
+ target: function () { return byId('pwBox'); },
243
+ show: function (c) {
244
+ if (busy) {
245
+ title(c, 'Running ', 'your recordings', '');
246
+ c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
247
+ waiting(c, 'Running');
248
+ return;
249
+ }
250
+ title(c, 'Type the ', 'password', ' you used');
251
+ c.appendChild(el('p', null, 'You signed in while recording. Kryptheon never keeps a password in the recording, so it cannot sign in by itself yet. Type the same password in the box, then press Save and run my recordings.'));
252
+ c.appendChild(el('p', null, 'It stays on this computer only.'));
253
+ waiting(c, 'Waiting for you to press Save');
254
+ },
255
+ done: function () { return !needsPassword() && !busy; },
256
+ next: 'check',
257
+ },
258
+ check: runStep('check', 'Press ', 'Check my app', '', 'One press runs every check on your app, one after another. Nothing is deleted, and every problem comes back with its proof.', 'findings'),
259
+ findings: {
260
+ view: 'findings',
261
+ target: function () { return q('#findingList .finding') || byId('findingList'); },
262
+ show: function (c) {
263
+ var n = findings().length;
264
+ if (!n) {
265
+ title(c, 'Nothing ', 'found', ' this time');
266
+ c.appendChild(el('p', null, 'Nothing found by the checks that ran. That is not the same as nothing wrong - the page Checks says what is not built yet. After every change your AI makes, press Check my app again.'));
267
+ row(c, [go('Next', function () { move('keep'); })]);
268
+ return;
269
+ }
270
+ title(c, n === 1 ? 'Your ' : 'Your ', n + (n === 1 ? ' finding' : ' findings'), '');
271
+ c.appendChild(el('p', null, 'Each one is something a check saw happen in your app, with its proof. The most serious is at the top. Open one to read what went wrong.'));
272
+ row(c, [go('Next', function () { move('fix'); })]);
273
+ },
274
+ },
275
+ fix: {
276
+ view: function () { return needsConnect() ? 'dashboard' : 'findings'; },
277
+ target: function () { return needsConnect() ? byId('accountCard') : (q('#findingList .finding .f-quick') || q('#findingList .finding') || byId('findingList')); },
278
+ enter: function () { seen.pressed = false; },
279
+ press: function () { if (!needsConnect()) seen.pressed = true; },
280
+ show: function (c) {
281
+ var f = findings()[0];
282
+ var hasPrompt = f && f.fixPrompt;
283
+ if (needsConnect()) {
284
+ title(c, 'Connect your ', 'free account', '');
285
+ c.appendChild(el('p', null, 'Fix prompts open when this dashboard is connected to your Kryptheon account: 5 free a month on Starter. Copy your connect code from kryptheon.tech/dashboard, paste it here and press Connect.'));
286
+ waiting(c, 'Waiting for you to press Connect');
287
+ row(c, [plain('I will fix it later', function () { move('keep'); })]);
288
+ return;
289
+ }
290
+ title(c, 'Copy the ', 'fix prompt', '');
291
+ c.appendChild(el('p', null, hasPrompt
292
+ ? 'Press Copy fix prompt, paste it into Lovable, Cursor or Claude, and let your AI make the change.'
293
+ : 'Press the first button here to open this fix prompt - then paste it into Lovable, Cursor or Claude and let your AI make the change.'));
294
+ if (seen.pressed) {
295
+ c.appendChild(el('p', null, 'Pasted it? Wait until your AI says it has finished.'));
296
+ row(c, [go('My AI made the change', function () { move('recheck'); })]);
297
+ } else {
298
+ waiting(c, 'Waiting for you to press it');
299
+ row(c, [plain('I will fix it later', function () { move('keep'); })]);
300
+ }
301
+ },
302
+ },
303
+ recheck: runStep('recheck', 'Press ', 'Check my app', ' again', 'It runs every check again on the changed app. A finding is marked FIXED only when the check that found it now passes.', 'keep'),
304
+ keep: {
305
+ view: 'dashboard',
306
+ target: function () { return byId('keepCard'); },
307
+ show: function (c) {
308
+ var a = state && state.autostart;
309
+ var d = state && state.daily;
310
+ title(c, 'Keep it ', 'running', '');
311
+ c.appendChild(el('p', null, (a && a.available ? 'Switch on Start with Windows: Kryptheon starts by itself every time you switch your laptop on, and this page opens once a day. ' : '') +
312
+ 'Switch on Check my app every day and pick a time: your checks run by themselves and a note in the corner of your screen says what is new.'));
313
+ var ready = (!a || !a.available || a.on) && d && d.on;
314
+ if (!ready) waiting(c, 'Switch them on, then press Done');
315
+ row(c, [go(ready ? 'Done' : 'Done for now', function () { move('end'); })]);
316
+ },
317
+ },
318
+ end: {
319
+ target: function () { return null; },
320
+ enter: function () { sparks(); keep({ done: true }); try { window.dispatchEvent(new CustomEvent('kryptheon:setup-done')); } catch (e) { /* the page asks again on its next load */ } },
321
+ show: function (c) { ending(c); },
322
+ },
323
+ // what a paid plan adds, each lit where it lives on this page
324
+ nightly: {
325
+ view: 'dashboard',
326
+ target: function () { return stepRow(/Check it every night/) || stepRow(/Connect your database/); },
327
+ show: function (c) {
328
+ title(c, 'Every ', 'night', '');
329
+ c.appendChild(el('p', null, 'Connect your database once here, then Set up nightly check. Every night it attacks a copy of your database - never your real data - and the result waits here in the morning.'));
330
+ row(c, [go('Back', function () { move('end'); })]);
331
+ },
332
+ },
333
+ fixall: {
334
+ view: 'findings',
335
+ target: function () { return q('#findingList .fix-all') || byId('findingList'); },
336
+ show: function (c) {
337
+ title(c, 'Fix ', 'all at once', '');
338
+ c.appendChild(el('p', null, 'One prompt with every fix, and rules that stop your AI from changing anything else. Copy it, paste it once, then Check my app.'));
339
+ row(c, [go('Back', function () { move('end'); })]);
340
+ },
341
+ },
342
+ };
343
+
344
+ // A step that waits for one whole run: lit on the button, then on the yes, then on the run itself.
345
+ function runStep(id, a, b, c2, text, next) {
346
+ return {
347
+ view: 'dashboard',
348
+ target: function () {
349
+ if (busy) return visible(byId('job')) ? byId('job') : null;
350
+ if (visible(byId('everyBox'))) return q('#everyBox .d-actions') || byId('everyBox');
351
+ return q('#launch .btn.go') ? byId('launch') : byId('runAll');
352
+ },
353
+ enter: function () { seen.ran = false; },
354
+ tick: function () { if (busy) seen.ran = true; },
355
+ show: function (c) {
356
+ if (busy) {
357
+ title(c, 'Checking ', 'your app', '');
358
+ c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
359
+ c.appendChild(el('p', null, 'Every check is running, one after another. You can watch each line here.'));
360
+ waiting(c, 'Running');
361
+ return;
362
+ }
363
+ if (visible(byId('everyBox'))) {
364
+ title(c, 'Say ', 'yes', ' once');
365
+ c.appendChild(el('p', null, 'Just above is everything it will run, and what it leaves out. Press the orange button to start. Nothing is ever deleted.'));
366
+ waiting(c, 'Waiting for your yes');
367
+ return;
368
+ }
369
+ title(c, a, b, c2);
370
+ c.appendChild(el('p', null, text));
371
+ waiting(c, 'Waiting for you to press it');
372
+ },
373
+ done: function () { return seen.ran && !busy; },
374
+ next: next,
375
+ };
376
+ }
377
+
378
+ /* ------------------------------- the card's parts ------------------------------- */
379
+
380
+ function title(c, before, lit2, after) {
381
+ var h = el('h2');
382
+ h.appendChild(document.createTextNode(before));
383
+ h.appendChild(el('em', null, lit2));
384
+ if (after) h.appendChild(document.createTextNode(after));
385
+ c.appendChild(h);
386
+ }
387
+ function waiting(c, text) { c.appendChild(el('div', 'kt-wait', text)); }
388
+ function go(text, fn) { var b = el('button', 'kt-btn kt-go', text); b.type = 'button'; b.addEventListener('click', fn); return b; }
389
+ function plain(text, fn) { var b = el('button', 'kt-btn', text); b.type = 'button'; b.addEventListener('click', fn); return b; }
390
+ function row(c, buttons, skipToo) {
391
+ var r = el('div', 'kt-row');
392
+ buttons.forEach(function (b) { r.appendChild(b); });
393
+ if (skipToo && optional) {
394
+ var s = el('button', 'kt-skip', 'Not now');
395
+ s.type = 'button';
396
+ s.addEventListener('click', function () { keep({ dismissed: true }); stop(); });
397
+ r.appendChild(s);
398
+ }
399
+ c.appendChild(r);
400
+ }
401
+ function demo() {
402
+ var d = el('div', 'kt-demo');
403
+ d.setAttribute('aria-hidden', 'true');
404
+ var top = el('div', 'kt-demo-top');
405
+ top.appendChild(el('span', 'kt-rec'));
406
+ top.appendChild(document.createTextNode('RECORDING - YOUR APP'));
407
+ d.appendChild(top);
408
+ [['Create your account', 'Sign up'], ['Pick a plan', 'Add to cart'], ['Checkout', 'Pay']].forEach(function (p) {
409
+ var page = el('div', 'kt-demo-page');
410
+ var inner = el('div');
411
+ inner.appendChild(el('b', null, p[0]));
412
+ inner.appendChild(el('span', null, p[1]));
413
+ page.appendChild(inner);
414
+ d.appendChild(page);
415
+ });
416
+ d.appendChild(el('div', 'kt-cursor'));
417
+ var log = el('div', 'kt-demo-log');
418
+ ['1 signed up', '2 added to cart', '3 paid'].forEach(function (t) { log.appendChild(el('i', null, t)); });
419
+ d.appendChild(log);
420
+ return d;
421
+ }
422
+
423
+ function ending(c) {
424
+ var p = plan();
425
+ var d = state && state.daily;
426
+ title(c, 'Congratulations - ', 'you are set up', '');
427
+ c.appendChild(el('p', null, 'You did every part yourself. From now on Kryptheon does the watching.'));
428
+ c.appendChild(el('div', 'kt-h', 'What happens now, every day'));
429
+ var list = el('ul', 'kt-list');
430
+ [
431
+ ['1', 'When your laptop starts', (state && state.autostart && state.autostart.on) ? 'Kryptheon starts by itself, and this page opens in your browser at your first sign-in of the day.' : 'Open this dashboard the way you did today - or switch on Start with Windows and it starts by itself.'],
432
+ ['2', d && d.on ? 'Every day at ' + d.at : 'Once a day', d && d.on ? 'Every check runs by itself, and a note in the corner of your screen says what is new and what got fixed.' : 'Switch on Check my app every day, and your checks run by themselves at a time you pick.'],
433
+ ['3', 'After every change your AI makes', 'Press Check my app. It uses your app the way you recorded it and tells you what broke.'],
434
+ ['4', 'When something broke', 'Copy the fix prompt into your AI, then Check my app again - FIXED only when it really is.'],
435
+ ].forEach(function (x) {
436
+ var li = el('li');
437
+ li.appendChild(el('span', null, x[0]));
438
+ var t = el('div');
439
+ t.appendChild(el('b', null, x[1]));
440
+ t.appendChild(el('small', null, x[2]));
441
+ li.appendChild(t);
442
+ list.appendChild(li);
443
+ });
444
+ c.appendChild(list);
445
+
446
+ if (p === 'pro' || p === 'studio') {
447
+ c.appendChild(el('div', 'kt-h', 'What your ' + (p === 'pro' ? 'Pro' : 'Studio') + ' plan adds'));
448
+ var extra = el('ul', 'kt-list');
449
+ var items = [
450
+ ['N', 'Every night, a test break-in on a copy of your database', 'Set up once, then it runs inside your database while you sleep.', 'nightly'],
451
+ ['A', 'Every fix in one prompt', 'Copy one prompt for all, paste once.', 'fixall'],
452
+ ['M', 'A morning email', 'And an alert when a new problem appears - set on kryptheon.tech.', null],
453
+ ];
454
+ if (p === 'studio') items.push(['S', 'Alerts to Slack, and a report for your client', 'Both on your account at kryptheon.tech, for up to 15 apps.', null]);
455
+ items.forEach(function (x) {
456
+ var li = el('li');
457
+ li.appendChild(el('span', null, x[0]));
458
+ var t = el('div');
459
+ t.appendChild(el('b', null, x[1]));
460
+ t.appendChild(el('small', null, x[2]));
461
+ if (x[3]) t.appendChild(plain('Show me', (function (id) { return function () { move(id); }; })(x[3])));
462
+ li.appendChild(t);
463
+ extra.appendChild(li);
464
+ });
465
+ c.appendChild(extra);
466
+ } else {
467
+ c.appendChild(el('div', 'kt-h', 'You are on Starter - 5 fix prompts a month'));
468
+ var plans = el('div', 'kt-plans');
469
+ [['Pro', '₹499 / month', ['Every fix prompt, for every problem', 'One prompt to fix them all', 'Every night, a test break-in on a copy of your database', 'A morning email and new-problem alerts', '3 apps'], true],
470
+ ['Studio', '₹799 / month', ['Everything in Pro', 'Alerts to Slack or any webhook', 'A report you can hand a client', '15 apps, a year of history'], false]].forEach(function (x) {
471
+ var box = el('div', 'kt-plan' + (x[3] ? ' kt-best' : ''));
472
+ box.appendChild(el('b', null, x[0]));
473
+ box.appendChild(el('strong', null, x[1]));
474
+ var ul = el('ul');
475
+ x[2].forEach(function (t) { ul.appendChild(el('li', null, t)); });
476
+ box.appendChild(ul);
477
+ plans.appendChild(box);
478
+ });
479
+ c.appendChild(plans);
480
+ var link = el('a', 'kt-btn', 'See plans on kryptheon.tech');
481
+ link.href = 'https://kryptheon.tech/pricing/';
482
+ link.target = '_blank';
483
+ link.rel = 'noopener noreferrer';
484
+ link.style.display = 'inline-flex';
485
+ link.style.alignItems = 'center';
486
+ link.style.textDecoration = 'none';
487
+ var r = el('div', 'kt-row');
488
+ r.appendChild(link);
489
+ c.appendChild(r);
490
+ }
491
+ row(c, [go('Finish', function () { stop(); })]);
492
+ }
493
+
494
+ // a few sparks rising, once, at the end
495
+ function sparks() {
496
+ if (still) return;
497
+ var cv = el('canvas', 'kt-sparks');
498
+ document.body.appendChild(cv);
499
+ var cx = cv.getContext('2d');
500
+ var w = cv.width = window.innerWidth;
501
+ var h = cv.height = window.innerHeight;
502
+ var bits = [];
503
+ for (var i = 0; i < 90; i++) bits.push({ x: w / 2 + (Math.random() - 0.5) * 120, y: h * 0.6, vx: (Math.random() - 0.5) * 7, vy: -4 - Math.random() * 7, r: 1.5 + Math.random() * 2.5, life: 1 });
504
+ var t0 = Date.now();
505
+ (function draw() {
506
+ cx.clearRect(0, 0, w, h);
507
+ bits.forEach(function (b) {
508
+ b.x += b.vx; b.y += b.vy; b.vy += 0.16; b.life -= 0.012;
509
+ if (b.life <= 0) return;
510
+ cx.fillStyle = 'rgba(255,' + (90 + Math.round(b.life * 80)) + ',20,' + b.life + ')';
511
+ cx.beginPath(); cx.arc(b.x, b.y, b.r, 0, Math.PI * 2); cx.fill();
512
+ });
513
+ if (Date.now() - t0 < 2600) window.requestAnimationFrame(draw);
514
+ else cv.remove();
515
+ })();
516
+ }
517
+
518
+ /* ------------------------------- moving the light ------------------------------- */
519
+
520
+ function place() {
521
+ if (!on) return;
522
+ var step = STEPS[at];
523
+ var target = step && step.target ? step.target() : null;
524
+ if (target && !visible(target)) target = null;
525
+ if (target !== lit) {
526
+ if (lit) lit.classList.remove('kt-lit');
527
+ lit = target;
528
+ if (lit) {
529
+ if (!still) lit.classList.add('kt-lit');
530
+ // scrolled to once per part: the page redraws its own boxes every few seconds, and a lit box drawn again is the same part
531
+ var what = at + '|' + (lit.id || lit.className.replace(/\s*kt-lit/, ''));
532
+ if (what !== scrolledTo) {
533
+ scrolledTo = what;
534
+ // near the top, so the card has room under it; a panel fixed in the corner needs no scrolling
535
+ if (window.getComputedStyle(lit).position !== 'fixed') {
536
+ var top = lit.getBoundingClientRect().top + window.pageYOffset - 90;
537
+ window.scrollTo({ top: Math.max(0, top), behavior: still ? 'auto' : 'smooth' });
538
+ }
539
+ }
540
+ }
541
+ }
542
+ var vw = window.innerWidth;
543
+ var vh = window.innerHeight;
544
+ if (!lit) {
545
+ // nothing to light: the whole room dark, the card in the middle
546
+ lens.className = 'kt-lens kt-none';
547
+ lens.hidden = true;
548
+ blocks.forEach(function (b, i) { b.hidden = i !== 0; });
549
+ blocks[0].style.cssText = 'left:0;top:0;width:100vw;height:100vh;background:rgba(9,7,5,.86)';
550
+ card.classList.add('kt-mid');
551
+ card.style.left = Math.max(14, (vw - card.offsetWidth) / 2) + 'px';
552
+ card.style.top = Math.max(20, (vh - card.offsetHeight) / 2) + 'px';
553
+ return;
554
+ }
555
+ card.classList.remove('kt-mid');
556
+ var r = lit.getBoundingClientRect();
557
+ var pad = 10;
558
+ var x = Math.max(4, r.left - pad);
559
+ var y = Math.max(4, r.top - pad);
560
+ var x2 = Math.min(vw - 4, r.right + pad);
561
+ var y2 = Math.min(vh - 4, r.bottom + pad);
562
+ lens.className = 'kt-lens';
563
+ lens.hidden = false;
564
+ lens.style.left = x + 'px';
565
+ lens.style.top = y + 'px';
566
+ lens.style.width = Math.max(0, x2 - x) + 'px';
567
+ lens.style.height = Math.max(0, y2 - y) + 'px';
568
+ // four panes around the lit part take every click that is not for it
569
+ var sides = [
570
+ [0, 0, vw, y],
571
+ [0, y, x, y2 - y],
572
+ [x2, y, vw - x2, y2 - y],
573
+ [0, y2, vw, vh - y2],
574
+ ];
575
+ blocks.forEach(function (b, i) {
576
+ b.hidden = false;
577
+ var s = sides[i];
578
+ b.style.cssText = 'left:' + s[0] + 'px;top:' + s[1] + 'px;width:' + Math.max(0, s[2]) + 'px;height:' + Math.max(0, s[3]) + 'px';
579
+ });
580
+ // the card where there is room: below, above, then to the side, then over the lower part
581
+ var cw = card.offsetWidth;
582
+ var ch = card.offsetHeight;
583
+ var left = Math.min(Math.max(14, r.left), vw - cw - 14);
584
+ var top;
585
+ if (y2 + 14 + ch < vh - 10) top = y2 + 14;
586
+ else if (y - 14 - ch > 10) top = y - 14 - ch;
587
+ else if (x2 + 14 + cw < vw - 10) { left = x2 + 14; top = Math.min(Math.max(10, r.top), vh - ch - 10); }
588
+ else if (x - 14 - cw > 10) { left = x - 14 - cw; top = Math.min(Math.max(10, r.top), vh - ch - 10); }
589
+ else top = vh - ch - 12;
590
+ card.style.left = left + 'px';
591
+ card.style.top = Math.max(10, top) + 'px';
592
+ }
593
+
594
+ var scrolledTo = '';
595
+ function draw() {
596
+ if (!on) return;
597
+ var step = STEPS[at];
598
+ var where = typeof step.view === 'function' ? step.view() : step.view;
599
+ if (where) view(where);
600
+ clear(card);
601
+ var n = MAIN.indexOf(at);
602
+ if (n >= 0) {
603
+ var head = el('div', 'kt-step');
604
+ head.appendChild(el('span', null, 'Step ' + (n + 1) + ' of ' + MAIN.length));
605
+ if (optional) {
606
+ var skip = el('button', 'kt-skip', 'Close the guide');
607
+ skip.type = 'button';
608
+ skip.addEventListener('click', function () { keep({ dismissed: true }); stop(); });
609
+ head.appendChild(skip);
610
+ } else if (Date.now() - stepSince > STUCK_MS) {
611
+ // a way out for someone who cannot do this step now - not a "no": it starts again next time
612
+ var stuck = el('button', 'kt-skip', 'Stuck here? Leave for now');
613
+ stuck.type = 'button';
614
+ stuck.addEventListener('click', function () { stop(); });
615
+ head.appendChild(stuck);
616
+ }
617
+ card.appendChild(head);
618
+ var bar = el('div', 'kt-bar');
619
+ MAIN.forEach(function (m, i) { bar.appendChild(el('i', i <= n ? 'on' : null)); });
620
+ card.appendChild(bar);
621
+ }
622
+ step.show(card);
623
+ if (n >= 0) {
624
+ var prev = n > 0 ? MAIN[n - 1] : null;
625
+ if (prev === 'connect' && connected()) prev = null;
626
+ var nav = el('div', 'kt-nav');
627
+ if (prev) nav.appendChild(plain('Back', function () { move(prev, true); }));
628
+ if (seen.back === at && n < MAIN.length - 1) nav.appendChild(plain('Next', function () { move(MAIN[n + 1]); }));
629
+ if (nav.firstChild) card.appendChild(nav);
630
+ }
631
+ card.hidden = false;
632
+ lens.hidden = false;
633
+ drawn = signature();
634
+ place();
635
+ }
636
+ var drawn = '';
637
+ function signature() {
638
+ return [at, busy, Date.now() - stepSince > STUCK_MS, seen.connectWhy || '', visible(byId('everyBox')), hasAddress(), recordings(), findings().length, seen.pressed, needsConnect(), connected(),
639
+ !!((q('#accountBox input') || {}).value),
640
+ state && state.autostart && state.autostart.on, state && state.daily && state.daily.on, needsPassword()].join('|');
641
+ }
642
+
643
+ function move(id, back) {
644
+ // also when the guide opens again at a step past recording: the password comes first
645
+ if (!busy && needsPassword() && (id === 'check' || id === 'findings')) id = 'password';
646
+ at = id;
647
+ seen.back = back ? id : null;
648
+ stepSince = Date.now();
649
+ keep({ at: id });
650
+ var step = STEPS[id];
651
+ if (step.enter) step.enter();
652
+ if (lit) { lit.classList.remove('kt-lit'); lit = null; }
653
+ window.setTimeout(draw, 60);
654
+ }
655
+
656
+ function start(from, byChoice) {
657
+ optional = !!byChoice;
658
+ MAIN = (connected() ? [] : ['connect']).concat(BASE);
659
+ if (from === 'connect' && connected()) from = 'app';
660
+ on = true;
661
+ document.body.classList.add('kt-on');
662
+ move(from || 'hello');
663
+ loop();
664
+ }
665
+ function stop() {
666
+ on = false;
667
+ document.body.classList.remove('kt-on');
668
+ at = null;
669
+ card.hidden = true;
670
+ lens.hidden = true;
671
+ blocks.forEach(function (b) { b.hidden = true; });
672
+ if (lit) { lit.classList.remove('kt-lit'); lit = null; }
673
+ window.cancelAnimationFrame(frame);
674
+ }
675
+ function loop() {
676
+ if (!on) return;
677
+ // some parts open without the server saying anything - the yes box of Check my app
678
+ if (signature() !== drawn) draw();
679
+ place();
680
+ frame = window.requestAnimationFrame(loop);
681
+ }
682
+
683
+ // A press inside the lit part, for steps that wait for one.
684
+ document.addEventListener('click', function (e) {
685
+ if (!on || !lit || !STEPS[at].press) return;
686
+ if (lit.contains(e.target) && e.target.closest('button')) { STEPS[at].press(); window.setTimeout(draw, 30); }
687
+ }, true);
688
+ document.addEventListener('keydown', function (e) {
689
+ if (on && optional && e.key === 'Escape') { keep({ dismissed: true }); stop(); }
690
+ });
691
+ window.addEventListener('resize', function () { if (on) place(); });
692
+ window.addEventListener('kryptheon:connect-failed', function (e) { seen.connectWhy = String((e.detail && e.detail.why) || 'kryptheon.tech did not accept that code'); if (on) draw(); });
693
+
694
+ // The page says what changed: move on when a step is done, redraw when what it says has changed.
695
+ var guideBtn = null;
696
+ window.addEventListener('kryptheon:state', function (e) {
697
+ state = (e.detail && e.detail.state) || state;
698
+ busy = !!(e.detail && e.detail.busy);
699
+ if (!state) return;
700
+ if (!guideBtn && byId('runAll')) {
701
+ guideBtn = el('button', 'btn kt-guide-btn', 'Guide me');
702
+ guideBtn.type = 'button';
703
+ guideBtn.addEventListener('click', function () { if (!on) start(read().at && read().at !== 'end' ? read().at : 'hello', true); });
704
+ byId('runAll').parentNode.insertBefore(guideBtn, byId('runAll'));
705
+ }
706
+ if (!on) {
707
+ var kept = read();
708
+ // #tour from a link, #tour-connect when a connect code came with the person from kryptheon.tech
709
+ var asked = /^#tour(-connect)?$/.exec(location.hash);
710
+ if (asked) { history.replaceState(null, '', '#dashboard'); return start(asked[1] ? 'connect' : 'hello'); }
711
+ // by itself only for someone who has not set up yet, and only until they finish or close it
712
+ if (!kept.done && !kept.dismissed && (kept.at || !hasAddress() || recordings() === 0)) start(kept.at && STEPS[kept.at] ? kept.at : 'hello');
713
+ return;
714
+ }
715
+ // A recording waiting for its password comes before checking: a check without it tries nothing.
716
+ if (!busy && needsPassword() && (at === 'check' || at === 'findings')) return move('password');
717
+ var step = STEPS[at];
718
+ if (step.tick) step.tick();
719
+ if (step.done && step.done()) return move(step.next);
720
+ if (signature() !== drawn) draw();
721
+ });
722
+ })();