magtool 1.0.2 → 1.0.4

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.
package/dist/cps.js CHANGED
@@ -1,71 +1,61 @@
1
- const y = (e) => {
2
- const { age: o } = e || {};
3
- let l, n;
1
+ const $ = (t) => {
2
+ const { age: o } = t || {};
3
+ let s, n;
4
4
  if (o != null && o.included) {
5
- const { minAge: t, maxAge: r } = o.included[0] || {};
6
- t ? l = t : l = "all", r ? n = r : n = "all";
5
+ const { minAge: e, maxAge: r } = o.included[0] || {};
6
+ e ? s = e : s = "all", r ? n = r : n = "all";
7
7
  }
8
- return n === "all" ? l === "all" ? "All" : `${l}~65+` : `${l}~${n}`;
9
- }, h = (e, o) => e === "all" ? null : o === 65 ? {
8
+ return n === "all" ? s === "all" ? "All" : `${s}~65+` : `${s}~${n}`;
9
+ }, b = (t, o) => t === "all" ? null : o === 65 ? {
10
10
  included: [
11
11
  {
12
- minAge: e
12
+ minAge: t
13
13
  }
14
14
  ]
15
15
  } : {
16
16
  included: [
17
17
  {
18
- minAge: e,
18
+ minAge: t,
19
19
  maxAge: o
20
20
  }
21
21
  ]
22
- }, j = (e) => {
23
- const { gender: o } = e || {};
22
+ }, h = (t) => {
23
+ const { gender: o } = t || {};
24
24
  return o != null && o.included ? o.included[0] : null;
25
- }, $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
- __proto__: null,
27
- useAgeFormat: y,
28
- useAgeValue: h,
29
- useGenderFormat: j
30
- }, Symbol.toStringTag, { value: "Module" })), P = (e) => new Promise((o, l) => {
25
+ }, y = { useAgeFormat: $, useAgeValue: b, useGenderFormat: h }, P = (t) => new Promise((o, s) => {
31
26
  const n = new Image();
32
- n.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), n.onload = () => o(n), n.onerror = () => l(new Error("Could not load image"));
33
- }), C = (e) => new Promise((o, l) => {
27
+ n.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), n.onload = () => o(n), n.onerror = () => s(new Error("Could not load image"));
28
+ }), C = (t) => new Promise((o, s) => {
34
29
  const n = document.createElement("video");
35
- n.preload = "metadata", window.$getType(e) === "String" ? n.src = e : n.src = URL.createObjectURL(e), n.onloadedmetadata = () => {
36
- window.URL.revokeObjectURL(e), console.info([n]), o(n);
30
+ n.preload = "metadata", window.$getType(t) === "String" ? n.src = t : n.src = URL.createObjectURL(t), n.onloadedmetadata = () => {
31
+ window.URL.revokeObjectURL(t), console.info([n]), o(n);
37
32
  };
38
- }), S = ({ type: e = "csv", data: o, name: l }) => {
33
+ }), M = ({ type: t = "csv", data: o, name: s }) => {
39
34
  let n = document.createElement("a");
40
- if (e === "csv") {
35
+ if (t === "csv") {
41
36
  const r = new Blob(["\uFEFF" + o], {
42
37
  type: "text/csv,charset=UTF-8"
43
38
  });
44
39
  n.href = URL.createObjectURL(r);
45
40
  }
46
- let t = new MouseEvent("click");
47
- n.download = l || "download", n.dispatchEvent(t), (e === "csv" || e === "video") && URL.revokeObjectURL(n.url), n = null, t = null;
48
- }, M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49
- __proto__: null,
50
- download: S,
51
- loadImage: P,
52
- loadVideo: C
53
- }, Symbol.toStringTag, { value: "Module" })), O = ({ table: e, key: o, form: l, value: n, cb: t = () => {
41
+ let e = new MouseEvent("click");
42
+ n.download = s || "download", n.dispatchEvent(e), (t === "csv" || t === "video") && URL.revokeObjectURL(n.url), n = null, e = null;
43
+ }, R = { loadImage: P, loadVideo: C, download: M }, A = ({ table: t, key: o, form: s, value: n, cb: e = () => {
54
44
  } }) => {
55
- const r = e.getSelectionRows();
56
- r.length > 1 ? (e.clearSelection(), e.toggleRowSelection(r[1], "selected"), l[n] = r[1][o]) : r.length === 1 && (l[n] = r[0][o]), t();
57
- }, R = (e = {}) => {
58
- let { sortable: o = !0, empty: l = !1, mmp: n = !1 } = e, t = window.$map.asa.asaMetric.all;
59
- n && (t = t.concat(window.$map.asa.mmpMetric.all));
60
- const r = t.map((a, f) => ({
61
- label: a.label,
62
- prop: a.value,
63
- width: a.width,
45
+ const r = t.getSelectionRows();
46
+ r.length > 1 ? (t.clearSelection(), t.toggleRowSelection(r[1], "selected"), s[n] = r[1][o]) : r.length === 1 && (s[n] = r[0][o]), e();
47
+ }, I = (t = {}) => {
48
+ let { sortable: o = !0, empty: s = !1, mmp: n = !1 } = t, e = window.$map.asa.asaMetric.all;
49
+ n && (e = e.concat(window.$map.asa.mmpMetric.all));
50
+ const r = e.map((l, u) => ({
51
+ label: l.label,
52
+ prop: l.value,
53
+ width: l.width,
64
54
  sortable: o,
65
- type: a.type,
66
- align: a.align,
67
- visible: a.visible,
68
- formatter: a.formatter
55
+ type: l.type,
56
+ align: l.align,
57
+ visible: l.visible,
58
+ formatter: l.formatter
69
59
  }));
70
60
  return r.unshift({
71
61
  label: "Currency",
@@ -73,46 +63,46 @@ const y = (e) => {
73
63
  width: 80,
74
64
  align: "right"
75
65
  }), r;
76
- }, A = () => ({
66
+ }, j = () => ({
77
67
  label: "-"
78
- }), I = ({ columns: e, data: o, currency: l = "", channel: n = "" }) => {
79
- if (!o.length || !e.length)
68
+ }), S = ({ columns: t, data: o, currency: s = "", channel: n = "" }) => {
69
+ if (!o.length || !t.length)
80
70
  return [];
81
- const t = {
71
+ const e = {
82
72
  spend: {
83
73
  prop: "spend",
84
- prefix: l,
85
- format: (s) => window.$fa(s, 2)
74
+ prefix: s,
75
+ format: (a) => window.$fa(a, 2)
86
76
  },
87
77
  taps: {
88
78
  prop: "taps",
89
- format: (s) => window.$fa(s, 0)
79
+ format: (a) => window.$fa(a, 0)
90
80
  },
91
81
  installs: {
92
82
  prop: "installs",
93
- format: (s) => window.$fa(s, 0)
83
+ format: (a) => window.$fa(a, 0)
94
84
  },
95
85
  impressions: {
96
86
  prop: "impressions",
97
- format: (s) => window.$fa(s, 0)
87
+ format: (a) => window.$fa(a, 0)
98
88
  },
99
89
  mmpInstalls: {
100
90
  prop: "mmpInstalls",
101
- format: (s) => window.$fa(s, 0)
91
+ format: (a) => window.$fa(a, 0)
102
92
  },
103
93
  mmpCPI: {
104
94
  prop: "mmpCPI",
105
- format: (s) => window.$fa(s, 2)
95
+ format: (a) => window.$fa(a, 2)
106
96
  },
107
97
  IPM: {
108
98
  prop: "IPM",
109
- format: (s) => window.$fa(s, 2)
99
+ format: (a) => window.$fa(a, 2)
110
100
  },
111
101
  revenue: {
112
102
  prop: "revenue",
113
- format: (s) => window.$fa(s, 2)
103
+ format: (a) => window.$fa(a, 2)
114
104
  }
115
- }, r = [], a = {
105
+ }, r = [], l = {
116
106
  avgCPT: {},
117
107
  avgCPA: {},
118
108
  avgCPM: {},
@@ -122,71 +112,60 @@ const y = (e) => {
122
112
  mmpInstalls: {},
123
113
  mmpCPI: {}
124
114
  };
125
- e.forEach((s, i) => {
126
- a[s.property] && (a[s.property].i = i);
127
- const p = t[s.property];
128
- if (p) {
129
- p.i = i;
115
+ t.forEach((a, i) => {
116
+ l[a.property] && (l[a.property].i = i);
117
+ const m = e[a.property];
118
+ if (m) {
119
+ m.i = i;
130
120
  let c = window.$bigNumber(0);
131
- o.forEach((_) => {
132
- c = c.plus(_[s.property] || 0);
133
- }), c = c.toNumber(), p.total = c, r.push(c);
121
+ o.forEach((v) => {
122
+ c = c.plus(v[a.property] || 0);
123
+ }), c = c.toNumber(), m.total = c, r.push(c);
134
124
  } else
135
125
  r.push("");
136
- }), Object.keys(t).forEach((s) => {
137
- const i = t[s];
126
+ }), Object.keys(e).forEach((a) => {
127
+ const i = e[a];
138
128
  i.format && r[i.i] && (r[i.i] = i.format(r[i.i]));
139
129
  });
140
- const m = t.taps.total ? window.$fa(t.spend.total / t.taps.total) : "0.00";
141
- r[a.avgCPT.i] = m;
142
- const w = t.installs.total ? window.$fa(t.spend.total / t.installs.total) : "0.00";
143
- if (r[a.avgCPA.i] = w, a.avgCPM.i !== void 0) {
144
- const s = t.impressions.total ? window.$fa(t.spend.total / (t.impressions.total / 1e3)) : "0.00";
145
- r[a.avgCPM.i] = s;
130
+ const p = e.taps.total ? window.$fa(e.spend.total / e.taps.total) : "0.00";
131
+ r[l.avgCPT.i] = p;
132
+ const d = e.installs.total ? window.$fa(e.spend.total / e.installs.total) : "0.00";
133
+ if (r[l.avgCPA.i] = d, l.avgCPM.i !== void 0) {
134
+ const a = e.impressions.total ? window.$fa(e.spend.total / (e.impressions.total / 1e3)) : "0.00";
135
+ r[l.avgCPM.i] = a;
146
136
  }
147
- const g = t.taps.total ? window.$fa(t.installs.total / t.taps.total * 100) : "0.00";
148
- r[a.cr.i] = g;
149
- const b = t.impressions.total ? window.$fa(t.taps.total / t.impressions.total * 100) : "0.00";
150
- r[a.ttr.i] = b;
151
- const v = t.impressions.total ? window.$fa(t.installs.total * 1e3 / t.impressions.total) : "0.00";
152
- return r[a.IPM.i] = v, r;
153
- }, T = (e) => {
137
+ const f = e.taps.total ? window.$fa(e.installs.total / e.taps.total * 100) : "0.00";
138
+ r[l.cr.i] = f;
139
+ const w = e.impressions.total ? window.$fa(e.taps.total / e.impressions.total * 100) : "0.00";
140
+ r[l.ttr.i] = w;
141
+ const g = e.impressions.total ? window.$fa(e.installs.total * 1e3 / e.impressions.total) : "0.00";
142
+ return r[l.IPM.i] = g, r;
143
+ }, U = (t) => {
154
144
  const o = window.$map.asa.allMetric.obj;
155
- return Object.keys(e).forEach((l) => {
156
- const n = e[l];
157
- o[l] && (e[`${l}Format`] = window.$fu({ prop: l, value: n, currency: !1, obj: o }));
158
- }), e;
159
- }, E = ({ columns: e, data: o }, l) => e.length && o.length ? e.map((t) => {
160
- let r = l[t.property] === void 0 ? "" : l[t.property];
145
+ return Object.keys(t).forEach((s) => {
146
+ const n = t[s];
147
+ o[s] && (t[`${s}Format`] = window.$fu({ prop: s, value: n, currency: !1, obj: o }));
148
+ }), t;
149
+ }, E = ({ columns: t, data: o }, s) => t.length && o.length ? t.map((e) => {
150
+ let r = s[e.property] === void 0 ? "" : s[e.property];
161
151
  if (r !== "")
162
152
  try {
163
- r = window.$fa(r, window.$map.asa.allMetric.obj[t.property].precision);
153
+ r = window.$fa(r, window.$map.asa.allMetric.obj[e.property].precision);
164
154
  } catch {
165
155
  }
166
156
  return r;
167
- }) : [], U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
168
- __proto__: null,
169
- useColumn: R,
170
- useEmptyColumn: A,
171
- useFormat: T,
172
- useRemoteSummary: E,
173
- useSingleSelect: O,
174
- useSummary: I
175
- }, Symbol.toStringTag, { value: "Module" })), L = (e, o = 88) => {
176
- const l = document.querySelector("html"), { scrollTop: n } = l, t = e.getBoundingClientRect();
177
- l.scrollTo({
178
- top: n + t.y - o,
157
+ }) : [], L = { useSingleSelect: A, useColumn: I, useEmptyColumn: j, useRemoteSummary: E, useSummary: S, useFormat: U }, T = (t, o = 88) => {
158
+ const s = document.querySelector("html"), { scrollTop: n } = s, e = t.getBoundingClientRect();
159
+ s.scrollTo({
160
+ top: n + e.y - o,
179
161
  behavior: "smooth"
180
162
  });
181
- }, k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
182
- __proto__: null,
183
- pageScrollTo: L
184
- }, Symbol.toStringTag, { value: "Module" })), d = /* @__PURE__ */ Object.assign({ "./chip/ads.js": $, "./chip/media.js": M, "./chip/table.js": U, "./chip/tool.js": k });
185
- let u = {};
186
- Object.keys(d).forEach((e) => {
187
- u = { ...u, ...d[e] };
188
- });
189
- const x = u;
163
+ }, O = { pageScrollTo: T }, x = {
164
+ ...y,
165
+ ...R,
166
+ ...L,
167
+ ...O
168
+ };
190
169
  export {
191
170
  x as c
192
171
  };