reneco-advanced-input-module 0.0.4 → 0.0.5

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 (53) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/ocr-file-uploader.cjs.entry.js +123 -0
  3. package/dist/cjs/ocr-file-uploader.cjs.entry.js.map +1 -0
  4. package/dist/cjs/ocr-file-uploader.entry.cjs.js.map +1 -0
  5. package/dist/cjs/{ocr-file-uploader_2.cjs.entry.js → voice-input-module.cjs.entry.js} +190 -118
  6. package/dist/cjs/voice-input-module.cjs.entry.js.map +1 -0
  7. package/dist/cjs/voice-input-module.cjs.js +1 -1
  8. package/dist/cjs/voice-input-module.entry.cjs.js.map +1 -0
  9. package/dist/collection/components/voice-input-module/voice-input-module.css +27 -15
  10. package/dist/collection/components/voice-input-module/voice-input-module.js +159 -34
  11. package/dist/collection/components/voice-input-module/voice-input-module.js.map +1 -1
  12. package/dist/components/ocr-file-uploader2.js +45 -3
  13. package/dist/components/ocr-file-uploader2.js.map +1 -1
  14. package/dist/components/voice-input-module.js +191 -39
  15. package/dist/components/voice-input-module.js.map +1 -1
  16. package/dist/esm/loader.js +1 -1
  17. package/dist/esm/ocr-file-uploader.entry.js +121 -0
  18. package/dist/esm/ocr-file-uploader.entry.js.map +1 -0
  19. package/dist/esm/{ocr-file-uploader_2.entry.js → voice-input-module.entry.js} +192 -119
  20. package/dist/esm/voice-input-module.entry.js.map +1 -0
  21. package/dist/esm/voice-input-module.js +1 -1
  22. package/dist/types/components/voice-input-module/voice-input-module.d.ts +5 -0
  23. package/dist/types/components.d.ts +8 -0
  24. package/dist/voice-input-module/ocr-file-uploader.entry.esm.js.map +1 -0
  25. package/dist/voice-input-module/p-2fdd8c9d.entry.js +3 -0
  26. package/dist/voice-input-module/p-2fdd8c9d.entry.js.map +1 -0
  27. package/dist/voice-input-module/p-a5eeaf1c.entry.js +2 -0
  28. package/dist/voice-input-module/p-a5eeaf1c.entry.js.map +1 -0
  29. package/dist/voice-input-module/voice-input-module.entry.esm.js.map +1 -0
  30. package/dist/voice-input-module/voice-input-module.esm.js +1 -1
  31. package/package.json +3 -4
  32. package/readme.md +220 -1
  33. package/www/build/ocr-file-uploader.entry.esm.js.map +1 -0
  34. package/www/build/p-0b3e3078.js +2 -0
  35. package/www/build/p-2fdd8c9d.entry.js +3 -0
  36. package/www/build/p-2fdd8c9d.entry.js.map +1 -0
  37. package/www/build/p-a5eeaf1c.entry.js +2 -0
  38. package/www/build/p-a5eeaf1c.entry.js.map +1 -0
  39. package/www/build/voice-input-module.entry.esm.js.map +1 -0
  40. package/www/build/voice-input-module.esm.js +1 -1
  41. package/www/config.js +6 -0
  42. package/www/index.html +138 -10
  43. package/dist/cjs/ocr-file-uploader.voice-input-module.entry.cjs.js.map +0 -1
  44. package/dist/cjs/ocr-file-uploader_2.cjs.entry.js.map +0 -1
  45. package/dist/esm/ocr-file-uploader.voice-input-module.entry.js.map +0 -1
  46. package/dist/esm/ocr-file-uploader_2.entry.js.map +0 -1
  47. package/dist/voice-input-module/ocr-file-uploader.voice-input-module.entry.esm.js.map +0 -1
  48. package/dist/voice-input-module/p-21d2e52b.entry.js +0 -3
  49. package/dist/voice-input-module/p-21d2e52b.entry.js.map +0 -1
  50. package/www/build/ocr-file-uploader.voice-input-module.entry.esm.js.map +0 -1
  51. package/www/build/p-21d2e52b.entry.js +0 -3
  52. package/www/build/p-21d2e52b.entry.js.map +0 -1
  53. package/www/build/p-b680b1be.js +0 -2
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
6
6
  const defineCustomElements = async (win, options) => {
7
7
  if (typeof window === 'undefined') return undefined;
8
8
  await appGlobals.globalScripts();
9
- return index.bootstrapLazy([["ocr-file-uploader_2.cjs",[[257,"voice-input-module",{"formJson":[1,"form-json"],"serviceConfig":[1,"service-config"],"apiKey":[1,"api-key"],"context":[1],"classificationRootUrl":[1,"classification-root-url"],"language":[1],"inputTypes":[1,"input-types"],"debug":[4],"renderForm":[4,"render-form"],"displayStatus":[4,"display-status"],"isRecording":[32],"isProcessing":[32],"statusMessage":[32],"hasError":[32],"transcription":[32],"filledData":[32],"debugInfo":[32],"isReadonlyMode":[32],"convertXmlToJson":[64],"convertJsonToXml":[64],"convertXmlToJsonLegacy":[64],"convertJsonToXmlLegacy":[64]},null,{"formJson":["initializeServices"],"serviceConfig":["initializeServices"]}],[257,"ocr-file-uploader",{"batch":[4],"callback":[16],"jsonSchema":[1,"json-schema"]}]]]], options);
9
+ return index.bootstrapLazy([["ocr-file-uploader.cjs",[[257,"ocr-file-uploader",{"batch":[4],"callback":[16],"jsonSchema":[1,"json-schema"],"theme":[1],"parsedTheme":[32]},null,{"theme":["parseTheme"]}]]],["voice-input-module.cjs",[[257,"voice-input-module",{"formJson":[1,"form-json"],"serviceConfig":[1,"service-config"],"apiKey":[1,"api-key"],"context":[1],"classificationRootUrl":[1,"classification-root-url"],"language":[1],"inputTypes":[1,"input-types"],"theme":[1],"debug":[4],"renderForm":[4,"render-form"],"displayStatus":[4,"display-status"],"isRecording":[32],"isProcessing":[32],"statusMessage":[32],"hasError":[32],"transcription":[32],"filledData":[32],"debugInfo":[32],"isReadonlyMode":[32],"convertXmlToJson":[64],"convertJsonToXml":[64],"convertXmlToJsonLegacy":[64],"convertJsonToXmlLegacy":[64]},null,{"formJson":["initializeServices"],"serviceConfig":["initializeServices"],"theme":["initializeServices"]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -0,0 +1,123 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-BTSzTkSZ.js');
4
+
5
+ const ocrFileUploaderCss = ".upload-container{display:inline-block;cursor:pointer}.upload-button{display:flex;align-items:center;justify-content:center;transition:transform 0.2s ease;user-select:none;width:var(--button-size, 50px);height:var(--button-size, 50px)}.upload-button svg{width:100%;height:100%;stroke:var(--button-bg, #10b981);transition:stroke 0.2s ease, transform 0.2s ease}.upload-button:hover svg{transform:scale(1.05);stroke:var(--button-hover, #059669)}";
6
+
7
+ const OcrFileUploader = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.batch = false;
11
+ this.parsedTheme = {};
12
+ this.triggerUpload = () => {
13
+ this.fileInput.click();
14
+ };
15
+ this.handleFileChange = async (event) => {
16
+ const input = event.target;
17
+ if (!input.files || input.files.length === 0)
18
+ return;
19
+ const file = input.files[0];
20
+ // Here you can handle the file upload to your API
21
+ console.log('Selected file:', file);
22
+ const formData = new FormData();
23
+ formData.append('file', file);
24
+ if (this.batch) {
25
+ try {
26
+ const response = await fetch('http://127.0.0.1:5001/api/convert-to-xml', {
27
+ method: 'POST',
28
+ body: formData
29
+ });
30
+ if (!response.ok) {
31
+ console.error("There has been an error!:", response);
32
+ throw new Error(`HTTP error! status: ${response.status}`);
33
+ }
34
+ // get the file as a blob
35
+ const blob = await response.blob();
36
+ // create a download link
37
+ const url = window.URL.createObjectURL(blob);
38
+ const a = document.createElement('a');
39
+ a.href = url;
40
+ a.download = 'result-' + Date.now().toString() + '.xlsx'; // filename
41
+ document.body.appendChild(a);
42
+ a.click();
43
+ a.remove();
44
+ window.URL.revokeObjectURL(url);
45
+ }
46
+ catch (err) {
47
+ console.error(err);
48
+ alert('Error uploading file');
49
+ }
50
+ }
51
+ else {
52
+ try {
53
+ if (this.jsonSchema) {
54
+ formData.append('json_schema', this.jsonSchema);
55
+ }
56
+ const response = await fetch('http://127.0.0.1:5001/api/convert-to-json', {
57
+ method: 'POST',
58
+ body: formData
59
+ });
60
+ if (!response.ok) {
61
+ console.error("There has been an error!:", response);
62
+ throw new Error(`HTTP error! status: ${response.status}`);
63
+ }
64
+ const data = await response.json();
65
+ console.log('Upload successful:', data);
66
+ if (this.callback && data[0] && data[0].content) {
67
+ this.callback(data[0].content);
68
+ }
69
+ }
70
+ catch (err) {
71
+ console.error(err);
72
+ alert('Error uploading file');
73
+ }
74
+ }
75
+ };
76
+ }
77
+ componentWillLoad() {
78
+ this.parseTheme();
79
+ }
80
+ parseTheme() {
81
+ if (this.theme) {
82
+ try {
83
+ this.parsedTheme = JSON.parse(this.theme);
84
+ }
85
+ catch (e) {
86
+ console.error('Invalid theme JSON:', e);
87
+ this.parsedTheme = {};
88
+ }
89
+ }
90
+ }
91
+ getThemeValue(path, defaultValue) {
92
+ const keys = path.split('.');
93
+ let value = this.parsedTheme;
94
+ for (const key of keys) {
95
+ value = value === null || value === void 0 ? void 0 : value[key];
96
+ }
97
+ return value || defaultValue;
98
+ }
99
+ render() {
100
+ const size = this.getThemeValue('button.size', '50px');
101
+ const backgroundColor = this.getThemeValue('button.backgroundColor', '#10b981');
102
+ const hoverColor = this.getThemeValue('button.hoverColor', '#059669');
103
+ const textColor = this.getThemeValue('button.textColor', '#ffffff');
104
+ return (index.h("div", { key: '25891d6205496b481c71e3378805f53cfd994f18', class: "upload-container", onClick: this.triggerUpload, style: {
105
+ width: size,
106
+ height: size
107
+ } }, index.h("input", { key: '33363a1a66873abab4d4e04a3d8c7f7091798767', type: "file", ref: el => (this.fileInput = el), onChange: this.handleFileChange, style: { display: 'none' } }), index.h("div", { key: '546471323e5ece5bb71cf6f5a12f350354e06b87', class: "upload-button", style: {
108
+ '--button-bg': backgroundColor,
109
+ '--button-hover': hoverColor,
110
+ '--button-text': textColor,
111
+ '--button-size': size
112
+ } }, index.h("svg", { key: 'ac90e8f2f7f37f7ef96f600e0dedc7c4b341ade4', viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { key: '9d04e535f632b7335d451fe9650fcac2ec644fb3', d: "M13.5 3H12H8C6.34315 3 5 4.34315 5 6V18C5 19.6569 6.34315 21 8 21H12M13.5 3L19 8.625M13.5 3V7.625C13.5 8.17728 13.9477 8.625 14.5 8.625H19M19 8.625V11.8125", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("path", { key: '0db48fbdaa67d2d85a6d931575b81a4f05e589e8', d: "M17.5 21L17.5 15M17.5 15L20 17.5M17.5 15L15 17.5", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })))));
113
+ }
114
+ static get watchers() { return {
115
+ "theme": ["parseTheme"]
116
+ }; }
117
+ };
118
+ OcrFileUploader.style = ocrFileUploaderCss;
119
+
120
+ exports.ocr_file_uploader = OcrFileUploader;
121
+ //# sourceMappingURL=ocr-file-uploader.entry.cjs.js.map
122
+
123
+ //# sourceMappingURL=ocr-file-uploader.cjs.entry.js.map
@@ -0,0 +1 @@
1
+ {"file":"ocr-file-uploader.entry.cjs.js","mappings":";;;;AAAA,MAAM,kBAAkB,GAAG,4bAA4b;;MCC1c,eAAe,GAAA,MAAA;AACxB,IAAA,WAAA,CAAA,OAAA,EAAA;;AACI,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,WAAW,GAAG,EAAE;AACrB,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;AACtB,YAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AAC1B,SAAC;AACD,QAAA,IAAI,CAAC,gBAAgB,GAAG,OAAO,KAAK,KAAI;AACpC,YAAA,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM;YAC1B,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;gBACxC;YACJ,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;;AAE3B,YAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC;AACnC,YAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;AAC/B,YAAA,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;AAC7B,YAAA,IAAI,IAAI,CAAC,KAAK,EAAE;AACZ,gBAAA,IAAI;AACA,oBAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,0CAA0C,EAAE;AACrE,wBAAA,MA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OAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,0CAA0C,EAAE,CAAC,EAAE,6JAA6J,EAAE,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,EAAEA,OAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,0CAA0C,EAAE,CAAC,EAAE,kDAAkD,EAAE,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;","names":["h"],"sources":["node_modules/ocr-file-uploader/dist/collection/components/ocr-file-uploader/ocr-file-uploader.css?tag=ocr-file-uploader&encapsulation=shadow","node_modules/ocr-file-uploader/dist/collection/components/ocr-file-uploader/ocr-file-uploader.js"],"sourcesContent":[".upload-container {\r\n display: inline-block;\r\n cursor: pointer;\r\n}\r\n\r\n.upload-button {\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n transition: transform 0.2s ease;\r\n user-select: none;\r\n width: var(--button-size, 50px);\r\n height: var(--button-size, 50px);\r\n}\r\n\r\n.upload-button svg {\r\n width: 100%;\r\n height: 100%;\r\n stroke: var(--button-bg, #10b981);\r\n transition: stroke 0.2s ease, transform 0.2s ease;\r\n}\r\n\r\n.upload-button:hover svg {\r\n transform: scale(1.05);\r\n stroke: var(--button-hover, #059669);\r\n}","import { h } from \"@stencil/core\";\nexport class OcrFileUploader {\n constructor() {\n this.batch = false;\n this.parsedTheme = {};\n this.triggerUpload = () => {\n this.fileInput.click();\n };\n this.handleFileChange = async (event) => {\n const input = event.target;\n if (!input.files || input.files.length === 0)\n return;\n const file = input.files[0];\n // Here you can handle the file upload to your API\n console.log('Selected file:', file);\n const formData = new FormData();\n formData.append('file', file);\n if (this.batch) {\n try {\n const response = await fetch('http://127.0.0.1:5001/api/convert-to-xml', {\n method: 'POST',\n body: formData\n });\n if (!response.ok) {\n console.error(\"There has been an error!:\", response);\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n // get the file as a blob\n const blob = await response.blob();\n // create a download link\n const url = window.URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = 'result-' + Date.now().toString() + '.xlsx'; // filename\n document.body.appendChild(a);\n a.click();\n a.remove();\n window.URL.revokeObjectURL(url);\n }\n catch (err) {\n console.error(err);\n alert('Error uploading file');\n }\n }\n else {\n try {\n if (this.jsonSchema) {\n formData.append('json_schema', this.jsonSchema);\n }\n const response = await fetch('http://127.0.0.1:5001/api/convert-to-json', {\n method: 'POST',\n body: formData\n });\n if (!response.ok) {\n console.error(\"There has been an error!:\", response);\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n const data = await response.json();\n console.log('Upload successful:', data);\n if (this.callback && data[0] && data[0].content) {\n this.callback(data[0].content);\n }\n }\n catch (err) {\n console.error(err);\n alert('Error uploading file');\n }\n }\n };\n }\n componentWillLoad() {\n this.parseTheme();\n }\n parseTheme() {\n if (this.theme) {\n try {\n this.parsedTheme = JSON.parse(this.theme);\n }\n catch (e) {\n console.error('Invalid theme JSON:', e);\n this.parsedTheme = {};\n }\n }\n }\n getThemeValue(path, defaultValue) {\n const keys = path.split('.');\n let value = this.parsedTheme;\n for (const key of keys) {\n value = value === null || value === void 0 ? void 0 : value[key];\n }\n return value || defaultValue;\n }\n render() {\n const size = this.getThemeValue('button.size', '50px');\n const backgroundColor = this.getThemeValue('button.backgroundColor', '#10b981');\n const hoverColor = this.getThemeValue('button.hoverColor', '#059669');\n const textColor = this.getThemeValue('button.textColor', '#ffffff');\n return (h(\"div\", { key: '25891d6205496b481c71e3378805f53cfd994f18', class: \"upload-container\", onClick: this.triggerUpload, style: {\n width: size,\n height: size\n } }, h(\"input\", { key: '33363a1a66873abab4d4e04a3d8c7f7091798767', type: \"file\", ref: el => (this.fileInput = el), onChange: this.handleFileChange, style: { display: 'none' } }), h(\"div\", { key: '546471323e5ece5bb71cf6f5a12f350354e06b87', class: \"upload-button\", style: {\n '--button-bg': backgroundColor,\n '--button-hover': hoverColor,\n '--button-text': textColor,\n '--button-size': size\n } }, h(\"svg\", { key: 'ac90e8f2f7f37f7ef96f600e0dedc7c4b341ade4', viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\" }, h(\"path\", { key: '9d04e535f632b7335d451fe9650fcac2ec644fb3', d: \"M13.5 3H12H8C6.34315 3 5 4.34315 5 6V18C5 19.6569 6.34315 21 8 21H12M13.5 3L19 8.625M13.5 3V7.625C13.5 8.17728 13.9477 8.625 14.5 8.625H19M19 8.625V11.8125\", \"stroke-width\": \"2\", \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" }), h(\"path\", { key: '0db48fbdaa67d2d85a6d931575b81a4f05e589e8', d: \"M17.5 21L17.5 15M17.5 15L20 17.5M17.5 15L15 17.5\", \"stroke-width\": \"2\", \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" })))));\n }\n static get is() { return \"ocr-file-uploader\"; }\n static get encapsulation() { return \"shadow\"; }\n static get originalStyleUrls() {\n return {\n \"$\": [\"ocr-file-uploader.css\"]\n };\n }\n static get styleUrls() {\n return {\n \"$\": [\"ocr-file-uploader.css\"]\n };\n }\n static get properties() {\n return {\n \"batch\": {\n \"type\": \"boolean\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"boolean\",\n \"resolved\": \"boolean\",\n \"references\": {}\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false,\n \"reflect\": false,\n \"attribute\": \"batch\",\n \"defaultValue\": \"false\"\n },\n \"callback\": {\n \"type\": \"unknown\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"Function\",\n \"resolved\": \"Function\",\n \"references\": {\n \"Function\": {\n \"location\": \"global\",\n \"id\": \"global::Function\"\n }\n }\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false\n },\n \"jsonSchema\": {\n \"type\": \"string\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"string\",\n \"resolved\": \"string\",\n \"references\": {}\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false,\n \"reflect\": false,\n \"attribute\": \"json-schema\"\n },\n \"theme\": {\n \"type\": \"string\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"string\",\n \"resolved\": \"string\",\n \"references\": {}\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false,\n \"reflect\": false,\n \"attribute\": \"theme\"\n }\n };\n }\n static get states() {\n return {\n \"parsedTheme\": {}\n };\n }\n static get watchers() {\n return [{\n \"propName\": \"theme\",\n \"methodName\": \"parseTheme\"\n }];\n }\n}\n"],"version":3}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ocr-file-uploader.entry.cjs.js","sources":["node_modules/ocr-file-uploader/dist/collection/components/ocr-file-uploader/ocr-file-uploader.css?tag=ocr-file-uploader&encapsulation=shadow","node_modules/ocr-file-uploader/dist/collection/components/ocr-file-uploader/ocr-file-uploader.js"],"sourcesContent":[".upload-container {\r\n display: inline-block;\r\n cursor: pointer;\r\n}\r\n\r\n.upload-button {\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n transition: transform 0.2s ease;\r\n user-select: none;\r\n width: var(--button-size, 50px);\r\n height: var(--button-size, 50px);\r\n}\r\n\r\n.upload-button svg {\r\n width: 100%;\r\n height: 100%;\r\n stroke: var(--button-bg, #10b981);\r\n transition: stroke 0.2s ease, transform 0.2s ease;\r\n}\r\n\r\n.upload-button:hover svg {\r\n transform: scale(1.05);\r\n stroke: var(--button-hover, #059669);\r\n}","import { h } from \"@stencil/core\";\nexport class OcrFileUploader {\n constructor() {\n this.batch = false;\n this.parsedTheme = {};\n this.triggerUpload = () => {\n this.fileInput.click();\n };\n this.handleFileChange = async (event) => {\n const input = event.target;\n if (!input.files || input.files.length === 0)\n return;\n const file = input.files[0];\n // Here you can handle the file upload to your API\n console.log('Selected file:', file);\n const formData = new FormData();\n formData.append('file', file);\n if (this.batch) {\n try {\n const response = await fetch('http://127.0.0.1:5001/api/convert-to-xml', {\n method: 'POST',\n body: formData\n });\n if (!response.ok) {\n console.error(\"There has been an error!:\", response);\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n // get the file as a blob\n const blob = await response.blob();\n // create a download link\n const url = window.URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = 'result-' + Date.now().toString() + '.xlsx'; // filename\n document.body.appendChild(a);\n a.click();\n a.remove();\n window.URL.revokeObjectURL(url);\n }\n catch (err) {\n console.error(err);\n alert('Error uploading file');\n }\n }\n else {\n try {\n if (this.jsonSchema) {\n formData.append('json_schema', this.jsonSchema);\n }\n const response = await fetch('http://127.0.0.1:5001/api/convert-to-json', {\n method: 'POST',\n body: formData\n });\n if (!response.ok) {\n console.error(\"There has been an error!:\", response);\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n const data = await response.json();\n console.log('Upload successful:', data);\n if (this.callback && data[0] && data[0].content) {\n this.callback(data[0].content);\n }\n }\n catch (err) {\n console.error(err);\n alert('Error uploading file');\n }\n }\n };\n }\n componentWillLoad() {\n this.parseTheme();\n }\n parseTheme() {\n if (this.theme) {\n try {\n this.parsedTheme = JSON.parse(this.theme);\n }\n catch (e) {\n console.error('Invalid theme JSON:', e);\n this.parsedTheme = {};\n }\n }\n }\n getThemeValue(path, defaultValue) {\n const keys = path.split('.');\n let value = this.parsedTheme;\n for (const key of keys) {\n value = value === null || value === void 0 ? void 0 : value[key];\n }\n return value || defaultValue;\n }\n render() {\n const size = this.getThemeValue('button.size', '50px');\n const backgroundColor = this.getThemeValue('button.backgroundColor', '#10b981');\n const hoverColor = this.getThemeValue('button.hoverColor', '#059669');\n const textColor = this.getThemeValue('button.textColor', '#ffffff');\n return (h(\"div\", { key: '25891d6205496b481c71e3378805f53cfd994f18', class: \"upload-container\", onClick: this.triggerUpload, style: {\n width: size,\n height: size\n } }, h(\"input\", { key: '33363a1a66873abab4d4e04a3d8c7f7091798767', type: \"file\", ref: el => (this.fileInput = el), onChange: this.handleFileChange, style: { display: 'none' } }), h(\"div\", { key: '546471323e5ece5bb71cf6f5a12f350354e06b87', class: \"upload-button\", style: {\n '--button-bg': backgroundColor,\n '--button-hover': hoverColor,\n '--button-text': textColor,\n '--button-size': size\n } }, h(\"svg\", { key: 'ac90e8f2f7f37f7ef96f600e0dedc7c4b341ade4', viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\" }, h(\"path\", { key: '9d04e535f632b7335d451fe9650fcac2ec644fb3', d: \"M13.5 3H12H8C6.34315 3 5 4.34315 5 6V18C5 19.6569 6.34315 21 8 21H12M13.5 3L19 8.625M13.5 3V7.625C13.5 8.17728 13.9477 8.625 14.5 8.625H19M19 8.625V11.8125\", \"stroke-width\": \"2\", \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" }), h(\"path\", { key: '0db48fbdaa67d2d85a6d931575b81a4f05e589e8', d: \"M17.5 21L17.5 15M17.5 15L20 17.5M17.5 15L15 17.5\", \"stroke-width\": \"2\", \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" })))));\n }\n static get is() { return \"ocr-file-uploader\"; }\n static get encapsulation() { return \"shadow\"; }\n static get originalStyleUrls() {\n return {\n \"$\": [\"ocr-file-uploader.css\"]\n };\n }\n static get styleUrls() {\n return {\n \"$\": [\"ocr-file-uploader.css\"]\n };\n }\n static get properties() {\n return {\n \"batch\": {\n \"type\": \"boolean\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"boolean\",\n \"resolved\": \"boolean\",\n \"references\": {}\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false,\n \"reflect\": false,\n \"attribute\": \"batch\",\n \"defaultValue\": \"false\"\n },\n \"callback\": {\n \"type\": \"unknown\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"Function\",\n \"resolved\": \"Function\",\n \"references\": {\n \"Function\": {\n \"location\": \"global\",\n \"id\": \"global::Function\"\n }\n }\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false\n },\n \"jsonSchema\": {\n \"type\": \"string\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"string\",\n \"resolved\": \"string\",\n \"references\": {}\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false,\n \"reflect\": false,\n \"attribute\": \"json-schema\"\n },\n \"theme\": {\n \"type\": \"string\",\n \"mutable\": false,\n \"complexType\": {\n \"original\": \"string\",\n \"resolved\": \"string\",\n \"references\": {}\n },\n \"required\": false,\n \"optional\": false,\n \"docs\": {\n \"tags\": [],\n \"text\": \"\"\n },\n \"getter\": false,\n \"setter\": false,\n \"reflect\": false,\n \"attribute\": \"theme\"\n }\n };\n }\n static get states() {\n return {\n \"parsedTheme\": {}\n };\n }\n static get watchers() {\n return [{\n \"propName\": \"theme\",\n \"methodName\": \"parseTheme\"\n }];\n }\n}\n"],"names":["h"],"mappings":";;;;AAAA,MAAM,kBAAkB,GAAG,4bAA4b;;MCC1c,eAAe,GAAA,MAAA;AACxB,IAAA,WAAA,CAAA,OAAA,EAAA;;AACI,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,WAAW,GAAG,EAAE;AACrB,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;AACtB,YAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AAC1B,SAAC;AACD,QAAA,IAAI,CAAC,gBAAgB,GAAG,OAAO,KAAK,KAAI;AACpC,YAAA,MAAM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