sera-code 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE-SERA.md +33 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.md +68 -0
  5. package/bin/sera.mjs +145 -0
  6. package/dist/bundle/chunks/anthropic-messages-RD7GXOQL.js +6 -0
  7. package/dist/bundle/chunks/anthropic.js +75 -0
  8. package/dist/bundle/chunks/azure-openai-responses-CJT3KTVK.js +2 -0
  9. package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  10. package/dist/bundle/chunks/chunk-46WGNYIE.js +82 -0
  11. package/dist/bundle/chunks/chunk-4UNN5OGR.js +4 -0
  12. package/dist/bundle/chunks/chunk-53H5DPHA.js +16 -0
  13. package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  14. package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  15. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  16. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  17. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  18. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  19. package/dist/bundle/chunks/chunk-AZC5WTED.js +1222 -0
  20. package/dist/bundle/chunks/chunk-BPHHHEET.js +9 -0
  21. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
  22. package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  23. package/dist/bundle/chunks/chunk-EDSQGWII.js +44 -0
  24. package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  25. package/dist/bundle/chunks/chunk-HODJBMOY.js +9 -0
  26. package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
  27. package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
  28. package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  29. package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
  30. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  31. package/dist/bundle/chunks/chunk-LOMPDCMP.js +2 -0
  32. package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  33. package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  34. package/dist/bundle/chunks/chunk-M3LEVT3X.js +2 -0
  35. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  36. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  37. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  38. package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  39. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  40. package/dist/bundle/chunks/chunk-QTM7S6TH.js +2 -0
  41. package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  42. package/dist/bundle/chunks/chunk-TLNP2BSO.js +2 -0
  43. package/dist/bundle/chunks/chunk-TMKHGABX.js +2 -0
  44. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  45. package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  46. package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  47. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  48. package/dist/bundle/chunks/chunk-ZLAHUYDW.js +131 -0
  49. package/dist/bundle/chunks/chunk-ZNCN2NGY.js +60 -0
  50. package/dist/bundle/chunks/cli-MML2DU4A.js +51 -0
  51. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-QPZQRBK5.js +2 -0
  52. package/dist/bundle/chunks/codemode-worker.js +478 -0
  53. package/dist/bundle/chunks/dist-ZNZCJI7B.js +7 -0
  54. package/dist/bundle/chunks/easter-egg-3d-VOETWRJO.js +2 -0
  55. package/dist/bundle/chunks/execute-HXDNZ26B.js +505 -0
  56. package/dist/bundle/chunks/github-copilot.js +2 -0
  57. package/dist/bundle/chunks/google-generative-ai-SJXMIEPZ.js +2 -0
  58. package/dist/bundle/chunks/google-vertex-VSXQ3BDH.js +2 -0
  59. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  60. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  61. package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  62. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  63. package/dist/bundle/chunks/kimi-coding.js +2 -0
  64. package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  65. package/dist/bundle/chunks/llama-cpp-classify-4KFSGAMH.js +22 -0
  66. package/dist/bundle/chunks/meta.js +2 -0
  67. package/dist/bundle/chunks/mistral-conversations-JYWDZV2K.js +5 -0
  68. package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  69. package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  70. package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  71. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  72. package/dist/bundle/chunks/openai-codex-responses-OQV5DCFA.js +10 -0
  73. package/dist/bundle/chunks/openai-codex.js +75 -0
  74. package/dist/bundle/chunks/openai-completions-RFDJM2W5.js +7 -0
  75. package/dist/bundle/chunks/openai-decisions-O6PHBSCB.js +5 -0
  76. package/dist/bundle/chunks/openai-responses-LVNAPALQ.js +4 -0
  77. package/dist/bundle/chunks/openrouter-images-4WG6OOLH.js +2 -0
  78. package/dist/bundle/chunks/openrouter.js +75 -0
  79. package/dist/bundle/chunks/pdfjs-BETXZQ7A.js +108 -0
  80. package/dist/bundle/chunks/pdfjs-decoders-37HBPYHX.js +2 -0
  81. package/dist/bundle/chunks/pdfjs-jbig2-MH7WRXUP.js +2 -0
  82. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-UVK7AQLA.js +2 -0
  83. package/dist/bundle/chunks/pdfjs-openjpeg-TC2QHC4G.js +2 -0
  84. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-ZC2FTHCZ.js +3 -0
  85. package/dist/bundle/chunks/pi-messages-EZXKVRR6.js +8 -0
  86. package/dist/bundle/chunks/radius.js +75 -0
  87. package/dist/bundle/chunks/runtime-JAH75CB5.js +2 -0
  88. package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  89. package/dist/bundle/chunks/typesafe-system-one-X3JT6ECA.js +2 -0
  90. package/dist/bundle/chunks/virtual-modules-Z2V3PTLI.js +2 -0
  91. package/dist/bundle/chunks/xai.js +2 -0
  92. package/dist/bundle/cli-runtime.js +3 -0
  93. package/dist/bundle/cli.js +5 -0
  94. package/dist/bundle/index.js +2 -0
  95. package/dist/bundle/rpc-entry.js +3 -0
  96. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  97. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  98. package/dist/core/export-html/ansi-to-html.js +249 -0
  99. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  100. package/dist/core/export-html/index.d.ts +37 -0
  101. package/dist/core/export-html/index.d.ts.map +1 -0
  102. package/dist/core/export-html/index.js +228 -0
  103. package/dist/core/export-html/index.js.map +1 -0
  104. package/dist/core/export-html/template.css +1085 -0
  105. package/dist/core/export-html/template.html +56 -0
  106. package/dist/core/export-html/template.js +2044 -0
  107. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  108. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  109. package/dist/core/export-html/tool-renderer.js +110 -0
  110. package/dist/core/export-html/tool-renderer.js.map +1 -0
  111. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  112. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  113. package/dist/core/export-html/vendor/marked.min.js +79 -0
  114. package/dist/modes/interactive/assets/clankolas.png +0 -0
  115. package/dist/modes/interactive/theme/dark.json +81 -0
  116. package/dist/modes/interactive/theme/light.json +81 -0
  117. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  118. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  119. package/dist/modes/interactive/theme/system-theme.js +546 -0
  120. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  121. package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
  122. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  123. package/dist/modes/interactive/theme/theme-controller.js +210 -0
  124. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  125. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  126. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  127. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  128. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  129. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  130. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  131. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  132. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  133. package/dist/modes/interactive/theme/theme.d.ts +155 -0
  134. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  135. package/dist/modes/interactive/theme/theme.js +905 -0
  136. package/dist/modes/interactive/theme/theme.js.map +1 -0
  137. package/docs/cli-integration.md +106 -0
  138. package/docs/cli.md +333 -0
  139. package/docs/codemode.md +230 -0
  140. package/docs/compaction.md +463 -0
  141. package/docs/configuration.md +47 -0
  142. package/docs/containerization.md +183 -0
  143. package/docs/custom-provider.md +227 -0
  144. package/docs/docs.json +220 -0
  145. package/docs/environment-variables.md +102 -0
  146. package/docs/extensions.md +400 -0
  147. package/docs/how-pi-works.md +49 -0
  148. package/docs/index.md +39 -0
  149. package/docs/json.md +226 -0
  150. package/docs/keybindings.md +195 -0
  151. package/docs/llama-cpp.md +121 -0
  152. package/docs/mcp.md +272 -0
  153. package/docs/message-types.md +279 -0
  154. package/docs/models-configuration.md +196 -0
  155. package/docs/models.md +225 -0
  156. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  157. package/docs/packages.md +131 -0
  158. package/docs/prompt-templates.md +59 -0
  159. package/docs/providers.md +247 -0
  160. package/docs/quickstart.md +136 -0
  161. package/docs/rpc-commands.md +860 -0
  162. package/docs/rpc-extension-ui.md +200 -0
  163. package/docs/rpc.md +193 -0
  164. package/docs/sdk.md +147 -0
  165. package/docs/security.md +99 -0
  166. package/docs/session-format.md +293 -0
  167. package/docs/sessions.md +66 -0
  168. package/docs/settings.md +172 -0
  169. package/docs/shell-aliases.md +93 -0
  170. package/docs/skills.md +93 -0
  171. package/docs/slash-commands.md +61 -0
  172. package/docs/terminal-setup.md +233 -0
  173. package/docs/termux.md +117 -0
  174. package/docs/themes.md +138 -0
  175. package/docs/tmux.md +55 -0
  176. package/docs/tui.md +195 -0
  177. package/docs/usage.md +94 -0
  178. package/docs/virtual-models.md +114 -0
  179. package/docs/windows.md +81 -0
  180. package/lib/auth.js +377 -0
  181. package/lib/provider.js +71 -0
  182. package/package.json +43 -5
  183. package/sera-core/skills/apple-tasarim/SKILL.md +48 -0
  184. package/sera-core/skills/apple-tasarim/referanslar/apple-hig.md +55 -0
  185. package/sera-core/skills/belge-yarat/SKILL.md +64 -0
  186. package/sera-core/skills/belge-yarat/referanslar/belge-yazim.md +60 -0
  187. package/sera-core/skills/derin-arastirma/SKILL.md +52 -0
  188. package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +50 -0
  189. package/sera-core/skills/dusunme-dogrulama/SKILL.md +59 -0
  190. package/sera-core/skills/dusunme-dogrulama/referanslar/dusunme-kontrol.md +54 -0
  191. package/sera-core/skills/film-stilleri/SKILL.md +51 -0
  192. package/sera-core/skills/hyperframes/LICENSE-UPSTREAM +190 -0
  193. package/sera-core/skills/hyperframes/SKILL.md +79 -0
  194. package/sera-core/skills/hyperframes/assets/frame-presets/biennale-yellow/FRAME.md +289 -0
  195. package/sera-core/skills/hyperframes/assets/frame-presets/blockframe/FRAME.md +275 -0
  196. package/sera-core/skills/hyperframes/assets/frame-presets/blue-professional/FRAME.md +307 -0
  197. package/sera-core/skills/hyperframes/assets/frame-presets/bold-poster/FRAME.md +275 -0
  198. package/sera-core/skills/hyperframes/assets/frame-presets/broadside/FRAME.md +284 -0
  199. package/sera-core/skills/hyperframes/assets/frame-presets/capsule/FRAME.md +284 -0
  200. package/sera-core/skills/hyperframes/assets/frame-presets/cartesian/FRAME.md +278 -0
  201. package/sera-core/skills/hyperframes/assets/frame-presets/cobalt-grid/FRAME.md +265 -0
  202. package/sera-core/skills/hyperframes/assets/frame-presets/code-editorial/FRAME.md +277 -0
  203. package/sera-core/skills/hyperframes/assets/frame-presets/coral/FRAME.md +314 -0
  204. package/sera-core/skills/hyperframes/assets/frame-presets/creative-mode/FRAME.md +333 -0
  205. package/sera-core/skills/hyperframes/assets/frame-presets/daisy-days/FRAME.md +274 -0
  206. package/sera-core/skills/hyperframes/assets/frame-presets/editorial-forest/FRAME.md +265 -0
  207. package/sera-core/skills/hyperframes/references/captions.md +46 -0
  208. package/sera-core/skills/hyperframes/references/film.md +48 -0
  209. package/sera-core/skills/hyperframes/references/format.md +159 -0
  210. package/sera-core/skills/hyperframes/references/look.md +69 -0
  211. package/sera-core/skills/hyperframes/references/motion.md +95 -0
  212. package/sera-core/skills/hyperframes/references/overlays.md +39 -0
  213. package/sera-core/skills/hyperframes/references/path-tracing.md +36 -0
  214. package/sera-core/skills/hyperframes/references/plugin-installation.md +42 -0
  215. package/sera-core/skills/hyperframes/references/review.md +51 -0
  216. package/sera-core/skills/hyperframes/references/runtimes.md +69 -0
  217. package/sera-core/skills/hyperframes/references/skill-lifecycle.md +54 -0
  218. package/sera-core/skills/hyperframes/references/sound.md +43 -0
  219. package/sera-core/skills/hyperframes/references/spec.md +76 -0
  220. package/sera-core/skills/hyperframes/references/story.md +103 -0
  221. package/sera-core/skills/hyperframes/references/storyboard-format.md +107 -0
  222. package/sera-core/skills/hyperframes/references/storyboard.md +36 -0
  223. package/sera-core/skills/hyperframes/references/types/3d.md +25 -0
  224. package/sera-core/skills/hyperframes/references/types/character.md +20 -0
  225. package/sera-core/skills/hyperframes/references/types/data.md +19 -0
  226. package/sera-core/skills/hyperframes/references/types/explainer.md +34 -0
  227. package/sera-core/skills/hyperframes/references/types/launch.md +41 -0
  228. package/sera-core/skills/hyperframes/references/types/music.md +24 -0
  229. package/sera-core/skills/hyperframes/references/types/vertical.md +23 -0
  230. package/sera-core/skills/hyperframes-cli/LICENSE-UPSTREAM +190 -0
  231. package/sera-core/skills/hyperframes-cli/SKILL.md +99 -0
  232. package/sera-core/skills/hyperframes-cli/references/beats.md +17 -0
  233. package/sera-core/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
  234. package/sera-core/skills/hyperframes-cli/references/conventions.md +16 -0
  235. package/sera-core/skills/hyperframes-cli/references/doctor-browser.md +80 -0
  236. package/sera-core/skills/hyperframes-cli/references/feedback.md +14 -0
  237. package/sera-core/skills/hyperframes-cli/references/init-and-scaffold.md +75 -0
  238. package/sera-core/skills/hyperframes-cli/references/lint-validate-inspect.md +164 -0
  239. package/sera-core/skills/hyperframes-cli/references/preview-render.md +204 -0
  240. package/sera-core/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
  241. package/sera-core/skills/impeccable/LICENSE-UPSTREAM +191 -0
  242. package/sera-core/skills/impeccable/NOTICE-UPSTREAM.md +11 -0
  243. package/sera-core/skills/impeccable/SKILL.md +89 -0
  244. package/sera-core/skills/impeccable/reference/adapt.md +318 -0
  245. package/sera-core/skills/impeccable/reference/adapt.native.md +58 -0
  246. package/sera-core/skills/impeccable/reference/android.md +46 -0
  247. package/sera-core/skills/impeccable/reference/animate.md +89 -0
  248. package/sera-core/skills/impeccable/reference/audit.md +139 -0
  249. package/sera-core/skills/impeccable/reference/audit.native.md +139 -0
  250. package/sera-core/skills/impeccable/reference/bolder.md +33 -0
  251. package/sera-core/skills/impeccable/reference/clarify.md +94 -0
  252. package/sera-core/skills/impeccable/reference/colorize.md +86 -0
  253. package/sera-core/skills/impeccable/reference/component-review.md +63 -0
  254. package/sera-core/skills/impeccable/reference/craft-floor.md +44 -0
  255. package/sera-core/skills/impeccable/reference/craft.md +5 -0
  256. package/sera-core/skills/impeccable/reference/critique.md +819 -0
  257. package/sera-core/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  258. package/sera-core/skills/impeccable/reference/degraded/documenter.md +24 -0
  259. package/sera-core/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  260. package/sera-core/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  261. package/sera-core/skills/impeccable/reference/delight.md +70 -0
  262. package/sera-core/skills/impeccable/reference/distill.md +111 -0
  263. package/sera-core/skills/impeccable/reference/doctor.md +54 -0
  264. package/sera-core/skills/impeccable/reference/document.md +416 -0
  265. package/sera-core/skills/impeccable/reference/extract.md +69 -0
  266. package/sera-core/skills/impeccable/reference/generate.md +101 -0
  267. package/sera-core/skills/impeccable/reference/harden.md +362 -0
  268. package/sera-core/skills/impeccable/reference/hooks.md +120 -0
  269. package/sera-core/skills/impeccable/reference/init.md +133 -0
  270. package/sera-core/skills/impeccable/reference/ios.md +51 -0
  271. package/sera-core/skills/impeccable/reference/layout.md +84 -0
  272. package/sera-core/skills/impeccable/reference/live-setup.md +104 -0
  273. package/sera-core/skills/impeccable/reference/live.md +327 -0
  274. package/sera-core/skills/impeccable/reference/mode-operate.md +21 -0
  275. package/sera-core/skills/impeccable/reference/mode-persuade.md +19 -0
  276. package/sera-core/skills/impeccable/reference/mode-read.md +21 -0
  277. package/sera-core/skills/impeccable/reference/new-work.md +152 -0
  278. package/sera-core/skills/impeccable/reference/onboard.md +234 -0
  279. package/sera-core/skills/impeccable/reference/operate.md +61 -0
  280. package/sera-core/skills/impeccable/reference/optimize.md +257 -0
  281. package/sera-core/skills/impeccable/reference/overdrive.md +127 -0
  282. package/sera-core/skills/impeccable/reference/polish.md +105 -0
  283. package/sera-core/skills/impeccable/reference/quieter.md +99 -0
  284. package/sera-core/skills/impeccable/reference/region-map.md +26 -0
  285. package/sera-core/skills/impeccable/reference/routing.md +24 -0
  286. package/sera-core/skills/impeccable/reference/shape.md +59 -0
  287. package/sera-core/skills/impeccable/reference/typeset.md +90 -0
  288. package/sera-core/skills/impeccable/reference/visualize.md +47 -0
  289. package/sera-core/skills/oyun-yarat/SKILL.md +106 -0
  290. package/sera-core/skills/oyun-yarat/referanslar/3b-yaris.md +74 -0
  291. package/sera-core/skills/oyun-yarat/referanslar/kaplay.md +99 -0
  292. package/sera-core/skills/oyun-yarat/referanslar/oyun-desenleri.md +73 -0
  293. package/sera-core/skills/oyun-yarat/sablonlar/kaplay-2d.html +164 -0
  294. package/sera-core/skills/oyun-yarat/sablonlar/three-yaris.html +149 -0
  295. package/sera-core/skills/oyun-yarat/sablonlar/tuval-minimal.html +77 -0
  296. package/sera-core/skills/receiving-code-review/LICENSE-UPSTREAM +21 -0
  297. package/sera-core/skills/receiving-code-review/SKILL.md +205 -0
  298. package/sera-core/skills/refero-design/LICENSE-UPSTREAM +21 -0
  299. package/sera-core/skills/refero-design/SKILL.md +534 -0
  300. package/sera-core/skills/refero-design/references/anti-ai-slop.md +292 -0
  301. package/sera-core/skills/refero-design/references/color.md +563 -0
  302. package/sera-core/skills/refero-design/references/copywriting.md +222 -0
  303. package/sera-core/skills/refero-design/references/craft-details.md +525 -0
  304. package/sera-core/skills/refero-design/references/example-workflow.md +264 -0
  305. package/sera-core/skills/refero-design/references/icons.md +166 -0
  306. package/sera-core/skills/refero-design/references/mcp-tools.md +258 -0
  307. package/sera-core/skills/refero-design/references/motion.md +504 -0
  308. package/sera-core/skills/refero-design/references/typography.md +737 -0
  309. package/sera-core/skills/refero-design/references/visual-workflow.md +105 -0
  310. package/sera-core/skills/requesting-code-review/LICENSE-UPSTREAM +21 -0
  311. package/sera-core/skills/requesting-code-review/SKILL.md +95 -0
  312. package/sera-core/skills/requesting-code-review/code-reviewer.md +198 -0
  313. package/sera-core/skills/reverse-engineer-anything/DISCLAIMER.md +136 -0
  314. package/sera-core/skills/reverse-engineer-anything/LICENSE-REA-MIT +21 -0
  315. package/sera-core/skills/reverse-engineer-anything/SKILL.md +363 -0
  316. package/sera-core/skills/reverse-engineer-anything/THIRD_PARTY_NOTICES.md +135 -0
  317. package/sera-core/skills/reverse-engineer-anything/references/android-applications.md +36 -0
  318. package/sera-core/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
  319. package/sera-core/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
  320. package/sera-core/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
  321. package/sera-core/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
  322. package/sera-core/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
  323. package/sera-core/skills/seo-audit/LICENSE-UPSTREAM +21 -0
  324. package/sera-core/skills/seo-audit/SKILL.md +210 -0
  325. package/sera-core/skills/sera-guvenlik-denetim/SKILL.md +44 -0
  326. package/sera-core/skills/sera-guvenlik-denetim/referanslar/guvenlik-listesi.md +33 -0
  327. package/sera-core/skills/sera-hata-ayikla/SKILL.md +27 -0
  328. package/sera-core/skills/sera-hata-ayikla/referanslar/hata-ayiklama.md +37 -0
  329. package/sera-core/skills/sera-kod-inceleme/SKILL.md +44 -0
  330. package/sera-core/skills/sera-kod-inceleme/referanslar/inceleme-listesi.md +62 -0
  331. package/sera-core/skills/sera-ofis-dosya/SKILL.md +27 -0
  332. package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-dosya.md +93 -0
  333. package/sera-core/skills/sera-research/SKILL.md +90 -0
  334. package/sera-core/skills/sera-tasarim/SKILL.md +149 -0
  335. package/sera-core/skills/sera-teslim-sozlesmesi/SKILL.md +592 -0
  336. package/sera-core/skills/sera-test-yaz/SKILL.md +26 -0
  337. package/sera-core/skills/sera-test-yaz/referanslar/test-yazimi.md +35 -0
  338. package/sera-core/skills/sera-veri-gorsel/SKILL.md +65 -0
  339. package/sera-core/skills/sera-web-test/SKILL.md +26 -0
  340. package/sera-core/skills/sera-web-test/referanslar/web-test.md +44 -0
  341. package/sera-core/skills/sera-zamanli-gorev/SKILL.md +22 -0
  342. package/sera-core/skills/sera-zamanli-gorev/referanslar/zamanli-gorev.md +58 -0
  343. package/sera-core/skills/systematic-debugging/LICENSE-UPSTREAM +21 -0
  344. package/sera-core/skills/systematic-debugging/SKILL.md +283 -0
  345. package/sera-core/skills/systematic-debugging/condition-based-waiting.md +115 -0
  346. package/sera-core/skills/systematic-debugging/defense-in-depth.md +122 -0
  347. package/sera-core/skills/systematic-debugging/root-cause-tracing.md +169 -0
  348. package/sera-core/skills/test-driven-development/LICENSE-UPSTREAM +21 -0
  349. package/sera-core/skills/test-driven-development/SKILL.md +330 -0
  350. package/sera-core/skills/test-driven-development/writing-good-tests.md +198 -0
  351. package/sera-core/skills/ticaret-icerik/SKILL.md +49 -0
  352. package/sera-core/skills/ticaret-icerik/referanslar/ticaret-icerik.md +54 -0
  353. package/sera-core/skills/uygulama-yarat/SKILL.md +95 -0
  354. package/sera-core/skills/uygulama-yarat/referanslar/uygulama-desenleri.md +63 -0
  355. package/sera-core/skills/uygulama-yarat/sablonlar/uygulama-tek-dosya.html +121 -0
  356. package/sera-core/skills/uyumluluk-denetim/SKILL.md +56 -0
  357. package/sera-core/skills/uyumluluk-denetim/referanslar/mevzuat-tablosu.md +65 -0
  358. package/sera-core/skills/veri-analizi/SKILL.md +54 -0
  359. package/sera-core/skills/veri-analizi/referanslar/veri-analizi-yontem.md +49 -0
  360. package/sera-core/skills/veri-analizi/sablonlar/profil.mjs +79 -0
  361. package/sera-core/skills/video-duzen/SKILL.md +50 -0
  362. package/sera-core/skills/video-duzen/referanslar/video-duzen.md +100 -0
  363. package/sera-core/skills/web-yayin-listesi/SKILL.md +115 -0
  364. package/sera-core/skills/writing-plans/LICENSE-UPSTREAM +21 -0
  365. package/sera-core/skills/writing-plans/SKILL.md +204 -0
  366. package/sera-core/src/action-nudge.ts +200 -0
  367. package/sera-core/src/agent-mode.ts +143 -0
  368. package/sera-core/src/agents.ts +185 -0
  369. package/sera-core/src/app-master.ts +275 -0
  370. package/sera-core/src/app-verify.ts +551 -0
  371. package/sera-core/src/approval.ts +131 -0
  372. package/sera-core/src/budget.ts +136 -0
  373. package/sera-core/src/command-policy.ts +808 -0
  374. package/sera-core/src/config.ts +135 -0
  375. package/sera-core/src/context-diet.ts +272 -0
  376. package/sera-core/src/device-id.ts +48 -0
  377. package/sera-core/src/dogal-arac.ts +203 -0
  378. package/sera-core/src/dogal-niyet.ts +173 -0
  379. package/sera-core/src/egress-allow.ts +52 -0
  380. package/sera-core/src/export.ts +124 -0
  381. package/sera-core/src/exposure.ts +8 -0
  382. package/sera-core/src/extension.ts +2410 -0
  383. package/sera-core/src/fs-tools.ts +448 -0
  384. package/sera-core/src/generated/build-rules.ts +26 -0
  385. package/sera-core/src/generated/zero-knowledge.ts +170 -0
  386. package/sera-core/src/github-agent-command.ts +133 -0
  387. package/sera-core/src/github-agent-engine.ts +198 -0
  388. package/sera-core/src/github-agent-schedule.ts +180 -0
  389. package/sera-core/src/github-agent.ts +669 -0
  390. package/sera-core/src/github-ajan-akis.ts +193 -0
  391. package/sera-core/src/github-ajan-gercek.ts +102 -0
  392. package/sera-core/src/github-tick.ts +78 -0
  393. package/sera-core/src/github-yedek.ts +269 -0
  394. package/sera-core/src/goal.ts +119 -0
  395. package/sera-core/src/handoff.ts +132 -0
  396. package/sera-core/src/hooks.ts +284 -0
  397. package/sera-core/src/image-tool.ts +118 -0
  398. package/sera-core/src/intake-brief.ts +82 -0
  399. package/sera-core/src/intake-core.ts +1152 -0
  400. package/sera-core/src/intake-hook.ts +88 -0
  401. package/sera-core/src/ios-build-tool.ts +134 -0
  402. package/sera-core/src/lazy-capability.ts +125 -0
  403. package/sera-core/src/lazy-mcp.ts +300 -0
  404. package/sera-core/src/limit-command.ts +51 -0
  405. package/sera-core/src/loop-brake.ts +129 -0
  406. package/sera-core/src/lsp.ts +618 -0
  407. package/sera-core/src/mcp-bridge.ts +159 -0
  408. package/sera-core/src/mcp-pin.ts +105 -0
  409. package/sera-core/src/mcp-ssrf.ts +124 -0
  410. package/sera-core/src/message-cap.ts +45 -0
  411. package/sera-core/src/model-list.ts +108 -0
  412. package/sera-core/src/no-progress.ts +177 -0
  413. package/sera-core/src/notebook-tool.ts +179 -0
  414. package/sera-core/src/ofis.ts +473 -0
  415. package/sera-core/src/path-guard.ts +139 -0
  416. package/sera-core/src/permission-bridge.ts +228 -0
  417. package/sera-core/src/policy-chain.ts +122 -0
  418. package/sera-core/src/pricing.ts +71 -0
  419. package/sera-core/src/proc.ts +149 -0
  420. package/sera-core/src/rea.ts +188 -0
  421. package/sera-core/src/repo-map.ts +230 -0
  422. package/sera-core/src/research.ts +347 -0
  423. package/sera-core/src/rules-memory.ts +227 -0
  424. package/sera-core/src/sandbox.ts +476 -0
  425. package/sera-core/src/server-error.ts +78 -0
  426. package/sera-core/src/skills.ts +268 -0
  427. package/sera-core/src/snapshot.ts +143 -0
  428. package/sera-core/src/spec-gate.ts +112 -0
  429. package/sera-core/src/subagent.ts +261 -0
  430. package/sera-core/src/teslim.ts +121 -0
  431. package/sera-core/src/test-fix.ts +184 -0
  432. package/sera-core/src/todo-question.ts +163 -0
  433. package/sera-core/src/turn-snapshots.ts +126 -0
  434. package/sera-core/src/tuval/arac.ts +338 -0
  435. package/sera-core/src/tuval/arsiv.ts +106 -0
  436. package/sera-core/src/tuval/belge.ts +216 -0
  437. package/sera-core/src/tuval/birlestir.ts +282 -0
  438. package/sera-core/src/tuval/disa.ts +235 -0
  439. package/sera-core/src/tuval/editor.ts +583 -0
  440. package/sera-core/src/tuval/film-cekirdek.ts +170 -0
  441. package/sera-core/src/tuval/film-disa.ts +188 -0
  442. package/sera-core/src/tuval/film-oynatici.ts +307 -0
  443. package/sera-core/src/tuval/kimlik.ts +156 -0
  444. package/sera-core/src/tuval/pano.ts +763 -0
  445. package/sera-core/src/tuval/proje.ts +728 -0
  446. package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
  447. package/sera-core/src/tuval/sistem.ts +328 -0
  448. package/sera-core/src/tuval/sunucu.ts +413 -0
  449. package/sera-core/src/tuval/uretim.ts +24 -0
  450. package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
  451. package/sera-core/src/tuval/xlsx.ts +215 -0
  452. package/sera-core/src/tuval/zip.ts +163 -0
  453. package/sera-core/src/untrusted.ts +201 -0
  454. package/sera-core/src/video-edit-tool.ts +411 -0
  455. package/sera-core/src/video-tool.ts +217 -0
  456. package/sera-core/src/web-tools.ts +257 -0
  457. package/sera-core/src/zk.ts +104 -0
