@dodona/papyros 0.1.59 → 0.1.90

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 (50) hide show
  1. package/dist/App.js +1 -0
  2. package/dist/Backend.d.ts +16 -6
  3. package/dist/Backend.js +1 -0
  4. package/dist/BackendManager.d.ts +10 -1
  5. package/dist/BackendManager.js +1 -0
  6. package/dist/CodeEditor.d.ts +86 -0
  7. package/dist/CodeEditor.js +1 -0
  8. package/dist/Constants.d.ts +17 -16
  9. package/dist/Constants.js +1 -0
  10. package/dist/InputManager.d.ts +24 -16
  11. package/dist/InputManager.js +1 -0
  12. package/dist/{inputServiceWorker.js → InputServiceWorker.js} +1 -1
  13. package/dist/{library.d.ts → Library.d.ts} +3 -2
  14. package/dist/Library.js +1 -0
  15. package/dist/OutputManager.d.ts +59 -5
  16. package/dist/OutputManager.js +1 -0
  17. package/dist/Papyros.d.ts +176 -33
  18. package/dist/Papyros.js +1 -0
  19. package/dist/PapyrosEvent.d.ts +19 -3
  20. package/dist/PapyrosEvent.js +1 -0
  21. package/dist/ProgrammingLanguage.d.ts +3 -0
  22. package/dist/ProgrammingLanguage.js +1 -0
  23. package/dist/RunListener.d.ts +13 -0
  24. package/dist/RunListener.js +1 -0
  25. package/dist/RunStateManager.d.ts +67 -0
  26. package/dist/RunStateManager.js +1 -0
  27. package/dist/Translations.js +1 -0
  28. package/dist/examples/Examples.js +1 -0
  29. package/dist/examples/JavaScriptExamples.js +1 -0
  30. package/dist/examples/PythonExamples.js +1 -0
  31. package/dist/input/BatchInputHandler.d.ts +32 -0
  32. package/dist/input/BatchInputHandler.js +1 -0
  33. package/dist/input/InteractiveInputHandler.d.ts +28 -0
  34. package/dist/input/InteractiveInputHandler.js +1 -0
  35. package/dist/input/UserInputHandler.d.ts +70 -0
  36. package/dist/input/UserInputHandler.js +1 -0
  37. package/dist/util/HTMLShapes.d.ts +13 -0
  38. package/dist/util/HTMLShapes.js +1 -0
  39. package/dist/util/Logging.d.ts +9 -0
  40. package/dist/util/Logging.js +1 -0
  41. package/dist/util/Util.d.ts +94 -2
  42. package/dist/util/Util.js +1 -0
  43. package/dist/workers/input/InputWorker.d.ts +19 -3
  44. package/dist/workers/input/InputWorker.js +1 -0
  45. package/dist/workers/python/Pyodide.d.ts +19 -0
  46. package/dist/workers/python/Pyodide.js +1 -0
  47. package/package.json +6 -5
  48. package/dist/StatusPanel.d.ts +0 -8
  49. package/dist/index.js +0 -2
  50. package/dist/index.js.LICENSE.txt +0 -7
@@ -1,6 +1,22 @@
1
+ /**
2
+ * Interface for events used for communication between threads
3
+ */
1
4
  export interface PapyrosEvent {
2
- type: "input" | "output" | "script" | "success" | "error";
3
- data: string;
5
+ /**
6
+ * The type of action generating this event
7
+ */
8
+ type: "input" | "output" | "success" | "error";
9
+ /**
10
+ * The identifier for the run this message is associated with
11
+ * This allows discarding outdated events that were delayed
12
+ */
4
13
  runId: number;
5
- content?: string;
14
+ /**
15
+ * The actual data stored in this event
16
+ */
17
+ data: string;
18
+ /**
19
+ * The format used for the data to help with parsing
20
+ */
21
+ contentType: string;
6
22
  }
