@celljs/ta-offer 0.0.0-stage → 4.38.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.
- package/README.en.md +16 -0
- package/README.md +15 -2
- package/extension/index.mjs +100 -0
- package/host/index.mjs +1124 -0
- package/package.json +63 -4
- package/web/index.js +1844 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,1844 @@
|
|
|
1
|
+
// ../ta-web/esm/browser/extension/share-sheet-compat.js
|
|
2
|
+
function ShareSheetCompat({ pi, ...props }) {
|
|
3
|
+
const h = pi.React.createElement;
|
|
4
|
+
if (pi.ui.ShareSheet) {
|
|
5
|
+
return h(pi.ui.ShareSheet, props);
|
|
6
|
+
}
|
|
7
|
+
const { title, link, error, name, gets, notes, password, own, onClose, children } = props;
|
|
8
|
+
const quiet = { margin: 0, opacity: 0.7, textAlign: "center" };
|
|
9
|
+
return h(pi.ui.Dialog, { title, onClose }, h("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 12 } }, error !== undefined ? h("p", { role: "alert" }, error) : [
|
|
10
|
+
name || gets ? h("p", { key: "who", style: { margin: 0, textAlign: "center" } }, [name, gets].filter(Boolean).join(" · ")) : null,
|
|
11
|
+
link && !own ? h(pi.ui.QrCode, { key: "qr", text: link, label: name || title }) : null,
|
|
12
|
+
h("code", { key: "link", style: { maxWidth: "100%", overflowWrap: "anywhere", userSelect: "all" } }, link !== null && link !== undefined ? link : "…"),
|
|
13
|
+
password ? h("code", { key: "password", style: { userSelect: "all" } }, password) : null,
|
|
14
|
+
link ? h("button", { key: "copy", type: "button", className: "ta-button ta-primary", onClick: () => {
|
|
15
|
+
var _a;
|
|
16
|
+
return void ((_a = navigator.clipboard) === null || _a === undefined ? undefined : _a.writeText(link));
|
|
17
|
+
} }, "Copy") : null,
|
|
18
|
+
children,
|
|
19
|
+
...(notes !== null && notes !== undefined ? notes : []).filter(Boolean).map((line) => h("p", { key: String(line), style: quiet }, line))
|
|
20
|
+
]));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// web-src/offer-protocol.ts
|
|
24
|
+
var NAME = "@celljs/ta-offer";
|
|
25
|
+
var OFFERS_VIEW = `${NAME}/offers`;
|
|
26
|
+
var DATA_KEY = "data";
|
|
27
|
+
var PAYEE_KEY = "payee";
|
|
28
|
+
var LIMITS = { name: 40, intro: 300, plans: 6, planName: 20, note: 300, picture: 400000 };
|
|
29
|
+
|
|
30
|
+
// ../ta-protocol/esm/common/language.js
|
|
31
|
+
var TaLanguageUtil;
|
|
32
|
+
(function(TaLanguageUtil2) {
|
|
33
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
34
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
35
|
+
function of(tag) {
|
|
36
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
37
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
38
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
39
|
+
}
|
|
40
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
41
|
+
}
|
|
42
|
+
TaLanguageUtil2.of = of;
|
|
43
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
44
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
45
|
+
}
|
|
46
|
+
TaLanguageUtil2.server = server;
|
|
47
|
+
function pick(language, words) {
|
|
48
|
+
return words[of(language)];
|
|
49
|
+
}
|
|
50
|
+
TaLanguageUtil2.pick = pick;
|
|
51
|
+
function say(words) {
|
|
52
|
+
return words[server()];
|
|
53
|
+
}
|
|
54
|
+
TaLanguageUtil2.say = say;
|
|
55
|
+
function chinese(language) {
|
|
56
|
+
return of(language).startsWith("zh");
|
|
57
|
+
}
|
|
58
|
+
TaLanguageUtil2.chinese = chinese;
|
|
59
|
+
function cjk(language) {
|
|
60
|
+
return of(language) !== "en-US";
|
|
61
|
+
}
|
|
62
|
+
TaLanguageUtil2.cjk = cjk;
|
|
63
|
+
function list(language, items) {
|
|
64
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
65
|
+
}
|
|
66
|
+
TaLanguageUtil2.list = list;
|
|
67
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
68
|
+
|
|
69
|
+
// web-src/i18n.ts
|
|
70
|
+
var ZH = {
|
|
71
|
+
title: "开放给别人用",
|
|
72
|
+
mineTitle: "开放给我的",
|
|
73
|
+
failed: "没做成:{message}",
|
|
74
|
+
free: "免费",
|
|
75
|
+
tokens: "{n} 万",
|
|
76
|
+
statePaused: "提供者暂停了",
|
|
77
|
+
stateEnded: "方案已到期",
|
|
78
|
+
stateNone: "还没有方案",
|
|
79
|
+
stateUsed: "额度用完了",
|
|
80
|
+
stateDaily: "今天的额度用完了,{time} 恢复",
|
|
81
|
+
leftToday: "今天还剩 {n}",
|
|
82
|
+
leftAll: "共剩 {n}",
|
|
83
|
+
endsOn: "{date}到期",
|
|
84
|
+
unlimited: "不限量",
|
|
85
|
+
anonymous: "匿名",
|
|
86
|
+
joinRow: "想用 {name}",
|
|
87
|
+
refuse: "拒绝",
|
|
88
|
+
letIn: "让他用",
|
|
89
|
+
paidRow: "付 {price} 开通 {plan}",
|
|
90
|
+
codeRow: "核对码 {code} · {date}",
|
|
91
|
+
notReceived: "没收到",
|
|
92
|
+
confirmPaid: "已收到,开通",
|
|
93
|
+
usersCount: "{n} 人在用",
|
|
94
|
+
usedToday: "今天用了 {n}",
|
|
95
|
+
pausedTag: "已暂停",
|
|
96
|
+
goneTag: "智能体已删除",
|
|
97
|
+
emptyTitle: "还没有开放给别人的智能体",
|
|
98
|
+
emptyHint: "选一个智能体,定好方案,就有一个链接:别人在浏览器里打开就能用,跑在你的电脑上",
|
|
99
|
+
openOne: "开放一个智能体",
|
|
100
|
+
waiting: "等你处理",
|
|
101
|
+
opened: "已开放",
|
|
102
|
+
payTitle: "收款",
|
|
103
|
+
payeeRow: "收款码",
|
|
104
|
+
payeeSet: "已上传",
|
|
105
|
+
payeeUnset: "还没上传收款码",
|
|
106
|
+
payHint: "对方扫你的收款码付款,备注里写核对码;你对一下收款记录再点开通。钱不经过 Ta。",
|
|
107
|
+
noLimit: "不限",
|
|
108
|
+
removePlan: "删除方案",
|
|
109
|
+
planPrice: "价格",
|
|
110
|
+
yuan: "元",
|
|
111
|
+
planDays: "有效期",
|
|
112
|
+
daysUnit: "天",
|
|
113
|
+
planTokens: "总额度",
|
|
114
|
+
tokenUnit: "万 token",
|
|
115
|
+
planDaily: "每天上限",
|
|
116
|
+
planTrial: "试用",
|
|
117
|
+
planPack: "按量包",
|
|
118
|
+
planMonth: "包月",
|
|
119
|
+
planNew: "新方案",
|
|
120
|
+
editTitle: "修改开放",
|
|
121
|
+
openTitle: "开放一个智能体",
|
|
122
|
+
noAgents: "还没有智能体。先在“伙伴”里建一个,再来开放。",
|
|
123
|
+
agent: "智能体",
|
|
124
|
+
shownName: "对外显示的名字",
|
|
125
|
+
intro: "介绍",
|
|
126
|
+
introHint: "一两句话:它能帮人做什么",
|
|
127
|
+
approve: "每个新使用者要我同意",
|
|
128
|
+
approveOn: "有人申请时问你",
|
|
129
|
+
approveOff: "拿到链接就能直接用(只给试用额度)",
|
|
130
|
+
plans: "方案",
|
|
131
|
+
addPlan: "添加方案",
|
|
132
|
+
trial: "新使用者先得到",
|
|
133
|
+
trialNone: "什么都不给,付款后才能用",
|
|
134
|
+
runsHere: "别人的对话跑在你的电脑上、用这个智能体的模型和说明;每人一个自己的对话和文件夹,互相看不到,也看不到你的对话、文件和记忆。电脑关机时暂停服务。",
|
|
135
|
+
accountModel: "这个智能体用的是账号登录的模型({model}),这类订阅一般不允许转给别人用来收费。换成自己按量付费的 API Key 后再开放收费方案,或者只留免费方案。",
|
|
136
|
+
cancel: "取消",
|
|
137
|
+
save: "保存",
|
|
138
|
+
openIt: "开放",
|
|
139
|
+
givePlanTitle: "给 {name} 开通",
|
|
140
|
+
plan: "方案",
|
|
141
|
+
amountGot: "收到的金额(元)",
|
|
142
|
+
giveHint: "线下收的钱(转账、现金)或者免费送都在这里开通,会记进账本。",
|
|
143
|
+
give: "开通",
|
|
144
|
+
removeUserTitle: "不再让 {name} 用?",
|
|
145
|
+
removeUserHint: "他的设备会断开,链接也不能再进来,除非重新申请。",
|
|
146
|
+
removeUser: "移除",
|
|
147
|
+
noPlan: "没有方案",
|
|
148
|
+
usedAll: "共用了 {n}",
|
|
149
|
+
onlineTag: "在线",
|
|
150
|
+
givePlan: "开通方案",
|
|
151
|
+
resume: "恢复",
|
|
152
|
+
pause: "暂停",
|
|
153
|
+
shareTitle: "分享 {name}",
|
|
154
|
+
linkGets: "对方在浏览器里打开就能用,用的是你的模型",
|
|
155
|
+
linkApprove: "每个申请的人都要你同意",
|
|
156
|
+
linkOpen: "拿到链接的人直接能用试用额度",
|
|
157
|
+
linkUntil: "链接 {date}前有效",
|
|
158
|
+
closeTitle: "关闭 {name}?",
|
|
159
|
+
closeHint: "链接失效,只为它进来的人会被移出你的 Ta。账本保留。",
|
|
160
|
+
closeOffer: "关闭开放",
|
|
161
|
+
agentLine: "用默认模型",
|
|
162
|
+
statUsers: "使用者",
|
|
163
|
+
statIncome: "已收款",
|
|
164
|
+
statCost: "模型花费",
|
|
165
|
+
shareLink: "分享链接",
|
|
166
|
+
edit: "修改",
|
|
167
|
+
trialTag: "试用",
|
|
168
|
+
users: "使用者",
|
|
169
|
+
noUsers: "还没有人用",
|
|
170
|
+
noUsersHint: "把链接发给别人",
|
|
171
|
+
privacyOwner: "使用者的对话保存在你的电脑上,默认不看,列在对话列表的“访客的对话”里。",
|
|
172
|
+
payeeTitle: "收款码",
|
|
173
|
+
payeeLead: "上传你的微信收款码,对方开通付费方案时扫码付款。",
|
|
174
|
+
changePicture: "换一张",
|
|
175
|
+
pickPicture: "上传收款码",
|
|
176
|
+
removePicture: "去掉",
|
|
177
|
+
payeeNote: "其他付款方式",
|
|
178
|
+
payeeNoteHint: "比如:也可以转账到 xxx,或当面付",
|
|
179
|
+
payeeTip: "建议用经营收款码:个人收款码频繁收款可能被微信限制。",
|
|
180
|
+
done: "完成",
|
|
181
|
+
pictureTooBig: "这张图片太大了,换一张小一点的。",
|
|
182
|
+
planAll: "共 {n}",
|
|
183
|
+
planDay: "每天 {n}",
|
|
184
|
+
planFor: "{n} 天",
|
|
185
|
+
payFor: "开通{plan}",
|
|
186
|
+
payMini: "小程序里不能付款。请联系 {owner} 开通。",
|
|
187
|
+
payLead: "付款给 {owner},对方确认收到后就开通。",
|
|
188
|
+
payNext: "去付款",
|
|
189
|
+
payNote: "付款时在备注里写上核对码 {code},方便 {owner} 找到你的付款。",
|
|
190
|
+
payNoCode: "提供者还没上传收款码,请联系对方付款",
|
|
191
|
+
payAfter: "付完点“我付好了”,提供者确认后就开通,这里会自动更新。",
|
|
192
|
+
payDone: "我付好了",
|
|
193
|
+
byOwner: "{owner} 开放给你",
|
|
194
|
+
startChat: "开始一个新对话",
|
|
195
|
+
chatsHere: "你的 {n} 个对话在对话列表里",
|
|
196
|
+
waitingPay: "等对方确认收款",
|
|
197
|
+
waitingLine: "核对码 {code} · {date}",
|
|
198
|
+
plansToBuy: "付费方案",
|
|
199
|
+
currentTag: "当前",
|
|
200
|
+
buyHint: "选一个方案,扫码付款,提供者确认后就开通。",
|
|
201
|
+
buyHintOffline: "选一个方案,然后和 {owner} 约好怎么付款。",
|
|
202
|
+
privacyUser: "对话保存在 {owner} 的电脑上,30 天后可能被清理;不要在这里发密码等私密信息。",
|
|
203
|
+
emptyUser: "没有开放给你的智能体"
|
|
204
|
+
};
|
|
205
|
+
var ZH_TW = {
|
|
206
|
+
title: "開放給別人用",
|
|
207
|
+
mineTitle: "開放給我的",
|
|
208
|
+
failed: "沒做成:{message}",
|
|
209
|
+
free: "免費",
|
|
210
|
+
tokens: "{n} 萬",
|
|
211
|
+
statePaused: "提供者暫停了",
|
|
212
|
+
stateEnded: "方案已到期",
|
|
213
|
+
stateNone: "還沒有方案",
|
|
214
|
+
stateUsed: "額度用完了",
|
|
215
|
+
stateDaily: "今天的額度用完了,{time} 恢復",
|
|
216
|
+
leftToday: "今天還剩 {n}",
|
|
217
|
+
leftAll: "共剩 {n}",
|
|
218
|
+
endsOn: "{date}到期",
|
|
219
|
+
unlimited: "不限量",
|
|
220
|
+
anonymous: "匿名",
|
|
221
|
+
joinRow: "想用 {name}",
|
|
222
|
+
refuse: "拒絕",
|
|
223
|
+
letIn: "讓他用",
|
|
224
|
+
paidRow: "付 {price} 開通 {plan}",
|
|
225
|
+
codeRow: "核對碼 {code} · {date}",
|
|
226
|
+
notReceived: "沒收到",
|
|
227
|
+
confirmPaid: "已收到,開通",
|
|
228
|
+
usersCount: "{n} 人在用",
|
|
229
|
+
usedToday: "今天用了 {n}",
|
|
230
|
+
pausedTag: "已暫停",
|
|
231
|
+
goneTag: "智慧體已刪除",
|
|
232
|
+
emptyTitle: "還沒有開放給別人的智慧體",
|
|
233
|
+
emptyHint: "選一個智慧體,定好方案,就有一個連結:別人在瀏覽器裡打開就能用,跑在你的電腦上",
|
|
234
|
+
openOne: "開放一個智慧體",
|
|
235
|
+
waiting: "等你處理",
|
|
236
|
+
opened: "已開放",
|
|
237
|
+
payTitle: "收款",
|
|
238
|
+
payeeRow: "收款碼",
|
|
239
|
+
payeeSet: "已上傳",
|
|
240
|
+
payeeUnset: "還沒上傳收款碼",
|
|
241
|
+
payHint: "對方掃你的收款碼付款,備註裡寫核對碼;你對一下收款紀錄再點開通。錢不經過 Ta。",
|
|
242
|
+
noLimit: "不限",
|
|
243
|
+
removePlan: "刪除方案",
|
|
244
|
+
planPrice: "價格",
|
|
245
|
+
yuan: "元",
|
|
246
|
+
planDays: "有效期",
|
|
247
|
+
daysUnit: "天",
|
|
248
|
+
planTokens: "總額度",
|
|
249
|
+
tokenUnit: "萬 token",
|
|
250
|
+
planDaily: "每天上限",
|
|
251
|
+
planTrial: "試用",
|
|
252
|
+
planPack: "按量包",
|
|
253
|
+
planMonth: "包月",
|
|
254
|
+
planNew: "新方案",
|
|
255
|
+
editTitle: "修改開放",
|
|
256
|
+
openTitle: "開放一個智慧體",
|
|
257
|
+
noAgents: "還沒有智慧體。先在「夥伴」裡建一個,再來開放。",
|
|
258
|
+
agent: "智慧體",
|
|
259
|
+
shownName: "對外顯示的名字",
|
|
260
|
+
intro: "介紹",
|
|
261
|
+
introHint: "一兩句話:它能幫人做什麼",
|
|
262
|
+
approve: "每個新使用者要我同意",
|
|
263
|
+
approveOn: "有人申請時問你",
|
|
264
|
+
approveOff: "拿到連結就能直接用(只給試用額度)",
|
|
265
|
+
plans: "方案",
|
|
266
|
+
addPlan: "新增方案",
|
|
267
|
+
trial: "新使用者先得到",
|
|
268
|
+
trialNone: "什麼都不給,付款後才能用",
|
|
269
|
+
runsHere: "別人的對話跑在你的電腦上、用這個智慧體的模型和說明;每人一個自己的對話和資料夾,互相看不到,也看不到你的對話、檔案和記憶。電腦關機時暫停服務。",
|
|
270
|
+
accountModel: "這個智慧體用的是帳號登入的模型({model}),這類訂閱一般不允許轉給別人用來收費。換成自己按量付費的 API Key 後再開放收費方案,或者只留免費方案。",
|
|
271
|
+
cancel: "取消",
|
|
272
|
+
save: "儲存",
|
|
273
|
+
openIt: "開放",
|
|
274
|
+
givePlanTitle: "給 {name} 開通",
|
|
275
|
+
plan: "方案",
|
|
276
|
+
amountGot: "收到的金額(元)",
|
|
277
|
+
giveHint: "線下收的錢(轉帳、現金)或者免費送都在這裡開通,會記進帳本。",
|
|
278
|
+
give: "開通",
|
|
279
|
+
removeUserTitle: "不再讓 {name} 用?",
|
|
280
|
+
removeUserHint: "他的裝置會中斷,連結也不能再進來,除非重新申請。",
|
|
281
|
+
removeUser: "移除",
|
|
282
|
+
noPlan: "沒有方案",
|
|
283
|
+
usedAll: "共用了 {n}",
|
|
284
|
+
onlineTag: "在線",
|
|
285
|
+
givePlan: "開通方案",
|
|
286
|
+
resume: "恢復",
|
|
287
|
+
pause: "暫停",
|
|
288
|
+
shareTitle: "分享 {name}",
|
|
289
|
+
linkGets: "對方在瀏覽器裡打開就能用,用的是你的模型",
|
|
290
|
+
linkApprove: "每個申請的人都要你同意",
|
|
291
|
+
linkOpen: "拿到連結的人直接能用試用額度",
|
|
292
|
+
linkUntil: "連結 {date}前有效",
|
|
293
|
+
closeTitle: "關閉 {name}?",
|
|
294
|
+
closeHint: "連結失效,只為它進來的人會被移出你的 Ta。帳本保留。",
|
|
295
|
+
closeOffer: "關閉開放",
|
|
296
|
+
agentLine: "用預設模型",
|
|
297
|
+
statUsers: "使用者",
|
|
298
|
+
statIncome: "已收款",
|
|
299
|
+
statCost: "模型花費",
|
|
300
|
+
shareLink: "分享連結",
|
|
301
|
+
edit: "修改",
|
|
302
|
+
trialTag: "試用",
|
|
303
|
+
users: "使用者",
|
|
304
|
+
noUsers: "還沒有人用",
|
|
305
|
+
noUsersHint: "把連結傳給別人",
|
|
306
|
+
privacyOwner: "使用者的對話儲存在你的電腦上,預設不看,列在對話列表的「訪客的對話」裡。",
|
|
307
|
+
payeeTitle: "收款碼",
|
|
308
|
+
payeeLead: "上傳你的微信收款碼,對方開通付費方案時掃碼付款。",
|
|
309
|
+
changePicture: "換一張",
|
|
310
|
+
pickPicture: "上傳收款碼",
|
|
311
|
+
removePicture: "去掉",
|
|
312
|
+
payeeNote: "其他付款方式",
|
|
313
|
+
payeeNoteHint: "比如:也可以轉帳到 xxx,或當面付",
|
|
314
|
+
payeeTip: "建議用經營收款碼:個人收款碼頻繁收款可能被微信限制。",
|
|
315
|
+
done: "完成",
|
|
316
|
+
pictureTooBig: "這張圖片太大了,換一張小一點的。",
|
|
317
|
+
planAll: "共 {n}",
|
|
318
|
+
planDay: "每天 {n}",
|
|
319
|
+
planFor: "{n} 天",
|
|
320
|
+
payFor: "開通{plan}",
|
|
321
|
+
payMini: "小程式裡不能付款。請聯絡 {owner} 開通。",
|
|
322
|
+
payLead: "付款給 {owner},對方確認收到後就開通。",
|
|
323
|
+
payNext: "去付款",
|
|
324
|
+
payNote: "付款時在備註裡寫上核對碼 {code},方便 {owner} 找到你的付款。",
|
|
325
|
+
payNoCode: "提供者還沒上傳收款碼,請聯絡對方付款",
|
|
326
|
+
payAfter: "付完點「我付好了」,提供者確認後就開通,這裡會自動更新。",
|
|
327
|
+
payDone: "我付好了",
|
|
328
|
+
byOwner: "{owner} 開放給你",
|
|
329
|
+
startChat: "開始一個新對話",
|
|
330
|
+
chatsHere: "你的 {n} 個對話在對話列表裡",
|
|
331
|
+
waitingPay: "等對方確認收款",
|
|
332
|
+
waitingLine: "核對碼 {code} · {date}",
|
|
333
|
+
plansToBuy: "付費方案",
|
|
334
|
+
currentTag: "目前",
|
|
335
|
+
buyHint: "選一個方案,掃碼付款,提供者確認後就開通。",
|
|
336
|
+
buyHintOffline: "選一個方案,然後和 {owner} 約好怎麼付款。",
|
|
337
|
+
privacyUser: "對話儲存在 {owner} 的電腦上,30 天後可能被清理;不要在這裡傳密碼等私密資訊。",
|
|
338
|
+
emptyUser: "沒有開放給你的智慧體"
|
|
339
|
+
};
|
|
340
|
+
var EN = {
|
|
341
|
+
title: "Open to others",
|
|
342
|
+
mineTitle: "Opened to me",
|
|
343
|
+
failed: "Could not do it: {message}",
|
|
344
|
+
free: "Free",
|
|
345
|
+
tokens: "{n}K",
|
|
346
|
+
statePaused: "Paused by its owner",
|
|
347
|
+
stateEnded: "Plan ended",
|
|
348
|
+
stateNone: "No plan yet",
|
|
349
|
+
stateUsed: "Allowance used up",
|
|
350
|
+
stateDaily: "Today’s allowance is used; back at {time}",
|
|
351
|
+
leftToday: "{n} left today",
|
|
352
|
+
leftAll: "{n} left",
|
|
353
|
+
endsOn: "ends {date}",
|
|
354
|
+
unlimited: "No limit",
|
|
355
|
+
anonymous: "Anonymous",
|
|
356
|
+
joinRow: "wants to use {name}",
|
|
357
|
+
refuse: "Refuse",
|
|
358
|
+
letIn: "Let in",
|
|
359
|
+
paidRow: "paying {price} for {plan}",
|
|
360
|
+
codeRow: "Code {code} · {date}",
|
|
361
|
+
notReceived: "Not received",
|
|
362
|
+
confirmPaid: "Received, open it",
|
|
363
|
+
usersCount: "{n} using it",
|
|
364
|
+
usedToday: "{n} today",
|
|
365
|
+
pausedTag: "Paused",
|
|
366
|
+
goneTag: "Agent removed",
|
|
367
|
+
emptyTitle: "Nothing opened to others yet",
|
|
368
|
+
emptyHint: "Pick an agent and its plans to get a link: others open it in a browser and use it, running on your computer",
|
|
369
|
+
openOne: "Open an agent",
|
|
370
|
+
waiting: "Waiting for you",
|
|
371
|
+
opened: "Opened",
|
|
372
|
+
payTitle: "Getting paid",
|
|
373
|
+
payeeRow: "Payment code",
|
|
374
|
+
payeeSet: "Uploaded",
|
|
375
|
+
payeeUnset: "No payment code yet",
|
|
376
|
+
payHint: "They pay by scanning your code, with a check code in the note; you look at what came in and open it. No money goes through Ta.",
|
|
377
|
+
noLimit: "No limit",
|
|
378
|
+
removePlan: "Remove the plan",
|
|
379
|
+
planPrice: "Price",
|
|
380
|
+
yuan: "yuan",
|
|
381
|
+
planDays: "Lasts",
|
|
382
|
+
daysUnit: "days",
|
|
383
|
+
planTokens: "In all",
|
|
384
|
+
tokenUnit: "K tokens",
|
|
385
|
+
planDaily: "A day at most",
|
|
386
|
+
planTrial: "Trial",
|
|
387
|
+
planPack: "Pack",
|
|
388
|
+
planMonth: "Monthly",
|
|
389
|
+
planNew: "New plan",
|
|
390
|
+
editTitle: "Change the offer",
|
|
391
|
+
openTitle: "Open an agent",
|
|
392
|
+
noAgents: "No agents yet. Make one among Partners, then open it.",
|
|
393
|
+
agent: "Agent",
|
|
394
|
+
shownName: "Name shown to others",
|
|
395
|
+
intro: "About",
|
|
396
|
+
introHint: "A line or two: what it helps with",
|
|
397
|
+
approve: "Ask me about each new user",
|
|
398
|
+
approveOn: "You are asked when someone asks to use it",
|
|
399
|
+
approveOff: "Anyone with the link uses it at once (the trial only)",
|
|
400
|
+
plans: "Plans",
|
|
401
|
+
addPlan: "Add a plan",
|
|
402
|
+
trial: "New users first get",
|
|
403
|
+
trialNone: "Nothing until they pay",
|
|
404
|
+
runsHere: "Their conversations run on your computer, on this agent’s model and role; each has their own conversations and folder, apart from the others and from your conversations, files and memory. Paused while your computer is off.",
|
|
405
|
+
accountModel: "This agent uses a model signed in by an account ({model}); such subscriptions rarely allow serving others for money. Use an API key you pay per request for paid plans, or keep only free ones.",
|
|
406
|
+
cancel: "Cancel",
|
|
407
|
+
save: "Save",
|
|
408
|
+
openIt: "Open it",
|
|
409
|
+
givePlanTitle: "Open a plan for {name}",
|
|
410
|
+
plan: "Plan",
|
|
411
|
+
amountGot: "Amount received (yuan)",
|
|
412
|
+
giveHint: "For money taken offline (a transfer, cash) or a plan given for free; it goes into the ledger.",
|
|
413
|
+
give: "Open it",
|
|
414
|
+
removeUserTitle: "Stop {name} using it?",
|
|
415
|
+
removeUserHint: "Their devices are disconnected, and they come in again only by asking.",
|
|
416
|
+
removeUser: "Remove",
|
|
417
|
+
noPlan: "No plan",
|
|
418
|
+
usedAll: "{n} used",
|
|
419
|
+
onlineTag: "Online",
|
|
420
|
+
givePlan: "Open a plan",
|
|
421
|
+
resume: "Resume",
|
|
422
|
+
pause: "Pause",
|
|
423
|
+
shareTitle: "Share {name}",
|
|
424
|
+
linkGets: "They open it in a browser and use it, on your models",
|
|
425
|
+
linkApprove: "You let in each one who asks",
|
|
426
|
+
linkOpen: "Anyone with the link gets the trial at once",
|
|
427
|
+
linkUntil: "The link works until {date}",
|
|
428
|
+
closeTitle: "Close {name}?",
|
|
429
|
+
closeHint: "The link stops, and those who came only for it are taken out of your Ta. The ledger stays.",
|
|
430
|
+
closeOffer: "Close the offer",
|
|
431
|
+
agentLine: "On the default model",
|
|
432
|
+
statUsers: "Users",
|
|
433
|
+
statIncome: "Received",
|
|
434
|
+
statCost: "Model cost",
|
|
435
|
+
shareLink: "Share the link",
|
|
436
|
+
edit: "Change",
|
|
437
|
+
trialTag: "trial",
|
|
438
|
+
users: "Users",
|
|
439
|
+
noUsers: "No one uses it yet",
|
|
440
|
+
noUsersHint: "Send the link to someone",
|
|
441
|
+
privacyOwner: "Their conversations are kept on your computer, not shown by default, under Guests’ conversations in the list.",
|
|
442
|
+
payeeTitle: "Payment code",
|
|
443
|
+
payeeLead: "Upload your WeChat payment code; people scan it when they pay for a plan.",
|
|
444
|
+
changePicture: "Change",
|
|
445
|
+
pickPicture: "Upload a code",
|
|
446
|
+
removePicture: "Remove",
|
|
447
|
+
payeeNote: "Other ways to pay",
|
|
448
|
+
payeeNoteHint: "For example: a transfer to xxx, or in person",
|
|
449
|
+
payeeTip: "A business payment code is best: a personal one taking many payments may be limited by WeChat.",
|
|
450
|
+
done: "Done",
|
|
451
|
+
pictureTooBig: "That picture is too large; pick a smaller one.",
|
|
452
|
+
planAll: "{n} in all",
|
|
453
|
+
planDay: "{n} a day",
|
|
454
|
+
planFor: "{n} days",
|
|
455
|
+
payFor: "Pay for {plan}",
|
|
456
|
+
payMini: "Paying is not possible in the mini program. Ask {owner} to open it for you.",
|
|
457
|
+
payLead: "Pay {owner}; it opens once they confirm they got it.",
|
|
458
|
+
payNext: "Pay",
|
|
459
|
+
payNote: "Write the check code {code} in the note as you pay, so that {owner} finds your payment.",
|
|
460
|
+
payNoCode: "Its owner has no payment code yet; ask them how to pay",
|
|
461
|
+
payAfter: "Once paid, tap I paid; it opens as its owner confirms, and this page updates by itself.",
|
|
462
|
+
payDone: "I paid",
|
|
463
|
+
byOwner: "Opened to you by {owner}",
|
|
464
|
+
startChat: "Start a new conversation",
|
|
465
|
+
chatsHere: "Your {n} conversations are in the list",
|
|
466
|
+
waitingPay: "Waiting for the owner to confirm",
|
|
467
|
+
waitingLine: "Code {code} · {date}",
|
|
468
|
+
plansToBuy: "Paid plans",
|
|
469
|
+
currentTag: "Current",
|
|
470
|
+
buyHint: "Pick a plan and pay by the code; it opens once its owner confirms.",
|
|
471
|
+
buyHintOffline: "Pick a plan, then agree with {owner} how to pay.",
|
|
472
|
+
privacyUser: "Conversations are kept on {owner}’s computer and may be cleared after 30 days; send no passwords or private details here.",
|
|
473
|
+
emptyUser: "Nothing is opened to you"
|
|
474
|
+
};
|
|
475
|
+
var JA = {
|
|
476
|
+
title: "ほかの人に公開",
|
|
477
|
+
mineTitle: "公開されたもの",
|
|
478
|
+
failed: "できませんでした:{message}",
|
|
479
|
+
free: "無料",
|
|
480
|
+
tokens: "{n} 万",
|
|
481
|
+
statePaused: "提供者が一時停止中",
|
|
482
|
+
stateEnded: "プランの期限切れ",
|
|
483
|
+
stateNone: "プランがありません",
|
|
484
|
+
stateUsed: "利用枠を使い切りました",
|
|
485
|
+
stateDaily: "今日の利用枠を使い切りました。{time} に戻ります",
|
|
486
|
+
leftToday: "今日の残り {n}",
|
|
487
|
+
leftAll: "残り {n}",
|
|
488
|
+
endsOn: "{date}まで",
|
|
489
|
+
unlimited: "無制限",
|
|
490
|
+
anonymous: "匿名",
|
|
491
|
+
joinRow: "{name} を使いたい",
|
|
492
|
+
refuse: "断る",
|
|
493
|
+
letIn: "許可",
|
|
494
|
+
paidRow: "{price} で {plan} を開通",
|
|
495
|
+
codeRow: "照合コード {code} · {date}",
|
|
496
|
+
notReceived: "未入金",
|
|
497
|
+
confirmPaid: "受け取った・開通",
|
|
498
|
+
usersCount: "{n} 人が利用中",
|
|
499
|
+
usedToday: "今日 {n}",
|
|
500
|
+
pausedTag: "一時停止中",
|
|
501
|
+
goneTag: "エージェント削除済み",
|
|
502
|
+
emptyTitle: "まだ公開したエージェントはありません",
|
|
503
|
+
emptyHint: "エージェントとプランを選ぶとリンクができます。相手はブラウザーで開くだけで使え、あなたのコンピューターで動きます",
|
|
504
|
+
openOne: "エージェントを公開",
|
|
505
|
+
waiting: "対応待ち",
|
|
506
|
+
opened: "公開中",
|
|
507
|
+
payTitle: "受け取り",
|
|
508
|
+
payeeRow: "受け取りコード",
|
|
509
|
+
payeeSet: "アップロード済み",
|
|
510
|
+
payeeUnset: "受け取りコードがまだありません",
|
|
511
|
+
payHint: "相手はあなたのコードをスキャンして支払い、備考に照合コードを書きます。入金を確認してから開通してください。お金は Ta を通りません。",
|
|
512
|
+
noLimit: "無制限",
|
|
513
|
+
removePlan: "プランを削除",
|
|
514
|
+
planPrice: "価格",
|
|
515
|
+
yuan: "元",
|
|
516
|
+
planDays: "有効期間",
|
|
517
|
+
daysUnit: "日",
|
|
518
|
+
planTokens: "合計",
|
|
519
|
+
tokenUnit: "万トークン",
|
|
520
|
+
planDaily: "1 日の上限",
|
|
521
|
+
planTrial: "お試し",
|
|
522
|
+
planPack: "従量パック",
|
|
523
|
+
planMonth: "月額",
|
|
524
|
+
planNew: "新しいプラン",
|
|
525
|
+
editTitle: "公開を変更",
|
|
526
|
+
openTitle: "エージェントを公開",
|
|
527
|
+
noAgents: "エージェントがまだありません。「仲間」で作ってから公開してください。",
|
|
528
|
+
agent: "エージェント",
|
|
529
|
+
shownName: "表示名",
|
|
530
|
+
intro: "紹介",
|
|
531
|
+
introHint: "一言二言で:何を手伝えるか",
|
|
532
|
+
approve: "新しい利用者ごとに承認する",
|
|
533
|
+
approveOn: "申請があればあなたに確認します",
|
|
534
|
+
approveOff: "リンクを持つ人はすぐ使えます(お試し枠のみ)",
|
|
535
|
+
plans: "プラン",
|
|
536
|
+
addPlan: "プランを追加",
|
|
537
|
+
trial: "新しい利用者がまず得るもの",
|
|
538
|
+
trialNone: "支払うまで何もなし",
|
|
539
|
+
runsHere: "相手の会話はあなたのコンピューターで、このエージェントのモデルと説明で動きます。ひとりずつ自分の会話とフォルダーを持ち、互いにも、あなたの会話・ファイル・記憶にも触れられません。コンピューターの電源が切れている間は停止します。",
|
|
540
|
+
accountModel: "このエージェントはアカウントでサインインしたモデル({model})を使っています。こうしたサブスクリプションは他人への有料提供をほぼ認めていません。有料プランには従量課金の API キーを使うか、無料プランだけにしてください。",
|
|
541
|
+
cancel: "キャンセル",
|
|
542
|
+
save: "保存",
|
|
543
|
+
openIt: "公開",
|
|
544
|
+
givePlanTitle: "{name} さんに開通",
|
|
545
|
+
plan: "プラン",
|
|
546
|
+
amountGot: "受け取った金額(元)",
|
|
547
|
+
giveHint: "オフラインで受け取ったお金(振込・現金)や無料で贈る場合はここで開通します。台帳に記録されます。",
|
|
548
|
+
give: "開通",
|
|
549
|
+
removeUserTitle: "{name} さんの利用を止めますか?",
|
|
550
|
+
removeUserHint: "相手のデバイスは切断され、改めて申請しない限り入れません。",
|
|
551
|
+
removeUser: "削除",
|
|
552
|
+
noPlan: "プランなし",
|
|
553
|
+
usedAll: "合計 {n} 使用",
|
|
554
|
+
onlineTag: "オンライン",
|
|
555
|
+
givePlan: "プランを開通",
|
|
556
|
+
resume: "再開",
|
|
557
|
+
pause: "一時停止",
|
|
558
|
+
shareTitle: "{name} を共有",
|
|
559
|
+
linkGets: "相手はブラウザーで開くだけで使え、あなたのモデルで動きます",
|
|
560
|
+
linkApprove: "申請ごとにあなたが承認します",
|
|
561
|
+
linkOpen: "リンクを持つ人はすぐお試し枠を使えます",
|
|
562
|
+
linkUntil: "リンクは {date} まで有効",
|
|
563
|
+
closeTitle: "{name} を閉じますか?",
|
|
564
|
+
closeHint: "リンクは無効になり、これのためだけに入った人はあなたの Ta から外れます。台帳は残ります。",
|
|
565
|
+
closeOffer: "公開を閉じる",
|
|
566
|
+
agentLine: "既定のモデルで動作",
|
|
567
|
+
statUsers: "利用者",
|
|
568
|
+
statIncome: "受取済み",
|
|
569
|
+
statCost: "モデル費用",
|
|
570
|
+
shareLink: "リンクを共有",
|
|
571
|
+
edit: "変更",
|
|
572
|
+
trialTag: "お試し",
|
|
573
|
+
users: "利用者",
|
|
574
|
+
noUsers: "まだ誰も使っていません",
|
|
575
|
+
noUsersHint: "リンクを送りましょう",
|
|
576
|
+
privacyOwner: "利用者の会話はあなたのコンピューターに保存されますが、既定では表示せず、会話一覧の「ゲストの会話」にまとまります。",
|
|
577
|
+
payeeTitle: "受け取りコード",
|
|
578
|
+
payeeLead: "WeChat の受け取りコードをアップロードすると、相手は有料プランの開通時にスキャンして支払えます。",
|
|
579
|
+
changePicture: "変更",
|
|
580
|
+
pickPicture: "コードをアップロード",
|
|
581
|
+
removePicture: "外す",
|
|
582
|
+
payeeNote: "ほかの支払い方法",
|
|
583
|
+
payeeNoteHint: "例:xxx への振込、対面での支払い",
|
|
584
|
+
payeeTip: "事業用の受け取りコードがおすすめです。個人用で頻繁に受け取ると WeChat に制限されることがあります。",
|
|
585
|
+
done: "完了",
|
|
586
|
+
pictureTooBig: "画像が大きすぎます。小さい画像を選んでください。",
|
|
587
|
+
planAll: "合計 {n}",
|
|
588
|
+
planDay: "1 日 {n}",
|
|
589
|
+
planFor: "{n} 日",
|
|
590
|
+
payFor: "{plan}を開通",
|
|
591
|
+
payMini: "ミニプログラムでは支払いできません。{owner} さんに開通を依頼してください。",
|
|
592
|
+
payLead: "{owner} さんに支払い、確認されれば開通します。",
|
|
593
|
+
payNext: "支払いへ",
|
|
594
|
+
payNote: "支払うときに備考に照合コード {code} を書いてください。{owner} さんがあなたの支払いを見つけやすくなります。",
|
|
595
|
+
payNoCode: "提供者はまだ受け取りコードを設定していません。支払い方法を相談してください",
|
|
596
|
+
payAfter: "支払ったら「支払いました」をタップ。提供者が確認すると開通し、このページも自動で更新されます。",
|
|
597
|
+
payDone: "支払いました",
|
|
598
|
+
byOwner: "{owner} さんがあなたに公開",
|
|
599
|
+
startChat: "新しい会話を始める",
|
|
600
|
+
chatsHere: "あなたの会話 {n} 件は会話一覧にあります",
|
|
601
|
+
waitingPay: "入金確認待ち",
|
|
602
|
+
waitingLine: "照合コード {code} · {date}",
|
|
603
|
+
plansToBuy: "有料プラン",
|
|
604
|
+
currentTag: "利用中",
|
|
605
|
+
buyHint: "プランを選んでコードで支払うと、提供者の確認後に開通します。",
|
|
606
|
+
buyHintOffline: "プランを選び、{owner} さんと支払い方法を決めてください。",
|
|
607
|
+
privacyUser: "会話は {owner} さんのコンピューターに保存され、30 日後に消えることがあります。パスワードなどの個人情報は送らないでください。",
|
|
608
|
+
emptyUser: "あなたに公開されたものはありません"
|
|
609
|
+
};
|
|
610
|
+
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
611
|
+
var OfferWords;
|
|
612
|
+
((OfferWords) => {
|
|
613
|
+
function of(language) {
|
|
614
|
+
return TaLanguageUtil.pick(language, WORDS);
|
|
615
|
+
}
|
|
616
|
+
OfferWords.of = of;
|
|
617
|
+
function format(text, values) {
|
|
618
|
+
return text.replace(/\{(\w+)\}/g, (whole, key) => (key in values) ? String(values[key]) : whole);
|
|
619
|
+
}
|
|
620
|
+
OfferWords.format = format;
|
|
621
|
+
})(OfferWords ||= {});
|
|
622
|
+
|
|
623
|
+
// web-src/react.ts
|
|
624
|
+
var React;
|
|
625
|
+
function bind(react) {
|
|
626
|
+
React = react;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// web-src/page.ts
|
|
630
|
+
var pi;
|
|
631
|
+
function bindPage(api) {
|
|
632
|
+
pi = api;
|
|
633
|
+
}
|
|
634
|
+
function t(key, values = {}) {
|
|
635
|
+
return OfferWords.format(OfferWords.of(pi.ui.language)[key], values);
|
|
636
|
+
}
|
|
637
|
+
function icon(name) {
|
|
638
|
+
return pi.ui.icons[name] ?? pi.ui.icons.Store ?? pi.ui.icons.Circle;
|
|
639
|
+
}
|
|
640
|
+
function message(error) {
|
|
641
|
+
return error instanceof Error ? error.message : String(error);
|
|
642
|
+
}
|
|
643
|
+
function call(method, ...params) {
|
|
644
|
+
return pi.callHost(method, ...params);
|
|
645
|
+
}
|
|
646
|
+
async function act(run) {
|
|
647
|
+
try {
|
|
648
|
+
const result = await run();
|
|
649
|
+
book.load();
|
|
650
|
+
return result;
|
|
651
|
+
} catch (error) {
|
|
652
|
+
pi.ui.notify(t("failed", { message: message(error) }), "error");
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function price(fen) {
|
|
657
|
+
return fen > 0 ? `¥${(fen / 100).toFixed(fen % 100 === 0 ? 0 : 2)}` : t("free");
|
|
658
|
+
}
|
|
659
|
+
var FACTOR = { "zh-CN": 1e4, "zh-TW": 1e4, "ja-JP": 1e4, "en-US": 1000 };
|
|
660
|
+
function tokenFactor() {
|
|
661
|
+
return TaLanguageUtil.pick(pi.ui.language, FACTOR);
|
|
662
|
+
}
|
|
663
|
+
function tokens(n) {
|
|
664
|
+
const value = n / tokenFactor();
|
|
665
|
+
const shown = value >= 100 || Number.isInteger(value) ? Math.round(value).toString() : value.toFixed(1);
|
|
666
|
+
return t("tokens", { n: shown });
|
|
667
|
+
}
|
|
668
|
+
function dateOf(at) {
|
|
669
|
+
return new Date(at).toLocaleDateString(pi.ui.language, { month: "short", day: "numeric" });
|
|
670
|
+
}
|
|
671
|
+
function timeOf(at) {
|
|
672
|
+
return new Date(at).toLocaleTimeString(pi.ui.language, { hour: "2-digit", minute: "2-digit" });
|
|
673
|
+
}
|
|
674
|
+
function leftLine(state) {
|
|
675
|
+
switch (state.block) {
|
|
676
|
+
case "paused":
|
|
677
|
+
case "closed":
|
|
678
|
+
return t("statePaused");
|
|
679
|
+
case "expired":
|
|
680
|
+
return state.endsAt ? t("stateEnded") : t("stateNone");
|
|
681
|
+
case "total":
|
|
682
|
+
return t("stateUsed");
|
|
683
|
+
case "daily":
|
|
684
|
+
return t("stateDaily", { time: state.resetsAt ? timeOf(state.resetsAt) : "0:00" });
|
|
685
|
+
default: {
|
|
686
|
+
const parts = [
|
|
687
|
+
state.todayLeft !== undefined ? t("leftToday", { n: tokens(state.todayLeft) }) : undefined,
|
|
688
|
+
state.left !== undefined ? t("leftAll", { n: tokens(state.left) }) : undefined,
|
|
689
|
+
state.endsAt !== undefined ? t("endsOn", { date: dateOf(state.endsAt) }) : undefined
|
|
690
|
+
].filter(Boolean);
|
|
691
|
+
return parts.length ? parts.join(" · ") : t("unlimited");
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
class OfferBook {
|
|
697
|
+
state = { loaded: false };
|
|
698
|
+
listeners = new Set;
|
|
699
|
+
loading;
|
|
700
|
+
get() {
|
|
701
|
+
return this.state;
|
|
702
|
+
}
|
|
703
|
+
subscribe = (listener) => {
|
|
704
|
+
this.listeners.add(listener);
|
|
705
|
+
return () => this.listeners.delete(listener);
|
|
706
|
+
};
|
|
707
|
+
load() {
|
|
708
|
+
this.loading ??= this.read().finally(() => {
|
|
709
|
+
this.loading = undefined;
|
|
710
|
+
});
|
|
711
|
+
return this.loading;
|
|
712
|
+
}
|
|
713
|
+
watch() {
|
|
714
|
+
return pi.storage.onChange((keys) => keys.includes(DATA_KEY) && void this.load());
|
|
715
|
+
}
|
|
716
|
+
async read() {
|
|
717
|
+
try {
|
|
718
|
+
const overview = await call("overview").catch(() => {
|
|
719
|
+
return;
|
|
720
|
+
});
|
|
721
|
+
const mine = overview ? undefined : await call("mine");
|
|
722
|
+
this.state = { ...overview ? { overview } : {}, ...mine ? { mine } : {}, loaded: true };
|
|
723
|
+
} catch (error) {
|
|
724
|
+
this.state = { ...this.state, loaded: true, error: message(error) };
|
|
725
|
+
}
|
|
726
|
+
for (const listener of this.listeners) {
|
|
727
|
+
listener();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
var book = new OfferBook;
|
|
732
|
+
function useBook() {
|
|
733
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
734
|
+
React.useEffect(() => book.subscribe(tick), []);
|
|
735
|
+
return book.get();
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// web-src/offer-dialog.tsx
|
|
739
|
+
var num = (value) => value.trim() === "" ? undefined : Number(value);
|
|
740
|
+
function toRow(plan) {
|
|
741
|
+
const factor = tokenFactor();
|
|
742
|
+
const shown = (n) => n === undefined ? "" : String(Math.round(n / factor * 10) / 10);
|
|
743
|
+
return {
|
|
744
|
+
id: plan.id,
|
|
745
|
+
name: plan.name,
|
|
746
|
+
price: plan.price ? String(plan.price / 100) : "",
|
|
747
|
+
tokens: shown(plan.tokens),
|
|
748
|
+
daily: shown(plan.daily),
|
|
749
|
+
days: plan.days ? String(plan.days) : ""
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
function toPlan(row) {
|
|
753
|
+
const factor = tokenFactor();
|
|
754
|
+
const tokens2 = num(row.tokens);
|
|
755
|
+
const daily = num(row.daily);
|
|
756
|
+
return {
|
|
757
|
+
id: row.id,
|
|
758
|
+
name: row.name,
|
|
759
|
+
price: Math.round((num(row.price) ?? 0) * 100),
|
|
760
|
+
...tokens2 !== undefined ? { tokens: Math.round(tokens2 * factor) } : {},
|
|
761
|
+
...daily !== undefined ? { daily: Math.round(daily * factor) } : {},
|
|
762
|
+
...num(row.days) !== undefined ? { days: num(row.days) } : {}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
function starting() {
|
|
766
|
+
return [
|
|
767
|
+
{ id: "trial", name: t("planTrial"), price: 0, tokens: 200000, days: 7 },
|
|
768
|
+
{ id: "pack", name: t("planPack"), price: 2000, tokens: 2000000 },
|
|
769
|
+
{ id: "month", name: t("planMonth"), price: 3000, tokens: 15000000, daily: 1e6, days: 30 }
|
|
770
|
+
].map(toRow);
|
|
771
|
+
}
|
|
772
|
+
function PlanEditor({ row, onChange, onRemove }) {
|
|
773
|
+
const X = pi.ui.icons.X;
|
|
774
|
+
const field = (key, label, suffix) => /* @__PURE__ */ React.createElement("label", {
|
|
775
|
+
className: "tof-plan-field"
|
|
776
|
+
}, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", {
|
|
777
|
+
className: "tof-plan-input"
|
|
778
|
+
}, /* @__PURE__ */ React.createElement("input", {
|
|
779
|
+
className: "tof-input",
|
|
780
|
+
inputMode: "decimal",
|
|
781
|
+
value: row[key],
|
|
782
|
+
placeholder: key === "price" ? "0" : t("noLimit"),
|
|
783
|
+
onChange: (event) => onChange({ ...row, [key]: event.target.value.replace(/[^\d.]/g, "") })
|
|
784
|
+
}), suffix && /* @__PURE__ */ React.createElement("small", null, suffix)));
|
|
785
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
786
|
+
className: "tof-plan"
|
|
787
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
788
|
+
className: "tof-plan-head"
|
|
789
|
+
}, /* @__PURE__ */ React.createElement("input", {
|
|
790
|
+
className: "tof-input tof-plan-name",
|
|
791
|
+
value: row.name,
|
|
792
|
+
maxLength: LIMITS.planName,
|
|
793
|
+
onChange: (event) => onChange({ ...row, name: event.target.value })
|
|
794
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
795
|
+
type: "button",
|
|
796
|
+
className: "tof-icon",
|
|
797
|
+
"aria-label": t("removePlan"),
|
|
798
|
+
onClick: onRemove
|
|
799
|
+
}, /* @__PURE__ */ React.createElement(X, {
|
|
800
|
+
size: 15
|
|
801
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
802
|
+
className: "tof-plan-grid"
|
|
803
|
+
}, field("price", t("planPrice"), t("yuan")), field("days", t("planDays"), t("daysUnit")), field("tokens", t("planTokens"), t("tokenUnit")), field("daily", t("planDaily"), t("tokenUnit"))));
|
|
804
|
+
}
|
|
805
|
+
async function accountModel(agent) {
|
|
806
|
+
const settings = await pi.settings.getSettings().catch(() => {
|
|
807
|
+
return;
|
|
808
|
+
});
|
|
809
|
+
if (!settings?.accounts) {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
const user = settings.user;
|
|
813
|
+
const model = agent?.model ?? (typeof user.defaultProvider === "string" && typeof user.defaultModel === "string" ? `${user.defaultProvider}/${user.defaultModel}` : undefined);
|
|
814
|
+
return model && settings.accounts.includes(model) ? model : undefined;
|
|
815
|
+
}
|
|
816
|
+
function OfferDialog({ offer, close }) {
|
|
817
|
+
const Loading = pi.ui.Loading;
|
|
818
|
+
const [agents, setAgents] = React.useState();
|
|
819
|
+
const [agent, setAgent] = React.useState(offer?.agent ?? "");
|
|
820
|
+
const [name, setName] = React.useState(offer?.name ?? "");
|
|
821
|
+
const [intro, setIntro] = React.useState(offer?.intro ?? "");
|
|
822
|
+
const [approve, setApprove] = React.useState(offer?.approve ?? true);
|
|
823
|
+
const [rows, setRows] = React.useState(() => offer ? offer.plans.map(toRow) : starting());
|
|
824
|
+
const [trial, setTrial] = React.useState(offer ? offer.trial ?? "" : "trial");
|
|
825
|
+
const [account, setAccount] = React.useState();
|
|
826
|
+
const [busy, run] = pi.ui.useBusy();
|
|
827
|
+
React.useEffect(() => {
|
|
828
|
+
call("agents").then((list) => {
|
|
829
|
+
setAgents(list);
|
|
830
|
+
setAgent((current) => current || list[0]?.id || "");
|
|
831
|
+
}, () => setAgents([]));
|
|
832
|
+
}, []);
|
|
833
|
+
const picked = agents?.find((one) => one.id === agent);
|
|
834
|
+
React.useEffect(() => {
|
|
835
|
+
accountModel(picked).then(setAccount);
|
|
836
|
+
}, [picked]);
|
|
837
|
+
const free = rows.filter((row) => !(num(row.price) ?? 0));
|
|
838
|
+
const charged = rows.some((row) => (num(row.price) ?? 0) > 0);
|
|
839
|
+
const blocked = charged && !!account;
|
|
840
|
+
const save = async () => {
|
|
841
|
+
const saved = await act(() => call("save", {
|
|
842
|
+
...offer ? { id: offer.id } : {},
|
|
843
|
+
agent,
|
|
844
|
+
name: name.trim() || picked?.name,
|
|
845
|
+
intro,
|
|
846
|
+
approve,
|
|
847
|
+
plans: rows.map(toPlan),
|
|
848
|
+
trial: free.some((row) => row.id === trial) ? trial : undefined,
|
|
849
|
+
language: pi.ui.language
|
|
850
|
+
}));
|
|
851
|
+
if (saved) {
|
|
852
|
+
close();
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
const add = () => {
|
|
856
|
+
const id = `p${Date.now().toString(36)}`;
|
|
857
|
+
setRows([...rows, { id, name: t("planNew"), price: "", tokens: "", daily: "", days: "" }]);
|
|
858
|
+
};
|
|
859
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
860
|
+
title: offer ? t("editTitle") : t("openTitle"),
|
|
861
|
+
onClose: close
|
|
862
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
863
|
+
className: "tof-dialog"
|
|
864
|
+
}, !agents ? /* @__PURE__ */ React.createElement(Loading, {
|
|
865
|
+
compact: true
|
|
866
|
+
}) : !agents.length ? /* @__PURE__ */ React.createElement("p", {
|
|
867
|
+
className: "tof-hint"
|
|
868
|
+
}, t("noAgents")) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", {
|
|
869
|
+
className: "tof-field"
|
|
870
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("agent")), /* @__PURE__ */ React.createElement("select", {
|
|
871
|
+
className: "tof-input",
|
|
872
|
+
value: agent,
|
|
873
|
+
disabled: !!offer,
|
|
874
|
+
onChange: (event) => setAgent(event.target.value)
|
|
875
|
+
}, agents.map((one) => /* @__PURE__ */ React.createElement("option", {
|
|
876
|
+
key: one.id,
|
|
877
|
+
value: one.id
|
|
878
|
+
}, one.name)))), /* @__PURE__ */ React.createElement("label", {
|
|
879
|
+
className: "tof-field"
|
|
880
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("shownName")), /* @__PURE__ */ React.createElement("input", {
|
|
881
|
+
className: "tof-input",
|
|
882
|
+
value: name,
|
|
883
|
+
maxLength: LIMITS.name,
|
|
884
|
+
placeholder: picked?.name,
|
|
885
|
+
onChange: (event) => setName(event.target.value)
|
|
886
|
+
})), /* @__PURE__ */ React.createElement("label", {
|
|
887
|
+
className: "tof-field"
|
|
888
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("intro")), /* @__PURE__ */ React.createElement("textarea", {
|
|
889
|
+
className: "tof-input tof-textarea",
|
|
890
|
+
value: intro,
|
|
891
|
+
maxLength: LIMITS.intro,
|
|
892
|
+
placeholder: t("introHint"),
|
|
893
|
+
onChange: (event) => setIntro(event.target.value)
|
|
894
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
895
|
+
className: "tof-switch-row"
|
|
896
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
897
|
+
className: "tof-row-text"
|
|
898
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("approve")), /* @__PURE__ */ React.createElement("small", null, approve ? t("approveOn") : t("approveOff"))), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
899
|
+
checked: approve,
|
|
900
|
+
label: t("approve"),
|
|
901
|
+
onChange: setApprove
|
|
902
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
903
|
+
className: "tof-field"
|
|
904
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("plans")), /* @__PURE__ */ React.createElement("ul", {
|
|
905
|
+
className: "tof-plans"
|
|
906
|
+
}, rows.map((row, index) => /* @__PURE__ */ React.createElement(PlanEditor, {
|
|
907
|
+
key: row.id,
|
|
908
|
+
row,
|
|
909
|
+
onChange: (next) => setRows(rows.map((one, at) => at === index ? next : one)),
|
|
910
|
+
onRemove: () => setRows(rows.filter((_, at) => at !== index))
|
|
911
|
+
}))), rows.length < LIMITS.plans && /* @__PURE__ */ React.createElement("button", {
|
|
912
|
+
type: "button",
|
|
913
|
+
className: "tof-link",
|
|
914
|
+
onClick: add
|
|
915
|
+
}, t("addPlan"))), free.length > 0 && /* @__PURE__ */ React.createElement("label", {
|
|
916
|
+
className: "tof-field"
|
|
917
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("trial")), /* @__PURE__ */ React.createElement("select", {
|
|
918
|
+
className: "tof-input",
|
|
919
|
+
value: free.some((row) => row.id === trial) ? trial : "",
|
|
920
|
+
onChange: (event) => setTrial(event.target.value)
|
|
921
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
922
|
+
value: ""
|
|
923
|
+
}, t("trialNone")), free.map((row) => /* @__PURE__ */ React.createElement("option", {
|
|
924
|
+
key: row.id,
|
|
925
|
+
value: row.id
|
|
926
|
+
}, row.name)))), /* @__PURE__ */ React.createElement("p", {
|
|
927
|
+
className: "tof-hint"
|
|
928
|
+
}, t("runsHere")), blocked && /* @__PURE__ */ React.createElement("p", {
|
|
929
|
+
className: "tof-warn"
|
|
930
|
+
}, t("accountModel", { model: account ?? "" })), /* @__PURE__ */ React.createElement("div", {
|
|
931
|
+
className: "tof-actions"
|
|
932
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
933
|
+
type: "button",
|
|
934
|
+
className: "ta-button",
|
|
935
|
+
onClick: close
|
|
936
|
+
}, t("cancel")), /* @__PURE__ */ React.createElement("button", {
|
|
937
|
+
type: "button",
|
|
938
|
+
className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
|
|
939
|
+
disabled: busy || blocked || !agent || !rows.length,
|
|
940
|
+
onClick: () => void run(save)
|
|
941
|
+
}, offer ? t("save") : t("openIt"))))));
|
|
942
|
+
}
|
|
943
|
+
function openOffer(id) {
|
|
944
|
+
const offer = id ? book.get().overview?.offers.find((one) => one.id === id) : undefined;
|
|
945
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(OfferDialog, {
|
|
946
|
+
offer,
|
|
947
|
+
close
|
|
948
|
+
}));
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// web-src/offer-detail.tsx
|
|
952
|
+
function GiveDialog({ user, offer, close }) {
|
|
953
|
+
const [plan, setPlan] = React.useState(offer.plans.find((one) => one.price > 0)?.id ?? offer.plans[0]?.id ?? "");
|
|
954
|
+
const chosen = offer.plans.find((one) => one.id === plan);
|
|
955
|
+
const [amount, setAmount] = React.useState(chosen ? String(chosen.price / 100) : "0");
|
|
956
|
+
const [busy, run] = pi.ui.useBusy();
|
|
957
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
958
|
+
title: t("givePlanTitle", { name: user.name }),
|
|
959
|
+
onClose: close
|
|
960
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
961
|
+
className: "tof-dialog"
|
|
962
|
+
}, /* @__PURE__ */ React.createElement("label", {
|
|
963
|
+
className: "tof-field"
|
|
964
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("plan")), /* @__PURE__ */ React.createElement("select", {
|
|
965
|
+
className: "tof-input",
|
|
966
|
+
value: plan,
|
|
967
|
+
onChange: (event) => {
|
|
968
|
+
setPlan(event.target.value);
|
|
969
|
+
const next = offer.plans.find((one) => one.id === event.target.value);
|
|
970
|
+
setAmount(next ? String(next.price / 100) : "0");
|
|
971
|
+
}
|
|
972
|
+
}, offer.plans.map((one) => /* @__PURE__ */ React.createElement("option", {
|
|
973
|
+
key: one.id,
|
|
974
|
+
value: one.id
|
|
975
|
+
}, one.name, " · ", price(one.price))))), /* @__PURE__ */ React.createElement("label", {
|
|
976
|
+
className: "tof-field"
|
|
977
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("amountGot")), /* @__PURE__ */ React.createElement("input", {
|
|
978
|
+
className: "tof-input",
|
|
979
|
+
inputMode: "decimal",
|
|
980
|
+
value: amount,
|
|
981
|
+
onChange: (event) => setAmount(event.target.value.replace(/[^\d.]/g, ""))
|
|
982
|
+
})), /* @__PURE__ */ React.createElement("p", {
|
|
983
|
+
className: "tof-hint"
|
|
984
|
+
}, t("giveHint")), /* @__PURE__ */ React.createElement("div", {
|
|
985
|
+
className: "tof-actions"
|
|
986
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
987
|
+
type: "button",
|
|
988
|
+
className: "ta-button",
|
|
989
|
+
onClick: close
|
|
990
|
+
}, t("cancel")), /* @__PURE__ */ React.createElement("button", {
|
|
991
|
+
type: "button",
|
|
992
|
+
className: "ta-button ta-primary",
|
|
993
|
+
disabled: busy || !plan,
|
|
994
|
+
onClick: () => void run(async () => await act(() => call("grant", user.id, plan, Math.round(Number(amount || 0) * 100))) !== undefined && close())
|
|
995
|
+
}, t("give")))));
|
|
996
|
+
}
|
|
997
|
+
function UserRow({ user, offer }) {
|
|
998
|
+
const [busy, run] = pi.ui.useBusy();
|
|
999
|
+
const remove = async () => {
|
|
1000
|
+
if (await pi.ui.confirm(t("removeUserTitle", { name: user.name }), t("removeUserHint"), { confirmLabel: t("removeUser"), danger: true })) {
|
|
1001
|
+
await act(() => call("removeUser", user.id));
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
const line = [user.grant ? user.grant.name : t("noPlan"), leftLine(user.state), user.used.total ? t("usedAll", { n: tokens(user.used.total) }) : undefined].filter(Boolean).join(" · ");
|
|
1005
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
1006
|
+
className: `tof-row tof-row-wrap${busy ? " ta-pending" : ""}`
|
|
1007
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1008
|
+
seed: user.name
|
|
1009
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1010
|
+
className: "tof-row-text"
|
|
1011
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1012
|
+
className: "tof-row-title"
|
|
1013
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1014
|
+
className: "tof-ellipsis"
|
|
1015
|
+
}, user.name), user.online && /* @__PURE__ */ React.createElement("span", {
|
|
1016
|
+
className: "tof-tag tof-tag-good"
|
|
1017
|
+
}, t("onlineTag")), user.paused && /* @__PURE__ */ React.createElement("span", {
|
|
1018
|
+
className: "tof-tag"
|
|
1019
|
+
}, t("pausedTag"))), /* @__PURE__ */ React.createElement("span", {
|
|
1020
|
+
className: "tof-row-line"
|
|
1021
|
+
}, line)), /* @__PURE__ */ React.createElement("div", {
|
|
1022
|
+
className: "tof-answers"
|
|
1023
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1024
|
+
type: "button",
|
|
1025
|
+
className: "ta-button",
|
|
1026
|
+
disabled: busy,
|
|
1027
|
+
onClick: () => pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(GiveDialog, {
|
|
1028
|
+
user,
|
|
1029
|
+
offer,
|
|
1030
|
+
close
|
|
1031
|
+
}))
|
|
1032
|
+
}, t("givePlan")), /* @__PURE__ */ React.createElement("button", {
|
|
1033
|
+
type: "button",
|
|
1034
|
+
className: "ta-button",
|
|
1035
|
+
disabled: busy,
|
|
1036
|
+
onClick: () => void run(() => act(() => call("setUserPaused", user.id, !user.paused)))
|
|
1037
|
+
}, user.paused ? t("resume") : t("pause")), /* @__PURE__ */ React.createElement("button", {
|
|
1038
|
+
type: "button",
|
|
1039
|
+
className: "ta-button tof-danger",
|
|
1040
|
+
disabled: busy,
|
|
1041
|
+
onClick: () => void run(remove)
|
|
1042
|
+
}, t("removeUser"))));
|
|
1043
|
+
}
|
|
1044
|
+
function LinkSheet({ offer, close }) {
|
|
1045
|
+
const [link, setLink] = React.useState(offer.invite?.link);
|
|
1046
|
+
return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
|
|
1047
|
+
pi,
|
|
1048
|
+
title: t("shareTitle", { name: offer.name }),
|
|
1049
|
+
link,
|
|
1050
|
+
face: /* @__PURE__ */ React.createElement(Face, {
|
|
1051
|
+
face: offer.face,
|
|
1052
|
+
seed: offer.agent,
|
|
1053
|
+
size: 44
|
|
1054
|
+
}),
|
|
1055
|
+
name: offer.name,
|
|
1056
|
+
gets: t("linkGets"),
|
|
1057
|
+
notes: [offer.approve ? t("linkApprove") : t("linkOpen"), offer.invite ? t("linkUntil", { date: dateOf(offer.invite.expiresAt) }) : undefined],
|
|
1058
|
+
onRenew: () => void act(() => call("renewLink", offer.id, pi.ui.language)).then((next) => {
|
|
1059
|
+
if (next?.invite) {
|
|
1060
|
+
setLink(next.invite.link);
|
|
1061
|
+
}
|
|
1062
|
+
}),
|
|
1063
|
+
onClose: close
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
function DetailDialog({ id, close }) {
|
|
1067
|
+
const { overview } = useBook();
|
|
1068
|
+
const offer = overview?.offers.find((one) => one.id === id);
|
|
1069
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1070
|
+
if (!overview || !offer) {
|
|
1071
|
+
return null;
|
|
1072
|
+
}
|
|
1073
|
+
const users = overview.users.filter((user) => user.offer === id);
|
|
1074
|
+
const cost = users.reduce((sum, user) => sum + user.used.cost, 0);
|
|
1075
|
+
const income = overview.payments.filter((one) => one.offer === id && one.status === "confirmed").reduce((sum, one) => sum + one.amount, 0);
|
|
1076
|
+
const Share = icon("Share2");
|
|
1077
|
+
const Pencil = icon("Pencil");
|
|
1078
|
+
const closeOffer = async () => {
|
|
1079
|
+
if (await pi.ui.confirm(t("closeTitle", { name: offer.name }), t("closeHint"), { confirmLabel: t("closeOffer"), danger: true })) {
|
|
1080
|
+
if (await act(() => call("remove", offer.id)) !== undefined) {
|
|
1081
|
+
close();
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1086
|
+
title: offer.name,
|
|
1087
|
+
onClose: close
|
|
1088
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1089
|
+
className: "tof-dialog tof-detail"
|
|
1090
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1091
|
+
className: "tof-top"
|
|
1092
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1093
|
+
face: offer.face,
|
|
1094
|
+
seed: offer.agent,
|
|
1095
|
+
size: 44
|
|
1096
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1097
|
+
className: "tof-row-text"
|
|
1098
|
+
}, /* @__PURE__ */ React.createElement("strong", null, offer.name), /* @__PURE__ */ React.createElement("span", {
|
|
1099
|
+
className: "tof-row-line"
|
|
1100
|
+
}, [offer.gone ? t("goneTag") : offer.agentName !== offer.name ? offer.agentName : undefined, offer.model].filter(Boolean).join(" · ") || t("agentLine")))), /* @__PURE__ */ React.createElement("div", {
|
|
1101
|
+
className: "tof-stats"
|
|
1102
|
+
}, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("b", null, users.length), t("statUsers")), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("b", null, price(income)), t("statIncome")), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("b", null, cost ? `$${cost.toFixed(2)}` : "-"), t("statCost"))), /* @__PURE__ */ React.createElement("div", {
|
|
1103
|
+
className: "tof-actions tof-start"
|
|
1104
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1105
|
+
type: "button",
|
|
1106
|
+
className: "ta-button ta-primary",
|
|
1107
|
+
onClick: () => pi.ui.custom(({ close: done }) => /* @__PURE__ */ React.createElement(LinkSheet, {
|
|
1108
|
+
offer,
|
|
1109
|
+
close: done
|
|
1110
|
+
}))
|
|
1111
|
+
}, /* @__PURE__ */ React.createElement(Share, {
|
|
1112
|
+
size: 15
|
|
1113
|
+
}), " ", t("shareLink")), /* @__PURE__ */ React.createElement("button", {
|
|
1114
|
+
type: "button",
|
|
1115
|
+
className: "ta-button",
|
|
1116
|
+
onClick: () => openOffer(offer.id)
|
|
1117
|
+
}, /* @__PURE__ */ React.createElement(Pencil, {
|
|
1118
|
+
size: 15
|
|
1119
|
+
}), " ", t("edit")), /* @__PURE__ */ React.createElement("button", {
|
|
1120
|
+
type: "button",
|
|
1121
|
+
className: "ta-button",
|
|
1122
|
+
disabled: busy,
|
|
1123
|
+
onClick: () => void run(() => act(() => call("setPaused", offer.id, !offer.paused)))
|
|
1124
|
+
}, offer.paused ? t("resume") : t("pause"))), /* @__PURE__ */ React.createElement("section", {
|
|
1125
|
+
className: "tof-section"
|
|
1126
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("plans")), /* @__PURE__ */ React.createElement("p", {
|
|
1127
|
+
className: "tof-hint tof-pad-x"
|
|
1128
|
+
}, offer.plans.map((plan) => `${plan.name} ${price(plan.price)}${plan.id === offer.trial ? ` (${t("trialTag")})` : ""}`).join(" · "))), /* @__PURE__ */ React.createElement("section", {
|
|
1129
|
+
className: "tof-section"
|
|
1130
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("users")), users.length ? /* @__PURE__ */ React.createElement("ul", {
|
|
1131
|
+
className: "tof-card"
|
|
1132
|
+
}, users.map((user) => /* @__PURE__ */ React.createElement(UserRow, {
|
|
1133
|
+
key: user.id,
|
|
1134
|
+
user,
|
|
1135
|
+
offer
|
|
1136
|
+
}))) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1137
|
+
compact: true,
|
|
1138
|
+
title: t("noUsers"),
|
|
1139
|
+
hint: t("noUsersHint")
|
|
1140
|
+
})), /* @__PURE__ */ React.createElement("p", {
|
|
1141
|
+
className: "tof-hint"
|
|
1142
|
+
}, t("privacyOwner")), /* @__PURE__ */ React.createElement("div", {
|
|
1143
|
+
className: "tof-actions"
|
|
1144
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1145
|
+
type: "button",
|
|
1146
|
+
className: "ta-button tof-danger",
|
|
1147
|
+
disabled: busy,
|
|
1148
|
+
onClick: () => void run(closeOffer)
|
|
1149
|
+
}, t("closeOffer")))));
|
|
1150
|
+
}
|
|
1151
|
+
function openDetail(id) {
|
|
1152
|
+
book.load();
|
|
1153
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(DetailDialog, {
|
|
1154
|
+
id,
|
|
1155
|
+
close
|
|
1156
|
+
}));
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// web-src/offer-quota.ts
|
|
1160
|
+
var DAY_MS = 86400000;
|
|
1161
|
+
var OfferQuota;
|
|
1162
|
+
((OfferQuota) => {
|
|
1163
|
+
function day(now) {
|
|
1164
|
+
const date = new Date(now);
|
|
1165
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
1166
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
1167
|
+
}
|
|
1168
|
+
OfferQuota.day = day;
|
|
1169
|
+
function nextDay(now) {
|
|
1170
|
+
const date = new Date(now);
|
|
1171
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1).getTime();
|
|
1172
|
+
}
|
|
1173
|
+
OfferQuota.nextDay = nextDay;
|
|
1174
|
+
function emptyMeter(now) {
|
|
1175
|
+
return { total: 0, day: day(now), today: 0, cost: 0 };
|
|
1176
|
+
}
|
|
1177
|
+
OfferQuota.emptyMeter = emptyMeter;
|
|
1178
|
+
function tokensOf(usage) {
|
|
1179
|
+
const n = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
1180
|
+
return Math.ceil(n(usage?.input) + n(usage?.output) + n(usage?.cacheWrite) + n(usage?.cacheRead) / 10);
|
|
1181
|
+
}
|
|
1182
|
+
OfferQuota.tokensOf = tokensOf;
|
|
1183
|
+
function add(meter, tokens2, cost, now) {
|
|
1184
|
+
const today = day(now);
|
|
1185
|
+
const same = meter.day === today;
|
|
1186
|
+
return {
|
|
1187
|
+
total: meter.total + tokens2,
|
|
1188
|
+
day: today,
|
|
1189
|
+
today: (same ? meter.today : 0) + tokens2,
|
|
1190
|
+
cost: meter.cost + (Number.isFinite(cost) && cost > 0 ? cost : 0)
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
OfferQuota.add = add;
|
|
1194
|
+
function grant(plan, by, now, before) {
|
|
1195
|
+
const old = before?.grant;
|
|
1196
|
+
const total = before?.used.total ?? 0;
|
|
1197
|
+
const carried = old && !old.days && !plan.days && old.tokens !== undefined && plan.tokens !== undefined && !(old.endsAt !== undefined && old.endsAt <= now) ? Math.max(0, old.tokens - (total - (old.from ?? 0))) : 0;
|
|
1198
|
+
return {
|
|
1199
|
+
plan: plan.id,
|
|
1200
|
+
name: plan.name,
|
|
1201
|
+
price: plan.price,
|
|
1202
|
+
...plan.tokens !== undefined ? { tokens: plan.tokens + carried } : {},
|
|
1203
|
+
...plan.daily !== undefined ? { daily: plan.daily } : {},
|
|
1204
|
+
...plan.days ? { days: plan.days } : {},
|
|
1205
|
+
...total ? { from: total } : {},
|
|
1206
|
+
startsAt: now,
|
|
1207
|
+
...plan.days ? { endsAt: now + plan.days * DAY_MS } : {},
|
|
1208
|
+
by
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
OfferQuota.grant = grant;
|
|
1212
|
+
function state(grant2, meter, now, stopped) {
|
|
1213
|
+
if (!grant2) {
|
|
1214
|
+
return { block: "expired" };
|
|
1215
|
+
}
|
|
1216
|
+
const today = meter.day === day(now) ? meter.today : 0;
|
|
1217
|
+
const left = grant2.tokens !== undefined ? Math.max(0, grant2.tokens - (meter.total - (grant2.from ?? 0))) : undefined;
|
|
1218
|
+
const todayLeft = grant2.daily !== undefined ? Math.max(0, grant2.daily - today) : undefined;
|
|
1219
|
+
const state2 = {
|
|
1220
|
+
block: "none",
|
|
1221
|
+
...left !== undefined ? { left } : {},
|
|
1222
|
+
...todayLeft !== undefined ? { todayLeft, resetsAt: nextDay(now) } : {},
|
|
1223
|
+
...grant2.endsAt !== undefined ? { endsAt: grant2.endsAt } : {}
|
|
1224
|
+
};
|
|
1225
|
+
if (stopped) {
|
|
1226
|
+
return { ...state2, block: stopped };
|
|
1227
|
+
}
|
|
1228
|
+
if (grant2.endsAt !== undefined && grant2.endsAt <= now) {
|
|
1229
|
+
return { ...state2, block: "expired" };
|
|
1230
|
+
}
|
|
1231
|
+
if (left === 0) {
|
|
1232
|
+
return { ...state2, block: "total" };
|
|
1233
|
+
}
|
|
1234
|
+
if (todayLeft === 0) {
|
|
1235
|
+
return { ...state2, block: "daily" };
|
|
1236
|
+
}
|
|
1237
|
+
return state2;
|
|
1238
|
+
}
|
|
1239
|
+
OfferQuota.state = state;
|
|
1240
|
+
function clean(plans, limits) {
|
|
1241
|
+
const whole = (value, min, max) => {
|
|
1242
|
+
const n = Math.floor(Number(value));
|
|
1243
|
+
return Number.isFinite(n) && n >= min ? Math.min(n, max) : undefined;
|
|
1244
|
+
};
|
|
1245
|
+
const seen = new Set;
|
|
1246
|
+
const out = [];
|
|
1247
|
+
for (const one of Array.isArray(plans) ? plans : []) {
|
|
1248
|
+
const given = one;
|
|
1249
|
+
const id = typeof given?.id === "string" && /^[A-Za-z0-9_-]{1,24}$/.test(given.id) ? given.id : undefined;
|
|
1250
|
+
const name = typeof given?.name === "string" ? given.name.trim().slice(0, limits.planName) : "";
|
|
1251
|
+
if (!id || !name || seen.has(id) || out.length >= limits.plans) {
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
seen.add(id);
|
|
1255
|
+
const tokens2 = whole(given.tokens, 1, 1000000000000);
|
|
1256
|
+
const daily = whole(given.daily, 1, 1000000000000);
|
|
1257
|
+
const days = whole(given.days, 1, 3660);
|
|
1258
|
+
out.push({
|
|
1259
|
+
id,
|
|
1260
|
+
name,
|
|
1261
|
+
price: whole(given.price, 0, 1e9) ?? 0,
|
|
1262
|
+
...tokens2 !== undefined ? { tokens: tokens2 } : {},
|
|
1263
|
+
...daily !== undefined ? { daily } : {},
|
|
1264
|
+
...days !== undefined ? { days } : {}
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
return out;
|
|
1268
|
+
}
|
|
1269
|
+
OfferQuota.clean = clean;
|
|
1270
|
+
})(OfferQuota ||= {});
|
|
1271
|
+
|
|
1272
|
+
// web-src/payee-dialog.tsx
|
|
1273
|
+
async function shrink(file) {
|
|
1274
|
+
const url = URL.createObjectURL(file);
|
|
1275
|
+
try {
|
|
1276
|
+
const image = new Image;
|
|
1277
|
+
image.src = url;
|
|
1278
|
+
await image.decode();
|
|
1279
|
+
for (const side of [1200, 900, 700, 500]) {
|
|
1280
|
+
const scale = Math.min(1, side / Math.max(image.naturalWidth, image.naturalHeight));
|
|
1281
|
+
const canvas = document.createElement("canvas");
|
|
1282
|
+
canvas.width = Math.round(image.naturalWidth * scale);
|
|
1283
|
+
canvas.height = Math.round(image.naturalHeight * scale);
|
|
1284
|
+
const context = canvas.getContext("2d");
|
|
1285
|
+
if (!context) {
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
context.fillStyle = "#fff";
|
|
1289
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
1290
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
1291
|
+
const data = canvas.toDataURL("image/jpeg", 0.85);
|
|
1292
|
+
if (data.length <= LIMITS.picture) {
|
|
1293
|
+
return data;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
throw new Error(t("pictureTooBig"));
|
|
1297
|
+
} finally {
|
|
1298
|
+
URL.revokeObjectURL(url);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function PayeeDialog({ close }) {
|
|
1302
|
+
const [payee, setPayee] = React.useState();
|
|
1303
|
+
const [note, setNote] = React.useState("");
|
|
1304
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1305
|
+
const input = React.useRef(null);
|
|
1306
|
+
React.useEffect(() => {
|
|
1307
|
+
pi.storage.get(PAYEE_KEY).then((kept) => {
|
|
1308
|
+
const value = kept ?? {};
|
|
1309
|
+
setPayee(value);
|
|
1310
|
+
setNote(value.note ?? "");
|
|
1311
|
+
});
|
|
1312
|
+
}, []);
|
|
1313
|
+
const pick = async (file) => {
|
|
1314
|
+
if (!file) {
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
const picture = await shrink(file).catch((error) => {
|
|
1318
|
+
pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1319
|
+
return;
|
|
1320
|
+
});
|
|
1321
|
+
if (picture && await act(() => call("setPayee", { picture })) !== undefined) {
|
|
1322
|
+
setPayee({ ...payee, picture });
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
const Upload = pi.ui.icons.ImagePlus ?? pi.ui.icons.Upload;
|
|
1326
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1327
|
+
title: t("payeeTitle"),
|
|
1328
|
+
onClose: close
|
|
1329
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1330
|
+
className: "tof-dialog"
|
|
1331
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
1332
|
+
className: "tof-hint"
|
|
1333
|
+
}, t("payeeLead")), /* @__PURE__ */ React.createElement("div", {
|
|
1334
|
+
className: "tof-qr-box"
|
|
1335
|
+
}, payee?.picture ? /* @__PURE__ */ React.createElement("img", {
|
|
1336
|
+
className: "tof-qr",
|
|
1337
|
+
src: payee.picture,
|
|
1338
|
+
alt: t("payeeRow")
|
|
1339
|
+
}) : /* @__PURE__ */ React.createElement("span", {
|
|
1340
|
+
className: "tof-quiet"
|
|
1341
|
+
}, t("payeeUnset"))), /* @__PURE__ */ React.createElement("input", {
|
|
1342
|
+
ref: input,
|
|
1343
|
+
type: "file",
|
|
1344
|
+
accept: "image/png,image/jpeg,image/webp",
|
|
1345
|
+
hidden: true,
|
|
1346
|
+
onChange: (event) => void run(() => pick(event.target.files?.[0]))
|
|
1347
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1348
|
+
className: "tof-actions tof-center"
|
|
1349
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1350
|
+
type: "button",
|
|
1351
|
+
className: "ta-button",
|
|
1352
|
+
disabled: busy,
|
|
1353
|
+
onClick: () => input.current?.click()
|
|
1354
|
+
}, /* @__PURE__ */ React.createElement(Upload, {
|
|
1355
|
+
size: 15
|
|
1356
|
+
}), " ", payee?.picture ? t("changePicture") : t("pickPicture")), payee?.picture && /* @__PURE__ */ React.createElement("button", {
|
|
1357
|
+
type: "button",
|
|
1358
|
+
className: "ta-button tof-danger",
|
|
1359
|
+
disabled: busy,
|
|
1360
|
+
onClick: () => void run(async () => await act(() => call("setPayee", { picture: null })) !== undefined && setPayee({ ...payee, picture: undefined }))
|
|
1361
|
+
}, t("removePicture"))), /* @__PURE__ */ React.createElement("label", {
|
|
1362
|
+
className: "tof-field"
|
|
1363
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("payeeNote")), /* @__PURE__ */ React.createElement("textarea", {
|
|
1364
|
+
className: "tof-input tof-textarea",
|
|
1365
|
+
value: note,
|
|
1366
|
+
maxLength: LIMITS.note,
|
|
1367
|
+
placeholder: t("payeeNoteHint"),
|
|
1368
|
+
onChange: (event) => setNote(event.target.value)
|
|
1369
|
+
})), /* @__PURE__ */ React.createElement("p", {
|
|
1370
|
+
className: "tof-hint"
|
|
1371
|
+
}, t("payeeTip")), /* @__PURE__ */ React.createElement("div", {
|
|
1372
|
+
className: "tof-actions"
|
|
1373
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1374
|
+
type: "button",
|
|
1375
|
+
className: "ta-button ta-primary",
|
|
1376
|
+
disabled: busy,
|
|
1377
|
+
onClick: () => void run(async () => await act(() => call("setPayee", { note })) !== undefined && close())
|
|
1378
|
+
}, t("done")))));
|
|
1379
|
+
}
|
|
1380
|
+
function openPayee() {
|
|
1381
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(PayeeDialog, {
|
|
1382
|
+
close
|
|
1383
|
+
}));
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
// web-src/owner-page.tsx
|
|
1387
|
+
function Face({ face, seed, size = 36 }) {
|
|
1388
|
+
return pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
|
|
1389
|
+
face,
|
|
1390
|
+
seed,
|
|
1391
|
+
size
|
|
1392
|
+
}) : /* @__PURE__ */ React.createElement("span", {
|
|
1393
|
+
className: "tof-letter"
|
|
1394
|
+
}, seed.slice(0, 1));
|
|
1395
|
+
}
|
|
1396
|
+
function JoinRow({ join, overview }) {
|
|
1397
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1398
|
+
const offer = overview.offers.find((one) => one.id === join.offer);
|
|
1399
|
+
const answer = (accept) => void run(() => act(() => call("answerJoin", join.id, accept)));
|
|
1400
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
1401
|
+
className: `tof-row${busy ? " ta-pending" : ""}`
|
|
1402
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1403
|
+
seed: join.name
|
|
1404
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1405
|
+
className: "tof-row-text"
|
|
1406
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1407
|
+
className: "tof-row-title"
|
|
1408
|
+
}, join.name), /* @__PURE__ */ React.createElement("span", {
|
|
1409
|
+
className: "tof-row-line tof-ellipsis"
|
|
1410
|
+
}, [join.account ?? t("anonymous"), t("joinRow", { name: offer?.name ?? "?" })].join(" · "))), /* @__PURE__ */ React.createElement("div", {
|
|
1411
|
+
className: "tof-answers"
|
|
1412
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1413
|
+
type: "button",
|
|
1414
|
+
className: "ta-button",
|
|
1415
|
+
disabled: busy,
|
|
1416
|
+
onClick: () => answer(false)
|
|
1417
|
+
}, t("refuse")), /* @__PURE__ */ React.createElement("button", {
|
|
1418
|
+
type: "button",
|
|
1419
|
+
className: "ta-button ta-primary",
|
|
1420
|
+
disabled: busy,
|
|
1421
|
+
onClick: () => answer(true)
|
|
1422
|
+
}, t("letIn"))));
|
|
1423
|
+
}
|
|
1424
|
+
function PaymentRow({ payment, overview }) {
|
|
1425
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1426
|
+
const user = overview.users.find((one) => one.id === payment.user);
|
|
1427
|
+
const offer = overview.offers.find((one) => one.id === payment.offer);
|
|
1428
|
+
const plan = offer?.plans.find((one) => one.id === payment.plan);
|
|
1429
|
+
const answer = (accept) => void run(() => act(() => call("answerPayment", payment.id, accept)));
|
|
1430
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
1431
|
+
className: `tof-row tof-row-wrap${busy ? " ta-pending" : ""}`
|
|
1432
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1433
|
+
seed: user?.name ?? "?"
|
|
1434
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1435
|
+
className: "tof-row-text"
|
|
1436
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1437
|
+
className: "tof-row-title"
|
|
1438
|
+
}, user?.name ?? "?", /* @__PURE__ */ React.createElement("span", {
|
|
1439
|
+
className: "tof-quiet"
|
|
1440
|
+
}, t("paidRow", { price: price(payment.amount), plan: plan?.name ?? "?" }))), /* @__PURE__ */ React.createElement("span", {
|
|
1441
|
+
className: "tof-row-line"
|
|
1442
|
+
}, t("codeRow", { code: payment.code, date: dateOf(payment.at) }))), /* @__PURE__ */ React.createElement("div", {
|
|
1443
|
+
className: "tof-answers"
|
|
1444
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1445
|
+
type: "button",
|
|
1446
|
+
className: "ta-button",
|
|
1447
|
+
disabled: busy,
|
|
1448
|
+
onClick: () => answer(false)
|
|
1449
|
+
}, t("notReceived")), /* @__PURE__ */ React.createElement("button", {
|
|
1450
|
+
type: "button",
|
|
1451
|
+
className: "ta-button ta-primary",
|
|
1452
|
+
disabled: busy,
|
|
1453
|
+
onClick: () => answer(true)
|
|
1454
|
+
}, t("confirmPaid"))));
|
|
1455
|
+
}
|
|
1456
|
+
function OfferRow({ offer, overview }) {
|
|
1457
|
+
const users = overview.users.filter((user) => user.offer === offer.id);
|
|
1458
|
+
const day = OfferQuota.day(Date.now());
|
|
1459
|
+
const today = users.reduce((sum, user) => sum + (user.used.day === day ? user.used.today : 0), 0);
|
|
1460
|
+
const line = [t("usersCount", { n: users.length }), users.length ? t("usedToday", { n: tokens(today) }) : undefined].filter(Boolean).join(" · ");
|
|
1461
|
+
const Right = icon("ChevronRight");
|
|
1462
|
+
return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
1463
|
+
type: "button",
|
|
1464
|
+
className: "tof-row tof-button-row",
|
|
1465
|
+
onClick: () => openDetail(offer.id)
|
|
1466
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1467
|
+
face: offer.face,
|
|
1468
|
+
seed: offer.agent
|
|
1469
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1470
|
+
className: "tof-row-text"
|
|
1471
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1472
|
+
className: "tof-row-title"
|
|
1473
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1474
|
+
className: "tof-ellipsis"
|
|
1475
|
+
}, offer.name), offer.paused && /* @__PURE__ */ React.createElement("span", {
|
|
1476
|
+
className: "tof-tag"
|
|
1477
|
+
}, t("pausedTag")), offer.gone && /* @__PURE__ */ React.createElement("span", {
|
|
1478
|
+
className: "tof-tag tof-tag-bad"
|
|
1479
|
+
}, t("goneTag"))), /* @__PURE__ */ React.createElement("span", {
|
|
1480
|
+
className: "tof-row-line tof-ellipsis"
|
|
1481
|
+
}, line)), /* @__PURE__ */ React.createElement("span", {
|
|
1482
|
+
className: "tof-quiet"
|
|
1483
|
+
}, /* @__PURE__ */ React.createElement(Right, {
|
|
1484
|
+
size: 16
|
|
1485
|
+
}))));
|
|
1486
|
+
}
|
|
1487
|
+
function OwnerPage({ overview }) {
|
|
1488
|
+
const waiting = overview.payments.filter((one) => one.status === "waiting");
|
|
1489
|
+
const Plus = icon("Plus");
|
|
1490
|
+
const Qr = icon("QrCode");
|
|
1491
|
+
const Empty = pi.ui.Empty;
|
|
1492
|
+
if (!overview.offers.length) {
|
|
1493
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1494
|
+
className: "tof-list tof-fill"
|
|
1495
|
+
}, /* @__PURE__ */ React.createElement(Empty, {
|
|
1496
|
+
title: t("emptyTitle"),
|
|
1497
|
+
hint: t("emptyHint")
|
|
1498
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1499
|
+
type: "button",
|
|
1500
|
+
className: "ta-button ta-primary",
|
|
1501
|
+
onClick: () => openOffer()
|
|
1502
|
+
}, t("openOne"))));
|
|
1503
|
+
}
|
|
1504
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1505
|
+
className: "tof-list"
|
|
1506
|
+
}, (overview.joins.length > 0 || waiting.length > 0) && /* @__PURE__ */ React.createElement("section", {
|
|
1507
|
+
className: "tof-section"
|
|
1508
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("waiting")), /* @__PURE__ */ React.createElement("ul", {
|
|
1509
|
+
className: "tof-card"
|
|
1510
|
+
}, overview.joins.map((join) => /* @__PURE__ */ React.createElement(JoinRow, {
|
|
1511
|
+
key: join.id,
|
|
1512
|
+
join,
|
|
1513
|
+
overview
|
|
1514
|
+
})), waiting.map((payment) => /* @__PURE__ */ React.createElement(PaymentRow, {
|
|
1515
|
+
key: payment.id,
|
|
1516
|
+
payment,
|
|
1517
|
+
overview
|
|
1518
|
+
})))), /* @__PURE__ */ React.createElement("section", {
|
|
1519
|
+
className: "tof-section"
|
|
1520
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("opened")), /* @__PURE__ */ React.createElement("ul", {
|
|
1521
|
+
className: "tof-card"
|
|
1522
|
+
}, overview.offers.map((offer) => /* @__PURE__ */ React.createElement(OfferRow, {
|
|
1523
|
+
key: offer.id,
|
|
1524
|
+
offer,
|
|
1525
|
+
overview
|
|
1526
|
+
})), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
1527
|
+
type: "button",
|
|
1528
|
+
className: "tof-row tof-button-row tof-add",
|
|
1529
|
+
onClick: () => openOffer()
|
|
1530
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1531
|
+
className: "tof-icon-cell"
|
|
1532
|
+
}, /* @__PURE__ */ React.createElement(Plus, {
|
|
1533
|
+
size: 18
|
|
1534
|
+
})), t("openOne"))))), /* @__PURE__ */ React.createElement("section", {
|
|
1535
|
+
className: "tof-section"
|
|
1536
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("payTitle")), /* @__PURE__ */ React.createElement("ul", {
|
|
1537
|
+
className: "tof-card"
|
|
1538
|
+
}, /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
1539
|
+
type: "button",
|
|
1540
|
+
className: "tof-row tof-button-row",
|
|
1541
|
+
onClick: () => openPayee()
|
|
1542
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1543
|
+
className: "tof-icon-cell"
|
|
1544
|
+
}, /* @__PURE__ */ React.createElement(Qr, {
|
|
1545
|
+
size: 18
|
|
1546
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
1547
|
+
className: "tof-row-text"
|
|
1548
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1549
|
+
className: "tof-row-title"
|
|
1550
|
+
}, t("payeeRow")), /* @__PURE__ */ React.createElement("span", {
|
|
1551
|
+
className: "tof-row-line"
|
|
1552
|
+
}, overview.payee.picture ? t("payeeSet") : t("payeeUnset")))))), /* @__PURE__ */ React.createElement("p", {
|
|
1553
|
+
className: "tof-hint tof-pad-x"
|
|
1554
|
+
}, t("payHint"))));
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// web-src/style.ts
|
|
1558
|
+
var STYLE = `
|
|
1559
|
+
.tof-page { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; }
|
|
1560
|
+
.tof-list { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: var(--ta-page-width); margin: 0 auto; padding: 8px 12px calc(24px + env(safe-area-inset-bottom)); box-sizing: border-box; }
|
|
1561
|
+
.tof-fill { flex: 1; justify-content: center; }
|
|
1562
|
+
.tof-pad-x { padding: 0 10px; }
|
|
1563
|
+
.tof-section { display: flex; flex-direction: column; gap: 4px; }
|
|
1564
|
+
.tof-section h3 { display: flex; align-items: center; height: 30px; margin: 0; padding: 0 10px; font-size: calc(12px * var(--ta-font-scale)); font-weight: 500; color: var(--ta-muted); }
|
|
1565
|
+
.tof-card { margin: 0; padding: 2px 6px; list-style: none; border-radius: 14px; background: var(--ta-raised); }
|
|
1566
|
+
.tof-card > li + li { border-top: 1px solid var(--ta-border-muted); }
|
|
1567
|
+
.tof-row { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 6px; box-sizing: border-box; }
|
|
1568
|
+
.tof-row-wrap { flex-wrap: wrap; }
|
|
1569
|
+
.tof-row-wrap .tof-answers { width: 100%; justify-content: flex-end; }
|
|
1570
|
+
.tof-row-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
|
|
1571
|
+
.tof-row-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: calc(14px * var(--ta-font-scale)); font-weight: 500; }
|
|
1572
|
+
.tof-row-line { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
1573
|
+
.tof-button-row { width: 100%; border: 0; background: none; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
|
|
1574
|
+
@media (hover: hover) { .tof-button-row:hover { background: var(--ta-hover); } }
|
|
1575
|
+
.tof-add { color: var(--ta-link); }
|
|
1576
|
+
.tof-icon-cell { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--ta-hover); color: var(--ta-secondary); }
|
|
1577
|
+
.tof-answers { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
1578
|
+
.tof-tag { flex: none; padding: 0 6px; border-radius: 6px; background: var(--ta-chip, var(--ta-hover)); color: var(--ta-secondary); font-size: calc(10.5px * var(--ta-font-scale)); font-weight: 400; line-height: calc(17px * var(--ta-font-scale)); }
|
|
1579
|
+
.tof-tag-good { background: color-mix(in srgb, var(--ta-green) 14%, transparent); color: var(--ta-green); }
|
|
1580
|
+
.tof-tag-bad { background: color-mix(in srgb, var(--ta-red) 12%, transparent); color: var(--ta-red); }
|
|
1581
|
+
.tof-quiet { color: var(--ta-muted); }
|
|
1582
|
+
.tof-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1583
|
+
.tof-letter { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ta-hover); font-weight: 600; }
|
|
1584
|
+
.tof-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; border: 0; border-radius: 8px; background: none; color: var(--ta-muted); cursor: pointer; }
|
|
1585
|
+
.tof-icon:hover { background: var(--ta-hover); }
|
|
1586
|
+
.tof-danger { color: var(--ta-red) !important; }
|
|
1587
|
+
.tof-link { align-self: flex-start; padding: 4px 2px; border: 0; background: none; color: var(--ta-link); font: inherit; font-size: calc(13px * var(--ta-font-scale)); cursor: pointer; }
|
|
1588
|
+
.tof-hint { margin: 0; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); line-height: 1.5; }
|
|
1589
|
+
.tof-warn { margin: 0; color: var(--ta-orange, var(--ta-red)); font-size: calc(12.5px * var(--ta-font-scale)); line-height: 1.5; }
|
|
1590
|
+
.tof-lead { margin: 0; line-height: 1.55; text-align: center; }
|
|
1591
|
+
.tof-error { margin: 0; padding: 16px; color: var(--ta-red); }
|
|
1592
|
+
.tof-center-text { text-align: center; }
|
|
1593
|
+
.tof-dialog { display: flex; flex-direction: column; gap: 12px; min-width: min(420px, 84vw); max-height: 78vh; overflow-y: auto; }
|
|
1594
|
+
.tof-field { display: flex; flex-direction: column; gap: 6px; font-size: calc(13px * var(--ta-font-scale)); }
|
|
1595
|
+
.tof-field > span:first-child { color: var(--ta-secondary); }
|
|
1596
|
+
.tof-input { box-sizing: border-box; width: 100%; padding: 7px 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-main); color: var(--ta-text); font: inherit; font-size: calc(14px * var(--ta-font-scale)); }
|
|
1597
|
+
.tof-textarea { min-height: 56px; resize: vertical; }
|
|
1598
|
+
.tof-switch-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; font-size: calc(13.5px * var(--ta-font-scale)); }
|
|
1599
|
+
.tof-switch-row small { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
1600
|
+
.tof-plans { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
|
|
1601
|
+
.tof-plan { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--ta-border-muted); border-radius: 12px; }
|
|
1602
|
+
.tof-plan-head { display: flex; align-items: center; gap: 6px; }
|
|
1603
|
+
.tof-plan-name { font-weight: 500; }
|
|
1604
|
+
.tof-plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
|
1605
|
+
.tof-plan-field { display: flex; flex-direction: column; gap: 4px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
1606
|
+
.tof-plan-input { display: flex; align-items: center; gap: 6px; }
|
|
1607
|
+
.tof-plan-input small { flex: none; color: var(--ta-muted); }
|
|
1608
|
+
.tof-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
|
|
1609
|
+
.tof-actions .ta-button { display: inline-flex; align-items: center; gap: 6px; }
|
|
1610
|
+
.tof-start { justify-content: flex-start; }
|
|
1611
|
+
.tof-center { justify-content: center; }
|
|
1612
|
+
.tof-top { display: flex; align-items: center; gap: 12px; }
|
|
1613
|
+
.tof-top strong { font-size: calc(16px * var(--ta-font-scale)); font-weight: 600; }
|
|
1614
|
+
.tof-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
|
|
1615
|
+
.tof-stats > span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--ta-raised); color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
1616
|
+
.tof-stats b { color: var(--ta-text); font-size: calc(17px * var(--ta-font-scale)); font-weight: 600; }
|
|
1617
|
+
.tof-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 16px 18px; border-radius: 16px; background: var(--ta-raised); text-align: center; }
|
|
1618
|
+
.tof-hero strong { font-size: calc(18px * var(--ta-font-scale)); font-weight: 600; }
|
|
1619
|
+
.tof-intro { margin: 2px 0; max-width: 46ch; line-height: 1.55; }
|
|
1620
|
+
.tof-state { padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ta-green) 12%, transparent); color: var(--ta-green); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1621
|
+
.tof-state-bad { background: color-mix(in srgb, var(--ta-orange, var(--ta-red)) 12%, transparent); color: var(--ta-orange, var(--ta-red)); }
|
|
1622
|
+
.tof-wide { min-width: 200px; margin-top: 4px; }
|
|
1623
|
+
.tof-pay-amount { font-size: calc(30px * var(--ta-font-scale)); font-weight: 600; text-align: center; }
|
|
1624
|
+
.tof-code { align-self: center; padding: 6px 18px; border: 1px dashed var(--ta-border); border-radius: 10px; font: 600 24px/1.2 var(--ta-mono, ui-monospace, monospace); letter-spacing: 0.18em; user-select: all; }
|
|
1625
|
+
.tof-qr-box { display: flex; align-items: center; justify-content: center; min-height: 160px; padding: 12px; border-radius: 14px; background: var(--ta-raised); }
|
|
1626
|
+
.tof-qr { display: block; max-width: min(240px, 70vw); max-height: 320px; border-radius: 8px; }
|
|
1627
|
+
`;
|
|
1628
|
+
function injectStyle() {
|
|
1629
|
+
const element = document.createElement("style");
|
|
1630
|
+
element.dataset.taPackage = "ta-offer";
|
|
1631
|
+
element.textContent = STYLE;
|
|
1632
|
+
document.head.appendChild(element);
|
|
1633
|
+
return () => element.remove();
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// web-src/user-page.tsx
|
|
1637
|
+
function inMiniProgram() {
|
|
1638
|
+
const wx = window.__wxjs_environment;
|
|
1639
|
+
return wx === "miniprogram" || /miniProgram/i.test(navigator.userAgent);
|
|
1640
|
+
}
|
|
1641
|
+
function planLine(plan) {
|
|
1642
|
+
return [
|
|
1643
|
+
plan.tokens !== undefined ? t("planAll", { n: tokens(plan.tokens) }) : undefined,
|
|
1644
|
+
plan.daily !== undefined ? t("planDay", { n: tokens(plan.daily) }) : undefined,
|
|
1645
|
+
plan.days ? t("planFor", { n: plan.days }) : undefined
|
|
1646
|
+
].filter(Boolean).join(" · ") || t("unlimited");
|
|
1647
|
+
}
|
|
1648
|
+
function PayDialog({ mine, plan, close }) {
|
|
1649
|
+
const [claim, setClaim] = React.useState();
|
|
1650
|
+
const [payee, setPayee] = React.useState();
|
|
1651
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1652
|
+
const mini = inMiniProgram();
|
|
1653
|
+
React.useEffect(() => {
|
|
1654
|
+
if (!mini) {
|
|
1655
|
+
call("payee", mine.offer.id).then(setPayee, () => setPayee({}));
|
|
1656
|
+
}
|
|
1657
|
+
}, [mine.offer.id, mini]);
|
|
1658
|
+
const start = async () => setClaim(await act(() => call("pay", mine.offer.id, plan.id)));
|
|
1659
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1660
|
+
title: t("payFor", { plan: plan.name }),
|
|
1661
|
+
onClose: close
|
|
1662
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1663
|
+
className: "tof-dialog"
|
|
1664
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1665
|
+
className: "tof-pay-amount"
|
|
1666
|
+
}, price(plan.price)), /* @__PURE__ */ React.createElement("p", {
|
|
1667
|
+
className: "tof-hint tof-center-text"
|
|
1668
|
+
}, planLine(plan)), mini ? /* @__PURE__ */ React.createElement("p", {
|
|
1669
|
+
className: "tof-lead"
|
|
1670
|
+
}, t("payMini", { owner: mine.offer.owner })) : !claim ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
|
|
1671
|
+
className: "tof-lead"
|
|
1672
|
+
}, t("payLead", { owner: mine.offer.owner })), /* @__PURE__ */ React.createElement("div", {
|
|
1673
|
+
className: "tof-actions tof-center"
|
|
1674
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1675
|
+
type: "button",
|
|
1676
|
+
className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
|
|
1677
|
+
disabled: busy,
|
|
1678
|
+
onClick: () => void run(start)
|
|
1679
|
+
}, t("payNext")))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
|
|
1680
|
+
className: "tof-lead"
|
|
1681
|
+
}, t("payNote", { code: claim.code, owner: mine.offer.owner })), /* @__PURE__ */ React.createElement("div", {
|
|
1682
|
+
className: "tof-code"
|
|
1683
|
+
}, claim.code), /* @__PURE__ */ React.createElement("div", {
|
|
1684
|
+
className: "tof-qr-box"
|
|
1685
|
+
}, payee?.picture ? /* @__PURE__ */ React.createElement("img", {
|
|
1686
|
+
className: "tof-qr",
|
|
1687
|
+
src: payee.picture,
|
|
1688
|
+
alt: t("payeeRow")
|
|
1689
|
+
}) : /* @__PURE__ */ React.createElement("span", {
|
|
1690
|
+
className: "tof-quiet"
|
|
1691
|
+
}, t("payNoCode"))), (payee?.note || mine.payeeNote) && /* @__PURE__ */ React.createElement("p", {
|
|
1692
|
+
className: "tof-hint tof-center-text"
|
|
1693
|
+
}, payee?.note ?? mine.payeeNote), /* @__PURE__ */ React.createElement("p", {
|
|
1694
|
+
className: "tof-hint tof-center-text"
|
|
1695
|
+
}, t("payAfter")), /* @__PURE__ */ React.createElement("div", {
|
|
1696
|
+
className: "tof-actions tof-center"
|
|
1697
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1698
|
+
type: "button",
|
|
1699
|
+
className: "ta-button ta-primary",
|
|
1700
|
+
onClick: close
|
|
1701
|
+
}, t("payDone"))))));
|
|
1702
|
+
}
|
|
1703
|
+
function MineCard({ mine }) {
|
|
1704
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1705
|
+
const { offer, user, state, waiting } = mine;
|
|
1706
|
+
const open = state.block === "none";
|
|
1707
|
+
const startChat = async () => {
|
|
1708
|
+
const started = await act(() => call("start", offer.id));
|
|
1709
|
+
if (started) {
|
|
1710
|
+
await pi.switchSession(started.sessionId);
|
|
1711
|
+
}
|
|
1712
|
+
};
|
|
1713
|
+
const paid = offer.plans.filter((plan) => plan.price > 0);
|
|
1714
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1715
|
+
className: "tof-list"
|
|
1716
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1717
|
+
className: "tof-hero"
|
|
1718
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1719
|
+
face: offer.face,
|
|
1720
|
+
seed: offer.id,
|
|
1721
|
+
size: 56
|
|
1722
|
+
}), /* @__PURE__ */ React.createElement("strong", null, offer.name), /* @__PURE__ */ React.createElement("span", {
|
|
1723
|
+
className: "tof-quiet"
|
|
1724
|
+
}, t("byOwner", { owner: offer.owner })), offer.intro && /* @__PURE__ */ React.createElement("p", {
|
|
1725
|
+
className: "tof-intro"
|
|
1726
|
+
}, offer.intro), /* @__PURE__ */ React.createElement("span", {
|
|
1727
|
+
className: `tof-state${open ? "" : " tof-state-bad"}`
|
|
1728
|
+
}, user.grant ? `${user.grant.name} · ` : "", leftLine(state)), /* @__PURE__ */ React.createElement("button", {
|
|
1729
|
+
type: "button",
|
|
1730
|
+
className: `ta-button ta-primary tof-wide${busy ? " ta-busy" : ""}`,
|
|
1731
|
+
disabled: busy || !open,
|
|
1732
|
+
onClick: () => void run(startChat)
|
|
1733
|
+
}, t("startChat")), user.sessions.length > 0 && /* @__PURE__ */ React.createElement("span", {
|
|
1734
|
+
className: "tof-hint"
|
|
1735
|
+
}, t("chatsHere", { n: user.sessions.length }))), waiting && /* @__PURE__ */ React.createElement("section", {
|
|
1736
|
+
className: "tof-section"
|
|
1737
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("waitingPay")), /* @__PURE__ */ React.createElement("ul", {
|
|
1738
|
+
className: "tof-card"
|
|
1739
|
+
}, /* @__PURE__ */ React.createElement("li", {
|
|
1740
|
+
className: "tof-row"
|
|
1741
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1742
|
+
className: "tof-row-text"
|
|
1743
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1744
|
+
className: "tof-row-title"
|
|
1745
|
+
}, offer.plans.find((plan) => plan.id === waiting.plan)?.name ?? "?", " · ", price(waiting.amount)), /* @__PURE__ */ React.createElement("span", {
|
|
1746
|
+
className: "tof-row-line"
|
|
1747
|
+
}, t("waitingLine", { code: waiting.code, date: dateOf(waiting.at) }))), /* @__PURE__ */ React.createElement("button", {
|
|
1748
|
+
type: "button",
|
|
1749
|
+
className: "ta-button",
|
|
1750
|
+
disabled: busy,
|
|
1751
|
+
onClick: () => void run(() => act(() => call("cancelPay", offer.id, waiting.id)))
|
|
1752
|
+
}, t("cancel"))))), paid.length > 0 && /* @__PURE__ */ React.createElement("section", {
|
|
1753
|
+
className: "tof-section"
|
|
1754
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("plansToBuy")), /* @__PURE__ */ React.createElement("ul", {
|
|
1755
|
+
className: "tof-card"
|
|
1756
|
+
}, paid.map((plan) => /* @__PURE__ */ React.createElement("li", {
|
|
1757
|
+
key: plan.id,
|
|
1758
|
+
className: "tof-row"
|
|
1759
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1760
|
+
className: "tof-row-text"
|
|
1761
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1762
|
+
className: "tof-row-title"
|
|
1763
|
+
}, plan.name, user.grant?.plan === plan.id && /* @__PURE__ */ React.createElement("span", {
|
|
1764
|
+
className: "tof-tag tof-tag-good"
|
|
1765
|
+
}, t("currentTag"))), /* @__PURE__ */ React.createElement("span", {
|
|
1766
|
+
className: "tof-row-line"
|
|
1767
|
+
}, planLine(plan))), /* @__PURE__ */ React.createElement("button", {
|
|
1768
|
+
type: "button",
|
|
1769
|
+
className: "ta-button",
|
|
1770
|
+
disabled: !!waiting,
|
|
1771
|
+
onClick: () => pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(PayDialog, {
|
|
1772
|
+
mine,
|
|
1773
|
+
plan,
|
|
1774
|
+
close
|
|
1775
|
+
}))
|
|
1776
|
+
}, price(plan.price))))), /* @__PURE__ */ React.createElement("p", {
|
|
1777
|
+
className: "tof-hint tof-pad-x"
|
|
1778
|
+
}, mine.payable ? t("buyHint") : t("buyHintOffline", { owner: offer.owner }))), /* @__PURE__ */ React.createElement("p", {
|
|
1779
|
+
className: "tof-hint tof-pad-x"
|
|
1780
|
+
}, t("privacyUser", { owner: offer.owner })));
|
|
1781
|
+
}
|
|
1782
|
+
function UserPage({ mine }) {
|
|
1783
|
+
if (!mine.length) {
|
|
1784
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1785
|
+
className: "tof-list tof-fill"
|
|
1786
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1787
|
+
title: t("emptyUser")
|
|
1788
|
+
}));
|
|
1789
|
+
}
|
|
1790
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, mine.map((one) => /* @__PURE__ */ React.createElement(MineCard, {
|
|
1791
|
+
key: one.offer.id,
|
|
1792
|
+
mine: one
|
|
1793
|
+
})));
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
// web-src/index.tsx
|
|
1797
|
+
function OffersPage() {
|
|
1798
|
+
const { overview, mine, loaded, error } = useBook();
|
|
1799
|
+
React.useEffect(() => {
|
|
1800
|
+
book.load();
|
|
1801
|
+
const timer = setInterval(() => void book.load(), 1e4);
|
|
1802
|
+
return () => clearInterval(timer);
|
|
1803
|
+
}, []);
|
|
1804
|
+
if (!loaded) {
|
|
1805
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1806
|
+
className: "tof-page"
|
|
1807
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Loading, null));
|
|
1808
|
+
}
|
|
1809
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1810
|
+
className: "tof-page"
|
|
1811
|
+
}, overview ? /* @__PURE__ */ React.createElement(OwnerPage, {
|
|
1812
|
+
overview
|
|
1813
|
+
}) : mine ? /* @__PURE__ */ React.createElement(UserPage, {
|
|
1814
|
+
mine
|
|
1815
|
+
}) : /* @__PURE__ */ React.createElement("p", {
|
|
1816
|
+
className: "tof-error"
|
|
1817
|
+
}, error));
|
|
1818
|
+
}
|
|
1819
|
+
function activate(api) {
|
|
1820
|
+
bind(api.React);
|
|
1821
|
+
bindPage(api);
|
|
1822
|
+
const removeStyle = injectStyle();
|
|
1823
|
+
pi.registerView("offers", {
|
|
1824
|
+
title: () => book.get().mine && !book.get().overview ? t("mineTitle") : t("title"),
|
|
1825
|
+
icon: icon("Store"),
|
|
1826
|
+
render: OffersPage,
|
|
1827
|
+
group: "share",
|
|
1828
|
+
order: 84
|
|
1829
|
+
});
|
|
1830
|
+
const stopWatch = book.watch();
|
|
1831
|
+
book.load().then(() => {
|
|
1832
|
+
const { overview, mine } = book.get();
|
|
1833
|
+
if (!overview && mine?.length) {
|
|
1834
|
+
pi.ui.showView("@celljs/ta-offer/offers");
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
return () => {
|
|
1838
|
+
removeStyle();
|
|
1839
|
+
stopWatch();
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
export {
|
|
1843
|
+
activate as default
|
|
1844
|
+
};
|