@mulmochat-plugin/quiz 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +99 -36
- package/README.md +99 -36
- package/README.npm.md +39 -5
- package/dist/core/definition.d.ts +6 -0
- package/dist/core/index.d.ts +4 -2
- package/dist/core/plugin.d.ts +2 -4
- package/dist/core/samples.d.ts +5 -0
- package/dist/core/types.d.ts +3 -222
- package/dist/react/Preview.d.ts +8 -0
- package/dist/react/View.d.ts +8 -0
- package/dist/react/index.d.ts +24 -0
- package/dist/react.cjs +8 -0
- package/dist/react.js +398 -0
- package/dist/style.css +1 -1
- package/dist/vue/Preview.vue.d.ts +1 -1
- package/dist/vue/View.vue.d.ts +1 -1
- package/dist/vue/index.d.ts +7 -5
- package/dist/vue.cjs +2 -2
- package/dist/vue.js +7 -6
- package/package.json +35 -6
- package/dist/vue/types.d.ts +0 -32
package/dist/core/types.d.ts
CHANGED
|
@@ -1,227 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Quiz Plugin Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Quiz-specific type definitions only.
|
|
5
|
+
* Common types should be imported directly from gui-chat-protocol.
|
|
5
6
|
*/
|
|
6
|
-
/**
|
|
7
|
-
* Backend types that plugins can declare they use.
|
|
8
|
-
* App layer manages actual provider/model settings for each type.
|
|
9
|
-
*/
|
|
10
|
-
export type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
|
|
11
|
-
/**
|
|
12
|
-
* App interface provided to plugins via context.app
|
|
13
|
-
* Contains backend functions and config accessors
|
|
14
|
-
*/
|
|
15
|
-
export interface ToolContextApp extends Record<string, (...args: any[]) => any> {
|
|
16
|
-
getConfig: <T = unknown>(key: string) => T | undefined;
|
|
17
|
-
setConfig: (key: string, value: unknown) => void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Context passed to plugin execute function
|
|
21
|
-
*/
|
|
22
|
-
export interface ToolContext {
|
|
23
|
-
currentResult?: ToolResult<unknown> | null;
|
|
24
|
-
app?: ToolContextApp;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Result returned from plugin execution
|
|
28
|
-
*/
|
|
29
|
-
export interface ToolResult<T = unknown, J = unknown> {
|
|
30
|
-
toolName?: string;
|
|
31
|
-
uuid?: string;
|
|
32
|
-
message: string;
|
|
33
|
-
title?: string;
|
|
34
|
-
jsonData?: J;
|
|
35
|
-
instructions?: string;
|
|
36
|
-
instructionsRequired?: boolean;
|
|
37
|
-
updating?: boolean;
|
|
38
|
-
cancelled?: boolean;
|
|
39
|
-
data?: T;
|
|
40
|
-
viewState?: Record<string, unknown>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Complete tool result with required fields
|
|
44
|
-
*/
|
|
45
|
-
export interface ToolResultComplete<T = unknown, J = unknown> extends ToolResult<T, J> {
|
|
46
|
-
toolName: string;
|
|
47
|
-
uuid: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* JSON Schema property definition for tool parameters
|
|
51
|
-
*/
|
|
52
|
-
export interface JsonSchemaProperty {
|
|
53
|
-
type?: string;
|
|
54
|
-
description?: string;
|
|
55
|
-
enum?: string[];
|
|
56
|
-
items?: JsonSchemaProperty;
|
|
57
|
-
minimum?: number;
|
|
58
|
-
maximum?: number;
|
|
59
|
-
minItems?: number;
|
|
60
|
-
maxItems?: number;
|
|
61
|
-
properties?: Record<string, JsonSchemaProperty>;
|
|
62
|
-
required?: string[];
|
|
63
|
-
additionalProperties?: boolean;
|
|
64
|
-
oneOf?: JsonSchemaProperty[];
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Tool definition for OpenAI-compatible function calling
|
|
69
|
-
*/
|
|
70
|
-
export interface ToolDefinition {
|
|
71
|
-
type: "function";
|
|
72
|
-
name: string;
|
|
73
|
-
description: string;
|
|
74
|
-
parameters?: {
|
|
75
|
-
type: "object";
|
|
76
|
-
properties: Record<string, JsonSchemaProperty>;
|
|
77
|
-
required: string[];
|
|
78
|
-
additionalProperties?: boolean;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* API response from server start endpoint
|
|
83
|
-
*/
|
|
84
|
-
export interface StartApiResponse {
|
|
85
|
-
hasOpenAIApiKey?: boolean;
|
|
86
|
-
hasAnthropicApiKey?: boolean;
|
|
87
|
-
hasGoogleApiKey?: boolean;
|
|
88
|
-
[key: string]: unknown;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Sample arguments for testing
|
|
92
|
-
*/
|
|
93
|
-
export interface ToolSample {
|
|
94
|
-
name: string;
|
|
95
|
-
args: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* File input handler
|
|
99
|
-
*/
|
|
100
|
-
export interface FileInputHandler {
|
|
101
|
-
type: "file";
|
|
102
|
-
acceptedTypes: string[];
|
|
103
|
-
handleInput: (fileData: string, fileName: string) => ToolResult<unknown, unknown>;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Clipboard image input handler
|
|
107
|
-
*/
|
|
108
|
-
export interface ClipboardImageInputHandler {
|
|
109
|
-
type: "clipboard-image";
|
|
110
|
-
handleInput: (imageData: string) => ToolResult<unknown, unknown>;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* URL input handler
|
|
114
|
-
*/
|
|
115
|
-
export interface UrlInputHandler {
|
|
116
|
-
type: "url";
|
|
117
|
-
patterns?: string[];
|
|
118
|
-
handleInput: (url: string) => ToolResult<unknown, unknown>;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Text input handler
|
|
122
|
-
*/
|
|
123
|
-
export interface TextInputHandler {
|
|
124
|
-
type: "text";
|
|
125
|
-
patterns?: string[];
|
|
126
|
-
handleInput: (text: string) => ToolResult<unknown, unknown>;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Union of all input handler types
|
|
130
|
-
*/
|
|
131
|
-
export type InputHandler = FileInputHandler | ClipboardImageInputHandler | UrlInputHandler | TextInputHandler;
|
|
132
|
-
/**
|
|
133
|
-
* Legacy file upload config (for backward compatibility)
|
|
134
|
-
* @deprecated Use InputHandler instead
|
|
135
|
-
*/
|
|
136
|
-
export interface FileUploadConfig {
|
|
137
|
-
acceptedTypes: string[];
|
|
138
|
-
handleUpload: (fileData: string, fileName: string, ...args: unknown[]) => ToolResult<unknown, unknown>;
|
|
139
|
-
}
|
|
140
|
-
export type ConfigValue = string | number | boolean | string[];
|
|
141
|
-
interface BaseFieldSchema {
|
|
142
|
-
label: string;
|
|
143
|
-
description?: string;
|
|
144
|
-
required?: boolean;
|
|
145
|
-
}
|
|
146
|
-
export interface StringFieldSchema extends BaseFieldSchema {
|
|
147
|
-
type: "string";
|
|
148
|
-
placeholder?: string;
|
|
149
|
-
minLength?: number;
|
|
150
|
-
maxLength?: number;
|
|
151
|
-
pattern?: string;
|
|
152
|
-
}
|
|
153
|
-
export interface NumberFieldSchema extends BaseFieldSchema {
|
|
154
|
-
type: "number";
|
|
155
|
-
min?: number;
|
|
156
|
-
max?: number;
|
|
157
|
-
step?: number;
|
|
158
|
-
}
|
|
159
|
-
export interface BooleanFieldSchema extends BaseFieldSchema {
|
|
160
|
-
type: "boolean";
|
|
161
|
-
}
|
|
162
|
-
export interface SelectOption {
|
|
163
|
-
value: string;
|
|
164
|
-
label: string;
|
|
165
|
-
description?: string;
|
|
166
|
-
disabled?: boolean;
|
|
167
|
-
}
|
|
168
|
-
export interface SelectFieldSchema extends BaseFieldSchema {
|
|
169
|
-
type: "select";
|
|
170
|
-
options: SelectOption[];
|
|
171
|
-
}
|
|
172
|
-
export interface MultiSelectFieldSchema extends BaseFieldSchema {
|
|
173
|
-
type: "multiselect";
|
|
174
|
-
options: SelectOption[];
|
|
175
|
-
minItems?: number;
|
|
176
|
-
maxItems?: number;
|
|
177
|
-
}
|
|
178
|
-
export type ConfigFieldSchema = StringFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema | MultiSelectFieldSchema;
|
|
179
|
-
/**
|
|
180
|
-
* Plugin configuration schema (JSON Schema based)
|
|
181
|
-
*/
|
|
182
|
-
export interface PluginConfigSchema {
|
|
183
|
-
key: string;
|
|
184
|
-
defaultValue: ConfigValue;
|
|
185
|
-
schema: ConfigFieldSchema;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Standard props for View components
|
|
189
|
-
*/
|
|
190
|
-
export interface ViewComponentProps<T = unknown, J = unknown> {
|
|
191
|
-
selectedResult: ToolResultComplete<T, J>;
|
|
192
|
-
sendTextMessage: (text?: string) => void;
|
|
193
|
-
onUpdateResult?: (result: Partial<ToolResult<T, J>>) => void;
|
|
194
|
-
pluginConfigs?: Record<string, unknown>;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Standard props for Preview components
|
|
198
|
-
*/
|
|
199
|
-
export interface PreviewComponentProps<T = unknown, J = unknown> {
|
|
200
|
-
result: ToolResultComplete<T, J>;
|
|
201
|
-
isSelected?: boolean;
|
|
202
|
-
onSelect?: () => void;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Core plugin interface - framework agnostic
|
|
206
|
-
* Does not include UI components
|
|
207
|
-
*/
|
|
208
|
-
export interface ToolPluginCore<T = unknown, J = unknown, A extends object = object> {
|
|
209
|
-
toolDefinition: ToolDefinition;
|
|
210
|
-
execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
|
|
211
|
-
generatingMessage: string;
|
|
212
|
-
waitingMessage?: string;
|
|
213
|
-
uploadMessage?: string;
|
|
214
|
-
isEnabled: (startResponse?: StartApiResponse | null) => boolean;
|
|
215
|
-
delayAfterExecution?: number;
|
|
216
|
-
systemPrompt?: string;
|
|
217
|
-
inputHandlers?: InputHandler[];
|
|
218
|
-
/** @deprecated Use inputHandlers instead */
|
|
219
|
-
fileUpload?: FileUploadConfig;
|
|
220
|
-
/** New JSON Schema based config (framework-agnostic) */
|
|
221
|
-
configSchema?: PluginConfigSchema;
|
|
222
|
-
samples?: ToolSample[];
|
|
223
|
-
backends?: BackendType[];
|
|
224
|
-
}
|
|
225
7
|
/** Single quiz question */
|
|
226
8
|
export interface QuizQuestion {
|
|
227
9
|
question: string;
|
|
@@ -239,4 +21,3 @@ export interface QuizArgs {
|
|
|
239
21
|
title?: string;
|
|
240
22
|
questions: QuizQuestion[];
|
|
241
23
|
}
|
|
242
|
-
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quiz Preview Component (React)
|
|
3
|
+
*/
|
|
4
|
+
import type { PreviewComponentProps } from "gui-chat-protocol";
|
|
5
|
+
import type { QuizData } from "../core/types";
|
|
6
|
+
type PreviewProps = PreviewComponentProps<never, QuizData>;
|
|
7
|
+
export declare function Preview({ result }: PreviewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export default Preview;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quiz View Component (React)
|
|
3
|
+
*/
|
|
4
|
+
import type { ViewComponentProps } from "gui-chat-protocol";
|
|
5
|
+
import type { QuizData } from "../core/types";
|
|
6
|
+
type ViewProps = ViewComponentProps<never, QuizData>;
|
|
7
|
+
export declare function View({ selectedResult, sendTextMessage, onUpdateResult }: ViewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export default View;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Quiz Plugin - React Implementation
|
|
3
|
+
*
|
|
4
|
+
* Full React plugin with UI components.
|
|
5
|
+
* Import from "@mulmochat-plugin/quiz/react"
|
|
6
|
+
*/
|
|
7
|
+
import "../style.css";
|
|
8
|
+
import type { ToolPluginReact } from "gui-chat-protocol/react";
|
|
9
|
+
import type { QuizData, QuizArgs } from "../core/types";
|
|
10
|
+
import { View } from "./View";
|
|
11
|
+
import { Preview } from "./Preview";
|
|
12
|
+
/**
|
|
13
|
+
* Quiz plugin instance with React components
|
|
14
|
+
*/
|
|
15
|
+
export declare const plugin: ToolPluginReact<never, QuizData, QuizArgs>;
|
|
16
|
+
export type { QuizQuestion, QuizData, QuizArgs } from "../core/types";
|
|
17
|
+
export { pluginCore, executeQuiz } from "../core/plugin";
|
|
18
|
+
export { TOOL_NAME, TOOL_DEFINITION } from "../core/definition";
|
|
19
|
+
export { SAMPLES } from "../core/samples";
|
|
20
|
+
export { View, Preview };
|
|
21
|
+
declare const _default: {
|
|
22
|
+
plugin: ToolPluginReact<never, QuizData, QuizArgs, import("gui-chat-protocol/react").InputHandler, Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});;/* empty css */const h=require("./core.cjs"),w=require("react");var S={exports:{}},g={};var W;function ae(){if(W)return g;W=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function x(l,d,u){var p=null;if(u!==void 0&&(p=""+u),d.key!==void 0&&(p=""+d.key),"key"in d){u={};for(var v in d)v!=="key"&&(u[v]=d[v])}else u=d;return d=u.ref,{$$typeof:i,type:l,key:p,ref:d!==void 0?d:null,props:u}}return g.Fragment=c,g.jsx=x,g.jsxs=x,g}var T={};var Q;function oe(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case b:return"Fragment";case k:return"Profiler";case y:return"StrictMode";case Z:return"Suspense";case K:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case m:return"Portal";case H:return e.displayName||"Context";case P:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:i(e.type)||"Memo";case C:r=e._payload,e=e._init;try{return i(e(r))}catch{}}return null}function c(e){return""+e}function x(e){try{c(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),c(e)}}function l(e){if(e===b)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===C)return"<...>";try{var r=i(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function d(){var e=$.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function p(e){if(L.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function v(e,r){function n(){M||(M=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function O(){var e=i(this.type);return F[e]||(F[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function j(e,r,n,a,A,D){var o=n.ref;return e={$$typeof:f,type:e,key:r,props:n,_owner:a},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:O}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function _(e,r,n,a,A,D){var o=r.children;if(o!==void 0)if(a)if(ne(o)){for(a=0;a<o.length;a++)N(o[a]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(o);if(L.call(r,"key")){o=i(e);var E=Object.keys(r).filter(function(se){return se!=="key"});a=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",V[o+a]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,a,o,E,o),V[o+a]=!0)}if(o=null,n!==void 0&&(x(n),o=""+n),p(r)&&(x(r.key),o=""+r.key),"key"in r){n={};for(var Y in r)Y!=="key"&&(n[Y]=r[Y])}else n=r;return o&&v(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),j(e,o,n,d(),A,D)}function N(e){R(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===C&&(e._payload.status==="fulfilled"?R(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function R(e){return typeof e=="object"&&e!==null&&e.$$typeof===f}var s=w,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),H=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),$=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,ne=Array.isArray,q=console.createTask?console.createTask:function(){return null};s={react_stack_bottom_frame:function(e){return e()}};var M,F={},z=s.react_stack_bottom_frame.bind(s,u)(),I=q(l(u)),V={};T.Fragment=b,T.jsx=function(e,r,n){var a=1e4>$.recentlyCreatedOwnerStacks++;return _(e,r,n,!1,a?Error("react-stack-top-frame"):z,a?q(l(e)):I)},T.jsxs=function(e,r,n){var a=1e4>$.recentlyCreatedOwnerStacks++;return _(e,r,n,!0,a?Error("react-stack-top-frame"):z,a?q(l(e)):I)}})()),T}var U;function le(){return U||(U=1,process.env.NODE_ENV==="production"?S.exports=ae():S.exports=oe()),S.exports}var t=le();function J({selectedResult:i,sendTextMessage:c,onUpdateResult:x}){const[l,d]=w.useState(null),[u,p]=w.useState([]);w.useEffect(()=>{if(i?.toolName===h.TOOL_NAME&&i.jsonData){const s=i.jsonData;d(s),i.viewState?.userAnswers?p(i.viewState.userAnswers):p(new Array(s.questions.length).fill(null))}},[i]);const v=w.useCallback(s=>{p(s),x&&x({viewState:{userAnswers:s}})},[x]),O=(s,f)=>{const m=[...u];m[s]=f,v(m)},j=u.filter(s=>s!==null).length,_=l&&j===l.questions.length,N=(s,f)=>u[s]===f?"border-blue-500 bg-blue-500/20":"border-[#4b4b6b] hover:border-[#6b6b8b] hover:bg-[#6b6b8b]/20",R=()=>{if(!l||!_)return;const f=`Here are my answers:
|
|
7
|
+
${u.map((m,b)=>{if(m===null)return null;const y=b+1,k=String.fromCharCode(65+m),P=l.questions[b].choices[m];return`Q${y}: ${k} - ${P}`}).filter(m=>m!==null).join(`
|
|
8
|
+
`)}`;c(f)};return l?t.jsx("div",{className:"w-full min-h-[400px] overflow-y-auto p-8 bg-[#1a1a2e] rounded-lg",children:t.jsxs("div",{className:"max-w-3xl mx-auto",children:[l.title&&t.jsx("h2",{className:"text-[#f0f0f0] text-3xl font-bold mb-8 text-center",children:l.title}),t.jsx("div",{className:"flex flex-col gap-6",children:l.questions.map((s,f)=>t.jsxs("div",{className:"bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]",children:[t.jsxs("div",{className:"text-white text-lg font-semibold mb-4",children:[t.jsxs("span",{className:"text-blue-400 mr-2",children:[f+1,"."]}),s.question]}),t.jsx("div",{className:"flex flex-col gap-3",children:s.choices.map((m,b)=>t.jsxs("label",{className:`flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2 ${N(f,b)}`,children:[t.jsx("input",{type:"radio",name:`question-${f}`,value:b,checked:u[f]===b,onChange:()=>O(f,b),className:"mt-1 mr-3 size-4 shrink-0"}),t.jsxs("span",{className:"text-white flex-1",children:[t.jsxs("span",{className:"font-semibold mr-2",children:[String.fromCharCode(65+b),"."]}),m]})]},b))})]},f))}),t.jsx("div",{className:"mt-8 flex justify-center",children:t.jsx("button",{onClick:R,disabled:!_,className:`py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer ${_?"bg-blue-600 hover:bg-blue-700":"bg-gray-600 cursor-not-allowed opacity-50"}`,children:"Submit Answers"})}),t.jsxs("div",{className:"mt-4 text-center text-gray-400 text-sm",children:[j," / ",l.questions.length," questions answered"]})]})}):null}function G({result:i}){const c=i.jsonData;return c?t.jsx("div",{className:"p-3 bg-blue-50 rounded-md",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-800 text-center",children:c.title||"Quiz"}),t.jsx("div",{className:"text-center",children:t.jsxs("span",{className:"inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full",children:[c.questions.length," ",c.questions.length===1?"Question":"Questions"]})}),t.jsx("div",{className:"text-xs text-gray-600 overflow-hidden line-clamp-2",children:c.questions[0]?.question}),t.jsxs("div",{className:"flex justify-center gap-1",children:[Array.from({length:Math.min(c.questions[0]?.choices.length||0,4)}).map((x,l)=>t.jsx("div",{className:"size-2 bg-gray-400 rounded-full"},l)),(c.questions[0]?.choices.length||0)>4&&t.jsxs("span",{className:"text-xs text-gray-500",children:["+",c.questions[0].choices.length-4]})]})]})}):null}const X={...h.pluginCore,ViewComponent:J,PreviewComponent:G},ie={plugin:X};exports.SAMPLES=h.SAMPLES;exports.TOOL_DEFINITION=h.TOOL_DEFINITION;exports.TOOL_NAME=h.TOOL_NAME;exports.executeQuiz=h.executeQuiz;exports.pluginCore=h.pluginCore;exports.Preview=G;exports.View=J;exports.default=ie;exports.plugin=X;
|