obi-sdk 0.5.2 → 0.6.2

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,6 @@
1
+ import { O } from "./obi-widget-27b273fd.js";
2
+ import "./types-e0297e7b.js";
3
+ export {
4
+ O as ObiWidget
5
+ };
6
+ //# sourceMappingURL=index-f4e9f79f.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-f4e9f79f.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -877,6 +877,113 @@ class ObiSession {
877
877
  }
878
878
  }
879
879
  }
880
+ const OBI_PRIMARY_COLOR = "#a10fff";
881
+ function hexToHsl(hex) {
882
+ hex = hex.replace(/^#/, "");
883
+ if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(hex)) {
884
+ throw new Error(`Invalid hex color format: ${hex}`);
885
+ }
886
+ if (hex.length === 3) {
887
+ hex = hex.split("").map((char) => char + char).join("");
888
+ }
889
+ const r2 = parseInt(hex.slice(0, 2), 16) / 255;
890
+ const g2 = parseInt(hex.slice(2, 4), 16) / 255;
891
+ const b2 = parseInt(hex.slice(4, 6), 16) / 255;
892
+ const max = Math.max(r2, g2, b2);
893
+ const min = Math.min(r2, g2, b2);
894
+ let h2, s2, l2 = (max + min) / 2;
895
+ if (max === min) {
896
+ h2 = s2 = 0;
897
+ } else {
898
+ const d2 = max - min;
899
+ s2 = l2 > 0.5 ? d2 / (2 - max - min) : d2 / (max + min);
900
+ switch (max) {
901
+ case r2:
902
+ h2 = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
903
+ break;
904
+ case g2:
905
+ h2 = (b2 - r2) / d2 + 2;
906
+ break;
907
+ case b2:
908
+ h2 = (r2 - g2) / d2 + 4;
909
+ break;
910
+ default:
911
+ h2 = 0;
912
+ }
913
+ h2 /= 6;
914
+ }
915
+ return { h: h2 * 360, s: s2 * 100, l: l2 * 100 };
916
+ }
917
+ function hslToHex(h2, s2, l2) {
918
+ h2 = h2 / 360;
919
+ s2 = s2 / 100;
920
+ l2 = l2 / 100;
921
+ const hue2rgb2 = (p2, q, t2) => {
922
+ if (t2 < 0)
923
+ t2 += 1;
924
+ if (t2 > 1)
925
+ t2 -= 1;
926
+ if (t2 < 1 / 6)
927
+ return p2 + (q - p2) * 6 * t2;
928
+ if (t2 < 1 / 2)
929
+ return q;
930
+ if (t2 < 2 / 3)
931
+ return p2 + (q - p2) * (2 / 3 - t2) * 6;
932
+ return p2;
933
+ };
934
+ let r2, g2, b2;
935
+ if (s2 === 0) {
936
+ r2 = g2 = b2 = l2;
937
+ } else {
938
+ const q = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2;
939
+ const p2 = 2 * l2 - q;
940
+ r2 = hue2rgb2(p2, q, h2 + 1 / 3);
941
+ g2 = hue2rgb2(p2, q, h2);
942
+ b2 = hue2rgb2(p2, q, h2 - 1 / 3);
943
+ }
944
+ const toHex = (c2) => {
945
+ const hex = Math.round(c2 * 255).toString(16);
946
+ return hex.length === 1 ? "0" + hex : hex;
947
+ };
948
+ return `#${toHex(r2)}${toHex(g2)}${toHex(b2)}`;
949
+ }
950
+ function generateSelectedColor(currentPrimaryColor, designedSelectedColor) {
951
+ try {
952
+ const originalPrimaryHsl = hexToHsl(OBI_PRIMARY_COLOR);
953
+ const designedSelectedHsl = hexToHsl(designedSelectedColor);
954
+ const hueDelta = (designedSelectedHsl.h - originalPrimaryHsl.h + 360) % 360;
955
+ const adjustedHueDelta = hueDelta > 180 ? hueDelta - 360 : hueDelta;
956
+ const saturationDelta = designedSelectedHsl.s - originalPrimaryHsl.s;
957
+ const lightnessDelta = designedSelectedHsl.l - originalPrimaryHsl.l;
958
+ const currentPrimaryHsl = hexToHsl(currentPrimaryColor);
959
+ const selectedHsl = {
960
+ h: (currentPrimaryHsl.h + adjustedHueDelta + 360) % 360,
961
+ s: Math.max(0, Math.min(100, currentPrimaryHsl.s + saturationDelta)),
962
+ l: Math.max(0, Math.min(100, currentPrimaryHsl.l + lightnessDelta))
963
+ };
964
+ return hslToHex(selectedHsl.h, selectedHsl.s, selectedHsl.l);
965
+ } catch (error) {
966
+ console.warn("Failed to generate selected color, using fallback:", error);
967
+ return designedSelectedColor;
968
+ }
969
+ }
970
+ function transformToLightTint(hexColor) {
971
+ try {
972
+ const hsl = hexToHsl(hexColor);
973
+ const newHsl = {
974
+ h: hsl.h,
975
+ // Keep original hue
976
+ s: 100,
977
+ // Maximum saturation
978
+ l: 96
979
+ // Very high lightness (96%)
980
+ };
981
+ return hslToHex(newHsl.h, newHsl.s, newHsl.l);
982
+ } catch (error) {
983
+ console.warn("Failed to transform to light tint, using fallback:", error);
984
+ return hexColor;
985
+ }
986
+ }
880
987
  const SESSION_URL_PARAM = "49206C6F7665204F6269_session";
