@bendyline/gezel-service 1.0.7 → 1.1.0
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.
- package/dist/bin/gezeld.js +6253 -3616
- package/dist/handboek-content/whats-new/1.26224.md +1 -0
- package/dist/handboek-content/whats-new/1.26226.md +1 -0
- package/dist/handboek-content/whats-new/1.26231.md +1 -0
- package/dist/handboek-content/whats-new/1.26234.md +1 -0
- package/dist/handboek-content/whats-new/1.26237.md +1 -0
- package/dist/handboek-content/whats-new/1.26244.md +2 -1
- package/dist/handboek-content/whats-new/1.26247.md +88 -0
- package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
- package/dist/index-store/static-index-worker.js +17 -1
- package/dist/index.d.ts +473 -209
- package/dist/index.js +6251 -3614
- package/dist/memory/embed-worker.js +58 -2
- package/dist/memory/image-embed-worker.js +8 -0
- package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
- package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
- package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
- package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
- package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
- package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
- package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
- package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
- package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
- package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
- package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
- package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
- package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
- package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
- package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
- package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
- package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
- package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
- package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
- package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
- package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
- package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
- package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
- package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
- package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
- package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
- package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
- package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
- package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
- package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
- package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
- package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
- package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
- package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
- package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
- package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
- package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
- package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
- package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
- package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
- package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
- package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
- package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
- package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
- package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
- package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
- package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
- package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
- package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
- package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
- package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
- package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
- package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
- package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
- package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
- package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
- package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
- package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
- package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
- package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
- package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
- package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
- package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
- package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
- package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
- package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
- package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
- package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
- package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
- package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
- package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
- package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
- package/dist/ui/assets/data-B2kHjlc5.js +1 -0
- package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
- package/dist/ui/assets/dist-BaHut5iX.js +2 -0
- package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
- package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
- package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
- package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
- package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
- package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
- package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
- package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
- package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
- package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
- package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
- package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
- package/dist/ui/assets/html-BGVOMhkv.js +253 -0
- package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
- package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
- package/dist/ui/assets/index-B8NcxqcR.css +1 -0
- package/dist/ui/assets/index-C0DYtvfg.js +34 -0
- package/dist/ui/assets/index-J8TOMdvV.js +2 -0
- package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
- package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
- package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
- package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
- package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
- package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
- package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
- package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
- package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
- package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
- package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
- package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
- package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
- package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
- package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
- package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
- package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
- package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
- package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
- package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
- package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
- package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
- package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
- package/dist/ui/assets/table-fcouR4db.js +1 -0
- package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
- package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
- package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
- package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
- package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
- package/dist/ui/index.html +19 -18
- package/package.json +11 -11
- package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
- package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
- package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
- package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
- package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
- package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
- package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
- package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
- package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
- package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
- package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
- package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
- package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
- package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
- package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
- package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
- package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
- package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
- package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
- package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
- package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
- package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
- package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
- package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
- package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
- package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
- package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
- package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
- package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
- package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
- package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
- package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
- package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
- package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
- package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
- package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
- package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
- package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
- package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
- package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
- package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
- package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
- package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
- package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
- package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
- package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
- package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
- package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
- package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
- package/dist/ui/assets/html-C9TlzI57.js +0 -253
- package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
- package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
- package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
- package/dist/ui/assets/index-DXWR4qW1.js +0 -34
- package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
- package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
- package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
- package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
- package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
- package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
- package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
- package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
- package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
- package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
- package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{n,t as r}from"./jsx-runtime-CEpd2cAX.js";import{t as i}from"./api-BPraLwsh.js";import{n as a,t as o}from"./document-companion-BQk2kS0F.js";import{t as s}from"./preload-helper-Czpn1I53.js";import{n as c}from"./styles-CKVKwqoQ.js";import{ht as l,o as u,x as d,z as f}from"./index-C0DYtvfg.js";import"./storage-D8pE2zg0.js";import{a as p,c as m,n as h,o as g,s as _,t as v}from"./SquisqIntegration-6v3yNOIP.js";import{c as y,d as b,f as x,h as S,i as C,m as w,p as T,s as E}from"./file-browser-c2tf4MIb.js";import{a as D,c as O,d as k,l as A,n as j,o as M,r as N,s as P,t as F,u as I}from"./outside-in-D73N1g_b.js";import{t as L}from"./markdown-baseline-9B52XlX2.js";import{t as R}from"./TransformToolbarButton-BWYkEB0d.js";var z=e(n(),1),B=r();function V(e){let t=e.lastIndexOf(`/`);return t<0?e:e.slice(t+1)}async function H(e,t){let n=F(t,(await i.listDocuments(``,!0)).files.filter(e=>!e.isDirectory).map(e=>e.path)),r;if(n)r=(await i.readDocument(n)).content;else{let a=await j(await(await i.fetchDocumentBlob(e)).arrayBuffer(),t),o=_({root:t.companionDirectory,client:i,primaryDocumentFilename:t.markdownFilename});for(let t of await a.container.listFiles()){if(/\.md$/i.test(t.path)||!t.path.includes(`/`)&&V(t.path).toLocaleLowerCase(`en-US`)===V(e).toLocaleLowerCase(`en-US`))continue;let n=await a.container.readFile(t.path);n&&await o.writeFile(t.path,n,t.mimeType)}r=k(a.markdown,t),await o.writeDocument(r,t.markdownFilename),n=t.markdownPath}let a=k(r,t);return a!==r&&(await i.writeDocument(n,a),r=a),{sourcePath:n,content:r,editingEnabled:A(t.format)&&N(r)}}function U({path:e,layout:t}){let[n,r]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!1);(0,z.useEffect)(()=>{let n=!1;return r(null),o(null),c(null),H(e,t).then(e=>{n||r(e)}).catch(e=>{n||o(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[t,e]);let d=(0,z.useCallback)(async()=>{if(!(!n||l)){if(!A(t.format)){c(`CSV data previews are read-only.`);return}u(!0),c(null);try{if(!(await i.listDocuments(``,!0)).files.some(e=>e.path===t.backupPath)){let e=await i.fetchDocumentBlob(t.targetPath);await i.writeDocumentBinary(t.backupPath,e,e.type||`application/octet-stream`)}let e=I(n.content,t);await i.writeDocument(n.sourcePath,e),r({...n,content:e,editingEnabled:!0})}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[l,t,n]);return a?(0,B.jsx)(`div`,{className:`placeholder`,children:(0,B.jsxs)(`p`,{children:[`Couldn't open `,(0,B.jsx)(`code`,{children:e}),`: `,a]})}):n?(0,B.jsx)(W,{path:e,layout:t,prepared:n,enabling:l,enableError:s,onEnableEditing:d},`${n.sourcePath}:${n.editingEnabled?`editable`:`readonly`}`):(0,B.jsxs)(`p`,{className:`placeholder`,children:[`Importing `,e,` for viewing…`]})}function W({path:e,layout:t,prepared:n,enabling:r,enableError:o,onEnableEditing:g}){let y=l(),x=v(),C=(0,z.useMemo)(()=>_({root:t.companionDirectory,client:i,primaryDocumentFilename:V(n.sourcePath)}),[t.companionDirectory,n.sourcePath]),E=(0,z.useMemo)(()=>S(C),[C]),j=(0,z.useMemo)(()=>w({client:i,currentDocumentPath:n.sourcePath}),[n.sourcePath]),N=(0,z.useMemo)(()=>a(n.sourcePath),[n.sourcePath]),P=(0,z.useMemo)(()=>p(E,N),[E,N]),F=(0,z.useMemo)(()=>f(E),[E]),I=(0,z.useCallback)(async r=>{let a=k(r,t),o=await i.listDocuments(``,!0),c=t.format===`html`?O(t.targetPath,new Set(o.files.filter(e=>e.isDirectory).map(e=>e.path.replace(/^\/+/,``)))):void 0,l=await M(a,t,E,c?D(t.parentDirectory,c):void 0);if(await i.writeDocument(n.sourcePath,a),c){let{PLAYER_BUNDLE:e}=await s(async()=>{let{PLAYER_BUNDLE:e}=await import(`./standalone-source-q_Zzd1bd.js`);return{PLAYER_BUNDLE:e}},[]);await i.writeDocument(c,e)}await i.writeDocumentBinary(t.targetPath,l.bytes,l.mimeType),u(e)},[E,t,e,n.sourcePath]),H=(0,z.useMemo)(()=>L(n.content),[n.content]),U=d({resourceKey:`outside-in:documents:${n.sourcePath}`,initialValue:H,save:I});(0,z.useEffect)(()=>()=>F.dispose(),[F]);let W=(0,z.useCallback)(e=>{U.update(e)},[U.update]);return(0,B.jsxs)(`section`,{className:`document-detail`,"data-testid":`document-detail`,children:[!n.editingEnabled&&(0,B.jsxs)(`output`,{className:`outside-in-readonly-banner`,children:[A(t.format)?(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`strong`,{children:[t.format.toUpperCase(),` preview · read-only.`]}),` If you enable editing via markdown, the structure of your `,t.format.toUpperCase(),` will not be fully preserved.`]}):(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:`CSV data preview · source preserved.`}),` Large datasets stay in a sidecar and open as a virtualized grid.`]}),o&&(0,B.jsxs)(`span`,{className:`error`,children:[`Could not enable editing: `,o]}),A(t.format)&&(0,B.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void g(),children:r?`Preparing…`:`Enable editing`})]}),(0,B.jsx)(`div`,{className:`editor-wrap`,children:(0,B.jsx)(c,{initialMarkdown:U.desiredValue(),fileName:n.sourcePath,initialView:`wysiwyg`,readOnly:!n.editingEnabled,onChange:n.editingEnabled?W:void 0,height:`100%`,colorScheme:y,fullWidth:!0,workspaceContainer:P,mediaProvider:F,documentLinkProvider:j,calcEngineFactory:n.editingEnabled?T:void 0,proofing:x,proofingIgnoreStore:h,allowVersioning:n.editingEnabled,versionBasename:N,toolbarSlotAfterActions:(0,B.jsxs)(B.Fragment,{children:[n.editingEnabled&&(0,B.jsx)(R,{context:`generic`}),(0,B.jsx)(b,{fileName:e})]}),statusBarSlotRight:n.editingEnabled?(0,B.jsx)(m,{autosave:U}):void 0})})]})}var G=t({DocumentDetail:()=>q});function K(e){let t=e.slice(e.lastIndexOf(`/`)+1);return!t.includes(`.`)||/\.(md|markdown|mdx)$/i.test(t)}function q({path:e}){let t=(0,z.useMemo)(()=>P(e),[e]);return t?(0,B.jsx)(U,{path:e,layout:t}):(0,B.jsx)(Y,{path:e})}var J=e=>i.fetchDocumentBlob(e);function Y({path:e}){let t=l(),n=v(),[r,s]=(0,z.useState)(null),[f,S]=(0,z.useState)(void 0),[D,O]=(0,z.useState)(null),k=(0,z.useCallback)(async t=>{await i.writeDocument(e,t),u(e)},[e]),A=d({resourceKey:`document:${e}`,initialValue:r??``,save:k}),{root:j,parentDirectory:M,companionName:N,primaryDocumentFilename:P}=(0,z.useMemo)(()=>o(e),[e]),F=(0,z.useMemo)(()=>_({root:j,client:i,referencePrefix:N}),[N,j]),I=(0,z.useMemo)(()=>_({root:M,client:i,primaryDocumentFilename:P}),[M,P]),V=(0,z.useMemo)(()=>g(F,N,I),[N,F,I]),H=(0,z.useMemo)(()=>a(e),[e]),U=(0,z.useMemo)(()=>p(F,H,[{container:I,basenames:[P,H]}],I),[F,I,P,H]),W=(0,z.useMemo)(()=>w({client:i,currentDocumentPath:e}),[e]);(0,z.useEffect)(()=>()=>V.dispose(),[V]),(0,z.useEffect)(()=>{let t=!1;return s(null),S(void 0),O(null),(async()=>{try{let n=await i.readDocument(e);if(t)return;S(n.size);let r=K(e)?L(n.content):n.content;s(A.hydrate(r))}catch(e){t||O(e.message)}})(),()=>{t=!0}},[e,A.hydrate]);let G=(0,z.useCallback)(e=>{A.update(e)},[A.update]);if(D)return(0,B.jsx)(`div`,{className:`placeholder`,children:(0,B.jsxs)(`p`,{children:[`Couldn't open `,(0,B.jsx)(`code`,{children:e}),`: `,D]})});if(r===null)return(0,B.jsxs)(`p`,{className:`placeholder`,children:[`Loading `,e,`…`]});if(y(r))return(0,B.jsx)(E,{content:C,path:e,fetchBlob:J,...f===void 0?{}:{sizeBytes:f}});let q=K(e);return(0,B.jsx)(`section`,{className:`document-detail`,"data-testid":`document-detail`,children:(0,B.jsx)(`div`,{className:`editor-wrap`,children:(0,B.jsx)(c,{initialMarkdown:r,fileName:e,onChange:G,height:`100%`,colorScheme:t,fullWidth:!0,workspaceContainer:q?U:null,mediaProvider:q?V:null,documentLinkProvider:q?W:null,calcEngineFactory:q?T:void 0,proofing:q?n:null,proofingIgnoreStore:h,allowVersioning:q,versionBasename:H,toolbarSlotAfterActions:q?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(R,{context:`generic`}),(0,B.jsx)(b,{fileName:e})]}):void 0,toolbarSlotRight:q?(0,B.jsx)(x,{selectedFile:e,mediaContainer:I,mediaSource:{kind:`documents`}}):void 0,statusBarSlotRight:(0,B.jsx)(m,{autosave:A})})})})}export{G as n,q as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{ht as r,vt as i}from"./dist-BqGwkOe5.js";import{t as a}from"./api-BPraLwsh.js";import{d as o,f as s,h as c,u as l}from"./document-companion-BQk2kS0F.js";import"./schemas-JY4jmLbC.js";import{S as u,c as d,ht as ee,s as f}from"./index-C0DYtvfg.js";import"./SquisqIntegration-6v3yNOIP.js";import{l as p,n as m,s as h,t as g,u as _}from"./file-browser-c2tf4MIb.js";import{t as te}from"./ProjectGitStatusBar-CjZxG54t.js";import{t as v}from"./DocumentDetail-ClDRj2N-.js";var y=n(),b=e(t(),1);function x({name:e,entries:t,onOpenFile:n,onOpenFolder:r,onNewDocument:i,onNewFolder:a,theme:o=`light`,height:s=`100%`,iconFor:c=C}){let l=[...t].sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):e.isDirectory?-1:1);return(0,y.jsxs)(`div`,{className:`squisq-folder-view`,"data-theme":o,style:{height:s},children:[(0,y.jsxs)(`div`,{className:`squisq-folder-view-header`,children:[(0,y.jsx)(`i`,{className:`fa-regular fa-folder-open squisq-folder-view-header-icon`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`squisq-folder-view-title`,children:e}),(0,y.jsxs)(`span`,{className:`squisq-folder-view-count`,children:[t.length,` `,t.length===1?`item`:`items`]})]}),(0,y.jsx)(`div`,{className:`squisq-folder-view-body`,children:l.length===0?(0,y.jsx)(`p`,{className:`squisq-folder-view-empty`,children:`This folder is empty.`}):(0,y.jsx)(`ul`,{className:`squisq-folder-view-list`,children:l.map(e=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{type:`button`,className:`squisq-folder-view-item`,onClick:()=>e.isDirectory?r(e):n(e),children:[(0,y.jsx)(`span`,{className:`squisq-folder-view-item-icon`,children:c(e)}),(0,y.jsx)(`span`,{className:`squisq-folder-view-item-name`,children:e.name}),e.isDirectory&&(0,y.jsx)(`i`,{className:`fa-solid fa-chevron-right squisq-folder-view-item-chevron`,"aria-hidden":`true`})]})},e.path))})}),(0,y.jsxs)(`div`,{className:`squisq-folder-view-actions`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`squisq-folder-view-new`,onClick:i,children:[(0,y.jsx)(`i`,{className:`fa-solid fa-plus`,"aria-hidden":`true`}),` New document`]}),a&&(0,y.jsxs)(`button`,{type:`button`,className:`squisq-folder-view-new-folder`,onClick:a,children:[(0,y.jsx)(`i`,{className:`fa-regular fa-folder`,"aria-hidden":`true`}),` New folder`]})]})]})}var S=/\.(png|jpe?g|gif|svg|webp|bmp|avif)$/i;function C(e){return e.isDirectory?(0,y.jsx)(`i`,{className:`fa-regular fa-folder fa-fw`,"aria-hidden":`true`}):S.test(e.name)?(0,y.jsx)(`i`,{className:`fa-regular fa-file-image fa-fw`,"aria-hidden":`true`}):(0,y.jsx)(`i`,{className:`fa-regular fa-file-lines fa-fw`,"aria-hidden":`true`})}var w=2,T=200;function ne(){let[e,t]=(0,b.useState)(``),[n,r]=(0,b.useState)(null),[i,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let t=e.trim();if(t.length<w){r(null),o(``),c(!1),u(!1);return}let n=!1;c(!0);let i=window.setTimeout(()=>{a.searchDocuments({q:t}).then(e=>{n||(u(e.engine===`unavailable`),o(t),r(e.results.map(e=>({entry:{name:e.path.split(`/`).pop()??e.path,path:e.path,isDirectory:!1},snippet:e.snippet,line:e.lineStart,related:e.source===`vector`}))))}).catch(()=>{n||(o(t),r([]))}).finally(()=>{n||c(!1)})},T);return()=>{n=!0,window.clearTimeout(i)}},[e]),{query:e,setQuery:t,hits:n,matchedQuery:i,searching:s,unavailable:l,clear:()=>t(``)}}var E=`gezel:documents:selectedPath`;function D(){try{return window.localStorage.getItem(E)}catch{return null}}function O(e){try{e?window.localStorage.setItem(E,e):window.localStorage.removeItem(E)}catch{}}function k(e){try{return window.localStorage.getItem(e)}catch{return null}}function A(e,t){try{window.localStorage.setItem(e,t)}catch{}}function j(){let e=ee(),t=(0,b.useMemo)(()=>m(),[]),n=ne(),[S,C]=(0,b.useState)([]),[w,T]=(0,b.useState)(!1),[E,j]=(0,b.useState)(!1),[M,N]=(0,b.useState)(null),[P,F]=(0,b.useState)(()=>c(k(o),`documents`)),[I,L]=(0,b.useState)(()=>k(l)===`1`),R=f(),[z,B]=(0,b.useState)(()=>D()),[V,H]=(0,b.useState)(null);(0,b.useEffect)(()=>{let e=!1;return a.listProjects().then(t=>{if(e)return;let n=t.projects.find(e=>i(e));H(n?.id??null)}).catch(()=>{}),()=>{e=!0}},[]);let U=(0,b.useCallback)(e=>{B(e),O(e),e&&R.noteUsed(e)},[R.noteUsed]),W=(0,b.useCallback)(e=>{F(e),A(o,e)},[]),G=(0,b.useCallback)(e=>{L(e),A(l,e?`1`:`0`)},[]),K=(0,b.useCallback)(async()=>{try{let e=await t.list({hidden:I});C(e.files),T(e.truncated===!0),j(!0)}catch(e){N(e.message)}},[I,t]);(0,b.useEffect)(()=>{K()},[K]);let q=(0,b.useMemo)(()=>I?S:S.filter(e=>!r(e.path)),[S,I]),J=g({source:t,entries:S,selectedPath:z,onSelectPath:U,refresh:K}),Y=(0,b.useCallback)(e=>{if(e.isDirectory)return[];let t=R.pinnedPaths.has(e.path);return[{label:t?`Unpin from Documents list`:`Pin to Documents list`,onSelect:()=>t?R.unpin(e.path):R.pin(e.path)}]},[R.pin,R.pinnedPaths,R.unpin]);(0,b.useEffect)(()=>{if(q.length===0)return;let e=q.find(e=>!e.isDirectory)??q[0];e&&B(t=>t&&q.some(e=>e.path===t)?t:e.path)},[q]);let X=(0,b.useMemo)(()=>z?q.find(e=>e.path===z)??null:null,[q,z]),Z=X?.isDirectory??!1,re=z?z.slice(z.lastIndexOf(`/`)+1):``,ie=(0,b.useMemo)(()=>{if(!z||!Z)return[];let e=`${z}/`;return q.filter(t=>t.path.startsWith(e)&&!t.path.slice(e.length).includes(`/`))},[q,z,Z]),Q=z&&!Z?p(z):null,$;$=z?Z?(0,y.jsx)(x,{name:re,entries:ie,theme:e,onOpenFile:e=>U(e.path),onOpenFolder:e=>U(e.path),onNewDocument:()=>J.newFile?.(z),onNewFolder:()=>J.newFolder?.(`${z}/`)}):Q?(0,y.jsx)(h,{content:Q,path:z,fetchBlob:t.fetchBlob}):X?(0,y.jsx)(v,{path:z},z):E?(0,y.jsx)(`p`,{className:`placeholder`,children:`Select a document or folder on the left to view it.`}):(0,y.jsx)(`p`,{className:`placeholder`,children:`Loading…`}):(0,y.jsx)(`p`,{className:`placeholder`,children:`Select a document or folder on the left to view it.`});let ae=n.hits?{entries:n.hits.map(e=>e.entry),emptyMessage:n.unavailable?`The library is still being indexed — search will work shortly.`:`Nothing in the library mentions “${n.query.trim()}”.`,detailForEntry:e=>{let t=n.hits?.find(t=>t.entry.path===e.path);return t?(0,y.jsxs)(`span`,{className:`documents-search-snippet`,children:[t.related&&(0,y.jsx)(`span`,{className:`documents-search-related`,children:`related`}),u(t.snippet,n.matchedQuery)]}):null}}:null;return(0,y.jsxs)(`div`,{className:`documents-listing`,"data-testid":`documents-view`,children:[(0,y.jsx)(_,{source:t,titleReplacement:(0,y.jsxs)(`div`,{className:`documents-search`,children:[(0,y.jsx)(`input`,{type:`search`,className:`documents-search-input`,placeholder:`${t.title} - search`,"aria-label":`Search document contents`,value:n.query,onChange:e=>n.setQuery(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n.clear()}}),n.searching&&(0,y.jsx)(`span`,{className:`muted documents-search-status`,children:`searching…`})]}),customList:ae,layoutClassName:`project-files-layout-documents`,entries:q,truncated:w,viewMode:P,modes:s,onViewModeChange:W,showHidden:I,onShowHiddenChange:G,selectedPath:z??void 0,onSelect:e=>U(e.path),selectableFolders:!0,labelFor:e=>d(e.name),trailingForEntry:e=>R.pinnedPaths.has(e.path)?(0,y.jsx)(`span`,{className:`document-pin-marker`,title:`Pinned`,"aria-label":`Pinned`,children:(0,y.jsx)(`i`,{className:`fa-solid fa-thumbtack`})}):null,actionsForEntry:Y,emptyMessage:`No documents yet. Create a mission statement, coding guidelines, or any shared reference.`,mutations:J,viewer:$}),M&&(0,y.jsx)(`p`,{className:`error`,children:M}),V?(0,y.jsx)(te,{projectId:V}):null]})}export{j as DocumentsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./dist-pLLFUPO-.js";var s=e,c=a,l=t,u=o,d=n,f=i,p=r;export{s as a,l as i,d as n,p as o,f as r,c as s,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{_t as r,d as i}from"./dist-BqGwkOe5.js";import{t as a}from"./api-BPraLwsh.js";import{t as o}from"./model-context-DBqdK0PS.js";import{n as s,r as c,t as l}from"./model-memory-copy-CeuXAj-T.js";import{t as u}from"./ConfirmDialog-Dt1ed4Fh.js";import{a as d,r as f,t as p}from"./model-inventory-ykSm_IT5.js";import{wt as m}from"./index-C0DYtvfg.js";import{t as h}from"./IncompleteDownloads-BiPaaahS.js";import{a as ee,i as te,n as g,o as ne,r as re,t as _}from"./UnrecognizedModels-HtdMZUqK.js";import{t as v}from"./useTotalRamBytes-DIx-_pf8.js";import{t as y}from"./ds4-availability-TaGRbP_O.js";import{t as b}from"./local-engine-label-BR-PGVFE.js";var x=e(t(),1),S=n();function C(e){return e.kind!==`chat-model`||!e.ds4?null:e}function w({onModelsChanged:e}){let[t,n]=(0,x.useState)(null),[v,y]=(0,x.useState)(new Set),[b,w]=(0,x.useState)(new Map),[T,E]=(0,x.useState)(new Set),[D,O]=(0,x.useState)(new Map),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)(!1),[N,ie]=(0,x.useState)(null),[ae,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(new Map),[L,R]=(0,x.useState)(null),[z,B]=(0,x.useState)([]),[V,H]=(0,x.useState)([]),[U,W]=(0,x.useState)(null),[G,oe]=(0,x.useState)(new Map),[K,se]=(0,x.useState)([]),q=(0,x.useRef)([]),J=(0,x.useCallback)(async()=>{try{let e=await a.listModelFitness();oe(new Map(e.records.map(e=>[e.key,e]))),se(e.probing),q.current=e.probing}catch{}},[]),Y=(0,x.useCallback)(async()=>{try{let e=await a.listIncompleteDs4Models();B(e.incomplete??[])}catch{}},[]),X=(0,x.useCallback)(async()=>{try{let e=await a.listDs4Models();y(new Set(e.models.map(e=>e.id))),w(new Map(e.models.map(e=>[e.id,e]))),E(new Set(e.models.filter(e=>e.readOnly).map(e=>e.id))),H(e.unrecognized??[])}catch{}try{let e=await a.listDs4ContextPlans();O(new Map(Object.entries(e.plans??{})))}catch{}Y()},[Y]),Z=(0,x.useCallback)(async()=>{R(null);try{let[e,t]=await Promise.all([a.listCatalogItems(`chat-model`),a.getMemoryProfile()]);n(e.items),A({totalRamBytes:t.totalRamBytes,usableBytes:t.usableBytes})}catch(e){R(e instanceof Error?e.message:String(e))}},[]);(0,x.useEffect)(()=>{Z(),X(),a.getModelContextOverrides(`ds4`).then(()=>P(!0)).catch(()=>P(!1))},[Z,X]),(0,x.useEffect)(()=>{let e=e=>{d(e)===`ds4`&&X()};return window.addEventListener(p,e),()=>window.removeEventListener(p,e)},[X]),(0,x.useEffect)(()=>{let e=!1,t,n=async()=>{await J(),!e&&(t=setTimeout(()=>void n(),q.current.length>0?2e3:15e3))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[J]),(0,x.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await a.listDs4ActiveInstalls();if(e)return;I(e=>{let n=new Map(e),r=new Set;for(let e of t.installs){r.add(e.catalogId);let t=n.get(e.catalogId);t?.origin===`local`&&!t.error||n.set(e.catalogId,{bytesWritten:e.bytesWritten,totalBytes:e.totalBytes,phase:e.phase===`extracting-metadata`?`finalizing`:e.phase,origin:`remote`})}for(let[e,t]of n)t.origin===`remote`&&!r.has(e)&&n.delete(e);return n}),t.installs.length===0&&X()}catch{}};t();let n=setInterval(()=>void t(),2e3);return()=>{e=!0,clearInterval(n)}},[X]);let Q=(0,x.useCallback)(t=>{I(e=>new Map(e).set(t,{bytesWritten:0,totalBytes:0,phase:`downloading`,origin:`local`})),(async()=>{try{await a.installDs4Model(t,e=>{I(n=>{let r=new Map(n),i=r.get(t)??{bytesWritten:0,totalBytes:0,phase:`downloading`,origin:`local`};return e.type===`progress`?r.set(t,{...i,bytesWritten:e.bytesWritten,totalBytes:e.totalBytes,phase:`downloading`}):e.type===`verifying`?r.set(t,{...i,phase:`verifying`}):e.type===`extracting-metadata`?r.set(t,{...i,phase:`finalizing`}):e.type===`error`&&r.set(t,{...i,error:e.error}),r})}),f(`ds4`)}catch(e){I(n=>{let r=new Map(n),i=r.get(t);return i&&r.set(t,{...i,error:e instanceof Error?e.message:String(e)}),r});return}finally{I(e=>{let n=new Map(e);return n.get(t)?.error||n.delete(t),n}),await X(),e?.()}})()},[X,e]),ce=(0,x.useCallback)(async t=>{R(null),y(e=>{let n=new Set(e);return n.delete(t),n}),B(e=>e.filter(e=>e.id!==t)),H(e=>e.filter(e=>e.id!==t));try{await a.deleteDs4Model(t),f(`ds4`),await X(),e?.()}catch(e){R(`delete failed: ${e instanceof Error?e.message:String(e)}`),X()}},[X,e]),$=(0,x.useMemo)(()=>(t??[]).map(e=>({it:e,m:C(e.manifest)})).filter(e=>e.m!==null),[t]);if(L)return(0,S.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.6rem`},children:[(0,S.jsxs)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:[`Couldn't load models: `,L]}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>void Z(),children:`Retry`})]});if(t===null)return(0,S.jsx)(`p`,{className:`muted small`,children:`Loading models…`});if($.length===0)return(0,S.jsx)(`p`,{className:`muted small`,children:`No DwarfStar models in the catalog.`});let le=new Set(V.map(e=>e.id)),ue=$.filter(({m:e})=>!le.has(e.id)||F.has(e.id)).filter(({m:e})=>j||v.has(e.id)||!r(e)).map((e,t)=>({entry:e,index:t})).sort((e,t)=>{let n=Number(v.has(t.entry.m.id))-Number(v.has(e.entry.m.id));return n===0?e.index-t.index:n}).map(({entry:e})=>e),de=e=>D.get(e.id)?.projectedResidentBytes??e.ds4.residentBytes,fe=Math.min(...ue.map(({m:e})=>de(e)??1/0));return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(g,{engine:`ds4`,onModelsChanged:e}),(0,S.jsx)(_,{items:V.filter(e=>!F.has(e.id)),onUpdate:Q,onRemove:W}),(0,S.jsx)(h,{items:z.filter(e=>!F.has(e.id)),onResume:e=>Q(e),onDelete:W}),(0,S.jsxs)(`div`,{className:`ollama-section`,children:[(0,S.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Retired models are hidden by default.`,` `,(0,S.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>M(e=>!e),children:j?`Hide retired models`:`Show all models`})]}),(0,S.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,S.jsxs)(`table`,{className:`ollama-model-table ds4-model-table`,children:[(0,S.jsxs)(`colgroup`,{children:[(0,S.jsx)(`col`,{className:`model-name-column`}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{})]}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{children:`Name`}),(0,S.jsx)(`th`,{title:`Download size, and the memory working set this device would run the model at. A streaming engine keeps far less resident than it downloads.`,children:`Size`}),(0,S.jsx)(`th`,{title:`Effective per-turn context size after Gezel's settings and memory limits`,children:`Context size`}),(0,S.jsx)(`th`,{title:`Reading and writing speed, measured against an approximately 20K-token prompt`,children:`Fitness`}),(0,S.jsx)(`th`,{})]})}),(0,S.jsx)(`tbody`,{children:ue.map(({m:e})=>{let t=D.get(e.id),n=de(e),u=e.ds4.cacheExpertsBytes??0,d=k?Math.max(0,k.totalRamBytes-i):0,f=k&&n?n<=d:!0,p=n?Math.max(0,n-u):0,m=!k||p+1024**3<=d,h=n===fe,g=v.has(e.id),_=r(e),y=F.get(e.id),C=y&&y.totalBytes>0?Math.floor(y.bytesWritten/y.totalBytes*100):0,w=t?.fullyResident===!0,E=w?(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok ds4-model-fit`,title:`This device holds the whole model in memory — no expert streaming from SSD. That is roughly ten times faster to generate than the streaming fallback${n?`, and costs about ${c(e.ds4.approxSizeBytes)} of memory while loaded`:``}.`,children:`runs fully in memory · fastest`}):n?f?(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--info ds4-model-fit`,title:`Too large to hold in memory on this device, so DwarfStar keeps about ${c(n)} resident and reads the remaining experts from SSD as it goes. That works, but generates roughly ten times slower than a model that fits in memory. A smaller quant that fits will be much faster.`,children:h?`streams from SSD · lightest option`:`streams from SSD · slower`}):m?(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn ds4-model-fit`,title:`Gezel will reduce this model's expert cache below its ${c(n)} target to preserve ${c(i)} for the system and other apps. It should run, but will read from SSD even more often than a normal streaming launch.`,children:`reduced cache · much slower`}):(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn ds4-model-fit`,title:`The model's fixed memory requirement leaves too little room for the system, even with the expert cache reduced.`,children:`needs more memory`}):null,O=e.name,A=b.get(e.id),j=A?{...A,...t?.effectiveContextWindow!==void 0&&!A.effectiveContextWindow?{effectiveContextWindow:t.effectiveContextWindow}:{},...t?.contextCeilingTokens!==void 0&&A.contextCeilingTokens===void 0?{contextCeilingTokens:t.contextCeilingTokens}:{},...t?.kvBytesPerToken!==void 0&&A.kvBytesPerTokenPerSlot===void 0?{kvBytesPerTokenPerSlot:t.kvBytesPerToken,kvFixedBytesPerSlot:0}:{},...t?.contextFreeResidentBytes!==void 0&&A.weightsResidentBytes===void 0?{weightsResidentBytes:t.contextFreeResidentBytes}:{}}:void 0,M=j?.effectiveContextWindow??t?.effectiveContextWindow,P=j?.overrideContextTokens??t?.overrideContextTokens,I=j?.contextSizingStatus===`restart-required`,L={approxSizeBytes:e.ds4.approxSizeBytes,residentBytes:n,...t?.kvBytesPerToken!==void 0&&t.contextFreeResidentBytes!==void 0&&M!==void 0?{contextFreeBytes:t.contextFreeResidentBytes}:{},...M===void 0?{}:{effectiveContextWindow:M},...w?{fullyResident:!0}:{}},R=l(L),z=j?.updateAvailable===!0,B=`ds4:${e.id}`;return(0,S.jsxs)(x.Fragment,{children:[(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{className:`model-name-table-cell`,children:(0,S.jsxs)(`div`,{className:`model-name-cell`,children:[(0,S.jsx)(`strong`,{className:`ds4-model-name`,children:O}),(0,S.jsxs)(`div`,{className:`model-name-meta`,children:[(0,S.jsx)(`span`,{className:`muted small`,children:e.parameterSize}),g&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`on device`}),_&&(0,S.jsx)(`span`,{className:`catalog-item-tag catalog-item-tag--retired`,title:`This model is kept for compatibility but is no longer recommended for new downloads.`,children:`retired`}),z&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:j?.updateReason??(j?.availableVersion?`A newer build is available in the catalog (→ v${j.availableVersion}). Updating downloads only the files that differ.`:`A newer build is available in the catalog. Updating downloads only the files that differ.`),children:`update available`})]}),E]})}),(0,S.jsx)(`td`,{children:(0,S.jsxs)(`span`,{className:`model-size-cell`,title:s(L),children:[c(e.ds4.approxSizeBytes),R?(0,S.jsx)(`span`,{className:`muted small model-memory-headline`,children:R}):null]})}),(0,S.jsx)(`td`,{title:I?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:M===void 0?void 0:P===void 0?`Gezel will grant up to ${M.toLocaleString()} tokens per turn.`:`You've set this model to ${P.toLocaleString()} tokens per turn.`,children:I?`Restart needed`:M===void 0?(0,S.jsx)(`span`,{className:`muted`,children:`—`}):(0,S.jsxs)(S.Fragment,{children:[o(M),P!==void 0&&(0,S.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),g?(0,S.jsx)(re,{entry:G.get(B),probing:K.includes(B)}):(0,S.jsx)(`td`,{className:`model-fitness-table-cell`,children:(0,S.jsx)(`span`,{className:`muted small`,title:`The fitness check measures this model on THIS machine, so it runs once the download lands.`,children:`after download`})}),(0,S.jsx)(`td`,{className:`model-actions-table-cell`,children:y?y.error?(0,S.jsxs)(`div`,{className:`ds4-model-progress`,children:[(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:y.error}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>Q(e.id),children:`Retry`})]}):(0,S.jsx)(`span`,{className:`muted small ds4-model-progress-label`,children:y.phase===`downloading`?`downloading… ${C}%`:y.phase===`verifying`?`verifying sha256…`:`finalizing…`}):g?(0,S.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,S.jsx)(`div`,{className:`model-action-status`,children:T.has(e.id)&&(0,S.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,S.jsx)(`div`,{className:`model-action-links`,children:(0,S.jsx)(ee,{engine:`ds4`,model:j??{id:e.id,approxSizeBytes:e.ds4.approxSizeBytes,readOnly:T.has(e.id)},contextSupported:ae,contextEditorOpen:N===e.id,onToggleContextEditor:()=>ie(t=>t===e.id?null:e.id),fitnessAction:te(G.get(B),K.includes(B),()=>{a.runModelFitnessProbe(`ds4`,e.id).then(()=>J()).catch(()=>{})}),onUpdate:()=>Q(e.id),onDelete:T.has(e.id)?void 0:()=>W(e.id)})})]}):m?(0,S.jsx)(`button`,{type:`button`,onClick:()=>Q(e.id),children:`Download`}):null})]}),N===e.id&&j&&(0,S.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,S.jsx)(`td`,{colSpan:5,children:(0,S.jsx)(ne,{engine:`ds4`,model:j,onSaved:X})})})]},e.id)})})]})})]}),(0,S.jsxs)(`div`,{style:{marginTop:`1.25rem`},children:[(0,S.jsx)(m,{}),(0,S.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,S.jsx)(u,{open:U!==null,title:`Remove ${U??`model`}?`,message:`This permanently removes the model files from this device. The model stays available in the catalog, so you can download a current build later.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{let e=U;W(null),e&&ce(e)},onCancel:()=>W(null)})]})}function T({config:e,onConfigChanged:t,health:n,title:r}){let i=v(),[o,s]=(0,x.useState)([]),[c,l]=(0,x.useState)(`idle`),u=(0,x.useCallback)(async()=>{try{let e=await a.listDs4Models();s(e.models)}catch{}},[]);(0,x.useEffect)(()=>{u()},[u]);let d=(0,x.useCallback)(async n=>{l(`saving`);try{t(await a.updateConfig({defaultModel:{...e?.defaultModel,ds4:n??void 0}})),l(`saved`),setTimeout(()=>l(`idle`),1200)}catch{l(`idle`)}},[e?.defaultModel,t]),f=(0,x.useCallback)(async e=>{l(`saving`);try{t(await a.updateConfig({ds4SsdStreaming:e?!0:void 0})),l(`saved`),setTimeout(()=>l(`idle`),1200)}catch{l(`idle`)}},[t]),p=e?.ds4SsdStreaming===!0,m=y({externalBaseUrl:e?.ds4BaseUrl,totalRamBytes:i??void 0,ds4ServerBundled:n?.ds4ServerBundled,serverPlatform:n?.platform,detectedBackend:n?.llamaCppDetectedBackend,gpuVendor:n?.llamaCppDetectedVendor});return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h3`,{children:r??b(`ds4`,n?.platform)}),(0,S.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`DwarfStar (ds4) is an inference engine built for a handful of very large mixture-of-experts models — DeepSeek V4 and GLM 5.2. They may not fit in memory; DwarfStar keeps a bounded expert cache in RAM and reads the other experts from SSD as they are needed.`}),(0,S.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,S.jsx)(`span`,{className:`muted small`,children:`Status:`}),m.status===`available`&&(0,S.jsxs)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:[`engine available · `,m.backend]}),m.status===`external`&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Using an external ds4-server at: ${e?.ds4BaseUrl}`,children:`using external DwarfStar server`}),m.status===`requires-cuda`&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:`requires NVIDIA / CUDA`}),m.status===`unavailable`&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:`unavailable on this device`}),c===`saved`&&(0,S.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]}),m.status===`available`&&(0,S.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.4rem`},children:[`This means the engine can launch on this`,` `,m.backend===`metal`?`Mac`:`machine`,`. Each model below still has its own disk and memory requirements.`]}),(m.status===`unavailable`||m.status===`requires-cuda`)&&(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.4rem`},children:m.reason})]}),m.status!==`unavailable`&&m.status!==`external`&&o.length>1&&(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h4`,{children:`Default model`}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which DwarfStar model new chat sessions use when a gezel doesn't pin one.`}),(0,S.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,S.jsxs)(`select`,{"aria-label":`Default model`,value:e?.defaultModel?.ds4??``,onChange:e=>void d(e.target.value||void 0),children:[(0,S.jsx)(`option`,{value:``,children:`First local model`}),o.map(e=>(0,S.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),m.status!==`unavailable`&&m.status!==`external`&&(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h4`,{children:`DwarfStar models`}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Lower quantizations (Q2) start faster and need less disk and memory; higher ones (Q4) keep more model detail but can need several times the disk space and a larger memory working set. Check the size on each row before starting — these downloads run to hundreds of gigabytes.`}),(0,S.jsx)(w,{onModelsChanged:u}),(0,S.jsx)(E,{})]}),m.status!==`unavailable`&&m.status!==`external`&&(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h4`,{children:`Memory use`}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`A model held entirely in memory generates roughly ten times faster than one whose experts are read from SSD as they're needed. Gezel keeps a model in memory whenever this machine has room for it, and falls back to streaming when it doesn't — the model list shows which each one will do.`}),(0,S.jsxs)(`div`,{className:`gz-tray`,role:`radiogroup`,"aria-label":`Memory use`,style:{marginTop:`0.6rem`},children:[(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":!p,className:`gz-key gz-key--stacked${p?``:` gz-key-active`}`,onClick:()=>void f(!1),children:[(0,S.jsx)(`span`,{className:`gz-key-label`,children:`Keep in memory when it fits`}),(0,S.jsx)(`span`,{className:`gz-key-hint`,children:`Fastest. Falls back to streaming automatically.`})]}),(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":p,className:`gz-key gz-key--stacked${p?` gz-key-active`:``}`,onClick:()=>void f(!0),children:[(0,S.jsx)(`span`,{className:`gz-key-label`,children:`Always stream from SSD`}),(0,S.jsx)(`span`,{className:`gz-key-hint`,children:`Much slower, but leaves memory free for other apps.`})]})]}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.6rem`},children:`Gezel never holds a model in memory that wouldn't leave enough for the system and your other apps — a model too large for this machine streams regardless of this setting.`})]}),m.status===`external`&&(0,S.jsx)(`p`,{className:`muted small`,children:`This external DwarfStar server manages its own model files and memory settings. Local downloads are not used while the external server is configured.`})]})}function E(){let[e,t]=(0,x.useState)({kind:`idle`}),n=(0,x.useCallback)(async()=>{t({kind:`loading`});try{t({kind:`loaded`,...await a.getDs4Log(4096)})}catch(e){t({kind:`error`,message:e instanceof Error?e.message:String(e)})}},[]);return(0,S.jsxs)(`details`,{style:{marginTop:`1rem`},children:[(0,S.jsxs)(`summary`,{style:{cursor:`pointer`,userSelect:`none`},children:[`Diagnostics`,` `,(0,S.jsx)(`span`,{className:`muted small`,children:`— DwarfStar engine output retained for troubleshooting.`})]}),(0,S.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,S.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.5rem`},children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.kind===`loading`,children:e.kind===`loading`?`Loading…`:`Refresh engine log`}),e.kind===`loaded`&&e.path&&(0,S.jsx)(`span`,{className:`muted small`,title:e.path,children:e.path}),e.kind===`loaded`&&!e.path&&(0,S.jsx)(`span`,{className:`muted small`,children:`No DwarfStar engine log yet.`})]}),e.kind===`error`&&(0,S.jsxs)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`,color:`#ff9b9b`},children:[`Couldn't load log: `,e.message]}),e.kind===`loaded`&&e.tail&&(0,S.jsx)(`pre`,{style:{marginTop:`0.5rem`,padding:`0.5rem`,background:`rgba(255,255,255,0.04)`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:4,maxHeight:`18rem`,overflow:`auto`,fontSize:`0.75rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:e.tail}),e.kind===`loaded`&&e.path&&!e.tail&&(0,S.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`},children:`The log exists but is empty. Start a DwarfStar chat, then refresh.`})]})]})}export{T as Ds4Settings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{ProjectDetailView as r}from"./ProjectsView-J77ECk6V.js";var i=e(t(),1),a=n();function o({projectId:e,theme:t,accent:n,bg:o,fg:s,fontFamily:c,compact:l=!1}){return(0,i.useEffect)(()=>{let e=document.documentElement;return n&&e.style.setProperty(`--accent`,n),o&&e.style.setProperty(`--bg`,o),s&&e.style.setProperty(`--fg`,s),c&&e.style.setProperty(`--font-ui`,c),t&&e.setAttribute(`data-host-theme`,t),e.classList.add(`embedded-chat`),()=>{e.classList.remove(`embedded-chat`),e.removeAttribute(`data-host-theme`)}},[t,n,o,s,c]),(0,a.jsx)(`div`,{className:`embedded-chat-root`,children:(0,a.jsx)(r,{projectId:e,compact:l})})}export{o as EmbeddedChat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{t as i}from"./ConfirmDialog-Dt1ed4Fh.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(!1),[n,s]=(0,a.useState)(!1),[c,l]=(0,a.useState)(!1),[u,d]=(0,a.useState)(null),[f,p]=(0,a.useState)(null);(0,a.useEffect)(()=>{(async()=>{try{let e=await r.getConfig();t(e.faceRecognition?.enabled===!0)}catch{}finally{s(!0)}})()},[]);let m=(0,a.useCallback)(async n=>{let i=e;t(n),p(null),d(null);try{await r.updateConfig({faceRecognition:{enabled:n}})}catch(e){t(i),p(e instanceof Error?e.message:String(e))}},[e]),h=(0,a.useCallback)(async()=>{p(null);try{let e=await r.wipeFaceData();t(!1),l(!1),d(e.projects>0?`Face data erased across ${e.projects} project${e.projects===1?``:`s`}.`:`No face data was stored.`)}catch(e){p(e instanceof Error?e.message:String(e))}},[]);return(0,o.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,o.jsx)(`h3`,{children:`People in photos`}),(0,o.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`When on, Gezel looks for faces in indexed photos and groups the same person across them, so you can name someone once and find them anywhere. Everything runs on this device — photos and face data never leave it. Turning this on downloads the face models once (about 260 MB).`}),(0,o.jsxs)(`label`,{className:`debug-toggle`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:e,disabled:!n,onChange:e=>void m(e.target.checked)}),(0,o.jsx)(`span`,{children:`Recognize people in photos`})]}),(0,o.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`},children:(0,o.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>l(!0),children:`Turn off and erase face data`})}),u&&(0,o.jsx)(`p`,{className:`muted small`,children:u}),f&&(0,o.jsx)(`p`,{className:`error small`,children:f}),(0,o.jsx)(i,{open:c,title:`Erase all face data?`,message:`Deletes every stored face signature, person, and name across all projects, and turns face recognition off. Photos themselves are not touched. This cannot be undone.`,confirmLabel:`Erase face data`,danger:!0,onConfirm:h,onCancel:()=>l(!1)})]})}export{s as FaceRecognitionCard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{$ as r,I as i,K as a,M as o,jt as s}from"./dist-BqGwkOe5.js";import{t as c}from"./api-BPraLwsh.js";import{y as l}from"./primitives-CWrGZpPI.js";import{i as u,n as d}from"./styles-CKVKwqoQ.js";import{U as f,ht as p}from"./index-C0DYtvfg.js";import{t as m}from"./MarkdownField-CK8K3fzj.js";var h=e(t(),1),g=.05;function _(e){return Math.max(g,Math.min(12,e))}function v(e){return e<.45?`city`:e<1.3?`district`:`street`}function y(e,t){return(t-e.offsetX)*e.scale}function b(e,t){return(t-e.offsetY)*e.scale}function x(e,t){return t/e.scale+e.offsetX}function ee(e,t){return t/e.scale+e.offsetY}function te(e,t,n,r=32){if(e.w<=0||e.h<=0||t<=0||n<=0)return{scale:1,offsetX:0,offsetY:0};let i=_(Math.min((t-r*2)/e.w,(n-r*2)/e.h)),a=e.x+e.w/2,o=e.y+e.h/2;return{scale:i,offsetX:a-t/2/i,offsetY:o-n/2/i}}function ne(e,t,n,r){let i=_(e.scale*t);if(i===e.scale)return e;let a=x(e,n),o=ee(e,r);return{scale:i,offsetX:a-n/i,offsetY:o-r/i}}function S(e,t,n,r){let i=y(e,t.x),a=b(e,t.y),o=t.w*e.scale,s=t.h*e.scale;return i+o>=0&&a+s>=0&&i<=n&&a<=r}function C(e){return a(e.id,e.lang)}function re(e){return e.buildingCount>0&&C(e)===`code`}function w(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function T(e){let t=e>>>0;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function ie(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}var E={brick:{satMul:.9,litDelta:-4,hue:14,hueMix:.82},stucco:{satMul:.62,litDelta:6,hue:42,hueMix:.45},timber:{satMul:.7,litDelta:-2,hue:28,hueMix:.82},stone:{satMul:.34,litDelta:2,hue:40,hueMix:.78},slate:{satMul:.34,litDelta:-8,hue:220,hueMix:.4},tile:{satMul:.72,litDelta:-1,hue:18,hueMix:.5},thatch:{satMul:.5,litDelta:4,hue:44,hueMix:.7},glass:{satMul:.55,litDelta:10,hue:196,hueMix:.5},iron:{satMul:.35,litDelta:-10,hue:210,hueMix:.55}},D={village:[`timber`,`stucco`,`brick`,`stone`],town:[`brick`,`stucco`,`stone`],city:[`brick`,`stone`]},ae={village:[`tile`,`slate`,`thatch`],town:[`tile`,`slate`],city:[`slate`,`tile`]};function oe(e,t,n){let r=T(e),i=D[t],a=ae[t],o=r();return{wall:t===`village`?o<.34?`timber`:o<.62?`stucco`:o<.88?`brick`:`stone`:i[Math.min(i.length-1,Math.floor(o*i.length))],roof:n?r()<.5?`iron`:`glass`:t===`village`?(e=>e<.5?`tile`:e<.9?`slate`:`thatch`)(r()):a[Math.min(a.length-1,Math.floor(r()*a.length))]}}function se(e,t,n){let r=(t-e+540)%360-180;return r*=n,((e+r)%360+360)%360}var O=4;function ce(e,t){let n=E[t].litDelta,r=E[e].litDelta-n;return n+Math.max(-4,Math.min(O,r))}function k(e,t,n,r=E[t].litDelta){let i=E[t],a=i.hueMix*(1-Math.max(0,Math.min(1,n)));return{h:se(e.h,i.hue,a),s:Math.max(0,Math.min(100,e.s*i.satMul)),l:Math.max(0,Math.min(100,e.l+r))}}function le({h:e,s:t,l:n}){return`hsl(${Math.round(e)} ${Math.round(t)}% ${Math.round(n)}%)`}function ue(e){return .38+-.2*Math.max(0,Math.min(1,e))}function de(e){return e?{dark:!0,ground:`hsl(130 10% 12%)`,districtFill:`hsl(40 7% 15%)`,districtStroke:`#3a3733`,curb:`hsl(40 10% 36%)`,sidewalk:`hsl(40 8% 30%)`,districtLabel:`#8b8f99`,label:`#c9ccd4`,road:`#4a4d56`,roadMutual:`#6b7280`,blockStroke:`#15161a`,shadow:`rgba(0, 0, 0, 0.38)`,building:`#11141a`,buildingFacade:`#04060a`,earth:`hsl(35 20% 22%)`,rubble:`hsl(30 6% 30%)`,crane:`hsl(38 80% 55%)`,newBlock:`#3f7d4f`,tombstone:`#55504a`,selected:`#e0a062`,hover:`#9aa0ad`,domeAccent:`hsl(42 60% 55%)`,window:`hsl(214 24% 16%)`,windowLit:`hsl(41 72% 61%)`,masonry:`hsl(18 24% 28%)`,awning:`hsl(8 48% 48%)`,pavementAvenue:`hsl(36 8% 25%)`,pavementStreet:`hsl(36 8% 22%)`,pavementLane:`hsl(36 7% 19%)`,avenueDash:`hsl(45 45% 48%)`,labelPlate:`hsl(228 10% 10% / 0.85)`,labelPlateStroke:`hsl(228 10% 34%)`,hedge:`hsl(128 22% 22%)`,fence:`hsl(36 16% 38%)`,orchard:`hsl(120 18% 20%)`,dirtLane:`hsl(32 16% 20%)`,cobble:`hsl(30 9% 23%)`,stall:`hsl(12 42% 42%)`,districtFillVillage:`hsl(120 9% 14%)`,districtFillCity:`hsl(40 5% 16%)`,street:{verge:`hsl(110 12% 15%)`,rail:`hsl(40 10% 42%)`,wire:`hsl(40 10% 50%)`,lampPost:`hsl(36 12% 40%)`,lampGlow:`hsl(41 80% 62%)`,pole:`hsl(30 14% 34%)`,cart:{top:`hsl(28 30% 42%)`,wallL:`hsl(28 30% 32%)`,wallR:`hsl(28 28% 25%)`},horse:{top:`hsl(24 22% 30%)`,wallL:`hsl(24 22% 22%)`,wallR:`hsl(24 20% 17%)`},trolley:{top:`hsl(150 16% 28%)`,wallL:`hsl(46 50% 60%)`,wallR:`hsl(46 40% 46%)`},trolleyRoof:`hsl(150 16% 28%)`,walker:`hsl(40 10% 62%)`,smoke:`hsl(40 6% 58%)`,water:`hsl(200 30% 36%)`,basin:`hsl(40 10% 34%)`},farm:{crops:[`hsl(44 40% 34%)`,`hsl(96 26% 24%)`,`hsl(30 22% 22%)`,`hsl(58 30% 30%)`],furrow:`hsl(30 20% 12%)`,shed:{top:`hsl(24 26% 30%)`,wallL:`hsl(24 24% 24%)`,wallR:`hsl(24 22% 18%)`}},park:{lawn:`hsl(118 18% 20%)`,path:`hsl(40 12% 34%)`}}:{dark:!1,ground:`hsl(80 24% 86%)`,districtFill:`hsl(46 28% 89%)`,districtStroke:`hsl(44 16% 76%)`,curb:`hsl(44 14% 70%)`,sidewalk:`hsl(46 24% 92%)`,districtLabel:`#7a715c`,label:`#473f30`,road:`#b3a98f`,roadMutual:`#8a7f64`,blockStroke:`#d8d0bd`,shadow:`rgba(70, 60, 35, 0.2)`,building:`#ffffff`,buildingFacade:`#d6cfbd`,earth:`hsl(36 35% 78%)`,rubble:`hsl(40 12% 72%)`,crane:`hsl(38 85% 55%)`,newBlock:`#7bb98a`,tombstone:`#c3bba9`,selected:`#c9722e`,hover:`#6f6651`,domeAccent:`hsl(42 65% 52%)`,window:`hsl(205 24% 39%)`,windowLit:`hsl(42 88% 70%)`,masonry:`hsl(18 26% 48%)`,awning:`hsl(8 52% 52%)`,pavementAvenue:`hsl(46 10% 72%)`,pavementStreet:`hsl(46 12% 78%)`,pavementLane:`hsl(46 14% 82%)`,avenueDash:`hsl(46 40% 94%)`,labelPlate:`hsl(46 30% 96% / 0.88)`,labelPlateStroke:`hsl(44 16% 72%)`,hedge:`hsl(122 26% 42%)`,fence:`hsl(38 20% 62%)`,orchard:`hsl(104 28% 68%)`,dirtLane:`hsl(34 24% 70%)`,cobble:`hsl(44 8% 74%)`,stall:`hsl(10 48% 58%)`,districtFillVillage:`hsl(92 22% 84%)`,districtFillCity:`hsl(44 14% 85%)`,street:{verge:`hsl(88 30% 80%)`,rail:`hsl(40 8% 52%)`,wire:`hsl(40 8% 45%)`,lampPost:`hsl(36 14% 42%)`,lampGlow:`hsl(42 90% 70%)`,pole:`hsl(30 16% 40%)`,cart:{top:`hsl(28 36% 52%)`,wallL:`hsl(28 34% 42%)`,wallR:`hsl(28 32% 34%)`},horse:{top:`hsl(24 26% 38%)`,wallL:`hsl(24 26% 30%)`,wallR:`hsl(24 24% 24%)`},trolley:{top:`hsl(150 20% 36%)`,wallL:`hsl(46 62% 70%)`,wallR:`hsl(46 48% 56%)`},trolleyRoof:`hsl(150 20% 36%)`,walker:`hsl(30 18% 32%)`,smoke:`hsl(40 8% 62%)`,water:`hsl(200 42% 62%)`,basin:`hsl(40 12% 62%)`},farm:{crops:[`hsl(46 62% 66%)`,`hsl(96 36% 52%)`,`hsl(30 30% 58%)`,`hsl(58 48% 72%)`],furrow:`hsl(30 30% 40%)`,shed:{top:`hsl(24 30% 46%)`,wallL:`hsl(24 28% 38%)`,wallR:`hsl(24 26% 30%)`}},park:{lawn:`hsl(112 34% 62%)`,path:`hsl(42 30% 86%)`}}}function fe(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.max(0,(t-n)/864e5);return r<=7?0:r<=30?1:r<=90?2:3}var A=[`hsl(28 92% 58%)`,`hsl(28 70% 46%)`,`hsl(28 42% 35%)`,`hsl(28 16% 27%)`],pe=[`hsl(28 92% 44%)`,`hsl(28 70% 34%)`,`hsl(28 42% 26%)`,`hsl(28 16% 20%)`],me=[`hsl(28 92% 68%)`,`hsl(28 70% 56%)`,`hsl(28 42% 44%)`,`hsl(28 16% 35%)`],he=[`hsl(28 95% 55%)`,`hsl(28 82% 66%)`,`hsl(28 55% 77%)`,`hsl(28 25% 86%)`],ge=[`hsl(28 95% 42%)`,`hsl(28 82% 52%)`,`hsl(28 55% 63%)`,`hsl(28 25% 72%)`],_e=[`hsl(28 95% 66%)`,`hsl(28 82% 76%)`,`hsl(28 55% 85%)`,`hsl(28 25% 92%)`],ve={typescript:210,tsx:210,javascript:48,jsx:48,python:160,rust:20,go:190,css:280,html:15,markdown:90};function ye(e){let t=ve[e.toLowerCase()];return t===void 0?Math.round(ie(e)/30)*30%360:t}function be(e,t,n){if(n!=null)return t.dark?{roof:A[n],facade:pe[n],edge:me[n]}:{roof:he[n],facade:ge[n],edge:_e[n]};if(!e)return t.dark?{roof:`hsl(220 6% 40%)`,facade:`hsl(220 7% 27%)`,edge:`hsl(220 8% 50%)`}:{roof:`hsl(46 12% 72%)`,facade:`hsl(46 12% 56%)`,edge:`hsl(46 16% 82%)`};let r=ye(e);return t.dark?{roof:`hsl(${r} 34% 42%)`,facade:`hsl(${r} 36% 28%)`,edge:`hsl(${r} 40% 52%)`}:{roof:`hsl(${r} 48% 70%)`,facade:`hsl(${r} 42% 54%)`,edge:`hsl(${r} 55% 80%)`}}var xe=5,j=[`hsl(28 92% 37%)`,`hsl(28 70% 28%)`,`hsl(28 42% 21%)`,`hsl(28 16% 16%)`],Se=[`hsl(28 95% 35%)`,`hsl(28 82% 45%)`,`hsl(28 55% 56%)`,`hsl(28 25% 65%)`];function Ce(e,t,n,r){let i=be(e,t,n);if(n!=null){let e=t.dark?j[n]:Se[n];return{top:i.roof,wallL:i.facade,wallR:e,edge:i.edge}}if(!e)return{top:i.roof,wallL:i.facade,wallR:t.dark?`hsl(220 7% 20%)`:`hsl(46 12% 46%)`,edge:i.edge};let a=ye(e);if(!r)return{top:i.roof,wallL:i.facade,wallR:t.dark?`hsl(${a} 36% 21%)`:`hsl(${a} 42% 44%)`,edge:i.edge};let o=t.dark?{top:34,wall:36,edge:40}:{top:48,wall:42,edge:55},s=t.dark?{top:42,wallL:28,wallR:21,edge:52}:{top:70,wallL:54,wallR:44,edge:80},c=ue(r.urbanity),l=ce(r.wall,r.roof),u=Math.max(-1,Math.min(1,r.variance??0))*xe;return{top:le(k({h:a,s:o.top,l:s.top+u},r.roof,1)),wallL:le(k({h:a,s:o.wall,l:s.wallL+u},r.wall,c,l)),wallR:le(k({h:a,s:o.wall,l:s.wallR+u},r.wall,c,l)),edge:le(k({h:a,s:o.edge,l:s.edge+u},r.roof,1))}}function M(e){return e.urbanity??.5}function N(e){switch(e.settlement){case`hamlet`:case`village`:return`village`;case`city`:return`city`;default:return`town`}}var we=new WeakMap;function Te(e){let t=we.get(e);if(t)return t;let n=new Map;for(let t of e.blocks){if(t.state===`tombstoned`||t.phantom)continue;let e=n.get(t.districtId)??{total:0,count:0};e.total+=M(t),e.count+=1,n.set(t.districtId,e)}let r=new Map;for(let[e,{total:t,count:i}]of n){let n=t/Math.max(1,i);r.set(e,n>=.74?`city`:n>=.52?`town`:`village`)}return we.set(e,r),r}var Ee={kind:`none`,u0:0,v0:0,u1:0,v1:0,height:0,behind:!1},De={FACADE:2710517197,ROOF_FURNITURE:1640531527,MASSING:2654435769,MATERIAL:2246822507,TRIM:3266489909,GROUND:668265263},Oe={village:{residential:[`cottage`,`cottage-row`,`farmhouse`],commercial:[`village-shop`,`smithy`,`market-cross`],civic:[`chapel`,`schoolhouse`,`parish-hall`],industrial:[`barn`,`mill`,`kiln`]},town:{residential:[`cottage`,`townhouse`,`boarding-house`],commercial:[`corner-shop`,`inn`,`market-hall`],civic:[`library`,`schoolhouse`,`guildhall`],industrial:[`workshop`,`rail-depot`,`foundry`]},city:{residential:[`terrace-house`,`tenement`,`mansion-flat`],commercial:[`shopfront-block`,`hotel`,`arcade`],civic:[`bank`,`institute`,`town-hall`],industrial:[`warehouse`,`works`,`terminus`]}},ke={cornice:!1,parapet:!1,stringCourse:!1,quoins:!1};function Ae(e,t,n,r=1){let i=e===`conical`?2.1:e===`pyramid`?1.35:1,a=Math.max(r,i);return n>0&&(a=Math.max(a,i+.68)),a=Math.max(a,i+({cupola:.78,bellcote:.62,"clock-tower":.78,finial:.4,lantern:.56}[t]??0)),a}function je(e,t,n,r){let i=oe(e^De.MATERIAL,t,n);return r===`thatch`?i.roof=`thatch`:r===`conical`?i.roof=`brick`:r===`barrel`&&(i.roof=`glass`),i}var Me={cottage:{roofs:[`gable`],eaves:`gable`,ground:`plain`,cap:`none`,trim:{}},"cottage-row":{roofs:[`thatch`,`gable`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{}},farmhouse:{roofs:[`catslide`,`half-hip`],eaves:`gable`,ground:`plain`,cap:`finial`,trim:{}},"village-shop":{roofs:[`gable`,`catslide`],eaves:`gable`,ground:`shopfront`,cap:`none`,trim:{}},smithy:{roofs:[`shed`,`catslide`],eaves:`eave`,ground:`cart-door`,cap:`none`,trim:{}},"market-cross":{roofs:[`pyramid`],eaves:`gable`,ground:`arcade`,cap:`finial`,trim:{}},chapel:{roofs:[`gable`],eaves:`gable`,ground:`plain`,cap:`bellcote`,trim:{}},"parish-hall":{roofs:[`half-hip`,`gable`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{}},barn:{roofs:[`gable`,`catslide`],eaves:`gable`,ground:`cart-door`,cap:`none`,trim:{}},mill:{roofs:[`monitor`,`gable`],eaves:`eave`,ground:`cart-door`,cap:`none`,trim:{}},kiln:{roofs:[`conical`],eaves:`gable`,ground:`cart-door`,cap:`none`,trim:{},roofFactor:1.6},"boarding-house":{roofs:[`hip`,`mansard`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{cornice:!0}},townhouse:{roofs:[`mansard`,`gable`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{cornice:!0,stringCourse:!0}},"corner-shop":{roofs:[`mansard`,`gable`],eaves:`eave`,ground:`shopfront`,cap:`none`,trim:{cornice:!0}},"market-hall":{roofs:[`gable`,`hip`],eaves:`eave`,ground:`arcade`,cap:`none`,trim:{cornice:!0}},inn:{roofs:[`hip`,`mansard`],eaves:`eave`,ground:`shopfront`,cap:`none`,trim:{cornice:!0}},guildhall:{roofs:[`hip`,`mansard`],eaves:`eave`,ground:`portico`,cap:`cupola`,trim:{cornice:!0,quoins:!0}},library:{roofs:[`hip`,`mansard`],eaves:`eave`,ground:`portico`,cap:`cupola`,trim:{cornice:!0,quoins:!0}},schoolhouse:{roofs:[`gable`],eaves:`gable`,ground:`plain`,cap:`bellcote`,trim:{}},foundry:{roofs:[`sawtooth`],eaves:`eave`,ground:`cart-door`,cap:`none`,trim:{}},"rail-depot":{roofs:[`gable`],eaves:`eave`,ground:`arcade`,cap:`none`,trim:{}},workshop:{roofs:[`sawtooth`],eaves:`eave`,ground:`cart-door`,cap:`none`,trim:{}},"terrace-house":{roofs:[`parapet`,`mansard`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{cornice:!0,parapet:!0,stringCourse:!0}},tenement:{roofs:[`mansard`,`parapet`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{cornice:!0,stringCourse:!0}},"mansion-flat":{roofs:[`mansard`,`hip`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{cornice:!0,stringCourse:!0,quoins:!0}},"shopfront-block":{roofs:[`parapet`,`mansard`],eaves:`eave`,ground:`shopfront`,cap:`none`,trim:{cornice:!0,parapet:!0,stringCourse:!0}},hotel:{roofs:[`mansard`,`hip`],eaves:`eave`,ground:`shopfront`,cap:`lantern`,trim:{cornice:!0,stringCourse:!0,quoins:!0},roofFactor:1.3},arcade:{roofs:[`barrel`,`monitor`],eaves:`eave`,ground:`arcade`,cap:`none`,trim:{cornice:!0,parapet:!0}},bank:{roofs:[`parapet`,`hip`],eaves:`eave`,ground:`portico`,cap:`none`,trim:{cornice:!0,parapet:!0,quoins:!0}},institute:{roofs:[`hip`,`parapet`],eaves:`eave`,ground:`portico`,cap:`cupola`,trim:{cornice:!0,quoins:!0}},"town-hall":{roofs:[`hip`,`mansard`],eaves:`eave`,ground:`portico`,cap:`clock-tower`,trim:{cornice:!0,quoins:!0,stringCourse:!0},roofFactor:1.6},warehouse:{roofs:[`monitor`,`gable`],eaves:`eave`,ground:`cart-door`,cap:`none`,trim:{cornice:!0,parapet:!0}},works:{roofs:[`sawtooth`],eaves:`eave`,ground:`cart-door`,cap:`none`,trim:{parapet:!0}},terminus:{roofs:[`barrel`,`monitor`],eaves:`eave`,ground:`arcade`,cap:`none`,trim:{cornice:!0,parapet:!0}},field:{roofs:[`shed`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{},roofFactor:1.4},park:{roofs:[`hip`],eaves:`eave`,ground:`plain`,cap:`none`,trim:{},roofFactor:2.2},"signal-tower":{roofs:[`parapet`],eaves:`eave`,ground:`portico`,cap:`lantern`,trim:{cornice:!0,parapet:!0,quoins:!0},roofFactor:1.9}},Ne={data:`field`,style:`park`,config:`signal-tower`},Pe={farmhouse:`ell`,"parish-hall":`ell`,barn:`ell`,mill:`ell`,smithy:`ell`,guildhall:`ell`,library:`ell`,inn:`ell`,"rail-depot":`ell`,"mansion-flat":`setback`,tenement:`setback`,hotel:`setback`,bank:`setback`,institute:`setback`,"town-hall":`setback`,warehouse:`setback`};function Fe(e,t,n){let r=Pe[e];if(!r)return Ee;let i=T(t^De.MASSING);if(r===`setback`)return n<3?Ee:{kind:r,u0:.12,v0:.12,u1:.88,v1:.88,height:1.22,behind:!1};let a=Math.floor(i()*4),o=.46+i()*.12,s=a===0||a===3;return{kind:r,...a===0?{u0:.04,v0:.04,u1:.04+o,v1:.52}:a===1?{u0:.96-o,v0:.04,u1:.96,v1:.52}:a===2?{u0:.96-o,v0:.48,u1:.96,v1:.96}:{u0:.04,v0:.48,u1:.04+o,v1:.96},height:n<=1?.72:(n-1)/n,behind:s}}function Ie(e,t){return e[Math.min(e.length-1,Math.floor(t()*e.length))]}function Le(e,t){let{w:n,h:r}=e.rect;return n>r*1.18?`x`:r>n*1.18?`y`:t()<.5?`x`:`y`}function Re(e,t){let n=Me[e].roofs;return n.length===1||t()<ze[e]?n[0]:n[1]}var ze={townhouse:.55,"corner-shop":.55,"boarding-house":.7,inn:.7,library:.7,guildhall:.7,"market-hall":.65,"cottage-row":.6,farmhouse:.55,"village-shop":.65,smithy:.6,"parish-hall":.6,barn:.7,mill:.6,"terrace-house":.6,tenement:.55,"mansion-flat":.6,"shopfront-block":.65,hotel:.6,arcade:.7,bank:.6,institute:.6,"town-hall":.6,warehouse:.6,terminus:.65};function Be(e){return/(?:^|[/_.-])(?:test|tests|spec|specs)(?:[/_.-]|$)/i.test(e)}var Ve={village:`parish-hall`,town:`guildhall`,city:`town-hall`};function He(e){let t=w(`town-1910:v1:${e.id}`),n=T(t),r=e.health?.zone??`residential`,i=N(e),a=Oe[i],o=C(e),s;s=Ne[o]||(e.landmark?Ve[i]:Be(e.id)&&r!==`industrial`?`schoolhouse`:Ie(a[r],n));let c=Math.max(1,Math.min(5,e.levels??1)),l=Math.ceil(Math.sqrt(Math.max(1,e.buildingCount))),u=Math.max(1,Math.min(5,l+ +(n()<.45))),d=r===`industrial`,f=r===`commercial`,p=r===`civic`||e.landmark===!0,m=e.health?.churn??0,h=Re(s,n),g=Le(e,n),_=Me[s],v=i===`city`?Math.max(1,Math.min(6,Math.round(u*1.4))):i===`village`?Math.min(3,u):u,y=d?1+Math.min(2,Math.floor(m/8)+ +(n()<.5)):s===`cottage`||s===`inn`||s===`boarding-house`||i===`village`&&!p?1+ +(n()<.25):0,b=p&&(e.landmark===!0||n()<.5),x=_.cap===`cupola`&&!b?`none`:_.cap,ee=y===0&&i===`city`&&!d&&c>=3?Math.max(1,Math.min(3,Math.floor(v/2))):y,te=Ae(h,x,ee,_.roofFactor);return{archetype:s,use:o,roof:h,ridge:g,storeys:c,bays:v,chimneys:ee,dormers:h===`mansard`||h===`gable`&&c>=3?Math.min(3,Math.max(1,Math.floor(v/2))):0,awning:f&&s!==`market-hall`,cupola:b,clock:e.landmark===!0,sawteeth:h===`sawtooth`?Math.max(2,Math.min(5,v)):0,seed:t,band:i,eaves:_.eaves,ground:_.ground,cap:x,trim:{...ke,..._.trim},material:je(t,i,d,h),massing:Fe(s,t,c),...te===1?{}:{roofFactor:te}}}function Ue(e,t){let n=w(`town-1910:symbol:v1:${e.id}`),r=T(n),i=e.kind.toLowerCase(),a=/class|interface|struct|enum|trait|type/.test(i),o=/module|namespace|package/.test(i),s=t.health?.zone===`industrial`,c=N(t),l=s?`industrial`:o?`civic`:a?`residential`:`commercial`,u=Oe[c][l],d=e.height<.4?0:e.height<.72?1:2,f=u[Math.min(u.length-1,d)],p=Re(f,r),m=Math.max(1,Math.min(3,1+Math.round(e.height*2))),h=Math.max(1,Math.min(3,Math.ceil(Math.sqrt(Math.max(1,e.lines??1))/3))),g=Me[f],_=g.cap===`clock-tower`?`cupola`:g.cap,v=Le(e,r),y=s||f===`cottage`||f===`farmhouse`||f===`inn`?1+ +(r()<.3):0,b=p===`sawtooth`?2+ +(r()<.4):0,x=Ae(p,_,y,g.roofFactor);return{archetype:f,use:`code`,roof:p,ridge:v,storeys:m,bays:h,chimneys:y,dormers:+(p===`mansard`&&e.height>.55),awning:t.health?.zone===`commercial`&&!a,cupola:_===`cupola`,clock:!1,sawteeth:b,seed:n,band:c,eaves:g.eaves,ground:g.ground,cap:_,trim:{...ke,...g.trim},material:je(n,c,s,p),massing:Ee,...x===1?{}:{roofFactor:x}}}function We(e){return e.archetype.replace(/-/g,` `)}function Ge(e){return`${e.band} ${We(e)}`}var Ke=new WeakMap;function qe(e){let t=Ke.get(e);if(t)return t;let n=new Map;for(let t of e.blocks)t.state!==`tombstoned`&&n.set(t.id,He(t));return Ke.set(e,n),n}function Je(e,t){let n=qe(e).get(t.id);if(n)return n;let r=He(t);return qe(e).set(t.id,r),r}function P(e,t){return{x:y(e,t.x),y:b(e,t.y),w:t.w*e.scale,h:t.h*e.scale}}function F(e,t,n,r,i,a){let o=Math.max(0,Math.min(a,r/2,i/2));e.beginPath(),e.moveTo(t+o,n),e.arcTo(t+r,n,t+r,n+i,o),e.arcTo(t+r,n+i,t,n+i,o),e.arcTo(t,n+i,t,n,o),e.arcTo(t,n,t+r,n,o),e.closePath()}var Ye=new Map;function Xe(e,t){let n=Ye.get(t);if(n!==void 0)return n;let r=null;try{let n=document.createElement(`canvas`);n.width=8,n.height=8;let i=n.getContext(`2d`);i&&(i.strokeStyle=t,i.lineWidth=1.2,i.beginPath(),i.moveTo(-2,10),i.lineTo(10,-2),i.stroke(),r=e.createPattern(n,`repeat`)??null)}catch{r=null}return Ye.set(t,r),r}var Ze=1.5,Qe=2.5,$e=6;function et(e,t){return e.tier===`street`&&re(t)}function tt(e,t){let n=t.palette,r=t.now??Date.now(),i=[];for(let e of t.model.blocks)S(t.cam,e.rect,t.viewW,t.viewH)&&i.push({b:e,r:P(t.cam,e.rect),age:t.ageLens?fe(e.lastTouchedAt??e.placedAt,r):void 0});if(t.tier!==`city`&&!t.ageLens)for(let n of i)nt(e,t,n);if(t.tier!==`city`){e.fillStyle=n.shadow;for(let{b:n,r}of i)n.state!==`live`&&!t.ageLens||n.phantom||r.w<$e||et(t,n)||(F(e,r.x+Ze,r.y+Qe,r.w,r.h,Math.min(3,r.w/6)),e.fill())}for(let n of i)it(e,t,n)}function nt(e,t,n){let{b:r}=n,i=t.palette;if(r.state!==`live`||r.phantom||!r.lot||!r.health)return;let a=P(t.cam,r.lot);if(a.w<10)return;rt(e,t,r,a);let{vibe:o,zone:s,maxSeverity:c}=r.health;s===`civic`?(e.fillStyle=i.sidewalk,F(e,a.x,a.y,a.w,a.h,3),e.fill(),e.strokeStyle=i.domeAccent,e.globalAlpha=.55,e.lineWidth=1,F(e,a.x+1.5,a.y+1.5,a.w-3,a.h-3,2),e.stroke(),e.globalAlpha=1):(o===`scruffy`||o===`blighted`)&&(e.fillStyle=i.earth,e.globalAlpha=o===`blighted`?.45:.3,F(e,a.x,a.y,a.w,a.h,3),e.fill(),e.globalAlpha=1,o===`blighted`&&c===`critical`&&(e.strokeStyle=i.crane,e.globalAlpha=.8,e.lineWidth=1,F(e,a.x,a.y,a.w,a.h,3),e.stroke(),e.globalAlpha=1))}function rt(e,t,n,r){let i=t.palette,a=M(n);e.globalAlpha=.4,e.fillStyle=a<.25?i.orchard:a<.5?i.ground:i.sidewalk,F(e,r.x,r.y,r.w,r.h,3),e.fill(),e.globalAlpha=1;let o=N(n);if(!(o===`city`&&a>.78)){if(o===`village`){e.strokeStyle=i.hedge,e.lineWidth=1.6,e.lineCap=`round`,e.beginPath();for(let[t,n,i,a]of[[r.x,r.y,r.x+r.w,r.y],[r.x+r.w,r.y,r.x+r.w,r.y+r.h],[r.x+r.w,r.y+r.h,r.x,r.y+r.h],[r.x,r.y+r.h,r.x,r.y]]){let r=Math.max(1,Math.floor(Math.hypot(i-t,a-n)/5));for(let o=0;o<r;o++){let s=(o+.15)/r,c=(o+.85)/r;e.moveTo(t+(i-t)*s,n+(a-n)*s),e.lineTo(t+(i-t)*c,n+(a-n)*c)}}e.stroke(),e.lineCap=`butt`;return}e.strokeStyle=o===`town`?i.fence:i.curb,e.lineWidth=1,o===`town`&&e.setLineDash([2,2]),F(e,r.x,r.y,r.w,r.h,3),e.stroke(),e.setLineDash([])}}function it(e,t,n){let{b:r,r:i,age:a}=n,o=t.palette;if(r.state===`tombstoned`){ct(e,t,n);return}if(r.phantom){ut(e,t,n);return}if(r.state===`new`&&!t.ageLens){lt(e,t,n);return}let s=be(r.lang,o,a),c=Math.min(3,i.w/6),l=Je(t.model,r);if(!t.ageLens&&(l.archetype===`field`||l.archetype===`park`)){at(e,t,n,l,s.roof);return}if(t.tier===`city`||i.w<$e){e.fillStyle=s.roof,F(e,i.x,i.y,i.w,i.h,c),e.fill(),i.w>3&&(e.strokeStyle=o.blockStroke,e.lineWidth=.5,F(e,i.x,i.y,i.w,i.h,c),e.stroke());return}if(et(t,r)){e.fillStyle=o.sidewalk,F(e,i.x,i.y,i.w,i.h,c),e.fill(),e.fillStyle=s.roof,e.globalAlpha=.28,F(e,i.x,i.y,i.w,i.h,c),e.fill(),e.globalAlpha=1,e.strokeStyle=o.blockStroke,e.lineWidth=.5,F(e,i.x,i.y,i.w,i.h,c),e.stroke();return}let u=Math.min(Math.max(2,Math.sqrt(Math.max(1,r.weight))*.15*t.cam.scale),8,i.h*.35);e.fillStyle=s.facade,F(e,i.x,i.y,i.w,i.h,c),e.fill(),e.fillStyle=s.roof,F(e,i.x,i.y,i.w,i.h-u,c),e.fill(),e.strokeStyle=s.edge,e.lineWidth=1,e.beginPath(),e.moveTo(i.x+c,i.y+.5),e.lineTo(i.x+i.w-c,i.y+.5),e.stroke(),t.ageLens||ot(e,t,n,i.h-u,s,l)}function at(e,t,n,r,i){let{r:a}=n,o=t.palette,s=Math.min(3,a.w/6);if(r.archetype===`field`){if(e.fillStyle=o.farm.crops[(r.seed>>>4)%4],F(e,a.x,a.y,a.w,a.h,s),e.fill(),t.tier!==`city`&&a.w>=10){let n=Math.max(3,1.6*t.cam.scale),i=r.ridge===`x`;e.strokeStyle=o.farm.furrow,e.globalAlpha=.35,e.lineWidth=.8,e.beginPath();let s=i?a.h:a.w;for(let t=n/2;t<s;t+=n)i?(e.moveTo(a.x+1,a.y+t),e.lineTo(a.x+a.w-1,a.y+t)):(e.moveTo(a.x+t,a.y+1),e.lineTo(a.x+t,a.y+a.h-1));e.stroke(),e.globalAlpha=1}return}if(e.fillStyle=o.park.lawn,F(e,a.x,a.y,a.w,a.h,s),e.fill(),t.tier===`city`||a.w<10)return;let c=Math.max(1,Math.min(a.w,a.h)*.1);e.fillStyle=o.park.path,e.fillRect(a.x,a.y+a.h/2-c/2,a.w,c),e.fillRect(a.x+a.w/2-c/2,a.y,c,a.h);let l=Math.min(a.w,a.h)*.3;e.fillStyle=i,e.globalAlpha=.85,e.fillRect(a.x+a.w/2-l/2,a.y+a.h/2-l/2,l,l),e.globalAlpha=1}function ot(e,t,n,r,i,a){let{r:o}=n;if(a.roof===`sawtooth`&&r>=12){st(e,t,n,r,i.facade,i.edge);return}if(o.w<14||r<10)return;let s=a.ridge===`x`?o.w>=r:o.w<r,c=o.x+o.w/2,l=o.y+r/2,u=(t,n,r,a,o=1)=>{e.strokeStyle=i.edge,e.lineWidth=o,e.beginPath(),e.moveTo(t,n),e.lineTo(r,a),e.stroke()},d=t=>{e.globalAlpha=.22,s?(e.fillStyle=i.edge,e.fillRect(o.x+1,o.y+1,o.w-2,r*t-1),e.fillStyle=i.facade,e.fillRect(o.x+1,o.y+r*t,o.w-2,r*(1-t)-1)):(e.fillStyle=i.edge,e.fillRect(o.x+1,o.y+1,o.w*t-1,r-2),e.fillStyle=i.facade,e.fillRect(o.x+o.w*t,o.y+1,o.w*(1-t)-1,r-2)),e.globalAlpha=1},f=(e=1)=>{let t=(1-e)/2;s?u(o.x+1+(o.w-2)*t,l,o.x+o.w-1-(o.w-2)*t,l):u(c,o.y+1+(r-2)*t,c,o.y+r-1-(r-2)*t)},p=e=>{let t=(1-e)/2,[n,i]=s?[{x:o.x+1+(o.w-2)*t,y:l},{x:o.x+o.w-1-(o.w-2)*t,y:l}]:[{x:c,y:o.y+1+(r-2)*t},{x:c,y:o.y+r-1-(r-2)*t}];u(n.x,n.y,o.x+1,o.y+1,.7),u(n.x,n.y,s?o.x+1:o.x+o.w-1,s?o.y+r-1:o.y+1,.7),u(i.x,i.y,o.x+o.w-1,o.y+r-1,.7),u(i.x,i.y,s?o.x+o.w-1:o.x+1,s?o.y+1:o.y+r-1,.7)},m=t=>{e.globalAlpha=.3,e.fillStyle=i.edge,e.fillRect(o.x+o.w*t,o.y+r*t,o.w*(1-t*2),r*(1-t*2)),e.globalAlpha=1};switch(a.roof){case`gable`:d(.5),f();break;case`catslide`:d(.34),s?u(o.x+1,o.y+r*.34,o.x+o.w-1,o.y+r*.34):u(o.x+o.w*.34,o.y+1,o.x+o.w*.34,o.y+r-1);break;case`thatch`:d(.5),f(.8),e.strokeStyle=i.facade,e.globalAlpha=.5,e.lineWidth=Math.max(2,Math.min(4,r*.16)),F(e,o.x+1.5,o.y+1.5,o.w-3,r-3,Math.min(r,o.w)/2),e.stroke(),e.globalAlpha=1;break;case`hip`:d(.5),f(.5),p(.5);break;case`half-hip`:d(.5),f(.76),p(.76);break;case`shed`:d(.82);break;case`mansard`:m(.24),p(.5);break;case`parapet`:e.strokeStyle=i.edge,e.lineWidth=1,e.strokeRect(o.x+1.5,o.y+1.5,o.w-3,r-3),m(.18);break;case`monitor`:{d(.5);let t=Math.max(2,r*.22);e.globalAlpha=.4,e.fillStyle=i.edge,s?e.fillRect(o.x+2,l-t/2,o.w-4,t):e.fillRect(c-t/2,o.y+2,t,r-4),e.globalAlpha=1,f();break}case`pyramid`:u(o.x+1,o.y+1,o.x+o.w-1,o.y+r-1,.8),u(o.x+o.w-1,o.y+1,o.x+1,o.y+r-1,.8);break;case`conical`:{let t=Math.min(o.w,r)*.42;e.strokeStyle=i.edge,e.lineWidth=.9;for(let n of[1,.45])e.beginPath(),e.arc(c,l,t*n,0,Math.PI*2),e.stroke();break}case`barrel`:e.strokeStyle=i.edge,e.lineWidth=.9,e.beginPath();for(let t of[.3,.5,.7])s?(e.moveTo(o.x+2,o.y+r*t),e.lineTo(o.x+o.w-2,o.y+r*t)):(e.moveTo(o.x+o.w*t,o.y+2),e.lineTo(o.x+o.w*t,o.y+r-2));e.stroke();break;default:d(.5),f();break}if(a.band===`city`&&a.bays>1&&o.w>=20){e.strokeStyle=i.facade,e.globalAlpha=.55,e.lineWidth=.7,e.beginPath();for(let t=1;t<Math.min(5,a.bays);t++){let n=t/a.bays;s?(e.moveTo(o.x+o.w*n,o.y+1),e.lineTo(o.x+o.w*n,o.y+r-1)):(e.moveTo(o.x+1,o.y+r*n),e.lineTo(o.x+o.w-1,o.y+r*n))}e.stroke(),e.globalAlpha=1}if(a.chimneys>0&&r>=12){e.fillStyle=t.palette.masonry;for(let t=0;t<Math.min(3,a.chimneys);t++){let n=a.chimneys===1?.5:.3+t/(a.chimneys-1)*.4,i=s?o.x+o.w*n:c,u=s?l:o.y+r*n;e.fillRect(i-1,u-1,2.2,2.2)}}if(a.cupola&&r>=12){let n=Math.min(o.w,r)*.16;e.fillStyle=t.palette.domeAccent,e.beginPath(),e.arc(c,l,n,0,Math.PI*2),e.fill(),e.strokeStyle=i.facade,e.lineWidth=1,e.stroke()}}function st(e,t,n,r,i,a){let{b:o,r:s}=n;e.fillStyle=i,e.globalAlpha=.3;for(let t=1;t<=3;t++){let n=s.y+r*t/4;e.fillRect(s.x+1,n,s.w-2,Math.max(1.5,r*.1))}e.globalAlpha=1;let c=T(w(o.id));e.fillStyle=a;for(let t=0;t<2;t++){let t=2+c()*2,n=s.x+2+c()*Math.max(1,s.w-t-4),i=s.y+2+c()*Math.max(1,r-t-4);e.fillRect(n,i,t,t)}}function ct(e,t,n){let{b:r,r:i}=n,a=t.palette,o=Math.min(3,i.w/6);if(e.fillStyle=t.ageLens?a.tombstone:a.earth,e.globalAlpha=t.ageLens?.4:.7,F(e,i.x,i.y,i.w,i.h,o),e.fill(),e.globalAlpha=1,t.tier!==`city`&&i.w>=10&&!t.ageLens){let t=T(w(r.id)),n=4+Math.floor(t()*4);e.fillStyle=a.rubble;for(let r=0;r<n;r++){let n=Math.min(5,Math.max(1,(.06+.08*t())*Math.min(i.w,i.h))),r=i.x+i.w*(.12+.76*t()),a=i.y+i.h*(.12+.76*t());e.fillRect(r,a,n,n)}e.strokeStyle=a.blockStroke,e.globalAlpha=.6,e.setLineDash([3,3]),F(e,i.x,i.y,i.w,i.h,o),e.stroke(),e.setLineDash([]),e.globalAlpha=1}}function lt(e,t,n){let{b:r,r:i}=n,a=t.palette,o=Math.min(3,i.w/6);if(t.tier===`city`||i.w<$e){e.fillStyle=a.newBlock,F(e,i.x,i.y,i.w,i.h,o),e.fill();return}if(e.fillStyle=a.earth,F(e,i.x,i.y,i.w,i.h,o),e.fill(),e.strokeStyle=a.newBlock,e.lineWidth=1.5,e.setLineDash([4,3]),F(e,i.x,i.y,i.w,i.h,o),e.stroke(),e.setLineDash([]),t.tier===`street`&&i.w>=14){let t=T(w(r.id)),n=i.x+i.w*(.25+.5*t()),o=i.y+i.h*.85,s=i.y+i.h*.2,c=i.w*.4*(t()<.5?-1:1);e.strokeStyle=a.crane,e.lineWidth=1.5,e.beginPath(),e.moveTo(n,o),e.lineTo(n,s),e.lineTo(n+c,s),e.moveTo(n+c*.8,s),e.lineTo(n+c*.8,s+i.h*.15),e.stroke()}}function ut(e,t,n){let{b:r,r:i}=n,a=t.palette,o=Math.min(3,i.w/6);e.fillStyle=be(r.lang,a).roof,e.globalAlpha=.25,F(e,i.x,i.y,i.w,i.h,o),e.fill(),e.globalAlpha=1;let s=Xe(e,a.dark?`#8b8f99`:`#8a7f64`);s&&(e.fillStyle=s,F(e,i.x,i.y,i.w,i.h,o),e.fill()),e.strokeStyle=a.blockStroke,e.setLineDash([4,3]),F(e,i.x,i.y,i.w,i.h,o),e.stroke(),e.setLineDash([])}function dt(e,t){let n=t.palette,r=(n,r,i)=>{let a=t.model.blocks.find(e=>e.id===n);if(!a||!S(t.cam,a.rect,t.viewW,t.viewH))return;let o=P(t.cam,a.rect);e.strokeStyle=r,e.lineWidth=i,F(e,o.x,o.y,o.w,o.h,Math.min(3,o.w/6)),e.stroke()};t.hoverId&&t.hoverId!==t.selectedId&&r(t.hoverId,n.hover,1.5),t.selectedId&&r(t.selectedId,n.selected,2)}function ft(e,t){if(t.tier!==`street`)return;let n=t.palette;for(let r of t.model.buildings){if(!S(t.cam,r.rect,t.viewW,t.viewH))continue;let i=P(t.cam,r.rect);if(i.w<1.5||i.h<1.5)continue;if(i.w<4||i.h<6){e.fillStyle=n.building,e.globalAlpha=.35+.55*r.height,e.fillRect(i.x,i.y,i.w,i.h);continue}let a=Math.min(Math.max(1.5,r.height*.35*i.h),6);e.globalAlpha=.5+.45*r.height,e.fillStyle=n.buildingFacade,e.fillRect(i.x,i.y,i.w,i.h),e.fillStyle=n.building,e.fillRect(i.x,i.y,i.w,i.h-a);let o=i.h-a;if(i.w>10&&o>8){let t=T(w(r.id));if(r.kind===`class`||r.kind===`interface`||r.kind===`struct`){e.strokeStyle=n.buildingFacade,e.lineWidth=1;let r=i.y+o*(.35+.3*t());e.beginPath(),e.moveTo(i.x+1,r),e.lineTo(i.x+i.w-1,r),e.stroke()}else if(r.kind===`function`||r.kind===`method`){let r=1+ +(t()<.4);e.fillStyle=n.buildingFacade;for(let n=0;n<r;n++){let n=2+t()*2,r=i.x+2+t()*Math.max(1,i.w-n-4),a=i.y+2+t()*Math.max(1,o-n-4);e.fillRect(r,a,n,n)}}}}e.globalAlpha=1}var pt=[`tree1`,`tree2`,`tree3`];function mt(e){let t=e.lot;if(!t||e.phantom||e.state===`tombstoned`)return[];let n=e.health?.vibe??`plain`;if(n===`plain`)return[];let r=T(w(e.id)),i=e.rect,a=[],o=()=>{let e=r(),n=t.x+1+r()*Math.max(.5,t.w-2),a=t.y+1+r()*Math.max(.5,t.h-2);return e<.45?{x:n,y:(i.y+i.h+t.y+t.h)/2}:e<.6?{x:n,y:(t.y+i.y)/2}:e<.8?{x:(t.x+i.x)/2,y:a}:{x:(i.x+i.w+t.x+t.w)/2,y:a}},s=(e,t,n)=>{let{x:i,y:s}=o();a.push({sprite:e,x:i,y:s,size:t+r()*(n-t)})},c=()=>s(pt[Math.floor(r()*pt.length)],2.2,3.4);switch(n){case`lush`:{let e=3+Math.floor(r()*3);for(let t=0;t<e;t++)c();let t=1+ +(r()<.5);for(let e=0;e<t;e++)s(`shrub`,1.5,2.2);break}case`tidy`:{let e=1+ +(r()<.5);for(let t=0;t<e;t++)c();break}case`scruffy`:{s(`dryPatch`,2.5,4);let e=1+ +(r()<.5);for(let t=0;t<e;t++)s(`weed`,1.6,2.4);break}case`blighted`:{s(`dryPatch`,2.5,4),s(`deadTree`,2.6,3.6);let e=1+ +(r()<.5);for(let t=0;t<e;t++)s(`weed`,1.6,2.4);break}}return a}var ht=new WeakMap;function gt(e){let t=ht.get(e);if(t)return t;let n=new Map;for(let t of e.blocks){let e=mt(t);e.length&&n.set(t.id,e)}return ht.set(e,n),n}var _t=3e3,vt=6e3,yt=14;function bt(e,t,n){if(!n||t.tier===`city`||t.ageLens||t.tier===`district`&&t.model.blocks.length>vt)return;let r=gt(t.model);if(r.size===0)return;let i=_t;for(let a of t.model.blocks){let o=r.get(a.id);if(!o||o.length===0)continue;let s=a.lot??a.rect;if(S(t.cam,s,t.viewW,t.viewH)&&!(t.tier===`district`&&s.w*t.cam.scale<=yt))for(let r of o){let a=r.size*t.cam.scale;if(a<2.5)continue;if(i--<=0)return;let o=n.index[r.sprite]*n.cell;e.drawImage(n.canvas,o,0,n.cell,n.cell,y(t.cam,r.x)-a/2,b(t.cam,r.y)-a/2,a,a)}}}var xt=[{carriageway:.55,sidewalk:0,surface:`dirt`,verge:!0,lamps:!1,trees:!1,trolley:!1,carts:0,walkers:!1},{carriageway:.55,sidewalk:0,surface:`cobble`,verge:!0,lamps:!1,trees:!1,trolley:!1,carts:0,walkers:!1},{carriageway:.55,sidewalk:0,surface:`paved`,verge:!0,lamps:!1,trees:!1,trolley:!1,carts:0,walkers:!1},{carriageway:.8,sidewalk:0,surface:`dirt`,verge:!0,lamps:!1,trees:!1,trolley:!1,carts:1,walkers:!1},{carriageway:.8,sidewalk:0,surface:`paved`,verge:!1,lamps:!1,trees:!1,trolley:!1,carts:1,walkers:!1},{carriageway:.64,sidewalk:.16,surface:`paved`,verge:!1,lamps:!0,trees:!1,trolley:!1,carts:1.5,walkers:!0},{carriageway:.72,sidewalk:.14,surface:`paved`,verge:!1,lamps:!0,trees:!0,trolley:!1,carts:2,walkers:!0},{carriageway:.72,sidewalk:.14,surface:`paved`,verge:!1,lamps:!0,trees:!0,trolley:!0,carts:2,walkers:!0}],St=[5,4,2,1];function Ct(e){return e.grade===void 0?St[Math.max(0,Math.min(3,e.tier))]:Math.max(0,Math.min(7,e.grade))}var wt=22,Tt=34,Et=18,Dt=26,Ot=48,kt=[`tree1`,`tree2`],At=.0055,jt=.012,Mt=.0022;function Nt(e,t,n){let r=t-e,i=Math.min(Ot,Math.floor(r/n));if(i<=0)return[];let a=r/i,o=[];for(let t=0;t<i;t++)o.push(e+a*(t+.5));return o}function Pt(e){let t=e.rect,n=t.w>=t.h,r=n?t.x:t.y,i=n?t.x+t.w:t.y+t.h,a=n?t.h:t.w,o=n?t.y+t.h/2:t.x+t.w/2,s=Ct(e),c=xt[s];return{street:e,grade:s,spec:c,horizontal:n,a0:r,a1:i,center:o,width:a,carriagewayWidth:a*c.carriageway,sidewalkWidth:a*c.sidewalk,c0:r,c1:i,r0:r,r1:i}}var Ft=20,It=.3;function Lt(e){let t=e.filter(e=>e.horizontal),n=e.filter(e=>!e.horizontal);for(let r of e){let e=r.horizontal?n:t;for(let t of[-1,1]){let n=null,i=t===1?r.a1:r.a0,a=Ft+r.width/2;for(let o of e){if(r.center<o.a0-a||r.center>o.a1+a)continue;let e=o.center-t*(o.width/2),s=t===1?e-i:i-e;s<-o.width||s>Ft||(!n||s<n.gap)&&(n={p:o,gap:s})}if(!n)continue;let{p:o}=n,s=r.center<o.a0+r.width||r.center>o.a1-r.width,c=o.carriagewayWidth/2,l=s?o.center+t*c:o.center-t*c+t*It,u=s?o.center+t*(o.width/2):o.center-t*(o.width/2);t===1?(r.c1=Math.max(r.c1,l),r.r1=Math.max(r.r1,u)):(r.c0=Math.min(r.c0,l),r.r0=Math.min(r.r0,u))}}}function Rt(e){let{street:t,grade:n,spec:r,horizontal:i,center:a,width:o,carriagewayWidth:s,sidewalkWidth:c}=e,l=e.c0,u=e.c1,d=(e,t)=>i?{x:e,y:a+t}:{x:a+t,y:e},f=(e,t,n,r)=>i?{x:e,y:a+n,w:t-e,h:r-n}:{x:a+n,y:e,w:r-n,h:t-e},p=s/2,m=f(l,u,-p,p),h=f(e.r0,e.r1,-o/2,o/2),g=c>0?[f(e.r0,e.r1,-p-c,-p),f(e.r0,e.r1,p,p+c)]:null,_=Math.min(1.6,s*.45),v=r.trolley?[{a:d(l,-_/2),b:d(u,-_/2)},{a:d(l,_/2),b:d(u,_/2)}]:null,y=T(w(`street-life:${t.id}`)),b=p+c,x=r.lamps?Nt(e.r0,e.r1,wt).map((e,t)=>d(e,(t%2==0?-1:1)*b*.9)):[],ee=r.trolley?Nt(e.r0,e.r1,Tt).map(e=>d(e,b*.85)):[],te=r.trees?Nt(e.r0,e.r1,Et).map((e,t)=>({...d(e+(y()-.5)*3,(t%2==0?1:-1)*b*.6),size:2+y()*.8,sprite:kt[Math.floor(y()*kt.length)]})):[],ne=[],S=u-l;if(r.trolley&&S>=40){let e=1+Math.floor(S/260);for(let t=0;t<e;t++)ne.push({kind:`trolley`,phase:y(),speed:jt*(.9+y()*.2),dir:t%2==0?1:-1,cross:0})}if(r.carts>0&&S>=24){let e=Math.min(5,Math.round(S/80*r.carts));for(let t=0;t<e;t++){let e=y()<.5?1:-1;ne.push({kind:`cart`,phase:y(),speed:At*(.8+y()*.4),dir:e,cross:e*p*.45})}}if(r.walkers&&g&&S>=Dt){let e=Math.min(8,Math.floor(S/Dt));for(let t=0;t<e;t++){let e=y()<.5?-1:1;ne.push({kind:`walker`,phase:y(),speed:Mt*(.7+y()*.6),dir:y()<.5?1:-1,cross:e*(p+c/2)})}}return{street:t,grade:n,spec:r,horizontal:i,a0:l,a1:u,length:S,center:a,width:o,carriagewayWidth:s,sidewalkWidth:c,reservation:h,carriageway:m,sidewalks:g,rails:v,gauge:_,lamps:x,poles:ee,trees:te,vehicles:ne}}var zt=new WeakMap;function Bt(e){let t=zt.get(e);if(t)return t;let n=(e.streets??[]).map(Pt);Lt(n);let r=n.map(Rt),i={streets:r,animated:r.filter(e=>e.vehicles.length>0)};return zt.set(e,i),i}function Vt(e,t){switch(e.spec.surface){case`dirt`:return t.dirtLane;case`cobble`:return t.cobble;default:return e.grade>=5?t.pavementAvenue:e.grade>=3?t.pavementStreet:t.pavementLane}}function Ht(e,t,n){let r=((n*t.speed+t.phase*e.length)%e.length%e.length+e.length)%e.length;return t.dir===1?e.a0+r:e.a1-r}function Ut(e,t,n){return e.horizontal?{x:t,y:e.center+n}:{x:e.center+n,y:t}}function Wt(e,t){let{model:n,palette:r,viewW:i,viewH:a}=t;e.fillStyle=r.ground,e.fillRect(0,0,i,a);let o=new Set;for(let e of n.districts)e.parentId&&o.add(e.parentId);Gt(e,t,o),Kt(e,t),qt(e,t,o)}function Gt(e,t,n){let{cam:r,model:i,palette:a,viewW:o,viewH:s}=t;e.fillStyle=a.districtFill;for(let t of i.districts){if(n.has(t.id)||!S(r,t.rect,o,s))continue;let{x:i,y:a,w:c,h:l}=P(r,t.rect);c<6||l<6||(e.globalAlpha=.9,F(e,i,a,c,l,6),e.fill())}e.globalAlpha=1}function Kt(e,t){let{cam:n,model:r,palette:i,viewW:a,viewH:o}=t,s=Bt(r);if(s.streets.length===0)return;let c=s.streets.filter(e=>S(n,e.reservation,a,o)),l=t=>{let r=P(n,t);e.fillRect(r.x,r.y,r.w,r.h)};if(t.tier===`city`){for(let t of c)t.street.tier>1||(e.fillStyle=Vt(t,i),l(t.carriageway));return}let u=Te(r),d=e=>e.sidewalks!==null&&e.sidewalkWidth*n.scale>=1.2;e.fillStyle=i.street.verge;for(let e of c){let t=e.street.districtId?u.get(e.street.districtId):void 0;!e.spec.verge||t===`city`||l(e.reservation)}e.fillStyle=i.sidewalk;for(let e of c)!e.sidewalks||!d(e)||(l(e.sidewalks[0]),l(e.sidewalks[1]));let f=[...c].sort((e,t)=>e.grade-t.grade||t.street.tier-e.street.tier);for(let t of f)e.fillStyle=Vt(t,i),l(t.sidewalks&&!d(t)?t.reservation:t.carriageway);e.strokeStyle=i.street.rail,e.beginPath();for(let t of c){if(!t.rails)continue;let r=t.gauge*n.scale>=2.4;e.lineWidth=r?Math.max(.7,.26*n.scale):1;let i=r?t.rails:[{a:Ut(t,t.a0,0),b:Ut(t,t.a1,0)}];for(let t of i)e.moveTo(y(n,t.a.x),b(n,t.a.y)),e.lineTo(y(n,t.b.x),b(n,t.b.y))}e.stroke()}function qt(e,t,n){let{cam:r,model:i,palette:a,tier:o,viewW:s,viewH:c}=t;for(let t of i.districts){if(!S(r,t.rect,s,c))continue;let{x:i,y:l,w:u,h:d}=P(r,t.rect);u<6||d<6||(n.has(t.id)?(e.strokeStyle=a.districtStroke,e.lineWidth=Math.max(.5,Math.min(2,3-t.depth*.4)),F(e,i,l,u,d,6),e.stroke()):(o!==`city`&&u>18&&d>18&&(e.strokeStyle=a.sidewalk,e.lineWidth=3,F(e,i+2,l+2,u-4,d-4,5),e.stroke()),e.strokeStyle=a.curb,e.lineWidth=1,F(e,i,l,u,d,6),e.stroke()))}}var Jt={info:.78,low:.86,medium:.96,high:1.08,critical:1.18};function Yt(e){let t=Math.max(0,Math.log2(Math.max(1,e)))*.52;return .82+Math.min(1.25,t)}function Xt(e){let t=e.health?.findings??0;if(e.state!==`live`||e.phantom||t<=0)return null;let n=e.health?.maxSeverity??`info`;return{findings:t,severity:n,flameCount:Math.min(3,1+Math.floor(Math.log2(t))),smokeCount:Math.min(7,3+Math.floor(Math.log2(t+1))),scale:Jt[n]+Math.min(.22,Math.log2(t)*.07),severe:n===`critical`||n===`high`}}function Zt(e){let t=null,n=-1;for(let r of e){let e=r.lines??r.height*1e3;e>n&&(t=r,n=e)}return t}function Qt(e,t,n,r,i,a,o=1,s=0){let c=n.scale*o,l=T(w(`${a}:issue-marker`)),u=10*c,d=i+.5;e.save(),e.lineJoin=`round`,e.fillStyle=t.districtLabel;for(let t=n.smokeCount-1;t>=0;t--){let t=l(),i=en(s*(16e-5+l()*55e-6)+t),a=(2.1+i*2.7+l()*.45)*c,o=(l()-.5)*4.5*c,f=Math.sin(s*.00125+t*Math.PI*2)*(1.4+i*3.2)*c,p=r+o+f,m=d-u-(3.5+i*22)*c,h=Math.sin(i*Math.PI),g=(n.severe?.38:.3)*h,_=l()*Math.PI*2;for(let t=0;t<3;t++){let n=_+t*Math.PI*2/3,r=a*(.62+l()*.15);e.globalAlpha=g*(.78+t*.08),e.beginPath(),e.arc(p+Math.cos(n)*a*.42,m+Math.sin(n)*a*.3,r,0,Math.PI*2),e.fill()}}let f=4.2*c;for(let i=0;i<n.flameCount;i++){let a=r+(i-(n.flameCount-1)/2)*f+(l()-.5)*1.3*c,o=l()*Math.PI*2,p=.008+l()*.005,m=Math.sin(s*p+o),h=Math.sin(s*p*1.9+o*.7),g=u*(.82+l()*.18+m*.1),_=(3.3+l()*1.1)*c,v=(m*.34+h*.14)*_;e.globalAlpha=n.severe?.96:.86,e.fillStyle=t.awning,$t(e,a,d,_,g,v),e.fill(),e.globalAlpha=.96,e.fillStyle=t.crane,$t(e,a,d-.25*c,_*.66,g*.72,v*.68),e.fill(),e.globalAlpha=.98,e.fillStyle=t.windowLit,$t(e,a,d-.45*c,_*.34,g*.44,v*.42),e.fill()}e.restore()}function $t(e,t,n,r,i,a){e.beginPath(),e.moveTo(t-r/2,n),e.bezierCurveTo(t-r*.62,n-i*.35,t-r*.16+a*.3,n-i*.7,t+a,n-i),e.bezierCurveTo(t+r*.15+a*.35,n-i*.62,t+r*.62,n-i*.3,t+r/2,n),e.closePath()}function en(e){return e-Math.floor(e)}function tn(e,t){if(t.tier===`city`||t.ageLens)return;let n=new Map;if(t.tier===`street`)for(let e of t.model.buildings){let t=n.get(e.blockId);t?t.push(e):n.set(e.blockId,[e])}for(let r of t.model.blocks){if(!S(t.cam,r.rect,t.viewW,t.viewH))continue;let i=Xt(r);if(!i)continue;let a=Zt(n.get(r.id)??[]),o=P(t.cam,a?.rect??r.rect);Qt(e,t.palette,i,o.x+o.w/2,o.y,r.id,Yt(t.cam.scale),t.animationTime??0)}}function nn(e,t){let{cam:n,model:r,palette:i,viewW:a,viewH:o}=t,s=r.districts.some(e=>e.displayLabel!==void 0);for(let t of r.districts){if(s&&t.displayLabel===void 0||!S(n,t.rect,a,o))continue;let{x:r,y:c,w:l,h:u}=P(n,t.rect);if(l<=60||u<=24)continue;let d=t.displayLabel??t.label;if(e.fillStyle=i.districtLabel,e.font=`${t.depth<=1?13:11}px ui-sans-serif, system-ui, sans-serif`,e.textBaseline=`top`,t.labelPlate){let r=P(n,t.labelPlate);e.fillText(d,r.x+2,r.y+1,Math.max(20,r.w))}else e.fillText(d,r+6,c+5,l-12)}if(t.tier===`street`){e.fillStyle=i.label,e.font=`11px ui-sans-serif, system-ui, sans-serif`,e.textBaseline=`bottom`;for(let t of r.blocks){if(t.state===`tombstoned`)continue;let r=t.rect.w*n.scale;if(r<44||!S(n,t.rect,a,o))continue;let{x:i,y:s}=P(n,t.rect);e.fillText(t.label,i+2,s-2,r)}}}var rn={added:`#3fb950`,modified:`#d29922`,deleted:`#f85149`,renamed:`#a371f7`},an=`#58a6ff`;function on(e,t){let{cam:n,model:r,palette:i,viewW:a,viewH:o}=t;if(!r.overlay||r.overlay.changedBlocks.length===0)return;let s=new Map(r.overlay.changedBlocks.map(e=>[e.blockId,e])),c=t.affectedIds,l=new Map(r.blocks.map(e=>[e.id,e]));if(e.fillStyle=i.ground,e.globalAlpha=.62,e.fillRect(0,0,a,o),e.globalAlpha=1,c&&c.size>0)for(let t of c){if(s.has(t))continue;let r=l.get(t);if(!r||!S(n,r.rect,a,o))continue;let i=P(n,r.rect),c=i.x,u=i.y,d=Math.max(3,i.w),f=Math.max(3,i.h),p=Math.min(3,d/6);e.fillStyle=an,e.globalAlpha=.18,F(e,c,u,d,f,p),e.fill(),e.globalAlpha=.7,e.strokeStyle=an,e.lineWidth=1,F(e,c,u,d,f,p),e.stroke(),e.globalAlpha=1}for(let t of r.blocks){let r=s.get(t.id);if(!r||!S(n,t.rect,a,o))continue;let i=rn[r.change]??`#888888`,c=P(n,t.rect),l=c.x,u=c.y,d=Math.max(3,c.w),f=Math.max(3,c.h),p=Math.min(3,d/6);e.fillStyle=i,e.globalAlpha=t.phantom?.45:.85,F(e,l,u,d,f,p),e.fill(),e.globalAlpha=1,e.save(),e.shadowColor=i,e.shadowBlur=8,e.strokeStyle=i,e.lineWidth=2,t.phantom&&e.setLineDash([4,3]),F(e,l-1,u-1,d+2,f+2,p+1),e.stroke(),e.restore()}}var sn=[1,1.15,1.35,1.6],cn=.5,ln=6e3,un=80,dn=(e,t,n)=>e<t?t:e>n?n:e,fn=(e,t)=>`${Math.round(e*10)/10},${Math.round(t*10)/10}`,pn=e=>({x:e.x+e.w/2,y:e.y+e.h/2}),mn=e=>sn[e]??1,hn=(e,t)=>e.axis===`h`?{x:t,y:e.line}:{x:e.line,y:t},gn=20;function _n(e){let t=e.streets;if(!t||t.length===0||t.length>ln)return null;let n=[];for(let e of t){let{x:t,y:r,w:i,h:a}=e.rect;i>=a?n.push({axis:`h`,line:r+a/2,min:t,max:t+i,tier:e.tier}):n.push({axis:`v`,line:t+i/2,min:r,max:r+a,tier:e.tier})}let r=n.map(e=>new Set([e.min,e.max])),i=[],a=[];n.forEach((e,t)=>(e.axis===`h`?i:a).push(t));for(let e of i){let t=n[e];for(let i of a){let a=n[i];a.line>=t.min-cn&&a.line<=t.max+cn&&t.line>=a.min-cn&&t.line<=a.max+cn&&(r[e].add(dn(a.line,t.min,t.max)),r[i].add(dn(t.line,a.min,a.max)))}}let o=[],s=(e,t)=>{let s=n[e],c=hn(s,t),l=s.axis===`h`?a:i,u=null;for(let e of l){let r=n[e],i=s.axis===`h`?c.y:c.x;if(i<r.min-cn||i>r.max+cn)continue;let a=Math.abs(r.line-t);a<=cn||a>gn||(!u||a<u.w)&&(u={proj:s.axis===`h`?{x:r.line,y:c.y}:{x:c.x,y:r.line},w:a,ti:e})}if(u){let e=n[u.ti],t=e.axis===`h`?u.proj.x:u.proj.y;r[u.ti].add(dn(t,e.min,e.max)),o.push({a:c,b:u.proj,w:u.w*mn(Math.max(s.tier,e.tier))})}};n.forEach((e,t)=>{e.max-e.min<.1||(s(t,e.min),s(t,e.max))});let c=new Map,l=new Map,u=[],d=(e,t,n)=>{(c.get(e)??c.set(e,[]).get(e)).push({to:t,w:n}),(c.get(t)??c.set(t,[]).get(t)).push({to:e,w:n})};n.forEach((e,t)=>{let n=[...r[t]].sort((e,t)=>e-t);if(e.max-e.min<.1){u.push({seg:e,pts:n});return}for(let t of n){let n=hn(e,t);l.set(fn(n.x,n.y),n)}let i=mn(e.tier);for(let t=0;t<n.length-1;t++){let r=hn(e,n[t]),a=hn(e,n[t+1]),o=(n[t+1]-n[t])*i;o>0&&d(fn(r.x,r.y),fn(a.x,a.y),o)}u.push({seg:e,pts:n})});for(let e of o)d(fn(e.a.x,e.a.y),fn(e.b.x,e.b.y),e.w);return{adj:c,coord:l,segs:u}}function vn(e,t){let n=null,r=1/0;return e.segs.forEach((e,i)=>{let a=e.seg;if(a.max-a.min<.1)return;let o=dn(a.axis===`h`?t.x:t.y,a.min,a.max),s=a.axis===`h`?{x:o,y:a.line}:{x:a.line,y:o},c=Math.hypot(t.x-s.x,t.y-s.y);c<r&&(r=c,n={segIndex:i,seg:a,along:o,point:s})}),n}function yn(e,t){let{seg:n,pts:r}=e,i=mn(n.tier),a=0;for(;a<r.length-2&&r[a+1]<t;)a++;let o=r[a],s=r[a+1]??o,c=e=>n.axis===`h`?fn(e,n.line):fn(n.line,e),l=[{key:c(o),w:Math.abs(t-o)*i}];return s!==o&&l.push({key:c(s),w:Math.abs(s-t)*i}),l}var bn=class{a=[];get size(){return this.a.length}push(e,t){let n=this.a;n.push([e,t]);let r=n.length-1;for(;r>0;){let e=r-1>>1;if(n[e][0]<=n[r][0])break;[n[e],n[r]]=[n[r],n[e]],r=e}}pop(){let e=this.a,t=e[0],n=e.pop();if(e.length>0){e[0]=n;let t=0;for(;;){let n=2*t+1,r=n+1,i=t;if(n<e.length&&e[n][0]<e[i][0]&&(i=n),r<e.length&&e[r][0]<e[i][0]&&(i=r),i===t)break;[e[i],e[t]]=[e[t],e[i]],t=i}}return t}};function xn(e,t,n){let r=new Map([[t,0]]),i=new Map,a=new Set,o=new bn;for(o.push(0,t);o.size>0;){let[t,s]=o.pop();if(!a.has(s)){if(a.add(s),s===n)break;for(let{to:n,w:a}of e(s)){let e=t+a;e<(r.get(n)??1/0)&&(r.set(n,e),i.set(n,s),o.push(e,n))}}}if(!r.has(n))return null;let s=[],c=n;for(;c!==void 0&&(s.push(c),c!==t);)c=i.get(c);return s[s.length-1]===t?s.reverse():null}function Sn(e,t){return{x:dn(t.x,e.x,e.x+e.w),y:dn(t.y,e.y,e.y+e.h)}}function Cn(e){if(e.length<=2)return e;let t=[e[0]];for(let n=1;n<e.length-1;n++){let r=t[t.length-1],i=e[n],a=e[n+1];!(Math.abs(r.x-i.x)<.1&&Math.abs(i.x-a.x)<.1||Math.abs(r.y-i.y)<.1&&Math.abs(i.y-a.y)<.1)&&(Math.abs(r.x-i.x)>.1||Math.abs(r.y-i.y)>.1)&&t.push(i)}return t.push(e[e.length-1]),t}function wn(e,t,n){let r=vn(e,pn(t)),i=vn(e,pn(n));if(!r||!i)return null;let a=new Map,o=(e,t)=>{(a.get(e)??a.set(e,[]).get(e)).push(t)};for(let t of yn(e.segs[r.segIndex],r.along))o(`\0A`,{to:t.key,w:t.w});for(let t of yn(e.segs[i.segIndex],i.along))o(t.key,{to:`\0B`,w:t.w});r.segIndex===i.segIndex&&o(`\0A`,{to:`\0B`,w:Math.abs(r.along-i.along)*mn(r.seg.tier)});let s=xn(t=>[...e.adj.get(t)??[],...a.get(t)??[]],`\0A`,`\0B`);if(!s)return null;let c=s.map(t=>t===`\0A`?r.point:t===`\0B`?i.point:e.coord.get(t)),l=Sn(t,c[0]),u=Sn(n,c[c.length-1]);return Cn([l,...c,u])}function Tn(e,t){let n=pn(e),r=pn(t);return Math.abs(r.x-n.x)>=Math.abs(r.y-n.y)?[{x:r.x>n.x?e.x+e.w:e.x,y:n.y},{x:r.x,y:n.y},{x:r.x,y:r.y>n.y?t.y:t.y+t.h}]:[{x:n.x,y:r.y>n.y?e.y+e.h:e.y},{x:n.x,y:r.y},{x:r.x>n.x?t.x:t.x+t.w,y:r.y}]}var En=new WeakMap,Dn=new WeakMap;function On(e){if(En.has(e))return En.get(e)??null;let t=_n(e);return En.set(e,t),t}function kn(e,t,n){let r=On(e);if(!r)return null;let i=Dn.get(e);if(i||(i=new Map,Dn.set(e,i)),i.has(t))return i.get(t)??null;let a=[],o=0;for(let i of e.roads){if(i.a!==t&&i.b!==t)continue;let e=n.get(i.a),s=n.get(i.b);if(!e||!s)continue;let c=null;o<un&&(c=wn(r,e,s),o++),c||=Tn(e,s),a.push({points:c,bidirectional:i.bidirectional,affinity:i.affinity})}return i.set(t,a),a}function An(e,t){let n=e.x+e.w/2,r=e.y+e.h/2,i=t.x+t.w/2,a=t.y+t.h/2,o=i-n,s=a-r;if(Math.abs(o)<1||Math.abs(s)<1)return[{x:n,y:r},{x:i,y:a}];if(Math.abs(o)>Math.abs(s)){let n=o>0?e.x+e.w:e.x,a=s>0?t.y:t.y+t.h;return[{x:n,y:r},{x:i,y:r},{x:i,y:a}]}let c=s>0?e.y+e.h:e.y,l=o>0?t.x:t.x+t.w;return[{x:n,y:c},{x:n,y:a},{x:l,y:a}]}function jn(e,t,n){let{cam:r,model:i,palette:a,tier:o,viewW:s,viewH:c}=t;if(o===`city`||i.roads.length===0||n===`selected`&&!t.selectedId)return;let l=new Map;for(let e of i.blocks)l.set(e.id,e.rect);if(n===`selected`&&t.selectedId){let n=kn(i,t.selectedId,l);if(n){Mn(e,t,n);return}}let u=Math.max(2,Math.min(8,4*r.scale));for(let o of i.roads){if(n===`selected`&&o.a!==t.selectedId&&o.b!==t.selectedId)continue;let i=l.get(o.a),d=l.get(o.b);if(!i||!d)continue;let f=An(i,d).map(e=>({x:y(r,e.x),y:b(r,e.y)})),p=1/0,m=1/0,h=-1/0,g=-1/0;for(let e of f)e.x<p&&(p=e.x),e.y<m&&(m=e.y),e.x>h&&(h=e.x),e.y>g&&(g=e.y);h<0||g<0||p>s||m>c||(n===`selected`?(e.strokeStyle=a.selected,e.globalAlpha=.9,e.lineWidth=2):(e.strokeStyle=o.bidirectional?a.roadMutual:a.road,e.globalAlpha=.25+.2*Math.min(1,o.affinity),e.lineWidth=o.bidirectional?1.5:1),e.beginPath(),e.moveTo(f[0].x,f[0].y),f.length===2?e.lineTo(f[1].x,f[1].y):(e.arcTo(f[1].x,f[1].y,f[2].x,f[2].y,u),e.lineTo(f[2].x,f[2].y)),e.stroke())}e.globalAlpha=1}function Mn(e,t,n){let{cam:r,palette:i,viewW:a,viewH:o}=t,s=Math.max(2,Math.min(6,3*r.scale));e.strokeStyle=i.selected,e.globalAlpha=.9,e.lineJoin=`round`;for(let t of n){if(t.points.length<2)continue;let n=t.points.map(e=>({x:y(r,e.x),y:b(r,e.y)})),i=1/0,c=1/0,l=-1/0,u=-1/0;for(let e of n)e.x<i&&(i=e.x),e.y<c&&(c=e.y),e.x>l&&(l=e.x),e.y>u&&(u=e.y);if(!(l<0||u<0||i>a||c>o)){e.lineWidth=t.bidirectional?2.4:2,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length-1;t++)e.arcTo(n[t].x,n[t].y,n[t+1].x,n[t+1].y,s);e.lineTo(n[n.length-1].x,n[n.length-1].y),e.stroke()}}e.globalAlpha=1}function Nn(e,t){e.save(),Wt(e,t),jn(e,t,`under`),tt(e,t),ft(e,t),bt(e,t,t.atlas),tn(e,t),dt(e,t),jn(e,t,`selected`),nn(e,t),on(e,t),e.restore()}var Pn=.01;function Fn(e,t){return e.x+e.w<=t.x+Pn||e.y+e.h<=t.y+Pn}function In(e){let t=e.length;if(t<=1)return e.map((e,t)=>t);let n=t=>{let n=e[t].rect;return n.x+n.w+n.y+n.h},r=(t,r)=>{let i=e[t].rect,a=e[r].rect;return(n(t)-n(r)||i.x-a.x||i.y-a.y||i.w-a.w||i.h-a.h||t-r)<0},i=e.map((e,t)=>t).sort((t,n)=>e[t].u0-e[n].u0),a=Array.from({length:t},()=>[]),o=Array(t).fill(0),s=[];for(let t of i){let n=e[t];for(let i=s.length-1;i>=0;i--){let c=s[i];if(e[c].u1<n.u0){s.splice(i,1);continue}let l=e[t].rect,u=e[c].rect,d=Fn(l,u),f=Fn(u,l);d&&!f?(a[t].push(c),o[c]+=1):f&&!d?(a[c].push(t),o[t]+=1):d&&f&&(r(t,c)?(a[t].push(c),o[c]+=1):(a[c].push(t),o[t]+=1))}s.push(t)}let c=e=>{let t=0;for(let n=1;n<e.length;n++)r(e[n],e[t])&&(t=n);return t},l=[],u=[],d=o.slice();for(let e=0;e<t;e++)d[e]===0&&u.push(e);let f=Array(t).fill(!1);for(;l.length<t;){if(u.length===0){let e=-1;for(let r=0;r<t;r++)f[r]||(e<0||n(r)<n(e))&&(e=r);u.push(e),d[e]=0}let e=c(u),r=u.splice(e,1)[0];if(!f[r]){f[r]=!0,l.push(r);for(let e of a[r])--d[e],d[e]===0&&!f[e]&&u.push(e)}}return l}var Ln=.6;function I(e,t){return{u:e-t,v:(e+t)/2}}function Rn(e){return e*3}var zn=3*Ln*.6;function Bn(e){return(.5+e*4.5)*3*Ln*.4}function Vn(e,t,n=!1){let r=Math.max(.001,t),i=(e.w+e.h)*r;return Math.max(n?2:3,Math.min(n?16:20,i*.17))/r}function Hn(e){return{n:I(e.x,e.y),e:I(e.x+e.w,e.y),s:I(e.x+e.w,e.y+e.h),w:I(e.x,e.y+e.h)}}function Un(e,t,n,r){let i=(t.x-(t.y+t.h)-e.offsetX)*e.scale,a=(t.x+t.w-t.y-e.offsetX)*e.scale,o=((t.x+t.y)/2-e.offsetY)*e.scale,s=((t.x+t.w+t.y+t.h)/2-e.offsetY)*e.scale;return a>=0&&s>=0&&i<=n&&o<=r}function Wn(e,t){return{u0:e.x-(e.y+e.h),u1:e.x+e.w-e.y,v0:(e.x+e.y)/2-t,v1:(e.x+e.w+e.y+e.h)/2}}function Gn(e,t,n,r){return Math.max(0,n.x-e/2-t,n.y+e/2-t)<=Math.min(r,n.x+n.w-e/2-t,n.y+n.h+e/2-t)}function Kn(e,t,n,r,i=32){if(e.w<=0||e.h<=0||n<=0||r<=0)return{scale:1,offsetX:0,offsetY:0};let a=Wn(e,t),o=a.u1-a.u0,s=a.v1-a.v0,c=_(Math.min((n-i*2)/o,(r-i*2)/s)),l=a.u0+o/2,u=a.v0+s/2;return{scale:c,offsetX:l-n/2/c,offsetY:u-r/2/c}}function qn(e){return e.levels===void 0?Math.max(1,Math.min(5,1+Math.round(Math.sqrt(Math.max(1,e.weight))/15))):e.levels}function Jn(e){let t=qe(e),n=e.blocks.map(e=>{let n=t.get(e.id),r=e.state===`tombstoned`||n?.archetype===`field`||n?.archetype===`park`?0:Rn(qn(e)),i=r*Ln;return{block:e,hWorld:r,hIso:i,aabb:Wn(e.rect,i),...n?{style:n}:{},roofFactor:n?.roofFactor??1}}),r=In(n.map(e=>({rect:e.block.rect,u0:e.aabb.u0,u1:e.aabb.u1}))),i=0;for(let e of n)e.hIso>i&&(i=e.hIso);return{geoms:n,order:r,maxHIso:i}}var Yn=new WeakMap;function Xn(e){let t=Yn.get(e);if(t)return t;let n=Jn(e);return Yn.set(e,n),n}function Zn(e,t){return e.block.state!==`live`||e.block.phantom?0:Vn(e.block.rect,t)*e.roofFactor}function Qn(e,t,n,r){let i=Zn(t,e.scale),a=(t.aabb.u0-e.offsetX)*e.scale,o=(t.aabb.u1-e.offsetX)*e.scale,s=(t.aabb.v0-i-e.offsetY)*e.scale,c=(t.aabb.v1-e.offsetY)*e.scale;return o>=0&&c>=0&&a<=n&&s<=r}function $n(e,t){let n=t.rect.x+t.rect.w/2,r=t.rect.y+t.rect.h/2,i=n-r,a=(n+r)/2-zn-Bn(t.height)-Vn(t.rect,e.scale,!0);return{x:(i-e.offsetX)*e.scale,y:(a-e.offsetY)*e.scale}}var er=new WeakMap;function tr(e,t){let n=er.get(e);if(!n){n=new Map;for(let t of e.buildings){let e=n.get(t.blockId);e?e.push(t):n.set(t.blockId,[t])}er.set(e,n)}return n.get(t)??nr}var nr=[];function rr(e,t,n,r,i){let a=r/n.scale+n.offsetX,o=i/n.scale+n.offsetY+zn,s=tr(e,t);for(let e=s.length-1;e>=0;e--){let t=s[e];if(Gn(a,o,t.rect,Bn(t.height)+Vn(t.rect,n.scale,!0)))return t}return null}function ir(e,t,n,r){let i=n/t.scale+t.offsetX,a=r/t.scale+t.offsetY;for(let n=e.order.length-1;n>=0;n--){let r=e.geoms[e.order[n]];if(Gn(i,a,r.block.rect,r.hIso+Zn(r,t.scale)))return r.block}return null}function L(e,t,n){return{x:(t-e.offsetX)*e.scale,y:(n-e.offsetY)*e.scale}}function R(e,t,n){let r=Hn(t),i=L(e,r.n.u,r.n.v),a=L(e,r.e.u,r.e.v),o=L(e,r.s.u,r.s.v),s=L(e,r.w.u,r.w.v),c=n*e.scale;return{gn:i,ge:a,gs:o,gw:s,tn:{x:i.x,y:i.y-c},te:{x:a.x,y:a.y-c},ts:{x:o.x,y:o.y-c},tw:{x:s.x,y:s.y-c},liftPx:c}}function z(e,t,n){let r=Hn(n),i=L(t,r.n.u,r.n.v),a=L(t,r.e.u,r.e.v),o=L(t,r.s.u,r.s.v),s=L(t,r.w.u,r.w.v);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(a.x,a.y),e.lineTo(o.x,o.y),e.lineTo(s.x,s.y),e.closePath()}function B(e,t,n,r,i){e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.lineTo(r.x,r.y),e.lineTo(i.x,i.y),e.closePath()}function V(e,t,n,r,i,a){e.fillStyle=t,B(e,n,r,i,a),e.fill()}function ar(e,t){e.beginPath(),e.moveTo(t.tn.x,t.tn.y),e.lineTo(t.te.x,t.te.y),e.lineTo(t.ge.x,t.ge.y),e.lineTo(t.gs.x,t.gs.y),e.lineTo(t.gw.x,t.gw.y),e.lineTo(t.tw.x,t.tw.y),e.closePath()}function or(e,t,n){t.liftPx>=.5&&(V(e,n.wallL,t.tw,t.ts,t.gs,t.gw),V(e,n.wallR,t.ts,t.te,t.ge,t.gs)),V(e,n.top,t.tn,t.te,t.ts,t.tw)}var sr=class{buckets=new Map;add(e,t,n,r,i){let a=this.buckets.get(e);a||(a=[],this.buckets.set(e,a)),a.push(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)}flush(e){for(let[t,n]of this.buckets){e.fillStyle=t,e.beginPath();for(let t=0;t<n.length;t+=8)e.moveTo(n[t],n[t+1]),e.lineTo(n[t+2],n[t+3]),e.lineTo(n[t+4],n[t+5]),e.lineTo(n[t+6],n[t+7]),e.closePath();e.fill()}this.buckets.clear()}},cr=2/Math.sqrt(5),lr=Math.sqrt(5)/2,ur=1.2,dr=4,fr=2.4,pr=2.6,mr=4,hr=400,gr={length:5.5,width:1.9,height:2.4},_r={length:2.4,width:1.2,height:1.1},vr={length:1.4,width:.6,height:1.2,lead:2.1},yr=1.3,br=2.2;function xr(e,t){let{cam:n,model:r,palette:i,viewW:a,viewH:o}=t,s=Bt(r);if(s.streets.length===0)return;let c=s.streets.filter(e=>Un(n,e.reservation,a,o));if(c.length===0)return;let l=n.scale;if(t.tier===`city`){let t=new Map;for(let e of c){if(e.street.tier>1)continue;let n=Vt(e,i),r=t.get(n);r?r.push(e):t.set(n,[e])}for(let[r,i]of t){e.fillStyle=r;for(let t of i)z(e,n,t.carriageway),e.fill()}return}let u=Te(r),d=e=>e.street.districtId?u.get(e.street.districtId):void 0,f=e=>e.sidewalks!==null&&e.sidewalkWidth*cr*l>=ur;e.fillStyle=i.street.verge;for(let t of c)!t.spec.verge||d(t)===`city`||(z(e,n,t.reservation),e.fill());e.fillStyle=i.sidewalk;for(let t of c)if(!(!t.sidewalks||!f(t)))for(let r of t.sidewalks)z(e,n,r),e.fill();let p=t.tier===`street`&&!t.ageLens,m=[...c].sort((e,t)=>e.grade-t.grade||t.street.tier-e.street.tier);for(let r of m){let a=r.sidewalks&&!f(r)?r.reservation:r.carriageway;e.fillStyle=Vt(r,i),z(e,n,a),e.fill(),p&&r.carriagewayWidth*cr*l>=dr&&Cr(e,t,r,f(r))}for(let n of c)n.rails&&wr(e,t,n);if(p){for(let n of c)Tr(e,t,n);for(let n of c)Dr(e,t,n)}}function H(e,t,n){let r=I(t,n);return L(e.cam,r.u,r.v)}function Sr(e,t,n=40){return t.x>=-n&&t.x<=e.viewW+n&&t.y>=-n&&t.y<=e.viewH+n}function U(e,t,n,r){e.moveTo(n.x,n.y),e.lineTo(r.x,r.y)}function Cr(e,t,n,r){let i=t.cam.scale,a=n.carriagewayWidth/2,o=(e,r)=>{let i=Ut(n,e,r);return H(t,i.x,i.y)};switch(n.spec.surface){case`dirt`:e.strokeStyle=`rgba(0, 0, 0, 0.24)`,e.lineWidth=Math.max(.6,.32*i),e.setLineDash([3.2*lr*i,2.4*lr*i]),e.beginPath();for(let r of[-a*.42,a*.42])U(e,t,o(n.a0+1,r),o(n.a1-1,r));e.stroke(),e.setLineDash([]);break;case`cobble`:{e.strokeStyle=t.palette.curb,e.globalAlpha=.3,e.lineWidth=Math.max(.5,.2*i),e.beginPath(),U(e,t,o(n.a0+.5,0),o(n.a1-.5,0));let r=Math.min(hr,Math.floor(n.length/pr));for(let i=0;i<r;i++){let r=n.a0+pr*(i+.5);i%2==0?U(e,t,o(r,-a*.85),o(r,0)):U(e,t,o(r,0),o(r,a*.85))}e.stroke(),e.globalAlpha=1;break}case`paved`:if(n.grade<4)break;e.strokeStyle=t.palette.curb,e.globalAlpha=r?.85:.55,e.lineWidth=Math.max(.6,.26*i),e.beginPath(),U(e,t,o(n.a0,-a),o(n.a1,-a)),U(e,t,o(n.a0,a),o(n.a1,a)),e.stroke(),e.globalAlpha=1;break}if(r&&n.sidewalkWidth*cr*i>=3){e.strokeStyle=`rgba(0, 0, 0, 0.12)`,e.lineWidth=Math.max(.5,.18*i),e.beginPath();let r=Math.min(hr,Math.floor(n.length/mr)),s=a+n.sidewalkWidth;for(let i=0;i<r;i++){let r=n.a0+mr*(i+.5);U(e,t,o(r,-s),o(r,-a)),U(e,t,o(r,a),o(r,s))}e.stroke()}}function wr(e,t,n){if(!n.rails)return;let r=t.cam.scale;if(e.strokeStyle=t.palette.street.rail,e.beginPath(),n.gauge*cr*r>=fr){e.lineWidth=Math.max(.7,.26*r);for(let r of n.rails)U(e,t,H(t,r.a.x,r.a.y),H(t,r.b.x,r.b.y))}else{e.lineWidth=1;let r=Ut(n,n.a0,0),i=Ut(n,n.a1,0);U(e,t,H(t,r.x,r.y),H(t,i.x,i.y))}e.stroke()}function Tr(e,t,n){let r=t.cam.scale,i=t.palette;if(n.lamps.length>0){let a=yr*r,o=Math.max(.8,.3*r),s=[];for(let e of n.lamps){let n=H(t,e.x,e.y);Sr(t,n)&&s.push(n)}if(s.length>0){if(i.dark){e.fillStyle=i.street.lampGlow,e.globalAlpha=.1;for(let t of s)e.beginPath(),e.arc(t.x,t.y-a,1.3*r,0,Math.PI*2),e.fill();e.globalAlpha=1}e.strokeStyle=i.street.lampPost,e.lineWidth=Math.max(.6,.22*r),e.beginPath();for(let t of s)e.moveTo(t.x,t.y),e.lineTo(t.x,t.y-a);e.stroke(),e.fillStyle=i.street.lampGlow;for(let t of s)e.beginPath(),e.arc(t.x,t.y-a,o,0,Math.PI*2),e.fill()}}if(n.poles.length>0){let a=br*r,o=.7*r*(n.horizontal?-1:1),s=[];e.strokeStyle=i.street.pole,e.lineWidth=Math.max(.7,.24*r),e.beginPath();for(let i of n.poles){let n=H(t,i.x,i.y),c={x:n.x,y:n.y-a};s.push(c),Sr(t,n)&&(e.moveTo(n.x,n.y),e.lineTo(c.x,c.y),e.moveTo(c.x,c.y+.3*r),e.lineTo(c.x+o,c.y+.3*r))}e.stroke(),e.strokeStyle=i.street.wire,e.globalAlpha=.55,e.lineWidth=Math.max(.5,.14*r),e.beginPath();for(let n=1;n<s.length;n++){let i=s[n-1],a=s[n];!Sr(t,i,200)&&!Sr(t,a,200)||(e.moveTo(i.x+o,i.y+.3*r),e.quadraticCurveTo((i.x+a.x)/2+o,(i.y+a.y)/2+.3*r+.35*r,a.x+o,a.y+.3*r))}e.stroke(),e.globalAlpha=1}if(n.trees.length>0&&t.atlas)for(let i of n.trees){let n=H(t,i.x,i.y);if(!Sr(t,n))continue;let a=i.size*r*2,o=t.atlas.index[i.sprite]*t.atlas.cell;e.drawImage(t.atlas.canvas,o,0,t.atlas.cell,t.atlas.cell,n.x-a/2,n.y-a,a,a)}}function Er(e,t,n,r,i){let a=Ut(e,t,n);return e.horizontal?{x:a.x-r/2,y:a.y-i/2,w:r,h:i}:{x:a.x-i/2,y:a.y-r/2,w:i,h:r}}function Dr(e,t,n){if(n.vehicles.length===0)return;let r=t.animationTime??0,i=t.palette;for(let a of n.vehicles){let o=Ht(n,a,r);switch(a.kind){case`trolley`:Or(e,t,n,o);break;case`cart`:{let r=Er(n,o,a.cross,_r.length,_r.width);if(!Sr(t,H(t,r.x+r.w/2,r.y+r.h/2)))break;let s=Er(n,o+a.dir*vr.lead,a.cross,vr.length,vr.width),c=a.dir===-1;c&&or(e,R(t.cam,s,vr.height*Ln),i.street.horse),or(e,R(t.cam,r,_r.height*Ln),i.street.cart),c||or(e,R(t.cam,s,vr.height*Ln),i.street.horse);break}case`walker`:{let r=Ut(n,o,a.cross),s=H(t,r.x,r.y);if(!Sr(t,s))break;let c=Math.max(1,.32*t.cam.scale),l=Math.max(2,.95*t.cam.scale);e.fillStyle=i.street.walker,e.fillRect(s.x-c/2,s.y-l,c,l);break}}}}function Or(e,t,n,r){let i=t.palette,a=Er(n,r,0,gr.length,gr.width),o=H(t,a.x+a.w/2,a.y+a.h/2);if(!Sr(t,o,60))return;let s=R(t.cam,a,gr.height*Ln);if(or(e,s,i.street.trolley),s.liftPx>=5){let[r,a,c,l]=n.horizontal?[s.tw,s.ts,s.gs,s.gw]:[s.ts,s.te,s.ge,s.gs];e.fillStyle=i.dark?i.windowLit:i.window;for(let t=0;t<4;t++){let n=(t+.2)/4,i=(t+.8)/4,o=W(r,a,n),s=W(r,a,i),u=W(l,c,n),d=W(l,c,i);e.beginPath(),e.moveTo(W(o,u,.2).x,W(o,u,.2).y),e.lineTo(W(s,d,.2).x,W(s,d,.2).y),e.lineTo(W(s,d,.6).x,W(s,d,.6).y),e.lineTo(W(o,u,.6).x,W(o,u,.6).y),e.closePath(),e.fill()}let u={x:o.x,y:o.y-s.liftPx};e.strokeStyle=i.street.pole,e.lineWidth=Math.max(.6,.18*t.cam.scale),e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(u.x+(n.horizontal?-.7:.7)*t.cam.scale,o.y-br*t.cam.scale),e.stroke()}}function W(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}var kr=14,Ar=6;function jr(e,t){let{cam:n,model:r,palette:i,viewW:a,viewH:o}=t;e.fillStyle=i.ground,e.fillRect(0,0,a,o);let s=new Set;for(let e of r.districts)e.parentId&&s.add(e.parentId);let c=t.tier===`city`?null:Te(r);for(let l of r.districts){if(!Un(n,l.rect,a,o))continue;if(s.has(l.id)){e.strokeStyle=i.districtStroke,e.lineWidth=Math.max(.5,Math.min(2,3-l.depth*.4)),z(e,n,l.rect),e.stroke();continue}let r=c?.get(l.id);e.globalAlpha=.9,e.fillStyle=r===`village`?i.districtFillVillage:r===`city`?i.districtFillCity:i.districtFill,z(e,n,l.rect),e.fill(),e.globalAlpha=1,t.tier!==`city`&&(e.strokeStyle=i.curb,e.lineWidth=1,z(e,n,l.rect),e.stroke())}for(let s of r.plazas??[])Un(n,s.rect,a,o)&&(s.kind===`plaza`?(e.fillStyle=i.sidewalk,z(e,n,s.rect),e.fill(),t.tier===`street`&&!t.ageLens&&(e.strokeStyle=i.domeAccent,e.globalAlpha=.55,e.lineWidth=1,z(e,n,s.rect),e.stroke(),e.globalAlpha=1,Mr(e,t,s))):(e.fillStyle=i.dark?`hsl(130 12% 15%)`:`hsl(90 26% 80%)`,z(e,n,s.rect),e.fill(),t.tier===`street`&&!t.ageLens&&Pr(e,t,s)));xr(e,t)}function Mr(e,t,n){let{cam:r}=t,i=Math.min(n.rect.w,n.rect.h)*.22*Math.SQRT2*r.scale;if(i<kr/2)return;let a=I(n.rect.x+n.rect.w/2,n.rect.y+n.rect.h/2);Nr(e,t,L(r,a.u,a.v),i)}function Nr(e,t,n,r){let{cam:i,palette:a}=t,o=r/2,s=Math.max(1,.28*i.scale);e.fillStyle=a.street.basin,e.beginPath(),e.ellipse(n.x,n.y,r,o,0,0,Math.PI*2),e.fill(),e.fillStyle=a.street.water,e.beginPath(),e.ellipse(n.x,n.y,r-s,o-s/2,0,0,Math.PI*2),e.fill(),e.strokeStyle=a.street.water,e.globalAlpha=.7,e.lineWidth=Math.max(.6,.2*i.scale),e.beginPath(),e.ellipse(n.x,n.y,r*.45,o*.45,0,0,Math.PI*2),e.stroke(),e.globalAlpha=1;let c=Math.max(2,1.1*i.scale);e.strokeStyle=a.sidewalk,e.lineWidth=Math.max(.8,.3*i.scale),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x,n.y-c),e.stroke(),e.fillStyle=a.sidewalk,e.beginPath(),e.arc(n.x,n.y-c,Math.max(.8,.28*i.scale),0,Math.PI*2),e.fill()}function Pr(e,t,n){let r=t.atlas;if(!r)return;let{cam:i}=t,a=n.rect.w*n.rect.h,o=Math.max(1,Math.min(Ar,Math.floor(a/500))),s=T(w(`green:${n.id}`));for(let t=0;t<o;t++){let t=n.rect.x+2+s()*Math.max(.5,n.rect.w-4),a=n.rect.y+2+s()*Math.max(.5,n.rect.h-4),o=(2+s()*1.2)*i.scale*2,c=s()<.7?`tree1`:`tree3`,l=I(t,a),u=L(i,l.u,l.v),d=r.index[c]*r.cell;e.drawImage(r.canvas,d,0,r.cell,r.cell,u.x-o/2,u.y-o,o,o)}}var Fr=12,Ir=5,Lr=.78;function Rr(e,t,n){if(t.tier===`city`||t.ageLens)return;let r=n.lot;if(!r||n.state===`tombstoned`||n.phantom||(r.w+r.h)*t.cam.scale<Fr)return;let i=Hn(r),a=[L(t.cam,i.n.u,i.n.v),L(t.cam,i.e.u,i.e.v),L(t.cam,i.s.u,i.s.v),L(t.cam,i.w.u,i.w.v)],o=M(n),s=t.palette;e.globalAlpha=.55,e.fillStyle=o<.25?s.orchard:o<.5?s.ground:s.sidewalk,Br(e,a),e.fill(),e.globalAlpha=1;let c=N(n);if(!(c===`city`&&o>Lr)){if(c===`village`){zr(e,t,a);return}e.strokeStyle=c===`town`?s.fence:s.curb,e.lineWidth=1,c===`town`&&e.setLineDash([2,2]),Br(e,a),e.stroke(),e.setLineDash([])}}function zr(e,t,n){e.strokeStyle=t.palette.hedge,e.lineWidth=1.6,e.lineCap=`round`,e.beginPath();for(let t=0;t<4;t++){let r=n[t],i=n[(t+1)%4],a=Math.max(1,Math.floor(Math.hypot(i.x-r.x,i.y-r.y)/Ir));for(let t=0;t<a;t++){let n=(t+.15)/a,o=(t+.85)/a;e.moveTo(r.x+(i.x-r.x)*n,r.y+(i.y-r.y)*n-1),e.lineTo(r.x+(i.x-r.x)*o,r.y+(i.y-r.y)*o-1)}}e.stroke(),e.lineCap=`butt`}function Br(e,[t,n,r,i]){e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.lineTo(r.x,r.y),e.lineTo(i.x,i.y),e.closePath()}var Vr=3,Hr=2;function Ur(e,t,n,r,i,a){if(n.length===0)return;let o=T(w(`${r}:chimney-smoke`)),s=Math.max(.6,.34*i);e.save(),e.fillStyle=t.street.smoke;for(let t of n.slice(0,Hr))for(let n=0;n<Vr;n++){let n=o(),r=Wr(a*(11e-5+o()*5e-5)+n),i=(1.1+r*2.8+o()*.4)*s,c=Math.sin(a*9e-4+n*Math.PI*2)*.8*s,l=t.x+r*10*s+c,u=t.y-.5*s-r*15*s;e.globalAlpha=.24*Math.sin(r*Math.PI),e.beginPath(),e.arc(l,u,i,0,Math.PI*2),e.fill()}e.restore()}function Wr(e){return e-Math.floor(e)}var Gr=20,Kr={"clock-tower":2.4,cupola:1.85,lantern:1.35,bellcote:1.5,finial:1.05};function qr(e,t,n,r,i,a={}){let o={stacks:[]};or(e,n,i);let s=a.compact===!0,c=Vn({x:0,y:0,w:Math.max(0,(n.te.x-n.tn.x)/t.cam.scale),h:Math.max(0,(n.tn.x-n.tw.x)/t.cam.scale)},t.cam.scale,s)*t.cam.scale;!a.suppressDetails&&t.tier===`street`&&n.liftPx>=5&&mi(e,t,n,r,s),!a.suppressDetails&&n.te.x-n.tw.x>=Gr&&gi(e,t,n,r,i);let l=Jr(e,t,n,r,c,i);if(!a.suppressDetails&&t.tier===`street`){Xr(e,n,r,l,i,s),Zr(e,n,r,l,i,s);let a=c*(r.roofFactor??1),u=Math.min(l.a.y,l.b.y,l.apex.y);xi(e,t,n,r,l,c,Math.max(0,a-(n.tn.y-u)),s,o.stacks)}return o}function Jr(e,t,n,r,i,a){let o=r.ridge;switch(r.roof){case`gable`:return $r(e,n,o,i,a);case`hip`:return ri(e,n,o,i,a);case`mansard`:return ii(e,n,o,i,a);case`sawtooth`:return ai(e,n,o,i,r.sawteeth,a);case`shed`:return oi(e,n,o,i,a);case`thatch`:return ei(e,n,o,i,a);case`half-hip`:return ti(e,n,o,i,a);case`catslide`:return ni(e,n,o,i,a);case`parapet`:return si(e,n,i,a);case`monitor`:return ci(e,n,o,i,a);case`pyramid`:return li(e,n,i,a);case`barrel`:return ui(e,t,n,o,i,a);case`conical`:return di(e,n,i,a)}}function Yr(e,t,n){return n===`x`?[{ridgeA:t.a,ridgeB:t.b,eaveA:e.tn,eaveB:e.te},{ridgeA:t.a,ridgeB:t.b,eaveA:e.tw,eaveB:e.ts}]:[{ridgeA:t.a,ridgeB:t.b,eaveA:e.tn,eaveB:e.tw},{ridgeA:t.a,ridgeB:t.b,eaveA:e.te,eaveB:e.ts}]}function Xr(e,t,n,r,i,a){let o=t.te.x-t.tw.x;if(o<(a?24:30)||n.roof===`sawtooth`||n.roof===`monitor`||n.roof===`pyramid`||n.roof===`barrel`||n.roof===`conical`||n.roof===`parapet`)return;let s=Yr(t,r,n.ridge),c=n.roof===`thatch`?`thatch`:n.material.roof,l=(t,n)=>{e.moveTo(t.x,t.y),e.lineTo(n.x,n.y)};e.strokeStyle=i.wallR,e.lineWidth=c===`iron`?.75:.6,e.globalAlpha=c===`thatch`?.34:.26,e.beginPath();for(let e of s)if(c===`slate`||c===`tile`){let t=c===`slate`?[.28,.48,.66,.82]:[.34,.6,.82],n=.08;for(let r=0;r<t.length;r++){let i=t[r];if(l(Z(e.ridgeA,e.eaveA,i),Z(e.ridgeB,e.eaveB,i)),o>=38){let t=a?3:5;for(let a=1;a<t;a++){let o=(a+(r%2==0?.28:-.18))/t;if(o<=0||o>=1)continue;let s=Z(e.ridgeA,e.ridgeB,o),c=Z(e.eaveA,e.eaveB,o);l(Z(s,c,n),Z(s,c,i))}}n=i}}else if(c===`thatch`){let t=a?4:7;for(let n=1;n<t;n++){let r=n/t,i=Z(e.ridgeA,e.ridgeB,r),a=Z(e.eaveA,e.eaveB,r);l(Z(i,a,.12),Z(i,a,.94))}}else if(c===`iron`||c===`glass`){let t=a?4:7;for(let n=1;n<t;n++){let r=n/t;l(Z(e.ridgeA,e.ridgeB,r),Z(e.eaveA,e.eaveB,r))}c===`glass`&&l(Z(e.ridgeA,e.eaveA,.55),Z(e.ridgeB,e.eaveB,.55))}e.stroke(),e.globalAlpha=1}function Zr(e,t,n,r,i,a){if(n.roof===`parapet`||n.roof===`conical`||n.roof===`pyramid`)return;let o=t.te.x-t.tw.x,s=Math.max(1,Math.min(a?1.7:2.2,o*.024));e.strokeStyle=i.wallR,e.globalAlpha=.55,e.lineWidth=s+.8,e.lineJoin=`round`,e.beginPath(),e.moveTo(t.tw.x,t.tw.y+1),e.lineTo(t.ts.x,t.ts.y+1),e.lineTo(t.te.x,t.te.y+1),e.stroke(),e.strokeStyle=i.edge,e.globalAlpha=.72,e.lineWidth=s,e.beginPath(),e.moveTo(t.tw.x,t.tw.y),e.lineTo(t.ts.x,t.ts.y),e.lineTo(t.te.x,t.te.y),(n.roof===`gable`||n.roof===`thatch`||n.roof===`catslide`||n.roof===`half-hip`)&&(n.ridge===`x`?(e.moveTo(t.te.x,t.te.y),e.lineTo(r.b.x,r.b.y),e.lineTo(t.ts.x,t.ts.y)):(e.moveTo(t.tw.x,t.tw.y),e.lineTo(r.b.x,r.b.y),e.lineTo(t.ts.x,t.ts.y))),e.stroke(),e.lineJoin=`miter`,e.globalAlpha=1}function Qr(e,t){return t===`x`?[X(e.tn,e.tw),X(e.te,e.ts)]:[X(e.tn,e.te),X(e.tw,e.ts)]}function G(e,t){return{a:e,b:t,apex:X(e,t)}}function $r(e,t,n,r,i){if(n===`x`){let n=Q(X(t.tn,t.tw),r),a=Q(X(t.te,t.ts),r);return q(e,i.wallL,t.tn,t.tw,n),q(e,i.wallR,t.te,a,t.ts),V(e,i.top,t.tn,t.te,a,n),V(e,i.wallL,n,a,t.ts,t.tw),J(e,i.edge,n,a),G(n,a)}let a=Q(X(t.tn,t.te),r),o=Q(X(t.tw,t.ts),r);return q(e,i.wallR,t.tn,a,t.te),q(e,i.wallL,t.tw,t.ts,o),V(e,i.top,t.tn,a,o,t.tw),V(e,i.wallL,a,t.te,t.ts,o),J(e,i.edge,a,o),G(a,o)}function ei(e,t,n,r,i){let a=$r(e,t,n,r*1.12,i),o=Math.max(1.2,r*.16);e.fillStyle=i.wallR,e.globalAlpha=.55;for(let[r,i]of n===`x`?[[t.tn,t.te],[t.tw,t.ts]]:[[t.tn,t.tw],[t.te,t.ts]])Y(e,[r,i,{x:i.x,y:i.y+o},{x:r.x,y:r.y+o}],!0),e.fill();return e.globalAlpha=1,e.strokeStyle=i.top,e.lineWidth=Math.max(1.5,r*.22),e.lineCap=`round`,e.beginPath(),e.moveTo(a.a.x,a.a.y),e.lineTo(a.b.x,a.b.y),e.stroke(),e.lineCap=`butt`,a}function ti(e,t,n,r,i){let[a,o]=Qr(t,n),s=Q(Z(a,o,.12),r),c=Q(Z(a,o,.88),r),l=.66;if(n===`x`){let n=Q(X(t.tn,t.tw),r*l),a=Q(X(t.te,t.ts),r*l);V(e,i.wallL,t.tn,t.tw,n,s),V(e,i.wallR,t.te,c,a,t.ts),V(e,i.top,t.tn,t.te,c,s),V(e,i.wallL,s,c,t.ts,t.tw)}else{let n=Q(X(t.tn,t.te),r*l),a=Q(X(t.tw,t.ts),r*l);V(e,i.wallR,t.tn,s,n,t.te),V(e,i.wallL,t.tw,t.ts,a,c),V(e,i.top,t.tn,s,c,t.tw),V(e,i.wallL,s,t.te,t.ts,c)}return J(e,i.edge,s,c),G(s,c)}function ni(e,t,n,r,i){let a=.34;if(n===`x`){let n=Q(Z(t.tw,t.tn,a),r),o=Q(Z(t.ts,t.te,a),r);return q(e,i.wallL,t.tn,t.tw,n),q(e,i.wallR,t.te,o,t.ts),V(e,i.top,t.tn,t.te,o,n),V(e,i.wallL,n,o,t.ts,t.tw),J(e,i.edge,n,o),G(n,o)}let o=Q(Z(t.te,t.tn,a),r),s=Q(Z(t.ts,t.tw,a),r);return q(e,i.wallR,t.tn,o,t.te),q(e,i.wallL,t.tw,t.ts,s),V(e,i.top,t.tn,o,s,t.tw),V(e,i.wallL,o,t.te,t.ts,s),J(e,i.edge,o,s),G(o,s)}function ri(e,t,n,r,i){let[a,o]=Qr(t,n),s=Q(Z(a,o,.24),r),c=Q(Z(a,o,.76),r);return n===`x`?(V(e,i.top,t.tn,t.te,c,s),q(e,i.wallR,t.te,t.ts,c),V(e,i.wallL,s,c,t.ts,t.tw),q(e,i.top,t.tn,s,t.tw)):(V(e,i.top,t.tn,s,c,t.tw),q(e,i.top,t.tn,t.te,s),V(e,i.wallR,s,t.te,t.ts,c),q(e,i.wallL,t.tw,c,t.ts)),J(e,i.edge,s,c),G(s,c)}function ii(e,t,n,r,i){let a=Ii(t.tn,t.te,t.ts,t.tw),o=Q(Fi(t.tn,a,.32),r),s=Q(Fi(t.te,a,.32),r),c=Q(Fi(t.ts,a,.32),r),l=Q(Fi(t.tw,a,.32),r);return V(e,i.top,t.tn,t.te,s,o),V(e,i.wallR,t.te,t.ts,c,s),V(e,i.wallL,l,c,t.ts,t.tw),V(e,i.top,t.tn,o,l,t.tw),V(e,i.top,o,s,c,l),e.strokeStyle=i.edge,e.lineWidth=.8,Y(e,[o,s,c,l],!0),e.stroke(),n===`x`?G(X(o,l),X(s,c)):G(X(o,s),X(l,c))}function ai(e,t,n,r,i,a){let o=Math.max(2,Math.min(5,i||3)),s=n===`x`?t.tn:t.tw,c=n===`x`?t.tw:t.ts,l=n===`x`?t.te:t.tn,u=n===`x`?t.ts:t.te;for(let t=0;t<o;t++){let n=t/o,i=(t+.68)/o,d=(t+1)/o,f=Z(s,c,n),p=Z(l,u,n),m=Q(Z(s,c,i),r*.72),h=Q(Z(l,u,i),r*.72),g=Z(s,c,d),_=Z(l,u,d);V(e,a.top,f,p,h,m),V(e,a.wallL,m,h,_,g),J(e,a.edge,m,h,.65)}return G(Q(Z(s,c,.68/o),r*.72),Q(Z(l,u,.68/o),r*.72))}function oi(e,t,n,r,i){if(n===`x`){let n=Q(t.tn,r),a=Q(t.te,r);return q(e,i.wallL,t.tn,t.tw,n),q(e,i.wallR,t.te,a,t.ts),V(e,i.top,n,a,t.ts,t.tw),J(e,i.edge,n,a),G(n,a)}let a=Q(t.tn,r),o=Q(t.tw,r);return q(e,i.wallR,t.tn,a,t.te),q(e,i.wallL,t.tw,t.ts,o),V(e,i.top,a,t.te,t.ts,o),J(e,i.edge,a,o),G(a,o)}function si(e,t,n,r){let i=Math.max(1.5,n*.42),a=Q(t.tn,i),o=Q(t.te,i),s=Q(t.ts,i),c=Q(t.tw,i);V(e,r.wallL,c,s,t.ts,t.tw),V(e,r.wallR,s,o,t.te,t.ts),V(e,r.top,a,o,s,c);let l=Ii(a,o,s,c),u=[Z(a,l,.2),Z(o,l,.2),Z(s,l,.2),Z(c,l,.2)];return V(e,r.wallL,...u),e.strokeStyle=r.edge,e.lineWidth=.8,Y(e,[a,o,s,c],!0),e.stroke(),G(u[0],u[2])}function ci(e,t,n,r,i){let a=$r(e,t,n,r*.6,i),o=r*.42,s=Math.abs(t.te.x-t.tw.x)*.1,c={x:a.a.x+s*.35,y:a.a.y},l={x:a.b.x-s*.35,y:a.b.y},u=Q(c,o),d=Q(l,o);return V(e,i.wallR,c,l,d,u),V(e,i.top,u,d,Q(d,1.5),Q(u,1.5)),J(e,i.edge,Q(u,1.5),Q(d,1.5)),G(Q(u,1.5),Q(d,1.5))}function li(e,t,n,r){let i=Q(Ii(t.tn,t.te,t.ts,t.tw),n*1.35);return q(e,r.top,t.tw,t.tn,i),q(e,r.top,t.tn,t.te,i),q(e,r.wallL,t.tw,i,t.ts),q(e,r.wallR,t.ts,i,t.te),J(e,r.edge,t.tn,i,.7),{a:i,b:i,apex:i}}function ui(e,t,n,r,i,a){let[o,s]=Qr(n,r),[c,l,u,d]=r===`x`?[n.tn,n.te,n.ts,n.tw]:[n.te,n.ts,n.tw,n.tn],f=Q(o,i),p=Q(s,i),m=Q(Z(d,o,.5),i*.86),h=Q(Z(u,s,.5),i*.86),g=Q(Z(c,o,.5),i*.86),_=Q(Z(l,s,.5),i*.86);return V(e,a.wallL,d,u,h,m),V(e,a.top,m,h,p,f),V(e,t.palette.windowLit,f,p,_,g),V(e,a.wallR,g,_,l,c),J(e,a.edge,f,p,.7),G(f,p)}function di(e,t,n,r){let i=Ii(t.tn,t.te,t.ts,t.tw),a=Q(i,n*2.1),o=.42,s=Q(Z(t.tn,i,o),n*1.05),c=Q(Z(t.te,i,o),n*1.05),l=Q(Z(t.ts,i,o),n*1.05),u=Q(Z(t.tw,i,o),n*1.05);return V(e,r.top,t.tn,t.te,c,s),V(e,r.wallR,t.te,t.ts,l,c),V(e,r.wallL,u,l,t.ts,t.tw),V(e,r.top,t.tn,s,u,t.tw),q(e,r.top,s,c,a),q(e,r.wallR,c,l,a),q(e,r.wallL,l,u,a),q(e,r.top,u,s,a),{a,b:a,apex:a}}var fi=34;function pi(e,t,n,r,i,a){if(!i)return;let o=(e,t,r,i)=>Pi(n.ta,n.tb,n.ga,n.gb,e,t,r,i),s=(t,n,r,i)=>{let a=o(t,t,n,n)[0],s=o(r,r,i,i)[0];e.moveTo(a.x,a.y),e.lineTo(s.x,s.y)},c=T(r.seed^1327217884^a*2654435769);switch(e.strokeStyle=t.palette.masonry,e.lineWidth=.55,e.globalAlpha=t.palette.dark?.3:.22,e.beginPath(),r.material.wall){case`brick`:for(let e=1;e<=6;e++){let t=.08+e*.86/7;s(.02,t,.98,t);let n=e%2==0?.2:.36;for(let e=n;e<.96;e+=.42){let n=.86/7/2;s(e,t-n,e,t+n)}}break;case`stone`:for(let e=1;e<=4;e++){let t=.1+e*.82/5;s(.02,t,.98,t);let n=.18+c()*.22,r=.58+c()*.24,i=.82/5/2;s(n,t-i,n,t+i),s(r,t-i,r,t+i)}break;case`timber`:for(let e=1;e<=7;e++){let t=.06+e*.88/8;s(.02,t,.98,t)}break;case`stucco`:for(let e=0;e<6;e++){let e=.1+c()*.76,t=.12+c()*.72;s(e,t,Math.min(.94,e+.06+c()*.08),t+(c()-.5)*.03)}break;case`iron`:case`glass`:for(let e=1;e<=6;e++){let t=e/7;s(t,.05,t,.95)}break;default:break}e.stroke(),e.globalAlpha=1}function mi(e,t,n,r,i){let a=T(r.seed^De.FACADE),o=Math.max(1,Math.min(3,r.storeys)),s=Math.max(1,Math.min(i?3:4,r.bays)),c=n.te.x-n.tw.x>=fi,l=[{q:{ta:n.tw,tb:n.ts,ga:n.gw,gb:n.gs},bays:s},{q:{ta:n.ts,tb:n.te,ga:n.gs,gb:n.ge},bays:Math.max(1,s-1)}];for(let n=0;n<l.length;n++){let{q:i,bays:s}=l[n];pi(e,t,i,r,c,n),_i(e,t,i,r,c,s),vi(e,i,o,s,c,()=>a()<.24?t.palette.windowLit:t.palette.window)}if(hi(e,t,n,r),r.awning){let r=Pi(n.ts,n.te,n.gs,n.ge,.08,.92,.57,.7);V(e,t.palette.awning,...r),e.strokeStyle=t.palette.windowLit,e.globalAlpha=.5,e.lineWidth=.7;for(let t=1;t<4;t++){let n=t/4,i=Z(r[0],r[1],n),a=Z(r[3],r[2],n);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(a.x,a.y),e.stroke()}e.globalAlpha=1}}function hi(e,t,n,r){let i=(e,t,r,i)=>Pi(n.ts,n.te,n.gs,n.ge,e,t,r,i),a=(e,t)=>i(e,e,t,t)[0];switch(r.ground){case`shopfront`:V(e,t.palette.sidewalk,...i(.05,.95,.5,.59)),V(e,t.palette.windowLit,...i(.06,.43,.61,.88)),V(e,t.palette.windowLit,...i(.63,.94,.61,.88)),V(e,t.palette.window,...i(.46,.6,.64,.98)),V(e,t.palette.windowLit,...i(.46,.6,.59,.68)),V(e,t.palette.masonry,...i(.06,.94,.88,.98)),e.strokeStyle=t.palette.masonry,e.lineWidth=.8,e.beginPath();for(let t of[.24,.43,.63,.79]){let n=a(t,.61),r=a(t,.88);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y)}e.stroke();break;case`arcade`:{let n=Math.max(2,Math.min(4,r.bays));for(let r=0;r<n;r++){let a=.88/n,o=.06+r*a+a*.16,s=.06+(r+1)*a-a*.16;V(e,t.palette.window,...i(o,s,.58,.98))}break}case`cart-door`:{V(e,t.palette.window,...i(.24,.74,.5,.98)),e.strokeStyle=t.palette.masonry,e.lineWidth=.8,e.beginPath();let n=a(.24,.5),r=a(.74,.5),o=a(.24,.98),s=a(.74,.98);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(n.x,n.y),e.lineTo(s.x,s.y),e.moveTo(r.x,r.y),e.lineTo(o.x,o.y),e.stroke();break}case`portico`:{for(let n of[.2,.42,.64])V(e,t.palette.sidewalk,...i(n,n+.08,.55,.98));let n=i(.14,.78,.44,.55);V(e,t.palette.sidewalk,...n);let r=a(.14,.44),o=a(.78,.44),s=X(r,o);q(e,t.palette.sidewalk,r,{x:s.x,y:s.y-Math.max(2,(o.x-r.x)*.08)},o),e.strokeStyle=t.palette.masonry,e.lineWidth=.7,e.beginPath(),e.moveTo(n[0].x,n[0].y),e.lineTo(n[1].x,n[1].y),e.stroke();break}default:{V(e,t.palette.sidewalk,...i(.09,.32,.54,.99)),V(e,t.palette.window,...i(.125,.285,.64,.99)),V(e,t.palette.windowLit,...i(.125,.285,.55,.65)),e.strokeStyle=t.palette.masonry,e.globalAlpha=.72,e.lineWidth=.65,e.beginPath();let o=a(.135,.82),s=a(.275,.82);e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.stroke(),e.globalAlpha=1;let c=a(.075,.98),l=a(.335,.98);if(V(e,t.palette.sidewalk,c,l,{x:l.x+1.2,y:l.y+2.5},{x:c.x+1.2,y:c.y+2.5}),n.te.x-n.tw.x>=38&&(r.archetype===`cottage`||r.archetype===`farmhouse`||r.archetype===`cottage-row`||r.archetype===`boarding-house`)){let n=i(.055,.355,.47,.54);V(e,t.palette.masonry,...n),e.strokeStyle=t.palette.sidewalk,e.lineWidth=.75,e.beginPath();for(let t of[.08,.33]){let n=a(t,.53),r=a(t,.96);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y)}e.stroke()}break}}}function gi(e,t,n,r,i){let a=r.trim;if(!a.cornice&&!a.stringCourse&&!a.parapet&&!a.quoins)return;let o=(t,r,i)=>{e.strokeStyle=r,e.lineWidth=i,e.beginPath();for(let[r,i,a,o]of[[n.tw,n.ts,n.gw,n.gs],[n.ts,n.te,n.gs,n.ge]]){let n=Pi(r,i,a,o,0,1,t,t);e.moveTo(n[0].x,n[0].y),e.lineTo(n[1].x,n[1].y)}e.stroke()};if(a.cornice&&o(.06,i.edge,1.1),a.parapet&&o(.14,i.edge,.7),a.stringCourse&&r.storeys>=3){let e=Math.min(3,r.storeys-1);for(let t=1;t<=e;t++)o(.12+t*.74/(e+1),i.wallR,.7)}if(a.quoins){e.fillStyle=i.edge,e.globalAlpha=.7;for(let t=0;t<4;t++){let r=.12+t*.2;V(e,i.edge,...Pi(n.ts,n.te,n.gs,n.ge,0,.07,r,r+.1))}e.globalAlpha=1}}function _i(e,t,n,r,i,a){let o=(e,t,r,i)=>Pi(n.ta,n.tb,n.ga,n.gb,e,t,r,i);if(e.globalAlpha=.5,V(e,t.palette.masonry,...o(0,1,.93,1)),e.globalAlpha=1,e.globalAlpha=.45,V(e,t.palette.sidewalk,...o(0,1,.02,.07)),e.globalAlpha=1,!i)return;let s=r.band!==`village`;if(e.globalAlpha=.3,s&&a>1)for(let n=1;n<a;n++){let r=.09+.82*n/a;V(e,t.palette.sidewalk,...o(r-.012,r+.012,.07,.93))}if(V(e,t.palette.sidewalk,...o(0,.035,.07,.93)),V(e,t.palette.sidewalk,...o(.965,1,.07,.93)),e.globalAlpha=1,r.material.wall===`timber`&&(r.archetype===`farmhouse`||r.archetype===`barn`||r.archetype===`smithy`||r.archetype===`mill`)){e.strokeStyle=t.palette.masonry,e.globalAlpha=.55,e.lineWidth=1,e.beginPath();let n=.5,r=o(.03,.03,n,n)[0],i=o(.97,.97,n,n)[0];e.moveTo(r.x,r.y),e.lineTo(i.x,i.y);for(let t=0;t<=a;t++){let n=.06+.88*t/Math.max(1,a),r=o(n,n,.08,.08)[0],i=o(n,n,.92,.92)[0];e.moveTo(r.x,r.y),e.lineTo(i.x,i.y)}for(let t=0;t<a;t++){let n=.06+.88*t/Math.max(1,a),r=.06+.88*(t+1)/Math.max(1,a),i=o(n,n,.5,.5)[0],s=o(r,r,.88,.88)[0];e.moveTo(i.x,i.y),e.lineTo(s.x,s.y)}e.stroke(),e.globalAlpha=1}}function vi(e,t,n,r,i,a){let o=(e,n,r,i)=>Pi(t.ta,t.tb,t.ga,t.gb,e,n,r,i);for(let t=0;t<n;t++){let s=.72/n,c=.12+t*s,l=Math.min(.86,c+s*.58);for(let t=0;t<r;t++){let n=.82/r,s=.09+t*n+n*.27,u=.09+(t+1)*n-n*.27,d=a();if(i&&(e.globalAlpha=.55,V(e,bi,...o(s-.008,u+.008,c-.022,c)),e.globalAlpha=.8,V(e,yi,...o(s-.016,u+.016,l,l+.022)),e.globalAlpha=1),V(e,d,...o(s,u,c,l)),i){e.strokeStyle=bi,e.globalAlpha=.5,e.lineWidth=.7,e.beginPath();let t=(s+u)/2,n=o(t,t,c,c)[0],r=o(t,t,l,l)[0];e.moveTo(n.x,n.y),e.lineTo(r.x,r.y);let i=c+(l-c)*.42,a=o(s,s,i,i)[0],d=o(u,u,i,i)[0];e.moveTo(a.x,a.y),e.lineTo(d.x,d.y),e.stroke(),e.globalAlpha=1}}}}var yi=`#cfc6b4`,bi=`#3a342c`;function xi(e,t,n,r,i,a,o,s,c){let l=T(r.seed^De.ROOF_FURNITURE),u=n.te.x-n.tw.x,d=Math.max(2,u*(s?.055:.07)),f=(e,t)=>Math.max(0,Math.min(e,o/t));for(let n=0;n<r.chimneys;n++){let a=r.chimneys===1?.5:.27+n/(r.chimneys-1)*.46,o=Z(i.a,i.b,a),s=f(d,1.9);if(s<1.5)continue;let u=o.x+(l()-.5)*s*.6;ji(e,u,o.y,s,s*1.9,t.palette.masonry),c.push({x:u,y:o.y-s*1.9})}if(r.cupola&&r.cap!==`clock-tower`){let n=f(u*.15,Kr.cupola);n>=3&&Mi(e,i.apex.x,i.apex.y,n,r.clock,t)}switch(r.cap){case`bellcote`:{let n=f(d*2,Kr.bellcote);n>=2.5&&Ei(e,Z(i.a,i.b,.14),n,t);break}case`finial`:{let n=f(d*1.8,Kr.finial);n>=2&&Di(e,i.a,n,t.palette.masonry);break}case`clock-tower`:{let r=f((n.te.x-n.tw.x)*.16,Kr[`clock-tower`]);r>=3&&Oi(e,i.apex,r,t);break}case`lantern`:{let n=f(r.archetype===`signal-tower`?u*.34:d*2.2,Kr.lantern);n>=3&&Ai(e,i.apex,n,t);break}default:break}if(r.dormers>0&&u>=28){let n=Math.min(3,r.dormers);for(let r=0;r<n;r++){let o=Z(i.a,i.b,n===1?.5:.25+r/(n-1)*.5),s=o.y+a*.45,c=Math.min(d*.9,a*.28);c>=2.4&&Ni(e,o.x,s,c,t.palette.window,t.palette.masonry)}}}function K(e,t){let n=t/2,r=t/4;return{n:{x:e.x,y:e.y-r},e:{x:e.x+n,y:e.y},s:{x:e.x,y:e.y+r},w:{x:e.x-n,y:e.y},c:e}}var Si=`rgba(0, 0, 0, 0.3)`;function Ci(e,t,n,r,i=1){let a=K(Q(t.c,n),t.e.x-t.w.x);return e.globalAlpha=i,e.fillStyle=r,Y(e,[a.w,a.s,t.s,t.w],!0),e.fill(),Y(e,[a.s,a.e,t.e,t.s],!0),e.fill(),e.fillStyle=Si,Y(e,[a.s,a.e,t.e,t.s],!0),e.fill(),e.globalAlpha=1,a}function wi(e,t,n,r){let i=Q(t.c,n);q(e,r,t.w,t.n,i),q(e,r,t.n,t.e,i),e.fillStyle=Si,Y(e,[t.n,t.e,i],!0),e.fill(),q(e,r,t.w,t.s,i),q(e,r,t.s,t.e,i),e.fillStyle=Si,Y(e,[t.s,t.e,i],!0),e.fill()}function Ti(e,t,n,r,i){let a=X(X(n.w,n.s),X(t.w,t.s));e.fillStyle=i.palette.windowLit,e.beginPath(),e.arc(a.x,a.y,r,0,Math.PI*2),e.fill(),e.strokeStyle=i.palette.window,e.lineWidth=.7,e.stroke()}function Ei(e,t,n,r){let i=K(t,n*.64),a=Ci(e,i,n,r.palette.masonry),o=X(X(a.w,a.s),X(i.w,i.s));e.fillStyle=r.palette.window,e.fillRect(o.x-n*.12,o.y-n*.28,n*.24,n*.5),wi(e,a,n*.5,r.palette.domeAccent)}function Di(e,t,n,r){e.strokeStyle=r,e.lineWidth=1;let i=t.y-n*.68;e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.x,t.y-n),e.moveTo(t.x-n*.2,i),e.lineTo(t.x+n*.38,i),e.stroke(),q(e,r,{x:t.x+n*.38,y:i},{x:t.x+n*.18,y:i-n*.12},{x:t.x+n*.18,y:i+n*.12})}function Oi(e,t,n,r){let i=K(t,n),a=n*1.5,o=Ci(e,i,a,r.palette.sidewalk),s=K(Q(i.c,a*.86),n);e.strokeStyle=r.palette.masonry,e.lineWidth=.7,Y(e,[s.w,s.s,s.e],!1),e.stroke(),wi(e,o,n*.88,r.palette.domeAccent),Ti(e,i,o,Math.max(1.6,n*.2),r)}function ki(e,t,n,r,i,a){if(a===`bandstand`){let a=Math.min(r,i/.95);if(a<4)return;wi(e,Ci(e,Ci(e,K(n,a),a*.12,t.palette.park.path),a*.38,t.palette.sidewalk,.55),a*.45,t.palette.domeAccent);return}let o=Math.min(r*.32,i/1.9);o<2||wi(e,Ci(e,K(n,o),o*1.6,t.palette.masonry),o*.3,t.palette.masonry)}function Ai(e,t,n,r){let i=K(t,n),a=Ci(e,i,n*.7,r.palette.windowLit,.85);e.strokeStyle=r.palette.masonry,e.lineWidth=.6,e.globalAlpha=.5,Y(e,[X(a.w,a.s),X(i.w,i.s)],!1),e.stroke(),Y(e,[X(a.s,a.e),X(i.s,i.e)],!1),e.stroke(),e.globalAlpha=1,wi(e,Ci(e,a,n*.1,r.palette.masonry),n*.55,r.palette.domeAccent)}function ji(e,t,n,r,i,a){let o=r/2,s=n-i+.45,c=Math.max(.8,r*.34),l=s+c;e.fillStyle=a,Y(e,[{x:t-o,y:l},{x:t,y:l+o*.45},{x:t,y:n+o*.45},{x:t-o,y:n}],!0),e.fill(),e.globalAlpha=.72,Y(e,[{x:t,y:l+o*.45},{x:t+o,y:l},{x:t+o,y:n},{x:t,y:n+o*.45}],!0),e.fill(),e.globalAlpha=1,e.fillStyle=bi,e.fillRect(t-o-.5,l-1,r+1,Math.max(1,r*.16));let u=r>=4.5?2:1,d=Math.max(.8,r*(u===2?.27:.34));for(let n=0;n<u;n++){let i=u===1?t:t+(n===0?-r*.23:r*.23);e.fillRect(i-d/2,s,d,c+.4),e.fillRect(i-d*.62,s-.45,d*1.24,.7)}}function Mi(e,t,n,r,i,a){let o=K({x:t,y:n},r*.72),s=r*.85,c=Ci(e,o,s,a.palette.sidewalk);wi(e,K(c.c,r),r*.65,a.palette.domeAccent),i&&Ti(e,o,c,Math.max(1.4,r*.12),a),e.strokeStyle=a.palette.masonry,e.lineWidth=.8,e.beginPath(),e.moveTo(t,n-s-r*.62),e.lineTo(t,n-s-r*.95),e.stroke()}function Ni(e,t,n,r,i,a){let o=Math.max(2.4,r),s=o*.94;e.fillStyle=i,e.fillRect(t-o/2,n-s,o,s),q(e,a,{x:t-o*.72,y:n-s},{x:t,y:n-s-o*.66},{x:t+o*.72,y:n-s})}function Pi(e,t,n,r,i,a,o,s){let c=(i,a)=>Z(Z(e,t,i),Z(n,r,i),a);return[c(i,o),c(a,o),c(a,s),c(i,s)]}function q(e,t,n,r,i){e.fillStyle=t,Y(e,[n,r,i],!0),e.fill()}function J(e,t,n,r,i=.85){e.strokeStyle=t,e.lineWidth=i,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke()}function Y(e,t,n){let r=t[0];if(r){e.beginPath(),e.moveTo(r.x,r.y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);n&&e.closePath()}}function X(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function Z(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Fi(e,t,n){return Z(e,t,n)}function Q(e,t){return{x:e.x,y:e.y-t}}function Ii(e,t,n,r){return{x:(e.x+t.x+n.x+r.x)/4,y:(e.y+t.y+n.y+r.y)/4}}var Li=14;function Ri(e,t,n,r){return e!==`city`&&t!==!0&&n>0&&re(r)}function zi(e,t){let n=t.now??Date.now(),r=t.tier===`street`&&!t.ageLens&&t.atlas?gt(t.model):null;if(t.tier===`city`){let r=new sr,i=[];for(let e of t.geom.order){let a=t.geom.geoms[e];if(!Qn(t.cam,a,t.viewW,t.viewH))continue;let o=a.block,s=t.ageLens?fe(o.lastTouchedAt??o.placedAt,n):void 0;if(o.state===`tombstoned`){r.add(t.ageLens?t.palette.tombstone:t.palette.earth,...Hi(t,o));continue}if(o.state===`new`&&!t.ageLens&&!o.phantom){r.add(t.palette.newBlock,...Hi(t,o));continue}let c=Ce(o.lang,t.palette,s),l=t.ageLens?c.top:a.style?.archetype===`field`?Ki(a.style,t.palette):a.style?.archetype===`park`?t.palette.park.lawn:c.top;r.add(l,...Hi(t,o)),o.landmark&&i.push(a)}r.flush(e),e.fillStyle=t.palette.domeAccent;for(let n of i){let r=Ui(t,n);e.beginPath(),e.arc(r.x,r.y-3,2,0,Math.PI*2),e.fill()}return}for(let i of t.geom.order){let a=t.geom.geoms[i];if(Qn(t.cam,a,t.viewW,t.viewH)){if(Rr(e,t,a.block),Wi(e,t,a,n),r){let n=r.get(a.block.id);if(n&&t.atlas)for(let r of n){let n=I(r.x,r.y),i=L(t.cam,n.u,n.v),a=r.size*t.cam.scale*2,o=t.atlas.index[r.sprite]*t.atlas.cell;e.drawImage(t.atlas.canvas,o,0,t.atlas.cell,t.atlas.cell,i.x-a/2,i.y-a,a,a)}}Bi(e,t,a)}}}function Bi(e,t,n){if(t.ageLens)return;let r=Xt(n.block);if(!r)return;let i=tr(t.model,n.block.id),a=Ri(t.tier,t.ageLens,i.length,n.block)?Zt(i):null,o=a?$n(t.cam,a):Vi(t,n);Qt(e,t.palette,r,o.x,o.y,n.block.id,Yt(t.cam.scale),t.animationTime??0)}function Vi(e,t){let n=Ui(e,t);return{x:n.x,y:n.y-Zn(t,e.cam.scale)*e.cam.scale}}function Hi(e,t){let n=Hn(t.rect);return[L(e.cam,n.n.u,n.n.v),L(e.cam,n.e.u,n.e.v),L(e.cam,n.s.u,n.s.v),L(e.cam,n.w.u,n.w.v)]}function Ui(e,t){let n=t.block.rect,r=I(n.x+n.w/2,n.y+n.h/2),i=L(e.cam,r.u,r.v);return{x:i.x,y:i.y-t.hIso*e.cam.scale}}function Wi(e,t,n,r){let i=n.block,a=t.palette,[o,s,c,l]=Hi(t,i),u=s.x-l.x;if(i.state===`tombstoned`){if(e.fillStyle=t.ageLens?a.tombstone:a.earth,e.globalAlpha=t.ageLens?.4:.7,B(e,o,s,c,l),e.fill(),e.globalAlpha=1,u>=10&&!t.ageLens){let n=T(w(i.id));e.fillStyle=a.rubble;let r=4+Math.floor(n()*4);for(let a=0;a<r;a++){let r=I(i.rect.x+i.rect.w*(.12+.76*n()),i.rect.y+i.rect.h*(.12+.76*n())),a=L(t.cam,r.u,r.v),o=Math.min(4,Math.max(1,.1*u*n()));e.fillRect(a.x,a.y-o/2,o,o/2+1)}e.strokeStyle=a.blockStroke,e.globalAlpha=.6,e.setLineDash([3,3]),B(e,o,s,c,l),e.stroke(),e.setLineDash([]),e.globalAlpha=1}return}let d=R(t.cam,i.rect,n.hIso);if(i.phantom){let n=t.ageLens?fe(i.lastTouchedAt??i.placedAt,r):void 0,u=Ce(i.lang,a,n);e.globalAlpha=.3,or(e,R(t.cam,i.rect,3*Ln),u),e.globalAlpha=1;let d=Xe(e,a.dark?`#8b8f99`:`#8a7f64`);d&&(e.fillStyle=d,B(e,o,s,c,l),e.fill()),e.strokeStyle=a.blockStroke,e.setLineDash([4,3]),B(e,o,s,c,l),e.stroke(),e.setLineDash([]);return}if(i.state===`new`&&!t.ageLens){if(e.fillStyle=a.earth,B(e,o,s,c,l),e.fill(),e.strokeStyle=a.newBlock,e.lineWidth=1.5,e.setLineDash([4,3]),B(e,o,s,c,l),e.stroke(),e.setLineDash([]),t.tier===`street`&&u>=Li){let t=T(w(i.id)),n=(l.x+s.x)/2+(t()-.5)*u*.3,r=(o.y+c.y)/2+(c.y-o.y)*.2,d=r-Math.max(12,u*.5),f=u*.35*(t()<.5?-1:1);e.strokeStyle=a.crane,e.lineWidth=1.5,e.beginPath(),e.moveTo(n,r),e.lineTo(n,d),e.lineTo(n+f,d),e.moveTo(n+f*.8,d),e.lineTo(n+f*.8,d+Math.max(6,u*.15)),e.stroke()}return}let f=t.ageLens?fe(i.lastTouchedAt??i.placedAt,r):void 0,p=n.style&&!t.ageLens&&t.tier!==`city`?{...n.style.material,urbanity:M(i),variance:(n.style.seed>>>8)%200/100-1}:void 0,m=Ce(i.lang,a,f,p),h=i.buildingCount>0?tr(t.model,i.id):Gi,g=Ri(t.tier,t.ageLens,h.length,i)?h:Gi;if(g.length>0){let n=R(t.cam,i.rect,zn);or(e,n,{top:a.sidewalk,wallL:m.wallL,wallR:m.wallR}),e.globalAlpha=.25,V(e,m.top,n.tn,n.te,n.ts,n.tw),e.globalAlpha=1,Zi(e,t,i,ta(e,t,g,n.liftPx,i,m));return}let _=n.style??He(i);if(!t.ageLens&&_.archetype===`field`){Yi(e,t,n,_);return}if(!t.ageLens&&_.archetype===`park`){Xi(e,t,n,_,m);return}let v=t.ageLens?null:$i(t,i,n,_);v?.behind&&ea(e,t,v.prism,_,m);let y=qr(e,t,d,_,m,{suppressDetails:t.ageLens===!0});v&&!v.behind&&ea(e,t,v.prism,_,m),e.strokeStyle=m.edge,e.lineWidth=1,e.beginPath(),e.moveTo(d.tw.x,d.tw.y),e.lineTo(d.tn.x,d.tn.y),e.lineTo(d.te.x,d.te.y),e.stroke(),Zi(e,t,i,y.stacks)}var Gi=[];function Ki(e,t){return t.farm.crops[(e.seed>>>4)%4]}var qi={district:3.2,street:1.6},Ji=80;function Yi(e,t,n,r){let i=n.block,a=t.palette,o=i.rect,[s,c,l,u]=Hi(t,i),d=c.x-u.x;if(e.fillStyle=Ki(r,a),B(e,s,c,l,u),e.fill(),d>=16){let n=qi[t.tier===`street`?`street`:`district`],i=r.ridge===`x`,s=i?o.h:o.w,c=Math.min(Ji,Math.floor(s/n));e.strokeStyle=a.farm.furrow,e.globalAlpha=.38,e.lineWidth=Math.max(.5,.22*t.cam.scale),e.beginPath();for(let r=1;r<=c;r++){let a=(r-.5)*n,s=i?I(o.x+.6,o.y+a):I(o.x+a,o.y+.6),c=i?I(o.x+o.w-.6,o.y+a):I(o.x+a,o.y+o.h-.6),l=L(t.cam,s.u,s.v),u=L(t.cam,c.u,c.v);e.moveTo(l.x,l.y),e.lineTo(u.x,u.y)}e.stroke(),e.globalAlpha=1}if(d>=24){let n=Math.max(2,Math.min(o.w,o.h)*.22),r={x:o.x+o.w-n-.8,y:o.y+o.h-n-.8,w:n,h:n*.8};or(e,R(t.cam,r,3*Ln*.55),a.farm.shed)}}function Xi(e,t,n,r,i){let a=n.block,o=t.palette,s=a.rect,[c,l,u,d]=Hi(t,a),f=l.x-d.x;if(e.fillStyle=o.park.lawn,B(e,c,l,u,d),e.fill(),f<14)return;let p=s.x+s.w/2,m=s.y+s.h/2,h=Math.min(1.4,Math.min(s.w,s.h)*.12);e.fillStyle=o.park.path;for(let n of[{x:s.x,y:m-h/2,w:s.w,h},{x:p-h/2,y:s.y,w:h,h:s.h}]){let r=Hn(n);B(e,L(t.cam,r.n.u,r.n.v),L(t.cam,r.e.u,r.e.v),L(t.cam,r.s.u,r.s.v),L(t.cam,r.w.u,r.w.v)),e.fill()}let g=Math.min(s.w,s.h)*.34,_=Hn({x:p-g/2,y:m-g/2,w:g,h:g});if(e.fillStyle=i.top,e.globalAlpha=.85,B(e,L(t.cam,_.n.u,_.n.v),L(t.cam,_.e.u,_.e.v),L(t.cam,_.s.u,_.s.v),L(t.cam,_.w.u,_.w.v)),e.fill(),e.globalAlpha=1,f>=30){let i=L(t.cam,I(p,m).u,I(p,m).v),a=Zn(n,t.cam.scale)*t.cam.scale,o=Math.min(s.w,s.h)*.3*t.cam.scale,c=(r.seed>>>6)%3;c===0?ki(e,t,i,o,a,`bandstand`):c===1?Nr(e,t,i,o*.6):ki(e,t,i,o,a,`obelisk`)}if(t.tier===`street`&&t.atlas){let n=T(r.seed^1374496523),i=2+Math.floor(n()*3);for(let r=0;r<i;r++){let i=r%2==0?.2:.8,a=r<2?.2:.8,o=s.x+s.w*(i+(n()-.5)*.14),c=s.y+s.h*(a+(n()-.5)*.14),l=(1.8+n()*1.2)*t.cam.scale*2,u=n()<.75?`tree1`:`tree2`,d=L(t.cam,I(o,c).u,I(o,c).v),f=t.atlas.index[u]*t.atlas.cell;e.drawImage(t.atlas.canvas,f,0,t.atlas.cell,t.atlas.cell,d.x-l/2,d.y-l,l,l)}}}function Zi(e,t,n,r){t.tier!==`street`||t.ageLens||r.length===0||n.health?.zone===`industrial`&&Ur(e,t.palette,r,n.id,t.cam.scale,t.animationTime??0)}var Qi=26;function $i(e,t,n,r){let i=r.massing;if(i.kind===`none`||e.tier===`city`||(t.rect.w+t.rect.h)*e.cam.scale<Qi)return null;let a={x:t.rect.x+t.rect.w*i.u0,y:t.rect.y+t.rect.h*i.v0,w:t.rect.w*(i.u1-i.u0),h:t.rect.h*(i.v1-i.v0)};return{prism:R(e.cam,a,n.hIso*i.height),behind:i.behind}}function ea(e,t,n,r,i){qr(e,t,n,{...r,chimneys:0,dormers:0,awning:!1,cupola:!1,clock:!1,cap:`none`},i,{compact:!0,suppressDetails:t.ageLens===!0}),e.strokeStyle=i.edge,e.lineWidth=.8,e.beginPath(),e.moveTo(n.tw.x,n.tw.y),e.lineTo(n.tn.x,n.tn.y),e.lineTo(n.te.x,n.te.y),e.stroke()}function ta(e,t,n,r,i,a){let o=[];for(let s=0;s<n.length;s++){let c=n[s],l=R(t.cam,c.rect,Bn(c.height)),u=-r,d={gn:ra(l.gn,u),ge:ra(l.ge,u),gs:ra(l.gs,u),gw:ra(l.gw,u),tn:ra(l.tn,u),te:ra(l.te,u),ts:ra(l.ts,u),tw:ra(l.tw,u),liftPx:l.liftPx},f=Ue(c,i);i.landmark&&s===n.length-1&&(f.roof=`hip`,f.cupola=!0,f.clock=!0);let p=t.ageLens||t.tier===`city`?a:Ce(i.lang,t.palette,void 0,{...f.material,urbanity:M(i),variance:(f.seed>>>8)%200/100-1});e.globalAlpha=.5+.45*c.height;let m=qr(e,t,d,f,p,{compact:!0,suppressDetails:t.ageLens===!0});e.globalAlpha=1,o.unshift(...m.stacks)}return o}function na(e,t){let n=(n,r,i)=>{let a=t.geom.geoms.find(e=>e.block.id===n);if(!a||!Qn(t.cam,a,t.viewW,t.viewH))return;let o=R(t.cam,a.block.rect,a.hIso);e.strokeStyle=r,e.lineWidth=i,ar(e,o),e.stroke()};t.hoverId&&t.hoverId!==t.selectedId&&n(t.hoverId,t.palette.hover,1.5),t.selectedId&&n(t.selectedId,t.palette.selected,2)}function ra(e,t){return{x:e.x,y:e.y+t}}function ia(){return{accepted:new Set,measure:new Map}}var aa=`12px ui-sans-serif, system-ui, sans-serif`,oa=`13px ui-sans-serif, system-ui, sans-serif`,sa=`11px ui-sans-serif, system-ui, sans-serif`,ca=`10px ui-sans-serif, system-ui, sans-serif`,la=16,ua=2.35,da=2.75,fa=18,pa=28;function ma(e,t,n,r){let i=`${n}|${r}`,a=t?.measure.get(i);if(a!==void 0)return a;e.font=n;let o=0;try{o=e.measureText(r).width}catch{o=r.length*6}return t&&(t.measure.size>8192&&t.measure.clear(),t.measure.set(i,o)),o}function ha(e,t,n){return e<=t?0:e>=n?1:(e-t)/(n-t)}function ga(e,t){let{cam:n,model:r,palette:i}=t,a=t.labels,o=[];for(let t of r.districts){if(t.displayLabel===void 0||(t.rect.w+t.rect.h)*n.scale<40)continue;let r=t.depth<=1?1-.85*ha(n.scale,1.6,2.6):1-.85*ha(n.scale,2,3.2);if(r<=.05)continue;let i=t.depth<=1?oa:aa,s=ma(e,a,i,t.displayLabel),c=t.labelPlate?{x:t.labelPlate.x,y:t.labelPlate.y}:{x:t.rect.x,y:t.rect.y},l=L(n,I(c.x,c.y).u,I(c.x,c.y).v);o.push({id:`d:${t.id}`,text:t.displayLabel,priority:3+t.depth,x:l.x,y:l.y-8,w:s+12,h:17,alpha:r,kind:`district`,font:i})}for(let r of t.geom.order){let i=t.geom.geoms[r],s=i.block;if(s.state===`tombstoned`||!Qn(n,i,t.viewW,t.viewH))continue;let c=s.id===t.selectedId,l=s.id===t.hoverId,u=s.landmark===!0;if(!c&&!l&&!u){if(t.tier!==`street`||s.rect.w*n.scale*2<44)continue;let r=.9*ha(n.scale,1.2,1.6);if(r<=.05)continue;let i=ma(e,a,sa,s.label),c=L(n,I(s.rect.x+s.rect.w,s.rect.y+s.rect.h).u,I(s.rect.x+s.rect.w,s.rect.y+s.rect.h).v);o.push({id:`b:${s.id}`,text:s.label,priority:10,x:c.x-i/2,y:c.y+2,w:i,h:12,alpha:r,kind:`block`,font:sa});continue}let d=sa,f=ma(e,a,d,s.label),p=I(s.rect.x+s.rect.w/2,s.rect.y+s.rect.h/2),m=L(n,p.u,p.v);o.push({id:`b:${s.id}`,text:s.label,priority:c?0:l?1:2,x:m.x-f/2,y:m.y-i.hIso*n.scale-18,w:f,h:13,alpha:1,kind:`landmark`,font:d})}let s=t.ageLens?0:ha(n.scale,ua,da);if(s>.05){let i=new Set(r.blocks.filter(e=>e.state===`live`&&!e.phantom&&re(e)).map(e=>e.id));for(let c of r.buildings){if(!i.has(c.blockId)||(c.rect.w+c.rect.h)*n.scale<fa)continue;let r=$n(n,c);if(r.x<-80||r.x>t.viewW+80||r.y<-40||r.y>t.viewH+40)continue;let l=_a(c.label),u=ma(e,a,ca,l),d=Math.min(180,Math.max(20,u+10)),f=Math.max(2,Math.min(t.viewW-d-2,r.x-d/2));o.push({id:`s:${c.id}`,text:l,priority:va(c.kind,c.lines),x:f,y:r.y-la-5,w:d,h:la,alpha:s,kind:`symbol`,font:ca,anchorX:r.x,anchorY:r.y})}}let c=e=>a?.accepted.has(e.id)?e.priority-.5:e.priority;o.sort((e,t)=>c(e)-c(t)||(e.id<t.id?-1:1));let l=[],u=new Set;for(let e of o){let t=a?.accepted.has(e.id)?2:0,n=!1;for(let r of l)if(e.x+t<r.x+r.w&&e.x+e.w-t>r.x&&e.y+t<r.y+r.h&&e.y+e.h-t>r.y){n=!0;break}n||(l.push(e),u.add(e.id))}a&&(a.accepted=u),e.textBaseline=`top`;for(let t of l)e.globalAlpha=t.alpha,e.font=t.font,t.kind===`district`?(e.fillStyle=i.labelPlate,F(e,t.x,t.y,t.w,t.h,3),e.fill(),e.strokeStyle=i.labelPlateStroke,e.lineWidth=1,F(e,t.x,t.y,t.w,t.h,3),e.stroke(),e.fillStyle=i.districtLabel,e.fillText(t.text,t.x+6,t.y+3,t.w-12)):t.kind===`symbol`?(e.strokeStyle=i.labelPlateStroke,e.lineWidth=.8,e.beginPath(),e.moveTo(Math.max(t.x+4,Math.min(t.x+t.w-4,t.anchorX??t.x+t.w/2)),t.y+t.h),e.lineTo(t.anchorX??t.x+t.w/2,t.anchorY??t.y+t.h+5),e.stroke(),e.fillStyle=i.labelPlate,F(e,t.x,t.y,t.w,t.h,3),e.fill(),e.strokeStyle=i.labelPlateStroke,F(e,t.x,t.y,t.w,t.h,3),e.stroke(),e.fillStyle=i.label,e.fillText(t.text,t.x+5,t.y+2,t.w-10)):t.kind===`landmark`?(e.strokeStyle=i.ground,e.lineWidth=3,e.strokeText(t.text,t.x,t.y,t.w+4),e.fillStyle=i.label,e.fillText(t.text,t.x,t.y,t.w+4),e.strokeStyle=i.districtLabel,e.lineWidth=1,e.beginPath(),e.moveTo(t.x+t.w/2,t.y+t.h+1),e.lineTo(t.x+t.w/2,t.y+t.h+5),e.stroke()):(e.strokeStyle=i.ground,e.lineWidth=3,e.strokeText(t.text,t.x,t.y,t.w+4),e.fillStyle=i.label,e.fillText(t.text,t.x,t.y,t.w+4));e.globalAlpha=1}function _a(e){return e.length<=pa?e:`${e.slice(0,pa-1)}…`}function va(e,t){let n=e.toLowerCase(),r=/function|method|constructor|procedure/.test(n)?0:/class|interface|struct|enum|trait|type/.test(n)?1:2,i=Math.min(.2,Math.max(0,t??0)/2e3);return 20+r-i}var ya={added:`#3fb950`,modified:`#d29922`,deleted:`#f85149`,renamed:`#a371f7`},ba=`#58a6ff`;function xa(e,t){let{cam:n,model:r,palette:i,viewW:a,viewH:o}=t;if(!r.overlay||r.overlay.changedBlocks.length===0)return;let s=new Map(r.overlay.changedBlocks.map(e=>[e.blockId,e])),c=new Map(t.geom.geoms.map(e=>[e.block.id,e]));if(e.fillStyle=i.ground,e.globalAlpha=.62,e.fillRect(0,0,a,o),e.globalAlpha=1,t.affectedIds&&t.affectedIds.size>0)for(let r of t.affectedIds){if(s.has(r))continue;let t=c.get(r);if(!t||!Qn(n,t,a,o))continue;let i=Hn(t.block.rect),l=t.hIso*n.scale,u=[i.n,i.e,i.s,i.w].map(e=>{let t=L(n,e.u,e.v);return{x:t.x,y:t.y-l}});e.fillStyle=ba,e.globalAlpha=.18,Sa(e,u),e.fill(),e.globalAlpha=.7,e.strokeStyle=ba,e.lineWidth=1,Sa(e,u),e.stroke(),e.globalAlpha=1}for(let r of t.geom.geoms){let t=s.get(r.block.id);if(!t||!Qn(n,r,a,o))continue;let i=ya[t.change]??`#888888`,c=R(n,r.block.rect,r.hIso);e.fillStyle=i,e.globalAlpha=r.block.phantom?.45:.85,ar(e,c),e.fill(),e.globalAlpha=1,e.save(),e.shadowColor=i,e.shadowBlur=8,e.strokeStyle=i,e.lineWidth=2,r.block.phantom&&e.setLineDash([4,3]),ar(e,c),e.stroke(),e.restore()}}function Sa(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.closePath()}var Ca=40;function wa(e,t){let{cam:n,model:r,palette:i}=t;if(t.tier===`city`||r.roads.length===0)return;let a=new Map;for(let e of r.blocks)a.set(e.id,e.rect);if(t.selectedId){let o=kn(r,t.selectedId,a);if(e.strokeStyle=i.selected,e.globalAlpha=.9,e.lineJoin=`round`,o){for(let t of o)if(!(t.points.length<2)){e.lineWidth=t.bidirectional?2.4:2,e.beginPath();for(let r=0;r<t.points.length;r++){let i=t.points[r],a=I(i.x,i.y),o=L(n,a.u,a.v);r===0?e.moveTo(o.x,o.y):e.lineTo(o.x,o.y)}e.stroke()}}else Ta(e,t,t.selectedId,a,2,.9);e.globalAlpha=1}t.hoverId&&t.hoverId!==t.selectedId&&Ta(e,t,t.hoverId,a,1.5,.35)}function Ta(e,t,n,r,i,a){let{cam:o,model:s,palette:c}=t;e.strokeStyle=c.selected,e.globalAlpha=a,e.lineWidth=i;let l=0;e.beginPath();for(let t of s.roads){if(t.a!==n&&t.b!==n)continue;if(l>=Ca)break;let i=r.get(t.a),a=r.get(t.b);if(!i||!a)continue;let s=I(i.x+i.w/2,i.y+i.h/2),c=I(a.x+a.w/2,a.y+a.h/2),u=L(o,s.u,s.v),d=L(o,c.u,c.v);e.moveTo(u.x,u.y),e.lineTo(d.x,d.y),l+=1}e.stroke(),e.globalAlpha=1}function Ea(e,t){e.save(),jr(e,t),zi(e,t),na(e,t),wa(e,t),ga(e,t),xa(e,t),e.restore()}var Da=[`tree1`,`tree2`,`tree3`,`shrub`,`weed`,`dryPatch`,`deadTree`,`rubble1`,`rubble2`],Oa=24,ka=new Map;function Aa(e,t){let n=t>1.5?2:1,r=`${e.dark?`dark`:`light`}|${n}`,i=ka.get(r);if(i!==void 0)return i;let a=ja(e,n*2);return ka.set(r,a),a}function ja(e,t){let n=Oa*t,r,i;try{r=document.createElement(`canvas`),r.width=n*Da.length,r.height=n,i=r.getContext(`2d`)}catch{return null}if(!i)return null;let a=e.dark?`hsl(135 28% 30%)`:`hsl(120 35% 52%)`,o=e.dark?`hsl(150 30% 24%)`:`hsl(95 38% 45%)`,s=e.dark?`hsl(140 24% 27%)`:`hsl(110 30% 60%)`,c=e.dark?`hsl(30 25% 25%)`:`hsl(30 35% 40%)`,l=e.dark?`hsl(60 20% 28%)`:`hsl(65 35% 55%)`,u=e.dark?`hsl(38 25% 30%)`:`hsl(42 45% 70%)`,d=e.dark?`hsl(30 12% 32%)`:`hsl(30 15% 45%)`,f={};Da.forEach((e,t)=>{f[e]=t});let p=(e,r)=>{i.save(),i.translate(e*n+n/2,n/2),i.scale(t,t),r(i),i.restore()},m=(e,t,n,r)=>{e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill()},h=(e,t,n)=>{e.fillStyle=c,e.fillRect(-1,2,2,6),e.fillStyle=t,m(e,0,-1,n),e.fillStyle=`rgba(255, 255, 255, 0.14)`,m(e,-n*.3,-1-n*.3,n*.45)};p(f.tree1,e=>h(e,a,7)),p(f.tree2,e=>h(e,o,6)),p(f.tree3,e=>{e.fillStyle=c,e.fillRect(-1,5,2,4),e.fillStyle=o;for(let[t,n]of[[7,5],[5.5,1],[4,-3]])e.beginPath(),e.moveTo(0,n-6),e.lineTo(-t,n),e.lineTo(t,n),e.closePath(),e.fill()}),p(f.shrub,e=>{e.fillStyle=s,m(e,-2.5,2,3.5),m(e,2.5,2,3),m(e,0,-1,3.5)}),p(f.weed,e=>{e.strokeStyle=l,e.lineWidth=1.2,e.beginPath();for(let[t,n]of[[-3,-1.5],[0,.5],[3,2]])e.moveTo(t,6),e.quadraticCurveTo(t+n,0,t+n*1.6,-4);e.stroke()}),p(f.dryPatch,e=>{e.fillStyle=u,e.beginPath(),e.ellipse(0,0,9,6,.4,0,Math.PI*2),e.fill(),e.fillStyle=`rgba(0, 0, 0, 0.08)`,e.beginPath(),e.ellipse(2,1,4,2.5,.2,0,Math.PI*2),e.fill()}),p(f.deadTree,e=>{e.strokeStyle=d,e.lineWidth=1.6,e.beginPath(),e.moveTo(0,8),e.lineTo(0,-2),e.moveTo(0,0),e.lineTo(-4,-5),e.moveTo(0,-2),e.lineTo(3,-7),e.moveTo(0,3),e.lineTo(4,-1),e.stroke()});let g=(t,n)=>{t.fillStyle=e.rubble;for(let[e,r,i]of n)t.fillRect(e,r,i,i)};return p(f.rubble1,e=>g(e,[[-6,-2,4],[-1,2,3],[3,-4,3.5],[4,3,2.5]])),p(f.rubble2,e=>g(e,[[-5,3,3],[-4,-5,2.5],[1,-1,4],[6,-4,2]])),{canvas:r,cell:n,index:f}}var $=n();function Ma(){try{return window.localStorage.getItem(`gezel.mapRenderer`)===`flat`?`flat`:`iso`}catch{return`iso`}}function Na(e){return e.closest(`[data-theme="dark"]`)!=null||!e.closest(`[data-theme="light"]`)&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches}function Pa({model:e,selectedId:t,onSelect:n,affectedIds:r,ageLens:i,renderer:a}){let o=(0,h.useRef)(null),s=(0,h.useRef)(null),c=(0,h.useRef)({scale:1,offsetX:0,offsetY:0}),l=(0,h.useRef)({w:0,h:0}),u=(0,h.useRef)(0),d=(0,h.useRef)(0),f=(0,h.useRef)(-1/0),p=(0,h.useRef)(!1),m=(0,h.useRef)(()=>!1),g=(0,h.useRef)(()=>{}),_=(0,h.useRef)(null),[y,b]=(0,h.useState)(null),[C,w]=(0,h.useState)(null),T=(0,h.useRef)(()=>{}),ie=(0,h.useRef)(ia()),E=a??Ma(),D=(0,h.useMemo)(()=>e.blocks.filter(e=>Xt(e)!==null),[e]),ae=(0,h.useMemo)(()=>new Set(D.map(e=>e.id)),[D]),oe=(0,h.useMemo)(()=>Bt(e).animated,[e]),se=(0,h.useMemo)(()=>{let t=qe(e);return new Set(e.blocks.filter(e=>e.state===`live`&&!e.phantom&&e.health?.zone===`industrial`&&(t.get(e.id)?.chimneys??0)>0).map(e=>e.id))},[e]);T.current=()=>{let n=s.current,a=n?.getContext(`2d`);if(!n||!a)return;let{w:o,h:u}=l.current,f=window.devicePixelRatio||1;a.setTransform(f,0,0,f,0,0);let p=de(Na(n)),m={cam:c.current,model:e,palette:p,tier:v(c.current.scale),viewW:o,viewH:u,selectedId:t,hoverId:y,atlas:Aa(p,f),animationTime:d.current,...r?{affectedIds:r}:{},...i?{ageLens:i}:{}};E===`iso`?Ea(a,{...m,geom:Xn(e),labels:ie.current}):Nn(a,m)},m.current=()=>{if(p.current||document.visibilityState!==`visible`||i)return!1;let t=v(c.current.scale);if(t===`city`)return!1;let{w:n,h:r}=l.current,a=c.current;return D.length>0&&(E===`iso`?Xn(e).geoms.some(e=>ae.has(e.block.id)&&Qn(a,e,n,r)):D.some(e=>S(a,e.rect,n,r)))?!0:E!==`iso`||t!==`street`?!1:oe.some(e=>Un(a,e.reservation,n,r))?!0:se.size>0&&Xn(e).geoms.some(e=>se.has(e.block.id)&&Qn(a,e,n,r))},g.current=e=>{if(u.current=0,m.current()&&e-f.current<1e3/30){u.current=requestAnimationFrame(e=>g.current(e));return}f.current=e,d.current=p.current?0:e,T.current(),m.current()&&(u.current=requestAnimationFrame(e=>g.current(e)))};let O=(0,h.useCallback)(()=>{u.current||=requestAnimationFrame(e=>g.current(e))},[]);(0,h.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),t=()=>{p.current=e?.matches??!1,O()},n=()=>O();return t(),e?.addEventListener(`change`,t),document.addEventListener(`visibilitychange`,n),()=>{e?.removeEventListener(`change`,t),document.removeEventListener(`visibilitychange`,n)}},[O]),(0,h.useEffect)(()=>()=>{u.current&&cancelAnimationFrame(u.current),u.current=0},[]),(0,h.useEffect)(()=>{let e=o.current,t=s.current;if(!e||!t)return;let n=()=>{let n=e.getBoundingClientRect(),r=window.devicePixelRatio||1;l.current={w:n.width,h:n.height},t.width=Math.max(1,Math.round(n.width*r)),t.height=Math.max(1,Math.round(n.height*r)),t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,O()};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[O]),(0,h.useEffect)(()=>{let{w:t,h:n}=l.current;c.current=E===`iso`?Kn(e.bounds,Xn(e).maxHIso,t||800,n||600):te(e.bounds,t||800,n||600),w(null),O()},[e,E,O]),(0,h.useEffect)(()=>{O()},[t,y,i,O]);let ce=(0,h.useCallback)((t,n)=>{let r=c.current;if(E===`iso`)return ir(Xn(e),r,t,n);let i=x(r,t),a=ee(r,n);for(let t=e.blocks.length-1;t>=0;t--){let n=e.blocks[t];if(i>=n.rect.x&&i<=n.rect.x+n.rect.w&&a>=n.rect.y&&a<=n.rect.y+n.rect.h)return n}return null},[e,E]),k=(0,h.useCallback)((t,n,r)=>!t||E!==`iso`||t.state===`tombstoned`||!re(t)||v(c.current.scale)!==`street`?null:rr(e,t.id,c.current,n,r),[e,E]);return(0,h.useEffect)(()=>{let e=s.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=Math.exp(-t.deltaY*.0015);c.current=ne(c.current,r,t.clientX-n.left,t.clientY-n.top),w(null),O()};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[O]),(0,$.jsxs)(`div`,{ref:o,className:`filemap-canvas-wrap`,children:[(0,$.jsx)(`canvas`,{ref:s,className:`filemap-canvas`,onPointerDown:e=>{e.target.setPointerCapture(e.pointerId),_.current={x:e.clientX,y:e.clientY},w(null)},onPointerMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(_.current){let t=e.clientX-_.current.x,n=e.clientY-_.current.y;_.current={x:e.clientX,y:e.clientY};let r=c.current;c.current={...r,offsetX:r.offsetX-t/r.scale,offsetY:r.offsetY-n/r.scale},O();return}let n=e.clientX-t.left,r=e.clientY-t.top,i=ce(n,r);b(i?.id??null);let a=k(i,n,r);w(e=>{if(!a)return e===null?e:null;if(e?.building===a)return e;let t=$n(c.current,a);return{building:a,x:t.x,y:t.y}})},onPointerUp:e=>{let t=_.current;_.current=null;let r=e.currentTarget.getBoundingClientRect();if(t){let t=e.clientX-r.left,i=e.clientY-r.top,a=ce(t,i);n(a,k(a,t,i))}},onPointerLeave:()=>{b(null),w(null)},style:{cursor:_.current?`grabbing`:y?`pointer`:`grab`,touchAction:`none`}}),C&&(0,$.jsxs)(`div`,{className:`filemap-symtip`,style:{left:C.x,top:C.y},children:[(0,$.jsx)(`strong`,{children:C.building.label}),(0,$.jsxs)(`span`,{children:[C.building.kind,C.building.lines===void 0?``:` · ${C.building.lines} ${C.building.lines===1?`line`:`lines`}`]})]})]})}var Fa={tsx:`typescript`,jsx:`javascript`,c:`cpp`,c_sharp:`csharp`,bash:`shell`,text:`plaintext`,toml:`ini`,properties:`ini`,yml:`yaml`};function Ia(e){let t=e?.trim().toLowerCase();if(t)return Fa[t]??t}var La=i(`filemap`),Ra=()=>void 0;function za(e){let t=e.line==null?``:` (Line ${e.line})`;return`[${e.severity}] ${e.category} — ${e.message}${t}`}function Ba(e){let t=e.slice(0,4096);if(!t)return!1;let n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);(r===65533||r<9||r>13&&r<32)&&n++}return n/t.length>.1}var Va={added:`added`,modified:`modified`,deleted:`deleted`,renamed:`renamed`},Ha={residential:`residential`,commercial:`commercial`,civic:`civic landmark`,industrial:`industrial`},Ua={lush:`lush`,tidy:`tidy`,plain:`plain`,scruffy:`scruffy`,blighted:`blighted`},Wa=[{value:`core`,label:`Code`},{value:`tests`,label:`Tests`},{value:`all`,label:`All`}];function Ga({projectId:e}){let[t,n]=(0,h.useState)(null),[i,a]=(0,h.useState)(!1),[u,d]=(0,h.useState)(null),[p,g]=(0,h.useState)(null),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(`core`),[x,ee]=(0,h.useState)([]),[te,ne]=(0,h.useState)(null),[S,C]=(0,h.useState)(!1),[re,w]=(0,h.useState)(()=>Ma()),[T,ie]=(0,h.useState)(null),[E,D]=(0,h.useState)([]),[ae,oe]=(0,h.useState)(!1),[se,O]=(0,h.useState)(null),[ce,k]=(0,h.useState)(null),[le,ue]=(0,h.useState)(null),[de,fe]=(0,h.useState)(0),[A,pe]=(0,h.useState)(null),[me,he]=(0,h.useState)(!1),[ge,_e]=(0,h.useState)(!1),[ve,ye]=(0,h.useState)(!1),[be,xe]=(0,h.useState)(null),j=(0,h.useRef)(new Map),Se=(0,h.useCallback)((e,t=1)=>{if(e&&window.__GEZEL__?.openWorkspaceFile){window.__GEZEL__.openWorkspaceFile(e.id,Math.max(1,t));return}g(e),v(e?{path:e.id,line:Math.max(1,t)}:null)},[]),Ce=(0,h.useCallback)((e,t)=>{Se(e,t?.lineStart??1)},[Se]),M=p?.id??null;(0,h.useEffect)(()=>{if(ye(!1),!M){ie(null);return}let t=!1;return ie({path:M,kind:`loading`}),c.readProjectWorkspaceFile(e,M).then(e=>{t||ie(Ba(e.content)?{path:M,kind:`binary`}:{path:M,kind:`ready`,content:e.content})}).catch(e=>{t||ie({path:M,kind:`error`,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[M,e]),(0,h.useEffect)(()=>{if(!M){D([]),O(null),ue(null);return}let t=!1;return oe(!0),ue(null),c.toolScanFindings(e,{path:M,maxResults:100}).then(e=>{if(t)return;let n=e.findings.filter(e=>e.path===M);D(n),O(e=>e&&n.some(t=>t.fingerprint===e)?e:n[0]?.fingerprint??null);let r=n.find(e=>e.line!=null)?.line;r&&v({path:M,line:r})}).catch(e=>{t||(D([]),ue(e instanceof Error?e.message:String(e)))}).finally(()=>{t||oe(!1)}),()=>{t=!0}},[M,e,de]),(0,h.useEffect)(()=>{if(!M){pe(null),he(!1),_e(!1);return}let t=!1;return pe(null),he(!1),_e(!1),c.toolFileReview(e,{path:M}).then(e=>{t||(pe(e.review??null),he(e.pending===!0),_e(e.eligible===!1))}).catch(e=>{t||La.debug(`file-review unavailable`,e)}),()=>{t=!0}},[M,e]),(0,h.useEffect)(()=>{if(!M){xe(null);return}let t=j.current.get(M);if(t){xe({path:M,value:t});return}let n=!1;return xe(null),c.toolFileContext(e,{path:M}).then(e=>{if(n)return;let t=o(e);if(j.current.size>=20){let e=j.current.keys().next().value;e!==void 0&&j.current.delete(e)}j.current.set(M,t),xe({path:M,value:t})}).catch(e=>{n||La.debug(`file-context unavailable`,e)}),()=>{n=!0}},[M,e,de]);let N=(0,h.useCallback)(()=>{a(!0),d(null),j.current.clear(),c.toolFileMap(e,{scope:y,...te?{pr:te}:{}}).then(e=>{n(e),g(t=>t?e.blocks.find(e=>e.id===t.id)??null:null)}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>a(!1))},[e,y,te]);(0,h.useEffect)(()=>{Se(null),N()},[N,Se]),(0,h.useEffect)(()=>{let t=!1;return c.listProjectGitHubPulls(e).then(e=>{t||ee(e.pulls)}).catch(()=>{t||ee([])}),()=>{t=!0}},[e]);let we=(0,h.useMemo)(()=>new Map((t?.overlay?.changedBlocks??[]).map(e=>[e.blockId,e])),[t]),Te=(0,h.useMemo)(()=>{let e=t?.overlay;if(!t||!e||e.changedBlocks.length===0)return;let n=new Map,r=(e,t)=>{let r=n.get(e);r?r.push(t):n.set(e,[t])};for(let e of t.roads)r(e.b,e.a),e.bidirectional&&r(e.a,e.b);let i=new Set(e.changedBlocks.map(e=>e.blockId)),a=new Set,o=[...i];for(let e=0;e<3&&o.length>0;e++){let e=[];for(let t of o)for(let r of n.get(t)??[])i.has(r)||a.has(r)||(a.add(r),e.push(r));o=e}return a.size>0?a:void 0},[t]),Ee=(0,h.useMemo)(()=>{if(!t)return null;let e=t.blocks.filter(e=>e.state!==`tombstoned`&&!e.phantom);return{files:e.length,folders:t.districts.length,roads:t.roads.length,symbols:e.reduce((e,t)=>e+t.buildingCount,0)}},[t]),De=(0,h.useMemo)(()=>{if(!p||!t)return[];let e=new Set;for(let n of t.roads)n.a===p.id?e.add(n.b):n.b===p.id&&e.add(n.a);let n=new Map(t.blocks.map(e=>[e.id,e]));return[...e].sort().map(e=>n.get(e)).filter(e=>!!e)},[p,t]),Oe=(0,h.useCallback)(e=>{let n=s(e);if(n?.kind!==`file`||!t)return!1;let r=t.blocks.find(e=>e.id===n.path);return r&&Se(r,n.line),!0},[t,Se]),ke=(0,h.useCallback)(e=>{O(e.fingerprint),e.line!=null&&v({path:e.path,line:e.line})},[]),Ae=(0,h.useCallback)(async t=>{k({fingerprint:t.fingerprint,kind:`resolve`}),ue(null);try{await c.resolveSecurityFinding(e,{fingerprint:t.fingerprint}),D(e=>e.filter(e=>e.fingerprint!==t.fingerprint)),O(null),j.current.delete(t.path),fe(e=>e+1),N()}catch(e){ue(e instanceof Error?e.message:String(e))}finally{k(null)}},[N,e]),je=(0,h.useCallback)(async t=>{k({fingerprint:t.fingerprint,kind:`delegate`}),ue(null);try{let n=await c.delegateSecurityFinding(e,{fingerprint:t.fingerprint});D(e=>e.map(e=>e.fingerprint===t.fingerprint?n.finding:e)),O(t.fingerprint)}catch(e){ue(e instanceof Error?e.message:String(e))}finally{k(null)}},[e]);(0,h.useEffect)(()=>{let e=[...new Set(E.flatMap(e=>e.taskRef?[e.taskRef]:[]))];if(e.length===0)return;let t=!1,n=async()=>{let n=await Promise.all(e.map(e=>c.getTaskByRef(e).catch(()=>null)));t||n.some(e=>e?.status===`complete`||e?.status===`canceled`)&&(j.current.clear(),fe(e=>e+1),N())},r=window.setInterval(()=>void n(),5e3);return n(),()=>{t=!0,window.clearInterval(r)}},[E,N]);let Me=A?r(A):null;return(0,$.jsxs)(`section`,{className:`filemap-view`,children:[(0,$.jsxs)(`header`,{className:`filemap-header`,children:[(0,$.jsxs)(`div`,{className:`filemap-title`,children:[(0,$.jsx)(`strong`,{children:`Village`}),Ee&&(0,$.jsxs)(`span`,{className:`filemap-stats`,children:[Ee.files,` files · `,Ee.folders,` neighborhoods · `,Ee.roads,` roads ·`,` `,Ee.symbols,` symbols`]}),t?.overlay&&(0,$.jsxs)(`span`,{className:`filemap-overlay-stat`,children:[`PR #`,t.overlay.prNumber,` · `,t.overlay.changedBlocks.length,` changed`,Te?` · ${Te.size} affected`:``]})]}),(0,$.jsxs)(`div`,{className:`filemap-actions`,children:[x.length>0&&(0,$.jsxs)(`select`,{className:`filemap-pr`,"aria-label":`Overlay a pull request`,value:te??``,onChange:e=>ne(e.target.value?Number(e.target.value):null),children:[(0,$.jsx)(`option`,{value:``,children:`No PR overlay`}),x.map(e=>(0,$.jsxs)(`option`,{value:e.number,children:[`#`,e.number,` `,e.title]},e.number))]}),(0,$.jsx)(`fieldset`,{className:`filemap-scope`,"aria-label":`Village scope`,children:Wa.map(e=>(0,$.jsx)(`button`,{type:`button`,className:y===e.value?`active`:``,"aria-pressed":y===e.value,onClick:()=>b(e.value),children:e.label},e.value))}),(0,$.jsx)(`fieldset`,{className:`filemap-scope`,"aria-label":`Color lens`,children:(0,$.jsx)(`button`,{type:`button`,className:S?`active`:``,"aria-pressed":S,title:`Color blocks by how recently they were added — the evolution lens`,onClick:()=>C(e=>!e),children:`Age`})}),(0,$.jsx)(`fieldset`,{className:`filemap-scope`,"aria-label":`Renderer`,children:(0,$.jsx)(`button`,{type:`button`,className:re===`iso`?`active`:``,"aria-pressed":re===`iso`,title:`Isometric village view; toggle off for the flat top-down plan`,onClick:()=>w(e=>{let t=e===`iso`?`flat`:`iso`;try{window.localStorage.setItem(`gezel.mapRenderer`,t)}catch{}return t}),children:`3D`})}),(0,$.jsx)(`button`,{type:`button`,className:`filemap-refresh`,onClick:N,disabled:i,children:i?`Building…`:`Rebuild`})]})]}),(0,$.jsx)(`div`,{className:`filemap-body`,children:u?(0,$.jsxs)(`div`,{className:`filemap-empty`,children:[`Couldn’t build the village: `,u]}):t&&!t.indexed?(0,$.jsx)(`div`,{className:`filemap-empty`,children:`This project hasn’t been indexed yet. The village appears once the workspace has been scanned.`}):t&&t.blocks.length===0&&!i?(0,$.jsx)(`div`,{className:`filemap-empty`,children:y===`tests`?`No test files found.`:`No files to build a village from yet.`}):t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pa,{model:t,selectedId:p?.id??null,onSelect:Ce,...Te?{affectedIds:Te}:{},renderer:re,ageLens:S}),p?(0,$.jsxs)(`aside`,{className:`filemap-inspector filemap-fileview open`,children:[(0,$.jsxs)(`header`,{className:`filemap-fileview-head`,children:[(0,$.jsxs)(`div`,{className:`filemap-fileview-titlerow`,children:[(0,$.jsx)(`span`,{className:`filemap-fileview-name`,title:p.id,children:p.label}),(0,$.jsxs)(`div`,{className:`filemap-fileview-actions`,children:[De.length>0&&(0,$.jsxs)(`button`,{type:`button`,className:`filemap-fileview-connected-btn`,"aria-expanded":ve,onClick:()=>ye(e=>!e),children:[(0,$.jsxs)(`span`,{children:[`Connected (`,De.length,`)`]}),(0,$.jsx)(l,{})]}),(0,$.jsx)(`button`,{type:`button`,className:`filemap-fileview-close`,onClick:()=>Se(null),"aria-label":`Close`,children:`×`})]}),ve&&De.length>0&&(0,$.jsx)(`div`,{className:`filemap-fileview-menu`,children:(0,$.jsx)(`ul`,{children:De.slice(0,60).map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,title:e.id,onClick:()=>{Se(e),ye(!1)},children:e.label})},e.id))})})]}),(0,$.jsxs)(`div`,{className:`filemap-fileview-stats`,children:[(0,$.jsx)(`span`,{className:`filemap-fileview-path`,children:p.id}),(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[Math.round(p.weight),` lines`]}),(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[p.buildingCount,` symbols`]}),p.lang&&(0,$.jsx)(`span`,{className:`filemap-chip`,children:p.lang}),re===`iso`&&(0,$.jsx)(`span`,{className:`filemap-chip`,children:Ge(He(p))}),p.health&&(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[Ha[p.health.zone],` · `,Ua[p.health.vibe]]}),p.health&&(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[`↓`,p.health.fanIn,` imported`]}),p.health&&(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[`↑`,p.health.fanOut,` imports`]}),p.health&&p.health.findings>0&&(0,$.jsxs)(`span`,{className:`filemap-chip filemap-chip-warn`,children:[p.health.findings,` finding`,p.health.findings>1?`s`:``,p.health.maxSeverity?` (max ${p.health.maxSeverity})`:``]}),p.placedAt&&(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[`since `,p.placedAt.slice(0,10)]}),we.get(p.id)&&(0,$.jsxs)(`span`,{className:`filemap-chip`,children:[`PR: `,Va[we.get(p.id).change],` `,(0,$.jsxs)(`span`,{className:`filemap-add`,children:[`+`,we.get(p.id).additions]}),` `,(0,$.jsxs)(`span`,{className:`filemap-del`,children:[`−`,we.get(p.id).deletions]})]})]})]}),(ae||E.length>0||le)&&(0,$.jsxs)(`section`,{className:`filemap-findings`,"aria-label":`Findings in this file`,children:[(0,$.jsxs)(`div`,{className:`filemap-findings-heading`,children:[(0,$.jsxs)(`strong`,{children:[E.length,` open finding`,E.length===1?``:`s`]}),ae&&(0,$.jsx)(`span`,{children:`Checking…`})]}),E.map(e=>{let t=e.fingerprint===se,n=ce?.fingerprint===e.fingerprint&&ce.kind===`resolve`,r=ce?.fingerprint===e.fingerprint&&ce.kind===`delegate`;return(0,$.jsxs)(`article`,{className:`filemap-finding-card${t?` active`:``}`,"data-severity":e.severity,children:[(0,$.jsxs)(`button`,{type:`button`,className:`filemap-finding-summary`,"aria-pressed":t,onClick:()=>ke(e),children:[(0,$.jsx)(`span`,{className:`filemap-finding-severity`,children:e.severity}),(0,$.jsx)(`strong`,{children:e.title}),(0,$.jsx)(`span`,{className:`filemap-finding-location`,children:e.line==null?`Whole file`:`Line ${e.line}`})]}),t&&(0,$.jsxs)(`div`,{className:`filemap-finding-detail`,children:[e.evidence&&(0,$.jsx)(`code`,{children:e.evidence}),(0,$.jsxs)(`span`,{children:[e.source,` · `,e.ruleId,` · `,e.category]}),e.taskRef&&(0,$.jsxs)(`span`,{className:`filemap-finding-task`,children:[`Developer gezel working ·`,` `,(0,$.jsx)(`button`,{type:`button`,className:`link-button filemap-finding-task-link`,"aria-label":`Open task ${e.taskRef}`,onClick:()=>f({kind:`task`,ref:e.taskRef}),children:e.taskRef})]}),(0,$.jsxs)(`div`,{className:`filemap-finding-actions`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Ae(e),disabled:ce!=null,children:n?`Resolving…`:`Mark resolved`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void je(e),disabled:ce!=null||e.status===`in_progress`,children:r?`Finding a developer…`:e.status===`in_progress`?`Developer working`:`Ask a developer gezel`})]})]})]},e.fingerprint)}),le&&(0,$.jsx)(`p`,{className:`filemap-finding-error error`,children:le})]}),(A||me||ge)&&(0,$.jsx)(`section`,{className:`filemap-review`,"aria-label":`Boekwachter review`,children:A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`filemap-review-heading`,children:[(0,$.jsxs)(`strong`,{children:[`Boekwachter review · `,A.health,`/10`]}),(0,$.jsx)(`span`,{className:`filemap-review-reason`,children:A.healthReason})]}),A.notesMd&&(0,$.jsx)(`div`,{className:`filemap-review-notes`,children:(0,$.jsx)(m,{value:A.notesMd,readOnly:!0,minHeight:`0`,onCommit:Ra},`${p.id}:review-notes`)}),A.issues.length>0&&(0,$.jsx)(`ul`,{className:`filemap-review-issues`,children:A.issues.map((e,t)=>{let n=e.line;return(0,$.jsx)(`li`,{children:n==null?(0,$.jsx)(`span`,{className:`filemap-review-issue`,children:za(e)}):(0,$.jsx)(`button`,{type:`button`,className:`filemap-review-issue`,onClick:()=>v({path:p.id,line:n}),children:za(e)})},`${e.category}:${e.message}:${t}`)})}),(0,$.jsx)(`p`,{className:`filemap-review-advice`,children:`Leads from a background model pass — its opinion, not a verdict.`}),Me&&(0,$.jsx)(`p`,{className:`filemap-review-provenance`,children:Me})]}):ge?(0,$.jsx)(`p`,{className:`filemap-review-pending`,children:`This file type isn’t reviewed.`}):(0,$.jsx)(`p`,{className:`filemap-review-pending`,children:`Not reviewed yet — the boekwachter studies files when idle or during Night Shift.`})}),(0,$.jsx)(`div`,{className:`filemap-fileview-body`,children:!T||T.kind===`loading`?(0,$.jsxs)(`div`,{className:`filemap-empty`,children:[`Loading `,p.label,`…`]}):T.kind===`error`?(0,$.jsxs)(`div`,{className:`filemap-empty`,children:[`Couldn’t read this file: `,T.error]}):T.kind===`binary`?(0,$.jsx)(`div`,{className:`filemap-empty`,children:`Binary file — no preview.`}):(0,$.jsx)(Ka,{path:T.path,content:T.content,language:Ia(p.lang),sourceReveal:_?.path===T.path?_:void 0,findings:E,activeFinding:se,codeContext:be?.path===T.path?be.value:null,onContextLink:Oe})})]}):(0,$.jsx)(`p`,{className:`filemap-hint filemap-hint-float`,children:`Scroll to zoom, drag to pan. Each building is a file; click one to open it.`})]}):(0,$.jsx)(`div`,{className:`filemap-empty`,children:i?`Building the village…`:``})})]})}function Ka({path:e,content:t,language:n,sourceReveal:r,findings:i,activeFinding:a,codeContext:o,onContextLink:s}){let c=p(),l=(0,h.useMemo)(()=>{if(!(!o||o.sections.length===0&&!o.fileTop))return{...o.fileTop?{fileTop:o.fileTop}:{},sections:o.sections,linkSchemes:[`gezel-nav`],onLinkClick:e=>s(e)}},[o,s]);return(0,$.jsx)(d,{initialMarkdown:t,fileName:e,language:n,height:`100%`,colorScheme:c,showPlayTab:!1,showStatusBar:!1,toolbarSlotLeft:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qa,{request:r}),(0,$.jsx)(Ja,{findings:i,activeFinding:a})]}),fullWidth:!0,readOnly:!0,...l?{codeContext:l}:{}},e)}function qa({request:e}){let{monacoEditor:t}=u();return(0,h.useEffect)(()=>{if(!t||!e)return;let n=t.getModel();if(!n)return;let r=Math.min(e.line,n.getLineCount());t.setPosition({lineNumber:r,column:1}),t.revealLineInCenter(r)},[t,e]),null}function Ja({findings:e,activeFinding:t}){let{monacoEditor:n}=u(),r=(0,h.useRef)([]);return(0,h.useEffect)(()=>{if(!n)return;let i=n.getModel();if(!i)return;let a=new Map;for(let n of e){if(n.line==null)continue;let e=Math.min(n.line,i.getLineCount());a.set(e,a.get(e)===!0||n.fingerprint===t)}return r.current=n.deltaDecorations(r.current,[...a].map(([e,t])=>({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:i.getLineMaxColumn(e)},options:{isWholeLine:!0,className:t?`filemap-finding-line-active`:`filemap-finding-line`,linesDecorationsClassName:t?`filemap-finding-gutter-active`:`filemap-finding-gutter`}}))),()=>{r.current=n.deltaDecorations(r.current,[])}},[t,e,n]),null}export{Ga as FileMapView,za as reviewIssueLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{t as i}from"./ConfirmDialog-Dt1ed4Fh.js";var a=e(t(),1),o=n(),s=[{id:`documents`,label:`Documents library`,help:`The shared documents folder gezellen read and write across projects.`},{id:`gezels`,label:`Gezellen`,help:`Each gezel’s about, threads, memories, and icons. Installed toolsets (npm packages) stay on this device.`},{id:`projects`,label:`Projects (artifacts, tasks, memories, documents)`,help:`Working files (workspace, git checkout, scripts) and history stay on this device.`}];function c(){let[e,t]=(0,a.useState)(null),[n,c]=(0,a.useState)(null),[d,f]=(0,a.useState)(null),[h,_]=(0,a.useState)(null),v=(0,a.useRef)(null),y=(0,a.useCallback)(async()=>{try{let e=await r.getFolders();t(e),c(null)}catch(e){c(e.message)}},[]);(0,a.useEffect)(()=>{y()},[y]),(0,a.useEffect)(()=>{if(!h||h.status===`done`||h.status===`error`||h.status===`cancelled`){v.current&&=(clearInterval(v.current),null);return}if(!v.current)return v.current=setInterval(async()=>{try{let e=await r.getFolderMoveStatus(h.id);_(e),(e.status===`done`||e.status===`error`||e.status===`cancelled`)&&await y()}catch(e){c(e.message)}},1e3),()=>{v.current&&=(clearInterval(v.current),null)}},[h,y]);let b=(0,a.useCallback)(async(e,t)=>{let n=window.__GEZEL__?.selectDirectory;if(!n){c(`Folder picker is only available in the desktop app.`);return}let i=await n({title:`Pick external location for ${t}`});if(i)try{let t=await r.planFolderMove({scope:e,destPath:i});if(!t.validation.ok){c(t.validation.reason??`destination is not valid`);return}f({scope:e,destPath:i,plan:t,conflictPolicy:(t.conflicts,`overwrite-all`)})}catch(e){c(e.message)}},[]),x=(0,a.useCallback)(async()=>{if(d)try{let{jobId:e}=await r.startFolderMove({scope:d.scope,destPath:d.destPath,conflictPolicy:d.conflictPolicy});f(null),_({id:e,scope:d.scope,sourcePath:d.plan.sourcePath,destPath:d.destPath,status:`queued`,filesDone:0,totalFiles:d.plan.files,bytesDone:0,totalBytes:d.plan.bytes,restartRequired:!1,startedAt:new Date().toISOString()})}catch(e){c(e.message)}},[d]),S=(0,a.useCallback)(async t=>{try{let{jobId:n}=await r.resetFolder(t);_({id:n,scope:t,sourcePath:e?.current[t]??``,destPath:e?.defaults[t]??``,status:`queued`,filesDone:0,totalFiles:0,bytesDone:0,totalBytes:0,restartRequired:!1,startedAt:new Date().toISOString()})}catch(e){c(e.message)}},[e]),C=(0,a.useCallback)(async e=>{let t=window.__GEZEL__?.openPath;if(!t){c(`Opening folders is only available in the desktop app.`);return}let n=await t(e);n&&c(n)},[]),w=(0,a.useCallback)(async()=>{let e=window.__GEZEL__?.restartService;if(!e){c(`Restart is only available in the desktop app.`);return}try{let t=await e(`folders-changed`);t.ok||c(t.error)}catch(e){c(e.message)}},[]);return e?(0,o.jsxs)(`section`,{className:`settings-section`,children:[(0,o.jsx)(`h2`,{children:`Folders`}),(0,o.jsxs)(`p`,{className:`muted small`,children:[`Move parts of your gezel data to a folder of your choosing — for example a OneDrive, iCloud Drive, or Dropbox folder so it syncs across machines and gets backed up. Before any move runs, a copy of the source is written to `,(0,o.jsx)(`code`,{children:e.backups.path}),` so the move can be undone by hand if something goes wrong.`]}),n&&(0,o.jsxs)(`p`,{className:`error small`,role:`alert`,children:[n,` `,(0,o.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>c(null),children:`dismiss`})]}),(0,o.jsx)(`div`,{className:`folders-rows`,children:s.map(t=>(0,o.jsx)(l,{label:t.label,help:t.help,currentPath:e.current[t.id],externalized:e.externalized[t.id],disabled:e.activeJob||h!==null,onPick:()=>b(t.id,t.label),onReset:()=>S(t.id),onOpen:()=>C(e.current[t.id])},t.id))}),e.backups.count>0&&(0,o.jsx)(u,{backups:e.backups,onOpen:C}),h&&(0,o.jsx)(m,{job:h,onRestart:w}),(0,o.jsx)(i,{open:d!==null,title:d?`Move ${d.plan.files} files?`:``,message:d&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:`From:`}),` `,(0,o.jsx)(`code`,{children:d.plan.sourcePath})]}),(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:`To:`}),` `,(0,o.jsx)(`code`,{children:d.destPath})]}),(0,o.jsxs)(`p`,{children:[d.plan.files.toLocaleString(),` files (`,g(d.plan.bytes),`) will be copied. A backup snapshot will be saved before the move.`]}),d.plan.conflicts>0&&(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:d.plan.conflicts}),` file`,d.plan.conflicts===1?``:`s`,` already exist at the destination.`,(0,o.jsx)(p,{value:d.conflictPolicy,onChange:e=>f(t=>t&&{...t,conflictPolicy:e})})]}),(0,o.jsx)(`p`,{children:`The gezel service will need to restart afterwards. Sessions on disk are preserved.`})]}),confirmLabel:`Start move`,cancelLabel:`Cancel`,onConfirm:x,onCancel:()=>f(null)})]}):(0,o.jsxs)(`section`,{className:`settings-section`,children:[(0,o.jsx)(`h2`,{children:`Folders`}),(0,o.jsx)(`p`,{className:`muted small`,children:`Loading…`})]})}function l({label:e,help:t,currentPath:n,externalized:r,disabled:i,onPick:a,onReset:s,onOpen:c}){return(0,o.jsxs)(`div`,{className:`folders-row`,style:{marginTop:24},children:[(0,o.jsx)(`div`,{className:`folders-row-head`,children:(0,o.jsx)(`strong`,{children:e})}),(0,o.jsx)(`p`,{className:`muted small`,children:t}),(0,o.jsx)(`div`,{className:`muted small`,children:r?`External`:`Default location`}),(0,o.jsx)(`code`,{className:`folders-row-path`,children:n}),(0,o.jsxs)(`div`,{className:`folders-row-actions`,style:{marginTop:16},children:[(0,o.jsx)(`button`,{type:`button`,className:`primary`,onClick:a,disabled:i,children:`Move to other folder…`}),window.__GEZEL__?.openPath&&(0,o.jsx)(`button`,{type:`button`,onClick:c,children:`Open`}),r&&(0,o.jsx)(`button`,{type:`button`,onClick:s,disabled:i,children:`Reset to default`})]})]})}function u({backups:e,onOpen:t}){return(0,o.jsxs)(`div`,{className:`folders-snapshots`,style:{marginTop:24},children:[(0,o.jsx)(`h3`,{children:`Move snapshots`}),(0,o.jsx)(`p`,{className:`muted small`,children:`Copies of the source taken before each move, newest first. The last 10 are kept; older ones are removed automatically. Nothing here is used by gezel — they exist so you can restore a move by hand.`}),(0,o.jsx)(`ul`,{className:`folders-snapshot-list`,children:e.snapshots.map(e=>(0,o.jsxs)(`li`,{className:`folders-snapshot`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{children:d(e)}),(0,o.jsxs)(`div`,{className:`muted small`,children:[f(e.scopes),` · `,g(e.bytes)]})]}),window.__GEZEL__?.openPath&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>t(e.path),children:`Open`})]},e.id))}),(0,o.jsxs)(`p`,{className:`muted small`,children:[g(e.totalBytes),` total in `,(0,o.jsx)(`code`,{children:e.path})]})]})}function d(e){return e.createdAt?new Date(e.createdAt).toLocaleString():e.id}function f(e){return e.length===0?`empty`:e.map(e=>s.find(t=>t.id===e)?.label??e).join(`, `)}function p({value:e,onChange:t}){return(0,o.jsxs)(`div`,{style:{marginTop:8},children:[(0,o.jsxs)(`label`,{style:{display:`block`,marginBottom:4},children:[(0,o.jsx)(`input`,{type:`radio`,name:`conflictPolicy`,checked:e===`overwrite-all`,onChange:()=>t(`overwrite-all`)}),` `,`Overwrite destination files`]}),(0,o.jsxs)(`label`,{style:{display:`block`},children:[(0,o.jsx)(`input`,{type:`radio`,name:`conflictPolicy`,checked:e===`skip-all`,onChange:()=>t(`skip-all`)}),` `,`Skip conflicting files (keep destination)`]})]})}function m({job:e,onRestart:t}){let n=e.totalFiles>0?Math.min(100,Math.round(e.filesDone/e.totalFiles*100)):0,r=h(e);return(0,o.jsxs)(`div`,{className:`folders-progress`,style:{marginTop:16},children:[(0,o.jsxs)(`div`,{className:`folders-progress-head`,children:[(0,o.jsxs)(`strong`,{children:[`Moving `,e.scope,` → `,(0,o.jsx)(`code`,{children:e.destPath})]}),(0,o.jsx)(`span`,{className:`muted small`,children:r})]}),e.status===`running`||e.status===`queued`?(0,o.jsxs)(`div`,{className:`ollama-pull-bar`,children:[(0,o.jsx)(`div`,{className:`ollama-pull-bar-fill`,style:{width:`${n}%`}}),(0,o.jsxs)(`span`,{className:`ollama-pull-bar-label`,children:[n,`%`]})]}):null,e.status===`error`&&(0,o.jsxs)(`p`,{className:`error small`,children:[`Error: `,e.error??`unknown`]}),e.status===`done`&&e.restartRequired&&(0,o.jsxs)(`p`,{style:{marginTop:8},children:[`Move complete.`,` `,(0,o.jsx)(`button`,{type:`button`,className:`primary`,onClick:t,children:`Restart now`})]}),e.status===`cancelled`&&(0,o.jsx)(`p`,{className:`muted small`,children:`Cancelled.`})]})}function h(e){if(e.status===`queued`)return`Queued`;if(e.status===`done`)return`Done`;if(e.status===`error`)return`Failed`;if(e.status===`cancelled`)return`Cancelled`;switch(e.phase){case`scan`:return`Scanning…`;case`backup`:return`Creating backup…`;case`copy`:return`Copying ${e.filesDone.toLocaleString()} of ${e.totalFiles.toLocaleString()} files (${g(e.bytesDone)} of ${g(e.totalBytes)})`;case`verify`:return`Verifying…`;case`swap`:return`Updating configuration…`;case`cleanup`:return`Cleaning up source…`;case`prune`:return`Pruning old backups…`;default:return`Working…`}}function g(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t.toFixed(1)} KB`;let n=t/1024;return n<1024?`${n.toFixed(1)} MB`:`${(n/1024).toFixed(2)} GB`}export{c as FoldersSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Et as r,Gt as i,V as a,_ as o,bn as s,h as c,p as l,r as u,t as d,tt as f,u as p,ut as m}from"./dist-BqGwkOe5.js";import{t as h}from"./dist-BaHut5iX.js";import{t as g}from"./api-BPraLwsh.js";import{i as _,n as v,r as y}from"./Tabs-jE0Z5Tzd.js";import{G as b,H as x,J as S,K as C,W as w,Y as T,d as E,l as D,m as O,p as k,q as A,s as j}from"./primitives-CWrGZpPI.js";import{n as M,t as N}from"./poppetje-DLB8uevw.js";import{t as P}from"./ConfirmDialog-Dt1ed4Fh.js";import{a as F,o as ee,t as I}from"./model-inventory-ykSm_IT5.js";import{n as te}from"./styles-CKVKwqoQ.js";import{C as L,It as R,K as z,f as ne,gt as re,ht as ie,jt as B,x as ae}from"./index-C0DYtvfg.js";import{i as V,t as oe}from"./ChatTimelineView-CQ4Sf4Ip.js";import{t as se}from"./SessionSwitcher-6okzcxT7.js";import{t as ce}from"./ProjectTimeline-BZpdCisR.js";import{c as le,l as H,n as ue,o as U,r as de,s as fe}from"./chat-thread-memory-Be48zsyG.js";import{t as pe}from"./ToolsetsEditor-Bb1wD5mV.js";import{t as me}from"./MemoriesTree-DzjXzIrM.js";import{t as he}from"./markdown-baseline-9B52XlX2.js";import{t as ge}from"./TransformToolbarButton-BWYkEB0d.js";import{t as _e}from"./ds4-availability-TaGRbP_O.js";import{i as ve,t as ye}from"./ModelPicker-DoXPfQkQ.js";var W=e(t(),1),G=n();function be({gezel:e,onUpdated:t}){let n=e.fixedFunction,r=n?.defaults?JSON.stringify(n.defaults,null,2):``,[i,a]=(0,W.useState)(r),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1);(0,W.useEffect)(()=>{a(r),p(!1),s(null),l(null)},[e.id]);let m=(0,W.useCallback)(async()=>{s(null),l(null);let n=null;if(i.trim())try{let e=JSON.parse(i);if(e===null||Array.isArray(e)||typeof e!=`object`)throw Error(`defaults must be a JSON object`);n=e}catch(e){s(`Invalid JSON: ${e.message}`);return}d(!0);try{t(await g.updateGezelFixedFunctionDefaults(e.id,{defaults:n&&Object.keys(n).length>0?n:null})),p(!1),l(`Saved`)}catch(e){s(`Save failed: ${e.message}`)}finally{d(!1)}},[i,e.id,t]);return n?(0,G.jsxs)(`div`,{className:`ff-about-panel`,children:[(0,G.jsxs)(`div`,{className:`ff-about-summary`,children:[(0,G.jsxs)(`div`,{className:`ff-about-row`,children:[(0,G.jsx)(`span`,{className:`ff-label`,children:`Forwards to`}),(0,G.jsx)(`code`,{className:`ff-tool-name`,children:n.tool}),(0,G.jsx)(`span`,{className:`muted small`,children:`— no LLM is invoked`})]}),(0,G.jsxs)(`div`,{className:`ff-about-row`,children:[(0,G.jsx)(`span`,{className:`ff-label`,children:`Argument`}),(0,G.jsxs)(`span`,{children:[`Your message text is passed as `,(0,G.jsx)(`code`,{children:n.promptKey}),`.`]})]}),e.description&&(0,G.jsx)(`p`,{className:`muted`,children:e.description})]}),(0,G.jsxs)(`div`,{className:`ff-defaults`,children:[(0,G.jsx)(`label`,{className:`ff-defaults-label`,htmlFor:`ff-defaults-${e.id}`,children:`Default arguments`}),(0,G.jsxs)(`p`,{className:`muted small ff-defaults-help`,children:[`Merged into every call as JSON. Your message text on `,(0,G.jsx)(`code`,{children:n.promptKey}),` always wins over a collision here. Common keys for `,(0,G.jsx)(`code`,{children:n.tool}),`: `,(0,G.jsx)(`code`,{children:`width`}),`,`,` `,(0,G.jsx)(`code`,{children:`height`}),`, `,(0,G.jsx)(`code`,{children:`steps`}),`, `,(0,G.jsx)(`code`,{children:`model`}),`, `,(0,G.jsx)(`code`,{children:`negativePrompt`}),`. Leave empty to forward only the prompt.`]}),(0,G.jsx)(`textarea`,{id:`ff-defaults-${e.id}`,className:`ff-defaults-textarea`,value:i,spellCheck:!1,rows:10,placeholder:`{\\n "width": 1024,\\n "height": 1024\\n}`,onChange:e=>{a(e.target.value),p(!0),l(null)},disabled:u}),(0,G.jsxs)(`div`,{className:`ff-defaults-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void m(),disabled:u||!f,children:u?`Saving…`:`Save defaults`}),c&&(0,G.jsx)(`span`,{className:`muted small`,children:c}),o&&(0,G.jsx)(`span`,{className:`error small`,children:o})]})]})]}):null}function xe({gezelId:e,activeSessionId:t,onFocusSession:n,onToolActivity:r,onArtifactReference:i,onArtifactSeen:a,onWorkspaceReference:o,onWorkspaceSeen:s,onOpenReference:c,onTaskReference:l,emptyPlaceholder:u}){let d=(0,W.useCallback)(t=>g.listGezelTimeline(e,t),[e]),f=(0,W.useCallback)(()=>g.gezelEventsUrl(e),[e]),p=(0,W.useMemo)(()=>({gezelId:e}),[e]);return(0,G.jsx)(oe,{scopeKey:`gezel:${e}`,activeSessionId:t,onFocusSession:n,onToolActivity:r,onArtifactReference:i,onArtifactSeen:a,onWorkspaceReference:o,onWorkspaceSeen:s,onOpenReference:c,...l?{onTaskReference:l}:{},emptyPlaceholder:u,loadTimeline:d,streamUrl:f,inflightScope:p})}var K=`__ALL__`,Se=`gezel:chat:last-project:`;function Ce(e){try{return window.localStorage.getItem(`${Se}${e}`)??void 0}catch{return}}function we({projects:e,intentProjectId:t,lastProjectId:n,workingProjectIds:r}){if(t)return e.find(e=>e.projectId===t)?.projectId??t;if(n&&r?.has(n))return n;let i=e.find(e=>r?.has(e.projectId));return i?i.projectId:n===K||e.some(e=>e.projectId===n)?n:e[0]?.projectId}function Te(e,t){return e.find(e=>t?.has(e.projectId))?.projectId}function Ee({gezel:e,engineLabel:t,workingProjectIds:n,activeTurnsReady:r=!0}){let[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(null),f=(0,W.useRef)(0),p=(0,W.useCallback)((e,t)=>{f.current+=1,d({sessionId:e,requestKey:f.current,...t===void 0?{}:{messageIndex:t}})},[]),m=(0,W.useRef)(n),h=(0,W.useRef)(r),_=(0,W.useRef)(!1),v=(0,W.useRef)(!1);return m.current=n,h.current=r,(0,W.useEffect)(()=>{let t=!1;a(null),s(``),_.current=!1,v.current=!1;let n=z(e.id);return n&&(_.current=!0,v.current=!0,l(n.sessionId),p(n.sessionId,n.messageIndex)),g.listProjectsForGezel(e.id).then(r=>{if(t)return;a(r.projects);let i=we({projects:r.projects,intentProjectId:n?.projectId,lastProjectId:Ce(e.id),workingProjectIds:h.current?m.current:void 0});i&&s(i)}).catch(()=>{t||a([])}),()=>{t=!0}},[e.id,p]),(0,W.useEffect)(()=>{if(!r||i===null||!o||_.current||v.current||(_.current=!0,n?.has(o)))return;let e=Te(i,n);e&&s(e)},[r,i,o,n]),(0,W.useEffect)(()=>{if(o)try{window.localStorage.setItem(`${Se}${e.id}`,o)}catch{}},[e.id,o]),(0,W.useEffect)(()=>{let t=t=>{let n=t.detail;!n||n.gezelId!==e.id||(_.current=!0,v.current=!0,n.projectId&&s(n.projectId),l(n.sessionId),p(n.sessionId,n.messageIndex))};return window.addEventListener(`gezel:open-session`,t),()=>window.removeEventListener(`gezel:open-session`,t)},[e.id,p]),(0,W.useEffect)(()=>{let t=t=>{if(t.detail?.gezelId!==e.id||i===null)return;let r=Te(i,n);r&&(_.current=!0,v.current=!1,s(r))};return window.addEventListener(`gezel:prefer-working-project`,t),()=>window.removeEventListener(`gezel:prefer-working-project`,t)},[e.id,i,n]),(0,W.useEffect)(()=>{o&&o!=="default"&&o!==K&&window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`project`,id:o,activate:!1}}))},[o]),i===null?(0,G.jsx)(`p`,{className:`muted small`,children:`Loading projects…`}):i.length===0?(0,G.jsx)(`p`,{className:`muted small`,children:`No projects available yet — create one from the Projects tab.`}):(0,G.jsxs)(`div`,{className:`gezel-chat-tab`,children:[(0,G.jsxs)(`div`,{className:`gezel-chat-project-row`,children:[(0,G.jsx)(`span`,{className:`muted small`,children:`Project:`}),(0,G.jsxs)(E,{value:o,onValueChange:e=>{v.current=!0,_.current=!0,s(e)},children:[(0,G.jsx)(k,{className:`gezel-chat-project-select`,children:(0,G.jsx)(O,{})}),(0,G.jsxs)(j,{children:[(0,G.jsx)(D,{value:K,children:`All projects`}),i.map(e=>(0,G.jsx)(D,{value:e.projectId,children:De(e)},e.projectId))]})]})]}),o===K?(0,G.jsx)(ke,{gezel:e},`${e.id}:__ALL__`):o&&(0,G.jsx)(Oe,{gezel:e,engineLabel:t,project:i.find(e=>e.projectId===o)??{projectId:o,projectName:o,precedence:`session`},focusSessionId:c||void 0,sessionFocusRequest:u??void 0},`${e.id}:${o}`)]})}function De(e){switch(e.precedence){case`voorman`:return`${e.projectName} — voorman`;case`assignment`:return`${e.projectName} — assigned`;case`session`:return`${e.projectName}`;case`fallback`:return`${e.projectName} (default)`}}function Oe({gezel:e,engineLabel:t,project:n,focusSessionId:r,sessionFocusRequest:o}){let s=a(e,L()),c=de(e.id,n.projectId),[l,u]=(0,W.useState)(()=>r??U(c)?.sessionId??``),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(0),[h,g]=(0,W.useState)(0),[_,v]=(0,W.useState)(null);(0,W.useEffect)(()=>{r&&u(r)},[r]),(0,W.useEffect)(()=>{fe(c,{sessionId:l})},[c,l]);let y=(0,W.useMemo)(()=>{let t=i(e.gender);return`Talk to ${s} about what ${t.subject} ${t.presentBe} working on in this project.`},[s,e.gender]),b=(0,W.useMemo)(()=>le({role:n.precedence===`voorman`?`voorman`:`other`,gezelName:s,gezelGender:e.gender,projectName:n.projectName,fixedFunctionTool:e.fixedFunction?.tool}),[n.precedence,n.projectName,s,e.gender,e.fixedFunction?.tool]);return(0,G.jsx)(H,{projectId:n.projectId,skillsProjectId:n.projectId==="default"?void 0:n.projectId,chatKey:`${n.projectId}:${e.id}`,children:({onToolActivity:r,onArtifactReference:i,onArtifactSeen:a,onWorkspaceReference:s,onWorkspaceSeen:c,recentReferences:x,onOpenReference:S,onTaskReference:C})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ce,{projectId:n.projectId,gezelId:e.id,activeSessionId:l||void 0,onFocusSession:(t,n)=>{n===e.id&&u(t)},onToolActivity:r,onArtifactReference:i,onArtifactSeen:a,onWorkspaceReference:s,onWorkspaceSeen:c,onOpenReference:S,onTaskReference:C,emptyPlaceholder:y,sessionFocusRequest:o}),_?(0,G.jsx)(Ae,{source:_,children:(0,G.jsx)(se,{gezelId:e.id,projectId:n.projectId,sessionId:l||void 0,onSessionIdChange:e=>u(e??``),onActiveSessionChange:e=>v(e?.source??null),onFreshThread:()=>g(e=>e+1),refreshKey:p,engineLabel:t})}):(0,G.jsx)(V,{gezelId:e.id,gezelName:e.name,gezelRoleBasedName:e.roleBasedName,gezelRole:e.role,gezelIcon:e.icon??null,gezelPoppetje:e.poppetje,gezelIconOverride:e.iconOverride,projectId:n.projectId,sessionId:l||void 0,focusRequestKey:h,onSessionCreated:e=>{u(e),m(e=>e+1)},onToolActivity:r,recentReferences:x,onOpenReference:S,placeholder:b,draftScope:`gezel`,draftId:d||void 0,onDraftIdChange:e=>f(e??``),belowAddressLine:(0,G.jsx)(se,{gezelId:e.id,projectId:n.projectId,sessionId:l||void 0,onSessionIdChange:e=>u(e??``),onActiveSessionChange:e=>v(e?.source??null),onFreshThread:()=>g(e=>e+1),refreshKey:p,engineLabel:t,activeDraftId:d||void 0,onDraftSelect:e=>f(e??``),draftScope:`gezel`})})]})})}function ke({gezel:e}){let t=a(e,L()),n=ue(e.id),[r,i]=(0,W.useState)(()=>{let e=U(n);return!e?.sessionId||!e.projectId?null:{sessionId:e.sessionId,projectId:e.projectId}});(0,W.useEffect)(()=>{fe(n,{sessionId:r?.sessionId??``,projectId:r?.projectId??``})},[n,r?.sessionId,r?.projectId]);let o=(0,W.useMemo)(()=>`No chats with ${t} yet — start one below.`,[t]),s=(0,W.useMemo)(()=>le({role:`other`,gezelName:t,gezelGender:e.gender,projectName:r?void 0:`default`,fixedFunctionTool:e.fixedFunction?.tool}),[t,e.gender,r,e.fixedFunction?.tool]),c=r?.projectId??`default`;return(0,G.jsx)(H,{projectId:c,skillsProjectId:c==="default"?void 0:c,chatKey:`all:${e.id}`,children:({onToolActivity:t,onArtifactReference:n,onArtifactSeen:a,onWorkspaceReference:l,onWorkspaceSeen:u,recentReferences:d,onOpenReference:f,onTaskReference:p})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xe,{gezelId:e.id,activeSessionId:r?.sessionId,onFocusSession:(e,t,n)=>{i({sessionId:e,projectId:n}),g.getChatSession(e).then(t=>{i(r=>r?.sessionId===e?{sessionId:e,projectId:n,...t.source?{source:t.source}:{}}:r)}).catch(()=>{})},onToolActivity:t,onArtifactReference:n,onArtifactSeen:a,onWorkspaceReference:l,onWorkspaceSeen:u,onOpenReference:f,onTaskReference:p,emptyPlaceholder:o}),r?.source?(0,G.jsx)(Ae,{source:r.source}):(0,G.jsx)(V,{gezelId:e.id,gezelName:e.name,gezelRoleBasedName:e.roleBasedName,gezelRole:e.role,gezelIcon:e.icon??null,gezelPoppetje:e.poppetje,gezelIconOverride:e.iconOverride,projectId:c,sessionId:r?.sessionId,onSessionCreated:e=>i({sessionId:e,projectId:c}),onToolActivity:t,recentReferences:d,onOpenReference:f,placeholder:s,draftScope:`gezel-all`})]})})}function Ae({source:e,children:t}){return(0,G.jsxs)(`div`,{className:`external-conversation-panel`,"aria-live":`polite`,children:[t,(0,G.jsxs)(`div`,{className:`external-conversation-notice`,children:[(0,G.jsxs)(`span`,{className:`external-conversation-label`,children:[`From `,e.appName,` · read-only`]}),(0,G.jsxs)(`span`,{children:[`This conversation updates live here. Replies and tool controls stay in `,e.appName,`.`]})]})]})}function je({gezelRole:e,gezelTemplateId:t,onApply:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)([]),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null);(0,W.useEffect)(()=>{r&&(c(!0),f(null),g.listCatalogItems(`gezel-template`).then(e=>o(e.items)).catch(e=>f(e.message)).finally(()=>c(!1)))},[r]);let p=(0,W.useMemo)(()=>{let n=a.filter(e=>e.manifest.kind===`gezel-template`),r=e?.toLowerCase().trim(),i=t?n.find(e=>e.manifest.id===t)?.manifest.id:void 0,o=i??(r?n.find(e=>e.manifest.role.toLowerCase().trim()===r)?.manifest.id:void 0);return n.map(e=>({item:e,isSuggested:e.manifest.id===o,isOriginal:e.manifest.id===i})).sort((e,t)=>e.isSuggested===t.isSuggested?e.item.manifest.name.localeCompare(t.item.manifest.name):e.isSuggested?-1:1)},[a,e,t]),m=(0,W.useCallback)(async e=>{u(e),f(null);try{let t=(await g.getCatalogItem(`gezel-template`,e)).about??``;if(!t.trim()){f(`This template has no about.md content.`);return}await n(e,t),i(!1)}catch(e){f(e.message)}finally{u(null)}},[n]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,className:`ai-btn`,onClick:()=>i(!0),title:`Replace this gezel's about.md with a gilde template`,"aria-label":`Use a template`,children:`📇`}),(0,G.jsx)(S,{open:r,onOpenChange:e=>{e||(i(!1),f(null))},children:(0,G.jsxs)(A,{children:[(0,G.jsx)(C,{}),(0,G.jsxs)(w,{className:`gz-dialog-wide`,children:[(0,G.jsx)(T,{asChild:!0,children:(0,G.jsx)(`h3`,{children:`Apply a template`})}),(0,G.jsxs)(b,{className:`muted small`,children:[`Replace this gezel's `,(0,G.jsx)(`code`,{children:`about.md`}),` with a template from the gilde. Current content is overwritten — you can edit back to undo.`]}),s&&(0,G.jsx)(`p`,{className:`muted`,children:`Loading templates…`}),!s&&p.length===0&&(0,G.jsx)(`p`,{className:`muted`,children:`No gilde templates available.`}),!s&&p.length>0&&(0,G.jsx)(`ul`,{className:`gezel-template-list`,children:p.map(({item:e,isSuggested:t,isOriginal:n})=>{let r=e.manifest,i=l===r.id;return(0,G.jsxs)(`li`,{className:t?`suggested`:void 0,children:[(0,G.jsxs)(`div`,{className:`gezel-template-head`,children:[(0,G.jsx)(`strong`,{children:r.name}),(0,G.jsx)(`span`,{className:`muted small`,children:r.role}),t&&(0,G.jsx)(`span`,{className:`gezel-template-badge`,children:n?`Original`:`Matches role`})]}),r.description&&(0,G.jsx)(`p`,{className:`muted small`,children:r.description}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(r.id),disabled:l!==null,children:i?`Applying…`:t?`Reset to this`:`Use this`})]},r.id)})}),d&&(0,G.jsx)(`p`,{className:`gz-dialog-error`,children:d}),(0,G.jsx)(x,{children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!1),disabled:l!==null,children:`Cancel`})})]})]})})]})}function Me({gezel:e,inherited:t,effectiveProvider:n,onUpdated:r}){let i=(0,W.useCallback)(async t=>{r(await g.updateGezelSettings(e.id,{tuning:t}))},[e.id,r]);return(0,G.jsxs)(`div`,{className:`gezel-tuning-editor`,children:[(0,G.jsx)(Ne,{gezel:e,availableProfiles:Object.keys(t?.profiles??{}),onUpdated:r}),(0,G.jsx)(ve,{provider:n,override:e.parsed?.frontmatter?.tuning,...t?{inherited:t}:{},...e.parsed?.frontmatter?.tuningProfile?{tuningProfileId:e.parsed.frontmatter.tuningProfile}:{},onSave:i,scopeLabel:e.name??`this gezel`})]})}function Ne({gezel:e,availableProfiles:t,onUpdated:n}){let r=e.parsed?.frontmatter?.tuningProfile??``,[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null),c=(0,W.useMemo)(()=>t.map(e=>{let t=m(e)?u[e]:null;return{id:e,label:t?.label??e,description:t?.description}}),[t]),l=(0,W.useCallback)(async t=>{a(!0),s(null);try{let r=t===``?null:t;n(await g.updateGezelSettings(e.id,{tuningProfile:r}))}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[e.id,n]);return c.length===0&&!r?null:(0,G.jsxs)(`div`,{className:`voice-picker`,style:{marginBottom:`0.75rem`},children:[(0,G.jsxs)(`label`,{htmlFor:`voice-${e.id}`,className:`small`,style:{display:`block`,marginBottom:`0.25rem`},children:[(0,G.jsx)(`strong`,{children:`Voice`}),` `,(0,G.jsx)(`span`,{className:`muted`,children:`— preset the model applies for this gezel. Your manual tuning below overrides individual fields.`})]}),(0,G.jsxs)(`select`,{id:`voice-${e.id}`,value:r,onChange:e=>void l(e.target.value),disabled:i,children:[(0,G.jsx)(`option`,{value:``,children:`(automatic — use template / model default)`}),c.map(e=>(0,G.jsx)(`option`,{value:e.id,title:e.description,children:e.label},e.id))]}),o&&(0,G.jsx)(`div`,{className:`small error`,style:{marginTop:`0.25rem`},children:o})]})}function q({level:e,pending:t=!1,overlay:n=!1}){if(e<2&&!t)return null;let r=t?`Level ${e} — a level-up is waiting in the Growth tab`:`Level ${e}`;return(0,G.jsxs)(`span`,{className:`level-badge${n?` level-badge--overlay`:``}`,title:r,"aria-label":r,children:[`Lv `,e,t&&(0,G.jsx)(`span`,{className:`level-badge-dot`,"aria-hidden":`true`})]})}function Pe(e,t,n){if(n<=t)return 100;let r=(e-t)/(n-t)*100;return Math.max(0,Math.min(100,Math.round(r)))}function J(e){let[t,n,r]=e.split(`-`).map(e=>Number.parseInt(e,10));return!t||!n||!r?e:new Date(Date.UTC(t,n-1,r)).toLocaleDateString(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`})}var Fe={fact:`Fact`,decision:`Decision`,pref:`Preference`,status:`Status`};function Ie(e){return[{label:`Memories`,value:e.memoryXp,hint:`Distinct deduplicated memories — preferences and decisions weigh most.`},{label:`Lessons`,value:e.lessonsXp,hint:`Times the distilled lessons file was refined.`},{label:`Task work`,value:e.taskXp,hint:`Completed task steps and finished tasks.`},{label:`Consults`,value:e.consultXp,hint:`Delivered gezel-to-gezel consultations (daily-capped).`}]}function Le(e,t){return`gezel-growth-celebrated:${e}:${t}`}function Re(e){switch(e.kind){case`trait`:return`Adopt this trait`;case`tuning`:if(e.action.type===`profile`){let t=e.action.profile;return`Switch to ${m(t)?u[t].label:t}`}return e.action.delta>0?`Run a little warmer`:`Run a little cooler`;case`cosmetic`:{let t=f(e.cosmeticId);return t?`Unlock ${t.label.toLowerCase()}`:`Mark the milestone`}}}function Y(e){if(e instanceof h){let t=e.details;if(typeof t==`object`&&t?.error)return t.error;if(typeof t==`string`&&t)return t}return e instanceof Error?e.message:String(e)}function ze(e){return e instanceof h&&e.status===409&&Y(e).includes(`no pending level-up`)}function Be(e,t){let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),f=(0,W.useCallback)(async()=>{try{r(await g.getGezelGrowth(e)),a(null)}catch(e){a(Y(e))}},[e]);(0,W.useEffect)(()=>{f()},[f]),(0,W.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.gezelId||n.gezelId===e)&&f()};return window.addEventListener(`gezel:growth-updated`,t),()=>window.removeEventListener(`gezel:growth-updated`,t)},[e,f]);let p=(0,W.useCallback)(async()=>{try{let t=await g.getGezel(e);window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`,{detail:t}))}catch{}t?.()},[e,t]),m=(0,W.useCallback)(async(e,t,n)=>{l(e??`*`),s(null);try{r(await t()),n&&await p()}catch(e){ze(e)?s(`This level-up was already resolved in another window.`):s(Y(e)),await f()}finally{l(null)}},[p,f]),h=(0,W.useCallback)(t=>m(t,()=>g.acceptGrowthProposal(e,t),!0),[e,m]),_=(0,W.useCallback)(t=>m(t,()=>g.declineGrowthLevelUp(e,t),!1),[e,m]),v=(0,W.useCallback)(()=>m(null,()=>g.declineGrowthLevelUp(e),!1),[e,m]),y=(0,W.useCallback)(t=>m(null,()=>g.retireGrowthTrait(e,t),!0),[e,m]),b=(0,W.useCallback)(async()=>{d(!0),s(null);try{r(await g.refreshGezelGrowth(e)),a(null)}catch(e){s(Y(e))}finally{d(!1)}},[e]);return{growth:n,error:i,notice:o,clearNotice:(0,W.useCallback)(()=>s(null),[]),busyId:c,refreshing:u,refresh:b,accept:h,decline:_,skipLevel:v,retireTrait:y}}function Ve({gezel:e,onUpdated:t}){let n=Be(e.id,t),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),[d,p]=(0,W.useState)(!1),h=n.growth?.state.pendingLevelUp?.toLevel;if((0,W.useEffect)(()=>{if(h===void 0)return;let t=Le(e.id,h);try{if(window.localStorage.getItem(t))return;window.localStorage.setItem(t,`1`)}catch{}p(!0);let n=setTimeout(()=>p(!1),1600);return()=>clearTimeout(n)},[e.id,h]),n.error)return(0,G.jsx)(`section`,{className:`growth-panel`,"data-testid":`growth-panel`,children:(0,G.jsxs)(`p`,{className:`error`,children:[`Couldn't load growth: `,n.error]})});if(!n.growth)return(0,G.jsx)(`section`,{className:`growth-panel`,"data-testid":`growth-panel`,children:(0,G.jsx)(`p`,{className:`placeholder`,children:`Loading growth…`})});let{state:g,nextLevelXp:_,activeTraits:v,driftedTraitIds:y}=n.growth,b=g.pendingLevelUp,x=s(g.level),S=Pe(g.xp,x,_),C=g.level===1&&!b&&v.length===0&&g.xp===0;return(0,G.jsxs)(`section`,{className:`growth-panel`,"data-testid":`growth-panel`,children:[n.notice&&(0,G.jsxs)(`output`,{className:`growth-notice`,children:[(0,G.jsx)(`span`,{children:n.notice}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:n.clearNotice,children:`Dismiss`})]}),b&&r&&(0,G.jsxs)(`div`,{className:`growth-deferred-reminder`,children:[(0,G.jsxs)(`span`,{children:[e.name,` reached level `,b.toLevel,` — growth choices are waiting.`]}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>i(!1),children:`Show choices`})]}),b&&!r&&(0,G.jsx)(He,{gezel:e,growth:n,onDefer:()=>i(!0),onSkip:()=>o(!0)}),(0,G.jsxs)(`header`,{className:`growth-header`,children:[(0,G.jsxs)(`span`,{className:`level-badge-anchor${d?` growth-celebrate`:``}`,children:[(0,G.jsx)(R,{svg:e.icon??null,poppetje:d&&e.poppetje?{...e.poppetje,expression:`wider`}:e.poppetje,iconOverride:e.iconOverride,name:e.name,size:96}),(0,G.jsx)(q,{level:g.level,pending:!!b,overlay:!0})]}),(0,G.jsxs)(`div`,{className:`growth-header-text`,children:[(0,G.jsxs)(`h4`,{children:[e.name,` · Level `,g.level]}),(0,G.jsx)(`div`,{className:`growth-xp-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":S,"aria-label":`${g.xp} XP — ${_} needed for level ${g.level+1}`,tabIndex:-1,children:(0,G.jsx)(`div`,{className:`growth-xp-fill`,style:{width:`${S}%`}})}),(0,G.jsxs)(`span`,{className:`muted small`,children:[g.xp,` XP · `,Math.max(0,_-g.xp),` to level `,g.level+1]})]}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn growth-refresh`,disabled:n.refreshing,title:`Recompute XP from memories, lessons, and task work now`,onClick:()=>void n.refresh(),children:n.refreshing?`Checking…`:`Check growth now`})]}),C?(0,G.jsxs)(`div`,{className:`growth-empty`,children:[(0,G.jsxs)(`p`,{children:[`Growth here is earned, not simulated — every point comes from real work. As `,e.name,` `,`accumulates distinct memories, distills lessons, and completes tasks, XP adds up; at each level you'll choose how they grow.`]}),(0,G.jsx)(`div`,{className:`growth-trait-ghost`,"aria-hidden":`true`,children:`Trait slot · unlocks at Level 2`})]}):(0,G.jsx)(`div`,{className:`growth-counters`,children:Ie(g.signals).map(e=>(0,G.jsxs)(`div`,{className:`growth-counter`,title:e.hint,children:[(0,G.jsx)(`span`,{className:`growth-counter-value`,children:e.value}),(0,G.jsx)(`span`,{className:`growth-counter-label`,children:e.label})]},e.label))}),y.length>0&&(0,G.jsxs)(`p`,{className:`growth-drift-warning`,children:[y.length===1?`One adopted trait is`:`Some adopted traits are`,` no longer in `,e.name,`'s frontmatter — likely lost to a manual gezel.md edit. Re-adopt from a future level-up, or edit the frontmatter directly.`]}),v.length>0&&(0,G.jsxs)(`div`,{className:`growth-traits`,children:[(0,G.jsx)(`h5`,{children:`Traits`}),v.map(e=>{let t=g.adoptedTraits.find(t=>t.traitId===e.id&&!t.removedAt);return(0,G.jsxs)(`details`,{className:`growth-trait`,children:[(0,G.jsxs)(`summary`,{children:[(0,G.jsx)(`span`,{className:`growth-trait-text`,children:e.text}),(0,G.jsxs)(`span`,{className:`muted small`,children:[` `,`· adopted `,J(e.adoptedAt.slice(0,10))]})]}),t&&t.evidence.length>0&&(0,G.jsx)(`div`,{className:`growth-trait-evidence`,children:t.evidence.map(e=>(0,G.jsxs)(`blockquote`,{children:[`“`,e.excerpt,`”`,(0,G.jsxs)(`footer`,{children:[(0,G.jsx)(`span`,{className:`growth-day-chip`,children:J(e.day)}),(0,G.jsx)(`span`,{className:`growth-kind-chip`,children:Fe[e.kind]??e.kind})]})]},`${e.day}-${e.excerpt.slice(0,24)}`))}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn growth-retire`,disabled:n.busyId!==null,onClick:()=>l(e),children:`Retire this trait`})]},e.id)})]}),e.tuningProfile&&m(e.tuningProfile)&&(0,G.jsxs)(`div`,{className:`growth-tuning`,children:[(0,G.jsx)(`h5`,{children:`Tuning`}),(0,G.jsx)(`span`,{className:`growth-tuning-chip`,children:u[e.tuningProfile].label})]}),g.unlockedCosmetics.length>0&&(0,G.jsxs)(`div`,{className:`growth-cosmetics`,children:[(0,G.jsx)(`h5`,{children:`Unlocked`}),(0,G.jsx)(`div`,{className:`growth-cosmetics-row`,children:g.unlockedCosmetics.map(e=>{let t=f(e.id);return(0,G.jsx)(`span`,{className:`growth-cosmetic-chip`,children:t?t.label:e.id.replace(/^level-(\d+)$/,`Level $1 milestone`)},e.id)})})]}),(0,G.jsx)(P,{open:a,title:`Skip level ${b?.toLevel??g.level+1}?`,message:`The level still advances — it was earned — but these trait offers won't come back. The evidence stays in memory for future level-ups.`,confirmLabel:`Skip this level`,onConfirm:async()=>{await n.skipLevel(),o(!1)},onCancel:()=>o(!1)}),(0,G.jsx)(P,{open:c!==null,title:`Retire this trait?`,message:c?(0,G.jsxs)(G.Fragment,{children:[`“`,c.text,`” will stop shaping `,e.name,`'s behavior. The adoption record and its evidence stay on the character sheet.`]}):void 0,confirmLabel:`Retire`,danger:!0,onConfirm:async()=>{c&&await n.retireTrait(c.id),l(null)},onCancel:()=>l(null)})]})}function He({gezel:e,growth:t,onDefer:n,onSkip:r}){let i=t.growth.state.pendingLevelUp;return i?(0,G.jsxs)(`div`,{className:`growth-levelup`,children:[(0,G.jsxs)(`h4`,{children:[e.name,` reached level `,i.toLevel,`.`]}),(0,G.jsx)(`p`,{className:`muted`,children:`Pick one way to grow — or skip; the evidence isn't going anywhere.`}),(0,G.jsx)(`div`,{className:`growth-proposals`,children:i.proposals.map(n=>(0,G.jsx)(Ue,{proposal:n,gezel:e,busy:t.busyId!==null,declinable:i.proposals.length>1,onAccept:()=>void t.accept(n.id),onDecline:()=>void t.decline(n.id)},n.id))}),(0,G.jsxs)(`div`,{className:`growth-levelup-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:n,children:`Decide later`}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:r,children:`Skip this level`})]})]}):null}function Ue({proposal:e,gezel:t,busy:n,declinable:r,onAccept:i,onDecline:a}){return(0,G.jsxs)(`div`,{className:`growth-proposal-card`,"data-kind":e.kind,children:[(0,G.jsx)(`span`,{className:`growth-proposal-kind`,children:We[e.kind]}),(0,G.jsx)(`h5`,{children:e.title}),e.kind===`trait`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`growth-proposal-trait-text`,children:[`“`,e.traitText,`”`]}),(0,G.jsx)(`div`,{className:`growth-trait-evidence`,children:e.evidence.map(e=>(0,G.jsxs)(`blockquote`,{children:[`“`,e.excerpt,`”`,(0,G.jsxs)(`footer`,{children:[(0,G.jsx)(`span`,{className:`growth-day-chip`,children:J(e.day)}),(0,G.jsx)(`span`,{className:`growth-kind-chip`,children:Fe[e.kind]??e.kind})]})]},`${e.day}-${e.excerpt.slice(0,24)}`))})]}),e.kind===`tuning`&&(0,G.jsx)(`p`,{className:`muted small`,children:e.description}),e.kind===`cosmetic`&&(0,G.jsx)(Ge,{poppetje:t.poppetje??null,cosmeticId:e.cosmeticId}),(0,G.jsxs)(`div`,{className:`growth-proposal-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`primary`,disabled:n,onClick:i,children:Re(e)}),r&&(0,G.jsx)(`button`,{type:`button`,disabled:n,onClick:a,children:`Not this one`})]})]})}var We={trait:`Trait`,tuning:`Tuning`,cosmetic:`Cosmetic`};function Ge({poppetje:e,cosmeticId:t}){let n=f(t);return!n||!e?n?(0,G.jsx)(`p`,{className:`muted small`,children:n.label}):null:(0,G.jsxs)(`div`,{className:`growth-cosmetic-tryon`,children:[(0,G.jsx)(`div`,{className:`growth-cosmetic-figure`,children:(0,G.jsx)(N,{poppetje:{...e,[n.slot]:n.option},variant:`headshot`,size:56})}),(0,G.jsx)(`span`,{className:`muted small`,children:n.label})]})}var X=`__INHERIT__`;function Ke(e,t){return e?`${e}:${t??``}`:X}function qe(e){if(e===X)return{kind:`inherit`};let t=e.indexOf(`:`);return t<0?{kind:`inherit`}:{kind:`override`,provider:e.slice(0,t),model:e.slice(t+1)||void 0}}function Je(){let e=window.__GEZEL__?.platform;if(e)return B(e);let t=typeof navigator>`u`?``:navigator.userAgent??``;return/Mac/i.test(t)?B(`darwin`):/Win/i.test(t)?B(`win32`):/Linux/i.test(t)?B(`linux`):B()}function Ye(e){switch(e){case`copilot`:return`GitHub Copilot`;case`openai`:return`OpenAI`;case`anthropic`:return`Anthropic`;case`anthropic-cli`:return`Claude CLI`;case`codex-cli`:return`Codex CLI`;case`ollama`:return`Ollama`;case`mlx`:case`llama-cpp`:return Je();case`ds4`:return`DwarfStar (ds4)`;default:return e}}function Xe({provider:e,model:t,onChange:n,globalProvider:r,disabled:i}){let[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)(0),d=(0,W.useRef)(null),f=(0,W.useRef)(!1);f.current=r===`copilot`||e===`copilot`,(0,W.useEffect)(()=>{let e=e=>{let t=F(e);t&&(d.current=t,u(e=>e+1))};return window.addEventListener(I,e),()=>window.removeEventListener(I,e)},[]),(0,W.useEffect)(()=>{let e=!1;return c(!0),(async()=>{let t=null,n=null,r=null;try{[t,n,r]=await Promise.all([g.getConfig(),g.getCopilotStatus().catch(()=>null),g.getMemoryProfile().catch(()=>null)])}catch{e||(o([]),c(!1));return}let i=[];(n?.available!==!1||f.current)&&i.push(`copilot`),t.hasOpenaiApiKey&&i.push(`openai`),t.hasAnthropicApiKey&&i.push(`anthropic`),t.anthropicCliStatus?.installed&&i.push(`anthropic-cli`),t.codexCliStatus?.installed&&i.push(`codex-cli`),i.push(`ollama`);let a=typeof navigator>`u`?``:navigator.userAgent;/Mac/i.test(a)&&i.push(`mlx`),i.push(`llama-cpp`),_e({externalBaseUrl:t.ds4BaseUrl,totalRamBytes:r?.totalRamBytes}).status!==`unavailable`&&i.push(`ds4`);let s=await Promise.all(i.map(async e=>{try{let t=(e===`llama-cpp`||e===`mlx`||e===`ds4`)&&(d.current===e&&l>0||ee(e)>0),n=await g.listProviderModels(e,t?{refresh:!0}:void 0);return n.models.length===0?null:{provider:e,label:Ye(e),models:n.models}}catch{return null}}));if(e)return;let u=s.filter(e=>e!==null),p=[`mlx`,`llama-cpp`,`ds4`,`ollama`,`copilot`,`openai`,`anthropic`,`anthropic-cli`,`codex-cli`];u.sort((e,t)=>p.indexOf(e.provider)-p.indexOf(t.provider)),o(u),c(!1)})(),()=>{e=!0}},[l]);let p=(0,W.useMemo)(()=>Ke(e,t),[e,t]),m=(0,W.useMemo)(()=>`Inherit default (${Ye(r)})`,[r]);return s?(0,G.jsx)(`span`,{className:`muted small`,children:`loading providers…`}):!a||a.length===0?(0,G.jsxs)(`span`,{className:`muted small`,children:[`No providers configured —`,` `,(0,G.jsx)(`button`,{type:`button`,className:`provider-model-select-link`,onClick:()=>{re(`defaults`),window.dispatchEvent(new CustomEvent(`gezel:navigate`,{detail:{view:`settings`,section:`defaults`}}))},children:`set one up`})]}):(0,G.jsxs)(E,{value:p,onValueChange:e=>{let t=qe(e);t.kind===`inherit`?n(null,void 0):n(t.provider,t.model)},disabled:i,children:[(0,G.jsx)(k,{children:(0,G.jsx)(O,{})}),(0,G.jsxs)(j,{children:[(0,G.jsx)(D,{value:X,children:m}),a.map(e=>e.models.map(t=>(0,G.jsxs)(D,{value:`${e.provider}:${t.id}`,children:[e.label,` — `,t.name,t.supportsReasoning?` · reasoning`:``]},`${e.provider}:${t.id}`)))]})]})}function Ze(e){switch(e){case`generate_video`:return{kind:`Video`,list:()=>g.listInstalledVideoModels()};case`generate_image`:return{kind:`Image`,list:()=>g.listInstalledImageModels()};default:return null}}function Qe(e){let t=e?.tool,n=typeof e?.defaults?.model==`string`?e.defaults.model:void 0,[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(!t){i(null);return}let e=Ze(t);if(!e){i(null);return}if(i(n?`${e.kind} · ${n}`:`${e.kind} generator`),n)return;let r=!1;return e.list().then(t=>{if(r)return;let n=t.defaultModel??t.models[0]?.id,a=t.models.find(e=>e.id===n)?.name??n;i(a?`${e.kind} · ${a}`:`${e.kind} generator`)}).catch(()=>{}),()=>{r=!0}},[t,n]),r}function Z(e){window.dispatchEvent(new CustomEvent(`gezel:gezel-updated`,{detail:e}))}function $e({gezelId:e,onDeleted:t,workingProjectIds:n,activeTurnsReady:r}){let i=ie(),a=L(),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(0),[w,T]=(0,W.useState)(`chat`),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(``),[A,j]=(0,W.useState)(!1),M=o?.fixedFunction!==void 0,N=M&&(w===`toolsets`||w===`memories`)?`chat`:w,P=Qe(o?.fixedFunction),F=(0,W.useRef)(null),ee=(0,W.useCallback)(t=>g.updateGezelAbout(e,{source:t}),[e]),I=ae({resourceKey:`gezel:${e}:about`,initialValue:``,save:ee,onLatestSaved:t=>{let n=F.current;if(!n||n.id!==e)return;let r={...n,about:t.about};F.current=r,s(r),Z(r)}});(0,W.useEffect)(()=>{let t=!1;return s(null),l(null),d(``),(async()=>{try{let n=await g.getGezel(e);if(t)return;let r={...n,about:I.hydrate(he(n.about))};F.current=r,s(r)}catch(e){t||l(e.message)}})(),()=>{t=!0}},[e,I.hydrate]),(0,W.useEffect)(()=>{M&&w!==N&&T(N)},[N,w,M]);let z=(0,W.useCallback)(e=>{F.current=e,s(e),Z(e)},[]),re=(0,W.useCallback)(e=>{d(``),I.update(e)},[I.update]),B=(0,W.useCallback)(()=>{o&&(k(o.name),j(!0))},[o]),V=(0,W.useCallback)(async()=>{if(!o||!O.trim()||O.trim()===o.name){j(!1);return}try{await I.flush();let e=await g.renameGezel(o.id,{name:O.trim()});F.current=e,I.adopt(e.about),s(e),Z(e)}catch(e){d(`rename failed: ${e.message}`)}j(!1)},[o,O,I.flush,I.adopt]),oe=(0,W.useCallback)(e=>{e.key===`Enter`&&V(),e.key===`Escape`&&j(!1)},[V]);return c?(0,G.jsx)(`div`,{className:`placeholder`,children:(0,G.jsxs)(`p`,{children:[`Couldn't open this gezel: `,c]})}):o?(0,G.jsxs)(`section`,{className:`gezel-detail${N===`chat`?` gezel-detail-chat`:``}`,"data-testid":`gezel-detail`,children:[(0,G.jsxs)(`header`,{className:`detail-header`,children:[(0,G.jsxs)(`span`,{className:`level-badge-anchor`,children:[(0,G.jsx)(R,{svg:o.icon??null,poppetje:o.poppetje,iconOverride:o.iconOverride,name:o.name,size:80,pulsing:f&&!o.icon&&!o.poppetje,onClick:()=>D(!0),title:o.iconOverride&&o.icon?`Click to iterate on this icon`:`Click to manage appearance`}),o.growth&&(0,G.jsx)(q,{level:o.growth.level,pending:!!o.growth.pending,overlay:!0})]}),(0,G.jsxs)(`div`,{className:`detail-header-text`,children:[A?(0,G.jsx)(`input`,{className:`rename-input`,value:O,onChange:e=>k(e.target.value),onBlur:()=>void V(),onKeyDown:oe}):(0,G.jsx)(`h3`,{className:`gezel-name-editable`,onClick:B,onKeyDown:e=>{e.key===`Enter`&&B()},title:`Click to rename`,children:o.name}),o.role&&(0,G.jsx)(`span`,{className:`gezel-role`,children:o.role}),o.fixedFunction?(0,G.jsxs)(`div`,{className:`provider-override`,children:[(0,G.jsxs)(`span`,{className:`gezel-role muted small ff-header-tag`,title:`Fixed-function gezel`,children:[`Fixed-function · forwards to `,(0,G.jsx)(`code`,{children:o.fixedFunction.tool})]}),P&&(0,G.jsx)(`span`,{className:`gezel-role muted small ff-header-tag`,title:`Generation model used by this gezel`,children:P})]}):(0,G.jsx)(st,{gezel:o,onUpdated:z})]}),(0,G.jsx)(`output`,{className:`status`,"aria-live":`polite`,children:I.phase===`error`?(0,G.jsxs)(G.Fragment,{children:[`save failed: `,I.error?.message??`unknown error`,` `,(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>void I.retry().catch(()=>{}),children:`Retry`})]}):u||(I.phase===`dirty`?`unsaved changes`:I.phase===`saving`?`saving…`:I.phase===`saved`?`saved`:null)}),(0,G.jsx)(ne,{gezel:o,onDeleted:t,boringMode:a})]}),(0,G.jsx)(ot,{open:E,gezel:o,isGenerating:f,onClose:()=>D(!1),onUpdated:z,setGenerating:p}),(0,G.jsx)(`div`,{className:`entity-tabs-row`,children:(0,G.jsx)(y,{value:N,onValueChange:e=>T(e),children:(0,G.jsxs)(v,{children:[(0,G.jsx)(_,{value:`chat`,children:`Chat`}),(0,G.jsx)(_,{value:`about`,children:`About`}),(0,G.jsx)(_,{value:`appearance`,children:`Appearance`}),(0,G.jsxs)(_,{value:`growth`,children:[`Growth`,o.growth?.pending&&(0,G.jsx)(`span`,{className:`growth-tab-dot`,title:`A level-up is waiting for your choice`,"aria-label":`Level-up pending`})]}),!M&&(0,G.jsx)(_,{value:`toolsets`,children:`Toolsets`}),!M&&(0,G.jsx)(_,{value:`memories`,children:`Memories`})]})})}),N===`appearance`&&(0,G.jsx)(et,{gezel:o,onUpdated:z}),N===`growth`&&(0,G.jsx)(Ve,{gezel:o,onUpdated:()=>{(async()=>{try{let e=await g.getGezel(o.id);F.current=e,s(e)}catch{}})()}}),!M&&N===`toolsets`&&(0,G.jsx)(pe,{scope:{kind:`gezel`,gezelId:o.id},subject:o.name}),N===`about`&&o.fixedFunction&&(0,G.jsx)(be,{gezel:o,onUpdated:z}),N===`about`&&!o.fixedFunction&&(0,G.jsxs)(`div`,{className:`editor-wrap`,children:[m&&(0,G.jsxs)(`div`,{className:`about-generating-banner`,children:[`Drafting `,(0,G.jsx)(`code`,{children:`about.md`}),` from the role…`]}),(0,G.jsx)(te,{initialMarkdown:o.about,onChange:re,height:`calc(100vh - 220px)`,colorScheme:i,showPlayTab:!1,fullWidth:!0,readOnly:m||b,toolbarSlotAfterActions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ge,{context:`about`}),(0,G.jsx)(je,{...o.role?{gezelRole:o.role}:{},...o.templateId?{gezelTemplateId:o.templateId}:{},onApply:async(e,t)=>{x(!0);try{if(!await I.saveNow(t))return;C(e=>e+1),d(`applied template`)}catch(e){d(`template apply failed: ${e.message}`)}finally{x(!1)}}}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,disabled:m||!o.role,title:o.role?`Re-draft about.md from the role`:`Set a role first to enable about generation`,onClick:async()=>{if(o.role){h(!0);try{await I.flush();let e=await g.generateGezelAbout(o.id,{role:o.role});I.adopt(e.about),F.current=e,C(e=>e+1),z(e)}catch(e){d(`about generation failed: ${e.message}`)}finally{h(!1)}}},children:m?`Drafting…`:`Draft from role`})]})},`${o.id}:${S}`)]}),N===`chat`&&(0,G.jsx)(Ee,{gezel:o,engineLabel:P,workingProjectIds:n,activeTurnsReady:r}),!M&&N===`memories`&&(0,G.jsx)(me,{gezelId:o.id,gezelName:o.name})]}):(0,G.jsx)(`p`,{className:`placeholder`,children:`Loading gezel…`})}function et({gezel:e,onUpdated:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),f=e.poppetje,p=async()=>{d(null),r(!0);try{let n=await g.rerollGezelPoppetje(e.id,{});t({...await g.getGezel(e.id),poppetje:n.poppetje})}catch(e){d(e.message)}finally{r(!1)}},m=async n=>{d(null),a(!0);try{t(await g.updateGezelSettings(e.id,{iconOverride:n?!0:null}))}catch(e){d(e.message)}finally{a(!1)}},h=async n=>{d(null),s(!0);try{t(await g.updateGezelSettings(e.id,{font:n||null}))}catch(e){d(e.message)}finally{s(!1)}};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`gezel-appearance`,"aria-label":`Appearance`,children:[(0,G.jsx)(`div`,{className:`gezel-appearance-hero`,"aria-label":`${e.name} portrait`,children:f?(0,G.jsx)(N,{poppetje:f,variant:`full`,size:160,grainStyle:`wavy`}):(0,G.jsx)(`span`,{className:`muted small`,children:`Generating…`})}),(0,G.jsxs)(`div`,{className:`gezel-appearance-actions`,children:[(0,G.jsxs)(`strong`,{children:[e.name,`'s appearance`]}),(0,G.jsxs)(`div`,{className:`gezel-appearance-buttons`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:p,disabled:n||!f,children:n?`Rerolling…`:`Reroll appearance`}),(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>l(!0),disabled:!f,title:`Add or remove worn items (hat, garment, accessory)`,children:`Accessories…`})]}),(0,G.jsx)(`span`,{className:`muted small`,children:`Reroll redraws everything (body, face, hair). Accessories let you toggle just the worn items.`}),e.icon&&(0,G.jsxs)(`label`,{className:`gezel-appearance-toggle`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!e.iconOverride,disabled:i,onChange:e=>void m(e.target.checked)}),`Show abstract icon instead of the poppetje`]}),u&&(0,G.jsx)(`p`,{className:`error small`,children:u})]}),(0,G.jsx)(at,{open:c,gezel:e,onClose:()=>l(!1),onUpdated:t})]}),(0,G.jsxs)(`section`,{className:`gezel-font-section`,"aria-label":`Chat font`,children:[(0,G.jsx)(`strong`,{children:`Chat font`}),(0,G.jsx)(dt,{value:e.font,onChange:e=>void h(e),disabled:o}),(0,G.jsxs)(`span`,{className:`muted small`,children:[`The typeface used for `,e.name,`'s chat bubbles. Inherits the app default unless overridden.`]})]})]})}var tt={cap:`Cap`,beanie:`Beanie`,kerchief:`Kerchief`,straw:`Straw hat`,newsboy:`Newsboy cap`,hood:`Hoodie`},nt={scarf:`Scarf`,apron:`Apron`,collar:`Collar`,turtleneck:`Turtleneck`},rt={glasses:`Glasses`,sunglasses:`Sunglasses`,cateye:`Cat-eye glasses`,readers:`Reading glasses`,monocle:`Monocle`,eyepatch:`Eye patch`,earrings:`Earrings`,"earring-left":`Left earring`,"earring-right":`Right earring`,flower:`Flower`,hairclip:`Hair clip`,headband:`Headband`,bowtie:`Bow tie`,necklace:`Necklace`,brooch:`Brooch`,facemask:`Face mask`,goggles:`Goggles`,"safety-glasses":`Safety glasses`,"pince-nez":`Pince-nez`,headphones:`Headphones`,"hearing-aid":`Hearing aid`,"nose-ring":`Nose ring`,"hoop-earrings":`Hoop earrings`,"drop-earrings":`Drop earrings`,"pearl-earrings":`Pearl earrings`,bandage:`Bandage`,feather:`Feather`,pencil:`Pencil`,ribbon:`Ribbon`,necktie:`Necktie`,cravat:`Cravat`,"bolo-tie":`Bolo tie`,lanyard:`Lanyard`,medal:`Medal`,"pocket-square":`Pocket square`,"tool-pendant":`Tool pendant`};function it({slot:e,option:t,label:n,selected:r,disabled:i,lockText:a,onSelect:o}){let s=a?.match(/\d+/)?.[0];return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,className:`accessory-tile${r?` selected`:``}${a?` locked`:``}`,disabled:i,onClick:o,title:a?`${n} — ${a}`:n,children:[(0,G.jsx)(`span`,{className:`accessory-tile-art`,children:e&&t?(0,G.jsx)(M,{slot:e,option:t,size:52}):(0,G.jsxs)(`svg`,{width:28,height:28,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,G.jsx)(`circle`,{cx:12,cy:12,r:9,fill:`none`,stroke:`currentColor`,strokeWidth:1.6}),(0,G.jsx)(`line`,{x1:6,y1:18,x2:18,y2:6,stroke:`currentColor`,strokeWidth:1.6})]})}),(0,G.jsx)(`span`,{className:`accessory-tile-label`,children:n}),s&&(0,G.jsxs)(`span`,{className:`accessory-tile-lock`,"aria-hidden":`true`,children:[`Lv `,s]})]})}function Q({slot:e,label:t,value:n,options:r,labels:i,locked:a,onChange:o,disabled:s}){return(0,G.jsxs)(`div`,{className:`accessory-section`,children:[(0,G.jsx)(`h4`,{className:`accessory-section-title`,children:t}),(0,G.jsxs)(`div`,{className:`accessory-tiles`,role:`radiogroup`,"aria-label":t,children:[(0,G.jsx)(it,{label:`None`,selected:n===null,disabled:s,onSelect:()=>o(null)}),r.map(t=>{let r=a?.[t];return(0,G.jsx)(it,{slot:e,option:t,label:i[t],selected:n===t,disabled:s||!!r,lockText:r,onSelect:()=>o(t)},t)})]})]})}function $(e,t,n){let r={};for(let i of c)i.slot===e&&(i.level<=t||n!==i.option&&(r[i.option]=`unlocks at level ${i.level}`));return r}function at({open:e,gezel:t,onClose:n,onUpdated:r}){let[i,a]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),l=t.poppetje,u=t.growth?.level??1,f=async e=>{if(l){c(null),a(!0);try{let n={...l,...e},i=await g.setGezelPoppetje(t.id,{poppetje:n});r({...t,poppetje:i.poppetje})}catch(e){c(e.message)}finally{a(!1)}}};return(0,G.jsx)(S,{open:e,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(A,{children:[(0,G.jsx)(C,{}),(0,G.jsxs)(w,{className:`accessories-dialog`,children:[(0,G.jsx)(T,{asChild:!0,children:(0,G.jsxs)(`h3`,{children:[t.name,`'s accessories`]})}),(0,G.jsx)(b,{className:`muted small`,children:`Add or remove worn items. Physical features — face, hair, skin, body — only change when you reroll.`}),(0,G.jsxs)(`div`,{className:`accessories-body`,children:[(0,G.jsx)(`div`,{className:`accessories-preview`,"aria-label":`${t.name} preview`,children:l?(0,G.jsx)(N,{poppetje:l,variant:`full`,size:150,grainStyle:`wavy`}):(0,G.jsx)(`span`,{className:`muted small`,children:`Generating…`})}),(0,G.jsxs)(`div`,{className:`accessories-controls`,children:[(0,G.jsx)(Q,{slot:`hat`,label:`Hat`,value:l?.hat??null,options:o,labels:tt,locked:$(`hat`,u,l?.hat??null),onChange:e=>void f({hat:e}),disabled:i||!l}),(0,G.jsx)(Q,{slot:`dress`,label:`Garment`,value:l?.dress??null,options:p,labels:nt,locked:$(`dress`,u,l?.dress??null),onChange:e=>void f({dress:e}),disabled:i||!l}),(0,G.jsx)(Q,{slot:`accessory`,label:`Accessory`,value:l?.accessory??null,options:d,labels:rt,locked:$(`accessory`,u,l?.accessory??null),onChange:e=>void f({accessory:e}),disabled:i||!l})]})]}),s&&(0,G.jsx)(`p`,{className:`gz-dialog-error`,children:s}),(0,G.jsx)(x,{children:(0,G.jsx)(`button`,{type:`button`,className:`primary`,onClick:n,children:`Done`})})]})]})})}function ot({open:e,gezel:t,isGenerating:n,onClose:r,onUpdated:i,setGenerating:a}){let[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)([]),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),m=(0,W.useCallback)(async()=>{try{let e=await g.listGezelIconHistory(t.id);l(e.history)}catch(e){p(e.message)}},[t.id]);(0,W.useEffect)(()=>{u&&m()},[u,m]);let h=async()=>{p(null),a(!0);try{i(await g.generateGezelIcon(t.id,o.trim()?{instruction:o.trim()}:{})),s(``),u&&await m()}catch(e){p(e.message)}finally{a(!1)}},_=async e=>{p(null);try{i(await g.revertGezelIcon(t.id,{timestamp:e})),await m()}catch(e){p(e.message)}};return(0,G.jsx)(S,{open:e,onOpenChange:e=>{e||r()},children:(0,G.jsxs)(A,{children:[(0,G.jsx)(C,{}),(0,G.jsxs)(w,{className:`iterate-dialog`,children:[(0,G.jsx)(T,{asChild:!0,children:(0,G.jsxs)(`h3`,{children:[`Iterate on `,t.name,`'s icon`]})}),(0,G.jsx)(`div`,{className:`iterate-preview`,children:(0,G.jsx)(R,{svg:t.icon??null,poppetje:t.poppetje,iconOverride:t.iconOverride,name:t.name,size:120,pulsing:n})}),(0,G.jsxs)(`label`,{children:[`What should change?`,(0,G.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:`e.g. make the colors warmer, try a cat shape, more geometric`,rows:3})]}),f&&(0,G.jsx)(`p`,{className:`error`,children:f}),(0,G.jsxs)(x,{children:[(0,G.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(e=>!e),children:u?`Hide history`:`Show history`}),(0,G.jsx)(`span`,{style:{flex:1}}),(0,G.jsx)(`button`,{type:`button`,onClick:r,children:`Close`}),(0,G.jsx)(`button`,{type:`button`,className:`primary`,onClick:h,disabled:n,children:n?`Generating…`:`Regenerate`})]}),u&&(0,G.jsxs)(`div`,{className:`icon-history-row`,children:[c.length===0&&(0,G.jsx)(`p`,{className:`muted`,children:`No previous variants yet.`}),c.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`icon-history-item`,onClick:()=>void _(e.timestamp),title:`Revert to ${e.timestamp}`,children:(0,G.jsx)(R,{svg:e.svg,iconOverride:!0,name:t.name,size:56})},e.timestamp))]})]})]})})}function st({gezel:e,onUpdated:t}){let[n,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(`copilot`);(0,W.useEffect)(()=>{g.getConfig().then(e=>o(e.provider)).catch(()=>{})},[]);let s=(0,W.useCallback)(async(n,r)=>{let a=(e.provider??null)!==(n??null);i(!0);try{t(await g.updateGezelSettings(e.id,{provider:n??null,model:r??null,...a||!r?{reasoningEffort:null}:{}}))}finally{i(!1)}},[e.id,e.provider,t]),c=(0,W.useCallback)(async n=>{i(!0);try{t(await g.updateGezelSettings(e.id,{reasoningEffort:n??null}))}finally{i(!1)}},[e.id,t]),l=(0,W.useCallback)(async n=>{i(!0);try{t(await g.updateGezelSettings(e.id,{sandboxCopilot:n==="default"?null:n===`on`}))}finally{i(!1)}},[e.id,t]),u=(0,W.useCallback)(async n=>{i(!0);try{t(await g.updateGezelSettings(e.id,{codexPermissionMode:n===`inherit`?null:n}))}finally{i(!1)}},[e.id,t]),d=(0,W.useCallback)(async n=>{i(!0);try{t(await g.updateGezelSettings(e.id,{retrieval:n===`inherit`?null:{...e.retrieval,mode:n}}))}finally{i(!1)}},[e.id,e.retrieval,t]),f=e.provider??a,p=e.sandboxCopilot===void 0?`default`:e.sandboxCopilot?`on`:`off`,m=e.codexPermissionMode?r(e.codexPermissionMode):`inherit`,h=e.retrieval?.mode??`inherit`;return(0,G.jsxs)(`div`,{className:`provider-override`,children:[(0,G.jsx)(`span`,{className:`muted small`,children:`Model:`}),(0,G.jsx)(Xe,{provider:e.provider??null,model:e.model,onChange:(e,t)=>void s(e,t),globalProvider:a,disabled:n}),(0,G.jsx)(ye,{provider:f,model:e.model,value:e.reasoningEffort,onChange:e=>void c(e)}),(0,G.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},title:`How much relevant indexed project knowledge is added to each substantive turn. Search remains available in Off mode.`,children:`Context:`}),[`inherit`,`off`,`lean`,`balanced`,`deep`].map(e=>(0,G.jsx)(`button`,{type:`button`,className:`provider-chip${h===e?` provider-chip-active`:``}`,onClick:()=>void d(e),disabled:n,children:e===`inherit`?`Inherit`:e===`off`?`Off`:e[0].toUpperCase()+e.slice(1)},e)),f===`copilot`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},title:`Deny the Copilot CLI's built-in tools (bash, web_fetch, file edit, grep) and force this gezel through our MCP tools.`,children:`Sandbox:`}),[`default`,`on`,`off`].map(e=>(0,G.jsx)(`button`,{type:`button`,className:`provider-chip${p===e?` provider-chip-active`:``}`,onClick:()=>void l(e),disabled:n,children:e==="default"?`Inherit`:e===`on`?`On`:`Off`},e))]}),f===`codex-cli`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},title:`Override this gezel's Codex execution posture. A project-level choice still takes precedence.`,children:`Access:`}),[`inherit`,`plan`,`edit`,`reviewed`,`full`].map(e=>(0,G.jsx)(`button`,{type:`button`,className:`provider-chip${m===e?` provider-chip-active`:``}`,onClick:()=>void u(e),disabled:n,children:e===`inherit`?`Inherit`:e===`plan`?`Plan`:e===`edit`?`Edit`:e===`reviewed`?`Reviewed`:`Full`},e))]}),e.model&&(0,G.jsx)(ct,{gezel:e,effectiveProvider:f,onUpdated:t})]})}function ct({gezel:e,effectiveProvider:t,onUpdated:n}){let[r,i]=(0,W.useState)(void 0),a=(0,W.useCallback)(async()=>{if(!(r!==void 0||!e.model))try{let[t,n]=await Promise.all([g.getCatalogItem(`chat-model`,e.model).catch(()=>null),g.getConfig().catch(()=>null)]),r=t&&t.manifest.kind===`chat-model`?t.manifest.tuning:void 0,a=n?.modelTuning?.[e.model],o=lt(r,a);o&&i(o)}catch{}},[r,e.model]);return(0,G.jsxs)(`details`,{className:`gezel-tuning-disclosure`,style:{flexBasis:`100%`,marginTop:`0.5rem`},onToggle:e=>{e.target.open&&a()},children:[(0,G.jsx)(`summary`,{className:`muted small`,style:{cursor:`pointer`},children:`Advanced tuning`}),(0,G.jsx)(`div`,{style:{marginTop:`0.5rem`},children:(0,G.jsx)(Me,{gezel:e,...r?{inherited:r}:{},effectiveProvider:t,onUpdated:n})})]})}function lt(e,t){if(!(!e&&!t))return e?t?ut(e,t):e:t}function ut(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];t&&typeof t==`object`&&!Array.isArray(t)&&r&&typeof r==`object`&&!Array.isArray(r)?n[e]=ut(t,r):n[e]=r}return n}function dt({value:e,onChange:t,disabled:n}){let r=`__default`,i=e&&e.length>0?e:r,a=i===r?`Inherit default`:l.find(e=>e.id===i)?.label??`Inherit default`,o=l.find(e=>e.id===i)?.family;return(0,G.jsxs)(E,{value:i,onValueChange:e=>t(e===r?``:e),disabled:n,children:[(0,G.jsx)(k,{className:`gezel-font-picker`,title:`Font used for this gezel's chat bubbles`,style:o?{fontFamily:o}:void 0,"aria-label":`Chat bubble font`,children:(0,G.jsx)(O,{children:a})}),(0,G.jsxs)(j,{children:[(0,G.jsx)(D,{value:r,children:`Inherit default`}),l.map(e=>(0,G.jsx)(D,{value:e.id,style:{fontFamily:e.family},children:e.label},e.id))]})]})}export{$e as GezelDetail,q as t};
|