@ezpaarse-project/ezreeport-sdk-js 2.1.0 → 2.2.0-beta.2

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.
Files changed (182) hide show
  1. package/dist/_commonjsHelpers-C6fGbg64.mjs +7 -0
  2. package/dist/_commonjsHelpers-C6fGbg64.mjs.map +1 -0
  3. package/dist/_commonjsHelpers-DwGv2jUC.js +2 -0
  4. package/dist/_commonjsHelpers-DwGv2jUC.js.map +1 -0
  5. package/dist/{api-DVzOqMA2.js → api-BSUnyE6V.js} +2 -2
  6. package/dist/api-BSUnyE6V.js.map +1 -0
  7. package/dist/{api-C_g0ldUn.d.ts → api-Beaugm6M.d.ts} +2 -2
  8. package/dist/{api-D8l8Ds3U.mjs → api-Cwb98wAh.mjs} +2 -3
  9. package/dist/api-Cwb98wAh.mjs.map +1 -0
  10. package/dist/auth.js +1 -1
  11. package/dist/auth.mjs +1 -1
  12. package/dist/crons.js +1 -1
  13. package/dist/crons.js.map +1 -1
  14. package/dist/crons.mjs +41 -39
  15. package/dist/crons.mjs.map +1 -1
  16. package/dist/decorator-C2gcn2rK.js.map +1 -1
  17. package/dist/{decorator-DBkj--6g.mjs → decorator-DCiVxI72.mjs} +2 -4
  18. package/dist/decorator-DCiVxI72.mjs.map +1 -0
  19. package/dist/elastic.js +1 -1
  20. package/dist/elastic.js.map +1 -1
  21. package/dist/elastic.mjs +2 -2
  22. package/dist/elastic.mjs.map +1 -1
  23. package/dist/fetch-CLjbXGAV.js +2 -0
  24. package/dist/fetch-CLjbXGAV.js.map +1 -0
  25. package/dist/fetch-kzLaYwl7.mjs +47 -0
  26. package/dist/fetch-kzLaYwl7.mjs.map +1 -0
  27. package/dist/generations.d.ts +17 -0
  28. package/dist/generations.js +2 -0
  29. package/dist/generations.js.map +1 -0
  30. package/dist/generations.mjs +7 -0
  31. package/dist/generations.mjs.map +1 -0
  32. package/dist/health.d.ts +20 -32
  33. package/dist/health.js +1 -1
  34. package/dist/health.js.map +1 -1
  35. package/dist/health.mjs +33 -31
  36. package/dist/health.mjs.map +1 -1
  37. package/dist/helpers/aggregations.d.ts +4 -4
  38. package/dist/helpers/aggregations.js.map +1 -1
  39. package/dist/helpers/aggregations.mjs.map +1 -1
  40. package/dist/helpers/figures.d.ts +19 -19
  41. package/dist/helpers/figures.js +1 -1
  42. package/dist/helpers/figures.mjs +4 -4
  43. package/dist/helpers/filters.js.map +1 -1
  44. package/dist/helpers/filters.mjs.map +1 -1
  45. package/dist/helpers/generations.d.ts +55 -0
  46. package/dist/helpers/generations.js +2 -0
  47. package/dist/helpers/generations.js.map +1 -0
  48. package/dist/helpers/generations.mjs +308 -0
  49. package/dist/helpers/generations.mjs.map +1 -0
  50. package/dist/helpers/layouts.d.ts +3 -3
  51. package/dist/helpers/layouts.js +1 -1
  52. package/dist/helpers/layouts.js.map +1 -1
  53. package/dist/helpers/layouts.mjs +6 -6
  54. package/dist/helpers/layouts.mjs.map +1 -1
  55. package/dist/helpers/permissions.d.ts +3 -1
  56. package/dist/helpers/permissions.js +1 -1
  57. package/dist/helpers/permissions.js.map +1 -1
  58. package/dist/helpers/permissions.mjs +8 -4
  59. package/dist/helpers/permissions.mjs.map +1 -1
  60. package/dist/helpers/task-presets.d.ts +2 -2
  61. package/dist/helpers/task-presets.js +1 -1
  62. package/dist/helpers/task-presets.js.map +1 -1
  63. package/dist/helpers/task-presets.mjs +6 -3
  64. package/dist/helpers/task-presets.mjs.map +1 -1
  65. package/dist/helpers/tasks.d.ts +4 -1
  66. package/dist/helpers/tasks.js +1 -1
  67. package/dist/helpers/tasks.js.map +1 -1
  68. package/dist/helpers/tasks.mjs +17 -15
  69. package/dist/helpers/tasks.mjs.map +1 -1
  70. package/dist/helpers/templates.js +1 -1
  71. package/dist/helpers/templates.js.map +1 -1
  72. package/dist/helpers/templates.mjs +6 -6
  73. package/dist/helpers/templates.mjs.map +1 -1
  74. package/dist/index-CVa-i8Jy.js +7 -0
  75. package/dist/index-CVa-i8Jy.js.map +1 -0
  76. package/dist/index-CqG3FOrT.mjs +1113 -0
  77. package/dist/index-CqG3FOrT.mjs.map +1 -0
  78. package/dist/index.d.ts +6 -6
  79. package/dist/index.js +1 -1
  80. package/dist/index.mjs +2 -2
  81. package/dist/{methods-ChKQbOFl.js → methods--DanahvX.js} +2 -2
  82. package/dist/{methods-ChKQbOFl.js.map → methods--DanahvX.js.map} +1 -1
  83. package/dist/methods-B7KR7IhF.js +2 -0
  84. package/dist/methods-B7KR7IhF.js.map +1 -0
  85. package/dist/{methods-jKz01wri.mjs → methods-BEqx06jZ.mjs} +6 -6
  86. package/dist/{methods-jKz01wri.mjs.map → methods-BEqx06jZ.mjs.map} +1 -1
  87. package/dist/{methods-M4GU2OL5.mjs → methods-BMzxDoxk.mjs} +3 -3
  88. package/dist/{methods-M4GU2OL5.mjs.map → methods-BMzxDoxk.mjs.map} +1 -1
  89. package/dist/{methods-Jar1Wkpj.js → methods-BRTxG87E.js} +2 -2
  90. package/dist/{methods-Jar1Wkpj.js.map → methods-BRTxG87E.js.map} +1 -1
  91. package/dist/{methods-C3rgYZb1.mjs → methods-BeMtF2ph.mjs} +5 -5
  92. package/dist/{methods-C3rgYZb1.mjs.map → methods-BeMtF2ph.mjs.map} +1 -1
  93. package/dist/{methods-BOf9WLn2.js → methods-C85_VqKZ.js} +2 -2
  94. package/dist/{methods-BOf9WLn2.js.map → methods-C85_VqKZ.js.map} +1 -1
  95. package/dist/methods-D5Sa5dxr.mjs +95 -0
  96. package/dist/methods-D5Sa5dxr.mjs.map +1 -0
  97. package/dist/methods-DRivN56g.js +2 -0
  98. package/dist/methods-DRivN56g.js.map +1 -0
  99. package/dist/{methods-sTFYWEAr.mjs → methods-DtUaMG7I.mjs} +59 -56
  100. package/dist/methods-DtUaMG7I.mjs.map +1 -0
  101. package/dist/methods-DvvWsTzZ.mjs +158 -0
  102. package/dist/methods-DvvWsTzZ.mjs.map +1 -0
  103. package/dist/methods-ExKehD5I.js +2 -0
  104. package/dist/methods-ExKehD5I.js.map +1 -0
  105. package/dist/recurrence.d.ts +28 -0
  106. package/dist/recurrence.js +2 -0
  107. package/dist/recurrence.js.map +1 -0
  108. package/dist/recurrence.mjs +49 -0
  109. package/dist/recurrence.mjs.map +1 -0
  110. package/dist/reports.d.ts +4 -5
  111. package/dist/reports.js +1 -1
  112. package/dist/reports.mjs +1 -1
  113. package/dist/task-activity.d.ts +2 -2
  114. package/dist/task-activity.js +1 -1
  115. package/dist/task-activity.js.map +1 -1
  116. package/dist/task-activity.mjs +5 -5
  117. package/dist/task-activity.mjs.map +1 -1
  118. package/dist/task-presets.d.ts +3 -3
  119. package/dist/task-presets.js +1 -1
  120. package/dist/task-presets.mjs +1 -1
  121. package/dist/{tasks-hn70eL7B.js → tasks-C-Si9c_j.js} +2 -2
  122. package/dist/tasks-C-Si9c_j.js.map +1 -0
  123. package/dist/{tasks-1x680qAf.mjs → tasks-rnhGl39m.mjs} +2 -2
  124. package/dist/tasks-rnhGl39m.mjs.map +1 -0
  125. package/dist/tasks.d.ts +3 -3
  126. package/dist/tasks.js +1 -1
  127. package/dist/tasks.mjs +1 -1
  128. package/dist/templates-BNAX4vB8.mjs +29 -0
  129. package/dist/templates-BNAX4vB8.mjs.map +1 -0
  130. package/dist/templates-D7C0TH1C.js +2 -0
  131. package/dist/templates-D7C0TH1C.js.map +1 -0
  132. package/dist/templates.d.ts +2 -2
  133. package/dist/templates.js +1 -1
  134. package/dist/templates.mjs +1 -1
  135. package/dist/{transform-EpMTJExd.mjs → transform-DrB-Z9tA.mjs} +3 -3
  136. package/dist/transform-DrB-Z9tA.mjs.map +1 -0
  137. package/dist/transform-DzLAfSJo.js.map +1 -1
  138. package/dist/{types-DtBHOMlQ.d.ts → types-BxhkIhgG.d.ts} +1 -1
  139. package/dist/{types-DP1QhOKe.d.ts → types-CCDLyhAJ.d.ts} +1 -1
  140. package/dist/types-Cac8HEO5.d.ts +23 -0
  141. package/dist/{types-jXqGnCKQ.d.ts → types-CgKoQCwb.d.ts} +12 -24
  142. package/package.json +30 -22
  143. package/dist/api-D8l8Ds3U.mjs.map +0 -1
  144. package/dist/api-DVzOqMA2.js.map +0 -1
  145. package/dist/decorator-DBkj--6g.mjs.map +0 -1
  146. package/dist/fetch-Hd-ajPIl.js +0 -2
  147. package/dist/fetch-Hd-ajPIl.js.map +0 -1
  148. package/dist/fetch-xZFTa3q1.mjs +0 -16
  149. package/dist/fetch-xZFTa3q1.mjs.map +0 -1
  150. package/dist/helpers/jobs.d.ts +0 -109
  151. package/dist/helpers/jobs.js +0 -2
  152. package/dist/helpers/jobs.js.map +0 -1
  153. package/dist/helpers/jobs.mjs +0 -390
  154. package/dist/helpers/jobs.mjs.map +0 -1
  155. package/dist/index-DfRKlMeG.d.ts +0 -109
  156. package/dist/index-btsFMVmd.js +0 -2
  157. package/dist/index-btsFMVmd.js.map +0 -1
  158. package/dist/index-niBfS4wD.mjs +0 -331
  159. package/dist/index-niBfS4wD.mjs.map +0 -1
  160. package/dist/methods-8bLJk-Sx.mjs +0 -161
  161. package/dist/methods-8bLJk-Sx.mjs.map +0 -1
  162. package/dist/methods-BJfwYB1p.mjs +0 -126
  163. package/dist/methods-BJfwYB1p.mjs.map +0 -1
  164. package/dist/methods-CMrpqFJZ.js +0 -2
  165. package/dist/methods-CMrpqFJZ.js.map +0 -1
  166. package/dist/methods-DC2Gjy1i.js +0 -2
  167. package/dist/methods-DC2Gjy1i.js.map +0 -1
  168. package/dist/methods-DU5cbtLn.js +0 -2
  169. package/dist/methods-DU5cbtLn.js.map +0 -1
  170. package/dist/methods-sTFYWEAr.mjs.map +0 -1
  171. package/dist/queues.d.ts +0 -6
  172. package/dist/queues.js +0 -2
  173. package/dist/queues.js.map +0 -1
  174. package/dist/queues.mjs +0 -10
  175. package/dist/queues.mjs.map +0 -1
  176. package/dist/tasks-1x680qAf.mjs.map +0 -1
  177. package/dist/tasks-hn70eL7B.js.map +0 -1
  178. package/dist/templates-yZjsVuN9.js +0 -2
  179. package/dist/templates-yZjsVuN9.js.map +0 -1
  180. package/dist/templates-zMmVXt6k.mjs +0 -30
  181. package/dist/templates-zMmVXt6k.mjs.map +0 -1
  182. package/dist/transform-EpMTJExd.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { T as Task, a as TaskRecurrence, L as LastExtended, I as InputTask } from '../types-DP1QhOKe.js';
1
+ import { T as Task, a as TaskRecurrence, L as LastExtended, I as InputTask } from '../types-CCDLyhAJ.js';
2
2
  import { T as TemplateBodyHelper } from '../body-ADynkNh0.js';
3
3
  import { TaskLayoutHelper, AnyLayoutHelper } from './layouts.js';
4
4
  import { c as TemplateFilter } from '../types-DcoMmjs3.js';
