kenobi-js 0.1.29 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Kenobi SDK v0.1.28
2
+ * Kenobi SDK v0.1.30
3
3
  * (c) 2025 Kenobi.ai
4
4
  */
5
5
  "use strict";
@@ -2488,8 +2488,23 @@ var KenobiLib = (() => {
2488
2488
  );
2489
2489
  }
2490
2490
  for (const selector of selectorGuesses) {
2491
- const element = document.querySelector(selector);
2492
- if (element !== null) return element;
2491
+ const candidates = document.querySelectorAll(selector);
2492
+ if (candidates.length === 0) continue;
2493
+ if (candidates.length === 1) return candidates[0];
2494
+ const visible = Array.from(candidates).filter((el) => {
2495
+ const rect = el.getBoundingClientRect();
2496
+ const style = getComputedStyle(el);
2497
+ return style.display !== "none" && style.visibility !== "hidden" && rect.width > 0 && rect.height > 0;
2498
+ });
2499
+ if (visible.length === 0) continue;
2500
+ const sorted = visible.sort(
2501
+ (a3, b) => a3.getBoundingClientRect().top - b.getBoundingClientRect().top
2502
+ );
2503
+ this.log(
2504
+ "debug",
2505
+ `Selector "${selector}" matched ${candidates.length} elements, selected topmost visible one at y=${sorted[0].getBoundingClientRect().top}`
2506
+ );
2507
+ return sorted[0];
2493
2508
  }
2494
2509
  throw new Error(
2495
2510
  `Could not find an element in the document with any of these selector patterns: ${selectorGuesses.join(
@@ -2978,7 +2993,7 @@ var KenobiLib = (() => {
2978
2993
  */
2979
2994
  /**
2980
2995
  * Initializes and mounts a CueCard with default configuration.
2981
- * Called automatically when publishableKey is provided.
2996
+ * Called automatically when publicKey is provided.
2982
2997
  *
2983
2998
  * Default config matches the template editor settings.
2984
2999
  * Future: This config will be fetched per-org from the database.
@@ -3026,8 +3041,8 @@ var KenobiLib = (() => {
3026
3041
  * @param input - User-provided fields (e.g., { companyDomain: "acme.com" })
3027
3042
  */
3028
3043
  __publicField(this, "personalize", /* @__PURE__ */ __name(async (input) => {
3029
- if (!this.config.publishableKey) {
3030
- this.log("error", "Cannot personalize: publishableKey not configured");
3044
+ if (!this.config.publicKey) {
3045
+ this.log("error", "Cannot personalize: publicKey not configured");
3031
3046
  return;
3032
3047
  }
3033
3048
  const startTime = /* @__PURE__ */ new Date();
@@ -3042,7 +3057,7 @@ var KenobiLib = (() => {
3042
3057
  "Content-Type": "application/json"
3043
3058
  },
3044
3059
  body: JSON.stringify({
3045
- publishableKey: this.config.publishableKey,
3060
+ publicKey: this.config.publicKey,
3046
3061
  input,
3047
3062
  pagePath: this.currentPath
3048
3063
  })
@@ -3114,8 +3129,8 @@ var KenobiLib = (() => {
3114
3129
  this.log("debug", "Auto-transform is requested... Starting...");
3115
3130
  void this.startAutoTransform();
3116
3131
  }
3117
- if (this.config.publishableKey) {
3118
- this.log("debug", "PublishableKey provided, auto-mounting CueCard...");
3132
+ if (this.config.publicKey) {
3133
+ this.log("debug", "Public key provided, auto-mounting CueCard...");
3119
3134
  this.initCueCard();
3120
3135
  }
3121
3136
  }
@@ -3124,4 +3139,4 @@ var KenobiLib = (() => {
3124
3139
  var Kenobi = _Kenobi;
3125
3140
  return __toCommonJS(index_exports);
3126
3141
  })();
3127
- //# sourceMappingURL=kenobi.js.map
3142
+ //# sourceMappingURL=dist.js.map