881
988
  var extendStatics = function(d2, b2) {
882
989
  extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
@@ -10045,96 +10152,6 @@ const STORAGE_KEYS = {
10045
10152
  SESSION_DATA: "session_data"
10046
10153
  };
10047
10154
  const storage = new StorageManager("io.obi.widget");
10048
- const ORIGINAL_PRIMARY_COLOR = "#a10fff";
10049
- function hexToHsl(hex) {
10050
- hex = hex.replace(/^#/, "");
10051
- if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(hex)) {
10052
- throw new Error(`Invalid hex color format: ${hex}`);
10053
- }
10054
- if (hex.length === 3) {
10055
- hex = hex.split("").map((char) => char + char).join("");
10056
- }
10057
- const r2 = parseInt(hex.slice(0, 2), 16) / 255;
10058
- const g2 = parseInt(hex.slice(2, 4), 16) / 255;
10059
- const b2 = parseInt(hex.slice(4, 6), 16) / 255;
10060
- const max = Math.max(r2, g2, b2);
10061
- const min = Math.min(r2, g2, b2);
10062
- let h2, s2, l2 = (max + min) / 2;
10063
- if (max === min) {
10064
- h2 = s2 = 0;
10065
- } else {
10066
- const d2 = max - min;
10067
- s2 = l2 > 0.5 ? d2 / (2 - max - min) : d2 / (max + min);
10068
- switch (max) {
10069
- case r2:
10070
- h2 = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
10071
- break;
10072
- case g2:
10073
- h2 = (b2 - r2) / d2 + 2;
10074
- break;
10075
- case b2:
10076
- h2 = (r2 - g2) / d2 + 4;
10077
- break;
10078
- default:
10079
- h2 = 0;
10080
- }
10081
- h2 /= 6;
10082
- }
10083
- return { h: h2 * 360, s: s2 * 100, l: l2 * 100 };
10084
- }
10085
- function hslToHex(h2, s2, l2) {
10086
- h2 = h2 / 360;
10087
- s2 = s2 / 100;
10088
- l2 = l2 / 100;
10089
- const hue2rgb2 = (p2, q, t2) => {
10090
- if (t2 < 0)
10091
- t2 += 1;
10092
- if (t2 > 1)
10093
- t2 -= 1;
10094
- if (t2 < 1 / 6)
10095
- return p2 + (q - p2) * 6 * t2;
10096
- if (t2 < 1 / 2)
10097
- return q;
10098
- if (t2 < 2 / 3)
10099
- return p2 + (q - p2) * (2 / 3 - t2) * 6;
10100
- return p2;
10101
- };
10102
- let r2, g2, b2;
10103
- if (s2 === 0) {
10104
- r2 = g2 = b2 = l2;
10105
- } else {
10106
- const q = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2;
10107
- const p2 = 2 * l2 - q;
10108
- r2 = hue2rgb2(p2, q, h2 + 1 / 3);
10109
- g2 = hue2rgb2(p2, q, h2);
10110
- b2 = hue2rgb2(p2, q, h2 - 1 / 3);
10111
- }
10112
- const toHex = (c2) => {
10113
- const hex = Math.round(c2 * 255).toString(16);
10114
- return hex.length === 1 ? "0" + hex : hex;
10115
- };
10116
- return `#${toHex(r2)}${toHex(g2)}${toHex(b2)}`;
10117
- }
10118
- function generateSelectedColor(currentPrimaryColor, designedSelectedColor) {
10119
- try {
10120
- const originalPrimaryHsl = hexToHsl(ORIGINAL_PRIMARY_COLOR);
10121
- const designedSelectedHsl = hexToHsl(designedSelectedColor);
10122
- const hueDelta = (designedSelectedHsl.h - originalPrimaryHsl.h + 360) % 360;
10123
- const adjustedHueDelta = hueDelta > 180 ? hueDelta - 360 : hueDelta;
10124
- const saturationDelta = designedSelectedHsl.s - originalPrimaryHsl.s;
10125
- const lightnessDelta = designedSelectedHsl.l - originalPrimaryHsl.l;
10126
- const currentPrimaryHsl = hexToHsl(currentPrimaryColor);
10127
- const selectedHsl = {
10128
- h: (currentPrimaryHsl.h + adjustedHueDelta + 360) % 360,
10129
- s: Math.max(0, Math.min(100, currentPrimaryHsl.s + saturationDelta)),
10130
- l: Math.max(0, Math.min(100, currentPrimaryHsl.l + lightnessDelta))
10131
- };
10132
- return hslToHex(selectedHsl.h, selectedHsl.s, selectedHsl.l);
10133
- } catch (error) {
10134
- console.warn("Failed to generate selected color, using fallback:", error);
10135
- return designedSelectedColor;
10136
- }
10137
- }
10138
10155
  var __defProp$7 = Object.defineProperty;
10139
10156
  var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
10140
10157
  var __decorateClass$7 = (decorators, target, key, kind) => {
@@ -10512,7 +10529,7 @@ Course.styles = i$4`
10512
10529
  align-items: center;
10513
10530
  gap: 8px;
10514
10531
  border-radius: 9999px;
10515
- background: #f5f3ff;
10532
+ background: var(--obi-course-selected-bg, #f5f3ff);
10516
10533
  color: #000;
10517
10534
  font-family: Satoshi;
10518
10535
  font-size: 14px;
@@ -11142,11 +11159,11 @@ class AudioEqualizer extends i$1 {
11142
11159
  this.canvasRef = e();
11143
11160
  this.barCount = 8;
11144
11161
  this.animationFrame = null;
11145
- this.primaryColor = ORIGINAL_PRIMARY_COLOR;
11162
+ this.primaryColor = OBI_PRIMARY_COLOR;
11146
11163
  }
11147
11164
  connectedCallback() {
11148
11165
  super.connectedCallback();
11149
- this.primaryColor = getComputedStyle(this).getPropertyValue("--obi-primary").trim() || ORIGINAL_PRIMARY_COLOR;
11166
+ this.primaryColor = getComputedStyle(this).getPropertyValue("--obi-primary").trim() || OBI_PRIMARY_COLOR;
11150
11167
  this.startAnimation();
11151
11168
  }
11152
11169
  disconnectedCallback() {
@@ -11756,7 +11773,7 @@ class ObiWidget extends i$1 {
11756
11773
  if (window.obiWidgetConfig.linkOnlyAccess !== void 0) {
11757
11774
  this.linkOnlyAccess = window.obiWidgetConfig.linkOnlyAccess;
11758
11775
  }
11759
- const primaryColor = window.obiWidgetConfig?.primaryColor || ORIGINAL_PRIMARY_COLOR;
11776
+ const primaryColor = window.obiWidgetConfig?.primaryColor || OBI_PRIMARY_COLOR;
11760
11777
  this.style.setProperty("--obi-primary", primaryColor);
11761
11778
  this.generateColorVariables(primaryColor);
11762
11779
  }
@@ -11768,7 +11785,7 @@ class ObiWidget extends i$1 {
11768
11785
  try {
11769
11786
  const secondaryColor = generateSelectedColor(primaryColor, "#c4b5fd");
11770
11787
  const courseSelected = generateSelectedColor(primaryColor, "#c76cff");
11771
- const courseSelectedBackground = generateSelectedColor(primaryColor, "#fbf3ff");
11788
+ const courseSelectedBackground = transformToLightTint(primaryColor);
11772
11789
  const pausedPulseColor = generateSelectedColor(primaryColor, "#A06DF9");
11773
11790
  this.style.setProperty("--obi-secondary", secondaryColor);
11774
11791
  this.style.setProperty("--obi-course-selected", courseSelected);
@@ -12369,4 +12386,4 @@ export {
12369
12386
  searchingLoader as s,
12370
12387
  x
12371
12388
  };
12372
- //# sourceMappingURL=obi-widget-3bb30929.js.map
12389
+ //# sourceMappingURL=obi-widget-27b273fd.js.map