LogstashUI 0.5.5.dev0__py3-none-any.whl

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 (762) hide show
  1. AI/__init__.py +0 -0
  2. AI/integration_factory.py +1392 -0
  3. AI/migrations/0001_initial.py +58 -0
  4. AI/migrations/0002_draftdefinition_normalizers.py +23 -0
  5. AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
  6. AI/migrations/__init__.py +0 -0
  7. AI/models.py +5 -0
  8. AI/static/js/integration_factory.js +1102 -0
  9. AI/system_prompts/dashboard_generator.md +367 -0
  10. AI/system_prompts/grok_patterns.txt +95 -0
  11. AI/system_prompts/ingest_pipeline_generator.md +331 -0
  12. AI/system_prompts/ingest_pipeline_processors.json +2851 -0
  13. AI/system_prompts/ingest_verifier.md +84 -0
  14. AI/system_prompts/integrations_list.json +2690 -0
  15. AI/system_prompts/log_classifier.md +134 -0
  16. AI/system_prompts/template_creator.md +123 -0
  17. AI/templates/integration_factory.html +200 -0
  18. AI/urls.py +16 -0
  19. AI/views.py +20 -0
  20. API/__init__.py +0 -0
  21. API/admin.py +7 -0
  22. API/api.http +784 -0
  23. API/apps.py +9 -0
  24. API/auth.py +101 -0
  25. API/connections_views.py +312 -0
  26. API/guides.py +88 -0
  27. API/mcp/__init__.py +5 -0
  28. API/mcp/dispatch.py +179 -0
  29. API/mcp/tools.py +890 -0
  30. API/mcp/views.py +215 -0
  31. API/migrations/__init__.py +0 -0
  32. API/models.py +7 -0
  33. API/pipelines_views.py +1224 -0
  34. API/policies_views.py +1015 -0
  35. API/security_views.py +488 -0
  36. API/simulation_detail.py +219 -0
  37. API/snmp_views.py +1539 -0
  38. API/urls.py +81 -0
  39. Common/__init__.py +0 -0
  40. Common/ai/agent_builder.py +690 -0
  41. Common/context_processors.py +49 -0
  42. Common/decorators.py +68 -0
  43. Common/elastic_utils.py +1154 -0
  44. Common/encryption.py +271 -0
  45. Common/error_handlers.py +65 -0
  46. Common/formatters.py +106 -0
  47. Common/logstash_config_parse.py +1469 -0
  48. Common/logstash_utils.py +34 -0
  49. Common/middleware.py +216 -0
  50. Common/product_ca.py +1124 -0
  51. Common/validators.py +66 -0
  52. Documentation/__init__.py +0 -0
  53. Documentation/admin.py +7 -0
  54. Documentation/apps.py +9 -0
  55. Documentation/content/CHANGELOG.md +890 -0
  56. Documentation/content/docs/getting_started.md +92 -0
  57. Documentation/content/docs/index.md +124 -0
  58. Documentation/content/docs/logstashagent/configuration/index.md +60 -0
  59. Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
  60. Documentation/content/docs/logstashagent/general/build.md +217 -0
  61. Documentation/content/docs/logstashagent/general/index.md +38 -0
  62. Documentation/content/docs/logstashagent/general/roles.md +267 -0
  63. Documentation/content/docs/logstashagent/index.md +264 -0
  64. Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
  65. Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
  66. Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
  67. Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
  68. Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
  69. Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
  70. Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
  71. Documentation/content/docs/logstashui/SNMP/index.md +58 -0
  72. Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
  73. Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
  74. Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
  75. Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
  76. Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
  77. Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
  78. Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
  79. Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
  80. Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
  81. Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
  82. Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
  83. Documentation/content/docs/logstashui/architecture.md +11 -0
  84. Documentation/content/docs/logstashui/compatibility.md +58 -0
  85. Documentation/content/docs/logstashui/configuration/environment.md +193 -0
  86. Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
  87. Documentation/content/docs/logstashui/configuration/index.md +72 -0
  88. Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
  89. Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
  90. Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
  91. Documentation/content/docs/logstashui/database/examples/README.md +15 -0
  92. Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
  93. Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
  94. Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
  95. Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
  96. Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
  97. Documentation/content/docs/logstashui/database/index.md +79 -0
  98. Documentation/content/docs/logstashui/database/migration.md +75 -0
  99. Documentation/content/docs/logstashui/general/build.md +154 -0
  100. Documentation/content/docs/logstashui/general/deploy.md +122 -0
  101. Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
  102. Documentation/content/docs/logstashui/general/index.md +62 -0
  103. Documentation/content/docs/logstashui/general/offline.md +68 -0
  104. Documentation/content/docs/logstashui/general/updating.md +50 -0
  105. Documentation/content/docs/logstashui/index.md +90 -0
  106. Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
  107. Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
  108. Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
  109. Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
  110. Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
  111. Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
  112. Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
  113. Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
  114. Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
  115. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
  116. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
  117. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
  118. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
  119. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
  120. Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
  121. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
  122. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
  123. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
  124. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
  125. Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
  126. Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
  127. Documentation/content/docs/logstashui/mcp.md +224 -0
  128. Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
  129. Documentation/content/docs/logstashui/rest_api.md +2783 -0
  130. Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
  131. Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
  132. Documentation/content/docs/logstashui/utilities/index.md +40 -0
  133. Documentation/content/images/LogstashIcon.png +0 -0
  134. Documentation/content/images/architecture.png +0 -0
  135. Documentation/content/images/connection_manager.png +0 -0
  136. Documentation/content/images/control_plane.png +0 -0
  137. Documentation/content/images/graph.gif +0 -0
  138. Documentation/content/images/login.png +0 -0
  139. Documentation/content/images/monitoring.png +0 -0
  140. Documentation/content/images/new_connection.gif +0 -0
  141. Documentation/content/images/simulate.gif +0 -0
  142. Documentation/content/images/simulate.png +0 -0
  143. Documentation/content/images/snmp.gif +0 -0
  144. Documentation/content/images/snmp.png +0 -0
  145. Documentation/content/images/snmp_architecture.png +0 -0
  146. Documentation/migrations/__init__.py +0 -0
  147. Documentation/models.py +9 -0
  148. Documentation/static/css/markdown.css +250 -0
  149. Documentation/templates/documentation.html +225 -0
  150. Documentation/templates/nav_item.html +41 -0
  151. Documentation/urls.py +11 -0
  152. Documentation/views.py +442 -0
  153. LogstashUI/__init__.py +0 -0
  154. LogstashUI/__main__.py +10 -0
  155. LogstashUI/asgi.py +16 -0
  156. LogstashUI/cli.py +626 -0
  157. LogstashUI/config.py +116 -0
  158. LogstashUI/database.py +263 -0
  159. LogstashUI/insecure_http.py +117 -0
  160. LogstashUI/logging_config.py +99 -0
  161. LogstashUI/migrate_engine.py +282 -0
  162. LogstashUI/packaging/__init__.py +3 -0
  163. LogstashUI/packaging/logstashui.default +68 -0
  164. LogstashUI/packaging/logstashui.service.in +22 -0
  165. LogstashUI/paths.py +181 -0
  166. LogstashUI/settings.py +437 -0
  167. LogstashUI/telemetry.py +159 -0
  168. LogstashUI/urls.py +56 -0
  169. LogstashUI/wsgi.py +77 -0
  170. Management/__init__.py +0 -0
  171. Management/apps.py +10 -0
  172. Management/migrations/0001_initial.py +29 -0
  173. Management/migrations/0002_settings.py +25 -0
  174. Management/migrations/0003_settings_agent_ui_url.py +29 -0
  175. Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
  176. Management/migrations/__init__.py +0 -0
  177. Management/models.py +92 -0
  178. Management/templates/api_tokens.html +214 -0
  179. Management/templates/components/api_token_created.html +38 -0
  180. Management/templates/components/api_token_row.html +84 -0
  181. Management/templates/components/logstash_artifact_row.html +100 -0
  182. Management/templates/components/logstash_artifact_tbody.html +26 -0
  183. Management/templates/components/user_row.html +67 -0
  184. Management/templates/logs.html +98 -0
  185. Management/templates/logstash_artifacts.html +172 -0
  186. Management/templates/management.html +80 -0
  187. Management/templates/management_settings.html +320 -0
  188. Management/templates/registration/login.html +404 -0
  189. Management/templates/users.html +304 -0
  190. Management/urls.py +23 -0
  191. Management/views.py +804 -0
  192. Monitoring/__init__.py +0 -0
  193. Monitoring/apps.py +9 -0
  194. Monitoring/migrations/__init__.py +0 -0
  195. Monitoring/static/js/monitoring.js +463 -0
  196. Monitoring/templates/components/node_metrics.html +161 -0
  197. Monitoring/templates/components/pipeline_metrics.html +189 -0
  198. Monitoring/templates/monitoring.html +271 -0
  199. Monitoring/urls.py +16 -0
  200. Monitoring/views.py +724 -0
  201. PipelineManager/__init__.py +0 -0
  202. PipelineManager/agent_api.py +1173 -0
  203. PipelineManager/agent_client.py +59 -0
  204. PipelineManager/agent_modes.py +880 -0
  205. PipelineManager/agent_policies.py +689 -0
  206. PipelineManager/agent_versions.py +151 -0
  207. PipelineManager/apps.py +10 -0
  208. PipelineManager/artifact_metrics.py +171 -0
  209. PipelineManager/artifacts.py +820 -0
  210. PipelineManager/connections_crud.py +722 -0
  211. PipelineManager/data/default_jvm.options +76 -0
  212. PipelineManager/data/default_log4j2.properties +165 -0
  213. PipelineManager/data/default_logstash.yml +405 -0
  214. PipelineManager/data/plugins.json +29109 -0
  215. PipelineManager/editor_views.py +608 -0
  216. PipelineManager/forms.py +284 -0
  217. PipelineManager/manager_views.py +490 -0
  218. PipelineManager/migrations/0001_initial.py +38 -0
  219. PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
  220. PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
  221. PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
  222. PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
  223. PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
  224. PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
  225. PipelineManager/migrations/0008_connection_agent_id.py +18 -0
  226. PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
  227. PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
  228. PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
  229. PipelineManager/migrations/0012_policy_binary_path.py +18 -0
  230. PipelineManager/migrations/0013_connection_status_blob.py +18 -0
  231. PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
  232. PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
  233. PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
  234. PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
  235. PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
  236. PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
  237. PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
  238. PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
  239. PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
  240. PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
  241. PipelineManager/migrations/0024_seed_system_policies.py +173 -0
  242. PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
  243. PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
  244. PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
  245. PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
  246. PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
  247. PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
  248. PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
  249. PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
  250. PipelineManager/migrations/0033_simulation_result.py +26 -0
  251. PipelineManager/migrations/__init__.py +0 -0
  252. PipelineManager/models.py +1300 -0
  253. PipelineManager/pipelines_crud.py +738 -0
  254. PipelineManager/policies_crud.py +772 -0
  255. PipelineManager/sim_keystore.py +319 -0
  256. PipelineManager/simulation.py +1581 -0
  257. PipelineManager/static/css/codemirror.min.css +1 -0
  258. PipelineManager/static/css/graph_move.css +79 -0
  259. PipelineManager/static/css/monokai.min.css +1 -0
  260. PipelineManager/static/css/move_mode.css +144 -0
  261. PipelineManager/static/css/show-hint.min.css +1 -0
  262. PipelineManager/static/images/age.png +0 -0
  263. PipelineManager/static/images/aggregate.png +0 -0
  264. PipelineManager/static/images/alter.png +0 -0
  265. PipelineManager/static/images/azure_event_hubs.png +0 -0
  266. PipelineManager/static/images/beats.png +0 -0
  267. PipelineManager/static/images/boundary.png +0 -0
  268. PipelineManager/static/images/bytes.png +0 -0
  269. PipelineManager/static/images/cidr.png +0 -0
  270. PipelineManager/static/images/cipher.png +0 -0
  271. PipelineManager/static/images/circonus.png +0 -0
  272. PipelineManager/static/images/clone.png +0 -0
  273. PipelineManager/static/images/cloudwatch.png +0 -0
  274. PipelineManager/static/images/comment.png +0 -0
  275. PipelineManager/static/images/continue.png +0 -0
  276. PipelineManager/static/images/couchdb_changes.png +0 -0
  277. PipelineManager/static/images/csv.png +0 -0
  278. PipelineManager/static/images/datadog.png +0 -0
  279. PipelineManager/static/images/datadog_metrics.png +0 -0
  280. PipelineManager/static/images/date.png +0 -0
  281. PipelineManager/static/images/de_dot.png +0 -0
  282. PipelineManager/static/images/dead_letter_queue.png +0 -0
  283. PipelineManager/static/images/dissect.png +0 -0
  284. PipelineManager/static/images/dns.png +0 -0
  285. PipelineManager/static/images/drop.png +0 -0
  286. PipelineManager/static/images/dynatrace.png +0 -0
  287. PipelineManager/static/images/elapsed.png +0 -0
  288. PipelineManager/static/images/elastic_agent.png +0 -0
  289. PipelineManager/static/images/elastic_integration.png +0 -0
  290. PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
  291. PipelineManager/static/images/elastic_workplace_search.png +0 -0
  292. PipelineManager/static/images/elasticsearch.png +0 -0
  293. PipelineManager/static/images/else.png +0 -0
  294. PipelineManager/static/images/else_if.png +0 -0
  295. PipelineManager/static/images/email.png +0 -0
  296. PipelineManager/static/images/environment.png +0 -0
  297. PipelineManager/static/images/exec.png +0 -0
  298. PipelineManager/static/images/extractnumbers.png +0 -0
  299. PipelineManager/static/images/file.png +0 -0
  300. PipelineManager/static/images/fingerprint.png +0 -0
  301. PipelineManager/static/images/ganglia.png +0 -0
  302. PipelineManager/static/images/gelf.png +0 -0
  303. PipelineManager/static/images/generator.png +0 -0
  304. PipelineManager/static/images/geoip.png +0 -0
  305. PipelineManager/static/images/github.png +0 -0
  306. PipelineManager/static/images/google_bigquery.png +0 -0
  307. PipelineManager/static/images/google_cloud_storage.png +0 -0
  308. PipelineManager/static/images/google_pubsub.png +0 -0
  309. PipelineManager/static/images/graphite.png +0 -0
  310. PipelineManager/static/images/graphtastic.png +0 -0
  311. PipelineManager/static/images/grok.png +0 -0
  312. PipelineManager/static/images/heartbeat.png +0 -0
  313. PipelineManager/static/images/http.png +0 -0
  314. PipelineManager/static/images/http_poller.png +0 -0
  315. PipelineManager/static/images/i18n.png +0 -0
  316. PipelineManager/static/images/if.png +0 -0
  317. PipelineManager/static/images/imap.png +0 -0
  318. PipelineManager/static/images/influxdb.png +0 -0
  319. PipelineManager/static/images/irc.png +0 -0
  320. PipelineManager/static/images/java_generator.png +0 -0
  321. PipelineManager/static/images/java_stdin.png +0 -0
  322. PipelineManager/static/images/java_stdout.png +0 -0
  323. PipelineManager/static/images/java_uuid.png +0 -0
  324. PipelineManager/static/images/jdbc.png +0 -0
  325. PipelineManager/static/images/jdbc_static.png +0 -0
  326. PipelineManager/static/images/jdbc_streaming.png +0 -0
  327. PipelineManager/static/images/jms.png +0 -0
  328. PipelineManager/static/images/jmx.png +0 -0
  329. PipelineManager/static/images/json.png +0 -0
  330. PipelineManager/static/images/json_encode.png +0 -0
  331. PipelineManager/static/images/juggernaut.png +0 -0
  332. PipelineManager/static/images/kafka.png +0 -0
  333. PipelineManager/static/images/kinesis.png +0 -0
  334. PipelineManager/static/images/kv.png +0 -0
  335. PipelineManager/static/images/librato.png +0 -0
  336. PipelineManager/static/images/log4j.png +0 -0
  337. PipelineManager/static/images/loggly.png +0 -0
  338. PipelineManager/static/images/logstash.png +0 -0
  339. PipelineManager/static/images/lumberjack.png +0 -0
  340. PipelineManager/static/images/meetup.png +0 -0
  341. PipelineManager/static/images/memcached.png +0 -0
  342. PipelineManager/static/images/metriccatcher.png +0 -0
  343. PipelineManager/static/images/metricize.png +0 -0
  344. PipelineManager/static/images/metrics.png +0 -0
  345. PipelineManager/static/images/mongodb.png +0 -0
  346. PipelineManager/static/images/mutate.png +0 -0
  347. PipelineManager/static/images/nagios.png +0 -0
  348. PipelineManager/static/images/nagios_nsca.png +0 -0
  349. PipelineManager/static/images/opentsdb.png +0 -0
  350. PipelineManager/static/images/pagerduty.png +0 -0
  351. PipelineManager/static/images/pipe.png +0 -0
  352. PipelineManager/static/images/pipeline.png +0 -0
  353. PipelineManager/static/images/prune.png +0 -0
  354. PipelineManager/static/images/puppet_facter.png +0 -0
  355. PipelineManager/static/images/rabbitmq.png +0 -0
  356. PipelineManager/static/images/range.png +0 -0
  357. PipelineManager/static/images/redis.png +0 -0
  358. PipelineManager/static/images/redmine.png +0 -0
  359. PipelineManager/static/images/relp.png +0 -0
  360. PipelineManager/static/images/riak.png +0 -0
  361. PipelineManager/static/images/riemann.png +0 -0
  362. PipelineManager/static/images/rss.png +0 -0
  363. PipelineManager/static/images/ruby.png +0 -0
  364. PipelineManager/static/images/s3-sns-sqs.png +0 -0
  365. PipelineManager/static/images/s3.png +0 -0
  366. PipelineManager/static/images/salesforce.png +0 -0
  367. PipelineManager/static/images/sink.png +0 -0
  368. PipelineManager/static/images/sleep.png +0 -0
  369. PipelineManager/static/images/snmp.png +0 -0
  370. PipelineManager/static/images/snmptrap.png +0 -0
  371. PipelineManager/static/images/sns.png +0 -0
  372. PipelineManager/static/images/solr_http.png +0 -0
  373. PipelineManager/static/images/split.png +0 -0
  374. PipelineManager/static/images/sqlite.png +0 -0
  375. PipelineManager/static/images/sqs.png +0 -0
  376. PipelineManager/static/images/statsd.png +0 -0
  377. PipelineManager/static/images/stdin.png +0 -0
  378. PipelineManager/static/images/stdout.png +0 -0
  379. PipelineManager/static/images/stomp.png +0 -0
  380. PipelineManager/static/images/syslog.png +0 -0
  381. PipelineManager/static/images/syslog_pri.png +0 -0
  382. PipelineManager/static/images/tcp.png +0 -0
  383. PipelineManager/static/images/threats_classifier.png +0 -0
  384. PipelineManager/static/images/throttle.png +0 -0
  385. PipelineManager/static/images/timber.png +0 -0
  386. PipelineManager/static/images/tld.png +0 -0
  387. PipelineManager/static/images/translate.png +0 -0
  388. PipelineManager/static/images/truncate.png +0 -0
  389. PipelineManager/static/images/twitter.png +0 -0
  390. PipelineManager/static/images/udp.png +0 -0
  391. PipelineManager/static/images/unix.png +0 -0
  392. PipelineManager/static/images/urldecode.png +0 -0
  393. PipelineManager/static/images/useragent.png +0 -0
  394. PipelineManager/static/images/uuid.png +0 -0
  395. PipelineManager/static/images/varnishlog.png +0 -0
  396. PipelineManager/static/images/webhdfs.png +0 -0
  397. PipelineManager/static/images/websocket.png +0 -0
  398. PipelineManager/static/images/wmi.png +0 -0
  399. PipelineManager/static/images/wurfl_device_detection.png +0 -0
  400. PipelineManager/static/images/xml.png +0 -0
  401. PipelineManager/static/images/xmpp.png +0 -0
  402. PipelineManager/static/images/zabbix.png +0 -0
  403. PipelineManager/static/js/agent_inspect_modal.js +141 -0
  404. PipelineManager/static/js/agent_policies.js +3746 -0
  405. PipelineManager/static/js/agent_status_sse.js +166 -0
  406. PipelineManager/static/js/codemirror.min.js +1 -0
  407. PipelineManager/static/js/connections_table.js +551 -0
  408. PipelineManager/static/js/d3.v7.js +20625 -0
  409. PipelineManager/static/js/diff_modal.js +995 -0
  410. PipelineManager/static/js/expression_editor.js +291 -0
  411. PipelineManager/static/js/js-yaml.min.js +1 -0
  412. PipelineManager/static/js/logstashyml_guides.js +1063 -0
  413. PipelineManager/static/js/move_graph.js +577 -0
  414. PipelineManager/static/js/move_mode.js +559 -0
  415. PipelineManager/static/js/pipeline_editor.js +4102 -0
  416. PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
  417. PipelineManager/static/js/pipeline_list.js +274 -0
  418. PipelineManager/static/js/pipeline_settings.js +121 -0
  419. PipelineManager/static/js/pipeline_text_editor.js +2088 -0
  420. PipelineManager/static/js/plugin_config_modal.js +2827 -0
  421. PipelineManager/static/js/policy_deploy_modal.js +1066 -0
  422. PipelineManager/static/js/show-hint.min.js +1 -0
  423. PipelineManager/static/js/sim_targets.js +380 -0
  424. PipelineManager/static/js/simple-comment-mode.js +56 -0
  425. PipelineManager/static/js/simulation_modal.js +1135 -0
  426. PipelineManager/static/js/simulation_results.js +2778 -0
  427. PipelineManager/static/js/stats_strip.js +231 -0
  428. PipelineManager/static/js/yaml.js +120 -0
  429. PipelineManager/system_policy_defaults.py +279 -0
  430. PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
  431. PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
  432. PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
  433. PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
  434. PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
  435. PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
  436. PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
  437. PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
  438. PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
  439. PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
  440. PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
  441. PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
  442. PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
  443. PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
  444. PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
  445. PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
  446. PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
  447. PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
  448. PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
  449. PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
  450. PipelineManager/templates/pipeline_editor.html +1738 -0
  451. PipelineManager/templates/pipeline_graph_editor.html +99 -0
  452. PipelineManager/templates/pipeline_manager.html +584 -0
  453. PipelineManager/templates/pipeline_text_editor.html +350 -0
  454. PipelineManager/urls.py +99 -0
  455. SNMP/__init__.py +0 -0
  456. SNMP/ai_template_generation.py +232 -0
  457. SNMP/apps.py +9 -0
  458. SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
  459. SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
  460. SNMP/data/authoring_instructions.md +65 -0
  461. SNMP/data/grounding/.gitignore +4 -0
  462. SNMP/data/grounding/build_grounding.py +35 -0
  463. SNMP/data/grounding/grounding.json +1 -0
  464. SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
  465. SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
  466. SNMP/data/mib_reference/std_entity_sensors.json +28 -0
  467. SNMP/data/mib_reference/std_host_resources.json +32 -0
  468. SNMP/data/mib_reference/std_ospf_mib.json +55 -0
  469. SNMP/data/mib_reference/std_ucd_linux.json +27 -0
  470. SNMP/data/normalizers.json +103 -0
  471. SNMP/data/official_device_templates/arista_eos.json +24 -0
  472. SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
  473. SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
  474. SNMP/data/official_device_templates/cisco_ios.json +21 -0
  475. SNMP/data/official_device_templates/default.json +13 -0
  476. SNMP/data/official_device_templates/dell_idrac.json +22 -0
  477. SNMP/data/official_device_templates/dell_x1026.json +16 -0
  478. SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
  479. SNMP/data/official_device_templates/eastpower_ups.json +20 -0
  480. SNMP/data/official_device_templates/eaton_ups.json +22 -0
  481. SNMP/data/official_device_templates/epson_printer.json +18 -0
  482. SNMP/data/official_device_templates/geist_watchdog.json +20 -0
  483. SNMP/data/official_device_templates/generic_linux.json +18 -0
  484. SNMP/data/official_device_templates/generic_ont.json +18 -0
  485. SNMP/data/official_device_templates/generic_ups.json +16 -0
  486. SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
  487. SNMP/data/official_device_templates/hpe_nimble.json +17 -0
  488. SNMP/data/official_device_templates/huawei_ups.json +19 -0
  489. SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
  490. SNMP/data/official_device_templates/isilon_onefs.json +22 -0
  491. SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
  492. SNMP/data/official_device_templates/netapp_7mode.json +22 -0
  493. SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
  494. SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
  495. SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
  496. SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
  497. SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
  498. SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
  499. SNMP/data/official_profiles/arista_eos.json +16 -0
  500. SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
  501. SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
  502. SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
  503. SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
  504. SNMP/data/official_profiles/cisco_cdp.json +26 -0
  505. SNMP/data/official_profiles/cisco_fans.json +18 -0
  506. SNMP/data/official_profiles/cisco_sensors.json +21 -0
  507. SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
  508. SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
  509. SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
  510. SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
  511. SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
  512. SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
  513. SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
  514. SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
  515. SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
  516. SNMP/data/official_profiles/eaton_ups.json +40 -0
  517. SNMP/data/official_profiles/geist_environment.json +50 -0
  518. SNMP/data/official_profiles/generic_arp.json +19 -0
  519. SNMP/data/official_profiles/generic_bgp.json +24 -0
  520. SNMP/data/official_profiles/generic_entity_psu.json +26 -0
  521. SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
  522. SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
  523. SNMP/data/official_profiles/generic_interfaces.json +86 -0
  524. SNMP/data/official_profiles/generic_ip_addr.json +19 -0
  525. SNMP/data/official_profiles/generic_lldp.json +54 -0
  526. SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
  527. SNMP/data/official_profiles/generic_mac_table.json +19 -0
  528. SNMP/data/official_profiles/generic_ont.json +88 -0
  529. SNMP/data/official_profiles/generic_ospf.json +21 -0
  530. SNMP/data/official_profiles/generic_printer_mib.json +48 -0
  531. SNMP/data/official_profiles/generic_rmon.json +38 -0
  532. SNMP/data/official_profiles/generic_system.json +17 -0
  533. SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
  534. SNMP/data/official_profiles/generic_ups_mib.json +154 -0
  535. SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
  536. SNMP/data/official_profiles/huawei_ups.json +111 -0
  537. SNMP/data/official_profiles/isilon_performance.json +92 -0
  538. SNMP/data/official_profiles/isilon_protocols.json +77 -0
  539. SNMP/data/official_profiles/isilon_system.json +86 -0
  540. SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
  541. SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
  542. SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
  543. SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
  544. SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
  545. SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
  546. SNMP/data/official_profiles/paloalto_components.json +36 -0
  547. SNMP/data/official_profiles/paloalto_system.json +15 -0
  548. SNMP/data/official_profiles/traps.json +16 -0
  549. SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
  550. SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
  551. SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
  552. SNMP/data/official_profiles/versa_flexvnf.json +14 -0
  553. SNMP/data/schema.md +650 -0
  554. SNMP/data/schema_reference/snmp_field_schema.md +747 -0
  555. SNMP/data/snmp_template.json +629 -0
  556. SNMP/data/template_profile_context.md +3986 -0
  557. SNMP/inline_grounding.py +77 -0
  558. SNMP/management/__init__.py +1 -0
  559. SNMP/management/commands/__init__.py +1 -0
  560. SNMP/management/commands/generate_template_profile_context.py +272 -0
  561. SNMP/management/commands/load_test_snmp_data.py +240 -0
  562. SNMP/management/commands/sync_snmp_official_data.py +263 -0
  563. SNMP/management/commands/unload_test_snmp_data.py +77 -0
  564. SNMP/migrations/0001_initial.py +101 -0
  565. SNMP/migrations/0002_devicetemplate.py +34 -0
  566. SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
  567. SNMP/migrations/0004_device_device_template.py +19 -0
  568. SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
  569. SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
  570. SNMP/migrations/0007_remove_device_profiles.py +17 -0
  571. SNMP/migrations/0008_devicetemplate_type.py +18 -0
  572. SNMP/migrations/0009_alter_device_device_template.py +19 -0
  573. SNMP/migrations/0010_alter_device_device_template.py +19 -0
  574. SNMP/migrations/0011_network_namespace.py +18 -0
  575. SNMP/migrations/0012_profile_normalizers.py +18 -0
  576. SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
  577. SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
  578. SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
  579. SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
  580. SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
  581. SNMP/migrations/0018_add_official_key.py +39 -0
  582. SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
  583. SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
  584. SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
  585. SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
  586. SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
  587. SNMP/migrations/0024_network_credential_mode.py +18 -0
  588. SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
  589. SNMP/migrations/__init__.py +0 -0
  590. SNMP/models.py +892 -0
  591. SNMP/network_map.py +660 -0
  592. SNMP/overview.py +394 -0
  593. SNMP/snmp_crud.py +6082 -0
  594. SNMP/snmp_grounding.py +146 -0
  595. SNMP/snmp_normalizers.py +594 -0
  596. SNMP/snmp_pipeline_generator.py +1658 -0
  597. SNMP/snmp_test.py +962 -0
  598. SNMP/static/css/snmp.css +33 -0
  599. SNMP/static/images/apc.png +0 -0
  600. SNMP/static/images/arista.png +0 -0
  601. SNMP/static/images/aruba.png +0 -0
  602. SNMP/static/images/brocade.png +0 -0
  603. SNMP/static/images/cisco.png +0 -0
  604. SNMP/static/images/dell.png +0 -0
  605. SNMP/static/images/dlink.png +0 -0
  606. SNMP/static/images/east.png +0 -0
  607. SNMP/static/images/eaton.png +0 -0
  608. SNMP/static/images/epson.png +0 -0
  609. SNMP/static/images/hauwei.png +0 -0
  610. SNMP/static/images/hp.png +0 -0
  611. SNMP/static/images/hpe.png +0 -0
  612. SNMP/static/images/ingrasys.png +0 -0
  613. SNMP/static/images/linux.png +0 -0
  614. SNMP/static/images/mellanox.png +0 -0
  615. SNMP/static/images/netapp.png +0 -0
  616. SNMP/static/images/paloalto.png +0 -0
  617. SNMP/static/images/phoenixtec.png +0 -0
  618. SNMP/static/images/ubiquiti.png +0 -0
  619. SNMP/static/images/unknown.png +0 -0
  620. SNMP/static/images/versa.png +0 -0
  621. SNMP/static/images/vertiv.png +0 -0
  622. SNMP/static/js/ai_device_template_modal.js +1116 -0
  623. SNMP/static/js/credentials_table.js +291 -0
  624. SNMP/static/js/devices_table.js +588 -0
  625. SNMP/static/js/discovered_devices.js +291 -0
  626. SNMP/static/js/network_map.js +1657 -0
  627. SNMP/static/js/networks_table.js +360 -0
  628. SNMP/static/js/onboarding.js +866 -0
  629. SNMP/static/js/overview.js +416 -0
  630. SNMP/static/js/snmp_changes_indicator.js +76 -0
  631. SNMP/static/js/snmp_commit_modal.js +39 -0
  632. SNMP/static/js/snmp_credentials_modal.js +217 -0
  633. SNMP/static/js/snmp_device_template_modal.js +669 -0
  634. SNMP/static/js/snmp_device_visual_preview.js +1707 -0
  635. SNMP/static/js/snmp_devices_modal.js +912 -0
  636. SNMP/static/js/snmp_diff_modal.js +1559 -0
  637. SNMP/static/js/snmp_network_modal.js +940 -0
  638. SNMP/static/js/snmp_profile_modal.js +1212 -0
  639. SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
  640. SNMP/static/js/snmp_test.js +538 -0
  641. SNMP/templates/Credentials.html +325 -0
  642. SNMP/templates/DeviceTemplates.html +1059 -0
  643. SNMP/templates/Devices.html +274 -0
  644. SNMP/templates/Networks.html +469 -0
  645. SNMP/templates/Onboarding.html +521 -0
  646. SNMP/templates/Overview.html +227 -0
  647. SNMP/templates/components/ai_device_template_modal.html +46 -0
  648. SNMP/templates/components/ai_generate_template_content.html +224 -0
  649. SNMP/templates/components/device_template_profile_modal.html +60 -0
  650. SNMP/templates/components/discovered_devices_content.html +86 -0
  651. SNMP/templates/components/discovered_devices_modal.html +43 -0
  652. SNMP/templates/components/gmaps_latlon_modal.html +93 -0
  653. SNMP/templates/components/network_map.html +110 -0
  654. SNMP/templates/components/snmp_commit_modal.html +53 -0
  655. SNMP/templates/components/snmp_credentials_modal.html +189 -0
  656. SNMP/templates/components/snmp_device_modal.html +6 -0
  657. SNMP/templates/components/snmp_device_template_modal.html +129 -0
  658. SNMP/templates/components/snmp_device_visual_preview.html +347 -0
  659. SNMP/templates/components/snmp_devices_modal.html +330 -0
  660. SNMP/templates/components/snmp_diff_modal.html +148 -0
  661. SNMP/templates/components/snmp_network_modal.html +380 -0
  662. SNMP/templates/components/snmp_profile_modal.html +147 -0
  663. SNMP/templates/components/snmp_test_modal.html +398 -0
  664. SNMP/templatetags/__init__.py +0 -0
  665. SNMP/templatetags/snmp_extras.py +17 -0
  666. SNMP/urls.py +94 -0
  667. SNMP/views.py +913 -0
  668. Site/__init__.py +0 -0
  669. Site/apps.py +9 -0
  670. Site/migrations/__init__.py +0 -0
  671. Site/product_ca_views.py +41 -0
  672. Site/static/images/ElasticIcon.png +0 -0
  673. Site/static/images/LoggyIcon.png +0 -0
  674. Site/static/images/LoggyWizardIcon.png +0 -0
  675. Site/static/images/LogstashAgentIcon.png +0 -0
  676. Site/static/images/LogstashIcon.png +0 -0
  677. Site/static/js/base.js +192 -0
  678. Site/static/js/marked.min.js +69 -0
  679. Site/templates/base.html +52 -0
  680. Site/templates/error.html +65 -0
  681. Site/templates/home.html +148 -0
  682. Site/templates/navigation.html +530 -0
  683. Site/templates/popup.html +251 -0
  684. Site/templatetags/__init__.py +0 -0
  685. Site/templatetags/custom_filters.py +36 -0
  686. Site/urls.py +21 -0
  687. Site/views.py +200 -0
  688. Utilities/__init__.py +0 -0
  689. Utilities/apps.py +9 -0
  690. Utilities/data/grok-patterns/LICENSE +202 -0
  691. Utilities/data/grok-patterns/ecs-v1/aws +33 -0
  692. Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
  693. Utilities/data/grok-patterns/ecs-v1/bind +13 -0
  694. Utilities/data/grok-patterns/ecs-v1/bro +30 -0
  695. Utilities/data/grok-patterns/ecs-v1/exim +26 -0
  696. Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
  697. Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
  698. Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
  699. Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
  700. Utilities/data/grok-patterns/ecs-v1/java +34 -0
  701. Utilities/data/grok-patterns/ecs-v1/junos +13 -0
  702. Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
  703. Utilities/data/grok-patterns/ecs-v1/maven +1 -0
  704. Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
  705. Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
  706. Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
  707. Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
  708. Utilities/data/grok-patterns/ecs-v1/rails +13 -0
  709. Utilities/data/grok-patterns/ecs-v1/redis +3 -0
  710. Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
  711. Utilities/data/grok-patterns/ecs-v1/squid +6 -0
  712. Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
  713. Utilities/data/grok-patterns/legacy/aws +14 -0
  714. Utilities/data/grok-patterns/legacy/bacula +50 -0
  715. Utilities/data/grok-patterns/legacy/bind +3 -0
  716. Utilities/data/grok-patterns/legacy/bro +13 -0
  717. Utilities/data/grok-patterns/legacy/exim +19 -0
  718. Utilities/data/grok-patterns/legacy/firewalls +91 -0
  719. Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
  720. Utilities/data/grok-patterns/legacy/haproxy +39 -0
  721. Utilities/data/grok-patterns/legacy/httpd +15 -0
  722. Utilities/data/grok-patterns/legacy/java +17 -0
  723. Utilities/data/grok-patterns/legacy/junos +9 -0
  724. Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
  725. Utilities/data/grok-patterns/legacy/maven +1 -0
  726. Utilities/data/grok-patterns/legacy/mcollective +1 -0
  727. Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
  728. Utilities/data/grok-patterns/legacy/mongodb +7 -0
  729. Utilities/data/grok-patterns/legacy/nagios +124 -0
  730. Utilities/data/grok-patterns/legacy/postgresql +3 -0
  731. Utilities/data/grok-patterns/legacy/rails +13 -0
  732. Utilities/data/grok-patterns/legacy/redis +3 -0
  733. Utilities/data/grok-patterns/legacy/ruby +2 -0
  734. Utilities/data/grok-patterns/legacy/squid +4 -0
  735. Utilities/dissect.py +302 -0
  736. Utilities/grok.py +412 -0
  737. Utilities/migrations/__init__.py +0 -0
  738. Utilities/static/css/debugger_editor.css +88 -0
  739. Utilities/static/js/debugger_editor.js +93 -0
  740. Utilities/static/js/grok_debugger.js +131 -0
  741. Utilities/templates/dissect_debugger.html +95 -0
  742. Utilities/templates/grok_debugger.html +99 -0
  743. Utilities/urls.py +14 -0
  744. Utilities/views.py +363 -0
  745. logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
  746. logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
  747. logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
  748. logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
  749. logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
  750. logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
  751. theme/__init__.py +0 -0
  752. theme/apps.py +9 -0
  753. theme/package-lock.json +6 -0
  754. theme/static/css/dist/styles.css +2 -0
  755. theme/static/images/favicon.ico +0 -0
  756. theme/static_src/.gitignore +1 -0
  757. theme/static_src/package-lock.json +1930 -0
  758. theme/static_src/package.json +26 -0
  759. theme/static_src/postcss.config.js +7 -0
  760. theme/static_src/src/styles.css +38 -0
  761. theme/static_src/tailwind.config.js +43 -0
  762. theme/templates/base.html +32 -0
