@jspsych/plugin-survey-multi-choice 1.1.3 → 2.0.1

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.
@@ -1,267 +1,241 @@
1
1
  var jsPsychSurveyMultiChoice = (function (jspsych) {
2
2
  'use strict';
3
3
 
4
+ var version = "2.0.1";
5
+
4
6
  const info = {
5
- name: "survey-multi-choice",
6
- parameters: {
7
- /** Array containing one or more objects with parameters for the question(s) that should be shown on the page. */
8
- questions: {
9
- type: jspsych.ParameterType.COMPLEX,
10
- array: true,
11
- pretty_name: "Questions",
12
- nested: {
13
- /** Question prompt. */
14
- prompt: {
15
- type: jspsych.ParameterType.HTML_STRING,
16
- pretty_name: "Prompt",
17
- default: undefined,
18
- },
19
- /** Array of multiple choice options for this question. */
20
- options: {
21
- type: jspsych.ParameterType.STRING,
22
- pretty_name: "Options",
23
- array: true,
24
- default: undefined,
25
- },
26
- /** Whether or not a response to this question must be given in order to continue. */
27
- required: {
28
- type: jspsych.ParameterType.BOOL,
29
- pretty_name: "Required",
30
- default: false,
31
- },
32
- /** If true, then the question will be centered and options will be displayed horizontally. */
33
- horizontal: {
34
- type: jspsych.ParameterType.BOOL,
35
- pretty_name: "Horizontal",
36
- default: false,
37
- },
38
- /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
39
- name: {
40
- type: jspsych.ParameterType.STRING,
41
- pretty_name: "Question Name",
42
- default: "",
43
- },
44
- },
45
- },
46
- /** If true, the order of the questions in the 'questions' array will be randomized. */
47
- randomize_question_order: {
48
- type: jspsych.ParameterType.BOOL,
49
- pretty_name: "Randomize Question Order",
50
- default: false,
7
+ name: "survey-multi-choice",
8
+ version,
9
+ parameters: {
10
+ /**
11
+ * An array of objects, each object represents a question that appears on the screen. Each object contains a prompt,
12
+ * options, required, and horizontal parameter that will be applied to the question. See examples below for further
13
+ * clarification.`prompt`: Type string, default value is *undefined*. The string is prompt/question that will be
14
+ * associated with a group of options (radio buttons). All questions will get presented on the same page (trial).
15
+ * `options`: Type array, defualt value is *undefined*. An array of strings. The array contains a set of options to
16
+ * display for an individual question.`required`: Type boolean, default value is null. The boolean value indicates
17
+ * if a question is required('true') or not ('false'), using the HTML5 `required` attribute. If this parameter is
18
+ * undefined, the question will be optional. `horizontal`:Type boolean, default value is false. If true, then the
19
+ * question is centered and the options are displayed horizontally. `name`: Name of the question. Used for storing
20
+ * data. If left undefined then default names (`Q0`, `Q1`, `...`) will be used for the questions.
21
+ */
22
+ questions: {
23
+ type: jspsych.ParameterType.COMPLEX,
24
+ array: true,
25
+ nested: {
26
+ /** Question prompt. */
27
+ prompt: {
28
+ type: jspsych.ParameterType.HTML_STRING,
29
+ default: void 0
51
30
  },
52
- /** HTML-formatted string to display at top of the page above all of the questions. */
53
- preamble: {
54
- type: jspsych.ParameterType.HTML_STRING,
55
- pretty_name: "Preamble",
56
- default: null,
31
+ /** Array of multiple choice options for this question. */
32
+ options: {
33
+ type: jspsych.ParameterType.STRING,
34
+ array: true,
35
+ default: void 0
57
36
  },
58
- /** Label of the button to submit responses. */
59
- button_label: {
60
- type: jspsych.ParameterType.STRING,
61
- pretty_name: "Button label",
62
- default: "Continue",
37
+ /** Whether or not a response to this question must be given in order to continue. */
38
+ required: {
39
+ type: jspsych.ParameterType.BOOL,
40
+ default: false
63
41
  },
64
- /** Setting this to true will enable browser auto-complete or auto-fill for the form. */
65
- autocomplete: {
66
- type: jspsych.ParameterType.BOOL,
67
- pretty_name: "Allow autocomplete",
68
- default: false,
42
+ /** If true, then the question will be centered and options will be displayed horizontally. */
43
+ horizontal: {
44
+ type: jspsych.ParameterType.BOOL,
45
+ default: false
69
46
  },
47
+ /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
48
+ name: {
49
+ type: jspsych.ParameterType.STRING,
50
+ default: ""
51
+ }
52
+ }
53
+ },
54
+ /**
55
+ * If true, the display order of `questions` is randomly determined at the start of the trial. In the data object,
56
+ * `Q0` will still refer to the first question in the array, regardless of where it was presented visually.
57
+ */
58
+ randomize_question_order: {
59
+ type: jspsych.ParameterType.BOOL,
60
+ default: false
61
+ },
62
+ /** HTML formatted string to display at the top of the page above all the questions. */
63
+ preamble: {
64
+ type: jspsych.ParameterType.HTML_STRING,
65
+ default: null
66
+ },
67
+ /** Label of the button. */
68
+ button_label: {
69
+ type: jspsych.ParameterType.STRING,
70
+ default: "Continue"
70
71
  },
72
+ /**
73
+ * This determines whether or not all of the input elements on the page should allow autocomplete. Setting
74
+ * this to true will enable autocomplete or auto-fill for the form.
75
+ */
76
+ autocomplete: {
77
+ type: jspsych.ParameterType.BOOL,
78
+ default: false
79
+ }
80
+ },
81
+ data: {
82
+ /** An object containing the response for each question. The object will have a separate key (variable) for each question, with the first question in the trial being recorded in `Q0`, the second in `Q1`, and so on. The responses are recorded as integers, representing the position selected on the likert scale for that question. If the `name` parameter is defined for the question, then the response object will use the value of `name` as the key for each question. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */
83
+ response: {
84
+ type: jspsych.ParameterType.OBJECT
85
+ },
86
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the questions first appear on the screen until the participant's response(s) are submitted. */
87
+ rt: {
88
+ type: jspsych.ParameterType.INT
89
+ },
90
+ /** An array with the order of questions. For example `[2,0,1]` would indicate that the first question was `trial.questions[2]` (the third item in the `questions` parameter), the second question was `trial.questions[0]`, and the final question was `trial.questions[1]`. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */
91
+ question_order: {
92
+ type: jspsych.ParameterType.INT,
93
+ array: true
94
+ }
95
+ }
71
96
  };
72
- /**
73
- * **survey-multi-choice**
74
- *
75
- * jsPsych plugin for presenting multiple choice survey questions
76
- *
77
- * @author Shane Martin
78
- * @see {@link https://www.jspsych.org/plugins/jspsych-survey-multi-choice/ survey-multi-choice plugin documentation on jspsych.org}
79
- */
80
97
  class SurveyMultiChoicePlugin {
81
- constructor(jsPsych) {
82
- this.jsPsych = jsPsych;
98
+ constructor(jsPsych) {
99
+ this.jsPsych = jsPsych;
100
+ }
101
+ static {
102
+ this.info = info;
103
+ }
104
+ trial(display_element, trial) {
105
+ var plugin_id_name = "jspsych-survey-multi-choice";
106
+ var html = "";
107
+ html += '<style id="jspsych-survey-multi-choice-css">';
108
+ html += ".jspsych-survey-multi-choice-question { margin-top: 2em; margin-bottom: 2em; text-align: left; }.jspsych-survey-multi-choice-text span.required {color: darkred;}.jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-text { text-align: center;}.jspsych-survey-multi-choice-option { line-height: 2; }.jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-option { display: inline-block; margin-left: 1em; margin-right: 1em; vertical-align: top;}label.jspsych-survey-multi-choice-text input[type='radio'] {margin-right: 1em;}";
109
+ html += "</style>";
110
+ if (trial.preamble !== null) {
111
+ html += '<div id="jspsych-survey-multi-choice-preamble" class="jspsych-survey-multi-choice-preamble">' + trial.preamble + "</div>";
83
112
  }
84
- trial(display_element, trial) {
85
- var plugin_id_name = "jspsych-survey-multi-choice";
86
- var html = "";
87
- // inject CSS for trial
88
- html += '<style id="jspsych-survey-multi-choice-css">';
89
- html +=
90
- ".jspsych-survey-multi-choice-question { margin-top: 2em; margin-bottom: 2em; text-align: left; }" +
91
- ".jspsych-survey-multi-choice-text span.required {color: darkred;}" +
92
- ".jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-text { text-align: center;}" +
93
- ".jspsych-survey-multi-choice-option { line-height: 2; }" +
94
- ".jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-option { display: inline-block; margin-left: 1em; margin-right: 1em; vertical-align: top;}" +
95
- "label.jspsych-survey-multi-choice-text input[type='radio'] {margin-right: 1em;}";
96
- html += "</style>";
97
- // show preamble text
98
- if (trial.preamble !== null) {
99
- html +=
100
- '<div id="jspsych-survey-multi-choice-preamble" class="jspsych-survey-multi-choice-preamble">' +
101
- trial.preamble +
102
- "</div>";
103
- }
104
- // form element
105
- if (trial.autocomplete) {
106
- html += '<form id="jspsych-survey-multi-choice-form">';
107
- }
108
- else {
109
- html += '<form id="jspsych-survey-multi-choice-form" autocomplete="off">';
110
- }
111
- // generate question order. this is randomized here as opposed to randomizing the order of trial.questions
112
- // so that the data are always associated with the same question regardless of order
113
- var question_order = [];
114
- for (var i = 0; i < trial.questions.length; i++) {
115
- question_order.push(i);
116
- }
117
- if (trial.randomize_question_order) {
118
- question_order = this.jsPsych.randomization.shuffle(question_order);
119
- }
120
- // add multiple-choice questions
121
- for (var i = 0; i < trial.questions.length; i++) {
122
- // get question based on question_order
123
- var question = trial.questions[question_order[i]];
124
- var question_id = question_order[i];
125
- // create question container
126
- var question_classes = ["jspsych-survey-multi-choice-question"];
127
- if (question.horizontal) {
128
- question_classes.push("jspsych-survey-multi-choice-horizontal");
129
- }
130
- html +=
131
- '<div id="jspsych-survey-multi-choice-' +
132
- question_id +
133
- '" class="' +
134
- question_classes.join(" ") +
135
- '" data-name="' +
136
- question.name +
137
- '">';
138
- // add question text
139
- html += '<p class="jspsych-survey-multi-choice-text survey-multi-choice">' + question.prompt;
140
- if (question.required) {
141
- html += "<span class='required'>*</span>";
142
- }
143
- html += "</p>";
144
- // create option radio buttons
145
- for (var j = 0; j < question.options.length; j++) {
146
- // add label and question text
147
- var option_id_name = "jspsych-survey-multi-choice-option-" + question_id + "-" + j;
148
- var input_name = "jspsych-survey-multi-choice-response-" + question_id;
149
- var input_id = "jspsych-survey-multi-choice-response-" + question_id + "-" + j;
150
- var required_attr = question.required ? "required" : "";
151
- // add radio button container
152
- html += '<div id="' + option_id_name + '" class="jspsych-survey-multi-choice-option">';
153
- html += '<label class="jspsych-survey-multi-choice-text" for="' + input_id + '">';
154
- html +=
155
- '<input type="radio" name="' +
156
- input_name +
157
- '" id="' +
158
- input_id +
159
- '" value="' +
160
- question.options[j] +
161
- '" ' +
162
- required_attr +
163
- "></input>";
164
- html += question.options[j] + "</label>";
165
- html += "</div>";
166
- }
167
- html += "</div>";
168
- }
169
- // add submit button
170
- html +=
171
- '<input type="submit" id="' +
172
- plugin_id_name +
173
- '-next" class="' +
174
- plugin_id_name +
175
- ' jspsych-btn"' +
176
- (trial.button_label ? ' value="' + trial.button_label + '"' : "") +
177
- "></input>";
178
- html += "</form>";
179
- // render
180
- display_element.innerHTML = html;
181
- document.querySelector("form").addEventListener("submit", (event) => {
182
- event.preventDefault();
183
- // measure response time
184
- var endTime = performance.now();
185
- var response_time = Math.round(endTime - startTime);
186
- // create object to hold responses
187
- var question_data = {};
188
- for (var i = 0; i < trial.questions.length; i++) {
189
- var match = display_element.querySelector("#jspsych-survey-multi-choice-" + i);
190
- var id = "Q" + i;
191
- var val;
192
- if (match.querySelector("input[type=radio]:checked") !== null) {
193
- val = match.querySelector("input[type=radio]:checked").value;
194
- }
195
- else {
196
- val = "";
197
- }
198
- var obje = {};
199
- var name = id;
200
- if (match.attributes["data-name"].value !== "") {
201
- name = match.attributes["data-name"].value;
202
- }
203
- obje[name] = val;
204
- Object.assign(question_data, obje);
205
- }
206
- // save data
207
- var trial_data = {
208
- rt: response_time,
209
- response: question_data,
210
- question_order: question_order,
211
- };
212
- display_element.innerHTML = "";
213
- // next trial
214
- this.jsPsych.finishTrial(trial_data);
215
- });
216
- var startTime = performance.now();
113
+ if (trial.autocomplete) {
114
+ html += '<form id="jspsych-survey-multi-choice-form">';
115
+ } else {
116
+ html += '<form id="jspsych-survey-multi-choice-form" autocomplete="off">';
217
117
  }
218
- simulate(trial, simulation_mode, simulation_options, load_callback) {
219
- if (simulation_mode == "data-only") {
220
- load_callback();
221
- this.simulate_data_only(trial, simulation_options);
118
+ var question_order = [];
119
+ for (var i = 0; i < trial.questions.length; i++) {
120
+ question_order.push(i);
121
+ }
122
+ if (trial.randomize_question_order) {
123
+ question_order = this.jsPsych.randomization.shuffle(question_order);
124
+ }
125
+ for (var i = 0; i < trial.questions.length; i++) {
126
+ var question = trial.questions[question_order[i]];
127
+ var question_id = question_order[i];
128
+ var question_classes = ["jspsych-survey-multi-choice-question"];
129
+ if (question.horizontal) {
130
+ question_classes.push("jspsych-survey-multi-choice-horizontal");
131
+ }
132
+ html += '<div id="jspsych-survey-multi-choice-' + question_id + '" class="' + question_classes.join(" ") + '" data-name="' + question.name + '">';
133
+ html += '<p class="jspsych-survey-multi-choice-text survey-multi-choice">' + question.prompt;
134
+ if (question.required) {
135
+ html += "<span class='required'>*</span>";
136
+ }
137
+ html += "</p>";
138
+ for (var j = 0; j < question.options.length; j++) {
139
+ var option_id_name = "jspsych-survey-multi-choice-option-" + question_id + "-" + j;
140
+ var input_name = "jspsych-survey-multi-choice-response-" + question_id;
141
+ var input_id = "jspsych-survey-multi-choice-response-" + question_id + "-" + j;
142
+ var required_attr = question.required ? "required" : "";
143
+ html += '<div id="' + option_id_name + '" class="jspsych-survey-multi-choice-option">';
144
+ html += '<label class="jspsych-survey-multi-choice-text" for="' + input_id + '">';
145
+ html += '<input type="radio" name="' + input_name + '" id="' + input_id + '" value="' + question.options[j] + '" ' + required_attr + "></input>";
146
+ html += question.options[j] + "</label>";
147
+ html += "</div>";
148
+ }
149
+ html += "</div>";
150
+ }
151
+ html += '<input type="submit" id="' + plugin_id_name + '-next" class="' + plugin_id_name + ' jspsych-btn"' + (trial.button_label ? ' value="' + trial.button_label + '"' : "") + "></input>";
152
+ html += "</form>";
153
+ display_element.innerHTML = html;
154
+ document.querySelector("form").addEventListener("submit", (event) => {
155
+ event.preventDefault();
156
+ var endTime = performance.now();
157
+ var response_time = Math.round(endTime - startTime);
158
+ var question_data = {};
159
+ for (var i2 = 0; i2 < trial.questions.length; i2++) {
160
+ var match = display_element.querySelector("#jspsych-survey-multi-choice-" + i2);
161
+ var id = "Q" + i2;
162
+ var val;
163
+ if (match.querySelector("input[type=radio]:checked") !== null) {
164
+ val = match.querySelector("input[type=radio]:checked").value;
165
+ } else {
166
+ val = "";
222
167
  }
223
- if (simulation_mode == "visual") {
224
- this.simulate_visual(trial, simulation_options, load_callback);
168
+ var obje = {};
169
+ var name = id;
170
+ if (match.attributes["data-name"].value !== "") {
171
+ name = match.attributes["data-name"].value;
225
172
  }
173
+ obje[name] = val;
174
+ Object.assign(question_data, obje);
175
+ }
176
+ var trial_data = {
177
+ rt: response_time,
178
+ response: question_data,
179
+ question_order
180
+ };
181
+ this.jsPsych.finishTrial(trial_data);
182
+ });
183
+ var startTime = performance.now();
184
+ }
185
+ simulate(trial, simulation_mode, simulation_options, load_callback) {
186
+ if (simulation_mode == "data-only") {
187
+ load_callback();
188
+ this.simulate_data_only(trial, simulation_options);
226
189
  }
227
- create_simulation_data(trial, simulation_options) {
228
- const question_data = {};
229
- let rt = 1000;
230
- for (const q of trial.questions) {
231
- const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;
232
- question_data[name] = this.jsPsych.randomization.sampleWithoutReplacement(q.options, 1)[0];
233
- rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);
234
- }
235
- const default_data = {
236
- response: question_data,
237
- rt: rt,
238
- question_order: trial.randomize_question_order
239
- ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()])
240
- : [...Array(trial.questions.length).keys()],
241
- };
242
- const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);
243
- this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);
244
- return data;
190
+ if (simulation_mode == "visual") {
191
+ this.simulate_visual(trial, simulation_options, load_callback);
245
192
  }
246
- simulate_data_only(trial, simulation_options) {
247
- const data = this.create_simulation_data(trial, simulation_options);
248
- this.jsPsych.finishTrial(data);
193
+ }
194
+ create_simulation_data(trial, simulation_options) {
195
+ const question_data = {};
196
+ let rt = 1e3;
197
+ for (const q of trial.questions) {
198
+ const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;
199
+ question_data[name] = this.jsPsych.randomization.sampleWithoutReplacement(q.options, 1)[0];
200
+ rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);
249
201
  }
250
- simulate_visual(trial, simulation_options, load_callback) {
251
- const data = this.create_simulation_data(trial, simulation_options);
252
- const display_element = this.jsPsych.getDisplayElement();
253
- this.trial(display_element, trial);
254
- load_callback();
255
- const answers = Object.entries(data.response);
256
- for (let i = 0; i < answers.length; i++) {
257
- this.jsPsych.pluginAPI.clickTarget(display_element.querySelector(`#jspsych-survey-multi-choice-response-${i}-${trial.questions[i].options.indexOf(answers[i][1])}`), ((data.rt - 1000) / answers.length) * (i + 1));
258
- }
259
- this.jsPsych.pluginAPI.clickTarget(display_element.querySelector("#jspsych-survey-multi-choice-next"), data.rt);
202
+ const default_data = {
203
+ response: question_data,
204
+ rt,
205
+ question_order: trial.randomize_question_order ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()]) : [...Array(trial.questions.length).keys()]
206
+ };
207
+ const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);
208
+ this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);
209
+ return data;
210
+ }
211
+ simulate_data_only(trial, simulation_options) {
212
+ const data = this.create_simulation_data(trial, simulation_options);
213
+ this.jsPsych.finishTrial(data);
214
+ }
215
+ simulate_visual(trial, simulation_options, load_callback) {
216
+ const data = this.create_simulation_data(trial, simulation_options);
217
+ const display_element = this.jsPsych.getDisplayElement();
218
+ this.trial(display_element, trial);
219
+ load_callback();
220
+ const answers = Object.entries(data.response);
221
+ for (let i = 0; i < answers.length; i++) {
222
+ this.jsPsych.pluginAPI.clickTarget(
223
+ display_element.querySelector(
224
+ `#jspsych-survey-multi-choice-response-${i}-${trial.questions[i].options.indexOf(
225
+ answers[i][1]
226
+ )}`
227
+ ),
228
+ (data.rt - 1e3) / answers.length * (i + 1)
229
+ );
260
230
  }
231
+ this.jsPsych.pluginAPI.clickTarget(
232
+ display_element.querySelector("#jspsych-survey-multi-choice-next"),
233
+ data.rt
234
+ );
235
+ }
261
236
  }
262
- SurveyMultiChoicePlugin.info = info;
263
237
 
264
238
  return SurveyMultiChoicePlugin;
265
239
 
266
240
  })(jsPsychModule);
267
- //# sourceMappingURL=https://unpkg.com/@jspsych/plugin-survey-multi-choice@1.1.3/dist/index.browser.js.map
241
+ //# sourceMappingURL=https://unpkg.com/@jspsych/plugin-survey-multi-choice@2.0.1/dist/index.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.js","sources":["../src/index.ts"],"sourcesContent":["import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from \"jspsych\";\n\nconst info = <const>{\n name: \"survey-multi-choice\",\n parameters: {\n /** Array containing one or more objects with parameters for the question(s) that should be shown on the page. */\n questions: {\n type: ParameterType.COMPLEX,\n array: true,\n pretty_name: \"Questions\",\n nested: {\n /** Question prompt. */\n prompt: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Prompt\",\n default: undefined,\n },\n /** Array of multiple choice options for this question. */\n options: {\n type: ParameterType.STRING,\n pretty_name: \"Options\",\n array: true,\n default: undefined,\n },\n /** Whether or not a response to this question must be given in order to continue. */\n required: {\n type: ParameterType.BOOL,\n pretty_name: \"Required\",\n default: false,\n },\n /** If true, then the question will be centered and options will be displayed horizontally. */\n horizontal: {\n type: ParameterType.BOOL,\n pretty_name: \"Horizontal\",\n default: false,\n },\n /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */\n name: {\n type: ParameterType.STRING,\n pretty_name: \"Question Name\",\n default: \"\",\n },\n },\n },\n /** If true, the order of the questions in the 'questions' array will be randomized. */\n randomize_question_order: {\n type: ParameterType.BOOL,\n pretty_name: \"Randomize Question Order\",\n default: false,\n },\n /** HTML-formatted string to display at top of the page above all of the questions. */\n preamble: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Preamble\",\n default: null,\n },\n /** Label of the button to submit responses. */\n button_label: {\n type: ParameterType.STRING,\n pretty_name: \"Button label\",\n default: \"Continue\",\n },\n /** Setting this to true will enable browser auto-complete or auto-fill for the form. */\n autocomplete: {\n type: ParameterType.BOOL,\n pretty_name: \"Allow autocomplete\",\n default: false,\n },\n },\n};\n\ntype Info = typeof info;\n\n/**\n * **survey-multi-choice**\n *\n * jsPsych plugin for presenting multiple choice survey questions\n *\n * @author Shane Martin\n * @see {@link https://www.jspsych.org/plugins/jspsych-survey-multi-choice/ survey-multi-choice plugin documentation on jspsych.org}\n */\nclass SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {\n static info = info;\n\n constructor(private jsPsych: JsPsych) {}\n\n trial(display_element: HTMLElement, trial: TrialType<Info>) {\n var plugin_id_name = \"jspsych-survey-multi-choice\";\n\n var html = \"\";\n\n // inject CSS for trial\n html += '<style id=\"jspsych-survey-multi-choice-css\">';\n html +=\n \".jspsych-survey-multi-choice-question { margin-top: 2em; margin-bottom: 2em; text-align: left; }\" +\n \".jspsych-survey-multi-choice-text span.required {color: darkred;}\" +\n \".jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-text { text-align: center;}\" +\n \".jspsych-survey-multi-choice-option { line-height: 2; }\" +\n \".jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-option { display: inline-block; margin-left: 1em; margin-right: 1em; vertical-align: top;}\" +\n \"label.jspsych-survey-multi-choice-text input[type='radio'] {margin-right: 1em;}\";\n html += \"</style>\";\n\n // show preamble text\n if (trial.preamble !== null) {\n html +=\n '<div id=\"jspsych-survey-multi-choice-preamble\" class=\"jspsych-survey-multi-choice-preamble\">' +\n trial.preamble +\n \"</div>\";\n }\n\n // form element\n if (trial.autocomplete) {\n html += '<form id=\"jspsych-survey-multi-choice-form\">';\n } else {\n html += '<form id=\"jspsych-survey-multi-choice-form\" autocomplete=\"off\">';\n }\n // generate question order. this is randomized here as opposed to randomizing the order of trial.questions\n // so that the data are always associated with the same question regardless of order\n var question_order = [];\n for (var i = 0; i < trial.questions.length; i++) {\n question_order.push(i);\n }\n if (trial.randomize_question_order) {\n question_order = this.jsPsych.randomization.shuffle(question_order);\n }\n\n // add multiple-choice questions\n for (var i = 0; i < trial.questions.length; i++) {\n // get question based on question_order\n var question = trial.questions[question_order[i]];\n var question_id = question_order[i];\n\n // create question container\n var question_classes = [\"jspsych-survey-multi-choice-question\"];\n if (question.horizontal) {\n question_classes.push(\"jspsych-survey-multi-choice-horizontal\");\n }\n\n html +=\n '<div id=\"jspsych-survey-multi-choice-' +\n question_id +\n '\" class=\"' +\n question_classes.join(\" \") +\n '\" data-name=\"' +\n question.name +\n '\">';\n\n // add question text\n html += '<p class=\"jspsych-survey-multi-choice-text survey-multi-choice\">' + question.prompt;\n if (question.required) {\n html += \"<span class='required'>*</span>\";\n }\n html += \"</p>\";\n\n // create option radio buttons\n for (var j = 0; j < question.options.length; j++) {\n // add label and question text\n var option_id_name = \"jspsych-survey-multi-choice-option-\" + question_id + \"-\" + j;\n var input_name = \"jspsych-survey-multi-choice-response-\" + question_id;\n var input_id = \"jspsych-survey-multi-choice-response-\" + question_id + \"-\" + j;\n\n var required_attr = question.required ? \"required\" : \"\";\n\n // add radio button container\n html += '<div id=\"' + option_id_name + '\" class=\"jspsych-survey-multi-choice-option\">';\n html += '<label class=\"jspsych-survey-multi-choice-text\" for=\"' + input_id + '\">';\n html +=\n '<input type=\"radio\" name=\"' +\n input_name +\n '\" id=\"' +\n input_id +\n '\" value=\"' +\n question.options[j] +\n '\" ' +\n required_attr +\n \"></input>\";\n html += question.options[j] + \"</label>\";\n html += \"</div>\";\n }\n\n html += \"</div>\";\n }\n\n // add submit button\n html +=\n '<input type=\"submit\" id=\"' +\n plugin_id_name +\n '-next\" class=\"' +\n plugin_id_name +\n ' jspsych-btn\"' +\n (trial.button_label ? ' value=\"' + trial.button_label + '\"' : \"\") +\n \"></input>\";\n html += \"</form>\";\n\n // render\n display_element.innerHTML = html;\n\n document.querySelector(\"form\").addEventListener(\"submit\", (event) => {\n event.preventDefault();\n // measure response time\n var endTime = performance.now();\n var response_time = Math.round(endTime - startTime);\n\n // create object to hold responses\n var question_data = {};\n for (var i = 0; i < trial.questions.length; i++) {\n var match = display_element.querySelector(\"#jspsych-survey-multi-choice-\" + i);\n var id = \"Q\" + i;\n var val: String;\n if (match.querySelector(\"input[type=radio]:checked\") !== null) {\n val = match.querySelector<HTMLInputElement>(\"input[type=radio]:checked\").value;\n } else {\n val = \"\";\n }\n var obje = {};\n var name = id;\n if (match.attributes[\"data-name\"].value !== \"\") {\n name = match.attributes[\"data-name\"].value;\n }\n obje[name] = val;\n Object.assign(question_data, obje);\n }\n // save data\n var trial_data = {\n rt: response_time,\n response: question_data,\n question_order: question_order,\n };\n display_element.innerHTML = \"\";\n\n // next trial\n this.jsPsych.finishTrial(trial_data);\n });\n\n var startTime = performance.now();\n }\n\n simulate(\n trial: TrialType<Info>,\n simulation_mode,\n simulation_options: any,\n load_callback: () => void\n ) {\n if (simulation_mode == \"data-only\") {\n load_callback();\n this.simulate_data_only(trial, simulation_options);\n }\n if (simulation_mode == \"visual\") {\n this.simulate_visual(trial, simulation_options, load_callback);\n }\n }\n\n private create_simulation_data(trial: TrialType<Info>, simulation_options) {\n const question_data = {};\n let rt = 1000;\n\n for (const q of trial.questions) {\n const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;\n question_data[name] = this.jsPsych.randomization.sampleWithoutReplacement(q.options, 1)[0];\n rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);\n }\n\n const default_data = {\n response: question_data,\n rt: rt,\n question_order: trial.randomize_question_order\n ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()])\n : [...Array(trial.questions.length).keys()],\n };\n\n const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);\n\n this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);\n\n return data;\n }\n\n private simulate_data_only(trial: TrialType<Info>, simulation_options) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n this.jsPsych.finishTrial(data);\n }\n\n private simulate_visual(trial: TrialType<Info>, simulation_options, load_callback: () => void) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n const display_element = this.jsPsych.getDisplayElement();\n\n this.trial(display_element, trial);\n load_callback();\n\n const answers = Object.entries(data.response);\n for (let i = 0; i < answers.length; i++) {\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\n `#jspsych-survey-multi-choice-response-${i}-${trial.questions[i].options.indexOf(\n answers[i][1]\n )}`\n ),\n ((data.rt - 1000) / answers.length) * (i + 1)\n );\n }\n\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\"#jspsych-survey-multi-choice-next\"),\n data.rt\n );\n }\n}\n\nexport default SurveyMultiChoicePlugin;\n"],"names":["ParameterType"],"mappings":";;;EAEA,MAAM,IAAI,GAAU;EAClB,IAAA,IAAI,EAAE,qBAAqB;EAC3B,IAAA,UAAU,EAAE;;EAEV,QAAA,SAAS,EAAE;cACT,IAAI,EAAEA,qBAAa,CAAC,OAAO;EAC3B,YAAA,KAAK,EAAE,IAAI;EACX,YAAA,WAAW,EAAE,WAAW;EACxB,YAAA,MAAM,EAAE;;EAEN,gBAAA,MAAM,EAAE;sBACN,IAAI,EAAEA,qBAAa,CAAC,WAAW;EAC/B,oBAAA,WAAW,EAAE,QAAQ;EACrB,oBAAA,OAAO,EAAE,SAAS;EACnB,iBAAA;;EAED,gBAAA,OAAO,EAAE;sBACP,IAAI,EAAEA,qBAAa,CAAC,MAAM;EAC1B,oBAAA,WAAW,EAAE,SAAS;EACtB,oBAAA,KAAK,EAAE,IAAI;EACX,oBAAA,OAAO,EAAE,SAAS;EACnB,iBAAA;;EAED,gBAAA,QAAQ,EAAE;sBACR,IAAI,EAAEA,qBAAa,CAAC,IAAI;EACxB,oBAAA,WAAW,EAAE,UAAU;EACvB,oBAAA,OAAO,EAAE,KAAK;EACf,iBAAA;;EAED,gBAAA,UAAU,EAAE;sBACV,IAAI,EAAEA,qBAAa,CAAC,IAAI;EACxB,oBAAA,WAAW,EAAE,YAAY;EACzB,oBAAA,OAAO,EAAE,KAAK;EACf,iBAAA;;EAED,gBAAA,IAAI,EAAE;sBACJ,IAAI,EAAEA,qBAAa,CAAC,MAAM;EAC1B,oBAAA,WAAW,EAAE,eAAe;EAC5B,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,CAAC,QAAQ,CAAC,CAAC;EAC9C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;cACvC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAChC,eAAe,CAAC,aAAa,CAC3B,CAAyC,sCAAA,EAAA,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAC9E,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACd,CAAE,CAAA,CACJ,EACD,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAC9C,CAAC;EACH,SAAA;EAED,QAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAChC,eAAe,CAAC,aAAa,CAAC,mCAAmC,CAAC,EAClE,IAAI,CAAC,EAAE,CACR,CAAC;OACH;;EAjOM,uBAAI,CAAA,IAAA,GAAG,IAAI;;;;;;;;"}
1
+ {"version":3,"file":"index.browser.js","sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@jspsych/plugin-survey-multi-choice\",\n \"version\": \"2.0.1\",\n \"description\": \"a jspsych plugin for multiple choice survey questions\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"exports\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"typings\": \"dist/index.d.ts\",\n \"unpkg\": \"dist/index.browser.min.js\",\n \"files\": [\n \"src\",\n \"dist\"\n ],\n \"source\": \"src/index.ts\",\n \"scripts\": {\n \"test\": \"jest\",\n \"test:watch\": \"npm test -- --watch\",\n \"tsc\": \"tsc\",\n \"build\": \"rollup --config\",\n \"build:watch\": \"npm run build -- --watch\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/jspsych/jsPsych.git\",\n \"directory\": \"packages/plugin-survey-multi-choice\"\n },\n \"author\": \"Shane Martin\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/jspsych/jsPsych/issues\"\n },\n \"homepage\": \"https://www.jspsych.org/latest/plugins/survey-multi-choice\",\n \"peerDependencies\": {\n \"jspsych\": \">=7.1.0\"\n },\n \"devDependencies\": {\n \"@jspsych/config\": \"^3.1.1\",\n \"@jspsych/test-utils\": \"^1.2.0\"\n }\n}\n","import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from \"jspsych\";\n\nimport { version } from \"../package.json\";\n\nconst info = <const>{\n name: \"survey-multi-choice\",\n version: version,\n parameters: {\n /**\n * An array of objects, each object represents a question that appears on the screen. Each object contains a prompt,\n * options, required, and horizontal parameter that will be applied to the question. See examples below for further\n * clarification.`prompt`: Type string, default value is *undefined*. The string is prompt/question that will be\n * associated with a group of options (radio buttons). All questions will get presented on the same page (trial).\n * `options`: Type array, defualt value is *undefined*. An array of strings. The array contains a set of options to\n * display for an individual question.`required`: Type boolean, default value is null. The boolean value indicates\n * if a question is required('true') or not ('false'), using the HTML5 `required` attribute. If this parameter is\n * undefined, the question will be optional. `horizontal`:Type boolean, default value is false. If true, then the\n * question is centered and the options are displayed horizontally. `name`: Name of the question. Used for storing\n * data. If left undefined then default names (`Q0`, `Q1`, `...`) will be used for the questions.\n */\n questions: {\n type: ParameterType.COMPLEX,\n array: true,\n nested: {\n /** Question prompt. */\n prompt: {\n type: ParameterType.HTML_STRING,\n default: undefined,\n },\n /** Array of multiple choice options for this question. */\n options: {\n type: ParameterType.STRING,\n array: true,\n default: undefined,\n },\n /** Whether or not a response to this question must be given in order to continue. */\n required: {\n type: ParameterType.BOOL,\n default: false,\n },\n /** If true, then the question will be centered and options will be displayed horizontally. */\n horizontal: {\n type: ParameterType.BOOL,\n default: false,\n },\n /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */\n name: {\n type: ParameterType.STRING,\n default: \"\",\n },\n },\n },\n /**\n * If true, the display order of `questions` is randomly determined at the start of the trial. In the data object,\n * `Q0` will still refer to the first question in the array, regardless of where it was presented visually.\n */\n randomize_question_order: {\n type: ParameterType.BOOL,\n default: false,\n },\n /** HTML formatted string to display at the top of the page above all the questions. */\n preamble: {\n type: ParameterType.HTML_STRING,\n default: null,\n },\n /** Label of the button. */\n button_label: {\n type: ParameterType.STRING,\n default: \"Continue\",\n },\n /**\n * This determines whether or not all of the input elements on the page should allow autocomplete. Setting\n * this to true will enable autocomplete or auto-fill for the form.\n */\n autocomplete: {\n type: ParameterType.BOOL,\n default: false,\n },\n },\n data: {\n /** An object containing the response for each question. The object will have a separate key (variable) for each question, with the first question in the trial being recorded in `Q0`, the second in `Q1`, and so on. The responses are recorded as integers, representing the position selected on the likert scale for that question. If the `name` parameter is defined for the question, then the response object will use the value of `name` as the key for each question. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */\n response: {\n type: ParameterType.OBJECT,\n },\n /** The response time in milliseconds for the participant to make a response. The time is measured from when the questions first appear on the screen until the participant's response(s) are submitted. */\n rt: {\n type: ParameterType.INT,\n },\n /** An array with the order of questions. For example `[2,0,1]` would indicate that the first question was `trial.questions[2]` (the third item in the `questions` parameter), the second question was `trial.questions[0]`, and the final question was `trial.questions[1]`. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */\n question_order: {\n type: ParameterType.INT,\n array: true,\n },\n },\n};\n\ntype Info = typeof info;\n\n/**\n * **survey-multi-choice**\n *\n * The survey-multi-choice plugin displays a set of questions with multiple choice response fields. The participant selects a single answer.\n *\n * @author Shane Martin\n * @see {@link https://www.jspsych.org/latest/plugins/survey-multi-choice/ survey-multi-choice plugin documentation on jspsych.org}\n */\nclass SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {\n static info = info;\n\n constructor(private jsPsych: JsPsych) {}\n\n trial(display_element: HTMLElement, trial: TrialType<Info>) {\n var plugin_id_name = \"jspsych-survey-multi-choice\";\n\n var html = \"\";\n\n // inject CSS for trial\n html += '<style id=\"jspsych-survey-multi-choice-css\">';\n html +=\n \".jspsych-survey-multi-choice-question { margin-top: 2em; margin-bottom: 2em; text-align: left; }\" +\n \".jspsych-survey-multi-choice-text span.required {color: darkred;}\" +\n \".jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-text { text-align: center;}\" +\n \".jspsych-survey-multi-choice-option { line-height: 2; }\" +\n \".jspsych-survey-multi-choice-horizontal .jspsych-survey-multi-choice-option { display: inline-block; margin-left: 1em; margin-right: 1em; vertical-align: top;}\" +\n \"label.jspsych-survey-multi-choice-text input[type='radio'] {margin-right: 1em;}\";\n html += \"</style>\";\n\n // show preamble text\n if (trial.preamble !== null) {\n html +=\n '<div id=\"jspsych-survey-multi-choice-preamble\" class=\"jspsych-survey-multi-choice-preamble\">' +\n trial.preamble +\n \"</div>\";\n }\n\n // form element\n if (trial.autocomplete) {\n html += '<form id=\"jspsych-survey-multi-choice-form\">';\n } else {\n html += '<form id=\"jspsych-survey-multi-choice-form\" autocomplete=\"off\">';\n }\n // generate question order. this is randomized here as opposed to randomizing the order of trial.questions\n // so that the data are always associated with the same question regardless of order\n var question_order = [];\n for (var i = 0; i < trial.questions.length; i++) {\n question_order.push(i);\n }\n if (trial.randomize_question_order) {\n question_order = this.jsPsych.randomization.shuffle(question_order);\n }\n\n // add multiple-choice questions\n for (var i = 0; i < trial.questions.length; i++) {\n // get question based on question_order\n var question = trial.questions[question_order[i]];\n var question_id = question_order[i];\n\n // create question container\n var question_classes = [\"jspsych-survey-multi-choice-question\"];\n if (question.horizontal) {\n question_classes.push(\"jspsych-survey-multi-choice-horizontal\");\n }\n\n html +=\n '<div id=\"jspsych-survey-multi-choice-' +\n question_id +\n '\" class=\"' +\n question_classes.join(\" \") +\n '\" data-name=\"' +\n question.name +\n '\">';\n\n // add question text\n html += '<p class=\"jspsych-survey-multi-choice-text survey-multi-choice\">' + question.prompt;\n if (question.required) {\n html += \"<span class='required'>*</span>\";\n }\n html += \"</p>\";\n\n // create option radio buttons\n for (var j = 0; j < question.options.length; j++) {\n // add label and question text\n var option_id_name = \"jspsych-survey-multi-choice-option-\" + question_id + \"-\" + j;\n var input_name = \"jspsych-survey-multi-choice-response-\" + question_id;\n var input_id = \"jspsych-survey-multi-choice-response-\" + question_id + \"-\" + j;\n\n var required_attr = question.required ? \"required\" : \"\";\n\n // add radio button container\n html += '<div id=\"' + option_id_name + '\" class=\"jspsych-survey-multi-choice-option\">';\n html += '<label class=\"jspsych-survey-multi-choice-text\" for=\"' + input_id + '\">';\n html +=\n '<input type=\"radio\" name=\"' +\n input_name +\n '\" id=\"' +\n input_id +\n '\" value=\"' +\n question.options[j] +\n '\" ' +\n required_attr +\n \"></input>\";\n html += question.options[j] + \"</label>\";\n html += \"</div>\";\n }\n\n html += \"</div>\";\n }\n\n // add submit button\n html +=\n '<input type=\"submit\" id=\"' +\n plugin_id_name +\n '-next\" class=\"' +\n plugin_id_name +\n ' jspsych-btn\"' +\n (trial.button_label ? ' value=\"' + trial.button_label + '\"' : \"\") +\n \"></input>\";\n html += \"</form>\";\n\n // render\n display_element.innerHTML = html;\n\n document.querySelector(\"form\").addEventListener(\"submit\", (event) => {\n event.preventDefault();\n // measure response time\n var endTime = performance.now();\n var response_time = Math.round(endTime - startTime);\n\n // create object to hold responses\n var question_data = {};\n for (var i = 0; i < trial.questions.length; i++) {\n var match = display_element.querySelector(\"#jspsych-survey-multi-choice-\" + i);\n var id = \"Q\" + i;\n var val: String;\n if (match.querySelector(\"input[type=radio]:checked\") !== null) {\n val = match.querySelector<HTMLInputElement>(\"input[type=radio]:checked\").value;\n } else {\n val = \"\";\n }\n var obje = {};\n var name = id;\n if (match.attributes[\"data-name\"].value !== \"\") {\n name = match.attributes[\"data-name\"].value;\n }\n obje[name] = val;\n Object.assign(question_data, obje);\n }\n // save data\n var trial_data = {\n rt: response_time,\n response: question_data,\n question_order: question_order,\n };\n\n // next trial\n this.jsPsych.finishTrial(trial_data);\n });\n\n var startTime = performance.now();\n }\n\n simulate(\n trial: TrialType<Info>,\n simulation_mode,\n simulation_options: any,\n load_callback: () => void\n ) {\n if (simulation_mode == \"data-only\") {\n load_callback();\n this.simulate_data_only(trial, simulation_options);\n }\n if (simulation_mode == \"visual\") {\n this.simulate_visual(trial, simulation_options, load_callback);\n }\n }\n\n private create_simulation_data(trial: TrialType<Info>, simulation_options) {\n const question_data = {};\n let rt = 1000;\n\n for (const q of trial.questions) {\n const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;\n question_data[name] = this.jsPsych.randomization.sampleWithoutReplacement(q.options, 1)[0];\n rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);\n }\n\n const default_data = {\n response: question_data,\n rt: rt,\n question_order: trial.randomize_question_order\n ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()])\n : [...Array(trial.questions.length).keys()],\n };\n\n const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);\n\n this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);\n\n return data;\n }\n\n private simulate_data_only(trial: TrialType<Info>, simulation_options) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n this.jsPsych.finishTrial(data);\n }\n\n private simulate_visual(trial: TrialType<Info>, simulation_options, load_callback: () => void) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n const display_element = this.jsPsych.getDisplayElement();\n\n this.trial(display_element, trial);\n load_callback();\n\n const answers = Object.entries(data.response);\n for (let i = 0; i < answers.length; i++) {\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\n `#jspsych-survey-multi-choice-response-${i}-${trial.questions[i].options.indexOf(\n answers[i][1]\n )}`\n ),\n ((data.rt - 1000) / answers.length) * (i + 1)\n );\n }\n\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\"#jspsych-survey-multi-choice-next\"),\n data.rt\n );\n }\n}\n\nexport default SurveyMultiChoicePlugin;\n"],"names":["ParameterType","i"],"mappings":";;;EAEE,IAAW,OAAA,GAAA,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