@picked/shopify 0.0.1-dev.1764898426031 → 0.0.1-dev.1764902620487

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@picked/client"),g=require("../../ajax-api/index.js"),a=require("../../../picked-config-BEFhVeAZ.cjs"),s=require("../../../global-obj-OziQiQ8j.cjs"),i={homepage:/^\/$/,page:/(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,blog:/(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,article:/^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,cart:/(?:^|\/)cart\/[^/]+$/,checkout:/^\/checkout\/.+/,appProxy:/^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,accountWildcard:/^\/account\/.+/,accountLogin:/^\/account\/login(?:\/|$)/,accountRegister:/^\/account\/register(?:\/|$)/},o=(e,t)=>t?!!e.exec(t.pathname):!1,r=(e,t)=>{if(t){const c=e.exec(t.pathname);if(c)return c[1]}},n=e=>{var t,c;switch(e){case"product":return((t=a.getPickedConfigProduct())==null?void 0:t.handle)??!1;case"collection":return((c=a.getPickedConfigCollection())==null?void 0:c.handle)??!1;default:return!1}},l={"is-page":({location:e})=>o(i.page,e),"get-page-handle":({location:e})=>r(i.page,e),"is-product-page":()=>!!n("product"),"get-product-handle":()=>n("product"),"is-collection-page":()=>!!n("collection"),"get-collection-handle":()=>n("collection"),"is-blog-page":({location:e})=>o(i.blog,e),"get-blog-handle":({location:e})=>r(i.blog,e),"is-article-page":({location:e})=>o(i.article,e),"get-article-handle":({location:e})=>r(i.article,e),"is-app-proxy-page":({location:e})=>o(i.appProxy,e),"get-app-proxy-handle":({location:e})=>r(i.appProxy,e),"is-account-page":({location:e})=>o(i.accountWildcard,e),"is-login-page":({location:e})=>o(i.accountLogin,e),"is-register-page":({location:e})=>o(i.accountRegister,e),"is-cart-page":({location:e})=>o(i.cart,e),"is-checkout-page":({location:e})=>o(i.checkout,e),"is-homepage":({location:e})=>o(i.homepage,e)},d=()=>({name:"shopify",setup:e=>{Object.entries(l).forEach(([t,c])=>{e.registerPredicate(`shopify-${t}`,c)}),p.supportsWindow()&&e.eventBus.watch(t=>{s.supportsShopifyAnalytics()&&(t.type==="session"&&(globalThis.window.Shopify.analytics.publish("picked:session",{id:t.id}),g.updateCart({attributes:{"picked.id":t.id}})),t.type==="feature_decide"&&g.updateCart({attributes:{[`picked.features.${t.feature.id}`]:`${t.feature.bucket}`}}),t.type==="user_decide"&&g.updateCart({attributes:{"picked.is_user":t.value?"true":"false"}}))})}});exports.getPickedConfig=a.getPickedConfig;exports.getPickedConfigCollection=a.getPickedConfigCollection;exports.getPickedConfigCustomer=a.getPickedConfigCustomer;exports.getPickedConfigExperiments=a.getPickedConfigExperiments;exports.getPickedConfigFeatureExperiments=a.getPickedConfigFeatureExperiments;exports.getPickedConfigProduct=a.getPickedConfigProduct;exports.getPickedConfigStorefrontApiToken=a.getPickedConfigStorefrontApiToken;exports.getShopify=s.getShopify;exports.shopifyPlugin=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@picked/client"),f=require("../../ajax-api/index.js"),a=require("../../../picked-config-DfcDhMyM.cjs"),l=require("../../../global-obj-OziQiQ8j.cjs");function h(e,i){let t;return(...n)=>{const s=()=>{t=void 0,e(...n)};clearTimeout(t),t=setTimeout(s,i)}}const o={homepage:/^\/$/,page:/(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,blog:/(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,article:/^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,cart:/(?:^|\/)cart\/[^/]+$/,checkout:/^\/checkout\/.+/,appProxy:/^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,accountWildcard:/^\/account\/.+/,accountLogin:/^\/account\/login(?:\/|$)/,accountRegister:/^\/account\/register(?:\/|$)/},c=(e,i)=>i?!!e.exec(i.pathname):!1,r=(e,i)=>{if(i){const t=e.exec(i.pathname);if(t)return t[1]}},g=e=>{var i,t;switch(e){case"product":return((i=a.getPickedConfigProduct())==null?void 0:i.handle)??!1;case"collection":return((t=a.getPickedConfigCollection())==null?void 0:t.handle)??!1;default:return!1}},k={"is-page":({location:e})=>c(o.page,e),"get-page-handle":({location:e})=>r(o.page,e),"is-product-page":()=>!!g("product"),"get-product-handle":()=>g("product"),"is-collection-page":()=>!!g("collection"),"get-collection-handle":()=>g("collection"),"is-blog-page":({location:e})=>c(o.blog,e),"get-blog-handle":({location:e})=>r(o.blog,e),"is-article-page":({location:e})=>c(o.article,e),"get-article-handle":({location:e})=>r(o.article,e),"is-app-proxy-page":({location:e})=>c(o.appProxy,e),"get-app-proxy-handle":({location:e})=>r(o.appProxy,e),"is-account-page":({location:e})=>c(o.accountWildcard,e),"is-login-page":({location:e})=>c(o.accountLogin,e),"is-register-page":({location:e})=>c(o.accountRegister,e),"is-cart-page":({location:e})=>c(o.cart,e),"is-checkout-page":({location:e})=>c(o.checkout,e),"is-homepage":({location:e})=>c(o.homepage,e)},P=()=>({name:"shopify",setup:e=>{if(Object.entries(k).forEach(([i,t])=>{e.registerPredicate(`shopify-${i}`,t)}),u.supportsWindow()){const i=h(f.updateCart,50);e.eventBus.watch(t=>{if(l.supportsShopifyAnalytics()&&(t.type==="session"&&globalThis.window.Shopify.analytics.publish("picked:session",{id:t.id}),t.type==="feature_decide"||t.type==="session")){const n=e.session;if(n){const s={"picked.id":n.id};typeof n.isUser<"u"&&(s["picked.is_user"]=n.isUser?"true":"false"),e.features.listStore.getState().forEach(p=>{if(p.isResolved){const d=p.getBucket();s[`picked.features.${p.id}`]=`${d.bucket}`}}),i({attributes:s})}}})}}});exports.getPickedConfig=a.getPickedConfig;exports.getPickedConfigCollection=a.getPickedConfigCollection;exports.getPickedConfigCustomer=a.getPickedConfigCustomer;exports.getPickedConfigExperiments=a.getPickedConfigExperiments;exports.getPickedConfigFeatureExperiments=a.getPickedConfigFeatureExperiments;exports.getPickedConfigProduct=a.getPickedConfigProduct;exports.getPickedConfigStorefrontApiToken=a.getPickedConfigStorefrontApiToken;exports.getShopify=l.getShopify;exports.shopifyPlugin=P;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@shopify/storefront-api-client");require("@picked/client");const n=require("../../picked-config-BEFhVeAZ.cjs"),i=require("../../global-obj-OziQiQ8j.cjs");function f(t){const o=i.getShopify(),e=n.getPickedConfigStorefrontApiToken();if(!e)throw new Error("Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront");return r.createStorefrontApiClient({storeDomain:o.shop,apiVersion:t.apiVersion,publicAccessToken:e})}const c=()=>{if(!client)throw new Error("Storefront API client not found");return client};exports.createStorefrontApiClient=f;exports.getStorefrontApiClient=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@shopify/storefront-api-client");require("@picked/client");const n=require("../../picked-config-DfcDhMyM.cjs"),i=require("../../global-obj-OziQiQ8j.cjs");function f(t){const o=i.getShopify(),e=n.getPickedConfigStorefrontApiToken();if(!e)throw new Error("Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront");return r.createStorefrontApiClient({storeDomain:o.shop,apiVersion:t.apiVersion,publicAccessToken:e})}const c=()=>{if(!client)throw new Error("Storefront API client not found");return client};exports.createStorefrontApiClient=f;exports.getStorefrontApiClient=c;
@@ -1,9 +1,18 @@
1
- import { supportsWindow as p } from "@picked/client";
2
- import { updateCart as s } from "../../ajax-api/index.js";
3
- import { a as n, b as g } from "../../../picked-config-DfW6lJWR.js";
4
- import { c as P, d as x, e as C, f as $, g as B } from "../../../picked-config-DfW6lJWR.js";
5
- import { s as l } from "../../../global-obj-DQ6S7d00.js";
6
- import { g as E } from "../../../global-obj-DQ6S7d00.js";
1
+ import { supportsWindow as l } from "@picked/client";
2
+ import { updateCart as u } from "../../ajax-api/index.js";
3
+ import { a as d, b as f } from "../../../picked-config-B69J6txs.js";
4
+ import { c as E, d as S, e as T, f as w, g as H } from "../../../picked-config-B69J6txs.js";
5
+ import { s as h } from "../../../global-obj-DQ6S7d00.js";
6
+ import { g as v } from "../../../global-obj-DQ6S7d00.js";
7
+ function m(e, o) {
8
+ let t;
9
+ return (...c) => {
10
+ const s = () => {
11
+ t = void 0, e(...c);
12
+ };
13
+ clearTimeout(t), t = setTimeout(s, o);
14
+ };
15
+ }
7
16
  const a = {
8
17
  homepage: /^\/$/,
9
18
  page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
@@ -15,83 +24,89 @@ const a = {
15
24
  accountWildcard: /^\/account\/.+/,
16
25
  accountLogin: /^\/account\/login(?:\/|$)/,
17
26
  accountRegister: /^\/account\/register(?:\/|$)/
18
- }, o = (e, t) => t ? !!e.exec(t.pathname) : !1, c = (e, t) => {
19
- if (t) {
20
- const i = e.exec(t.pathname);
21
- if (i)
22
- return i[1];
27
+ }, i = (e, o) => o ? !!e.exec(o.pathname) : !1, r = (e, o) => {
28
+ if (o) {
29
+ const t = e.exec(o.pathname);
30
+ if (t)
31
+ return t[1];
23
32
  }
24
- }, r = (e) => {
25
- var t, i;
33
+ }, n = (e) => {
34
+ var o, t;
26
35
  switch (e) {
27
36
  case "product":
28
- return ((t = g()) == null ? void 0 : t.handle) ?? !1;
37
+ return ((o = f()) == null ? void 0 : o.handle) ?? !1;
29
38
  case "collection":
30
- return ((i = n()) == null ? void 0 : i.handle) ?? !1;
39
+ return ((t = d()) == null ? void 0 : t.handle) ?? !1;
31
40
  default:
32
41
  return !1;
33
42
  }
34
- }, u = {
43
+ }, y = {
35
44
  // Pages
36
- "is-page": ({ location: e }) => o(a.page, e),
37
- "get-page-handle": ({ location: e }) => c(a.page, e),
45
+ "is-page": ({ location: e }) => i(a.page, e),
46
+ "get-page-handle": ({ location: e }) => r(a.page, e),
38
47
  // Products
39
- "is-product-page": () => !!r("product"),
40
- "get-product-handle": () => r("product"),
48
+ "is-product-page": () => !!n("product"),
49
+ "get-product-handle": () => n("product"),
41
50
  // Collections
42
- "is-collection-page": () => !!r("collection"),
43
- "get-collection-handle": () => r("collection"),
51
+ "is-collection-page": () => !!n("collection"),
52
+ "get-collection-handle": () => n("collection"),
44
53
  // Blogs
45
- "is-blog-page": ({ location: e }) => o(a.blog, e),
46
- "get-blog-handle": ({ location: e }) => c(a.blog, e),
54
+ "is-blog-page": ({ location: e }) => i(a.blog, e),
55
+ "get-blog-handle": ({ location: e }) => r(a.blog, e),
47
56
  // Blog Articles
48
- "is-article-page": ({ location: e }) => o(a.article, e),
49
- "get-article-handle": ({ location: e }) => c(a.article, e),
57
+ "is-article-page": ({ location: e }) => i(a.article, e),
58
+ "get-article-handle": ({ location: e }) => r(a.article, e),
50
59
  // Apps
51
- "is-app-proxy-page": ({ location: e }) => o(a.appProxy, e),
52
- "get-app-proxy-handle": ({ location: e }) => c(a.appProxy, e),
60
+ "is-app-proxy-page": ({ location: e }) => i(a.appProxy, e),
61
+ "get-app-proxy-handle": ({ location: e }) => r(a.appProxy, e),
53
62
  // Account
54
- "is-account-page": ({ location: e }) => o(a.accountWildcard, e),
55
- "is-login-page": ({ location: e }) => o(a.accountLogin, e),
56
- "is-register-page": ({ location: e }) => o(a.accountRegister, e),
63
+ "is-account-page": ({ location: e }) => i(a.accountWildcard, e),
64
+ "is-login-page": ({ location: e }) => i(a.accountLogin, e),
65
+ "is-register-page": ({ location: e }) => i(a.accountRegister, e),
57
66
  // Cart
58
- "is-cart-page": ({ location: e }) => o(a.cart, e),
67
+ "is-cart-page": ({ location: e }) => i(a.cart, e),
59
68
  // Checkout
60
- "is-checkout-page": ({ location: e }) => o(a.checkout, e),
69
+ "is-checkout-page": ({ location: e }) => i(a.checkout, e),
61
70
  // Homepage
62
- "is-homepage": ({ location: e }) => o(a.homepage, e)
63
- }, y = () => ({
71
+ "is-homepage": ({ location: e }) => i(a.homepage, e)
72
+ }, C = () => ({
64
73
  name: "shopify",
65
74
  setup: (e) => {
66
- Object.entries(u).forEach(([t, i]) => {
67
- e.registerPredicate(`shopify-${t}`, i);
68
- }), p() && e.eventBus.watch((t) => {
69
- l() && (t.type === "session" && (globalThis.window.Shopify.analytics.publish("picked:session", {
70
- id: t.id
71
- }), s({
72
- attributes: {
73
- "picked.id": t.id
75
+ if (Object.entries(y).forEach(([o, t]) => {
76
+ e.registerPredicate(`shopify-${o}`, t);
77
+ }), l()) {
78
+ const o = m(u, 50);
79
+ e.eventBus.watch((t) => {
80
+ if (h() && (t.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", {
81
+ id: t.id
82
+ }), t.type === "feature_decide" || t.type === "session")) {
83
+ const c = e.session;
84
+ if (c) {
85
+ const s = {
86
+ "picked.id": c.id
87
+ };
88
+ typeof c.isUser < "u" && (s["picked.is_user"] = c.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
89
+ if (p.isResolved) {
90
+ const g = p.getBucket();
91
+ s[`picked.features.${p.id}`] = `${g.bucket}`;
92
+ }
93
+ }), o({
94
+ attributes: s
95
+ });
96
+ }
74
97
  }
75
- })), t.type === "feature_decide" && s({
76
- attributes: {
77
- [`picked.features.${t.feature.id}`]: `${t.feature.bucket}`
78
- }
79
- }), t.type === "user_decide" && s({
80
- attributes: {
81
- "picked.is_user": t.value ? "true" : "false"
82
- }
83
- }));
84
- });
98
+ });
99
+ }
85
100
  }
86
101
  });
87
102
  export {
88
- P as getPickedConfig,
89
- n as getPickedConfigCollection,
90
- x as getPickedConfigCustomer,
91
- C as getPickedConfigExperiments,
92
- $ as getPickedConfigFeatureExperiments,
93
- g as getPickedConfigProduct,
94
- B as getPickedConfigStorefrontApiToken,
95
- E as getShopify,
96
- y as shopifyPlugin
103
+ E as getPickedConfig,
104
+ d as getPickedConfigCollection,
105
+ S as getPickedConfigCustomer,
106
+ T as getPickedConfigExperiments,
107
+ w as getPickedConfigFeatureExperiments,
108
+ f as getPickedConfigProduct,
109
+ H as getPickedConfigStorefrontApiToken,
110
+ v as getShopify,
111
+ C as shopifyPlugin
97
112
  };
@@ -1,6 +1,6 @@
1
1
  import { createStorefrontApiClient as e } from "@shopify/storefront-api-client";
2
2
  import "@picked/client";
3
- import { g as n } from "../../picked-config-DfW6lJWR.js";
3
+ import { g as n } from "../../picked-config-B69J6txs.js";
4
4
  import { g as i } from "../../global-obj-DQ6S7d00.js";
5
5
  function S(t) {
6
6
  const r = i(), o = n();
@@ -0,0 +1,70 @@
1
+ import { supportsWindow as n, createStorageKey as u, localStore as f } from "@picked/client";
2
+ function i() {
3
+ if (n())
4
+ return globalThis.window.pickedConfig;
5
+ }
6
+ function a() {
7
+ var t;
8
+ if (n())
9
+ return (t = i()) == null ? void 0 : t.customer;
10
+ }
11
+ function l() {
12
+ var t;
13
+ if (n())
14
+ return (t = i()) == null ? void 0 : t.product;
15
+ }
16
+ function k() {
17
+ var t;
18
+ if (n())
19
+ return (t = i()) == null ? void 0 : t.collection;
20
+ }
21
+ function s() {
22
+ var t;
23
+ if (n())
24
+ return (t = i()) == null ? void 0 : t.experiments;
25
+ }
26
+ function p() {
27
+ var t, r;
28
+ if (n())
29
+ return (r = (t = i()) == null ? void 0 : t.storefront_api) == null ? void 0 : r.token;
30
+ }
31
+ function d() {
32
+ const t = u("shopify-roll"), r = f.get(t);
33
+ try {
34
+ const e = r.json();
35
+ if (typeof e == "number") return e;
36
+ } catch {
37
+ }
38
+ const o = Math.random() * 100;
39
+ return r.set(o), o;
40
+ }
41
+ function C() {
42
+ const t = s();
43
+ if (!t)
44
+ return {};
45
+ const r = d();
46
+ try {
47
+ return t.reduce(
48
+ (o, e) => {
49
+ const c = o ? { ...o } : {};
50
+ return e.enabled && (c[e.id] = {
51
+ name: e.name,
52
+ key: e.version.toString(),
53
+ decide: () => r < e.weight
54
+ }), c;
55
+ },
56
+ {}
57
+ );
58
+ } catch {
59
+ return {};
60
+ }
61
+ }
62
+ export {
63
+ k as a,
64
+ l as b,
65
+ i as c,
66
+ a as d,
67
+ s as e,
68
+ C as f,
69
+ p as g
70
+ };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("@picked/client");function i(){if(o.supportsWindow())return globalThis.window.pickedConfig}function s(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.customer}function d(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.product}function f(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.collection}function u(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.experiments}function g(){var e,n;if(o.supportsWindow())return(n=(e=i())==null?void 0:e.storefront_api)==null?void 0:n.token}function p(){const e=o.createStorageKey("shopify-roll"),n=o.localStore.get(e);try{const t=n.json();if(typeof t=="number")return t}catch{}const r=Math.random()*100;return n.set(r),r}function l(){const e=u();if(!e)return{};const n=p();try{return e.reduce((r,t)=>{const c=r?{...r}:{};return t.enabled&&(c[t.id]={name:t.name,key:t.version.toString(),decide:()=>n<t.weight}),c},{})}catch{return{}}}exports.getPickedConfig=i;exports.getPickedConfigCollection=f;exports.getPickedConfigCustomer=s;exports.getPickedConfigExperiments=u;exports.getPickedConfigFeatureExperiments=l;exports.getPickedConfigProduct=d;exports.getPickedConfigStorefrontApiToken=g;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAMpD,eAAO,MAAM,aAAa,QAAO,MAqDhC,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAOpD,eAAO,MAAM,aAAa,QAAO,MAuDhC,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@picked/shopify",
3
3
  "description": "Shopify plugin for @picked/client",
4
- "version": "0.0.1-dev.1764898426031",
4
+ "version": "0.0.1-dev.1764902620487",
5
5
  "dependencies": {},
6
6
  "devDependencies": {
7
7
  "@picked/client": "workspace:*",
@@ -63,7 +63,7 @@
63
63
  "main": "./dist/cjs/index.js",
64
64
  "module": "./dist/esm/index.js",
65
65
  "peerDependencies": {
66
- "@picked/client": "0.0.1-dev.1764898426031",
66
+ "@picked/client": "0.0.1-dev.1764902620487",
67
67
  "@shopify/storefront-api-client": "^1.0.9",
68
68
  "effector": "^23.3.0"
69
69
  },
@@ -1 +0,0 @@
1
- "use strict";const n=require("@picked/client");function i(){if(n.supportsWindow())return globalThis.window.pickedConfig}function s(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.customer}function d(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.product}function f(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.collection}function u(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.experiments}function g(){var e,o;if(n.supportsWindow())return(o=(e=i())==null?void 0:e.storefront_api)==null?void 0:o.token}function p(){const e=n.createStorageKey("shopify-plugin-experiment-roll"),o=n.localStore.get(e);try{const t=o.json();if(typeof t=="number")return t}catch{}const r=Math.random()*100;return o.set(r),r}function l(){const e=u();if(!e)return{};const o=p();try{return e.reduce((r,t)=>{const c=r?{...r}:{};return t.enabled&&(c[t.id]={name:t.name,key:t.version.toString(),decide:()=>o<t.weight}),c},{})}catch{return{}}}exports.getPickedConfig=i;exports.getPickedConfigCollection=f;exports.getPickedConfigCustomer=s;exports.getPickedConfigExperiments=u;exports.getPickedConfigFeatureExperiments=l;exports.getPickedConfigProduct=d;exports.getPickedConfigStorefrontApiToken=g;
@@ -1,70 +0,0 @@
1
- import { supportsWindow as r, createStorageKey as u, localStore as f } from "@picked/client";
2
- function i() {
3
- if (r())
4
- return globalThis.window.pickedConfig;
5
- }
6
- function a() {
7
- var e;
8
- if (r())
9
- return (e = i()) == null ? void 0 : e.customer;
10
- }
11
- function l() {
12
- var e;
13
- if (r())
14
- return (e = i()) == null ? void 0 : e.product;
15
- }
16
- function p() {
17
- var e;
18
- if (r())
19
- return (e = i()) == null ? void 0 : e.collection;
20
- }
21
- function s() {
22
- var e;
23
- if (r())
24
- return (e = i()) == null ? void 0 : e.experiments;
25
- }
26
- function k() {
27
- var e, n;
28
- if (r())
29
- return (n = (e = i()) == null ? void 0 : e.storefront_api) == null ? void 0 : n.token;
30
- }
31
- function d() {
32
- const e = u("shopify-plugin-experiment-roll"), n = f.get(e);
33
- try {
34
- const t = n.json();
35
- if (typeof t == "number") return t;
36
- } catch {
37
- }
38
- const o = Math.random() * 100;
39
- return n.set(o), o;
40
- }
41
- function C() {
42
- const e = s();
43
- if (!e)
44
- return {};
45
- const n = d();
46
- try {
47
- return e.reduce(
48
- (o, t) => {
49
- const c = o ? { ...o } : {};
50
- return t.enabled && (c[t.id] = {
51
- name: t.name,
52
- key: t.version.toString(),
53
- decide: () => n < t.weight
54
- }), c;
55
- },
56
- {}
57
- );
58
- } catch {
59
- return {};
60
- }
61
- }
62
- export {
63
- p as a,
64
- l as b,
65
- i as c,
66
- a as d,
67
- s as e,
68
- C as f,
69
- k as g
70
- };