shinychat 0.0.1a0__py3-none-any.whl

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.
shinychat/_utils.py ADDED
@@ -0,0 +1,173 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ import contextlib
5
+ import functools
6
+ import inspect
7
+ import random
8
+ import secrets
9
+ from typing import (
10
+ Any,
11
+ AsyncIterable,
12
+ Awaitable,
13
+ Callable,
14
+ Generator,
15
+ Iterable,
16
+ TypeVar,
17
+ cast,
18
+ )
19
+
20
+ from ._typing_extensions import ParamSpec, TypeGuard
21
+
22
+ CancelledError = asyncio.CancelledError
23
+
24
+
25
+ # ==============================================================================
26
+ # Misc utility functions
27
+ # ==============================================================================
28
+ def rand_hex(bytes: int) -> str:
29
+ """
30
+ Creates a random hexadecimal string of size `bytes`. The length in
31
+ characters will be bytes*2.
32
+ """
33
+ format_str = "{{:0{}x}}".format(bytes * 2)
34
+ return format_str.format(secrets.randbits(bytes * 8))
35
+
36
+
37
+ def drop_none(x: dict[str, Any]) -> dict[str, object]:
38
+ return {k: v for k, v in x.items() if v is not None}
39
+
40
+
41
+ # Intended for use with json.load()'s object_hook parameter.
42
+ # Note also that object_hook is only called on dicts, not on lists, so this
43
+ # won't work for converting "top-level" lists to tuples
44
+ def lists_to_tuples(x: object) -> object:
45
+ if isinstance(x, dict):
46
+ x = cast("dict[str, object]", x)
47
+ return {k: lists_to_tuples(v) for k, v in x.items()}
48
+ elif isinstance(x, list):
49
+ x = cast("list[object]", x)
50
+ return tuple(lists_to_tuples(y) for y in x)
51
+ else:
52
+ # TODO: are there other mutable iterators that we want to make read only?
53
+ return x
54
+
55
+
56
+ # ==============================================================================
57
+ # Private random stream
58
+ # ==============================================================================
59
+ def private_random_id(prefix: str = "", bytes: int = 3) -> str:
60
+ if prefix != "" and not prefix.endswith("_"):
61
+ prefix += "_"
62
+
63
+ with private_seed():
64
+ return prefix + rand_hex(bytes)
65
+
66
+
67
+ @contextlib.contextmanager
68
+ def private_seed() -> Generator[None, None, None]:
69
+ state = random.getstate()
70
+ global own_random_state # noqa: PLW0603
71
+ try:
72
+ random.setstate(own_random_state)
73
+ yield
74
+ finally:
75
+ own_random_state = random.getstate()
76
+ random.setstate(state)
77
+
78
+
79
+ # Initialize random state for shiny's own private stream of randomness.
80
+ current_random_state = random.getstate()
81
+ random.seed(secrets.randbits(128))
82
+ own_random_state = random.getstate()
83
+ random.setstate(current_random_state)
84
+
85
+ # ==============================================================================
86
+ # Async-related functions
87
+ # ==============================================================================
88
+
89
+ R = TypeVar("R") # Return type
90
+ P = ParamSpec("P")
91
+
92
+
93
+ def wrap_async(
94
+ fn: Callable[P, R] | Callable[P, Awaitable[R]],
95
+ ) -> Callable[P, Awaitable[R]]:
96
+ """
97
+ Given a synchronous function that returns R, return an async function that wraps the
98
+ original function. If the input function is already async, then return it unchanged.
99
+ """
100
+
101
+ if is_async_callable(fn):
102
+ return fn
103
+
104
+ fn = cast(Callable[P, R], fn)
105
+
106
+ @functools.wraps(fn)
107
+ async def fn_async(*args: P.args, **kwargs: P.kwargs) -> R:
108
+ return fn(*args, **kwargs)
109
+
110
+ return fn_async
111
+
112
+
113
+ # This function should generally be used in this code base instead of
114
+ # `iscoroutinefunction()`.
115
+ def is_async_callable(
116
+ obj: Callable[P, R] | Callable[P, Awaitable[R]],
117
+ ) -> TypeGuard[Callable[P, Awaitable[R]]]:
118
+ """
119
+ Determine if an object is an async function.
120
+
121
+ This is a more general version of `inspect.iscoroutinefunction()`, which only works
122
+ on functions. This function works on any object that has a `__call__` method, such
123
+ as a class instance.
124
+
125
+ Returns
126
+ -------
127
+ :
128
+ Returns True if `obj` is an `async def` function, or if it's an object with a
129
+ `__call__` method which is an `async def` function.
130
+ """
131
+ if inspect.iscoroutinefunction(obj):
132
+ return True
133
+ if hasattr(obj, "__call__"): # noqa: B004
134
+ if inspect.iscoroutinefunction(obj.__call__): # type: ignore
135
+ return True
136
+
137
+ return False
138
+
139
+
140
+ def wrap_async_iterable(
141
+ x: Iterable[Any] | AsyncIterable[Any],
142
+ ) -> AsyncIterable[Any]:
143
+ """
144
+ Given any iterable, return an async iterable. The async iterable will yield the
145
+ values of the original iterable, but will also yield control to the event loop
146
+ after each value. This is useful when you want to interleave processing with other
147
+ tasks, or when you want to simulate an async iterable from a regular iterable.
148
+ """
149
+
150
+ if isinstance(x, AsyncIterable):
151
+ return x
152
+
153
+ if not isinstance(x, Iterable):
154
+ raise TypeError("wrap_async_iterable requires an Iterable object.")
155
+
156
+ return MakeIterableAsync(x)
157
+
158
+
159
+ class MakeIterableAsync:
160
+ def __init__(self, iterable: Iterable[Any]):
161
+ self.iterable = iterable
162
+
163
+ def __aiter__(self):
164
+ self.iterator = iter(self.iterable)
165
+ return self
166
+
167
+ async def __anext__(self):
168
+ try:
169
+ value = next(self.iterator)
170
+ await asyncio.sleep(0) # Yield control to the event loop
171
+ return value
172
+ except StopIteration:
173
+ raise StopAsyncIteration
@@ -0,0 +1,3 @@
1
+ from .._chat import ChatExpress as Chat
2
+
3
+ __all__ = ["Chat"]
@@ -0,0 +1,3 @@
1
+ from ._chat import Chat as ChatController
2
+
3
+ __all__ = ["ChatController"]
@@ -0,0 +1,154 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from playwright.sync_api import Locator, Page
6
+ from playwright.sync_api import expect as playwright_expect
7
+ from shiny.playwright._types import PatternOrStr, Timeout
8
+ from shiny.playwright.controller._base import UiBase
9
+
10
+
11
+ class Chat(UiBase):
12
+ """Controller for :func:`shiny.ui.chat`."""
13
+
14
+ loc: Locator
15
+ """
16
+ Playwright `Locator` for the chat.
17
+ """
18
+ loc_messages: Locator
19
+ """
20
+ Playwright `Locator` for the chat messages.
21
+ """
22
+ loc_latest_message: Locator
23
+ """
24
+ Playwright `Locator` for the last message in the chat.
25
+ """
26
+ loc_input_container: Locator
27
+ """
28
+ Playwright `Locator` for the chat input container.
29
+ """
30
+ loc_input: Locator
31
+ """
32
+ Playwright `Locator` for the chat's <textarea> input.
33
+ """
34
+ loc_input_button: Locator
35
+ """
36
+ Playwright `Locator` for the chat's <button> input.
37
+ """
38
+
39
+ def __init__(self, page: Page, id: str) -> None:
40
+ """
41
+ Initializes a new instance of the `Chat` class.
42
+
43
+ Parameters
44
+ ----------
45
+ page
46
+ Playwright `Page` of the Shiny app.
47
+ id
48
+ The ID of the chat.
49
+ """
50
+ super().__init__(
51
+ page,
52
+ id=id,
53
+ loc=f"#{id}",
54
+ )
55
+ self.loc_messages = self.loc.locator("> shiny-chat-messages")
56
+ self.loc_latest_message = self.loc_messages.locator("> :last-child")
57
+ self.loc_input_container = self.loc.locator("> shiny-chat-input")
58
+ self.loc_input = self.loc_input_container.locator("textarea")
59
+ self.loc_input_button = self.loc_input_container.locator("button")
60
+
61
+ def expect_latest_message(
62
+ self,
63
+ value: PatternOrStr,
64
+ *,
65
+ timeout: Timeout = None,
66
+ ) -> None:
67
+ """
68
+ Expects the last message in the chat.
69
+
70
+ Parameters
71
+ ----------
72
+ value
73
+ The expected last message.
74
+ timeout
75
+ The maximum time to wait for the expectation to pass. Defaults to `None`.
76
+ """
77
+ # playwright_expect(self.loc_latest_message).to_have_text(value, timeout=timeout)
78
+ playwright_expect(self.loc_latest_message).to_have_text(
79
+ value, use_inner_text=True, timeout=timeout
80
+ )
81
+
82
+ def expect_messages(
83
+ self,
84
+ value: PatternOrStr,
85
+ *,
86
+ timeout: Timeout = None,
87
+ ) -> None:
88
+ """
89
+ Expects the chat messages.
90
+
91
+ Parameters
92
+ ----------
93
+ value
94
+ The expected messages.
95
+ timeout
96
+ The maximum time to wait for the expectation to pass. Defaults to `None`.
97
+ """
98
+ playwright_expect(self.loc_messages).to_have_text(
99
+ value, use_inner_text=True, timeout=timeout
100
+ )
101
+
102
+ def set_user_input(
103
+ self,
104
+ value: str,
105
+ *,
106
+ timeout: Timeout = None,
107
+ ) -> None:
108
+ """
109
+ Sets the user message in the chat.
110
+
111
+ Parameters
112
+ ----------
113
+ value
114
+ The message to send.
115
+ timeout
116
+ The maximum time to wait for the chat input to be visible and interactable. Defaults to `None`.
117
+ """
118
+ self.loc_input.type(value, timeout=timeout)
119
+
120
+ def send_user_input(
121
+ self,
122
+ *,
123
+ method: Literal["enter", "click"] = "enter",
124
+ timeout: Timeout = None,
125
+ ) -> None:
126
+ """
127
+ Sends the user message in the chat.
128
+
129
+ Parameters
130
+ ----------
131
+ method
132
+ The method to send the user message. Defaults to `"enter"`.
133
+ timeout
134
+ The maximum time to wait for the chat input to be visible and interactable. Defaults to `None`.
135
+ """
136
+ if method == "enter":
137
+ self.loc_input.press("Enter", timeout=timeout)
138
+ else:
139
+ self.loc_input_button.click(timeout=timeout)
140
+
141
+ def expect_user_input(
142
+ self, value: PatternOrStr, *, timeout: Timeout = None
143
+ ) -> None:
144
+ """
145
+ Expects the user message in the chat.
146
+
147
+ Parameters
148
+ ----------
149
+ value
150
+ The expected user message.
151
+ timeout
152
+ The maximum time to wait for the expectation to pass. Defaults to `None`.
153
+ """
154
+ playwright_expect(self.loc_input).to_have_value(value, timeout=timeout)
@@ -0,0 +1 @@
1
+ 084033e8198070adf6ea80ce826fa1b620900658
@@ -0,0 +1,2 @@
1
+ @charset "UTF-8";shiny-chat-container{--shiny-chat-border: var(--bs-border-width, 1px) solid var(--bs-border-color, #e9ecef);--shiny-chat-user-message-bg: RGBA(var(--bs-primary-rgb, 0, 123, 194), .06);--_chat-container-padding: .25rem;display:grid;grid-template-columns:1fr;grid-template-rows:1fr auto;margin:0 auto;gap:0;padding:var(--_chat-container-padding);padding-bottom:0}shiny-chat-container p:last-child{margin-bottom:0}shiny-chat-container .suggestion,shiny-chat-container [data-suggestion]{cursor:pointer}shiny-chat-container .suggestion{color:var(--bs-link-color, #007bc2);text-decoration-color:var(--bs-link-color, #007bc2);text-decoration-line:underline;text-decoration-style:dotted;text-underline-offset:2px;text-underline-offset:4px;text-decoration-thickness:2px;padding-inline:2px}shiny-chat-container .suggestion:hover{text-decoration-style:solid}shiny-chat-container .suggestion:after{content:"\2726";display:inline-block;margin-inline-start:.15em}shiny-chat-container .suggestion.submit:after,shiny-chat-container .suggestion[data-suggestion-submit=""]:after,shiny-chat-container .suggestion[data-suggestion-submit=true]:after{content:"\21b5"}shiny-chat-container .card[data-suggestion]:hover{color:var(--bs-link-color, #007bc2);border-color:rgba(var(--bs-link-color-rgb),.5)}shiny-chat-messages{display:flex;flex-direction:column;gap:2rem;overflow:auto;margin-bottom:1rem;--_scroll-margin: 1rem;padding-right:var(--_scroll-margin);margin-right:calc(-1 * var(--_scroll-margin))}shiny-chat-message{display:grid;grid-template-columns:auto minmax(0,1fr);gap:1rem}shiny-chat-message>*{height:fit-content}shiny-chat-message .message-icon{border-radius:50%;border:var(--shiny-chat-border);height:2rem;width:2rem;display:grid;place-items:center;overflow:clip}shiny-chat-message .message-icon>*{height:100%;width:100%;max-width:100%;max-height:100%;margin:0!important;object-fit:contain}shiny-chat-message .message-icon>svg,shiny-chat-message .message-icon>.icon,shiny-chat-message .message-icon>.fa,shiny-chat-message .message-icon>.bi{max-height:66%;max-width:66%}shiny-chat-message .message-icon:has(>.border-0){border:none;border-radius:unset;overflow:unset}shiny-chat-message shiny-markdown-stream{align-self:center}shiny-user-message{align-self:flex-end;padding:.75rem 1rem;border-radius:10px;background-color:var(--shiny-chat-user-message-bg);max-width:100%}shiny-user-message[content_type=text],shiny-chat-message[content_type=text]{white-space:pre;overflow-x:auto}shiny-chat-input{--_input-padding-top: 0;--_input-padding-bottom: var(--_chat-container-padding, .25rem);margin-top:calc(-1 * var(--_input-padding-top));position:sticky;bottom:calc(-1 * var(--_input-padding-bottom) + 4px);padding-block:var(--_input-padding-top) var(--_input-padding-bottom)}shiny-chat-input textarea{--bs-border-radius: 26px;resize:none;padding-right:36px!important;max-height:175px}shiny-chat-input textarea::placeholder{color:var(--bs-gray-600, #707782)!important}shiny-chat-input button{position:absolute;bottom:calc(6px + var(--_input-padding-bottom));right:8px;background-color:transparent;color:var(--bs-primary, #007bc2);transition:color .25s ease-in-out;border:none;padding:0;cursor:pointer;line-height:16px;border-radius:50%}shiny-chat-input button:disabled{cursor:not-allowed;color:var(--bs-gray-500, #8d959e)}.shiny-busy:has(shiny-chat-input[disabled]):after{display:none}
2
+ /*# sourceMappingURL=chat.css.map */
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/chat/chat.scss"],
4
+ "sourcesContent": ["@charset \"UTF-8\";\nshiny-chat-container {\n --shiny-chat-border: var(--bs-border-width, 1px) solid var(--bs-border-color, #e9ecef);\n --shiny-chat-user-message-bg: RGBA(var(--bs-primary-rgb, 0, 123, 194), 0.06);\n --_chat-container-padding: 0.25rem;\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: 1fr auto;\n margin: 0 auto;\n gap: 0;\n padding: var(--_chat-container-padding);\n padding-bottom: 0;\n}\nshiny-chat-container p:last-child {\n margin-bottom: 0;\n}\nshiny-chat-container .suggestion,\nshiny-chat-container [data-suggestion] {\n cursor: pointer;\n}\nshiny-chat-container .suggestion {\n color: var(--bs-link-color, #007bc2);\n text-decoration-color: var(--bs-link-color, #007bc2);\n text-decoration-line: underline;\n text-decoration-style: dotted;\n text-decoration-thickness: 2px;\n text-underline-offset: 2px;\n text-underline-offset: 4px;\n text-decoration-thickness: 2px;\n padding-inline: 2px;\n}\nshiny-chat-container .suggestion:hover {\n text-decoration-style: solid;\n}\nshiny-chat-container .suggestion::after {\n content: \"\u2726\";\n display: inline-block;\n margin-inline-start: 0.15em;\n}\nshiny-chat-container .suggestion.submit::after, shiny-chat-container .suggestion[data-suggestion-submit=\"\"]::after, shiny-chat-container .suggestion[data-suggestion-submit=true]::after {\n content: \"\u21B5\";\n}\nshiny-chat-container .card[data-suggestion]:hover {\n color: var(--bs-link-color, #007bc2);\n border-color: rgba(var(--bs-link-color-rgb), 0.5);\n}\n\nshiny-chat-messages {\n display: flex;\n flex-direction: column;\n gap: 2rem;\n overflow: auto;\n margin-bottom: 1rem;\n --_scroll-margin: 1rem;\n padding-right: var(--_scroll-margin);\n margin-right: calc(-1 * var(--_scroll-margin));\n}\n\nshiny-chat-message {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr);\n gap: 1rem;\n /* Vertically center the 2nd column (message content) */\n}\nshiny-chat-message > * {\n height: fit-content;\n}\nshiny-chat-message .message-icon {\n border-radius: 50%;\n border: var(--shiny-chat-border);\n height: 2rem;\n width: 2rem;\n display: grid;\n place-items: center;\n overflow: clip;\n}\nshiny-chat-message .message-icon > * {\n height: 100%;\n width: 100%;\n max-width: 100%;\n max-height: 100%;\n margin: 0 !important;\n object-fit: contain;\n}\nshiny-chat-message .message-icon > svg,\nshiny-chat-message .message-icon > .icon,\nshiny-chat-message .message-icon > .fa,\nshiny-chat-message .message-icon > .bi {\n max-height: 66%;\n max-width: 66%;\n}\nshiny-chat-message .message-icon:has(> .border-0) {\n border: none;\n border-radius: unset;\n overflow: unset;\n}\nshiny-chat-message shiny-markdown-stream {\n align-self: center;\n}\n\n/* Align the user message to the right */\nshiny-user-message {\n align-self: flex-end;\n padding: 0.75rem 1rem;\n border-radius: 10px;\n background-color: var(--shiny-chat-user-message-bg);\n max-width: 100%;\n}\n\nshiny-user-message[content_type=text],\nshiny-chat-message[content_type=text] {\n white-space: pre;\n overflow-x: auto;\n}\n\nshiny-chat-input {\n --_input-padding-top: 0;\n --_input-padding-bottom: var(--_chat-container-padding, 0.25rem);\n margin-top: calc(-1 * var(--_input-padding-top));\n position: sticky;\n bottom: calc(-1 * var(--_input-padding-bottom) + 4px);\n padding-block: var(--_input-padding-top) var(--_input-padding-bottom);\n}\nshiny-chat-input textarea {\n --bs-border-radius: 26px;\n resize: none;\n padding-right: 36px !important;\n max-height: 175px;\n}\nshiny-chat-input textarea::placeholder {\n color: var(--bs-gray-600, #707782) !important;\n}\nshiny-chat-input button {\n position: absolute;\n bottom: calc(6px + var(--_input-padding-bottom));\n right: 8px;\n background-color: transparent;\n color: var(--bs-primary, #007bc2);\n transition: color 0.25s ease-in-out;\n border: none;\n padding: 0;\n cursor: pointer;\n line-height: 16px;\n border-radius: 50%;\n}\nshiny-chat-input button:disabled {\n cursor: not-allowed;\n color: var(--bs-gray-500, #8d959e);\n}\n\n/*\n Disable the page-level pulse when the chat input is disabled\n (i.e., when a response is being generated and brought into the chat)\n*/\n.shiny-busy:has(shiny-chat-input[disabled])::after {\n display: none;\n}"],
5
+ "mappings": "iBACA,qBACE,qBAAqB,IAAI,iBAAiB,EAAE,KAAK,MAAM,IAAI,iBAAiB,EAAE,SAC9E,8BAA8B,KAAK,IAAI,gBAAgB,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KACvE,2BAA2B,OAC3B,QAAS,KACT,sBAAuB,IACvB,mBAAoB,IAAI,KAP1B,OAQU,EAAE,KACV,IAAK,EACL,QAAS,IAAI,2BACb,eAAgB,CAClB,CACA,qBAAqB,CAAC,YACpB,cAAe,CACjB,CACA,qBAAqB,CAAC,WACtB,qBAAqB,CAAC,iBACpB,OAAQ,OACV,CACA,qBAAqB,CAJC,WAKpB,MAAO,IAAI,eAAe,EAAE,SAC5B,sBAAuB,IAAI,eAAe,EAAE,SAC5C,qBAAsB,UACtB,sBAAuB,OAEvB,sBAAuB,IACvB,sBAAuB,IACvB,0BAA2B,IAC3B,eAAgB,GAClB,CACA,qBAAqB,CAfC,UAeU,OAC9B,sBAAuB,KACzB,CACA,qBAAqB,CAlBC,UAkBU,OAC9B,QAAS,QACT,QAAS,aACT,oBAAqB,KACvB,CACA,qBAAqB,CAvBC,UAuBU,CAAC,MAAM,OAAS,qBAAqB,CAvB/C,UAuB0D,CAAC,0BAA0B,OAAS,qBAAqB,CAvBnH,UAuB8H,CAAC,4BAA4B,OAC/K,QAAS,OACX,CACA,qBAAqB,CAAC,IAAI,CAAC,gBAAgB,OACzC,MAAO,IAAI,eAAe,EAAE,SAC5B,aAAc,KAAK,IAAI,oBAAoB,CAAE,GAC/C,CAEA,oBACE,QAAS,KACT,eAAgB,OAChB,IAAK,KACL,SAAU,KACV,cAAe,KACf,kBAAkB,KAClB,cAAe,IAAI,kBACnB,aAAc,KAAK,GAAG,EAAE,IAAI,kBAC9B,CAEA,mBACE,QAAS,KACT,sBAAuB,KAAK,OAAO,CAAC,CAAE,KACtC,IAAK,IAEP,CACA,kBAAmB,CAAE,EACnB,OAAQ,WACV,CACA,mBAAmB,CAAC,aAnEpB,cAoEiB,IACf,OAAQ,IAAI,qBACZ,OAAQ,KACR,MAAO,KACP,QAAS,KACT,YAAa,OACb,SAAU,IACZ,CACA,mBAAmB,CATC,YASa,CAAE,EACjC,OAAQ,KACR,MAAO,KACP,UAAW,KACX,WAAY,KAhFd,OAiFU,YACR,WAAY,OACd,CACA,mBAAmB,CAjBC,YAiBa,CAAE,IACnC,mBAAmB,CAlBC,YAkBa,CAAE,CAAC,KACpC,mBAAmB,CAnBC,YAmBa,CAAE,CAAC,GACpC,mBAAmB,CApBC,YAoBa,CAAE,CAAC,GAClC,WAAY,IACZ,UAAW,GACb,CACA,mBAAmB,CAxBC,YAwBY,KAAK,CAAE,CAAC,UACtC,OAAQ,KACR,cAAe,MACf,SAAU,KACZ,CACA,mBAAmB,sBACjB,WAAY,MACd,CAGA,mBACE,WAAY,SAtGd,QAuGW,OAAQ,KAvGnB,cAwGiB,KACf,iBAAkB,IAAI,8BACtB,UAAW,IACb,CAEA,kBAAkB,CAAC,mBACnB,kBAAkB,CAAC,mBACjB,YAAa,IACb,WAAY,IACd,CAEA,iBACE,sBAAsB,EACtB,yBAAyB,IAAI,yBAAyB,EAAE,QACxD,WAAY,KAAK,GAAG,EAAE,IAAI,uBAC1B,SAAU,OACV,OAAQ,KAAK,GAAG,EAAE,IAAI,yBAAyB,EAAE,KACjD,cAAe,IAAI,sBAAsB,IAAI,wBAC/C,CACA,iBAAiB,SACf,oBAAoB,KACpB,OAAQ,KACR,cAAe,eACf,WAAY,KACd,CACA,iBAAiB,QAAQ,cACvB,MAAO,IAAI,aAAa,EAAE,kBAC5B,CACA,iBAAiB,OACf,SAAU,SACV,OAAQ,KAAK,IAAI,EAAE,IAAI,0BACvB,MAAO,IACP,iBAAkB,YAClB,MAAO,IAAI,YAAY,EAAE,SACzB,WAAY,MAAM,KAAM,YACxB,OAAQ,KA3IV,QA4IW,EACT,OAAQ,QACR,YAAa,KA9If,cA+IiB,GACjB,CACA,iBAAiB,MAAM,UACrB,OAAQ,YACR,MAAO,IAAI,aAAa,EAAE,QAC5B,CAMA,CAAC,UAAU,KAAK,gBAAgB,CAAC,UAAU,OACzC,QAAS,IACX",
6
+ "names": []
7
+ }
@@ -0,0 +1,87 @@
1
+ var hs=Object.defineProperty;var ps=Object.getOwnPropertyDescriptor;var B=(o,t,e,n)=>{for(var i=n>1?void 0:n?ps(t,e):t,r=o.length-1,l;r>=0;r--)(l=o[r])&&(i=(n?l(t,e,i):l(i))||i);return n&&i&&hs(t,e,i),i};var kt=globalThis,Ht=kt.ShadowRoot&&(kt.ShadyCSS===void 0||kt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,an=Symbol(),rn=new WeakMap,Ut=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==an)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(Ht&&t===void 0){let n=e!==void 0&&e.length===1;n&&(t=rn.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&rn.set(e,t))}return t}toString(){return this.cssText}},ln=o=>new Ut(typeof o=="string"?o:o+"",void 0,an);var cn=(o,t)=>{if(Ht)o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let n=document.createElement("style"),i=kt.litNonce;i!==void 0&&n.setAttribute("nonce",i),n.textContent=e.cssText,o.appendChild(n)}},pe=Ht?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(let n of t.cssRules)e+=n.cssText;return ln(e)})(o):o;var{is:ds,defineProperty:fs,getOwnPropertyDescriptor:ms,getOwnPropertyNames:gs,getOwnPropertySymbols:_s,getPrototypeOf:Es}=Object,zt=globalThis,un=zt.trustedTypes,As=un?un.emptyScript:"",ys=zt.reactiveElementPolyfillSupport,mt=(o,t)=>o,gt={toAttribute(o,t){switch(t){case Boolean:o=o?As:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Ft=(o,t)=>!ds(o,t),hn={attribute:!0,type:String,converter:gt,reflect:!1,useDefault:!1,hasChanged:Ft};Symbol.metadata??=Symbol("metadata"),zt.litPropertyMetadata??=new WeakMap;var G=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=hn){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let n=Symbol(),i=this.getPropertyDescriptor(t,n,e);i!==void 0&&fs(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){let{get:i,set:r}=ms(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get:i,set(l){let d=i?.call(this);r?.call(this,l),this.requestUpdate(t,d,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??hn}static _$Ei(){if(this.hasOwnProperty(mt("elementProperties")))return;let t=Es(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(mt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(mt("properties"))){let e=this.properties,n=[...gs(e),..._s(e)];for(let i of n)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[n,i]of e)this.elementProperties.set(n,i)}this._$Eh=new Map;for(let[e,n]of this.elementProperties){let i=this._$Eu(e,n);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let n=new Set(t.flat(1/0).reverse());for(let i of n)e.unshift(pe(i))}else t!==void 0&&e.push(pe(t));return e}static _$Eu(t,e){let n=e.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return cn(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$ET(t,e){let n=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,n);if(i!==void 0&&n.reflect===!0){let r=(n.converter?.toAttribute!==void 0?n.converter:gt).toAttribute(e,n.type);this._$Em=t,r==null?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){let n=this.constructor,i=n._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let r=n.getPropertyOptions(i),l=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:gt;this._$Em=i,this[i]=l.fromAttribute(e,r.type)??this._$Ej?.get(i)??null,this._$Em=null}}requestUpdate(t,e,n){if(t!==void 0){let i=this.constructor,r=this[t];if(n??=i.getPropertyOptions(t),!((n.hasChanged??Ft)(r,e)||n.useDefault&&n.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,n))))return;this.C(t,e,n)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:i,wrapped:r},l){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,l??e??this[t]),r!==!0||l!==void 0)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,r]of this._$Ep)this[i]=r;this._$Ep=void 0}let n=this.constructor.elementProperties;if(n.size>0)for(let[i,r]of n){let{wrapped:l}=r,d=this[i];l!==!0||this._$AL.has(i)||d===void 0||this.C(i,void 0,r,d)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(n=>n.hostUpdate?.()),this.update(e)):this._$EM()}catch(n){throw t=!1,this._$EM(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};G.elementStyles=[],G.shadowRootOptions={mode:"open"},G[mt("elementProperties")]=new Map,G[mt("finalized")]=new Map,ys?.({ReactiveElement:G}),(zt.reactiveElementVersions??=[]).push("2.1.0");var Ae=globalThis,Bt=Ae.trustedTypes,pn=Bt?Bt.createPolicy("lit-html",{createHTML:o=>o}):void 0,En="$lit$",j=`lit$${Math.random().toFixed(9).slice(2)}$`,An="?"+j,Ts=`<${An}>`,J=document,Et=()=>J.createComment(""),At=o=>o===null||typeof o!="object"&&typeof o!="function",ye=Array.isArray,vs=o=>ye(o)||typeof o?.[Symbol.iterator]=="function",de=`[
2
+ \f\r]`,_t=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,dn=/-->/g,fn=/>/g,X=RegExp(`>|${de}(?:([^\\s"'>=/]+)(${de}*=${de}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),mn=/'/g,gn=/"/g,yn=/^(?:script|style|textarea|title)$/i,Te=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),ct=Te(1),ii=Te(2),oi=Te(3),W=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),_n=new WeakMap,Z=J.createTreeWalker(J,129);function Tn(o,t){if(!ye(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return pn!==void 0?pn.createHTML(t):t}var Ss=(o,t)=>{let e=o.length-1,n=[],i,r=t===2?"<svg>":t===3?"<math>":"",l=_t;for(let d=0;d<e;d++){let h=o[d],m,y,f=-1,I=0;for(;I<h.length&&(l.lastIndex=I,y=l.exec(h),y!==null);)I=l.lastIndex,l===_t?y[1]==="!--"?l=dn:y[1]!==void 0?l=fn:y[2]!==void 0?(yn.test(y[2])&&(i=RegExp("</"+y[2],"g")),l=X):y[3]!==void 0&&(l=X):l===X?y[0]===">"?(l=i??_t,f=-1):y[1]===void 0?f=-2:(f=l.lastIndex-y[2].length,m=y[1],l=y[3]===void 0?X:y[3]==='"'?gn:mn):l===gn||l===mn?l=X:l===dn||l===fn?l=_t:(l=X,i=void 0);let R=l===X&&o[d+1].startsWith("/>")?" ":"";r+=l===_t?h+Ts:f>=0?(n.push(m),h.slice(0,f)+En+h.slice(f)+j+R):h+j+(f===-2?d:R)}return[Tn(o,r+(o[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]},yt=class o{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,l=0,d=t.length-1,h=this.parts,[m,y]=Ss(t,e);if(this.el=o.createElement(m,n),Z.currentNode=this.el.content,e===2||e===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Z.nextNode())!==null&&h.length<d;){if(i.nodeType===1){if(i.hasAttributes())for(let f of i.getAttributeNames())if(f.endsWith(En)){let I=y[l++],R=i.getAttribute(f).split(j),P=/([.?@])?(.*)/.exec(I);h.push({type:1,index:r,name:P[2],strings:R,ctor:P[1]==="."?me:P[1]==="?"?ge:P[1]==="@"?_e:lt}),i.removeAttribute(f)}else f.startsWith(j)&&(h.push({type:6,index:r}),i.removeAttribute(f));if(yn.test(i.tagName)){let f=i.textContent.split(j),I=f.length-1;if(I>0){i.textContent=Bt?Bt.emptyScript:"";for(let R=0;R<I;R++)i.append(f[R],Et()),Z.nextNode(),h.push({type:2,index:++r});i.append(f[I],Et())}}}else if(i.nodeType===8)if(i.data===An)h.push({type:2,index:r});else{let f=-1;for(;(f=i.data.indexOf(j,f+1))!==-1;)h.push({type:7,index:r}),f+=j.length-1}r++}}static createElement(t,e){let n=J.createElement("template");return n.innerHTML=t,n}};function at(o,t,e=o,n){if(t===W)return t;let i=n!==void 0?e._$Co?.[n]:e._$Cl,r=At(t)?void 0:t._$litDirective$;return i?.constructor!==r&&(i?._$AO?.(!1),r===void 0?i=void 0:(i=new r(o),i._$AT(o,e,n)),n!==void 0?(e._$Co??=[])[n]=i:e._$Cl=i),i!==void 0&&(t=at(o,i._$AS(o,t.values),i,n)),t}var fe=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:n}=this._$AD,i=(t?.creationScope??J).importNode(e,!0);Z.currentNode=i;let r=Z.nextNode(),l=0,d=0,h=n[0];for(;h!==void 0;){if(l===h.index){let m;h.type===2?m=new Tt(r,r.nextSibling,this,t):h.type===1?m=new h.ctor(r,h.name,h.strings,this,t):h.type===6&&(m=new Ee(r,this,t)),this._$AV.push(m),h=n[++d]}l!==h?.index&&(r=Z.nextNode(),l++)}return Z.currentNode=J,i}p(t){let e=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}},Tt=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=at(this,t,e),At(t)?t===E||t==null||t===""?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==W&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):vs(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==E&&At(this._$AH)?this._$AA.nextSibling.data=t:this.T(J.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:n}=t,i=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=yt.createElement(Tn(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(e);else{let r=new fe(i,this),l=r.u(this.options);r.p(e),this.T(l),this._$AH=r}}_$AC(t){let e=_n.get(t.strings);return e===void 0&&_n.set(t.strings,e=new yt(t)),e}k(t){ye(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,n,i=0;for(let r of t)i===e.length?e.push(n=new o(this.O(Et()),this.O(Et()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let n=t.nextSibling;t.remove(),t=n}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},lt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,r){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=E}_$AI(t,e=this,n,i){let r=this.strings,l=!1;if(r===void 0)t=at(this,t,e,0),l=!At(t)||t!==this._$AH&&t!==W,l&&(this._$AH=t);else{let d=t,h,m;for(t=r[0],h=0;h<r.length-1;h++)m=at(this,d[n+h],e,h),m===W&&(m=this._$AH[h]),l||=!At(m)||m!==this._$AH[h],m===E?t=E:t!==E&&(t+=(m??"")+r[h+1]),this._$AH[h]=m}l&&!i&&this.j(t)}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},me=class extends lt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===E?void 0:t}},ge=class extends lt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E)}},_e=class extends lt{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){if((t=at(this,t,e,0)??E)===W)return;let n=this._$AH,i=t===E&&n!==E||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,r=t!==E&&(n===E||i);i&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Ee=class{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){at(this,t)}};var bs=Ae.litHtmlPolyfillSupport;bs?.(yt,Tt),(Ae.litHtmlVersions??=[]).push("3.3.0");var vn=(o,t,e)=>{let n=e?.renderBefore??t,i=n._$litPart$;if(i===void 0){let r=e?.renderBefore??null;n._$litPart$=i=new Tt(t.insertBefore(Et(),r),r,void 0,e??{})}return i._$AI(o),i};var ve=globalThis,q=class extends G{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=vn(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}};q._$litElement$=!0,q.finalized=!0,ve.litElementHydrateSupport?.({LitElement:q});var Cs=ve.litElementPolyfillSupport;Cs?.({LitElement:q});(ve.litElementVersions??=[]).push("4.2.0");var Sn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},bn=o=>(...t)=>({_$litDirective$:o,values:t}),Gt=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var vt=class extends Gt{constructor(t){if(super(t),this.it=E,t.type!==Sn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===E||t==null)return this._t=void 0,this.it=t;if(t===W)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};vt.directiveName="unsafeHTML",vt.resultType=1;var Se=bn(vt);var ws={attribute:!0,type:String,converter:gt,reflect:!1,hasChanged:Ft},$s=(o=ws,t,e)=>{let{kind:n,metadata:i}=e,r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),n==="setter"&&((o=Object.create(o)).wrapped=!0),r.set(e.name,o),n==="accessor"){let{name:l}=e;return{set(d){let h=t.get.call(this);t.set.call(this,d),this.requestUpdate(l,h,o)},init(d){return d!==void 0&&this.C(l,void 0,o,d),d}}}if(n==="setter"){let{name:l}=e;return function(d){let h=this[l];t.call(this,d),this.requestUpdate(l,h,o)}}throw Error("Unsupported decorator location: "+n)};function U(o){return(t,e)=>typeof e=="object"?$s(o,t,e):((n,i,r)=>{let l=i.hasOwnProperty(r);return i.constructor.createProperty(r,n),l?Object.getOwnPropertyDescriptor(i,r):void 0})(o,t,e)}var{entries:In,setPrototypeOf:Cn,isFrozen:Ms,getPrototypeOf:Os,getOwnPropertyDescriptor:xs}=Object,{freeze:O,seal:N,create:Dn}=Object,{apply:Oe,construct:xe}=typeof Reflect<"u"&&Reflect;O||(O=function(t){return t});N||(N=function(t){return t});Oe||(Oe=function(t,e,n){return t.apply(e,n)});xe||(xe=function(t,e){return new t(...e)});var Vt=x(Array.prototype.forEach),Ls=x(Array.prototype.lastIndexOf),wn=x(Array.prototype.pop),St=x(Array.prototype.push),Rs=x(Array.prototype.splice),qt=x(String.prototype.toLowerCase),be=x(String.prototype.toString),$n=x(String.prototype.match),bt=x(String.prototype.replace),Ns=x(String.prototype.indexOf),Is=x(String.prototype.trim),D=x(Object.prototype.hasOwnProperty),M=x(RegExp.prototype.test),Ct=Ds(TypeError);function x(o){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Oe(o,t,n)}}function Ds(o){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return xe(o,e)}}function p(o,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;Cn&&Cn(o,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){let r=e(i);r!==i&&(Ms(t)||(t[n]=r),i=r)}o[i]=!0}return o}function Ps(o){for(let t=0;t<o.length;t++)D(o,t)||(o[t]=null);return o}function V(o){let t=Dn(null);for(let[e,n]of In(o))D(o,e)&&(Array.isArray(n)?t[e]=Ps(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=V(n):t[e]=n);return t}function wt(o,t){for(;o!==null;){let n=xs(o,t);if(n){if(n.get)return x(n.get);if(typeof n.value=="function")return x(n.value)}o=Os(o)}function e(){return null}return e}var Mn=O(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ce=O(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),we=O(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ks=O(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),$e=O(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Us=O(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),On=O(["#text"]),xn=O(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Me=O(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ln=O(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),jt=O(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Hs=N(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zs=N(/<%[\w\W]*|[\w\W]*%>/gm),Fs=N(/\$\{[\w\W]*/gm),Bs=N(/^data-[\-\w.\u00B7-\uFFFF]+$/),Gs=N(/^aria-[\-\w]+$/),Pn=N(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ws=N(/^(?:\w+script|data):/i),Vs=N(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),kn=N(/^html$/i),js=N(/^[a-z][.\w]*(-[.\w]+)+$/i),Rn=Object.freeze({__proto__:null,ARIA_ATTR:Gs,ATTR_WHITESPACE:Vs,CUSTOM_ELEMENT:js,DATA_ATTR:Bs,DOCTYPE_NAME:kn,ERB_EXPR:zs,IS_ALLOWED_URI:Pn,IS_SCRIPT_OR_DATA:Ws,MUSTACHE_EXPR:Hs,TMPLIT_EXPR:Fs}),$t={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},qs=function(){return typeof window>"u"?null:window},Ys=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null,i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));let r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Nn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Un(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qs(),t=u=>Un(u);if(t.version="3.2.6",t.removed=[],!o||!o.document||o.document.nodeType!==$t.document||!o.Element)return t.isSupported=!1,t;let{document:e}=o,n=e,i=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:l,Node:d,Element:h,NodeFilter:m,NamedNodeMap:y=o.NamedNodeMap||o.MozNamedAttrMap,HTMLFormElement:f,DOMParser:I,trustedTypes:R}=o,P=h.prototype,Vn=wt(P,"cloneNode"),jn=wt(P,"remove"),qn=wt(P,"nextSibling"),Yn=wt(P,"childNodes"),Ot=wt(P,"parentNode");if(typeof l=="function"){let u=e.createElement("template");u.content&&u.content.ownerDocument&&(e=u.content.ownerDocument)}let w,ut="",{implementation:Zt,createNodeIterator:Kn,createDocumentFragment:Xn,getElementsByTagName:Zn}=e,{importNode:Jn}=n,$=Nn();t.isSupported=typeof In=="function"&&typeof Ot=="function"&&Zt&&Zt.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:Jt,ERB_EXPR:Qt,TMPLIT_EXPR:te,DATA_ATTR:Qn,ARIA_ATTR:ts,IS_SCRIPT_OR_DATA:es,ATTR_WHITESPACE:Ie,CUSTOM_ELEMENT:ns}=Rn,{IS_ALLOWED_URI:De}=Rn,T=null,Pe=p({},[...Mn,...Ce,...we,...$e,...On]),S=null,ke=p({},[...xn,...Me,...Ln,...jt]),_=Object.seal(Dn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ht=null,ee=null,Ue=!0,ne=!0,He=!1,ze=!0,tt=!1,xt=!0,K=!1,se=!1,ie=!1,et=!1,Lt=!1,Rt=!1,Fe=!0,Be=!1,ss="user-content-",oe=!0,pt=!1,nt={},st=null,Ge=p({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),We=null,Ve=p({},["audio","video","img","source","image","track"]),re=null,je=p({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Nt="http://www.w3.org/1998/Math/MathML",It="http://www.w3.org/2000/svg",H="http://www.w3.org/1999/xhtml",it=H,ae=!1,le=null,is=p({},[Nt,It,H],be),Dt=p({},["mi","mo","mn","ms","mtext"]),Pt=p({},["annotation-xml"]),os=p({},["title","style","font","a","script"]),dt=null,rs=["application/xhtml+xml","text/html"],as="text/html",v=null,ot=null,ls=e.createElement("form"),qe=function(s){return s instanceof RegExp||s instanceof Function},ce=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ot&&ot===s)){if((!s||typeof s!="object")&&(s={}),s=V(s),dt=rs.indexOf(s.PARSER_MEDIA_TYPE)===-1?as:s.PARSER_MEDIA_TYPE,v=dt==="application/xhtml+xml"?be:qt,T=D(s,"ALLOWED_TAGS")?p({},s.ALLOWED_TAGS,v):Pe,S=D(s,"ALLOWED_ATTR")?p({},s.ALLOWED_ATTR,v):ke,le=D(s,"ALLOWED_NAMESPACES")?p({},s.ALLOWED_NAMESPACES,be):is,re=D(s,"ADD_URI_SAFE_ATTR")?p(V(je),s.ADD_URI_SAFE_ATTR,v):je,We=D(s,"ADD_DATA_URI_TAGS")?p(V(Ve),s.ADD_DATA_URI_TAGS,v):Ve,st=D(s,"FORBID_CONTENTS")?p({},s.FORBID_CONTENTS,v):Ge,ht=D(s,"FORBID_TAGS")?p({},s.FORBID_TAGS,v):V({}),ee=D(s,"FORBID_ATTR")?p({},s.FORBID_ATTR,v):V({}),nt=D(s,"USE_PROFILES")?s.USE_PROFILES:!1,Ue=s.ALLOW_ARIA_ATTR!==!1,ne=s.ALLOW_DATA_ATTR!==!1,He=s.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=s.ALLOW_SELF_CLOSE_IN_ATTR!==!1,tt=s.SAFE_FOR_TEMPLATES||!1,xt=s.SAFE_FOR_XML!==!1,K=s.WHOLE_DOCUMENT||!1,et=s.RETURN_DOM||!1,Lt=s.RETURN_DOM_FRAGMENT||!1,Rt=s.RETURN_TRUSTED_TYPE||!1,ie=s.FORCE_BODY||!1,Fe=s.SANITIZE_DOM!==!1,Be=s.SANITIZE_NAMED_PROPS||!1,oe=s.KEEP_CONTENT!==!1,pt=s.IN_PLACE||!1,De=s.ALLOWED_URI_REGEXP||Pn,it=s.NAMESPACE||H,Dt=s.MATHML_TEXT_INTEGRATION_POINTS||Dt,Pt=s.HTML_INTEGRATION_POINTS||Pt,_=s.CUSTOM_ELEMENT_HANDLING||{},s.CUSTOM_ELEMENT_HANDLING&&qe(s.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(_.tagNameCheck=s.CUSTOM_ELEMENT_HANDLING.tagNameCheck),s.CUSTOM_ELEMENT_HANDLING&&qe(s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(_.attributeNameCheck=s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),s.CUSTOM_ELEMENT_HANDLING&&typeof s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(_.allowCustomizedBuiltInElements=s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),tt&&(ne=!1),Lt&&(et=!0),nt&&(T=p({},On),S=[],nt.html===!0&&(p(T,Mn),p(S,xn)),nt.svg===!0&&(p(T,Ce),p(S,Me),p(S,jt)),nt.svgFilters===!0&&(p(T,we),p(S,Me),p(S,jt)),nt.mathMl===!0&&(p(T,$e),p(S,Ln),p(S,jt))),s.ADD_TAGS&&(T===Pe&&(T=V(T)),p(T,s.ADD_TAGS,v)),s.ADD_ATTR&&(S===ke&&(S=V(S)),p(S,s.ADD_ATTR,v)),s.ADD_URI_SAFE_ATTR&&p(re,s.ADD_URI_SAFE_ATTR,v),s.FORBID_CONTENTS&&(st===Ge&&(st=V(st)),p(st,s.FORBID_CONTENTS,v)),oe&&(T["#text"]=!0),K&&p(T,["html","head","body"]),T.table&&(p(T,["tbody"]),delete ht.tbody),s.TRUSTED_TYPES_POLICY){if(typeof s.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ct('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof s.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ct('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=s.TRUSTED_TYPES_POLICY,ut=w.createHTML("")}else w===void 0&&(w=Ys(R,i)),w!==null&&typeof ut=="string"&&(ut=w.createHTML(""));O&&O(s),ot=s}},Ye=p({},[...Ce,...we,...ks]),Ke=p({},[...$e,...Us]),cs=function(s){let a=Ot(s);(!a||!a.tagName)&&(a={namespaceURI:it,tagName:"template"});let c=qt(s.tagName),g=qt(a.tagName);return le[s.namespaceURI]?s.namespaceURI===It?a.namespaceURI===H?c==="svg":a.namespaceURI===Nt?c==="svg"&&(g==="annotation-xml"||Dt[g]):!!Ye[c]:s.namespaceURI===Nt?a.namespaceURI===H?c==="math":a.namespaceURI===It?c==="math"&&Pt[g]:!!Ke[c]:s.namespaceURI===H?a.namespaceURI===It&&!Pt[g]||a.namespaceURI===Nt&&!Dt[g]?!1:!Ke[c]&&(os[c]||!Ye[c]):!!(dt==="application/xhtml+xml"&&le[s.namespaceURI]):!1},k=function(s){St(t.removed,{element:s});try{Ot(s).removeChild(s)}catch{jn(s)}},rt=function(s,a){try{St(t.removed,{attribute:a.getAttributeNode(s),from:a})}catch{St(t.removed,{attribute:null,from:a})}if(a.removeAttribute(s),s==="is")if(et||Lt)try{k(a)}catch{}else try{a.setAttribute(s,"")}catch{}},Xe=function(s){let a=null,c=null;if(ie)s="<remove></remove>"+s;else{let A=$n(s,/^[\r\n\t ]+/);c=A&&A[0]}dt==="application/xhtml+xml"&&it===H&&(s='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+s+"</body></html>");let g=w?w.createHTML(s):s;if(it===H)try{a=new I().parseFromString(g,dt)}catch{}if(!a||!a.documentElement){a=Zt.createDocument(it,"template",null);try{a.documentElement.innerHTML=ae?ut:g}catch{}}let b=a.body||a.documentElement;return s&&c&&b.insertBefore(e.createTextNode(c),b.childNodes[0]||null),it===H?Zn.call(a,K?"html":"body")[0]:K?a.documentElement:b},Ze=function(s){return Kn.call(s.ownerDocument||s,s,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},ue=function(s){return s instanceof f&&(typeof s.nodeName!="string"||typeof s.textContent!="string"||typeof s.removeChild!="function"||!(s.attributes instanceof y)||typeof s.removeAttribute!="function"||typeof s.setAttribute!="function"||typeof s.namespaceURI!="string"||typeof s.insertBefore!="function"||typeof s.hasChildNodes!="function")},Je=function(s){return typeof d=="function"&&s instanceof d};function z(u,s,a){Vt(u,c=>{c.call(t,s,a,ot)})}let Qe=function(s){let a=null;if(z($.beforeSanitizeElements,s,null),ue(s))return k(s),!0;let c=v(s.nodeName);if(z($.uponSanitizeElement,s,{tagName:c,allowedTags:T}),xt&&s.hasChildNodes()&&!Je(s.firstElementChild)&&M(/<[/\w!]/g,s.innerHTML)&&M(/<[/\w!]/g,s.textContent)||s.nodeType===$t.progressingInstruction||xt&&s.nodeType===$t.comment&&M(/<[/\w]/g,s.data))return k(s),!0;if(!T[c]||ht[c]){if(!ht[c]&&en(c)&&(_.tagNameCheck instanceof RegExp&&M(_.tagNameCheck,c)||_.tagNameCheck instanceof Function&&_.tagNameCheck(c)))return!1;if(oe&&!st[c]){let g=Ot(s)||s.parentNode,b=Yn(s)||s.childNodes;if(b&&g){let A=b.length;for(let L=A-1;L>=0;--L){let F=Vn(b[L],!0);F.__removalCount=(s.__removalCount||0)+1,g.insertBefore(F,qn(s))}}}return k(s),!0}return s instanceof h&&!cs(s)||(c==="noscript"||c==="noembed"||c==="noframes")&&M(/<\/no(script|embed|frames)/i,s.innerHTML)?(k(s),!0):(tt&&s.nodeType===$t.text&&(a=s.textContent,Vt([Jt,Qt,te],g=>{a=bt(a,g," ")}),s.textContent!==a&&(St(t.removed,{element:s.cloneNode()}),s.textContent=a)),z($.afterSanitizeElements,s,null),!1)},tn=function(s,a,c){if(Fe&&(a==="id"||a==="name")&&(c in e||c in ls))return!1;if(!(ne&&!ee[a]&&M(Qn,a))){if(!(Ue&&M(ts,a))){if(!S[a]||ee[a]){if(!(en(s)&&(_.tagNameCheck instanceof RegExp&&M(_.tagNameCheck,s)||_.tagNameCheck instanceof Function&&_.tagNameCheck(s))&&(_.attributeNameCheck instanceof RegExp&&M(_.attributeNameCheck,a)||_.attributeNameCheck instanceof Function&&_.attributeNameCheck(a))||a==="is"&&_.allowCustomizedBuiltInElements&&(_.tagNameCheck instanceof RegExp&&M(_.tagNameCheck,c)||_.tagNameCheck instanceof Function&&_.tagNameCheck(c))))return!1}else if(!re[a]){if(!M(De,bt(c,Ie,""))){if(!((a==="src"||a==="xlink:href"||a==="href")&&s!=="script"&&Ns(c,"data:")===0&&We[s])){if(!(He&&!M(es,bt(c,Ie,"")))){if(c)return!1}}}}}}return!0},en=function(s){return s!=="annotation-xml"&&$n(s,ns)},nn=function(s){z($.beforeSanitizeAttributes,s,null);let{attributes:a}=s;if(!a||ue(s))return;let c={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:S,forceKeepAttr:void 0},g=a.length;for(;g--;){let b=a[g],{name:A,namespaceURI:L,value:F}=b,ft=v(A),he=F,C=A==="value"?he:Is(he);if(c.attrName=ft,c.attrValue=C,c.keepAttr=!0,c.forceKeepAttr=void 0,z($.uponSanitizeAttribute,s,c),C=c.attrValue,Be&&(ft==="id"||ft==="name")&&(rt(A,s),C=ss+C),xt&&M(/((--!?|])>)|<\/(style|title)/i,C)){rt(A,s);continue}if(c.forceKeepAttr)continue;if(!c.keepAttr){rt(A,s);continue}if(!ze&&M(/\/>/i,C)){rt(A,s);continue}tt&&Vt([Jt,Qt,te],on=>{C=bt(C,on," ")});let sn=v(s.nodeName);if(!tn(sn,ft,C)){rt(A,s);continue}if(w&&typeof R=="object"&&typeof R.getAttributeType=="function"&&!L)switch(R.getAttributeType(sn,ft)){case"TrustedHTML":{C=w.createHTML(C);break}case"TrustedScriptURL":{C=w.createScriptURL(C);break}}if(C!==he)try{L?s.setAttributeNS(L,A,C):s.setAttribute(A,C),ue(s)?k(s):wn(t.removed)}catch{rt(A,s)}}z($.afterSanitizeAttributes,s,null)},us=function u(s){let a=null,c=Ze(s);for(z($.beforeSanitizeShadowDOM,s,null);a=c.nextNode();)z($.uponSanitizeShadowNode,a,null),Qe(a),nn(a),a.content instanceof r&&u(a.content);z($.afterSanitizeShadowDOM,s,null)};return t.sanitize=function(u){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,c=null,g=null,b=null;if(ae=!u,ae&&(u="<!-->"),typeof u!="string"&&!Je(u))if(typeof u.toString=="function"){if(u=u.toString(),typeof u!="string")throw Ct("dirty is not a string, aborting")}else throw Ct("toString is not a function");if(!t.isSupported)return u;if(se||ce(s),t.removed=[],typeof u=="string"&&(pt=!1),pt){if(u.nodeName){let F=v(u.nodeName);if(!T[F]||ht[F])throw Ct("root node is forbidden and cannot be sanitized in-place")}}else if(u instanceof d)a=Xe("<!---->"),c=a.ownerDocument.importNode(u,!0),c.nodeType===$t.element&&c.nodeName==="BODY"||c.nodeName==="HTML"?a=c:a.appendChild(c);else{if(!et&&!tt&&!K&&u.indexOf("<")===-1)return w&&Rt?w.createHTML(u):u;if(a=Xe(u),!a)return et?null:Rt?ut:""}a&&ie&&k(a.firstChild);let A=Ze(pt?u:a);for(;g=A.nextNode();)Qe(g),nn(g),g.content instanceof r&&us(g.content);if(pt)return u;if(et){if(Lt)for(b=Xn.call(a.ownerDocument);a.firstChild;)b.appendChild(a.firstChild);else b=a;return(S.shadowroot||S.shadowrootmode)&&(b=Jn.call(n,b,!0)),b}let L=K?a.outerHTML:a.innerHTML;return K&&T["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&M(kn,a.ownerDocument.doctype.name)&&(L="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
4
+ `+L),tt&&Vt([Jt,Qt,te],F=>{L=bt(L,F," ")}),w&&Rt?w.createHTML(L):L},t.setConfig=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ce(u),se=!0},t.clearConfig=function(){ot=null,se=!1},t.isValidAttribute=function(u,s,a){ot||ce({});let c=v(u),g=v(s);return tn(c,g,a)},t.addHook=function(u,s){typeof s=="function"&&St($[u],s)},t.removeHook=function(u,s){if(s!==void 0){let a=Ls($[u],s);return a===-1?void 0:Rs($[u],a,1)[0]}return wn($[u])},t.removeHooks=function(u){$[u]=[]},t.removeAllHooks=function(){$=Nn()},t}var Hn=Un();function Yt(o,t){let e=document.createElement(o);for(let[n,i]of Object.entries(t)){let r=n.replace(/_/g,"-");i!==null&&e.setAttribute(r,i)}return e}var Y=class extends q{createRenderRoot(){return this}};function Le({headline:o="",message:t,status:e="warning"}){document.dispatchEvent(new CustomEvent("shiny:client-message",{detail:{headline:o,message:t,status:e}}))}async function zn(o){if(window.Shiny&&o)try{await window.Shiny.renderDependenciesAsync(o)}catch(t){Le({status:"error",message:`Failed to render HTML dependencies: ${t}`})}}var Ks=Hn();Ks.addHook("uponSanitizeElement",(o,t)=>{if(o.nodeName&&o.nodeName==="SCRIPT"){let e=o,n=e.getAttribute("type")==="application/json"&&e.getAttribute("data-for")!==null;t.allowedTags.script=n}});var Re="shiny-chat-message",Bn="shiny-user-message",Gn="shiny-chat-messages",Wn="shiny-chat-input",Xs="shiny-chat-container",Fn={robot:'<svg fill="currentColor" class="bi bi-robot" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M6 12.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5M3 8.062C3 6.76 4.235 5.765 5.53 5.886a26.6 26.6 0 0 0 4.94 0C11.765 5.765 13 6.76 13 8.062v1.157a.93.93 0 0 1-.765.935c-.845.147-2.34.346-4.235.346s-3.39-.2-4.235-.346A.93.93 0 0 1 3 9.219zm4.542-.827a.25.25 0 0 0-.217.068l-.92.9a25 25 0 0 1-1.871-.183.25.25 0 0 0-.068.495c.55.076 1.232.149 2.02.193a.25.25 0 0 0 .189-.071l.754-.736.847 1.71a.25.25 0 0 0 .404.062l.932-.97a25 25 0 0 0 1.922-.188.25.25 0 0 0-.068-.495c-.538.074-1.207.145-1.98.189a.25.25 0 0 0-.166.076l-.754.785-.842-1.7a.25.25 0 0 0-.182-.135"/><path d="M8.5 1.866a1 1 0 1 0-1 0V3h-2A4.5 4.5 0 0 0 1 7.5V8a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1v1a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-1a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1v-.5A4.5 4.5 0 0 0 10.5 3h-2zM14 7.5V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.5A3.5 3.5 0 0 1 5.5 4h5A3.5 3.5 0 0 1 14 7.5"/></svg>',dots_fade:'<svg width="24" height="24" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_S1WN{animation:spinner_MGfb .8s linear infinite;animation-delay:-.8s}.spinner_Km9P{animation-delay:-.65s}.spinner_JApP{animation-delay:-.5s}@keyframes spinner_MGfb{93.75%,100%{opacity:.2}}</style><circle class="spinner_S1WN" cx="4" cy="12" r="3"/><circle class="spinner_S1WN spinner_Km9P" cx="12" cy="12" r="3"/><circle class="spinner_S1WN spinner_JApP" cx="20" cy="12" r="3"/></svg>'},Q=class extends Y{constructor(){super(...arguments);this.content="...";this.contentType="markdown";this.streaming=!1;this.icon=""}render(){let n=this.content.trim().length===0?Fn.dots_fade:this.icon||Fn.robot;return ct`
5
+ <div class="message-icon">${Se(n)}</div>
6
+ <shiny-markdown-stream
7
+ content=${this.content}
8
+ content-type=${this.contentType}
9
+ ?streaming=${this.streaming}
10
+ auto-scroll
11
+ .onContentChange=${this.#e.bind(this)}
12
+ .onStreamEnd=${this.#t.bind(this)}
13
+ ></shiny-markdown-stream>
14
+ `}#e(){this.streaming||this.#t()}#t(){this.querySelectorAll(".suggestion,[data-suggestion]").forEach(e=>{if(!(e instanceof HTMLElement)||e.hasAttribute("tabindex"))return;e.setAttribute("tabindex","0"),e.setAttribute("role","button");let n=e.dataset.suggestion||e.textContent;e.setAttribute("aria-label",`Use chat suggestion: ${n}`)})}};B([U()],Q.prototype,"content",2),B([U({attribute:"content-type"})],Q.prototype,"contentType",2),B([U({type:Boolean,reflect:!0})],Q.prototype,"streaming",2),B([U()],Q.prototype,"icon",2);var Kt=class extends Y{constructor(){super(...arguments);this.content="..."}render(){return ct`
15
+ <shiny-markdown-stream
16
+ content=${this.content}
17
+ content-type="semi-markdown"
18
+ ></shiny-markdown-stream>
19
+ `}};B([U()],Kt.prototype,"content",2);var Ne=class extends Y{render(){return ct``}},Mt=class extends Y{constructor(){super(...arguments);this.placeholder="Enter a message...";this._disabled=!1}get disabled(){return this._disabled}set disabled(e){let n=this._disabled;e!==n&&(this._disabled=e,e?this.setAttribute("disabled",""):this.removeAttribute("disabled"),this.requestUpdate("disabled",n),this.#t())}connectedCallback(){super.connectedCallback(),this.inputVisibleObserver=new IntersectionObserver(e=>{e.forEach(n=>{n.isIntersecting&&this.#n()})}),this.inputVisibleObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.inputVisibleObserver?.disconnect(),this.inputVisibleObserver=void 0}attributeChangedCallback(e,n,i){super.attributeChangedCallback(e,n,i),e==="disabled"&&(this.disabled=i!==null)}get textarea(){return this.querySelector("textarea")}get value(){return this.textarea.value}get valueIsEmpty(){return this.value.trim().length===0}get button(){return this.querySelector("button")}render(){return ct`
20
+ <textarea
21
+ id="${this.id}"
22
+ class="form-control"
23
+ rows="1"
24
+ placeholder="${this.placeholder}"
25
+ @keydown=${this.#e}
26
+ @input=${this.#t}
27
+ data-shiny-no-bind-input
28
+ ></textarea>
29
+ <button
30
+ type="button"
31
+ title="Send message"
32
+ aria-label="Send message"
33
+ @click=${this.#s}
34
+ >
35
+ ${Se('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-arrow-up-circle-fill" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 0 0 8a8 8 0 0 0 16 0m-7.5 3.5a.5.5 0 0 1-1 0V5.707L5.354 7.854a.5.5 0 1 1-.708-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 5.707z"/></svg>')}
36
+ </button>
37
+ `}#e(e){e.code==="Enter"&&!e.shiftKey&&!this.valueIsEmpty&&(e.preventDefault(),this.#s())}#t(){this.#n(),this.button.disabled=this.disabled?!0:this.value.trim().length===0}firstUpdated(){this.#t()}#s(e=!0){if(this.valueIsEmpty||this.disabled)return;window.Shiny.setInputValue(this.id,this.value,{priority:"event"});let n=new CustomEvent("shiny-chat-input-sent",{detail:{content:this.value,role:"user"},bubbles:!0,composed:!0});this.dispatchEvent(n),this.setInputValue(""),this.disabled=!0,e&&this.textarea.focus()}#n(){let e=this.textarea;e.scrollHeight!=0&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}setInputValue(e,{submit:n=!1,focus:i=!1}={}){let r=this.textarea.value;this.textarea.value=e;let l=new Event("input",{bubbles:!0,cancelable:!0});this.textarea.dispatchEvent(l),n&&(this.#s(!1),r&&this.setInputValue(r)),i&&this.textarea.focus()}};B([U()],Mt.prototype,"placeholder",2),B([U({type:Boolean})],Mt.prototype,"disabled",1);var Xt=class extends Y{constructor(){super(...arguments);this.iconAssistant=""}get input(){return this.querySelector(Wn)}get messages(){return this.querySelector(Gn)}get lastMessage(){let e=this.messages.lastElementChild;return e||null}render(){return ct``}connectedCallback(){super.connectedCallback();let e=this.querySelector("div");e||(e=Yt("div",{style:"width: 100%; height: 0;"}),this.input.insertAdjacentElement("afterend",e)),this.inputSentinelObserver=new IntersectionObserver(n=>{let i=this.input.querySelector("textarea");if(!i)return;let r=n[0]?.intersectionRatio===0;i.classList.toggle("shadow",r)},{threshold:[0,1],rootMargin:"0px"}),this.inputSentinelObserver.observe(e)}firstUpdated(){this.messages&&(this.addEventListener("shiny-chat-input-sent",this.#e),this.addEventListener("shiny-chat-append-message",this.#t),this.addEventListener("shiny-chat-append-message-chunk",this.#r),this.addEventListener("shiny-chat-clear-messages",this.#a),this.addEventListener("shiny-chat-update-user-input",this.#l),this.addEventListener("shiny-chat-remove-loading-message",this.#p),this.addEventListener("click",this.#c),this.addEventListener("keydown",this.#u))}disconnectedCallback(){super.disconnectedCallback(),this.inputSentinelObserver?.disconnect(),this.inputSentinelObserver=void 0,this.removeEventListener("shiny-chat-input-sent",this.#e),this.removeEventListener("shiny-chat-append-message",this.#t),this.removeEventListener("shiny-chat-append-message-chunk",this.#r),this.removeEventListener("shiny-chat-clear-messages",this.#a),this.removeEventListener("shiny-chat-update-user-input",this.#l),this.removeEventListener("shiny-chat-remove-loading-message",this.#p),this.removeEventListener("click",this.#c),this.removeEventListener("keydown",this.#u)}#e(e){this.#n(e.detail),this.#d()}#t(e){this.#n(e.detail)}#s(){this.#o(),this.input.disabled||(this.input.disabled=!0)}#n(e,n=!0){this.#s();let i=e.role==="user"?Bn:Re;this.iconAssistant&&(e.icon=e.icon||this.iconAssistant);let r=Yt(i,e);this.messages.appendChild(r),n&&this.#i()}#d(){let n=Yt(Re,{content:"",role:"assistant"});this.messages.appendChild(n)}#o(){this.lastMessage?.content||this.lastMessage?.remove()}#r(e){this.#f(e.detail)}#f(e){e.chunk_type==="message_start"&&this.#n(e,!1);let n=this.lastMessage;if(!n)throw new Error("No messages found in the chat output");if(e.chunk_type==="message_start"){n.setAttribute("streaming","");return}let i=e.operation==="append"?n.getAttribute("content")+e.content:e.content;n.setAttribute("content",i),e.chunk_type==="message_end"&&(this.lastMessage?.removeAttribute("streaming"),this.#i())}#a(){this.messages.innerHTML=""}#l(e){let{value:n,placeholder:i,submit:r,focus:l}=e.detail;n!==void 0&&this.input.setInputValue(n,{submit:r,focus:l}),i!==void 0&&(this.input.placeholder=i)}#c(e){this.#h(e)}#u(e){(e.key==="Enter"||e.key===" ")&&this.#h(e)}#h(e){let{suggestion:n,submit:i}=this.#m(e.target);if(!n)return;e.preventDefault();let r=e.metaKey||e.ctrlKey?!0:e.altKey?!1:i;this.input.setInputValue(n,{submit:r,focus:!r})}#m(e){if(!(e instanceof HTMLElement))return{};let n=e.closest(".suggestion, [data-suggestion]");return n instanceof HTMLElement?n.classList.contains("suggestion")||n.dataset.suggestion!==void 0?{suggestion:n.dataset.suggestion||n.textContent||void 0,submit:n.classList.contains("submit")||n.dataset.suggestionSubmit===""||n.dataset.suggestionSubmit==="true"}:{}:{}}#p(){this.#o(),this.#i()}#i(){this.input.disabled=!1}};B([U({attribute:"icon-assistant"})],Xt.prototype,"iconAssistant",2);var Zs=[{tag:Re,component:Q},{tag:Bn,component:Kt},{tag:Gn,component:Ne},{tag:Wn,component:Mt},{tag:Xs,component:Xt}];Zs.forEach(({tag:o,component:t})=>{customElements.get(o)||customElements.define(o,t)});window.Shiny.addCustomMessageHandler("shinyChatMessage",async function(o){o.obj?.html_deps&&await zn(o.obj.html_deps);let t=new CustomEvent(o.handler,{detail:o.obj}),e=document.getElementById(o.id);if(!e){Le({status:"error",message:`Unable to handle Chat() message since element with id
38
+ ${o.id} wasn't found. Do you need to call .ui() (Express) or need a
39
+ chat_ui('${o.id}') in the UI (Core)?
40
+ `});return}e.dispatchEvent(t)});export{Xs as CHAT_CONTAINER_TAG};
41
+ /*! Bundled license information:
42
+
43
+ @lit/reactive-element/css-tag.js:
44
+ (**
45
+ * @license
46
+ * Copyright 2019 Google LLC
47
+ * SPDX-License-Identifier: BSD-3-Clause
48
+ *)
49
+
50
+ @lit/reactive-element/reactive-element.js:
51
+ lit-html/lit-html.js:
52
+ lit-element/lit-element.js:
53
+ lit-html/directive.js:
54
+ lit-html/directives/unsafe-html.js:
55
+ @lit/reactive-element/decorators/custom-element.js:
56
+ @lit/reactive-element/decorators/property.js:
57
+ @lit/reactive-element/decorators/state.js:
58
+ @lit/reactive-element/decorators/event-options.js:
59
+ @lit/reactive-element/decorators/base.js:
60
+ @lit/reactive-element/decorators/query.js:
61
+ @lit/reactive-element/decorators/query-all.js:
62
+ @lit/reactive-element/decorators/query-async.js:
63
+ @lit/reactive-element/decorators/query-assigned-nodes.js:
64
+ (**
65
+ * @license
66
+ * Copyright 2017 Google LLC
67
+ * SPDX-License-Identifier: BSD-3-Clause
68
+ *)
69
+
70
+ lit-html/is-server.js:
71
+ (**
72
+ * @license
73
+ * Copyright 2022 Google LLC
74
+ * SPDX-License-Identifier: BSD-3-Clause
75
+ *)
76
+
77
+ @lit/reactive-element/decorators/query-assigned-elements.js:
78
+ (**
79
+ * @license
80
+ * Copyright 2021 Google LLC
81
+ * SPDX-License-Identifier: BSD-3-Clause
82
+ *)
83
+
84
+ dompurify/dist/purify.es.mjs:
85
+ (*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE *)
86
+ */
87
+ //# sourceMappingURL=chat.js.map