@@ -0,0 +1,763 @@
1
+ /**
2
+ * Sera Tuval veri panosu: `veri/` (CSV/TSV/JSON) + `pano.json` tanimi -> tek dosyali, tarayicida canli hesaplayan pano.html.
3
+ * Her sayi ve grafik noktasi tiklaninca degeri ureten kaynak satirlar gosterilir (kaynak izi).
4
+ * Hesap cekirdegi veri-cekirdek.ts'tedir (tarayicida ve testlerde AYNI kod). Ozgun tasarim.
5
+ */
6
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from "node:fs";
7
+ import { basename, join } from "node:path";
8
+ import { atomikYaz, BILDIRIM, bildirimOku, kokIci, olustur } from "./proje.ts";
9
+ import { SeraVeri, VERI_JS, type VeriKumesi } from "./veri-cekirdek.ts";
10
+ import { xlsxMetne } from "./xlsx.ts";
11
+
12
+ export const VERI_KLASORU = "veri";
13
+ export const PANO_TANIM = "pano.json";
14
+ export const PANO_DOSYA = "pano.html";
15
+ export const VERI_UZANTI = /\.(csv|tsv|json|txt|xlsx)$/i;
16
+ const TOPLAM_SINIR = 6_000_000;
17
+
18
+ export interface PanoFiltre {
19
+ alan: string;
20
+ /** secim: dugme cipleri; coklu: onay kutulu liste; aralik: min-max kaydirici + girdi (sayi/tarih); ara: metin arama */
21
+ tur?: "secim" | "coklu" | "aralik" | "ara";
22
+ baslik?: string;
23
+ }
24
+ export interface PanoSeri {
25
+ islem: PanoKart["islem"];
26
+ alan?: string;
27
+ /** lejant/secicide gorunecek ad (varsayilan: alan ya da "satir sayisi") */
28
+ ad?: string;
29
+ }
30
+ export interface PanoKart {
31
+ baslik: string;
32
+ islem: "say" | "topla" | "ortalama" | "min" | "max" | "benzersiz";
33
+ alan?: string;
34
+ veri?: string;
35
+ bicim?: "sayi" | "para" | "yuzde" | "tarih";
36
+ }
37
+ export interface PanoGrafik {
38
+ tur: "cubuk" | "cizgi" | "alan" | "halka" | "dagilim";
39
+ baslik: string;
40
+ x: string;
41
+ /** tek seri {islem, alan} ya da cok seri icin dizi */
42
+ y?: PanoSeri | PanoSeri[];
43
+ /** cok seri kisayolu: sayisal sutun adlari (islem: y.islem ya da "topla") ya da {islem, alan, ad} */
44
+ seriler?: (string | PanoSeri)[];
45
+ /** dagilim icin: y alani (sayisal sutun adi) */
46
+ yAlan?: string;
47
+ grupla?: "gun" | "ay" | "yil";
48
+ sinir?: number;
49
+ veri?: string;
50
+ bicim?: PanoKart["bicim"];
51
+ sirala?: "deger" | "etiket";
52
+ }
53
+ export interface PanoTablo {
54
+ baslik: string;
55
+ sutunlar?: string[];
56
+ sirala?: string;
57
+ azalan?: boolean;
58
+ adet?: number;
59
+ veri?: string;
60
+ }
61
+ export interface PanoTanim {
62
+ surum: 1;
63
+ ad: string;
64
+ veri: string;
65
+ filtreler: PanoFiltre[];
66
+ kartlar: PanoKart[];
67
+ grafikler: PanoGrafik[];
68
+ tablolar: PanoTablo[];
69
+ }
70
+
71
+ const ISLEMLER = ["say", "topla", "ortalama", "min", "max", "benzersiz"];
72
+ const GRAFIK_TURLERI = ["cubuk", "cizgi", "alan", "halka", "dagilim"];
73
+ const FILTRE_TURLERI = ["secim", "coklu", "aralik", "ara"];
74
+ export const SERI_SINIR = 8;
75
+
76
+ /** Grafik tanimindan seri listesi: y dizi, y nesne ya da seriler kisayolu. Bos olabilir (dagilim). */
77
+ export function panoSeriler(g: PanoGrafik): PanoSeri[] {
78
+ if (Array.isArray(g.y)) return g.y;
79
+ if (Array.isArray(g.seriler) && g.seriler.length) {
80
+ const islem = g.y && !Array.isArray(g.y) ? g.y.islem : "topla";
81
+ return g.seriler.map((q) => (typeof q === "string" ? { islem, alan: q } : q));
82
+ }
83
+ return g.y ? [g.y] : [];
84
+ }
85
+
86
+ /** Bayt dizisini metne cevirir: gecerli UTF-8 degilse Windows-1254 (Turkce Excel CSV'leri) varsayilir. */
87
+ export function metinOku(b: Buffer): string {
88
+ try {
89
+ return new TextDecoder("utf-8", { fatal: true }).decode(b).replace(/^\uFEFF/, "");
90
+ } catch {
91
+ return new TextDecoder("windows-1254").decode(b);
92
+ }
93
+ }
94
+
95
+ export function veriAdiTemizle(ad: string): string {
96
+ const t = basename(ad.replaceAll("\\", "/"))
97
+ .replace(/[^\p{L}\p{N}._ -]/gu, "_")
98
+ .trim();
99
+ if (!t || t.startsWith(".") || !VERI_UZANTI.test(t))
100
+ throw new Error(`Veri dosyasi adi gecersiz (.csv, .tsv, .json ya da .xlsx olmali): ${ad}`);
101
+ return t.slice(-80);
102
+ }
103
+
104
+ export function veriDosyalari(kok: string): string[] {
105
+ const d = join(kok, VERI_KLASORU);
106
+ if (!existsSync(d)) return [];
107
+ return readdirSync(d)
108
+ .filter((f) => VERI_UZANTI.test(f) && statSync(join(d, f)).isFile())
109
+ .sort();
110
+ }
111
+
112
+ export function hamVeriOku(kok: string): Record<string, string> {
113
+ const o: Record<string, string> = {};
114
+ let toplam = 0;
115
+ for (const f of veriDosyalari(kok)) {
116
+ const bayt = readFileSync(kokIci(join(kok, VERI_KLASORU), f));
117
+ let m: string;
118
+ if (/\.xlsx$/i.test(f)) {
119
+ try {
120
+ m = xlsxMetne(bayt); // ikili dosya: okurken CSV metnine cevrilir (veri/ altindaki orijinal degismez)
121
+ } catch (e) {
122
+ throw new Error(`veri/${f}: ${(e as Error).message}`);
123
+ }
124
+ } else m = metinOku(bayt);
125
+ toplam += m.length;
126
+ if (toplam > TOPLAM_SINIR)
127
+ throw new Error("Veri dosyalari toplamda 6 MB'i asiyor; pano icin dosyalari kucultun.");
128
+ o[f] = m;
129
+ }
130
+ return o;
131
+ }
132
+
133
+ // ---------------------------------------------------------------- otomatik tanim
134
+
135
+ const PARA_AD = /tutar|ciro|fiyat|gelir|maliyet|ucret|ücret|bedel|kar\b|kâr|hasilat|hasılat|satis|satış|toplam/i;
136
+ const KIMLIK_AD = /^(id|no|sira|sıra|kod)$|(_id|\bid)$/i;
137
+ const OLCU_AD = /tutar|ciro|fiyat|gelir|adet|miktar|satis|satış|toplam|maliyet|ucret|ücret|bedel|puan|sayi|sayı/i;
138
+
139
+ function farkliSayisi(ds: VeriKumesi, alan: string): number {
140
+ return new Set(ds.satirlar.map((r) => r.h[alan]).filter((x) => x !== "")).size;
141
+ }
142
+ function paraMi(alan: string): boolean {
143
+ return PARA_AD.test(alan);
144
+ }
145
+
146
+ /** Sifir bilgili kullanici icin: sutunlardan makul bir pano tanimi uretir. */
147
+ export function panoOtomatik(ad: string, dosya: string, ds: VeriKumesi): PanoTanim {
148
+ const sayisal = ds.basliklar.filter((b) => ds.turler[b] === "sayi" && !KIMLIK_AD.test(b));
149
+ const olculer = [
150
+ ...sayisal.filter((b) => PARA_AD.test(b)),
151
+ ...sayisal.filter((b) => !PARA_AD.test(b) && OLCU_AD.test(b)),
152
+ ...sayisal.filter((b) => !PARA_AD.test(b) && !OLCU_AD.test(b)),
153
+ ];
154
+ const tarihler = ds.basliklar.filter((b) => ds.turler[b] === "tarih");
155
+ const kategoriler = ds.basliklar.filter((b) => {
156
+ if (ds.turler[b] !== "metin") return false;
157
+ const n = farkliSayisi(ds, b);
158
+ return n >= 2 && n <= 30 && n < ds.satirlar.length;
159
+ });
160
+ const kucukKat = kategoriler.filter((b) => farkliSayisi(ds, b) <= 12);
161
+ const bicimOf = (a: string): PanoKart["bicim"] => (paraMi(a) ? "para" : "sayi");
162
+ const t: PanoTanim = { surum: 1, ad, veri: dosya, filtreler: [], kartlar: [], grafikler: [], tablolar: [] };
163
+
164
+ if (tarihler[0]) t.filtreler.push({ alan: tarihler[0], tur: "aralik" });
165
+ for (const k of kucukKat.slice(0, 3)) t.filtreler.push({ alan: k, tur: "secim" });
166
+ // cok degerli kategori (13-30): ciplere sigmaz, onay kutulu liste
167
+ const cokKat = kategoriler.find((k) => farkliSayisi(ds, k) > 12);
168
+ if (cokKat) t.filtreler.push({ alan: cokKat, tur: "coklu" });
169
+ // yeterince cok satirli sayisal olcu: min-max kaydirici
170
+ if (olculer[0] && ds.satirlar.length >= 20 && farkliSayisi(ds, olculer[0]) >= 10)
171
+ t.filtreler.push({ alan: olculer[0], tur: "aralik" });
172
+
173
+ t.kartlar.push({ baslik: "Toplam satır", islem: "say" });
174
+ for (const o of olculer.slice(0, 2))
175
+ t.kartlar.push({ baslik: `Toplam ${o}`, islem: "topla", alan: o, bicim: bicimOf(o) });
176
+ if (olculer[0])
177
+ t.kartlar.push({
178
+ baslik: `Ortalama ${olculer[0]}`,
179
+ islem: "ortalama",
180
+ alan: olculer[0],
181
+ bicim: bicimOf(olculer[0]),
182
+ });
183
+
184
+ const m = olculer[0];
185
+ if (kategoriler[0])
186
+ t.grafikler.push(
187
+ m
188
+ ? {
189
+ tur: "cubuk",
190
+ baslik: `${kategoriler[0]} bazında ${m}`,
191
+ x: kategoriler[0],
192
+ y: { islem: "topla", alan: m },
193
+ sinir: 10,
194
+ bicim: bicimOf(m),
195
+ }
196
+ : {
197
+ tur: "cubuk",
198
+ baslik: `${kategoriler[0]} bazında satır sayısı`,
199
+ x: kategoriler[0],
200
+ y: { islem: "say" },
201
+ sinir: 10,
202
+ },
203
+ );
204
+ if (tarihler[0])
205
+ t.grafikler.push(
206
+ m
207
+ ? {
208
+ tur: "cizgi",
209
+ baslik: `Aylara göre ${m}`,
210
+ x: tarihler[0],
211
+ y: { islem: "topla", alan: m },
212
+ grupla: "ay",
213
+ bicim: bicimOf(m),
214
+ }
215
+ : { tur: "cizgi", baslik: "Aylara göre satır sayısı", x: tarihler[0], y: { islem: "say" }, grupla: "ay" },
216
+ );
217
+ const halkaKat = kucukKat.find((k) => k !== kategoriler[0]) ?? kucukKat[0];
218
+ if (halkaKat && (kategoriler.length > 1 || !t.grafikler.length))
219
+ t.grafikler.push({
220
+ tur: "halka",
221
+ baslik: m ? `${halkaKat} payı (${m})` : `${halkaKat} payı`,
222
+ x: halkaKat,
223
+ y: m ? { islem: "topla", alan: m } : { islem: "say" },
224
+ sinir: 7,
225
+ bicim: m ? bicimOf(m) : "sayi",
226
+ });
227
+ if (olculer.length >= 2)
228
+ t.grafikler.push({
229
+ tur: "dagilim",
230
+ baslik: `${olculer[0]} ve ${olculer[1]} ilişkisi`,
231
+ x: olculer[0]!,
232
+ yAlan: olculer[1],
233
+ });
234
+
235
+ const sirala = tarihler[0] ?? olculer[0];
236
+ t.tablolar.push({
237
+ baslik: "Satırlar",
238
+ sutunlar: ds.basliklar.slice(0, 8),
239
+ ...(sirala ? { sirala, azalan: true } : {}),
240
+ adet: 10,
241
+ });
242
+ return t;
243
+ }
244
+
245
+ // ---------------------------------------------------------------- dogrulama
246
+
247
+ function tanimNormal(o: unknown): PanoTanim {
248
+ if (!o || typeof o !== "object") throw new Error(`${PANO_TANIM} bir nesne olmali.`);
249
+ const x = o as Record<string, unknown>;
250
+ const dz = (k: string) => (Array.isArray(x[k]) ? (x[k] as never[]) : []);
251
+ return {
252
+ surum: 1,
253
+ ad: typeof x.ad === "string" && x.ad.trim() ? x.ad.trim() : "Veri panosu",
254
+ veri: typeof x.veri === "string" ? x.veri : "",
255
+ filtreler: dz("filtreler"),
256
+ kartlar: dz("kartlar"),
257
+ grafikler: dz("grafikler"),
258
+ tablolar: dz("tablolar"),
259
+ };
260
+ }
261
+
262
+ /** Tanim + veri kumeleri tutarli mi? Sorun listesi (bos = gecerli). Hata iletileri duzeltme yolunu soyler. */
263
+ export function panoDogrula(t: PanoTanim, kumeler: Record<string, VeriKumesi>): string[] {
264
+ const s: string[] = [];
265
+ const adlar = Object.keys(kumeler);
266
+ if (!adlar.length) return [`veri/ klasorunde .csv/.tsv/.json dosyasi yok.`];
267
+ const kumeAl = (ad: string | undefined, nerede: string): VeriKumesi | undefined => {
268
+ const a = ad || t.veri;
269
+ const k = kumeler[a];
270
+ if (!k) s.push(`${nerede}: veri/${a || "?"} dosyasi yok. Mevcut: ${adlar.join(", ")}`);
271
+ return k;
272
+ };
273
+ const alanVar = (k: VeriKumesi, alan: string | undefined, nerede: string, sayisal = false) => {
274
+ if (!alan) {
275
+ s.push(`${nerede}: alan gerekli.`);
276
+ return;
277
+ }
278
+ if (!k.basliklar.includes(alan)) {
279
+ s.push(`${nerede}: "${alan}" sutunu yok. Sutunlar: ${k.basliklar.join(", ")}`);
280
+ return;
281
+ }
282
+ if (sayisal && k.turler[alan] !== "sayi")
283
+ s.push(
284
+ `${nerede}: "${alan}" sayisal degil (${k.turler[alan]}); topla/ortalama/min/max icin sayisal sutun gerekir.`,
285
+ );
286
+ };
287
+ kumeAl(t.veri, "veri");
288
+ t.filtreler.forEach((f, i) => {
289
+ const k = kumeler[t.veri] ?? Object.values(kumeler)[0]!;
290
+ const var_ = Object.values(kumeler).find((q) => q.basliklar.includes(f.alan)) ?? k;
291
+ alanVar(var_, f.alan, `filtreler[${i}]`);
292
+ if (f.tur !== undefined && !FILTRE_TURLERI.includes(f.tur))
293
+ s.push(`filtreler[${i}].tur ${FILTRE_TURLERI.join("|")} olmali (${f.tur}).`);
294
+ else if (f.tur === "aralik" && var_.basliklar.includes(f.alan) && var_.turler[f.alan] === "metin")
295
+ s.push(
296
+ `filtreler[${i}]: "${f.alan}" metin sutunu; aralik kaydirici icin sayisal ya da tarih sutunu gerekir (metin icin tur: "coklu" ya da "secim" kullanin).`,
297
+ );
298
+ });
299
+ t.kartlar.forEach((c, i) => {
300
+ const n = `kartlar[${i}]`;
301
+ if (!ISLEMLER.includes(c.islem)) {
302
+ s.push(`${n}: islem ${ISLEMLER.join("|")} olmali.`);
303
+ return;
304
+ }
305
+ const k = kumeAl(c.veri, n);
306
+ if (k && c.islem !== "say") alanVar(k, c.alan, n, c.islem !== "benzersiz");
307
+ });
308
+ t.grafikler.forEach((g, i) => {
309
+ const n = `grafikler[${i}]`;
310
+ if (!GRAFIK_TURLERI.includes(g.tur)) {
311
+ s.push(`${n}: tur ${GRAFIK_TURLERI.join("|")} olmali.`);
312
+ return;
313
+ }
314
+ const k = kumeAl(g.veri, n);
315
+ if (!k) return;
316
+ alanVar(k, g.x, `${n}.x`, g.tur === "dagilim");
317
+ if (g.tur === "dagilim") alanVar(k, g.yAlan, `${n}.yAlan`, true);
318
+ else {
319
+ if (g.seriler !== undefined && !Array.isArray(g.seriler))
320
+ s.push(`${n}.seriler sutun adlari dizisi olmali (orn. ["Adet","Tutar"]).`);
321
+ const sl = panoSeriler(g);
322
+ if (!sl.length) s.push(`${n}.y: {islem, alan} (ya da seriler: [sutun adlari]) gerekli.`);
323
+ if (sl.length > SERI_SINIR) s.push(`${n}: en fazla ${SERI_SINIR} seri cizilebilir (${sl.length} verilmis).`);
324
+ if (sl.length > 1 && g.tur === "halka")
325
+ s.push(`${n}: ${g.tur} grafigi tek seri gosterir; cok seri icin tur cubuk ya da cizgi olmali.`);
326
+ if (sl.length > 1 && g.tur === "alan")
327
+ s.push(
328
+ `${n}: alan grafigi tek seri icindir (ust uste binince okunmaz); cok seri icin cubuk ya da cizgi kullanin.`,
329
+ );
330
+ sl.forEach((q, j) => {
331
+ const nn = sl.length > 1 ? `${n}.seriler[${j}]` : `${n}.y`;
332
+ if (!q || !ISLEMLER.includes(q.islem)) s.push(`${nn}: islem ${ISLEMLER.join("|")} olmali.`);
333
+ else if (q.islem !== "say") alanVar(k, q.alan, nn, q.islem !== "benzersiz");
334
+ });
335
+ }
336
+ });
337
+ t.tablolar.forEach((tb, i) => {
338
+ const n = `tablolar[${i}]`;
339
+ const k = kumeAl(tb.veri, n);
340
+ if (!k) return;
341
+ for (const c of tb.sutunlar ?? []) alanVar(k, c, `${n}.sutunlar`);
342
+ if (tb.sirala) alanVar(k, tb.sirala, `${n}.sirala`);
343
+ });
344
+ return s;
345
+ }
346
+
347
+ // ---------------------------------------------------------------- sayfa
348
+
349
+ const kacisJson = (v: unknown) =>
350
+ JSON.stringify(v).replaceAll("<", "\\u003c").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
351
+
352
+ const PANO_CSS = `
353
+ :root{color-scheme:light dark;--zemin:#f7f6f2;--yuzey:#ffffff;--yuzey2:#efede8;--metin:#1c1b19;--soluk:#5f5b53;--cizgi:#dcd8cf;--vurgu:#1f5f4a;--vurgu-ac:#e3f0ea;--uyari:#9a3412;
354
+ --p1:#0072B2;--p2:#E69F00;--p3:#009E73;--p4:#CC79A7;--p5:#56B4E9;--p6:#D55E00;--p7:#8a7f00;--p8:#555555}
355
+ @media (prefers-color-scheme:dark){:root{--zemin:#161614;--yuzey:#1f1f1c;--yuzey2:#2a2a26;--metin:#efece6;--soluk:#a9a498;--cizgi:#3a3935;--vurgu:#6fcf9f;--vurgu-ac:#1f3a2f;--uyari:#f0a36b;
356
+ --p1:#56B4E9;--p2:#F0A830;--p3:#2FC79A;--p4:#E39BC4;--p5:#8FD0F5;--p6:#F08A4B;--p7:#F0E442;--p8:#c9c9c9}}
357
+ *{box-sizing:border-box}
358
+ body{margin:0;background:var(--zemin);color:var(--metin);font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;padding:24px 16px 120px}
359
+ .sar{max-width:1280px;margin:0 auto}
360
+ h1{font-size:1.6rem;margin:0 0 4px}h2{font-size:1.05rem;margin:0 0 8px}
361
+ .alt{color:var(--soluk);font-size:.85rem;margin:0}
362
+ button{font:inherit;color:inherit}
363
+ .filtreler{display:flex;flex-wrap:wrap;gap:12px;margin:20px 0}
364
+ fieldset.filtre{border:1px solid var(--cizgi);border-radius:12px;background:var(--yuzey);padding:8px 12px 10px;margin:0;min-width:160px}
365
+ fieldset.filtre legend{font-size:.8rem;color:var(--soluk);padding:0 6px}
366
+ .cipler{display:flex;flex-wrap:wrap;gap:6px}
367
+ .cip{border:1px solid var(--cizgi);background:var(--zemin);border-radius:999px;padding:6px 12px;min-height:36px;cursor:pointer}
368
+ .coklu{display:flex;flex-direction:column;gap:4px;max-height:160px;overflow:auto}.ck{display:flex;gap:6px;align-items:center;font-size:.9rem}.kayd{display:flex;flex-direction:column;gap:2px;margin-top:6px}.kayd input{width:100%;padding:0;min-height:24px}.seri{display:flex;flex-wrap:wrap;gap:6px;margin:4px 0 8px}.serisec{display:inline-flex;gap:6px;align-items:center;border:1px solid var(--cizgi);background:var(--zemin);border-radius:999px;padding:4px 10px;min-height:32px;cursor:pointer}.serisec[aria-pressed=false]{opacity:.45;text-decoration:line-through}.serisec .sw{width:10px;height:10px;border-radius:2px;display:inline-block}
369
+ .cip[aria-pressed=true]{background:var(--vurgu);border-color:var(--vurgu);color:var(--zemin);font-weight:600}
370
+ .araliklar{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
371
+ input{font:inherit;color:inherit;background:var(--zemin);border:1px solid var(--cizgi);border-radius:8px;padding:6px 8px;min-height:36px;max-width:100%}
372
+ .temizle{border:1px solid var(--cizgi);background:var(--yuzey);border-radius:10px;padding:8px 14px;min-height:40px;cursor:pointer;align-self:end}
373
+ button:focus-visible,input:focus-visible,.nk:focus-visible{outline:3px solid var(--vurgu);outline-offset:2px}
374
+ .nk:focus-visible{outline:none}.nk:focus-visible rect,.nk:focus-visible circle,.nk:focus-visible path{stroke:var(--metin);stroke-width:3}
375
+ .kartlar{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr));gap:12px;margin-bottom:20px}
376
+ .kart{text-align:left;border:1px solid var(--cizgi);background:var(--yuzey);border-radius:14px;padding:14px 16px;cursor:pointer;min-height:44px}
377
+ .kart:hover{border-color:var(--vurgu)}
378
+ .kart .ad{display:block;color:var(--soluk);font-size:.85rem}
379
+ .kart .sayi{display:block;font-size:1.9rem;font-weight:650;line-height:1.2;font-variant-numeric:tabular-nums}
380
+ .kart .kn{display:block;color:var(--soluk);font-size:.78rem}
381
+ .izgara{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));gap:16px;margin-bottom:20px}
382
+ figure.kutu,section.kutu{margin:0;border:1px solid var(--cizgi);background:var(--yuzey);border-radius:14px;padding:14px 16px;min-width:0}
383
+ figcaption{font-weight:600;margin-bottom:6px}
384
+ svg.grafik{width:100%;height:auto;display:block;font:12px system-ui,sans-serif;fill:var(--metin)}
385
+ svg .izgara{stroke:var(--cizgi);stroke-width:1}
386
+ svg .eks{fill:var(--soluk)}svg .soluk{fill:var(--soluk)}svg .deg{font-weight:600}svg .buyuk{font-size:18px;font-weight:650}
387
+ .nk{cursor:pointer}.nk:hover rect,.nk:hover path,.nk:hover circle{filter:brightness(1.12)}
388
+ .nk.secili rect,.nk.secili path,.nk.secili circle{stroke:var(--metin);stroke-width:2.5}
389
+ details{margin-top:6px;font-size:.85rem;color:var(--soluk)}summary{cursor:pointer;min-height:32px}
390
+ table{border-collapse:collapse;width:100%;font-size:.88rem;font-variant-numeric:tabular-nums}
391
+ th,td{text-align:left;padding:6px 10px;border-bottom:1px solid var(--cizgi);white-space:nowrap}
392
+ th{color:var(--soluk);font-weight:600;position:sticky;top:0;background:var(--yuzey)}
393
+ .kay{overflow:auto;max-width:100%}
394
+ td.olcu,th.olcu{background:var(--vurgu-ac)}
395
+ td.sn,th.sn{color:var(--soluk)}
396
+ .uyari{border:1px solid var(--uyari);color:var(--uyari);border-radius:10px;padding:8px 12px;margin:8px 0;font-size:.88rem}
397
+ .hata{border:2px solid var(--uyari);border-radius:14px;padding:16px;background:var(--yuzey)}
398
+ .hata li{margin:4px 0}
399
+ #iz{position:fixed;left:0;right:0;bottom:0;max-height:55vh;overflow:auto;background:var(--yuzey);border-top:2px solid var(--vurgu);padding:12px 16px 16px;box-shadow:0 -6px 24px rgba(0,0,0,.18);z-index:5}
400
+ #iz[hidden]{display:none}
401
+ #iz .ust{display:flex;gap:12px;align-items:flex-start;justify-content:space-between}
402
+ #iz .kapat{border:1px solid var(--cizgi);background:var(--zemin);border-radius:10px;padding:6px 14px;min-height:40px;cursor:pointer}
403
+ #iz h2{margin:0}
404
+ .bos{color:var(--soluk)}
405
+ @media (max-width:520px){body{padding:16px 16px 120px}h1{font-size:1.35rem}.kart .sayi{font-size:1.6rem}}
406
+ `;
407
+
408
+ const PANO_JS = `
409
+ (function(){
410
+ var V=SeraVeri,e=V.kacis;
411
+ function $(s,k){return (k||document).querySelector(s)}
412
+ var T=JSON.parse($('#tanim').textContent),HAM=JSON.parse($('#veri').textContent),K={},IZ={},durum={},acikIz=null,gizli={};
413
+ function seriler(g){
414
+ if(Array.isArray(g.y))return g.y;
415
+ if(Array.isArray(g.seriler)&&g.seriler.length){var is=g.y&&!Array.isArray(g.y)?g.y.islem:'topla';return g.seriler.map(function(q){return typeof q==='string'?{islem:is,alan:q}:q})}
416
+ return g.y?[g.y]:[];
417
+ }
418
+ function seriAd(q){return q.ad||(q.islem==='say'?'satır sayısı':q.alan)}
419
+ Object.keys(HAM).forEach(function(ad){K[ad]=V.veriKumesi(ad,HAM[ad])});
420
+ function kume(ad){return K[ad||T.veri]}
421
+ function alanKumesi(alan){return K[T.veri]&&K[T.veri].turler.hasOwnProperty(alan)?K[T.veri]:Object.keys(K).map(function(a){return K[a]}).filter(function(d){return d.turler.hasOwnProperty(alan)})[0]}
422
+ function tabloya(d){return d.kaynakTur==='json'?'Kayıt':'Satır'}
423
+ function bicimOf(o,ds){
424
+ if(o.bicim)return o.bicim;
425
+ var y=o.tur?(seriler(o)[0]||o):(o.y||o);
426
+ if(y.islem==='say'||y.islem==='benzersiz')return 'sayi';
427
+ return ds&&ds.turler[y.alan]==='tarih'?'tarih':'sayi';
428
+ }
429
+
430
+ /* ---- suzgec arayuzu ---- */
431
+ function filtreCiz(){
432
+ var h='';
433
+ (T.filtreler||[]).forEach(function(f,i){
434
+ var ds=alanKumesi(f.alan);if(!ds)return;
435
+ var t=ds.turler[f.alan],tur=f.tur||(t==='metin'?'secim':'aralik');
436
+ h+='<fieldset class="filtre"><legend>'+e(f.baslik||f.alan)+'</legend>';
437
+ if(tur==='secim'){
438
+ var set={};ds.satirlar.forEach(function(r){if(r.h[f.alan]!=='')set[r.h[f.alan]]=1});
439
+ h+='<div class="cipler">'+Object.keys(set).sort(function(a,b){return a.localeCompare(b,'tr')}).slice(0,40).map(function(d){return '<button type="button" class="cip" aria-pressed="false" data-f="'+i+'" data-d="'+e(d)+'">'+e(d)+'</button>'}).join('')+'</div>';
440
+ }else if(tur==='coklu'){
441
+ var cs={};ds.satirlar.forEach(function(r){if(r.h[f.alan]!=='')cs[r.h[f.alan]]=1});
442
+ h+='<div class="coklu" role="group" aria-label="'+e(f.baslik||f.alan)+' seçimi">'+Object.keys(cs).sort(function(a,b){return a.localeCompare(b,'tr')}).slice(0,200).map(function(d){return '<label class="ck"><input type="checkbox" data-f="'+i+'" data-d="'+e(d)+'"> '+e(d)+'</label>'}).join('')+'</div>';
443
+ }else if(tur==='ara'){
444
+ h+='<input type="search" data-f="'+i+'" data-k="ara" aria-label="'+e(f.alan)+' içinde ara" placeholder="Ara…">';
445
+ }else{
446
+ var tip=t==='tarih'?'date':'number',lo=Infinity,hi=-Infinity;
447
+ ds.satirlar.forEach(function(r){var x=r.v[f.alan];if(typeof x==='number'&&!isNaN(x)){if(x<lo)lo=x;if(x>hi)hi=x}});
448
+ h+='<div class="araliklar"><label>En az <input type="'+tip+'" data-f="'+i+'" data-k="min"></label><label>En çok <input type="'+tip+'" data-f="'+i+'" data-k="max"></label></div>';
449
+ if(t==='sayi'&&hi>lo){
450
+ var st=(hi-lo)/200;
451
+ h+='<div class="kayd"><input type="range" class="kay-r" data-f="'+i+'" data-r="min" min="'+lo+'" max="'+hi+'" step="'+st+'" value="'+lo+'" aria-label="'+e(f.alan)+' alt sınır"><input type="range" class="kay-r" data-f="'+i+'" data-r="max" min="'+lo+'" max="'+hi+'" step="'+st+'" value="'+hi+'" aria-label="'+e(f.alan)+' üst sınır"></div>';
452
+ }
453
+ }
454
+ h+='</fieldset>';
455
+ });
456
+ if(h)h+='<button type="button" class="temizle" id="temizle">Süzgeçleri temizle</button>';
457
+ $('#filtreler').innerHTML=h;
458
+ }
459
+ function filtreOku(){
460
+ durum={};
461
+ (T.filtreler||[]).forEach(function(f,i){
462
+ var ds=alanKumesi(f.alan);if(!ds)return;
463
+ var sec=[].map.call(document.querySelectorAll('.cip[data-f="'+i+'"][aria-pressed="true"]'),function(b){return b.getAttribute('data-d')});
464
+ [].forEach.call(document.querySelectorAll('input[type=checkbox][data-f="'+i+'"]:checked'),function(c){sec.push(c.getAttribute('data-d'))});
465
+ if(sec.length){durum[f.alan]={secim:sec};return}
466
+ var o={},t=ds.turler[f.alan];
467
+ [].forEach.call(document.querySelectorAll('input[data-k][data-f="'+i+'"]'),function(inp){
468
+ var k=inp.getAttribute('data-k'),v=inp.value;if(v==='')return;
469
+ if(k==='ara')o.ara=v;else o[k]=t==='tarih'?V.tarihCoz(v):V.sayiCoz(v);
470
+ });
471
+ Object.keys(o).forEach(function(k){if(typeof o[k]==='number'&&isNaN(o[k]))delete o[k]});
472
+ if(Object.keys(o).length)durum[f.alan]=o;
473
+ });
474
+ }
475
+
476
+ /* ---- kaynak izi ---- */
477
+ function izKaydet(id,bilgi){IZ[id]=bilgi;return id}
478
+ function izAc(id){
479
+ var b=IZ[id];if(!b)return;
480
+ acikIz=id;
481
+ var ds=b.ds,rows=b.satirlar,ad=tabloya(ds),sinir=200;
482
+ [].forEach.call(document.querySelectorAll('.secili'),function(x){x.classList.remove('secili')});
483
+ var sec=document.querySelector('[data-iz="'+id+'"]');if(sec)sec.classList.add('secili');
484
+ var h='<div class="ust"><div><h2 id="iz-baslik" tabindex="-1">Kaynak izi: '+e(b.baslik)+' = '+e(b.deger)+'</h2>'+
485
+ '<p class="alt">'+e(b.aciklama)+' · '+rows.length+' '+ad.toLowerCase()+' · dosya: '+e(ds.ad)+(b.filtreli?' · şu anki süzgeçler uygulanmış':'')+'</p></div>'+
486
+ '<button type="button" class="kapat" id="iz-kapat">Kapat (Esc)</button></div>';
487
+ if(!rows.length)h+='<p class="bos">Bu değeri üreten satır yok.</p>';
488
+ else{
489
+ h+='<div class="kay"><table><thead><tr><th class="sn">'+ad+' no</th>'+ds.basliklar.map(function(c){return '<th'+(c===b.alan?' class="olcu"':'')+'>'+e(c)+'</th>'}).join('')+'</tr></thead><tbody>';
490
+ rows.slice(0,sinir).forEach(function(r){
491
+ h+='<tr><td class="sn">'+r.n+'</td>'+ds.basliklar.map(function(c){return '<td'+(c===b.alan?' class="olcu"':'')+'>'+e(r.h[c])+'</td>'}).join('')+'</tr>';
492
+ });
493
+ h+='</tbody></table></div>';
494
+ if(rows.length>sinir)h+='<p class="alt">İlk '+sinir+' satır gösteriliyor (toplam '+rows.length+').</p>';
495
+ }
496
+ var p=$('#iz');p.innerHTML=h;p.hidden=false;
497
+ $('#iz-kapat').onclick=izKapat;
498
+ $('#iz-baslik').focus({preventScroll:true});
499
+ }
500
+ function izKapat(){
501
+ $('#iz').hidden=true;acikIz=null;
502
+ [].forEach.call(document.querySelectorAll('.secili'),function(x){x.classList.remove('secili')});
503
+ }
504
+
505
+ /* ---- cizim ---- */
506
+ function ciz(){
507
+ var kartH='',izgaraH='',tabloH='',n=0,uyar=[];
508
+ var ozet=Object.keys(K).map(function(a){
509
+ var s=V.filtrele(K[a],durum).length;
510
+ return e(a)+': '+V.bicim(s)+' / '+V.bicim(K[a].satirlar.length)+' '+tabloya(K[a]).toLowerCase()+' gösteriliyor';
511
+ }).join(' · ');
512
+ $('#ozet').innerHTML=ozet;
513
+ Object.keys(K).forEach(function(a){K[a].uyarilar.forEach(function(u){uyar.push(a+': '+u)})});
514
+ $('#uyarilar').innerHTML=uyar.map(function(u){return '<p class="uyari">'+e(u)+'</p>'}).join('');
515
+ IZ={};
516
+ (T.kartlar||[]).forEach(function(c,i){
517
+ var ds=kume(c.veri),rows=V.filtrele(ds,durum),h=V.hesapla(rows,c.islem,c.alan);
518
+ var tur=bicimOf(c,ds),txt=V.bicim(h.deger,tur);
519
+ var id=izKaydet('k'+i,{baslik:c.baslik,deger:txt,aciklama:h.aciklama,satirlar:h.kullanilan,ds:ds,alan:c.alan,filtreli:Object.keys(durum).length>0});
520
+ kartH+='<button type="button" class="kart" data-iz="'+id+'" aria-label="'+e(c.baslik+': '+txt+'. Kaynak satırlarını göster')+'"><span class="ad">'+e(c.baslik)+'</span><span class="sayi">'+e(txt)+'</span><span class="kn">'+h.kullanilan.length+' '+tabloya(ds).toLowerCase()+' · kaynağı göster</span></button>';
521
+ });
522
+ (T.grafikler||[]).forEach(function(g,i){
523
+ var sl=g.tur==='dagilim'?[]:seriler(g),lej='';
524
+ if(sl.length>1)lej='<div class="seri" role="group" aria-label="Gösterilecek seriler">'+sl.map(function(q,j){return '<button type="button" class="serisec" data-c="'+i+'" data-s="'+j+'" aria-pressed="'+(gizli[i+':'+j]?'false':'true')+'"><span class="sw" style="background:var(--p'+(j%8+1)+')"></span>'+e(seriAd(q))+'</button>'}).join('')+'</div>';
525
+ izgaraH+='<figure class="kutu"><figcaption>'+e(g.baslik)+'</figcaption>'+lej+'<div class="cizim" data-c="'+i+'"></div><div class="tab" data-t="'+i+'"></div></figure>';
526
+ });
527
+ (T.tablolar||[]).forEach(function(tb,i){
528
+ var ds=kume(tb.veri),rows=V.filtrele(ds,durum).slice();
529
+ if(tb.sirala){
530
+ var al=tb.sirala,ters=tb.azalan?-1:1;
531
+ rows.sort(function(a,b){var x=a.v[al],y=b.v[al];if(x===y)return 0;if(x==null)return 1;if(y==null)return -1;return (x<y?-1:1)*ters});
532
+ }
533
+ var cols=tb.sutunlar||ds.basliklar,say=rows.length;rows=rows.slice(0,tb.adet||10);
534
+ tabloH+='<section class="kutu" style="margin-bottom:16px"><h2>'+e(tb.baslik)+'</h2>'+(rows.length?'<div class="kay"><table><thead><tr><th class="sn">'+tabloya(ds)+' no</th>'+cols.map(function(c){return '<th>'+e(c)+'</th>'}).join('')+'</tr></thead><tbody>'+rows.map(function(r){return '<tr><td class="sn">'+r.n+'</td>'+cols.map(function(c){return '<td>'+e(r.h[c])+'</td>'}).join('')+'</tr>'}).join('')+'</tbody></table></div>':'<p class="bos">Bu süzgeçle satır yok.</p>')+'<p class="alt">'+rows.length+' / '+say+' satır gösteriliyor</p></section>';
535
+ });
536
+ $('#kartlar').innerHTML=kartH;
537
+ $('#grafikler').innerHTML=izgaraH;
538
+ $('#tablolar').innerHTML=tabloH;
539
+ grafikCiz();
540
+ if(acikIz&&IZ[acikIz])izAc(acikIz);else if(acikIz)izKapat();
541
+ }
542
+ function grafikCiz(){
543
+ (T.grafikler||[]).forEach(function(g,i){
544
+ var kap=document.querySelector('.cizim[data-c="'+i+'"]');if(!kap)return;
545
+ var ds=kume(g.veri),rows=V.filtrele(ds,durum),pts=[],tur=bicimOf(g,ds),dag=g.tur==='dagilim';
546
+ var fmt=function(x,kisa,eks){return V.bicim(x,eks==='x'?'sayi':tur,kisa)};
547
+ var filtreli=Object.keys(durum).length>0;
548
+ var SL=dag?[]:seriler(g),gor=[];
549
+ SL.forEach(function(q,j){if(!gizli[i+':'+j])gor.push(j)});
550
+ if(SL.length&&!gor.length)gor=[0];
551
+ var sinir=g.sinir||(g.tur==='halka'?7:g.tur==='cubuk'?12:0),sirala=g.sirala||(g.tur==='cizgi'||g.tur==='alan'?'':'deger');
552
+ if(dag){
553
+ rows.forEach(function(r){if(typeof r.v[g.x]==='number'&&typeof r.v[g.yAlan]==='number'){
554
+ pts.push({etiket:tabloya(ds)+' '+r.n,deger:r.v[g.yAlan],x:r.v[g.x],y:r.v[g.yAlan],satirlar:[r]})}});
555
+ if(pts.length>600){var adim=Math.ceil(pts.length/600);pts=pts.filter(function(p,k){return k%adim===0})}
556
+ }else{
557
+ var G={};
558
+ gor.forEach(function(j,n){
559
+ var q=SL[j];
560
+ G[j]=V.grupla(ds,rows,g.x,q.islem,q.alan,{hassasiyet:g.grupla,sinir:n===0?sinir:0,sirala:n===0?sirala:''});
561
+ });
562
+ var haritalar={};
563
+ gor.forEach(function(j){haritalar[j]={};G[j].forEach(function(q){haritalar[j][q.anahtar]=q})});
564
+ G[gor[0]].forEach(function(q){
565
+ var dg=gor.map(function(j){var m=haritalar[j][q.anahtar];return m?m.deger:null});
566
+ pts.push({etiket:q.etiket,deger:q.deger,degerler:dg,satirlar:q.kullanilan,grup:q,anahtar:q.anahtar});
567
+ });
568
+ }
569
+ var coklu=!dag&&SL.length>1;
570
+ var ynBaslik=dag?g.yAlan:(coklu?'değerler':seriAd(SL[0]));
571
+ var secenek={g:kap.clientWidth||520,bicim:fmt,xBaslik:g.x,yBaslik:ynBaslik,baslik:g.baslik,toplamEtiketi:SL[0]&&SL[0].alan?SL[0].alan:'satır'};
572
+ if(coklu)secenek.seriler=gor.map(function(j){return {ad:seriAd(SL[j]),renk:j}});
573
+ kap.innerHTML=V.grafik(g.tur,pts.map(function(p){return {etiket:p.etiket,deger:p.deger,degerler:p.degerler,x:p.x,y:p.y}}),secenek);
574
+ [].forEach.call(kap.querySelectorAll('.nk'),function(el){
575
+ var k=+el.getAttribute('data-i'),p=pts[k];if(!p)return;
576
+ var sIdx=el.hasAttribute('data-s')?+el.getAttribute('data-s'):0,j=dag?0:gor[sIdx],q=dag?null:SL[j];
577
+ var satirlar=p.satirlar,deger=p.deger;
578
+ if(coklu){var m=null;G[j].forEach(function(z){if(z.anahtar===p.anahtar)m=z});satirlar=m?m.kullanilan:[];deger=m?m.deger:0}
579
+ var aciklama=dag?'iki sütun değeri':(q.islem==='say'?'satır sayısı':q.alan+' için '+q.islem);
580
+ var id=izKaydet('g'+i+'-'+k+(coklu?'-'+j:''),{baslik:p.etiket,deger:dag?fmt(p.x,false,'x')+' / '+fmt(p.y):fmt(deger),aciklama:g.baslik+' · '+aciklama,satirlar:satirlar,ds:ds,alan:dag?g.yAlan:(q&&q.alan),filtreli:filtreli});
581
+ el.setAttribute('data-iz',id);
582
+ if(acikIz===id)el.classList.add('secili');
583
+ });
584
+ var tab=document.querySelector('.tab[data-t="'+i+'"]');
585
+ if(tab&&!dag&&pts.length){
586
+ var bas=coklu?gor.map(function(j){return '<th>'+e(seriAd(SL[j]))+'</th>'}).join(''):'<th>Değer</th><th>Satır</th>';
587
+ tab.innerHTML='<details><summary>Verileri tablo olarak göster</summary><div class="kay"><table><thead><tr><th>'+e(g.x)+'</th>'+bas+'</tr></thead><tbody>'+pts.map(function(p){
588
+ var h2=coklu?p.degerler.map(function(x){return '<td>'+(x==null?'':e(fmt(x)))+'</td>'}).join(''):'<td>'+e(fmt(p.deger))+'</td><td>'+p.satirlar.length+'</td>';
589
+ return '<tr><td>'+e(p.etiket)+'</td>'+h2+'</tr>';
590
+ }).join('')+'</tbody></table></div></details>';
591
+ }
592
+ });
593
+ }
594
+
595
+ /* ---- olaylar ---- */
596
+ document.addEventListener('click',function(ev){
597
+ var t=ev.target,cip=t.closest&&t.closest('.cip');
598
+ if(cip){cip.setAttribute('aria-pressed',cip.getAttribute('aria-pressed')==='true'?'false':'true');filtreOku();ciz();return}
599
+ if(t.id==='temizle'){
600
+ [].forEach.call(document.querySelectorAll('.cip'),function(b){b.setAttribute('aria-pressed','false')});
601
+ [].forEach.call(document.querySelectorAll('#filtreler input'),function(x){
602
+ if(x.type==='checkbox')x.checked=false;
603
+ else if(x.type==='range')x.value=x.getAttribute(x.getAttribute('data-r')==='min'?'min':'max');
604
+ else x.value='';
605
+ });
606
+ filtreOku();ciz();return;
607
+ }
608
+ var ss=t.closest&&t.closest('.serisec');
609
+ if(ss){
610
+ var ci=ss.getAttribute('data-c'),sj=ss.getAttribute('data-s'),kk=ci+':'+sj,gorunen=document.querySelectorAll('.serisec[data-c="'+ci+'"][aria-pressed="true"]').length;
611
+ if(!gizli[kk]&&gorunen<=1)return;
612
+ gizli[kk]=!gizli[kk];ss.setAttribute('aria-pressed',gizli[kk]?'false':'true');grafikCiz();return;
613
+ }
614
+ var iz=t.closest&&t.closest('[data-iz]');
615
+ if(iz&&iz.getAttribute('data-iz'))izAc(iz.getAttribute('data-iz'));
616
+ });
617
+ document.addEventListener('input',function(ev){
618
+ var x=ev.target;
619
+ if(x.closest&&x.closest('#filtreler')&&x.tagName==='INPUT'){
620
+ if(x.type==='range'){
621
+ var kar=document.querySelector('input[data-k="'+x.getAttribute('data-r')+'"][data-f="'+x.getAttribute('data-f')+'"]');
622
+ var alt=document.querySelector('input[data-r="min"][data-f="'+x.getAttribute('data-f')+'"]'),ust=document.querySelector('input[data-r="max"][data-f="'+x.getAttribute('data-f')+'"]');
623
+ if(alt&&ust&&+alt.value>+ust.value){if(x===alt)alt.value=ust.value;else ust.value=alt.value}
624
+ if(kar)kar.value=x.value;
625
+ }else if(x.getAttribute('data-k')==='min'||x.getAttribute('data-k')==='max'){
626
+ var rr=document.querySelector('input[data-r="'+x.getAttribute('data-k')+'"][data-f="'+x.getAttribute('data-f')+'"]');
627
+ if(rr&&x.value!=='')rr.value=x.value;
628
+ }
629
+ filtreOku();ciz();
630
+ }
631
+ });
632
+ document.addEventListener('keydown',function(ev){
633
+ if(ev.key==='Escape'&&acikIz)izKapat();
634
+ var el=ev.target;
635
+ if((ev.key==='Enter'||ev.key===' ')&&el.classList&&el.classList.contains('nk')&&el.getAttribute('data-iz')){ev.preventDefault();izAc(el.getAttribute('data-iz'))}
636
+ });
637
+ var yenile;
638
+ addEventListener('resize',function(){clearTimeout(yenile);yenile=setTimeout(grafikCiz,150)});
639
+ window.__pano={K:K,durum:function(){return durum},ciz:ciz};
640
+ filtreCiz();ciz();
641
+ })();
642
+ `;
643
+
644
+ function sayfa(ad: string, govde: string, scriptler = ""): string {
645
+ return `<!doctype html>
646
+ <html lang="tr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
647
+ <meta name="color-scheme" content="light dark"><title>${ad.replace(/[<&]/g, "")}</title>
648
+ <style>${PANO_CSS}</style></head><body><div class="sar">${govde}</div>${scriptler}</body></html>`;
649
+ }
650
+
651
+ export function hataSayfasi(ad: string, sorunlar: string[]): string {
652
+ const e = (s: string) =>
653
+ s.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]!);
654
+ return sayfa(
655
+ ad,
656
+ `<h1>${e(ad)}</h1><div class="hata" role="alert"><h2>Pano henüz kurulamadı</h2><ul>${sorunlar.map((s) => `<li>${e(s)}</li>`).join("")}</ul><p class="alt">Veriyi ya da pano.json dosyasını düzeltince bu sayfa kendiliğinden yenilenir.</p></div>`,
657
+ );
658
+ }
659
+
660
+ /** Pano HTML'i: veri ham metin olarak gomulur, hesap tarayicida yapilir. Gomulu JSON '<' kacisli (</script> enjeksiyonu yok). */
661
+ export function panoHtml(t: PanoTanim, ham: Record<string, string>): string {
662
+ return sayfa(
663
+ t.ad,
664
+ `<header><h1>${t.ad.replace(/[<&]/g, "")}</h1><p class="alt" id="ozet" aria-live="polite"></p></header>
665
+ <div id="uyarilar"></div>
666
+ <div class="filtreler" id="filtreler" role="group" aria-label="Süzgeçler"></div>
667
+ <div class="kartlar" id="kartlar"></div>
668
+ <div class="izgara" id="grafikler"></div>
669
+ <div id="tablolar"></div>
670
+ <aside id="iz" hidden aria-label="Kaynak izi" role="region"></aside>`,
671
+ `<script type="application/json" id="tanim">${kacisJson(t)}</script><script type="application/json" id="veri">${kacisJson(ham)}</script><script>${VERI_JS}</script><script>${PANO_JS}</script>`,
672
+ );
673
+ }
674
+
675
+ // ---------------------------------------------------------------- proje islemleri
676
+
677
+ export interface PanoUretim {
678
+ html: string;
679
+ sorunlar: string[];
680
+ }
681
+
682
+ /** pano.json (yoksa otomatik) + veri/ -> pano.html icerigi. Sorun varsa hata sayfasi + sorun listesi. */
683
+ export function panoUret(kok: string): PanoUretim {
684
+ const b = bildirimOku(kok);
685
+ let ham: Record<string, string>;
686
+ try {
687
+ ham = hamVeriOku(kok);
688
+ } catch (e) {
689
+ return { html: hataSayfasi(b.ad, [(e as Error).message]), sorunlar: [(e as Error).message] };
690
+ }
691
+ const kumeler: Record<string, VeriKumesi> = {};
692
+ const sorunlar: string[] = [];
693
+ for (const [ad, m] of Object.entries(ham)) {
694
+ try {
695
+ kumeler[ad] = SeraVeri.veriKumesi(ad, m);
696
+ } catch (e) {
697
+ sorunlar.push(`veri/${ad}: okunamadi (${(e as Error).message})`);
698
+ }
699
+ }
700
+ let tanim: PanoTanim | undefined;
701
+ const yol = join(kok, PANO_TANIM);
702
+ if (existsSync(yol)) {
703
+ try {
704
+ tanim = tanimNormal(JSON.parse(readFileSync(yol, "utf8")));
705
+ } catch (e) {
706
+ sorunlar.push(`${PANO_TANIM}: ${(e as Error).message}`);
707
+ }
708
+ } else {
709
+ const ilkAd = Object.keys(kumeler)[0];
710
+ if (ilkAd) tanim = panoOtomatik(b.ad, ilkAd, kumeler[ilkAd]!);
711
+ }
712
+ if (tanim) {
713
+ if (!tanim.veri) tanim.veri = Object.keys(kumeler)[0] ?? "";
714
+ sorunlar.push(...panoDogrula(tanim, kumeler));
715
+ }
716
+ if (!tanim || sorunlar.length) {
717
+ return { html: hataSayfasi(b.ad, sorunlar.length ? sorunlar : ["Pano tanimi okunamadi."]), sorunlar };
718
+ }
719
+ return { html: panoHtml(tanim, ham), sorunlar: [] };
720
+ }
721
+
722
+ /** pano.html'i yazar (icerik ayniysa dokunmaz). Donus: degisti mi + sorunlar. */
723
+ export function panoYaz(kok: string): { degisti: boolean; sorunlar: string[] } {
724
+ const { html, sorunlar } = panoUret(kok);
725
+ const yol = kokIci(kok, PANO_DOSYA);
726
+ let eski = "";
727
+ try {
728
+ eski = readFileSync(yol, "utf8");
729
+ } catch {
730
+ // henuz yok
731
+ }
732
+ if (eski === html) return { degisti: false, sorunlar };
733
+ atomikYaz(yol, html);
734
+ return { degisti: true, sorunlar };
735
+ }
736
+
737
+ export interface VeriYukleSonuc {
738
+ dosya: string;
739
+ yeniProje: boolean;
740
+ kume: VeriKumesi;
741
+ }
742
+
743
+ /** Veri dosyasini veri/ altina yazar (ayni ad = guncelleme); proje yoksa pano projesi kurar. */
744
+ export function veriYukle(kok: string, ad: string, icerik: string, projeAdi?: string): VeriYukleSonuc {
745
+ let dosya = veriAdiTemizle(ad);
746
+ if (/\.xlsx$/i.test(dosya)) dosya = dosya.replace(/\.xlsx$/i, ".csv"); // icerik zaten CSV metnine cevrilmis gelir
747
+ if (icerik.length > TOPLAM_SINIR) throw new Error("Veri dosyasi 6 MB'i asiyor.");
748
+ const kume = SeraVeri.veriKumesi(dosya, icerik); // gecersizse once burada hata
749
+ if (!kume.basliklar.length || !kume.satirlar.length)
750
+ throw new Error("Veri dosyasinda baslik ve en az bir satir olmali.");
751
+ let yeniProje = false;
752
+ if (!existsSync(join(kok, BILDIRIM))) {
753
+ olustur(kok, projeAdi || dosya.replace(/\.[^.]+$/, ""), "pano", [
754
+ { id: "pano", ad: "Pano", dosya: PANO_DOSYA, genislik: 1440, yukseklik: 1100 },
755
+ ]);
756
+ yeniProje = true;
757
+ } else if (bildirimOku(kok).tur !== "pano") {
758
+ throw new Error("Bu klasor bir veri panosu projesi degil; bos ya da pano projesi olan bir klasor secin.");
759
+ }
760
+ mkdirSync(join(kok, VERI_KLASORU), { recursive: true });
761
+ atomikYaz(join(kok, VERI_KLASORU, dosya), icerik);
762
+ return { dosya, yeniProje, kume };
763
+ }