@@ -0,0 +1 @@
1
+ !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Papyros=o():e.Papyros=o()}(self,(function(){return(()=>{"use strict";var e={r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};return e.r(o),o})()}));
@@ -1,3 +1,6 @@
1
+ /**
2
+ * String enum representing programming languages supported by Papyros
3
+ */
1
4
  export declare enum ProgrammingLanguage {
2
5
  Python = "Python",
3
6
  JavaScript = "JavaScript"
@@ -0,0 +1 @@
1
+ !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Papyros=o():e.Papyros=o()}(self,(function(){return(()=>{"use strict";var e,o={d:(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};return o.r(t),o.d(t,{ProgrammingLanguage:()=>e}),function(e){e.Python="Python",e.JavaScript="JavaScript"}(e||(e={})),t})()}));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Interface for components that maintain state based on runs of code
3
+ */
4
+ export interface RunListener {
5
+ /**
6
+ * Inform this listener that a new run started
7
+ */
8
+ onRunStart(): void;
9
+ /**
10
+ * Inform this listener that the run ended
11
+ */
12
+ onRunEnd(): void;
13
+ }
@@ -0,0 +1 @@
1
+ !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Papyros=o():e.Papyros=o()}(self,(function(){return(()=>{"use strict";var e={r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};return e.r(o),o})()}));
@@ -0,0 +1,67 @@
1
+ import { ButtonOptions, RenderOptions } from "./util/Util";
2
+ interface DynamicButton {
3
+ id: string;
4
+ buttonHTML: string;
5
+ onClick: () => void;
6
+ }
7
+ /**
8
+ * Enum representing the possible states while processing code
9
+ */
10
+ export declare enum RunState {
11
+ Loading = "loading",
12
+ Running = "running",
13
+ AwaitingInput = "awaiting_input",
14
+ Stopping = "stopping",
15
+ Ready = "ready"
16
+ }
17
+ /**
18
+ * Helper component to manage and visualize the current RunState
19
+ */
20
+ export declare class RunStateManager {
21
+ /**
22
+ * Current state of the program
23
+ */
24
+ state: RunState;
25
+ /**
26
+ * Buttons managed by this component
27
+ */
28
+ buttons: Array<DynamicButton>;
29
+ /**
30
+ * Construct a new RunStateManager with the given listeners
31
+ * @param {function} onRunClicked Callback for when the run button is clicked
32
+ * @param {function} onStopClicked Callback for when the stop button is clicked
33
+ */
34
+ constructor(onRunClicked: () => void, onStopClicked: () => void);
35
+ /**
36
+ * Get the button to run the code
37
+ */
38
+ get runButton(): HTMLButtonElement;
39
+ /**
40
+ * Get the button to interrupt the code
41
+ */
42
+ get stopButton(): HTMLButtonElement;
43
+ /**
44
+ * Show or hide the spinning circle, representing a running animation
45
+ * @param {boolean} show Whether to show the spinner
46
+ */
47
+ showSpinner(show: boolean): void;
48
+ /**
49
+ * Show the current state of the program to the user
50
+ * @param {RunState} state The current state of the run
51
+ * @param {string} message Optional message to indicate the state
52
+ */
53
+ setState(state: RunState, message?: string): void;
54
+ /**
55
+ * Add a button to display to the user
56
+ * @param {ButtonOptions} options Options for rendering the button
57
+ * @param {function} onClick Listener for click events on the button
58
+ */
59
+ addButton(options: ButtonOptions, onClick: () => void): void;
60
+ /**
61
+ * Render the RunStateManager with the given options
62
+ * @param {RenderOptions} options Options for rendering
63
+ * @return {HTMLElement} The rendered RunStateManager
64
+ */
65
+ render(options: RenderOptions): HTMLElement;
66
+ }
67
+ export {};
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Papyros=e():t.Papyros=e()}(self,(function(){return(()=>{var t={13:function(t,e,r){var n,a;a=this,n=function(){return function(t){"use strict";var e=t&&t.I18n||{},r=Array.prototype.slice,n=function(t){return("0"+t.toString()).substr(-2)},a=function(t,e){return d("round",t,-e).toFixed(e)},i=function(t){var e=typeof t;return"function"===e||"object"===e},o=function(t){return"function"==typeof t},l=function(t){return null!=t},s=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},u=function(t){return"string"==typeof t||"[object String]"===Object.prototype.toString.call(t)},c=function(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)},p=function(t){return!0===t||!1===t},f=function(t){return null===t},d=function(t,e,r){return void 0===r||0==+r?Math[t](e):(e=+e,r=+r,isNaN(e)||"number"!=typeof r||r%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math[t](+(e[0]+"e"+(e[1]?+e[1]-r:-r)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+r:r))))},h=function(t,e){return o(t)?t(e):t},g=function(t,e){var r,n;for(r in e)e.hasOwnProperty(r)&&(n=e[r],u(n)||c(n)||p(n)||s(n)||f(n)?t[r]=n:(null==t[r]&&(t[r]={}),g(t[r],n)));return t},m={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},b={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},y={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},v={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},S=[null,"kb","mb","gb","tb"],T={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return e.reset=function(){var t;for(t in T)this[t]=T[t]},e.initializeOptions=function(){var t;for(t in T)l(this[t])||(this[t]=T[t])},e.initializeOptions(),e.locales={},e.locales.get=function(t){var r=this[t]||this[e.locale]||this.default;return o(r)&&(r=r(t)),!1===s(r)&&(r=[r]),r},e.locales.default=function(t){var r=[],n=[];return t&&r.push(t),!t&&e.locale&&r.push(e.locale),e.fallbacks&&e.defaultLocale&&r.push(e.defaultLocale),r.forEach((function(t){var r=t.split("-"),a=null,i=null;3===r.length?(a=[r[0],r[1]].join("-"),i=r[0]):2===r.length&&(a=r[0]),-1===n.indexOf(t)&&n.push(t),e.fallbacks&&[a,i].forEach((function(e){null!=e&&e!==t&&-1===n.indexOf(e)&&n.push(e)}))})),r.length||r.push("en"),n},e.pluralization={},e.pluralization.get=function(t){return this[t]||this[e.locale]||this.default},e.pluralization.default=function(t){switch(t){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},e.currentLocale=function(){return this.locale||this.defaultLocale},e.isSet=l,e.lookup=function(t,e){e=e||{};var r,n,a,i,o=this.locales.get(e.locale).slice();for(a=this.getFullScope(t,e);o.length;)if(r=o.shift(),n=a.split(e.separator||this.defaultSeparator),i=this.translations[r]){for(;n.length&&null!=(i=i[n.shift()]););if(null!=i)return i}if(l(e.defaultValue))return h(e.defaultValue,t)},e.pluralizationLookupWithoutFallback=function(t,e,r){var n,a,o=this.pluralization.get(e)(t);if(i(r))for(;o.length;)if(n=o.shift(),l(r[n])){a=r[n];break}return a},e.pluralizationLookup=function(t,e,r){r=r||{};var n,a,o,s,u=this.locales.get(r.locale).slice();for(e=this.getFullScope(e,r);u.length;)if(n=u.shift(),a=e.split(r.separator||this.defaultSeparator),o=this.translations[n]){for(;a.length&&(o=o[a.shift()],i(o));)0===a.length&&(s=this.pluralizationLookupWithoutFallback(t,n,o));if(null!=s)break}return null==s&&l(r.defaultValue)&&(s=i(r.defaultValue)?this.pluralizationLookupWithoutFallback(t,r.locale,r.defaultValue):r.defaultValue,o=r.defaultValue),{message:s,translations:o}},e.meridian=function(){var t=this.lookup("time"),e=this.lookup("date");return t&&t.am&&t.pm?[t.am,t.pm]:e&&e.meridian?e.meridian:m.meridian},e.prepareOptions=function(){for(var t,e=r.call(arguments),n={};e.length;)if("object"==typeof(t=e.shift()))for(var a in t)t.hasOwnProperty(a)&&(l(n[a])||(n[a]=t[a]));return n},e.createTranslationOptions=function(t,e){var r=[{scope:t}];return l(e.defaults)&&(r=r.concat(e.defaults)),l(e.defaultValue)&&r.push({message:e.defaultValue}),r},e.translate=function(t,e){e=e||{};var r,n=this.createTranslationOptions(t,e),a=t,o=this.prepareOptions(e);return delete o.defaultValue,n.some((function(e){if(l(e.scope)?(a=e.scope,r=this.lookup(a,o)):l(e.message)&&(r=h(e.message,t)),null!=r)return!0}),this)?("string"==typeof r?r=this.interpolate(r,e):s(r)?r=r.map((function(t){return"string"==typeof t?this.interpolate(t,e):t}),this):i(r)&&l(e.count)&&(r=this.pluralize(e.count,a,e)),r):this.missingTranslation(t,e)},e.interpolate=function(t,e){if(null==t)return t;e=e||{};var r,n,a,i,o=t.match(this.placeholder);if(!o)return t;for(;o.length;)a=(r=o.shift()).replace(this.placeholder,"$1"),n=l(e[a])?e[a].toString().replace(/\$/gm,"_#$#_"):a in e?this.nullPlaceholder(r,t,e):this.missingPlaceholder(r,t,e),i=new RegExp(r.replace(/{/gm,"\\{").replace(/}/gm,"\\}")),t=t.replace(i,n);return t.replace(/_#\$#_/g,"$")},e.pluralize=function(t,e,r){var n,a;return r=this.prepareOptions({count:String(t)},r),void 0===(a=this.pluralizationLookup(t,e,r)).translations||null==a.translations?this.missingTranslation(e,r):void 0!==a.message&&null!=a.message?this.interpolate(a.message,r):(n=this.pluralization.get(r.locale),this.missingTranslation(e+"."+n(t)[0],r))},e.missingTranslation=function(t,e){if("guess"===this.missingBehaviour){var r=t.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+r.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(t,e,r){return e+" "+r.toLowerCase()}))}return'[missing "'+[null!=e&&null!=e.locale?e.locale:this.currentLocale(),this.getFullScope(t,e)].join(e.separator||this.defaultSeparator)+'" translation]'},e.missingPlaceholder=function(t,e,r){return"[missing "+t+" value]"},e.nullPlaceholder=function(){return e.missingPlaceholder.apply(e,arguments)},e.toNumber=function(t,e){e=this.prepareOptions(e,this.lookup("number.format"),b);var r,n,i=t<0,o=a(Math.abs(t),e.precision).toString().split("."),l=[],s=e.format||"%n",u=i?"-":"";for(t=o[0],r=o[1];t.length>0;)l.unshift(t.substr(Math.max(0,t.length-3),3)),t=t.substr(0,t.length-3);return n=l.join(e.delimiter),e.strip_insignificant_zeros&&r&&(r=r.replace(/0+$/,"")),e.precision>0&&r&&(n+=e.separator+r),n=(s=e.sign_first?"%s"+s:s.replace("%n","%s%n")).replace("%u",e.unit).replace("%n",n).replace("%s",u)},e.toCurrency=function(t,e){return e=this.prepareOptions(e,this.lookup("number.currency.format",e),this.lookup("number.format",e),y),this.toNumber(t,e)},e.localize=function(t,e,r){switch(r||(r={}),t){case"currency":return this.toCurrency(e,r);case"number":return t=this.lookup("number.format",r),this.toNumber(e,t);case"percentage":return this.toPercentage(e,r);default:var n;return n=t.match(/^(date|time)/)?this.toTime(t,e,r):e.toString(),this.interpolate(n,r)}},e.parseDate=function(t){var e,r,n;if(null==t)return t;if("object"==typeof t)return t;if(e=t.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/)){for(var a=1;a<=6;a++)e[a]=parseInt(e[a],10)||0;e[2]-=1,n=e[7]?1e3*("0"+e[7]):null,r=e[8]?new Date(Date.UTC(e[1],e[2],e[3],e[4],e[5],e[6],n)):new Date(e[1],e[2],e[3],e[4],e[5],e[6],n)}else"number"==typeof t?(r=new Date).setTime(t):t.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)?(r=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(t.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/),(r=new Date).setTime(Date.parse(t)));return r},e.strftime=function(t,r,a){a=this.lookup("date",a);var i=e.meridian();if(a||(a={}),a=this.prepareOptions(a,m),isNaN(t.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var o=t.getDay(),l=t.getDate(),s=t.getFullYear(),u=t.getMonth()+1,c=t.getHours(),p=c,f=c>11?1:0,d=t.getSeconds(),h=t.getMinutes(),g=t.getTimezoneOffset(),b=Math.floor(Math.abs(g/60)),y=Math.abs(g)-60*b,v=(g>0?"-":"+")+(b.toString().length<2?"0"+b:b)+(y.toString().length<2?"0"+y:y);return p>12?p-=12:0===p&&(p=12),r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace("%a",a.abbr_day_names[o])).replace("%A",a.day_names[o])).replace("%b",a.abbr_month_names[u])).replace("%B",a.month_names[u])).replace("%d",n(l))).replace("%e",l)).replace("%-d",l)).replace("%H",n(c))).replace("%-H",c)).replace("%k",c)).replace("%I",n(p))).replace("%-I",p)).replace("%l",p)).replace("%m",n(u))).replace("%-m",u)).replace("%M",n(h))).replace("%-M",h)).replace("%p",i[f])).replace("%P",i[f].toLowerCase())).replace("%S",n(d))).replace("%-S",d)).replace("%w",o)).replace("%y",n(s))).replace("%-y",n(s).replace(/^0+/,""))).replace("%Y",s)).replace("%z",v)).replace("%Z",v)},e.toTime=function(t,e,r){var n=this.parseDate(e),a=this.lookup(t,r);if(null==n)return n;var i=n.toString();return i.match(/invalid/i)?i:a?this.strftime(n,a,r):i},e.toPercentage=function(t,e){return e=this.prepareOptions(e,this.lookup("number.percentage.format",e),this.lookup("number.format",e),v),this.toNumber(t,e)},e.toHumanSize=function(t,e){for(var r,n,a,i=1024,o=t,l=0;o>=i&&l<4;)o/=i,l+=1;return 0===l?(a=this.getFullScope("number.human.storage_units.units.byte",e),r=this.t(a,{count:o}),n=0):(a=this.getFullScope("number.human.storage_units.units."+S[l],e),r=this.t(a),n=o-Math.floor(o)==0?0:1),e=this.prepareOptions(e,{unit:r,precision:n,format:"%n%u",delimiter:""}),this.toNumber(o,e)},e.getFullScope=function(t,e){return e=e||{},s(t)&&(t=t.join(e.separator||this.defaultSeparator)),e.scope&&(t=[e.scope,t].join(e.separator||this.defaultSeparator)),t},e.extend=function(t,e){return void 0===t&&void 0===e?{}:g(t,e)},e.t=e.translate.bind(e),e.l=e.localize.bind(e),e.p=e.pluralize.bind(e),e}(a)}.call(e,r,e,t),void 0===n||(t.exports=n)},738:(t,e,r)=>{"use strict";r.d(e,{STATE_SPINNER_ID:()=>i,APPLICATION_STATE_TEXT_ID:()=>o,RUN_BTN_ID:()=>l,STOP_BTN_ID:()=>s});var n=r(905);function a(t){return"__papyros-".concat(t)}a("papyros"),a("code-output-area"),a("code-input-area-wrapper"),a("code-input-area"),a("user-input-wrapper"),a("code-area"),a("code-status-panel");var i=a("state-spinner"),o=a("application-state-text"),l=a("run-code-btn"),s=a("stop-btn");a("send-input-btn"),a("switch-input-mode"),a("example-select"),a("locale-select"),a("programming-language-select"),n.ProgrammingLanguage.Python},905:(t,e,r)=>{"use strict";var n;r.d(e,{ProgrammingLanguage:()=>n}),function(t){t.Python="Python",t.JavaScript="JavaScript"}(n||(n={}))},223:(t,e,r)=>{"use strict";r.d(e,{svgCircle:()=>n});var n=function(t,e){return'<svg id="'.concat(t,'" class="animate-spin mr-3 h-5 w-5 text-white"\nxmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">\n <circle class="opacity-25" cx="12" cy="12" r="10" stroke="').concat(e,'" stroke-width="4">\n </circle>\n <path class="opacity-75" fill="').concat(e,'"\n d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">\n </path>\n</svg>')}},155:(t,e,r)=>{"use strict";var n;!function(t){t[t.Debug=0]="Debug",t[t.Error=1]="Error",t[t.Important=2]="Important"}(n||(n={}))},924:(t,e,r)=>{"use strict";r.d(e,{t:()=>s,renderButton:()=>u,addListener:()=>c,getElement:()=>p,renderWithOptions:()=>f});var n=r(13),a=r.n(n),i=(r(963),r(155),function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}),o=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,a,i=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(t){a={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(a)throw a.error}}return o},l=function(t,e,r){if(r||2===arguments.length)for(var n,a=0,i=e.length;a<i;a++)!n&&a in e||(n||(n=Array.prototype.slice.call(e,0,a)),n[a]=e[a]);return t.concat(n||Array.prototype.slice.call(e))},s=a().t;function u(t){return t.extraClasses&&(t.extraClasses=" ".concat(t.extraClasses)),'\n<button id="'.concat(t.id,'" type="button"\n class="border-2 m-1 px-4 inset-y-2 rounded-lg\n disabled:opacity-50 disabled:cursor-wait').concat(t.extraClasses,'">\n ').concat(t.buttonText,"\n</button>")}function c(t,e,r,n){void 0===r&&(r="change"),void 0===n&&(n="value");var a=p(t);a.addEventListener(r,(function(){e(a[n]||a.getAttribute(n))}))}function p(t){return"string"==typeof t?document.getElementById(t):t}function f(t,e){var r,n,a,s=p(t.parentElementId);if(t.classNames&&(r=s.classList).add.apply(r,l([],o(t.classNames.split(" ")),!1)),t.attributes)try{for(var u=i(t.attributes.entries()),c=u.next();!c.done;c=u.next()){var f=o(c.value,2),d=f[0],h=f[1];s.setAttribute(d,h)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}return"string"==typeof e?s.innerHTML=e:s.replaceChildren(e),s}},963:t=>{}},e={};function r(n){var a=e[n];if(void 0!==a)return a.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{RunState:()=>t,RunStateManager:()=>o});var t,e=r(738),a=r(223),i=r(924);!function(t){t.Loading="loading",t.Running="running",t.AwaitingInput="awaiting_input",t.Stopping="stopping",t.Ready="ready"}(t||(t={}));var o=function(){function r(r,n){this.buttons=[],this.addButton({id:e.RUN_BTN_ID,buttonText:(0,i.t)("Papyros.run"),extraClasses:"text-white bg-blue-500"},r),this.addButton({id:e.STOP_BTN_ID,buttonText:(0,i.t)("Papyros.stop"),extraClasses:"text-white bg-red-500"},n),this.state=t.Ready}return Object.defineProperty(r.prototype,"runButton",{get:function(){return(0,i.getElement)(e.RUN_BTN_ID)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"stopButton",{get:function(){return(0,i.getElement)(e.STOP_BTN_ID)},enumerable:!1,configurable:!0}),r.prototype.showSpinner=function(t){(0,i.getElement)(e.STATE_SPINNER_ID).style.display=t?"":"none"},r.prototype.setState=function(r,n){this.state=r,this.stopButton.disabled=[t.Ready,t.Loading].includes(r),r===t.Ready?(this.showSpinner(!1),this.runButton.disabled=!1):(this.showSpinner(!0),this.runButton.disabled=!0),(0,i.getElement)(e.APPLICATION_STATE_TEXT_ID).innerText=n||(0,i.t)("Papyros.states.".concat(r))},r.prototype.addButton=function(t,e){this.buttons.push({id:t.id,buttonHTML:(0,i.renderButton)(t),onClick:e})},r.prototype.render=function(t){var r=(0,i.renderWithOptions)(t,'\n<div class="grid grid-cols-2 items-center">\n <div class="col-span-1 flex flex-row">\n '.concat(this.buttons.map((function(t){return t.buttonHTML})).join("\n"),'\n </div>\n <div class="col-span-1 flex flex-row-reverse">\n <div id="').concat(e.APPLICATION_STATE_TEXT_ID,'"></div>\n ').concat((0,a.svgCircle)(e.STATE_SPINNER_ID,"red"),"\n </div>\n</div>"));return this.buttons.forEach((function(t){return(0,i.addListener)(t.id,t.onClick,"click")})),r},r}()})(),n})()}));
@@ -0,0 +1 @@
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Papyros=n():e.Papyros=n()}(self,(function(){return e={963:e=>{const n={en:{Papyros:{Papyros:"Papyros",code:"Code",code_placeholder:"Write your %{programmingLanguage} code here and click 'Run' to execute...",input:"Input",input_placeholder:{interactive:"Provide input and press enter to send",batch:"Provide all input required by your code here.\nYou can enter multiple lines by pressing enter."},input_disabled:"You can only provide input when your code requires it in interactive mode",output:"Output",output_placeholder:"The output of your code will appear here",run:"Run",stop:"Stop",finished:"Code executed in %{time} s",states:{running:"Running",stopping:"Stopping",loading:"Loading",awaiting_input:"Awaiting input",ready:" "},programming_language:"Programming language",programming_languages:{Python:"Python",JavaScript:"JavaScript"},locales:{en:"English",nl:"Nederlands"},input_modes:{switch_to_interactive:"Switch to interactive mode",switch_to_batch:"Switch to batch input"},enter:"Enter",examples:"Examples"}},nl:{Papyros:{Papyros:"Papyros",code:"Code",code_placeholder:"Schrijf hier je %{programmingLanguage} code en klik op 'Run' om uit te voeren...",input:"Invoer",input_placeholder:{interactive:"Geef invoer in en druk op enter",batch:"Geef hier alle invoer die je code nodig heeft vooraf in.\nJe kan verschillende lijnen ingeven door op enter te drukken."},input_disabled:"Je kan enkel invoer invullen als je code erom vraagt in interactieve modus",output:"Uitvoer",output_placeholder:"Hier komt de uitvoer van je code",run:"Run",stop:"Stop",states:{running:"Aan het uitvoeren",stopping:"Aan het stoppen",loading:"Aan het laden",awaiting_input:"Aan het wachten op invoer",ready:" "},finished:"Code uitgevoerd in %{time} s",programming_language:"Programmeertaal",programming_languages:{Python:"Python",JavaScript:"JavaScript"},locales:{en:"English",nl:"Nederlands"},input_modes:{switch_to_interactive:"Wissel naar interactieve invoer",switch_to_batch:"Geef invoer vooraf in"},enter:"Enter",examples:"Voorbeelden"}}};e.exports.TRANSLATIONS=n}},n={},t=function t(o){var i=n[o];if(void 0!==i)return i.exports;var r=n[o]={exports:{}};return e[o](r,r.exports,t),r.exports}(963),t;var e,n,t}));
@@ -0,0 +1 @@
1
+ !function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Papyros=e():n.Papyros=e()}(self,(function(){return(()=>{"use strict";var n={905:(n,e,t)=>{var r;t.d(e,{ProgrammingLanguage:()=>r}),function(n){n.Python="Python",n.JavaScript="JavaScript"}(r||(r={}))},849:(n,e,t)=>{t.d(e,{JAVASCRIPT_EXAMPLES:()=>r});var r={"Hello world!":'console.log("Hello, World!");',Input:"const name = prompt('What is your name?')\nconsole.log(`Hello, ${name}!`)",Fibonacci:"function fibonacci(n){\n if (n <= 1) {\n return n;\n }\n return fibonacci(n - 2) + fibonacci(n - 1);\n}\nfor(let i = 0; i < 10; i += 1){\n console.log(fibonacci(i));\n}\n"}},652:(n,e,t)=>{t.d(e,{PYTHON_EXAMPLES:()=>r});var r={"Hello, World!":"print('Hello, World!')",Input:"name = input('What is your name?')\nprint(f'Hello, {name}!')",Fibonacci:"def fibonacci(n):\n return n if n <= 1 else fibonacci(n- 2) + fibonacci(n - 1)\n\nprint([fibonacci(n) for n in range(10)])",Doctests:'def factorial(n):\n """Return the factorial of n, an exact integer >= 0.\n\n >>> [factorial(n) for n in range(6)]\n [1, 1, 2, 6, 24, 120]\n >>> factorial(30)\n 265252859812191058636308480000000\n >>> factorial(-1)\n Traceback (most recent call last):\n ...\n ValueError: n must be >= 0\n\n Factorials of floats are OK, but the float must be an exact integer:\n >>> factorial(30.1)\n Traceback (most recent call last):\n ...\n ValueError: n must be exact integer\n >>> factorial(30.0)\n 265252859812191058636308480000000\n\n It must also not be ridiculously large:\n >>> factorial(1e100)\n Traceback (most recent call last):\n ...\n OverflowError: n too large\n """\n\n import math\n if not n >= 0:\n raise ValueError("n must be >= 0")\n if math.floor(n) != n:\n raise ValueError("n must be exact integer")\n if n+1 == n: # catch a value like 1e300\n raise OverflowError("n too large")\n result = 1\n factor = 2\n while factor <= n:\n result *= factor\n factor += 1\n return result\n\ndef wrong_factorial(n):\n """\n >>> [wrong_factorial(n) for n in range(6)]\n [1, 1, 2, 6, 24, 120]\n >>> wrong_factorial(30)\n 265252859812191058636308480000000\n """\n return 0\n\nif __name__ == "__main__":\n import doctest\n doctest.testmod()\n',Async:"async def main():\n import micropip\n await micropip.install('snowballstemmer')\n import snowballstemmer\n stemmer = snowballstemmer.stemmer('english')\n print(stemmer.stemWords('go goes going gone'.split()))\n\nawait main()",Erroneous:"def bitonic_search(numbers, query):\n if not numbers:\n return -1\n if len(numbers) == 1:\n return 0 if numbers[0] == query else -1\n int top_index = find_max_index(numbers, 0, len(numbers))\n possible_position = find_bitonic_query(numbers,query,0,top_index+1, lambda a, b: a - b)\n if possible_position != -1:\n return possible_position\n else:\n return find_bitonic_query(numbers,query,top_index, len(numbers), lambda a, b: b - a)\n\ndef find_max_index(numbers, start, stop):\n while start <= stop:\n if stop - start <= 1:\n return start\n middle = (start + stop) / 2;\n if numbers[middle] < numbers[middle+1]:\n start = midden + 1\n else:\n stop = midden\n \ndef find_bitonic_query(numbers, query, start, stop, comp):\n while start <= stop:\n if stop - start <= 1:\n return start if numbers[start] == query else -1\n middle = (start + stop) / 2;\n if comp(numbers[midden], query) <= 0:\n start = midden\n else:\n stop = midden\n",Unicode:"import random\nemoji = '🎅🤶👪🦌🌟❄️☃️🔥🎄🎁🧦🔔🎶🕯️🦆'\nfor _ in range(10):\n print(''.join(random.choice(emoji) for _ in range(30)))\n",Files:'with open("names.txt", "w") as out_file:\n for name in ["Alice", "Bob", "Claire"]:\n print(name, file=out_file)\n\nwith open("names.txt", "r") as in_file:\n for line in in_file:\n print(line.rstrip())\n',Matplotlib:"import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.linspace(0, 10, 1000)\nplt.plot(x, np.sin(x));\n\nplt.show()\n"}}},e={};function t(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return n[r](i,i.exports,t),i.exports}t.d=(n,e)=>{for(var r in e)t.o(e,r)&&!t.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:e[r]})},t.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),t.r=n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var r={};return(()=>{t.r(r),t.d(r,{getExamples:()=>a,getExampleNames:()=>s,getCodeForExample:()=>l});var n=t(905),e=t(849),o=t(652),i=new Map([[n.ProgrammingLanguage.JavaScript,e.JAVASCRIPT_EXAMPLES],[n.ProgrammingLanguage.Python,o.PYTHON_EXAMPLES]]);function a(n){return i.has(n)?i.get(n):{}}function s(n){return Object.keys(a(n))}function l(n,e){return a(n)[e]}})(),r})()}));
@@ -0,0 +1 @@
1
+ !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Papyros=o():e.Papyros=o()}(self,(function(){return(()=>{"use strict";var e={d:(o,n)=>{for(var t in n)e.o(n,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:n[t]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{JAVASCRIPT_EXAMPLES:()=>n});var n={"Hello world!":'console.log("Hello, World!");',Input:"const name = prompt('What is your name?')\nconsole.log(`Hello, ${name}!`)",Fibonacci:"function fibonacci(n){\n if (n <= 1) {\n return n;\n }\n return fibonacci(n - 2) + fibonacci(n - 1);\n}\nfor(let i = 0; i < 10; i += 1){\n console.log(fibonacci(i));\n}\n"};return o})()}));
@@ -0,0 +1 @@
1
+ !function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Papyros=e():n.Papyros=e()}(self,(function(){return(()=>{"use strict";var n={d:(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},e={};n.r(e),n.d(e,{PYTHON_EXAMPLES:()=>t});var t={"Hello, World!":"print('Hello, World!')",Input:"name = input('What is your name?')\nprint(f'Hello, {name}!')",Fibonacci:"def fibonacci(n):\n return n if n <= 1 else fibonacci(n- 2) + fibonacci(n - 1)\n\nprint([fibonacci(n) for n in range(10)])",Doctests:'def factorial(n):\n """Return the factorial of n, an exact integer >= 0.\n\n >>> [factorial(n) for n in range(6)]\n [1, 1, 2, 6, 24, 120]\n >>> factorial(30)\n 265252859812191058636308480000000\n >>> factorial(-1)\n Traceback (most recent call last):\n ...\n ValueError: n must be >= 0\n\n Factorials of floats are OK, but the float must be an exact integer:\n >>> factorial(30.1)\n Traceback (most recent call last):\n ...\n ValueError: n must be exact integer\n >>> factorial(30.0)\n 265252859812191058636308480000000\n\n It must also not be ridiculously large:\n >>> factorial(1e100)\n Traceback (most recent call last):\n ...\n OverflowError: n too large\n """\n\n import math\n if not n >= 0:\n raise ValueError("n must be >= 0")\n if math.floor(n) != n:\n raise ValueError("n must be exact integer")\n if n+1 == n: # catch a value like 1e300\n raise OverflowError("n too large")\n result = 1\n factor = 2\n while factor <= n:\n result *= factor\n factor += 1\n return result\n\ndef wrong_factorial(n):\n """\n >>> [wrong_factorial(n) for n in range(6)]\n [1, 1, 2, 6, 24, 120]\n >>> wrong_factorial(30)\n 265252859812191058636308480000000\n """\n return 0\n\nif __name__ == "__main__":\n import doctest\n doctest.testmod()\n',Async:"async def main():\n import micropip\n await micropip.install('snowballstemmer')\n import snowballstemmer\n stemmer = snowballstemmer.stemmer('english')\n print(stemmer.stemWords('go goes going gone'.split()))\n\nawait main()",Erroneous:"def bitonic_search(numbers, query):\n if not numbers:\n return -1\n if len(numbers) == 1:\n return 0 if numbers[0] == query else -1\n int top_index = find_max_index(numbers, 0, len(numbers))\n possible_position = find_bitonic_query(numbers,query,0,top_index+1, lambda a, b: a - b)\n if possible_position != -1:\n return possible_position\n else:\n return find_bitonic_query(numbers,query,top_index, len(numbers), lambda a, b: b - a)\n\ndef find_max_index(numbers, start, stop):\n while start <= stop:\n if stop - start <= 1:\n return start\n middle = (start + stop) / 2;\n if numbers[middle] < numbers[middle+1]:\n start = midden + 1\n else:\n stop = midden\n \ndef find_bitonic_query(numbers, query, start, stop, comp):\n while start <= stop:\n if stop - start <= 1:\n return start if numbers[start] == query else -1\n middle = (start + stop) / 2;\n if comp(numbers[midden], query) <= 0:\n start = midden\n else:\n stop = midden\n",Unicode:"import random\nemoji = '🎅🤶👪🦌🌟❄️☃️🔥🎄🎁🧦🔔🎶🕯️🦆'\nfor _ in range(10):\n print(''.join(random.choice(emoji) for _ in range(30)))\n",Files:'with open("names.txt", "w") as out_file:\n for name in ["Alice", "Bob", "Claire"]:\n print(name, file=out_file)\n\nwith open("names.txt", "r") as in_file:\n for line in in_file:\n print(line.rstrip())\n',Matplotlib:"import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.linspace(0, 10, 1000)\nplt.plot(x, np.sin(x));\n\nplt.show()\n"};return e})()}));
@@ -0,0 +1,32 @@
1
+ import { InputMode } from "../InputManager";
2
+ import { RenderOptions } from "../util/Util";
3
+ import { UserInputHandler } from "./UserInputHandler";
4
+ export declare class BatchInputHandler extends UserInputHandler {
5
+ /**
6
+ * The index of the next line in lines to send
7
+ */
8
+ private lineNr;
9
+ /**
10
+ * The previous input of the user
11
+ * Is restored upon switching back to InputMode.Batch
12
+ */
13
+ private previousInput;
14
+ /**
15
+ * Construct a new BatchInputHandler
16
+ * @param {function()} onInput Callback for when the user has entered a value
17
+ * @param {string} inputAreaId HTML identifier for the used HTML input field
18
+ */
19
+ constructor(onInput: () => void, inputAreaId: string);
20
+ onToggle(active: boolean): void;
21
+ getInputMode(): InputMode;
22
+ /**
23
+ * Retrieve the lines of input that the user has given so far
24
+ * @return {Array<string>} The entered lines
25
+ */
26
+ private get lines();
27
+ hasNext(): boolean;
28
+ next(): string;
29
+ onRunStart(): void;
30
+ onRunEnd(): void;
31
+ render(options: RenderOptions): HTMLElement;
32
+ }
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Papyros=e():t.Papyros=e()}(self,(function(){return(()=>{var t={13:function(t,e,n){var r,o;o=this,r=function(){return function(t){"use strict";var e=t&&t.I18n||{},n=Array.prototype.slice,r=function(t){return("0"+t.toString()).substr(-2)},o=function(t,e){return h("round",t,-e).toFixed(e)},i=function(t){var e=typeof t;return"function"===e||"object"===e},a=function(t){return"function"==typeof t},u=function(t){return null!=t},s=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},l=function(t){return"string"==typeof t||"[object String]"===Object.prototype.toString.call(t)},c=function(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)},p=function(t){return!0===t||!1===t},f=function(t){return null===t},h=function(t,e,n){return void 0===n||0==+n?Math[t](e):(e=+e,n=+n,isNaN(e)||"number"!=typeof n||n%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math[t](+(e[0]+"e"+(e[1]?+e[1]-n:-n)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+n:n))))},d=function(t,e){return a(t)?t(e):t},y=function(t,e){var n,r;for(n in e)e.hasOwnProperty(n)&&(r=e[n],l(r)||c(r)||p(r)||s(r)||f(r)?t[n]=r:(null==t[n]&&(t[n]={}),y(t[n],r)));return t},g={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},m={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},v={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},b={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},w=[null,"kb","mb","gb","tb"],_={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return e.reset=function(){var t;for(t in _)this[t]=_[t]},e.initializeOptions=function(){var t;for(t in _)u(this[t])||(this[t]=_[t])},e.initializeOptions(),e.locales={},e.locales.get=function(t){var n=this[t]||this[e.locale]||this.default;return a(n)&&(n=n(t)),!1===s(n)&&(n=[n]),n},e.locales.default=function(t){var n=[],r=[];return t&&n.push(t),!t&&e.locale&&n.push(e.locale),e.fallbacks&&e.defaultLocale&&n.push(e.defaultLocale),n.forEach((function(t){var n=t.split("-"),o=null,i=null;3===n.length?(o=[n[0],n[1]].join("-"),i=n[0]):2===n.length&&(o=n[0]),-1===r.indexOf(t)&&r.push(t),e.fallbacks&&[o,i].forEach((function(e){null!=e&&e!==t&&-1===r.indexOf(e)&&r.push(e)}))})),n.length||n.push("en"),r},e.pluralization={},e.pluralization.get=function(t){return this[t]||this[e.locale]||this.default},e.pluralization.default=function(t){switch(t){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},e.currentLocale=function(){return this.locale||this.defaultLocale},e.isSet=u,e.lookup=function(t,e){e=e||{};var n,r,o,i,a=this.locales.get(e.locale).slice();for(o=this.getFullScope(t,e);a.length;)if(n=a.shift(),r=o.split(e.separator||this.defaultSeparator),i=this.translations[n]){for(;r.length&&null!=(i=i[r.shift()]););if(null!=i)return i}if(u(e.defaultValue))return d(e.defaultValue,t)},e.pluralizationLookupWithoutFallback=function(t,e,n){var r,o,a=this.pluralization.get(e)(t);if(i(n))for(;a.length;)if(r=a.shift(),u(n[r])){o=n[r];break}return o},e.pluralizationLookup=function(t,e,n){n=n||{};var r,o,a,s,l=this.locales.get(n.locale).slice();for(e=this.getFullScope(e,n);l.length;)if(r=l.shift(),o=e.split(n.separator||this.defaultSeparator),a=this.translations[r]){for(;o.length&&(a=a[o.shift()],i(a));)0===o.length&&(s=this.pluralizationLookupWithoutFallback(t,r,a));if(null!=s)break}return null==s&&u(n.defaultValue)&&(s=i(n.defaultValue)?this.pluralizationLookupWithoutFallback(t,n.locale,n.defaultValue):n.defaultValue,a=n.defaultValue),{message:s,translations:a}},e.meridian=function(){var t=this.lookup("time"),e=this.lookup("date");return t&&t.am&&t.pm?[t.am,t.pm]:e&&e.meridian?e.meridian:g.meridian},e.prepareOptions=function(){for(var t,e=n.call(arguments),r={};e.length;)if("object"==typeof(t=e.shift()))for(var o in t)t.hasOwnProperty(o)&&(u(r[o])||(r[o]=t[o]));return r},e.createTranslationOptions=function(t,e){var n=[{scope:t}];return u(e.defaults)&&(n=n.concat(e.defaults)),u(e.defaultValue)&&n.push({message:e.defaultValue}),n},e.translate=function(t,e){e=e||{};var n,r=this.createTranslationOptions(t,e),o=t,a=this.prepareOptions(e);return delete a.defaultValue,r.some((function(e){if(u(e.scope)?(o=e.scope,n=this.lookup(o,a)):u(e.message)&&(n=d(e.message,t)),null!=n)return!0}),this)?("string"==typeof n?n=this.interpolate(n,e):s(n)?n=n.map((function(t){return"string"==typeof t?this.interpolate(t,e):t}),this):i(n)&&u(e.count)&&(n=this.pluralize(e.count,o,e)),n):this.missingTranslation(t,e)},e.interpolate=function(t,e){if(null==t)return t;e=e||{};var n,r,o,i,a=t.match(this.placeholder);if(!a)return t;for(;a.length;)o=(n=a.shift()).replace(this.placeholder,"$1"),r=u(e[o])?e[o].toString().replace(/\$/gm,"_#$#_"):o in e?this.nullPlaceholder(n,t,e):this.missingPlaceholder(n,t,e),i=new RegExp(n.replace(/{/gm,"\\{").replace(/}/gm,"\\}")),t=t.replace(i,r);return t.replace(/_#\$#_/g,"$")},e.pluralize=function(t,e,n){var r,o;return n=this.prepareOptions({count:String(t)},n),void 0===(o=this.pluralizationLookup(t,e,n)).translations||null==o.translations?this.missingTranslation(e,n):void 0!==o.message&&null!=o.message?this.interpolate(o.message,n):(r=this.pluralization.get(n.locale),this.missingTranslation(e+"."+r(t)[0],n))},e.missingTranslation=function(t,e){if("guess"===this.missingBehaviour){var n=t.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(t,e,n){return e+" "+n.toLowerCase()}))}return'[missing "'+[null!=e&&null!=e.locale?e.locale:this.currentLocale(),this.getFullScope(t,e)].join(e.separator||this.defaultSeparator)+'" translation]'},e.missingPlaceholder=function(t,e,n){return"[missing "+t+" value]"},e.nullPlaceholder=function(){return e.missingPlaceholder.apply(e,arguments)},e.toNumber=function(t,e){e=this.prepareOptions(e,this.lookup("number.format"),m);var n,r,i=t<0,a=o(Math.abs(t),e.precision).toString().split("."),u=[],s=e.format||"%n",l=i?"-":"";for(t=a[0],n=a[1];t.length>0;)u.unshift(t.substr(Math.max(0,t.length-3),3)),t=t.substr(0,t.length-3);return r=u.join(e.delimiter),e.strip_insignificant_zeros&&n&&(n=n.replace(/0+$/,"")),e.precision>0&&n&&(r+=e.separator+n),r=(s=e.sign_first?"%s"+s:s.replace("%n","%s%n")).replace("%u",e.unit).replace("%n",r).replace("%s",l)},e.toCurrency=function(t,e){return e=this.prepareOptions(e,this.lookup("number.currency.format",e),this.lookup("number.format",e),v),this.toNumber(t,e)},e.localize=function(t,e,n){switch(n||(n={}),t){case"currency":return this.toCurrency(e,n);case"number":return t=this.lookup("number.format",n),this.toNumber(e,t);case"percentage":return this.toPercentage(e,n);default:var r;return r=t.match(/^(date|time)/)?this.toTime(t,e,n):e.toString(),this.interpolate(r,n)}},e.parseDate=function(t){var e,n,r;if(null==t)return t;if("object"==typeof t)return t;if(e=t.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/)){for(var o=1;o<=6;o++)e[o]=parseInt(e[o],10)||0;e[2]-=1,r=e[7]?1e3*("0"+e[7]):null,n=e[8]?new Date(Date.UTC(e[1],e[2],e[3],e[4],e[5],e[6],r)):new Date(e[1],e[2],e[3],e[4],e[5],e[6],r)}else"number"==typeof t?(n=new Date).setTime(t):t.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)?(n=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(t.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/),(n=new Date).setTime(Date.parse(t)));return n},e.strftime=function(t,n,o){o=this.lookup("date",o);var i=e.meridian();if(o||(o={}),o=this.prepareOptions(o,g),isNaN(t.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var a=t.getDay(),u=t.getDate(),s=t.getFullYear(),l=t.getMonth()+1,c=t.getHours(),p=c,f=c>11?1:0,h=t.getSeconds(),d=t.getMinutes(),y=t.getTimezoneOffset(),m=Math.floor(Math.abs(y/60)),v=Math.abs(y)-60*m,b=(y>0?"-":"+")+(m.toString().length<2?"0"+m:m)+(v.toString().length<2?"0"+v:v);return p>12?p-=12:0===p&&(p=12),n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace("%a",o.abbr_day_names[a])).replace("%A",o.day_names[a])).replace("%b",o.abbr_month_names[l])).replace("%B",o.month_names[l])).replace("%d",r(u))).replace("%e",u)).replace("%-d",u)).replace("%H",r(c))).replace("%-H",c)).replace("%k",c)).replace("%I",r(p))).replace("%-I",p)).replace("%l",p)).replace("%m",r(l))).replace("%-m",l)).replace("%M",r(d))).replace("%-M",d)).replace("%p",i[f])).replace("%P",i[f].toLowerCase())).replace("%S",r(h))).replace("%-S",h)).replace("%w",a)).replace("%y",r(s))).replace("%-y",r(s).replace(/^0+/,""))).replace("%Y",s)).replace("%z",b)).replace("%Z",b)},e.toTime=function(t,e,n){var r=this.parseDate(e),o=this.lookup(t,n);if(null==r)return r;var i=r.toString();return i.match(/invalid/i)?i:o?this.strftime(r,o,n):i},e.toPercentage=function(t,e){return e=this.prepareOptions(e,this.lookup("number.percentage.format",e),this.lookup("number.format",e),b),this.toNumber(t,e)},e.toHumanSize=function(t,e){for(var n,r,o,i=1024,a=t,u=0;a>=i&&u<4;)a/=i,u+=1;return 0===u?(o=this.getFullScope("number.human.storage_units.units.byte",e),n=this.t(o,{count:a}),r=0):(o=this.getFullScope("number.human.storage_units.units."+w[u],e),n=this.t(o),r=a-Math.floor(a)==0?0:1),e=this.prepareOptions(e,{unit:n,precision:r,format:"%n%u",delimiter:""}),this.toNumber(a,e)},e.getFullScope=function(t,e){return e=e||{},s(t)&&(t=t.join(e.separator||this.defaultSeparator)),e.scope&&(t=[e.scope,t].join(e.separator||this.defaultSeparator)),t},e.extend=function(t,e){return void 0===t&&void 0===e?{}:y(t,e)},e.t=e.translate.bind(e),e.l=e.localize.bind(e),e.p=e.pluralize.bind(e),e}(o)}.call(e,n,e,t),void 0===r||(t.exports=r)},137:t=>{self,t.exports=(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{serviceWorkerFetchListener:()=>s,asyncSleep:()=>l,ServiceWorkerError:()=>p,writeMessageAtomics:()=>f,writeMessageServiceWorker:()=>h,writeMessage:()=>d,makeChannel:()=>y,makeAtomicsChannel:()=>g,makeServiceWorkerChannel:()=>m,readMessage:()=>b,syncSleep:()=>w,uuidv4:()=>c});var n,r=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},i=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},a="__SyncMessageServiceWorkerInput__",u="__sync-message-v2__";function s(){var t={},e={};return function(n){var r=n.request.url;return!!r.includes(a)&&(n.respondWith(function(){return o(this,void 0,void 0,(function(){function o(t){var e={message:t,version:u};return new Response(JSON.stringify(e),{status:200})}var a,s,l,c,p,f,h,d;return i(this,(function(i){switch(i.label){case 0:return r.endsWith("/read")?[4,n.request.json()]:[3,5];case 1:return a=i.sent(),s=a.messageId,l=a.timeout,(c=t[s])?(delete t[s],[2,o(c)]):[3,2];case 2:return[4,new Promise((function(t){e[s]=t,setTimeout((function(){delete e[s],t(new Response("",{status:408}))}),l)}))];case 3:return[2,i.sent()];case 4:return[3,8];case 5:return r.endsWith("/write")?[4,n.request.json()]:[3,7];case 6:return p=i.sent(),f=p.message,h=p.messageId,(d=e[h])?(d(o(f)),delete e[h]):t[h]=f,[2,o({early:!d})];case 7:if(r.endsWith("/version"))return[2,new Response(u,{status:200})];i.label=8;case 8:return[2]}}))}))}()),!0)}}function l(t){return new Promise((function(e){return setTimeout(e,t)}))}var c,p=function(t){function e(n,r){var o=t.call(this,"Received status ".concat(r," from ").concat(n,". Ensure the service worker is registered and active."))||this;return o.url=n,o.status=r,Object.setPrototypeOf(o,e.prototype),o}return r(e,t),e}(Error);function f(t,e){var n=(new TextEncoder).encode(JSON.stringify(e)),r=t.data,o=t.meta;if(n.length>r.length)throw"Input is too long";r.set(n,0),Atomics.store(o,0,n.length),Atomics.store(o,1,1),Atomics.notify(o,1)}function h(t,e,n){return o(this,void 0,void 0,(function(){var r,o,a,s,c;return i(this,(function(i){switch(i.label){case 0:return[4,navigator.serviceWorker.ready];case 1:i.sent(),r=t.baseUrl+"/write",o=Date.now(),i.label=2;case 2:return a={message:e,messageId:n},[4,fetch(r,{method:"POST",body:JSON.stringify(a)})];case 3:return s=i.sent(),(c=200===s.status)?[4,s.json()]:[3,5];case 4:c=i.sent().version===u,i.label=5;case 5:return c?[2]:Date.now()-o<t.timeout?[4,l(100)]:[3,7];case 6:return i.sent(),[3,2];case 7:throw new p(r,s.status);case 8:return[2]}}))}))}function d(t,e,n){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return"atomics"!==t.type?[3,1]:(f(t,e),[3,3]);case 1:return[4,h(t,e,n)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))}function y(t){return void 0===t&&(t={}),"undefined"!=typeof SharedArrayBuffer?g(t.atomics):"serviceWorker"in navigator?m(t.serviceWorker):null}function g(t){var e=(void 0===t?{}:t).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(e||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function m(t){return void 0===t&&(t={}),{type:"serviceWorker",baseUrl:(t.scope||"/")+a,timeout:t.timeout||5e3}}function v(t,e){return t>0?+t:e}function b(t,e,n){var r=void 0===n?{}:n,o=r.checkInterrupt,i=r.checkTimeout,a=r.timeout,s=performance.now();i=v(i,o?100:5e3);var l,c=v(a,Number.POSITIVE_INFINITY);if("atomics"===t.type){var f=t.data,h=t.meta;l=function(){if("timed-out"===Atomics.wait(h,1,0,i))return null;var t=Atomics.exchange(h,0,0),e=f.slice(0,t);Atomics.store(h,1,0);var n=(new TextDecoder).decode(e);return JSON.parse(n)}}else l=function(){var n=new XMLHttpRequest,r=t.baseUrl+"/read";n.open("POST",r,!1);var o={messageId:e,timeout:i};n.send(JSON.stringify(o));var a=n.status;if(408===a)return null;if(200===a){var l=JSON.parse(n.responseText);return l.version!==u?null:l.message}if(performance.now()-s<t.timeout)return null;throw new p(r,a)};for(;;){var d=c-(performance.now()-s);if(d<=0)return null;i=Math.min(i,d);var y=l();if(null!==y)return y;if(null==o?void 0:o())return null}}function w(t,e){if(t=v(t,0))if("undefined"!=typeof SharedArrayBuffer){var n=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));n[0]=0,Atomics.wait(n,0,0,t)}else b(e,"sleep ".concat(t," ").concat(c()),{timeout:t})}return c="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(t){var e=Number(t);return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)}))},e})()},738:(t,e,n)=>{"use strict";n.d(e,{INPUT_TA_ID:()=>i,USER_INPUT_WRAPPER_ID:()=>a,SEND_INPUT_BTN_ID:()=>u,SWITCH_INPUT_MODE_A_ID:()=>s});var r=n(905);function o(t){return"__papyros-".concat(t)}o("papyros"),o("code-output-area"),o("code-input-area-wrapper");var i=o("code-input-area"),a=o("user-input-wrapper"),u=(o("code-area"),o("code-status-panel"),o("state-spinner"),o("application-state-text"),o("run-code-btn"),o("stop-btn"),o("send-input-btn")),s=o("switch-input-mode");o("example-select"),o("locale-select"),o("programming-language-select"),r.ProgrammingLanguage.Python},934:(t,e,n)=>{"use strict";n.d(e,{InputMode:()=>r});var r,o=n(13),i=n(738),a=n(155),u=n(924),s=n(137),l=n(410),c=n(64),p=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},f=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};!function(t){t.Interactive="interactive",t.Batch="batch"}(r||(r={}));r.Batch,r.Interactive,function(){function t(t,e){this.messageId="",this._inputMode=e,this.channel=(0,s.makeChannel)(),this.onSend=t,this._waiting=!1,this.prompt="",this.inputHandlers=this.buildInputHandlerMap(),this.renderOptions={}}t.prototype.buildInputHandlerMap=function(){var t=this,e=new l.InteractiveInputHandler((function(){return t.sendLine()}),i.INPUT_TA_ID,i.SEND_INPUT_BTN_ID),n=new c.BatchInputHandler((function(){return t.sendLine()}),i.INPUT_TA_ID);return new Map([[r.Interactive,e],[r.Batch,n]])},Object.defineProperty(t.prototype,"inputMode",{get:function(){return this._inputMode},set:function(t){this.inputHandler.onToggle(!1),this._inputMode=t,this.render(this.renderOptions),this.inputHandler.onToggle(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputHandler",{get:function(){return this.inputHandlers.get(this.inputMode)},enumerable:!1,configurable:!0}),t.prototype.render=function(t){var e=this;this.renderOptions=t;var n=this.inputMode===r.Interactive?r.Batch:r.Interactive;(0,u.renderWithOptions)(t,'\n<div id="'.concat(i.USER_INPUT_WRAPPER_ID,'">\n</div>\n<a id="').concat(i.SWITCH_INPUT_MODE_A_ID,'" data-value="').concat(n,'"\nclass="flex flex-row-reverse hover:cursor-pointer text-blue-500">\n ').concat((0,o.t)("Papyros.input_modes.switch_to_".concat(n)),"\n</a>")),(0,u.addListener)(i.SWITCH_INPUT_MODE_A_ID,(function(t){return e.inputMode=t}),"click","data-value"),this.inputHandler.render({parentElementId:i.USER_INPUT_WRAPPER_ID}),this.inputHandler.waitWithPrompt(this._waiting,this.prompt)},Object.defineProperty(t.prototype,"waiting",{set:function(t){this._waiting=t,this.inputHandler.waitWithPrompt(t,this.prompt)},enumerable:!1,configurable:!0}),t.prototype.sendLine=function(){return p(this,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return this.inputHandler.hasNext()?(t=this.inputHandler.next(),(0,a.papyrosLog)(a.LogType.Debug,"Sending input to user: "+t),[4,(0,s.writeMessage)(this.channel,t,this.messageId)]):[3,2];case 1:return e.sent(),this.waiting=!1,this.onSend(),[3,3];case 2:(0,a.papyrosLog)(a.LogType.Debug,"Had no input to send, still waiting!"),this.waiting=!0,e.label=3;case 3:return[2]}}))}))},t.prototype.onInput=function(t){return p(this,void 0,void 0,(function(){var e;return f(this,(function(n){return(0,a.papyrosLog)(a.LogType.Debug,"Handling input request in Papyros"),e=(0,u.parseEventData)(t),this.messageId=e.messageId,this.prompt=e.prompt,[2,this.sendLine()]}))}))},t.prototype.onRunStart=function(){this.waiting=!1,this.inputHandler.onRunStart()},t.prototype.onRunEnd=function(){this.prompt="",this.inputHandler.onRunEnd(),this.waiting=!1}}()},905:(t,e,n)=>{"use strict";var r;n.d(e,{ProgrammingLanguage:()=>r}),function(t){t.Python="Python",t.JavaScript="JavaScript"}(r||(r={}))},64:(t,e,n)=>{"use strict";n.r(e),n.d(e,{BatchInputHandler:()=>s});var r,o=n(934),i=n(924),a=n(171),u=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.lineNr=0,r.previousInput="",r}return u(e,t),e.prototype.onToggle=function(t){t?this.inputArea.value=this.previousInput:this.previousInput=this.inputArea.value},e.prototype.getInputMode=function(){return o.InputMode.Batch},Object.defineProperty(e.prototype,"lines",{get:function(){var t=this.inputArea.value.split("\n");return t[t.length-1]||t.splice(t.length-1),t},enumerable:!1,configurable:!0}),e.prototype.hasNext=function(){return this.lineNr<this.lines.length},e.prototype.next=function(){var t=this.lines[this.lineNr];return this.lineNr+=1,t},e.prototype.onRunStart=function(){this.lineNr=0},e.prototype.onRunEnd=function(){},e.prototype.render=function(t){var e=this,n=(0,i.renderWithOptions)(t,'\n<textarea id="'.concat(this.inputAreaId,'" \nclass="border-2 h-auto w-full max-h-1/4 px-1 overflow-auto\nfocus:outline-none focus:ring-1 focus:ring-blue-500" rows="5">\n</textarea>'));return this.inputArea.addEventListener("keydown",(function(t){e.waiting&&"enter"===t.key.toLowerCase()&&(e.lines.length<e.lineNr&&(e.lineNr=e.lines.length-1),e.onInput())})),n},e}(a.UserInputHandler)},410:(t,e,n)=>{"use strict";n.d(e,{InteractiveInputHandler:()=>s});var r,o=n(934),i=n(924),a=n(171),u=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t){function e(e,n,r){var o=t.call(this,e,n)||this;return o.sendButtonId=r,o}return u(e,t),Object.defineProperty(e.prototype,"sendButton",{get:function(){return(0,i.getElement)(this.sendButtonId)},enumerable:!1,configurable:!0}),e.prototype.getInputMode=function(){return o.InputMode.Interactive},e.prototype.hasNext=function(){return this.waiting},e.prototype.next=function(){var t=this.inputArea.value;return this.inputArea.value="",t},e.prototype.waitWithPrompt=function(e,n){t.prototype.waitWithPrompt.call(this,e,n),this.sendButton.disabled=!e,this.inputArea.disabled=!e,this.inputArea.disabled&&(this.inputArea.setAttribute("placeholder",""),this.inputArea.setAttribute("title",(0,i.t)("Papyros.input_disabled")))},e.prototype.onToggle=function(){this.reset()},e.prototype.onRunStart=function(){this.reset()},e.prototype.onRunEnd=function(){},e.prototype.render=function(t){var e=this,n=(0,i.renderWithOptions)(t,'\n<div class="flex flex-row">\n <input id="'.concat(this.inputAreaId,'" type="text"\n class="border border-transparent w-full mr-0.5 px-1\n disabled:cursor-not-allowed focus:outline-none focus:ring-1 focus:ring-blue-500">\n </input>\n <button id="').concat(this.sendButtonId,'" type="button"\n class="text-black bg-white border-2 px-4\n disabled:opacity-50 disabled:cursor-wait">\n ').concat((0,i.t)("Papyros.enter"),"\n </button>\n</div>"));return(0,i.getElement)(this.sendButtonId).addEventListener("click",(function(){return e.onInput()})),this.inputArea.addEventListener("keydown",(function(t){e.waiting&&"enter"===t.key.toLowerCase()&&e.onInput()})),n},e}(a.UserInputHandler)},171:(t,e,n)=>{"use strict";n.d(e,{UserInputHandler:()=>o});var r=n(924),o=function(){function t(t,e){this.waiting=!1,this.onInput=t,this.inputAreaId=e}return Object.defineProperty(t.prototype,"inputArea",{get:function(){return(0,r.getElement)(this.inputAreaId)},enumerable:!1,configurable:!0}),t.prototype.waitWithPrompt=function(t,e){var n=this;void 0===e&&(e=""),this.waiting=t,this.inputArea.setAttribute("placeholder",e||(0,r.t)("Papyros.input_placeholder.".concat(this.getInputMode()))),t&&setTimeout((function(){return n.inputArea.focus()}),0)},t.prototype.reset=function(){this.inputArea.value=""},t}()},155:(t,e,n)=>{"use strict";n.d(e,{LogType:()=>r,papyrosLog:()=>a});var r,o=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},i=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};!function(t){t[t.Debug=0]="Debug",t[t.Error=1]="Error",t[t.Important=2]="Important"}(r||(r={}));function a(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var a=t!==r.Debug;a&&(t===r.Error?console.error.apply(console,i([],o(e),!1)):console.log.apply(console,i([],o(e),!1)))}},924:(t,e,n)=>{"use strict";n.d(e,{t:()=>l,addListener:()=>c,getElement:()=>p,renderWithOptions:()=>f,parseEventData:()=>h});var r=n(13),o=n.n(r),i=(n(963),n(155)),a=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},u=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},s=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},l=o().t;function c(t,e,n,r){void 0===n&&(n="change"),void 0===r&&(r="value");var o=p(t);o.addEventListener(n,(function(){e(o[r]||o.getAttribute(r))}))}function p(t){return"string"==typeof t?document.getElementById(t):t}function f(t,e){var n,r,o,i=p(t.parentElementId);if(t.classNames&&(n=i.classList).add.apply(n,s([],u(t.classNames.split(" ")),!1)),t.attributes)try{for(var l=a(t.attributes.entries()),c=l.next();!c.done;c=l.next()){var f=u(c.value,2),h=f[0],d=f[1];i.setAttribute(h,d)}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}return"string"==typeof e?i.innerHTML=e:i.replaceChildren(e),i}function h(t){var e=t.data,n=u(t.contentType.split("/"),2),r=n[0],o=n[1];switch(r){case"text":switch(o){case"plain":return e;case"json":return JSON.parse(e)}break;case"img":if("png;base64"===o)return e}return(0,i.papyrosLog)(i.LogType.Important,"Unhandled content type: ".concat(t.contentType)),e}},963:t=>{}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(64)})()}));
@@ -0,0 +1,28 @@
1
+ import { InputMode } from "../InputManager";
2
+ import { RenderOptions } from "../util/Util";
3
+ import { UserInputHandler } from "./UserInputHandler";
4
+ export declare class InteractiveInputHandler extends UserInputHandler {
5
+ /**
6
+ * HTML identifier for the used HTML button
7
+ */
8
+ private sendButtonId;
9
+ /**
10
+ * Construct a new InteractiveInputHandler
11
+ * @param {function()} onInput Callback for when the user has entered a value
12
+ * @param {string} inputAreaId HTML identifier for the used HTML input field
13
+ * @param {string} sendButtonId HTML identifier for the used HTML button
14
+ */
15
+ constructor(onInput: () => void, inputAreaId: string, sendButtonId: string);
16
+ /**
17
+ * Retrieve the button that users can click to send their input
18
+ */
19
+ get sendButton(): HTMLButtonElement;
20
+ getInputMode(): InputMode;
21
+ hasNext(): boolean;
22
+ next(): string;
23
+ waitWithPrompt(waiting: boolean, prompt?: string): void;
24
+ onToggle(): void;
25
+ onRunStart(): void;
26
+ onRunEnd(): void;
27
+ render(options: RenderOptions): HTMLElement;
28
+ }
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Papyros=e():t.Papyros=e()}(self,(function(){return(()=>{var t={13:function(t,e,n){var r,o;o=this,r=function(){return function(t){"use strict";var e=t&&t.I18n||{},n=Array.prototype.slice,r=function(t){return("0"+t.toString()).substr(-2)},o=function(t,e){return h("round",t,-e).toFixed(e)},i=function(t){var e=typeof t;return"function"===e||"object"===e},a=function(t){return"function"==typeof t},u=function(t){return null!=t},s=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},l=function(t){return"string"==typeof t||"[object String]"===Object.prototype.toString.call(t)},c=function(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)},p=function(t){return!0===t||!1===t},f=function(t){return null===t},h=function(t,e,n){return void 0===n||0==+n?Math[t](e):(e=+e,n=+n,isNaN(e)||"number"!=typeof n||n%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math[t](+(e[0]+"e"+(e[1]?+e[1]-n:-n)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+n:n))))},d=function(t,e){return a(t)?t(e):t},y=function(t,e){var n,r;for(n in e)e.hasOwnProperty(n)&&(r=e[n],l(r)||c(r)||p(r)||s(r)||f(r)?t[n]=r:(null==t[n]&&(t[n]={}),y(t[n],r)));return t},g={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},m={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},v={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},b={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},w=[null,"kb","mb","gb","tb"],_={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return e.reset=function(){var t;for(t in _)this[t]=_[t]},e.initializeOptions=function(){var t;for(t in _)u(this[t])||(this[t]=_[t])},e.initializeOptions(),e.locales={},e.locales.get=function(t){var n=this[t]||this[e.locale]||this.default;return a(n)&&(n=n(t)),!1===s(n)&&(n=[n]),n},e.locales.default=function(t){var n=[],r=[];return t&&n.push(t),!t&&e.locale&&n.push(e.locale),e.fallbacks&&e.defaultLocale&&n.push(e.defaultLocale),n.forEach((function(t){var n=t.split("-"),o=null,i=null;3===n.length?(o=[n[0],n[1]].join("-"),i=n[0]):2===n.length&&(o=n[0]),-1===r.indexOf(t)&&r.push(t),e.fallbacks&&[o,i].forEach((function(e){null!=e&&e!==t&&-1===r.indexOf(e)&&r.push(e)}))})),n.length||n.push("en"),r},e.pluralization={},e.pluralization.get=function(t){return this[t]||this[e.locale]||this.default},e.pluralization.default=function(t){switch(t){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},e.currentLocale=function(){return this.locale||this.defaultLocale},e.isSet=u,e.lookup=function(t,e){e=e||{};var n,r,o,i,a=this.locales.get(e.locale).slice();for(o=this.getFullScope(t,e);a.length;)if(n=a.shift(),r=o.split(e.separator||this.defaultSeparator),i=this.translations[n]){for(;r.length&&null!=(i=i[r.shift()]););if(null!=i)return i}if(u(e.defaultValue))return d(e.defaultValue,t)},e.pluralizationLookupWithoutFallback=function(t,e,n){var r,o,a=this.pluralization.get(e)(t);if(i(n))for(;a.length;)if(r=a.shift(),u(n[r])){o=n[r];break}return o},e.pluralizationLookup=function(t,e,n){n=n||{};var r,o,a,s,l=this.locales.get(n.locale).slice();for(e=this.getFullScope(e,n);l.length;)if(r=l.shift(),o=e.split(n.separator||this.defaultSeparator),a=this.translations[r]){for(;o.length&&(a=a[o.shift()],i(a));)0===o.length&&(s=this.pluralizationLookupWithoutFallback(t,r,a));if(null!=s)break}return null==s&&u(n.defaultValue)&&(s=i(n.defaultValue)?this.pluralizationLookupWithoutFallback(t,n.locale,n.defaultValue):n.defaultValue,a=n.defaultValue),{message:s,translations:a}},e.meridian=function(){var t=this.lookup("time"),e=this.lookup("date");return t&&t.am&&t.pm?[t.am,t.pm]:e&&e.meridian?e.meridian:g.meridian},e.prepareOptions=function(){for(var t,e=n.call(arguments),r={};e.length;)if("object"==typeof(t=e.shift()))for(var o in t)t.hasOwnProperty(o)&&(u(r[o])||(r[o]=t[o]));return r},e.createTranslationOptions=function(t,e){var n=[{scope:t}];return u(e.defaults)&&(n=n.concat(e.defaults)),u(e.defaultValue)&&n.push({message:e.defaultValue}),n},e.translate=function(t,e){e=e||{};var n,r=this.createTranslationOptions(t,e),o=t,a=this.prepareOptions(e);return delete a.defaultValue,r.some((function(e){if(u(e.scope)?(o=e.scope,n=this.lookup(o,a)):u(e.message)&&(n=d(e.message,t)),null!=n)return!0}),this)?("string"==typeof n?n=this.interpolate(n,e):s(n)?n=n.map((function(t){return"string"==typeof t?this.interpolate(t,e):t}),this):i(n)&&u(e.count)&&(n=this.pluralize(e.count,o,e)),n):this.missingTranslation(t,e)},e.interpolate=function(t,e){if(null==t)return t;e=e||{};var n,r,o,i,a=t.match(this.placeholder);if(!a)return t;for(;a.length;)o=(n=a.shift()).replace(this.placeholder,"$1"),r=u(e[o])?e[o].toString().replace(/\$/gm,"_#$#_"):o in e?this.nullPlaceholder(n,t,e):this.missingPlaceholder(n,t,e),i=new RegExp(n.replace(/{/gm,"\\{").replace(/}/gm,"\\}")),t=t.replace(i,r);return t.replace(/_#\$#_/g,"$")},e.pluralize=function(t,e,n){var r,o;return n=this.prepareOptions({count:String(t)},n),void 0===(o=this.pluralizationLookup(t,e,n)).translations||null==o.translations?this.missingTranslation(e,n):void 0!==o.message&&null!=o.message?this.interpolate(o.message,n):(r=this.pluralization.get(n.locale),this.missingTranslation(e+"."+r(t)[0],n))},e.missingTranslation=function(t,e){if("guess"===this.missingBehaviour){var n=t.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(t,e,n){return e+" "+n.toLowerCase()}))}return'[missing "'+[null!=e&&null!=e.locale?e.locale:this.currentLocale(),this.getFullScope(t,e)].join(e.separator||this.defaultSeparator)+'" translation]'},e.missingPlaceholder=function(t,e,n){return"[missing "+t+" value]"},e.nullPlaceholder=function(){return e.missingPlaceholder.apply(e,arguments)},e.toNumber=function(t,e){e=this.prepareOptions(e,this.lookup("number.format"),m);var n,r,i=t<0,a=o(Math.abs(t),e.precision).toString().split("."),u=[],s=e.format||"%n",l=i?"-":"";for(t=a[0],n=a[1];t.length>0;)u.unshift(t.substr(Math.max(0,t.length-3),3)),t=t.substr(0,t.length-3);return r=u.join(e.delimiter),e.strip_insignificant_zeros&&n&&(n=n.replace(/0+$/,"")),e.precision>0&&n&&(r+=e.separator+n),r=(s=e.sign_first?"%s"+s:s.replace("%n","%s%n")).replace("%u",e.unit).replace("%n",r).replace("%s",l)},e.toCurrency=function(t,e){return e=this.prepareOptions(e,this.lookup("number.currency.format",e),this.lookup("number.format",e),v),this.toNumber(t,e)},e.localize=function(t,e,n){switch(n||(n={}),t){case"currency":return this.toCurrency(e,n);case"number":return t=this.lookup("number.format",n),this.toNumber(e,t);case"percentage":return this.toPercentage(e,n);default:var r;return r=t.match(/^(date|time)/)?this.toTime(t,e,n):e.toString(),this.interpolate(r,n)}},e.parseDate=function(t){var e,n,r;if(null==t)return t;if("object"==typeof t)return t;if(e=t.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/)){for(var o=1;o<=6;o++)e[o]=parseInt(e[o],10)||0;e[2]-=1,r=e[7]?1e3*("0"+e[7]):null,n=e[8]?new Date(Date.UTC(e[1],e[2],e[3],e[4],e[5],e[6],r)):new Date(e[1],e[2],e[3],e[4],e[5],e[6],r)}else"number"==typeof t?(n=new Date).setTime(t):t.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)?(n=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(t.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/),(n=new Date).setTime(Date.parse(t)));return n},e.strftime=function(t,n,o){o=this.lookup("date",o);var i=e.meridian();if(o||(o={}),o=this.prepareOptions(o,g),isNaN(t.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var a=t.getDay(),u=t.getDate(),s=t.getFullYear(),l=t.getMonth()+1,c=t.getHours(),p=c,f=c>11?1:0,h=t.getSeconds(),d=t.getMinutes(),y=t.getTimezoneOffset(),m=Math.floor(Math.abs(y/60)),v=Math.abs(y)-60*m,b=(y>0?"-":"+")+(m.toString().length<2?"0"+m:m)+(v.toString().length<2?"0"+v:v);return p>12?p-=12:0===p&&(p=12),n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace("%a",o.abbr_day_names[a])).replace("%A",o.day_names[a])).replace("%b",o.abbr_month_names[l])).replace("%B",o.month_names[l])).replace("%d",r(u))).replace("%e",u)).replace("%-d",u)).replace("%H",r(c))).replace("%-H",c)).replace("%k",c)).replace("%I",r(p))).replace("%-I",p)).replace("%l",p)).replace("%m",r(l))).replace("%-m",l)).replace("%M",r(d))).replace("%-M",d)).replace("%p",i[f])).replace("%P",i[f].toLowerCase())).replace("%S",r(h))).replace("%-S",h)).replace("%w",a)).replace("%y",r(s))).replace("%-y",r(s).replace(/^0+/,""))).replace("%Y",s)).replace("%z",b)).replace("%Z",b)},e.toTime=function(t,e,n){var r=this.parseDate(e),o=this.lookup(t,n);if(null==r)return r;var i=r.toString();return i.match(/invalid/i)?i:o?this.strftime(r,o,n):i},e.toPercentage=function(t,e){return e=this.prepareOptions(e,this.lookup("number.percentage.format",e),this.lookup("number.format",e),b),this.toNumber(t,e)},e.toHumanSize=function(t,e){for(var n,r,o,i=1024,a=t,u=0;a>=i&&u<4;)a/=i,u+=1;return 0===u?(o=this.getFullScope("number.human.storage_units.units.byte",e),n=this.t(o,{count:a}),r=0):(o=this.getFullScope("number.human.storage_units.units."+w[u],e),n=this.t(o),r=a-Math.floor(a)==0?0:1),e=this.prepareOptions(e,{unit:n,precision:r,format:"%n%u",delimiter:""}),this.toNumber(a,e)},e.getFullScope=function(t,e){return e=e||{},s(t)&&(t=t.join(e.separator||this.defaultSeparator)),e.scope&&(t=[e.scope,t].join(e.separator||this.defaultSeparator)),t},e.extend=function(t,e){return void 0===t&&void 0===e?{}:y(t,e)},e.t=e.translate.bind(e),e.l=e.localize.bind(e),e.p=e.pluralize.bind(e),e}(o)}.call(e,n,e,t),void 0===r||(t.exports=r)},137:t=>{self,t.exports=(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{serviceWorkerFetchListener:()=>s,asyncSleep:()=>l,ServiceWorkerError:()=>p,writeMessageAtomics:()=>f,writeMessageServiceWorker:()=>h,writeMessage:()=>d,makeChannel:()=>y,makeAtomicsChannel:()=>g,makeServiceWorkerChannel:()=>m,readMessage:()=>b,syncSleep:()=>w,uuidv4:()=>c});var n,r=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},i=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},a="__SyncMessageServiceWorkerInput__",u="__sync-message-v2__";function s(){var t={},e={};return function(n){var r=n.request.url;return!!r.includes(a)&&(n.respondWith(function(){return o(this,void 0,void 0,(function(){function o(t){var e={message:t,version:u};return new Response(JSON.stringify(e),{status:200})}var a,s,l,c,p,f,h,d;return i(this,(function(i){switch(i.label){case 0:return r.endsWith("/read")?[4,n.request.json()]:[3,5];case 1:return a=i.sent(),s=a.messageId,l=a.timeout,(c=t[s])?(delete t[s],[2,o(c)]):[3,2];case 2:return[4,new Promise((function(t){e[s]=t,setTimeout((function(){delete e[s],t(new Response("",{status:408}))}),l)}))];case 3:return[2,i.sent()];case 4:return[3,8];case 5:return r.endsWith("/write")?[4,n.request.json()]:[3,7];case 6:return p=i.sent(),f=p.message,h=p.messageId,(d=e[h])?(d(o(f)),delete e[h]):t[h]=f,[2,o({early:!d})];case 7:if(r.endsWith("/version"))return[2,new Response(u,{status:200})];i.label=8;case 8:return[2]}}))}))}()),!0)}}function l(t){return new Promise((function(e){return setTimeout(e,t)}))}var c,p=function(t){function e(n,r){var o=t.call(this,"Received status ".concat(r," from ").concat(n,". Ensure the service worker is registered and active."))||this;return o.url=n,o.status=r,Object.setPrototypeOf(o,e.prototype),o}return r(e,t),e}(Error);function f(t,e){var n=(new TextEncoder).encode(JSON.stringify(e)),r=t.data,o=t.meta;if(n.length>r.length)throw"Input is too long";r.set(n,0),Atomics.store(o,0,n.length),Atomics.store(o,1,1),Atomics.notify(o,1)}function h(t,e,n){return o(this,void 0,void 0,(function(){var r,o,a,s,c;return i(this,(function(i){switch(i.label){case 0:return[4,navigator.serviceWorker.ready];case 1:i.sent(),r=t.baseUrl+"/write",o=Date.now(),i.label=2;case 2:return a={message:e,messageId:n},[4,fetch(r,{method:"POST",body:JSON.stringify(a)})];case 3:return s=i.sent(),(c=200===s.status)?[4,s.json()]:[3,5];case 4:c=i.sent().version===u,i.label=5;case 5:return c?[2]:Date.now()-o<t.timeout?[4,l(100)]:[3,7];case 6:return i.sent(),[3,2];case 7:throw new p(r,s.status);case 8:return[2]}}))}))}function d(t,e,n){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return"atomics"!==t.type?[3,1]:(f(t,e),[3,3]);case 1:return[4,h(t,e,n)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))}function y(t){return void 0===t&&(t={}),"undefined"!=typeof SharedArrayBuffer?g(t.atomics):"serviceWorker"in navigator?m(t.serviceWorker):null}function g(t){var e=(void 0===t?{}:t).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(e||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function m(t){return void 0===t&&(t={}),{type:"serviceWorker",baseUrl:(t.scope||"/")+a,timeout:t.timeout||5e3}}function v(t,e){return t>0?+t:e}function b(t,e,n){var r=void 0===n?{}:n,o=r.checkInterrupt,i=r.checkTimeout,a=r.timeout,s=performance.now();i=v(i,o?100:5e3);var l,c=v(a,Number.POSITIVE_INFINITY);if("atomics"===t.type){var f=t.data,h=t.meta;l=function(){if("timed-out"===Atomics.wait(h,1,0,i))return null;var t=Atomics.exchange(h,0,0),e=f.slice(0,t);Atomics.store(h,1,0);var n=(new TextDecoder).decode(e);return JSON.parse(n)}}else l=function(){var n=new XMLHttpRequest,r=t.baseUrl+"/read";n.open("POST",r,!1);var o={messageId:e,timeout:i};n.send(JSON.stringify(o));var a=n.status;if(408===a)return null;if(200===a){var l=JSON.parse(n.responseText);return l.version!==u?null:l.message}if(performance.now()-s<t.timeout)return null;throw new p(r,a)};for(;;){var d=c-(performance.now()-s);if(d<=0)return null;i=Math.min(i,d);var y=l();if(null!==y)return y;if(null==o?void 0:o())return null}}function w(t,e){if(t=v(t,0))if("undefined"!=typeof SharedArrayBuffer){var n=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));n[0]=0,Atomics.wait(n,0,0,t)}else b(e,"sleep ".concat(t," ").concat(c()),{timeout:t})}return c="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(t){var e=Number(t);return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)}))},e})()},738:(t,e,n)=>{"use strict";n.d(e,{INPUT_TA_ID:()=>i,USER_INPUT_WRAPPER_ID:()=>a,SEND_INPUT_BTN_ID:()=>u,SWITCH_INPUT_MODE_A_ID:()=>s});var r=n(905);function o(t){return"__papyros-".concat(t)}o("papyros"),o("code-output-area"),o("code-input-area-wrapper");var i=o("code-input-area"),a=o("user-input-wrapper"),u=(o("code-area"),o("code-status-panel"),o("state-spinner"),o("application-state-text"),o("run-code-btn"),o("stop-btn"),o("send-input-btn")),s=o("switch-input-mode");o("example-select"),o("locale-select"),o("programming-language-select"),r.ProgrammingLanguage.Python},934:(t,e,n)=>{"use strict";n.d(e,{InputMode:()=>r});var r,o=n(13),i=n(738),a=n(155),u=n(924),s=n(137),l=n(410),c=n(64),p=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},f=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};!function(t){t.Interactive="interactive",t.Batch="batch"}(r||(r={}));r.Batch,r.Interactive,function(){function t(t,e){this.messageId="",this._inputMode=e,this.channel=(0,s.makeChannel)(),this.onSend=t,this._waiting=!1,this.prompt="",this.inputHandlers=this.buildInputHandlerMap(),this.renderOptions={}}t.prototype.buildInputHandlerMap=function(){var t=this,e=new l.InteractiveInputHandler((function(){return t.sendLine()}),i.INPUT_TA_ID,i.SEND_INPUT_BTN_ID),n=new c.BatchInputHandler((function(){return t.sendLine()}),i.INPUT_TA_ID);return new Map([[r.Interactive,e],[r.Batch,n]])},Object.defineProperty(t.prototype,"inputMode",{get:function(){return this._inputMode},set:function(t){this.inputHandler.onToggle(!1),this._inputMode=t,this.render(this.renderOptions),this.inputHandler.onToggle(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputHandler",{get:function(){return this.inputHandlers.get(this.inputMode)},enumerable:!1,configurable:!0}),t.prototype.render=function(t){var e=this;this.renderOptions=t;var n=this.inputMode===r.Interactive?r.Batch:r.Interactive;(0,u.renderWithOptions)(t,'\n<div id="'.concat(i.USER_INPUT_WRAPPER_ID,'">\n</div>\n<a id="').concat(i.SWITCH_INPUT_MODE_A_ID,'" data-value="').concat(n,'"\nclass="flex flex-row-reverse hover:cursor-pointer text-blue-500">\n ').concat((0,o.t)("Papyros.input_modes.switch_to_".concat(n)),"\n</a>")),(0,u.addListener)(i.SWITCH_INPUT_MODE_A_ID,(function(t){return e.inputMode=t}),"click","data-value"),this.inputHandler.render({parentElementId:i.USER_INPUT_WRAPPER_ID}),this.inputHandler.waitWithPrompt(this._waiting,this.prompt)},Object.defineProperty(t.prototype,"waiting",{set:function(t){this._waiting=t,this.inputHandler.waitWithPrompt(t,this.prompt)},enumerable:!1,configurable:!0}),t.prototype.sendLine=function(){return p(this,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return this.inputHandler.hasNext()?(t=this.inputHandler.next(),(0,a.papyrosLog)(a.LogType.Debug,"Sending input to user: "+t),[4,(0,s.writeMessage)(this.channel,t,this.messageId)]):[3,2];case 1:return e.sent(),this.waiting=!1,this.onSend(),[3,3];case 2:(0,a.papyrosLog)(a.LogType.Debug,"Had no input to send, still waiting!"),this.waiting=!0,e.label=3;case 3:return[2]}}))}))},t.prototype.onInput=function(t){return p(this,void 0,void 0,(function(){var e;return f(this,(function(n){return(0,a.papyrosLog)(a.LogType.Debug,"Handling input request in Papyros"),e=(0,u.parseEventData)(t),this.messageId=e.messageId,this.prompt=e.prompt,[2,this.sendLine()]}))}))},t.prototype.onRunStart=function(){this.waiting=!1,this.inputHandler.onRunStart()},t.prototype.onRunEnd=function(){this.prompt="",this.inputHandler.onRunEnd(),this.waiting=!1}}()},905:(t,e,n)=>{"use strict";var r;n.d(e,{ProgrammingLanguage:()=>r}),function(t){t.Python="Python",t.JavaScript="JavaScript"}(r||(r={}))},64:(t,e,n)=>{"use strict";n.d(e,{BatchInputHandler:()=>s});var r,o=n(934),i=n(924),a=n(171),u=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.lineNr=0,r.previousInput="",r}return u(e,t),e.prototype.onToggle=function(t){t?this.inputArea.value=this.previousInput:this.previousInput=this.inputArea.value},e.prototype.getInputMode=function(){return o.InputMode.Batch},Object.defineProperty(e.prototype,"lines",{get:function(){var t=this.inputArea.value.split("\n");return t[t.length-1]||t.splice(t.length-1),t},enumerable:!1,configurable:!0}),e.prototype.hasNext=function(){return this.lineNr<this.lines.length},e.prototype.next=function(){var t=this.lines[this.lineNr];return this.lineNr+=1,t},e.prototype.onRunStart=function(){this.lineNr=0},e.prototype.onRunEnd=function(){},e.prototype.render=function(t){var e=this,n=(0,i.renderWithOptions)(t,'\n<textarea id="'.concat(this.inputAreaId,'" \nclass="border-2 h-auto w-full max-h-1/4 px-1 overflow-auto\nfocus:outline-none focus:ring-1 focus:ring-blue-500" rows="5">\n</textarea>'));return this.inputArea.addEventListener("keydown",(function(t){e.waiting&&"enter"===t.key.toLowerCase()&&(e.lines.length<e.lineNr&&(e.lineNr=e.lines.length-1),e.onInput())})),n},e}(a.UserInputHandler)},410:(t,e,n)=>{"use strict";n.r(e),n.d(e,{InteractiveInputHandler:()=>s});var r,o=n(934),i=n(924),a=n(171),u=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t){function e(e,n,r){var o=t.call(this,e,n)||this;return o.sendButtonId=r,o}return u(e,t),Object.defineProperty(e.prototype,"sendButton",{get:function(){return(0,i.getElement)(this.sendButtonId)},enumerable:!1,configurable:!0}),e.prototype.getInputMode=function(){return o.InputMode.Interactive},e.prototype.hasNext=function(){return this.waiting},e.prototype.next=function(){var t=this.inputArea.value;return this.inputArea.value="",t},e.prototype.waitWithPrompt=function(e,n){t.prototype.waitWithPrompt.call(this,e,n),this.sendButton.disabled=!e,this.inputArea.disabled=!e,this.inputArea.disabled&&(this.inputArea.setAttribute("placeholder",""),this.inputArea.setAttribute("title",(0,i.t)("Papyros.input_disabled")))},e.prototype.onToggle=function(){this.reset()},e.prototype.onRunStart=function(){this.reset()},e.prototype.onRunEnd=function(){},e.prototype.render=function(t){var e=this,n=(0,i.renderWithOptions)(t,'\n<div class="flex flex-row">\n <input id="'.concat(this.inputAreaId,'" type="text"\n class="border border-transparent w-full mr-0.5 px-1\n disabled:cursor-not-allowed focus:outline-none focus:ring-1 focus:ring-blue-500">\n </input>\n <button id="').concat(this.sendButtonId,'" type="button"\n class="text-black bg-white border-2 px-4\n disabled:opacity-50 disabled:cursor-wait">\n ').concat((0,i.t)("Papyros.enter"),"\n </button>\n</div>"));return(0,i.getElement)(this.sendButtonId).addEventListener("click",(function(){return e.onInput()})),this.inputArea.addEventListener("keydown",(function(t){e.waiting&&"enter"===t.key.toLowerCase()&&e.onInput()})),n},e}(a.UserInputHandler)},171:(t,e,n)=>{"use strict";n.d(e,{UserInputHandler:()=>o});var r=n(924),o=function(){function t(t,e){this.waiting=!1,this.onInput=t,this.inputAreaId=e}return Object.defineProperty(t.prototype,"inputArea",{get:function(){return(0,r.getElement)(this.inputAreaId)},enumerable:!1,configurable:!0}),t.prototype.waitWithPrompt=function(t,e){var n=this;void 0===e&&(e=""),this.waiting=t,this.inputArea.setAttribute("placeholder",e||(0,r.t)("Papyros.input_placeholder.".concat(this.getInputMode()))),t&&setTimeout((function(){return n.inputArea.focus()}),0)},t.prototype.reset=function(){this.inputArea.value=""},t}()},155:(t,e,n)=>{"use strict";n.d(e,{LogType:()=>r,papyrosLog:()=>a});var r,o=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},i=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};!function(t){t[t.Debug=0]="Debug",t[t.Error=1]="Error",t[t.Important=2]="Important"}(r||(r={}));function a(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var a=t!==r.Debug;a&&(t===r.Error?console.error.apply(console,i([],o(e),!1)):console.log.apply(console,i([],o(e),!1)))}},924:(t,e,n)=>{"use strict";n.d(e,{t:()=>l,addListener:()=>c,getElement:()=>p,renderWithOptions:()=>f,parseEventData:()=>h});var r=n(13),o=n.n(r),i=(n(963),n(155)),a=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},u=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},s=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},l=o().t;function c(t,e,n,r){void 0===n&&(n="change"),void 0===r&&(r="value");var o=p(t);o.addEventListener(n,(function(){e(o[r]||o.getAttribute(r))}))}function p(t){return"string"==typeof t?document.getElementById(t):t}function f(t,e){var n,r,o,i=p(t.parentElementId);if(t.classNames&&(n=i.classList).add.apply(n,s([],u(t.classNames.split(" ")),!1)),t.attributes)try{for(var l=a(t.attributes.entries()),c=l.next();!c.done;c=l.next()){var f=u(c.value,2),h=f[0],d=f[1];i.setAttribute(h,d)}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}return"string"==typeof e?i.innerHTML=e:i.replaceChildren(e),i}function h(t){var e=t.data,n=u(t.contentType.split("/"),2),r=n[0],o=n[1];switch(r){case"text":switch(o){case"plain":return e;case"json":return JSON.parse(e)}break;case"img":if("png;base64"===o)return e}return(0,i.papyrosLog)(i.LogType.Important,"Unhandled content type: ".concat(t.contentType)),e}},963:t=>{}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(410)})()}));
@@ -0,0 +1,70 @@
1
+ import { InputMode } from "../InputManager";
2
+ import { RunListener } from "../RunListener";
3
+ import { RenderOptions } from "../util/Util";
4
+ /**
5
+ * Base class for components that handle input from the user
6
+ */
7
+ export declare abstract class UserInputHandler implements RunListener {
8
+ /**
9
+ * Whether we are waiting for the user to input data
10
+ */
11
+ protected waiting: boolean;
12
+ /**
13
+ * Callback for when the user has entered a value
14
+ */
15
+ protected onInput: () => void;
16
+ /**
17
+ * HTML identifier for the used HTML input field
18
+ */
19
+ protected inputAreaId: string;
20
+ /**
21
+ * Construct a new UserInputHandler
22
+ * @param {function()} onInput Callback for when the user has entered a value
23
+ * @param {string} inputAreaId HTML identifier for the used HTML input field
24
+ */
25
+ constructor(onInput: () => void, inputAreaId: string);
26
+ /**
27
+ * Whether this handler has input ready
28
+ */
29
+ abstract hasNext(): boolean;
30
+ /**
31
+ * Consume and return the next input value
32
+ *
33
+ * Assumes hasNext() has been called and returned true,
34
+ * otherwise behaviour can produce incorrect results
35
+ * @return {string} The next value
36
+ */
37
+ abstract next(): string;
38
+ /**
39
+ * Render this UserInputHandler with the given options
40
+ * @param {RenderOptions} options The options to use while rendering
41
+ * @return {HTMLElement} The parent with the new content
42
+ */
43
+ abstract render(options: RenderOptions): HTMLElement;
44
+ abstract onRunStart(): void;
45
+ abstract onRunEnd(): void;
46
+ /**
47
+ * Retrieve the InputMode corresponding to this handler
48
+ * @return {InputMode} The InputMode enum value
49
+ */
50
+ abstract getInputMode(): InputMode;
51
+ /**
52
+ * Enable or disable this UserInputHandler
53
+ * @param {boolean} active Whether this component is active
54
+ */
55
+ abstract onToggle(active: boolean): void;
56
+ /**
57
+ * Retrieve the HTMLInputElement for this InputHandler
58
+ */
59
+ get inputArea(): HTMLInputElement;
60
+ /**
61
+ * Wait for input of the user for a certain prompt
62
+ * @param {boolean} waiting Whether we are waiting for input
63
+ * @param {string} prompt Optional message to display if waiting
64
+ */
65
+ waitWithPrompt(waiting: boolean, prompt?: string): void;
66
+ /**
67
+ * Helper method to reset internal state when needed
68
+ */
69
+ protected reset(): void;
70
+ }
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Papyros=t():e.Papyros=t()}(self,(function(){return(()=>{var e={13:function(e,t,r){var n,a;a=this,n=function(){return function(e){"use strict";var t=e&&e.I18n||{},r=Array.prototype.slice,n=function(e){return("0"+e.toString()).substr(-2)},a=function(e,t){return h("round",e,-t).toFixed(t)},i=function(e){var t=typeof e;return"function"===t||"object"===t},o=function(e){return"function"==typeof e},l=function(e){return null!=e},u=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},s=function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},p=function(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)},c=function(e){return!0===e||!1===e},f=function(e){return null===e},h=function(e,t,r){return void 0===r||0==+r?Math[e](t):(t=+t,r=+r,isNaN(t)||"number"!=typeof r||r%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math[e](+(t[0]+"e"+(t[1]?+t[1]-r:-r)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+r:r))))},d=function(e,t){return o(e)?e(t):e},m=function(e,t){var r,n;for(r in t)t.hasOwnProperty(r)&&(n=t[r],s(n)||p(n)||c(n)||u(n)||f(n)?e[r]=n:(null==e[r]&&(e[r]={}),m(e[r],n)));return e},g={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},b={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},y={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},v={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},S=[null,"kb","mb","gb","tb"],_={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return t.reset=function(){var e;for(e in _)this[e]=_[e]},t.initializeOptions=function(){var e;for(e in _)l(this[e])||(this[e]=_[e])},t.initializeOptions(),t.locales={},t.locales.get=function(e){var r=this[e]||this[t.locale]||this.default;return o(r)&&(r=r(e)),!1===u(r)&&(r=[r]),r},t.locales.default=function(e){var r=[],n=[];return e&&r.push(e),!e&&t.locale&&r.push(t.locale),t.fallbacks&&t.defaultLocale&&r.push(t.defaultLocale),r.forEach((function(e){var r=e.split("-"),a=null,i=null;3===r.length?(a=[r[0],r[1]].join("-"),i=r[0]):2===r.length&&(a=r[0]),-1===n.indexOf(e)&&n.push(e),t.fallbacks&&[a,i].forEach((function(t){null!=t&&t!==e&&-1===n.indexOf(t)&&n.push(t)}))})),r.length||r.push("en"),n},t.pluralization={},t.pluralization.get=function(e){return this[e]||this[t.locale]||this.default},t.pluralization.default=function(e){switch(e){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},t.currentLocale=function(){return this.locale||this.defaultLocale},t.isSet=l,t.lookup=function(e,t){t=t||{};var r,n,a,i,o=this.locales.get(t.locale).slice();for(a=this.getFullScope(e,t);o.length;)if(r=o.shift(),n=a.split(t.separator||this.defaultSeparator),i=this.translations[r]){for(;n.length&&null!=(i=i[n.shift()]););if(null!=i)return i}if(l(t.defaultValue))return d(t.defaultValue,e)},t.pluralizationLookupWithoutFallback=function(e,t,r){var n,a,o=this.pluralization.get(t)(e);if(i(r))for(;o.length;)if(n=o.shift(),l(r[n])){a=r[n];break}return a},t.pluralizationLookup=function(e,t,r){r=r||{};var n,a,o,u,s=this.locales.get(r.locale).slice();for(t=this.getFullScope(t,r);s.length;)if(n=s.shift(),a=t.split(r.separator||this.defaultSeparator),o=this.translations[n]){for(;a.length&&(o=o[a.shift()],i(o));)0===a.length&&(u=this.pluralizationLookupWithoutFallback(e,n,o));if(null!=u)break}return null==u&&l(r.defaultValue)&&(u=i(r.defaultValue)?this.pluralizationLookupWithoutFallback(e,r.locale,r.defaultValue):r.defaultValue,o=r.defaultValue),{message:u,translations:o}},t.meridian=function(){var e=this.lookup("time"),t=this.lookup("date");return e&&e.am&&e.pm?[e.am,e.pm]:t&&t.meridian?t.meridian:g.meridian},t.prepareOptions=function(){for(var e,t=r.call(arguments),n={};t.length;)if("object"==typeof(e=t.shift()))for(var a in e)e.hasOwnProperty(a)&&(l(n[a])||(n[a]=e[a]));return n},t.createTranslationOptions=function(e,t){var r=[{scope:e}];return l(t.defaults)&&(r=r.concat(t.defaults)),l(t.defaultValue)&&r.push({message:t.defaultValue}),r},t.translate=function(e,t){t=t||{};var r,n=this.createTranslationOptions(e,t),a=e,o=this.prepareOptions(t);return delete o.defaultValue,n.some((function(t){if(l(t.scope)?(a=t.scope,r=this.lookup(a,o)):l(t.message)&&(r=d(t.message,e)),null!=r)return!0}),this)?("string"==typeof r?r=this.interpolate(r,t):u(r)?r=r.map((function(e){return"string"==typeof e?this.interpolate(e,t):e}),this):i(r)&&l(t.count)&&(r=this.pluralize(t.count,a,t)),r):this.missingTranslation(e,t)},t.interpolate=function(e,t){if(null==e)return e;t=t||{};var r,n,a,i,o=e.match(this.placeholder);if(!o)return e;for(;o.length;)a=(r=o.shift()).replace(this.placeholder,"$1"),n=l(t[a])?t[a].toString().replace(/\$/gm,"_#$#_"):a in t?this.nullPlaceholder(r,e,t):this.missingPlaceholder(r,e,t),i=new RegExp(r.replace(/{/gm,"\\{").replace(/}/gm,"\\}")),e=e.replace(i,n);return e.replace(/_#\$#_/g,"$")},t.pluralize=function(e,t,r){var n,a;return r=this.prepareOptions({count:String(e)},r),void 0===(a=this.pluralizationLookup(e,t,r)).translations||null==a.translations?this.missingTranslation(t,r):void 0!==a.message&&null!=a.message?this.interpolate(a.message,r):(n=this.pluralization.get(r.locale),this.missingTranslation(t+"."+n(e)[0],r))},t.missingTranslation=function(e,t){if("guess"===this.missingBehaviour){var r=e.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+r.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(e,t,r){return t+" "+r.toLowerCase()}))}return'[missing "'+[null!=t&&null!=t.locale?t.locale:this.currentLocale(),this.getFullScope(e,t)].join(t.separator||this.defaultSeparator)+'" translation]'},t.missingPlaceholder=function(e,t,r){return"[missing "+e+" value]"},t.nullPlaceholder=function(){return t.missingPlaceholder.apply(t,arguments)},t.toNumber=function(e,t){t=this.prepareOptions(t,this.lookup("number.format"),b);var r,n,i=e<0,o=a(Math.abs(e),t.precision).toString().split("."),l=[],u=t.format||"%n",s=i?"-":"";for(e=o[0],r=o[1];e.length>0;)l.unshift(e.substr(Math.max(0,e.length-3),3)),e=e.substr(0,e.length-3);return n=l.join(t.delimiter),t.strip_insignificant_zeros&&r&&(r=r.replace(/0+$/,"")),t.precision>0&&r&&(n+=t.separator+r),n=(u=t.sign_first?"%s"+u:u.replace("%n","%s%n")).replace("%u",t.unit).replace("%n",n).replace("%s",s)},t.toCurrency=function(e,t){return t=this.prepareOptions(t,this.lookup("number.currency.format",t),this.lookup("number.format",t),y),this.toNumber(e,t)},t.localize=function(e,t,r){switch(r||(r={}),e){case"currency":return this.toCurrency(t,r);case"number":return e=this.lookup("number.format",r),this.toNumber(t,e);case"percentage":return this.toPercentage(t,r);default:var n;return n=e.match(/^(date|time)/)?this.toTime(e,t,r):t.toString(),this.interpolate(n,r)}},t.parseDate=function(e){var t,r,n;if(null==e)return e;if("object"==typeof e)return e;if(t=e.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/)){for(var a=1;a<=6;a++)t[a]=parseInt(t[a],10)||0;t[2]-=1,n=t[7]?1e3*("0"+t[7]):null,r=t[8]?new Date(Date.UTC(t[1],t[2],t[3],t[4],t[5],t[6],n)):new Date(t[1],t[2],t[3],t[4],t[5],t[6],n)}else"number"==typeof e?(r=new Date).setTime(e):e.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)?(r=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(e.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/),(r=new Date).setTime(Date.parse(e)));return r},t.strftime=function(e,r,a){a=this.lookup("date",a);var i=t.meridian();if(a||(a={}),a=this.prepareOptions(a,g),isNaN(e.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var o=e.getDay(),l=e.getDate(),u=e.getFullYear(),s=e.getMonth()+1,p=e.getHours(),c=p,f=p>11?1:0,h=e.getSeconds(),d=e.getMinutes(),m=e.getTimezoneOffset(),b=Math.floor(Math.abs(m/60)),y=Math.abs(m)-60*b,v=(m>0?"-":"+")+(b.toString().length<2?"0"+b:b)+(y.toString().length<2?"0"+y:y);return c>12?c-=12:0===c&&(c=12),r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace("%a",a.abbr_day_names[o])).replace("%A",a.day_names[o])).replace("%b",a.abbr_month_names[s])).replace("%B",a.month_names[s])).replace("%d",n(l))).replace("%e",l)).replace("%-d",l)).replace("%H",n(p))).replace("%-H",p)).replace("%k",p)).replace("%I",n(c))).replace("%-I",c)).replace("%l",c)).replace("%m",n(s))).replace("%-m",s)).replace("%M",n(d))).replace("%-M",d)).replace("%p",i[f])).replace("%P",i[f].toLowerCase())).replace("%S",n(h))).replace("%-S",h)).replace("%w",o)).replace("%y",n(u))).replace("%-y",n(u).replace(/^0+/,""))).replace("%Y",u)).replace("%z",v)).replace("%Z",v)},t.toTime=function(e,t,r){var n=this.parseDate(t),a=this.lookup(e,r);if(null==n)return n;var i=n.toString();return i.match(/invalid/i)?i:a?this.strftime(n,a,r):i},t.toPercentage=function(e,t){return t=this.prepareOptions(t,this.lookup("number.percentage.format",t),this.lookup("number.format",t),v),this.toNumber(e,t)},t.toHumanSize=function(e,t){for(var r,n,a,i=1024,o=e,l=0;o>=i&&l<4;)o/=i,l+=1;return 0===l?(a=this.getFullScope("number.human.storage_units.units.byte",t),r=this.t(a,{count:o}),n=0):(a=this.getFullScope("number.human.storage_units.units."+S[l],t),r=this.t(a),n=o-Math.floor(o)==0?0:1),t=this.prepareOptions(t,{unit:r,precision:n,format:"%n%u",delimiter:""}),this.toNumber(o,t)},t.getFullScope=function(e,t){return t=t||{},u(e)&&(e=e.join(t.separator||this.defaultSeparator)),t.scope&&(e=[t.scope,e].join(t.separator||this.defaultSeparator)),e},t.extend=function(e,t){return void 0===e&&void 0===t?{}:m(e,t)},t.t=t.translate.bind(t),t.l=t.localize.bind(t),t.p=t.pluralize.bind(t),t}(a)}.call(t,r,t,e),void 0===n||(e.exports=n)},155:(e,t,r)=>{"use strict";var n;!function(e){e[e.Debug=0]="Debug",e[e.Error=1]="Error",e[e.Important=2]="Important"}(n||(n={}))},924:(e,t,r)=>{"use strict";r.d(t,{t:()=>i,getElement:()=>o});var n=r(13),a=r.n(n),i=(r(963),r(155),a().t);function o(e){return"string"==typeof e?document.getElementById(e):e}},963:e=>{}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{UserInputHandler:()=>t});var e=r(924),t=function(){function t(e,t){this.waiting=!1,this.onInput=e,this.inputAreaId=t}return Object.defineProperty(t.prototype,"inputArea",{get:function(){return(0,e.getElement)(this.inputAreaId)},enumerable:!1,configurable:!0}),t.prototype.waitWithPrompt=function(t,r){var n=this;void 0===r&&(r=""),this.waiting=t,this.inputArea.setAttribute("placeholder",r||(0,e.t)("Papyros.input_placeholder.".concat(this.getInputMode()))),t&&setTimeout((function(){return n.inputArea.focus()}),0)},t.prototype.reset=function(){this.inputArea.value=""},t}()})(),n})()}));
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Draw a circle using an HTML svg element
3
+ * @param {string} id HTML id for this element
4
+ * @param {string} color The color of the circle
5
+ * @return {string} A string representation of the circle
6
+ */
1
7
  export declare const svgCircle: (id: string, color: string) => string;
8
+ /**
9
+ * Wrap text (best a single character) in a circle to provide information to the user
10
+ * @param {string} content The symbol in the circle, e.g. ? of !
11
+ * @param {string} title The information to display when hovering over the element
12
+ * @param {string} color The color of the circle and the symbol
13
+ * @return {string} A string representation of the circle with content
14
+ */
2
15
  export declare const inCircle: (content: string, title: string, color: string) => string;
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Papyros=t():e.Papyros=t()}(self,(function(){return(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{svgCircle:()=>o,inCircle:()=>n});var o=function(e,t){return'<svg id="'.concat(e,'" class="animate-spin mr-3 h-5 w-5 text-white"\nxmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">\n <circle class="opacity-25" cx="12" cy="12" r="10" stroke="').concat(t,'" stroke-width="4">\n </circle>\n <path class="opacity-75" fill="').concat(t,'"\n d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">\n </path>\n</svg>')},n=function(e,t,o){var n=t?'title="'.concat(t,'"'):"";return"<span ".concat(n,' class="display-block font-bold text-center\n w-10 h-10 rounded-full px-1 text-').concat(o," bg-white-500 border-").concat(o,' border-2">').concat(e,"</span>")};return t})()}));
@@ -1,6 +1,15 @@
1
+ /**
2
+ * Enum representing the importance of a log message
3
+ * This is helpful for debugging while allowing filtering in production
4
+ */
1
5
  export declare enum LogType {
2
6
  Debug = 0,
3
7
  Error = 1,
4
8
  Important = 2
5
9
  }
10
+ /**
11
+ * Helper method to log useful information at runtime
12
+ * @param {LogType} logType The importance of this log message
13
+ * @param {any[]} args The data to log
14
+ */
6
15
  export declare function papyrosLog(logType: LogType, ...args: any[]): void;
@@ -0,0 +1 @@
1
+ !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Papyros=o():e.Papyros=o()}(self,(function(){return(()=>{"use strict";var e={d:(o,r)=>{for(var t in r)e.o(r,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:r[t]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{LogType:()=>r,papyrosLog:()=>l});var r,t=function(e,o){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,n,l=r.call(e),a=[];try{for(;(void 0===o||o-- >0)&&!(t=l.next()).done;)a.push(t.value)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return a},n=function(e,o,r){if(r||2===arguments.length)for(var t,n=0,l=o.length;n<l;n++)!t&&n in o||(t||(t=Array.prototype.slice.call(o,0,n)),t[n]=o[n]);return e.concat(t||Array.prototype.slice.call(o))};!function(e){e[e.Debug=0]="Debug",e[e.Error=1]="Error",e[e.Important=2]="Important"}(r||(r={}));function l(e){for(var o=[],l=1;l<arguments.length;l++)o[l-1]=arguments[l];var a=e!==r.Debug;a&&(e===r.Error?console.error.apply(console,n([],t(o),!1)):console.log.apply(console,n([],t(o),!1)))}return o})()}));