@@ -0,0 +1,2827 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License;
4
+ * you may not use this file except in compliance with the Elastic License.
5
+ */
6
+
7
+ // Plugin Configuration Modal Controller
8
+ window.PluginConfigModal = (function () {
9
+ let currentComponent = null;
10
+ let pluginData = {};
11
+ let isNewComponent = false; // Track if this is a newly added component
12
+ let keystoreKeys = [];
13
+
14
+ // Initialize the modal with plugin data
15
+ function init(data) {
16
+ pluginData = data;
17
+ }
18
+
19
+ function setKeystoreKeys(keys) {
20
+ keystoreKeys = keys;
21
+ }
22
+
23
+ function toggleKeystoreDropdown(fieldId) {
24
+ const existing = document.getElementById(`keystore-dropdown-${fieldId}`);
25
+ if (existing) {
26
+ existing.remove();
27
+ return;
28
+ }
29
+ // Close any other open dropdowns
30
+ document.querySelectorAll('[id^="keystore-dropdown-"]').forEach(el => el.remove());
31
+
32
+ const btn = document.getElementById(`keystore-btn-${fieldId}`);
33
+ if (!btn) return;
34
+
35
+ const dropdown = document.createElement('div');
36
+ dropdown.id = `keystore-dropdown-${fieldId}`;
37
+ dropdown.className = 'absolute z-50 mt-1 bg-gray-900 border border-purple-500/50 rounded-lg shadow-xl py-1 min-w-max';
38
+ dropdown.style.top = `${btn.offsetTop + btn.offsetHeight}px`;
39
+ dropdown.style.right = '0';
40
+
41
+ if (keystoreKeys.length === 0) {
42
+ dropdown.innerHTML = `<div class="px-4 py-2 text-xs text-gray-400 italic">No keystore entries found</div>`;
43
+ } else {
44
+ keystoreKeys.forEach(key => {
45
+ const item = document.createElement('button');
46
+ item.type = 'button';
47
+ item.className = 'w-full text-left px-4 py-1.5 text-sm text-gray-200 hover:bg-purple-800/50 hover:text-white font-mono flex items-center gap-2';
48
+ item.innerHTML = `
49
+ <svg class="w-3.5 h-3.5 text-purple-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
50
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"/>
51
+ </svg>
52
+ <span class="text-purple-300">\${</span>${escapeHtml(key)}<span class="text-purple-300">}</span>`;
53
+ item.addEventListener('click', () => insertKeystoreKey(fieldId, key));
54
+ dropdown.appendChild(item);
55
+ });
56
+ }
57
+
58
+ btn.parentElement.style.position = 'relative';
59
+ btn.parentElement.appendChild(dropdown);
60
+
61
+ // Close when clicking outside
62
+ setTimeout(() => {
63
+ document.addEventListener('click', function closeDropdown(e) {
64
+ if (!dropdown.contains(e.target) && e.target !== btn) {
65
+ dropdown.remove();
66
+ document.removeEventListener('click', closeDropdown);
67
+ }
68
+ });
69
+ }, 0);
70
+ }
71
+
72
+ function insertKeystoreKey(fieldId, key) {
73
+ const input = document.getElementById(fieldId);
74
+ if (input) {
75
+ input.value = `\${${key}}`;
76
+ input.type = 'text'; // show the reference, not dots
77
+ // Trigger plaintext warning check
78
+ const warningId = `warning-${fieldId}`;
79
+ const warning = document.getElementById(warningId);
80
+ if (warning) warning.classList.add('hidden');
81
+ }
82
+ const dropdown = document.getElementById(`keystore-dropdown-${fieldId}`);
83
+ if (dropdown) dropdown.remove();
84
+ }
85
+
86
+ // Show the configuration modal for a component
87
+ function show(component, isNew = false) {
88
+ currentComponent = component;
89
+ isNewComponent = isNew;
90
+ const modal = document.getElementById('configModal');
91
+ const configForm = document.getElementById('configForm');
92
+ const pluginInfo = pluginData[component.type]?.[component.plugin] || {};
93
+
94
+ // Set plugin icon (only for input and output plugins)
95
+ const iconImg = modal.querySelector('#pluginIconImg');
96
+ if (component.type === 'input' || component.type === 'output') {
97
+ iconImg.style.display = ''; // Reset display style
98
+ const iconPath = `/static/images/${component.plugin}.png`;
99
+ iconImg.src = iconPath;
100
+ iconImg.onerror = () => {
101
+ // Hide the icon if the plugin-specific one doesn't exist
102
+ iconImg.style.display = 'none';
103
+ };
104
+ } else {
105
+ // Hide icon for filter plugins
106
+ iconImg.style.display = 'none';
107
+ }
108
+
109
+ // Set modal title with plugin type badge
110
+ const titleElement = modal.querySelector('h3');
111
+ titleElement.innerHTML = `
112
+ <div class="flex items-center">
113
+ <span>${component.plugin}</span>
114
+ <span class="ml-2 px-1.5 py-0.5 text-xs rounded-full ${getPluginTypeColor(component.type)}">
115
+ ${component.type.charAt(0).toUpperCase() + component.type.slice(1)}
116
+ </span>
117
+ ${pluginInfo.deprecated ?
118
+ '<span class="ml-1 px-1.5 py-0.5 text-xs rounded-full bg-red-600/50 text-red-100">Deprecated</span>' : ''}
119
+ </div>
120
+ `;
121
+
122
+ // Clear previous configuration
123
+ configForm.innerHTML = '';
124
+
125
+ // Add plugin description if available
126
+ if (pluginInfo.description) {
127
+ const desc = document.createElement('p');
128
+ desc.className = 'text-sm text-gray-300 mb-4 pb-4 border-b border-gray-700';
129
+ desc.textContent = pluginInfo.description;
130
+ configForm.appendChild(desc);
131
+ }
132
+
133
+ // Add configuration fields based on plugin options
134
+ if (pluginInfo.options && Object.keys(pluginInfo.options).length > 0) {
135
+ // Add search bar for filtering fields
136
+ const searchContainer = document.createElement('div');
137
+ searchContainer.className = 'mb-4 pb-4 border-b border-gray-700';
138
+ searchContainer.innerHTML = `
139
+ <div class="rounded-lg border border-blue-500/40 bg-blue-950/30 px-3 pt-2 pb-3">
140
+ <div class="flex items-center gap-1.5 mb-2">
141
+ <span class="text-xs font-semibold uppercase tracking-wider text-blue-400">Filter Fields</span>
142
+ </div>
143
+ <div class="relative">
144
+ <input type="text"
145
+ id="configFieldSearch"
146
+ placeholder="Type to filter fields below..."
147
+ class="w-full p-2 pl-9 bg-gray-900 border border-blue-500/30 rounded text-white text-sm placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
148
+ oninput="PluginConfigModal.filterFields(this.value)">
149
+ <svg class="absolute left-2.5 top-1/2 transform -translate-y-1/2 w-4 h-4 text-blue-400/70 pointer-events-none" fill="none" stroke="currentColor" viewBox="0 0 24 24">
150
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
151
+ </svg>
152
+ </div>
153
+ </div>
154
+ `;
155
+ configForm.appendChild(searchContainer);
156
+ // Convert options to array and separate into important and advanced
157
+ const allOptions = Object.entries(pluginInfo.options)
158
+ .filter(([key]) => !key.startsWith('_')); // Skip internal fields
159
+
160
+ // Separate fields into important (required or important) and advanced
161
+ const importantOptions = [];
162
+ const advancedOptions = [];
163
+
164
+ allOptions.forEach(([key, option]) => {
165
+ const isRequired = option.required === 'Yes';
166
+ const isImportant = option.important === 'Yes';
167
+ const isExplicitlyNotImportant = option.important === 'No';
168
+
169
+ // A field is "advanced" only if it's explicitly marked as not important AND not required
170
+ // If the important field is missing (undefined), treat it as important by default
171
+ if (isRequired || isImportant || !isExplicitlyNotImportant) {
172
+ importantOptions.push([key, option]);
173
+ } else {
174
+ advancedOptions.push([key, option]);
175
+ }
176
+ });
177
+
178
+ // Sort important fields: Required:Yes first, then non-required
179
+ importantOptions.sort((a, b) => {
180
+ const aRequired = a[1].required === 'Yes';
181
+ const bRequired = b[1].required === 'Yes';
182
+
183
+ // If one is required and the other isn't, required comes first
184
+ if (aRequired && !bRequired) return -1;
185
+ if (!aRequired && bRequired) return 1;
186
+
187
+ // If both have same required status, maintain original order (stable sort)
188
+ return 0;
189
+ });
190
+
191
+ // Sort advanced fields alphabetically
192
+ advancedOptions.sort((a, b) => a[0].localeCompare(b[0]));
193
+
194
+ // Render important fields first
195
+ importantOptions.forEach(([key, option]) => {
196
+ const fieldId = `config-${key}`;
197
+ const value = component.config[key] !== undefined ? component.config[key] : '';
198
+ const inputType = (option.input_type || 'text').toLowerCase();
199
+
200
+ const fieldGroup = document.createElement('div');
201
+ fieldGroup.className = 'mb-4';
202
+ fieldGroup.dataset.required = option.required === 'Yes' ? 'true' : 'false';
203
+ fieldGroup.dataset.fieldName = key;
204
+ fieldGroup.dataset.fieldType = inputType;
205
+
206
+ let inputField = '';
207
+ const inputClasses = 'w-full p-2 bg-gray-700 border border-gray-600 rounded text-white';
208
+
209
+ // Create appropriate input based on type
210
+ if (inputType === 'codec') {
211
+ // Special handling for codec field
212
+ const codecData = pluginData.codec || {};
213
+ const codecNames = Object.keys(codecData).sort();
214
+
215
+ // Get current codec value
216
+ let currentCodecName = '';
217
+ let currentCodecConfig = {};
218
+ if (value && typeof value === 'object') {
219
+ // value is like {"cef": {"ecs_compatibility": "v1"}}
220
+ const entries = Object.entries(value);
221
+ if (entries.length > 0) {
222
+ [currentCodecName, currentCodecConfig] = entries[0];
223
+ }
224
+ }
225
+
226
+ const codecContainerId = `codec-container-${Date.now()}`;
227
+ const codecSelectId = `codec-select-${Date.now()}`;
228
+ const codecConfigId = `codec-config-${Date.now()}`;
229
+
230
+ inputField = `
231
+ <div id="${codecContainerId}" class="space-y-3">
232
+ <select id="${codecSelectId}"
233
+ class="${inputClasses}"
234
+ onchange="handleCodecChange('${codecContainerId}', '${fieldId}', this.value)">
235
+ <option value="">-- Select Codec --</option>
236
+ ${codecNames.map(name => `
237
+ <option value="${name}" ${name === currentCodecName ? 'selected' : ''}>${name}</option>
238
+ `).join('')}
239
+ </select>
240
+ <div id="${codecConfigId}" class="ml-4 space-y-2 border-l-2 border-gray-600 pl-4">
241
+ <!-- Codec configuration fields will be inserted here -->
242
+ </div>
243
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="codec" value='${escapeHtml(JSON.stringify(value || {}))}'>
244
+ </div>
245
+ `;
246
+ } else if (inputType === 'dropdown') {
247
+ // Handle dropdown input type
248
+ const dropdownOptions = option.options || [];
249
+ inputField = `
250
+ <select id="${fieldId}" name="${key}" class="${inputClasses}">
251
+ <option value="">-- Select an option --</option>
252
+ ${value !== '' && value !== undefined && value !== null && typeof value !== 'object' && !dropdownOptions.map(String).includes(String(value)) ? `
253
+ <option value="${escapeHtml(value)}" selected>${escapeHtml(value)}</option>
254
+ ` : ''}
255
+ ${dropdownOptions.map(opt => `
256
+ <option value="${escapeHtml(opt)}" ${String(value) === String(opt) ? 'selected' : ''}>${escapeHtml(opt)}</option>
257
+ `).join('')}
258
+ </select>
259
+ `;
260
+ } else if (inputType.includes('boolean') || inputType === 'bool') {
261
+ inputField = `
262
+ <select id="${fieldId}" name="${key}" class="${inputClasses}">
263
+ <option value="true" ${value === true || value === 'true' ? 'selected' : ''}>true</option>
264
+ <option value="false" ${value === false || value === 'false' ? 'selected' : ''}>false</option>
265
+ <option value="" ${value === '' ? 'selected' : ''}></option>
266
+ </select>
267
+ `;
268
+ } else if (inputType === 'array_of_hashes') {
269
+ // Handle array of hashes input type (e.g., SNMP hosts)
270
+ let arrayValue = [];
271
+ if (Array.isArray(value)) {
272
+ arrayValue = [...value];
273
+ } else if (typeof value === 'string' && value.trim() !== '') {
274
+ try {
275
+ const parsed = JSON.parse(value);
276
+ arrayValue = Array.isArray(parsed) ? parsed : [parsed];
277
+ } catch (e) {
278
+ arrayValue = [];
279
+ }
280
+ }
281
+
282
+ const containerId = `array-hash-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
283
+ const hashOptions = option.options || {};
284
+ const optionsJson = escapeHtml(JSON.stringify(hashOptions));
285
+
286
+ inputField = `
287
+ <div id="${containerId}" class="space-y-3" data-hash-options='${optionsJson}'>
288
+ <div class="p-3 bg-gray-900/50 border border-gray-600 rounded">
289
+ <div class="text-xs text-gray-400 mb-2">No entries yet. Click "+ Add Entry" to add one.</div>
290
+ </div>
291
+ <button type="button"
292
+ class="mt-2 px-3 py-1 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm"
293
+ onclick="addArrayOfHashesItem('${containerId}', '${fieldId}')">
294
+ + Add Entry
295
+ </button>
296
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="array_of_hashes" value='${escapeHtml(JSON.stringify(arrayValue))}'>
297
+ </div>
298
+ `;
299
+ } else if (inputType === 'key_list_hash') {
300
+ // Handle key_list_hash input type (e.g., grok match field)
301
+ let keyListHashValue = {};
302
+ try {
303
+ if (typeof value === 'string' && value.trim() !== '') {
304
+ keyListHashValue = JSON.parse(value);
305
+ } else if (typeof value === 'object' && value !== null) {
306
+ keyListHashValue = { ...value };
307
+ }
308
+ } catch (e) {
309
+ console.error('Error parsing key_list_hash value:', e);
310
+ }
311
+
312
+ const containerId = `key-list-hash-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
313
+ const sectionId = `key-list-hash-section-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
314
+
315
+ inputField = `
316
+ <div id="${containerId}" class="space-y-2">
317
+ <div class="p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-3" data-section-id="${sectionId}">
318
+ <div class="flex items-center gap-2">
319
+ <input type="text"
320
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm section-key focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
321
+ placeholder="Key (e.g., message, field1)"
322
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
323
+ <button type="button"
324
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
325
+ onclick="removeKeyListHashSection('${containerId}', '${fieldId}', this)">
326
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
327
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
328
+ </svg>
329
+ Remove Section
330
+ </button>
331
+ </div>
332
+ <div class="ml-4 space-y-2 section-values">
333
+ <div class="flex items-center gap-2">
334
+ <span class="text-gray-400 text-sm">=></span>
335
+ <input type="text"
336
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
337
+ placeholder="Value (e.g., pattern1)"
338
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
339
+ <button type="button"
340
+ class="flex-shrink-0 p-1 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
341
+ title="Expand editor"
342
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
343
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
344
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
345
+ </svg>
346
+ </button>
347
+ <button type="button"
348
+ class="px-3 py-1 text-red-400 hover:bg-gray-700 rounded text-xs transition-colors flex items-center gap-1"
349
+ onclick="removeKeyListHashValue('${containerId}', '${fieldId}', this)">
350
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
351
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
352
+ </svg>
353
+ Remove
354
+ </button>
355
+ </div>
356
+ </div>
357
+ <button type="button"
358
+ class="ml-4 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-xs transition-colors"
359
+ onclick="addKeyListHashValue('${containerId}', '${fieldId}', this)">
360
+ + Add Value
361
+ </button>
362
+ </div>
363
+ <button type="button"
364
+ class="px-3 py-1.5 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm transition-colors"
365
+ onclick="addKeyListHashSection('${containerId}', '${fieldId}')">
366
+ + Add Section
367
+ </button>
368
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="key_list_hash" value='${escapeHtml(JSON.stringify(keyListHashValue))}'>
369
+ </div>
370
+ `;
371
+ } else if (inputType.includes('hash') || inputType === 'object') {
372
+ // Handle hash/object input type
373
+ let hashValue = {};
374
+ try {
375
+ if (typeof value === 'string' && value.trim() !== '') {
376
+ hashValue = JSON.parse(value);
377
+ } else if (typeof value === 'object' && value !== null) {
378
+ hashValue = { ...value };
379
+ }
380
+ } catch (e) {
381
+ console.error('Error parsing hash value:', e);
382
+ }
383
+
384
+ const containerId = `hash-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
385
+ inputField = `
386
+ <div id="${containerId}" class="p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-2">
387
+ <div class="flex items-center space-x-2">
388
+ <input type="text"
389
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
390
+ placeholder="Key"
391
+ onchange="updateHashPair('${containerId}', '${fieldId}', this, 'key')">
392
+ <span class="text-gray-400">=></span>
393
+ <input type="text"
394
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
395
+ placeholder="Value"
396
+ onchange="updateHashPair('${containerId}', '${fieldId}', this, 'value')">
397
+ <button type="button"
398
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
399
+ title="Expand editor"
400
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
401
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
402
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
403
+ </svg>
404
+ </button>
405
+ <button type="button"
406
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
407
+ onclick="removeHashPair('${containerId}', this)">
408
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
409
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
410
+ </svg>
411
+ Remove
412
+ </button>
413
+ </div>
414
+ <button type="button"
415
+ class="mt-2 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-sm"
416
+ onclick="addHashPair('${containerId}', '${fieldId}')">
417
+ + Add More
418
+ </button>
419
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="hash" value='${escapeHtml(JSON.stringify(hashValue))}'>
420
+ </div>
421
+ `;
422
+ } else if (inputType.includes('array') || inputType === 'list') {
423
+ // Handle array input type
424
+ let arrayValue = [];
425
+ if (Array.isArray(value)) {
426
+ arrayValue = [...value];
427
+ } else if (typeof value === 'string' && value.trim() !== '') {
428
+ // Try to parse as JSON first
429
+ try {
430
+ const parsed = JSON.parse(value);
431
+ arrayValue = Array.isArray(parsed) ? parsed : [parsed];
432
+ } catch (e) {
433
+ // If not valid JSON, treat as a single string value
434
+ arrayValue = [value];
435
+ }
436
+ } else if (value !== undefined && value !== null && value !== '') {
437
+ // For any other non-empty value, wrap it in an array
438
+ arrayValue = [value];
439
+ }
440
+
441
+ const containerId = `array-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
442
+ inputField = `
443
+ <div id="${containerId}" class="p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-2">
444
+ <div class="flex items-center space-x-2">
445
+ <input type="text"
446
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
447
+ placeholder="Value"
448
+ onchange="updateArrayItem('${containerId}', '${fieldId}', this, 0)">
449
+ <button type="button"
450
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
451
+ title="Expand editor"
452
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
453
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
454
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
455
+ </svg>
456
+ </button>
457
+ <button type="button"
458
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
459
+ onclick="removeArrayItem('${containerId}', this)">
460
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
461
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
462
+ </svg>
463
+ Remove
464
+ </button>
465
+ </div>
466
+ <button type="button"
467
+ class="mt-2 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-sm"
468
+ onclick="addArrayItem('${containerId}', '${fieldId}')">
469
+ + Add More
470
+ </button>
471
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="array" value='${escapeHtml(JSON.stringify(arrayValue))}'>
472
+ </div>
473
+ `;
474
+ } else if (inputType.includes('number') || inputType === 'int' || inputType === 'float') {
475
+ inputField = `
476
+ <input type="number" id="${fieldId}" name="${key}"
477
+ value="${escapeHtml(value)}"
478
+ step="${inputType === 'float' ? '0.1' : '1'}"
479
+ class="${inputClasses}">
480
+ `;
481
+ } else if (key.toLowerCase() === 'code') {
482
+ // Special handling for "code" field - use textarea with preserved whitespace
483
+ inputField = `
484
+ <textarea id="${fieldId}" name="${key}"
485
+ rows="10"
486
+ class="${inputClasses} font-mono text-sm whitespace-pre"
487
+ style="resize: vertical; min-height: 200px;">${escapeHtml(value)}</textarea>
488
+ `;
489
+ } else if (component.plugin === 'comment' && (key === 'string' || key.toLowerCase() === 'message' || key.toLowerCase() === 'text')) {
490
+ // Special handling for comment plugin - use textarea for multiline comments
491
+ inputField = `
492
+ <textarea id="${fieldId}" name="${key}"
493
+ rows="5"
494
+ class="${inputClasses} font-mono text-sm"
495
+ style="resize: vertical; min-height: 100px;"
496
+ placeholder="Enter your comment here...">${escapeHtml(value)}</textarea>
497
+ `;
498
+ } else if (inputType === 'password') {
499
+ // Handle password input type with show/hide functionality
500
+ const warningId = `warning-${fieldId}`;
501
+ const isPlaintext = value && !String(value).startsWith('${');
502
+ inputField = `
503
+ <div id="${warningId}" class="${isPlaintext ? '' : 'hidden'} flex items-start gap-2 mb-2 p-3 bg-amber-900/30 border border-amber-600/50 rounded text-amber-300 text-xs">
504
+ <svg class="w-4 h-4 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
505
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
506
+ </svg>
507
+ It looks like you're storing a credential in plaintext. We highly encourage you to use the Logstash Keystore to store passwords.
508
+ </div>
509
+ <div class="flex items-center gap-2">
510
+ <div class="relative flex-1">
511
+ <input type="password" id="${fieldId}" name="${key}"
512
+ value="${escapeHtml(value)}"
513
+ class="${inputClasses} pr-10"
514
+ oninput="PluginConfigModal.checkPasswordPlaintext('${warningId}', this.value)">
515
+ <button type="button"
516
+ class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-200"
517
+ onclick="togglePasswordVisibility('${fieldId}', this)"
518
+ title="Show/Hide">
519
+ <svg class="w-5 h-5 eye-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
520
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
521
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
522
+ </svg>
523
+ </button>
524
+ </div>
525
+ ${keystoreKeys.length > 0 ? `
526
+ <div class="relative self-stretch flex-shrink-0">
527
+ <button type="button"
528
+ id="keystore-btn-${fieldId}"
529
+ onclick="PluginConfigModal.toggleKeystoreDropdown('${fieldId}')"
530
+ title="Insert keystore reference"
531
+ class="h-full flex items-center gap-1 px-2 rounded bg-purple-900/40 border border-purple-500/50 hover:bg-purple-900/70 hover:border-purple-400 text-purple-300 hover:text-purple-100 transition-colors">
532
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
533
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"/>
534
+ </svg>
535
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
536
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
537
+ </svg>
538
+ </button>
539
+ </div>` : ''}
540
+ </div>
541
+ `;
542
+ } else if (inputType === 'fs_path') {
543
+ // Handle filesystem path input type with file picker button
544
+ inputField = `
545
+ <div class="flex items-center space-x-2">
546
+ <input type="text" id="${fieldId}" name="${key}"
547
+ value="${escapeHtml(value)}"
548
+ class="${inputClasses} flex-1"
549
+ placeholder="Enter file path or click Browse...">
550
+ <button type="button"
551
+ class="px-3 py-2 bg-gray-600 text-white rounded hover:bg-gray-500 text-sm whitespace-nowrap"
552
+ onclick="browseFilePath('${fieldId}')"
553
+ title="Browse for file">
554
+ <svg class="w-5 h-5 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
555
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />
556
+ </svg>
557
+ Browse...
558
+ </button>
559
+ </div>
560
+ `;
561
+ } else {
562
+ // Default to text input with expand button
563
+ inputField = `
564
+ <div class="flex items-center gap-1">
565
+ <input type="text" id="${fieldId}" name="${key}"
566
+ value="${escapeHtml(value)}"
567
+ class="${inputClasses} flex-1">
568
+ <button type="button"
569
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
570
+ title="Expand editor"
571
+ aria-label="Expand editor for ${escapeHtml(key)}"
572
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
573
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
574
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
575
+ </svg>
576
+ </button>
577
+ </div>
578
+ `;
579
+ }
580
+
581
+ fieldGroup.innerHTML = `
582
+ <div class="flex items-start justify-between">
583
+ <label for="${fieldId}" class="block text-sm font-medium text-gray-300 mb-1">
584
+ ${key}
585
+ <span class="text-xs font-normal">
586
+ (Required:
587
+ <span class="${option.required === 'Yes' ? 'text-green-400' : 'text-red-400'}">
588
+ ${option.required || 'No'}
589
+ </span>
590
+ , Type: ${option.input_type || 'string'}
591
+ )
592
+ </span>
593
+ </label>
594
+ ${pluginInfo.link && option.setting_link ? `
595
+ <div class="flex items-center gap-1 ml-2">
596
+ <a href="${pluginInfo.link}${option.setting_link}" target="_blank"
597
+ class="text-gray-400 hover:text-white transition-colors"
598
+ title="Documentation for ${key}">
599
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
600
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
601
+ </svg>
602
+ </a>
603
+ <button type="button" onclick="event.preventDefault(); event.stopPropagation(); DocsIframeModal.show('${component.plugin}', '${component.type}')"
604
+ class="text-gray-400 hover:text-blue-400 transition-colors"
605
+ title="View documentation in window">
606
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
607
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
608
+ </svg>
609
+ </button>
610
+ </div>
611
+ ` : ''}
612
+ </div>
613
+ ${option.description ? `<p class="text-xs text-gray-400 mb-1">${option.description}</p>` : ''}
614
+ ${inputField}
615
+ ${option.default_value !== undefined ?
616
+ `<p class="text-xs text-gray-400 mt-1">Default: <code class="bg-gray-900 px-1 rounded">${escapeHtml(option.default_value)}</code></p>` : ''}
617
+ `;
618
+
619
+ configForm.appendChild(fieldGroup);
620
+ });
621
+
622
+ // Add Advanced Settings section if there are advanced options
623
+ if (advancedOptions.length > 0) {
624
+ const advancedSection = document.createElement('div');
625
+ advancedSection.className = 'mt-6 border-t border-gray-700 pt-4';
626
+ advancedSection.id = 'advancedSettingsSection';
627
+
628
+ const advancedHeader = document.createElement('div');
629
+ advancedHeader.className = 'flex items-center justify-between cursor-pointer mb-4';
630
+ advancedHeader.onclick = function () {
631
+ const content = advancedSection.querySelector('.advanced-content');
632
+ const icon = advancedSection.querySelector('.toggle-icon');
633
+ content.classList.toggle('hidden');
634
+ icon.classList.toggle('rotate-180');
635
+ };
636
+
637
+ advancedHeader.innerHTML = `
638
+ <h4 class="text-sm font-semibold text-gray-300">Advanced Settings</h4>
639
+ <svg class="toggle-icon w-5 h-5 text-gray-400 transform transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
640
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
641
+ </svg>
642
+ `;
643
+
644
+ advancedSection.appendChild(advancedHeader);
645
+
646
+ const advancedContent = document.createElement('div');
647
+ advancedContent.className = 'advanced-content hidden space-y-4';
648
+ advancedContent.id = 'advancedSettingsContent';
649
+
650
+ // Render advanced fields
651
+ advancedOptions.forEach(([key, option]) => {
652
+ const fieldId = `config-${key}`;
653
+ const value = component.config[key] !== undefined ? component.config[key] : '';
654
+ const inputType = (option.input_type || 'text').toLowerCase();
655
+
656
+ const fieldGroup = document.createElement('div');
657
+ fieldGroup.className = 'mb-4';
658
+ fieldGroup.dataset.required = option.required === 'Yes' ? 'true' : 'false';
659
+ fieldGroup.dataset.fieldName = key;
660
+ fieldGroup.dataset.fieldType = inputType;
661
+
662
+ let inputField = '';
663
+ const inputClasses = 'w-full p-2 bg-gray-700 border border-gray-600 rounded text-white';
664
+
665
+ // Create appropriate input based on type (same logic as above)
666
+ if (inputType === 'codec') {
667
+ // Special handling for codec field
668
+ const codecData = pluginData.codec || {};
669
+ const codecNames = Object.keys(codecData).sort();
670
+
671
+ // Get current codec value
672
+ let currentCodecName = '';
673
+ let currentCodecConfig = {};
674
+ if (value && typeof value === 'object') {
675
+ // value is like {"cef": {"ecs_compatibility": "v1"}}
676
+ const entries = Object.entries(value);
677
+ if (entries.length > 0) {
678
+ [currentCodecName, currentCodecConfig] = entries[0];
679
+ }
680
+ }
681
+
682
+ const codecContainerId = `codec-container-${Date.now()}`;
683
+ const codecSelectId = `codec-select-${Date.now()}`;
684
+ const codecConfigId = `codec-config-${Date.now()}`;
685
+
686
+ inputField = `
687
+ <div id="${codecContainerId}" class="space-y-3">
688
+ <select id="${codecSelectId}"
689
+ class="${inputClasses}"
690
+ onchange="handleCodecChange('${codecContainerId}', '${fieldId}', this.value)">
691
+ <option value="">-- Select Codec --</option>
692
+ ${codecNames.map(name => `
693
+ <option value="${name}" ${name === currentCodecName ? 'selected' : ''}>${name}</option>
694
+ `).join('')}
695
+ </select>
696
+ <div id="${codecConfigId}" class="ml-4 space-y-2 border-l-2 border-gray-600 pl-4">
697
+ <!-- Codec configuration fields will be inserted here -->
698
+ </div>
699
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="codec" value='${escapeHtml(JSON.stringify(value || {}))}'>
700
+ </div>
701
+ `;
702
+ } else if (inputType === 'dropdown') {
703
+ // Handle dropdown input type
704
+ const dropdownOptions = option.options || [];
705
+ inputField = `
706
+ <select id="${fieldId}" name="${key}" class="${inputClasses}">
707
+ <option value="">-- Select an option --</option>
708
+ ${value !== '' && value !== undefined && value !== null && typeof value !== 'object' && !dropdownOptions.map(String).includes(String(value)) ? `
709
+ <option value="${escapeHtml(value)}" selected>${escapeHtml(value)}</option>
710
+ ` : ''}
711
+ ${dropdownOptions.map(opt => `
712
+ <option value="${escapeHtml(opt)}" ${String(value) === String(opt) ? 'selected' : ''}>${escapeHtml(opt)}</option>
713
+ `).join('')}
714
+ </select>
715
+ `;
716
+ } else if (inputType.includes('boolean') || inputType === 'bool') {
717
+ inputField = `
718
+ <select id="${fieldId}" name="${key}" class="${inputClasses}">
719
+ <option value="true" ${value === true || value === 'true' ? 'selected' : ''}>true</option>
720
+ <option value="false" ${value === false || value === 'false' ? 'selected' : ''}>false</option>
721
+ <option value="" ${value === '' ? 'selected' : ''}></option>
722
+ </select>
723
+ `;
724
+ } else if (inputType === 'array_of_hashes') {
725
+ // Handle array of hashes input type (e.g., SNMP hosts)
726
+ let arrayValue = [];
727
+ if (Array.isArray(value)) {
728
+ arrayValue = [...value];
729
+ } else if (typeof value === 'string' && value.trim() !== '') {
730
+ try {
731
+ const parsed = JSON.parse(value);
732
+ arrayValue = Array.isArray(parsed) ? parsed : [parsed];
733
+ } catch (e) {
734
+ arrayValue = [];
735
+ }
736
+ }
737
+
738
+ const containerId = `array-hash-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
739
+ const hashOptions = option.options || {};
740
+ const optionsJson = escapeHtml(JSON.stringify(hashOptions));
741
+
742
+ inputField = `
743
+ <div id="${containerId}" class="space-y-3" data-hash-options='${optionsJson}'>
744
+ <div class="p-3 bg-gray-900/50 border border-gray-600 rounded">
745
+ <div class="text-xs text-gray-400 mb-2">No entries yet. Click "+ Add Entry" to add one.</div>
746
+ </div>
747
+ <button type="button"
748
+ class="mt-2 px-3 py-1 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm"
749
+ onclick="addArrayOfHashesItem('${containerId}', '${fieldId}')">
750
+ + Add Entry
751
+ </button>
752
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="array_of_hashes" value='${escapeHtml(JSON.stringify(arrayValue))}'>
753
+ </div>
754
+ `;
755
+ } else if (inputType === 'key_list_hash') {
756
+ // Handle key_list_hash input type (e.g., grok match field)
757
+ let keyListHashValue = {};
758
+ try {
759
+ if (typeof value === 'string' && value.trim() !== '') {
760
+ keyListHashValue = JSON.parse(value);
761
+ } else if (typeof value === 'object' && value !== null) {
762
+ keyListHashValue = { ...value };
763
+ }
764
+ } catch (e) {
765
+ console.error('Error parsing key_list_hash value:', e);
766
+ }
767
+
768
+ const containerId = `key-list-hash-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
769
+ const sectionId = `key-list-hash-section-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
770
+
771
+ inputField = `
772
+ <div id="${containerId}" class="space-y-2">
773
+ <div class="p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-3" data-section-id="${sectionId}">
774
+ <div class="flex items-center gap-2">
775
+ <input type="text"
776
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm section-key focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
777
+ placeholder="Key (e.g., message, field1)"
778
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
779
+ <button type="button"
780
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
781
+ onclick="removeKeyListHashSection('${containerId}', '${fieldId}', this)">
782
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
783
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
784
+ </svg>
785
+ Remove Section
786
+ </button>
787
+ </div>
788
+ <div class="ml-4 space-y-2 section-values">
789
+ <div class="flex items-center gap-2">
790
+ <span class="text-gray-400 text-sm">=></span>
791
+ <input type="text"
792
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
793
+ placeholder="Value (e.g., pattern1)"
794
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
795
+ <button type="button"
796
+ class="flex-shrink-0 p-1 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
797
+ title="Expand editor"
798
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
799
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
800
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
801
+ </svg>
802
+ </button>
803
+ <button type="button"
804
+ class="px-3 py-1 text-red-400 hover:bg-gray-700 rounded text-xs transition-colors flex items-center gap-1"
805
+ onclick="removeKeyListHashValue('${containerId}', '${fieldId}', this)">
806
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
807
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
808
+ </svg>
809
+ Remove
810
+ </button>
811
+ </div>
812
+ </div>
813
+ <button type="button"
814
+ class="ml-4 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-xs transition-colors"
815
+ onclick="addKeyListHashValue('${containerId}', '${fieldId}', this)">
816
+ + Add Value
817
+ </button>
818
+ </div>
819
+ <button type="button"
820
+ class="px-3 py-1.5 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm transition-colors"
821
+ onclick="addKeyListHashSection('${containerId}', '${fieldId}')">
822
+ + Add Section
823
+ </button>
824
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="key_list_hash" value='${escapeHtml(JSON.stringify(keyListHashValue))}'>
825
+ </div>
826
+ `;
827
+ } else if (inputType.includes('hash') || inputType === 'object') {
828
+ // Handle hash/object input type
829
+ let hashValue = {};
830
+ try {
831
+ if (typeof value === 'string' && value.trim() !== '') {
832
+ hashValue = JSON.parse(value);
833
+ } else if (typeof value === 'object' && value !== null) {
834
+ hashValue = { ...value };
835
+ }
836
+ } catch (e) {
837
+ console.error('Error parsing hash value:', e);
838
+ }
839
+
840
+ const containerId = `hash-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
841
+ inputField = `
842
+ <div id="${containerId}" class="p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-2">
843
+ <div class="flex items-center space-x-2">
844
+ <input type="text"
845
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
846
+ placeholder="Key"
847
+ onchange="updateHashPair('${containerId}', '${fieldId}', this, 'key')">
848
+ <span class="text-gray-400">=></span>
849
+ <input type="text"
850
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
851
+ placeholder="Value"
852
+ onchange="updateHashPair('${containerId}', '${fieldId}', this, 'value')">
853
+ <button type="button"
854
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
855
+ title="Expand editor"
856
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
857
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
858
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
859
+ </svg>
860
+ </button>
861
+ <button type="button"
862
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
863
+ onclick="removeHashPair('${containerId}', this)">
864
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
865
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
866
+ </svg>
867
+ Remove
868
+ </button>
869
+ </div>
870
+ <button type="button"
871
+ class="mt-2 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-sm"
872
+ onclick="addHashPair('${containerId}', '${fieldId}')">
873
+ + Add More
874
+ </button>
875
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="hash" value='${escapeHtml(JSON.stringify(hashValue))}'>
876
+ </div>
877
+ `;
878
+ } else if (inputType.includes('array') || inputType === 'list') {
879
+ // Handle array input type
880
+ let arrayValue = [];
881
+ if (Array.isArray(value)) {
882
+ arrayValue = [...value];
883
+ } else if (typeof value === 'string' && value.trim() !== '') {
884
+ // Try to parse as JSON first
885
+ try {
886
+ const parsed = JSON.parse(value);
887
+ arrayValue = Array.isArray(parsed) ? parsed : [parsed];
888
+ } catch (e) {
889
+ // If not valid JSON, treat as a single string value
890
+ arrayValue = [value];
891
+ }
892
+ } else if (value !== undefined && value !== null && value !== '') {
893
+ // For any other non-empty value, wrap it in an array
894
+ arrayValue = [value];
895
+ }
896
+
897
+ const containerId = `array-container-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
898
+ inputField = `
899
+ <div id="${containerId}" class="p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-2">
900
+ <div class="flex items-center space-x-2">
901
+ <input type="text"
902
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
903
+ placeholder="Value"
904
+ onchange="updateArrayItem('${containerId}', '${fieldId}', this, 0)">
905
+ <button type="button"
906
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
907
+ title="Expand editor"
908
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
909
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
910
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
911
+ </svg>
912
+ </button>
913
+ <button type="button"
914
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
915
+ onclick="removeArrayItem('${containerId}', this)">
916
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
917
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
918
+ </svg>
919
+ Remove
920
+ </button>
921
+ </div>
922
+ <button type="button"
923
+ class="mt-2 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-sm"
924
+ onclick="addArrayItem('${containerId}', '${fieldId}')">
925
+ + Add More
926
+ </button>
927
+ <input type="hidden" id="${fieldId}" name="${key}" data-field-type="array" value='${escapeHtml(JSON.stringify(arrayValue))}'>
928
+ </div>
929
+ `;
930
+ } else if (inputType.includes('number') || inputType === 'int' || inputType === 'float') {
931
+ inputField = `
932
+ <input type="number" id="${fieldId}" name="${key}"
933
+ value="${escapeHtml(value)}"
934
+ step="${inputType === 'float' ? '0.1' : '1'}"
935
+ class="${inputClasses}">
936
+ `;
937
+ } else if (key.toLowerCase() === 'code') {
938
+ // Special handling for "code" field - use textarea with preserved whitespace
939
+ inputField = `
940
+ <textarea id="${fieldId}" name="${key}"
941
+ rows="10"
942
+ class="${inputClasses} font-mono text-sm whitespace-pre"
943
+ style="resize: vertical; min-height: 200px;">${escapeHtml(value)}</textarea>
944
+ `;
945
+ } else if (component.plugin === 'comment' && (key === 'string' || key.toLowerCase() === 'message' || key.toLowerCase() === 'text')) {
946
+ // Special handling for comment plugin - use textarea for multiline comments
947
+ inputField = `
948
+ <textarea id="${fieldId}" name="${key}"
949
+ rows="5"
950
+ class="${inputClasses} font-mono text-sm"
951
+ style="resize: vertical; min-height: 100px;"
952
+ placeholder="Enter your comment here...">${escapeHtml(value)}</textarea>
953
+ `;
954
+ } else if (inputType === 'password') {
955
+ // Handle password input type with show/hide functionality
956
+ const warningId = `warning-${fieldId}`;
957
+ const isPlaintext = value && !String(value).startsWith('${');
958
+ inputField = `
959
+ <div id="${warningId}" class="${isPlaintext ? '' : 'hidden'} flex items-start gap-2 mb-2 p-3 bg-amber-900/30 border border-amber-600/50 rounded text-amber-300 text-xs">
960
+ <svg class="w-4 h-4 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
961
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
962
+ </svg>
963
+ It looks like you're storing a credential in plaintext. We highly encourage you to use the Logstash Keystore to store passwords.
964
+ </div>
965
+ <div class="flex items-center gap-2">
966
+ <div class="relative flex-1">
967
+ <input type="password" id="${fieldId}" name="${key}"
968
+ value="${escapeHtml(value)}"
969
+ class="${inputClasses} pr-10"
970
+ oninput="PluginConfigModal.checkPasswordPlaintext('${warningId}', this.value)">
971
+ <button type="button"
972
+ class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-200"
973
+ onclick="togglePasswordVisibility('${fieldId}', this)"
974
+ title="Show/Hide">
975
+ <svg class="w-5 h-5 eye-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
976
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
977
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
978
+ </svg>
979
+ </button>
980
+ </div>
981
+ ${keystoreKeys.length > 0 ? `
982
+ <div class="relative self-stretch flex-shrink-0">
983
+ <button type="button"
984
+ id="keystore-btn-${fieldId}"
985
+ onclick="PluginConfigModal.toggleKeystoreDropdown('${fieldId}')"
986
+ title="Insert keystore reference"
987
+ class="h-full flex items-center gap-1 px-2 rounded bg-purple-900/40 border border-purple-500/50 hover:bg-purple-900/70 hover:border-purple-400 text-purple-300 hover:text-purple-100 transition-colors">
988
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
989
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"/>
990
+ </svg>
991
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
992
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
993
+ </svg>
994
+ </button>
995
+ </div>` : ''}
996
+ </div>
997
+ `;
998
+ } else if (inputType === 'fs_path') {
999
+ // Handle filesystem path input type with file picker button
1000
+ inputField = `
1001
+ <div class="flex items-center space-x-2">
1002
+ <input type="text" id="${fieldId}" name="${key}"
1003
+ value="${escapeHtml(value)}"
1004
+ class="${inputClasses} flex-1"
1005
+ placeholder="Enter file path or click Browse...">
1006
+ <button type="button"
1007
+ class="px-3 py-2 bg-gray-600 text-white rounded hover:bg-gray-500 text-sm whitespace-nowrap"
1008
+ onclick="browseFilePath('${fieldId}')"
1009
+ title="Browse for file">
1010
+ <svg class="w-5 h-5 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1011
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />
1012
+ </svg>
1013
+ Browse...
1014
+ </button>
1015
+ </div>
1016
+ `;
1017
+ } else {
1018
+ // Default to text input with expand button
1019
+ inputField = `
1020
+ <div class="flex items-center gap-1">
1021
+ <input type="text" id="${fieldId}" name="${key}"
1022
+ value="${escapeHtml(value)}"
1023
+ class="${inputClasses} flex-1">
1024
+ <button type="button"
1025
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
1026
+ title="Expand editor"
1027
+ aria-label="Expand editor for ${escapeHtml(key)}"
1028
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
1029
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1030
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
1031
+ </svg>
1032
+ </button>
1033
+ </div>
1034
+ `;
1035
+ }
1036
+
1037
+ fieldGroup.innerHTML = `
1038
+ <div class="flex items-start justify-between">
1039
+ <label for="${fieldId}" class="block text-sm font-medium text-gray-300 mb-1">
1040
+ ${key}
1041
+ <span class="text-xs font-normal">
1042
+ (Required:
1043
+ <span class="${option.required === 'Yes' ? 'text-green-400' : 'text-red-400'}">
1044
+ ${option.required || 'No'}
1045
+ </span>
1046
+ , Type: ${option.input_type || 'string'}
1047
+ )
1048
+ </span>
1049
+ </label>
1050
+ ${pluginInfo.link && option.setting_link ? `
1051
+ <div class="flex items-center gap-1 ml-2">
1052
+ <a href="${pluginInfo.link}${option.setting_link}" target="_blank"
1053
+ class="text-gray-400 hover:text-white transition-colors"
1054
+ title="Documentation for ${key}">
1055
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1056
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
1057
+ </svg>
1058
+ </a>
1059
+ <button type="button" onclick="event.preventDefault(); event.stopPropagation(); DocsIframeModal.show('${component.plugin}', '${component.type}')"
1060
+ class="text-gray-400 hover:text-blue-400 transition-colors"
1061
+ title="View documentation in window">
1062
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1063
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
1064
+ </svg>
1065
+ </button>
1066
+ </div>
1067
+ ` : ''}
1068
+ </div>
1069
+ ${option.description ? `<p class="text-xs text-gray-400 mb-1">${option.description}</p>` : ''}
1070
+ ${inputField}
1071
+ ${option.default_value !== undefined ?
1072
+ `<p class="text-xs text-gray-400 mt-1">Default: <code class="bg-gray-900 px-1 rounded">${escapeHtml(option.default_value)}</code></p>` : ''}
1073
+ `;
1074
+
1075
+ advancedContent.appendChild(fieldGroup);
1076
+ });
1077
+
1078
+ advancedSection.appendChild(advancedContent);
1079
+ configForm.appendChild(advancedSection);
1080
+ }
1081
+ } else {
1082
+ const noOptions = document.createElement('p');
1083
+ noOptions.className = 'text-gray-400 italic';
1084
+ noOptions.textContent = 'No configuration options available for this plugin.';
1085
+ configForm.appendChild(noOptions);
1086
+ }
1087
+
1088
+ // Show the modal
1089
+ modal.classList.remove('hidden');
1090
+
1091
+ // Check if we're in simulation mode and show event data panel
1092
+ const eventDataPanel = document.getElementById('eventDataPanel');
1093
+ const eventDataBefore = document.getElementById('eventDataBefore');
1094
+ const eventDataAfter = document.getElementById('eventDataAfter');
1095
+ const modalContainer = document.getElementById('configModalContainer');
1096
+
1097
+ // Check if simulation mode is active by looking for simulation badges
1098
+ const isSimulationMode = document.querySelector('.simulation-executed-badge') !== null;
1099
+
1100
+ if (isSimulationMode && eventDataPanel && eventDataBefore && eventDataAfter) {
1101
+ // Find the component element for this plugin
1102
+ const componentElement = document.querySelector(`[data-id="${component.id}"]`);
1103
+
1104
+ if (componentElement) {
1105
+ // Find all "Original Event" or "View Full Event" elements
1106
+ const allDataFlows = document.querySelectorAll('.simulation-data-flow');
1107
+
1108
+ // Find the data flow elements that come BEFORE and AFTER this component in the DOM
1109
+ let beforeDataFlow = null;
1110
+ let afterDataFlow = null;
1111
+
1112
+ for (let i = 0; i < allDataFlows.length; i++) {
1113
+ const dataFlow = allDataFlows[i];
1114
+
1115
+ // Check if this data flow comes before the component element in the DOM
1116
+ const position = componentElement.compareDocumentPosition(dataFlow);
1117
+
1118
+ // If dataFlow comes before componentElement (position & 2 means PRECEDING)
1119
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
1120
+ beforeDataFlow = dataFlow;
1121
+ } else if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
1122
+ // If dataFlow comes after componentElement and we haven't found one yet
1123
+ if (!afterDataFlow) {
1124
+ afterDataFlow = dataFlow;
1125
+ }
1126
+ }
1127
+ }
1128
+
1129
+ // Populate before section
1130
+ if (beforeDataFlow && beforeDataFlow.dataset.eventJson) {
1131
+ // Use highlightJSON if available (from simulation_results.js)
1132
+ if (typeof highlightJSON === 'function') {
1133
+ const beforeChanges = beforeDataFlow.dataset.changes ? JSON.parse(beforeDataFlow.dataset.changes) : null;
1134
+ eventDataBefore.innerHTML = highlightJSON(beforeDataFlow.dataset.eventJson, beforeChanges);
1135
+ } else {
1136
+ eventDataBefore.textContent = beforeDataFlow.dataset.eventJson;
1137
+ }
1138
+ } else {
1139
+ eventDataBefore.textContent = 'No event data available';
1140
+ }
1141
+
1142
+ // Populate after section
1143
+ if (afterDataFlow && afterDataFlow.dataset.eventJson) {
1144
+ // Use highlightJSON if available (from simulation_results.js)
1145
+ if (typeof highlightJSON === 'function') {
1146
+ const afterChanges = afterDataFlow.dataset.changes ? JSON.parse(afterDataFlow.dataset.changes) : null;
1147
+ eventDataAfter.innerHTML = highlightJSON(afterDataFlow.dataset.eventJson, afterChanges);
1148
+ } else {
1149
+ eventDataAfter.textContent = afterDataFlow.dataset.eventJson;
1150
+ }
1151
+ } else {
1152
+ eventDataAfter.textContent = 'No event data available (plugin may be last in pipeline)';
1153
+ }
1154
+
1155
+ // Show the panel
1156
+ eventDataPanel.classList.remove('hidden');
1157
+ modalContainer.style.maxWidth = '1400px';
1158
+ } else {
1159
+ eventDataPanel.classList.add('hidden');
1160
+ modalContainer.style.maxWidth = '600px';
1161
+ }
1162
+ } else {
1163
+ // Not in simulation mode, hide the event data panel
1164
+ if (eventDataPanel) {
1165
+ eventDataPanel.classList.add('hidden');
1166
+ }
1167
+ if (modalContainer) {
1168
+ modalContainer.style.maxWidth = '600px';
1169
+ }
1170
+ }
1171
+
1172
+ // Populate existing hash, array, array_of_hashes, and key_list_hash values
1173
+ setTimeout(() => {
1174
+ populateExistingValues(component);
1175
+ populateCodecValues(component);
1176
+ populateArrayOfHashesValues(component);
1177
+ populateKeyListHashValues(component);
1178
+ checkAllFieldReferences();
1179
+ }, 10);
1180
+
1181
+ // Focus the first input field
1182
+ const firstInput = configForm.querySelector('input, select, textarea');
1183
+ if (firstInput) firstInput.focus();
1184
+ }
1185
+
1186
+ // Populate existing hash and array values
1187
+ function populateExistingValues(component) {
1188
+ const configForm = document.getElementById('configForm');
1189
+ if (!configForm) return;
1190
+
1191
+ // Find all hash containers and populate them
1192
+ configForm.querySelectorAll('[id^="hash-container-"]').forEach(container => {
1193
+ const hiddenField = container.querySelector('input[type="hidden"]');
1194
+ if (!hiddenField) return;
1195
+
1196
+ try {
1197
+ const hashValue = JSON.parse(hiddenField.value);
1198
+ const entries = Object.entries(hashValue);
1199
+
1200
+ if (entries.length > 0) {
1201
+ // Remove the default empty pair
1202
+ const defaultPair = container.querySelector('.flex.items-center.space-x-2');
1203
+ if (defaultPair) {
1204
+ const inputs = defaultPair.querySelectorAll('input[type="text"]');
1205
+ if (inputs.length === 2 && !inputs[0].value && !inputs[1].value) {
1206
+ defaultPair.remove();
1207
+ }
1208
+ }
1209
+
1210
+ // Add all existing pairs
1211
+ const addButton = container.querySelector('button[onclick*="addHashPair"]');
1212
+ entries.forEach(([key, value]) => {
1213
+ const newPair = document.createElement('div');
1214
+ newPair.className = 'flex items-center space-x-2';
1215
+ newPair.innerHTML = `
1216
+ <input type="text"
1217
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
1218
+ placeholder="Key"
1219
+ value="${String(key).replace(/\\/g, '\\\\').replace(/"/g, '&quot;')}"
1220
+ onchange="updateHashPair('${container.id}', '${hiddenField.id}', this, 'key')">
1221
+ <span class="text-gray-400">=></span>
1222
+ <input type="text"
1223
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
1224
+ placeholder="Value"
1225
+ value="${String(value).replace(/\\/g, '\\\\').replace(/"/g, '&quot;')}"
1226
+ onchange="updateHashPair('${container.id}', '${hiddenField.id}', this, 'value')">
1227
+ <button type="button"
1228
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
1229
+ title="Expand editor"
1230
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
1231
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1232
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
1233
+ </svg>
1234
+ </button>
1235
+ <button type="button"
1236
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
1237
+ onclick="removeHashPair('${container.id}', this)">
1238
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1239
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
1240
+ </svg>
1241
+ Remove
1242
+ </button>
1243
+ `;
1244
+ addButton.parentNode.insertBefore(newPair, addButton);
1245
+ });
1246
+ }
1247
+ } catch (e) {
1248
+ console.error('Error populating hash values:', e);
1249
+ }
1250
+ });
1251
+
1252
+ // Find all array containers and populate them
1253
+ configForm.querySelectorAll('[id^="array-container-"]').forEach(container => {
1254
+ const hiddenField = container.querySelector('input[type="hidden"]');
1255
+ if (!hiddenField) return;
1256
+
1257
+ try {
1258
+ const arrayValue = JSON.parse(hiddenField.value);
1259
+
1260
+ if (Array.isArray(arrayValue) && arrayValue.length > 0) {
1261
+ // Remove the default empty item
1262
+ const defaultItem = container.querySelector('.flex.items-center.space-x-2');
1263
+ if (defaultItem) {
1264
+ const input = defaultItem.querySelector('input[type="text"]');
1265
+ if (input && !input.value) {
1266
+ defaultItem.remove();
1267
+ }
1268
+ }
1269
+
1270
+ // Add all existing items
1271
+ const addButton = container.querySelector('button[onclick*="addArrayItem"]');
1272
+ arrayValue.forEach((value, index) => {
1273
+ const newItem = document.createElement('div');
1274
+ newItem.className = 'flex items-center space-x-2';
1275
+ newItem.innerHTML = `
1276
+ <input type="text"
1277
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
1278
+ placeholder="Value"
1279
+ value="${String(value).replace(/\\/g, '\\\\').replace(/"/g, '&quot;')}"
1280
+ onchange="updateArrayItem('${container.id}', '${hiddenField.id}', this, ${index})">
1281
+ <button type="button"
1282
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
1283
+ title="Expand editor"
1284
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
1285
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1286
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
1287
+ </svg>
1288
+ </button>
1289
+ <button type="button"
1290
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
1291
+ onclick="removeArrayItem('${container.id}', this)">
1292
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1293
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
1294
+ </svg>
1295
+ Remove
1296
+ </button>
1297
+ `;
1298
+ addButton.parentNode.insertBefore(newItem, addButton);
1299
+ });
1300
+ }
1301
+ } catch (e) {
1302
+ console.error('Error populating array values:', e);
1303
+ }
1304
+ });
1305
+ }
1306
+
1307
+ // Populate codec values
1308
+ function populateCodecValues(component) {
1309
+ const configForm = document.getElementById('configForm');
1310
+ if (!configForm) return;
1311
+
1312
+ // Find all codec containers
1313
+ configForm.querySelectorAll('[id^="codec-container-"]').forEach(container => {
1314
+ const selectElement = container.querySelector('select[id^="codec-select-"]');
1315
+ const hiddenField = container.querySelector('input[type="hidden"]');
1316
+
1317
+ if (!selectElement || !hiddenField) return;
1318
+
1319
+ try {
1320
+ const codecValue = JSON.parse(hiddenField.value);
1321
+ const entries = Object.entries(codecValue);
1322
+
1323
+ if (entries.length > 0) {
1324
+ const [codecName, codecConfig] = entries[0];
1325
+
1326
+ // Set the select value
1327
+ selectElement.value = codecName;
1328
+
1329
+ // Trigger the codec change to populate fields
1330
+ window.handleCodecChange(container.id, hiddenField.id, codecName);
1331
+ }
1332
+ } catch (e) {
1333
+ console.error('Error populating codec values:', e);
1334
+ }
1335
+ });
1336
+ }
1337
+
1338
+ // Hide the configuration modal
1339
+ function hide() {
1340
+ document.getElementById('configModal').classList.add('hidden');
1341
+ isNewComponent = false; // Reset flag
1342
+
1343
+ // Trigger pending animation if there is one
1344
+ if (typeof window.triggerPendingAnimation === 'function') {
1345
+ window.triggerPendingAnimation();
1346
+ }
1347
+ }
1348
+
1349
+ // Cancel and remove component if it's new
1350
+ function cancel() {
1351
+ if (isNewComponent && currentComponent) {
1352
+ // Remove the component from the components array
1353
+ removeComponentById(currentComponent.id);
1354
+ // Refresh the UI
1355
+ if (typeof loadExistingComponents === 'function') {
1356
+ loadExistingComponents();
1357
+ }
1358
+ }
1359
+ hide();
1360
+ }
1361
+
1362
+ // Helper function to remove a component by ID
1363
+ function removeComponentById(componentId) {
1364
+ // Search through all component types
1365
+ for (const type in components) {
1366
+ const index = components[type].findIndex(c => c.id === componentId);
1367
+ if (index !== -1) {
1368
+ components[type].splice(index, 1);
1369
+ return true;
1370
+ }
1371
+ // Also check nested components in conditionals
1372
+ for (const component of components[type]) {
1373
+ if (component.plugin === 'if') {
1374
+ // Check if block
1375
+ if (component.config.plugins) {
1376
+ const ifIndex = component.config.plugins.findIndex(c => c.id === componentId);
1377
+ if (ifIndex !== -1) {
1378
+ component.config.plugins.splice(ifIndex, 1);
1379
+ return true;
1380
+ }
1381
+ }
1382
+ // Check else-if blocks
1383
+ if (component.config.else_ifs) {
1384
+ for (const elseIf of component.config.else_ifs) {
1385
+ if (elseIf.plugins) {
1386
+ const elseIfIndex = elseIf.plugins.findIndex(c => c.id === componentId);
1387
+ if (elseIfIndex !== -1) {
1388
+ elseIf.plugins.splice(elseIfIndex, 1);
1389
+ return true;
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+ // Check else block
1395
+ if (component.config.else && component.config.else.plugins) {
1396
+ const elseIndex = component.config.else.plugins.findIndex(c => c.id === componentId);
1397
+ if (elseIndex !== -1) {
1398
+ component.config.else.plugins.splice(elseIndex, 1);
1399
+ return true;
1400
+ }
1401
+ }
1402
+ }
1403
+ }
1404
+ }
1405
+ return false;
1406
+ }
1407
+
1408
+ // Save the configuration
1409
+ function saveConfig() {
1410
+ if (!currentComponent) return;
1411
+
1412
+ const form = document.getElementById('configForm');
1413
+
1414
+ // Validate required fields
1415
+ const firstEmptyField = validateRequiredFields();
1416
+ if (firstEmptyField) {
1417
+ // Focus the first empty required field
1418
+ firstEmptyField.focus();
1419
+ return;
1420
+ }
1421
+
1422
+ const formData = new FormData(form);
1423
+ const config = {};
1424
+
1425
+ // Process form data
1426
+ for (const [key, value] of formData.entries()) {
1427
+ const input = form.querySelector(`[name="${key}"]`);
1428
+ const fieldType = input ? input.dataset.fieldType : null;
1429
+
1430
+ // Skip if the value is empty and not explicitly set
1431
+ if (value === '') {
1432
+ continue;
1433
+ }
1434
+
1435
+ try {
1436
+ // Handle different field types
1437
+ if (fieldType === 'codec') {
1438
+ const parsedValue = JSON.parse(value);
1439
+ // Only add if codec is selected
1440
+ if (Object.keys(parsedValue).length > 0) {
1441
+ config[key] = parsedValue;
1442
+ }
1443
+ } else if (fieldType === 'hash' || fieldType === 'array' || fieldType === 'array_of_hashes' || fieldType === 'key_list_hash') {
1444
+ const parsedValue = JSON.parse(value);
1445
+ // Only add if the hash/array is not empty
1446
+ if (Object.keys(parsedValue).length > 0 || (Array.isArray(parsedValue) && parsedValue.length > 0)) {
1447
+ config[key] = parsedValue;
1448
+ }
1449
+ } else if (value === 'true') {
1450
+ // Only add boolean if it's different from default
1451
+ if (pluginData[currentComponent.type]?.[currentComponent.plugin]?.options?.[key]?.default !== true) {
1452
+ config[key] = true;
1453
+ }
1454
+ } else if (value === 'false') {
1455
+ // Only add boolean if it's different from default
1456
+ if (pluginData[currentComponent.type]?.[currentComponent.plugin]?.options?.[key]?.default !== false) {
1457
+ config[key] = false;
1458
+ }
1459
+ } else if (!isNaN(value)) {
1460
+ // Only add number if it's different from default
1461
+ const defaultValue = pluginData[currentComponent.type]?.[currentComponent.plugin]?.options?.[key]?.default;
1462
+ if (defaultValue === undefined || Number(value) !== defaultValue) {
1463
+ config[key] = Number(value);
1464
+ }
1465
+ } else {
1466
+ // Only add string if it's different from default
1467
+ const defaultValue = pluginData[currentComponent.type]?.[currentComponent.plugin]?.options?.[key]?.default;
1468
+ if (defaultValue === undefined || value !== defaultValue.toString()) {
1469
+ config[key] = value;
1470
+ }
1471
+ }
1472
+ } catch (e) {
1473
+ console.error(`Error processing field ${key}:`, e);
1474
+ // Only add if there was an error and the value is not empty
1475
+ if (value !== '') {
1476
+ config[key] = value;
1477
+ }
1478
+ }
1479
+ }
1480
+
1481
+ // Update the component's configuration
1482
+ currentComponent.config = config;
1483
+
1484
+ // Store the pending animation ID before updating (in case it gets cleared)
1485
+ const savedPendingId = typeof pendingAnimationPluginId !== 'undefined' ? pendingAnimationPluginId : null;
1486
+
1487
+ // If there's a global update function, call it
1488
+ if (window.updateComponent) {
1489
+ window.updateComponent(currentComponent);
1490
+ }
1491
+
1492
+ // Restore the pending animation ID if it was cleared
1493
+ if (savedPendingId && typeof pendingAnimationPluginId !== 'undefined') {
1494
+ pendingAnimationPluginId = savedPendingId;
1495
+ }
1496
+
1497
+ // Hide the modal (this will trigger the animation)
1498
+ hide();
1499
+
1500
+ // Trigger pipeline warming synchronously (same as delete behavior)
1501
+ if (typeof triggerPipelineWarmingAndChecking === 'function') {
1502
+ triggerPipelineWarmingAndChecking();
1503
+ } else {
1504
+ console.error('[Plugin Config Modal] triggerPipelineWarmingAndChecking function not found - pipeline warming will not occur');
1505
+ }
1506
+
1507
+ // Dispatch event to mark UI as changed
1508
+ document.body.dispatchEvent(new CustomEvent('componentModified'));
1509
+ }
1510
+
1511
+ // Validate required fields
1512
+ function validateRequiredFields() {
1513
+ const form = document.getElementById('configForm');
1514
+ const requiredFields = form.querySelectorAll('[data-required="true"]');
1515
+
1516
+ for (const fieldGroup of requiredFields) {
1517
+ const fieldName = fieldGroup.dataset.fieldName;
1518
+ const fieldType = fieldGroup.dataset.fieldType;
1519
+ const input = fieldGroup.querySelector('input:not([type="hidden"]), select, textarea');
1520
+
1521
+ if (!input) continue;
1522
+
1523
+ let isEmpty = false;
1524
+
1525
+ // Check based on field type
1526
+ if (fieldType === 'codec') {
1527
+ const hiddenInput = fieldGroup.querySelector('input[type="hidden"]');
1528
+ if (hiddenInput) {
1529
+ try {
1530
+ const value = JSON.parse(hiddenInput.value);
1531
+ isEmpty = Object.keys(value).length === 0;
1532
+ } catch (e) {
1533
+ isEmpty = true;
1534
+ }
1535
+ }
1536
+ } else if (fieldType === 'hash' || fieldType === 'object' || fieldType === 'key_list_hash') {
1537
+ const hiddenInput = fieldGroup.querySelector('input[type="hidden"]');
1538
+ if (hiddenInput) {
1539
+ try {
1540
+ const value = JSON.parse(hiddenInput.value);
1541
+ isEmpty = Object.keys(value).length === 0;
1542
+ } catch (e) {
1543
+ isEmpty = true;
1544
+ }
1545
+ }
1546
+ } else if (fieldType === 'array' || fieldType === 'list' || fieldType === 'array_of_hashes') {
1547
+ const hiddenInput = fieldGroup.querySelector('input[type="hidden"]');
1548
+ if (hiddenInput) {
1549
+ try {
1550
+ const value = JSON.parse(hiddenInput.value);
1551
+ isEmpty = !Array.isArray(value) || value.length === 0;
1552
+ } catch (e) {
1553
+ isEmpty = true;
1554
+ }
1555
+ }
1556
+ } else {
1557
+ // Regular input field
1558
+ isEmpty = !input.value || input.value.trim() === '';
1559
+ }
1560
+
1561
+ if (isEmpty) {
1562
+ // Return the first visible input to focus
1563
+ return input;
1564
+ }
1565
+ }
1566
+
1567
+ return null;
1568
+ }
1569
+
1570
+ // Helper function to get color based on plugin type
1571
+ function getPluginTypeColor(type) {
1572
+ switch (type) {
1573
+ case 'input':
1574
+ return 'bg-green-600/20 text-green-400';
1575
+ case 'filter':
1576
+ return 'bg-blue-600/20 text-blue-400';
1577
+ case 'output':
1578
+ return 'bg-purple-600/20 text-purple-400';
1579
+ default:
1580
+ return 'bg-gray-600/20 text-gray-400';
1581
+ }
1582
+ }
1583
+
1584
+ // Helper function to check if a field is sensitive (password/api_key)
1585
+ function isSensitiveField(fieldName) {
1586
+ const lowerFieldName = fieldName.toLowerCase();
1587
+ return lowerFieldName.includes('password') ||
1588
+ lowerFieldName.includes('api_key') ||
1589
+ lowerFieldName.includes('apikey') ||
1590
+ lowerFieldName === 'token' ||
1591
+ lowerFieldName.includes('secret');
1592
+ }
1593
+
1594
+ // Filter fields based on search query
1595
+ function filterFields(query) {
1596
+ const searchQuery = query.toLowerCase().trim();
1597
+ const configForm = document.getElementById('configForm');
1598
+ if (!configForm) return;
1599
+
1600
+ // Get all field groups (both important and advanced)
1601
+ const allFieldGroups = configForm.querySelectorAll('[data-field-name]');
1602
+ const advancedSection = document.getElementById('advancedSettingsSection');
1603
+ const advancedContent = document.getElementById('advancedSettingsContent');
1604
+
1605
+ let hasVisibleFields = false;
1606
+ let hasVisibleAdvancedFields = false;
1607
+
1608
+ // If search is empty, show all fields and collapse advanced settings
1609
+ if (!searchQuery) {
1610
+ allFieldGroups.forEach(fieldGroup => {
1611
+ fieldGroup.style.display = '';
1612
+ });
1613
+
1614
+ // Collapse advanced settings when search is cleared
1615
+ if (advancedSection && advancedContent) {
1616
+ advancedContent.classList.add('hidden');
1617
+ const icon = advancedSection.querySelector('.toggle-icon');
1618
+ if (icon) {
1619
+ icon.classList.remove('rotate-180');
1620
+ }
1621
+ }
1622
+ return;
1623
+ }
1624
+
1625
+ // Filter fields based on search query
1626
+ allFieldGroups.forEach(fieldGroup => {
1627
+ const fieldName = fieldGroup.dataset.fieldName.toLowerCase();
1628
+ const isMatch = fieldName.includes(searchQuery);
1629
+
1630
+ // Show/hide based on match
1631
+ fieldGroup.style.display = isMatch ? '' : 'none';
1632
+
1633
+ if (isMatch) {
1634
+ hasVisibleFields = true;
1635
+
1636
+ // Check if this field is in advanced settings
1637
+ const isInAdvanced = advancedContent && advancedContent.contains(fieldGroup);
1638
+ if (isInAdvanced) {
1639
+ hasVisibleAdvancedFields = true;
1640
+ }
1641
+ }
1642
+ });
1643
+
1644
+ // Auto-expand advanced settings if there are matching fields inside
1645
+ if (advancedSection && advancedContent && hasVisibleAdvancedFields) {
1646
+ advancedContent.classList.remove('hidden');
1647
+ const icon = advancedSection.querySelector('.toggle-icon');
1648
+ if (icon) {
1649
+ icon.classList.add('rotate-180');
1650
+ }
1651
+ }
1652
+ }
1653
+
1654
+ function checkPasswordPlaintext(warningId, value) {
1655
+ const warning = document.getElementById(warningId);
1656
+ if (!warning) return;
1657
+ if (value && !String(value).startsWith('${')) {
1658
+ warning.classList.remove('hidden');
1659
+ } else {
1660
+ warning.classList.add('hidden');
1661
+ }
1662
+ }
1663
+
1664
+ const FIELD_REFERENCE_DOCS_URL = 'https://www.elastic.co/docs/reference/logstash/event-dependent-configuration#logstash-config-field-references';
1665
+
1666
+ /**
1667
+ * Converts a dotted field name to Logstash bracket syntax.
1668
+ *
1669
+ * Args:
1670
+ * value: Field name as typed by the user.
1671
+ *
1672
+ * Returns:
1673
+ * Bracketed field reference, or null if the value has no dot to convert.
1674
+ * Bracketed paths with a dot past the first segment are left alone, since
1675
+ * those usually name a real dotted key (e.g. Kubernetes labels).
1676
+ *
1677
+ * Example:
1678
+ * toFieldReference('source.ip') // '[source][ip]'
1679
+ * toFieldReference('[source.ip]') // '[source][ip]'
1680
+ * toFieldReference('[kubernetes][labels][app.kubernetes.io/name]') // null
1681
+ */
1682
+ function toFieldReference(value) {
1683
+ const trimmed = String(value).trim();
1684
+ if (!trimmed.includes('.') || trimmed.includes('%{')) return null;
1685
+ const bracketed = trimmed.match(/^\[(.+)\]$/);
1686
+ if (bracketed) {
1687
+ const segments = bracketed[1].split('][');
1688
+ if (segments.length > 1 && segments.slice(1).some(s => s.includes('.'))) return null;
1689
+ }
1690
+ const parts = trimmed.split(/[\[\].]/).filter(Boolean);
1691
+ if (parts.length < 2) return null;
1692
+ return parts.map(part => `[${part}]`).join('');
1693
+ }
1694
+
1695
+ // Returns the field_reference mode that applies to this specific input, or null
1696
+ function getFieldReferenceMode(input) {
1697
+ if (!currentComponent) return null;
1698
+
1699
+ let option;
1700
+ if (input.dataset.codecName) {
1701
+ option = pluginData.codec?.[input.dataset.codecName]?.options?.[input.dataset.codecOption];
1702
+ } else {
1703
+ const fieldGroup = input.closest('[data-field-name]');
1704
+ if (!fieldGroup) return null;
1705
+ option = pluginData[currentComponent.type]?.[currentComponent.plugin]?.options?.[fieldGroup.dataset.fieldName];
1706
+ }
1707
+ const mode = option?.field_reference;
1708
+ if (!mode || mode === 'No') return null;
1709
+
1710
+ const isKey = input.classList.contains('section-key') || (input.placeholder || '').startsWith('Key');
1711
+ if (mode === 'both') return mode;
1712
+ if (mode === 'key') return isKey ? mode : null;
1713
+ if (isKey) return null;
1714
+ if (mode === 'first') {
1715
+ const container = input.closest('[id^="array-container-"], [data-codec-rows]');
1716
+ return container && container.querySelector('input[type="text"]') === input ? mode : null;
1717
+ }
1718
+ return mode;
1719
+ }
1720
+
1721
+ function checkFieldReference(input) {
1722
+ let hint = input._fieldRefHint;
1723
+ const mode = getFieldReferenceMode(input);
1724
+ const suggestion = mode ? toFieldReference(input.value) : null;
1725
+
1726
+ if (!suggestion) {
1727
+ if (hint) {
1728
+ hint.remove();
1729
+ input._fieldRefHint = null;
1730
+ }
1731
+ return;
1732
+ }
1733
+
1734
+ if (!hint) {
1735
+ hint = document.createElement('p');
1736
+ hint.className = 'field-ref-hint text-xs text-gray-400 mt-1';
1737
+ hint._input = input;
1738
+ hint.innerHTML = `This field uses Logstash's <a href="${FIELD_REFERENCE_DOCS_URL}" target="_blank" rel="noopener" class="underline hover:text-white">field reference syntax</a>, you may be meaning to use <button type="button" class="font-mono underline decoration-dotted text-blue-300 hover:text-blue-200"></button> here.`;
1739
+ hint.querySelector('button').addEventListener('click', () => {
1740
+ input.value = hint._suggestion;
1741
+ input.dispatchEvent(new Event('input', { bubbles: true }));
1742
+ input.dispatchEvent(new Event('change', { bubbles: true }));
1743
+ input.focus();
1744
+ });
1745
+ const anchor = input.parentElement.classList.contains('flex') ? input.parentElement : input;
1746
+ anchor.insertAdjacentElement('afterend', hint);
1747
+ input._fieldRefHint = hint;
1748
+ }
1749
+ hint._suggestion = suggestion;
1750
+ hint.querySelector('button').textContent = suggestion;
1751
+ }
1752
+
1753
+ // Remove hints whose input was removed (e.g. a hash row was deleted)
1754
+ function sweepFieldReferenceHints() {
1755
+ document.querySelectorAll('#configForm .field-ref-hint').forEach(hint => {
1756
+ if (!hint._input || !hint._input.isConnected) hint.remove();
1757
+ });
1758
+ }
1759
+
1760
+ function checkAllFieldReferences() {
1761
+ document.querySelectorAll('#configForm input[type="text"]').forEach(checkFieldReference);
1762
+ }
1763
+
1764
+ document.addEventListener('input', (e) => {
1765
+ if (e.target.matches?.('#configForm input[type="text"]')) checkFieldReference(e.target);
1766
+ });
1767
+ document.addEventListener('click', (e) => {
1768
+ if (e.target.closest?.('#configForm')) setTimeout(sweepFieldReferenceHints, 0);
1769
+ }, true);
1770
+ document.addEventListener('change', (e) => {
1771
+ if (e.target.matches?.('#configForm select[id^="codec-select-"]')) setTimeout(checkAllFieldReferences, 0);
1772
+ });
1773
+
1774
+ // Public API
1775
+ return {
1776
+ init,
1777
+ show,
1778
+ hide,
1779
+ cancel,
1780
+ saveConfig,
1781
+ filterFields,
1782
+ checkPasswordPlaintext,
1783
+ getPluginData: () => pluginData,
1784
+ setKeystoreKeys,
1785
+ toggleKeystoreDropdown,
1786
+ insertKeystoreKey,
1787
+ };
1788
+ })();
1789
+
1790
+ // Hash/Dictionary helper functions
1791
+ window.addHashPair = function (containerId, fieldId) {
1792
+ const container = document.getElementById(containerId);
1793
+ if (!container) return;
1794
+
1795
+ const addButton = container.querySelector('button[onclick*="addHashPair"]');
1796
+ if (!addButton) return;
1797
+
1798
+ const newPair = document.createElement('div');
1799
+ newPair.className = 'flex items-center space-x-2';
1800
+ newPair.innerHTML = `
1801
+ <input type="text"
1802
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
1803
+ placeholder="Key"
1804
+ onchange="updateHashPair('${containerId}', '${fieldId}', this, 'key')">
1805
+ <span class="text-gray-400">=></span>
1806
+ <input type="text"
1807
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
1808
+ placeholder="Value"
1809
+ onchange="updateHashPair('${containerId}', '${fieldId}', this, 'value')">
1810
+ <button type="button"
1811
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
1812
+ title="Expand editor"
1813
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
1814
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1815
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
1816
+ </svg>
1817
+ </button>
1818
+ <button type="button"
1819
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
1820
+ onclick="removeHashPair('${containerId}', this)">
1821
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1822
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
1823
+ </svg>
1824
+ Remove
1825
+ </button>
1826
+ `;
1827
+
1828
+ // Insert before the add button
1829
+ addButton.parentNode.insertBefore(newPair, addButton);
1830
+ };
1831
+
1832
+ window.removeHashPair = function (containerId, button) {
1833
+ const container = document.getElementById(containerId);
1834
+ if (!container) return;
1835
+
1836
+ const pairDiv = button.closest('.flex.items-center.space-x-2');
1837
+ if (pairDiv) {
1838
+ pairDiv.remove();
1839
+ // Update the hidden field after removal
1840
+ const fieldId = container.querySelector('input[type="hidden"]').id;
1841
+ updateHashField(containerId, fieldId);
1842
+ }
1843
+ };
1844
+
1845
+ window.updateHashPair = function (containerId, fieldId, input, type) {
1846
+ updateHashField(containerId, fieldId);
1847
+ };
1848
+
1849
+ function updateHashField(containerId, fieldId) {
1850
+ const container = document.getElementById(containerId);
1851
+ const hiddenField = document.getElementById(fieldId);
1852
+ if (!container || !hiddenField) return;
1853
+
1854
+ const pairs = container.querySelectorAll('.flex.items-center.space-x-2');
1855
+ const hashObj = {};
1856
+
1857
+ pairs.forEach(pair => {
1858
+ const inputs = pair.querySelectorAll('input[type="text"]');
1859
+ if (inputs.length === 2) {
1860
+ const key = inputs[0].value.trim();
1861
+ const value = inputs[1].value.trim();
1862
+ if (key !== '') {
1863
+ hashObj[key] = value;
1864
+ }
1865
+ }
1866
+ });
1867
+
1868
+ hiddenField.value = JSON.stringify(hashObj);
1869
+ }
1870
+
1871
+ // Array/List helper functions
1872
+ window.addArrayItem = function (containerId, fieldId) {
1873
+ const container = document.getElementById(containerId);
1874
+ if (!container) return;
1875
+
1876
+ const addButton = container.querySelector('button[onclick*="addArrayItem"]');
1877
+ if (!addButton) return;
1878
+
1879
+ const existingItems = container.querySelectorAll('.flex.items-center.space-x-2');
1880
+ const newIndex = existingItems.length;
1881
+
1882
+ const newItem = document.createElement('div');
1883
+ newItem.className = 'flex items-center space-x-2';
1884
+ newItem.innerHTML = `
1885
+ <input type="text"
1886
+ class="flex-1 min-w-0 p-2 bg-gray-700 border border-gray-600 rounded text-white"
1887
+ placeholder="Value"
1888
+ onchange="updateArrayItem('${containerId}', '${fieldId}', this, ${newIndex})">
1889
+ <button type="button"
1890
+ class="flex-shrink-0 p-1.5 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
1891
+ title="Expand editor"
1892
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
1893
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1894
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
1895
+ </svg>
1896
+ </button>
1897
+ <button type="button"
1898
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
1899
+ onclick="removeArrayItem('${containerId}', this)">
1900
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1901
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
1902
+ </svg>
1903
+ Remove
1904
+ </button>
1905
+ `;
1906
+
1907
+ // Insert before the add button
1908
+ addButton.parentNode.insertBefore(newItem, addButton);
1909
+ };
1910
+
1911
+ window.removeArrayItem = function (containerId, button) {
1912
+ const container = document.getElementById(containerId);
1913
+ if (!container) return;
1914
+
1915
+ const itemDiv = button.closest('.flex.items-center.space-x-2');
1916
+ if (itemDiv) {
1917
+ itemDiv.remove();
1918
+ // Update the hidden field after removal
1919
+ const fieldId = container.querySelector('input[type="hidden"]').id;
1920
+ updateArrayField(containerId, fieldId);
1921
+ }
1922
+ };
1923
+
1924
+ window.updateArrayItem = function (containerId, fieldId, input, index) {
1925
+ updateArrayField(containerId, fieldId);
1926
+ };
1927
+
1928
+ function updateArrayField(containerId, fieldId) {
1929
+ const container = document.getElementById(containerId);
1930
+ const hiddenField = document.getElementById(fieldId);
1931
+ if (!container || !hiddenField) return;
1932
+
1933
+ const items = container.querySelectorAll('.flex.items-center.space-x-2');
1934
+ const arrayValues = [];
1935
+
1936
+ items.forEach(item => {
1937
+ const input = item.querySelector('input[type="text"]');
1938
+ if (input) {
1939
+ const value = input.value.trim();
1940
+ if (value !== '') {
1941
+ arrayValues.push(value);
1942
+ }
1943
+ }
1944
+ });
1945
+
1946
+ hiddenField.value = JSON.stringify(arrayValues);
1947
+ }
1948
+
1949
+ // Array of Hashes helper functions
1950
+ window.addArrayOfHashesItem = function (containerId, fieldId) {
1951
+ const container = document.getElementById(containerId);
1952
+ if (!container) return;
1953
+
1954
+ const addButton = container.querySelector('button[onclick*="addArrayOfHashesItem"]');
1955
+ if (!addButton) return;
1956
+
1957
+ // Get hash options from container data attribute
1958
+ const hashOptionsJson = container.dataset.hashOptions;
1959
+ let hashOptions = {};
1960
+ try {
1961
+ hashOptions = JSON.parse(hashOptionsJson);
1962
+ } catch (e) {
1963
+ console.error('Error parsing hash options:', e);
1964
+ return;
1965
+ }
1966
+
1967
+ // Remove the "no entries" placeholder if it exists (but not actual entries)
1968
+ // The placeholder doesn't have a data-entry-id attribute
1969
+ const allDivs = container.querySelectorAll('.bg-gray-900\\/50, [class*="bg-gray-900/50"]');
1970
+ allDivs.forEach(div => {
1971
+ if (!div.dataset.entryId && div.textContent.includes('No entries yet')) {
1972
+ div.remove();
1973
+ }
1974
+ });
1975
+
1976
+ // Create unique ID for this hash entry
1977
+ const entryId = `hash-entry-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
1978
+
1979
+ // Build the hash entry with fields based on options
1980
+ const entryDiv = document.createElement('div');
1981
+ entryDiv.className = 'p-3 bg-gray-900/50 border border-gray-600 rounded space-y-2';
1982
+ entryDiv.dataset.entryId = entryId;
1983
+
1984
+ let fieldsHtml = '';
1985
+ for (const [optKey, optInfo] of Object.entries(hashOptions)) {
1986
+ const optType = (optInfo.type || 'string').toLowerCase();
1987
+ const inputClass = 'w-full p-2 bg-gray-700 border border-gray-600 rounded text-white text-sm';
1988
+
1989
+ let inputHtml = '';
1990
+ if (optType === 'number') {
1991
+ inputHtml = `<input type="number" class="${inputClass}" placeholder="${optKey}" data-field="${optKey}" onchange="updateArrayOfHashesField('${containerId}', '${fieldId}')">`;
1992
+ } else if (optType === 'boolean') {
1993
+ inputHtml = `
1994
+ <select class="${inputClass}" data-field="${optKey}" onchange="updateArrayOfHashesField('${containerId}', '${fieldId}')">
1995
+ <option value="">-- Not Set --</option>
1996
+ <option value="true">true</option>
1997
+ <option value="false">false</option>
1998
+ </select>
1999
+ `;
2000
+ } else {
2001
+ inputHtml = `<input type="text" class="${inputClass}" placeholder="${optKey}" data-field="${optKey}" onchange="updateArrayOfHashesField('${containerId}', '${fieldId}')">`;
2002
+ }
2003
+
2004
+ fieldsHtml += `
2005
+ <div>
2006
+ <label class="block text-xs font-medium text-gray-300 mb-1">${optKey}</label>
2007
+ ${inputHtml}
2008
+ </div>
2009
+ `;
2010
+ }
2011
+
2012
+ entryDiv.innerHTML = `
2013
+ ${fieldsHtml}
2014
+ <button type="button"
2015
+ class="mt-2 px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 text-sm w-full"
2016
+ onclick="removeArrayOfHashesItem('${containerId}', '${fieldId}', this)">
2017
+ Remove Entry
2018
+ </button>
2019
+ `;
2020
+
2021
+ // Insert before the add button
2022
+ addButton.parentNode.insertBefore(entryDiv, addButton);
2023
+
2024
+ // Update the hidden field
2025
+ updateArrayOfHashesField(containerId, fieldId);
2026
+ };
2027
+
2028
+ window.removeArrayOfHashesItem = function (containerId, fieldId, button) {
2029
+ const container = document.getElementById(containerId);
2030
+ if (!container) return;
2031
+
2032
+ const entryDiv = button.closest('[data-entry-id]');
2033
+ if (entryDiv) {
2034
+ entryDiv.remove();
2035
+
2036
+ // Check if there are any entries left
2037
+ const remainingEntries = container.querySelectorAll('[data-entry-id]');
2038
+ if (remainingEntries.length === 0) {
2039
+ // Add back the placeholder
2040
+ const addButton = container.querySelector('button[onclick*="addArrayOfHashesItem"]');
2041
+ if (addButton) {
2042
+ const placeholder = document.createElement('div');
2043
+ placeholder.className = 'p-3 bg-gray-900/50 border border-gray-600 rounded';
2044
+ placeholder.innerHTML = '<div class="text-xs text-gray-400 mb-2">No entries yet. Click "+ Add Entry" to add one.</div>';
2045
+ addButton.parentNode.insertBefore(placeholder, addButton);
2046
+ }
2047
+ }
2048
+
2049
+ // Update the hidden field
2050
+ updateArrayOfHashesField(containerId, fieldId);
2051
+ }
2052
+ };
2053
+
2054
+ window.updateArrayOfHashesField = function (containerId, fieldId) {
2055
+ const container = document.getElementById(containerId);
2056
+ const hiddenField = document.getElementById(fieldId);
2057
+ if (!container || !hiddenField) return;
2058
+
2059
+ const entries = container.querySelectorAll('[data-entry-id]');
2060
+ const arrayValue = [];
2061
+
2062
+ entries.forEach(entry => {
2063
+ const hashObj = {};
2064
+ const inputs = entry.querySelectorAll('[data-field]');
2065
+
2066
+ inputs.forEach(input => {
2067
+ const fieldName = input.dataset.field;
2068
+ let value = input.value.trim();
2069
+
2070
+ if (value !== '') {
2071
+ // Convert boolean strings to actual booleans
2072
+ if (value === 'true') value = true;
2073
+ else if (value === 'false') value = false;
2074
+ // Convert numbers
2075
+ else if (input.type === 'number' && !isNaN(value)) value = Number(value);
2076
+
2077
+ hashObj[fieldName] = value;
2078
+ }
2079
+ });
2080
+
2081
+ // Only add the hash if it has at least one field
2082
+ if (Object.keys(hashObj).length > 0) {
2083
+ arrayValue.push(hashObj);
2084
+ }
2085
+ });
2086
+
2087
+ hiddenField.value = JSON.stringify(arrayValue);
2088
+ };
2089
+
2090
+ // Populate existing array_of_hashes values
2091
+ function populateArrayOfHashesValues(component) {
2092
+ const configForm = document.getElementById('configForm');
2093
+ if (!configForm) return;
2094
+
2095
+ // Find all array-hash containers and populate them
2096
+ configForm.querySelectorAll('[id^="array-hash-container-"]').forEach(container => {
2097
+ const hiddenField = container.querySelector('input[type="hidden"]');
2098
+ if (!hiddenField) return;
2099
+
2100
+ try {
2101
+ const arrayValue = JSON.parse(hiddenField.value);
2102
+
2103
+ if (Array.isArray(arrayValue) && arrayValue.length > 0) {
2104
+ // Remove the placeholder (but not actual entries)
2105
+ const allDivs = container.querySelectorAll('.bg-gray-900\\/50, [class*="bg-gray-900/50"]');
2106
+ allDivs.forEach(div => {
2107
+ if (!div.dataset.entryId && div.textContent.includes('No entries yet')) {
2108
+ div.remove();
2109
+ }
2110
+ });
2111
+
2112
+ // Get hash options
2113
+ const hashOptionsJson = container.dataset.hashOptions;
2114
+ let hashOptions = {};
2115
+ try {
2116
+ hashOptions = JSON.parse(hashOptionsJson);
2117
+ } catch (e) {
2118
+ console.error('Error parsing hash options:', e);
2119
+ return;
2120
+ }
2121
+
2122
+ // Add all existing entries
2123
+ const addButton = container.querySelector('button[onclick*="addArrayOfHashesItem"]');
2124
+ arrayValue.forEach((hashObj, index) => {
2125
+ const entryId = `hash-entry-${Date.now()}-${index}`;
2126
+ const entryDiv = document.createElement('div');
2127
+ entryDiv.className = 'p-3 bg-gray-900/50 border border-gray-600 rounded space-y-2';
2128
+ entryDiv.dataset.entryId = entryId;
2129
+
2130
+ let fieldsHtml = '';
2131
+ for (const [optKey, optInfo] of Object.entries(hashOptions)) {
2132
+ const optType = (optInfo.type || 'string').toLowerCase();
2133
+ const inputClass = 'w-full p-2 bg-gray-700 border border-gray-600 rounded text-white text-sm';
2134
+ const existingValue = hashObj[optKey] || '';
2135
+
2136
+ let inputHtml = '';
2137
+ if (optType === 'number') {
2138
+ inputHtml = `<input type="number" class="${inputClass}" placeholder="${optKey}" data-field="${optKey}" value="${existingValue}" onchange="updateArrayOfHashesField('${container.id}', '${hiddenField.id}')">`;
2139
+ } else if (optType === 'boolean') {
2140
+ inputHtml = `
2141
+ <select class="${inputClass}" data-field="${optKey}" onchange="updateArrayOfHashesField('${container.id}', '${hiddenField.id}')">
2142
+ <option value="">-- Not Set --</option>
2143
+ <option value="true" ${existingValue === true || existingValue === 'true' ? 'selected' : ''}>true</option>
2144
+ <option value="false" ${existingValue === false || existingValue === 'false' ? 'selected' : ''}>false</option>
2145
+ </select>
2146
+ `;
2147
+ } else {
2148
+ const escapedValue = String(existingValue).replace(/\\/g, '\\\\').replace(/"/g, '&quot;');
2149
+ inputHtml = `<input type="text" class="${inputClass}" placeholder="${optKey}" data-field="${optKey}" value="${escapedValue}" onchange="updateArrayOfHashesField('${container.id}', '${hiddenField.id}')">`;
2150
+ }
2151
+
2152
+ fieldsHtml += `
2153
+ <div>
2154
+ <label class="block text-xs font-medium text-gray-300 mb-1">${optKey}</label>
2155
+ ${inputHtml}
2156
+ </div>
2157
+ `;
2158
+ }
2159
+
2160
+ entryDiv.innerHTML = `
2161
+ ${fieldsHtml}
2162
+ <button type="button"
2163
+ class="mt-2 px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 text-sm w-full"
2164
+ onclick="removeArrayOfHashesItem('${container.id}', '${hiddenField.id}', this)">
2165
+ Remove Entry
2166
+ </button>
2167
+ `;
2168
+
2169
+ addButton.parentNode.insertBefore(entryDiv, addButton);
2170
+ });
2171
+ }
2172
+ } catch (e) {
2173
+ console.error('Error populating array_of_hashes values:', e);
2174
+ }
2175
+ });
2176
+ }
2177
+
2178
+ // Key List Hash helper functions (for fields like grok match)
2179
+ window.addKeyListHashSection = function (containerId, fieldId) {
2180
+ const container = document.getElementById(containerId);
2181
+ if (!container) return;
2182
+
2183
+ const addButton = container.querySelector('button[onclick*="addKeyListHashSection"]');
2184
+ if (!addButton) return;
2185
+
2186
+ // Create unique ID for this section
2187
+ const sectionId = `key-list-hash-section-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
2188
+
2189
+ const sectionDiv = document.createElement('div');
2190
+ sectionDiv.className = 'p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-3';
2191
+ sectionDiv.dataset.sectionId = sectionId;
2192
+
2193
+ sectionDiv.innerHTML = `
2194
+ <div class="flex items-center gap-2">
2195
+ <input type="text"
2196
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm section-key focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
2197
+ placeholder="Key (e.g., message, field1)"
2198
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
2199
+ <button type="button"
2200
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
2201
+ onclick="removeKeyListHashSection('${containerId}', '${fieldId}', this)">
2202
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2203
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
2204
+ </svg>
2205
+ Remove Section
2206
+ </button>
2207
+ </div>
2208
+ <div class="ml-4 space-y-2 section-values">
2209
+ <div class="flex items-center gap-2">
2210
+ <span class="text-gray-400 text-sm">=></span>
2211
+ <input type="text"
2212
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
2213
+ placeholder="Value (e.g., pattern1)"
2214
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
2215
+ <button type="button"
2216
+ class="flex-shrink-0 p-1 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
2217
+ title="Expand editor"
2218
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
2219
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2220
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
2221
+ </svg>
2222
+ </button>
2223
+ <button type="button"
2224
+ class="px-3 py-1 text-red-400 hover:bg-gray-700 rounded text-xs transition-colors flex items-center gap-1"
2225
+ onclick="removeKeyListHashValue('${containerId}', '${fieldId}', this)">
2226
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2227
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
2228
+ </svg>
2229
+ Remove
2230
+ </button>
2231
+ </div>
2232
+ </div>
2233
+ <button type="button"
2234
+ class="ml-4 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-xs transition-colors"
2235
+ onclick="addKeyListHashValue('${containerId}', '${fieldId}', this)">
2236
+ + Add Value
2237
+ </button>
2238
+ `;
2239
+
2240
+ addButton.parentNode.insertBefore(sectionDiv, addButton);
2241
+ updateKeyListHashField(containerId, fieldId);
2242
+ };
2243
+
2244
+ window.removeKeyListHashSection = function (containerId, fieldId, button) {
2245
+ const container = document.getElementById(containerId);
2246
+ if (!container) return;
2247
+
2248
+ const sectionDiv = button.closest('[data-section-id]');
2249
+ if (sectionDiv) {
2250
+ // Check if there are any sections left
2251
+ const remainingSections = container.querySelectorAll('[data-section-id]');
2252
+
2253
+ // Only remove if there's more than one section (keep at least one)
2254
+ if (remainingSections.length > 1) {
2255
+ sectionDiv.remove();
2256
+ updateKeyListHashField(containerId, fieldId);
2257
+ } else {
2258
+ // Clear the inputs instead of removing the last section
2259
+ const keyInput = sectionDiv.querySelector('.section-key');
2260
+ const valueInputs = sectionDiv.querySelectorAll('.section-values input[type="text"]');
2261
+
2262
+ if (keyInput) keyInput.value = '';
2263
+ valueInputs.forEach(input => input.value = '');
2264
+
2265
+ updateKeyListHashField(containerId, fieldId);
2266
+ }
2267
+ }
2268
+ };
2269
+
2270
+ window.addKeyListHashValue = function (containerId, fieldId, button) {
2271
+ const sectionDiv = button.closest('[data-section-id]');
2272
+ if (!sectionDiv) return;
2273
+
2274
+ const valuesContainer = sectionDiv.querySelector('.section-values');
2275
+ if (!valuesContainer) return;
2276
+
2277
+ const newValue = document.createElement('div');
2278
+ newValue.className = 'flex items-center gap-2';
2279
+ newValue.innerHTML = `
2280
+ <span class="text-gray-400 text-sm">=></span>
2281
+ <input type="text"
2282
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
2283
+ placeholder="Value"
2284
+ onchange="updateKeyListHashField('${containerId}', '${fieldId}')">
2285
+ <button type="button"
2286
+ class="flex-shrink-0 p-1 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
2287
+ title="Expand editor"
2288
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
2289
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2290
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
2291
+ </svg>
2292
+ </button>
2293
+ <button type="button"
2294
+ class="px-3 py-1 text-red-400 hover:bg-gray-700 rounded text-xs transition-colors flex items-center gap-1"
2295
+ onclick="removeKeyListHashValue('${containerId}', '${fieldId}', this)">
2296
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2297
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
2298
+ </svg>
2299
+ Remove
2300
+ </button>
2301
+ `;
2302
+
2303
+ valuesContainer.appendChild(newValue);
2304
+ updateKeyListHashField(containerId, fieldId);
2305
+ };
2306
+
2307
+ window.removeKeyListHashValue = function (containerId, fieldId, button) {
2308
+ const valueDiv = button.closest('.flex.items-center.gap-2');
2309
+ if (valueDiv) {
2310
+ valueDiv.remove();
2311
+ updateKeyListHashField(containerId, fieldId);
2312
+ }
2313
+ };
2314
+
2315
+ window.updateKeyListHashField = function (containerId, fieldId) {
2316
+ const container = document.getElementById(containerId);
2317
+ const hiddenField = document.getElementById(fieldId);
2318
+ if (!container || !hiddenField) return;
2319
+
2320
+ const sections = container.querySelectorAll('[data-section-id]');
2321
+ const result = {};
2322
+
2323
+ sections.forEach(section => {
2324
+ const keyInput = section.querySelector('.section-key');
2325
+ if (!keyInput) return;
2326
+
2327
+ const key = keyInput.value.trim();
2328
+ if (!key) return;
2329
+
2330
+ const valueInputs = section.querySelectorAll('.section-values input[type="text"]');
2331
+ const values = [];
2332
+
2333
+ valueInputs.forEach(input => {
2334
+ const value = input.value.trim();
2335
+ if (value) {
2336
+ values.push(value);
2337
+ }
2338
+ });
2339
+
2340
+ // Store as single value if only one, or array if multiple
2341
+ if (values.length === 1) {
2342
+ result[key] = values[0];
2343
+ } else if (values.length > 1) {
2344
+ result[key] = values;
2345
+ }
2346
+ });
2347
+
2348
+ hiddenField.value = JSON.stringify(result);
2349
+ };
2350
+
2351
+ // Populate existing key_list_hash values
2352
+ function populateKeyListHashValues(component) {
2353
+ const configForm = document.getElementById('configForm');
2354
+ if (!configForm) return;
2355
+
2356
+ configForm.querySelectorAll('[id^="key-list-hash-container-"]').forEach(container => {
2357
+ const hiddenField = container.querySelector('input[type="hidden"]');
2358
+ if (!hiddenField) return;
2359
+
2360
+ try {
2361
+ const keyListHashValue = JSON.parse(hiddenField.value);
2362
+ const entries = Object.entries(keyListHashValue);
2363
+
2364
+ if (entries.length > 0) {
2365
+ // Remove the default empty section first
2366
+ const defaultSection = container.querySelector('[data-section-id]');
2367
+ if (defaultSection) {
2368
+ const keyInput = defaultSection.querySelector('.section-key');
2369
+ if (keyInput && !keyInput.value) {
2370
+ defaultSection.remove();
2371
+ }
2372
+ }
2373
+
2374
+ const addButton = container.querySelector('button[onclick*="addKeyListHashSection"]');
2375
+
2376
+ entries.forEach(([key, value]) => {
2377
+ const sectionId = `key-list-hash-section-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
2378
+ const sectionDiv = document.createElement('div');
2379
+ sectionDiv.className = 'p-3 bg-gray-800/30 border border-gray-600/50 rounded space-y-3';
2380
+ sectionDiv.dataset.sectionId = sectionId;
2381
+
2382
+ // Normalize value to array
2383
+ const values = Array.isArray(value) ? value : [value];
2384
+
2385
+ let valuesHtml = '';
2386
+ values.forEach(val => {
2387
+ valuesHtml += `
2388
+ <div class="flex items-center gap-2">
2389
+ <span class="text-gray-400 text-sm">=></span>
2390
+ <input type="text"
2391
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
2392
+ placeholder="Value"
2393
+ value="${String(val).replace(/\\/g, '\\\\').replace(/"/g, '&quot;')}"
2394
+ onchange="updateKeyListHashField('${container.id}', '${hiddenField.id}')">
2395
+ <button type="button"
2396
+ class="flex-shrink-0 p-1 text-gray-500 hover:text-gray-200 hover:bg-gray-600/50 rounded transition-colors"
2397
+ title="Expand editor"
2398
+ onclick="ExpandedValueEditor.open(this.previousElementSibling)">
2399
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2400
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
2401
+ </svg>
2402
+ </button>
2403
+ <button type="button"
2404
+ class="px-3 py-1 text-red-400 hover:bg-gray-700 rounded text-xs transition-colors flex items-center gap-1"
2405
+ onclick="removeKeyListHashValue('${container.id}', '${hiddenField.id}', this)">
2406
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2407
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
2408
+ </svg>
2409
+ Remove
2410
+ </button>
2411
+ </div>
2412
+ `;
2413
+ });
2414
+
2415
+ sectionDiv.innerHTML = `
2416
+ <div class="flex items-center gap-2">
2417
+ <input type="text"
2418
+ class="flex-1 p-2 bg-gray-700/50 border border-gray-600/50 rounded text-white text-sm section-key focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50"
2419
+ placeholder="Key (e.g., message, field1)"
2420
+ value="${String(key).replace(/\\/g, '\\\\').replace(/"/g, '&quot;')}"
2421
+ onchange="updateKeyListHashField('${container.id}', '${hiddenField.id}')">
2422
+ <button type="button"
2423
+ class="px-3 py-2 text-red-400 hover:bg-gray-700 rounded text-sm transition-colors flex items-center gap-1"
2424
+ onclick="removeKeyListHashSection('${container.id}', '${hiddenField.id}', this)">
2425
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2426
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
2427
+ </svg>
2428
+ Remove Section
2429
+ </button>
2430
+ </div>
2431
+ <div class="ml-4 space-y-2 section-values">
2432
+ ${valuesHtml}
2433
+ </div>
2434
+ <button type="button"
2435
+ class="ml-4 px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-xs transition-colors"
2436
+ onclick="addKeyListHashValue('${container.id}', '${hiddenField.id}', this)">
2437
+ + Add Value
2438
+ </button>
2439
+ `;
2440
+
2441
+ addButton.parentNode.insertBefore(sectionDiv, addButton);
2442
+ });
2443
+ }
2444
+ } catch (e) {
2445
+ console.error('Error populating key_list_hash values:', e);
2446
+ }
2447
+ });
2448
+ }
2449
+
2450
+ // Codec helper functions
2451
+ const CODEC_INPUT_CLASSES = 'w-full p-2 bg-gray-700 border border-gray-600 rounded text-white text-sm';
2452
+
2453
+ function codecWidgetType(optInfo) {
2454
+ const t = (optInfo.input_type || 'string').toLowerCase();
2455
+ if (t.includes('boolean') || t === 'bool') return 'boolean';
2456
+ if (t === 'dropdown') return 'dropdown';
2457
+ if (t.includes('number') || t === 'int' || t === 'float') return 'number';
2458
+ if (t === 'password') return 'password';
2459
+ if (t.includes('hash')) return 'hash';
2460
+ if (t.includes('array') || t === 'list') return 'array';
2461
+ return 'string';
2462
+ }
2463
+
2464
+ // Keeps values the list doesn't know about (e.g. "${ECS_MODE}") selected instead of dropping them
2465
+ function codecSelectOptions(choices, value) {
2466
+ const current = value === undefined || value === null ? '' : String(value);
2467
+ const known = choices.map(String);
2468
+ const custom = current !== '' && !known.includes(current)
2469
+ ? `<option value="${escapeHtml(current)}" selected>${escapeHtml(current)}</option>` : '';
2470
+ return `<option value="">-- Not Set --</option>${custom}` + known.map(c =>
2471
+ `<option value="${escapeHtml(c)}" ${c === current ? 'selected' : ''}>${escapeHtml(c)}</option>`).join('');
2472
+ }
2473
+
2474
+ function codecRowHtml(codecName, optKey, kind, key = '', value = '') {
2475
+ const attrs = `data-codec-name="${escapeHtml(codecName)}" data-codec-option="${escapeHtml(optKey)}"`;
2476
+ const keyInput = kind === 'hash'
2477
+ ? `<input type="text" class="${CODEC_INPUT_CLASSES} flex-1 min-w-0" placeholder="Key" data-codec-part="key" ${attrs} value="${escapeHtml(key)}">
2478
+ <span class="text-gray-400">=></span>` : '';
2479
+ return `
2480
+ <div class="flex items-center gap-2" data-codec-row>
2481
+ ${keyInput}
2482
+ <input type="text" class="${CODEC_INPUT_CLASSES} flex-1 min-w-0" placeholder="Value" data-codec-part="value" ${attrs} value="${escapeHtml(value)}">
2483
+ <button type="button" data-codec-action="remove-row" class="px-2 py-1 text-red-400 hover:bg-gray-700 rounded text-xs">Remove</button>
2484
+ </div>`;
2485
+ }
2486
+
2487
+ function codecWidgetHtml(codecName, optKey, optInfo, value, inputId) {
2488
+ const type = codecWidgetType(optInfo);
2489
+ const attrs = `data-codec-name="${escapeHtml(codecName)}" data-codec-option="${escapeHtml(optKey)}"`;
2490
+ const text = value === undefined || value === null || typeof value === 'object' ? '' : String(value);
2491
+ let inner;
2492
+
2493
+ if (type === 'boolean' || type === 'dropdown') {
2494
+ const choices = type === 'boolean' ? ['true', 'false'] : (optInfo.options || []);
2495
+ inner = `<select id="${inputId}" class="${CODEC_INPUT_CLASSES}" ${attrs}>${codecSelectOptions(choices, value)}</select>`;
2496
+ } else if (type === 'hash' || type === 'array') {
2497
+ let rows;
2498
+ if (type === 'hash') {
2499
+ const entries = value && typeof value === 'object' && !Array.isArray(value) ? Object.entries(value) : [];
2500
+ rows = (entries.length ? entries : [['', '']]).map(([k, v]) => codecRowHtml(codecName, optKey, 'hash', k, v ?? '')).join('');
2501
+ } else {
2502
+ const items = Array.isArray(value) ? value : (text !== '' ? [text] : []);
2503
+ rows = (items.length ? items : ['']).map(v => codecRowHtml(codecName, optKey, 'array', '', v ?? '')).join('');
2504
+ }
2505
+ inner = `
2506
+ <div class="space-y-2" data-codec-rows>${rows}</div>
2507
+ <button type="button" data-codec-action="add-row" class="mt-2 px-2 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-xs">+ Add More</button>`;
2508
+ } else {
2509
+ const inputType = type === 'password' ? 'password' : 'text';
2510
+ const inputMode = type === 'number' ? 'inputmode="decimal"' : '';
2511
+ inner = `<input type="${inputType}" id="${inputId}" class="${CODEC_INPUT_CLASSES}" ${inputMode} ${attrs} value="${escapeHtml(text)}">`;
2512
+ }
2513
+
2514
+ return `<div data-codec-widget data-codec-option="${escapeHtml(optKey)}" data-codec-type="${type}">${inner}</div>`;
2515
+ }
2516
+
2517
+ /**
2518
+ * Reads a codec option widget back into a config value using the option's declared type.
2519
+ *
2520
+ * Returns:
2521
+ * The value to store, or undefined to remove the option.
2522
+ *
2523
+ * Example:
2524
+ * number widget "1.50" -> 1.5, string widget "1.0" -> "1.0",
2525
+ * array rows ["5", "9"] -> [5, 9], array rows ["007"] -> ["007"]
2526
+ */
2527
+ function readCodecWidget(widget) {
2528
+ const type = widget.dataset.codecType;
2529
+ const isDecimal = s => /^-?\d+(\.\d+)?$/.test(s);
2530
+ const isNumberLiteral = s => isDecimal(s) && String(Number(s)) === s;
2531
+
2532
+ if (type === 'hash') {
2533
+ const result = {};
2534
+ widget.querySelectorAll('[data-codec-row]').forEach(row => {
2535
+ const key = row.querySelector('[data-codec-part="key"]').value.trim();
2536
+ if (key) result[key] = row.querySelector('[data-codec-part="value"]').value;
2537
+ });
2538
+ return Object.keys(result).length ? result : undefined;
2539
+ }
2540
+ if (type === 'array') {
2541
+ const items = [...widget.querySelectorAll('[data-codec-part="value"]')]
2542
+ .map(input => input.value.trim())
2543
+ .filter(v => v !== '')
2544
+ .map(v => (isNumberLiteral(v) ? Number(v) : v));
2545
+ return items.length ? items : undefined;
2546
+ }
2547
+
2548
+ const raw = widget.querySelector('input, select').value;
2549
+ if (raw === '') return undefined;
2550
+ if (type === 'boolean' && (raw === 'true' || raw === 'false')) return raw === 'true';
2551
+ if (type === 'number' && isDecimal(raw.trim())) return Number(raw.trim());
2552
+ return raw;
2553
+ }
2554
+
2555
+ function updateCodecOption(widget, hiddenField, codecName) {
2556
+ let current = {};
2557
+ try {
2558
+ current = JSON.parse(hiddenField.value) || {};
2559
+ } catch (e) {
2560
+ console.error('Error parsing codec value:', e);
2561
+ }
2562
+ const config = current[codecName] || {};
2563
+ const value = readCodecWidget(widget);
2564
+ if (value === undefined) {
2565
+ delete config[widget.dataset.codecOption];
2566
+ } else {
2567
+ config[widget.dataset.codecOption] = value;
2568
+ }
2569
+ hiddenField.value = JSON.stringify({ [codecName]: config });
2570
+ }
2571
+
2572
+ window.handleCodecChange = function (containerId, fieldId, codecName) {
2573
+ const container = document.getElementById(containerId);
2574
+ const hiddenField = document.getElementById(fieldId);
2575
+ if (!container || !hiddenField) return;
2576
+
2577
+ const codecConfigContainer = container.querySelector('[id^="codec-config-"]');
2578
+ if (!codecConfigContainer) return;
2579
+ codecConfigContainer.innerHTML = '';
2580
+
2581
+ if (!codecName) {
2582
+ hiddenField.value = JSON.stringify({});
2583
+ return;
2584
+ }
2585
+
2586
+ const codecInfo = window.PluginConfigModal.getPluginData().codec?.[codecName];
2587
+
2588
+ let existingConfig = {};
2589
+ try {
2590
+ existingConfig = JSON.parse(hiddenField.value)[codecName] || {};
2591
+ } catch (e) {
2592
+ console.error('Error parsing codec value:', e);
2593
+ }
2594
+ hiddenField.value = JSON.stringify({ [codecName]: existingConfig });
2595
+
2596
+ if (!codecInfo || !codecInfo.options) return;
2597
+
2598
+ if (codecInfo.description) {
2599
+ const desc = document.createElement('p');
2600
+ desc.className = 'text-xs text-gray-400 mb-2 italic';
2601
+ desc.textContent = codecInfo.description;
2602
+ codecConfigContainer.appendChild(desc);
2603
+ }
2604
+
2605
+ Object.entries(codecInfo.options).forEach(([optKey, optInfo]) => {
2606
+ const inputId = `codec-field-${codecName}-${optKey}-${Date.now()}`;
2607
+ const fieldDiv = document.createElement('div');
2608
+ fieldDiv.className = 'mb-3';
2609
+ fieldDiv.innerHTML = `
2610
+ <label for="${inputId}" class="block text-xs font-medium text-gray-300 mb-1">
2611
+ ${escapeHtml(optKey)}
2612
+ <span class="text-xs font-normal text-gray-400">
2613
+ (Required: ${escapeHtml(optInfo.required || 'No')}, Type: ${escapeHtml(optInfo.input_type || 'string')})
2614
+ </span>
2615
+ </label>
2616
+ ${optInfo.description ? `<p class="text-xs text-gray-400 mb-1">${optInfo.description}</p>` : ''}
2617
+ ${codecWidgetHtml(codecName, optKey, optInfo, existingConfig[optKey], inputId)}
2618
+ `;
2619
+ codecConfigContainer.appendChild(fieldDiv);
2620
+ });
2621
+
2622
+ if (codecConfigContainer.dataset.codecBound) return;
2623
+ codecConfigContainer.dataset.codecBound = 'true';
2624
+
2625
+ const onEdit = (e) => {
2626
+ const widget = e.target.closest('[data-codec-widget]');
2627
+ const name = container.querySelector('select[id^="codec-select-"]')?.value;
2628
+ if (widget && name) updateCodecOption(widget, hiddenField, name);
2629
+ };
2630
+ codecConfigContainer.addEventListener('input', onEdit);
2631
+ codecConfigContainer.addEventListener('change', onEdit);
2632
+ codecConfigContainer.addEventListener('click', (e) => {
2633
+ const button = e.target.closest('[data-codec-action]');
2634
+ if (!button) return;
2635
+ const widget = button.closest('[data-codec-widget]');
2636
+ const rows = widget.querySelector('[data-codec-rows]');
2637
+ const name = container.querySelector('select[id^="codec-select-"]')?.value;
2638
+ if (button.dataset.codecAction === 'add-row') {
2639
+ const kind = widget.dataset.codecType === 'hash' ? 'hash' : 'array';
2640
+ rows.insertAdjacentHTML('beforeend', codecRowHtml(name, widget.dataset.codecOption, kind));
2641
+ } else {
2642
+ button.closest('[data-codec-row]').remove();
2643
+ if (!rows.querySelector('[data-codec-row]')) {
2644
+ const kind = widget.dataset.codecType === 'hash' ? 'hash' : 'array';
2645
+ rows.insertAdjacentHTML('beforeend', codecRowHtml(name, widget.dataset.codecOption, kind));
2646
+ }
2647
+ }
2648
+ if (name) updateCodecOption(widget, hiddenField, name);
2649
+ });
2650
+ };
2651
+
2652
+ // Make it globally available
2653
+ window.PluginConfigModal = PluginConfigModal;
2654
+
2655
+ // Initialize when the document is ready
2656
+ function initializePluginConfigModal() {
2657
+ // No need to initialize here as we'll do it from pipeline_editor.html
2658
+ }
2659
+
2660
+ // Make sure the modal is available globally
2661
+ window.showConfigModal = function (component) {
2662
+ if (typeof PluginConfigModal !== 'undefined') {
2663
+ PluginConfigModal.show(component);
2664
+ }
2665
+ };
2666
+
2667
+ // Toggle password visibility function
2668
+ window.togglePasswordVisibility = function (fieldId, button) {
2669
+ const input = document.getElementById(fieldId);
2670
+ if (!input) return;
2671
+
2672
+ if (input.type === 'password') {
2673
+ input.type = 'text';
2674
+ // Change icon to eye-slash (password is now visible)
2675
+ button.innerHTML = `
2676
+ <svg class="w-5 h-5 eye-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2677
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
2678
+ </svg>
2679
+ `;
2680
+ } else {
2681
+ input.type = 'password';
2682
+ // Change icon back to eye (password is now hidden)
2683
+ button.innerHTML = `
2684
+ <svg class="w-5 h-5 eye-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2685
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
2686
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
2687
+ </svg>
2688
+ `;
2689
+ }
2690
+ };
2691
+
2692
+ // Browse file path function for fs_path input type
2693
+ window.browseFilePath = function (fieldId) {
2694
+ const targetInput = document.getElementById(fieldId);
2695
+ if (!targetInput) return;
2696
+
2697
+ // Create a hidden file input element
2698
+ const fileInput = document.createElement('input');
2699
+ fileInput.type = 'file';
2700
+ fileInput.style.display = 'none';
2701
+
2702
+ // Handle file selection
2703
+ fileInput.addEventListener('change', function (e) {
2704
+ if (e.target.files && e.target.files.length > 0) {
2705
+ const file = e.target.files[0];
2706
+ // Get the file path (webkitRelativePath or name)
2707
+ // Note: For security reasons, browsers don't expose the full file system path
2708
+ // We'll use the file name as a placeholder
2709
+ const filePath = file.webkitRelativePath || file.name;
2710
+ targetInput.value = filePath;
2711
+ }
2712
+ // Clean up the temporary file input
2713
+ document.body.removeChild(fileInput);
2714
+ });
2715
+
2716
+ // Add to DOM and trigger click
2717
+ document.body.appendChild(fileInput);
2718
+ fileInput.click();
2719
+ };
2720
+
2721
+ // Initialize when the DOM is ready
2722
+ if (document.readyState === 'loading') {
2723
+ document.addEventListener('DOMContentLoaded', initializePluginConfigModal);
2724
+ } else {
2725
+ initializePluginConfigModal();
2726
+ }
2727
+
2728
+ // ---------------------------------------------------------------------------
2729
+ // Expanded Value Editor
2730
+ // A universal focused overlay editor for any single text-input value.
2731
+ // Usage: ExpandedValueEditor.open(inputElement)
2732
+ // ---------------------------------------------------------------------------
2733
+ window.ExpandedValueEditor = (function () {
2734
+ let _target = null; // the original <input> element we are editing
2735
+ let _onKeydown = null; // bound keyboard handler so we can remove it
2736
+
2737
+ function _getContext(inputEl) {
2738
+ // Walk up to the field-group div that carries data-field-name / data-field-type
2739
+ const fieldGroup = inputEl.closest('[data-field-name]');
2740
+ const fieldName = fieldGroup ? fieldGroup.dataset.fieldName : '';
2741
+ const fieldType = fieldGroup ? fieldGroup.dataset.fieldType : '';
2742
+
2743
+ // Plugin name lives in the first <span> child of the modal <h3>
2744
+ const pluginNameEl = document.querySelector('#configModal h3 div > span:first-child');
2745
+ const pluginName = pluginNameEl ? pluginNameEl.textContent.trim() : '';
2746
+
2747
+ let parts = [];
2748
+ if (pluginName) parts.push('Plugin: ' + pluginName);
2749
+ if (fieldName) parts.push('Field: ' + fieldName);
2750
+ if (fieldType) parts.push('Type: ' + fieldType);
2751
+
2752
+ // For key_list_hash value inputs, include the section key if available
2753
+ const section = inputEl.closest('[data-section-id]');
2754
+ if (section) {
2755
+ const sectionKey = section.querySelector('.section-key');
2756
+ if (sectionKey && sectionKey.value.trim()) {
2757
+ parts.push('Key: ' + sectionKey.value.trim());
2758
+ }
2759
+ }
2760
+
2761
+ return parts.length ? parts.join(' · ') : 'value';
2762
+ }
2763
+
2764
+ function _updateCharCount() {
2765
+ const ta = document.getElementById('expandedValueEditorTextarea');
2766
+ const el = document.getElementById('expandedValueEditorCharCount');
2767
+ if (!ta || !el) return;
2768
+ const n = ta.value.length;
2769
+ el.textContent = n.toLocaleString() + ' character' + (n !== 1 ? 's' : '');
2770
+ }
2771
+
2772
+ function open(inputEl) {
2773
+ if (!inputEl) return;
2774
+ _target = inputEl;
2775
+
2776
+ const overlay = document.getElementById('expandedValueEditorOverlay');
2777
+ const textarea = document.getElementById('expandedValueEditorTextarea');
2778
+ const ctxEl = document.getElementById('expandedValueEditorContext');
2779
+ if (!overlay || !textarea) return;
2780
+
2781
+ textarea.value = inputEl.value;
2782
+ if (ctxEl) ctxEl.textContent = _getContext(inputEl);
2783
+ _updateCharCount();
2784
+
2785
+ overlay.classList.remove('hidden');
2786
+ textarea.focus();
2787
+ textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
2788
+
2789
+ textarea.addEventListener('input', _updateCharCount);
2790
+
2791
+ _onKeydown = function (e) {
2792
+ if (e.key === 'Escape') { e.stopPropagation(); cancel(); }
2793
+ if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { e.preventDefault(); apply(); }
2794
+ };
2795
+ // Use capture so Escape is caught before any parent modal handler
2796
+ document.addEventListener('keydown', _onKeydown, true);
2797
+ }
2798
+
2799
+ function cancel() {
2800
+ _close();
2801
+ }
2802
+
2803
+ function apply() {
2804
+ const textarea = document.getElementById('expandedValueEditorTextarea');
2805
+ if (_target && textarea) {
2806
+ _target.value = textarea.value;
2807
+ // Trigger both change and input so all update handlers (hash/array/keylisthash) fire
2808
+ _target.dispatchEvent(new Event('input', { bubbles: true }));
2809
+ _target.dispatchEvent(new Event('change', { bubbles: true }));
2810
+ }
2811
+ const returnTo = _target;
2812
+ _close();
2813
+ if (returnTo) returnTo.focus();
2814
+ }
2815
+
2816
+ function _close() {
2817
+ const overlay = document.getElementById('expandedValueEditorOverlay');
2818
+ const textarea = document.getElementById('expandedValueEditorTextarea');
2819
+ if (overlay) overlay.classList.add('hidden');
2820
+ if (textarea) textarea.removeEventListener('input', _updateCharCount);
2821
+ if (_onKeydown) document.removeEventListener('keydown', _onKeydown, true);
2822
+ _target = null;
2823
+ _onKeydown = null;
2824
+ }
2825
+
2826
+ return { open, cancel, apply };
2827
+ }());