@@ -51,6 +51,9 @@ declare function getLayoutsOfHelpers(taskBody: TaskBodyHelper, templateBody: Tem
51
51
  * @param initial Initial date of the task
52
52
  * @param recurrence The task recurrence
53
53
  *
54
+ * @deprecated Please use the `recurrence` module
55
+ * @see {@link getNextDateFromRecurrence}
56
+ *
54
57
  * @returns The new date of the task
55
58
  */
56
59
  declare function calcNextDateFromRecurrence(initial: Date, recurrence: TaskRecurrence): Date;
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.defineProperty,S=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var x=(e,n,r)=>n in e?A(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,f=(e,n)=>{for(var r in n||(n={}))h.call(n,r)&&x(e,r,n[r]);if(u)for(var r of u(n))H.call(n,r)&&x(e,r,n[r]);return e},m=(e,n)=>S(e,D(n));var y=(e,n)=>{var r={};for(var t in e)h.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&u)for(var t of u(e))n.indexOf(t)<0&&H.call(e,t)&&(r[t]=e[t]);return r};var g=(e,n,r)=>new Promise((t,a)=>{var s=d=>{try{c(r.next(d))}catch(i){a(i)}},o=d=>{try{c(r.throw(d))}catch(i){a(i)}},c=d=>d.done?t(d.value):Promise.resolve(d.value).then(s,o);c((r=r.apply(e,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../decorator-C2gcn2rK.js"),l=require("../methods-DC2Gjy1i.js"),B=require("object-hash"),q=require("date-fns"),L=require("../tasks-hn70eL7B.js");function I(e,n){const r={};switch(n){case"DAILY":r.days=1;break;case"WEEKLY":r.weeks=1;break;case"MONTHLY":r.months=1;break;case"QUARTERLY":r.months=3;break;case"BIENNIAL":r.months=6;break;case"YEARLY":r.years=1;break;default:throw new Error("Recurrence not found")}return q.add(e,r)}function T(e="",n="",r=[],t=[]){var a;return{version:2,dateField:n,inserts:r,filters:new Map((a=t==null?void 0:t.map(s=>[s.name,s]))!=null?a:[]),index:e}}function E(e){var n,r;return T(e.index,e.dateField,(r=(n=e.inserts)==null?void 0:n.map(t=>L.createTaskLayoutHelperFrom(t)))!=null?r:[],e.filters)}function J(e){return{version:e.version,index:e.index,inserts:e.inserts.map(n=>L.taskLayoutHelperToJSON(n)),dateField:e.dateField,filters:Array.from(e.filters.values())}}function k(e,n){if(e.inserts.some(r=>r.id===n.id))throw new Error(`Layout "${n.id}" already exists`);return e.inserts.splice(n.at,0,n),e}function M(e,n){const r=e;return r.inserts=e.inserts.filter(t=>t.id!==n.id),e}function j(e,n,r){const t=e.inserts.findIndex(s=>s.id===n.id);if(t<0)throw new Error(`Layout "${n.id}" not found`);const a=e;return a.inserts[t]=r,e}function O(e){return B({name:e.name,description:e.description,extendedId:e.extendedId,template:e.template,targets:e.targets,recurrence:e.recurrence,nextRun:e.nextRun,enabled:e.enabled})}function w(e="",n="",r="",t="",a,s=[],o="DAILY",c,d=!0,i,F,R="",N=new Date,v){const p={id:R,name:e,description:n,namespaceId:r,extendedId:t,template:a!=null?a:T(),targets:s,recurrence:o,nextRun:c!=null?c:I(new Date,o),enabled:d,lastExtended:i,lastRun:F,createdAt:N,updatedAt:v,hash:""};return p.hash=O(p),p}function C(e){var n;return w(e.name,e.description,e.namespaceId,e.extendedId,E(e.template),e.targets,e.recurrence,e.nextRun,e.enabled,(n=e.lastExtended)!=null?n:void 0,e.lastRun,e.id,e.createdAt,e.updatedAt)}function $(e){return{name:e.name,description:e.description,namespaceId:e.namespaceId,extendedId:e.extendedId,template:J(e.template),targets:e.targets,recurrence:e.recurrence,nextRun:e.nextRun,enabled:e.enabled,lastExtended:e.lastExtended}}function K(e){return e.hash!==O(e)}function P(e,n){const r=n.layouts.map(s=>m(f({},s),{readonly:!0}));for(const t of e.inserts){const a=t,{at:s}=a,o=y(a,["at"]);r.splice(s,0,m(f({},o),{readonly:!1}))}return r}function b(e,n){return g(this,null,function*(){const r=yield l.getTask(e);return yield l.upsertTask({id:r.id,name:r.name,description:r.description,extendedId:r.extendedId,namespaceId:r.namespaceId,nextRun:r.nextRun,recurrence:r.recurrence,targets:r.targets,template:r.template,lastExtended:r.lastExtended,enabled:n})})}Y.assignDependencies(b,[l.getTask,l.upsertTask]);exports.addLayoutOfHelper=k;exports.calcNextDateFromRecurrence=I;exports.changeTaskEnableState=b;exports.createTaskBodyHelper=T;exports.createTaskBodyHelperFrom=E;exports.createTaskHelper=w;exports.createTaskHelperFrom=C;exports.getLayoutsOfHelpers=P;exports.hasTaskChanged=K;exports.removeLayoutOfHelper=M;exports.taskHelperToJSON=$;exports.updateLayoutOfHelper=j;
1
+ "use strict";var A=Object.defineProperty,S=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var h=(e,n,r)=>n in e?A(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,f=(e,n)=>{for(var r in n||(n={}))x.call(n,r)&&h(e,r,n[r]);if(u)for(var r of u(n))H.call(n,r)&&h(e,r,n[r]);return e},m=(e,n)=>S(e,D(n));var g=(e,n)=>{var r={};for(var t in e)x.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&u)for(var t of u(e))n.indexOf(t)<0&&H.call(e,t)&&(r[t]=e[t]);return r};var y=(e,n,r)=>new Promise((t,a)=>{var s=d=>{try{c(r.next(d))}catch(i){a(i)}},o=d=>{try{c(r.throw(d))}catch(i){a(i)}},c=d=>d.done?t(d.value):Promise.resolve(d.value).then(s,o);c((r=r.apply(e,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../decorator-C2gcn2rK.js"),l=require("../methods-B7KR7IhF.js"),B=require("../index-CVa-i8Jy.js"),q=require("date-fns"),L=require("../tasks-C-Si9c_j.js");function I(e,n){const r={};switch(n){case"DAILY":r.days=1;break;case"WEEKLY":r.weeks=1;break;case"MONTHLY":r.months=1;break;case"QUARTERLY":r.months=3;break;case"BIENNIAL":r.months=6;break;case"YEARLY":r.years=1;break;default:throw new Error("Recurrence not found")}return q.add(e,r)}function T(e="",n="",r=[],t=[]){var a;return{version:2,dateField:n,inserts:r,filters:new Map((a=t==null?void 0:t.map(s=>[s.name,s]))!=null?a:[]),index:e}}function E(e){var n,r;return T(e.index,e.dateField,(r=(n=e.inserts)==null?void 0:n.map(t=>L.createTaskLayoutHelperFrom(t)))!=null?r:[],e.filters)}function J(e){return{version:e.version,index:e.index,inserts:e.inserts.map(n=>L.taskLayoutHelperToJSON(n)),dateField:e.dateField,filters:Array.from(e.filters.values())}}function k(e,n){if(e.inserts.some(r=>r.id===n.id))throw new Error(`Layout "${n.id}" already exists`);return e.inserts.splice(n.at,0,n),e}function M(e,n){const r=e;return r.inserts=e.inserts.filter(t=>t.id!==n.id),e}function j(e,n,r){const t=e.inserts.findIndex(s=>s.id===n.id);if(t<0)throw new Error(`Layout "${n.id}" not found`);const a=e;return a.inserts[t]=r,e}function O(e){return B.objectHash({name:e.name,description:e.description,extendedId:e.extendedId,template:e.template,targets:e.targets,recurrence:e.recurrence,nextRun:e.nextRun,enabled:e.enabled})}function w(e="",n="",r="",t="",a,s=[],o="DAILY",c,d=!0,i,F,R="",N=new Date,v){const p={id:R,name:e,description:n,namespaceId:r,extendedId:t,template:a!=null?a:T(),targets:s,recurrence:o,nextRun:c!=null?c:I(new Date,o),enabled:d,lastExtended:i,lastRun:F,createdAt:N,updatedAt:v,hash:""};return p.hash=O(p),p}function C(e){var n;return w(e.name,e.description,e.namespaceId,e.extendedId,E(e.template),e.targets,e.recurrence,e.nextRun,e.enabled,(n=e.lastExtended)!=null?n:void 0,e.lastRun,e.id,e.createdAt,e.updatedAt)}function $(e){return{name:e.name,description:e.description,namespaceId:e.namespaceId,extendedId:e.extendedId,template:J(e.template),targets:e.targets,recurrence:e.recurrence,nextRun:e.nextRun,enabled:e.enabled,lastExtended:e.lastExtended}}function K(e){return e.hash!==O(e)}function P(e,n){const r=n.layouts.map(s=>m(f({},s),{readonly:!0}));for(const t of e.inserts){const a=t,{at:s}=a,o=g(a,["at"]);r.splice(s,0,m(f({},o),{readonly:!1}))}return r}function b(e,n){return y(this,null,function*(){const r=yield l.getTask(e);return yield l.upsertTask({id:r.id,name:r.name,description:r.description,extendedId:r.extendedId,namespaceId:r.namespaceId,nextRun:r.nextRun,recurrence:r.recurrence,targets:r.targets,template:r.template,lastExtended:r.lastExtended,enabled:n})})}Y.assignDependencies(b,[l.getTask,l.upsertTask]);exports.addLayoutOfHelper=k;exports.calcNextDateFromRecurrence=I;exports.changeTaskEnableState=b;exports.createTaskBodyHelper=T;exports.createTaskBodyHelperFrom=E;exports.createTaskHelper=w;exports.createTaskHelperFrom=C;exports.getLayoutsOfHelpers=P;exports.hasTaskChanged=K;exports.removeLayoutOfHelper=M;exports.taskHelperToJSON=$;exports.updateLayoutOfHelper=j;
2
2
  //# sourceMappingURL=tasks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.js","sources":["../../src/helpers/tasks/recurrence.ts","../../src/helpers/tasks/editor/body.ts","../../src/helpers/tasks/editor/index.ts","../../src/helpers/tasks/index.ts"],"sourcesContent":["import { add, type Duration } from 'date-fns';\nimport type { TaskRecurrence } from '~/modules/tasks';\n\n/**\n * Calculate next run date for the task\n *\n * @param initial Initial date of the task\n * @param recurrence The task recurrence\n *\n * @returns The new date of the task\n */\n// eslint-disable-next-line import/prefer-default-export\nexport function calcNextDateFromRecurrence(initial: Date, recurrence: TaskRecurrence): Date {\n const duration: Duration = {};\n\n switch (recurrence) {\n case 'DAILY':\n duration.days = 1;\n break;\n case 'WEEKLY':\n duration.weeks = 1;\n break;\n case 'MONTHLY':\n duration.months = 1;\n break;\n case 'QUARTERLY':\n duration.months = 3;\n break;\n case 'BIENNIAL':\n duration.months = 6;\n break;\n case 'YEARLY':\n duration.years = 1;\n break;\n default:\n throw new Error('Recurrence not found');\n }\n\n return add(initial, duration);\n}\n","import type { TemplateFilter } from '~/modules/templates';\nimport type { Task } from '~/modules/tasks';\n\nimport {\n createTaskLayoutHelperFrom,\n taskLayoutHelperToJSON,\n type TaskLayoutHelper,\n} from '../../templates/editor/layouts';\n\nexport interface TaskBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index: string;\n dateField?: string;\n inserts: TaskLayoutHelper[];\n}\n\nexport function createTaskBodyHelper(\n index: string = '',\n dateField: string = '',\n inserts: TaskLayoutHelper[] = [],\n filters: TemplateFilter[] = [],\n): TaskBodyHelper {\n return {\n version: 2,\n dateField,\n inserts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n index,\n };\n}\n\nexport function createTaskBodyHelperFrom(template: Task['template']): TaskBodyHelper {\n return createTaskBodyHelper(\n template.index,\n template.dateField,\n template.inserts?.map((l) => createTaskLayoutHelperFrom(l)) ?? [],\n template.filters,\n );\n}\n\nexport function taskBodyHelperToJSON(template: TaskBodyHelper): Task['template'] {\n return {\n version: template.version,\n index: template.index,\n inserts: template.inserts.map((l) => taskLayoutHelperToJSON(l)),\n dateField: template.dateField,\n filters: Array.from(template.filters.values()),\n };\n}\n\nexport function addLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper,\n): TaskBodyHelper {\n if (body.inserts.some((l) => l.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.inserts.splice(layout.at, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper,\n): TaskBodyHelper {\n const template = body;\n template.inserts = body.inserts.filter((l) => l.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TaskBodyHelper,\n oldLayout: TaskLayoutHelper,\n newLayout: TaskLayoutHelper,\n): TaskBodyHelper {\n const index = body.inserts.findIndex((l) => l.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.inserts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\n\nimport type { Task } from '~/modules/tasks';\nimport type { InputTask, LastExtended, TaskRecurrence } from '~/modules/tasks/types';\n\nimport type { TemplateBodyHelper } from '../../templates/editor/body';\nimport type { AnyLayoutHelper } from '../../templates/editor/layouts';\nimport { calcNextDateFromRecurrence } from '../recurrence';\nimport {\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n taskBodyHelperToJSON,\n type TaskBodyHelper,\n} from './body';\n\nexport interface TaskHelper {\n readonly id: string;\n name: string;\n description: string;\n namespaceId: string;\n extendedId: string;\n template: TaskBodyHelper;\n targets: string[];\n recurrence: TaskRecurrence;\n nextRun: Date;\n enabled: boolean;\n readonly lastExtended?: LastExtended | null;\n readonly lastRun?: Date;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTask(task: TaskHelper | Task): string {\n return objectHash({\n name: task.name,\n description: task.description,\n extendedId: task.extendedId,\n template: task.template,\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n });\n}\n\nexport function createTaskHelper(\n name: string = '',\n description: string = '',\n namespaceId: string = '',\n extendedId: string = '',\n template?: TaskBodyHelper,\n targets: string[] = [],\n recurrence: TaskRecurrence = 'DAILY',\n nextRun?: Date,\n enabled: boolean = true,\n lastExtended?: LastExtended,\n lastRun?: Date,\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date,\n): TaskHelper {\n const task = {\n id,\n name,\n description,\n namespaceId,\n extendedId,\n template: template ?? createTaskBodyHelper(),\n targets,\n recurrence,\n nextRun: nextRun ?? calcNextDateFromRecurrence(new Date(), recurrence),\n enabled,\n lastExtended,\n lastRun,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n task.hash = hashTask(task);\n\n return task;\n}\n\nexport function createTaskHelperFrom(task: Task): TaskHelper {\n return createTaskHelper(\n task.name,\n task.description,\n task.namespaceId,\n task.extendedId,\n createTaskBodyHelperFrom(task.template),\n task.targets,\n task.recurrence,\n task.nextRun,\n task.enabled,\n task.lastExtended ?? undefined,\n task.lastRun,\n task.id,\n task.createdAt,\n task.updatedAt,\n );\n}\n\nexport function taskHelperToJSON(task: TaskHelper): InputTask {\n return {\n name: task.name,\n description: task.description,\n namespaceId: task.namespaceId,\n extendedId: task.extendedId,\n template: taskBodyHelperToJSON(task.template),\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n lastExtended: task.lastExtended,\n };\n}\n\nexport function hasTaskChanged(task: TaskHelper): boolean {\n return task.hash !== hashTask(task);\n}\n\nexport function getLayoutsOfHelpers(\n taskBody: TaskBodyHelper,\n templateBody: TemplateBodyHelper,\n): (AnyLayoutHelper & { readonly: boolean })[] {\n const layouts = templateBody.layouts.map((l) => ({ ...l, readonly: true }));\n // eslint-disable-next-line no-restricted-syntax\n for (const { at, ...layout } of taskBody.inserts) {\n layouts.splice(at, 0, { ...layout, readonly: false });\n }\n return layouts;\n}\n\nexport {\n type TaskBodyHelper,\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\n","import { assignDependencies } from '~/helpers/permissions/decorator';\n\nimport { getTask, upsertTask, type Task } from '~/modules/tasks';\n\nexport * from './editor';\nexport * from './recurrence';\n\n/**\n * Change enable state of a task\n *\n * @param taskOrId Task or Task's id\n * @param enabled New state\n *\n * @returns Updated task\n */\n// eslint-disable-next-line import/prefer-default-export\nexport async function changeTaskEnableState(\n taskOrId: Omit<Task, 'template'> | string,\n enabled: boolean,\n): Promise<Task> {\n const base = await getTask(taskOrId);\n\n const task = await upsertTask({\n id: base.id,\n name: base.name,\n description: base.description,\n extendedId: base.extendedId,\n namespaceId: base.namespaceId,\n nextRun: base.nextRun,\n recurrence: base.recurrence,\n targets: base.targets,\n template: base.template,\n lastExtended: base.lastExtended,\n enabled,\n });\n\n return task;\n}\nassignDependencies(changeTaskEnableState, [getTask, upsertTask]);\n"],"names":["calcNextDateFromRecurrence","initial","recurrence","duration","add","createTaskBodyHelper","index","dateField","inserts","filters","_a","filter","createTaskBodyHelperFrom","template","_b","l","createTaskLayoutHelperFrom","taskBodyHelperToJSON","taskLayoutHelperToJSON","addLayoutOfHelper","body","layout","removeLayoutOfHelper","updateLayoutOfHelper","oldLayout","newLayout","hashTask","task","objectHash","createTaskHelper","name","description","namespaceId","extendedId","targets","nextRun","enabled","lastExtended","lastRun","id","createdAt","updatedAt","createTaskHelperFrom","taskHelperToJSON","hasTaskChanged","getLayoutsOfHelpers","taskBody","templateBody","layouts","__spreadProps","__spreadValues","at","__objRest","changeTaskEnableState","taskOrId","__async","base","getTask","upsertTask","assignDependencies"],"mappings":"6gCAYgB,SAAAA,EAA2BC,EAAeC,EAAkC,CAC1F,MAAMC,EAAqB,CAAC,EAE5B,OAAQD,EAAY,CAClB,IAAK,QACHC,EAAS,KAAO,EAChB,MACF,IAAK,SACHA,EAAS,MAAQ,EACjB,MACF,IAAK,UACHA,EAAS,OAAS,EAClB,MACF,IAAK,YACHA,EAAS,OAAS,EAClB,MACF,IAAK,WACHA,EAAS,OAAS,EAClB,MACF,IAAK,SACHA,EAAS,MAAQ,EACjB,MACF,QACQ,MAAA,IA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,YAAaA,EAAK,YAClB,YAAaA,EAAK,YAClB,WAAYA,EAAK,WACjB,SAAUV,EAAqBU,EAAK,QAAQ,EAC5C,QAASA,EAAK,QACd,WAAYA,EAAK,WACjB,QAASA,EAAK,QACd,QAASA,EAAK,QACd,aAAcA,EAAK,YACrB,CACF,CAEO,SAASiB,EAAejB,EAA2B,CACjD,OAAAA,EAAK,OAASD,EAASC,CAAI,CACpC,CAEgB,SAAAkB,EACdC,EACAC,EAC6C,CACvC,MAAAC,EAAUD,EAAa,QAAQ,IAAKhC,GAAOkC,EAAAC,EAAA,GAAKnC,GAAL,CAAQ,SAAU,EAAO,EAAA,EAE1E,UAAWL,KAAqBoC,EAAS,QAC/B,CADV,MAAAhC,EAAAJ,EAAa,IAAAyC,GAAbrC,EAAoBO,EAAA+B,EAApBtC,EAAoB,CAAP,OACHkC,EAAA,OAAOG,EAAI,EAAGF,EAAAC,EAAA,GAAK7B,GAAL,CAAa,SAAU,IAAO,EAE/C,OAAA2B,CACT,CCrHsB,SAAAK,EACpBC,EACAlB,EACe,QAAAmB,EAAA,sBACT,MAAAC,EAAO,MAAMC,EAAA,QAAQH,CAAQ,EAgB5B,OAdM,MAAMI,aAAW,CAC5B,GAAIF,EAAK,GACT,KAAMA,EAAK,KACX,YAAaA,EAAK,YAClB,WAAYA,EAAK,WACjB,YAAaA,EAAK,YAClB,QAASA,EAAK,QACd,WAAYA,EAAK,WACjB,QAASA,EAAK,QACd,SAAUA,EAAK,SACf,aAAcA,EAAK,aACnB,QAAApB,CAAA,CACD,CAGH,GACAuB,EAAA,mBAAmBN,EAAuB,CAACI,UAASC,EAAAA,UAAU,CAAC"}
1
+ {"version":3,"file":"tasks.js","sources":["../../src/helpers/tasks/recurrence.ts","../../src/helpers/tasks/editor/body.ts","../../src/helpers/tasks/editor/index.ts","../../src/helpers/tasks/index.ts"],"sourcesContent":["import { add, type Duration } from 'date-fns';\nimport type { TaskRecurrence } from '~/modules/tasks';\n\n/**\n * Calculate next run date for the task\n *\n * @param initial Initial date of the task\n * @param recurrence The task recurrence\n *\n * @deprecated Please use the `recurrence` module\n * @see {@link getNextDateFromRecurrence}\n *\n * @returns The new date of the task\n */\nexport function calcNextDateFromRecurrence(\n initial: Date,\n recurrence: TaskRecurrence\n): Date {\n const duration: Duration = {};\n\n switch (recurrence) {\n case 'DAILY':\n duration.days = 1;\n break;\n case 'WEEKLY':\n duration.weeks = 1;\n break;\n case 'MONTHLY':\n duration.months = 1;\n break;\n case 'QUARTERLY':\n duration.months = 3;\n break;\n case 'BIENNIAL':\n duration.months = 6;\n break;\n case 'YEARLY':\n duration.years = 1;\n break;\n default:\n throw new Error('Recurrence not found');\n }\n\n return add(initial, duration);\n}\n","import type { TemplateFilter } from '~/modules/templates';\nimport type { Task } from '~/modules/tasks';\n\nimport {\n createTaskLayoutHelperFrom,\n taskLayoutHelperToJSON,\n type TaskLayoutHelper,\n} from '../../templates/editor/layouts';\n\nexport interface TaskBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index: string;\n dateField?: string;\n inserts: TaskLayoutHelper[];\n}\n\nexport function createTaskBodyHelper(\n index: string = '',\n dateField: string = '',\n inserts: TaskLayoutHelper[] = [],\n filters: TemplateFilter[] = []\n): TaskBodyHelper {\n return {\n version: 2,\n dateField,\n inserts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n index,\n };\n}\n\nexport function createTaskBodyHelperFrom(\n template: Task['template']\n): TaskBodyHelper {\n return createTaskBodyHelper(\n template.index,\n template.dateField,\n template.inserts?.map((lay) => createTaskLayoutHelperFrom(lay)) ?? [],\n template.filters\n );\n}\n\nexport function taskBodyHelperToJSON(\n template: TaskBodyHelper\n): Task['template'] {\n return {\n version: template.version,\n index: template.index,\n inserts: template.inserts.map((lay) => taskLayoutHelperToJSON(lay)),\n dateField: template.dateField,\n filters: Array.from(template.filters.values()),\n };\n}\n\nexport function addLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper\n): TaskBodyHelper {\n if (body.inserts.some((lay) => lay.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.inserts.splice(layout.at, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper\n): TaskBodyHelper {\n const template = body;\n template.inserts = body.inserts.filter((lay) => lay.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TaskBodyHelper,\n oldLayout: TaskLayoutHelper,\n newLayout: TaskLayoutHelper\n): TaskBodyHelper {\n const index = body.inserts.findIndex((lay) => lay.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.inserts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\n\nimport type { Task } from '~/modules/tasks';\nimport type {\n InputTask,\n LastExtended,\n TaskRecurrence,\n} from '~/modules/tasks/types';\n\nimport type { TemplateBodyHelper } from '../../templates/editor/body';\nimport type { AnyLayoutHelper } from '../../templates/editor/layouts';\nimport { calcNextDateFromRecurrence } from '../recurrence';\nimport {\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n taskBodyHelperToJSON,\n type TaskBodyHelper,\n} from './body';\n\nexport interface TaskHelper {\n readonly id: string;\n name: string;\n description: string;\n namespaceId: string;\n extendedId: string;\n template: TaskBodyHelper;\n targets: string[];\n recurrence: TaskRecurrence;\n nextRun: Date;\n enabled: boolean;\n readonly lastExtended?: LastExtended | null;\n readonly lastRun?: Date;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTask(task: TaskHelper | Task): string {\n return objectHash({\n name: task.name,\n description: task.description,\n extendedId: task.extendedId,\n template: task.template,\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n });\n}\n\nexport function createTaskHelper(\n name: string = '',\n description: string = '',\n namespaceId: string = '',\n extendedId: string = '',\n template?: TaskBodyHelper,\n targets: string[] = [],\n recurrence: TaskRecurrence = 'DAILY',\n nextRun?: Date,\n enabled: boolean = true,\n lastExtended?: LastExtended,\n lastRun?: Date,\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date\n): TaskHelper {\n const task = {\n id,\n name,\n description,\n namespaceId,\n extendedId,\n template: template ?? createTaskBodyHelper(),\n targets,\n recurrence,\n nextRun: nextRun ?? calcNextDateFromRecurrence(new Date(), recurrence),\n enabled,\n lastExtended,\n lastRun,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n task.hash = hashTask(task);\n\n return task;\n}\n\nexport function createTaskHelperFrom(task: Task): TaskHelper {\n return createTaskHelper(\n task.name,\n task.description,\n task.namespaceId,\n task.extendedId,\n createTaskBodyHelperFrom(task.template),\n task.targets,\n task.recurrence,\n task.nextRun,\n task.enabled,\n task.lastExtended ?? undefined,\n task.lastRun,\n task.id,\n task.createdAt,\n task.updatedAt\n );\n}\n\nexport function taskHelperToJSON(task: TaskHelper): InputTask {\n return {\n name: task.name,\n description: task.description,\n namespaceId: task.namespaceId,\n extendedId: task.extendedId,\n template: taskBodyHelperToJSON(task.template),\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n lastExtended: task.lastExtended,\n };\n}\n\nexport function hasTaskChanged(task: TaskHelper): boolean {\n return task.hash !== hashTask(task);\n}\n\nexport function getLayoutsOfHelpers(\n taskBody: TaskBodyHelper,\n templateBody: TemplateBodyHelper\n): (AnyLayoutHelper & { readonly: boolean })[] {\n const layouts = templateBody.layouts.map((lay) => ({\n ...lay,\n readonly: true,\n }));\n for (const { at, ...layout } of taskBody.inserts) {\n layouts.splice(at, 0, { ...layout, readonly: false });\n }\n return layouts;\n}\n\nexport {\n type TaskBodyHelper,\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\n","import { assignDependencies } from '~/helpers/permissions/decorator';\n\nimport { getTask, upsertTask, type Task } from '~/modules/tasks';\n\nexport * from './editor';\nexport * from './recurrence';\n\n/**\n * Change enable state of a task\n *\n * @param taskOrId Task or Task's id\n * @param enabled New state\n *\n * @returns Updated task\n */\nexport async function changeTaskEnableState(\n taskOrId: Omit<Task, 'template'> | string,\n enabled: boolean\n): Promise<Task> {\n const base = await getTask(taskOrId);\n\n const task = await upsertTask({\n id: base.id,\n name: base.name,\n description: base.description,\n extendedId: base.extendedId,\n namespaceId: base.namespaceId,\n nextRun: base.nextRun,\n recurrence: base.recurrence,\n targets: base.targets,\n template: base.template,\n lastExtended: base.lastExtended,\n enabled,\n });\n\n return task;\n}\nassignDependencies(changeTaskEnableState, [getTask, upsertTask]);\n"],"names":["calcNextDateFromRecurrence","initial","recurrence","duration","add","createTaskBodyHelper","index","dateField","inserts","filters","_a","filter","createTaskBodyHelperFrom","template","_b","lay","createTaskLayoutHelperFrom","taskBodyHelperToJSON","taskLayoutHelperToJSON","addLayoutOfHelper","body","layout","removeLayoutOfHelper","updateLayoutOfHelper","oldLayout","newLayout","hashTask","task","objectHash","createTaskHelper","name","description","namespaceId","extendedId","targets","nextRun","enabled","lastExtended","lastRun","id","createdAt","updatedAt","createTaskHelperFrom","taskHelperToJSON","hasTaskChanged","getLayoutsOfHelpers","taskBody","templateBody","layouts","__spreadProps","__spreadValues","at","__objRest","changeTaskEnableState","taskOrId","__async","base","getTask","upsertTask","assignDependencies"],"mappings":"shCAcO,SAASA,EACdC,EACAC,EACM,CACN,MAAMC,EAAqB,CAAA,EAE3B,OAAQD,EAAA,CACN,IAAK,QACHC,EAAS,KAAO,EAChB,MACF,IAAK,SACHA,EAAS,MAAQ,EACjB,MACF,IAAK,UACHA,EAAS,OAAS,EAClB,MACF,IAAK,YACHA,EAAS,OAAS,EAClB,MACF,IAAK,WACHA,EAAS,OAAS,EAClB,MACF,IAAK,SACHA,EAAS,MAAQ,EACjB,MACF,QACE,MAAM,IAAI,MAAM,sBAAsB,CAAA,CAG1C,OAAOC,EAAAA,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SAAUV,EAAqBU,EAAK,QAAQ,EAC5C,QAASA,EAAK,QACd,WAAYA,EAAK,WACjB,QAASA,EAAK,QACd,QAASA,EAAK,QACd,aAAcA,EAAK,YAAA,CAEvB,CAEO,SAASiB,EAAejB,EAA2B,CACxD,OAAOA,EAAK,OAASD,EAASC,CAAI,CACpC,CAEO,SAASkB,EACdC,EACAC,EAC6C,CAC7C,MAAMC,EAAUD,EAAa,QAAQ,IAAKhC,GAASkC,EAAAC,EAAA,GAC9CnC,GAD8C,CAEjD,SAAU,EAAA,EACV,EACF,UAAWL,KAAqBoC,EAAS,QACvC,CADF,MAAAhC,EAAAJ,EAAa,IAAAyC,GAAbrC,EAAoBO,EAAA+B,EAApBtC,EAAoB,CAAP,OACXkC,EAAQ,OAAOG,EAAI,EAAGF,EAAAC,EAAA,GAAK7B,GAAL,CAAa,SAAU,IAAO,EAEtD,OAAO2B,CACT,CC5HA,SAAsBK,EACpBC,EACAlB,EACe,QAAAmB,EAAA,sBACf,MAAMC,EAAO,MAAMC,EAAAA,QAAQH,CAAQ,EAgBnC,OAda,MAAMI,aAAW,CAC5B,GAAIF,EAAK,GACT,KAAMA,EAAK,KACX,YAAaA,EAAK,YAClB,WAAYA,EAAK,WACjB,YAAaA,EAAK,YAClB,QAASA,EAAK,QACd,WAAYA,EAAK,WACjB,QAASA,EAAK,QACd,SAAUA,EAAK,SACf,aAAcA,EAAK,aACnB,QAAApB,CAAA,CACD,CAGH,GACAuB,EAAAA,mBAAmBN,EAAuB,CAACI,UAASC,EAAAA,UAAU,CAAC"}
@@ -22,24 +22,24 @@ var I = (e, r) => {
22
22
  var T = (e, r, n) => new Promise((t, a) => {
23
23
  var d = (s) => {
24
24
  try {
25
- i(n.next(s));
25
+ o(n.next(s));
26
26
  } catch (c) {
27
27
  a(c);
28
28
  }
29
- }, o = (s) => {
29
+ }, i = (s) => {
30
30
  try {
31
- i(n.throw(s));
31
+ o(n.throw(s));
32
32
  } catch (c) {
33
33
  a(c);
34
34
  }
35
- }, i = (s) => s.done ? t(s.value) : Promise.resolve(s.value).then(d, o);
36
- i((n = n.apply(e, r)).next());
35
+ }, o = (s) => s.done ? t(s.value) : Promise.resolve(s.value).then(d, i);
36
+ o((n = n.apply(e, r)).next());
37
37
  });
38
- import { b as N } from "../decorator-DBkj--6g.mjs";
39
- import { a as E, u as H } from "../methods-sTFYWEAr.mjs";
40
- import Y from "object-hash";
38
+ import { b as N } from "../decorator-DCiVxI72.mjs";
39
+ import { a as E, u as H } from "../methods-DtUaMG7I.mjs";
40
+ import { o as Y } from "../index-CqG3FOrT.mjs";
41
41
  import { add as v } from "date-fns";
42
- import { a as D, t as B } from "../tasks-1x680qAf.mjs";
42
+ import { a as D, t as B } from "../tasks-rnhGl39m.mjs";
43
43
  function S(e, r) {
44
44
  const n = {};
45
45
  switch (r) {
@@ -122,7 +122,7 @@ function w(e) {
122
122
  enabled: e.enabled
123
123
  });
124
124
  }
125
- function $(e = "", r = "", n = "", t = "", a, d = [], o = "DAILY", i, s = !0, c, g, y = "", R = /* @__PURE__ */ new Date(), b) {
125
+ function $(e = "", r = "", n = "", t = "", a, d = [], i = "DAILY", o, s = !0, c, g, y = "", R = /* @__PURE__ */ new Date(), b) {
126
126
  const p = {
127
127
  id: y,
128
128
  name: e,
@@ -131,8 +131,8 @@ function $(e = "", r = "", n = "", t = "", a, d = [], o = "DAILY", i, s = !0, c,
131
131
  extendedId: t,
132
132
  template: a != null ? a : L(),
133
133
  targets: d,
134
- recurrence: o,
135
- nextRun: i != null ? i : S(/* @__PURE__ */ new Date(), o),
134
+ recurrence: i,
135
+ nextRun: o != null ? o : S(/* @__PURE__ */ new Date(), i),
136
136
  enabled: s,
137
137
  lastExtended: c,
138
138
  lastRun: g,
@@ -179,10 +179,12 @@ function Z(e) {
179
179
  return e.hash !== w(e);
180
180
  }
181
181
  function _(e, r) {
182
- const n = r.layouts.map((d) => l(m({}, d), { readonly: !0 }));
182
+ const n = r.layouts.map((d) => l(m({}, d), {
183
+ readonly: !0
184
+ }));
183
185
  for (const t of e.inserts) {
184
- const a = t, { at: d } = a, o = I(a, ["at"]);
185
- n.splice(d, 0, l(m({}, o), { readonly: !1 }));
186
+ const a = t, { at: d } = a, i = I(a, ["at"]);
187
+ n.splice(d, 0, l(m({}, i), { readonly: !1 }));
186
188
  }
187
189
  return n;
188
190
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.mjs","sources":["../../src/helpers/tasks/recurrence.ts","../../src/helpers/tasks/editor/body.ts","../../src/helpers/tasks/editor/index.ts","../../src/helpers/tasks/index.ts"],"sourcesContent":["import { add, type Duration } from 'date-fns';\nimport type { TaskRecurrence } from '~/modules/tasks';\n\n/**\n * Calculate next run date for the task\n *\n * @param initial Initial date of the task\n * @param recurrence The task recurrence\n *\n * @returns The new date of the task\n */\n// eslint-disable-next-line import/prefer-default-export\nexport function calcNextDateFromRecurrence(initial: Date, recurrence: TaskRecurrence): Date {\n const duration: Duration = {};\n\n switch (recurrence) {\n case 'DAILY':\n duration.days = 1;\n break;\n case 'WEEKLY':\n duration.weeks = 1;\n break;\n case 'MONTHLY':\n duration.months = 1;\n break;\n case 'QUARTERLY':\n duration.months = 3;\n break;\n case 'BIENNIAL':\n duration.months = 6;\n break;\n case 'YEARLY':\n duration.years = 1;\n break;\n default:\n throw new Error('Recurrence not found');\n }\n\n return add(initial, duration);\n}\n","import type { TemplateFilter } from '~/modules/templates';\nimport type { Task } from '~/modules/tasks';\n\nimport {\n createTaskLayoutHelperFrom,\n taskLayoutHelperToJSON,\n type TaskLayoutHelper,\n} from '../../templates/editor/layouts';\n\nexport interface TaskBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index: string;\n dateField?: string;\n inserts: TaskLayoutHelper[];\n}\n\nexport function createTaskBodyHelper(\n index: string = '',\n dateField: string = '',\n inserts: TaskLayoutHelper[] = [],\n filters: TemplateFilter[] = [],\n): TaskBodyHelper {\n return {\n version: 2,\n dateField,\n inserts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n index,\n };\n}\n\nexport function createTaskBodyHelperFrom(template: Task['template']): TaskBodyHelper {\n return createTaskBodyHelper(\n template.index,\n template.dateField,\n template.inserts?.map((l) => createTaskLayoutHelperFrom(l)) ?? [],\n template.filters,\n );\n}\n\nexport function taskBodyHelperToJSON(template: TaskBodyHelper): Task['template'] {\n return {\n version: template.version,\n index: template.index,\n inserts: template.inserts.map((l) => taskLayoutHelperToJSON(l)),\n dateField: template.dateField,\n filters: Array.from(template.filters.values()),\n };\n}\n\nexport function addLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper,\n): TaskBodyHelper {\n if (body.inserts.some((l) => l.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.inserts.splice(layout.at, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper,\n): TaskBodyHelper {\n const template = body;\n template.inserts = body.inserts.filter((l) => l.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TaskBodyHelper,\n oldLayout: TaskLayoutHelper,\n newLayout: TaskLayoutHelper,\n): TaskBodyHelper {\n const index = body.inserts.findIndex((l) => l.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.inserts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\n\nimport type { Task } from '~/modules/tasks';\nimport type { InputTask, LastExtended, TaskRecurrence } from '~/modules/tasks/types';\n\nimport type { TemplateBodyHelper } from '../../templates/editor/body';\nimport type { AnyLayoutHelper } from '../../templates/editor/layouts';\nimport { calcNextDateFromRecurrence } from '../recurrence';\nimport {\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n taskBodyHelperToJSON,\n type TaskBodyHelper,\n} from './body';\n\nexport interface TaskHelper {\n readonly id: string;\n name: string;\n description: string;\n namespaceId: string;\n extendedId: string;\n template: TaskBodyHelper;\n targets: string[];\n recurrence: TaskRecurrence;\n nextRun: Date;\n enabled: boolean;\n readonly lastExtended?: LastExtended | null;\n readonly lastRun?: Date;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTask(task: TaskHelper | Task): string {\n return objectHash({\n name: task.name,\n description: task.description,\n extendedId: task.extendedId,\n template: task.template,\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n });\n}\n\nexport function createTaskHelper(\n name: string = '',\n description: string = '',\n namespaceId: string = '',\n extendedId: string = '',\n template?: TaskBodyHelper,\n targets: string[] = [],\n recurrence: TaskRecurrence = 'DAILY',\n nextRun?: Date,\n enabled: boolean = true,\n lastExtended?: LastExtended,\n lastRun?: Date,\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date,\n): TaskHelper {\n const task = {\n id,\n name,\n description,\n namespaceId,\n extendedId,\n template: template ?? createTaskBodyHelper(),\n targets,\n recurrence,\n nextRun: nextRun ?? calcNextDateFromRecurrence(new Date(), recurrence),\n enabled,\n lastExtended,\n lastRun,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n task.hash = hashTask(task);\n\n return task;\n}\n\nexport function createTaskHelperFrom(task: Task): TaskHelper {\n return createTaskHelper(\n task.name,\n task.description,\n task.namespaceId,\n task.extendedId,\n createTaskBodyHelperFrom(task.template),\n task.targets,\n task.recurrence,\n task.nextRun,\n task.enabled,\n task.lastExtended ?? undefined,\n task.lastRun,\n task.id,\n task.createdAt,\n task.updatedAt,\n );\n}\n\nexport function taskHelperToJSON(task: TaskHelper): InputTask {\n return {\n name: task.name,\n description: task.description,\n namespaceId: task.namespaceId,\n extendedId: task.extendedId,\n template: taskBodyHelperToJSON(task.template),\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n lastExtended: task.lastExtended,\n };\n}\n\nexport function hasTaskChanged(task: TaskHelper): boolean {\n return task.hash !== hashTask(task);\n}\n\nexport function getLayoutsOfHelpers(\n taskBody: TaskBodyHelper,\n templateBody: TemplateBodyHelper,\n): (AnyLayoutHelper & { readonly: boolean })[] {\n const layouts = templateBody.layouts.map((l) => ({ ...l, readonly: true }));\n // eslint-disable-next-line no-restricted-syntax\n for (const { at, ...layout } of taskBody.inserts) {\n layouts.splice(at, 0, { ...layout, readonly: false });\n }\n return layouts;\n}\n\nexport {\n type TaskBodyHelper,\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\n","import { assignDependencies } from '~/helpers/permissions/decorator';\n\nimport { getTask, upsertTask, type Task } from '~/modules/tasks';\n\nexport * from './editor';\nexport * from './recurrence';\n\n/**\n * Change enable state of a task\n *\n * @param taskOrId Task or Task's id\n * @param enabled New state\n *\n * @returns Updated task\n */\n// eslint-disable-next-line import/prefer-default-export\nexport async function changeTaskEnableState(\n taskOrId: Omit<Task, 'template'> | string,\n enabled: boolean,\n): Promise<Task> {\n const base = await getTask(taskOrId);\n\n const task = await upsertTask({\n id: base.id,\n name: base.name,\n description: base.description,\n extendedId: base.extendedId,\n namespaceId: base.namespaceId,\n nextRun: base.nextRun,\n recurrence: base.recurrence,\n targets: base.targets,\n template: base.template,\n lastExtended: base.lastExtended,\n enabled,\n });\n\n return task;\n}\nassignDependencies(changeTaskEnableState, [getTask, upsertTask]);\n"],"names":["calcNextDateFromRecurrence","initial","recurrence","duration","add","createTaskBodyHelper","index","dateField","inserts","filters","_a","filter","createTaskBodyHelperFrom","template","_b","l","createTaskLayoutHelperFrom","taskBodyHelperToJSON","taskLayoutHelperToJSON","addLayoutOfHelper","body","layout","removeLayoutOfHelper","updateLayoutOfHelper","oldLayout","newLayout","hashTask","task","objectHash","createTaskHelper","name","description","namespaceId","extendedId","targets","nextRun","enabled","lastExtended","lastRun","id","createdAt","updatedAt","createTaskHelperFrom","taskHelperToJSON","hasTaskChanged","getLayoutsOfHelpers","taskBody","templateBody","layouts","__spreadProps","__spreadValues","at","__objRest","changeTaskEnableState","taskOrId","__async","base","getTask","upsertTask","assignDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYgB,SAAAA,EAA2BC,GAAeC,GAAkC;AAC1F,QAAMC,IAAqB,CAAC;AAE5B,UAAQD,GAAY;AAAA,IAClB,KAAK;AACH,MAAAC,EAAS,OAAO;AAChB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,QAAQ;AACjB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,SAAS;AAClB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,SAAS;AAClB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,SAAS;AAClB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,QAAQ;AACjB;AAAA,IACF;AACQ,YAAA,IAAI,MAAM,sBAAsB;AAAA,EAAA;AAGnC,SAAAC,EAAIH,GAASE,CAAQ;AAC9B;ACtBgB,SAAAE,EACdC,IAAgB,IAChBC,IAAoB,IACpBC,IAA8B,CAAA,GAC9BC,IAA4B,IACZ;;AACT,SAAA;AAAA,IACL,SAAS;AAAA,IACT,WAAAF;AAAA,IACA,SAAAC;AAAA,IACA,SAAS,IAAI,KAAIE,IAAAD,KAAA,gBAAAA,EAAS,IAAI,CAACE,MAAW,CAACA,EAAO,MAAMA,CAAM,OAA7C,OAAAD,IAAmD,CAAA,CAAE;AAAA,IACtE,OAAAJ;AAAA,EACF;AACF;AAEO,SAASM,EAAyBC,GAA4C;;AAC5E,SAAAR;AAAA,IACLQ,EAAS;AAAA,IACTA,EAAS;AAAA,KACTC,KAAAJ,IAAAG,EAAS,YAAT,gBAAAH,EAAkB,IAAI,CAACK,MAAMC,EAA2BD,CAAC,OAAzD,OAAAD,IAA+D,CAAC;AAAA,IAChED,EAAS;AAAA,EACX;AACF;AAEO,SAASI,EAAqBJ,GAA4C;AACxE,SAAA;AAAA,IACL,SAASA,EAAS;AAAA,IAClB,OAAOA,EAAS;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AEgB,SAAAkB,EACdC,GACAC,GAC6C;AACvC,QAAAC,IAAUD,EAAa,QAAQ,IAAI,CAAChC,MAAOkC,EAAAC,EAAA,IAAKnC,IAAL,EAAQ,UAAU,GAAO,EAAA;AAE1E,aAAWL,KAAqBoC,EAAS,SAC/B;AADV,UAAAhC,IAAAJ,GAAa,MAAAyC,MAAbrC,GAAoBO,IAAA+B,EAApBtC,GAAoB,CAAP;AACH,IAAAkC,EAAA,OAAOG,GAAI,GAAGF,EAAAC,EAAA,IAAK7B,IAAL,EAAa,UAAU,KAAO;AAAA;AAE/C,SAAA2B;AACT;ACrHsB,SAAAK,EACpBC,GACAlB,GACe;AAAA,SAAAmB,EAAA;AACT,UAAAC,IAAO,MAAMC,EAAQH,CAAQ;AAgB5B,WAdM,MAAMI,EAAW;AAAA,MAC5B,IAAIF,EAAK;AAAA,MACT,MAAMA,EAAK;AAAA,MACX,aAAaA,EAAK;AAAA,MAClB,YAAYA,EAAK;AAAA,MACjB,aAAaA,EAAK;AAAA,MAClB,SAASA,EAAK;AAAA,MACd,YAAYA,EAAK;AAAA,MACjB,SAASA,EAAK;AAAA,MACd,UAAUA,EAAK;AAAA,MACf,cAAcA,EAAK;AAAA,MACnB,SAAApB;AAAA,IAAA,CACD;AAAA,EAGH;AAAA;AACAuB,EAAmBN,GAAuB,CAACI,GAASC,CAAU,CAAC;"}
1
+ {"version":3,"file":"tasks.mjs","sources":["../../src/helpers/tasks/recurrence.ts","../../src/helpers/tasks/editor/body.ts","../../src/helpers/tasks/editor/index.ts","../../src/helpers/tasks/index.ts"],"sourcesContent":["import { add, type Duration } from 'date-fns';\nimport type { TaskRecurrence } from '~/modules/tasks';\n\n/**\n * Calculate next run date for the task\n *\n * @param initial Initial date of the task\n * @param recurrence The task recurrence\n *\n * @deprecated Please use the `recurrence` module\n * @see {@link getNextDateFromRecurrence}\n *\n * @returns The new date of the task\n */\nexport function calcNextDateFromRecurrence(\n initial: Date,\n recurrence: TaskRecurrence\n): Date {\n const duration: Duration = {};\n\n switch (recurrence) {\n case 'DAILY':\n duration.days = 1;\n break;\n case 'WEEKLY':\n duration.weeks = 1;\n break;\n case 'MONTHLY':\n duration.months = 1;\n break;\n case 'QUARTERLY':\n duration.months = 3;\n break;\n case 'BIENNIAL':\n duration.months = 6;\n break;\n case 'YEARLY':\n duration.years = 1;\n break;\n default:\n throw new Error('Recurrence not found');\n }\n\n return add(initial, duration);\n}\n","import type { TemplateFilter } from '~/modules/templates';\nimport type { Task } from '~/modules/tasks';\n\nimport {\n createTaskLayoutHelperFrom,\n taskLayoutHelperToJSON,\n type TaskLayoutHelper,\n} from '../../templates/editor/layouts';\n\nexport interface TaskBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index: string;\n dateField?: string;\n inserts: TaskLayoutHelper[];\n}\n\nexport function createTaskBodyHelper(\n index: string = '',\n dateField: string = '',\n inserts: TaskLayoutHelper[] = [],\n filters: TemplateFilter[] = []\n): TaskBodyHelper {\n return {\n version: 2,\n dateField,\n inserts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n index,\n };\n}\n\nexport function createTaskBodyHelperFrom(\n template: Task['template']\n): TaskBodyHelper {\n return createTaskBodyHelper(\n template.index,\n template.dateField,\n template.inserts?.map((lay) => createTaskLayoutHelperFrom(lay)) ?? [],\n template.filters\n );\n}\n\nexport function taskBodyHelperToJSON(\n template: TaskBodyHelper\n): Task['template'] {\n return {\n version: template.version,\n index: template.index,\n inserts: template.inserts.map((lay) => taskLayoutHelperToJSON(lay)),\n dateField: template.dateField,\n filters: Array.from(template.filters.values()),\n };\n}\n\nexport function addLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper\n): TaskBodyHelper {\n if (body.inserts.some((lay) => lay.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.inserts.splice(layout.at, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TaskBodyHelper,\n layout: TaskLayoutHelper\n): TaskBodyHelper {\n const template = body;\n template.inserts = body.inserts.filter((lay) => lay.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TaskBodyHelper,\n oldLayout: TaskLayoutHelper,\n newLayout: TaskLayoutHelper\n): TaskBodyHelper {\n const index = body.inserts.findIndex((lay) => lay.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.inserts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\n\nimport type { Task } from '~/modules/tasks';\nimport type {\n InputTask,\n LastExtended,\n TaskRecurrence,\n} from '~/modules/tasks/types';\n\nimport type { TemplateBodyHelper } from '../../templates/editor/body';\nimport type { AnyLayoutHelper } from '../../templates/editor/layouts';\nimport { calcNextDateFromRecurrence } from '../recurrence';\nimport {\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n taskBodyHelperToJSON,\n type TaskBodyHelper,\n} from './body';\n\nexport interface TaskHelper {\n readonly id: string;\n name: string;\n description: string;\n namespaceId: string;\n extendedId: string;\n template: TaskBodyHelper;\n targets: string[];\n recurrence: TaskRecurrence;\n nextRun: Date;\n enabled: boolean;\n readonly lastExtended?: LastExtended | null;\n readonly lastRun?: Date;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTask(task: TaskHelper | Task): string {\n return objectHash({\n name: task.name,\n description: task.description,\n extendedId: task.extendedId,\n template: task.template,\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n });\n}\n\nexport function createTaskHelper(\n name: string = '',\n description: string = '',\n namespaceId: string = '',\n extendedId: string = '',\n template?: TaskBodyHelper,\n targets: string[] = [],\n recurrence: TaskRecurrence = 'DAILY',\n nextRun?: Date,\n enabled: boolean = true,\n lastExtended?: LastExtended,\n lastRun?: Date,\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date\n): TaskHelper {\n const task = {\n id,\n name,\n description,\n namespaceId,\n extendedId,\n template: template ?? createTaskBodyHelper(),\n targets,\n recurrence,\n nextRun: nextRun ?? calcNextDateFromRecurrence(new Date(), recurrence),\n enabled,\n lastExtended,\n lastRun,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n task.hash = hashTask(task);\n\n return task;\n}\n\nexport function createTaskHelperFrom(task: Task): TaskHelper {\n return createTaskHelper(\n task.name,\n task.description,\n task.namespaceId,\n task.extendedId,\n createTaskBodyHelperFrom(task.template),\n task.targets,\n task.recurrence,\n task.nextRun,\n task.enabled,\n task.lastExtended ?? undefined,\n task.lastRun,\n task.id,\n task.createdAt,\n task.updatedAt\n );\n}\n\nexport function taskHelperToJSON(task: TaskHelper): InputTask {\n return {\n name: task.name,\n description: task.description,\n namespaceId: task.namespaceId,\n extendedId: task.extendedId,\n template: taskBodyHelperToJSON(task.template),\n targets: task.targets,\n recurrence: task.recurrence,\n nextRun: task.nextRun,\n enabled: task.enabled,\n lastExtended: task.lastExtended,\n };\n}\n\nexport function hasTaskChanged(task: TaskHelper): boolean {\n return task.hash !== hashTask(task);\n}\n\nexport function getLayoutsOfHelpers(\n taskBody: TaskBodyHelper,\n templateBody: TemplateBodyHelper\n): (AnyLayoutHelper & { readonly: boolean })[] {\n const layouts = templateBody.layouts.map((lay) => ({\n ...lay,\n readonly: true,\n }));\n for (const { at, ...layout } of taskBody.inserts) {\n layouts.splice(at, 0, { ...layout, readonly: false });\n }\n return layouts;\n}\n\nexport {\n type TaskBodyHelper,\n createTaskBodyHelper,\n createTaskBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\n","import { assignDependencies } from '~/helpers/permissions/decorator';\n\nimport { getTask, upsertTask, type Task } from '~/modules/tasks';\n\nexport * from './editor';\nexport * from './recurrence';\n\n/**\n * Change enable state of a task\n *\n * @param taskOrId Task or Task's id\n * @param enabled New state\n *\n * @returns Updated task\n */\nexport async function changeTaskEnableState(\n taskOrId: Omit<Task, 'template'> | string,\n enabled: boolean\n): Promise<Task> {\n const base = await getTask(taskOrId);\n\n const task = await upsertTask({\n id: base.id,\n name: base.name,\n description: base.description,\n extendedId: base.extendedId,\n namespaceId: base.namespaceId,\n nextRun: base.nextRun,\n recurrence: base.recurrence,\n targets: base.targets,\n template: base.template,\n lastExtended: base.lastExtended,\n enabled,\n });\n\n return task;\n}\nassignDependencies(changeTaskEnableState, [getTask, upsertTask]);\n"],"names":["calcNextDateFromRecurrence","initial","recurrence","duration","add","createTaskBodyHelper","index","dateField","inserts","filters","_a","filter","createTaskBodyHelperFrom","template","_b","lay","createTaskLayoutHelperFrom","taskBodyHelperToJSON","taskLayoutHelperToJSON","addLayoutOfHelper","body","layout","removeLayoutOfHelper","updateLayoutOfHelper","oldLayout","newLayout","hashTask","task","objectHash","createTaskHelper","name","description","namespaceId","extendedId","targets","nextRun","enabled","lastExtended","lastRun","id","createdAt","updatedAt","createTaskHelperFrom","taskHelperToJSON","hasTaskChanged","getLayoutsOfHelpers","taskBody","templateBody","layouts","__spreadProps","__spreadValues","at","__objRest","changeTaskEnableState","taskOrId","__async","base","getTask","upsertTask","assignDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAASA,EACdC,GACAC,GACM;AACN,QAAMC,IAAqB,CAAA;AAE3B,UAAQD,GAAA;AAAA,IACN,KAAK;AACH,MAAAC,EAAS,OAAO;AAChB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,QAAQ;AACjB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,SAAS;AAClB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,SAAS;AAClB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,SAAS;AAClB;AAAA,IACF,KAAK;AACH,MAAAA,EAAS,QAAQ;AACjB;AAAA,IACF;AACE,YAAM,IAAI,MAAM,sBAAsB;AAAA,EAAA;AAG1C,SAAOC,EAAIH,GAASE,CAAQ;AAC9B;AC3BO,SAASE,EACdC,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EAAK;AAAA,MAClB,SAASA,EAAK;AAAA,MACd,YAAYA,EAAK;AAAA,MACjB,SAASA,EAAK;AAAA,MACd,UAAUA,EAAK;AAAA,MACf,cAAcA,EAAK;AAAA,MACnB,SAAApB;AAAA,IAAA,CACD;AAAA,EAGH;AAAA;AACAuB,EAAmBN,GAAuB,CAACI,GAASC,CAAU,CAAC;"}
@@ -1,2 +1,2 @@
1
- "use strict";var m=(e,t,a)=>new Promise((r,n)=>{var o=l=>{try{u(a.next(l))}catch(p){n(p)}},i=l=>{try{u(a.throw(l))}catch(p){n(p)}},u=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,i);u((a=a.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../methods-BOf9WLn2.js"),h=require("../decorator-C2gcn2rK.js"),y=require("object-hash"),d=require("../templates-yZjsVuN9.js");function c(e,t="",a=[],r=[],n){var o;return{version:2,dateField:t,layouts:a,filters:new Map((o=r==null?void 0:r.map(i=>[i.name,i]))!=null?o:[]),grid:n,index:e}}function f(e){return c(e.index,e.dateField,e.layouts.map(t=>d.createLayoutHelperFrom(t)),e.filters,e.grid)}function O(e){return{version:e.version,dateField:e.dateField,layouts:e.layouts.map(t=>d.layoutHelperToJSON(t)),filters:Array.from(e.filters.values()),grid:e.grid,index:e.index}}function w(e,t,a){if(e.layouts.some(r=>r.id===t.id))throw new Error(`Layout "${t.id}" already exists`);return e.layouts.splice(a!=null?a:e.layouts.length,0,t),e}function v(e,t){const a=e;return a.layouts=e.layouts.filter(r=>r.id!==t.id),e}function F(e,t,a){const r=e.layouts.findIndex(o=>o.id===t.id);if(r<0)throw new Error(`Layout "${t.id}" not found`);const n=e;return n.layouts[r]=a,e}function T(e){return y({name:e.name,body:e.body,tags:e.tags})}function g(e="",t,a=new Map,r="",n=new Date,o){const i={id:r,name:e,body:t!=null?t:c(),tags:a,createdAt:n,updatedAt:o,hash:""};return i.hash=T(i),i}function L(e){var t,a;return g(e.name,f(e.body),new Map((a=(t=e.tags)==null?void 0:t.map(r=>[r.name,r]))!=null?a:[]),e.id,e.createdAt,e.updatedAt)}function S(e){return{name:e.name,body:O(e.body),tags:Array.from(e.tags.values())}}function B(e){return e.hash!==T(e)}function H(e,t){return m(this,null,function*(){const a=yield s.getTemplate(e);return yield s.upsertTemplate({id:a.id,name:a.name,tags:a.tags,body:a.body,hidden:t})})}h.assignDependencies(H,[s.getTemplate,s.upsertTemplate]);exports.addLayoutOfHelper=w;exports.changeTemplateVisibility=H;exports.createTemplateBodyHelper=c;exports.createTemplateBodyHelperFrom=f;exports.createTemplateHelper=g;exports.createTemplateHelperFrom=L;exports.hasTemplateChanged=B;exports.removeLayoutOfHelper=v;exports.templateHelperToJSON=S;exports.updateLayoutOfHelper=F;
1
+ "use strict";var m=(e,t,a)=>new Promise((r,n)=>{var o=i=>{try{u(a.next(i))}catch(p){n(p)}},s=i=>{try{u(a.throw(i))}catch(p){n(p)}},u=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,s);u((a=a.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../methods-C85_VqKZ.js"),H=require("../decorator-C2gcn2rK.js"),y=require("../index-CVa-i8Jy.js"),d=require("../templates-D7C0TH1C.js");function c(e,t="",a=[],r=[],n){var o;return{version:2,dateField:t,layouts:a,filters:new Map((o=r==null?void 0:r.map(s=>[s.name,s]))!=null?o:[]),grid:n,index:e}}function f(e){return c(e.index,e.dateField,e.layouts.map(t=>d.createLayoutHelperFrom(t)),e.filters,e.grid)}function O(e){return{version:e.version,dateField:e.dateField,layouts:e.layouts.map(t=>d.layoutHelperToJSON(t)),filters:Array.from(e.filters.values()),grid:e.grid,index:e.index}}function w(e,t,a){if(e.layouts.some(r=>r.id===t.id))throw new Error(`Layout "${t.id}" already exists`);return e.layouts.splice(a!=null?a:e.layouts.length,0,t),e}function v(e,t){const a=e;return a.layouts=e.layouts.filter(r=>r.id!==t.id),e}function F(e,t,a){const r=e.layouts.findIndex(o=>o.id===t.id);if(r<0)throw new Error(`Layout "${t.id}" not found`);const n=e;return n.layouts[r]=a,e}function T(e){return y.objectHash({name:e.name,body:e.body,tags:e.tags})}function g(e="",t,a=new Map,r="",n=new Date,o){const s={id:r,name:e,body:t!=null?t:c(),tags:a,createdAt:n,updatedAt:o,hash:""};return s.hash=T(s),s}function L(e){var t,a;return g(e.name,f(e.body),new Map((a=(t=e.tags)==null?void 0:t.map(r=>[r.name,r]))!=null?a:[]),e.id,e.createdAt,e.updatedAt)}function S(e){return{name:e.name,body:O(e.body),tags:Array.from(e.tags.values())}}function B(e){return e.hash!==T(e)}function h(e,t){return m(this,null,function*(){const a=yield l.getTemplate(e);return yield l.upsertTemplate({id:a.id,name:a.name,tags:a.tags,body:a.body,hidden:t})})}H.assignDependencies(h,[l.getTemplate,l.upsertTemplate]);exports.addLayoutOfHelper=w;exports.changeTemplateVisibility=h;exports.createTemplateBodyHelper=c;exports.createTemplateBodyHelperFrom=f;exports.createTemplateHelper=g;exports.createTemplateHelperFrom=L;exports.hasTemplateChanged=B;exports.removeLayoutOfHelper=v;exports.templateHelperToJSON=S;exports.updateLayoutOfHelper=F;
2
2
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sources":["../../src/helpers/templates/editor/body.ts","../../src/helpers/templates/editor/index.ts","../../src/helpers/templates/index.ts"],"sourcesContent":["import type { TemplateBody, TemplateFilter, TemplateBodyGrid } from '~/modules/templates';\nimport { createLayoutHelperFrom, layoutHelperToJSON, type LayoutHelper } from './layouts';\n\nexport interface TemplateBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index?: string;\n dateField: string;\n layouts: LayoutHelper[];\n grid?: TemplateBodyGrid;\n}\n\nexport function createTemplateBodyHelper(\n index?: string,\n dateField: string = '',\n layouts: LayoutHelper[] = [],\n filters: TemplateFilter[] = [],\n grid?: TemplateBodyGrid,\n): TemplateBodyHelper {\n return {\n version: 2,\n dateField,\n layouts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n grid,\n index,\n };\n}\n\nexport function createTemplateBodyHelperFrom(body: TemplateBody): TemplateBodyHelper {\n return createTemplateBodyHelper(\n body.index,\n body.dateField,\n body.layouts.map((l) => createLayoutHelperFrom(l)),\n body.filters,\n body.grid,\n );\n}\n\nexport function templateHelperBodyToJSON(body: TemplateBodyHelper): TemplateBody {\n return {\n version: body.version,\n dateField: body.dateField,\n layouts: body.layouts.map((l) => layoutHelperToJSON(l)),\n filters: Array.from(body.filters.values()),\n grid: body.grid,\n index: body.index,\n };\n}\n\nexport function addLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper,\n index?: number,\n): TemplateBodyHelper {\n if (body.layouts.some((l) => l.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.layouts.splice(index ?? body.layouts.length, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper,\n): TemplateBodyHelper {\n const template = body;\n template.layouts = body.layouts.filter((l) => l.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TemplateBodyHelper,\n oldLayout: LayoutHelper,\n newLayout: LayoutHelper,\n): TemplateBodyHelper {\n const index = body.layouts.findIndex((l) => l.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.layouts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\nimport type { InputTemplate, Template } from '~/modules/templates';\n\nimport type { TemplateTagMap } from './tags';\nimport {\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n templateHelperBodyToJSON,\n type TemplateBodyHelper,\n} from './body';\n\nexport interface TemplateHelper {\n readonly id: string;\n name: string;\n body: TemplateBodyHelper;\n tags: TemplateTagMap;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTemplate(template: Template | TemplateHelper): string {\n return objectHash({\n name: template.name,\n body: template.body,\n tags: template.tags,\n });\n}\n\nexport function createTemplateHelper(\n name: string = '',\n body?: TemplateBodyHelper,\n tags: TemplateTagMap = new Map(),\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date,\n): TemplateHelper {\n const template = {\n id,\n name,\n body: body ?? createTemplateBodyHelper(),\n tags,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n template.hash = hashTemplate(template);\n\n return template;\n}\n\nexport function createTemplateHelperFrom(template: Template): TemplateHelper {\n return createTemplateHelper(\n template.name,\n createTemplateBodyHelperFrom(template.body),\n new Map(template.tags?.map((t) => [t.name, t]) ?? []),\n template.id,\n template.createdAt,\n template.updatedAt,\n );\n}\n\nexport function templateHelperToJSON(template: TemplateHelper): InputTemplate {\n return {\n name: template.name,\n body: templateHelperBodyToJSON(template.body),\n tags: Array.from(template.tags.values()),\n };\n}\n\nexport function hasTemplateChanged(template: TemplateHelper): boolean {\n return template.hash !== hashTemplate(template);\n}\n\nexport {\n type TemplateBodyHelper,\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\nexport * from './tags';\n","import { type Template, getTemplate, upsertTemplate } from '~/modules/templates';\n\nimport { assignDependencies } from '~/helpers/permissions/decorator';\n\nexport * from './editor';\n\n/**\n * Change visibility of a template\n *\n * @param templateOrId Template or Template's id\n * @param hidden New state\n *\n * @returns Updated template\n */\nexport async function changeTemplateVisibility(\n templateOrId: Omit<Template, 'body'> | string,\n hidden: boolean,\n): Promise<Template> {\n const base = await getTemplate(templateOrId);\n\n const template = await upsertTemplate({\n id: base.id,\n name: base.name,\n tags: base.tags,\n body: base.body,\n hidden,\n });\n\n return template;\n}\nassignDependencies(changeTemplateVisibility, [getTemplate, upsertTemplate]);\n"],"names":["createTemplateBodyHelper","index","dateField","layouts","filters","grid","_a","filter","createTemplateBodyHelperFrom","body","l","createLayoutHelperFrom","templateHelperBodyToJSON","layoutHelperToJSON","addLayoutOfHelper","layout","removeLayoutOfHelper","template","updateLayoutOfHelper","oldLayout","newLayout","hashTemplate","objectHash","createTemplateHelper","name","tags","id","createdAt","updatedAt","createTemplateHelperFrom","_b","t","templateHelperToJSON","hasTemplateChanged","changeTemplateVisibility","templateOrId","hidden","__async","base","getTemplate","upsertTemplate","assignDependencies"],"mappings":"4aAYgB,SAAAA,EACdC,EACAC,EAAoB,GACpBC,EAA0B,GAC1BC,EAA4B,CAAC,EAC7BC,EACoB,OACb,MAAA,CACL,QAAS,EACT,UAAAH,EACA,QAAAC,EACA,QAAS,IAAI,KAAIG,EAAAF,GAAA,YAAAA,EAAS,IAAKG,GAAW,CAACA,EAAO,KAAMA,CAAM,KAA7C,KAAAD,EAAmD,CAAA,CAAE,EACtE,KAAAD,EACA,MAAAJ,CACF,CACF,CAEO,SAASO,EAA6BC,EAAwC,CAC5E,OAAAT,EACLS,EAAK,MACLA,EAAK,UACLA,EAAK,QAAQ,IAAKC,GAAMC,EAAAA,uBAAuBD,CAAC,CAAC,EACjDD,EAAK,QACLA,EAAK,IACP,CACF,CAEO,SAASG,EAAyBH,EAAwC,CACxE,MAAA,CACL,QAASA,EAAK,QACd,UAAWA,EAAK,UAChB,QAASA,EAAK,QAAQ,IAAKC,GAAMG,EAAAA,mBAAmBH,CAAC,CAAC,EACtD,QAAS,MAAM,KAAKD,EAAK,QAAQ,QAAQ,EACzC,KAAMA,EAAK,KACX,MAAOA,EAAK,KACd,CACF,CAEgB,SAAAK,EACdL,EACAM,EACAd,EACoB,CAChB,GAAAQ,EAAK,QAAQ,KAAMC,GAAMA,EAAE,KAAOK,EAAO,EAAE,EAC7C,MAAM,IAAI,MAAM,WAAWA,EAAO,EAAE,kBAAkB,EAExD,OAAAN,EAAK,QAAQ,OAAOR,GAAA,KAAAA,EAASQ,EAAK,QAAQ,OAAQ,EAAGM,CAAM,EACpDN,CACT,CAEgB,SAAAO,EACdP,EACAM,EACoB,CACpB,MAAME,EAA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AaJ,CAAQ,CAChD,CC3DsB,SAAAiB,EACpBC,EACAC,EACmB,QAAAC,EAAA,sBACb,MAAAC,EAAO,MAAMC,EAAA,YAAYJ,CAAY,EAUpC,OARU,MAAMK,iBAAe,CACpC,GAAIF,EAAK,GACT,KAAMA,EAAK,KACX,KAAMA,EAAK,KACX,KAAMA,EAAK,KACX,OAAAF,CAAA,CACD,CAGH,GACAK,EAAA,mBAAmBP,EAA0B,CAACK,cAAaC,EAAAA,cAAc,CAAC"}
1
+ {"version":3,"file":"templates.js","sources":["../../src/helpers/templates/editor/body.ts","../../src/helpers/templates/editor/index.ts","../../src/helpers/templates/index.ts"],"sourcesContent":["import type {\n TemplateBody,\n TemplateFilter,\n TemplateBodyGrid,\n} from '~/modules/templates';\nimport {\n createLayoutHelperFrom,\n layoutHelperToJSON,\n type LayoutHelper,\n} from './layouts';\n\nexport interface TemplateBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index?: string;\n dateField: string;\n layouts: LayoutHelper[];\n grid?: TemplateBodyGrid;\n}\n\nexport function createTemplateBodyHelper(\n index?: string,\n dateField: string = '',\n layouts: LayoutHelper[] = [],\n filters: TemplateFilter[] = [],\n grid?: TemplateBodyGrid\n): TemplateBodyHelper {\n return {\n version: 2,\n dateField,\n layouts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n grid,\n index,\n };\n}\n\nexport function createTemplateBodyHelperFrom(\n body: TemplateBody\n): TemplateBodyHelper {\n return createTemplateBodyHelper(\n body.index,\n body.dateField,\n body.layouts.map((lay) => createLayoutHelperFrom(lay)),\n body.filters,\n body.grid\n );\n}\n\nexport function templateHelperBodyToJSON(\n body: TemplateBodyHelper\n): TemplateBody {\n return {\n version: body.version,\n dateField: body.dateField,\n layouts: body.layouts.map((lay) => layoutHelperToJSON(lay)),\n filters: Array.from(body.filters.values()),\n grid: body.grid,\n index: body.index,\n };\n}\n\nexport function addLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper,\n index?: number\n): TemplateBodyHelper {\n if (body.layouts.some((lay) => lay.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.layouts.splice(index ?? body.layouts.length, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper\n): TemplateBodyHelper {\n const template = body;\n template.layouts = body.layouts.filter((lay) => lay.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TemplateBodyHelper,\n oldLayout: LayoutHelper,\n newLayout: LayoutHelper\n): TemplateBodyHelper {\n const index = body.layouts.findIndex((lay) => lay.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.layouts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\nimport type { InputTemplate, Template } from '~/modules/templates';\n\nimport type { TemplateTagMap } from './tags';\nimport {\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n templateHelperBodyToJSON,\n type TemplateBodyHelper,\n} from './body';\n\nexport interface TemplateHelper {\n readonly id: string;\n name: string;\n body: TemplateBodyHelper;\n tags: TemplateTagMap;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTemplate(template: Template | TemplateHelper): string {\n return objectHash({\n name: template.name,\n body: template.body,\n tags: template.tags,\n });\n}\n\nexport function createTemplateHelper(\n name: string = '',\n body?: TemplateBodyHelper,\n tags: TemplateTagMap = new Map(),\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date\n): TemplateHelper {\n const template = {\n id,\n name,\n body: body ?? createTemplateBodyHelper(),\n tags,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n template.hash = hashTemplate(template);\n\n return template;\n}\n\nexport function createTemplateHelperFrom(template: Template): TemplateHelper {\n return createTemplateHelper(\n template.name,\n createTemplateBodyHelperFrom(template.body),\n new Map(template.tags?.map((tag) => [tag.name, tag]) ?? []),\n template.id,\n template.createdAt,\n template.updatedAt\n );\n}\n\nexport function templateHelperToJSON(template: TemplateHelper): InputTemplate {\n return {\n name: template.name,\n body: templateHelperBodyToJSON(template.body),\n tags: Array.from(template.tags.values()),\n };\n}\n\nexport function hasTemplateChanged(template: TemplateHelper): boolean {\n return template.hash !== hashTemplate(template);\n}\n\nexport {\n type TemplateBodyHelper,\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\nexport * from './tags';\n","import {\n type Template,\n getTemplate,\n upsertTemplate,\n} from '~/modules/templates';\n\nimport { assignDependencies } from '~/helpers/permissions/decorator';\n\nexport * from './editor';\n\n/**\n * Change visibility of a template\n *\n * @param templateOrId Template or Template's id\n * @param hidden New state\n *\n * @returns Updated template\n */\nexport async function changeTemplateVisibility(\n templateOrId: Omit<Template, 'body'> | string,\n hidden: boolean\n): Promise<Template> {\n const base = await getTemplate(templateOrId);\n\n const template = await upsertTemplate({\n id: base.id,\n name: base.name,\n tags: base.tags,\n body: base.body,\n hidden,\n });\n\n return template;\n}\nassignDependencies(changeTemplateVisibility, [getTemplate, upsertTemplate]);\n"],"names":["createTemplateBodyHelper","index","dateField","layouts","filters","grid","_a","filter","createTemplateBodyHelperFrom","body","lay","createLayoutHelperFrom","templateHelperBodyToJSON","layoutHelperToJSON","addLayoutOfHelper","layout","removeLayoutOfHelper","template","updateLayoutOfHelper","oldLayout","newLayout","hashTemplate","objectHash","createTemplateHelper","name","tags","id","createdAt","updatedAt","createTemplateHelperFrom","_b","tag","templateHelperToJSON","hasTemplateChanged","changeTemplateVisibility","templateOrId","hidden","__async","base","getTemplate","upsertTemplate","assignDependencies"],"mappings":"qbAoBO,SAASA,EACdC,EACAC,EAAoB,GACpBC,EAA0B,GAC1BC,EAA4B,CAAA,EAC5BC,EACoB,OACpB,MAAO,CACL,QAAS,EACT,UAAAH,EACA,QAAAC,EACA,QAAS,IAAI,KAAIG,EAAAF,GAAA,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(o, s);
15
15
  u((t = t.apply(e, a)).next());
16
16
  });
17
- import { a as p, u as c } from "../methods-C3rgYZb1.mjs";
18
- import { b as g } from "../decorator-DBkj--6g.mjs";
19
- import h from "object-hash";
20
- import { a as H, l as T } from "../templates-zMmVXt6k.mjs";
17
+ import { a as p, u as c } from "../methods-BeMtF2ph.mjs";
18
+ import { b as h } from "../decorator-DCiVxI72.mjs";
19
+ import { o as g } from "../index-CqG3FOrT.mjs";
20
+ import { a as H, l as T } from "../templates-BNAX4vB8.mjs";
21
21
  function f(e, a = "", t = [], r = [], n) {
22
22
  var o;
23
23
  return {
@@ -65,7 +65,7 @@ function N(e, a, t) {
65
65
  return n.layouts[r] = t, e;
66
66
  }
67
67
  function d(e) {
68
- return h({
68
+ return g({
69
69
  name: e.name,
70
70
  body: e.body,
71
71
  tags: e.tags
@@ -116,7 +116,7 @@ function F(e, a) {
116
116
  });
117
117
  });
118
118
  }
119
- g(F, [p, c]);
119
+ h(F, [p, c]);
120
120
  export {
121
121
  J as addLayoutOfHelper,
122
122
  F as changeTemplateVisibility,
@@ -1 +1 @@
1
- {"version":3,"file":"templates.mjs","sources":["../../src/helpers/templates/editor/body.ts","../../src/helpers/templates/editor/index.ts","../../src/helpers/templates/index.ts"],"sourcesContent":["import type { TemplateBody, TemplateFilter, TemplateBodyGrid } from '~/modules/templates';\nimport { createLayoutHelperFrom, layoutHelperToJSON, type LayoutHelper } from './layouts';\n\nexport interface TemplateBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index?: string;\n dateField: string;\n layouts: LayoutHelper[];\n grid?: TemplateBodyGrid;\n}\n\nexport function createTemplateBodyHelper(\n index?: string,\n dateField: string = '',\n layouts: LayoutHelper[] = [],\n filters: TemplateFilter[] = [],\n grid?: TemplateBodyGrid,\n): TemplateBodyHelper {\n return {\n version: 2,\n dateField,\n layouts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n grid,\n index,\n };\n}\n\nexport function createTemplateBodyHelperFrom(body: TemplateBody): TemplateBodyHelper {\n return createTemplateBodyHelper(\n body.index,\n body.dateField,\n body.layouts.map((l) => createLayoutHelperFrom(l)),\n body.filters,\n body.grid,\n );\n}\n\nexport function templateHelperBodyToJSON(body: TemplateBodyHelper): TemplateBody {\n return {\n version: body.version,\n dateField: body.dateField,\n layouts: body.layouts.map((l) => layoutHelperToJSON(l)),\n filters: Array.from(body.filters.values()),\n grid: body.grid,\n index: body.index,\n };\n}\n\nexport function addLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper,\n index?: number,\n): TemplateBodyHelper {\n if (body.layouts.some((l) => l.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.layouts.splice(index ?? body.layouts.length, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper,\n): TemplateBodyHelper {\n const template = body;\n template.layouts = body.layouts.filter((l) => l.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TemplateBodyHelper,\n oldLayout: LayoutHelper,\n newLayout: LayoutHelper,\n): TemplateBodyHelper {\n const index = body.layouts.findIndex((l) => l.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.layouts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\nimport type { InputTemplate, Template } from '~/modules/templates';\n\nimport type { TemplateTagMap } from './tags';\nimport {\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n templateHelperBodyToJSON,\n type TemplateBodyHelper,\n} from './body';\n\nexport interface TemplateHelper {\n readonly id: string;\n name: string;\n body: TemplateBodyHelper;\n tags: TemplateTagMap;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTemplate(template: Template | TemplateHelper): string {\n return objectHash({\n name: template.name,\n body: template.body,\n tags: template.tags,\n });\n}\n\nexport function createTemplateHelper(\n name: string = '',\n body?: TemplateBodyHelper,\n tags: TemplateTagMap = new Map(),\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date,\n): TemplateHelper {\n const template = {\n id,\n name,\n body: body ?? createTemplateBodyHelper(),\n tags,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n template.hash = hashTemplate(template);\n\n return template;\n}\n\nexport function createTemplateHelperFrom(template: Template): TemplateHelper {\n return createTemplateHelper(\n template.name,\n createTemplateBodyHelperFrom(template.body),\n new Map(template.tags?.map((t) => [t.name, t]) ?? []),\n template.id,\n template.createdAt,\n template.updatedAt,\n );\n}\n\nexport function templateHelperToJSON(template: TemplateHelper): InputTemplate {\n return {\n name: template.name,\n body: templateHelperBodyToJSON(template.body),\n tags: Array.from(template.tags.values()),\n };\n}\n\nexport function hasTemplateChanged(template: TemplateHelper): boolean {\n return template.hash !== hashTemplate(template);\n}\n\nexport {\n type TemplateBodyHelper,\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\nexport * from './tags';\n","import { type Template, getTemplate, upsertTemplate } from '~/modules/templates';\n\nimport { assignDependencies } from '~/helpers/permissions/decorator';\n\nexport * from './editor';\n\n/**\n * Change visibility of a template\n *\n * @param templateOrId Template or Template's id\n * @param hidden New state\n *\n * @returns Updated template\n */\nexport async function changeTemplateVisibility(\n templateOrId: Omit<Template, 'body'> | string,\n hidden: boolean,\n): Promise<Template> {\n const base = await getTemplate(templateOrId);\n\n const template = await upsertTemplate({\n id: base.id,\n name: base.name,\n tags: base.tags,\n body: base.body,\n hidden,\n });\n\n return template;\n}\nassignDependencies(changeTemplateVisibility, [getTemplate, upsertTemplate]);\n"],"names":["createTemplateBodyHelper","index","dateField","layouts","filters","grid","_a","filter","createTemplateBodyHelperFrom","body","l","createLayoutHelperFrom","templateHelperBodyToJSON","layoutHelperToJSON","addLayoutOfHelper","layout","removeLayoutOfHelper","template","updateLayoutOfHelper","oldLayout","newLayout","hashTemplate","objectHash","createTemplateHelper","name","tags","id","createdAt","updatedAt","createTemplateHelperFrom","_b","t","templateHelperToJSON","hasTemplateChanged","changeTemplateVisibility","templateOrId","hidden","__async","base","getTemplate","upsertTemplate","assignDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYgB,SAAAA,EACdC,GACAC,IAAoB,IACpBC,IAA0B,IAC1BC,IAA4B,CAAC,GAC7BC,GACoB;;AACb,SAAA;AAAA,IACL,SAAS;AAAA,IACT,WAAAH;AAAA,IACA,SAAAC;AAAA,IACA,SAAS,IAAI,KAAIG,IAAAF,KAAA,gBAAAA,EAAS,IAAI,CAACG,MAAW,CAACA,EAAO,MAAMA,CAAM,OAA7C,OAAAD,IAAmD,CAAA,CAAE;AAAA,IACtE,MAAAD;AAAA,IACA,OAAAJ;AAAA,EACF;AACF;AAEO,SAASO,EAA6BC,GAAwC;AAC5E,SAAAT;AAAA,IACLS,EAAK;AAAA,IACLA,EAAK;AAAA,IACLA,EAAK,QAAQ,IAAI,CAACC,MAAMC,EAAuBD,CAAC,CAAC;AAAA,IACjDD,EAAK;AAAA,IACLA,EAAK;AAAA,EACP;AACF;AAEO,SAASG,EAAyBH,GAAwC;AACxE,SAAA;AAAA,IACL,SAASA,EAAK;AAAA,IACd,WAAWA,EAAK;AAAA,IAChB,SAASA,EAAK,QAAQ,IAAI,CAACC,MAAMG,EAAmBH,CAAC,CAAC;AAAA,IACtD,SAAS,MAAM,KAAKD,EAAK,QAAQ,QAAQ;AAAA,IACzC,MAAMA,EAAK;AAAA,IACX,OAAOA,EAAK;AAAA,EACd;AACF;AAEgB,SAAAK,EACdL,GACAM,GACAd,GACoB;AAChB,MAAAQ,EAAK,QAAQ,KAAK,CAACC,MAAMA,EAAE,OAAOK,EAAO,EAAE;AAC7C,UAAM,IAAI,MAAM,WAAWA,EAAO,EAAE,kBAAkB;AAExD,SAAAN,EAAK,QAAQ,OAAOR,KAAA,OAAAA,IAASQ,EAAK,QAAQ,QAAQ,GAAGM,CA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AASe,EAAqBf,GAAyC;AACrE,SAAA;AAAA,IACL,MAAMA,EAAS;AAAA,IACf,MAAML,EAAyBK,EAAS,IAAI;AAAA,IAC5C,MAAM,MAAM,KAAKA,EAAS,KAAK,OAAQ,CAAA;AAAA,EACzC;AACF;AAEO,SAASgB,EAAmBhB,GAAmC;AAC7D,SAAAA,EAAS,SAASI,EAAaJ,CAAQ;AAChD;AC3DsB,SAAAiB,EACpBC,GACAC,GACmB;AAAA,SAAAC,EAAA;AACb,UAAAC,IAAO,MAAMC,EAAYJ,CAAY;AAUpC,WARU,MAAMK,EAAe;AAAA,MACpC,IAAIF,EAAK;AAAA,MACT,MAAMA,EAAK;AAAA,MACX,MAAMA,EAAK;AAAA,MACX,MAAMA,EAAK;AAAA,MACX,QAAAF;AAAA,IAAA,CACD;AAAA,EAGH;AAAA;AACAK,EAAmBP,GAA0B,CAACK,GAAaC,CAAc,CAAC;"}
1
+ {"version":3,"file":"templates.mjs","sources":["../../src/helpers/templates/editor/body.ts","../../src/helpers/templates/editor/index.ts","../../src/helpers/templates/index.ts"],"sourcesContent":["import type {\n TemplateBody,\n TemplateFilter,\n TemplateBodyGrid,\n} from '~/modules/templates';\nimport {\n createLayoutHelperFrom,\n layoutHelperToJSON,\n type LayoutHelper,\n} from './layouts';\n\nexport interface TemplateBodyHelper {\n readonly version: number;\n filters: Map<string, TemplateFilter>;\n index?: string;\n dateField: string;\n layouts: LayoutHelper[];\n grid?: TemplateBodyGrid;\n}\n\nexport function createTemplateBodyHelper(\n index?: string,\n dateField: string = '',\n layouts: LayoutHelper[] = [],\n filters: TemplateFilter[] = [],\n grid?: TemplateBodyGrid\n): TemplateBodyHelper {\n return {\n version: 2,\n dateField,\n layouts,\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n grid,\n index,\n };\n}\n\nexport function createTemplateBodyHelperFrom(\n body: TemplateBody\n): TemplateBodyHelper {\n return createTemplateBodyHelper(\n body.index,\n body.dateField,\n body.layouts.map((lay) => createLayoutHelperFrom(lay)),\n body.filters,\n body.grid\n );\n}\n\nexport function templateHelperBodyToJSON(\n body: TemplateBodyHelper\n): TemplateBody {\n return {\n version: body.version,\n dateField: body.dateField,\n layouts: body.layouts.map((lay) => layoutHelperToJSON(lay)),\n filters: Array.from(body.filters.values()),\n grid: body.grid,\n index: body.index,\n };\n}\n\nexport function addLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper,\n index?: number\n): TemplateBodyHelper {\n if (body.layouts.some((lay) => lay.id === layout.id)) {\n throw new Error(`Layout \"${layout.id}\" already exists`);\n }\n body.layouts.splice(index ?? body.layouts.length, 0, layout);\n return body;\n}\n\nexport function removeLayoutOfHelper(\n body: TemplateBodyHelper,\n layout: LayoutHelper\n): TemplateBodyHelper {\n const template = body;\n template.layouts = body.layouts.filter((lay) => lay.id !== layout.id);\n return body;\n}\n\nexport function updateLayoutOfHelper(\n body: TemplateBodyHelper,\n oldLayout: LayoutHelper,\n newLayout: LayoutHelper\n): TemplateBodyHelper {\n const index = body.layouts.findIndex((lay) => lay.id === oldLayout.id);\n if (index < 0) {\n throw new Error(`Layout \"${oldLayout.id}\" not found`);\n }\n const template = body;\n template.layouts[index] = newLayout;\n return body;\n}\n","import objectHash from 'object-hash';\nimport type { InputTemplate, Template } from '~/modules/templates';\n\nimport type { TemplateTagMap } from './tags';\nimport {\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n templateHelperBodyToJSON,\n type TemplateBodyHelper,\n} from './body';\n\nexport interface TemplateHelper {\n readonly id: string;\n name: string;\n body: TemplateBodyHelper;\n tags: TemplateTagMap;\n readonly createdAt: Date;\n readonly updatedAt?: Date;\n readonly hash: string;\n}\n\nfunction hashTemplate(template: Template | TemplateHelper): string {\n return objectHash({\n name: template.name,\n body: template.body,\n tags: template.tags,\n });\n}\n\nexport function createTemplateHelper(\n name: string = '',\n body?: TemplateBodyHelper,\n tags: TemplateTagMap = new Map(),\n id: string = '',\n createdAt: Date = new Date(),\n updatedAt?: Date\n): TemplateHelper {\n const template = {\n id,\n name,\n body: body ?? createTemplateBodyHelper(),\n tags,\n createdAt,\n updatedAt,\n hash: '',\n };\n\n template.hash = hashTemplate(template);\n\n return template;\n}\n\nexport function createTemplateHelperFrom(template: Template): TemplateHelper {\n return createTemplateHelper(\n template.name,\n createTemplateBodyHelperFrom(template.body),\n new Map(template.tags?.map((tag) => [tag.name, tag]) ?? []),\n template.id,\n template.createdAt,\n template.updatedAt\n );\n}\n\nexport function templateHelperToJSON(template: TemplateHelper): InputTemplate {\n return {\n name: template.name,\n body: templateHelperBodyToJSON(template.body),\n tags: Array.from(template.tags.values()),\n };\n}\n\nexport function hasTemplateChanged(template: TemplateHelper): boolean {\n return template.hash !== hashTemplate(template);\n}\n\nexport {\n type TemplateBodyHelper,\n createTemplateBodyHelper,\n createTemplateBodyHelperFrom,\n addLayoutOfHelper,\n removeLayoutOfHelper,\n updateLayoutOfHelper,\n} from './body';\nexport * from './tags';\n","import {\n type Template,\n getTemplate,\n upsertTemplate,\n} from '~/modules/templates';\n\nimport { assignDependencies } from '~/helpers/permissions/decorator';\n\nexport * from './editor';\n\n/**\n * Change visibility of a template\n *\n * @param templateOrId Template or Template's id\n * @param hidden New state\n *\n * @returns Updated template\n */\nexport async function changeTemplateVisibility(\n templateOrId: Omit<Template, 'body'> | string,\n hidden: boolean\n): Promise<Template> {\n const base = await getTemplate(templateOrId);\n\n const template = await upsertTemplate({\n id: base.id,\n name: base.name,\n tags: base.tags,\n body: base.body,\n hidden,\n });\n\n return template;\n}\nassignDependencies(changeTemplateVisibility, [getTemplate, upsertTemplate]);\n"],"names":["createTemplateBodyHelper","index","dateField","layouts","filters","grid","_a","filter","createTemplateBodyHelperFrom","body","lay","createLayoutHelperFrom","templateHelperBodyToJSON","layoutHelperToJSON","addLayoutOfHelper","layout","removeLayoutOfHelper","template","updateLayoutOfHelper","oldLayout","newLayout","hashTemplate","objectHash","createTemplateHelper","name","tags","id","createdAt","updatedAt","createTemplateHelperFrom","_b","tag","templateHelperToJSON","hasTemplateChanged","changeTemplateVisibility","templateOrId","hidden","__async","base","getTemplate","upsertTemplate","assignDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBO,SAASA,EACdC,GACAC,IAAoB,IACpBC,IAA0B,IAC1BC,IAA4B,CAAA,GAC5BC,GACoB;;AACpB,SAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAAH;AAAA,IACA,SAAAC;AAAA,IACA,SAAS,IAAI,KAAIG,IAAAF,KAAA,gBAAAA,EAAS,IAAI,CAACG,MAAW,CAACA,EAAO,MAAMA,CAAM,OAA7C,OAAAD,IAAmD,CAAA,CAAE;AAAA,IACtE,MAAAD;AAAA,IACA,OAAAJ;AAAA,EAAA;AAEJ;AAEO,SAASO,EACdC,GACoB;AACpB,SAAOT;AAAA,IACLS,EAAK;AAAA,IACLA,EAAK;AAAA,IACLA,EAAK,QAAQ,IAAI,CAACC,MAAQC,EAAuBD,CAAG,CAAC;AAAA,IACrDD,EAAK;AAAA,IACLA,EAAK;AAAA,EAAA;AAET;AAEO,SAASG,EACdH,GACc;AACd,SAAO;AAAA,IACL,SAASA,EAAK;AAAA,IACd,WAAWA,EAAK;AAAA,IAChB,SAASA,EAAK,QAAQ,IAAI,CAACC,MAAQG,EAAmBH,CAAG,CAAC;AAAA,IAC1D,SAAS,MAAM,KAAKD,EAAK,QAAQ,QAAQ;AAAA,IACzC,MAAMA,EAAK;AAAA,IACX,OAAOA,EAAK;AAAA,EAAA;AAEhB;AAEO,SAASK,EACdL,GACAM,GACAd,GACoB;AACpB,MAAIQ,EAAK,QAAQ,KAAK,CAACC,MAAQA,EAAI,OAAOK,EAAO,EAAE;AACjD,UAAM,IAAI,MAAM,WAAWA,EAAO,EAAE,kBAAkB;AAExD,SAAAN,EAAK,QAAQ,OAAOR,KAAA,OAAAA,IAASQ,EAAK,QAAQ,QAAQ,GAAGM,CAAM,GACpDN;AACT;AAEO,SAASO,EACdP,GACAM,GACoB;AACpB,QAAME,IAAWR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;AAAA,IACf,MAAML,EAAyBK,EAAS,IAAI;AAAA,IAC5C,MAAM,MAAM,KAAKA,EAAS,KAAK,QAAQ;AAAA,EAAA;AAE3C;AAEO,SAASgB,EAAmBhB,GAAmC;AACpE,SAAOA,EAAS,SAASI,EAAaJ,CAAQ;AAChD;ACvDA,SAAsBiB,EACpBC,GACAC,GACmB;AAAA,SAAAC,EAAA;AACnB,UAAMC,IAAO,MAAMC,EAAYJ,CAAY;AAU3C,WARiB,MAAMK,EAAe;AAAA,MACpC,IAAIF,EAAK;AAAA,MACT,MAAMA,EAAK;AAAA,MACX,MAAMA,EAAK;AAAA,MACX,MAAMA,EAAK;AAAA,MACX,QAAAF;AAAA,IAAA,CACD;AAAA,EAGH;AAAA;AACAK,EAAmBP,GAA0B,CAACK,GAAaC,CAAc,CAAC;"}
@@ -0,0 +1,7 @@
1
+ "use strict";var jr=Object.defineProperty,kr=Object.defineProperties;var Or=Object.getOwnPropertyDescriptors;var br=Object.getOwnPropertySymbols;var Nr=Object.prototype.hasOwnProperty,Yr=Object.prototype.propertyIsEnumerable;var wr=(s,_,d)=>_ in s?jr(s,_,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[_]=d,ar=(s,_)=>{for(var d in _||(_={}))Nr.call(_,d)&&wr(s,d,_[d]);if(br)for(var d of br(_))Yr.call(_,d)&&wr(s,d,_[d]);return s},sr=(s,_)=>kr(s,Or(_));const Dr=require("./_commonjsHelpers-DwGv2jUC.js");let Pr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",_r=(s=21)=>{let _="",d=s|0;for(;d--;)_+=Pr[Math.random()*64|0];return _};function nr(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ur={exports:{}},vr;function Jr(){return vr||(vr=1,function(s,_){(function(d){s.exports=d()})(function(){return function d(B,I,F){function C(M,J){if(!I[M]){if(!B[M]){var q=typeof nr=="function"&&nr;if(!J&&q)return q(M,!0);if(D)return D(M,!0);throw new Error("Cannot find module '"+M+"'")}J=I[M]={exports:{}},B[M][0].call(J.exports,function(R){var $=B[M][1][R];return C($||R)},J,J.exports,d,B,I,F)}return I[M].exports}for(var D=typeof nr=="function"&&nr,O=0;O<F.length;O++)C(F[O]);return C}({1:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){var b=d("crypto");function L(a,f){f=E(a,f);var t;return(t=f.algorithm!=="passthrough"?b.createHash(f.algorithm):new x).write===void 0&&(t.write=t.update,t.end=t.update),g(f,t).dispatch(a),t.update||t.end(""),t.digest?t.digest(f.encoding==="buffer"?void 0:f.encoding):(a=t.read(),f.encoding!=="buffer"?a.toString(f.encoding):a)}(I=B.exports=L).sha1=function(a){return L(a)},I.keys=function(a){return L(a,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},I.MD5=function(a){return L(a,{algorithm:"md5",encoding:"hex"})},I.keysMD5=function(a){return L(a,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var c=b.getHashes?b.getHashes().slice():["sha1","md5"],y=(c.push("passthrough"),["buffer","hex","binary","base64"]);function E(a,f){var t={};if(t.algorithm=(f=f||{}).algorithm||"sha1",t.encoding=f.encoding||"hex",t.excludeValues=!!f.excludeValues,t.algorithm=t.algorithm.toLowerCase(),t.encoding=t.encoding.toLowerCase(),t.ignoreUnknown=f.ignoreUnknown===!0,t.respectType=f.respectType!==!1,t.respectFunctionNames=f.respectFunctionNames!==!1,t.respectFunctionProperties=f.respectFunctionProperties!==!1,t.unorderedArrays=f.unorderedArrays===!0,t.unorderedSets=f.unorderedSets!==!1,t.unorderedObjects=f.unorderedObjects!==!1,t.replacer=f.replacer||void 0,t.excludeKeys=f.excludeKeys||void 0,a===void 0)throw new Error("Object argument required.");for(var o=0;o<c.length;++o)c[o].toLowerCase()===t.algorithm.toLowerCase()&&(t.algorithm=c[o]);if(c.indexOf(t.algorithm)===-1)throw new Error('Algorithm "'+t.algorithm+'" not supported. supported values: '+c.join(", "));if(y.indexOf(t.encoding)===-1&&t.algorithm!=="passthrough")throw new Error('Encoding "'+t.encoding+'" not supported. supported values: '+y.join(", "));return t}function m(a){if(typeof a=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(a))!=null}function g(a,f,t){t=t||[];function o(e){return f.update?f.update(e,"utf8"):f.write(e,"utf8")}return{dispatch:function(e){return this["_"+((e=a.replacer?a.replacer(e):e)===null?"null":typeof e)](e)},_object:function(e){var u,l=Object.prototype.toString.call(e),S=/\[object (.*)\]/i.exec(l);if(S=(S=S?S[1]:"unknown:["+l+"]").toLowerCase(),0<=(l=t.indexOf(e)))return this.dispatch("[CIRCULAR:"+l+"]");if(t.push(e),D!==void 0&&D.isBuffer&&D.isBuffer(e))return o("buffer:"),o(e);if(S==="object"||S==="function"||S==="asyncfunction")return l=Object.keys(e),a.unorderedObjects&&(l=l.sort()),a.respectType===!1||m(e)||l.splice(0,0,"prototype","__proto__","constructor"),a.excludeKeys&&(l=l.filter(function(H){return!a.excludeKeys(H)})),o("object:"+l.length+":"),u=this,l.forEach(function(H){u.dispatch(H),o(":"),a.excludeValues||u.dispatch(e[H]),o(",")});if(!this["_"+S]){if(a.ignoreUnknown)return o("["+S+"]");throw new Error('Unknown object type "'+S+'"')}this["_"+S](e)},_array:function(e,H){H=H!==void 0?H:a.unorderedArrays!==!1;var l=this;if(o("array:"+e.length+":"),!H||e.length<=1)return e.forEach(function(T){return l.dispatch(T)});var S=[],H=e.map(function(T){var A=new x,k=t.slice();return g(a,A,k).dispatch(T),S=S.concat(k.slice(t.length)),A.read().toString()});return t=t.concat(S),H.sort(),this._array(H,!1)},_date:function(e){return o("date:"+e.toJSON())},_symbol:function(e){return o("symbol:"+e.toString())},_error:function(e){return o("error:"+e.toString())},_boolean:function(e){return o("bool:"+e.toString())},_string:function(e){o("string:"+e.length+":"),o(e.toString())},_function:function(e){o("fn:"),m(e)?this.dispatch("[native]"):this.dispatch(e.toString()),a.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(e.name)),a.respectFunctionProperties&&this._object(e)},_number:function(e){return o("number:"+e.toString())},_xml:function(e){return o("xml:"+e.toString())},_null:function(){return o("Null")},_undefined:function(){return o("Undefined")},_regexp:function(e){return o("regex:"+e.toString())},_uint8array:function(e){return o("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint8clampedarray:function(e){return o("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},_int8array:function(e){return o("int8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint16array:function(e){return o("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},_int16array:function(e){return o("int16array:"),this.dispatch(Array.prototype.slice.call(e))},_uint32array:function(e){return o("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},_int32array:function(e){return o("int32array:"),this.dispatch(Array.prototype.slice.call(e))},_float32array:function(e){return o("float32array:"),this.dispatch(Array.prototype.slice.call(e))},_float64array:function(e){return o("float64array:"),this.dispatch(Array.prototype.slice.call(e))},_arraybuffer:function(e){return o("arraybuffer:"),this.dispatch(new Uint8Array(e))},_url:function(e){return o("url:"+e.toString())},_map:function(e){return o("map:"),e=Array.from(e),this._array(e,a.unorderedSets!==!1)},_set:function(e){return o("set:"),e=Array.from(e),this._array(e,a.unorderedSets!==!1)},_file:function(e){return o("file:"),this.dispatch([e.name,e.size,e.type,e.lastModfied])},_blob:function(){if(a.ignoreUnknown)return o("[blob]");throw Error(`Hashing Blob objects is currently not supported
2
+ (see https://github.com/puleos/object-hash/issues/26)
3
+ Use "options.replacer" or "options.ignoreUnknown"
4
+ `)},_domwindow:function(){return o("domwindow")},_bigint:function(e){return o("bigint:"+e.toString())},_process:function(){return o("process")},_timer:function(){return o("timer")},_pipe:function(){return o("pipe")},_tcp:function(){return o("tcp")},_udp:function(){return o("udp")},_tty:function(){return o("tty")},_statwatcher:function(){return o("statwatcher")},_securecontext:function(){return o("securecontext")},_connection:function(){return o("connection")},_zlib:function(){return o("zlib")},_context:function(){return o("context")},_nodescript:function(){return o("nodescript")},_httpparser:function(){return o("httpparser")},_dataview:function(){return o("dataview")},_signal:function(){return o("signal")},_fsevent:function(){return o("fsevent")},_tlswrap:function(){return o("tlswrap")}}}function x(){return{buf:"",write:function(a){this.buf+=a},end:function(a){this.buf+=a},read:function(){return this.buf}}}I.writeToStream=function(a,f,t){return t===void 0&&(t=f,f={}),g(f=E(a,f),t).dispatch(a)}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){(function(b){var L=typeof Uint8Array!="undefined"?Uint8Array:Array,c=43,y=47,E=48,m=97,g=65,x=45,a=95;function f(t){return t=t.charCodeAt(0),t===c||t===x?62:t===y||t===a?63:t<E?-1:t<E+10?t-E+26+26:t<g+26?t-g:t<m+26?t-m+26:void 0}b.toByteArray=function(t){var o,e;if(0<t.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var u=t.length,u=t.charAt(u-2)==="="?2:t.charAt(u-1)==="="?1:0,l=new L(3*t.length/4-u),S=0<u?t.length-4:t.length,H=0;function T(A){l[H++]=A}for(o=0;o<S;o+=4,0)T((16711680&(e=f(t.charAt(o))<<18|f(t.charAt(o+1))<<12|f(t.charAt(o+2))<<6|f(t.charAt(o+3))))>>16),T((65280&e)>>8),T(255&e);return u==2?T(255&(e=f(t.charAt(o))<<2|f(t.charAt(o+1))>>4)):u==1&&(T((e=f(t.charAt(o))<<10|f(t.charAt(o+1))<<4|f(t.charAt(o+2))>>2)>>8&255),T(255&e)),l},b.fromByteArray=function(t){var o,e,u,l,S=t.length%3,H="";function T(A){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(A)}for(o=0,u=t.length-S;o<u;o+=3)e=(t[o]<<16)+(t[o+1]<<8)+t[o+2],H+=T((l=e)>>18&63)+T(l>>12&63)+T(l>>6&63)+T(63&l);switch(S){case 1:H=(H+=T((e=t[t.length-1])>>2))+T(e<<4&63)+"==";break;case 2:H=(H=(H+=T((e=(t[t.length-2]<<8)+t[t.length-1])>>10))+T(e>>4&63))+T(e<<2&63)+"="}return H}})(I===void 0?this.base64js={}:I)}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(d,B,I){(function(F,C,c,O,M,J,q,R,$){var b=d("base64-js"),L=d("ieee754");function c(r,n,i){if(!(this instanceof c))return new c(r,n,i);var h,p,v,U,Y=typeof r;if(n==="base64"&&Y=="string")for(r=(U=r).trim?U.trim():U.replace(/^\s+|\s+$/g,"");r.length%4!=0;)r+="=";if(Y=="number")h=W(r);else if(Y=="string")h=c.byteLength(r,n);else{if(Y!="object")throw new Error("First argument needs to be a number, array or string.");h=W(r.length)}if(c._useTypedArrays?p=c._augment(new Uint8Array(h)):((p=this).length=h,p._isBuffer=!0),c._useTypedArrays&&typeof r.byteLength=="number")p._set(r);else if(N(U=r)||c.isBuffer(U)||U&&typeof U=="object"&&typeof U.length=="number")for(v=0;v<h;v++)c.isBuffer(r)?p[v]=r.readUInt8(v):p[v]=r[v];else if(Y=="string")p.write(r,0,n);else if(Y=="number"&&!c._useTypedArrays&&!i)for(v=0;v<h;v++)p[v]=0;return p}function y(r,n,i,h){return c._charsWritten=tr(function(p){for(var v=[],U=0;U<p.length;U++)v.push(255&p.charCodeAt(U));return v}(n),r,i,h)}function E(r,n,i,h){return c._charsWritten=tr(function(p){for(var v,U,Y=[],K=0;K<p.length;K++)U=p.charCodeAt(K),v=U>>8,U=U%256,Y.push(U),Y.push(v);return Y}(n),r,i,h)}function m(r,n,i){var h="";i=Math.min(r.length,i);for(var p=n;p<i;p++)h+=String.fromCharCode(r[p]);return h}function g(r,n,i,v){v||(w(typeof i=="boolean","missing or invalid endian"),w(n!=null,"missing offset"),w(n+1<r.length,"Trying to read beyond buffer length"));var p,v=r.length;if(!(v<=n))return i?(p=r[n],n+1<v&&(p|=r[n+1]<<8)):(p=r[n]<<8,n+1<v&&(p|=r[n+1])),p}function x(r,n,i,v){v||(w(typeof i=="boolean","missing or invalid endian"),w(n!=null,"missing offset"),w(n+3<r.length,"Trying to read beyond buffer length"));var p,v=r.length;if(!(v<=n))return i?(n+2<v&&(p=r[n+2]<<16),n+1<v&&(p|=r[n+1]<<8),p|=r[n],n+3<v&&(p+=r[n+3]<<24>>>0)):(n+1<v&&(p=r[n+1]<<16),n+2<v&&(p|=r[n+2]<<8),n+3<v&&(p|=r[n+3]),p+=r[n]<<24>>>0),p}function a(r,n,i,h){if(h||(w(typeof i=="boolean","missing or invalid endian"),w(n!=null,"missing offset"),w(n+1<r.length,"Trying to read beyond buffer length")),!(r.length<=n))return h=g(r,n,i,!0),32768&h?-1*(65535-h+1):h}function f(r,n,i,h){if(h||(w(typeof i=="boolean","missing or invalid endian"),w(n!=null,"missing offset"),w(n+3<r.length,"Trying to read beyond buffer length")),!(r.length<=n))return h=x(r,n,i,!0),2147483648&h?-1*(4294967295-h+1):h}function t(r,n,i,h){return h||(w(typeof i=="boolean","missing or invalid endian"),w(n+3<r.length,"Trying to read beyond buffer length")),L.read(r,n,i,23,4)}function o(r,n,i,h){return h||(w(typeof i=="boolean","missing or invalid endian"),w(n+7<r.length,"Trying to read beyond buffer length")),L.read(r,n,i,52,8)}function e(r,n,i,h,p){if(p||(w(n!=null,"missing value"),w(typeof h=="boolean","missing or invalid endian"),w(i!=null,"missing offset"),w(i+1<r.length,"trying to write beyond buffer length"),or(n,65535)),p=r.length,!(p<=i))for(var v=0,U=Math.min(p-i,2);v<U;v++)r[i+v]=(n&255<<8*(h?v:1-v))>>>8*(h?v:1-v)}function u(r,n,i,h,p){if(p||(w(n!=null,"missing value"),w(typeof h=="boolean","missing or invalid endian"),w(i!=null,"missing offset"),w(i+3<r.length,"trying to write beyond buffer length"),or(n,4294967295)),p=r.length,!(p<=i))for(var v=0,U=Math.min(p-i,4);v<U;v++)r[i+v]=n>>>8*(h?v:3-v)&255}function l(r,n,i,h,p){p||(w(n!=null,"missing value"),w(typeof h=="boolean","missing or invalid endian"),w(i!=null,"missing offset"),w(i+1<r.length,"Trying to write beyond buffer length"),ir(n,32767,-32768)),r.length<=i||e(r,0<=n?n:65535+n+1,i,h,p)}function S(r,n,i,h,p){p||(w(n!=null,"missing value"),w(typeof h=="boolean","missing or invalid endian"),w(i!=null,"missing offset"),w(i+3<r.length,"Trying to write beyond buffer length"),ir(n,2147483647,-2147483648)),r.length<=i||u(r,0<=n?n:4294967295+n+1,i,h,p)}function H(r,n,i,h,p){p||(w(n!=null,"missing value"),w(typeof h=="boolean","missing or invalid endian"),w(i!=null,"missing offset"),w(i+3<r.length,"Trying to write beyond buffer length"),yr(n,34028234663852886e22,-34028234663852886e22)),r.length<=i||L.write(r,n,i,h,23,4)}function T(r,n,i,h,p){p||(w(n!=null,"missing value"),w(typeof h=="boolean","missing or invalid endian"),w(i!=null,"missing offset"),w(i+7<r.length,"Trying to write beyond buffer length"),yr(n,17976931348623157e292,-17976931348623157e292)),r.length<=i||L.write(r,n,i,h,52,8)}I.Buffer=c,I.SlowBuffer=c,I.INSPECT_MAX_BYTES=50,c.poolSize=8192,c._useTypedArrays=function(){try{var r=new ArrayBuffer(0),n=new Uint8Array(r);return n.foo=function(){return 42},n.foo()===42&&typeof n.subarray=="function"}catch(i){return!1}}(),c.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.isBuffer=function(r){return!(r==null||!r._isBuffer)},c.byteLength=function(r,n){var i;switch(r+="",n||"utf8"){case"hex":i=r.length/2;break;case"utf8":case"utf-8":i=Q(r).length;break;case"ascii":case"binary":case"raw":i=r.length;break;case"base64":i=hr(r).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=2*r.length;break;default:throw new Error("Unknown encoding")}return i},c.concat=function(r,n){if(w(N(r),`Usage: Buffer.concat(list, [totalLength])
5
+ list should be an Array.`),r.length===0)return new c(0);if(r.length===1)return r[0];if(typeof n!="number")for(p=n=0;p<r.length;p++)n+=r[p].length;for(var i=new c(n),h=0,p=0;p<r.length;p++){var v=r[p];v.copy(i,h),h+=v.length}return i},c.prototype.write=function(r,n,i,h){isFinite(n)?isFinite(i)||(h=i,i=void 0):(K=h,h=n,n=i,i=K),n=Number(n)||0;var p,v,U,Y,K=this.length-n;switch((!i||K<(i=Number(i)))&&(i=K),h=String(h||"utf8").toLowerCase()){case"hex":p=function(G,z,X,V){X=Number(X)||0;var P=G.length-X;(!V||P<(V=Number(V)))&&(V=P),w((P=z.length)%2==0,"Invalid hex string"),P/2<V&&(V=P/2);for(var er=0;er<V;er++){var mr=parseInt(z.substr(2*er,2),16);w(!isNaN(mr),"Invalid hex string"),G[X+er]=mr}return c._charsWritten=2*er,er}(this,r,n,i);break;case"utf8":case"utf-8":v=this,U=n,Y=i,p=c._charsWritten=tr(Q(r),v,U,Y);break;case"ascii":case"binary":p=y(this,r,n,i);break;case"base64":v=this,U=n,Y=i,p=c._charsWritten=tr(hr(r),v,U,Y);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":p=E(this,r,n,i);break;default:throw new Error("Unknown encoding")}return p},c.prototype.toString=function(r,n,i){var h,p,v,U,Y=this;if(r=String(r||"utf8").toLowerCase(),n=Number(n)||0,(i=i!==void 0?Number(i):Y.length)===n)return"";switch(r){case"hex":h=function(K,G,z){var X=K.length;(!G||G<0)&&(G=0),(!z||z<0||X<z)&&(z=X);for(var V="",P=G;P<z;P++)V+=j(K[P]);return V}(Y,n,i);break;case"utf8":case"utf-8":h=function(K,G,z){var X="",V="";z=Math.min(K.length,z);for(var P=G;P<z;P++)K[P]<=127?(X+=gr(V)+String.fromCharCode(K[P]),V=""):V+="%"+K[P].toString(16);return X+gr(V)}(Y,n,i);break;case"ascii":case"binary":h=m(Y,n,i);break;case"base64":p=Y,U=i,h=(v=n)===0&&U===p.length?b.fromByteArray(p):b.fromByteArray(p.slice(v,U));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=function(K,G,z){for(var X=K.slice(G,z),V="",P=0;P<X.length;P+=2)V+=String.fromCharCode(X[P]+256*X[P+1]);return V}(Y,n,i);break;default:throw new Error("Unknown encoding")}return h},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.copy=function(r,n,i,h){if(n=n||0,(h=h||h===0?h:this.length)!==(i=i||0)&&r.length!==0&&this.length!==0){w(i<=h,"sourceEnd < sourceStart"),w(0<=n&&n<r.length,"targetStart out of bounds"),w(0<=i&&i<this.length,"sourceStart out of bounds"),w(0<=h&&h<=this.length,"sourceEnd out of bounds"),h>this.length&&(h=this.length);var p=(h=r.length-n<h-i?r.length-n+i:h)-i;if(p<100||!c._useTypedArrays)for(var v=0;v<p;v++)r[v+n]=this[v+i];else r._set(this.subarray(i,i+p),n)}},c.prototype.slice=function(r,n){var i=this.length;if(r=k(r,i,0),n=k(n,i,i),c._useTypedArrays)return c._augment(this.subarray(r,n));for(var h=n-r,p=new c(h,void 0,!0),v=0;v<h;v++)p[v]=this[v+r];return p},c.prototype.get=function(r){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(r)},c.prototype.set=function(r,n){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(r,n)},c.prototype.readUInt8=function(r,n){if(n||(w(r!=null,"missing offset"),w(r<this.length,"Trying to read beyond buffer length")),!(r>=this.length))return this[r]},c.prototype.readUInt16LE=function(r,n){return g(this,r,!0,n)},c.prototype.readUInt16BE=function(r,n){return g(this,r,!1,n)},c.prototype.readUInt32LE=function(r,n){return x(this,r,!0,n)},c.prototype.readUInt32BE=function(r,n){return x(this,r,!1,n)},c.prototype.readInt8=function(r,n){if(n||(w(r!=null,"missing offset"),w(r<this.length,"Trying to read beyond buffer length")),!(r>=this.length))return 128&this[r]?-1*(255-this[r]+1):this[r]},c.prototype.readInt16LE=function(r,n){return a(this,r,!0,n)},c.prototype.readInt16BE=function(r,n){return a(this,r,!1,n)},c.prototype.readInt32LE=function(r,n){return f(this,r,!0,n)},c.prototype.readInt32BE=function(r,n){return f(this,r,!1,n)},c.prototype.readFloatLE=function(r,n){return t(this,r,!0,n)},c.prototype.readFloatBE=function(r,n){return t(this,r,!1,n)},c.prototype.readDoubleLE=function(r,n){return o(this,r,!0,n)},c.prototype.readDoubleBE=function(r,n){return o(this,r,!1,n)},c.prototype.writeUInt8=function(r,n,i){i||(w(r!=null,"missing value"),w(n!=null,"missing offset"),w(n<this.length,"trying to write beyond buffer length"),or(r,255)),n>=this.length||(this[n]=r)},c.prototype.writeUInt16LE=function(r,n,i){e(this,r,n,!0,i)},c.prototype.writeUInt16BE=function(r,n,i){e(this,r,n,!1,i)},c.prototype.writeUInt32LE=function(r,n,i){u(this,r,n,!0,i)},c.prototype.writeUInt32BE=function(r,n,i){u(this,r,n,!1,i)},c.prototype.writeInt8=function(r,n,i){i||(w(r!=null,"missing value"),w(n!=null,"missing offset"),w(n<this.length,"Trying to write beyond buffer length"),ir(r,127,-128)),n>=this.length||(0<=r?this.writeUInt8(r,n,i):this.writeUInt8(255+r+1,n,i))},c.prototype.writeInt16LE=function(r,n,i){l(this,r,n,!0,i)},c.prototype.writeInt16BE=function(r,n,i){l(this,r,n,!1,i)},c.prototype.writeInt32LE=function(r,n,i){S(this,r,n,!0,i)},c.prototype.writeInt32BE=function(r,n,i){S(this,r,n,!1,i)},c.prototype.writeFloatLE=function(r,n,i){H(this,r,n,!0,i)},c.prototype.writeFloatBE=function(r,n,i){H(this,r,n,!1,i)},c.prototype.writeDoubleLE=function(r,n,i){T(this,r,n,!0,i)},c.prototype.writeDoubleBE=function(r,n,i){T(this,r,n,!1,i)},c.prototype.fill=function(r,n,i){if(n=n||0,i=i||this.length,w(typeof(r=typeof(r=r||0)=="string"?r.charCodeAt(0):r)=="number"&&!isNaN(r),"value is not a number"),w(n<=i,"end < start"),i!==n&&this.length!==0){w(0<=n&&n<this.length,"start out of bounds"),w(0<=i&&i<=this.length,"end out of bounds");for(var h=n;h<i;h++)this[h]=r}},c.prototype.inspect=function(){for(var r=[],n=this.length,i=0;i<n;i++)if(r[i]=j(this[i]),i===I.INSPECT_MAX_BYTES){r[i+1]="...";break}return"<Buffer "+r.join(" ")+">"},c.prototype.toArrayBuffer=function(){if(typeof Uint8Array=="undefined")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(c._useTypedArrays)return new c(this).buffer;for(var r=new Uint8Array(this.length),n=0,i=r.length;n<i;n+=1)r[n]=this[n];return r.buffer};var A=c.prototype;function k(r,n,i){return typeof r!="number"?i:n<=(r=~~r)?n:0<=r||0<=(r+=n)?r:0}function W(r){return(r=~~Math.ceil(+r))<0?0:r}function N(r){return(Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"})(r)}function j(r){return r<16?"0"+r.toString(16):r.toString(16)}function Q(r){for(var n=[],i=0;i<r.length;i++){var h=r.charCodeAt(i);if(h<=127)n.push(r.charCodeAt(i));else for(var p=i,v=(55296<=h&&h<=57343&&i++,encodeURIComponent(r.slice(p,i+1)).substr(1).split("%")),U=0;U<v.length;U++)n.push(parseInt(v[U],16))}return n}function hr(r){return b.toByteArray(r)}function tr(r,n,i,h){for(var p=0;p<h&&!(p+i>=n.length||p>=r.length);p++)n[p+i]=r[p];return p}function gr(r){try{return decodeURIComponent(r)}catch(n){return"�"}}function or(r,n){w(typeof r=="number","cannot write a non-number as a number"),w(0<=r,"specified a negative value for writing an unsigned value"),w(r<=n,"value is larger than maximum value for type"),w(Math.floor(r)===r,"value has a fractional component")}function ir(r,n,i){w(typeof r=="number","cannot write a non-number as a number"),w(r<=n,"value larger than maximum allowed value"),w(i<=r,"value smaller than minimum allowed value"),w(Math.floor(r)===r,"value has a fractional component")}function yr(r,n,i){w(typeof r=="number","cannot write a non-number as a number"),w(r<=n,"value larger than maximum allowed value"),w(i<=r,"value smaller than minimum allowed value")}function w(r,n){if(!r)throw new Error(n||"Failed assertion")}c._augment=function(r){return r._isBuffer=!0,r._get=r.get,r._set=r.set,r.get=A.get,r.set=A.set,r.write=A.write,r.toString=A.toString,r.toLocaleString=A.toString,r.toJSON=A.toJSON,r.copy=A.copy,r.slice=A.slice,r.readUInt8=A.readUInt8,r.readUInt16LE=A.readUInt16LE,r.readUInt16BE=A.readUInt16BE,r.readUInt32LE=A.readUInt32LE,r.readUInt32BE=A.readUInt32BE,r.readInt8=A.readInt8,r.readInt16LE=A.readInt16LE,r.readInt16BE=A.readInt16BE,r.readInt32LE=A.readInt32LE,r.readInt32BE=A.readInt32BE,r.readFloatLE=A.readFloatLE,r.readFloatBE=A.readFloatBE,r.readDoubleLE=A.readDoubleLE,r.readDoubleBE=A.readDoubleBE,r.writeUInt8=A.writeUInt8,r.writeUInt16LE=A.writeUInt16LE,r.writeUInt16BE=A.writeUInt16BE,r.writeUInt32LE=A.writeUInt32LE,r.writeUInt32BE=A.writeUInt32BE,r.writeInt8=A.writeInt8,r.writeInt16LE=A.writeInt16LE,r.writeInt16BE=A.writeInt16BE,r.writeInt32LE=A.writeInt32LE,r.writeInt32BE=A.writeInt32BE,r.writeFloatLE=A.writeFloatLE,r.writeFloatBE=A.writeFloatBE,r.writeDoubleLE=A.writeDoubleLE,r.writeDoubleBE=A.writeDoubleBE,r.fill=A.fill,r.inspect=A.inspect,r.toArrayBuffer=A.toArrayBuffer,r}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(d,B,I){(function(F,C,b,O,M,J,q,R,$){var b=d("buffer").Buffer,L=4,c=new b(L);c.fill(0),B.exports={hash:function(y,E,m,g){for(var x=E(function(e,u){e.length%L!=0&&(l=e.length+(L-e.length%L),e=b.concat([e,c],l));for(var l,S=[],H=u?e.readInt32BE:e.readInt32LE,T=0;T<e.length;T+=L)S.push(H.call(e,T));return S}(y=b.isBuffer(y)?y:new b(y),g),8*y.length),E=g,a=new b(m),f=E?a.writeInt32BE:a.writeInt32LE,t=0;t<x.length;t++)f.call(a,x[t],4*t,!0);return a}}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(d,B,I){(function(F,C,b,O,M,J,q,R,$){var b=d("buffer").Buffer,L=d("./sha"),c=d("./sha256"),y=d("./rng"),E={sha1:L,sha256:c,md5:d("./md5")},m=64,g=new b(m);function x(e,u){var l=E[e=e||"sha1"],S=[];return l||a("algorithm:",e,"is not yet supported"),{update:function(H){return b.isBuffer(H)||(H=new b(H)),S.push(H),H.length,this},digest:function(H){var T=b.concat(S),T=u?function(A,k,W){b.isBuffer(k)||(k=new b(k)),b.isBuffer(W)||(W=new b(W)),k.length>m?k=A(k):k.length<m&&(k=b.concat([k,g],m));for(var N=new b(m),j=new b(m),Q=0;Q<m;Q++)N[Q]=54^k[Q],j[Q]=92^k[Q];return W=A(b.concat([N,W])),A(b.concat([j,W]))}(l,u,T):l(T);return S=null,H?T.toString(H):T}}}function a(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
6
+ `))}g.fill(0),I.createHash=function(e){return x(e)},I.createHmac=x,I.randomBytes=function(e,u){if(!u||!u.call)return new b(y(e));try{u.call(this,void 0,new b(y(e)))}catch(l){u(l)}};var f,t=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],o=function(e){I[e]=function(){a("sorry,",e,"is not implemented yet")}};for(f in t)o(t[f])}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){var b=d("./helpers");function L(a,f){a[f>>5]|=128<<f%32,a[14+(f+64>>>9<<4)]=f;for(var t=1732584193,o=-271733879,e=-1732584194,u=271733878,l=0;l<a.length;l+=16){var S=t,H=o,T=e,A=u,t=y(t,o,e,u,a[l+0],7,-680876936),u=y(u,t,o,e,a[l+1],12,-389564586),e=y(e,u,t,o,a[l+2],17,606105819),o=y(o,e,u,t,a[l+3],22,-1044525330);t=y(t,o,e,u,a[l+4],7,-176418897),u=y(u,t,o,e,a[l+5],12,1200080426),e=y(e,u,t,o,a[l+6],17,-1473231341),o=y(o,e,u,t,a[l+7],22,-45705983),t=y(t,o,e,u,a[l+8],7,1770035416),u=y(u,t,o,e,a[l+9],12,-1958414417),e=y(e,u,t,o,a[l+10],17,-42063),o=y(o,e,u,t,a[l+11],22,-1990404162),t=y(t,o,e,u,a[l+12],7,1804603682),u=y(u,t,o,e,a[l+13],12,-40341101),e=y(e,u,t,o,a[l+14],17,-1502002290),t=E(t,o=y(o,e,u,t,a[l+15],22,1236535329),e,u,a[l+1],5,-165796510),u=E(u,t,o,e,a[l+6],9,-1069501632),e=E(e,u,t,o,a[l+11],14,643717713),o=E(o,e,u,t,a[l+0],20,-373897302),t=E(t,o,e,u,a[l+5],5,-701558691),u=E(u,t,o,e,a[l+10],9,38016083),e=E(e,u,t,o,a[l+15],14,-660478335),o=E(o,e,u,t,a[l+4],20,-405537848),t=E(t,o,e,u,a[l+9],5,568446438),u=E(u,t,o,e,a[l+14],9,-1019803690),e=E(e,u,t,o,a[l+3],14,-187363961),o=E(o,e,u,t,a[l+8],20,1163531501),t=E(t,o,e,u,a[l+13],5,-1444681467),u=E(u,t,o,e,a[l+2],9,-51403784),e=E(e,u,t,o,a[l+7],14,1735328473),t=m(t,o=E(o,e,u,t,a[l+12],20,-1926607734),e,u,a[l+5],4,-378558),u=m(u,t,o,e,a[l+8],11,-2022574463),e=m(e,u,t,o,a[l+11],16,1839030562),o=m(o,e,u,t,a[l+14],23,-35309556),t=m(t,o,e,u,a[l+1],4,-1530992060),u=m(u,t,o,e,a[l+4],11,1272893353),e=m(e,u,t,o,a[l+7],16,-155497632),o=m(o,e,u,t,a[l+10],23,-1094730640),t=m(t,o,e,u,a[l+13],4,681279174),u=m(u,t,o,e,a[l+0],11,-358537222),e=m(e,u,t,o,a[l+3],16,-722521979),o=m(o,e,u,t,a[l+6],23,76029189),t=m(t,o,e,u,a[l+9],4,-640364487),u=m(u,t,o,e,a[l+12],11,-421815835),e=m(e,u,t,o,a[l+15],16,530742520),t=g(t,o=m(o,e,u,t,a[l+2],23,-995338651),e,u,a[l+0],6,-198630844),u=g(u,t,o,e,a[l+7],10,1126891415),e=g(e,u,t,o,a[l+14],15,-1416354905),o=g(o,e,u,t,a[l+5],21,-57434055),t=g(t,o,e,u,a[l+12],6,1700485571),u=g(u,t,o,e,a[l+3],10,-1894986606),e=g(e,u,t,o,a[l+10],15,-1051523),o=g(o,e,u,t,a[l+1],21,-2054922799),t=g(t,o,e,u,a[l+8],6,1873313359),u=g(u,t,o,e,a[l+15],10,-30611744),e=g(e,u,t,o,a[l+6],15,-1560198380),o=g(o,e,u,t,a[l+13],21,1309151649),t=g(t,o,e,u,a[l+4],6,-145523070),u=g(u,t,o,e,a[l+11],10,-1120210379),e=g(e,u,t,o,a[l+2],15,718787259),o=g(o,e,u,t,a[l+9],21,-343485551),t=x(t,S),o=x(o,H),e=x(e,T),u=x(u,A)}return Array(t,o,e,u)}function c(a,f,t,o,e,u){return x((f=x(x(f,a),x(o,u)))<<e|f>>>32-e,t)}function y(a,f,t,o,e,u,l){return c(f&t|~f&o,a,f,e,u,l)}function E(a,f,t,o,e,u,l){return c(f&o|t&~o,a,f,e,u,l)}function m(a,f,t,o,e,u,l){return c(f^t^o,a,f,e,u,l)}function g(a,f,t,o,e,u,l){return c(t^(f|~o),a,f,e,u,l)}function x(a,f){var t=(65535&a)+(65535&f);return(a>>16)+(f>>16)+(t>>16)<<16|65535&t}B.exports=function(a){return b.hash(a,L,16)}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){B.exports=function(b){for(var L,c=new Array(b),y=0;y<b;y++)(3&y)==0&&(L=4294967296*Math.random()),c[y]=L>>>((3&y)<<3)&255;return c}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){var b=d("./helpers");function L(E,m){E[m>>5]|=128<<24-m%32,E[15+(m+64>>9<<4)]=m;for(var g,x,a,f=Array(80),t=1732584193,o=-271733879,e=-1732584194,u=271733878,l=-1009589776,S=0;S<E.length;S+=16){for(var H=t,T=o,A=e,k=u,W=l,N=0;N<80;N++){f[N]=N<16?E[S+N]:y(f[N-3]^f[N-8]^f[N-14]^f[N-16],1);var j=c(c(y(t,5),(j=o,x=e,a=u,(g=N)<20?j&x|~j&a:!(g<40)&&g<60?j&x|j&a|x&a:j^x^a)),c(c(l,f[N]),(g=N)<20?1518500249:g<40?1859775393:g<60?-1894007588:-899497514)),l=u,u=e,e=y(o,30),o=t,t=j}t=c(t,H),o=c(o,T),e=c(e,A),u=c(u,k),l=c(l,W)}return Array(t,o,e,u,l)}function c(E,m){var g=(65535&E)+(65535&m);return(E>>16)+(m>>16)+(g>>16)<<16|65535&g}function y(E,m){return E<<m|E>>>32-m}B.exports=function(E){return b.hash(E,L,20,!0)}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){function b(m,g){var x=(65535&m)+(65535&g);return(m>>16)+(g>>16)+(x>>16)<<16|65535&x}function L(m,g){var x,a=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),f=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),t=new Array(64);m[g>>5]|=128<<24-g%32,m[15+(g+64>>9<<4)]=g;for(var o,e,u=0;u<m.length;u+=16){for(var l=f[0],S=f[1],H=f[2],T=f[3],A=f[4],k=f[5],W=f[6],N=f[7],j=0;j<64;j++)t[j]=j<16?m[j+u]:b(b(b((e=t[j-2],y(e,17)^y(e,19)^E(e,10)),t[j-7]),(e=t[j-15],y(e,7)^y(e,18)^E(e,3))),t[j-16]),x=b(b(b(b(N,y(e=A,6)^y(e,11)^y(e,25)),A&k^~A&W),a[j]),t[j]),o=b(y(o=l,2)^y(o,13)^y(o,22),l&S^l&H^S&H),N=W,W=k,k=A,A=b(T,x),T=H,H=S,S=l,l=b(x,o);f[0]=b(l,f[0]),f[1]=b(S,f[1]),f[2]=b(H,f[2]),f[3]=b(T,f[3]),f[4]=b(A,f[4]),f[5]=b(k,f[5]),f[6]=b(W,f[6]),f[7]=b(N,f[7])}return f}var c=d("./helpers"),y=function(m,g){return m>>>g|m<<32-g},E=function(m,g){return m>>>g};B.exports=function(m){return c.hash(m,L,32,!0)}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){I.read=function(b,L,c,y,u){var m,g,x=8*u-y-1,a=(1<<x)-1,f=a>>1,t=-7,o=c?u-1:0,e=c?-1:1,u=b[L+o];for(o+=e,m=u&(1<<-t)-1,u>>=-t,t+=x;0<t;m=256*m+b[L+o],o+=e,t-=8);for(g=m&(1<<-t)-1,m>>=-t,t+=y;0<t;g=256*g+b[L+o],o+=e,t-=8);if(m===0)m=1-f;else{if(m===a)return g?NaN:1/0*(u?-1:1);g+=Math.pow(2,y),m-=f}return(u?-1:1)*g*Math.pow(2,m-y)},I.write=function(b,L,c,y,E,l){var g,x,a=8*l-E-1,f=(1<<a)-1,t=f>>1,o=E===23?Math.pow(2,-24)-Math.pow(2,-77):0,e=y?0:l-1,u=y?1:-1,l=L<0||L===0&&1/L<0?1:0;for(L=Math.abs(L),isNaN(L)||L===1/0?(x=isNaN(L)?1:0,g=f):(g=Math.floor(Math.log(L)/Math.LN2),L*(y=Math.pow(2,-g))<1&&(g--,y*=2),2<=(L+=1<=g+t?o/y:o*Math.pow(2,1-t))*y&&(g++,y/=2),f<=g+t?(x=0,g=f):1<=g+t?(x=(L*y-1)*Math.pow(2,E),g+=t):(x=L*Math.pow(2,t-1)*Math.pow(2,E),g=0));8<=E;b[c+e]=255&x,e+=u,x/=256,E-=8);for(g=g<<E|x,a+=E;0<a;b[c+e]=255&g,e+=u,g/=256,a-=8);b[c+e-u]|=128*l}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(d,B,I){(function(F,C,D,O,M,J,q,R,$){var b,L,c;function y(){}(F=B.exports={}).nextTick=(L=typeof window!="undefined"&&window.setImmediate,c=typeof window!="undefined"&&window.postMessage&&window.addEventListener,L?function(E){return window.setImmediate(E)}:c?(b=[],window.addEventListener("message",function(E){var m=E.source;m!==window&&m!==null||E.data!=="process-tick"||(E.stopPropagation(),0<b.length&&b.shift()())},!0),function(E){b.push(E),window.postMessage("process-tick","*")}):function(E){setTimeout(E,0)}),F.title="browser",F.browser=!0,F.env={},F.argv=[],F.on=y,F.addListener=y,F.once=y,F.off=y,F.removeListener=y,F.removeAllListeners=y,F.emit=y,F.binding=function(E){throw new Error("process.binding is not supported")},F.cwd=function(){return"/"},F.chdir=function(E){throw new Error("process.chdir is not supported")}}).call(this,d("lYpoI2"),typeof self!="undefined"?self:typeof window!="undefined"?window:{},d("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(ur)),ur.exports}var Kr=Jr();const Er=Dr.getDefaultExportFromCjs(Kr);function Ir(s){return Er({type:s.type,data:"data"in s?s.data:void 0,filters:"filters"in s?s.filters:void 0,params:s.params,slots:s.slots})}function Ar(s,_={},d){return{id:_r(),type:s,params:_,slots:new Set(d!=null?d:[]),hash:""}}function Vr(s,_,d={},B){const I=sr(ar({},Ar(s,d,B)),{data:_});return I.hash=Ir(I),I}function lr(s,_=[],d={},B){var F;const I=sr(ar({},Ar(s,d,B)),{filters:new Map((F=_==null?void 0:_.map(C=>[C.name,C]))!=null?F:[]),hash:""});return I.hash=Ir(I),I}function fr(s="",_){return Vr("md",s,{},_)}function Br(s){const _=typeof s.data=="string"?s.data:"";return fr(_,s.slots)}function qr(s){return s}function cr(s=[],_=[],d=!0,B){return lr("metric",_,{labels:s,order:d},B)}function Lr(s){var _,d,B,I,F;return cr((d=(_=s.params)==null?void 0:_.labels)!=null?d:[],(B=s.filters)!=null?B:[],(F=(I=s.params)==null?void 0:I.order)!=null?F:!0,s.slots)}function Fr(s){return{labels:s.labels,order:s.order}}function Z(s){return s.text}function Rr(s){return s.params.labels.map(Z)}function Wr(s,_,d){const B=Z(_);if(s.params.labels.some(I=>Z(I)===B))throw new Error(`Label "${_.text}" already exists`);return s.params.labels.splice(d!=null?d:s.params.labels.length,0,_),s}function $r(s,_){const d=s,B=Z(_);return d.params.labels=s.params.labels.filter(I=>Z(I)!==B),s}function zr(s,_,d){const B=Z(_),I=s.params.labels.findIndex(C=>Z(C)===B);if(I<0)throw new Error(`Label "${_.text}" not found`);const F=s;return F.params.labels[I]=d,s}function dr(s="",_=[],d=!1,B=[],I=!0,F){return lr("table",B,{title:s,columns:_,total:d,order:I},F)}function xr(s){var _,d,B,I,F,C,D,O;return dr((_=s.params)==null?void 0:_.title,(B=(d=s.params)==null?void 0:d.columns)!=null?B:[],(F=(I=s.params)==null?void 0:I.total)!=null?F:!1,(C=s.filters)!=null?C:[],(O=(D=s.params)==null?void 0:D.order)!=null?O:!0,s.slots)}function Hr(s){return{title:s.title,columns:s.columns,total:s.total,order:s.order}}function rr(s){return s.header}function Xr(s){return s.params.columns.map(rr)}function Gr(s,_,d){const B=rr(_);if(s.params.columns.some(I=>rr(I)===B))throw new Error(`Column "${_.header}" already exists`);return s.params.columns.splice(d!=null?d:s.params.columns.length,0,_),s}function Qr(s,_){const d=s,B=rr(_);return d.params.columns=s.params.columns.filter(I=>rr(I)!==B),s}function Zr(s,_,d){const B=rr(_),I=s.params.columns.findIndex(C=>rr(C)===B);if(I<0)throw new Error(`Column "${B}" not found`);const F=s;return F.params.columns[I]=d,s}function pr(s,_="",d={},B={},I,F,C=!1,D=[],O=!0,M){return lr(s,D,{title:_,invertAxis:C,label:d,value:B,color:I,dataLabel:F,order:O},M)}function Sr(s){var _,d,B,I,F,C,D,O,M,J,q,R,$;return pr(s.type,(d=(_=s.params)==null?void 0:_.title)!=null?d:"",(I=(B=s.params)==null?void 0:B.label)!=null?I:{},(C=(F=s.params)==null?void 0:F.value)!=null?C:{},(D=s.params)==null?void 0:D.color,(O=s.params)==null?void 0:O.dataLabel,(J=(M=s.params)==null?void 0:M.invertAxis)!=null?J:!1,(q=s.filters)!=null?q:[],($=(R=s.params)==null?void 0:R.order)!=null?$:!0,s.slots)}function Tr(s){return{title:s.title,invertAxis:s.invertAxis,label:s.label,value:s.value,color:s.color,dataLabel:s.dataLabel,order:s.order}}function re(s,_,d,B){switch(s){case"md":return fr(void 0,B);case"metric":return cr(void 0,_,d,B);case"table":return dr(void 0,void 0,void 0,_,d,B);default:return pr(s,void 0,void 0,void 0,void 0,void 0,void 0,_,d,B)}}function ee(s){switch(s.type){case"md":return Br(s);case"metric":return Lr(s);case"table":return xr(s);default:return Sr(s)}}function te(s){let _={};switch(s.type){case"md":_=s.params;break;case"metric":_=Fr(s.params);break;case"table":_=Hr(s.params);break;default:_=Tr(s.params);break}return{type:s.type,data:"data"in s?s.data:void 0,filters:"filters"in s?Array.from(s.filters.values()):void 0,params:_,slots:Array.from(s.slots)}}function Ur(s){return s.type==="md"}function Cr(s){return s.type==="metric"}function Mr(s){return s.type==="table"}function ne(s){return!Ur(s)&&!Cr(s)&&!Mr(s)}exports.addMetricLabelOfHelper=Wr;exports.addTableColumnOfHelper=Gr;exports.createFigureHelper=re;exports.createFigureHelperFrom=ee;exports.createMdFigureHelper=fr;exports.createMdFigureHelperFrom=Br;exports.createMetricFigureHelper=cr;exports.createMetricFigureHelperFrom=Lr;exports.createTableFigureHelper=dr;exports.createTableFigureHelperFrom=xr;exports.createVegaFigureHelper=pr;exports.createVegaFigureHelperFrom=Sr;exports.figureHelperToJSON=te;exports.getAllMetricLabelKeysOfHelper=Rr;exports.getAllTableColumnKeysOfHelper=Xr;exports.getMetricLabelKey=Z;exports.getTableColumnKey=rr;exports.isFigureHelperMarkdown=Ur;exports.isFigureHelperMetric=Cr;exports.isFigureHelperTable=Mr;exports.isFigureHelperVega=ne;exports.mdHelperParamsToJSON=qr;exports.metricHelperParamsToJSON=Fr;exports.nanoid=_r;exports.objectHash=Er;exports.removeMetricLabelOfHelper=$r;exports.removeTableColumnOfHelper=Qr;exports.tableHelperParamsToJSON=Hr;exports.updateMetricLabelOfHelper=zr;exports.updateTableColumnOfHelper=Zr;exports.vegaHelperParamsToJSON=Tr;
7
+ //# sourceMappingURL=index-CVa-i8Jy.js.map