@drincs/nqtr 0.8.1 → 1.0.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.
@@ -0,0 +1,270 @@
1
+ import { R as RoomInterface, h as LocationInterface, M as MapInterface, Q as QuestInterface, C as CommitmentInterface, c as ActiveScheduling } from './StageInterface-BN_O8nDA.js';
2
+ import { RoomIdType, CommitmentIdType } from '@drincs/nqtr/registries';
3
+ import { OnRunProps } from '@drincs/nqtr';
4
+ import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
5
+
6
+ type TimeSlotInterface = {
7
+ name: string;
8
+ startTime: number;
9
+ };
10
+ /**
11
+ * Time Settings, which can be set using {@link timeTracker.editSettings}
12
+ */
13
+ type TimeSettings = {
14
+ /**
15
+ * Minimum time of the day
16
+ * @default 0
17
+ */
18
+ dayStartTime?: number;
19
+ /**
20
+ * Maximum time of the day
21
+ * @default 24
22
+ */
23
+ dayEndTime?: number;
24
+ /**
25
+ * Default time spent
26
+ * @default 1
27
+ */
28
+ defaultTimeSpent?: number;
29
+ /**
30
+ * Time slots
31
+ * @default []
32
+ * @example
33
+ * ```ts
34
+ * [
35
+ * { name: 'Morning', startTime: 5 },
36
+ * { name: 'Afternoon', startTime: 12 },
37
+ * { name: 'Evening', startTime: 18 },
38
+ * { name: 'Night', startTime: 22 }
39
+ * ]
40
+ */
41
+ timeSlots?: TimeSlotInterface[];
42
+ /**
43
+ * Week length
44
+ * @default 7
45
+ */
46
+ weekLength?: number;
47
+ /**
48
+ * Weekend start day. For example, if the real life weekend starts on Saturday, then the value should be 6
49
+ * @default weekLength - 1
50
+ */
51
+ weekendStartDay?: number;
52
+ /**
53
+ * Week days name
54
+ * @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
55
+ * @returns The name of the week day.
56
+ * @example
57
+ * ```ts
58
+ * (weekDayNumber: number) => {
59
+ * const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
60
+ * return weekDaysNames[weekDayNumber];
61
+ * }
62
+ * ```
63
+ */
64
+ getDayName?: (weekDayNumber: number) => string;
65
+ };
66
+
67
+ declare class NavigatorHandler {
68
+ get rooms(): RoomInterface[];
69
+ get locations(): LocationInterface[];
70
+ get maps(): MapInterface[];
71
+ get currentRoomId(): string | undefined;
72
+ get currentRoom(): RoomInterface | undefined;
73
+ set currentRoom(room: RoomInterface | RoomIdType);
74
+ get currentLocation(): LocationInterface | undefined;
75
+ get currentMap(): MapInterface | undefined;
76
+ /**
77
+ * Clear all the expired activities.
78
+ */
79
+ clearExpiredActivities(): void;
80
+ }
81
+
82
+ declare class QuestHandler {
83
+ /**
84
+ * The quests registered in the game.
85
+ */
86
+ get quests(): QuestInterface[];
87
+ /**
88
+ * The quests that are started, so they are in progress or completed or failed.
89
+ */
90
+ get startedQuests(): QuestInterface[];
91
+ /**
92
+ * The quests that are in progress.
93
+ */
94
+ get inProgressQuests(): QuestInterface[];
95
+ /**
96
+ * The quests that are completed.
97
+ */
98
+ get completedQuests(): QuestInterface[];
99
+ /**
100
+ * The quests that are failed.
101
+ */
102
+ get failedQuests(): QuestInterface[];
103
+ /**
104
+ * The quests that are not started.
105
+ */
106
+ get notStartedQuests(): QuestInterface[];
107
+ /**
108
+ * Get the quest by the id.
109
+ * @param id The id of the quest.
110
+ * @returns The quest with the id.
111
+ */
112
+ find(id: string): QuestInterface | undefined;
113
+ /**
114
+ * Start the quests that must start on the current stage.
115
+ */
116
+ startsStageMustBeStarted(props: OnRunProps): Promise<void>;
117
+ }
118
+
119
+ declare class RoutineHandler {
120
+ /**
121
+ * Get the temporary commitments by its id.
122
+ * @returns The temporary commitments.
123
+ */
124
+ private get temporaryRoutine();
125
+ get commitmentsIds(): string[];
126
+ /**
127
+ * This feature adds the commitments during the game session.
128
+ * @param commitment The commitment or commitments to add.
129
+ * @param roomId The id of the room where the commitment is.
130
+ */
131
+ add(commitment: (CommitmentInterface | CommitmentIdType)[] | CommitmentInterface | CommitmentIdType, roomId: string, options?: ActiveScheduling): void;
132
+ /**
133
+ * Get the commitments added during the game session.
134
+ * @param id The id of the commitment.
135
+ * @returns The commitment or undefined if not found.
136
+ */
137
+ find(id: string): CommitmentInterface | undefined;
138
+ /**
139
+ * Remove the commitments added during the game session.
140
+ * @param commitment The commitment or commitment id to remove.
141
+ * @param roomId The id of the room where the commitment is.
142
+ */
143
+ remove(commitment: CommitmentInterface | CommitmentIdType, roomId?: string): void;
144
+ /**
145
+ * Clear all the expired commitments.
146
+ */
147
+ clearExpiredRoutine(): void;
148
+ get characterCommitments(): {
149
+ [character: string]: [CommitmentInterface, string];
150
+ };
151
+ /**
152
+ * Get the current commitments. The hidden commitments are not included.
153
+ * In case there is a character who has two or more commitments at the same time, will be selected the commitment with the highest priority.
154
+ * Higher priority commitments are calculated using the following steps:
155
+ * 1. The commitments that have Commitments BaseModel.priority set to a higher value will be selected first.
156
+ * 2. If there are commitments with the same priority, the commitments that are not fixed will be selected first.
157
+ * 3. If there are commitments with the same priority and the same fixed status, priority will be given to the commitment with a lower index.
158
+ * @returns The current commitments.
159
+ */
160
+ get currentRoutine(): CommitmentInterface[];
161
+ get roomCommitments(): {
162
+ [roomId: string]: CommitmentInterface[];
163
+ };
164
+ /**
165
+ * Get the character commitment.
166
+ * @param character The character.
167
+ * @returns The commitment or undefined if not found.
168
+ */
169
+ getCommitmentByCharacter(character: CharacterInterface | CharacterIdType): CommitmentInterface | undefined;
170
+ }
171
+
172
+ declare class TimeHandler {
173
+ initialize(settings: TimeSettings): void;
174
+ get dayStartTime(): number;
175
+ get dayEndTime(): number;
176
+ get defaultTimeSpent(): number;
177
+ get timeSlots(): TimeSlotInterface[];
178
+ get weekLength(): number;
179
+ get weekendStartDay(): number;
180
+ /**
181
+ * Week days name
182
+ * @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
183
+ * @returns The name of the week day.
184
+ * @example
185
+ * ```ts
186
+ * (weekDayNumber: number) => {
187
+ * const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
188
+ * return weekDaysNames[weekDayNumber];
189
+ * }
190
+ * ```
191
+ */
192
+ get getDayName(): ((weekDayNumber: number) => string) | undefined;
193
+ /**
194
+ * Get the current time. Time is a numeric variable used to determine and manage time during a day/date.
195
+ * It's recommended to use currentTime as if it were the current time. If you also want to manage minutes, you can use a float value.
196
+ */
197
+ get currentTime(): number;
198
+ set currentTime(value: number | undefined);
199
+ /**
200
+ * Get the current date. Date is a numeric variable used to determine and manage the number of days passed.
201
+ * It's recommended to use currentDate as if it were the current day.
202
+ */
203
+ get currentDate(): number;
204
+ set currentDate(value: number | undefined);
205
+ /**
206
+ * If the current day is greater than or equal to the weekend start day, then it will return true.
207
+ */
208
+ get isWeekend(): boolean;
209
+ /**
210
+ * Get the current week day number (from: 1 - to: {@link weekLength}).
211
+ * For example, if the week length is 7 and the current day is 10, then the result will be 4.
212
+ */
213
+ get currentWeekDayNumber(): number;
214
+ /**
215
+ * Get the current week day name. If the week days names are not defined, then it will return undefined.
216
+ * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
217
+ * @default ""
218
+ */
219
+ get currentDayName(): string;
220
+ /**
221
+ * Get the current {@link timeSlots} index.
222
+ * You can use this property to create "Image that changes based on the time period":
223
+ * @example
224
+ * ```tsx
225
+ * import { weekLength } from '@drincs/nqtr';
226
+ *
227
+ * function changeBackground() {
228
+ * return (
229
+ * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />
230
+ * )
231
+ * }
232
+ */
233
+ get currentTimeSlot(): number;
234
+ /**
235
+ * This function will increase the current time by the given time spent.
236
+ * If the new time is greater than or equal to the max day times, then it will increase the day and set the new time.
237
+ * @param delta is the time spent in times (default: {@link defaultTimeSpent})
238
+ * @returns currentTimeSlot.currentTime
239
+ */
240
+ increaseTime(delta?: number): number;
241
+ /**
242
+ * This function will increase the current date by the given delta.
243
+ * @param delta is the number of days to increase (default: 1)
244
+ * @param time is the time of the new day (default: {@link dayStartTime})
245
+ * @returns timeTracker.currentDate
246
+ */
247
+ increaseDate(delta?: number, time?: number): number;
248
+ /**
249
+ * This function will check if the current time is between the given times.
250
+ * @param fromTime the starting time. If the {@link currentTime} is equal to this time, the function will return true.
251
+ * @param toTime the ending time.
252
+ * @returns true if the current time is between the given times, otherwise false.
253
+ */
254
+ nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
255
+ }
256
+
257
+ declare const timeTracker: TimeHandler;
258
+ declare const navigator: NavigatorHandler;
259
+ declare const routine: RoutineHandler;
260
+ declare const questsNotebook: QuestHandler;
261
+
262
+ declare const handlers_navigator: typeof navigator;
263
+ declare const handlers_questsNotebook: typeof questsNotebook;
264
+ declare const handlers_routine: typeof routine;
265
+ declare const handlers_timeTracker: typeof timeTracker;
266
+ declare namespace handlers {
267
+ export { handlers_navigator as navigator, handlers_questsNotebook as questsNotebook, handlers_routine as routine, handlers_timeTracker as timeTracker };
268
+ }
269
+
270
+ export { type TimeSlotInterface as T, type TimeSettings as a, handlers as h, navigator as n, questsNotebook as q, routine as r, timeTracker as t };
@@ -0,0 +1,270 @@
1
+ import { R as RoomInterface, h as LocationInterface, M as MapInterface, Q as QuestInterface, C as CommitmentInterface, c as ActiveScheduling } from './StageInterface-BN_O8nDA.mjs';
2
+ import { RoomIdType, CommitmentIdType } from '@drincs/nqtr/registries';
3
+ import { OnRunProps } from '@drincs/nqtr';
4
+ import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
5
+
6
+ type TimeSlotInterface = {
7
+ name: string;
8
+ startTime: number;
9
+ };
10
+ /**
11
+ * Time Settings, which can be set using {@link timeTracker.editSettings}
12
+ */
13
+ type TimeSettings = {
14
+ /**
15
+ * Minimum time of the day
16
+ * @default 0
17
+ */
18
+ dayStartTime?: number;
19
+ /**
20
+ * Maximum time of the day
21
+ * @default 24
22
+ */
23
+ dayEndTime?: number;
24
+ /**
25
+ * Default time spent
26
+ * @default 1
27
+ */
28
+ defaultTimeSpent?: number;
29
+ /**
30
+ * Time slots
31
+ * @default []
32
+ * @example
33
+ * ```ts
34
+ * [
35
+ * { name: 'Morning', startTime: 5 },
36
+ * { name: 'Afternoon', startTime: 12 },
37
+ * { name: 'Evening', startTime: 18 },
38
+ * { name: 'Night', startTime: 22 }
39
+ * ]
40
+ */
41
+ timeSlots?: TimeSlotInterface[];
42
+ /**
43
+ * Week length
44
+ * @default 7
45
+ */
46
+ weekLength?: number;
47
+ /**
48
+ * Weekend start day. For example, if the real life weekend starts on Saturday, then the value should be 6
49
+ * @default weekLength - 1
50
+ */
51
+ weekendStartDay?: number;
52
+ /**
53
+ * Week days name
54
+ * @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
55
+ * @returns The name of the week day.
56
+ * @example
57
+ * ```ts
58
+ * (weekDayNumber: number) => {
59
+ * const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
60
+ * return weekDaysNames[weekDayNumber];
61
+ * }
62
+ * ```
63
+ */
64
+ getDayName?: (weekDayNumber: number) => string;
65
+ };
66
+
67
+ declare class NavigatorHandler {
68
+ get rooms(): RoomInterface[];
69
+ get locations(): LocationInterface[];
70
+ get maps(): MapInterface[];
71
+ get currentRoomId(): string | undefined;
72
+ get currentRoom(): RoomInterface | undefined;
73
+ set currentRoom(room: RoomInterface | RoomIdType);
74
+ get currentLocation(): LocationInterface | undefined;
75
+ get currentMap(): MapInterface | undefined;
76
+ /**
77
+ * Clear all the expired activities.
78
+ */
79
+ clearExpiredActivities(): void;
80
+ }
81
+
82
+ declare class QuestHandler {
83
+ /**
84
+ * The quests registered in the game.
85
+ */
86
+ get quests(): QuestInterface[];
87
+ /**
88
+ * The quests that are started, so they are in progress or completed or failed.
89
+ */
90
+ get startedQuests(): QuestInterface[];
91
+ /**
92
+ * The quests that are in progress.
93
+ */
94
+ get inProgressQuests(): QuestInterface[];
95
+ /**
96
+ * The quests that are completed.
97
+ */
98
+ get completedQuests(): QuestInterface[];
99
+ /**
100
+ * The quests that are failed.
101
+ */
102
+ get failedQuests(): QuestInterface[];
103
+ /**
104
+ * The quests that are not started.
105
+ */
106
+ get notStartedQuests(): QuestInterface[];
107
+ /**
108
+ * Get the quest by the id.
109
+ * @param id The id of the quest.
110
+ * @returns The quest with the id.
111
+ */
112
+ find(id: string): QuestInterface | undefined;
113
+ /**
114
+ * Start the quests that must start on the current stage.
115
+ */
116
+ startsStageMustBeStarted(props: OnRunProps): Promise<void>;
117
+ }
118
+
119
+ declare class RoutineHandler {
120
+ /**
121
+ * Get the temporary commitments by its id.
122
+ * @returns The temporary commitments.
123
+ */
124
+ private get temporaryRoutine();
125
+ get commitmentsIds(): string[];
126
+ /**
127
+ * This feature adds the commitments during the game session.
128
+ * @param commitment The commitment or commitments to add.
129
+ * @param roomId The id of the room where the commitment is.
130
+ */
131
+ add(commitment: (CommitmentInterface | CommitmentIdType)[] | CommitmentInterface | CommitmentIdType, roomId: string, options?: ActiveScheduling): void;
132
+ /**
133
+ * Get the commitments added during the game session.
134
+ * @param id The id of the commitment.
135
+ * @returns The commitment or undefined if not found.
136
+ */
137
+ find(id: string): CommitmentInterface | undefined;
138
+ /**
139
+ * Remove the commitments added during the game session.
140
+ * @param commitment The commitment or commitment id to remove.
141
+ * @param roomId The id of the room where the commitment is.
142
+ */
143
+ remove(commitment: CommitmentInterface | CommitmentIdType, roomId?: string): void;
144
+ /**
145
+ * Clear all the expired commitments.
146
+ */
147
+ clearExpiredRoutine(): void;
148
+ get characterCommitments(): {
149
+ [character: string]: [CommitmentInterface, string];
150
+ };
151
+ /**
152
+ * Get the current commitments. The hidden commitments are not included.
153
+ * In case there is a character who has two or more commitments at the same time, will be selected the commitment with the highest priority.
154
+ * Higher priority commitments are calculated using the following steps:
155
+ * 1. The commitments that have Commitments BaseModel.priority set to a higher value will be selected first.
156
+ * 2. If there are commitments with the same priority, the commitments that are not fixed will be selected first.
157
+ * 3. If there are commitments with the same priority and the same fixed status, priority will be given to the commitment with a lower index.
158
+ * @returns The current commitments.
159
+ */
160
+ get currentRoutine(): CommitmentInterface[];
161
+ get roomCommitments(): {
162
+ [roomId: string]: CommitmentInterface[];
163
+ };
164
+ /**
165
+ * Get the character commitment.
166
+ * @param character The character.
167
+ * @returns The commitment or undefined if not found.
168
+ */
169
+ getCommitmentByCharacter(character: CharacterInterface | CharacterIdType): CommitmentInterface | undefined;
170
+ }
171
+
172
+ declare class TimeHandler {
173
+ initialize(settings: TimeSettings): void;
174
+ get dayStartTime(): number;
175
+ get dayEndTime(): number;
176
+ get defaultTimeSpent(): number;
177
+ get timeSlots(): TimeSlotInterface[];
178
+ get weekLength(): number;
179
+ get weekendStartDay(): number;
180
+ /**
181
+ * Week days name
182
+ * @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
183
+ * @returns The name of the week day.
184
+ * @example
185
+ * ```ts
186
+ * (weekDayNumber: number) => {
187
+ * const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
188
+ * return weekDaysNames[weekDayNumber];
189
+ * }
190
+ * ```
191
+ */
192
+ get getDayName(): ((weekDayNumber: number) => string) | undefined;
193
+ /**
194
+ * Get the current time. Time is a numeric variable used to determine and manage time during a day/date.
195
+ * It's recommended to use currentTime as if it were the current time. If you also want to manage minutes, you can use a float value.
196
+ */
197
+ get currentTime(): number;
198
+ set currentTime(value: number | undefined);
199
+ /**
200
+ * Get the current date. Date is a numeric variable used to determine and manage the number of days passed.
201
+ * It's recommended to use currentDate as if it were the current day.
202
+ */
203
+ get currentDate(): number;
204
+ set currentDate(value: number | undefined);
205
+ /**
206
+ * If the current day is greater than or equal to the weekend start day, then it will return true.
207
+ */
208
+ get isWeekend(): boolean;
209
+ /**
210
+ * Get the current week day number (from: 1 - to: {@link weekLength}).
211
+ * For example, if the week length is 7 and the current day is 10, then the result will be 4.
212
+ */
213
+ get currentWeekDayNumber(): number;
214
+ /**
215
+ * Get the current week day name. If the week days names are not defined, then it will return undefined.
216
+ * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
217
+ * @default ""
218
+ */
219
+ get currentDayName(): string;
220
+ /**
221
+ * Get the current {@link timeSlots} index.
222
+ * You can use this property to create "Image that changes based on the time period":
223
+ * @example
224
+ * ```tsx
225
+ * import { weekLength } from '@drincs/nqtr';
226
+ *
227
+ * function changeBackground() {
228
+ * return (
229
+ * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />
230
+ * )
231
+ * }
232
+ */
233
+ get currentTimeSlot(): number;
234
+ /**
235
+ * This function will increase the current time by the given time spent.
236
+ * If the new time is greater than or equal to the max day times, then it will increase the day and set the new time.
237
+ * @param delta is the time spent in times (default: {@link defaultTimeSpent})
238
+ * @returns currentTimeSlot.currentTime
239
+ */
240
+ increaseTime(delta?: number): number;
241
+ /**
242
+ * This function will increase the current date by the given delta.
243
+ * @param delta is the number of days to increase (default: 1)
244
+ * @param time is the time of the new day (default: {@link dayStartTime})
245
+ * @returns timeTracker.currentDate
246
+ */
247
+ increaseDate(delta?: number, time?: number): number;
248
+ /**
249
+ * This function will check if the current time is between the given times.
250
+ * @param fromTime the starting time. If the {@link currentTime} is equal to this time, the function will return true.
251
+ * @param toTime the ending time.
252
+ * @returns true if the current time is between the given times, otherwise false.
253
+ */
254
+ nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
255
+ }
256
+
257
+ declare const timeTracker: TimeHandler;
258
+ declare const navigator: NavigatorHandler;
259
+ declare const routine: RoutineHandler;
260
+ declare const questsNotebook: QuestHandler;
261
+
262
+ declare const handlers_navigator: typeof navigator;
263
+ declare const handlers_questsNotebook: typeof questsNotebook;
264
+ declare const handlers_routine: typeof routine;
265
+ declare const handlers_timeTracker: typeof timeTracker;
266
+ declare namespace handlers {
267
+ export { handlers_navigator as navigator, handlers_questsNotebook as questsNotebook, handlers_routine as routine, handlers_timeTracker as timeTracker };
268
+ }
269
+
270
+ export { type TimeSlotInterface as T, type TimeSettings as a, handlers as h, navigator as n, questsNotebook as q, routine as r, timeTracker as t };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var handlers=require('@drincs/nqtr/handlers'),Qe=require('@drincs/nqtr/registries'),storage=require('@drincs/pixi-vn/storage'),narration=require('@drincs/pixi-vn/narration'),core=require('@drincs/pixi-vn/core');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Qe__namespace=/*#__PURE__*/_interopNamespace(Qe);var U=Object.defineProperty;var me=(o,r,e)=>r in o?U(o,r,{enumerable:true,configurable:true,writable:true,value:e}):o[r]=e;var W=(o,r)=>{for(var e in r)U(o,e,{get:r[e],enumerable:true});};var n=(o,r,e)=>me(o,typeof r!="symbol"?r+"":r,e);var F={};W(F,{ActivityBaseModel:()=>b,ActivityStoredClass:()=>g,CommitmentBaseModel:()=>P,CommitmentStoredClass:()=>y,LocationBaseModel:()=>E,LocationStoredClass:()=>S,MapBaseModel:()=>C,MapStoredClass:()=>v,QuestBaseModel:()=>w,QuestStoredClass:()=>_,RoomBaseModel:()=>D,RoomStoredClass:()=>I,StageBaseModel:()=>O,StageStoredClass:()=>x});var ge="__nqtr-activity__",g=class extends storage.StoredClassModel{constructor(e,t,i,a=ge){super(a,e);this._onRun=t;n(this,"_timeSlot");n(this,"_dateScheduling");this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}_onRun;get timeSlot(){return this._timeSlot}get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.narration.addCurrentStepToHistory();}get run(){return async e=>(this.addTempHistoryItem(),await this._onRun(this,e))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=handlers.timeTracker.currentDate)}isActive(e={}){let{timeSlot:t=this.timeSlot,dateScheduling:i=this.dateScheduling}=e;if(i?.from!=null&&i.from>handlers.timeTracker.currentDate||i?.to!=null&&i.to<handlers.timeTracker.currentDate)return false;t&&!Array.isArray(t)&&(t=[t]);for(let a of t||[])if(!handlers.timeTracker.nowIsBetween(a?.from,a?.to))return false;return true}};var b=class extends g{constructor(e,t,i){super(e,t,{dateScheduling:i.dateScheduling,timeSlot:i.timeSlot});n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.renderIcon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var m="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",Y="___nqtr-last_event_memory___";function R(o){storage.storage.set(Y,o);}function J(){return storage.storage.get(Y)}var pe="__nqtr-commitment__",y=class extends g{constructor(e,t,i,a){i=i||(()=>{});super(e,i,a,pe);this._characters=t;n(this,"defaultExecutionType");n(this,"defaultPriority");this.defaultExecutionType=a.executionType||"interaction",this.defaultPriority=a.priority;}_characters;get characters(){return this._characters}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=handlers.navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=J();switch(t?.type){case "editroom":storage.storage.set(p,t.prev),super.addTempHistoryItem(),storage.storage.set(p,e.id);break;case "edittime":let i=storage.storage.get(m)||{};storage.storage.set(m,t.prev),super.addTempHistoryItem(),storage.storage.set(m,i);break}}};var P=class extends y{constructor(e,t,i){super(e,t?Array.isArray(t)?t:[t]:[],i.onRun,{executionType:i.executionType,priority:i.priority,timeSlot:i.timeSlot,dateScheduling:i.dateScheduling});n(this,"_name");n(this,"_image");n(this,"_icon");n(this,"defaultDisabled");n(this,"defaultHidden");this._name=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this._name}get image(){return this._image}get icon(){return this._icon}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var d;(i=>(i.log=(a,...s)=>console.log(`[NQTR] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[NQTR] ${a}`,...s),i.error=(a,...s)=>console.error(`[NQTR] ${a}`,...s),i.info=(a,...s)=>console.info(`[NQTR] ${a}`,...s)))(d||(d={}));var h=class extends storage.StoredClassModel{constructor(e,t,i=[]){super(e,t);this.defaultActivities=i;}defaultActivities;get defaultActivitiesIds(){return this.defaultActivities.map(e=>e.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let i=this.excludedActivitiesScheduling;delete i[e],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.activeActivityScheduling;i[e]=t,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.excludedActivitiesScheduling;i[e]=t,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:l=handlers.timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=l)throw d.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw d.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");let s=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(e.id)||s.includes(e.id)?d.info(`Activity with id ${e.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(s.push(e.id),this.setStorageProperty("additionalActivitiesIds",s)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),d.log(`Activity with id ${e.id} was excluded from the ${this.id}, but now it will be added again with the new scheduling options. So it will be removed from the excluded activities list.`)),(i||a)&&this.editActivityScheduling(e.id,{timeSlot:i,dateScheduling:a});}removeActivity(e){let t=typeof e=="string"?e:e.id,i=this.additionalActivitiesIds;if(i.includes(t))i=i.filter(a=>a!==t),this.setStorageProperty("additionalActivitiesIds",i);else if(this.defaultActivitiesIds.includes(t)){let a=this.excludedActivitiesIds;a.push(t),this.setStorageProperty("excludedActivitiesIds",a);}else d.warn(`Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,a=this.excludedActivitiesIds;i.forEach(s=>{if(s in e){let{to:c}=e[s].dateScheduling||{};c&&c<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(s),i=i.filter(l=>l!==s));}}),a.forEach(s=>{s in t&&t[s]&&(this.removeActivityScheduling(s),a=a.filter(c=>c!==s));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let i=Qe.RegisteredActivities.get(t);return i&&i.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(i),e},[])}};var Ie="__nqtr-location__",S=class extends h{constructor(e,t,i=[]){super(Ie,e,i);this._map=t;}_map;get map(){return this._map}get rooms(){return handlers.navigator.rooms.filter(e=>e.location.id===this.id)}};var E=class extends S{constructor(e,t,i={}){super(e,t,i.activities||[]);n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var xe="__nqtr-map__",v=class extends h{constructor(r,e=[]){super(xe,r,e);}get locations(){return handlers.navigator.locations.filter(r=>r.map.id===this.id)}};var C=class extends v{constructor(e,t={}){super(e,t.activities||[]);n(this,"defaultName");n(this,"_image");this.defaultName=t.name||"",this._image=t.image;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}};var ie="__nqtr-room__",I=class extends h{constructor(e,t,i=[]){var r=(...Nt)=>(super(...Nt),this._location=t,this);Array.isArray(i)?r(ie,e,i):(r(ie,e,i.activities),i.routine.forEach(a=>Qe.fixedCommitments.set(a.id,[a,e])));}_location;get routine(){return handlers.routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(s=>{let{to:c=handlers.timeTracker.dayEndTime+1}=s||{};if(s&&s.from>=c)throw d.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw d.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");handlers.routine.add(e,this.id,{timeSlot:i,dateScheduling:a});}removeCommitment(e){handlers.routine.remove(e,this.id);}get location(){return this._location}get characters(){return this.routine.reduce((e,t)=>(e.push(...t.characters),e),[])}get automaticFunctions(){return this.routine.reduce((e,t)=>{if(t.executionType==="automatic"&&t.run){let i=async a=>{await t.run(a);};e.push(i);}return e},[])}};var D=class extends I{constructor(e,t,i={}){super(e,t,{activities:i.activities||[],routine:i.routine||[]});n(this,"defaultName");n(this,"_image");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var Ae="__nqtr-quest__",_=class extends storage.StoredClassModel{constructor(e,t,i={}){super(Ae,e);this._stages=t;n(this,"_onStart");n(this,"_onNextStage");this._onStart=i.onStart,this._onNextStage=i.onNextStage;}_stages;get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===void 0||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}get onStart(){return this._onStart}get onNextStage(){return this._onNextStage}async start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){d.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&await this.onStart(this,e),await t.start(e);d.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(e){return await this.advanceIfCompleted(e)}async advanceIfCompleted(e){if(!this.inProgress)return false;let t=this.currentStage;return t?t.completed?await this.advanceUnconditionally(e):false:(d.error(`Quest ${this.id} has no current stage`),false)}async goNext(e){return await this.continue(e)}async continue(e){let t=this.currentStage;return t?(t.completed=true,await this.advanceUnconditionally(e)):(d.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(e){return await this.advanceUnconditionally(e)}async advanceUnconditionally(e){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===void 0)return d.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&await this.onNextStage(this,e),t&&t.onEnd&&await t.onEnd(t,e);let a=this.currentStage;return a&&(a.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}async startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?await t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var w=class extends _{constructor(e,t,i){super(e,t,{onStart:i.onStart,onNextStage:i.onNextStage});n(this,"_name");n(this,"_description");n(this,"_icon");n(this,"_image");n(this,"_inDevelopment");this._name=i.name||"",this._description=i.description||"",this._icon=i.icon,this._image=i.image,this._inDevelopment=i.inDevelopment||false;}get name(){return this._name}get description(){return this._description}get icon(){return this._icon}get image(){return this._image}get inDevelopment(){return this._inDevelopment}};var Ee="__nqtr-stage__",x=class extends storage.StoredClassModel{constructor(e,t={}){super(Ee,e);n(this,"_onStart");n(this,"_onEnd");n(this,"_deltaDateRequired");n(this,"_questsRequired");this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}get onStart(){return this._onStart}get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>handlers.timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=handlers.timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}get deltaDateRequired(){return this._deltaDateRequired||0}get questsRequired(){return this._questsRequired||[]}};var O=class extends x{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired});n(this,"_name");n(this,"_description");n(this,"_adviceDescription");n(this,"_image");n(this,"_flags");n(this,"_flagsRequired");n(this,"_requestDescriptionToStart");this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}get name(){return this._name}get description(){return this._description}get adviceDescription(){return this._adviceDescription}get image(){return this._image}get flags(){return this._flags}get flagsRequired(){return this._flagsRequired}get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.storage.getFlag(e.flag))?false:super.canStart}};var oe={};var de={};var K={};W(K,{navigator:()=>qe,questsNotebook:()=>Ne,routine:()=>Me,timeTracker:()=>Oe});var q=class{get rooms(){return Qe.RegisteredRooms.values()}get locations(){return Qe.RegisteredLocations.values()}get maps(){return Qe.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(p)}get currentRoom(){let r=this.currentRoomId;if(!r){d.error("The current room has not yet been set");return}let e=Qe.RegisteredRooms.get(r);if(!e){d.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!Qe.RegisteredRooms.get(r)){d.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.storage.get(p);t!==r&&(R({type:"editroom",prev:t,value:r}),storage.storage.set(p,r));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Qe.RegisteredRooms.values().forEach(r=>{r.clearExpiredActivities();});}};var M=class{get quests(){return Qe.RegisteredQuests.values()}get startedQuests(){return this.quests.filter(r=>r.started)}get inProgressQuests(){return this.quests.filter(r=>r.inProgress)}get completedQuests(){return this.quests.filter(r=>r.completed)}get failedQuests(){return this.quests.filter(r=>r.failed)}get notStartedQuests(){return this.quests.filter(r=>!r.started)}find(r){return Qe.RegisteredQuests.get(r)}async startsStageMustBeStarted(r){let e=this.quests.map(t=>t.currentStageMustStart?t.startCurrentStage(r):Promise.resolve());await Promise.all(e);}};var H="___nqtr-temporary_commitment___",Q=class{get temporaryRoutine(){let r=storage.storage.get(H);if(r){if(Array.isArray(r)){if(r.length>0)throw new core.PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return r}get commitmentsIds(){return [...Qe.fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(r,e,t={}){Array.isArray(r)||(r=[r]);let i=this.temporaryRoutine;r.forEach(a=>{Qe.RegisteredCommitments.get(a.id)&&d.warn(`The commitment ${a.id} is already registered, it will be overwritten`),Qe.RegisteredCommitments.add(a),i[a.id]={id:a.id,roomId:e,...t};}),storage.storage.set(H,i);}find(r){return Qe.RegisteredCommitments.get(r)}remove(r,e){typeof r!="string"&&(r=r.id);let t=this.temporaryRoutine;t[r]?(!e||t[r].roomId===e)&&delete t[r]:d.warn(`The commitment ${r} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.storage.set(H,t);}clearExpiredRoutine(){Qe.RegisteredCommitments.values().forEach(r=>{r.expired&&this.remove(r);});}get characterCommitments(){let r=this.temporaryRoutine;return this.commitmentsIds.reduce((e,t)=>{let i=Qe.RegisteredCommitments.get(t),a=r[t],s=a?.roomId||Qe.fixedCommitments.get(t)?.[1];return s&&i&&i.isActive(a)&&(i.characters.length>0?i.characters.every(l=>!e[l.id]||i.priority>e[l.id][0].priority)&&i.characters.forEach(l=>{e[l.id]=[i,s];}):d.error(`The commitment ${i.id} has no characters assigned`)),e},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([r])=>r)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((r,e)=>{let t=e[1];return r[t]||(r[t]=[]),r[t].push(e[0]),r},{})}getCommitmentByCharacter(r){return this.currentRoutine.find(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e})}};var f=class f{};n(f,"dayStartTime",0),n(f,"dayEndTime",24),n(f,"defaultTimeSpent",1),n(f,"timeSlots",[]),n(f,"weekLength",7),n(f,"weekendStartDay",f.weekLength-1),n(f,"getDayName");var u=f;var L=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:s=7,weekendStartDay:c=s-1,getDayName:l}=r;u.dayStartTime=e,u.dayEndTime=t,u.defaultTimeSpent=i,u.timeSlots=a,u.weekLength=s,c>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):u.weekendStartDay=c,u.getDayName=l;}get dayStartTime(){return u.dayStartTime}get dayEndTime(){return u.dayEndTime}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get getDayName(){return u.getDayName}get currentTime(){let r=storage.storage.get(m)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.storage.get(m)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,R({type:"edittime",prev:e,value:t}),storage.storage.set(m,t);}get currentDate(){let r=storage.storage.get(m)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.storage.get(m)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,R({type:"edittime",prev:e,value:t}),storage.storage.set(m,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let r=0;r<this.timeSlots.length;r++){let e=this.timeSlots[r];if(this.timeSlots.length>r+1&&this.nowIsBetween(e.startTime,this.timeSlots[r+1].startTime))return r}return this.timeSlots.length-1}increaseTime(r=this.defaultTimeSpent){let e=this.currentTime+r;return e>=this.dayEndTime&&(this.increaseDate(),e=this.dayStartTime+(e-this.dayEndTime)),this.currentTime=e,this.currentTime}increaseDate(r=1,e=this.dayStartTime){let t=this.currentDate+r;return this.currentDate=t,this.currentTime=e,this.currentDate}nowIsBetween(r,e){r===void 0&&(r=this.dayStartTime-1),e===void 0&&(e=this.dayEndTime+1);let t=this.currentTime;return r<e?t>=r&&t<e:t>=r||t<e}};var Oe=new L,qe=new q,Me=new Q,Ne=new M;var Le={...F,...oe,...de,handlers:K,registries:Qe__namespace},zr=Le;Object.defineProperty(exports,"RegisteredActivities",{enumerable:true,get:function(){return Qe.RegisteredActivities}});Object.defineProperty(exports,"RegisteredCommitments",{enumerable:true,get:function(){return Qe.RegisteredCommitments}});Object.defineProperty(exports,"RegisteredLocations",{enumerable:true,get:function(){return Qe.RegisteredLocations}});Object.defineProperty(exports,"RegisteredMaps",{enumerable:true,get:function(){return Qe.RegisteredMaps}});Object.defineProperty(exports,"RegisteredQuests",{enumerable:true,get:function(){return Qe.RegisteredQuests}});Object.defineProperty(exports,"RegisteredRooms",{enumerable:true,get:function(){return Qe.RegisteredRooms}});exports.ActivityBaseModel=b;exports.ActivityStoredClass=g;exports.CommitmentBaseModel=P;exports.CommitmentStoredClass=y;exports.LocationBaseModel=E;exports.LocationStoredClass=S;exports.MapBaseModel=C;exports.MapStoredClass=v;exports.QuestBaseModel=w;exports.QuestStoredClass=_;exports.RoomBaseModel=D;exports.RoomStoredClass=I;exports.StageBaseModel=O;exports.StageStoredClass=x;exports.default=zr;Object.keys(handlers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return handlers[k]}})});
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var handlers=require('@drincs/nqtr/handlers'),Qe=require('@drincs/nqtr/registries'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage'),characters=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Qe__namespace=/*#__PURE__*/_interopNamespace(Qe);var ce=Object.defineProperty;var K=(s,e)=>{for(var t in e)ce(s,t,{get:e[t],enumerable:true});};var $={};K($,{ActivityBaseModel:()=>_,ActivityStoredClass:()=>m,CommitmentBaseModel:()=>A,CommitmentStoredClass:()=>p,LocationBaseModel:()=>b,LocationStoredClass:()=>h,MapBaseModel:()=>C,MapStoredClass:()=>y,QuestBaseModel:()=>P,QuestStoredClass:()=>v,RoomBaseModel:()=>E,RoomStoredClass:()=>S,StageBaseModel:()=>D,StageStoredClass:()=>I});var fe="__nqtr-activity__",m=class extends storage.StoredClassModel{constructor(t,r,i,n=fe){super(n,t);this._onRun=r;this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}_onRun;_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){return narration.narration.addCurrentStepToHistory()}get run(){return async t=>(this.addTempHistoryItem(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=handlers.timeTracker.currentDate)}isActive(t={}){let{timeSlot:r=this.timeSlot,dateScheduling:i=this.dateScheduling}=t;if(i?.from!=null&&i.from>handlers.timeTracker.currentDate||i?.to!=null&&i.to<handlers.timeTracker.currentDate)return false;r&&!Array.isArray(r)&&(r=[r]);for(let n of r||[])if(!handlers.timeTracker.nowIsBetween(n?.from,n?.to))return false;return true}};var _=class extends m{constructor(e,t,r){super(e,t,{dateScheduling:r.dateScheduling,timeSlot:r.timeSlot}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var u="___nqtr-time_manager_data___",g="___nqtr-current_room_memory___",L="___nqtr-last_event_memory___";function R(s){storage.storage.set(L,s);}function j(){return storage.storage.get(L)}var he="__nqtr-commitment__",p=class extends m{constructor(e,t,r,i){r=r||(()=>{}),super(e,r,i,he),this.defaultExecutionType=i.executionType||"interaction",this.defaultPriority=i.priority,this.characters=t.reduce((n,a)=>{if(typeof a=="string"){let c=characters.RegisteredCharacters.get(a);c?n.push(c):console.warn(`Character with id ${a} not found for commitment ${e}`);}else n.push(a);return n},[]);}defaultExecutionType;defaultPriority;characters;get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=handlers.navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=j();switch(t?.type){case "editroom":storage.storage.set(g,t.prev),super.addTempHistoryItem(),storage.storage.set(g,e.id);break;case "edittime":{let r=storage.storage.get(u)||{};storage.storage.set(u,t.prev),super.addTempHistoryItem(),storage.storage.set(u,r);break}}}runOptions;get run(){return async(e,t)=>{let r=t?.removeFromRoutine??this.executionType==="automatic";return this.addTempHistoryItem(),r&&handlers.routine.remove(this.id),await this._onRun(this,e)}}};var A=class extends p{constructor(e,t,r){super(e,t?Array.isArray(t)?t:[t]:[],r.onRun,{executionType:r.executionType,priority:r.priority,timeSlot:r.timeSlot,dateScheduling:r.dateScheduling}),this._name=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var o;(i=>(i.log=(n,...a)=>console.log(`[NQTR] ${n}`,...a),i.warn=(n,...a)=>console.warn(`[NQTR] ${n}`,...a),i.error=(n,...a)=>console.error(`[NQTR] ${n}`,...a),i.info=(n,...a)=>console.info(`[NQTR] ${n}`,...a)))(o||={});var f=class extends storage.StoredClassModel{constructor(e,t,r=[]){super(e,t),this.defaultActivitiesIds=r.map(i=>typeof i=="string"?i:i.id);}defaultActivitiesIds;get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let r=this.excludedActivitiesScheduling;delete r[e],this.setStorageProperty("excludedActivitiesScheduling",r);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.activeActivityScheduling;r[e]=t,this.setStorageProperty("activeActivityScheduling",r);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.excludedActivitiesScheduling;r[e]=t,this.setStorageProperty("excludedActivitiesScheduling",r);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let r=typeof e=="string"?Qe.RegisteredActivities.get(e):e;if(!r)throw o.error(`Activity with id ${e} not found.`),new core.PixiError("unknown_element",`Activity with id ${e} not found.`);let{timeSlot:i,dateScheduling:n}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:l=handlers.timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=l)throw o.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),n?.from!==void 0&&n?.to!==void 0&&n?.from>=n?.to)throw o.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");let a=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(r.id)||a.includes(r.id)?o.info(`Activity with id ${r.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(a.push(r.id),this.setStorageProperty("additionalActivitiesIds",a)),this.excludedActivitiesIds.includes(r.id)&&(this.removeActivityScheduling(r.id),o.log(`Activity with id ${r.id} was excluded from the ${this.id}, but now it will be added again with the new scheduling options. So it will be removed from the excluded activities list.`)),(i||n)&&this.editActivityScheduling(r.id,{timeSlot:i,dateScheduling:n});}removeActivity(e){let t=typeof e=="string"?e:e.id,r=this.additionalActivitiesIds;if(r.includes(t))r=r.filter(i=>i!==t),this.setStorageProperty("additionalActivitiesIds",r);else if(this.defaultActivitiesIds.includes(t)){let i=this.excludedActivitiesIds;i.push(t),this.setStorageProperty("excludedActivitiesIds",i);}else o.warn(`Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,r=this.additionalActivitiesIds,i=this.excludedActivitiesIds;r.forEach(n=>{if(n in e){let{to:a}=e[n].dateScheduling||{};a&&a<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(n),r=r.filter(c=>c!==n));}}),i.forEach(n=>{n in t&&t[n]&&(this.removeActivityScheduling(n),i=i.filter(a=>a!==n));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let r=Qe.RegisteredActivities.get(t);return r?.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(r),e},[])}};var ve="__nqtr-location__",h=class extends f{constructor(t,r,i=[]){super(ve,t,i);this._map=r;}_map;get map(){return this._map}get rooms(){return handlers.navigator.rooms.filter(t=>t.location.id===this.id)}};var b=class extends h{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Te="__nqtr-map__",y=class extends f{constructor(e,t=[]){super(Te,e,t);}get locations(){return handlers.navigator.locations.filter(e=>e.map.id===this.id)}};var C=class extends y{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var te="__nqtr-room__",S=class extends f{_location;constructor(e,t,r=[]){Array.isArray(r)?super(te,e,r):(super(te,e,r.activities),r.routine.forEach(i=>{let n=typeof i=="string"?i:i.id;Qe.fixedCommitments.set(n,e);})),this._location=t;}get routine(){return handlers.routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:r,dateScheduling:i}=t;if(r&&!Array.isArray(r)&&(r=[r]),r?.forEach(n=>{let{to:a=handlers.timeTracker.dayEndTime+1}=n||{};if(n&&n.from>=a)throw o.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw o.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");handlers.routine.add(e,this.id,{timeSlot:r,dateScheduling:i});}removeCommitment(e){handlers.routine.remove(e,this.id);}get location(){return this._location}get characters(){return this.routine.reduce((e,t)=>(e.push(...t.characters),e),[])}get automaticFunctions(){return this.routine.reduce((e,t)=>{if(t.executionType==="automatic"&&t.run){let r=async i=>{await t.run(i);};e.push(r);}return e},[])}};var E=class extends S{constructor(e,t,r={}){super(e,t,{activities:r.activities||[],routine:r.routine||[]}),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ae="__nqtr-quest__",v=class extends storage.StoredClassModel{constructor(t,r,i={}){super(Ae,t);this._stages=r;this._onStart=i.onStart,this._onContinue=i.onContinue||i.onNextStage;}_stages;get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===void 0||t>=this.stages.length))return this.stages[t]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onContinue;get onContinue(){return this._onContinue}get onNextStage(){return this._onContinue}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){o.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r?.start)return this.onStart&&await this.onStart(this,t),await r.start(t);o.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(t){return await this.advanceIfCompleted(t)}async advanceIfCompleted(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.advanceUnconditionally(t):false:(o.error(`Quest ${this.id} has no current stage`),false)}async goNext(t){return await this.continue(t)}async continue(t){let r=this.currentStage;return r?(r.completed=true,await this.advanceUnconditionally(t)):(o.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(t){return await this.advanceUnconditionally(t)}async advanceUnconditionally(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,i=this.currentStageIndex;if(!r||i===void 0)return o.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onContinue&&await this.onContinue(this,t),r?.onEnd&&await r.onEnd(r,t);let n=this.currentStage;return n&&(n.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var P=class extends v{constructor(e,t,r){super(e,t,{onStart:r.onStart,onContinue:r.onContinue||r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};var Ce="__nqtr-stage__",I=class extends storage.StoredClassModel{constructor(e,t={}){super(Ce,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>handlers.timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=handlers.timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_deltaDateRequired;get deltaDateRequired(){return this._deltaDateRequired||0}_questsRequired;get questsRequired(){return this._questsRequired||[]}};var D=class extends I{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequired;get flagsRequired(){return this._flagsRequired}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.storage.getFlag(e.flag))?false:super.canStart}};var ae={};var oe={};var G={};K(G,{navigator:()=>qe,questsNotebook:()=>Ne,routine:()=>Me,timeTracker:()=>Oe});var w=class{get rooms(){return Qe.RegisteredRooms.values()}get locations(){return Qe.RegisteredLocations.values()}get maps(){return Qe.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(g)}get currentRoom(){let e=this.currentRoomId;if(!e){o.error("The current room has not yet been set");return}let t=Qe.RegisteredRooms.get(e);if(!t){o.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!Qe.RegisteredRooms.get(e)){o.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.storage.get(g);r!==e&&(R({type:"editroom",prev:r,value:e}),storage.storage.set(g,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Qe.RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var O=class{get quests(){return Qe.RegisteredQuests.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return Qe.RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var H="___nqtr-temporary_commitment___",q=class{get temporaryRoutine(){let e=storage.storage.get(H);if(e){if(Array.isArray(e)){if(e.length>0)throw new core.PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return e}get commitmentsIds(){return [...Qe.fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let i=this.temporaryRoutine;e.forEach(n=>{let a=typeof n=="string"?n:n.id;i[a]={id:a,roomId:t,...r};}),storage.storage.set(H,i);}find(e){return Qe.RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:o.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.storage.set(H,r);}clearExpiredRoutine(){Qe.RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let i=Qe.RegisteredCommitments.get(r),n=e[r],a=n?.roomId||Qe.fixedCommitments.get(r);return a&&i?.isActive(n)&&(i.characters.length>0?i.characters.every(l=>!t[l.id]||i.priority>t[l.id][0].priority)&&i.characters.forEach(l=>{t[l.id]=[i,a];}):o.error(`The commitment ${i.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){let t=typeof e=="string"?e:e.id;return this.currentRoutine.find(r=>{if(r.characters.map(i=>i.id).includes(t))return r})}};var we={dayStartTime:0,dayEndTime:24,defaultTimeSpent:1,timeSlots:[],weekLength:7,weekendStartDay:6,getDayName:void 0},d=we;var M=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:n=[],weekLength:a=7,weekendStartDay:c=a-1,getDayName:l}=e;d.dayStartTime=t,d.dayEndTime=r,d.defaultTimeSpent=i,d.timeSlots=n,d.weekLength=a,c>=d.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${a}, so will be ignored`):d.weekendStartDay=c,d.getDayName=l;}get dayStartTime(){return d.dayStartTime}get dayEndTime(){return d.dayEndTime}get defaultTimeSpent(){return d.defaultTimeSpent}get timeSlots(){return d.timeSlots}get weekLength(){return d.weekLength}get weekendStartDay(){return d.weekendStartDay}get getDayName(){return d.getDayName}get currentTime(){let e=storage.storage.get(u)||{};return Object.hasOwn(e,"currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.storage.get(u)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,R({type:"edittime",prev:t,value:r}),storage.storage.set(u,r);}get currentDate(){let e=storage.storage.get(u)||{};return Object.hasOwn(e,"currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.storage.get(u)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,R({type:"edittime",prev:t,value:r}),storage.storage.set(u,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var Oe=new M,qe=new w,Me=new q,Ne=new O;var Le={...$,...ae,...oe,handlers:G,registries:Qe__namespace},wr=Le;Object.defineProperty(exports,"RegisteredActivities",{enumerable:true,get:function(){return Qe.RegisteredActivities}});Object.defineProperty(exports,"RegisteredCommitments",{enumerable:true,get:function(){return Qe.RegisteredCommitments}});Object.defineProperty(exports,"RegisteredLocations",{enumerable:true,get:function(){return Qe.RegisteredLocations}});Object.defineProperty(exports,"RegisteredMaps",{enumerable:true,get:function(){return Qe.RegisteredMaps}});Object.defineProperty(exports,"RegisteredQuests",{enumerable:true,get:function(){return Qe.RegisteredQuests}});Object.defineProperty(exports,"RegisteredRooms",{enumerable:true,get:function(){return Qe.RegisteredRooms}});exports.ActivityBaseModel=_;exports.ActivityStoredClass=m;exports.CommitmentBaseModel=A;exports.CommitmentStoredClass=p;exports.LocationBaseModel=b;exports.LocationStoredClass=h;exports.MapBaseModel=C;exports.MapStoredClass=y;exports.QuestBaseModel=P;exports.QuestStoredClass=v;exports.RoomBaseModel=E;exports.RoomStoredClass=S;exports.StageBaseModel=D;exports.StageStoredClass=I;exports.default=wr;Object.keys(handlers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return handlers[k]}})});