@preprio/toolkit 0.2.0-beta.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ __export(astro_exports, {
30
30
  module.exports = __toCommonJS(astro_exports);
31
31
 
32
32
  // src/version.ts
33
- var VERSION = "0.2.0-beta.7";
33
+ var VERSION = "0.2.0";
34
34
 
35
35
  // src/core/features.ts
36
36
  function isEnabled(config) {
@@ -100,7 +100,11 @@ function getPreprHeadersFromHeaders(headers) {
100
100
  }
101
101
  function validatePreprToken(token) {
102
102
  if (!token) {
103
- throw new PreprError("Token is required", "MISSING_TOKEN", "validatePreprToken");
103
+ throw new PreprError(
104
+ "Token is required",
105
+ "MISSING_TOKEN",
106
+ "validatePreprToken"
107
+ );
104
108
  }
105
109
  if (!token.startsWith("https://")) {
106
110
  throw new PreprError(
@@ -222,7 +226,11 @@ function parseCookies(request) {
222
226
  const name = part.slice(0, eq).trim();
223
227
  const value = part.slice(eq + 1).trim();
224
228
  if (!name) continue;
225
- cookies.set(name, decodeURIComponent(value));
229
+ try {
230
+ cookies.set(name, decodeURIComponent(value));
231
+ } catch {
232
+ cookies.set(name, value);
233
+ }
226
234
  }
227
235
  return cookies;
228
236
  }
@@ -261,7 +269,10 @@ function processPreprRequest(request, opts) {
261
269
  if (userAgent) {
262
270
  requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
263
271
  }
264
- requestHeaders.set("Prepr-Package", `@preprio/toolkit@${opts?.version ?? VERSION}`);
272
+ requestHeaders.set(
273
+ "Prepr-Package",
274
+ `@preprio/toolkit@${opts?.version ?? VERSION}`
275
+ );
265
276
  const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
266
277
  if (ip) {
267
278
  requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
@@ -270,7 +281,7 @@ function processPreprRequest(request, opts) {
270
281
  if (hutkCookie) {
271
282
  requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
272
283
  }
273
- let uid = requestCookies.get(COOKIE_UID);
284
+ let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
274
285
  if (!uid) {
275
286
  uid = crypto.randomUUID();
276
287
  responseCookies.push({
@@ -346,7 +357,10 @@ function processPreprRequest(request, opts) {
346
357
 
347
358
  // src/astro/index.ts
348
359
  async function onPreprRequest(context, next, options) {
349
- const { requestHeaders, responseCookies } = processPreprRequest(context.request, options);
360
+ const { requestHeaders, responseCookies } = processPreprRequest(
361
+ context.request,
362
+ options
363
+ );
350
364
  requestHeaders.forEach((value, key) => {
351
365
  context.request.headers.set(key, value);
352
366
  });
@@ -90,7 +90,7 @@ type AstroNext = () => Promise<Response>;
90
90
  * Astro middleware entry point: computes the Prepr headers/cookies for this
91
91
  * request, forwards the headers downstream and sets the cookies on the response.
92
92
  *
93
- * Astro hands downstream code the same `Request` instance we get here, so the
93
+ * Astro hands downstream code the same `Request` instance this middleware receives, so the
94
94
  * headers are mutated in place — building a new `Request` would go nowhere,
95
95
  * there's no way to hand a replacement back out of middleware.
96
96
  */
@@ -90,7 +90,7 @@ type AstroNext = () => Promise<Response>;
90
90
  * Astro middleware entry point: computes the Prepr headers/cookies for this
91
91
  * request, forwards the headers downstream and sets the cookies on the response.
92
92
  *
93
- * Astro hands downstream code the same `Request` instance we get here, so the
93
+ * Astro hands downstream code the same `Request` instance this middleware receives, so the
94
94
  * headers are mutated in place — building a new `Request` would go nowhere,
95
95
  * there's no way to hand a replacement back out of middleware.
96
96
  */
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.2.0-beta.7";
2
+ var VERSION = "0.2.0";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
@@ -69,7 +69,11 @@ function getPreprHeadersFromHeaders(headers) {
69
69
  }
70
70
  function validatePreprToken(token) {
71
71
  if (!token) {
72
- throw new PreprError("Token is required", "MISSING_TOKEN", "validatePreprToken");
72
+ throw new PreprError(
73
+ "Token is required",
74
+ "MISSING_TOKEN",
75
+ "validatePreprToken"
76
+ );
73
77
  }
74
78
  if (!token.startsWith("https://")) {
75
79
  throw new PreprError(
@@ -191,7 +195,11 @@ function parseCookies(request) {
191
195
  const name = part.slice(0, eq).trim();
192
196
  const value = part.slice(eq + 1).trim();
193
197
  if (!name) continue;
194
- cookies.set(name, decodeURIComponent(value));
198
+ try {
199
+ cookies.set(name, decodeURIComponent(value));
200
+ } catch {
201
+ cookies.set(name, value);
202
+ }
195
203
  }
196
204
  return cookies;
197
205
  }
@@ -230,7 +238,10 @@ function processPreprRequest(request, opts) {
230
238
  if (userAgent) {
231
239
  requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
232
240
  }
233
- requestHeaders.set("Prepr-Package", `@preprio/toolkit@${opts?.version ?? VERSION}`);
241
+ requestHeaders.set(
242
+ "Prepr-Package",
243
+ `@preprio/toolkit@${opts?.version ?? VERSION}`
244
+ );
234
245
  const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
235
246
  if (ip) {
236
247
  requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
@@ -239,7 +250,7 @@ function processPreprRequest(request, opts) {
239
250
  if (hutkCookie) {
240
251
  requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
241
252
  }
242
- let uid = requestCookies.get(COOKIE_UID);
253
+ let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
243
254
  if (!uid) {
244
255
  uid = crypto.randomUUID();
245
256
  responseCookies.push({
@@ -315,7 +326,10 @@ function processPreprRequest(request, opts) {
315
326
 
316
327
  // src/astro/index.ts
317
328
  async function onPreprRequest(context, next, options) {
318
- const { requestHeaders, responseCookies } = processPreprRequest(context.request, options);
329
+ const { requestHeaders, responseCookies } = processPreprRequest(
330
+ context.request,
331
+ options
332
+ );
319
333
  requestHeaders.forEach((value, key) => {
320
334
  context.request.headers.set(key, value);
321
335
  });
@@ -142,9 +142,7 @@ function decodeStega(str) {
142
142
  const match = str.match(/{"origin.*?}/);
143
143
  if (match) {
144
144
  try {
145
- const decodedMatch = vercelStegaDecode(
146
- match[0]
147
- );
145
+ const decodedMatch = vercelStegaDecode(match[0]);
148
146
  if (decodedMatch?.href) {
149
147
  return decodedMatch;
150
148
  }
@@ -570,8 +568,13 @@ function createStegaController(opts) {
570
568
  overlay.hide();
571
569
  }
572
570
  }, 16);
573
- document.addEventListener("mousemove", throttledMouseMove);
574
- window.addEventListener("scroll", handleScroll, { capture: true });
571
+ document.addEventListener("mousemove", throttledMouseMove, {
572
+ passive: true
573
+ });
574
+ window.addEventListener("scroll", handleScroll, {
575
+ capture: true,
576
+ passive: true
577
+ });
575
578
  initialized = true;
576
579
  debug5.log("stega controller started");
577
580
  };
@@ -1028,7 +1031,7 @@ var CLOSE_ICON_SVG = `<svg width="10" height="10" viewBox="0 0 10 10" fill="none
1028
1031
  </svg>`;
1029
1032
 
1030
1033
  // src/core/ui/toolbar.generated.ts
1031
- var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
1034
+ var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle>span{display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
1032
1035
 
1033
1036
  // ../../node_modules/.pnpm/preact@10.29.7/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
1034
1037
  var f2 = 0;
@@ -1042,7 +1045,10 @@ function u2(e2, t3, n2, o2, i2, u3) {
1042
1045
  }
1043
1046
 
1044
1047
  // src/core/ui/panel.tsx
1045
- function RawSvg({ svg, className }) {
1048
+ function RawSvg({
1049
+ svg,
1050
+ className
1051
+ }) {
1046
1052
  return /* @__PURE__ */ u2(
1047
1053
  "span",
1048
1054
  {
@@ -1309,7 +1315,7 @@ function StatusPill({
1309
1315
  {
1310
1316
  class: "prepr-status-x",
1311
1317
  "data-prepr": "status-x",
1312
- hidden: !features.segments || !state.previewMode || state.selectedSegment === null,
1318
+ hidden: !state.previewMode || !(features.segments && state.selectedSegment !== null || features.abTesting && state.selectedVariant === "B"),
1313
1319
  children: /* @__PURE__ */ u2(RawSvg, { svg: XMARK_ICON_SVG })
1314
1320
  }
1315
1321
  )
@@ -1613,9 +1619,7 @@ var PreprToolbarElement = class extends HTMLElementBase {
1613
1619
  ) ?? null;
1614
1620
  }
1615
1621
  optionsList() {
1616
- return this.shadowRoot?.querySelector(
1617
- '[data-prepr="options"]'
1618
- ) ?? null;
1622
+ return this.shadowRoot?.querySelector('[data-prepr="options"]') ?? null;
1619
1623
  }
1620
1624
  onListboxKeydown(event) {
1621
1625
  const e2 = event;
@@ -1991,7 +1995,9 @@ function createChangeHandler(deps) {
1991
1995
  }
1992
1996
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1993
1997
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1994
- sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
1998
+ sendPreprEvent("preview_mode_toggled", {
1999
+ previewMode: after.previewMode
2000
+ });
1995
2001
  if (!after.isIframe) {
1996
2002
  const [path, existing] = splitPath(deps.currentPath());
1997
2003
  const params = new URLSearchParams(existing);
@@ -2133,9 +2139,13 @@ function createPreprPreview(opts = {}) {
2133
2139
  const bridge = createIframeBridge(store, {
2134
2140
  allowedEditorOrigins: options?.allowedEditorOrigins
2135
2141
  });
2136
- sendPreprEvent("getScrollPosition", { value: 0 }, {
2137
- allowUntrustedTarget: true
2138
- });
2142
+ sendPreprEvent(
2143
+ "getScrollPosition",
2144
+ { value: 0 },
2145
+ {
2146
+ allowUntrustedTarget: true
2147
+ }
2148
+ );
2139
2149
  if (isIframe) {
2140
2150
  bridge.start();
2141
2151
  }
package/dist/index.cjs CHANGED
@@ -44,7 +44,7 @@ __export(src_exports, {
44
44
  module.exports = __toCommonJS(src_exports);
45
45
 
46
46
  // src/version.ts
47
- var VERSION = "0.2.0-beta.7";
47
+ var VERSION = "0.2.0";
48
48
 
49
49
  // src/core/features.ts
50
50
  function isEnabled(config) {
@@ -393,9 +393,7 @@ function decodeStega(str) {
393
393
  const match = str.match(/{"origin.*?}/);
394
394
  if (match) {
395
395
  try {
396
- const decodedMatch = (0, import_stega.vercelStegaDecode)(
397
- match[0]
398
- );
396
+ const decodedMatch = (0, import_stega.vercelStegaDecode)(match[0]);
399
397
  if (decodedMatch?.href) {
400
398
  return decodedMatch;
401
399
  }
@@ -923,8 +921,13 @@ function createStegaController(opts) {
923
921
  overlay.hide();
924
922
  }
925
923
  }, 16);
926
- document.addEventListener("mousemove", throttledMouseMove);
927
- window.addEventListener("scroll", handleScroll, { capture: true });
924
+ document.addEventListener("mousemove", throttledMouseMove, {
925
+ passive: true
926
+ });
927
+ window.addEventListener("scroll", handleScroll, {
928
+ capture: true,
929
+ passive: true
930
+ });
928
931
  initialized = true;
929
932
  debug6.log("stega controller started");
930
933
  };
@@ -1067,7 +1070,9 @@ function createChangeHandler(deps) {
1067
1070
  }
1068
1071
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1069
1072
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1070
- sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
1073
+ sendPreprEvent("preview_mode_toggled", {
1074
+ previewMode: after.previewMode
1075
+ });
1071
1076
  if (!after.isIframe) {
1072
1077
  const [path, existing] = splitPath(deps.currentPath());
1073
1078
  const params = new URLSearchParams(existing);
@@ -1374,7 +1379,7 @@ var CLOSE_ICON_SVG = `<svg width="10" height="10" viewBox="0 0 10 10" fill="none
1374
1379
  </svg>`;
1375
1380
 
1376
1381
  // src/core/ui/toolbar.generated.ts
1377
- var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
1382
+ var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle>span{display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
1378
1383
 
1379
1384
  // ../../node_modules/.pnpm/preact@10.29.7/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
1380
1385
  var f2 = 0;
@@ -1388,7 +1393,10 @@ function u2(e2, t3, n2, o2, i2, u3) {
1388
1393
  }
1389
1394
 
1390
1395
  // src/core/ui/panel.tsx
1391
- function RawSvg({ svg, className }) {
1396
+ function RawSvg({
1397
+ svg,
1398
+ className
1399
+ }) {
1392
1400
  return /* @__PURE__ */ u2(
1393
1401
  "span",
1394
1402
  {
@@ -1655,7 +1663,7 @@ function StatusPill({
1655
1663
  {
1656
1664
  class: "prepr-status-x",
1657
1665
  "data-prepr": "status-x",
1658
- hidden: !features.segments || !state.previewMode || state.selectedSegment === null,
1666
+ hidden: !state.previewMode || !(features.segments && state.selectedSegment !== null || features.abTesting && state.selectedVariant === "B"),
1659
1667
  children: /* @__PURE__ */ u2(RawSvg, { svg: XMARK_ICON_SVG })
1660
1668
  }
1661
1669
  )
@@ -1959,9 +1967,7 @@ var PreprToolbarElement = class extends HTMLElementBase {
1959
1967
  ) ?? null;
1960
1968
  }
1961
1969
  optionsList() {
1962
- return this.shadowRoot?.querySelector(
1963
- '[data-prepr="options"]'
1964
- ) ?? null;
1970
+ return this.shadowRoot?.querySelector('[data-prepr="options"]') ?? null;
1965
1971
  }
1966
1972
  onListboxKeydown(event) {
1967
1973
  const e2 = event;
@@ -2181,9 +2187,13 @@ function createPreprPreview(opts = {}) {
2181
2187
  const bridge = createIframeBridge(store, {
2182
2188
  allowedEditorOrigins: options?.allowedEditorOrigins
2183
2189
  });
2184
- sendPreprEvent("getScrollPosition", { value: 0 }, {
2185
- allowUntrustedTarget: true
2186
- });
2190
+ sendPreprEvent(
2191
+ "getScrollPosition",
2192
+ { value: 0 },
2193
+ {
2194
+ allowUntrustedTarget: true
2195
+ }
2196
+ );
2187
2197
  if (isIframe) {
2188
2198
  bridge.start();
2189
2199
  }
@@ -2252,7 +2262,11 @@ function getPreprHeadersFromHeaders(headers) {
2252
2262
  }
2253
2263
  function validatePreprToken(token) {
2254
2264
  if (!token) {
2255
- throw new PreprError("Token is required", "MISSING_TOKEN", "validatePreprToken");
2265
+ throw new PreprError(
2266
+ "Token is required",
2267
+ "MISSING_TOKEN",
2268
+ "validatePreprToken"
2269
+ );
2256
2270
  }
2257
2271
  if (!token.startsWith("https://")) {
2258
2272
  throw new PreprError(
@@ -2379,7 +2393,11 @@ function parseCookies(request) {
2379
2393
  const name = part.slice(0, eq).trim();
2380
2394
  const value = part.slice(eq + 1).trim();
2381
2395
  if (!name) continue;
2382
- cookies.set(name, decodeURIComponent(value));
2396
+ try {
2397
+ cookies.set(name, decodeURIComponent(value));
2398
+ } catch {
2399
+ cookies.set(name, value);
2400
+ }
2383
2401
  }
2384
2402
  return cookies;
2385
2403
  }
@@ -2418,7 +2436,10 @@ function processPreprRequest(request, opts) {
2418
2436
  if (userAgent) {
2419
2437
  requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
2420
2438
  }
2421
- requestHeaders.set("Prepr-Package", `@preprio/toolkit@${opts?.version ?? VERSION}`);
2439
+ requestHeaders.set(
2440
+ "Prepr-Package",
2441
+ `@preprio/toolkit@${opts?.version ?? VERSION}`
2442
+ );
2422
2443
  const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
2423
2444
  if (ip) {
2424
2445
  requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
@@ -2427,7 +2448,7 @@ function processPreprRequest(request, opts) {
2427
2448
  if (hutkCookie) {
2428
2449
  requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
2429
2450
  }
2430
- let uid = requestCookies.get(COOKIE_UID);
2451
+ let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
2431
2452
  if (!uid) {
2432
2453
  uid = crypto.randomUUID();
2433
2454
  responseCookies.push({
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
5
5
  * Package version; must match package.json. Lives in its own leaf module so
6
6
  * core can import it without cycling through the barrel.
7
7
  */
8
- declare const VERSION = "0.2.0-beta.7";
8
+ declare const VERSION = "0.2.0";
9
9
 
10
10
  /**
11
11
  * Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
5
5
  * Package version; must match package.json. Lives in its own leaf module so
6
6
  * core can import it without cycling through the barrel.
7
7
  */
8
- declare const VERSION = "0.2.0-beta.7";
8
+ declare const VERSION = "0.2.0";
9
9
 
10
10
  /**
11
11
  * Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
package/dist/index.js CHANGED
@@ -17,10 +17,10 @@ import {
17
17
  setTrackingParam,
18
18
  stegaClean,
19
19
  trackEvent
20
- } from "./chunk-P6VTLWM4.js";
20
+ } from "./chunk-4PJK6IQ4.js";
21
21
 
22
22
  // src/version.ts
23
- var VERSION = "0.2.0-beta.7";
23
+ var VERSION = "0.2.0";
24
24
 
25
25
  // src/core/server.ts
26
26
  var PreprError = class extends Error {
@@ -72,7 +72,11 @@ function getPreprHeadersFromHeaders(headers) {
72
72
  }
73
73
  function validatePreprToken(token) {
74
74
  if (!token) {
75
- throw new PreprError("Token is required", "MISSING_TOKEN", "validatePreprToken");
75
+ throw new PreprError(
76
+ "Token is required",
77
+ "MISSING_TOKEN",
78
+ "validatePreprToken"
79
+ );
76
80
  }
77
81
  if (!token.startsWith("https://")) {
78
82
  throw new PreprError(
@@ -199,7 +203,11 @@ function parseCookies(request) {
199
203
  const name = part.slice(0, eq).trim();
200
204
  const value = part.slice(eq + 1).trim();
201
205
  if (!name) continue;
202
- cookies.set(name, decodeURIComponent(value));
206
+ try {
207
+ cookies.set(name, decodeURIComponent(value));
208
+ } catch {
209
+ cookies.set(name, value);
210
+ }
203
211
  }
204
212
  return cookies;
205
213
  }
@@ -238,7 +246,10 @@ function processPreprRequest(request, opts) {
238
246
  if (userAgent) {
239
247
  requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
240
248
  }
241
- requestHeaders.set("Prepr-Package", `@preprio/toolkit@${opts?.version ?? VERSION}`);
249
+ requestHeaders.set(
250
+ "Prepr-Package",
251
+ `@preprio/toolkit@${opts?.version ?? VERSION}`
252
+ );
242
253
  const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
243
254
  if (ip) {
244
255
  requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
@@ -247,7 +258,7 @@ function processPreprRequest(request, opts) {
247
258
  if (hutkCookie) {
248
259
  requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
249
260
  }
250
- let uid = requestCookies.get(COOKIE_UID);
261
+ let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
251
262
  if (!uid) {
252
263
  uid = crypto.randomUUID();
253
264
  responseCookies.push({