@sevenfold/setto-client 0.44.0 → 0.46.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/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SettoLanguages } from './LanguageSwitcher.js';
|
|
2
2
|
export { DEFAULT_LANGUAGE, languageName, pickInitialLanguage, siteLanguages, } from './lib/languages.js';
|
|
3
3
|
export { alternateLinks, languageFromPath, pathForLanguage, redirectForVisitor, type LanguageRoute, } from './lib/language-routing.js';
|
|
4
|
-
export { SettoProvider, useSetto } from './provider.js';
|
|
4
|
+
export { SettoProvider, useSetto, useVisitorView } from './provider.js';
|
|
5
5
|
export { GuestEditProvider, useGuestEdit } from './guest-edit.js';
|
|
6
6
|
export { SettoChrome, useSettoChromeSlot } from './chrome.js';
|
|
7
7
|
export type { SettoChromeHandshake } from './chrome.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the page is being looked at by a visitor only, so a site may rewrite
|
|
3
|
+
* its own text in the DOM: GSAP's SplitText, a typewriter, anything that moves
|
|
4
|
+
* or replaces the nodes React put there.
|
|
5
|
+
*
|
|
6
|
+
* Text inside `<T>` belongs to React. Rewritten under it, React later removes
|
|
7
|
+
* a node that is no longer where it left it, and the whole page goes blank:
|
|
8
|
+
* that is what turning on editing did to a site whose headline SplitText had
|
|
9
|
+
* split and reverted (2026-10-26). An owner can switch editing on at any
|
|
10
|
+
* moment, so for them the answer is no for the whole visit.
|
|
11
|
+
*
|
|
12
|
+
* `null` while it is not known yet: the session is being read, or the site's
|
|
13
|
+
* membership fetched. A site waits for `true` before it rewrites anything,
|
|
14
|
+
* which for a visitor is a moment after the first paint.
|
|
15
|
+
*/
|
|
16
|
+
export declare function visitorView(state: {
|
|
17
|
+
authLoading: boolean;
|
|
18
|
+
hasSession: boolean;
|
|
19
|
+
/** Null while the signed-in person's sites are being fetched. */
|
|
20
|
+
sitesLoaded: boolean;
|
|
21
|
+
canEdit: boolean;
|
|
22
|
+
guestEdit: boolean;
|
|
23
|
+
}): boolean | null;
|
|
@@ -97,6 +97,13 @@ export declare function insertMention(value: string, name: string, at: {
|
|
|
97
97
|
value: string;
|
|
98
98
|
caret: number;
|
|
99
99
|
};
|
|
100
|
+
/** The visitor's conversations: those still going first, then those that have ended. */
|
|
101
|
+
export declare function chatGroups<T extends {
|
|
102
|
+
status: 'bot' | 'human' | 'closed';
|
|
103
|
+
}>(chats: readonly T[]): Array<{
|
|
104
|
+
ended: boolean;
|
|
105
|
+
chats: T[];
|
|
106
|
+
}>;
|
|
100
107
|
/**
|
|
101
108
|
* «Translated from English · Show original» under a translated message, in
|
|
102
109
|
* the visitor's language. The toggle is a real button; the line is left out
|
package/dist/provider.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface SettoContextValue {
|
|
|
61
61
|
* Exported for one caller: the chrome bundle.
|
|
62
62
|
*
|
|
63
63
|
* The dashboard is compiled into that bundle, so its `useSetto` reads *this*
|
|
64
|
-
* module's context
|
|
64
|
+
* module's context — a different instance from the one the host provider
|
|
65
65
|
* fills, which would otherwise throw "must be used within SettoProvider" the
|
|
66
66
|
* moment it rendered. Handing it the host's value through this provider is
|
|
67
67
|
* what lets the same components run on either side of the boundary.
|
|
@@ -80,8 +80,7 @@ export interface SettoProviderProps {
|
|
|
80
80
|
* The owner may edit (`canEdit`) when ALL of:
|
|
81
81
|
* 1. There is an authenticated Supabase session.
|
|
82
82
|
* 2. The user has access to `config.siteId` in the Setto sites table.
|
|
83
|
-
* 3. The
|
|
84
|
-
* 4. The current path is not the `/setto` admin SPA.
|
|
83
|
+
* 3. The current path is not the `/setto` admin SPA.
|
|
85
84
|
*
|
|
86
85
|
* Once an editor signs in via `/setto` they stay signed in until they sign out
|
|
87
86
|
* there. Whether they are editing is their own switch (`setEditing`): the
|
|
@@ -89,3 +88,9 @@ export interface SettoProviderProps {
|
|
|
89
88
|
*/
|
|
90
89
|
export declare function SettoProvider({ config, children }: SettoProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
91
90
|
export declare function useSetto(): SettoContextValue;
|
|
91
|
+
/**
|
|
92
|
+
* True once it is known that nobody on this page can edit it, false for an
|
|
93
|
+
* owner, null until it is known. Wait for `true` before rewriting text in the
|
|
94
|
+
* DOM (SplitText and the like): see `lib/visitor-view.ts`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function useVisitorView(): boolean | null;
|
package/dist/setto-client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { useState, useRef, useEffect, useMemo, useId, useInsertionEffect, useLayoutEffect, Children, createContext, useContext, useCallback, useSyncExternalStore, forwardRef
|
|
3
|
+
import { useState, useRef, useEffect, useMemo, useId, Fragment as Fragment$1, useInsertionEffect, useLayoutEffect, Children, createContext, useContext, useCallback, useSyncExternalStore, forwardRef } from "react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import * as ReactDOM from "react-dom";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
@@ -22014,9 +22014,11 @@ function useSiteAccess(supabase, session, siteId) {
|
|
|
22014
22014
|
}, [supabase, session, siteId]);
|
|
22015
22015
|
return state;
|
|
22016
22016
|
}
|
|
22017
|
-
function
|
|
22018
|
-
|
|
22019
|
-
|
|
22017
|
+
function visitorView(state) {
|
|
22018
|
+
if (state.authLoading) return null;
|
|
22019
|
+
if (!state.hasSession) return !state.guestEdit;
|
|
22020
|
+
if (!state.sitesLoaded) return null;
|
|
22021
|
+
return !state.canEdit && !state.guestEdit;
|
|
22020
22022
|
}
|
|
22021
22023
|
const CHROME_CONTRACT = 1;
|
|
22022
22024
|
function chromeUrl(apiUrl) {
|
|
@@ -35575,6 +35577,12 @@ function CloseIcon({ size = 22 }) {
|
|
|
35575
35577
|
}
|
|
35576
35578
|
) });
|
|
35577
35579
|
}
|
|
35580
|
+
function chatGroups(chats) {
|
|
35581
|
+
return [false, true].map((ended) => ({ ended, chats: chats.filter((chat) => chat.status === "closed" === ended) })).filter((group) => group.chats.length > 0);
|
|
35582
|
+
}
|
|
35583
|
+
function CheckIcon$1() {
|
|
35584
|
+
return /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M5 12.5l4.5 4.5L19 7.5" }) });
|
|
35585
|
+
}
|
|
35578
35586
|
function PlusIcon() {
|
|
35579
35587
|
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "18", height: "18", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
|
|
35580
35588
|
"path",
|
|
@@ -36265,6 +36273,8 @@ function SettoChat() {
|
|
|
36265
36273
|
const [queued, setQueued] = useState(false);
|
|
36266
36274
|
const [loadingConversation, setLoadingConversation] = useState(false);
|
|
36267
36275
|
const [humanJoined, setHumanJoined] = useState(false);
|
|
36276
|
+
const [ended, setEnded] = useState(false);
|
|
36277
|
+
const [ending, setEnding] = useState(false);
|
|
36268
36278
|
const [originals, setOriginals] = useState(() => /* @__PURE__ */ new Set());
|
|
36269
36279
|
const [availability, setAvailability] = useState({
|
|
36270
36280
|
humanAvailable: false,
|
|
@@ -36364,7 +36374,10 @@ function SettoChat() {
|
|
|
36364
36374
|
failed: "Jeg får ikke svart akkurat nå. Kontakt gjerne teamet direkte.",
|
|
36365
36375
|
image: "Bilde",
|
|
36366
36376
|
seen: "Sett",
|
|
36367
|
-
emptyChats: "Nye samtaler du starter her vises i denne listen."
|
|
36377
|
+
emptyChats: "Nye samtaler du starter her vises i denne listen.",
|
|
36378
|
+
endChat: "Avslutt samtalen",
|
|
36379
|
+
endedChats: "Avsluttet",
|
|
36380
|
+
startNew: "Start en ny samtale"
|
|
36368
36381
|
} : {
|
|
36369
36382
|
open: siteName ? `Open chat with ${siteName}` : "Open chat",
|
|
36370
36383
|
close: "Close chat",
|
|
@@ -36389,7 +36402,10 @@ function SettoChat() {
|
|
|
36389
36402
|
failed: "I cannot reply right now. Please contact the team directly.",
|
|
36390
36403
|
image: "Image",
|
|
36391
36404
|
seen: "Seen",
|
|
36392
|
-
emptyChats: "New conversations you start here will appear in this list."
|
|
36405
|
+
emptyChats: "New conversations you start here will appear in this list.",
|
|
36406
|
+
endChat: "End this conversation",
|
|
36407
|
+
endedChats: "Ended",
|
|
36408
|
+
startNew: "Start a new conversation"
|
|
36393
36409
|
};
|
|
36394
36410
|
function ensureVisitor() {
|
|
36395
36411
|
return visitor.current ??= visitorId();
|
|
@@ -36445,6 +36461,7 @@ function SettoChat() {
|
|
|
36445
36461
|
rememberConversation(next.conversationId);
|
|
36446
36462
|
loadedConversationRef.current = next.conversationId;
|
|
36447
36463
|
setHumanJoined(next.humanJoined);
|
|
36464
|
+
setEnded(next.status === "closed");
|
|
36448
36465
|
setMessages(next.messages);
|
|
36449
36466
|
const supported = "realtimeTopic" in next || "teamReadAt" in next || "visitorReadAt" in next;
|
|
36450
36467
|
const serverTeamReadAt = typeof next.teamReadAt === "string" ? next.teamReadAt : null;
|
|
@@ -36527,6 +36544,31 @@ function SettoChat() {
|
|
|
36527
36544
|
useEffect(() => {
|
|
36528
36545
|
refreshRef.current = refreshConversation;
|
|
36529
36546
|
});
|
|
36547
|
+
async function endConversation() {
|
|
36548
|
+
const id = conversationId.current;
|
|
36549
|
+
const visitorIdValue = visitor.current;
|
|
36550
|
+
if (!id || !visitorIdValue || ending) return;
|
|
36551
|
+
setEnding(true);
|
|
36552
|
+
try {
|
|
36553
|
+
const response = await fetch(
|
|
36554
|
+
`${apiUrl}/sites/${encodeURIComponent(config.siteId)}/chat/conversations/${encodeURIComponent(id)}/public/close`,
|
|
36555
|
+
{
|
|
36556
|
+
method: "POST",
|
|
36557
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
36558
|
+
body: JSON.stringify({ visitorId: visitorIdValue })
|
|
36559
|
+
}
|
|
36560
|
+
);
|
|
36561
|
+
if (!response.ok) return;
|
|
36562
|
+
typingSender().stop();
|
|
36563
|
+
setEnded(true);
|
|
36564
|
+
setDrawer(false);
|
|
36565
|
+
void refreshConversation();
|
|
36566
|
+
void loadChats();
|
|
36567
|
+
} catch {
|
|
36568
|
+
} finally {
|
|
36569
|
+
setEnding(false);
|
|
36570
|
+
}
|
|
36571
|
+
}
|
|
36530
36572
|
async function loadConversation(id) {
|
|
36531
36573
|
const visitorIdValue = ensureVisitor();
|
|
36532
36574
|
setLoadingConversation(true);
|
|
@@ -36719,6 +36761,7 @@ function SettoChat() {
|
|
|
36719
36761
|
setRealtime(null);
|
|
36720
36762
|
setTeamTypingUntil(null);
|
|
36721
36763
|
setHumanJoined(false);
|
|
36764
|
+
setEnded(false);
|
|
36722
36765
|
setMessages(welcomeMessages());
|
|
36723
36766
|
setDraft("");
|
|
36724
36767
|
setTapped(/* @__PURE__ */ new Set());
|
|
@@ -36902,22 +36945,40 @@ function SettoChat() {
|
|
|
36902
36945
|
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
36903
36946
|
labels.newChat
|
|
36904
36947
|
] }),
|
|
36905
|
-
|
|
36948
|
+
conversationId.current && !ended ? /* @__PURE__ */ jsxs(
|
|
36906
36949
|
"button",
|
|
36907
36950
|
{
|
|
36908
|
-
className:
|
|
36951
|
+
className: "setto-chat__new setto-chat__end",
|
|
36909
36952
|
type: "button",
|
|
36910
|
-
onClick: () => void
|
|
36953
|
+
onClick: () => void endConversation(),
|
|
36954
|
+
disabled: ending || sending,
|
|
36911
36955
|
children: [
|
|
36912
|
-
/* @__PURE__ */ jsx(
|
|
36913
|
-
|
|
36914
|
-
isNo ? "nb-NO" : "en-GB",
|
|
36915
|
-
{ day: "numeric", month: "short" }
|
|
36916
|
-
) })
|
|
36956
|
+
/* @__PURE__ */ jsx(CheckIcon$1, {}),
|
|
36957
|
+
labels.endChat
|
|
36917
36958
|
]
|
|
36918
|
-
}
|
|
36919
|
-
|
|
36920
|
-
|
|
36959
|
+
}
|
|
36960
|
+
) : null,
|
|
36961
|
+
/* @__PURE__ */ jsx("div", { className: "setto-chat__chat-list", children: conversations.length ? chatGroups(conversations).map(({ ended: closedGroup, chats: group }) => {
|
|
36962
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
36963
|
+
closedGroup ? /* @__PURE__ */ jsx("span", { className: "setto-chat__chat-group", children: labels.endedChats }) : null,
|
|
36964
|
+
group.map((chat) => /* @__PURE__ */ jsxs(
|
|
36965
|
+
"button",
|
|
36966
|
+
{
|
|
36967
|
+
className: `setto-chat__chat-row${conversationId.current === chat.id ? " is-active" : ""}${closedGroup ? " is-ended" : ""}`,
|
|
36968
|
+
type: "button",
|
|
36969
|
+
onClick: () => void loadConversation(chat.id),
|
|
36970
|
+
children: [
|
|
36971
|
+
/* @__PURE__ */ jsx("span", { children: chat.preview }),
|
|
36972
|
+
/* @__PURE__ */ jsx("time", { children: new Date(chat.lastActivityAt).toLocaleDateString(
|
|
36973
|
+
isNo ? "nb-NO" : "en-GB",
|
|
36974
|
+
{ day: "numeric", month: "short" }
|
|
36975
|
+
) })
|
|
36976
|
+
]
|
|
36977
|
+
},
|
|
36978
|
+
chat.id
|
|
36979
|
+
))
|
|
36980
|
+
] }, closedGroup ? "ended" : "open");
|
|
36981
|
+
}) : /* @__PURE__ */ jsx("p", { children: labels.emptyChats }) })
|
|
36921
36982
|
]
|
|
36922
36983
|
}
|
|
36923
36984
|
),
|
|
@@ -37027,7 +37088,11 @@ function SettoChat() {
|
|
|
37027
37088
|
}
|
|
37028
37089
|
),
|
|
37029
37090
|
/* @__PURE__ */ jsxs("div", { className: "setto-chat__composer-shell", ref: composerShellRef, children: [
|
|
37030
|
-
|
|
37091
|
+
ended ? /* @__PURE__ */ jsx("div", { className: "setto-chat__ended", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: startNew, children: [
|
|
37092
|
+
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
37093
|
+
labels.startNew
|
|
37094
|
+
] }) }) : null,
|
|
37095
|
+
!ended && nearby.length ? /* @__PURE__ */ jsxs("div", { className: "setto-chat__team", children: [
|
|
37031
37096
|
teamRowLabelled(nearby) ? /* @__PURE__ */ jsx("span", { className: "setto-chat__team-label", children: labels.teamRow }) : null,
|
|
37032
37097
|
nearby.map((human) => /* @__PURE__ */ jsxs(
|
|
37033
37098
|
"button",
|
|
@@ -37049,7 +37114,7 @@ function SettoChat() {
|
|
|
37049
37114
|
human.handle
|
|
37050
37115
|
))
|
|
37051
37116
|
] }) : null,
|
|
37052
|
-
/* @__PURE__ */ jsx(
|
|
37117
|
+
ended ? null : /* @__PURE__ */ jsx(
|
|
37053
37118
|
SiteChatComposer,
|
|
37054
37119
|
{
|
|
37055
37120
|
value: draft,
|
|
@@ -37141,7 +37206,7 @@ function useChatStyles() {
|
|
|
37141
37206
|
style.textContent = `
|
|
37142
37207
|
.setto-chat__markdown{display:block;min-width:0;white-space:normal}.setto-chat__markdown> :first-child{margin-top:0}.setto-chat__markdown> :last-child{margin-bottom:0}.setto-chat__markdown p{margin:0 0 .72em}.setto-chat__markdown h1,.setto-chat__markdown h2,.setto-chat__markdown h3{margin:.95em 0 .36em;font-size:1em;font-weight:680;line-height:1.28;letter-spacing:-.012em}.setto-chat__markdown h1{font-size:1.08em}.setto-chat__markdown ul,.setto-chat__markdown ol{margin:.12em 0 .72em;padding-left:1.25em}.setto-chat__markdown ul{list-style:disc}.setto-chat__markdown ol{list-style:decimal}.setto-chat__markdown li{margin:.2em 0;padding-left:.08em}.setto-chat__markdown li::marker{color:color-mix(in srgb,var(--setto-chat-accent) 78%,var(--setto-chat-ink))}.setto-chat__markdown strong{font-weight:700}.setto-chat__markdown a{color:inherit;text-decoration:underline;text-decoration-color:color-mix(in srgb,var(--setto-chat-accent) 70%,transparent);text-decoration-thickness:1px;text-underline-offset:.16em}.setto-chat__markdown blockquote{margin:.2em 0 .72em;padding:.08em 0 .08em .7em;border-left:2px solid color-mix(in srgb,var(--setto-chat-accent) 58%,transparent);color:color-mix(in srgb,var(--setto-chat-ink) 76%,transparent)}.setto-chat__markdown hr{height:1px;margin:.85em 0;border:0;background:color-mix(in srgb,var(--setto-chat-ink) 13%,transparent)}.setto-chat__markdown code{padding:.08em .28em;border-radius:.32em;background:color-mix(in srgb,var(--setto-chat-ink) 8%,transparent);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.88em}.setto-chat__markdown pre{max-width:100%;margin:.3em 0 .78em;padding:.7em;overflow-x:auto;overscroll-behavior:contain;border-radius:.7em;background:color-mix(in srgb,var(--setto-chat-ink) 8%,transparent);white-space:pre;-webkit-overflow-scrolling:touch}.setto-chat__markdown pre code{padding:0;background:transparent}.setto-chat__table-wrap{max-width:100%;margin:.25em 0 .75em;overflow-x:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.setto-chat__markdown table{width:100%;border-collapse:collapse;font-size:.88em}.setto-chat__markdown th,.setto-chat__markdown td{padding:.38em .5em;border-bottom:1px solid color-mix(in srgb,var(--setto-chat-ink) 13%,transparent);text-align:left;vertical-align:top}.setto-chat__markdown th{font-weight:680}.setto-chat__markdown-image-label{font-style:italic;color:color-mix(in srgb,var(--setto-chat-ink) 62%,transparent)}.setto-chat__word{display:inline-block}.setto-chat__markdown.is-revealing .setto-chat__word{opacity:0;transform:translateY(.08em);filter:blur(.35px);animation:setto-chat-word-in 180ms cubic-bezier(.2,.8,.2,1) forwards;will-change:opacity,transform,filter}@keyframes setto-chat-word-in{to{opacity:1;transform:none;filter:none}}
|
|
37143
37208
|
.setto-chat{--setto-chat-edge:.75rem;position:fixed;right:max(18px,env(safe-area-inset-right));bottom:max(18px,env(safe-area-inset-bottom));z-index:2147483000;overscroll-behavior:contain;color:var(--setto-chat-ink);font-family:"Archivo Variable",Archivo,system-ui,sans-serif;-webkit-font-smoothing:antialiased}.setto-chat *,.setto-chat *::before,.setto-chat *::after{box-sizing:border-box}.setto-chat button,.setto-chat input,.setto-chat textarea{font:inherit}.setto-chat--mounted{top:0;right:auto;bottom:auto;left:0;width:100vw;height:var(--setto-chat-layout-height,100lvh);overflow:hidden;background:var(--setto-chat-canvas);opacity:0;transition:opacity ${CLOSE_MS}ms ease}.setto-chat--visible{opacity:1}.setto-chat__shell{position:absolute;top:var(--setto-chat-top,0);left:0;width:100%;height:var(--setto-chat-height,100svh);display:flex;overflow:hidden;overscroll-behavior:contain;background:var(--setto-chat-canvas);opacity:0;transform:translateY(12px) scale(.994);transform-origin:center bottom;transition:opacity ${CLOSE_MS}ms ease,transform ${CLOSE_MS}ms cubic-bezier(.16,1,.3,1)}.setto-chat--visible .setto-chat__shell{opacity:1;transform:none}
|
|
37144
|
-
.setto-chat__scrim{position:absolute;inset:0;z-index:45;border:0;background:rgba(33,23,17,.32);opacity:0;pointer-events:none;transition:opacity 220ms ease}.setto-chat__scrim.is-open{opacity:1;pointer-events:auto}.setto-chat__chats{position:relative;z-index:50;width:min(84vw,280px);height:100%;flex:0 0 280px;padding:1rem .85rem calc(1rem + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:.9rem;background:color-mix(in srgb,var(--setto-chat-crema) 32%,var(--setto-chat-canvas));border-right:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);overflow:hidden}.setto-chat__chats-heading{display:flex;align-items:center;justify-content:space-between;gap:.5rem;min-height:34px;font-size:.66rem;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent)}.setto-chat__chats-heading button{width:34px;height:34px;padding:0;border:0;border-radius:8px;background:transparent;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}.setto-chat__new{display:flex;align-items:center;gap:.55rem;width:100%;padding:.5rem .55rem;border:0;border-radius:8px;background:transparent;color:var(--setto-chat-ink);font-weight:600;font-size:.9rem;text-align:left;cursor:pointer;transition:background 140ms ease}.setto-chat__new:hover{background:color-mix(in srgb,var(--setto-chat-ink) 5%,transparent)}.setto-chat__chat-list{display:flex;flex-direction:column;gap:.1rem;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;margin-right:-.85rem;padding-right:.3rem}.setto-chat__chat-list p{margin:.35rem .55rem;font-size:.85rem;line-height:1.5;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent)}.setto-chat__chat-row{width:100%;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.4rem;padding:.55rem;border:0;border-radius:8px;background:transparent;color:var(--setto-chat-ink);text-align:left;cursor:pointer}.setto-chat__chat-row:hover,.setto-chat__chat-row.is-active{background:color-mix(in srgb,var(--setto-chat-ink) 7.5%,transparent)}.setto-chat__chat-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.9rem;font-weight:600}.setto-chat__chat-row time{font-size:.72rem;color:color-mix(in srgb,var(--setto-chat-ink) 55%,transparent)}
|
|
37209
|
+
.setto-chat__scrim{position:absolute;inset:0;z-index:45;border:0;background:rgba(33,23,17,.32);opacity:0;pointer-events:none;transition:opacity 220ms ease}.setto-chat__scrim.is-open{opacity:1;pointer-events:auto}.setto-chat__chats{position:relative;z-index:50;width:min(84vw,280px);height:100%;flex:0 0 280px;padding:1rem .85rem calc(1rem + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:.9rem;background:color-mix(in srgb,var(--setto-chat-crema) 32%,var(--setto-chat-canvas));border-right:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);overflow:hidden}.setto-chat__chats-heading{display:flex;align-items:center;justify-content:space-between;gap:.5rem;min-height:34px;font-size:.66rem;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent)}.setto-chat__chats-heading button{width:34px;height:34px;padding:0;border:0;border-radius:8px;background:transparent;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}.setto-chat__new{display:flex;align-items:center;gap:.55rem;width:100%;padding:.5rem .55rem;border:0;border-radius:8px;background:transparent;color:var(--setto-chat-ink);font-weight:600;font-size:.9rem;text-align:left;cursor:pointer;transition:background 140ms ease}.setto-chat__new:hover{background:color-mix(in srgb,var(--setto-chat-ink) 5%,transparent)}.setto-chat__chat-list{display:flex;flex-direction:column;gap:.1rem;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;margin-right:-.85rem;padding-right:.3rem}.setto-chat__chat-list p{margin:.35rem .55rem;font-size:.85rem;line-height:1.5;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent)}.setto-chat__chat-row{width:100%;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.4rem;padding:.55rem;border:0;border-radius:8px;background:transparent;color:var(--setto-chat-ink);text-align:left;cursor:pointer}.setto-chat__chat-row:hover,.setto-chat__chat-row.is-active{background:color-mix(in srgb,var(--setto-chat-ink) 7.5%,transparent)}.setto-chat__chat-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.9rem;font-weight:600}.setto-chat__chat-row time{font-size:.72rem;color:color-mix(in srgb,var(--setto-chat-ink) 55%,transparent)}.setto-chat__chat-row.is-ended span{font-weight:500;color:color-mix(in srgb,var(--setto-chat-ink) 72%,transparent)}.setto-chat__chat-group{display:block;margin:.75rem .55rem .2rem;font-size:.66rem;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent)}.setto-chat__end{margin-top:-.6rem;font-weight:500;color:color-mix(in srgb,var(--setto-chat-ink) 72%,transparent)}.setto-chat__end:disabled{opacity:.5;cursor:default}.setto-chat__ended{position:relative;z-index:1;display:flex;justify-content:center;padding:.25rem 0 .35rem}.setto-chat__ended button{display:inline-flex;align-items:center;gap:.5rem;min-height:44px;padding:0 1.15rem;border:0;border-radius:999px;background:var(--setto-chat-accent);color:var(--setto-chat-on-accent);font:inherit;font-size:.95rem;font-weight:600;cursor:pointer;box-shadow:0 8px 24px -16px color-mix(in srgb,var(--setto-chat-ink) 45%,transparent);transition:transform 200ms ease}.setto-chat__ended button:hover{transform:translateY(-1px)}
|
|
37145
37210
|
.setto-chat__main{position:relative;z-index:1;display:flex;flex:1;min-width:0;max-width:820px;height:100%;margin:0 auto;flex-direction:column;background:var(--setto-chat-canvas)}.setto-chat__header{position:absolute;inset:0 0 auto;z-index:30;min-height:calc(46px + 2 * var(--setto-chat-edge));padding:var(--setto-chat-edge);display:flex;align-items:center;gap:.5rem;background:linear-gradient(to bottom,color-mix(in srgb,var(--setto-chat-crema) 88%,transparent),color-mix(in srgb,var(--setto-chat-crema) 72%,transparent));border-bottom:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);backdrop-filter:blur(20px) saturate(150%);-webkit-backdrop-filter:blur(20px) saturate(150%);isolation:isolate}.setto-chat__round-button{flex:none;width:46px;height:46px;padding:0;border:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);border-radius:50%;background:var(--setto-chat-raised);color:var(--setto-chat-ink);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background 160ms ease,border-color 160ms ease,color 160ms ease}.setto-chat__round-button:hover{background:var(--setto-chat-crema);border-color:var(--setto-chat-accent);color:var(--setto-chat-accent)}.setto-chat__round-button:active{transform:scale(.96)}.setto-chat__brand{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;line-height:1.15;text-align:center}.setto-chat__brand h2{margin:0;color:var(--setto-chat-ink);font-size:1.02rem;font-weight:600;line-height:1.15}.setto-chat__brand p{max-width:100%;margin:2px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:color-mix(in srgb,var(--setto-chat-ink) 56%,transparent);font-size:.78rem;line-height:1.15}
|
|
37146
37211
|
.setto-chat__body{position:relative;display:flex;flex:1 1 auto;min-height:0;height:100%;flex-direction:column}.setto-chat__log{display:flex;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;flex-direction:column;padding:calc(46px + 2 * var(--setto-chat-edge) + 1.3rem) .75rem var(--setto-chat-composer-space,8rem);scroll-padding-bottom:var(--setto-chat-composer-space,8rem);scroll-behavior:auto;-webkit-overflow-scrolling:touch}.setto-chat__message-list{display:flex;flex-direction:column}.setto-chat__message{--setto-chat-bubble:color-mix(in srgb,var(--setto-chat-ink) 7%,var(--setto-chat-canvas));display:flex;align-items:flex-end;gap:.55rem;width:100%;margin-bottom:1rem;color:color-mix(in srgb,var(--setto-chat-ink) 92%,transparent);font-size:16px;line-height:1.5;overflow-wrap:anywhere}.setto-chat__message-stack{display:flex;min-width:0;max-width:min(78%,36rem);flex-direction:column;align-items:flex-start}.setto-chat__message-bubble{position:relative;min-width:2.5rem;padding:.58rem .82rem;border-radius:19px 19px 19px 5px;background:var(--setto-chat-bubble);white-space:pre-wrap}.setto-chat__message--assistant .setto-chat__message-bubble::before,.setto-chat__message--human .setto-chat__message-bubble::before{content:"";position:absolute;z-index:0;left:-7px;bottom:0;width:16px;height:17px;border-bottom-right-radius:14px;background:var(--setto-chat-bubble)}.setto-chat__message--assistant .setto-chat__message-bubble::after,.setto-chat__message--human .setto-chat__message-bubble::after{content:"";position:absolute;z-index:1;left:-10px;bottom:0;width:10px;height:18px;border-bottom-right-radius:10px;background:var(--setto-chat-canvas)}.setto-chat__message-copy,.setto-chat__image{position:relative;z-index:2}.setto-chat__message--visitor{--setto-chat-bubble:var(--setto-chat-accent);justify-content:flex-end;color:var(--setto-chat-on-accent)}.setto-chat__message--visitor .setto-chat__message-stack{align-items:flex-end}.setto-chat__message--visitor .setto-chat__message-bubble{border-radius:19px 19px 5px 19px}.setto-chat__message--visitor .setto-chat__message-bubble::before{content:"";position:absolute;z-index:0;right:-7px;bottom:0;width:16px;height:17px;border-bottom-left-radius:14px;background:var(--setto-chat-bubble)}.setto-chat__message--visitor .setto-chat__message-bubble::after{content:"";position:absolute;z-index:1;right:-10px;bottom:0;width:10px;height:18px;border-bottom-left-radius:10px;background:var(--setto-chat-canvas)}.setto-chat__message--system{justify-content:center;color:color-mix(in srgb,var(--setto-chat-ink) 55%,transparent);font-size:.78rem;line-height:1.45;text-align:center}.setto-chat__message--system .setto-chat__message-stack{max-width:85%;align-items:center}.setto-chat__message--system .setto-chat__message-bubble{padding:.25rem .6rem;background:transparent}.setto-chat__avatar{position:relative;z-index:3;display:grid;place-items:center;flex:0 0 34px;width:34px;height:34px;margin-bottom:1px;overflow:hidden;border:2px solid var(--setto-chat-canvas);border-radius:50%;background:var(--setto-chat-crema);color:var(--setto-chat-ink);box-shadow:0 2px 8px color-mix(in srgb,var(--setto-chat-ink) 14%,transparent)}.setto-chat__avatar--assistant{background:var(--setto-chat-accent);color:var(--setto-chat-on-accent)}.setto-chat__avatar img{display:block;width:100%;height:100%;object-fit:cover}.setto-chat__speaker{display:block;margin:0 0 .2rem .4rem;color:color-mix(in srgb,var(--setto-chat-ink) 52%,transparent);font-size:.69rem;font-weight:500;line-height:1.2}.setto-chat__typing{display:inline-block;min-width:1.8rem;animation:setto-chat-pulse 1s ease-in-out infinite}.setto-chat__image{display:block;width:max-content;max-width:100%;margin-top:.65rem;overflow:hidden;border-radius:13px}.setto-chat__image img{display:block;width:min(280px,100%);max-height:260px;object-fit:cover}
|
|
37147
37212
|
.setto-chat__message--agent-joined{justify-content:flex-start;align-items:center;gap:.55rem;padding:.1rem 0;color:color-mix(in srgb,var(--setto-chat-ink) 62%,transparent);font-size:.8rem;line-height:1.4;text-align:left}.setto-chat__message--agent-joined .setto-chat__message-stack{max-width:calc(100% - 38px);align-items:flex-start}.setto-chat__message--agent-joined .setto-chat__message-bubble{min-width:0;padding:.2rem 0;background:transparent;white-space:normal}.setto-chat__avatar--joined{margin:0}button.setto-chat__avatar{padding:0;font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:transform 140ms ease}button.setto-chat__avatar:active{transform:scale(.94)}button.setto-chat__avatar:focus-visible{outline:2px solid var(--setto-chat-accent);outline-offset:2px}
|
|
@@ -37245,7 +37310,7 @@ function SettoProvider({ config, children }) {
|
|
|
37245
37310
|
pageStoreRef.current = new PageStore(bundledManifest(config.pages));
|
|
37246
37311
|
setStoreReady(true);
|
|
37247
37312
|
}, [i18n, config.theme, config.pages]);
|
|
37248
|
-
const canEdit = !!session &&
|
|
37313
|
+
const canEdit = !!session && !!access.currentSite && !onAdminRoute && !authLoading && !access.loading;
|
|
37249
37314
|
const [editing, setEditingState] = useState(() => readEditing(config.siteId));
|
|
37250
37315
|
const setEditing = useCallback(
|
|
37251
37316
|
(on) => {
|
|
@@ -37316,6 +37381,10 @@ function useSetto() {
|
|
|
37316
37381
|
}
|
|
37317
37382
|
return ctx;
|
|
37318
37383
|
}
|
|
37384
|
+
function useVisitorView() {
|
|
37385
|
+
const { authLoading, session, sites, canEdit, guestEdit } = useSetto();
|
|
37386
|
+
return visitorView({ authLoading, hasSession: !!session, sitesLoaded: sites !== null, canEdit, guestEdit });
|
|
37387
|
+
}
|
|
37319
37388
|
const INLINE_MARKER = "data-setto-languages-inline";
|
|
37320
37389
|
function SettoLanguages({ languages: given, inline = false }) {
|
|
37321
37390
|
const { i18n } = useTranslation();
|
|
@@ -41416,6 +41485,7 @@ export {
|
|
|
41416
41485
|
useSetto,
|
|
41417
41486
|
useSettoChromeSlot,
|
|
41418
41487
|
useSettoMenu,
|
|
41488
|
+
useVisitorView,
|
|
41419
41489
|
validateBlockTree,
|
|
41420
41490
|
visibleMenu,
|
|
41421
41491
|
wantsCheckout,
|