@harperfast/harper 5.3.2 → 5.3.3
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/bin/cliOperations.ts +3 -3
- package/bin/copyDb.ts +4 -3
- package/components/DESIGN.md +12 -0
- package/components/packageComponent.ts +42 -17
- package/config/DESIGN.md +4 -0
- package/config/configUtils.ts +8 -8
- package/config/parseConfigFile.ts +11 -7
- package/dist/bin/cliOperations.js +3 -3
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/copyDb.js +3 -3
- package/dist/bin/copyDb.js.map +1 -1
- package/dist/components/packageComponent.d.ts +9 -7
- package/dist/components/packageComponent.js +41 -16
- package/dist/components/packageComponent.js.map +1 -1
- package/dist/config/configUtils.js +4 -3
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/parseConfigFile.d.ts +1 -0
- package/dist/config/parseConfigFile.js +7 -3
- package/dist/config/parseConfigFile.js.map +1 -1
- package/dist/resources/DatabaseTransaction.d.ts +75 -10
- package/dist/resources/DatabaseTransaction.js +1080 -277
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/Resource.js +40 -14
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.js +1 -0
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.js +16 -2
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/write.js +34 -16
- package/dist/resources/analytics/write.js.map +1 -1
- package/dist/resources/databases.d.ts +5 -0
- package/dist/resources/databases.js +38 -4
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/recordLock.d.ts +9 -4
- package/dist/resources/recordLock.js +79 -19
- package/dist/resources/recordLock.js.map +1 -1
- package/dist/server/DurableSubscriptionsSession.d.ts +2 -0
- package/dist/server/DurableSubscriptionsSession.js +20 -17
- package/dist/server/DurableSubscriptionsSession.js.map +1 -1
- package/dist/server/mqtt.js +41 -23
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/serverHelpers/NodeAdapterResponse.js +18 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js.map +1 -1
- package/dist/utility/npmUtilities.js +18 -7
- package/dist/utility/npmUtilities.js.map +1 -1
- package/package.json +1 -1
- package/resources/DESIGN.md +42 -10
- package/resources/DatabaseTransaction.ts +1244 -275
- package/resources/Resource.ts +39 -14
- package/resources/RocksTransactionLogStore.ts +1 -0
- package/resources/Table.ts +24 -2
- package/resources/analytics/DESIGN.md +17 -0
- package/resources/analytics/write.ts +28 -15
- package/resources/databases.ts +40 -4
- package/resources/record-locks.md +34 -17
- package/resources/recordLock.ts +89 -22
- package/server/DESIGN.md +2 -0
- package/server/DurableSubscriptionsSession.ts +18 -16
- package/server/mqtt.ts +39 -22
- package/server/serverHelpers/NodeAdapterResponse.ts +19 -1
- package/studio/web/assets/Chat-B-Rd-ft9.js +2100 -0
- package/studio/web/assets/FloatingChat-CFypO7kh.js +23 -0
- package/studio/web/assets/SearchDialog-BRIyPiBl.js +1 -0
- package/studio/web/assets/{abnfDiagram-O67JEVCF-raXE027J.js → abnfDiagram-YUKMZFIV-DPR2lFRk.js} +1 -1
- package/studio/web/assets/{apiToken-DNrfij0E.js → apiToken-BraYnzvC.js} +1 -1
- package/studio/web/assets/applications-XCds8-ZP.js +296 -0
- package/studio/web/assets/architecture-WOLXFQ4H-DtJHIK0_.js +1 -0
- package/studio/web/assets/{architectureDiagram-NJMV4G6O-C8_Eet7w.js → architectureDiagram-47P4ROYG-MDymp2dh.js} +3 -3
- package/studio/web/assets/authStore-DE1HFvVP.js +3 -0
- package/studio/web/assets/{blockDiagram-BEXU5L5S-DR6S5-1D.js → blockDiagram-E7TT5TSB-O5qRgZmd.js} +3 -3
- package/studio/web/assets/button-C37w80Uk.js +21 -0
- package/studio/web/assets/{c4Diagram-YGBWAQC7-BAfZ1G01.js → c4Diagram-CRA5TL53-BdPORGHo.js} +2 -2
- package/studio/web/assets/channel-yCStoq0_.js +1 -0
- package/studio/web/assets/{chevron-up-CFxbMGv2.js → chevron-up-DozwrIz-.js} +1 -1
- package/studio/web/assets/chunk-2BW5OAIV-DJ-iXJAw.js +10 -0
- package/studio/web/assets/{chunk-ZIGJFQKS-Cs8fUn7y.js → chunk-3YJQHVM4-BOgacqS1.js} +2 -2
- package/studio/web/assets/{chunk-7PRAP22T-KyqX6x3f.js → chunk-4EA7E6EY-C-7xqUBl.js} +1 -1
- package/studio/web/assets/{chunk-GWA4HPMP-DsejB6gA.js → chunk-7TKQ45FW-C3XA1bIN.js} +1 -1
- package/studio/web/assets/{chunk-GTNCS2PH-DGHLXyow.js → chunk-AW2ZBBNX-BdvgD1UW.js} +3 -3
- package/studio/web/assets/{chunk-5DYCD2WN-BceBfIHT.js → chunk-DBDB3WZW-CKKxIc6F.js} +1 -1
- package/studio/web/assets/{chunk-MBY4JIJT-BwSGweQP.js → chunk-E2ZNV5FY-bVefNHvz.js} +3 -3
- package/studio/web/assets/chunk-EU5HNXII-BHv2kWp4.js +213 -0
- package/studio/web/assets/chunk-FVRAUYC3-BoL_NO6b.js +2 -0
- package/studio/web/assets/{chunk-742MDFTN-CIkt8ijt.js → chunk-HJ2JQQFS-N_98oMRS.js} +1 -1
- package/studio/web/assets/{chunk-NETBCI7D-C8UnOw_f.js → chunk-HTAEGDNF-BQ1fSjPs.js} +1 -1
- package/studio/web/assets/{chunk-WEXAMYUT-BAIhTwyh.js → chunk-KQW6MTUR-qP0QiQAg.js} +1 -1
- package/studio/web/assets/chunk-NGNAAXSQ-DqoPQk1a.js +136 -0
- package/studio/web/assets/{chunk-UA2S7LBM-BHpEdH8D.js → chunk-NTY3LDVX-CSBFjlJg.js} +1 -1
- package/studio/web/assets/chunk-VPRB5NB3-BVHOe9Q-.js +129 -0
- package/studio/web/assets/{chunk-7INBJB4K-BpeAXyOi.js → chunk-XC4XBNZT-46uQwtF4.js} +10 -10
- package/studio/web/assets/{classDiagram-v2-NBCMYWYE-DmDPkt2u.js → classDiagram-v2-K4WV4PDN-Da0ps1Ui.js} +3 -3
- package/studio/web/assets/cn-DpF1PxBT.js +1 -0
- package/studio/web/assets/{createLucideIcon-fO5dL7D5.js → createLucideIcon-DLWRoWN-.js} +1 -1
- package/studio/web/assets/{cssMode-DBucrQdT.js → cssMode-BY1w91l8.js} +1 -1
- package/studio/web/assets/cynefin-EF2NZ3EQ-jQ2eCUaU.js +1 -0
- package/studio/web/assets/cynefinDiagram-3GCD6N5R-TNi5iS0E.js +62 -0
- package/studio/web/assets/dagre-W4DXFKR2-BnLHmA44.js +4 -0
- package/studio/web/assets/{diagram-22UHCM2B-DJCvcaWP.js → diagram-2UJZ2QOL-r_jehhZR.js} +7 -7
- package/studio/web/assets/{diagram-3UASUU5V-Du6VKWln.js → diagram-OVF4WLC6-BSUXGVh8.js} +11 -11
- package/studio/web/assets/{diagram-CDSNMT55-l5Ga0u-W.js → diagram-PFPMY2P6-BrVedycw.js} +3 -3
- package/studio/web/assets/{diagram-MLGK6HIB-CNQY47LA.js → diagram-UMYRVEAY-CBIaakBB.js} +1 -1
- package/studio/web/assets/diagram-YEKJPTXX-DFmmDXCl.js +41 -0
- package/studio/web/assets/diagram-ZIFT7M5P-CQfOWxOi.js +3 -0
- package/studio/web/assets/dist-9lpzt2Hn.js +11 -0
- package/studio/web/assets/{ebnfDiagram-ZINNZB2B-5OnkTpfi.js → ebnfDiagram-VR2GEFS7-FXA3Xe6e.js} +1 -1
- package/studio/web/assets/{editor-CHpQCuBq.js → editor-D5mpVs1b.js} +1 -1
- package/studio/web/assets/elk-IJKZMXRS-CC4gfVRU.js +27 -0
- package/studio/web/assets/{erDiagram-OPXOYQCR-CQlCX84D.js → erDiagram-O2IAPWRE-C-BkDTPl.js} +2 -2
- package/studio/web/assets/errorText-8xV8WZBt.js +1 -0
- package/studio/web/assets/eventmodeling-K75KTNOO-D0dJ_PbR.js +1 -0
- package/studio/web/assets/flowDiagram-OXPTDLAJ-C1LEc_Hf.js +1 -0
- package/studio/web/assets/{ganttDiagram-FUAMR5RP-bloX3Voy.js → ganttDiagram-R7TSEDQI-85F44BIo.js} +4 -4
- package/studio/web/assets/{getAnalytics-C0FHjtdQ.js → getAnalytics-B1xpd4kG.js} +1 -1
- package/studio/web/assets/gitGraph-VSP46ZUC-BBmqrmjK.js +1 -0
- package/studio/web/assets/gitGraphDiagram-XJZIOB7I-CFY6iMwg.js +106 -0
- package/studio/web/assets/graphlib-DS17s2tU.js +1 -0
- package/studio/web/assets/{html-B1iA8q38.js → html-DiXKiahz.js} +1 -1
- package/studio/web/assets/{htmlMode-CrL3YO5Y.js → htmlMode-DitVJ707.js} +1 -1
- package/studio/web/assets/index-CDnn0-PN.css +1 -0
- package/studio/web/assets/index-D8kyF6dt.js +833 -0
- package/studio/web/assets/index.lazy-DgbjUxLo.js +1 -0
- package/studio/web/assets/info-OHQRW6UA-Bs2aEco7.js +1 -0
- package/studio/web/assets/{infoDiagram-VRGFBTTK-B0J1132p.js → infoDiagram-5W2HQ5XZ-d6yG1yfZ.js} +1 -1
- package/studio/web/assets/invalidateEntityQueries-BkWXiqjz.js +1 -0
- package/studio/web/assets/{ishikawaDiagram-OU5B5YK6-BNk0tuQx.js → ishikawaDiagram-K3B6WC7H-CSYz-WRA.js} +2 -2
- package/studio/web/assets/{javascript-CXgQMkoa.js → javascript-BBVXeMDm.js} +1 -1
- package/studio/web/assets/{journeyDiagram-ZHPQQLJL-Be79RMQM.js → journeyDiagram-COXZFDF6-BDj6Wqcj.js} +3 -3
- package/studio/web/assets/{jsonMode-DycqRKOv.js → jsonMode-D85_j2oD.js} +1 -1
- package/studio/web/assets/{kanban-definition-PNTS6WVX-4uuoQP9W.js → kanban-definition-P3RFRI5V-C2Bjfbp-.js} +6 -6
- package/studio/web/assets/{languageServices-HYHV1wDJ.js → languageServices-U3mWhpRL.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-CH_6SYiA.js → lspLanguageFeatures-CoymyM3c.js} +1 -1
- package/studio/web/assets/{mermaid-parser.core-V1UYMeXV.js → mermaid-parser.core-Ch_T61iL.js} +6 -6
- package/studio/web/assets/mermaid.core-BOAgKzo5.js +44 -0
- package/studio/web/assets/{mindmap-definition-NLK3R4M7-C70Ctm0J.js → mindmap-definition-LZFPQGKD-DzOapzMM.js} +3 -3
- package/studio/web/assets/notifications-CPgEC6ZP.js +1 -0
- package/studio/web/assets/notifications-D_VqhHnx.js +1 -0
- package/studio/web/assets/operations-D8aaKYty.js +4 -0
- package/studio/web/assets/packet-JDAUHWVQ-CGHB_EIE.js +1 -0
- package/studio/web/assets/{pegDiagram-GJSIUBJH-d6z1cc7W.js → pegDiagram-BGZESJAR-ADzOIKrz.js} +1 -1
- package/studio/web/assets/pie-XZMESJXO-Bijz5Y2o.js +1 -0
- package/studio/web/assets/pieDiagram-CAPJLFHJ-VM7fvbwO.js +39 -0
- package/studio/web/assets/profile-DM5E6Xls.js +1 -0
- package/studio/web/assets/{quadrantDiagram-O4NWA36T-CIF5Qkou.js → quadrantDiagram-GDMTTRAM-Bmza84_j.js} +3 -3
- package/studio/web/assets/radar-ABXABTNO-IaC8pB63.js +1 -0
- package/studio/web/assets/railroad-I3PHUGI6-CCrSUqeq.js +1 -0
- package/studio/web/assets/railroad-abnf-LNEFI6M7-BhobVp-t.js +1 -0
- package/studio/web/assets/railroad-ebnf-DWYD2UWJ-OHhGUTEh.js +1 -0
- package/studio/web/assets/railroad-peg-JR7BVNR7-FupC3Jcn.js +1 -0
- package/studio/web/assets/{railroadDiagram-XR7U4H2S-y3Jv2U6N.js → railroadDiagram-SM67HX2B-CgFGOVI5.js} +1 -1
- package/studio/web/assets/regions-WFvXqryO.js +1 -0
- package/studio/web/assets/{register-DCN4QUii.js → register-B7DvfAGj.js} +3 -3
- package/studio/web/assets/request-ChoMERRk.js +2 -0
- package/studio/web/assets/{requirementDiagram-PLB6GJNP-ChINZEmu.js → requirementDiagram-X7JNWC4A-BHoQgkoT.js} +4 -4
- package/studio/web/assets/restartGate-D_e93lFE.js +1 -0
- package/studio/web/assets/restartUnconfirmed-BqcDZ__Y.js +1 -0
- package/studio/web/assets/sankeyDiagram-UM26HJRW-8tFu_oUe.js +40 -0
- package/studio/web/assets/sequenceDiagram-ZO4K6R2Y-jryb1rwT.js +169 -0
- package/studio/web/assets/setComponentFile-BHk22Rh6.js +1 -0
- package/studio/web/assets/setup-wNdpTrVH.js +2 -0
- package/studio/web/assets/{stateDiagram-v2-GCMORJYK-Bs8RIb9K.js → stateDiagram-v2-TBUQTH76-CnWE5yFn.js} +2 -2
- package/studio/web/assets/status-CYoonm9V.js +61 -0
- package/studio/web/assets/{swimlanes-2SLR337P-B52xrf6t.js → swimlanes-N4OXWK64-CBlFzDJn.js} +1 -1
- package/studio/web/assets/swimlanesDiagram-K3J5GTZL-DvFLtUPi.js +8 -0
- package/studio/web/assets/{timeline-definition-EJHVYXUP-DJSITpQX.js → timeline-definition-YOQAKGHF-CFWqHrqI.js} +4 -4
- package/studio/web/assets/{toggleHighContrast-CfAp6Sxb.js → toggleHighContrast-CKEm-P4K.js} +1 -1
- package/studio/web/assets/treeView-D4JQ5SDB-CpV9zuVb.js +1 -0
- package/studio/web/assets/treemap-SAJKECNS-Bc94Tqiq.js +1 -0
- package/studio/web/assets/{tsMode-HZR0bfq4.js → tsMode-Dv35qHmn.js} +1 -1
- package/studio/web/assets/{typescript-UMJSfZyF.js → typescript-Bly1EW8o.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-B379CS-h.js → useEntityRestURL-Cg3P0MOb.js} +1 -1
- package/studio/web/assets/usecaseDiagram-VIAY4XPW-Brf2xP3S.js +328 -0
- package/studio/web/assets/{vendor-core-6LhfJlRC.js → vendor-core-PejxhUWQ.js} +1 -1
- package/studio/web/assets/vendor-datadog-GjET_Cbn.js +6 -0
- package/studio/web/assets/{vendor-react-BOliS0BL.js → vendor-react-DSIx92Ld.js} +1 -1
- package/studio/web/assets/vendor-tanstack-C5Y-nrd2.js +2 -0
- package/studio/web/assets/vendor-ui-BBWHOEoQ.js +41 -0
- package/studio/web/assets/{vennDiagram-UO4OBE2U-DZTsDA4k.js → vennDiagram-BLWOH2XV-XxOyJPq_.js} +3 -3
- package/studio/web/assets/wardley-7MLQ67FV-DRW0zuE4.js +1 -0
- package/studio/web/assets/{wardleyDiagram-VNRHLVJA-qu_f7Tvl.js → wardleyDiagram-YMQ3BMBF-B3WskJ9W.js} +3 -3
- package/studio/web/assets/wasAReleasedBeforeB-D5grAaGM.js +1 -0
- package/studio/web/assets/{workers-Bn_0_L1R.js → workers-DVtjrvUa.js} +1 -1
- package/studio/web/assets/{xml-CG2N-1r1.js → xml-DjAPbgLN.js} +1 -1
- package/studio/web/assets/xychartDiagram-TAQBALBS-D5NV4Env.js +7 -0
- package/studio/web/assets/{yaml-68pda6Av.js → yaml-oTUyoJy1.js} +1 -1
- package/studio/web/index.html +17 -15
- package/utility/npmUtilities.ts +17 -7
- package/studio/web/assets/Chat-CrxPD4ph.js +0 -2294
- package/studio/web/assets/FloatingChat-EXzoUQ-9.js +0 -23
- package/studio/web/assets/SearchDialog-7qRL8Yqx.js +0 -1
- package/studio/web/assets/_basePickBy-QJXUw_pr.js +0 -1
- package/studio/web/assets/_baseUniq-DR4vVjyC.js +0 -1
- package/studio/web/assets/alertDialog-BbWD9Xxa.js +0 -1
- package/studio/web/assets/applications-CdqjiSQe.js +0 -296
- package/studio/web/assets/architecture-7GRP2DOG-DDmz3hpI.js +0 -1
- package/studio/web/assets/arrow-up-D2g_57vT.js +0 -1
- package/studio/web/assets/authStore-CJCaADw9.js +0 -3
- package/studio/web/assets/button-DWwfgGWI.js +0 -21
- package/studio/web/assets/channel-D0AkPjJ8.js +0 -1
- package/studio/web/assets/chunk-3FUC2YCW-DuRp-j19.js +0 -2
- package/studio/web/assets/chunk-7M6MHVWA-h6WlaTzO.js +0 -213
- package/studio/web/assets/chunk-FOHPRMQF-DzxwRta7.js +0 -161
- package/studio/web/assets/chunk-O7XYJQB3-CBS3nZYV.js +0 -128
- package/studio/web/assets/chunk-Z7XXMR3K-DSHbImdf.js +0 -10
- package/studio/web/assets/cn-6T8VranJ.js +0 -1
- package/studio/web/assets/cynefin-OW5HDTMX-DIvbXLSj.js +0 -1
- package/studio/web/assets/cynefinDiagram-VND7K2PF-BdtaXiCE.js +0 -62
- package/studio/web/assets/dagre-6A5THRUB-C7RUWHyz.js +0 -4
- package/studio/web/assets/diagram-ATOU4E4O-dxRfeG4B.js +0 -3
- package/studio/web/assets/diagram-MPIPVDR6-7prveD1B.js +0 -41
- package/studio/web/assets/dist-BrRuMUzt.js +0 -11
- package/studio/web/assets/download-Cn6tPG4L.js +0 -1
- package/studio/web/assets/elk-276RUBZZ-DxDQPjQT.js +0 -27
- package/studio/web/assets/errorText-NpBmvk9I.js +0 -1
- package/studio/web/assets/eventmodeling-NTZA5JFV-DONQf5aG.js +0 -1
- package/studio/web/assets/flowDiagram-KWPJA3E3-BoZ8_QR1.js +0 -1
- package/studio/web/assets/gitGraph-4MIJSDKK-BrXWmJt2.js +0 -1
- package/studio/web/assets/gitGraphDiagram-X574FWY7-C2KnnZeY.js +0 -106
- package/studio/web/assets/graphlib-C9Tl7QrK.js +0 -1
- package/studio/web/assets/index-QLZw6xrU.css +0 -1
- package/studio/web/assets/index-qCLyhyah.js +0 -828
- package/studio/web/assets/index.lazy-DCx-DxIV.js +0 -2
- package/studio/web/assets/info-A6RAGUB7-BhzBHe4U.js +0 -1
- package/studio/web/assets/mermaid.core-1PX6R49U.js +0 -44
- package/studio/web/assets/notifications-BSObVIY1.js +0 -1
- package/studio/web/assets/notifications-DFLXk68b.js +0 -1
- package/studio/web/assets/packet-AYTQ26CC-DWbXHx5g.js +0 -1
- package/studio/web/assets/pie-WAS4IAKB-DjoTm3yr.js +0 -1
- package/studio/web/assets/pieDiagram-5QR66LMP-Dz3RHpDA.js +0 -39
- package/studio/web/assets/profile-TBjzOMIy.js +0 -1
- package/studio/web/assets/radar-RG4KPBEZ-CVBgjCOj.js +0 -1
- package/studio/web/assets/railroad-74A4TZTK-BdhXw10Q.js +0 -1
- package/studio/web/assets/railroad-abnf-HS5TGJTU-BcoQPN39.js +0 -1
- package/studio/web/assets/railroad-ebnf-LZEXJU2U-B1Lke2JN.js +0 -1
- package/studio/web/assets/railroad-peg-WCYAUIDC-D-oJFkiV.js +0 -1
- package/studio/web/assets/regions-C4an4H7e.js +0 -1
- package/studio/web/assets/restartGate-nHAFLDh-.js +0 -1
- package/studio/web/assets/sankeyDiagram-IPEJSGJF-D9AyLce2.js +0 -40
- package/studio/web/assets/sequenceDiagram-PO4LG4MO-hfk4aIEm.js +0 -169
- package/studio/web/assets/setComponentFile-BrqOM1Zm.js +0 -1
- package/studio/web/assets/setup-0v2MCm-E.js +0 -2
- package/studio/web/assets/status-DdezofUu.js +0 -61
- package/studio/web/assets/swimlanesDiagram-TC7HE7FX-DfN7BAP5.js +0 -8
- package/studio/web/assets/tabs-BCTQzoQK.js +0 -1
- package/studio/web/assets/treeView-Q6P3EWNA-C-epdxRo.js +0 -1
- package/studio/web/assets/treemap-WGGIJYW6-DOVyp_zw.js +0 -1
- package/studio/web/assets/usecaseDiagram-POWQR4AR-B6252cbq.js +0 -328
- package/studio/web/assets/vendor-datadog-ozKf-pts.js +0 -6
- package/studio/web/assets/vendor-tanstack-Bntfka-M.js +0 -2
- package/studio/web/assets/vendor-ui-9EYYDgoN.js +0 -41
- package/studio/web/assets/wardley-WFR3VGLG-Cfqoe6z4.js +0 -1
- package/studio/web/assets/xychartDiagram-PMCCYNJV-UrOKRsmR.js +0 -7
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SearchDialog-BRIyPiBl.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/vendor-datadog-GjET_Cbn.js","assets/vendor-react-DSIx92Ld.js","assets/vendor-tanstack-C5Y-nrd2.js","assets/notifications-CPgEC6ZP.js","assets/cn-DpF1PxBT.js","assets/vendor-core-PejxhUWQ.js","assets/button-C37w80Uk.js","assets/vendor-ui-BBWHOEoQ.js","assets/regions-WFvXqryO.js","assets/chevron-up-DozwrIz-.js","assets/createLucideIcon-DLWRoWN-.js","assets/apiToken-BraYnzvC.js","assets/setup-wNdpTrVH.js","assets/dist-9lpzt2Hn.js","assets/register-B7DvfAGj.js","assets/register-DjpsE8to.css","assets/editor-D5mpVs1b.js","assets/toggleHighContrast-CKEm-P4K.js","assets/toggleHighContrast-n7clI0si.css","assets/index.lazy-DgbjUxLo.js","assets/authStore-DE1HFvVP.js","assets/restartGate-D_e93lFE.js","assets/setSessionStorage-B0bf71m4.js","assets/safeParse-DeaoCCWH.js","assets/localStorageKeys-etzFY_xV.js","assets/wasAReleasedBeforeB-D5grAaGM.js","assets/useEntityRestURL-Cg3P0MOb.js","assets/request-ChoMERRk.js","assets/applications-XCds8-ZP.js","assets/setComponentFile-BHk22Rh6.js","assets/errorText-8xV8WZBt.js","assets/restartUnconfirmed-BqcDZ__Y.js","assets/invalidateEntityQueries-BkWXiqjz.js","assets/languageServices-U3mWhpRL.js","assets/applications-DNZhsH95.css","assets/FloatingChat-CFypO7kh.js","assets/operations-D8aaKYty.js","assets/status-CYoonm9V.js","assets/linear-Ds1AeO4V.js","assets/step-vX8bovaY.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CPleeUAT.js","assets/time-Ci1v4fvT.js","assets/band-DZ4Jagyz.js","assets/getAnalytics-B1xpd4kG.js","assets/notifications-D_VqhHnx.js","assets/profile-DM5E6Xls.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{_ as n,a as r,b as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,t as m,v as h,x as g,y as _}from"./authStore-DE1HFvVP.js";import{D as v,E as y,_ as b,b as x,d as S,g as C,i as w,j as T,k as E,o as D,p as O,r as k,s as A,t as j,u as M,v as ee,x as te,y as N}from"./vendor-core-PejxhUWQ.js";import{n as P,t as F}from"./cn-DpF1PxBT.js";import{a as ne,c as re,d as ie,f as ae,h as oe,i as se,l as ce,o as le,r as ue,s as de,u as fe}from"./restartGate-D_e93lFE.js";import{a as pe,n as me,o as he,t as ge}from"./vendor-datadog-GjET_Cbn.js";import{r as _e,t as ve}from"./vendor-react-DSIx92Ld.js";import{A as ye,B as be,C as xe,D as Se,F as Ce,G as we,H as I,J as Te,K as L,L as Ee,M as De,N as Oe,O as R,P as z,Q as ke,S as Ae,T as je,U as Me,V as Ne,W as B,X as Pe,Y as Fe,Z as Ie,_ as Le,a as Re,b as ze,c as Be,d as Ve,et as He,f as Ue,g as We,h as Ge,i as Ke,j as qe,k as V,l as Je,m as Ye,n as Xe,nt as Ze,o as Qe,p as $e,q as et,r as tt,s as nt,t as rt,tt as it,u as at,v as ot,w as st,x as ct,y as lt,z as ut}from"./vendor-tanstack-C5Y-nrd2.js";import{n as dt,t as ft}from"./setSessionStorage-B0bf71m4.js";import{n as pt,t as H}from"./button-C37w80Uk.js";import{$ as mt,A as ht,At as gt,B as _t,Bt as vt,C as yt,Ct as bt,D as xt,Dt as St,E as Ct,Et as wt,F as Tt,Ft as Et,G as Dt,H as Ot,I as kt,It as At,J as jt,K as Mt,L as Nt,Lt as Pt,M as Ft,Mt as It,N as Lt,Nt as Rt,O as zt,Ot as Bt,P as Vt,Pt as Ht,Q as Ut,R as Wt,Rt as Gt,S as Kt,St as qt,T as Jt,Tt as Yt,U as Xt,V as Zt,W as Qt,X as $t,Y as en,Z as tn,_ as nn,_t as rn,a as an,at as on,b as sn,bt as cn,c as ln,ct as un,d as dn,dt as fn,et as pn,f as mn,ft as hn,g as gn,gt as _n,h as vn,ht as yn,i as bn,it as xn,j as Sn,jt as Cn,k as wn,kt as Tn,l as En,lt as Dn,m as On,mt as kn,n as An,nt as jn,o as Mn,ot as Nn,p as Pn,pt as Fn,q as In,r as Ln,rt as Rn,s as zn,st as Bn,t as Vn,tt as Hn,u as Un,ut as Wn,v as Gn,vt as Kn,w as qn,wt as Jn,x as Yn,xt as Xn,y as Zn,yt as Qn,z as $n,zt as U}from"./vendor-ui-BBWHOEoQ.js";import{t as W}from"./createLucideIcon-DLWRoWN-.js";import{n as er,r as tr,t as nr}from"./chevron-up-DozwrIz-.js";import{a as rr,c as ir,i as ar,l as or,n as sr,o as cr,r as lr,s as ur,t as dr}from"./restartUnconfirmed-BqcDZ__Y.js";import{n as fr,t as pr}from"./errorText-8xV8WZBt.js";import{t as mr}from"./invalidateEntityQueries-BkWXiqjz.js";import{n as hr,r as gr,t as _r}from"./localStorageKeys-etzFY_xV.js";import{n as vr,t as yr}from"./wasAReleasedBeforeB-D5grAaGM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(he(),1);function br(){let[e,t]=(0,G.useState)(()=>({...u.getAllConnections()}));return(0,G.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function xr(){let e=u.calculateIdFromEntity(m),[t,n]=(0,G.useState)(u.getConnectionById(m));return(0,G.useEffect)(()=>u.listenToEntity(e,n),[e]),t}function Sr(){return xr()}function Cr(e,t){return!e||!(`fabricRole`in e)?!1:e.staffPermissions?e.staffPermissions.includes(t):e.fabricRole===`fabric_admin`||e.fabricRole===`super_user`}function wr(e){let{user:t}=Sr();return Cr(t,e)}function Tr(e){let{clusterId:t,instanceId:n}=z({strict:!1}),r=m,[i,a]=(0,G.useState)(()=>({key:r,connection:u.getConnectionById(r)}));return(0,G.useEffect)(()=>u.listenToEntity(r,e=>a({key:r,connection:e})),[r]),i.key===r?i.connection:u.getConnectionById(r)}var K=_e();function Er({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card`,className:F(`bg-card text-card-foreground flex flex-col gap-4 rounded-2xl py-5 shadow-deep ring-1 ring-black/5 dark:ring-white/5`,e),...t})}function Dr({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-header`,className:F(`flex flex-col gap-1.5 px-6`,e),...t})}function Or({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-title`,className:F(`leading-none text-lg`,e),...t})}function kr({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-description`,className:F(`text-muted-foreground text-xs`,e),...t})}function Ar({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-content`,className:F(`px-6`,e),...t})}function jr(e){try{return e?.response?.status??e?.status}catch{return}}function Mr(e){return e!==null&&!!e.username}function Nr(e){if(!e||Mr(e))return[];let t=Cr(e,`org:read`);return Object.entries(e.roles??{}).map(([e,n])=>({id:e,name:n.organizationName||e,roleName:n.role??`fabric staff`,locked:`oauthProviders`in n&&!t,providers:n.oauthProviders??[]})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function Pr(e){let t=Nr(e);return t.length===1&&!t[0].locked?`/${t[0].id}`:`/`}var Fr={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};Fr.node;var Ir=W(Fr),Lr={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Lr.node;var Rr=W(Lr),zr={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};zr.node;var Br=W(zr),Vr={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Vr.node;var Hr=W(Vr),Ur={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ur.node;var Wr=W(Ur),Gr={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};Gr.node;var Kr=W(Gr),qr={name:`arrow-up-from-line`,size:24,node:[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};qr.node;var Jr=W(qr),Yr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Yr.node;var Xr=W(Yr),Zr={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};Zr.node;var Qr=W(Zr),$r={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};$r.node;var ei=W($r),ti={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};ti.node;var ni=W(ti),ri={name:`book-open-text`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M16 13h2`,key:`weia3s`}],[`path`,{d:`M16 9h2`,key:`1n7gjm`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}],[`path`,{d:`M6 13h2`,key:`1cckiz`}],[`path`,{d:`M6 9h2`,key:`1k7j9f`}]]};ri.node;var ii=W(ri),ai={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};ai.node;var oi=W(ai),si={name:`brush-cleaning`,size:24,node:[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]};si.node;var ci=W(si),li={name:`bug`,size:24,node:[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]};li.node;var ui=W(li),di={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};di.node;var fi=W(di),pi={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};pi.node;var mi=W(pi),hi={name:`chart-column-increasing`,size:24,node:[[`path`,{d:`M13 17V9`,key:`1fwyjl`}],[`path`,{d:`M18 17V5`,key:`sfb6ij`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-4`]};hi.node;var gi=W(hi),_i={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};_i.node;var vi=W(_i),yi={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};yi.node;var bi=W(yi),xi={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};xi.node;var Si=W(xi),Ci={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Ci.node;var wi=W(Ci),Ti={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Ti.node;var Ei=W(Ti),Di={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Di.node;var Oi=W(Di),ki={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};ki.node;var Ai=W(ki),ji={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};ji.node;var Mi=W(ji),Ni={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ni.node;var Pi=W(Ni),Fi={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Fi.node;var Ii=W(Fi),Li={name:`clipboard-check`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]};Li.node;var Ri=W(Li),zi={name:`clipboard`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]};zi.node;var Bi=W(zi),Vi={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Vi.node;var Hi=W(Vi),Ui={name:`cloud-alert`,size:24,node:[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]};Ui.node;var Wi=W(Ui),Gi={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};Gi.node;var Ki=W(Gi),qi={name:`cloud-upload`,size:24,node:[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]],aliases:[`upload-cloud`]};qi.node;var Ji=W(qi),Yi={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Yi.node;var Xi=W(Yi),Zi={name:`columns-3-cog`,size:24,node:[[`path`,{d:`M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6`,key:`19s2bv`}],[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`M15 3v7.6`,key:`mv9izd`}],[`path`,{d:`m15.229 16.852-.924-.383`,key:`qpfz85`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`m20.773 16.852.922-.383`,key:`59dfo2`}],[`path`,{d:`m20.773 19.148.922.383`,key:`1lk755`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]],aliases:[`columns-settings`,`table-config`]};Zi.node;var Qi=W(Zi),$i={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};$i.node;var ea=W($i),ta={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};ta.node;var na=W(ta),ra={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ra.node;var ia=W(ra),aa={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};aa.node;var oa=W(aa),sa={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};sa.node;var ca=W(sa),la={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};la.node;var ua=W(la),da={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};da.node;var fa=W(da),pa={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};pa.node;var ma=W(pa),ha={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};ha.node;var ga=W(ha),_a={name:`file-up`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]};_a.node;var va=W(_a),ya={name:`funnel-plus`,size:24,node:[[`path`,{d:`M13.354 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l1.218-1.348`,key:`8mvsmf`}],[`path`,{d:`M16 6h6`,key:`1dogtp`}],[`path`,{d:`M19 3v6`,key:`1ytpjt`}]]};ya.node;var ba=W(ya),xa={name:`funnel-x`,size:24,node:[[`path`,{d:`M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473`,key:`ol2ft2`}],[`path`,{d:`m16.5 3.5 5 5`,key:`15e6fa`}],[`path`,{d:`m21.5 3.5-5 5`,key:`m0lwru`}]],aliases:[`filter-x`]};xa.node;var Sa=W(xa),Ca={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Ca.node;var wa=W(Ca),Ta={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Ta.node;var Ea=W(Ta),Da={name:`git-graph`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]};Da.node;var Oa=W(Da),ka={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};ka.node;var Aa=W(ka),ja={name:`grip-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]};ja.node;var Ma=W(ja),Na={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Na.node;var Pa=W(Na),Fa={name:`handshake`,size:24,node:[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]};Fa.node;var Ia=W(Fa),La={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};La.node;var Ra=W(La),za={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};za.node;var Ba=W(za),Va={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Va.node;var Ha=W(Va),Ua={name:`key`,size:24,node:[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]};Ua.node;var Wa=W(Ua),Ga={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ga.node;var Ka=W(Ga),qa={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};qa.node;var Ja=W(qa),Ya={name:`life-buoy`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]};Ya.node;var Xa=W(Ya),Za={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Za.node;var Qa=W(Za),$a={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};$a.node;var eo=W($a),to={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};to.node;var no=W(to),ro={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};ro.node;var io=W(ro),ao={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};ao.node;var oo=W(ao),so={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};so.node;var co=W(so),lo={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};lo.node;var uo=W(lo),fo={name:`mail-check`,size:24,node:[[`path`,{d:`M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8`,key:`12jkf8`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`m16 19 2 2 4-4`,key:`1b14m6`}]]};fo.node;var po=W(fo),mo={name:`mail-warning`,size:24,node:[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]};mo.node;var ho=W(mo),go={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};go.node;var _o=W(go),vo={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};vo.node;var yo=W(vo),bo={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};bo.node;var xo=W(bo),So={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};So.node;var Co=W(So),wo={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]};wo.node;var To=W(wo),Eo={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Eo.node;var Do=W(Eo),Oo={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Oo.node;var ko=W(Oo),Ao={name:`notepad-text`,size:24,node:[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`16`,height:`18`,x:`4`,y:`4`,rx:`2`,key:`1u9h20`}],[`path`,{d:`M8 10h6`,key:`3oa6kw`}],[`path`,{d:`M8 14h8`,key:`1fgep2`}],[`path`,{d:`M8 18h5`,key:`17enja`}]]};Ao.node;var jo=W(Ao),Mo={name:`octagon-alert`,size:24,node:[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]],aliases:[`alert-octagon`]};Mo.node;var No=W(Mo),Po={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Po.node;var Fo=W(Po),Io={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};Io.node;var Lo=W(Io),Ro={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Ro.node;var zo=W(Ro),Bo={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Bo.node;var Vo=W(Bo),Ho={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ho.node;var Uo=W(Ho),Wo={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};Wo.node;var Go=W(Wo),Ko={name:`rocket`,size:24,node:[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]};Ko.node;var qo=W(Ko),Jo={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};Jo.node;var Yo=W(Jo),Xo={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};Xo.node;var Zo=W(Xo),Qo={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};Qo.node;var $o=W(Qo),es={name:`scale`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]};es.node;var ts=W(es),ns={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};ns.node;var rs=W(ns),is={name:`server-off`,size:24,node:[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};is.node;var as=W(is),os={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};os.node;var ss=W(os),cs={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};cs.node;var ls=W(cs),us={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};us.node;var ds=W(us),fs={name:`shield-x`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]],aliases:[`shield-close`]};fs.node;var ps=W(fs),ms={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};ms.node,W(ms);var hs={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};hs.node;var gs=W(hs),_s={name:`square-pen`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]],aliases:[`pen-box`,`edit`,`pen-square`]};_s.node;var vs=W(_s),ys={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};ys.node;var bs=W(ys),xs={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};xs.node;var Ss=W(xs),Cs={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Cs.node;var ws=W(Cs),Ts={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};Ts.node;var Es=W(Ts),Ds={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};Ds.node;var Os=W(Ds),ks={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};ks.node;var As=W(ks),js={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};js.node;var Ms=W(js),Ns={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Ns.node;var Ps=W(Ns),Fs={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Fs.node;var Is=W(Fs),Ls={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Ls.node;var Rs=W(Ls),zs={name:`user-minus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};zs.node;var Bs=W(zs),Vs={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Vs.node;var Hs=W(Vs),Us={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Us.node;var Ws=W(Us),Gs={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Gs.node;var Ks=W(Gs),qs={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};qs.node;var Js=W(qs),Ys=`An unexpected error occurred.`,Xs=`Something Went Wrong`,Zs={title:`Access Denied`,description:`Your account doesn't have permission to view this. If you think it should, ask an administrator for access.`},Qs={title:`Not Found`,description:`We couldn't find what you were looking for. It may have been deleted, or the link may be wrong.`},$s={title:`Couldn't Reach the Server`,description:`The request didn't get an answer. Check your connection, then try again.`,retryable:!0},ec=new Set([E.ERR_NETWORK,E.ECONNABORTED,E.ETIMEDOUT]);function tc(e){try{return e?.code}catch{return}}function nc(e){let t=jr(e);return t===403?Zs:t===404?Qs:typeof t==`number`?t>=500&&t<600?{title:Xs,description:`The server couldn't load this (error ${t}). Try again in a moment.`,retryable:!0}:void 0:ec.has(tc(e))?$s:void 0}function rc(){let e=Ee(),[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(H,{type:`button`,variant:`outline`,disabled:t,onClick:()=>{n(!0),e.invalidate().finally(()=>n(!1))},children:[(0,K.jsx)(Zo,{className:t?`animate-spin`:void 0}),` `,t?`Trying Again…`:`Try Again`]})}function ic(e){return typeof e==`string`?e.length>0:typeof e==`number`||(0,G.isValidElement)(e)?!0:Array.isArray(e)?e.length>0&&e.every(ic):!1}function ac(e){try{if(e instanceof Error)return e.message.length>0?e.message:Ys;if(typeof e==`object`&&e&&`message`in e){let t=e.message;return ic(t)?t:Ys}if(ic(e))return e}catch{return Ys}return Ys}function oc({className:e,error:t,title:n,description:r,showReturnToHome:i,reset:a,children:o}){let{user:s,isLoading:c}=xr();Pr(s);let l=nc(t),u=a!==void 0&&l?.retryable===!0;return(0,K.jsxs)(Er,{"data-testid":`error-component`,className:F(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(Dr,{children:[(0,K.jsx)(Or,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??l?.title??Xs})}),(0,K.jsx)(kr,{children:r??l?.description??ac(t)})]}),(0,K.jsxs)(Ar,{children:[o,(u||i!==!1)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[u&&(0,K.jsx)(rc,{}),i!==!1&&(s&&!c?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Go to Sign In Page`]})}))]})]})]})}function sc(){let{user:e,isLoading:t}=xr();return Pr(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(Er,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(Dr,{children:(0,K.jsx)(Or,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Ar,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Go Sign In Page`]})})})]})})}function cc(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var lc=new WeakMap;function uc(e,t){if(t.aborted)return()=>void 0;lc.set(e,(lc.get(e)??0)+1);let n=!1,r=()=>{if(n)return;n=!0,t.removeEventListener(`abort`,r);let i=(lc.get(e)??1)-1;i>0?lc.set(e,i):lc.delete(e)};return t.addEventListener(`abort`,r),r}function dc(e){return lc.has(e)}function fc(e){if(or(e))return{title:cr,description:ur,message:ur};if(e instanceof lr)return{title:sr,description:dr,message:dr};let t=`Error`,n=`We had some trouble!`,r=!0,i=e,a=e;if(typeof e==`string`)n=e;else if(i?.response?.data){let e=i.response.data;if(typeof e==`string`)n=e;else if(typeof e.title==`string`&&e.title){typeof e.code==`string`&&e.code&&(t=e.code);let i=pr(e.detail);n=i?`${e.title}: ${i}`:e.title,r=!1}else n=pr(e.error)??pr(e.message)??n}else n=pr(a?.message)??n;let o=n;if(r&&n.includes(`:`)&&!n.startsWith(`{`)&&!n.startsWith(`[`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}return{title:t,description:n,message:o}}function pc(e){return!or(e)&&!(e instanceof lr)}function mc(e){console.error(e);let{title:t,description:n}=fc(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403,o=or(e)?void 0:i?`request-timeout`:a?`request-forbidden`:void 0;U.error(t,{id:o,description:n,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}var hc=new Te({queryCache:new Fe({onError:(e,t)=>{if(ue(e,t.queryKey)){console.debug(`Suppressed a failure from a restarting entity`,e);return}if(!dc(t)){if(t.meta?.inlineSearchError&&t.getObserversCount()===0){console.error(e);return}mc(e)}}}),mutationCache:new Pe({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||mc(e)}})});fe(e=>void mr(hc,e,void 0,{cancelRefetch:!1}));function gc({...e}){return(0,K.jsx)(Jn,{"data-slot":`dropdown-menu`,...e})}function _c({...e}){return(0,K.jsx)(Pt,{"data-slot":`dropdown-menu-trigger`,...e})}function vc({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(gt,{children:(0,K.jsx)(wt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...n})})}function yc({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(St,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:F(`focus:bg-accent focus:text-grey`,`data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10`,`dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive`,`data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground`,`relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm`,`outline-hidden select-none`,`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function bc({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(Yt,{"data-slot":`dropdown-menu-checkbox-item`,className:F(`focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm`,`py-1.5 pr-2 pl-8`,`text-sm outline-hidden`,`select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Bt,{children:(0,K.jsx)(tr,{className:`size-4`})})}),t]})}function xc({...e}){return(0,K.jsx)(Cn,{"data-slot":`dropdown-menu-radio-group`,...e})}function Sc({className:e,children:t,...n}){return(0,K.jsxs)(It,{"data-slot":`dropdown-menu-radio-item`,className:F(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Bt,{children:(0,K.jsx)(Ii,{className:`size-2 fill-current`})})}),t]})}function Cc({className:e,inset:t,...n}){return(0,K.jsx)(Tn,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:F(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function wc({className:e,...t}){return(0,K.jsx)(Rt,{"data-slot":`dropdown-menu-separator`,className:F(`bg-border -mx-1 my-1 h-px`,e),...t})}function Tc({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:F(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ec({...e}){return(0,K.jsx)(Ht,{"data-slot":`dropdown-menu-sub`,...e})}function Dc({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(At,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:F(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(Si,{className:`ml-auto size-4`})]})}function Oc({className:e,...t}){return(0,K.jsx)(Et,{"data-slot":`dropdown-menu-sub-content`,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}var kc=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Ac=`block p-2 rounded-lg text-sm transition-colors`,jc={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Mc={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Nc({items:e,ariaLabel:t}){let{pathname:n}=ze(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`studio-section-rail hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:kc,activeOptions:{exact:!!e.exact},activeProps:Mc,inactiveProps:jc,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Ac,activeOptions:{exact:!!e.exact},activeProps:Mc,inactiveProps:jc,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(er,{className:`size-4`})]})}),(0,K.jsx)(vc,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Pc=[{to:`/admin/notifications`,label:`Notifications`,icon:ni,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:Aa,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:Ha,permission:`apiToken:create`,ssoAccountOnly:!0}];function Fc(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Pc.filter(n=>Cr(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ic(){let{isLoading:e,user:t}=Sr(),{pathname:n}=ze();if(e)return null;let r=Fc(t);if(!r.length)return(0,K.jsx)(qe,{to:`/`,replace:!0});let i=Pc.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(qe,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Nc,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(st,{})})]})})}function Lc({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Rc(e){return jr(e)===403}function zc(e){let t=jr(e);return t===400||t===403}var Bc=3e5,Vc=6e4,Hc=new WeakMap;function Uc(e){return e!==void 0&&e>=500&&e<600}function Wc(e,t,n){let{errorUpdatedAt:r,dataUpdatedAt:i=0}=e.state;if(!Number.isFinite(r))return t;let a=Hc.get(e);(a===void 0||a<i)&&(a=r,Hc.set(e,a));let o=r-a-n;return Math.min(Math.max(t,o),Math.max(t,Bc))}function Gc(e){return t=>{let n=jr(t.state.error);return n===403?!1:e?n===400?Wc(t,e,0):Uc(n)?Wc(t,e,Vc):e:e??!1}}function Kc(e=3){return(t,n)=>!zc(n)&&t<e}function qc(e){return!!e&&e!==`undefined`&&e!==`null`}async function Jc(e){if(!qc(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await P.get(`/Organization/${e}`);return t}function Yc(e){return B({queryKey:[e],queryFn:()=>Jc(e),retry:!1,enabled:qc(e),refetchInterval:Gc(1e4)})}function Xc(){let{user:e}=Sr(),{organizationId:t}=z({strict:!1});(0,G.useMemo)(()=>Nr(e),[e]);let{data:n}=L({...Yc(t),enabled:!1});return null}function Zc(e,t){let n=(0,G.useState)(gr(e,t)),[r]=n;return(0,G.useEffect)(()=>hr(e,r),[e,r]),n}function Qc(){let[e,t]=(0,G.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var $c=(0,G.createContext)([`system`,()=>{}]);function el({children:e}){let[t,n]=Zc(_r.Theme,`system`),r=Qc();return(0,G.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)($c.Provider,{value:[t,n],children:e})}function tl(){return(0,G.useContext)($c)}function nl({user:e,onSignOut:t,signingOut:n}){let[r,i]=tl(),{organizationId:a}=z({strict:!1}),o=Mr(e)?e.username:[e.firstname,e.lastname].filter(Boolean).join(` `)||e.email,s=o.trim().split(/\s+/).slice(0,2).map(e=>e[0]).join(``).toUpperCase();return(0,G.useMemo)(()=>Nr(e).some(e=>!e.locked&&e.id!==a),[e,a]),(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Account menu`,className:`ml-2 inline-flex items-center gap-2 rounded-full border border-primary/25 bg-card/50 p-1 pr-2 text-foreground hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-primary/15 text-xs font-semibold text-primary dark:text-violet-200`,children:s||(0,K.jsx)(Hs,{className:`size-4`})}),(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsxs)(vc,{align:`end`,className:`w-64`,children:[(0,K.jsx)(Cc,{className:`truncate`,title:o,children:o}),!Mr(e)&&o!==e.email&&(0,K.jsx)(`p`,{className:`truncate px-2 pb-2 text-xs text-muted-foreground`,title:e.email,children:e.email}),(0,K.jsx)(wc,{}),!1,(0,K.jsxs)(Ec,{children:[(0,K.jsxs)(Dc,{children:[(0,K.jsx)(Lo,{className:`size-4`}),`Appearance`]}),(0,K.jsx)(Oc,{children:(0,K.jsxs)(xc,{value:r,onValueChange:e=>{(e===`light`||e===`dark`||e===`system`)&&i(e)},children:[(0,K.jsx)(Sc,{value:`light`,children:`Light`}),(0,K.jsx)(Sc,{value:`system`,children:`System`}),(0,K.jsx)(Sc,{value:`dark`,children:`Dark`})]})})]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{disabled:n,onSelect:t,children:[(0,K.jsx)(uo,{className:`size-4`}),n?`Signing out…`:`Sign Out`]})]})]})}function rl(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function il(){let e=`studio`,t=`Harper Studio`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,K.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var al=y(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-red-600 text-white [a&]:hover:bg-red-700 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function ol({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?vt:`span`,{"data-slot":`badge`,className:F(al({variant:t}),e),...r})}function sl({className:e,children:t,...n}){return(0,K.jsxs)(Qn,{"data-slot":`scroll-area`,className:F(`relative`,e),...n,children:[(0,K.jsx)(bt,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,K.jsx)(cl,{}),(0,K.jsx)(cn,{})]})}function cl({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(Xn,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:F(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,K.jsx)(qt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var ll=[`notification-acks`];function ul(){let e=gr(_r.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function dl(e){hc.setQueryData(ll,e);try{hr(_r.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function fl(){return B({queryKey:ll,queryFn:ul,staleTime:1/0,gcTime:1/0,initialData:ul})}function pl(e){dl(Array.from(new Set([...ul(),e])))}function ml(e){dl(ul().filter(t=>t!==e))}function hl(){let{data:e}=L(fl());return(0,G.useMemo)(()=>new Set(e??[]),[e])}var gl={critical:{severity:`critical`,label:`Critical`,Icon:No,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:Rs,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Ba,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},_l=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),vl=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),yl=new Set([`info`,`information`,`informational`,`success`,`ok`]);function bl(e){let t=(e??``).trim().toLowerCase();return vl.has(t)?`warning`:yl.has(t)?`info`:(_l.has(t),`critical`)}function xl(e){return gl[bl(e)]}var Sl={critical:0,warning:1,info:2};function Cl(e){if(e==null)return{kind:`absent`};if(typeof e==`number`)return Number.isFinite(e)?{kind:`valid`,ms:e}:{kind:`invalid`};if(typeof e!=`string`)return{kind:`invalid`};let t=e.trim();if(!t)return{kind:`absent`};if(/^\d+$/.test(t))return{kind:`valid`,ms:Number(t)};let n=Date.parse(t);return Number.isNaN(n)?{kind:`invalid`}:{kind:`valid`,ms:n}}function wl(e){let t=Cl(e);return t.kind===`valid`?t.ms:null}function Tl(e){return new Date(e).toLocaleString()}function El(e,t){let n=Cl(e.startAt),r=Cl(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${Tl(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${Tl(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${Tl(r.ms)}`}:{state:`active`,label:`Active`}}var Dl=new Set([`http`,`https`,`mailto`]);function Ol(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.startsWith(`//`))return{kind:`external`,href:t};let n=t.match(/^([a-z][a-z0-9+.-]*):/i)?.[1]?.toLowerCase();return n?Dl.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function kl({url:e,className:t,children:n,onNavigate:r}){let i=Ol(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(fa,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var Al=[`system-status`];async function jl(){let{data:e}=await P.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function Ml(){return B({queryKey:Al,queryFn:jl,refetchInterval:6e4,staleTime:3e4})}var Nl=3e4,Pl=new Set,Fl=Date.now(),Il=null;function Ll(e){return Pl.add(e),Il||=(Fl=Date.now(),setInterval(()=>{Fl=Date.now(),Pl.forEach(e=>e())},Nl)),()=>{Pl.delete(e),Pl.size===0&&Il&&(clearInterval(Il),Il=null)}}function Rl(){return(0,G.useSyncExternalStore)(Ll,()=>Fl,()=>Fl)}function zl(){return L(Ml())}var Bl=[{value:`light`,icon:(0,K.jsx)(ws,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Do,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(ko,{className:`size-4`}),label:`Dark`}];function Vl(){let[e,t]=tl();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Bl.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Hl({className:e,...t}){return(0,K.jsx)(`div`,{className:F(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(Kn,{"data-slot":`navigation-menu-viewport`,className:F(`origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]`,e),...t})})}function Ul({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(kn,{"data-slot":`navigation-menu`,"data-viewport":n,className:F(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Hl,{})]})}function Wl({className:e,...t}){return(0,K.jsx)(yn,{"data-slot":`navigation-menu-item`,className:F(`relative`,e),...t})}function Gl({className:e,...t}){return(0,K.jsx)(_n,{"data-slot":`navigation-menu-link`,className:F(`hover:text-foreground dark:hover:text-white ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function Kl({className:e,...t}){return(0,K.jsx)(rn,{"data-slot":`navigation-menu-list`,className:F(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function ql({delayDuration:e=0,...t}){return(0,K.jsx)(hn,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jl({...e}){return(0,K.jsx)(ql,{children:(0,K.jsx)(un,{"data-slot":`tooltip`,...e})})}function Yl({...e}){return(0,K.jsx)(Fn,{"data-slot":`tooltip-trigger`,...e})}function Xl({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(fn,{children:(0,K.jsxs)(Wn,{"data-slot":`tooltip-content`,sideOffset:t,className:F(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,K.jsx)(Dn,{className:F(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Zl(){let e=`v5.3.3`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:F(al({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ql(e={}){let{instanceId:t,clusterId:r}=z({strict:!1});return n({id:m,...e})}function $l(e={}){let{instanceId:t,clusterId:r}=z({strict:!1});return{instanceClient:n({id:m,...e}),entityType:`instance`}}function q(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return(0,G.useMemo)(()=>eu({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function eu({instanceId:e,clusterId:t,...r}){let i=m;if(!i)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:n({id:i,...r}),entityId:i,entityType:`instance`}}function tu(){localStorage.clear()}var nu=new Map,ru=new Map;function iu(e){for(let t of ru.get(e)??[])t()}function au(e,t){let n=`stored`;try{ft(e,t)}catch(t){n=`refused`,nu.get(e)?.state!==`refused`&&console.warn(`sessionStorage refused a write; keeping the value in memory only`,t)}nu.set(e,{value:t,state:n})}function ou(e,t){let n=nu.get(e);if(!n||n.state==="default"&&!ru.has(e)){let r=dt(e,void 0);n={value:r===void 0?t:r,state:r===void 0?`default`:`stored`},nu.set(e,n)}return n}function su(){return[...nu].filter(([,e])=>e.state===`refused`).map(([e])=>e)}function cu(e,t){return ou(e,t).value}function lu(e,t,n){let r=cu(e,t),i=typeof n==`function`?n(r):n;Object.is(i,r)||(au(e,i),iu(e))}function uu(e,t,n){let r=ru.get(e);if(!r){let n=ou(e,t);n.state!==`stored`&&au(e,n.value),r=new Set,ru.set(e,r)}return r.add(n),()=>{r.delete(n),r.size||(ru.delete(e),nu.get(e)?.state!==`refused`&&nu.delete(e))}}function du(){nu.clear();for(let e of ru.keys())iu(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{e.storageArea===sessionStorage&&(e.key===null?du():nu.delete(e.key)&&iu(e.key))});function fu(){try{sessionStorage.clear()}finally{du()}}function pu(){hu([()=>u.signOutAllLocally(),()=>hc.getMutationCache().clear(),()=>hc.getQueryCache().clear(),tu,fu])}function mu(){hu([()=>u.forgetAppSignInEndedElsewhere(),()=>hc.getMutationCache().clear(),()=>hc.getQueryCache().clear(),fu])}function hu(e){for(let t of e)try{t()}catch(e){console.error(e)}}async function gu(){pu(),await hc.invalidateQueries({refetchType:`none`})}async function _u(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function vu(){let e=Ql();return I({mutationFn:()=>_u({instanceClient:e}),onSuccess:gu})}(0,G.lazy)(()=>pe(()=>import(`./SearchDialog-BRIyPiBl.js`).then(e=>({default:e.SearchDialog})),__vite__mapDeps([0,1,2,3,4])));var yu=(0,G.createContext)(null);function bu(){let e=(0,G.useContext)(yu);return e?(0,K.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search organizations and clusters`,className:`inline-flex cursor-pointer items-center gap-2 rounded-lg border border-primary/20 bg-card/30 p-2 text-sm text-muted-foreground hover:bg-primary/15 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(rs,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`hidden lg:inline`,children:`Search`}),(0,K.jsx)(`kbd`,{className:`hidden xl:inline rounded border border-border px-1 text-xs`,children:`⌘ / Ctrl K`})]}):null}var xu={className:`text-foreground dark:text-white font-semibold`};function Su(){let{mutate:e,isPending:t}=vu(),n=De(),{user:r}=xr(),i=Ee(),a=(0,G.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),n({to:`/sign-in`}),i.invalidate()}})},[e,i,n]),o=(0,G.useMemo)(()=>[{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(ii,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(ui,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(rl,{}),text:`Discord`,textBreakpoint:`lg`}],[]);return r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{menuItems:o,user:r,accountMenu:(0,K.jsx)(nl,{user:r,onSignOut:a,signingOut:t})}),(0,K.jsx)(Tu,{menuItems:o,user:r,accountMenu:(0,K.jsx)(nl,{user:r,onSignOut:a,signingOut:t})})]}):(0,K.jsx)(wu,{})}function Cu(e){return e.items!==void 0}function wu(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsx)(Ul,{children:(0,K.jsxs)(Kl,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(Wl,{children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(ii,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(Wl,{children:(0,K.jsx)(Vl,{})}),(0,K.jsx)(Wl,{children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:xu,children:[(0,K.jsx)(co,{}),` Sign In`]})})})]})})]})}function Tu({menuItems:e,accountMenu:t,user:n}){return(0,G.useMemo)(()=>Pr(n),[n]),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsx)(Ul,{children:(0,K.jsxs)(Kl,{className:`text-muted-foreground dark:text-grey-400`,children:[!1,e.map(e=>Cu(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(Eu,{menuItem:e},e.text))},e.text):(0,K.jsx)(Eu,{menuItem:e},e.text)),!1,(0,K.jsx)(Wl,{children:t})]})})]})})}function Eu({menuItem:e}){return(0,K.jsx)(Wl,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?xu:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Xl,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function Du({menuItems:e,accountMenu:t,user:n}){(0,G.useMemo)(()=>Pr(n),[n]);let[r,i]=(0,G.useState)(!1),a=(0,G.useCallback)(()=>i(e=>!e),[]),o=(0,G.useCallback)(()=>i(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(bu,{}),!1,t,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:a,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:r?`Close menu`:`Open menu`}),r?(0,K.jsx)(Ks,{}):(0,K.jsx)(Co,{})]})]})]}),(0,K.jsx)(`div`,{className:`${r?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:o}),(0,K.jsx)(`div`,{className:`${r?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:e.map(e=>Cu(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(Ou,{menuItem:e,onClick:o},e.text))},e.text):(0,K.jsx)(Ou,{menuItem:e,onClick:o},e.text))})]})}function Ou({menuItem:e,onClick:t}){let n=(0,G.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?xu:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function ku(){let{isLoading:e,user:t}=xr(),{createCluster:n}=Oe({strict:!1}),[,r]=Zc(_r.SavedClusterState,null);return(0,G.useEffect)(()=>{n&&r(n)},[n,r]),e||!t?(0,K.jsx)(Lc,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(`div`,{className:`studio-shell`,children:[(0,K.jsx)(`header`,{className:`studio-shell-header fixed top-0 z-40 w-full h-20 p-4 md:px-12`,children:(0,K.jsx)(Su,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(st,{})})]})}function Au(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var ju=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function Mu(){let e=Au();return!ju.includes(e)&&{redirect:e}}var Nu={isLoading:!1,user:null};function Pu(e){return u.isKnownSignedOut(`OverallAppSignIn`)?Nu:e.authentication[m]}var Fu=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,Iu=String.raw`[^&#\s",<>[\]{}|\\]+`,Lu=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${Fu})=)${Iu}`,`gi`),new RegExp(String.raw`([?&](?:${Fu})=)${Iu}|${Lu}`,`gi`);var Ru=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${Ru}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${Ru})://\S*)\s*$`);var zu=!1;function Bu(){(0,G.useEffect)(()=>{zu||=!0},[])}function Vu(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lt,{}),(0,K.jsx)(st,{})]})}var Hu=Se()({component:Vu}),Uu=R({getParentRoute:()=>Hu,id:`_dashboardLayout`,component:ku,beforeLoad:({context:e})=>{let t=Pu(e);if(t&&!t.isLoading&&!t.user)throw Ne({to:`/sign-in`,search:Mu()})}}),Wu=R({getParentRoute:()=>Uu,path:`admin`,component:Ic});R({getParentRoute:()=>Wu,path:`/`,beforeLoad:()=>{throw Ne({to:`/admin/notifications`})}}),R({getParentRoute:()=>Wu,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./notifications-CPgEC6ZP.js`),__vite__mapDeps([5,1,6,7,2,3,4,8,9])),`NotificationsAdminIndex`)}),R({getParentRoute:()=>Wu,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./regions-WFvXqryO.js`),__vite__mapDeps([10,1,7,6,2,3,4,8,9,11,12])),`RegionsIndex`)}),R({getParentRoute:()=>Wu,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./apiToken-BraYnzvC.js`),__vite__mapDeps([13,1,6,7,2,3,4,8,9])),`ApiTokenIndex`)});function Gu(){let[e,t]=(0,G.useState)(()=>typeof document<`u`&&document.documentElement.classList.contains(`dark`));return(0,G.useEffect)(()=>{let e=document.documentElement;t(e.classList.contains(`dark`));let n=new MutationObserver(()=>{t(e.classList.contains(`dark`))});return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e?`dark`:`light`}var Ku={dark:[`M 246 426 C 211 389 184 377 154 386 C 72 399 44 492 0 576`,`M 658 383 C 693 318 748 286 795 286 C 905 281 957 477 952 583`,`M 750 438 C 915 444 1083 562 1183 766`,`M 0 576 C 119 529 273 575 372 766`,`M 1196 766 C 1291 526 1514 442 1690 432 C 1844 430 1973 530 2054 651`],light:[`M 258 355 C 212 300 171 289 136 313 C 74 352 37 434 0 542`,`M 633 350 C 684 251 744 193 790 200 C 882 201 967 380 951 548`,`M 756 405 C 891 368 1055 510 1169 766`,`M 0 542 C 112 440 299 588 356 766`,`M 1285 766 C 1391 564 1556 518 1710 505 C 1840 504 1971 571 2054 668`]},qu={dark:[[246,426,0,576],[658,383,952,583],[750,438,1183,766],[0,576,372,766],[1196,766,2054,651]],light:[[258,355,0,542],[633,350,951,548],[756,405,1169,766],[0,542,356,766],[1285,766,2054,668]]},Ju=[{path:0,duration:12,phase:3},{path:1,duration:16,phase:6},{path:1,duration:16,phase:14},{path:2,duration:14,phase:4},{path:3,duration:18,phase:11},{path:4,duration:22,phase:5},{path:4,duration:22,phase:16}];function Yu({theme:e}){let t=(0,G.useId)();return(0,K.jsxs)(`svg`,{className:`auth-energy-particles`,viewBox:`0 0 2054 766`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsxs)(`defs`,{children:[(0,K.jsxs)(`radialGradient`,{id:`${t}-fade`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`black`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`white`})]}),qu[e].map(([e,n,r,i],a)=>(0,K.jsxs)(`mask`,{id:`${t}-${a}`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`2054`,height:`766`,children:[(0,K.jsx)(`rect`,{width:`2054`,height:`766`,fill:`white`}),(0,K.jsx)(`circle`,{cx:e,cy:n,r:`60`,fill:`url(#${t}-fade)`}),(0,K.jsx)(`circle`,{cx:r,cy:i,r:`60`,fill:`url(#${t}-fade)`})]},a))]}),Ku[e].map((e,n)=>(0,K.jsx)(`path`,{className:`auth-energy-line`,d:e,mask:`url(#${t}-${n})`},e)),Ju.map(({path:t,duration:n,phase:r},i)=>(0,K.jsxs)(`g`,{className:`auth-energy-particle`,opacity:`0`,children:[(0,K.jsx)(`circle`,{r:`12`,fill:`currentColor`,opacity:`0.06`}),(0,K.jsx)(`circle`,{r:`6`,fill:`currentColor`,opacity:`0.16`}),(0,K.jsx)(`circle`,{r:`2.2`,fill:`currentColor`}),(0,K.jsx)(`animateMotion`,{path:Ku[e][t],dur:`${n}s`,begin:`-${r}s`,repeatCount:`indefinite`}),(0,K.jsx)(`animate`,{attributeName:`opacity`,values:`0;0.85;0.85;0`,keyTimes:`0;0.12;0.82;1`,dur:`${n}s`,begin:`-${r}s`,repeatCount:`indefinite`})]},`${e}-${i}`))]})}var Xu=[{title:`App`,description:`Build faster`,Icon:oi},{title:`Database`,description:`Store smarter`,Icon:ia},{title:`Cache`,description:`Move quicker`,Icon:Js},{title:`Messaging`,description:`Stay connected`,Icon:_o}];function Zu(){let e=Gu();return(0,K.jsxs)(`div`,{className:`fabric-sign-in-page`,children:[(0,K.jsxs)(`header`,{className:`sign-in-header`,children:[(0,K.jsxs)(`div`,{className:`sign-in-brand`,children:[(0,K.jsx)(V,{to:`/`,"aria-label":`Harper Fabric home`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsxs)(`nav`,{"aria-label":`Authentication navigation`,children:[(0,K.jsxs)(`a`,{className:`sign-in-docs`,href:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,children:[(0,K.jsx)(ii,{"aria-hidden":`true`}),` `,(0,K.jsx)(`span`,{children:`Docs`})]}),(0,K.jsx)(Vl,{})]})]}),(0,K.jsxs)(`main`,{className:`sign-in-content`,children:[(0,K.jsxs)(`section`,{className:`sign-in-story`,"aria-labelledby":`sign-in-story-title`,children:[(0,K.jsxs)(`div`,{className:`sign-in-story-copy`,children:[(0,K.jsxs)(`h2`,{id:`sign-in-story-title`,children:[`One runtime.`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{children:`Endless possibilities.`})]}),(0,K.jsxs)(`p`,{children:[`Build, deploy, and scale distributed applications`,(0,K.jsx)(`br`,{className:`sign-in-desktop-break`}),` `,`with built-in data, cache, and messaging.`]}),(0,K.jsx)(`ul`,{className:`sign-in-features`,children:Xu.map(({title:e,description:t,Icon:n})=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`sign-in-feature-icon`,children:(0,K.jsx)(n,{"aria-hidden":`true`})}),(0,K.jsx)(`strong`,{children:e}),(0,K.jsx)(`span`,{children:t})]},e))})]}),(0,K.jsx)(`div`,{className:`sign-in-artwork`,children:(0,K.jsxs)(`div`,{className:`auth-hero-panorama`,children:[(0,K.jsx)(`img`,{className:`auth-hero-globe`,src:`/auth/fabric-globe-${e}.png`,alt:``,"aria-hidden":`true`}),(0,K.jsx)(Yu,{theme:e}),(0,K.jsx)(`img`,{className:`auth-hero-platform`,src:`/auth/fabric-platform-${e}.png`,width:`2054`,height:`766`,alt:`App, database, cache, and messaging together on a globally distributed platform.`,fetchPriority:`high`})]})}),(0,K.jsxs)(`div`,{className:`sign-in-story-footer`,children:[(0,K.jsx)(`span`,{children:`Free to deploy`}),(0,K.jsx)(`span`,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:`Live in minutes`})]})]}),(0,K.jsx)(`section`,{className:`sign-in-card`,"aria-label":`Account access`,children:(0,K.jsx)(st,{})})]})]})}function Qu(){(0,G.useEffect)(()=>{},[])}var $u=[`gmail.com`,`yahoo.com`,`hotmail.com`,`outlook.com`,`icloud.com`,`aol.com`,`protonmail.com`,`mail.com`,`zoho.com`,`yandex.com`,`gmx.com`,`live.com`,`msn.com`,`me.com`,`inbox.com`];function ed(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of $u)if(t===e||t.endsWith(`.`+e))return null;return t}var td=[`error`,`reason`];function nd(e){let t=new URLSearchParams(e),n=td.filter(e=>t.has(e));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function rd(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=nd(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var id=`utm_`;function ad(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(id));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function od(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=ad(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}function sd({icon:e,title:t,subtitle:n,loading:r=!1}){return(0,K.jsxs)(`div`,{className:`auth-heading`,children:[(0,K.jsx)(`span`,{className:`auth-status-icon`,children:(0,K.jsx)(e,{"aria-hidden":`true`,className:r?`auth-loading-icon`:void 0})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{children:t}),n&&(0,K.jsx)(`p`,{className:`auth-heading-subtitle`,children:n})]})]})}var cd=`We were not able to verify your sign-in. Please try signing in again.`,ld=`Sign-in is temporarily unavailable. Please try again in a few minutes.`,ud=`This sign-in method isn't allowed for your account.`,dd={state_storage:ld,account_lookup_failed:ld,identity_resolution:ld,token_exchange:ld,user_mapping:ld,user_info:ld,login_hook:ld,internal_error:ld,unknown:ld,email_lookup_failed:ld,csrf:`Your sign-in session expired. Please try signing in again.`,email_not_verified:`Verify your email address before signing in with this provider.`,email_ambiguous:`More than one of your verified email addresses matches an existing account. Contact your administrator for help signing in.`,provider_not_authorized:ud,login_not_allowed:ud,denied:ud,login_denied:ud,confirmation_required:`Your sign-in needs an extra step that was not completed. Please contact your administrator.`,access_denied:`Sign-in was cancelled.`},fd={invalid_request:`Your sign-in link is invalid or has expired. Please try signing in again.`,server_error:ld,auth_failed:ld,oauth_failed:`The identity provider couldn't complete sign-in. Please try again.`,access_denied:ud};function pd(e,t){if(e)return t&&Object.hasOwn(dd,t)?dd[t]:Object.hasOwn(fd,e)?fd[e]:cd}var md=null;function hd(){let e=De(),t=Ee(),n=Ze(),{redirect:r}=Oe({strict:!1});return(0,G.useEffect)(()=>{md||=Promise.resolve().then(async()=>{try{let i=new URLSearchParams(window.location.search),a=pd(i.get(`error`),i.get(`reason`));try{rd()}catch(e){console.debug(`Failed to clear OAuth error params from the URL, carrying on:`,e)}if(a){U.error(a,{duration:1e4}),await e({to:`/sign-in`});return}let o=await l().catch(()=>null);if(!o)U.error(cd,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(m,o),od();let i=Pr(o);ed(o.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:i})}}finally{md=null}}).catch(e=>{console.debug(`OAuth sign-in check failed, carrying on:`,e)})},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`auth-form flex flex-col gap-4`,children:[(0,K.jsx)(sd,{icon:no,title:`Checking...`,subtitle:`We’re confirming your sign-in.`,loading:!0}),(0,K.jsx)(`div`,{className:`auth-links`,children:(0,K.jsx)(V,{className:`text-sm`,to:`/sign-in`,children:`Try signing in again`})})]})}var gd=new Map;function _d(e){if(!e)return``;if(gd.has(e))return gd.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return gd.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return gd.set(e,``),``;let r=[];for(let e=0;e<n.length;e++){let t=n[e],i=e+1<n.length?n[e+1]:void 0;/^[A-Z]{2,}$/.test(t)&&i&&/[A-Z]*s$/.test(i)||/^[A-Z]$/.test(t)&&i!==void 0&&/^[A-Z]s$/.test(i)?(r.push(t+i),e++):r.push(t)}let i=r.map(vd).join(` `);return gd.set(e,i),i}function vd(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var yd=new Set([`mode`]),bd=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,xd=/^\{-\$(\w+)\}$/,Sd=`_splat`;function Cd(e,t,n){let r=[],i=0;for(let a of(e??``).split(`/`).filter(Boolean)){if(i>=t)break;let e=xd.exec(a);if(e)n[e[1]]!==void 0&&(r[i++]=e[1]);else if(a===`$`)for(;i<t;)r[i++]=Sd;else r[i++]=a.startsWith(`$`)?a.slice(1):void 0}return r}function wd(e){try{return decodeURIComponent(e)}catch{return e}}function Td(e,t,n){switch(e){case`organizationId`:return{label:n.organization||`Org`};case`clusterId`:return{label:n.cluster||`Cluster`};case`instanceId`:return{label:n.instance?.split(`.`)?.shift()||`Instance`}}return yd.has(e)?{label:_d(t)}:bd.test(t)?{label:t.slice(0,8),title:t}:{label:t}}function Ed(e,t,n,r){let i=e.split(`/`).filter(Boolean),a=Cd(t,i.length,n),o=e=>{let t=a[e],r=t&&t!==Sd?n[t]:void 0;return typeof r==`string`?r:wd(i[e])},s=[];for(let e=0;e<i.length;e++){let t=i[e],n=a[e];if(!n&&t===`instance`)continue;let c=`/${i.slice(0,e+1).join(`/`)}`;if(n)n===`clusterId`&&i[e+1]===`instance`&&(c+=`/instances`),s.push({path:c,...Td(n,o(e),r)});else if(t===`databases`&&i.length===e+3)s.push({path:c,label:o(e+2)}),e+=2;else{let e=_d(t);s.push({path:c,label:e===`Apis`?`APIs`:e})}}return s}function Dd({restartRequired:e}){let t=ze(),{organization:n,instance:r,cluster:i}=ye({strict:!1}),a=xe({select:e=>e[e.length-1]}),o=a?.pathname??t.pathname,s=a?.fullPath,c=a?.params,l=(0,G.useMemo)(()=>{let e=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Ra,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)],t=Ed(o,s,c??{},{organization:n?.name,cluster:i?.name,instance:r?.name});for(let{path:n,label:r,title:i}of t)e.push((0,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},e.length+`-dash`),(0,K.jsx)(V,{to:n,title:i,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:r},n));return e},[o,s,c,i?.name,r?.name,n?.name]);return(0,K.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...l,e&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Xl,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Od=jn,kd=(0,G.createContext)({}),Ad=(0,G.createContext)({});function jd(){let e=(0,G.useContext)(kd),t=(0,G.useContext)(Ad),{errors:n}=Nn({name:e.name}),r=Rn(n,e.name);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,formLengthHintId:`${i}-form-item-length-hint`,error:r}}function J({"aria-describedby":e,...t}){let{error:n,formItemId:r,formDescriptionId:i,formMessageId:a}=jd();return(0,K.jsx)(vt,{"data-slot":`form-control`,id:r,"aria-describedby":[i,n&&a,e].filter(Boolean).join(` `),"aria-invalid":!!n,...t})}function Y({...e}){return(0,K.jsx)(kd,{value:{name:e.name},children:(0,K.jsx)(Hn,{...e})})}function X({className:e,...t}){let n=(0,G.useId)();return(0,K.jsx)(Ad,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:F(`grid gap-2`,e),...t})})}function Md({className:e,...t}){return(0,K.jsx)(pn,{"data-slot":`label`,className:F(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Z({className:e,...t}){let{error:n,formItemId:r}=jd();return(0,K.jsx)(Md,{"data-slot":`form-label`,"data-error":!!n,className:F(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=jd(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:F(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:F(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
|
|
3
|
+
selection:text-primary-foreground
|
|
4
|
+
dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
|
|
5
|
+
dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
|
|
6
|
+
aria-invalid:ring-destructive/20 aria-invalid:border-destructive/60 dark:aria-invalid:border-destructive
|
|
7
|
+
flex h-9 w-full min-w-0 rounded-md border bg-white text-foreground dark:bg-grey-700 dark:text-white px-3 py-1 text-base
|
|
8
|
+
file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium
|
|
9
|
+
focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
|
|
10
|
+
aria-invalid:focus-visible:ring-[1px] aria-invalid:focus-visible:outline-none md:text-sm dark:aria-invalid:focus-visible:ring-1`,e),...n})}var Nd=[`RUNNING`],Pd=[`TERMINATING`,`TERMINATED`,`REMOVED`];function Fd(e){return e?.status?Pd.includes(e.status)||e.status===`FAILED`&&!!e.terminatedAt:!1}function Id(){return`https://fabric.harper.fast/#/?createCluster=`+encodeURIComponent(JSON.stringify({deploymentDescription:`Self-Hosted`,performanceDescription:`Self Supported and Managed`,instances:[{secure:String(location.protocol===`https:`),fqdn:location.hostname,port:parseInt(location.port,10)}]}))}var Ld=`You're offline`,Rd=`You're offline, so we can't reach the server. Check your connection, then try again.`,zd=`We can't reach the server. Check your connection, then try again.`,Bd=`auth-offline`,Vd=/^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])$|\.localhost$/i,Hd=class extends Error{constructor(e){super(`Auth request failed while the browser reported no connection`,{cause:e}),this.name=`OfflineSubmitError`}};function Ud(e){return{networkMode:`always`,mutationFn:async t=>{let n=!ke.isOnline();try{return await e(t)}catch(e){throw n&&Wd(e)?new Hd(e):e}}}}function Wd(e){return T(e)&&!e.response&&e.code===E.ERR_NETWORK&&!Gd(e)}function Gd({config:e}){if(!e)return!1;try{let t=new URL(e.baseURL??``,window.location.href).href;return Vd.test(new URL(e.url??``,t).hostname)}catch{return!1}}function Kd(e){if(e instanceof Hd){console.debug(`Auth request failed offline`,e);return}console.error(e)}function qd(e){if(!(e instanceof Hd)){mc(e);return}console.debug(`Auth request failed offline`,e),U.error(Ld,{id:Bd,description:zd,action:{label:`Dismiss`,onClick:()=>U.dismiss(Bd)}})}var Jd={meta:{skipGlobalErrorToast:!0},onError:qd};async function Yd({username:e,password:t,instanceClient:n,entityId:i}){let a={username:e,password:t};u.checkForBasicAuth(i)&&(n.defaults.auth=a,n.defaults.withCredentials=!1);let{data:{message:o}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!u.checkForBasicAuth(i))try{let e=await r({instanceClient:n});return u.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=a,n.defaults.withCredentials=!1;let e=await r({instanceClient:n,auth:a});return u.flagForBasicAuth(i,a),u.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}}function Xd(){return I({...Ud(Yd),...Jd})}function Zd({cluster:e,instance:t,instanceParams:n}){let r=De(),i=Ee(),{redirect:a}=Oe({strict:!1}),{mutate:o,isPending:s}=Xd();return{isPending:s,submitForm:(0,G.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(U.success(n),e?.instances?.length&&!t)for(let t of e.instances)u.setUserForEntity(t,o);let s=m;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);u.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}function Qd(e){if(sf(e)||cf(e))return`warning`;if(rf(e))return`success`;switch(e){case`STOPPED`:return`destructive`;case`TERMINATING`:case`TERMINATED`:case`FAILED`:case`REMOVED`:case`ERROR`:return`destructive`;default:return`default`}}function $d(e){switch(e){case`STOPPED`:case`STOPPING`:case`STARTING`:case`RESTARTING`:return!0;default:return!1}}function ef(e){switch(e){case`TERMINATING`:case`TERMINATED`:case`REMOVED`:case`ERROR`:case`FAILED`:return!0;default:return $d(e)}}function tf(e){switch(e){case`CLONE_PENDING`:case`CLONE_READY`:case`CLONING`:return!0;default:return!1}}function nf(e){switch(e){case`GENERATE_TOKEN`:case`TOKEN_GENERATED`:return!0;default:return!1}}function rf(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function af(e){switch(e){case`FAILED`:return!0;default:return!1}}function of(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function sf(e){switch(e){case`CLONE_PENDING`:case`PENDING_UPGRADE`:return!0;default:return!1}}function cf(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`DRAINING`:case`UPDATING`:return!0;default:return!1}}function lf(e){let t=(e?.instances??[]).filter(e=>!(e.status&&Pd.includes(e.status)));return t.length>0&&t.every(e=>rf(e.status))}var uf=[`STOPPED`,`ERROR`,`FAILED`];function df(e){return!!e?.instances&&e.instances.every(e=>e.status&&Pd.includes(e.status)||rf(e.status)||e.status&&uf.includes(e.status))}function ff(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function pf(e){return ff(e)?{title:`Cluster Removed`,detail:`was removed from Harper Fabric, so it can no longer be managed or signed in to from here.`}:e.status===`TERMINATING`?{title:`Cluster Terminating`,detail:`is being terminated, so it can no longer be signed in to.`}:{title:`Cluster Terminated`,detail:`was terminated, so there is nothing left to sign in to.`}}function mf({cluster:e}){let{title:t,detail:n}=pf(e);return(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(as,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:t}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto mb-6`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:e.name}),` `,n]}),(0,K.jsx)(H,{asChild:!0,variant:`outline`,children:(0,K.jsxs)(V,{to:`/${e.organizationId}`,children:[(0,K.jsx)(Hr,{}),` Back to clusters`]})})]})}async function hf(e){let t=ce(),{data:n}=await P.get(`/Cluster/${e}`);return ae(n,t),n}async function gf(e,t){let{queryKey:n}=_f(t);await e.cancelQueries({queryKey:n,exact:!0}),e.setQueryData(n,e=>e&&{...e,resetPassword:!1})}function _f(e,t){return B({queryKey:[e],queryFn:()=>hf(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:Gc(t?t===!0?1e4:t:void 0)})}var vf=M({error:`Please enter a valid email address.`}).toLowerCase().trim(),yf=x().nonempty({error:`Please enter your password.`}),bf=`Password cannot be longer than 256 characters.`,xf=x().nonempty({error:`Please enter a username.`}),Sf=b({username:xf,password:yf}),Cf=b({email:vf,password:yf});function wf({entityId:e,instanceClient:t}){return B({queryKey:[`health`,e],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var Tf=[`localhost`,`127.0.0.1`],Ef=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function Df(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=Tf.includes(t),a=Tf.includes(r);if(i&&a&&r!==t)return`MixedLoopback`;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return`InsecureCookieOutsideChromeAndFirefox`}return null}function Of(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n}=L(_f(e,!0)),r=(0,G.useMemo)(()=>t&&n&&n?.instances?.find(e=>e.id===t)||void 0,[n,t]),i=(0,G.useMemo)(()=>n?.status&&Nd.includes(n.status),[n?.status]),a=Fd(n),o=`instance`,s=(0,G.useMemo)(()=>n?r?(u.flagForFabricConnect(r.id,!1),p(r)):(u.flagForFabricConnect(n.id,!1),c(n)):null,[n,r]),l=r?.id??n?.id;(0,G.useEffect)(()=>{r?u.setUserForEntity(r,null):n&&u.setUserForEntity(n,null)},[l]);let d=q({operationsUrl:s}),f=(0,G.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),m=(0,G.useMemo)(()=>Df(navigator.userAgent,location.hostname,s),[s]),{data:h}=L({...wf(d),enabled:!a}),g=on({resolver:mt(Sf),defaultValues:{username:``,password:``}}),{control:_,handleSubmit:y}=g,{submitForm:b,isPending:x}=Zd({cluster:n,instance:r,instanceParams:d});if(n&&a)return(0,K.jsx)(`div`,{className:`flex flex-col items-center mt-24`,children:(0,K.jsx)(mf,{cluster:n})});if(!t&&n&&!n?.fqdn)return(0,K.jsx)(qe,{to:`../instances`,replace:!0});if(n?.resetPassword){let e=i&&lf(n);return(0,K.jsx)(qe,{to:`/${n.organizationId}/${n.id}/${e?`finish-setup`:`starting-up`}`,replace:!0})}return(0,K.jsxs)(K.Fragment,{children:[!1,(0,K.jsx)(`div`,{className:v(`min-h-screen`,`items-center justify-center flex`),children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs py-8`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,K.jsx)(Od,{...g,children:(0,K.jsxs)(`form`,{id:`auth-${o}-signin-form`,name:`auth-${o}-signin-form`,onSubmit:y(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:_,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:_,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(H,{disabled:x,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Sign In`}),h===!1&&(0,K.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,o,` is not responding to GET`,` `,(0,K.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,K.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,K.jsx)(`li`,{children:`Is the server running?`}),(0,K.jsxs)(`li`,{children:[`Have you`,` `,(0,K.jsx)(`a`,{href:`https://docs.harperdb.io/docs/developers/security/configuration#cors`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`enabled CORS`}),` `,`for the operations API?`]}),f&&(0,K.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,K.jsx)(`a`,{href:`https://www.google.com/search?q=How+do+I+enable+local+network+access+in+my+browser%3F`,className:`underline`,target:`_blank`,rel:`noreferrer`,children:`local network access`}),` `,`in your browser?`]})]})]}),m===Ef.MixedLoopback&&(0,K.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because you're mixing 127.0.0.1 and localhost. Pick one or the other.`]}),m===Ef.InsecureCookieOutsideChromeAndFirefox&&(0,K.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because your browser doesn't consider localhost to be secure, so it doesn't pass the cookies along. Firefox or Chromium based browsers should pass the cookies properly.`]}),(0,K.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,K.jsx)(`div`,{className:`text-center pt-2`,children:(0,K.jsx)(V,{to:Id(),target:`_blank`,children:(0,K.jsx)(H,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}function kf({text:e,before:t,after:n,selection:r,maxLength:i}){let a=e.replace(/[\r\n]+$/,``).replace(/\r\n|\r|\n/g,` `);if(!a||n.length<i-1)return null;let o=t.length-(r[1]-r[0]),s=Math.max(0,i-o);return s>=a.length?null:{pasted:a.length,kept:Math.min(s,Math.max(0,n.length-o))}}function Af(e,t){let{name:n,formLengthHintId:r}=jd(),i=Bn({name:n,disabled:e==null}),a=typeof i==`string`?i:``,[o,s]=(0,G.useState)(null),c=(0,G.useRef)(void 0);if((0,G.useEffect)(()=>()=>clearTimeout(c.current),[]),e==null)return{controlProps:{},inputProps:{onPaste:t},hint:null};let l=o;l&&l!==`pending`&&a!==l.value&&(l=null,s(null));let u=n=>{t?.(n);let r=n.currentTarget,i=n.clipboardData?.getData(`text/plain`)??``,{selectionStart:a,selectionEnd:o}=r;if(n.defaultPrevented||r.readOnly||!i||a===null||o===null)return;let l=r.value,u=[a,o];s(`pending`),clearTimeout(c.current),c.current=setTimeout(()=>{let t=r.value,n=kf({text:i,before:l,after:t,selection:u,maxLength:e});s(n&&{...n,value:t})})},d=jf(e,a.length),f=null;if(l&&l!==`pending`){let e=l.kept?`only the first ${l.kept} fit`:`none of it fit`;f=`${d} Pasted text was ${oe(l.pasted,`character`,`characters`)}; ${e}.`}else!l&&a.length>=e&&(f=d);return{controlProps:{"aria-describedby":r},inputProps:{maxLength:e,onPaste:u},hint:(0,K.jsx)(Mf,{id:r,message:f})}}function jf(e,t){return t>e?`Maximum ${e} characters; this has ${t}.`:t===e?`Maximum ${e} characters reached.`:`Maximum ${e} characters.`}function Mf({id:e,message:t}){return(0,K.jsxs)(`p`,{id:e,"data-slot":`form-length-hint`,"aria-live":`polite`,"aria-atomic":`true`,className:t?`flex items-start gap-1.5 text-sm text-amber-800 dark:text-yellow`:`sr-only`,children:[t&&(0,K.jsx)(Rs,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0`}),t]})}function Nf({type:e=`text`,passwordLabel:t=`password`,maxLength:n,onPaste:r,...i}){let[a,o]=(0,G.useState)(!1),s=Af(n,r),c=e===`email`?_o:e===`password`?io:Hs;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`auth-input`,children:[(0,K.jsx)(J,{...s.controlProps,children:(0,K.jsx)($,{...i,...s.inputProps,type:e===`password`&&a?`text`:e})}),(0,K.jsx)(c,{"aria-hidden":`true`,className:`auth-input-icon`}),e===`password`&&(0,K.jsx)(`button`,{type:`button`,className:`auth-password-toggle`,"aria-label":`${a?`Hide`:`Show`} ${t}`,disabled:i.disabled,onClick:()=>o(e=>!e),children:a?(0,K.jsx)(ma,{"aria-hidden":`true`}):(0,K.jsx)(ga,{"aria-hidden":`true`})})]}),s.hint]})}function Pf({overEmail:e}){return(0,K.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}var Ff=`The server is temporarily unavailable. It isn't a problem with the details you entered — please try again in a moment.`,If=`Something went wrong on our end. It isn't a problem with the details you entered, and trying again may not help.`,Lf=`Too many attempts. Please wait a short while before trying again.`,Rf=`We didn't get an answer from the server, so we can't tell whether that went through.`,zf=new Set([503]),Bf=new Set([502,504]);function Vf(e,t){if(e instanceof Hd)return Rd;let n=`${Rf} ${t}`,r=e,i=r?.response?.status;if(typeof i==`number`)return i===429?Lf:i<500?void 0:Bf.has(i)?n:zf.has(i)?Ff:If;let a=r?.code;return typeof a==`string`&&rr.has(a)?n:void 0}function Hf(e,t){return Vf(e,t)??fc(e).message}var Uf=240,Wf=/[\uD800-\uDBFF]$/;function Gf(e){return`${e.slice(0,Uf).replace(Wf,``).trimEnd()}…`}function Kf({message:e,suggestSupport:t}){if(!e)return null;let n=e.length>Uf?Gf(e):e;return(0,K.jsxs)(`p`,{role:`alert`,"data-slot":`form-message`,className:`text-destructive text-sm break-words`,children:[n,(t||e===`Something went wrong on our end. It isn't a problem with the details you entered, and trying again may not help.`)&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(Pf,{overEmail:!0}),` if this keeps happening.`]})]})}function qf(){return!1}var Jf;function Yf(){return Jf??=$f().catch(e=>{throw Jf=void 0,e}),Jf}function Xf(){qf()&&Yf().catch(()=>{})}async function Zf(e){}var Qf=8e3;function $f(){return new Promise((e,t)=>{if(window.grecaptcha?.enterprise){e(window.grecaptcha.enterprise);return}let n=document.createElement(`script`);n.src=`https://www.google.com/recaptcha/enterprise.js?render=undefined`,n.async=!0,n.defer=!0;let r=e=>{clearTimeout(i),n.remove(),t(Error(e))},i=setTimeout(()=>r(`reCAPTCHA script load timed out`),Qf);n.addEventListener(`load`,()=>{clearTimeout(i),window.grecaptcha?.enterprise?e(window.grecaptcha.enterprise):r(`reCAPTCHA script loaded without exposing its API`)}),n.addEventListener(`error`,()=>r(`reCAPTCHA script failed to load`)),document.head.appendChild(n)})}var ep=`verification failed`,tp=[`error`,`message`,`title`,`detail`];function np(e){let t=e?.response;if(t?.status!==403)return!1;let n=t.data;return typeof n==`string`?rp(n):tp.some(e=>rp(n?.[e]))}function rp(e){return typeof e==`string`&&e.toLowerCase().includes(ep)}var ip=`We couldn't verify this request. A VPN, proxy, or strict browser privacy setting can cause this — turn it off for this page, then try again.`,ap=`We could not run the verification check. Disable any ad blocker for this page, then reload and try again.`,op=`The verification check expired before it reached us. Please try again.`,sp=`The verification check couldn't run while you were offline. Check your connection, then try again.`,cp=2,lp=0;function up(e){e instanceof Hd||(lp=0)}function dp(e){if(e?.minted===!1)return e.offline?sp:void 0;if(e&&Date.now()-e.at>=12e4)return op}function fp(e,t){(0,G.useEffect)(()=>{Xf()},[]);let n=(0,G.useRef)(void 0),[r,i]=(0,G.useState)(!1),a=(0,G.useCallback)(async()=>{i(!0);let t=!ke.isOnline();try{let r=await Zf(e);return n.current=r?{minted:!0,at:Date.now()}:qf()?{minted:!1,offline:t||!ke.isOnline()}:void 0,r}finally{i(!1)}},[e]),[o,s]=(0,G.useState)(!1);return{getToken:a,describeCaptchaError:(0,G.useCallback)(e=>{if(!np(e)){up(e),s(!1);return}let r=n.current,i=dp(r);if(i)return s(!1),i;lp+=1,s(lp>=cp);let a=r?.minted===!1?ap:ip;return t?`${a} ${t}`:a},[t]),minting:r,supportSuggested:o}}async function pp({email:e,captchaToken:t}){let{data:n}=await P.post(`/ForgotPassword/`,{email:e,...t?{captchaToken:t}:{}});if(n)return n;throw Error(`Something went wrong`)}function mp(){return I({...Ud(pp),meta:{skipGlobalErrorToast:!0},onSuccess:()=>up(),onError:e=>{np(e)||(up(e),Kd(e))}})}var hp=`Check your inbox before requesting another link.`,gp=b({email:vf});function _p(){let e=De(),{me:t}=Oe({strict:!1}),n=on({resolver:mt(gp),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n,[s,c]=(0,G.useState)(),l=(0,G.useCallback)(()=>c(void 0),[]);(0,G.useEffect)(()=>{i(`email`)},[i]);let{mutate:u,isPending:d}=mp(),f=fp(`forgot_password`),p=async t=>{c(void 0);let n=await f.getToken();u({...t,captchaToken:n},{onSuccess:t=>{U.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e({to:`/sign-in`,search:{me:r}})},onError:e=>{c(f.describeCaptchaError(e)??Hf(e,hp))}})};return(0,K.jsxs)(`div`,{className:`auth-form`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,K.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(p,l),className:`sign-in-form`,children:[(0,K.jsx)(Y,{control:a,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(Nf,{disabled:d,type:`email`,autoComplete:`email`,placeholder:`you@company.com`,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Kf,{message:s,suggestSupport:f.supportSuggested}),(0,K.jsx)(H,{type:`submit`,variant:`submit`,disabled:d||f.minting,className:`sign-in-submit`,children:`Send Password Reset Email`})]})}),(0,K.jsxs)(`div`,{className:`auth-links`,children:[(0,K.jsx)(V,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,K.jsx)(V,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var vp=async({token:e,password:t})=>{let{data:n}=await P.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function yp(){return I({...Ud(vp),...Jd})}var bp=b({password:yf.min(8,{error:`Password must be at least 8 characters long.`}).max(256,{error:bf}),confirmPassword:x()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function xp(){let{token:e}=Oe({strict:!1}),t=De();(0,G.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=on({resolver:mt(bp),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,G.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=yp(),c=(0,G.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{U.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,K.jsxs)(`div`,{className:`auth-form`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`sign-in-form`,onSubmit:a(c),children:[(0,K.jsx)(Y,{control:i,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`New Password`}),(0,K.jsx)(Nf,{disabled:s,type:`password`,autoComplete:`new-password`,...e,placeholder:`Your new password`,passwordLabel:`new password`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:i,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(Nf,{disabled:s,type:`password`,autoComplete:`new-password`,...e,placeholder:`Confirm your password`,passwordLabel:`password confirmation`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:s,className:`sign-in-submit`,children:`Submit New Password`})]})})]})}function Sp(...e){let t=e.flat(1);return t.map((e,n)=>typeof e==`string`?Cp(e,n!==0,n!==t.length-1):e).join(`/`)}function Cp(e,t=!0,n=!0){let r=t&&e[0]===`/`,i=n&&e[e.length-1]===`/`;return r&&i?e.slice(1,-1):r?e.slice(1):i?e.slice(0,-1):e}var wp=`/#/check-oauth`;function Tp(e,t){let n=Sp(`/`,`oauth`,e,`login`);return t?`${n}?redirect=${encodeURIComponent(t)}`:n}function Ep(){return(0,K.jsx)(ol,{className:`pointer-events-none absolute -top-2 right-3 z-10 rounded-full border-primary bg-primary px-1.5 py-0 text-[10px] font-medium text-white shadow-sm`,children:`Last used`})}function Dp({text:e,disabled:t,onClick:n,lastUsed:r=!1,compact:i=!1}){let a=(0,K.jsxs)(`a`,{"aria-label":e,href:t?void 0:Tp(`github`,wp),role:t?`link`:void 0,tabIndex:t?0:void 0,onClick:n,"aria-disabled":t||void 0,className:v(`github-signin-btn`,t&&`opacity-50 cursor-default`),children:[(0,K.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:``,className:`github-icon`}),i?`GitHub`:e]});return r?(0,K.jsxs)(`div`,{className:`relative flex flex-col`,children:[a,(0,K.jsx)(Ep,{})]}):a}function Op({text:e,disabled:t,onClick:n,lastUsed:r=!1,compact:i=!1}){let a=(0,K.jsxs)(`a`,{"aria-label":e,href:t?void 0:Tp(`google`,wp),role:t?`link`:void 0,tabIndex:t?0:void 0,onClick:n,"aria-disabled":t||void 0,className:v(`gsi-material-button`,t&&`opacity-50 cursor-default`),children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-state`}),(0,K.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-icon`,children:(0,K.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 48 48`,xmlnsXlink:`http://www.w3.org/1999/xlink`,className:`block`,children:[(0,K.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,K.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,K.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,K.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`}),(0,K.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,K.jsx)(`span`,{className:`gsi-material-button-contents`,children:i?`Google`:e}),(0,K.jsx)(`span`,{className:`hidden`,children:e})]})]});return r?(0,K.jsxs)(`div`,{className:`relative flex flex-col`,children:[a,(0,K.jsx)(Ep,{})]}):a}function kp(e){if(!T(e)||e.response?.status!==403)return!1;let t=e.response.data,n=typeof t==`string`?t:pr(t?.error)??pr(t?.message)??pr(t?.title)??``;return/verif/i.test(n)}var Ap=async({email:e})=>{let{data:t}=await P.post(`/ResendVerificationEmail/`,{email:e});return t};function jp(){return I({...Ud(Ap),...Jd})}function Mp(){let e=De(),t=Ze(),n=Ee(),{redirect:r}=Oe({strict:!1}),[i,a]=(0,G.useState)(),{mutate:o,isPending:s}=Np(),{mutate:c}=jp();return{clearSubmitError:(0,G.useCallback)(()=>a(void 0),[]),isPending:s,submitError:i,submitForm:(0,G.useCallback)(i=>{a(void 0),o(i,{onSuccess:async i=>{u.setUserForEntity(m,i),od();let a=Pr(i);ed(i.email),await t.invalidateQueries({queryKey:f,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})},onError:t=>{if(kp(t)){c({email:i.email},{onSuccess:()=>U.info(`Verify your email to finish signing in`,{description:`We sent a new verification link to ${i.email}.`})}),e({to:`/verifying?email=`+encodeURIComponent(i.email)});return}a(Hf(t,`Try signing in again.`))}})},[e,t,r,c,n,o])}}function Np(){return I({...Ud(Pp),meta:{skipGlobalErrorToast:!0},onError:e=>{kp(e)||Kd(e)}})}async function Pp({email:e,password:t}){let{data:n}=await P.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function Fp(){let[e,t]=Zc(_r.RememberSignInMethod,!0),[n,r]=Zc(_r.LastUsedSignInMethod,null),i=(0,G.useCallback)(t=>{e&&(hr(_r.LastUsedSignInMethod,t),r(t))},[e,r]),a=(0,G.useCallback)(()=>{r(null),t(!1)},[r,t]),o=(0,G.useCallback)(()=>{t(!0)},[t]);return{lastUsed:e?n:null,remember:e,recordMethod:i,disable:a,enable:o}}var Ip=`mx-auto mt-3 block text-xs text-muted-foreground underline hover:text-foreground dark:text-inherit dark:hover:text-blue-300`;function Lp(){let{me:e}=Oe({strict:!1}),t=on({resolver:mt(Cf),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o,submitError:s,clearSubmitError:c}=Mp(),{lastUsed:l,remember:u,recordMethod:d,disable:f,enable:p}=Fp();return(0,K.jsxs)(`div`,{className:`auth-form fabric-sign-in`,children:[(0,K.jsx)(`h1`,{children:`Welcome back`}),(0,K.jsx)(`p`,{className:`sign-in-subtitle`,children:`Sign in to Harper Fabric`}),(0,K.jsx)(Od,{...t,children:(0,K.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a,c),className:`sign-in-form`,children:[(0,K.jsx)(Y,{control:r,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(Nf,{type:`email`,placeholder:`you@company.com`,autoFocus:!0,autoComplete:`email`,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(Nf,{type:`password`,placeholder:`Your password`,autoComplete:`current-password`,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Kf,{message:s}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,className:`sign-in-submit`,disabled:o,children:[`Sign In `,(0,K.jsx)(Wr,{"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`sign-in-recovery`,children:(0,K.jsx)(V,{to:`/forgot-password`,search:{me:i},children:`Forgot password?`})})]})}),(0,K.jsx)(`div`,{className:`sign-in-divider`,children:(0,K.jsx)(`span`,{children:`or continue with`})}),(0,K.jsxs)(`div`,{className:`sign-in-providers`,children:[(0,K.jsx)(Op,{text:`Sign in with Google`,compact:!0,lastUsed:l===`google`,onClick:()=>d(`google`)}),(0,K.jsx)(Dp,{text:`Sign in with GitHub`,compact:!0,lastUsed:l===`github`,onClick:()=>d(`github`)})]}),(0,K.jsxs)(`p`,{className:`sign-in-signup`,children:[`Don’t have an account? `,(0,K.jsx)(V,{to:`/sign-up`,search:{me:i},children:`Sign up for free`})]}),u?l&&(0,K.jsx)(`button`,{type:`button`,onClick:f,className:Ip,children:`On a shared device? Forget my sign-in method.`}):(0,K.jsx)(`button`,{type:`button`,onClick:p,className:Ip,children:`Remember my last sign-in method on this device.`})]})}var Rp=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function zp({captchaToken:e,...t}){let{data:n}=await P.post(`/User/`,{...t,...e?{captchaToken:e}:{}});if(n)return n;throw Error(`Something went wrong`)}function Bp(){return I({...Ud(zp),meta:{skipGlobalErrorToast:!0},onSuccess:()=>up(),onError:e=>{np(e)||(up(e),Kd(e))}})}var Vp=`Check your email for a verification link before signing up again.`,Hp=`You can also sign up with Google or GitHub above, which skips this check.`,Up=b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:x().trim().min(2,{error:`Please enter your first name.`}).regex(Rp,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:x().trim().min(2,{error:`Please enter your last name.`}).regex(Rp,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:yf.min(8,{error:`Password must be at least 8 characters long.`}).max(256,{error:bf}),confirmPassword:x(),acceptTerms:A().refine(e=>e===!0,{message:`You must accept the Privacy Policy and Terms of Service.`})}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function Wp(){let e=De(),{email:t,me:n}=Oe({strict:!1}),[r,i]=(0,G.useState)(!1),a=on({resolver:mt(Up),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,setError:l,clearErrors:u,control:d,handleSubmit:f,formState:p}=a,m=p.errors.root?.message;(0,G.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:h,isPending:g}=Bp(),_=fp(`signup`,Hp),v=(0,G.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;u(`root`);let a=await _.getToken();h({...i,captchaToken:a},{onSuccess:()=>{ed(i.email),od(),e({to:`/verifying?email=`+encodeURIComponent(i.email)})},onError:e=>{l(`root`,{type:`server`,message:_.describeCaptchaError(e)??Hf(e,Vp)})}})},[u,e,l,h,_]),y=(0,G.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),b=(0,K.jsx)(Y,{control:d,name:`acceptTerms`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex flex-row items-start space-x-3 space-y-0 p-1 transition-colors duration-300 ${r?`bg-red-500/20 animate-pulse rounded`:``}`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`size-4 rounded border-gray-300 bg-white text-purple-600 focus:ring-purple-500`,checked:e.value,onChange:e.onChange})}),(0,K.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,K.jsxs)(Z,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,K.jsx)(`a`,{href:`https://www.harper.fast/resources/privacy-policy`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Privacy Policy (opens in new tab)`,children:`Privacy Policy`}),` `,`and`,` `,(0,K.jsx)(`a`,{href:`https://www.harper.fast/resources/paas-terms-of-service`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Terms of Service (opens in new tab)`,children:`Terms of Service`})]}),(0,K.jsx)(Q,{})]})]})});return(0,K.jsxs)(`div`,{className:`auth-form`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign up for Harper Fabric`}),(0,K.jsxs)(Od,{...a,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[b,(0,K.jsx)(Op,{text:`Sign up with Google`,disabled:!s,onClick:y}),(0,K.jsx)(Dp,{text:`Sign up with GitHub`,disabled:!s,onClick:y})]}),(0,K.jsx)(`hr`,{className:`border-gray-600`}),(0,K.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:f(v),className:`sign-in-form`,children:[(0,K.jsx)(Y,{control:d,name:`firstname`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`First Name`}),(0,K.jsx)(Nf,{type:`text`,autoCapitalize:`words`,maxLength:Up.shape.firstname.maxLength,...e,placeholder:`Your first name`,autoComplete:`given-name`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`lastname`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Last Name`}),(0,K.jsx)(Nf,{type:`text`,autoCapitalize:`words`,maxLength:Up.shape.lastname.maxLength,...e,placeholder:`Your last name`,autoComplete:`family-name`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(Nf,{type:`email`,placeholder:`you@company.com`,readOnly:!!t,disabled:!!t,autoComplete:`email`,autoCapitalize:`none`,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(Nf,{type:`password`,autoComplete:`new-password`,...e,placeholder:`Your password`,passwordLabel:`password`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(Nf,{type:`password`,autoComplete:`new-password`,...e,placeholder:`Confirm your password`,passwordLabel:`password confirmation`}),(0,K.jsx)(Q,{})]})}),b,(0,K.jsx)(Kf,{message:m,suggestSupport:_.supportSuggested}),(0,K.jsx)(H,{type:`submit`,variant:`submit`,disabled:g||_.minting,className:`sign-in-submit`,children:`Sign Up For Free`})]})]}),(0,K.jsx)(`div`,{className:`auth-links`,children:(0,K.jsx)(V,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var Gp=async e=>{let{data:t}=await P.put(`/VerifyEmail/`,{token:e.toString()});return t};function Kp(){return I({...Ud(Gp),...Jd})}var qp=b({email:vf});function Jp(){let e=De(),{mutate:t,isPending:n}=jp(),r=on({resolver:mt(qp),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,G.useEffect)(()=>{a(`email`)},[a]);let c=(0,G.useCallback)(async n=>{t(n,{onSuccess:t=>{U.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,K.jsx)(Od,{...r,children:(0,K.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`sign-in-form`,children:[(0,K.jsx)(Y,{control:o,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`auth-field`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(Nf,{disabled:n,type:`email`,autoComplete:`email`,placeholder:`you@company.com`,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(H,{type:`submit`,variant:`submit`,disabled:n,className:`sign-in-submit`,children:`Send Verification Email`})]})})}function Yp(){let{token:e}=Oe({strict:!1}),t=De(),{mutate:n,isPending:r}=Kp(),i=(0,G.useCallback)(e=>{n(e,{onSuccess:()=>{U.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,G.useEffect)(()=>{e&&i(e)},[i,e]),(0,K.jsxs)(`div`,{className:`auth-form`,children:[(0,K.jsx)(sd,{icon:po,title:`Verify Email`,subtitle:r?void 0:`Enter your email to receive a verification link.`}),r?(0,K.jsxs)(`p`,{role:`status`,className:`auth-pending-message`,children:[(0,K.jsx)(no,{"aria-hidden":`true`,className:`auth-loading-icon`}),`Verifying email...`]}):(0,K.jsx)(Jp,{})]})}function Xp(){let{email:e}=Oe({strict:!1}),{mutate:t,isPending:n}=jp(),r=(0,G.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{U.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}}),!1),[e,t]);return(0,K.jsxs)(`div`,{className:`auth-form flex flex-col gap-4`,children:[(0,K.jsx)(sd,{icon:po,title:`Check your email!`,subtitle:`Open the verification link in your inbox.`}),(0,K.jsxs)(`p`,{children:[`From:`,` `,(0,K.jsxs)(`strong`,{children:[`harper@`,(0,K.jsx)(`wbr`,{}),`notifications.`,(0,K.jsx)(`wbr`,{}),`harperfabric.com`]})]}),(0,K.jsxs)(`p`,{children:[`To: `,(0,K.jsx)(`strong`,{children:e||`your email`})]}),(0,K.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,K.jsxs)(`div`,{className:`auth-links`,children:[(0,K.jsx)(V,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,K.jsx)(V,{className:`text-sm`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var Zp=R({getParentRoute:()=>Hu,id:`_authLayout`,component:Zu}),Qp=R({getParentRoute:()=>Zp,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Lp,beforeLoad:({context:e,location:t})=>{let n=Pu(e)?.user;if(n){let e=t?.search,r=Pr(n);throw Ne({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),$p=R({getParentRoute:()=>Hu,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:({context:e,location:t})=>{if(Pu(e)?.user){let e=t?.search;throw Ne({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),em=R({getParentRoute:()=>Zp,path:`sign-up`,head:()=>({meta:[{title:`Sign Up — Harper Fabric`}]}),component:Wp}),tm=R({getParentRoute:()=>Zp,path:`forgot-password`,head:()=>({meta:[{title:`Forgot Password — Harper Fabric`}]}),component:_p}),nm=R({getParentRoute:()=>Zp,path:`verify-email`,head:()=>({meta:[{title:`Verify Email — Harper Fabric`}]}),component:Yp}),rm=R({getParentRoute:()=>Zp,path:`verifying`,head:()=>({meta:[{title:`Check Your Email — Harper Fabric`}]}),component:Xp}),im=R({getParentRoute:()=>Zp,path:`check-oauth`,head:()=>({meta:[{title:`Signing In — Harper Fabric`}]}),component:hd}),am=R({getParentRoute:()=>Zp,path:`reset-password`,head:()=>({meta:[{title:`Reset Password — Harper Fabric`}]}),component:xp});Zp.addChildren([Qp,em,im,tm,nm,rm,am]);var om=[$p];function sm({context:e,params:t}){if(Fd(e?.cluster))throw Ne({to:`/${t.organizationId}/${t.clusterId}`})}function cm({children:e}){return(0,K.jsx)(`nav`,{className:`studio-subnav fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,K.jsx)(Dd,{}),e]})})}var lm=360,um=280,dm=16,fm={width:820,height:680};function pm({width:e,height:t},n,r){return{width:Math.round(Math.max(lm,Math.min(e,n-32))),height:Math.round(Math.max(um,Math.min(t,r-32)))}}function mm({width:e,height:t},n,r){return{x:Math.round((n-e)/2),y:Math.round((r-t)/2)}}function hm({x:e,y:t},{width:n,height:r},i,a){let o=Math.max(dm,i-n-dm),s=Math.max(dm,a-r-dm);return{x:Math.min(Math.max(e,dm),o),y:Math.min(Math.max(t,dm),s)}}function gm(){let[e,t]=Zc(_r.ResizableModalSize,fm),[n,r]=(0,G.useState)(()=>pm(e,window.innerWidth,window.innerHeight)),[i,a]=(0,G.useState)(()=>mm(n,window.innerWidth,window.innerHeight)),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(n);f.current=n;let p=(0,G.useRef)(i);p.current=i;let m=(0,G.useRef)(u);m.current=u;let h=(0,G.useRef)(null),g=(0,G.useRef)(e);g.current=e;let _=(0,G.useRef)(null),v=(0,G.useRef)(!1),y=(0,G.useRef)(null),b=(0,G.useCallback)(e=>{if(!e||e===y.current)return;y.current=e,d(!1),h.current=null;let t=window.innerWidth,n=window.innerHeight,i=pm(g.current,t,n);r(i),a(mm(i,t,n))},[]);return(0,G.useEffect)(()=>{let e=()=>{let e=window.innerWidth,t=window.innerHeight;if(m.current){let n=pm({width:e,height:t},e,t);r(n),a(mm(n,e,t));return}let n=pm(g.current,e,t);r(n),a(hm(p.current,n,e,t))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>(v.current=!1,()=>{v.current=!0,_.current?.()}),[]),{size:n,position:i,isDragging:o,isResizing:c,isMaximized:u,contentRef:b,startDrag:(0,G.useCallback)(e=>{e.preventDefault(),_.current?.();let t=y.current,n=e.clientX,r=e.clientY,i={...p.current};s(!0),d(!1);let o=0,c=0,l=0,u=()=>{o=0,t&&(t.style.transform=`translate3d(${c}px, ${l}px, 0)`)},m=e=>{c=e.clientX-n,l=e.clientY-r,o||=requestAnimationFrame(u)},h=()=>{o&&cancelAnimationFrame(o),window.removeEventListener(`mousemove`,m),window.removeEventListener(`mouseup`,g),v.current||s(!1),_.current===h&&(_.current=null)},g=()=>{h();let e=hm({x:i.x+c,y:i.y+l},f.current,window.innerWidth,window.innerHeight);t&&(t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.transform=``),a(e)};window.addEventListener(`mousemove`,m),window.addEventListener(`mouseup`,g),_.current=h},[]),startResize:(0,G.useCallback)(e=>n=>{n.preventDefault(),n.stopPropagation(),_.current?.();let i=y.current,o=n.clientX,s=n.clientY,c={...f.current},u={...p.current};l(!0),d(!1);let m=0,h=c,g=u,b=()=>{m=0,i&&(i.style.width=`${h.width}px`,i.style.height=`${h.height}px`,i.style.left=`${g.x}px`,i.style.top=`${g.y}px`)},x=t=>{let n=window.innerWidth,r=window.innerHeight,i=t.clientX-o,a=t.clientY-s,l=t.altKey,d=l?2:1,f=c.width,p=c.height;e.includes(`e`)&&(f=c.width+i*d),e.includes(`w`)&&(f=c.width-i*d),e.includes(`s`)&&(p=c.height+a*d),e.includes(`n`)&&(p=c.height-a*d),h=pm({width:f,height:p},n,r);let{x:_,y:v}=u;l?(_=Math.round(u.x+(c.width-h.width)/2),v=Math.round(u.y+(c.height-h.height)/2)):(e.includes(`w`)&&(_=u.x+c.width-h.width),e.includes(`n`)&&(v=u.y+c.height-h.height)),g={x:_,y:v},m||=requestAnimationFrame(b)},S=()=>{m&&cancelAnimationFrame(m),window.removeEventListener(`mousemove`,x),window.removeEventListener(`mouseup`,C),v.current||l(!1),_.current===S&&(_.current=null)},C=()=>{S();let e=window.innerWidth,n=window.innerHeight,i=pm(h,e,n);r(i),a(hm(g,i,e,n)),t(i)};window.addEventListener(`mousemove`,x),window.addEventListener(`mouseup`,C),_.current=S},[t]),toggleMaximize:(0,G.useCallback)(()=>{let e=window.innerWidth,t=window.innerHeight;if(m.current){let n=h.current;if(n){let i=pm(n.size,e,t);r(i),a(hm(n.position,i,e,t))}d(!1)}else{h.current={size:f.current,position:p.current};let n=pm({width:e,height:t},e,t);r(n),a(mm(n,e,t)),d(!0)}},[])}}function _m({...e}){return(0,K.jsx)(Dt,{"data-slot":`dialog`,...e})}function vm({...e}){return(0,K.jsx)(Ut,{"data-slot":`dialog-trigger`,...e})}function ym({...e}){return(0,K.jsx)($t,{"data-slot":`dialog-portal`,...e})}function bm({className:e,...t}){return(0,K.jsx)(en,{"data-slot":`dialog-overlay`,className:F(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-white/80 backdrop-blur-xs dark:bg-black-dark/90 dark:backdrop-blur-none`,e),...t})}function xm({className:e}){return(0,K.jsxs)(Mt,{className:F(`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-0 right-0 flex items-start justify-end rounded-bl-md p-4 opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),children:[(0,K.jsx)(Ks,{className:`text-popover-foreground`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}var Sm=[{dir:`n`,className:`-top-2 inset-x-5 h-4 cursor-ns-resize z-30`},{dir:`s`,className:`-bottom-2 inset-x-5 h-4 cursor-ns-resize z-30`},{dir:`e`,className:`-right-2 inset-y-5 w-4 cursor-ew-resize z-30`},{dir:`w`,className:`-left-2 inset-y-5 w-4 cursor-ew-resize z-30`},{dir:`nw`,className:`-top-2 -left-2 size-6 cursor-nwse-resize z-40`},{dir:`ne`,className:`-top-2 -right-2 size-6 cursor-nesw-resize z-40`},{dir:`sw`,className:`-bottom-2 -left-2 size-6 cursor-nesw-resize z-40`},{dir:`se`,className:`-bottom-2 -right-2 size-6 cursor-nwse-resize z-40`}];function Cm({className:e,children:t,...n}){let{size:r,position:i,isDragging:a,isResizing:o,isMaximized:s,contentRef:c,startDrag:l,startResize:u,toggleMaximize:d}=gm(),f=`ring-offset-background focus:ring-ring text-popover-foreground flex size-8 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none`;return(0,K.jsxs)(ym,{"data-slot":`dialog-portal`,children:[(0,K.jsx)(bm,{className:F(`transition-opacity duration-200`,a&&`opacity-0`)}),(0,K.jsxs)(In,{ref:c,"data-slot":`dialog-content`,style:{left:i.x,top:i.y,width:r.width,height:r.height},className:F(`bg-popover data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed z-50 rounded-md border shadow-2xl transition-none`,a&&`will-change-transform`,e),...n,children:[(0,K.jsxs)(`div`,{className:F(`flex h-full w-full flex-col gap-4 overflow-hidden rounded-md p-6`,(a||o)&&`select-none`),children:[(0,K.jsx)(`div`,{onMouseDown:l,className:`absolute inset-x-0 top-0 z-10 flex h-12 cursor-move items-start justify-center`,"aria-hidden":!0,children:(0,K.jsx)(Ma,{className:`mt-1 size-4 text-muted-foreground/40`})}),t,(0,K.jsxs)(`div`,{className:`absolute top-6 right-4 z-20 flex h-[1.125rem] items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:d,"aria-label":s?`Restore modal size`:`Maximize modal`,className:f,children:s?(0,K.jsx)(To,{className:`size-4`}):(0,K.jsx)(xo,{className:`size-4`})}),(0,K.jsxs)(Mt,{"aria-label":`Close`,className:f,children:[(0,K.jsx)(Ks,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),Sm.map(({dir:e,className:t})=>(0,K.jsx)(`div`,{"data-resize-handle":e,onMouseDown:u(e),className:F(`absolute`,t),"aria-hidden":!0},e))]})]})}function wm({className:e,children:t,resizable:n,...r}){return n?(0,K.jsx)(Cm,{className:e,...r,children:t}):(0,K.jsxs)(ym,{"data-slot":`dialog-portal`,children:[(0,K.jsx)(bm,{}),(0,K.jsxs)(In,{"data-slot":`dialog-content`,className:F(`bg-popover data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] lg:max-w-2xl max-h-screen overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md border p-6 shadow-2xl duration-200`,e),...r,children:[t,(0,K.jsx)(xm,{})]})]})}function Tm({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`dialog-header`,className:F(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Em({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`dialog-footer`,className:F(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Dm({className:e,...t}){return(0,K.jsx)(tn,{"data-slot":`dialog-title`,className:F(`text-lg leading-none text-popover-foreground font-semibold`,e),...t})}function Om({className:e,...t}){return(0,K.jsx)(jt,{"data-slot":`dialog-description`,className:F(`text-muted-foreground text-sm`,e),...t})}function km({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,K.jsxs)(_m,{open:n,onOpenChange:i,children:[s&&(0,K.jsx)(vm,{asChild:!0,children:s}),(0,K.jsxs)(wm,{className:`sm:max-w-[750px]`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsxs)(Dm,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,K.jsx)(Om,{children:`This action cannot be undone.`})]}),!r&&(0,K.jsxs)(`div`,{className:`p-3 my-5 rounded-md border border-destructive bg-destructive/10 text-foreground`,children:[(0,K.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,K.jsx)(No,{className:`inline-block size-5 text-destructive`}),` `,(0,K.jsx)(`span`,{children:`Warning`})]}),(0,K.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,K.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,K.jsxs)(H,{type:`button`,onClick:()=>i(!1),children:[(0,K.jsx)(Hr,{}),` Cancel`]}),(0,K.jsxs)(H,{variant:`destructive`,onClick:a,disabled:o,children:[(0,K.jsx)(Is,{}),` `,l]})]})})]})]})}function Am({...e}){return(0,K.jsx)(Wt,{"data-slot":`context-menu`,...e})}function jm({...e}){return(0,K.jsx)(Qt,{"data-slot":`context-menu-trigger`,...e})}function Mm({className:e,...t}){return(0,K.jsx)(Ot,{children:(0,K.jsx)($n,{"data-slot":`context-menu-content`,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...t})})}function Nm({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(_t,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:F(`focus:bg-accent focus:text-grey dark:focus:bg-white/15 dark:focus:text-white`,`data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10`,`dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive`,`data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground`,`relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm`,`outline-hidden select-none`,`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function Pm({className:e,inset:t,...n}){return(0,K.jsx)(Zt,{"data-slot":`context-menu-label`,"data-inset":t,className:F(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Fm({className:e,...t}){return(0,K.jsx)(Xt,{"data-slot":`context-menu-separator`,className:F(`bg-border -mx-1 my-1 h-px`,e),...t})}function Im({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`context-menu-shortcut`,className:F(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}var Lm={dropdown:{Item:yc,Label:Cc,Separator:wc},context:{Item:Nm,Label:Pm,Separator:Fm}};function Rm(e,t){let{Item:n,Label:r,Separator:i}=Lm[t];return e.map(e=>{if(e.type===`separator`)return(0,K.jsx)(i,{},e.key);if(e.type===`label`)return(0,K.jsx)(r,{className:e.className,children:e.label},e.key);let t=(0,K.jsxs)(n,{className:e.className,onClick:e.onClick,disabled:e.disabled,variant:e.variant,children:[e.icon,e.label]});return e.to?(0,K.jsx)(V,{to:e.to,disabled:e.disabled,children:t},e.key):(0,K.jsx)(G.Fragment,{children:t},e.key)})}function zm({items:e,children:t}){return e.length?(0,K.jsxs)(Am,{children:[(0,K.jsx)(jm,{asChild:!0,children:t}),(0,K.jsx)(Mm,{children:Rm(e,`context`)})]}):(0,K.jsx)(K.Fragment,{children:t})}function Bm(e,t){if(e<45)return`a few seconds ago`;if(e<120)return`a minute ago`;let n=Math.floor(e/60);if(n<60)return`${n} minutes ago`;if(n<120)return`an hour ago`;let r=Math.floor(e/3600);return r>48?new Date(t).toLocaleString():`${r} hours ago`}function Vm(e){if(!tf(e.status))return null;if(e.status===`CLONE_PENDING`)return{waiting:!0,copiedGb:0};let t=Math.max(0,e.cloneProgressGb??0),n=e.cloneExpectedGb&&e.cloneExpectedGb>0?e.cloneExpectedGb:void 0;return{waiting:!1,copiedGb:t,expectedGb:n,ratio:n===void 0?void 0:Math.min(1,t/n),lastProgressAt:Jm(e.cloneProgressAt),startedAt:Jm(e.cloneStartedAt)}}function Hm(e){return!e||!(e.syncing>0)?null:e.progress!==void 0&&Number.isFinite(e.progress)?`Syncing · ~${Um(Math.min(1,Math.max(0,e.progress)))}%`:`Syncing`}function Um(e){return Math.floor(e*100)}function Wm(e,t){return e.waiting?`Waiting to sync data`:[`Syncing data`,e.expectedGb===void 0||e.ratio===void 0?`~${Km(e.copiedGb)} GB copied`:`~${Km(e.copiedGb)} of ~${Km(e.expectedGb)} GB (${Um(e.ratio)}%)`,e.lastProgressAt===void 0?e.startedAt===void 0?void 0:`started ${qm(e.startedAt,t)}`:`last progress ${qm(e.lastProgressAt,t)}`].filter(Boolean).join(` · `)}var Gm=new Intl.NumberFormat(void 0,{maximumFractionDigits:1});function Km(e){return Gm.format(e)}function qm(e,t){return Bm(Math.max(0,Math.round((t-e)/1e3)),e)}function Jm(e){if(!e)return;let t=new Date(e).getTime();return Number.isFinite(t)?t:void 0}var Ym=`5.3.0-alpha.1`,Xm=`5.3.0-beta.3`;function Zm(e){return vr(`5.3.0-beta.3`,e)?`5.3`:vr(Ym,e)?`5.3-early`:`pre-5.3`}function Qm(e){return e!==`pre-5.3`}function $m(e,t){return bh.get(e)?.outOfGate===t}function eh(e,t){switch(bh.get(e)?.gate){case`from-5.3`:return t===`5.3`?`grants`:`needs-5.3`;case`until-5.3`:return t===`5.3`?`never`:`grants`;case`never`:return`never`;default:return`grants`}}function th(e,t){let n=bh.get(e);return!!n?.aliasOf||!!n?.nonDelegable||$m(e,t)||eh(e,t)!==`grants`}var nh=`5.1.0-alpha.1`,rh=`5.2.0-alpha.1`,ih=`5.3.0-alpha.1`,ah=`Data`,oh=`Schema`,sh=`Users & Roles`,ch=`Components & Deployments`,lh=`Clustering & Replication`,uh=`Jobs`,dh=`Logs & Analytics`,fh=`System`,ph=`Managed Backups`,mh=`Secrets & Environment`,hh=`Agent`,gh=[ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh],_h=[{name:`search`,su:!1,category:ah},{name:`search_by_conditions`,su:!1,category:ah},{name:`search_by_hash`,su:!1,category:ah},{name:`search_by_id`,su:!1,category:ah,aliasOf:`search_by_hash`},{name:`search_by_value`,su:!1,category:ah},{name:`sql`,su:!1,category:ah,outOfGate:`pre-5.3`,caveat:`This instance's Harper authorizes SQL against table permissions only, so listing or omitting sql here changes nothing. Harper 5.3 and later gate it by this list as well.`},{name:`insert`,su:!1,category:ah},{name:`update`,su:!1,category:ah},{name:`upsert`,su:!1,category:ah},{name:`put`,su:!1,category:ah,addedIn:ih},{name:`delete`,su:!1,category:ah},{name:`delete_records_before`,su:!0,category:ah,aliasOf:`delete_files_before`},{name:`csv_data_load`,su:!1,category:ah},{name:`csv_file_load`,su:!1,category:ah},{name:`csv_url_load`,su:!1,category:ah},{name:`import_from_s3`,su:!1,category:ah},{name:`export_local`,su:!0,category:ah},{name:`export_to_s3`,su:!0,category:ah},{name:`describe_all`,su:!1,category:oh},{name:`describe_database`,su:!1,category:oh,aliasOf:`describe_schema`},{name:`describe_schema`,su:!1,category:oh},{name:`describe_table`,su:!1,category:oh},{name:`create_database`,su:!0,category:oh},{name:`create_schema`,su:!0,category:oh,aliasOf:`create_database`},{name:`drop_database`,su:!0,category:oh},{name:`drop_schema`,su:!0,category:oh,aliasOf:`drop_database`},{name:`create_table`,su:!0,category:oh},{name:`drop_table`,su:!0,category:oh},{name:`create_attribute`,su:!1,category:oh},{name:`drop_attribute`,su:!0,category:oh},{name:`cleanup_orphan_blobs`,su:!0,category:oh,gate:`from-5.3`},{name:`user_info`,su:!1,category:sh},{name:`list_users`,su:!0,category:sh},{name:`add_user`,su:!0,category:sh},{name:`alter_user`,su:!0,category:sh},{name:`drop_user`,su:!0,category:sh},{name:`list_roles`,su:!0,category:sh},{name:`add_role`,su:!0,category:sh},{name:`alter_role`,su:!0,category:sh},{name:`drop_role`,su:!0,category:sh},{name:`refresh_operation_token`,su:!1,category:sh},{name:`add_oidc_trust`,su:!0,category:sh,addedIn:ih,nonDelegable:!0},{name:`list_oidc_trust`,su:!0,category:sh,addedIn:ih,nonDelegable:!0},{name:`drop_oidc_trust`,su:!0,category:sh,addedIn:ih,nonDelegable:!0},{name:`get_components`,su:!0,category:ch},{name:`get_component_file`,su:!0,category:ch},{name:`set_component_file`,su:!0,category:ch,gate:`from-5.3`},{name:`add_component`,su:!0,category:ch,gate:`from-5.3`},{name:`drop_component`,su:!0,category:ch,gate:`from-5.3`},{name:`deploy_component`,su:!0,category:ch,gate:`from-5.3`},{name:`package_component`,su:!0,category:ch,gate:`from-5.3`},{name:`install_node_modules`,su:!0,category:ch,gate:`from-5.3`},{name:`audit_node_modules`,su:!0,category:ch},{name:`custom_functions_status`,su:!0,category:ch},{name:`get_custom_functions`,su:!0,category:ch},{name:`get_custom_function`,su:!0,category:ch},{name:`set_custom_function`,su:!0,category:ch,gate:`from-5.3`},{name:`drop_custom_function`,su:!0,category:ch,gate:`from-5.3`},{name:`add_custom_function_project`,su:!0,category:ch,aliasOf:`add_component`},{name:`deploy_custom_function_project`,su:!0,category:ch,aliasOf:`deploy_component`},{name:`package_custom_function_project`,su:!0,category:ch,aliasOf:`package_component`},{name:`drop_custom_function_project`,su:!0,category:ch,gate:`from-5.3`},{name:`list_deployments`,su:!0,category:ch,addedIn:nh},{name:`get_deployment`,su:!0,category:ch,addedIn:nh},{name:`get_deployment_payload`,su:!0,category:ch,addedIn:nh,nonDelegable:!0},{name:`delete_deployment_payload`,su:!0,category:ch,addedIn:nh},{name:`add_node`,su:!0,category:lh},{name:`update_node`,su:!0,category:lh},{name:`set_node_replication`,su:!0,category:lh},{name:`purge_stream`,su:!0,category:lh},{name:`catchup`,su:!0,category:lh,gate:`until-5.3`},{name:`get_job`,su:!1,category:uh},{name:`search_jobs_by_start_date`,su:!0,category:uh,gate:`from-5.3`},{name:`update_job`,su:!0,category:uh},{name:`delete_job`,su:!0,category:uh},{name:`read_log`,su:!0,category:dh},{name:`read_audit_log`,su:!0,category:dh},{name:`read_transaction_log`,su:!0,category:dh,gate:`never`},{name:`delete_files_before`,su:!0,category:dh,gate:`from-5.3`},{name:`delete_audit_logs_before`,su:!0,category:dh,gate:`from-5.3`},{name:`delete_transaction_logs_before`,su:!0,category:dh,gate:`from-5.3`},{name:`get_analytics`,su:!1,category:dh},{name:`list_metrics`,su:!1,category:dh},{name:`describe_metric`,su:!1,category:dh},{name:`get_configuration`,su:!0,category:fh},{name:`set_configuration`,su:!0,category:fh,gate:`from-5.3`},{name:`restart`,su:!0,category:fh},{name:`restart_service`,su:!0,category:fh,gate:`from-5.3`},{name:`system_information`,su:!0,category:fh},{name:`get_status`,su:!0,category:fh,gate:`from-5.3`},{name:`set_status`,su:!0,category:fh,gate:`from-5.3`},{name:`clear_status`,su:!0,category:fh,gate:`from-5.3`},{name:`registration_info`,su:!1,category:fh,gate:`from-5.3`},{name:`get_backup`,su:!0,category:fh,gate:`never`},{name:`create_backup`,su:!0,category:ph,addedIn:rh,nonDelegable:!0},{name:`verify_backup`,su:!0,category:ph,addedIn:rh,nonDelegable:!0},{name:`restore_backup`,su:!0,category:ph,addedIn:rh,nonDelegable:!0},{name:`list_backups`,su:!0,category:ph,addedIn:rh,nonDelegable:!0},{name:`delete_backup`,su:!0,category:ph,addedIn:rh,nonDelegable:!0},{name:`purge_backups`,su:!0,category:ph,addedIn:rh,nonDelegable:!0},{name:`set_secret`,su:!0,category:mh,addedIn:rh,nonDelegable:!0},{name:`grant_secret`,su:!0,category:mh,addedIn:rh,nonDelegable:!0},{name:`revoke_secret`,su:!0,category:mh,addedIn:rh,nonDelegable:!0},{name:`list_secrets`,su:!0,category:mh,addedIn:rh,nonDelegable:!0},{name:`delete_secret`,su:!0,category:mh,addedIn:rh,nonDelegable:!0},{name:`get_secrets_public_key`,su:!0,category:mh,addedIn:rh,nonDelegable:!0},{name:`set_env_value`,su:!0,category:mh,addedIn:rh},{name:`delete_env_value`,su:!0,category:mh,addedIn:rh},{name:`get_env_keys`,su:!0,category:mh,addedIn:rh},{name:`agent_prompt`,su:!0,category:hh,addedIn:nh},{name:`get_agent_session`,su:!0,category:hh,addedIn:nh},{name:`list_agent_sessions`,su:!0,category:hh,addedIn:nh},{name:`cancel_agent_run`,su:!0,category:hh,addedIn:nh},{name:`approve_agent_action`,su:!0,category:hh,addedIn:nh},{name:`set_agent_config`,su:!0,category:hh,addedIn:nh}],vh=[`search`,`search_by_conditions`,`search_by_hash`,`search_by_id`,`search_by_value`,`sql`,`describe_all`,`describe_schema`,`describe_database`,`describe_table`,`user_info`,`get_job`,`get_analytics`,`list_metrics`,`describe_metric`],yh=[{name:`read_only`,description:`Read-only data access: searches, SQL, schema describes, and user/analytics reads.`,members:vh},{name:`admin_read`,description:`Read-only access to configuration, logs, and component views (normally super_user-only).`,members:[`get_configuration`,`read_log`,`read_audit_log`,`get_custom_functions`,`get_custom_function`,`get_components`,`get_component_file`]},{name:`standard_user`,description:`Everything in read_only plus data writes and bulk loads. No DDL, user management, or admin reads.`,members:[...vh,`insert`,`update`,`upsert`,`put`,`delete`,`csv_data_load`,`csv_file_load`,`csv_url_load`,`import_from_s3`]},{name:`agent`,description:`Drive the built-in agent: prompts, sessions, and run approvals. Excludes agent configuration.`,members:[`agent_prompt`,`get_agent_session`,`list_agent_sessions`,`cancel_agent_run`,`approve_agent_action`],addedIn:rh}],bh=new Map(_h.map(e=>[e.name,e])),xh=new Map(yh.map(e=>[e.name,e]));function Sh(e){return bh.get(e)}function Ch(e){return bh.get(e)?.aliasOf??e}function wh(e){return xh.has(e)}function Th(e){return!!e&&vr(`5.0.0-alpha.8`,e)}function Eh(e){let t=Zm(e);return _h.filter(n=>!n.nonDelegable&&!n.aliasOf&&eh(n.name,t)!==`never`&&(!n.addedIn||vr(n.addedIn,e)))}function Dh(e){return yh.filter(t=>!t.addedIn||vr(t.addedIn,e))}function Oh(e,t){let n=new Set;for(let r of e){let e=xh.get(r);if(e){for(let r of e.members){let e=bh.get(r)?.aliasOf??r;th(e,t)||n.add(e)}continue}th(r,t)||n.add(r)}return[...n].sort()}function kh(e,t=40){return e.length>t?`${e.slice(0,t).join(`, `)}, +${e.length-t} more`:e.join(`, `)}var Ah=[`super_user`,`structure_user`,`cluster_user`,`operations`],jh=new Set(Ah);function Mh(e,t,n){if((t===`operations`?n:jh.has(t))||!Object.hasOwn(e,t))return;let r=e[t];return typeof r==`object`&&r&&!Array.isArray(r)?r:void 0}function Nh(e){return e?.super_user===!0||e?.cluster_user===!0}function Ph(e){let t=e?.structure_user;return t===!0?!0:Array.isArray(t)&&t.length>0?t:!1}var Fh=[`create_table`,`create_attribute`,`drop_table`,`drop_attribute`],Ih=[`create_database`,`drop_database`];function Lh(e){let t=e?.operations;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:void 0}function Rh(e,t){let n=e?.operations;return e===void 0||n===void 0?`absent`:t?Lh(e)===void 0?n&&typeof n!=`string`&&!Array.isArray(n)?`breaks-auth`:`malformed`:`allowlist`:Mh(e,`operations`,!1)===void 0?`inert`:`database`}function zh(e){let t=Ah.filter(t=>t in e),n=Object.keys(e).filter(e=>!jh.has(e));return Object.fromEntries([...t,...n].map(t=>[t,e[t]]))}function Bh(e,t){let n={...e};return t===void 0?delete n.operations:n.operations=t,zh(n)}var Vh={read:[`search`,`search_by_conditions`,`search_by_hash`,`search_by_value`,`sql`],insert:[`insert`],update:[`update`],delete:[`delete`]},Hh=[`insert`],Uh=[`csv_data_load`,`get_job`],Wh=[`csv_url_load`,`get_job`],Gh={"json-records":Hh,"csv-data":Uh,"csv-url":Wh},Kh={sample:[Hh,Uh],file:[Hh,Uh],url:[Wh]},qh=Object.keys(Kh),Jh=new WeakMap,Yh=new Map(yh.map(e=>[e.name,e.members]));function Xh(e){let t=new Set;for(let n of e){let e=Yh.get(n);if(e)for(let n of e)t.add(n);else t.add(n)}return t}function Zh(e,t){let n=Lh(e);if(!n)return!0;let r=Jh.get(n);return r||(r=Xh(n),Jh.set(n,r)),t.some(e=>r.has(Ch(e)))}function Qh(e,t){return e?.super_user===!0||Zh(e,t)}function $h(e,t){return Qh(e,Vh[t]??[])}function eg(e,t){return t.every(t=>Zh(e,[t]))}function tg(e,t){return e?.super_user===!0||eg(e,Gh[t])}function ng(e,t){return e?.super_user===!0||Kh[t].some(t=>eg(e,t))}function rg(e){return qh.some(t=>ng(e,t))}function ig(e,t,n,r){return $h(e,r)&&sg(e,t,n,r)}function ag(e,t,n){if(!e)return!1;if(e.super_user===!0)return!0;if(!Zh(e,[`put`]))return!1;let r=Mh(e,t,!1)?.tables?.[n];return r?.insert!==!0||r.update!==!0?!1:!(`attribute_permissions`in r&&r.attribute_permissions?.length||`attribute_restrictions`in r&&r.attribute_restrictions?.length)}function og(e,t,n){return rg(e)&&sg(e,t,n,`insert`)}function sg(e,t,n,r){return e?e.super_user===!0||e.structure_user===!0||Mh(e,t,!1)?.tables?.[n]?.[r]===!0:!1}function cg(e){let{user:t}=Sr(),{organizationId:n}=z({strict:!1}),r=lg(t,e??n);return{update:Cr(t,`org:update`)||r.update,remove:Cr(t,`org:delete`)||r.remove}}function lg(e,t){let n=e?.roles?.[t];return!n||`oauthProviders`in n||!n.permission&&!n.organization?{update:!1,remove:!1}:n.permission?.super_user?{update:!0,remove:!0}:{update:n.organization.update,remove:n.organization.delete}}function ug(e,t){if(e?.fabricRole===`super_user`)return!0;let n=e?.roles?.[t];return!n||`oauthProviders`in n?!1:n.role===`admin`}function dg(e){let{user:t}=Sr(),{organizationId:n}=z({strict:!1});return ug(t,e??n)}function fg(e){let{user:t}=Sr(),{organizationId:n}=z({strict:!1}),r=pg(t,e??n);return{create:Cr(t,`role:create`)||r.create,remove:Cr(t,`role:delete`)||r.remove,update:Cr(t,`role:update`)||r.update,view:Cr(t,`role:read`)||r.view}}function pg(e,t){let n=e?.roles?.[t];if(!n||`oauthProviders`in n||!n.permission&&!n.organization?.roles)return{create:!1,remove:!1,update:!1,view:!1};if(n.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let r=n.organization.roles;return{create:r.create,remove:r.delete,update:r.update,view:r.view}}function mg(e,t){let{user:n}=Sr(),{organizationId:r,clusterId:i}=z({strict:!1});return hg(n,e??r,t??i)}function hg(e,t,n){let r=gg(e,t,n);return{create:Cr(e,`cluster:create`)||r.create,remove:Cr(e,`cluster:delete`)||r.remove,update:Cr(e,`cluster:update`)||r.update,view:Cr(e,`cluster:read`)||r.view}}function gg(e,t,n){let r=e?.roles?.[t];if(!r||`oauthProviders`in r||!r.permission&&!r.organization?.clusters)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.clusters.resources?.find(e=>e.id===n),a=r.organization.clusters;return{create:a.create,remove:i?i.delete:a.delete,update:i?i.update:a.update,view:i?i.view:a.view}}function _g(e){let{user:t}=Sr(),{organizationId:n}=z({strict:!1});return vg(t,e??n)}function vg(e,t){return Cr(e,`instance:update`)||yg(e,t)}function yg(e,t){let n=e?.roles?.[t];return!n||`oauthProviders`in n?!1:n.role===`admin`}function bg(e,t){let{user:n}=Sr(),{organizationId:r,clusterId:i}=z({strict:!1});return xg(n,e??r,t??i)}function xg(e,t,n){let r=Sg(e,t,n);return{create:Cr(e,`cluster:update`)||r.create,remove:Cr(e,`cluster:delete`)||r.remove,update:Cr(e,`instance:update`)||r.update,view:Cr(e,`instance:read`)||r.view}}function Sg(e,t,n){let r=e?.roles?.[t];if(!r||`oauthProviders`in r||!r.permission&&!r.organization?.clusters)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.clusters.resources?.find(e=>e.id===n)?.instances,a=r.organization.clusters;return{create:i?i.create:a.create,remove:i?i.delete:a.delete,update:i?i.update:a.update,view:i?i.view:a.view}}function Cg(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Tr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function wg(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Tr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Tg(e,t,n,r){let{clusterId:i,instanceId:a}=z({strict:!1}),{user:o}=Tr(e??a??i);return ig(o?.role?.permission,t,n,r)}function Eg(e,t,n){let{clusterId:r,instanceId:i}=z({strict:!1}),{user:a}=Tr(e??i??r);return ag(a?.role?.permission,t,n)}function Dg(e,t,n){let{clusterId:r,instanceId:i}=z({strict:!1}),{user:a}=Tr(e??i??r);return og(a?.role?.permission,t,n)}function Og(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Tr(e??n??t);return rg(r?.role?.permission)}function kg(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Tr(e??n??t),i=r?.role?.permission;return(0,G.useMemo)(()=>({methods:Object.fromEntries(qh.map(e=>[e,ng(i,e)])),allowsSource:e=>tg(i,e),allowsDestination:(e,t)=>og(i,e,t)}),[i])}function Ag({cluster:e,hasCardLink:t=!1}){let{view:n,update:r}=mg(e.organizationId,e.id),i=`/${e.organizationId}/${e.id}`;if(n)return ff(e)?(0,K.jsx)(jg,{cluster:e,hasCardLink:t}):e.fqdn?e.resetPassword?r?(0,K.jsx)(V,{to:`${i}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,K.jsxs)(H,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,K.jsx)(Wr,{className:`inline-block`})]})}):(0,K.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`}):(0,K.jsx)(jg,{cluster:e,hasCardLink:t}):t?(0,K.jsx)(Mg,{children:`Instances`}):(0,K.jsx)(V,{to:`${i}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,K.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances`,` `,(0,K.jsx)(Wr,{className:`inline-block transition-transform duration-200 group-hover/cluster:translate-x-1 motion-reduce:transform-none motion-reduce:transition-none`})]})})}function jg({cluster:e,hasCardLink:t}){return t?(0,K.jsx)(Mg,{children:`Open`}):(0,K.jsx)(V,{to:`/${e.organizationId}/${e.id}`,className:`text-sm text-nowrap`,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,children:(0,K.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Open`,` `,(0,K.jsx)(Wr,{className:`inline-block transition-transform duration-200 group-hover/cluster:translate-x-1 motion-reduce:transform-none motion-reduce:transition-none`})]})})}function Mg({children:e}){return(0,K.jsxs)(`span`,{className:`pointer-events-none text-sm text-nowrap py-2 ml-auto`,children:[e,` `,(0,K.jsx)(Wr,{className:`inline-block transition-transform duration-200 group-hover/cluster:translate-x-1 motion-reduce:transform-none motion-reduce:transition-none`})]})}function Ng({clusterName:e,isPending:t,stopOpen:n,setStopOpen:r,onConfirmStop:i,restartOpen:a,setRestartOpen:o,onConfirmRestart:s}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_m,{open:n,onOpenChange:r,children:(0,K.jsxs)(wm,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsxs)(Dm,{children:[`Stop cluster `,e,`?`]}),(0,K.jsx)(Om,{children:`This stops every instance in the cluster. It will be offline and stop serving traffic until you start it again.`})]}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>r(!1),children:`Cancel`}),(0,K.jsx)(H,{type:`button`,variant:`destructive`,onClick:i,disabled:t,children:`Stop cluster`})]})})]})}),(0,K.jsx)(_m,{open:a,onOpenChange:o,children:(0,K.jsxs)(wm,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsxs)(Dm,{children:[`Restart cluster `,e]}),(0,K.jsx)(Om,{children:`Choose how to restart the cluster's instances.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>s(`rolling`),className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-60`,children:[(0,K.jsxs)(`div`,{className:`font-medium`,children:[`Rolling `,(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(recommended)`})]}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`One instance at a time, waiting for each to rejoin before moving on. No downtime.`})]}),(0,K.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>s(`parallel`),className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-60`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:`Parallel`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`All instances at once. Faster, but the whole cluster is briefly offline.`})]})]}),(0,K.jsx)(Em,{children:(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>o(!1),children:`Cancel`})})]})})]})}function Pg(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function Fg({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,G.useState)(t||!1),{data:i}=L(_f(n&&e.id,2e3));(0,G.useEffect)(function(){(sf(e.status)||cf(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,G.useMemo)(()=>{let e=Pg(i?.plans??[],`planId`),t=i?.instances??[],n=0,r=0,a=0,o=0,s={},c={},l={},u={},d=(e,t)=>{e[t]=(e[t]??0)+1};for(let i of t){let t=i.status;t&&!of(t)&&(sf(t)?(n+=1,d(s,t)):cf(t)?(r+=1,d(c,t)):af(t)?(o+=1,d(u,t)):!i.planId||!e.includes(i.planId)?(r+=1,d(c,`Draining Traffic`)):(rf(t)||nf(t))&&(a+=1,d(l,rf(t)?t:`RUNNING`)))}let f=e=>Object.keys(e).sort().map(t=>`${e[t]} ${_d(t)}`),p=n+r+a+o;return{pendingWidth:`${p===0?100:n===0?0:n/p*100}%`,updatingWidth:`${r===0?0:r/p*100}%`,failedWidth:`${o===0?0:o/p*100}%`,runningWidth:`${a===0?0:a/p*100}%`,text:[...f(l),...f(u),...f(c),...f(s)].join(` · `)}},[i]);return n?(0,K.jsxs)(`div`,{className:`w-full text-center`,children:[(0,K.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,K.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.jsx)(`div`,{style:{width:a.updatingWidth},className:`grow animate-pulse bg-yellow/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.jsx)(`div`,{style:{width:a.pendingWidth},className:`grow bg-gray-600 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`})]}),a.text&&(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}function Ig({open:e,setOpen:t,action:n,targetName:r,scope:i,isPending:a,onConfirm:o}){let s=n===`start`?`Start`:`Restart`;return(0,K.jsx)(_m,{open:e,onOpenChange:t,children:(0,K.jsxs)(wm,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsxs)(Dm,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Xa,{className:`size-5 text-yellow`}),s,` `,r,` in safe mode?`]}),(0,K.jsxs)(Om,{children:[`Safe mode boots Harper`,` `,(0,K.jsx)(`strong`,{className:`text-foreground`,children:`without loading your applications or components`}),`. Use it to recover `,i===`cluster`?`a cluster`:`an instance`,` `,`that a bad app, component, or config is keeping from starting. Then fix or remove what's broken and`,` `,n===`start`?`start`:`restart`,` normally to bring everything back.`]})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===`cluster`?`All instances are ${n===`start`?`started`:`restarted`} at once (parallel)${n===`restart`?`, so expect a brief interruption while they come back.`:`.`}`:`The instance ${n===`start`?`starts`:`restarts`} in safe mode${n===`restart`?`, so expect a brief interruption while it comes back.`:`.`}`}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsxs)(H,{type:`button`,variant:`warning`,onClick:o,disabled:a,children:[(0,K.jsx)(Xa,{}),` `,s,` in safe mode`]})]})})]})})}async function Lg(e){let{data:t}=await P.delete(`/Cluster/${e}`,{timeout:0});return t}function Rg(){return I({mutationFn:e=>Lg(e)})}async function zg({clusterId:e,action:t,safeMode:n,strategy:r}){let i={};n!==void 0&&(i.safeMode=n),r!==void 0&&(i.strategy=r);let{data:a}=await P.post(`/Cluster/${e}/container/${t}`,i);return a}function Bg(){return I({mutationFn:zg})}var Vg={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function Hg(e){let{mutateAsync:t,isPending:n}=Bg(),r=Ze();return{run:(0,G.useCallback)(async(n,i)=>{let a=i?.label??Vg[n],o=U.loading(a,{description:`${a} cluster ${e.name}. Status will update automatically.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{let s=await t({clusterId:e.id,action:n,safeMode:i?.safeMode,strategy:i?.strategy});n!==`stop`&&de({clusterId:e.id,instanceIds:s?.instanceIds??[],label:Vg[n],allAtOnce:s?.strategy===`parallel`}),r.invalidateQueries({queryKey:[e.organizationId]}),r.invalidateQueries({queryKey:[e.id]}),U.dismiss(o),U.success(`Request accepted`,{description:`${e.name} is ${a.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(o)}},[e.id,e.name,e.organizationId,t,r]),isPending:n}}async function Ug(e){if(!navigator.clipboard)return U.error(`Clipboard access is not available in this environment.`),!1;try{return await navigator.clipboard.writeText(e),!0}catch{return U.error(`Failed to copy to clipboard.`),!1}}function Wg(e){Ug(e).then(e=>{e&&U.info(`Copied to clipboard!`,{icon:(0,K.jsx)(Ri,{}),duration:1e3})})}function Gg(...e){return(0,G.useMemo)(()=>e.map(e=>()=>Wg(e)),e)}function Kg(){return Wg}function qg({clusterId:e,instanceId:t,organizationId:n},r){return`/${[n,e,t&&`instance`,t,r].filter(fr).join(`/`)}`}function Jg({item:e}){let{cluster:t}=e,n={organizationId:t.organizationId,clusterId:t.id},r=Hm(e.syncSummary),i=Ee(),a=Ze(),o=(0,G.useMemo)(()=>c(t),[t]),s=Ql({operationsUrl:o}),l=Tr(t.id),[,f]=Zc(_r.SavedClusterState,null),{view:p,update:m,remove:h,create:g}=mg(t.organizationId,t.id),_=_g(t.organizationId),{mutate:v,isPending:y}=Rg(),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(!1),[O,k]=(0,G.useState)(null),{run:A,isPending:j}=Hg(t),M=t.status===`RUNNING`,ee=t.status===`STOPPED`,te=t.status===`PARTIAL`,N=(0,G.useMemo)(()=>!!(t.status&&Nd.includes(t.status)),[t.status]),P=ff(t),F=_&&!P,ne=u.checkForFabricConnect(t.id),re=!ne&&!!l.user,ie=(0,G.useMemo)(()=>!!(t.status&&Pd.includes(t.status)),[t.status]),ae=(0,G.useMemo)(()=>!!(t.status&&af(t.status)),[t.status]),oe=m&&!P&&!ie&&!cf(t.status)&&!sf(t.status),se=(0,G.useCallback)(async()=>{x(!0);let e=await hf(t.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await d({entityId:t.id,instanceClient:s}),e?.instances?.length)for(let t of e.instances)u.setUserForEntity(t,null);u.setUserForEntity(t,null)},[t,s]),ce=(0,G.useCallback)(()=>{f(t),i.navigate({to:`/${t.organizationId}/new-cluster`})},[t,i,f]),le=(0,G.useCallback)(()=>C(!0),[]),ue=(0,G.useCallback)(()=>{let e=t.organizationId;v(t.id,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[e],refetchType:`active`}),await i.invalidate(),U.success(`Success`,{description:P?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),C(!1)},onError:e=>{pc(e)&&U.error(`Error`,{description:P?`Failed to remove cluster: ${t.name}`:`Failed to terminate cluster: ${t.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),C(!1)}})},[i,t.organizationId,t.id,t.name,v,P,a]),de=P?void 0:t.status===`PROVISIONING`?`/${t.organizationId}/${t.id}/starting-up`:t.status===`UPDATING`?`/${t.organizationId}/${t.id}/scaling`:void 0,fe=!p||ie?void 0:de||(t.status===`STOPPED`?`/${t.organizationId}/${t.id}/instances`:t.status===`PARTIAL`?`/${t.organizationId}/${t.id}`:N?P?`/${t.organizationId}/${t.id}`:t.fqdn?t.resetPassword?void 0:`/${t.organizationId}/${t.id}`:`/${t.organizationId}/${t.id}/instances`:void 0),pe=!!de&&fe===de,me=t.domains?.[0]?.domain||t.fqdn,[he,ge]=Gg(`${me}`,`https://${me}`),_e=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-separator`},N&&m&&!l.isLoading&&(!re||ne)&&{key:`sign-in`,to:qg(n,`sign-in`),disabled:b,icon:(0,K.jsx)(Wa,{className:`text-green`}),label:`Direct Sign In`},N&&p&&!!o&&!l.isLoading&&re&&{key:`direct-sign-out`,onClick:se,disabled:b,label:`Direct Sign Out`},N&&m&&{key:`edit`,to:qg(n,`edit`),disabled:b,icon:(0,K.jsx)(ts,{className:`text-purple-600`}),label:P?`Edit`:`Edit Scaling`},oe&&{key:`edit-version`,to:qg(n,`edit/version`),disabled:b,icon:(0,K.jsx)(Oa,{className:`text-fuchsia-300`}),label:`Edit Version`},N&&m&&!1,N&&p&&{key:`instances`,to:qg(n,`instances`),disabled:b,icon:(0,K.jsx)(ss,{className:`text-orange-300`}),label:`Instances`},N&&p&&!!l.user&&{key:`deployments`,to:qg(n,`config/deployments`),disabled:b,icon:(0,K.jsx)(qo,{className:`text-sky-400`}),label:`Deployments`},F&&(M||ee||te)&&{type:`separator`,key:`container-separator`},F&&(M||ee||te)&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},F&&(ee||te)&&{key:`container-start`,disabled:j,onClick:()=>void A(`start`,{safeMode:!1,strategy:`parallel`}),icon:(0,K.jsx)(Vo,{}),label:`Start`},F&&ee&&{key:`container-start-safe`,disabled:j,onClick:()=>k(`start`),icon:(0,K.jsx)(Xa,{}),label:`Start in safe mode`},F&&(M||te)&&{key:`container-restart`,disabled:j,onClick:()=>D(!0),icon:(0,K.jsx)(Zo,{}),label:`Restart`},F&&M&&{key:`container-restart-safe`,disabled:j,onClick:()=>k(`restart`),icon:(0,K.jsx)(Xa,{}),label:`Restart in safe mode`},F&&(M||te)&&{key:`container-stop`,variant:`destructive`,disabled:j,onClick:()=>T(!0),icon:(0,K.jsx)(Ss,{}),label:`Stop`},N&&p&&!!t.fqdn&&{type:`separator`,key:`copy-separator`},N&&p&&!!t.fqdn&&{key:`copy-host-name`,onClick:he,disabled:b,icon:(0,K.jsx)(Bi,{}),label:`Copy Host Name`},N&&p&&!!t.fqdn&&{key:`copy-api-url`,onClick:ge,disabled:b,icon:(0,K.jsx)(Bi,{}),label:`Copy API URL`},ae&&g&&{key:`try-again`,onClick:ce,className:`focus:bg-green/70 focus:text-white`,label:`Try Again`},!ie&&h&&N&&{type:`separator`,key:`remove-separator`},!ie&&h&&{key:`remove`,onClick:le,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(Is,{className:`text-red-300`}),label:P?`Remove`:`Terminate`}].filter(fr);return(0,K.jsx)(zm,{items:ie?[]:_e,children:(0,K.jsxs)(Er,{className:`group/cluster relative isolate min-w-0 h-full overflow-hidden border border-border bg-card/30 py-0 gap-0 shadow-sm transition-[background-color,border-color,box-shadow] duration-200 motion-reduce:transition-none ${fe?`cursor-pointer hover:border-primary hover:bg-card/70 hover:shadow-xl hover:shadow-primary/20 hover:ring-2 hover:ring-primary/70 dark:hover:border-violet-400 dark:hover:ring-violet-400/70`:``}`,children:[fe&&(0,K.jsx)(V,{to:fe,"aria-label":pe?`View progress for ${t.name}`:`${P||t.fqdn?`Open`:`View`} ${t.name}`,className:`absolute inset-0 z-1 cursor-pointer rounded-[inherit] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:outline-none`}),(0,K.jsxs)(Dr,{className:`gap-3 bg-linear-to-br from-transparent via-primary/5 to-primary/15 dark:from-primary/15 dark:to-transparent px-5 py-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 pt-1`,children:[(0,K.jsxs)(ol,{variant:e.category===`failed`?`destructive`:e.category===`attention`?`warning`:e.category===`running`?`success`:`secondary`,className:`rounded-full`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`,"aria-hidden":`true`}),e.label]}),r&&(0,K.jsxs)(ol,{variant:`warning`,className:`rounded-full`,children:[(0,K.jsx)(Go,{"aria-hidden":`true`,className:`animate-[spin_2.5s_linear_infinite] motion-reduce:animate-none`}),r]}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.hosting})]}),!ie&&(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Cluster options`,onClick:e=>e.stopPropagation(),className:`relative z-10 inline-flex shrink-0 items-center gap-1.5 rounded-md border border-primary/25 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground shadow-sm transition-colors hover:border-primary/60 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[`Options `,(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsx)(vc,{align:`end`,children:Rm(_e,`dropdown`)})]})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`break-words text-xl font-semibold leading-snug`,children:t.name})}),(0,K.jsx)(kr,{className:`flex min-w-0 items-center gap-3 justify-between`,children:me?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,title:me,children:me}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Copy host name`,onClick:e=>{e.stopPropagation(),he()},className:`relative z-10 -m-1.5 p-1.5 rounded-md text-muted-foreground cursor-pointer hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(ea,{size:16})}),(0,K.jsx)(`span`,{className:`grow`})]}):(0,K.jsx)(`span`,{children:P?`Self-hosted endpoint`:`Hostname not assigned`})})]}),(0,K.jsxs)(Ar,{className:`mt-auto flex flex-col gap-3 border-t border-border px-5 py-4`,children:[(0,K.jsx)(Fg,{cluster:t}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-xs`,children:[e.notices.length?(0,K.jsx)(`ul`,{className:`space-y-1 ${e.category===`failed`?`text-destructive`:`text-amber-800 dark:text-yellow`}`,children:e.notices.map(e=>(0,K.jsx)(`li`,{children:e},e))}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:P?`Monitoring managed externally`:e.category===`running`?`Cluster is running`:e.label}),ae&&g&&(0,K.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Open cluster options to retry or manage this cluster.`})]}),pe&&(0,K.jsx)(Mg,{children:`View progress`}),N&&p&&(0,K.jsx)(Ag,{cluster:t,hasCardLink:!!fe})]})]}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:P?`Remove`:`Terminate`,presentParticiple:P?`Removing`:`Terminating`,nameOfThingBeingDeleted:t.name,isModalOpen:S,hideDataLossWarning:P,setIsModalOpen:e=>C(e),deletionConfirmed:ue,deletionPending:y}),(0,K.jsx)(Ng,{clusterName:t.name,isPending:j,stopOpen:w,setStopOpen:T,onConfirmStop:()=>{T(!1),A(`stop`,{strategy:`parallel`})},restartOpen:E,setRestartOpen:D,onConfirmRestart:e=>{D(!1),A(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ig,{open:O!==null,setOpen:e=>{e||k(null)},action:O??`restart`,targetName:t.name,scope:`cluster`,isPending:j,onConfirm:()=>{let e=O;k(null),e&&A(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}})]})})}function Yg(e){return e.filter(e=>!!e&&!(e.status!=null&&Pd.includes(e.status))).map(e=>e.version).filter(e=>!!e)}function Xg(e,t=[]){let n=Yg(e);if(n.length<2)return null;let r=n.reduce((e,t)=>yr(t,e)>0?t:e),i=n.filter(e=>e!==r);if(i.length===0)return null;let a=new Set(t);return{latest:r,behindCount:i.length,total:n.length,ambiguous:i.some(e=>a.has(e))}}var Zg={search:``,category:`all`,region:``,sort:`attention`};function Qg(e,t,n){let r=ff(e),i=e.instances?.filter(e=>!Pd.includes(e.status??``)),a=[...(e.plans??[]).map(e=>e.region||t?.get(e.regionId??``)).filter(Boolean),...(i??[]).map(e=>e.region||t?.get(e.regionId??``))],o=[...new Set(a.filter(e=>!!e))].sort(),s=[...new Set((i??[]).map(e=>e.version).filter(Boolean))].sort(),c=e.status,l=c===`FAILED`||c===`ERROR`||!r&&i?.some(e=>e.status===`FAILED`||e.status===`ERROR`),u=c===`PENDING_UPGRADE`||!r&&i?.some(e=>e.status===`PENDING_UPGRADE`),d=!r&&i?Xg(i):null,f=cf(c)||sf(c)||[`STARTING`,`STOPPING`,`RESTARTING`].includes(c??``),p=[];l&&p.push(`Failure reported`),u&&p.push(`Upgrade pending`),d&&p.push(`${d.behindCount} ${d.behindCount===1?`instance`:`instances`} on an older version`),c===`PARTIAL`&&p.push(`Some instances are not running`),c===`UPDATED`&&p.push(`Waiting for running status`),c===`STOPPED`&&p.push(`Cluster stopped`),e.resetPassword&&p.push(`Setup required`),f&&!u&&p.push(_d(c));let m=l?`failed`:p.length?`attention`:Nd.includes(c??``)?`running`:`other`,h=Date.parse(e.createdAt??``);return{cluster:e,syncSummary:n??null,category:m,label:l&&c!==`FAILED`&&c!==`ERROR`?`Instance failure`:c?_d(c):`Status unknown`,notices:p,regions:o,instanceCount:i?.length,version:s.length>1?`Mixed versions`:s[0],hosting:r?`Self-hosted`:e.plans?.length?`Harper Cloud`:`Hosting unknown`,createdAt:Number.isFinite(h)?h:-1/0,searchText:[e.name,e.id,e.fqdn,...(e.domains??[]).map(e=>e.domain),...o].filter(Boolean).join(` `).toLowerCase()}}function $g(e,t,n){let r=e.filter(e=>e.status!==`TERMINATED`&&e.status!==`REMOVED`).map(e=>Qg(e,t,n?.[e.id])),i={running:0,attention:0,failed:0,other:0};for(let e of r)i[e.category]++;return{items:r,counts:i,regions:[...new Set(r.flatMap(e=>e.regions))].sort()}}var e_={failed:0,attention:1,other:2,running:3};function t_(e,t){let n=t.search.trim().toLowerCase();return e.filter(e=>(t.category===`all`||e.category===t.category)&&(!t.region||e.regions.includes(t.region))&&(!n||e.searchText.includes(n))).sort((e,n)=>t.sort===`attention`&&e.category!==n.category?e_[e.category]-e_[n.category]:t.sort===`newest`&&e.createdAt!==n.createdAt?e.createdAt>n.createdAt?-1:1:e.cluster.name.localeCompare(n.cluster.name)||e.cluster.id.localeCompare(n.cluster.id))}async function n_({organizationId:e,availableHosts:t}={}){let{data:n}=await P.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function r_({organizationId:e,availableHosts:t}={}){return B({queryKey:[e,`regionLocations`,t],queryFn:()=>n_({organizationId:e,availableHosts:t}),retry:!1})}function i_({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}var a_=`studio:sidebar-help:minimized:v1`;function o_({items:e,ariaLabel:t}){let[n,r]=(0,G.useState)(()=>{try{return window.localStorage.getItem(a_)===`1`}catch{return!1}}),i=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`section-rail`,children:[(0,K.jsxs)(`div`,{className:`section-rail-navigation`,children:[(0,K.jsx)(Xc,{}),(0,K.jsx)(Nc,{items:e,ariaLabel:t})]}),(0,K.jsx)(`div`,{className:`section-rail-help-space`,children:(0,K.jsxs)(`section`,{"aria-label":`Need help?`,className:`section-rail-help rounded-xl border border-primary/25 bg-linear-to-br from-primary/15 via-card/50 to-card/30 p-4 shadow-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(qo,{className:`size-5 text-primary dark:text-violet-300`,"aria-hidden":`true`}),(0,K.jsx)(`p`,{className:`text-sm font-semibold`,children:`Need help?`})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{let e=!n;r(e);try{window.localStorage.setItem(a_,e?`1`:`0`)}catch{}},"aria-label":n?`Expand help card`:`Minimize help card`,"aria-expanded":!n,"aria-controls":i,className:`flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-primary/10 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:n?(0,K.jsx)(nr,{className:`size-4`}):(0,K.jsx)(er,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{id:i,hidden:n,children:[(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`Explore the docs or join our community on Discord.`}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-x-4 gap-y-3 text-xs font-medium`,children:[(0,K.jsxs)(`a`,{href:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-sm hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(ii,{className:`size-3.5`}),`View docs`,(0,K.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]}),(0,K.jsxs)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-sm hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`[&_svg]:size-3.5`,children:(0,K.jsx)(rl,{})}),`Join Discord`,(0,K.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]})]})]})]})})]})}var s_=y(`relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90`,warning:`border-amber-700 dark:border-amber-500 bg-amber-500/10 text-foreground [&>svg]:text-amber-700 dark:[&>svg]:text-amber-400 *:data-[slot=alert-description]:text-foreground`}},defaultVariants:{variant:`default`}});function c_({className:e,variant:t,...n}){return(0,K.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:F(s_({variant:t}),e),...n})}function l_({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`alert-title`,className:F(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),...t})}function u_({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`alert-description`,className:F(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}function d_(e){let t=(0,G.useCallback)(()=>{let t=se(e);return t?JSON.stringify(t):``},[e]),n=(0,G.useSyncExternalStore)(ie,t);return(0,G.useMemo)(()=>n?JSON.parse(n):void 0,[n])}function f_(){return(0,G.useSyncExternalStore)(ie,ne)}var p_=5e3;function m_({entityId:e,clusterId:t,noun:n,className:r}){let i=d_(e);if(L({..._f(t,p_),enabled:!!i&&!!t}),!i)return null;let a=le(i,{proxied:!!e&&o(e)});return(0,K.jsx)(`div`,{className:r,children:(0,K.jsxs)(c_,{variant:`warning`,role:`status`,"aria-live":`polite`,children:[(0,K.jsx)(no,{className:`animate-spin`}),(0,K.jsxs)(l_,{children:[i.label,` `,n]}),(0,K.jsx)(u_,{children:a?`Studio is holding its requests to this ${n} until it's back online, then refreshes what's shown here.`:`Instances are restarting one at a time, so the cluster stays available. Brief connection errors are expected and hidden until it finishes.`})]})})}function h_({children:e}){let{organizationId:t,clusterId:n}=z({strict:!1}),{view:r,update:i}=mg(t,n),{data:a}=L(_f(n,!1)),o=a?ff(a):!1,s=!Fd(a),c=`/${t}/${n}`,l=[{to:c,label:`Overview`,icon:Ja,exact:!0},r&&!o&&{to:`${c}/usage`,label:`Usage`,icon:gi},i&&s&&{to:`${c}/edit`,label:o?`Configuration`:`Scaling`,icon:Ea,exact:!0},i&&s&&!o&&{to:`${c}/edit/version`,label:`Version`,icon:As,exact:!0},i&&s&&!o&&{to:`${c}/domains`,label:`Domains`,icon:Aa},r&&s&&{to:`${c}/instances`,label:`Instances`,icon:ss}].filter(Boolean);return(0,K.jsx)(`div`,{className:`relative mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`section-rail-aside md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(o_,{items:l,ariaLabel:`Cluster sections`})}),(0,K.jsxs)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:[(0,K.jsx)(m_,{entityId:n,clusterId:n,noun:`cluster`,className:`mb-4`}),e]})]})})}async function g_(e){let{data:t}=await P.get(`/Plan/`,{params:{organizationId:e}});return t}function __(e){return B({queryKey:[e,`instancePlan`],queryFn:()=>g_(e),retry:!1})}var v_=[`stable`,`next`,`beta`,`alpha`];function y_(e){let t=v_.indexOf(e);return t===-1?v_.length:t}function b_(e){let t=new Map;for(let n of e){let e=t.get(n.version),r=!e||y_(n.name)<y_(e.name)?n:e,i=n.scoped||e?.scoped;t.set(n.version,i&&!r.scoped?{...r,scoped:!0}:r)}return[...t.values()]}async function x_(e){let{data:t}=await P.get(`/HarperVersions/`,{params:{organizationId:e}}),n=t;return{...n,value:b_(n.value)}}function S_(e){return B({queryKey:[e,`HarperVersions`],queryFn:()=>x_(e),staleTime:6e4,retry:!1})}function C_(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function w_(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function T_(e){return typeof e==`string`&&/^(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/.test(e)}function E_(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:T_(e.instanceFqdn)&&T_(t.instanceFqdn)?w_(e.instanceFqdn)-w_(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function D_(e,t){let n={};for(let r of e){let e=r[t];if(e!==void 0){if(Array.isArray(e))for(let t of e)n[t]||(n[t]=[]),n[t].push(r);else n[e]||(n[e]=[]),n[e].push(r)}}return n}function O_(e,t){let n={};for(let r of e){let e=r[t];if(e!==void 0){if(Array.isArray(e))for(let t of e)n[t]=r;else n[e]=r}}return n}function k_(e,t,n){let r=D_(e,t),i={};for(let e in r)i[e]=O_(r[e],n);return i}function A_({width:e,className:t,animated:n,placeholder:r}){return(0,K.jsxs)(`div`,{className:v(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,K.jsx)(`div`,{className:`absolute top-0 h-full w-full font-bold text-xs flex flex-col items-center justify-center text-black/60 text-shadow-2xs`,children:r}),(0,K.jsx)(`div`,{className:v(`rounded-full`,r?`h-6`:`h-2.5`,!t?.includes(`bg-`)&&`bg-purple/40`,n&&`transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`,t),style:{width:e}})]})}function j_({duration:e,message:t,lateMessage:n}){let r=(0,G.useRef)(0),i=(0,G.useRef)(0),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(`5%`),l=(0,G.useCallback)(function t(n){i.current||=n;let a=n-i.current,s=Math.min(a/e,1);c(Math.max(5,s*100)+`%`),s<1?r.current=requestAnimationFrame(t):o(!0)},[e]);return(0,G.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,K.jsxs)(K.Fragment,{children:[a?n:t,(0,K.jsx)(A_,{width:s,animated:!1})]})}async function M_(e){let{data:t}=await P.post(`/Cluster/`,e,{timeout:0});return t}function N_(){return I({mutationFn:e=>M_(e)})}async function P_(e){let{id:t,...n}=e,{data:r}=await P.put(`/Cluster/${t}`,n,{timeout:0});return r}function F_(){return I({mutationFn:e=>P_(e),meta:{skipGlobalErrorToast:!0},onError:e=>console.error(e)})}var I_=`ENTERPRISE`;function L_(e,t){if(t<=0)return``;if(e.length<=t)return e;let n=e.split(`-`);if(n.length===1)return n[0].slice(0,t);let r=[n[0],...n.slice(1).map(e=>e.charAt(0))],i=r.join(`-`);if(i.length<=t)return i;let a=r.slice(1).join(``).length,o=r.length-1,s=t-a-o;if(s>0)return r[0]=r[0].slice(0,s),r.join(`-`);{let e=[],i=0;t>0&&(e.push(n[0].charAt(0)),i=1);for(let n=1;n<r.length&&i+2<=t;n++)e.push(r[n]),i+=2;return e.join(`-`)}}function R_(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function z_(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function B_(e){return e!==void 0&&e>0}async function V_(e){await P.put(`/Payment/`,e)}function H_(){return I({mutationFn:e=>V_(e)})}function U_(e){let{mutate:t}=H_();return(0,G.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{U.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{U.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var W_=(0,G.createContext)(null);function G_(){return(0,G.useContext)(W_)}var K_=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),q_=t(((e,t)=>{var n=K_();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),J_=e(t(((e,t)=>{t.exports=q_()()}))(),1);function Y_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function X_(e){if(Array.isArray(e))return e}function Z_(e,t,n){return(t=ov(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Q_(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function $_(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
11
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ev(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tv(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ev(Object(n),!0).forEach(function(t){Z_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ev(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function nv(e,t){if(e==null)return{};var n,r,i=rv(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function rv(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function iv(e,t){return X_(e)||Q_(e,t)||cv(e,t)||$_()}function av(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ov(e){var t=av(e,`string`);return typeof t==`symbol`?t:t+``}function sv(e){"@babel/helpers - typeof";return sv=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},sv(e)}function cv(e,t){if(e){if(typeof e==`string`)return Y_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Y_(e,t):void 0}}var lv=function(e,t,n){var r=!!n,i=G.useRef(n);G.useEffect(function(){i.current=n},[n]),G.useEffect(function(){if(!r||!e)return function(){};var n=function(){if(i.current)return i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},uv=function(e){var t=G.useRef(e);return G.useEffect(function(){t.current=e},[e]),t.current},dv=function(e){return e!==null&&sv(e)===`object`},fv=`[object Object]`,pv=function e(t,n){if(t===n)return!0;if(!dv(t)||!dv(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===fv;if(i!==(Object.prototype.toString.call(n)===fv))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},mv=function(e,t,n){return dv(e)?Object.keys(e).reduce(function(r,i){var a=!dv(t)||!pv(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?tv(tv({},r||{}),{},Z_({},i,e[i])):r},null):null},hv=G.createContext(null);hv.displayName=`ElementsContext`;var gv=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e};J_.default.any,J_.default.object;var _v=function(e){return gv(G.useContext(hv),e)},vv=function(){return _v(`calls useElements()`).elements};J_.default.func.isRequired;var yv=G.createContext(null);yv.displayName=`CheckoutContext`;var bv=G.createContext(null);bv.displayName=`CheckoutSdkContext`;var xv=function(e){var t=G.useContext(bv),n=G.useContext(hv);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}return gv(n,e)},Sv=[`mode`],Cv=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},wv=function(e,t,n){var r=`${Cv(e)}Element`,i=t?function(e){xv(`mounts <${r}>`);var t=e.id,n=e.className;return G.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=xv(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutSdk`in C?C.checkoutSdk:null,E=iv(G.useState(null),2),D=E[0],O=E[1],k=G.useRef(null),A=G.useRef(null);lv(D,`blur`,s),lv(D,`focus`,c),lv(D,`escape`,d),lv(D,`click`,f),lv(D,`loaderror`,p),lv(D,`loaderstart`,m),lv(D,`networkschange`,h),lv(D,`confirm`,g),lv(D,`cancel`,_),lv(D,`shippingaddresschange`,v),lv(D,`shippingratechange`,y),lv(D,`savedpaymentmethodremove`,b),lv(D,`savedpaymentmethodupdate`,x),lv(D,`availablepaymentmethodschange`,S),lv(D,`change`,u);var j;l&&(j=e===`expressCheckout`?l:function(){l(D)}),lv(D,`ready`,j),G.useLayoutEffect(function(){if(k.current===null&&A.current!==null&&(w||T)){var t=null;if(T){var n=T,i=T;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=nv(o,Sv);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=T.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;case`linkSignup`:if(`createLinkSignupElement`in T)t=T.createLinkSignupElement(o);else throw Error(`<LinkSignupElement> requires <CheckoutElementsProvider> and is not supported inside <CheckoutFormProvider>.`);break;case`terms`:t=n.createTermsElement(o);break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));k.current=t,O(t),t&&t.mount(A.current)}},[w,T,o]);var M=uv(o);return G.useEffect(function(){if(k.current){var e=mv(o,M,[]);e&&`update`in k.current&&k.current.update(e)}},[o,M]),G.useLayoutEffect(function(){return function(){if(k.current&&typeof k.current.destroy==`function`)try{k.current.destroy(),k.current=null}catch{}}},[]),G.createElement(`div`,{id:n,className:i,ref:A})};return i.propTypes={id:J_.default.string,className:J_.default.string,onChange:J_.default.func,onBlur:J_.default.func,onFocus:J_.default.func,onReady:J_.default.func,onEscape:J_.default.func,onClick:J_.default.func,onLoadError:J_.default.func,onLoaderStart:J_.default.func,onNetworksChange:J_.default.func,onConfirm:J_.default.func,onCancel:J_.default.func,onShippingAddressChange:J_.default.func,onShippingRateChange:J_.default.func,onSavedPaymentMethodRemove:J_.default.func,onSavedPaymentMethodUpdate:J_.default.func,onAvailablePaymentMethodsChange:J_.default.func,options:J_.default.object},i.displayName=r,i.__elementType=e,i},Tv=typeof window>`u`,Ev=G.createContext(null);Ev.displayName=`EmbeddedCheckoutProviderContext`;var Dv=function(){return xv(`calls useStripe()`).stripe};wv(`auBankAccount`,Tv),wv(`card`,Tv),wv(`cardNumber`,Tv),wv(`cardExpiry`,Tv),wv(`cardCvc`,Tv),wv(`currencySelector`,Tv),wv(`iban`,Tv);var Ov=wv(`payment`,Tv);wv(`expressCheckout`,Tv),wv(`linkAuthentication`,Tv),wv(`linkSignup`,Tv),wv(`contactDetails`,Tv);var kv=wv(`address`,Tv);wv(`shippingAddress`,Tv),wv(`paymentMethodMessaging`,Tv),wv(`taxId`,Tv),wv(`issuingCardNumberDisplay`,Tv),wv(`issuingCardCvcDisplay`,Tv),wv(`issuingCardExpiryDisplay`,Tv),wv(`issuingCardPinDisplay`,Tv),wv(`issuingCardCopyButton`,Tv),wv(`terms`,Tv);function Av({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=z({strict:!1}),i=Dv(),a=G_(),o=vv(),[s,c]=(0,G.useState)(!1),l=U_(r),u=(0,G.useCallback)(()=>{t(!1)},[t]),d=(0,G.useCallback)(async e=>{if(e.preventDefault(),!i||!o)return;c(!0),await o.submit(),n?.(!0);let s=await i.confirmSetup({clientSecret:a.clientSecret,elements:o,redirect:`if_required`,confirmParams:{return_url:`${window.location.origin}/#/${r}/billing/confirm`}});s.error?(console.error(s.error.message),U.error(s.error.message),c(!1),n?.(!1)):s.setupIntent.payment_method&&(l(s.setupIntent.payment_method,t),n?.(!1))},[o,t,n,r,l,i,a.clientSecret]);return(0,K.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:d,className:`max-w-xl`,children:[(0,K.jsx)(Ov,{}),(0,K.jsx)(kv,{options:{mode:`billing`}}),(0,K.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,K.jsxs)(H,{disabled:!i||!o||s,variant:`submit`,children:[(0,K.jsx)($o,{}),` Add Payment Method`]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,K.jsx)(H,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}var jv=`endive`,Mv=`https://js.stripe.com`,Nv=`${Mv}/${jv}/stripe.js`,Pv=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Fv=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Iv=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,Lv=function(e){return Pv.test(e)||Fv.test(e)},Rv=function(){for(var e=document.querySelectorAll(`script[src^="${Mv}"]`),t=0;t<e.length;t++){var n=e[t];if(Lv(n.src))return n}return null},zv=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${Nv}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},Bv=null,Vv=null,Hv=null,Uv=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},Wv=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},Gv=function(e){if(Bv!==null)return Bv;var t=function(){return new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(Iv),window.Stripe){t(window.Stripe);return}try{var r=Rv();if(r&&e)console.warn(Iv);else if(!r)r=zv(e);else if(r&&Hv!==null&&Vv!==null){var i;r.removeEventListener(`load`,Hv),r.removeEventListener(`error`,Vv),(i=r.parentNode)==null||i.removeChild(r),r=zv(e)}Hv=Wv(t,n),Vv=Uv(n),r.addEventListener(`load`,Hv),r.addEventListener(`error`,Vv)}catch(e){n(e);return}})},n=function(){return t().catch(function(e){return Bv=null,Promise.reject(e)})};return n().catch(function(){return n()})},Kv,qv=function(){return Kv||(Kv=Gv(null).catch(function(e){return Kv=null,Promise.reject(e)}),Kv)};Promise.resolve().then(function(){return qv()}).catch(function(e){console.warn(e)});async function Jv(e){let{data:t}=await P.post(`/StripeAccount/`,e);return t}function Yv(){return I({mutationFn:e=>Jv(e)})}async function Xv(e){let{data:t}=await P.post(`/Payment/`,{organizationId:e.organizationId});return t}function Zv(){return I({mutationFn:e=>Xv(e)})}function Qv(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=Yv(),{mutate:a}=Zv(),[o,s]=(0,G.useState)(void 0),c=(0,G.useCallback)(e=>{s(e.clientSecret)},[]);return(0,G.useEffect)(()=>{},[i,t,n,a,c,r]),o}function $v({children:e}){let{organizationId:t}=z({strict:!1}),{data:n}=L(Yc(t)),r=Qv({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId}),i=Qc();return(0,G.useMemo)(()=>({clientSecret:r||``,appearance:{theme:i===`dark`?`night`:`stripe`}}),[r,i]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,K.jsx)(`div`,{className:`mt-20 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`Setting up your billing is currently disabled. Please check back again later.`})}function ey({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=z({strict:!1}),{data:r}=L(Yc(n)),i=r?.billing,a=i?.paymentMethod;return(0,K.jsxs)($v,{children:[(0,K.jsx)(`div`,{className:`mt-2 mb-6`,children:!a&&`You currently have no payment method on file. Please fill out the secure form below.`}),(0,K.jsx)(Av,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var ty=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function ny(e){switch(e){case ty.PASS:return`success`;case ty.FAIL:case ty.ERROR:return`destructive`;case ty.PENDING:default:return`default`}}function ry(e){switch(e){case ty.PASS:return`READY`;case ty.FAIL:case ty.ERROR:case ty.PENDING:default:return e.toUpperCase()}}function iy(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function ay(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=z({strict:!1}),{update:i}=cg(r),{data:a,refetch:o}=L(Yc(r)),s=a?.billing?.paymentMethod,[c,l]=(0,G.useState)(!1),u=(0,G.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,G.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,K.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your payment methods on this page. Want to explore your solution with Harper more? `,(0,K.jsx)(Pf,{}),`, we would love to talk!`]}):s&&!c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,K.jsxs)(K.Fragment,{children:[`(exp `,iy(s.expMonth,s.expYear),`)`]}):null,s.status?(0,K.jsxs)(K.Fragment,{children:[`—`,` `,(0,K.jsx)(ol,{variant:ny(s.status),children:ry(s.status)})]}):null]}),i&&(0,K.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,K.jsx)(H,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,K.jsx)(ey,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,K.jsx)(`div`,{children:`This org doesn't have a payment method, and you don't have access to add one. Please contact your administrator.`})}function oy({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o,submitError:s}){let{data:c}=L(Yc(a)),l=c?.billing,u=c?.type===I_,d=u||l?.paymentMethod?.status===ty.PASS,[f,p]=(0,G.useState)(!1),m=B_(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,h=(0,K.jsxs)(K.Fragment,{children:[s&&(0,K.jsx)(`div`,{className:`mt-3 max-w-xl`,children:(0,K.jsx)(Kf,{message:s})}),(0,K.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,disabled:t,onClick:n,children:[(0,K.jsx)(Hr,{}),` Back to Details`]}),(0,K.jsxs)(H,{disabled:t||!d||f,type:`submit`,variant:`submit`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,K.jsx)(Wr,{})]})]})]});if(u)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,K.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,K.jsxs)(`li`,{children:[`Your account representative can work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,K.jsx)(Pf,{overEmail:!0}),`, we are here to help.`]})]}),h]});let g=m&&`, or ${oe(m,`month`,`months`)} elapse`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,K.jsx)(`li`,{children:`You will be billed for this cluster today, and will receive a license for the block of usage you've requested.`}),e&&(0,K.jsx)(`li`,{children:`If you scale up, you'll be charged for the additional blocks you've purchased now, and your next auto renewal will be for all purchased blocks.`}),e&&(0,K.jsx)(`li`,{children:`If you remove a region, that region's usage block will not be used anymore (because it is specific to that region).`}),(0,K.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,K.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,K.jsxs)(`li`,{children:[`We would love to work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,K.jsx)(Pf,{overEmail:!0}),`, we are here to help.`]})]}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,K.jsx)(ay,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:p}),h]})}function sy({hostname:e,testId:t,labelledBy:n}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-full border border-border/60 bg-background/70 px-4 py-3 shadow-inner`,children:[(0,K.jsx)(io,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`p`,{className:`min-w-0 overflow-x-auto whitespace-nowrap font-mono text-xs leading-5`,"data-testid":t,role:`region`,"aria-labelledby":n,"aria-label":n?void 0:`Address preview`,tabIndex:0,children:e})]})}function cy({maxLength:e,onPaste:t,...n}){let{controlProps:r,inputProps:i,hint:a}=Af(e,t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{...r,children:(0,K.jsx)($,{...n,...i})}),a]})}var ly=/(^$|^(?:localhost|(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,})$)/i,uy=65535,dy=x().max(20,`Must be at most 20 characters long.`).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,`Can only contain lowercase letters, numbers and dashes. Must not start or end with a dash.`),fy=b({clusterName:x().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:te([O(``),w(),dy]).optional(),fqdn:x().regex(ly,`Please enter a valid host name without the port or any path.`).optional(),version:x().optional(),deploymentDescription:x().nonempty(`Please select a deployment tier.`),performanceDescription:x().nonempty(`Please select a performance tier.`),regionPlans:D(b({regionName:x().nonempty(`Please select a region.`),latencyDescription:x().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:D(b({secure:j([`true`,`false`]),fqdn:x().nonempty(`Please enter the host name of your instance.`).regex(ly,`Please enter a valid host name without the port or any path.`),port:C().min(0,`Positive thinking only, please.`).max(uy,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:A().optional(),skipGtmWait:A().optional(),sourceClusterId:x().optional()});function py({calculatedNames:e,disabled:t,form:n}){let r=(0,G.useId)();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Host Name`}),(0,K.jsx)(cy,{...n,type:`text`,maxLength:dy.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`col-span-3 min-w-0 space-y-2`,children:[(0,K.jsx)(`p`,{id:r,className:`text-sm font-medium`,children:`Full Host Name`}),(0,K.jsx)(sy,{hostname:e.fullHostName,testId:`cluster-hostname-preview`,labelledBy:r})]})]})}function my({className:e}={}){let t=(0,G.useMemo)(()=>v(`animate-pulse h-2.5 bg-gray-200 rounded-full dark:bg-gray-700`,!e?.includes(`mb-`)&&`mb-4 `,!e?.includes(`w-`)&&`w-48 `,e),[e]);return(0,K.jsx)(`div`,{className:t})}function hy({...e}){return(0,K.jsx)(qn,{"data-slot":`select`,...e})}function gy({...e}){return(0,K.jsx)(Ct,{"data-slot":`select-group`,...e})}function _y({...e}){return(0,K.jsx)(kt,{"data-slot":`select-value`,...e})}function vy({className:e,children:t,...n}){return(0,K.jsxs)(Tt,{"data-slot":`select-trigger`,className:F(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-white text-foreground dark:bg-grey-700 dark:text-white px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:truncate *:data-[slot=select-value]:block *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,K.jsx)(xt,{asChild:!0,children:(0,K.jsx)(er,{className:`size-4 text-foreground dark:text-white`})})]})}function yy({className:e,children:t,position:n=`popper`,...r}){return(0,K.jsx)(Ft,{children:(0,K.jsxs)(Jt,{"data-slot":`select-content`,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,K.jsx)(Sy,{}),(0,K.jsx)(Nt,{className:F(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,K.jsx)(Cy,{})]})})}function by({className:e,...t}){return(0,K.jsx)(Sn,{"data-slot":`select-label`,className:F(`px-2 py-1.5 text-sm font-medium`,e),...t})}function xy({className:e,children:t,...n}){return(0,K.jsxs)(zt,{"data-slot":`select-item`,className:F(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,K.jsx)(ht,{children:t}),(0,K.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(wn,{children:(0,K.jsx)(tr,{className:`size-4`})})})]})}function Sy({className:e,...t}){return(0,K.jsx)(Vt,{"data-slot":`select-scroll-up-button`,className:F(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,K.jsx)(nr,{className:`size-4`})})}function Cy({className:e,...t}){return(0,K.jsx)(Lt,{"data-slot":`select-scroll-down-button`,className:F(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,K.jsx)(er,{className:`size-4`})})}var wy={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Ty({availableDeploymentTypes:e,disabled:t,form:n}){return(0,K.jsx)(Y,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Harper Deployment`}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(my,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,K.jsx)(vy,{className:`w-full h-auto`,children:(0,K.jsx)(_y,{placeholder:`Choose Tier`})}),(0,K.jsx)(yy,{children:(0,K.jsx)(gy,{children:e.map(e=>(0,K.jsxs)(xy,{value:e,children:[(0,K.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),wy[e]&&(0,K.jsx)(`dd`,{className:`font-light`,children:wy[e]})]},e))})})]})})}),(0,K.jsx)(Q,{})]})})}function Ey({disabled:e,form:t}){return(0,K.jsx)(Y,{control:t.control,name:`fqdn`,render:({field:t})=>(0,K.jsxs)(X,{className:`md:col-span-6 col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`e.g. cluster.your-company.com`,disabled:e})}),(0,K.jsx)(Q,{})]})})}function Dy({className:e,disabled:t,form:n}){return(0,K.jsx)(Y,{control:n.control,name:`clusterName`,render:({field:n})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Cluster Name`}),(0,K.jsx)(cy,{autoFocus:!0,type:`text`,maxLength:fy.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n}),(0,K.jsx)(Q,{})]})})}function Oy({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,K.jsx)(Y,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsxs)(Z,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(my,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,K.jsx)(vy,{className:`w-full h-auto`,children:(0,K.jsx)(_y,{placeholder:`Choose Tier`})}),(0,K.jsx)(yy,{children:(0,K.jsx)(gy,{children:e.map(e=>(0,K.jsxs)(xy,{value:e.performanceTier,children:[(0,K.jsxs)(`dt`,{className:`text-left font-bold text-sm/6 flex items-center gap-2`,children:[e.name,e.isPremium&&(0,K.jsx)(ol,{children:`Premium`})]}),e.description&&(0,K.jsx)(`dd`,{className:`text-left font-light`,children:e.description})]},e.name))})})]})})}),(0,K.jsx)(Q,{})]})})}function ky({className:e,...t}){let{formDescriptionId:n}=jd();return(0,K.jsx)(`p`,{"data-slot":`form-description`,id:n,className:F(`text-muted-foreground text-sm`,e),...t})}function Ay({className:e,form:t}){return(0,K.jsx)(Y,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-4 h-4 cursor-pointer`,checked:t.value||!1,onChange:t.onChange,onBlur:t.onBlur,name:t.name,ref:t.ref})}),(0,K.jsx)(Z,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,K.jsx)(ky,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function jy({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,K.jsx)(Y,{control:n.control,name:`version`,render:({field:i})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Harper Version`}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(my,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,K.jsx)(vy,{className:`w-full h-auto`,children:(0,K.jsx)(_y,{placeholder:`Choose Version`})}),(0,K.jsx)(yy,{children:(0,K.jsx)(gy,{children:r?.value.map(e=>(0,K.jsxs)(xy,{value:e.version,children:[e.version,` `,(0,K.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,K.jsx)(Q,{})]})}):null}var My=new RegExp(/^\d+/);function Ny(e,t){let n=parseInt(e.match(My)?.[0]||`0`,10),r=parseInt(t.match(My)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var Py=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],Fy=[`secs`,`mins`,`hrs`],Iy={bytes:1e3,secs:60};function Ly(e,t,n){let r,i;switch(t){case`bytes`:r=Py,i=Iy.bytes;break;case`secs`:r=Fy,i=Iy.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function Ry(e,t){let n,r;switch(e){case`bytes`:n=Py,r=Iy.bytes;break;case`secs`:n=Fy,r=Iy.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function zy(e,t=1){let n=e*t,r=Ry(`bytes`,n),i=Ly(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function By(e){return new Intl.NumberFormat().format(e)}var Vy=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function Hy(e){let t=1e3,n=e;if(Math.abs(n)<t)return String(Math.round(n));let r=-1;do n/=t,++r;while(Math.round(Math.abs(n)*10)/10>=t&&r<Vy.length-1);return`${By(Math.round(n))} ${Vy[r]}`}function Uy(e,t){let n=Object.values(t).flatMap(e=>Object.values(e)).map(e=>e.purchasedBlockMultiplier??1),r=Math.max(...n,1),i=Math.min(...n,r),a=t=>{let n=e.map(t).filter(e=>typeof e==`number`&&e>0);return n.length?{min:Math.min(...n),max:Math.max(...n)}:{min:0,max:0}},o=a(e=>e.planLimits?.readsPerMinuteCount),s=a(e=>e.planLimits?.totalReadCount);return{readRate:{min:o.min*i,max:o.max*r},totalReads:{min:s.min*i,max:s.max*r},writeRate:a(e=>e.planLimits?.writesPerMinuteCount),totalWrites:a(e=>e.planLimits?.totalWriteCount)}}function Wy(e,{min:t,max:n}){if(e<=0)return 0;let r=Math.max(Math.min(t,e),1),i=Math.max(n,e);if(i<=r)return 1;let a=(Math.log(e)-Math.log(r))/(Math.log(i)-Math.log(r));return Math.min(Math.max(a,0),1)}function Gy({selectedPlan:e,selectedRegion:t,usageScale:n,isEnterprise:r,cloudProvider:i}){let[a,o]=(0,G.useState)(!1),s=(0,G.useCallback)(()=>{o(!a)},[a,o]),c=e?.planLimits,l=e?.resourcesPerInstance,u=i&&e?.cloudInstanceTypes?.[i],d=B_(c?.expirationMonths)&&c.expirationMonths<1e3&&c.expirationMonths,f=t?.purchasedBlockMultiplier??1,p=(0,G.useMemo)(()=>c?[B_(c.totalReadCount)&&{label:`Total Reads`,value:Hy(c.totalReadCount*f)},B_(c.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${zy(c.totalReadsBytes*f)}`},B_(c.readsPerMinuteCount)&&{label:`Read Rate`,value:`${Hy(c.readsPerMinuteCount*60*f)}/hr`},B_(c.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${zy(c.readsPerMinuteBytes*60*f)}/hr`},B_(c.totalWriteCount)&&{label:`Total Writes`,value:Hy(c.totalWriteCount)},B_(c.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${zy(c.totalWritesBytes)}`},B_(c.writesPerMinuteCount)&&{label:`Write Rate`,value:`${Hy(c.writesPerMinuteCount*60)}/hr`},B_(c.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${zy(c.writesPerMinuteBytes*60)}/hr`},B_(c.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${Hy(c.totalRealTimeMessageDeliveries*f)} messages`},B_(c.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${zy(c.totalRealTimeMessageDeliveryBytes*f)}`},B_(c.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${Hy(c.realTimeMessageDeliveriesPerMinute*60*f)}/hr`},B_(c.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${zy(c.realTimeMessageDeliveryBytesPerMinute*60*f)}/hr`},B_(c.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${Hy(c.tlsHandshakes*60*f)}`},B_(c.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${Hy(c.applicationComputeHours*f)}`},!!l&&B_(l.storageGb)&&{label:`Storage`,value:`${zy(l.storageGb*1e9)}`},!!l&&B_(l.cpuCores)&&{label:`Maximum CPU Cores`,value:`${Hy(l.cpuCores)}`},!!l&&B_(l.memoryMb)&&{label:`Memory`,value:`${l.memoryMb/1024} GB`},!!u&&{label:`Cloud Instance Type`,value:u},!!d&&{label:`Expiration`,value:oe(d,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(fr):[],[d,t,e,f]);if(!c)return``;if(!B_(c.totalReadCount))return`This plan has no usage limits.`;let m=r?`for the contracted rate`:`for the price listed above`,h=d?` in ${oe(d,`month`,`months`)} or`:``,g=B_(c.readsPerMinuteCount)?c.readsPerMinuteCount*f:0,_=B_(c.writesPerMinuteCount)?c.writesPerMinuteCount:0,v=c.totalReadCount*f,y=B_(c.totalWriteCount)?c.totalWriteCount:0,b=[g>0&&{icon:Ea,label:`Read Rate`,value:`${Hy(g)}/min`,fill:Wy(g,n.readRate)},v>0&&{icon:Jr,label:`Total Reads`,value:Hy(v),fill:Wy(v,n.totalReads)},_>0&&{icon:Ea,label:`Write Rate`,value:`${Hy(_)}/min`,fill:Wy(_,n.writeRate)},y>0&&{icon:Rr,label:`Total Writes`,value:Hy(y),fill:Wy(y,n.totalWrites)},!!d&&{icon:mi,label:`License Term`,value:oe(d,`month`,`months`)}].filter(fr);return(0,K.jsxs)(X,{className:`basis-full`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-2`,children:[(0,K.jsx)(Z,{onClick:s,className:`cursor-pointer`,children:`Usage block included with this plan`}),(0,K.jsxs)(H,{type:`button`,variant:`link`,className:`text-foreground`,onClick:s,children:[`Learn More `,a?(0,K.jsx)(Br,{}):(0,K.jsx)(Wr,{})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:b.map(e=>(0,K.jsx)(Ky,{icon:e.icon,label:e.label,value:e.value,fill:e.fill},e.label))}),(0,K.jsx)(J,{children:(0,K.jsxs)(`dl`,{className:F(`divide-y divide-border rounded-md overflow-hidden transition-[max-height] duration-200 ease-in`,a?`max-h-fit border border-border`:`max-h-0`),children:[(0,K.jsxs)(`div`,{className:`text-sm px-4 py-5 leading-relaxed text-muted-foreground`,children:[`This plan licenses Harper for the usage limits below, `,m,`. The usage license expires`,h,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),p.map((e,t)=>(0,K.jsxs)(`div`,{className:F(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-muted dark:bg-grey-700`),children:[(0,K.jsx)(`dt`,{className:`text-sm/6 font-medium text-foreground`,children:e.label}),(0,K.jsx)(`dd`,{className:`mt-1 text-sm/6 text-muted-foreground sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,K.jsx)(Q,{})]})}function Ky({icon:e,label:t,value:n,fill:r}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-background/50 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(e,{className:`size-4 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,K.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:n}),r!==void 0&&(0,K.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-sky-500/15`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full bg-sky-500 transition-[width] duration-300`,style:{width:`${Math.max(Math.min(r,1)*100,4)}%`}})})]})}function qy({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,premiumOnlyRegions:a,usageScale:o,selectedPlan:s,isEnterprise:c,cloudProvider:l}){let u=(0,G.useMemo)(()=>Object.keys(i).sort(),[i]),d=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),f=n.watch(`regionPlans.${r}.regionName`),p=n.watch(`regionPlans.${r}.latencyDescription`),m=(0,G.useMemo)(()=>Object.keys(i[f]||{}).sort(Ny).reverse(),[i,f]),h=s?.allowedRegionIds,g=(0,G.useCallback)(e=>!h?.length||Object.values(i[e]||{}).some(e=>h.includes(e.id)),[h,i]),_=(0,G.useCallback)(e=>{if(!h?.length)return!0;let t=i[f]?.[e]?.id;return!t||h.includes(t)},[h,i,f]);(0,G.useEffect)(function(){if(f&&m?.length&&!m?.includes(p)){let e=p?.split(` `)[0].toLowerCase(),t=m.find(t=>!e||t.split(` `)[0].toLowerCase()===e)||m[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[m,n,r,p,f]);let v=(0,G.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,K.jsxs)(`div`,{className:`md:col-span-6 col-span-3 py-2 pl-4 border-l-4 border-border gap-6 flex flex-wrap items-start`,children:[(0,K.jsx)(Y,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,K.jsxs)(X,{className:`min-w-0 basis-full sm:flex-1`,children:[(0,K.jsxs)(Z,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(yo,{className:`size-4 shrink-0`}),`Region `,t.fields.length>1?r+1:``]}),(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Region`})}),(0,K.jsx)(yy,{children:(0,K.jsx)(gy,{children:u.map(e=>(0,K.jsx)(xy,{value:e,disabled:!g(e),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,a.regionNames.has(e)&&(0,K.jsx)(ol,{children:`Premium`})]})},e))})})]})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,K.jsxs)(X,{className:`min-w-0 basis-full sm:flex-1`,children:[(0,K.jsxs)(Z,{children:[`Estimated `,d?`P95`:`P90`,` Latency, Distribution`]}),(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!m?.length,children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Latency Tier`})}),(0,K.jsx)(yy,{children:(0,K.jsx)(gy,{children:m.map(e=>(0,K.jsx)(xy,{value:e,disabled:!_(e),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(()=>{let t=i[f]?.[e]?.id;return t&&a.regionIds.has(t)&&(0,K.jsx)(ol,{children:`Premium`})})()]})},e))})})]})}),(0,K.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,K.jsx)(`div`,{className:`flex-none mt-6`,children:(0,K.jsxs)(H,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:v,children:[(0,K.jsx)(Is,{}),` `,(0,K.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,K.jsx)(Gy,{selectedPlan:s,selectedRegion:i[f]?.[p],usageScale:o,isEnterprise:c,cloudProvider:l})]})}function Jy({form:e,regionLocations:t,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,totalPrice:o,isEnterprise:s,cloudProvider:c}){let l=e.watch(`regionPlans`),u=xn({control:e.control,name:`regionPlans`}),d=(0,G.useMemo)(()=>{let e=l.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return o?t?.find(t=>!e.includes(t.region)):null},[t,n,l,o]),f=(0,G.useCallback)(()=>{d&&(u.append({regionName:d.region,latencyDescription:d.latencyDescription}),e.trigger())},[e,d,u]);return t?.length?(0,K.jsxs)(K.Fragment,{children:[u.fields.map((t,o)=>(0,K.jsx)(qy,{control:e.control,fieldArray:u,form:e,index:o,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,isEnterprise:s,cloudProvider:c},t.id)),d&&(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsxs)(H,{type:`button`,variant:`positiveOutline`,onClick:f,children:[(0,K.jsx)(Uo,{}),`Add Additional Region Usage`]})})]}):(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsx)(oc,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,K.jsxs)(K.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,K.jsx)(Pf,{}),`.`]})}})})}function Yy({control:e,fieldArray:t,form:n,index:r}){let i=(0,G.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,K.jsxs)(`div`,{className:`md:col-span-6 col-span-3 p-4 rounded-md bg-accent gap-6 flex flex-wrap items-start`,children:[(0,K.jsx)(Y,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsxs)(Z,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`https://`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`true`,children:`https://`}),(0,K.jsx)(xy,{value:`false`,children:`http://`})]})})]})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-3`,children:[(0,K.jsx)(Z,{children:`Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,onChange:t=>{e.onChange(t);let i=t.target.value,a=i===`localhost`||i===`127.0.0.1`,o=n.getFieldState(`instances.${r}.secure`);a&&!o.isDirty&&n.setValue(`instances.${r}.secure`,`false`)}})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Operations API Port`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`number`,min:0,max:uy,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(g),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),n.trigger()}})}),(0,K.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,K.jsx)(`div`,{className:`flex-none mt-6`,children:(0,K.jsxs)(H,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,K.jsx)(Is,{}),` `,(0,K.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Xy({form:e}){let t=xn({control:e.control,name:`instances`}),n=(0,G.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:g})},[t]);return(0,K.jsxs)(K.Fragment,{children:[t.fields.map((n,r)=>(0,K.jsx)(Yy,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsxs)(H,{type:`button`,variant:`positiveOutline`,onClick:n,children:[(0,K.jsx)(Uo,{}),`Add Instance`]})})]})}function Zy(e,t){return!e.allowedRegionIds?.length||e.allowedRegionIds.includes(t)}function Qy(e,t){let n=new Set,r=new Set;if(!e.length)return{regionNames:n,regionIds:r};let i=Math.min(...e.map(e=>e.planLevel??0)),a=e.filter(e=>(e.planLevel??0)===i),o=e.filter(e=>(e.planLevel??0)>i);if(!o.length)return{regionNames:n,regionIds:r};for(let[e,i]of Object.entries(t)){let t=!1,s=!0;for(let e of Object.values(i)){let n=a.some(t=>Zy(t,e.id)),i=o.some(t=>Zy(t,e.id));(n||i)&&(t=!0,n?s=!1:r.add(e.id))}t&&s&&n.add(e)}return{regionNames:n,regionIds:r}}function $y({priceSummary:e,calculatedNames:t,clusterId:n,deploymentToPerformanceToPlan:r,form:i,harperVersions:a,isEnterprise:o,cloudProvider:s,isPending:c,mode:l,partialUpgrade:u,regionLocations:d,regionNameToLatencyToRegion:f,selectedDeployment:p,selectedPerformance:m,selectedPlan:h,submitError:g,totalPrice:_}){let{isDirty:v,isValid:y}=Nn(),b=(0,G.useMemo)(()=>{let e=r[p]||{},t=Object.values(e).map(e=>e.planLevel??0),n=t.length?Math.min(...t):0;return Object.keys(e).map(t=>{let r=(e[t].planLevel??0)>n,i=t.slice(0,-1).split(`(`);if(i.length>1)return{performanceTier:t,name:i[0],description:i[1],isPremium:r};let a=t.split(` for `);return a.length>1?{performanceTier:t,name:a[0],description:`For `+a[1],isPremium:r}:{performanceTier:t,name:t,description:``,isPremium:r}})},[r,p]),x=(0,G.useMemo)(()=>Object.keys(r).sort(),[r]),S=(0,G.useMemo)(()=>Qy(Object.values(r[p]||{}),f),[r,f,p]),C=(0,G.useMemo)(()=>Uy(Object.values(r).flatMap(e=>Object.values(e)),f),[r,f]);(0,G.useEffect)(function(){b?.length&&!b.find(e=>e.performanceTier===m)&&(i.setValue(`performanceDescription`,b[0].performanceTier),i.trigger())},[p,m,b,i]);let w=p===`Self-Hosted`,T=l===`version`&&!!u&&!u.ambiguous,E=(0,K.jsxs)(Em,{className:`mt-6 mb-8 border-t border-border/60 pt-6 sm:items-center`,children:[(0,K.jsx)(Kf,{message:g}),(0,K.jsxs)(H,{className:`w-full sm:w-auto`,type:`submit`,variant:`submit`,disabled:c||n&&!v&&!T||!y,children:[l!==`version`&&_>0?`Confirm Payment Details`:n?`Edit Cluster`:`Create New Cluster`,(0,K.jsx)(Wr,{})]})]});return l===`version`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Er,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,K.jsxs)(Dr,{className:`border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/15 py-5 dark:from-primary/15 dark:to-primary/5`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,K.jsx)(ss,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Cluster details`]}),(0,K.jsx)(kr,{children:`Choose the Harper version for your cluster.`})]}),(0,K.jsxs)(Ar,{className:`grid min-w-0 grid-cols-3 items-start gap-6 py-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Dy,{className:a?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:i}),(0,K.jsx)(jy,{className:`col-span-3`,form:i,harperVersions:a}),(0,K.jsx)(Ay,{className:`col-span-3 md:col-span-6`,form:i}),u&&(0,K.jsxs)(`p`,{className:`col-span-3 md:col-span-6 max-w-prose text-xs font-light text-amber-600 dark:text-amber-400`,children:[u.behindCount,` of `,u.total,` instances`,` `,u.behindCount===1?`is`:`are`,` `,u.ambiguous?`on a different version from ${u.latest}, and a version pinned to your organization is among them. Choose the version the whole cluster should run.`:`still on an older version. Re-run the upgrade to bring ${u.behindCount===1?`it`:`them`} up to ${u.latest}.`]})]})]}),E]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:e?`grid items-start gap-6 xl:grid-cols-[minmax(0,1fr)_18rem]`:``,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[(0,K.jsxs)(Er,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,K.jsxs)(Dr,{className:`border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/15 py-5 dark:from-primary/15 dark:to-primary/5`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,K.jsx)(ss,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Cluster details`]}),(0,K.jsx)(kr,{children:`Your cluster’s identity, version, and address.`})]}),(0,K.jsxs)(Ar,{className:`grid min-w-0 grid-cols-3 items-start gap-6 py-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Dy,{className:a?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!n,form:i}),(0,K.jsx)(jy,{className:`col-span-3`,disabled:!!n,form:i,harperVersions:a}),w?(0,K.jsx)(Ey,{form:i,disabled:!!n}):(0,K.jsx)(py,{form:i,calculatedNames:t,disabled:!!n})]})]}),(0,K.jsxs)(Er,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,K.jsxs)(Dr,{className:`border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/15 py-5 dark:from-primary/15 dark:to-primary/5`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,K.jsx)(Ka,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Deployment & capacity`]}),(0,K.jsx)(kr,{children:`Choose your infrastructure and the capacity your workload needs.`})]}),(0,K.jsxs)(Ar,{className:`grid min-w-0 grid-cols-3 items-start gap-6 py-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Ty,{form:i,availableDeploymentTypes:x}),(0,K.jsx)(Oy,{availablePerformanceDescriptions:b,form:i,selectedDeployment:p}),w?(0,K.jsx)(Xy,{form:i}):(0,K.jsx)(Jy,{form:i,regionLocations:d,regionNameToLatencyToRegion:f,premiumOnlyRegions:S,usageScale:C,selectedPlan:h,totalPrice:_,isEnterprise:o,cloudProvider:s}),n&&!w&&(0,K.jsx)(Ay,{className:`col-span-3 md:col-span-6`,form:i})]})]})]}),e]}),E]})}function eb(e){let{fqdn:t}=e,{secure:n,port:r}=e;return r||=g,r===443&&n===`false`&&(n=`true`),r===80&&n===`true`&&(n=`false`),`${n===`true`?`https`:`http`}://${t}${r===443||r===80?``:`:`+r}`.toLowerCase()}function tb(e,t,n){let r=e.find(e=>(n?!!e.priceUsd:!e.priceUsd)&&e.deploymentType===`colocated`)||e.find(e=>e.deploymentType===`colocated`)||e[0],i=r?.allowedRegionIds;if(r){let e=i?t.filter(e=>i.includes(e.id)):t,n=e.find(e=>e.region===`US`)||e[0];if(n)return{deploymentDescription:r.deploymentDescription,performanceDescription:r.performanceDescription,regionPlans:[{regionName:n.region,latencyDescription:n.latencyDescription}]}}return null}function nb(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=tb(t,n);i&&(!r.deploymentDescription&&!r.performanceDescription&&(e.setValue(`deploymentDescription`,i.deploymentDescription),e.setValue(`performanceDescription`,i.performanceDescription)),r.regionPlans.length||e.setValue(`regionPlans`,i.regionPlans))}}}function rb({price:e}){let t=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0);return(0,K.jsx)(`span`,{className:`text-4xl`,children:t.map((e,t)=>(0,K.jsx)(ib,{type:e.type,value:e.value},t))})}function ib({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,K.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function ab({alreadyUsingFree:e,clusterId:t,defaultValues:n,deploymentToPerformanceToPlan:r,harperVersions:i,mode:a,organization:o,organizationId:s,partialUpgrade:c,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:f,startOffOnBilling:p}){let m=De(),h=Ee(),_=o?.type===I_,v=o?.channel===`Akamai`?`linode`:void 0,y=Ze(),{mutate:b,isPending:x}=N_(),{mutate:S,isPending:C,error:w}=F_(),T=w?fc(w).message:void 0,[E,D]=(0,G.useState)(p),O=(0,G.useMemo)(()=>k_(u?.sort(C_(`latencyDescription`))||[],`region`,`latencyDescription`),[u]),k=(0,G.useMemo)(()=>k_(d?.sort(C_(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),A=(0,G.useCallback)((t,n)=>{let i=new Set,a=r?.[t.deploymentDescription]?.[t.performanceDescription];if(t.deploymentDescription===`Self-Hosted`)for(let e=0;e<t.instances.length;e++){let r=eb(t.instances[e]);i.has(r)?n.addIssue({code:`custom`,path:[`instances.${e}.fqdn`],message:`Every instance url must be unique!`}):i.add(r)}else{a?.priceUsd===0&&e&&n.addIssue({code:`custom`,path:[`performanceDescription`],message:`Only one free cluster is allowed per organization.`});let r=a?.deploymentDescription===`Dedicated`?k:O;for(let e=0;e<t.regionPlans.length;e++){let o=t.regionPlans[e],s=r[o.regionName]?.[o.latencyDescription];i.has(o.regionName)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select a region once!`}):i.add(o.regionName),a?.allowedRegionIds?.length&&s?.id&&(a.allowedRegionIds.includes(s.id)?e>=1&&n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select one region with this performance tier!`}):R_(a.allowedRegionIds,s.id)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.latencyDescription`],message:`This latency is not available with the selected performance tier!`}):n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`This region is not available with the selected performance tier!`}))}}},[e,O,k,r]),j=on({mode:`onChange`,resolver:mt(fy.superRefine(A)),defaultValues:n}),[M,ee]=(0,G.useState)(!0);(0,G.useEffect)(()=>{M&&n&&(f(null),ee(!1))},[n,M,f]);let te=j.watch(`clusterName`),N=j.watch(`abbreviatedName`),P=j.watch(`deploymentDescription`),F=j.watch(`performanceDescription`),ne=j.watch(`regionPlans`),re=j.watch(`instances`),ie=P===`Dedicated`?k:O,ae=P===`Dedicated`?d:u;(0,G.useEffect)(function(){let e=j.getValues();P&&(P===`Self-Hosted`?(e.abbreviatedName&&j.setValue(`abbreviatedName`,``),e.regionPlans.length&&j.setValue(`regionPlans`,[]),e.instances.length||j.setValue(`instances`,[{secure:`true`,fqdn:``,port:g}])):(e.fqdn&&j.setValue(`fqdn`,``),e.instances.length&&j.setValue(`instances`,[]),e.regionPlans.length||nb(j,l,ae)))},[j,l,ae,P]);let se=(0,G.useMemo)(()=>{let e=L_(z_(te),dy.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${N||e}.${o.subdomain||`your-org`}.harperfabric.com`}},[te,N,o]),ce=(0,G.useMemo)(()=>r?.[P]?.[F],[r,P,F]);(0,G.useEffect)(function(){let e=ce?.allowedRegionIds;if(e?.length&&ne?.length===1){let t=ne[0],n=ie?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=ae?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(j.setValue(`regionPlans.0.regionName`,n.region),j.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),j.trigger())}}},[ce,ne,j,ie,ae]),(0,G.useEffect)(function(){if(P!==`Self-Hosted`&&Object.keys(ie).length&&ne.length)for(let e=0;e<ne.length;e++){let t=ne[e];ie[t.regionName]||j.setValue(`regionPlans.${e}.regionName`,``)}},[j,ie,P,ne]);let le=ce?.priceUsd?P===`Self-Hosted`?re.length*ce.priceUsd:ne.reduce((e,t)=>{let n=ie?.[t.regionName]?.[t.latencyDescription];return e+(n?ce.priceUsd*n.instanceCount/2:0)},0):0,ue=ce?.planLimits?.expirationMonths,de=B_(ue)&&ue<1e3?ue:void 0,fe=de?le/de:le,pe=(0,G.useCallback)(({creating:e,deploymentDescription:t})=>U.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,K.jsx)(j_,{message:`This may take a little bit, hold tight!`,lateMessage:`Still working on it... why don't you grab a coffee, and I'll let you know when it's done?`,duration:t===`Dedicated`?6e4:5e3}),duration:0}),[]),me=(0,G.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i,skipGtmWait:a})=>{if(n&&t){let e=(await Jc(s)).clusters?.find(e=>e.id===t);af(e?.status)&&await Lg(t)}y.invalidateQueries({queryKey:[s],refetchType:`active`}),n||mr(y,e,{refetchType:`active`}),h.invalidate(),m(i?{to:`/${s}/${e}/instances`}:n?{to:`/${s}/${e}/starting-up`}:{to:`/${s}/${e}/scaling`,search:a?{immediate:!0}:void 0}),j.reset(),U.success(n?`Cluster Created`:`Cluster Updated`,{id:r,description:i?void 0:n?`It is being provisioned now.`:`The updates are being provisioned now.`,duration:5e3})},[y,h,m,s,j]),he=(0,G.useCallback)(async()=>{let e=j.getValues(),n=[],i=r[e.deploymentDescription][e.performanceDescription],o=e.deploymentDescription===`Self-Hosted`;if(o)for(let t of e.instances)n.push({autoRenew:!0,instanceFqdn:t.fqdn,operationsApiPort:t.port||9925,operationsApiSecure:t.secure===`true`,planId:i.id});else for(let t of e.regionPlans){let e=ie[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}f(null);let c=pe({creating:!t,deploymentDescription:e.deploymentDescription}),l=()=>U.dismiss(c);t?S(a===`version`?{id:t,version:e.version,skipGtmWait:e.skipGtmWait}:{id:t,regionPlans:n,skipGtmWait:e.skipGtmWait},{onSuccess:t=>me({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:o,creating:!1,toastId:c,skipGtmWait:e.skipGtmWait}),onError:l}):b({abbreviatedName:o?void 0:e.abbreviatedName||se.suggestedAbbreviatedName,autoRenew:!0,fqdn:o&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:s,regionPlans:n},{onSuccess:t=>me({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:o,creating:!0,toastId:c}),onError:l})},[se.suggestedAbbreviatedName,t,r,j,me,pe,s,ie,f,S,b]),ge=(0,G.useCallback)(()=>{if(a!==`version`&&le>0){D(!0);return}return he()},[a,he,le]),_e=(0,G.useCallback)(e=>{f(e?{clusterId:t,...j.getValues(),skipToBilling:!0}:null)},[t,j,f]),ve=(0,G.useCallback)(()=>{D(!1)},[]),ye=!_&&a!==`version`?(0,K.jsxs)(`aside`,{"aria-label":`Price summary`,className:`min-w-0 rounded-2xl border border-primary/15 bg-primary/5 p-6 xl:order-2`,children:[(0,K.jsx)(`p`,{className:`mb-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Your plan`}),(0,K.jsxs)(`dl`,{children:[(0,K.jsx)(`dt`,{className:`text-sm text-muted-foreground`,children:de?`Monthly Price`:`Total Price`}),(0,K.jsx)(`dd`,{className:`mt-2 font-bold`,children:le>0?(0,K.jsxs)(`span`,{className:`inline-flex items-baseline`,children:[(0,K.jsx)(rb,{price:fe}),!!de&&(0,K.jsxs)(`span`,{className:`text-base font-normal text-muted-foreground`,children:[`/mo`,de>1&&(0,K.jsx)(`sup`,{children:`*`})]})]}):(0,K.jsx)(`span`,{className:`text-4xl text-green`,children:`Free`})})]}),!!de&&de>1&&le>0&&(0,K.jsxs)(`p`,{className:`mt-4 text-sm leading-relaxed text-muted-foreground`,children:[`* Billed as `,new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(le),` `,`every`,` `,oe(de,`month`,`months`),`, or sooner if you reach a usage limit — then a new license is issued.`]}),(0,K.jsx)(`div`,{className:`mt-5 border-t border-primary/15 pt-5`,children:(0,K.jsx)(ol,{variant:`warning`,children:`Beta pricing subject to change.`})})]}):null;return(0,K.jsxs)(`div`,{className:`space-y-7 py-5`,children:[(0,K.jsxs)(`header`,{className:`flex items-start gap-4`,children:[(0,K.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-2xl border border-primary/20 bg-primary/10 text-primary`,children:(0,K.jsx)(ss,{className:`size-6`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:a===`version`?`Cluster upgrade`:t?`Manage your cluster`:`Your infrastructure`}),(0,K.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight sm:text-3xl`,children:E?`Cluster Billing`:`Cluster Configuration`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:E?`Review your billing details before applying these changes.`:a===`version`?`Keep your cluster up to date with the right Harper version.`:`Configure your Harper cluster and define deployment plans.`})]})]}),(0,K.jsx)(Od,{...j,children:E?(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:ye?`grid items-start gap-6 xl:grid-cols-[minmax(0,1fr)_18rem]`:``,children:[ye,(0,K.jsxs)(Er,{className:`min-w-0 xl:order-1`,children:[(0,K.jsx)(Dr,{children:(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,K.jsx)(na,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Payment review`]})}),(0,K.jsx)(Ar,{children:(0,K.jsx)(oy,{clusterId:t,isPending:x||C,onGoBackToDetails:ve,onSaveStateForBillingRedirect:_e,onSubmit:he,organizationId:s,selectedPlan:ce,submitError:T})})]})]})}):(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:j.handleSubmit(ge),children:(0,K.jsx)($y,{priceSummary:ye,calculatedNames:se,clusterId:t,deploymentToPerformanceToPlan:r,form:j,isPending:x||C,harperVersions:i,mode:a,partialUpgrade:c,regionLocations:ae,regionNameToLatencyToRegion:ie,selectedDeployment:P,selectedPerformance:F,selectedPlan:ce,submitError:T,totalPrice:le,isEnterprise:_,cloudProvider:v})})})})]})}function ob(e){return e?.clusterName!==void 0}function sb(e,t){let n=Yg(t),r=[...n].sort(yr).pop(),i=new Set(n),a=e.filter(e=>e.scoped?e.version!==r:!i.has(e.version)&&(!r||vr(r,e.version)));return r?[{name:`current`,version:r},...a]:a}function cb({isEdit:e,className:t,children:n}){return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:t,children:n})})]}):(0,K.jsx)(i_,{className:t,children:n})}function lb(){let{organizationId:e,clusterId:t,mode:n}=z({strict:!1}),{create:r,update:i}=mg(e),{organization:a,cluster:o}=ye({strict:!1}),[s,c]=Zc(_r.SavedClusterState,null),{data:l}=L(__(e)),{data:u}=L(r_({availableHosts:!0,organizationId:e})),{data:d}=L(r_({organizationId:e})),{data:f}=L(S_(e)),p=(0,G.useMemo)(()=>o?.instances&&f?{...f,value:sb(f.value??[],o.instances)}:f,[f,o]),m=(0,G.useMemo)(()=>Xg(o?.instances??[],(f?.value??[]).filter(e=>e.scoped).map(e=>e.version)),[o,f]),h=(0,G.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!of(e.status)&&!af(e.status)&&e.plans)for(let t of e.plans){let e=l.find(e=>e.id===t.planId);if(e?.priceUsd===0&&!e.id.startsWith(`self-hosted`))return!0}return!1},[o?.id,a?.clusters,l]),g=(0,G.useMemo)(()=>k_(l?.sort(C_(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),_=(0,G.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(ob(s))return{...s,clusterName:s.clusterName||``,abbreviatedName:s.abbreviatedName||``,version:s.version,deploymentDescription:s.deploymentDescription||``,performanceDescription:s.performanceDescription||``,fqdn:s.fqdn||``,regionPlans:s.regionPlans||[],instances:s.instances||[]};e=s}let r=l?.find(e=>e.id===o?.plans?.[0].planId),i=[],a=[],c=r?.deploymentDescription===`Dedicated`?d:u,f=tb(l,c,h),g=!1;if(e){if(e.plans){for(let t of e.plans)if(t.regionId){let e=c.find(e=>e.id===t.regionId);e&&i.push({regionName:e.region,latencyDescription:e.latencyDescription})}}if(!i.length&&e.instances){let t=e.instances.filter(e=>e.status&&!Pd.includes(e.status)).sort(E_);for(let e of t)g=!0,a.push({fqdn:e.instanceFqdn,port:e.operationsApiPort,secure:e.operationsApiSecure?`true`:`false`})}}else f&&i.push(...f.regionPlans);!g&&!i.length&&i.push({regionName:``,latencyDescription:``});let _=m?.ambiguous&&n===`version`?void 0:p.value?.find(e=>e.name===`current`)?.version??p.value?.find(e=>e.name===`stable`)?.version;return{sourceClusterId:e?.id,autoRenew:e?.plans?.[0]?.autoRenew??!0,clusterName:e?.name??``,abbreviatedName:e?.abbreviatedName??``,version:_,deploymentDescription:r?.deploymentDescription??f?.deploymentDescription??``,performanceDescription:r?.performanceDescription??f?.performanceDescription??``,fqdn:g?e?.fqdn??``:``,instances:a,regionPlans:i}},[h,o,t,n,m,l,p,u,d,s]);return!_||!a||!l||!u||!d?(0,K.jsx)(cb,{isEdit:!!t,children:(0,K.jsx)(Lc,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,K.jsx)(cb,{isEdit:!!t,children:(0,K.jsx)(oc,{title:`Not Allowed`,error:{message:(0,K.jsxs)(K.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,K.jsx)(cb,{isEdit:!!t,children:(0,K.jsx)(oc,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,K.jsxs)(K.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,K.jsx)(Pf,{}),`.`]})}})}):(0,K.jsx)(cb,{isEdit:!!t,className:`w-full max-w-6xl mx-auto`,children:(0,K.jsx)(ab,{alreadyUsingFree:h,clusterId:t,defaultValues:_,deploymentToPerformanceToPlan:g,harperVersions:p,mode:n,organization:a,organizationId:e,partialUpgrade:m,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:c,startOffOnBilling:ob(s)&&s.skipToBilling===!0})})}function ub({children:e}){let{organizationId:t}=z({strict:!1}),{view:n}=fg(t),{update:r}=cg(t),i=`/${t}`,a=[{to:i,label:`Clusters`,icon:ss,exact:!0},n&&{to:`${i}/users`,label:`Users`,icon:Ws},n&&{to:`${i}/roles`,label:`Roles`,icon:ds},r&&{to:`${i}/billing`,label:`Billing`,icon:na,children:[{to:`${i}/billing`,label:`Payment Method`,exact:!0},{to:`${i}/billing/invoices`,label:`Invoices`}]},r&&{to:`${i}/settings`,label:`Settings`,icon:ls}].filter(Boolean);return(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`section-rail-aside md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(o_,{items:a,ariaLabel:`Organization sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}var db=[{category:`all`,label:`Total clusters`,Icon:Ka,color:`text-primary dark:text-violet-300 bg-primary/10`},{category:`running`,label:`Running`,Icon:Oi,color:`text-emerald-700 dark:text-green bg-green/10`},{category:`attention`,label:`Needs attention`,Icon:Rs,color:`text-amber-700 dark:text-yellow bg-yellow/10`},{category:`failed`,label:`Failures`,Icon:wi,color:`text-destructive bg-destructive/10`}];function fb(){let{organizationId:e}=z({strict:!1}),{create:t}=mg(e),{data:n}=we(Yc(e)),[r]=Zc(_r.SavedClusterState,null),[i,a]=(0,G.useState)(Zg),{data:o}=L({...r_({organizationId:e}),enabled:!1,staleTime:6e4}),s=(0,G.useMemo)(()=>new Map(o?.map(e=>[e.id,e.region])),[o]),c=(0,G.useMemo)(()=>$g(n?.clusters??[],s,n?.clusterSyncSummaries),[n?.clusters,s,n?.clusterSyncSummaries]),l=(0,G.useMemo)(()=>t_(c.items,i),[c.items,i]),u=!!i.search||i.category!==`all`||!!i.region;return n&&c.items.length===0&&t?(0,K.jsx)(lb,{}):r?(0,K.jsx)(qe,{to:`/${e}/new-cluster`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(`div`,{className:`pb-16`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-4 pb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-normal text-primary sm:text-3xl dark:text-violet-300`,children:`Clusters`}),t&&(0,K.jsx)(H,{variant:`positive`,asChild:!0,accessKey:`n`,className:`shrink-0`,children:(0,K.jsxs)(V,{to:`/${e}/new-cluster`,children:[(0,K.jsx)(Uo,{"aria-hidden":`true`}),` New Cluster`]})})]}),(0,K.jsx)(`div`,{className:`mb-3 hidden grid-cols-2 gap-3 sm:grid lg:grid-cols-4`,role:`group`,"aria-label":`Cluster summary`,children:db.map(({category:e,label:t,Icon:n,color:r})=>(0,K.jsxs)(`button`,{type:`button`,"aria-label":`${t} ${e===`all`?c.items.length:c.counts[e]}`,"aria-pressed":i.category===e,onClick:()=>a({...i,category:e}),className:`flex items-center gap-3 rounded-xl border bg-card/30 p-4 text-left transition-colors hover:border-primary/60 focus-visible:outline-2 focus-visible:outline-ring ${i.category===e?`border-primary/60`:`border-border`}`,children:[(0,K.jsx)(`span`,{className:`rounded-full p-2.5 ${r}`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t}),(0,K.jsx)(`span`,{className:`mt-1 block text-2xl font-semibold tabular-nums`,children:e===`all`?c.items.length:c.counts[e]})]})]},e))}),(0,K.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`Reported lifecycle status. Running does not confirm monitoring health.`}),(0,K.jsxs)(`div`,{className:`cluster-list-controls mb-3 flex flex-wrap gap-3`,role:`search`,"aria-label":`Find clusters`,children:[(0,K.jsxs)(`div`,{className:`relative min-w-48 basis-full sm:basis-auto flex-1`,children:[(0,K.jsx)(rs,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)($,{"aria-label":`Search clusters`,placeholder:`Search name, hostname, or region…`,className:`h-10 pl-9`,value:i.search,onChange:e=>a({...i,search:e.target.value})})]}),(0,K.jsx)(`label`,{className:`sr-only`,htmlFor:`cluster-status`,children:`Cluster status`}),(0,K.jsxs)(`select`,{id:`cluster-status`,className:`h-10 rounded-md border border-input bg-card px-3 text-sm`,value:i.category,onChange:e=>a({...i,category:e.target.value}),children:[(0,K.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,K.jsx)(`option`,{value:`running`,children:`Running`}),(0,K.jsx)(`option`,{value:`attention`,children:`Needs attention`}),(0,K.jsx)(`option`,{value:`failed`,children:`Failures`}),(0,K.jsx)(`option`,{value:`other`,children:`Other / unknown`})]}),(0,K.jsx)(`label`,{className:`sr-only`,htmlFor:`cluster-region`,children:`Cluster region`}),(0,K.jsxs)(`select`,{id:`cluster-region`,className:`h-10 max-w-full rounded-md border border-input bg-card px-3 text-sm`,value:i.region,onChange:e=>a({...i,region:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:`All regions`}),i.region&&!c.regions.includes(i.region)&&(0,K.jsx)(`option`,{value:i.region,children:i.region}),c.regions.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsx)(`label`,{className:`sr-only`,htmlFor:`cluster-sort`,children:`Sort clusters`}),(0,K.jsxs)(`select`,{id:`cluster-sort`,className:`h-10 rounded-md border border-input bg-card px-3 text-sm`,value:i.sort,onChange:e=>a({...i,sort:e.target.value}),children:[(0,K.jsx)(`option`,{value:`attention`,children:`Sort: Attention first`}),(0,K.jsx)(`option`,{value:`name`,children:`Sort: Name`}),(0,K.jsx)(`option`,{value:`newest`,children:`Sort: Newest`})]})]}),(0,K.jsxs)(`div`,{className:`mb-4 flex min-h-8 items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`p`,{role:`status`,children:[`Showing `,l.length,` of `,c.items.length,` clusters`]}),u&&(0,K.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>a({...Zg,sort:i.sort}),children:`Clear filters`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2 2xl:grid-cols-3`,children:l.map(e=>(0,K.jsx)(Jg,{item:e},e.cluster.id))}),!l.length&&(0,K.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border px-6 py-12 text-center`,children:[(0,K.jsx)(Ka,{className:`mx-auto mb-3 size-8 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`h2`,{className:`text-lg font-medium`,children:c.items.length?`No matching clusters`:`No clusters yet`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:c.items.length?`Try a different search or clear your filters.`:`Ask an organization administrator to create a cluster.`}),u&&(0,K.jsx)(H,{className:`mt-4`,variant:`outline`,onClick:()=>a({...Zg,sort:i.sort}),children:`Reset filters`})]})]})})]})}function pb(){return`/#`+Au()}function mb(){let{organizationId:e}=z({strict:!1}),t=De(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=Oe({strict:!1}),[i]=Zc(_r.SavedClusterState,null),a=n||r,o=Dv(),s=U_(e),c=(0,G.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,pb()),t({search:void 0,to:e})},[t,i]);return(0,G.useEffect)(()=>{o&&a&&s&&e&&c&&(async function(){try{let{setupIntent:e}=await o.retrieveSetupIntent(a);switch(e?.status){case`succeeded`:e.payment_method===null?(U.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:U.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:U.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:U.error(`Failed to process payment method details. Please try another payment method.`),c()}}catch(e){console.error(e),U.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,K.jsx)(Lc,{centered:!0})}function hb(){return(0,K.jsx)($v,{children:(0,K.jsx)(mb,{})})}function gb(){let{organizationId:e}=z({strict:!1}),{update:t}=cg(e);return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsx)(st,{})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`You don't have access to manage payments for this organization. Please contact your administrator.`})}var _b=500,vb=16,yb=16;function bb({className:e,containerClassName:t,containerRef:n,...r}){return(0,K.jsx)(`div`,{ref:n,"data-slot":`table-container`,className:F(`relative w-full overflow-x-auto`,t),children:(0,K.jsx)(`table`,{"data-slot":`table`,className:F(`w-full caption-bottom text-sm`,e),...r})})}function xb({className:e,...t}){return(0,K.jsx)(`thead`,{"data-slot":`table-header`,className:F(`[&_tr]:border-b`,e),...t})}function Sb({className:e,...t}){return(0,K.jsx)(`tbody`,{"data-slot":`table-body`,className:F(`[&_tr:last-child]:border-0`,e),...t})}function Cb({className:e,...t}){return(0,K.jsx)(`tr`,{"data-slot":`table-row`,className:F(`border-b border-grey-700 transition-colors`,e),...t})}function wb({className:e,...t}){return(0,K.jsx)(`th`,{"data-slot":`table-head`,className:F(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Tb({header:e,onColumnClick:t,className:n,...r}){let i=(0,G.useCallback)(()=>{let n=e.column.getIsSorted()!==`asc`;e.column.toggleSorting(!n),t?.(e.column.columnDef.accessorKey,n)},[e,t]),a=e.column.columnDef.enableSorting,o=e.getContext().table.options.enableColumnResizing===!0&&e.column.getCanResize(),s=e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext()),c=e.getContext().table,l=e.getSize(),u=e.column.columnDef.minSize??c.options.defaultColumn?.minSize??20,d=(0,G.useCallback)(t=>{let n=t.currentTarget.closest(`table`);if(!n){e.column.resetSize();return}let r=`[data-col-id="${CSS.escape(e.column.id)}"]`,i=document.createRange(),a=e=>(i.selectNodeContents(e),i.getBoundingClientRect().width),o=0;n.querySelectorAll(`tbody ${r}`).forEach(e=>{o=Math.max(o,a(e))});let s=n.querySelector(`thead ${r} > div`),l=s?.querySelector(`.truncate`);if(s&&l){let e=Array.from(s.children).reduce((e,t)=>e+t.getBoundingClientRect().width,0)-l.getBoundingClientRect().width;o=Math.max(o,a(l)+e+yb)}let d=Math.min(Math.max(Math.ceil(o)+vb,u),_b);c.setColumnSizing(t=>({...t,[e.column.id]:d}))},[e,c,u]),f=e.column.getIsResizing()?Math.max(c.store.state.columnResizing.deltaOffset??0,u-l):0;return(0,K.jsxs)(wb,{...r,"data-col-id":e.column.id,style:{width:`${l}px`,maxWidth:`${l}px`},className:F(`relative`,o&&`select-none`,a?`px-0`:`px-2`,n),children:[(0,K.jsx)(`div`,{className:F(`flex items-center min-w-0 overflow-hidden`,o&&`pr-4`),children:a?(0,K.jsxs)(H,{type:`button`,variant:`ghost`,className:F(`rounded-none min-w-0`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:i,children:[(0,K.jsx)(`span`,{className:`truncate`,children:s}),e.column.getIsSorted()===`asc`?(0,K.jsx)(Xr,{className:`shrink-0`}):e.column.getIsSorted()===`desc`?(0,K.jsx)(Br,{className:`shrink-0`}):(0,K.jsx)(Kr,{className:`shrink-0 text-gray-600`})]}):(0,K.jsx)(`span`,{className:`truncate`,children:s})}),o&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`absolute top-0 right-0 z-10 flex h-full w-4 cursor-col-resize items-center justify-center text-muted-foreground hover:text-foreground`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onDoubleClick:d,style:{transform:e.column.getIsResizing()?`translateX(${f}px)`:``},children:(0,K.jsx)(Pa,{className:`size-3.5`})})]})}function Eb({className:e,...t}){return(0,K.jsx)(`td`,{"data-slot":`table-cell`,className:F(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}var Db=[20,50,100,250];function Ob({pageIndex:e,pageSize:t,totalPages:n,totalRecords:r,uncountedPage:i,isEstimatedCount:a,estimatedRange:o,isExactCountFetching:s,isExactCountError:c,onRequestExactCount:l,setPageIndex:u,setPageSize:d}){let f=e+1,p=n===void 0||r===void 0,m=i?i.rowCount===void 0:p,h=!!i?.hasNextPage,g=i?f+ +!!h:n&&n>0?n:1,_=!i||kb(e,t,i)!==void 0,v=e>0,y=!m&&f<g,b=e=>{u(Math.max(0,Math.min(e,g)-1))},x=e=>{d(e),u(0)},S=[...Fb(f,g),...h?[`ellipsis`]:[]];return(0,K.jsx)(`div`,{className:`@container shrink-0 border-t border-border`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 whitespace-nowrap text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{className:`hidden @min-[400px]:inline`,children:[`Page `,By(f),m?` of …`:_?` of ${By(g)}`:null]}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`hidden text-border @min-[400px]:inline`,children:`•`}),(0,K.jsx)(`span`,{children:i?m?(0,K.jsx)(my,{}):(0,K.jsx)(Ab,{pageIndex:e,pageSize:t,page:i}):p?(0,K.jsx)(my,{}):a?(0,K.jsx)(jb,{totalRecords:r,estimatedRange:o,isExactCountFetching:s,isExactCountError:c,onRequestExactCount:l}):(0,K.jsxs)(K.Fragment,{children:[By(r),` `,r===1?`record`:`records`]})})]}),(0,K.jsx)(`div`,{className:`grow`}),(0,K.jsxs)(`nav`,{className:`flex items-center divide-x divide-border overflow-hidden rounded-lg border border-border`,children:[(0,K.jsxs)(Mb,{onClick:()=>b(f-1),disabled:!v,"aria-label":`Previous page`,children:[(0,K.jsx)(bi,{}),(0,K.jsx)(`span`,{className:`hidden @min-[480px]:inline`,children:`Previous`})]}),(0,K.jsx)(`div`,{className:`hidden divide-x divide-border @min-[620px]:flex`,children:S.map((e,t)=>e===`ellipsis`?(0,K.jsx)(`span`,{className:`flex h-9 min-w-9 items-center justify-center px-1 text-sm text-muted-foreground`,children:`…`},`ellipsis-${t}`):(0,K.jsx)(Mb,{onClick:()=>b(e),isActive:e===f,"aria-label":`Page ${e}`,"aria-current":e===f?`page`:void 0,children:By(e)},e))}),(0,K.jsxs)(Mb,{onClick:()=>b(f+1),disabled:!y,"aria-label":`Next page`,children:[(0,K.jsx)(`span`,{className:`hidden @min-[480px]:inline`,children:`Next`}),(0,K.jsx)(Si,{})]})]}),(0,K.jsx)(`div`,{className:`hidden grow @min-[840px]:block`}),(0,K.jsx)(Pb,{pageSize:t,onChange:x}),(0,K.jsx)(Nb,{pageCount:g,disabled:m||g<=1,onGo:b})]})})}function kb(e,t,n){if(!(n.rowCount===void 0||n.hasNextPage||n.rowCount===0&&e>0))return e*t+n.rowCount}function Ab({pageIndex:e,pageSize:t,page:n}){let r=kb(e,t,n);return r===void 0?n.hasNextPage?(0,K.jsxs)(K.Fragment,{children:[`More than `,By(e*t+(n.rowCount??0)),` matching records`]}):(0,K.jsx)(K.Fragment,{children:`No matching records on this page`}):(0,K.jsxs)(K.Fragment,{children:[By(r),` matching `,r===1?`record`:`records`]})}function jb({totalRecords:e,estimatedRange:t,isExactCountFetching:n,isExactCountError:r,onRequestExactCount:i}){let a=e===1?`record`:`records`,o=r&&!n;return(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`cursor-help underline decoration-dotted underline-offset-4`,"aria-label":`Approximately ${By(e)} ${a} (estimated)`,children:[`~`,By(e),` `,a]})}),(0,K.jsxs)(Xl,{side:`top`,align:`start`,className:`flex max-w-60 flex-col gap-2 p-3 text-left`,children:[(0,K.jsxs)(`span`,{children:[`Estimated count.`,t?(0,K.jsxs)(K.Fragment,{children:[` `,`Likely between `,By(t[0]),` and `,By(t[1]),`.`]}):null]}),o&&(0,K.jsx)(`span`,{className:`font-medium`,children:`Couldn’t get the exact count.`}),(0,K.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:`inline-flex items-center justify-center gap-1.5 self-start rounded border
|
|
12
|
+
border-primary-foreground/30 bg-primary-foreground/10 px-2 py-1 font-medium transition-colors
|
|
13
|
+
hover:bg-primary-foreground/20 disabled:pointer-events-none disabled:opacity-60`,children:[n&&(0,K.jsx)(no,{className:`size-3 animate-spin`}),n?`Counting…`:o?`Try again`:`Get exact count`]})]})]})}function Mb({isActive:e,className:t,...n}){return(0,K.jsx)(`button`,{type:`button`,className:F(`flex h-9 min-w-9 items-center justify-center gap-1 px-3 text-sm whitespace-nowrap
|
|
14
|
+
transition-colors hover:bg-accent hover:text-foreground
|
|
15
|
+
disabled:pointer-events-none disabled:opacity-40
|
|
16
|
+
[&_svg]:size-4 [&_svg]:shrink-0`,e&&`bg-muted font-semibold text-foreground`,t),...n})}function Nb({pageCount:e,disabled:t,onGo:n}){let[r,i]=(0,G.useState)(``);return(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=Number(r);Number.isFinite(a)&&a>=1&&n(Math.min(a,e)),i(``)},className:`hidden items-center gap-2 @min-[840px]:flex`,children:[(0,K.jsx)(`label`,{htmlFor:`pagination-go-to`,className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Go to`}),(0,K.jsx)(`input`,{id:`pagination-go-to`,type:`number`,min:1,max:e,inputMode:`numeric`,placeholder:`Page`,disabled:t,value:r,onChange:e=>i(e.target.value),className:`h-9 w-20 rounded-md border border-input bg-white px-3 text-sm text-foreground
|
|
17
|
+
placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-purple focus-visible:outline-none
|
|
18
|
+
disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function Pb({pageSize:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,K.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,K.jsxs)(hy,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,K.jsx)(vy,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,K.jsx)(_y,{})}),(0,K.jsx)(yy,{side:`top`,children:Db.map(e=>(0,K.jsx)(xy,{value:String(e),children:By(e)},e))})]})]})}function Fb(e,t,n=1){if(t<=n*2+5)return Ib(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,o=i<t-1,s=3+2*n;return!a&&o?[...Ib(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...Ib(t-s+1,t)]:[1,`ellipsis`,...Ib(r,i),`ellipsis`,t]}function Ib(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}var Lb=We({columnSizingFeature:$e,columnResizingFeature:Ye,columnVisibilityFeature:Ue,columnFilteringFeature:Ge,globalFilteringFeature:Ve,rowPaginationFeature:at,rowSelectionFeature:Je,rowSortingFeature:nt,sortedRowModel:Ke(),sortFns:Be}),Rb={filteredRowModel:Qe(),paginatedRowModel:Re()},zb={...Lb,...Rb};function Bb(){return Le()}var Vb=Db[0];function Hb({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,filter:o,paginated:s,children:c}){let[l,u]=(0,G.useState)(()=>a??[]),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)({pageIndex:0,pageSize:Vb}),h=()=>m(e=>({...e,pageIndex:0})),g=tt({features:zb,data:t,columns:e,manualFiltering:!o,manualPagination:!s,autoResetPageIndex:!1,state:{sorting:l,globalFilter:d,pagination:p},onSortingChange:e=>{u(e),h()},onGlobalFilterChange:e=>{f(e),h()},onPaginationChange:m}),_=g.getPrePaginatedRowModel().rows.length,v=s&&_>Vb,y=Math.max(g.getPageCount()-1,0);return(0,G.useLayoutEffect)(()=>{p.pageIndex>y&&m(e=>({...e,pageIndex:y}))},[p.pageIndex,y]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[o&&(0,K.jsxs)(`div`,{className:`relative mr-auto w-full max-w-xs`,children:[(0,K.jsx)(rs,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)($,{type:`search`,"aria-label":o.label,placeholder:o.placeholder??o.label,className:`pl-9`,value:d,onChange:e=>g.setGlobalFilter(e.target.value)})]}),(0,K.jsx)(`div`,{className:`grow lg:hidden`}),c,(0,K.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,K.jsxs)(bb,{containerClassName:`rounded-md border border-border dark:border-grey-700 bg-card dark:bg-black-dark`,children:[(0,K.jsx)(xb,{children:g.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(Tb,{header:e,onColumnClick:i},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:g.getRowModel().rows?.length?g.getRowModel().rows.map(e=>(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:F(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:ot(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,K.jsx)(`div`,{children:(0,K.jsx)(Lc,{className:`p-12`})}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),v&&(0,K.jsx)(Ob,{pageIndex:p.pageIndex,pageSize:p.pageSize,totalPages:g.getPageCount(),totalRecords:_,setPageIndex:g.setPageIndex,setPageSize:g.setPageSize})]})}function Ub(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Wb(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}var Gb=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,K.jsx)(ol,{variant:Ub(e.getValue()),children:e.getValue()})},{header:`Date`,accessorKey:`periodStart`,enableSorting:!1,cell:({cell:e})=>{let t=e.row.original.periodStart*1e3,n=e.row.original.periodEnd*1e3,r=(Date.now()-t)/1e3,i=(Date.now()-n)/1e3;return Math.abs(r-i)<1e3?Bm(r,t):[t?Bm(r,t):`-`,n?Bm(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Wb(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Wb(e.getValue()?e.getValue()/100:0)},{header:`Lines`,accessorKey:`lines`,enableSorting:!1,cell:({cell:e})=>{let t=e.getValue(),n=[];for(let e of t)n.push(`${e.quantity}x ${e.description} @ ${Wb(e.amount/100)}`);return n.join(`
|
|
19
|
+
`)}}];function Kb(e){return(0,G.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await h(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function qb(e){let{data:t}=await P.get(`/Invoice/${e}`);return t}function Jb(e,t){return B({queryKey:[e,`invoices`],queryFn:()=>qb(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Yb(){let{organizationId:e}=z({strict:!1}),{data:t}=L(Yc(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(Jb(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Kb(r);return t?.type===`ENTERPRISE`?(0,K.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,K.jsx)(Pf,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Lc,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(Pf,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Hb,{data:n,columns:Gb,children:(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Xb(e){let t=R({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:gb}),n=R({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:ay}),r=R({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:Yb}),i=R({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:hb});return t.addChildren([n,r,i])}function Zb({error:e,reset:t}){switch(jr(e)){case 403:return(0,K.jsx)(oc,{error:e,title:`No Access to This Organization`,description:`This organization doesn't exist, or your account isn't a member of it. To join it, ask one of its administrators to invite you.`});case 404:return(0,K.jsx)(oc,{error:e,title:`Organization Not Found`,description:`No organization has this ID. Check that the link is complete and correct.`});default:return(0,K.jsx)(oc,{error:e,reset:t})}}async function Qb(e){let{data:t}=await P.get(`/OrganizationRole/${e}`);return t}function $b(e){return B({queryKey:[e,`roles`],queryFn:()=>Qb(e),retry:!1,refetchInterval:Gc(1e4)})}function ex(e){return e.userIds?.length??0}var tx=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!0},{header:`ID`,accessorKey:`id`,enableSorting:!0,enableGlobalFilter:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})},{header:`Users Assigned`,id:`userIds`,accessorFn:ex,enableSorting:!0,enableGlobalFilter:!1,cell:e=>ex(e.row.original)||`No users assigned`}],nx=new Set([`checkbox`,`radio`,`file`,`submit`,`button`,`image`,`reset`]);function rx(e){return t=>{let n=t.target;if(t.key!==`Enter`||t.nativeEvent.isComposing||!(n instanceof HTMLInputElement)||nx.has(n.type)||!n.name)return;let r=n.name,i=e.getValues(r);i!==void 0&&e.setValue(r,i,{shouldTouch:!0,shouldValidate:!0})}}async function ix(e){let{data:t}=await P.post(`/Role/`,e);return t}function ax(){return I({mutationFn:ix})}var ox=b({name:x().nonempty({error:`Please enter a role name.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role name cannot be longer than 30 characters.`}),update:A(),delete:A()}).pick({name:!0});b({roles:b({create:A(),delete:A(),update:A(),view:A()}),clusters:b({create:A(),delete:A(),update:A(),view:A(),resources:D(b({id:x(),delete:A(),update:A(),view:A(),instances:b({create:A(),delete:A(),update:A(),view:A()})}))})});function sx({className:e,...t}){return(0,K.jsx)(sn,{"data-slot":`tabs`,className:F(`flex flex-col gap-2`,e),...t})}function cx({className:e,...t}){return(0,K.jsx)(Kt,{"data-slot":`tabs-list`,className:F(`text-muted-foreground inline-flex w-fit items-center justify-center rounded-full bg-muted dark:bg-gray-950 p-1`,e),...t})}function lx({className:e,...t}){return(0,K.jsx)(yt,{"data-slot":`tabs-trigger`,className:F(`data-[state=active]:text-foreground data-[state=active]:bg-card dark:data-[state=active]:bg-gray-600 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:outline-1 text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 border rounded-full border-transparent px-2 py-1 font-medium whitespace-nowrap transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function ux({className:e,...t}){return(0,K.jsx)(Yn,{"data-slot":`tabs-content`,className:F(`flex-1 outline-none`,e),...t})}var dx=b({create:A(),view:A(),update:A(),delete:A()}),fx=b({id:x().min(1),view:A(),update:A(),delete:A(),instances:dx}),px=N({update:A(),delete:A(),roles:N(dx.shape),clusters:N({...dx.shape,resources:D(N(fx.shape))})}),mx={create:!0,view:!0,update:!0,delete:!0},hx={update:!1,delete:!1,roles:mx,clusters:{...mx,resources:[]}},gx=e=>({create:e?.create===!0,view:e?.view===!0,update:e?.update===!0,delete:e?.delete===!0});function _x({organization:e}){return{update:e.update===!0,delete:e.delete===!0,roles:gx(e.roles),clusters:{...gx(e.clusters),resources:(e.clusters?.resources??[]).map(e=>({id:e.id,view:e.view===!0,update:e.update===!0,delete:e.delete===!0,instances:gx(e.instances)}))}}}function vx(e,t,n){return{name:e,organizationId:t,...n}}function yx(e){return JSON.stringify(e,null,2)}function bx(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`This isn’t valid JSON.`}}let n=px.safeParse(t);if(!n.success){let e=n.error.issues[0];return{ok:!1,error:`${e.path.length?e.path.join(`.`):`the permissions`}: ${e.message}`}}return{ok:!0,permissions:n.data}}var xx=(e,t)=>({create:e,view:t.view,update:t.update,delete:t.delete});function Sx({clusters:e}){if(e.resources.length===0)return{scope:`all`};let[t]=e.resources,n=e.resources.every(n=>n.view===t.view&&n.update===t.update&&n.delete===t.delete&&n.instances.create===e.create&&n.instances.view===n.view&&n.instances.update===n.update&&n.instances.delete===n.delete),r=!e.view&&!e.update&&!e.delete;return n&&r?{scope:`selected`,clusterIds:e.resources.map(e=>e.id)}:{scope:`custom`}}function Cx(e,t){let{clusters:n}=e;if(t.scope===`selected`&&n.resources.length>0){let[e]=n.resources;return{create:n.create,view:e.view,update:e.update,delete:e.delete}}return{create:n.create,view:n.view,update:n.update,delete:n.delete}}function wx(e,t,n){if(n.scope===`all`)return{...e,clusters:{...t,resources:[]}};let r={view:t.view,update:t.update,delete:t.delete};return{...e,clusters:{create:t.create,view:!1,update:!1,delete:!1,resources:n.clusterIds.map(e=>({id:e,...r,instances:xx(t.create,r)}))}}}function Tx(){let[e]=tl(),t=Qc();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var Ex=(0,G.lazy)(async()=>(await pe(()=>import(`./setup-wNdpTrVH.js`),__vite__mapDeps([14,2,1,15,16,17,18,19,20])),{default:(await pe(()=>import(`./dist-9lpzt2Hn.js`).then(e=>e.t),__vite__mapDeps([15,1,2]))).default}));function Dx(e){return(0,K.jsx)(G.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(Ex,{...e})})}var Ox=[`view`,`create`,`update`,`delete`],kx={view:`View`,create:`Create`,update:`Update`,delete:`Delete`};function Ax({checked:e,disabled:t,onChange:n,label:r,id:i,describedBy:a}){return(0,K.jsx)(`input`,{id:i,type:`checkbox`,"aria-label":r,"aria-describedby":a,className:`size-4 shrink-0 accent-primary dark:accent-violet-300 disabled:opacity-60`,checked:e,disabled:t,onChange:e=>n(e.target.checked)})}function jx({label:e,description:t,checked:n,disabled:r,onChange:i}){let a=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`pt-0.5`,children:(0,K.jsx)(Ax,{id:a,describedBy:`${a}-description`,checked:n,disabled:r,onChange:i})}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`label`,{htmlFor:a,className:`text-foreground`,children:e}),(0,K.jsx)(`p`,{id:`${a}-description`,className:`text-xs text-muted-foreground`,children:t})]})]})}function Mx({value:e,onChange:t,clusters:n,disabled:r}){let[i,a]=(0,G.useState)(()=>Sx(e)),[o,s]=(0,G.useState)(()=>Cx(e,Sx(e))),c=i.scope===`custom`,l=r||c,u=i.scope===`selected`?i.clusterIds:[],d=n.filter(e=>!Pd.includes(e.status??``)||u.includes(e.id)),f=(n,r)=>{s(n),a(r),t(wx(e,n,r))};return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`section`,{"aria-labelledby":`role-organization-heading`,children:[(0,K.jsx)(`h3`,{id:`role-organization-heading`,className:`mb-3 font-medium text-foreground`,children:`Organization`}),(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,K.jsx)(jx,{label:`Update organization`,description:`Change the organization’s settings and billing.`,checked:e.update,disabled:r,onChange:n=>t({...e,update:n})}),(0,K.jsx)(jx,{label:`Delete organization`,description:`Permanently delete the organization.`,checked:e.delete,disabled:r,onChange:n=>t({...e,delete:n})})]})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`role-resources-heading`,children:[(0,K.jsx)(`h3`,{id:`role-resources-heading`,className:`mb-3 font-medium text-foreground`,children:`Resource permissions`}),(0,K.jsxs)(bb,{containerClassName:`rounded-md border border-border dark:border-grey-700 bg-card dark:bg-black-dark`,children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-none`,children:[(0,K.jsx)(wb,{className:`w-1/3 px-2`,children:`Resource`}),Ox.map(e=>(0,K.jsx)(wb,{className:`px-2 text-center`,children:kx[e]},e))]})}),(0,K.jsxs)(Sb,{className:`bg-background dark:bg-black`,children:[(0,K.jsxs)(Cb,{className:`border-border dark:border-grey-700`,children:[(0,K.jsx)(Eb,{className:`px-2 py-2.5 font-medium`,children:`Roles`}),Ox.map(n=>(0,K.jsx)(Eb,{className:`px-2 py-2.5 text-center`,children:(0,K.jsx)(Ax,{label:`Roles: ${kx[n]}`,checked:e.roles[n],disabled:r,onChange:r=>t({...e,roles:{...e.roles,[n]:r}})})},n))]}),(0,K.jsxs)(Cb,{className:`border-border dark:border-grey-700`,children:[(0,K.jsx)(Eb,{className:`px-2 py-2.5 font-medium`,children:`Clusters`}),Ox.map(e=>(0,K.jsx)(Eb,{className:`px-2 py-2.5 text-center`,children:(0,K.jsx)(Ax,{label:`Clusters: ${kx[e]}`,checked:o[e],disabled:l,onChange:t=>f({...o,[e]:t},i)})},e))]})]})]}),(0,K.jsxs)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:[(0,K.jsx)(`li`,{children:`Role permissions also control membership: Create allows adding members and inviting people; Delete allows removing members.`}),(0,K.jsx)(`li`,{children:`Cluster Update also allows running operations.`})]})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`role-cluster-access-heading`,className:`space-y-2`,children:[(0,K.jsx)(`h3`,{id:`role-cluster-access-heading`,className:`font-medium text-foreground`,children:`Cluster access`}),c?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This role sets permissions cluster by cluster in a way this form can’t show. Edit them in Advanced JSON.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`max-w-xs`,children:(0,K.jsxs)(hy,{value:i.scope,disabled:r,onValueChange:e=>f(o,e===`selected`?{scope:`selected`,clusterIds:[]}:{scope:`all`}),children:[(0,K.jsx)(vy,{className:`w-full`,"aria-labelledby":`role-cluster-access-heading`,children:(0,K.jsx)(_y,{})}),(0,K.jsxs)(yy,{children:[(0,K.jsx)(xy,{value:`all`,children:`All clusters`}),(0,K.jsx)(xy,{value:`selected`,children:`Selected clusters`})]})]})}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.scope===`selected`?`View, Update and Delete apply only to the clusters chosen here. Create always applies to the whole organization.`:`The Clusters permissions apply to every cluster in the organization.`}),i.scope===`selected`&&(d.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This organization has no clusters yet.`}):(0,K.jsx)(`ul`,{className:`grid gap-2 pt-1 sm:grid-cols-2`,children:d.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Ax,{checked:u.includes(e.id),disabled:r,onChange:t=>f(o,{scope:`selected`,clusterIds:t?[...u,e.id]:u.filter(t=>t!==e.id)})}),e.name??e.id,Pd.includes(e.status??``)&&(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`(deleted)`})]})},e.id))}))]})]})]})}function Nx({value:e,onChange:t,clusters:n,disabled:r=!1,onValidChange:i}){let a=Tx(),[o,s]=(0,G.useState)(`form`),[c,l]=(0,G.useState)(()=>yx(e)),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(0),m=(0,G.useRef)(null),[h,g]=(0,G.useState)();return(0,K.jsxs)(sx,{value:o,onValueChange:t=>{t===`json`?(g(m.current?.offsetHeight),l(yx(e)),d(null),s(`json`)):u||(p(e=>e+1),s(`form`))},children:[(0,K.jsxs)(cx,{className:`p-0.5 text-sm dark:bg-gray-800`,children:[(0,K.jsx)(lx,{value:`form`,className:`px-3 py-0.5`,children:`Permissions`}),(0,K.jsx)(lx,{value:`json`,className:`px-3 py-0.5`,children:`Advanced JSON`})]}),(0,K.jsx)(ux,{value:`form`,ref:m,className:`pt-2`,children:(0,K.jsx)(Mx,{value:e,onChange:t,clusters:n,disabled:r},f)}),(0,K.jsxs)(ux,{value:`json`,style:{height:h},className:`flex min-h-80 flex-none flex-col pt-2`,children:[(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-lg border`,children:(0,K.jsx)(Dx,{className:`h-full w-full`,theme:a,defaultLanguage:`json`,value:c,onChange:e=>{let n=e??``;l(n);let r=bx(n);d(r.ok?null:r.error),i?.(r.ok),r.ok&&t(r.permissions)},options:{readOnly:r,automaticLayout:!0,minimap:{enabled:!1}}})}),u&&(0,K.jsxs)(`p`,{role:`alert`,className:`mt-2 text-sm text-red-500`,children:[u,` Fix it to save or to go back to Permissions.`]})]})]})}function Px({isModalOpen:e,setIsModalOpen:t}){let n=Ze(),{organizationId:r}=z({strict:!1}),{data:i}=L(Yc(r)),[a,o]=(0,G.useState)(hx),[s,c]=(0,G.useState)(!0),{mutate:l,isPending:u}=ax(),d=on({resolver:mt(ox),mode:`onTouched`,defaultValues:{name:``}}),f=()=>{t(!1),d.reset(),o(hx),c(!0)},p=({name:e})=>l(vx(e,r,a),{onSuccess:()=>{U.success(`Role "${e}" created.`),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),f()},onError:e=>{pc(e)&&U.error(`Failed to create the role: ${e.message}`)}});return(0,K.jsx)(_m,{onOpenChange:e=>!e&&f(),open:e,children:(0,K.jsxs)(wm,{className:`max-h-[90vh] overflow-y-auto focus:outline-none sm:max-w-[760px]`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus()},children:[(0,K.jsx)(Dm,{children:`Create role`}),(0,K.jsx)(Om,{children:`Choose what this role can access.`}),(0,K.jsx)(Od,{...d,children:(0,K.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-col gap-4 my-2`,onSubmit:d.handleSubmit(p),onKeyDown:rx(d),children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. deployment_operator`,maxLength:ox.shape.name.maxLength,...e}),(0,K.jsx)(ky,{children:`Letters and underscores, up to 30 characters.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Nx,{value:a,onChange:o,onValidChange:c,clusters:i?.clusters??[]}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`outline`,type:`button`,onClick:f,disabled:u,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,disabled:u||!s||!d.formState.isValid,children:u?`Creating…`:`Create role`})]})})]})})]})})}async function Fx({roleId:e}){let{data:t}=await P.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function Ix(){return I({mutationFn:({roleId:e})=>Fx({roleId:e})})}async function Lx({roleId:e,updatedRoleInfo:t}){let{data:n}=await P.put(`/Role/${e}`,t);return n}function Rx(){return I({mutationFn:({roleId:e,updatedRoleInfo:t})=>Lx({roleId:e,updatedRoleInfo:t})})}function zx({organizationId:e,roleId:t}){return B({queryKey:[e,`roles`,t],queryFn:()=>Bx(t),refetchInterval:Gc(1e4),retry:Kc()})}async function Bx(e){let{data:t}=await P.get(`/Role/${e}`);return t}function Vx({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Confirm Role Deletion`}),(0,K.jsx)(Om,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(H,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Hx({data:e,isModalOpen:t,closeModal:n}){let r=(0,G.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(_m,{onOpenChange:r,open:t,children:(0,K.jsx)(wm,{className:`max-h-[90vh] overflow-y-auto sm:max-w-[760px]`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Ux,{roleName:e.roleName}),children:(0,K.jsx)(Wx,{data:e,closeModal:n})})})})}function Ux({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Dm,{children:[`Role "`,e,`"`]}),(0,K.jsx)(Lc,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Wx({data:e,closeModal:t}){let n=Ze(),{data:r}=we(zx({roleId:e.id,organizationId:e.organizationId})),{data:i}=L(Yc(e.organizationId)),a=Sr().user?.roles?.[e.organizationId]?.id===e.id,o=e.roleName===`admin`,{update:s,remove:c}=fg(e.organizationId),l=s&&!a&&!o,u=c&&!a&&!o,{mutate:d,isPending:f}=Rx(),{mutate:p,isPending:m}=Ix(),[h,g]=(0,G.useState)(!1),[_]=(0,G.useState)(()=>_x(r)),[v,y]=(0,G.useState)(_),[b,x]=(0,G.useState)(!0),S=JSON.stringify(v)!==JSON.stringify(_),C=(0,G.useCallback)(()=>{p({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted.`),t(!0)},onError:e=>{pc(e)&&U.error(`Failed to delete the role: ${e instanceof Error?e.message:String(e)}`)}})},[e.id,p,t]);return h?(0,K.jsx)(Vx,{onRoleDeleteClick:C,setIsConfirmingRoleDeletion:g,isRoleDeletionPending:m}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Dm,{children:[l?`Edit role`:`Role`,` "`,e.roleName,`"`]}),(0,K.jsx)(Om,{children:o?`The admin role is built in and can’t be edited.`:a?`This is your role. Another member who can update roles can change it.`:l?`Members and service accounts with this role get these permissions from their next request.`:`What members and service accounts with this role can do.`}),(0,K.jsx)(`div`,{className:`my-2`,children:(0,K.jsx)(Nx,{value:v,onChange:y,onValidChange:x,clusters:i?.clusters??[],disabled:!l})}),(l||u)&&(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[u?(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:()=>{x(!0),g(!0)},disabled:f,children:`Delete role`}):(0,K.jsx)(`span`,{}),l&&(0,K.jsx)(H,{variant:`submit`,type:`button`,onClick:()=>d({roleId:e.id,updatedRoleInfo:vx(e.roleName,e.organizationId,v)},{onSuccess:async()=>{U.success(`Role updated. It applies to each member’s next request.`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1)},onError:e=>{pc(e)&&U.error(`Failed to update the role: ${e instanceof Error?e.message:String(e)}`)}}),disabled:f||!S||!b,children:f?`Saving…`:`Save changes`})]})})]})}function Gx(){let e=De(),t=Ze(),{organizationId:n,orgRoleId:r}=z({strict:!1}),{create:i}=fg(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=we($b(n)),l=(0,G.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,G.useCallback)(()=>{f(!0)},[f]),h=(0,G.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,G.useCallback)(e=>p(void 0,e),[p]),_=Kb(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(ub,{children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light`,children:`Roles`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage access to this organization and its clusters.`})]}),(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:a,columns:tx,onRowClick:h,filter:{label:`Filter roles`,placeholder:`Filter by role name`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(Px,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(Hx,{data:l,isModalOpen:u,closeModal:g},l.id)]})]})]})}function Kx({className:e,...t}){return(0,K.jsx)(Gn,{"data-slot":`switch`,className:F(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(Zn,{"data-slot":`switch-thumb`,className:F(`bg-white dark:data-[state=unchecked]:bg-white dark:data-[state=checked]:bg-white pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}async function qx({tokenId:e}){let{data:t}=await P.delete(`/ApiToken/${encodeURIComponent(e)}`);return t}function Jx(e){let t=Ze();return I({mutationFn:qx,onSuccess:(n,{tokenId:r})=>{t.setQueriesData({queryKey:[e,`apiTokens`]},e=>e?.filter(e=>e.id!==r)),t.invalidateQueries({queryKey:[e,`apiTokens`],refetchType:`active`}),t.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})}})}function Yx({token:e}){let[t,n]=(0,G.useState)(!1),{mutate:r,isPending:i}=Jx(e.organizationId),a=(0,G.useRef)(!1);return(0,K.jsx)(km,{typeOfThingBeingDeleted:`API token`,nameOfThingBeingDeleted:e.name,isModalOpen:t,setIsModalOpen:n,deletionConfirmed:()=>{a.current||(a.current=!0,r({tokenId:e.id},{onSuccess:()=>{U.success(`API token "${e.name}" revoked.`),n(!1)},onSettled:()=>{a.current=!1}}))},deletionPending:i,hideDataLossWarning:!0,transitiveVerb:`Revoke`,presentParticiple:`Revoking`,trigger:(0,K.jsxs)(H,{variant:`destructiveGhost`,size:`sm`,className:`text-destructive/75 hover:text-destructive focus-visible:text-destructive`,"aria-label":`Revoke ${e.name}`,children:[(0,K.jsx)(ei,{}),` Revoke`]})})}var Xx=6e4,Zx=60*Xx,Qx=24*Zx;function $x(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function eS(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`long`})}function tS(e,t=Date.now()){let n=new Date(e).getTime()-t,r=Math.abs(n),[i,a]=r<Zx?[n/Xx,`minute`]:r<Qx?[n/Zx,`hour`]:[n/Qx,`day`],o=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(i),a);return o.charAt(0).toUpperCase()+o.slice(1)}function nS({value:e,format:t,className:n}){return(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`time`,{dateTime:e,tabIndex:0,className:F(`rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,n),children:t===`date`?$x(e):tS(e)})}),(0,K.jsx)(Xl,{children:eS(e)})]})}async function rS(e){let{data:t}=await P.post(`/ApiToken/`,e);return t}function iS(){return I({mutationFn:rS,gcTime:0})}var aS=30,oS=90,sS=b({name:x().trim().nonempty({error:`Please enter a name.`}).max(100,{error:`Name cannot be longer than 100 characters.`}),expiresInDays:C({error:`Enter a whole number of days.`}).int({error:`Enter a whole number of days.`}).min(1,{error:`Must be at least 1 day.`}).max(oS,{error:`Must be at most ${oS} days.`})});function cS({organizationId:e,serviceAccountId:t,onClose:n}){let r=Ze(),i=Kg(),{mutateAsync:a,isPending:o,reset:s}=iS(),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(!1),d=(0,G.useRef)(!1),f=(0,G.useRef)(!1),p=(0,G.useRef)(null);(0,G.useEffect)(()=>(u.current=!0,()=>{u.current=!1,p.current&&_(p.current)}),[]),(0,G.useEffect)(()=>{c&&(p.current=null,d.current=!1,s())},[c,s]);let m=on({resolver:mt(sS),mode:`onTouched`,defaultValues:{name:``,expiresInDays:aS}}),{isValid:h}=m.formState,g=()=>Promise.all([r.invalidateQueries({queryKey:[e,`apiTokens`],refetchType:`active`}),r.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})]),_=async e=>{try{await qx({tokenId:e.id}),U.warning(`An API token created after its dialog closed was revoked.`)}catch(e){console.error(`Failed to revoke an API token that was never shown`,e),U.error(`An API token created after its dialog closed could not be revoked. Revoke it from its service account’s API Tokens.`)}g()},v=async e=>{if(d.current||f.current||!u.current)return;d.current=!0;let n;try{n=await a({serviceAccountId:t,...e})}catch{d.current=!1;return}if(f.current=!0,!u.current){_(n);return}p.current=n,l(n),g()},y=()=>{d.current||n()};return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>{e||y()},children:(0,K.jsx)(wm,{className:`sm:max-w-[600px]`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Copy your API token`}),(0,K.jsxs)(Om,{children:[`It won't be shown again. Expires `,new Date(c.expiresAt).toLocaleString(),`.`]}),(0,K.jsxs)(`div`,{className:`my-4 flex items-center gap-2`,children:[(0,K.jsx)($,{readOnly:!0,"aria-label":`API token`,value:c.token,className:`font-mono text-xs`,onClick:()=>i(c.token)}),(0,K.jsx)(H,{type:`button`,size:`icon`,variant:`ghost`,className:`shrink-0`,"aria-label":`Copy token`,onClick:()=>i(c.token),children:(0,K.jsx)(ea,{})})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Send it as a bearer token:`,` `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`Authorization: Bearer <token>`}),`. It acts as this service account, with its role, on this organization's clusters and their instances.`]}),(0,K.jsx)(Em,{children:(0,K.jsx)(H,{type:`button`,variant:`submit`,onClick:n,children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Create API Token`}),(0,K.jsx)(Om,{children:`For CI pipelines and scripts. The token acts as this service account, with its role.`}),(0,K.jsx)(Od,{...m,children:(0,K.jsxs)(`form`,{id:`create-api-token-form`,name:`create-api-token-form`,className:`flex flex-col gap-4 my-4`,onSubmit:m.handleSubmit(v),onKeyDown:rx(m),children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. github-actions-deploy`,maxLength:sS.shape.name.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`expiresInDays`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Expires in (days)`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`number`,min:1,max:oS,step:1,name:e.name,ref:e.ref,onBlur:e.onBlur,value:Number.isFinite(e.value)?e.value:``,onChange:t=>e.onChange(t.target.valueAsNumber)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:y,disabled:o,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:o||!h,children:o?`Creating…`:`Create Token`})]})})]})})]})})})}function lS(e){return B({queryKey:[e,`serviceAccounts`],queryFn:async()=>{let{data:t}=await P.get(`/ServiceAccount/`,{params:{organizationId:e}});return t},retry:!1})}function uS(e,t){return B({queryKey:[e,`apiTokens`,t],queryFn:async()=>{let{data:n}=await P.get(`/ApiToken/`,{params:{organizationId:e,serviceAccountId:t}});return n},retry:!1})}var dS=6048e5;function fS({token:e,now:t}){let n=new Date(e.expiresAt).getTime()-t;return n<=0?(0,K.jsxs)(`span`,{className:`text-red-500`,children:[`Expired `,(0,K.jsx)(nS,{value:e.expiresAt,format:`relative`,className:`lowercase`})]}):(0,K.jsx)(nS,{value:e.expiresAt,format:`relative`,className:F(n<dS&&`text-amber-600`)})}function pS({token:e}){return e.createdByUserId?e.createdByEmail?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`span`,{tabIndex:0,className:`rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,children:e.createdByEmail})}),(0,K.jsx)(Xl,{children:e.createdByUserId})]}):(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.createdByUserId}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}function mS({organizationId:e,account:t,regionId:n}){let[r,i]=(0,G.useState)(!1),{data:a,isLoading:o,isError:s}=L(uS(e,t.id)),c=t.status===`ACTIVE`,l=Date.now();return(0,K.jsxs)(`section`,{id:n,"aria-label":`API tokens of ${t.name}`,className:`mt-4 rounded-lg border border-primary/30 bg-primary/5 dark:border-white/15 dark:bg-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b px-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h4`,{className:`font-medium text-foreground truncate`,children:t.name}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`API tokens`})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,size:`sm`,onClick:()=>i(!0),disabled:!c,children:[(0,K.jsx)(Uo,{}),`Create token`]})]}),!t.roleName&&(0,K.jsx)(`p`,{className:`px-4 pt-3 text-sm text-red-500`,children:`Its role was deleted; change it from the account’s menu, or its tokens are refused.`}),!c&&(0,K.jsx)(`p`,{className:`px-4 pt-3 text-sm text-muted-foreground`,children:`While the account is disabled its tokens are refused; enabling it restores those not revoked or expired.`}),(0,K.jsx)(`div`,{className:`px-4 pb-2`,children:o?(0,K.jsx)(Lc,{className:`py-6`}):s&&!a?(0,K.jsx)(`p`,{className:`py-4 text-sm text-red-500`,children:`Couldn’t load this account’s tokens.`}):a?.length?(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(wb,{children:`Name`}),(0,K.jsx)(wb,{children:`Created by`}),(0,K.jsx)(wb,{children:`Created`}),(0,K.jsx)(wb,{children:`Expires`}),(0,K.jsx)(wb,{children:`Last used`}),(0,K.jsx)(wb,{children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,K.jsx)(Sb,{children:a.map(e=>(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(Eb,{className:`py-2.5 font-medium`,children:e.name}),(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsx)(pS,{token:e})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(nS,{value:e.createdAt,format:`date`})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(fS,{token:e,now:l})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:e.lastUsedAt?(0,K.jsx)(nS,{value:e.lastUsedAt,format:`relative`}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Not used yet`})}),(0,K.jsx)(Eb,{className:`py-2.5 text-right`,children:(0,K.jsx)(Yx,{token:e})})]},e.id))})]}):(0,K.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tokens yet.`})}),r&&(0,K.jsx)(cS,{organizationId:e,serviceAccountId:t.id,onClose:()=>i(!1)})]})}function hS({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}async function gS(e){let{data:t}=await P.post(`/ServiceAccount/`,e);return t}async function _S({id:e,...t}){let{data:n}=await P.patch(`/ServiceAccount/${encodeURIComponent(e)}`,t);return n}async function vS({id:e}){let{data:t}=await P.delete(`/ServiceAccount/${encodeURIComponent(e)}`);return t}function yS(e){let t=Ze();return I({mutationFn:gS,onSuccess:n=>{t.setQueryData([e,`serviceAccounts`],e=>e&&[...e.filter(e=>e.id!==n.id),n]),t.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})}})}function bS(e){let t=Ze();return I({mutationFn:_S,onSuccess:n=>{t.setQueryData([e,`serviceAccounts`],e=>e?.map(e=>e.id===n.id?n:e)),t.invalidateQueries({queryKey:[e,`serviceAccounts`],exact:!0})}})}function xS(e){let t=Ze();return I({mutationFn:vS,onSuccess:(n,{id:r})=>{t.setQueryData([e,`serviceAccounts`],e=>e?.filter(e=>e.id!==r)),t.invalidateQueries({queryKey:[e,`serviceAccounts`],exact:!0})}})}function SS({organizationId:e,account:t,onClose:n}){let{data:r}=L($b(e)),{mutate:i,isPending:a}=bS(e),[o,s]=(0,G.useState)(t.roleName?t.roleId:``),c=!!t.roleName&&o===t.roleId;return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>!e&&!a&&n(),children:(0,K.jsxs)(wm,{className:`sm:max-w-[480px]`,children:[(0,K.jsx)(Dm,{children:`Change role`}),(0,K.jsxs)(Om,{children:[t.name,`'s tokens act with this role from their next request.`]}),(0,K.jsxs)(hy,{value:o,onValueChange:s,disabled:a,children:[(0,K.jsx)(vy,{className:`w-full`,"aria-label":`Role`,children:(0,K.jsx)(_y,{placeholder:`Choose a role`})}),(0,K.jsx)(yy,{children:r?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))})]}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:n,disabled:a,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`button`,onClick:()=>i({id:t.id,roleId:o},{onSuccess:()=>{U.success(`Role changed. It applies to the account’s next request.`),n()}}),disabled:!o||c||a,children:a?`Saving…`:`Save`})]})]})})}var CS=b({name:x().trim().nonempty({error:`Please enter a name.`}).max(100,{error:`Name cannot be longer than 100 characters.`}),roleId:x().nonempty({error:`Please choose a role.`})});function wS({organizationId:e,onClose:t,onCreated:n}){let{mutate:r,isPending:i}=yS(e),a=(0,G.useRef)(!1),o=(0,G.useRef)(!1);(0,G.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let{data:s,isLoading:c}=L($b(e)),l=on({resolver:mt(CS),mode:`onTouched`,defaultValues:{name:``,roleId:``}}),{isValid:u}=l.formState,d=t=>{!o.current&&a.current&&(o.current=!0,r({organizationId:e,...t},{onSuccess:e=>{U.success(`Service account "${e.name}" created.`),n(e)},onError:()=>{o.current=!1}}))},f=()=>{o.current||t()};return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>!e&&f(),children:(0,K.jsxs)(wm,{className:`sm:max-w-[600px]`,children:[(0,K.jsx)(Dm,{children:`Create Service Account`}),(0,K.jsx)(Om,{children:`A non-human member of this organization for CI pipelines and scripts. It acts with the role you give it.`}),(0,K.jsx)(Od,{...l,children:(0,K.jsxs)(`form`,{id:`create-service-account-form`,name:`create-service-account-form`,className:`flex flex-col gap-4 my-4`,onSubmit:l.handleSubmit(d),onKeyDown:rx(l),children:[(0,K.jsx)(Y,{control:l.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. github-actions`,maxLength:CS.shape.name.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:l.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role`}),c?(0,K.jsx)(my,{}):(0,K.jsxs)(hy,{value:e.value,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(J,{children:(0,K.jsx)(vy,{className:`w-full`,"aria-label":`Role`,children:(0,K.jsx)(_y,{placeholder:`Choose a role`})})}),(0,K.jsx)(yy,{children:s?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:f,disabled:i,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:i||!u,children:i?`Creating…`:`Create Service Account`})]})})]})})]})})}function TS({status:e}){let t=e===`ACTIVE`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:F(`size-2 rounded-full`,t?`bg-green`:`bg-amber-600`)}),(0,K.jsx)(`span`,{className:F(!t&&`text-amber-600`),children:t?`Enabled`:`Disabled`})]})}function ES({organizationId:e,account:t,onDeleted:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),{mutate:s,isPending:c}=bS(e),{mutate:l,isPending:u}=xS(e),d=(0,G.useRef)(!1),f=t.status===`ACTIVE`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Options for ${t.name}`,children:(0,K.jsx)(ua,{})})}),(0,K.jsxs)(vc,{align:`end`,className:`min-w-40`,children:[(0,K.jsxs)(yc,{onClick:()=>o(!0),children:[(0,K.jsx)(ds,{}),`Change role…`]}),(0,K.jsxs)(yc,{onClick:()=>s({id:t.id,status:f?`DISABLED`:`ACTIVE`},{onSuccess:()=>U.success(f?`Service account disabled.`:`Service account enabled.`)}),disabled:c,children:[f?(0,K.jsx)(ei,{}):(0,K.jsx)(Ei,{}),f?`Disable`:`Enable`]}),(0,K.jsxs)(yc,{variant:`destructive`,onClick:()=>i(!0),children:[(0,K.jsx)(Is,{}),`Delete`]})]})]}),a&&(0,K.jsx)(SS,{organizationId:e,account:t,onClose:()=>o(!1)}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`service account`,nameOfThingBeingDeleted:t.name,isModalOpen:r,setIsModalOpen:i,deletionConfirmed:()=>{d.current||(d.current=!0,l({id:t.id},{onError:()=>{d.current=!1},onSuccess:()=>{U.success(`Service account "${t.name}" deleted; its tokens no longer work.`),i(!1),n()}}))},deletionPending:u,hideDataLossWarning:!0})]})}function DS({organizationId:e}){let t=(0,G.useId)(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(null),{data:o,isLoading:s,isError:c,refetch:l,isFetching:u}=L(lS(e)),d=Kb(l),f=o?.find(e=>e.id===i),p=e=>a(t=>t===e.id?null:e.id);return(0,K.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 mb-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-foreground`,children:`Service accounts`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Identities for CI pipelines and scripts, each acting with one of this organization’s roles.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mr-[17px]`,children:[(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,"aria-label":`Refresh service accounts`,onClick:d,disabled:u,children:(0,K.jsx)(Go,{})})}),(0,K.jsx)(Xl,{children:`Refresh`})]}),(0,K.jsxs)(H,{variant:`positive`,size:`sm`,onClick:()=>r(!0),disabled:n,children:[(0,K.jsx)(Uo,{}),`Create service account`]})]})]}),s?(0,K.jsx)(Lc,{className:`py-6`}):c&&!o?(0,K.jsx)(`p`,{className:`py-4 text-sm text-red-500`,children:`Couldn’t load service accounts.`}):o?.length?(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(wb,{children:`Name`}),(0,K.jsx)(wb,{children:`Role`}),(0,K.jsx)(wb,{children:`Status`}),(0,K.jsx)(wb,{children:`Active tokens`}),(0,K.jsx)(wb,{children:`Created`}),(0,K.jsx)(wb,{children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,K.jsx)(Sb,{children:o.map(n=>{let r=n.id===i;return(0,K.jsxs)(Cb,{"data-state":r?`selected`:void 0,onClick:()=>p(n),className:`cursor-pointer border-border hover:bg-muted/40 data-[state=selected]:bg-primary/10 dark:data-[state=selected]:bg-white/10`,children:[(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":r?t:void 0,onClick:e=>{e.stopPropagation(),p(n)},className:`group flex flex-col items-start text-left rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground group-hover:underline group-focus-visible:underline`,children:n.name}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:n.id})]})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:n.roleName??(0,K.jsx)(`span`,{className:`text-red-500`,children:`Role deleted`})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsx)(TS,{status:n.status})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:n.activeTokens}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(nS,{value:n.createdAt,format:`date`})}),(0,K.jsx)(Eb,{className:`py-2.5 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(ES,{organizationId:e,account:n,onDeleted:()=>a(e=>e===n.id?null:e)})})]},n.id)})})]}):(0,K.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No service accounts yet.`}),f&&(0,K.jsx)(mS,{organizationId:e,account:f,regionId:t}),n&&(0,K.jsx)(wS,{organizationId:e,onClose:()=>r(!1),onCreated:e=>{r(!1),a(e.id)}})]})}async function OS(e,t){let{data:n}=await P.patch(`/Organization/${e}/settings/apiTokens`,{enabled:t});return n}function kS({organizationId:e,enabled:t}){let n=Ze(),{mutate:r,isPending:i}=I({mutationFn:t=>OS(e,t),onSuccess:({apiTokensEnabled:t})=>{U.success(t?`API tokens are allowed.`:`API tokens are now refused.`),n.setQueryData([e],e=>e&&{...e,settings:{...e.settings,apiTokensEnabled:t}}),n.invalidateQueries({queryKey:[e]})}});return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-b px-4 py-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`allow-api-tokens`,className:`font-medium text-foreground`,children:`Allow API tokens`}),(0,K.jsx)(`p`,{id:`allow-api-tokens-help`,className:`text-sm text-muted-foreground`,children:`Service account tokens work only while this is on.`})]}),(0,K.jsx)(Kx,{id:`allow-api-tokens`,"aria-describedby":`allow-api-tokens-help`,checked:t,disabled:i,onCheckedChange:r})]})}function AS({title:e,actions:t,children:n,bodyClassName:r}){let i=(0,G.useId)();return(0,K.jsxs)(`section`,{"aria-labelledby":i,className:`rounded-lg border bg-card text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3`,children:[(0,K.jsx)(`h3`,{id:i,className:`text-lg font-medium`,children:e}),t]}),(0,K.jsx)(`div`,{className:F(`p-4`,r),children:n})]})}function jS({organizationId:e,apiTokensEnabled:t}){return dg(e)?(0,K.jsxs)(AS,{title:`API access`,bodyClassName:`p-0`,children:[(0,K.jsx)(kS,{organizationId:e,enabled:t}),(0,K.jsx)(DS,{organizationId:e})]}):null}async function MS(e,t){let{data:n}=await P.patch(`/Organization/${e}/settings/oauth`,t);return n}var NS=`openid email profile`,PS=b({domain:x().min(1,`Domain is required`),clientId:x().min(1,`Client ID is required`),clientSecret:x().min(1,`Client secret is required`),scope:x().optional()}),FS=b({domain:x().min(1,`Domain is required`),clientId:x().optional(),clientSecret:x().optional(),scope:x().optional()});function IS(){let{organizationId:e}=z({strict:!1}),{user:t}=Sr(),{update:n}=cg(e),{data:r}=we(Yc(e)),i=Ze(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=I({mutationFn:t=>MS(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:e=>{pc(e)&&U.error(`Failed to update OAuth settings.`)}}),f=on({resolver:mt(PS),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:NS}}),p=e=>{u({provider:`okta`,...e,scope:e.scope?.trim()||NS},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=on({resolver:mt(FS)}),h=e=>{c(e.id??null),m.reset({domain:e.domain,clientId:``,clientSecret:``,scope:e.scope??``})},g=(e,t)=>{let n={id:e.id,provider:e.provider,domain:t.domain,scope:t.scope?.trim()||NS};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await Ug(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await Ug(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(`div`,{className:`max-w-5xl space-y-6 pb-12`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light`,children:`Authentication`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage sign-in methods and API access for your organization.`})]}),(0,K.jsxs)(AS,{title:`OAuth providers`,actions:!a&&(0,K.jsxs)(H,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Uo,{}),`Add OAuth provider`]}),children:[l.length===0&&!a&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-4 text-center`,children:[(0,K.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-full bg-muted`,children:(0,K.jsx)(Qa,{"aria-hidden":!0,className:`size-5 text-muted-foreground`})}),(0,K.jsx)(`p`,{className:`font-medium`,children:`No OAuth providers configured`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add your organization’s Okta so members can sign in with single sign-on.`})]}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Ks,{className:`size-4`})})]}),(0,K.jsx)(Od,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`e.g. company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:NS,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(ea,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Tp(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Tp(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Tp(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(ea,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Tp(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(fa,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Kx,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Kx,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Xl,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(H,{variant:`outline`,size:`sm`,"aria-label":`Edit provider`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(zo,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Ks,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Od,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`e.g. company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:NS,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]}),(0,K.jsx)(jS,{organizationId:e,apiTokensEnabled:r.settings?.apiTokensEnabled===!0})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x().nonempty({error:`Please select a role.`})});async function LS(e){let{data:t}=await P.post(`/UserInvite/`,e);return t}function RS(){return I({mutationFn:e=>LS(e)})}function zS({user:e}){let{update:t}=fg(),{mutate:n,isPending:r}=RS(),i=e.roles?.[0]?.id,a=(0,G.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(_o,{}),` Resend invite`]}):null}var BS=[{header:`User Id`,accessorKey:`id`,enableSorting:!0,enableGlobalFilter:!1},{header:`Email`,accessorKey:`email`,enableSorting:!0},{header:`First Name`,accessorKey:`firstname`,enableSorting:!0},{header:`Last Name`,accessorKey:`lastname`,enableSorting:!0},{header:`Roles`,id:`roles`,accessorFn:e=>(e.roles??[]).map(e=>e.roleName).sort().join(`, `),enableSorting:!0},{header:`Status`,accessorKey:`status`,enableSorting:!0},{header:`Verified`,accessorKey:`isVerified`,enableSorting:!0},Bb().display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(zS,{user:e.row.original}):null})],VS=b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x().nonempty({error:`Please select a role.`})});async function HS(e){let{data:t}=await P.post(`/OrganizationRole/`,e);return t}function US(){return I({mutationFn:e=>HS(e)})}function WS({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=z({strict:!1}),{data:i,isLoading:a}=L({...$b(r),throwOnError:!0}),[o,s]=(0,G.useState)(!1),c=on({resolver:mt(VS),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=US(),{mutate:d,isPending:f}=RS(),p=(0,G.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(_m,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(my,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Role`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(by,{children:`Role`}),i?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(Om,{className:`p-3 my-5 rounded-md border border-amber-600 dark:border-amber-500 bg-amber-500/10 text-foreground flex`,children:[(0,K.jsx)(ho,{className:`inline-block size-12 pr-2 text-amber-700 dark:text-amber-400`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)($o,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function GS({roleId:e,userId:t}){let{data:n}=await P.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function KS(){return I({mutationFn:({roleId:e,userId:t})=>GS({roleId:e,userId:t})})}function qS(e){let[t,n]=(0,G.useState)(e||!1);return[t,(0,G.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function JS({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=US(),{mutate:c,isPending:l}=KS(),u=!!i[r.id],[d,f]=(0,G.useState)(u),[p,m]=qS(u);return(0,G.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(Md,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function YS({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,G.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?uo:Bs;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(H,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(H,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(H,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function XS(e){return e?.trim().toLowerCase()===`admin`}function ZS({canDelete:e,isSelf:t,orgUserCount:n,adminCount:r,isAdmin:i,roleCount:a}){let o=e?t&&n<=1?`sole-member`:t&&i&&r<=1?`last-admin`:null:null,s=e&&o===null;return{canRemoveRoles:s,showRemovalAction:s&&a>0,blockedReason:o}}function QS({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=z({strict:!1}),s=Sr(),{update:c,remove:l}=fg(o),u=s.user?.email===t.email,[d,f]=(0,G.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=ZS({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>XS(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=KS(),[_,v]=(0,G.useState)(!1),y=(0,G.useCallback)(async()=>{let e=t.roles??[];v(!0);let n=(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).flatMap(e=>e.status===`rejected`&&e.reason?.response?.status!==404?[e.reason]:[]);n.some(pc)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):n.length===0&&U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(_m,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.jsxs)(Om,{children:[`Use the checkboxes to change which roles `,u?`you have`:`this user has`,`.`,m&&(u?` To leave the organization entirely, use the button below.`:` To remove this user from the organization entirely, use the button below.`)]}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Lc,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)($S,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(zS,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(YS,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function $S({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=we($b(t)),o=(0,G.useMemo)(()=>e.roles?O_(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(JS,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function eC(e,t){return e.email>t.email?1:-1}function tC(e){return(e.users??[]).filter(e=>e!=null)}function nC(e){let t={};for(let n of e)for(let e of tC(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(eC)}function rC(e){let t=new Set;for(let n of e)if(XS(n.roleName))for(let e of tC(n))t.add(e.id);return t.size}function iC(){let e=De(),{organizationId:t,orgUserId:n}=z({strict:!1}),{update:r}=fg(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=we($b(t)),c=(0,G.useMemo)(()=>nC(i),[i]),l=(0,G.useMemo)(()=>rC(i),[i]),u=(0,G.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,G.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,G.useState)(!1),[h]=(0,G.useState)({attribute:`email`,descending:!1}),g=(0,G.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,G.useCallback)(()=>{m(!0)},[m]),v=(0,G.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,G.useCallback)(e=>{d(e.original.id)},[d]),b=(0,G.useCallback)(()=>{d(void 0)},[d]),x=(0,G.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Kb(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:c,isFetching:o||s,columns:BS,onRowClick:y,sortingState:g,filter:{label:`Filter users`,placeholder:`Filter by email, name, role or status`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Uo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(WS,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(QS,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function aC({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:F(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function oC({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(Er,{className:`relative gap-0 py-0 h-full justify-between overflow-hidden border border-amber-500/30`,children:[(0,K.jsxs)(Dr,{className:`gap-4 py-5 border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`rounded-lg border border-primary/20 bg-background/50 p-2 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsx)(`span`,{className:`rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-xs`,children:`Sign-in required`})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`truncate text-xl`,title:t||e,children:t||e})}),t&&t!==e&&(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e,children:e})]}),(0,K.jsxs)(Ar,{className:`py-4 flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(Ha,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Tp(e.oauthConfigId),children:(0,K.jsxs)(H,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var sC=b({couponId:x().nonempty({message:`Please enter a coupon ID.`}).trim()});async function cC({organizationId:e,couponId:t}){let n=await P.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});if(n.status===400||n.status===409)return fc({response:n}).message}function lC(){return I({mutationFn:cC})}function uC({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=lC(),o=on({resolver:mt(sC),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,G.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,G.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(_m,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(wm,{children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add Coupon`}),(0,K.jsxs)(Om,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Od,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(H,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function dC({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,a=r||n,o={organizationId:n},s=qg(o),[c]=Gg(n),{remove:l,update:u}=cg(n),d=u,{view:f}=fg(n),p=wr(`billing:write`),[m,h]=(0,G.useState)(!1),g=(0,G.useCallback)(()=>{t(e)},[t,e]),_=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:s,icon:(0,K.jsx)(ss,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},f&&{key:`roles`,to:qg(o,`roles`),icon:(0,K.jsx)(ds,{className:`size-4 mr-2 text-purple`}),label:`Roles`},f&&{key:`users`,to:qg(o,`users`),icon:(0,K.jsx)(Ws,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},d&&{key:`billing`,to:qg(o,`billing`),icon:(0,K.jsx)(na,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},u&&{key:`settings`,to:qg(o,`settings`),icon:(0,K.jsx)(Ha,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},p&&{key:`add-coupon`,onClick:()=>h(!0),icon:(0,K.jsx)(Ps,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},l&&{type:`separator`,key:`sep-bottom`},l&&{key:`delete`,onClick:g,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(Is,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(fr),v=l||p;return(0,K.jsx)(zm,{items:v?_:[],children:(0,K.jsxs)(Er,{className:`group relative gap-0 py-0 h-full cursor-pointer justify-between overflow-hidden border border-primary/15 transition-[border-color,box-shadow] duration-200 hover:border-primary/60 hover:shadow-lg hover:ring-2 hover:ring-primary/40 dark:hover:ring-violet-400/60`,children:[(0,K.jsx)(V,{to:s,"aria-label":`Open ${a}`,className:`absolute inset-0 z-10 cursor-pointer rounded-[inherit] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:outline-none`}),(0,K.jsxs)(Dr,{className:`gap-4 py-5 border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(kr,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`rounded-lg border border-primary/20 bg-background/50 p-2 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-5`,"aria-hidden":`true`})}),v&&(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-20 inline-flex cursor-pointer shrink-0 items-center gap-1.5 rounded-md border border-primary/25 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground shadow-sm transition-colors hover:border-primary/60 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[`Options `,(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsx)(vc,{align:`end`,children:Rm(_,`dropdown`)})]})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`truncate text-xl`,title:a,children:a})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,children:[n!==a&&(0,K.jsx)(`span`,{className:`truncate`,title:n,children:n}),(0,K.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Copy ID for ${a}`,className:`relative z-20 shrink-0 cursor-pointer rounded p-1 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:(0,K.jsx)(ea,{className:`size-3.5`,"aria-hidden":`true`})})]})]}),(0,K.jsxs)(Ar,{className:`py-4 flex items-center justify-between gap-2`,children:[(0,K.jsx)(ol,{variant:`outline`,className:`min-w-0 shrink border-primary/25 bg-primary/10 text-foreground`,title:_d(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:_d(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`Open `,(0,K.jsx)(Wr,{className:`inline-block`})]})]}),(0,K.jsx)(uC,{organizationId:n,organizationName:r,isOpen:m,onClose:()=>h(!1)})]})})}function fC(e,t){let n=t.toLowerCase();return t=>{for(let r of e){let e=t[r];if(e!=null){if(typeof e==`string`){if(e.toLowerCase().includes(n))return!0}else if(typeof e==`boolean`){if(e&&(n===`yes`||n===`true`||n===`1`)||!e&&(n===`no`||n===`false`||n===`0`))return!0}else throw Error(`curryFilterByFuzzySearch has not implemented support for `+typeof e+` fields yet!`)}}return!1}}function pC(e){let t=e.filter(e=>e.locked).length;return{total:e.length,accessible:e.length-t,locked:t}}function mC(e,t,n,r,i){return e.filter(fC([`id`,`name`],t)).filter(e=>n===`all`||(n===`locked`?e.locked:!e.locked)).filter(e=>!r||!e.locked&&e.roleName===r).sort((e,t)=>(e.name.localeCompare(t.name)||e.id.localeCompare(t.id))*(i?-1:1))}async function hC(e){let{data:t}=await P.delete(`/Organization/${e}`);return t}function gC(){let e=Ze();return I({mutationFn:e=>hC(e),onSuccess:(t,n)=>{e.removeQueries({queryKey:[n]}),e.invalidateQueries({queryKey:[]})}})}async function _C(e){let{data:t}=await P.post(`/Organization/`,{...e});return t}function vC(){return I({mutationFn:e=>_C(e)})}var yC=x().max(62,{error:`Must be at most 62 characters long.`}).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{error:`Please only use lowercase letters, digits and dashes (-) in the subdomain. Must not start or end with a dash.`}),bC=b({name:x().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:te([O(``),w(),yC]).optional()});function xC(){let{user:e}=Sr(),t=De(),n=on({resolver:mt(bC),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,G.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,G.useMemo)(()=>{let e=L_(z_(o),yC.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=vC(),p=Ze(),h=(0,G.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:f,refetchType:`active`}),u.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,p,l,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid items-start gap-6 text-foreground lg:grid-cols-[1.2fr_1fr]`,children:[(0,K.jsxs)(Er,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,K.jsxs)(Dr,{className:`border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 py-5 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-primary dark:text-violet-300`,children:[(0,K.jsx)(fi,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:`Organization details`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose a name and an address for your organization.`})]}),(0,K.jsxs)(Ar,{className:`grid gap-6 py-6`,children:[(0,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,className:`bg-background/60`,maxLength:bC.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e}),(0,K.jsx)(ky,{children:`Use a name your team will recognize.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(cy,{type:`text`,className:`bg-background/60`,maxLength:yC.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e}),(0,K.jsx)(ky,{children:`Lowercase letters, numbers, and dashes. Leave blank to use the suggested subdomain.`}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`border-t border-border/60 bg-muted/20 px-6 py-5`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:d,className:`w-full sm:w-auto`,children:[d?`Creating organization…`:`Create organization`,` `,(0,K.jsx)(Wr,{"aria-hidden":`true`})]})})]}),(0,K.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-primary/15 bg-primary/5 p-6`,"aria-labelledby":`org-address-heading`,children:[(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary dark:text-violet-300`,children:(0,K.jsx)(ca,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsx)(`h2`,{id:`org-address-heading`,className:`text-base font-semibold`,children:`Your cluster addresses`})]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:`Your subdomain is part of the address for Harper-hosted clusters you create in this organization.`}),(0,K.jsxs)(`div`,{className:`my-5`,children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Address preview`}),(0,K.jsx)(sy,{hostname:c.fullHostName,testId:`org-hostname-preview`})]}),(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`The cluster name here is a placeholder. After creating your organization, you’ll name your first cluster!`}),(0,K.jsxs)(`div`,{className:`mt-5 border-t border-primary/15 pt-5`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Prefer your own domain?`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:`You can also bind a domain you own to a Harper-hosted cluster after creating it.`}),(0,K.jsxs)(`a`,{href:`https://docs.harperdb.io/fabric/custom-domains`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-3 inline-flex items-center gap-1.5 rounded-sm text-sm font-medium text-primary underline underline-offset-4 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring dark:text-violet-300`,children:[`Learn about custom domains`,(0,K.jsx)(fa,{className:`size-3.5`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]})]})]})]})})})}function SC(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(`section`,{className:`mx-auto mt-32 w-full max-w-6xl px-4 py-8 md:px-12 md:py-10`,children:[(0,K.jsxs)(`header`,{className:`mb-8 flex items-center gap-4`,children:[(0,K.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-2xl border border-primary/20 bg-primary/10 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-6`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-widest text-muted-foreground`,children:`Your workspace`}),(0,K.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Create an organization`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`A home for your team and clusters in Harper Fabric.`})]})]}),(0,K.jsx)(xC,{})]})]})}var CC={org:`organization`,clu:`cluster`,ins:`instance`},wC=/^(org|clu|ins)-[a-z0-9]+$/;function TC(e){if(typeof e!=`string`)return null;let t=e.trim(),n=wC.exec(t);return n?{kind:CC[n[1]],id:t}:null}function EC(e,t){let n=e*12,r=DC(t);return`/Admin/Organization/?${[...r?[`search=${encodeURIComponent(r)}`]:[],`status=ne=DELETED`,...r?[]:[`sort(name)`],`limit(${n},${n+12+1})`].join(`&`)}`}function DC(e){return typeof e==`string`?e.trim():``}async function OC(e,t){let{data:n}=await P.get(EC(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var kC={organizations:[],hasNextPage:!1};function AC(e){return e instanceof E&&(e.response?.status===404||e.status===404)}async function jC(e){try{let{data:t}=await P.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:kC}catch(e){if(AC(e))return kC;throw e}}async function MC(e){try{let{data:t}=await P.get(`/Cluster/${e}`),n=t?.organizationId;return n?await jC(n):kC}catch(e){if(AC(e))return kC;throw e}}function NC(e,t){let n=DC(t),r=TC(n);return B({queryKey:[`admin-all-organizations`,n,e],queryFn:()=>r?.kind===`organization`?jC(r.id):r?.kind===`cluster`?MC(r.id):OC(e,n),placeholderData:He,retry:!1})}function PC(e,t=300,n){let[r,i]=(0,G.useState)(e),a=n?n(e):e;return(0,G.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function FC(e,t){let n=(0,G.useRef)({key:e,defaultValue:t});(0,G.useInsertionEffect)(()=>{n.current={key:e,defaultValue:t}});let r=(0,G.useRef)(!0);(0,G.useLayoutEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let i=(0,G.useCallback)(t=>uu(e,n.current.defaultValue,t),[e]);return[(0,G.useSyncExternalStore)(i,()=>cu(e,t)),(0,G.useCallback)(e=>{r.current&&lu(n.current.key,n.current.defaultValue,e)},[])]}function IC(){let{data:e}=we(s()),{mutate:t,isPending:n}=gC(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`all`),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(!1),g=()=>{l(``),d(`all`),p(``),h(!1),x(0)},_=wr(`org:read`),[v,y]=FC(`ShowAllOrganizations`,!1),[b,x]=(0,G.useState)(0),S=_&&v,C=(0,G.useCallback)(e=>{y(e),x(0)},[y]),w=PC(c,300),T=(0,G.useMemo)(()=>{if(!_)return null;let e=TC(w);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[_,w]),E=S||!!T,{data:D,isPending:O,isError:k,isFetching:A,refetch:j}=L({...NC(b,w),enabled:E}),M=(0,G.useMemo)(()=>Nr(e),[e]),ee=(0,G.useMemo)(()=>pC(M),[M]),te=(0,G.useMemo)(()=>[...new Set(M.filter(e=>!e.locked).map(e=>e.roleName))].sort(),[M]),N=te.includes(f)?f:``,P=(0,G.useMemo)(()=>E?[]:mC(M,c,u,N,m),[M,c,u,N,m,E]),F=!!c||u!==`all`||!!N||m,ne=(0,G.useMemo)(()=>{let t=e?.roles||{};return(D?.organizations||[]).map(e=>({organizationId:e.id,organizationName:e.name||e.id,roleName:t[e.id]?.role||`fabric staff`}))},[D?.organizations,e?.roles]),re=(0,G.useCallback)(e=>{l(e.currentTarget.value||``),x(0)},[]),ie=(0,G.useCallback)(e=>{e?.organizationId&&t(e.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),i(!1)},onError:()=>i(!1)})},[t,i]),ae=(0,G.useCallback)(e=>{o(e),i(!0)},[]),{createCluster:oe}=Oe({strict:!1});return!E&&ee.accessible===1&&!F&&oe?(0,K.jsx)(qe,{to:`/${M.find(e=>!e.locked).id}/new-cluster`,replace:!0}):!E&&!M.length&&!F?(0,K.jsx)(SC,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-6 pb-10 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-4 pb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-normal text-primary sm:text-3xl dark:text-violet-300`,children:`Organizations`}),(0,K.jsx)(H,{asChild:!0,variant:`positive`,accessKey:`n`,children:(0,K.jsxs)(V,{to:`/new-org`,children:[(0,K.jsx)(Uo,{}),`New Organization`]})})]}),!E&&(0,K.jsx)(`div`,{role:`group`,"aria-label":`Organization summary`,className:`mb-5 hidden grid-cols-3 gap-3 sm:grid`,children:[{value:`all`,label:`Total organizations`,count:ee.total},{value:`accessible`,label:`Accessible`,count:ee.accessible},{value:`locked`,label:`Sign-in required`,count:ee.locked}].map(e=>(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":u===e.value,onClick:()=>{d(e.value),p(``)},className:`flex cursor-pointer items-center justify-between rounded-xl border px-4 py-3 text-sm transition-colors hover:border-primary/60 focus-visible:outline-2 focus-visible:outline-ring ${u===e.value?`border-primary/40 bg-primary/10`:`border-border bg-card/60`}`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,K.jsx)(`span`,{className:`text-xl font-semibold`,children:e.count})]},e.value))}),(0,K.jsxs)(`div`,{role:`search`,"aria-label":`Find organizations`,className:`mb-4 flex flex-wrap items-center gap-3 rounded-xl border border-border bg-card/60 p-3`,children:[(0,K.jsx)($,{"aria-label":`Search organizations`,placeholder:`Search name or ID…`,className:`min-w-0 flex-1 basis-56 dark:bg-background/60`,value:c,onChange:re}),!E&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{"aria-label":`Organization access`,value:u,onChange:e=>{d(e.target.value),p(``)},className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:`all`,children:`All access`}),(0,K.jsx)(`option`,{value:`accessible`,children:`Accessible`}),(0,K.jsx)(`option`,{value:`locked`,children:`Sign-in required`})]}),u!==`locked`&&(te.length>1||!!N)&&(0,K.jsxs)(`select`,{"aria-label":`Organization role`,value:N,onChange:e=>p(e.target.value),className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`All roles`}),te.map(e=>(0,K.jsx)(`option`,{value:e,children:_d(e)},e))]}),(0,K.jsxs)(`select`,{"aria-label":`Sort organizations`,value:m?`desc`:`asc`,onChange:e=>h(e.target.value===`desc`),className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:`asc`,children:`Name: A–Z`}),(0,K.jsx)(`option`,{value:`desc`,children:`Name: Z–A`})]})]}),_&&(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm`,children:[(0,K.jsx)(Kx,{checked:v,onCheckedChange:C,"aria-label":`Show all organizations`}),`All organizations`]})]}),(0,K.jsx)(`p`,{role:`status`,className:`mb-4 text-xs text-muted-foreground`,children:E?`Staff directory · Server search and pagination`:`Showing ${P.length} of ${ee.total} organizations`}),E&&k&&(0,K.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-xl border p-6`,children:[(0,K.jsx)(`p`,{children:D?`Organizations couldn’t be refreshed. Showing the last available results.`:`Organizations couldn’t be loaded.`}),(0,K.jsx)(H,{variant:`outline`,disabled:A,onClick:()=>void j(),children:A?`Retrying…`:`Retry`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:[E?O?Array.from({length:12},(e,t)=>(0,K.jsx)(aC,{className:`h-48`},t)):ne.map(e=>(0,K.jsx)(dC,{organizationRole:e,onDeleteOrgModal:ae},e.organizationId)):P.map(e=>e.locked?(0,K.jsx)(oC,{organizationId:e.id,organizationName:e.name,providers:e.providers},e.id):(0,K.jsx)(dC,{organizationRole:{organizationId:e.id,organizationName:e.name,roleName:e.roleName},onDeleteOrgModal:ae},e.id)),(E?!O&&!k&&!ne.length:!P.length)&&(0,K.jsxs)(`div`,{className:`col-span-full rounded-xl border border-dashed p-10 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium`,children:`No matching organizations`}),(0,K.jsx)(`p`,{className:`my-3 text-sm text-muted-foreground`,children:`Try another name or clear your filters.`}),(0,K.jsx)(H,{variant:`outline`,onClick:g,children:`Clear filters`})]})]}),E&&(b>0||D?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:b===0,onClick:()=>x(e=>e-1),children:[(0,K.jsx)(Hr,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,b+1]}),(0,K.jsxs)(H,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!D?.hasNextPage,onClick:()=>x(e=>e+1),children:[`Next`,(0,K.jsx)(Wr,{})]})]})]}),a&&(0,K.jsx)(km,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:a.organizationName,isModalOpen:r,setIsModalOpen:()=>i(!1),deletionConfirmed:()=>ie(a),deletionPending:n})]})}var LC=R({getParentRoute:()=>Uu,id:`_orgsLayout`});R({getParentRoute:()=>LC,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:IC}),R({getParentRoute:()=>LC,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:SC});async function RC(e,t){let{queryClient:n}=e.context,r=u.getSignOutGeneration(m),i;if(!e.preload){let r=n.getQueryCache().build(n,n.defaultQueryOptions(t));r.state.data===void 0&&(i=uc(r,e.abortController.signal))}try{return await n.ensureQueryData(t)}catch(e){if(Ie(e)&&u.getSignOutGeneration(`OverallAppSignIn`)!==r)return new Promise(()=>void 0);throw e}finally{i?.()}}var zC=R({getParentRoute:()=>LC,path:`$organizationId`,errorComponent:Zb,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!qc(t))throw Ne({to:`/`});return{organization:await RC(e,Yc(t))}}});R({getParentRoute:()=>zC,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Gx}),R({getParentRoute:()=>zC,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Gx}),R({getParentRoute:()=>zC,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:iC}),R({getParentRoute:()=>zC,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:iC}),R({getParentRoute:()=>zC,path:`/settings`,component:IS}),Xb(zC);var BC=R({getParentRoute:()=>zC,id:`_clusterLayout`});R({getParentRoute:()=>BC,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:fb}),R({getParentRoute:()=>zC,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:lb}),R({getParentRoute:()=>WC,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),beforeLoad:sm,component:lb}),R({getParentRoute:()=>WC,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),beforeLoad:sm,component:lb});function VC(){return(0,K.jsx)(st,{})}function HC(){return(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(ss,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})}function UC({error:e,reset:t}){let{organizationId:n}=z({strict:!1});return Rc(e)?(0,K.jsxs)(`div`,{className:`flex flex-col items-center mt-24`,children:[(0,K.jsx)(HC,{}),n&&(0,K.jsx)(V,{to:`/${n}`,children:(0,K.jsxs)(H,{variant:`outline`,children:[(0,K.jsx)(Hr,{}),` Back to clusters`]})})]}):(0,K.jsx)(oc,{error:e,reset:t})}var WC=R({getParentRoute:()=>BC,path:`$clusterId`,component:VC,errorComponent:UC,beforeLoad:async e=>({cluster:await RC(e,_f(e.params.clusterId))})}),GC=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),KC=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,qC=e=>zy(e),JC={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},YC={reads:GC,readBytes:qC,writes:GC,writeBytes:qC,realTimeMessages:GC,realTimeBytes:qC,cpuTimeHours:KC,storageBytes:qC},XC=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function ZC(e,t,n){return{label:n??JC[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:YC[e]}}function QC({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-amber-800 dark:text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function $C(e){return B({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await P.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function ew(e){return L($C(e))}function tw(e){let{regions:t}=e,n=t.every(e=>e.planName===t[0]?.planName)?t[0]?.planName:null,r=t.length>1?`next renewal`:`renews`;return[n?`${n} plan`:null,e.renewsAt?`${r} ${nw(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function nw(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function rw({clusterId:e,base:t}){let{data:n}=ew(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Wr,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:tw(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(iw,{data:n}):(0,K.jsx)(aw,{data:n})})]})}function iw({data:e}){let t=e.regions[0].metrics,n=[ZC(`reads`,t.reads),ZC(`writes`,t.writes),ZC(`storageBytes`,t.storageBytes),ZC(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(QC,{...e},e.label))})}function aw({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(QC,{...ZC(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${JC[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ow({cluster:e}){let t=Ee(),n=Ze(),{update:r,remove:i}=mg(e.organizationId,e.id),a=_g(e.organizationId),{run:o,isPending:s}=Hg(e),{mutate:c,isPending:l}=Rg(),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=e.status===`RUNNING`,y=e.status===`STOPPED`,b=e.status===`PARTIAL`,x=!a||s,S=(0,G.useCallback)(()=>{c(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),h(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{h(!1)}})},[e.id,e.organizationId,c,n,t]),C=(0,G.useCallback)(()=>{let e=g;_(null),e&&o(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[g,o]);return ff(e)||!r&&!i&&!a?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`outline`,size:`sm`,disabled:s,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(er,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(vc,{align:`end`,className:`w-56`,children:[(0,K.jsxs)(Cc,{className:`text-gray-600 text-xs`,children:[`Container`,!a&&(0,K.jsx)(`span`,{className:`block font-normal`,children:`Requires an organization admin`})]}),(0,K.jsxs)(sw,{reason:a?void 0:`Only an organization administrator can start, stop, or restart this cluster.`,children:[(0,K.jsxs)(yc,{disabled:x||!(y||b),onClick:()=>void o(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Vo,{}),` Start`]}),(0,K.jsxs)(yc,{disabled:x||!y,onClick:()=>_(`start`),children:[(0,K.jsx)(Xa,{}),` Start in safe mode`]}),(0,K.jsxs)(yc,{disabled:x||!(v||b),onClick:()=>p(!0),children:[(0,K.jsx)(Zo,{}),` Restart`]}),(0,K.jsxs)(yc,{disabled:x||!v,onClick:()=>_(`restart`),children:[(0,K.jsx)(Xa,{}),` Restart in safe mode`]}),(0,K.jsxs)(yc,{variant:`destructive`,disabled:x||!(v||b),onClick:()=>d(!0),children:[(0,K.jsx)(Ss,{}),` Stop`]})]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{variant:`destructive`,disabled:!i,onClick:()=>h(!0),children:[(0,K.jsx)(Is,{}),` Terminate`]})]})]}),(0,K.jsx)(Ng,{clusterName:e.name,isPending:s,stopOpen:u,setStopOpen:d,onConfirmStop:()=>{d(!1),o(`stop`,{strategy:`parallel`})},restartOpen:f,setRestartOpen:p,onConfirmRestart:e=>{p(!1),o(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ig,{open:g!==null,setOpen:e=>{e||_(null)},action:g??`restart`,targetName:e.name,scope:`cluster`,isPending:s,onConfirm:C}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:m,setIsModalOpen:h,deletionConfirmed:S,deletionPending:l})]})}function sw({reason:e,children:t}){return e?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`div`,{role:`none`,children:t})}),(0,K.jsx)(Xl,{side:`left`,className:`max-w-60`,children:e})]}):(0,K.jsx)(K.Fragment,{children:t})}function cw(){let{clusterId:e}=z({strict:!1}),t=Ee(),r=De(),{data:i}=L(_f(e,!0)),{user:a,isLoading:o}=Tr(e),{view:s,update:l}=mg(i?.organizationId,i?.id),[f,p]=(0,G.useState)(!1),m=i?.domains?.[0]?.domain||i?.fqdn||``,[h,g]=Gg(m,m?`https://${m}`:``),_=i?`/${i.organizationId}/${i.id}`:``,v=(0,G.useCallback)(async()=>{if(i){p(!0);try{await u.establishFabricConnectAuth({id:i.id,operationsUrl:c(i)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[i,t]),y=(0,G.useCallback)(()=>{i&&(u.setUserForEntity(i,null),u.flagForFabricConnect(i.id,!1)),r({to:`${_}/sign-in`})},[_,i,r]),b=(0,G.useCallback)(async()=>{if(i){try{await d({instanceClient:n({id:i.id}),entityId:i.id})}catch{}u.setUserForEntity(i,null),u.flagForFabricConnect(i.id,!1),u.flagForBasicAuth(i.id,null),await t.invalidate()}},[i,t]);if(!i)return(0,K.jsx)(uw,{children:(0,K.jsx)(dw,{})});if(!s)return(0,K.jsx)(qe,{to:`/${i.organizationId}`,replace:!0});if(Fd(i))return(0,K.jsx)(uw,{children:(0,K.jsx)(mf,{cluster:i})});if(ff(i))return(0,K.jsx)(lw,{cluster:i});if(!i.fqdn)return(0,K.jsx)(qe,{to:`${_}/instances`,replace:!0});if(i.resetPassword){if(!l)return(0,K.jsx)(uw,{children:(0,K.jsx)(HC,{})});let e=i.status&&Nd.includes(i.status)&&lf(i);return(0,K.jsx)(qe,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=u.checkForFabricConnect(i.id),S=!!a,C=u.getLastConnectMode(i.id),w=(i.instances??[]).filter(e=>e.status&&!Pd.includes(e.status)).length,T=i.instances??[],E=!!i.status&&Nd.includes(i.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(uw,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(ss,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:i.name}),(0,K.jsx)(fw,{status:i.status}),E&&(0,K.jsx)(pw,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,K.jsx)(fa,{className:`size-3`})]}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(ea,{className:`size-3.5`})}),(0,K.jsxs)(vc,{align:`start`,children:[(0,K.jsx)(yc,{onClick:h,children:`Copy host name`}),(0,K.jsx)(yc,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ow,{cluster:i})]}),o?(0,K.jsx)(dw,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Oi,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qo,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Wr,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!ff(i)&&(0,K.jsx)(mw,{icon:Js,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(H,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,K.jsx)(no,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.jsx)(mw,{icon:Ha,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,K.jsx)(H,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(rw,{clusterId:i.id,base:_})]})}function lw({cluster:e}){let t=Ee(),r=De(),i=`/${e.organizationId}/${e.id}`,a=(0,G.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Pd.includes(e.status)).sort(E_),[e.instances]),o=a.at(0),{user:s,isLoading:c}=Tr(o?.id),l=!!o&&!!s,f=(0,G.useCallback)(()=>{o&&r({to:`${i}/instance/${o.id}/sign-in`})},[i,o,r]),m=(0,G.useCallback)(async()=>{if(o){try{await d({instanceClient:n({id:o.id,operationsUrl:p(o)}),entityId:o.id})}catch{}u.setUserForEntity(o,null),u.flagForBasicAuth(o.id,null),await t.invalidate()}},[o,t]);return(0,K.jsxs)(uw,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(ss,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${i}/instances`,className:`hover:text-foreground hover:underline`,children:[a.length,` `,a.length===1?`instance`:`instances`]})})]})]}),o?c?(0,K.jsx)(dw,{}):l?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Oi,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,o.name||o.instanceFqdn]})]}),(0,K.jsxs)(V,{to:`${i}/instance/${o.id}/`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qo,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Wr,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(mw,{icon:Ha,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(H,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${i}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function uw({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function dw(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(no,{className:`size-6 animate-spin`})})}function fw({status:e}){let t=e&&Nd.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-amber-800 dark:text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function pw(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-amber-800 dark:text-yellow bg-yellow/10`,children:[(0,K.jsx)(Xa,{className:`size-3`}),`Safe mode`]})}function mw({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function hw({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}function gw(e){let t=jr(e);return t===void 0||t===408||t>=500}var _w=`Not attempted.`;function vw(e){return[...new Set(e.split(/[,\s]+/).map(e=>e.trim().toLowerCase()).filter(Boolean))]}function yw(e){let t=jr(e);return gw(e)||t===401||t===429}async function bw(e,t){let n=[],r=[];for(let i=0;i<e.length;i+=1){let a=e[i];try{await t(a),n.push(a)}catch(t){if(r.push({domain:a,message:fc(t).message,error:t,attempted:!0}),yw(t)){for(let t of e.slice(i+1))r.push({domain:t,message:_w,error:void 0,attempted:!1});break}}}return xw(r),{added:n,failures:r}}function xw(e){let t=new Set;for(let{error:n,attempted:r}of e){if(!r||jr(n)===409)continue;let e=jr(n);t.has(e)||(t.add(e),console.error(n))}}var Sw=4e3;async function Cw(e,t=Sw){let n;try{return await Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(void 0),t)})])}finally{clearTimeout(n)}}function ww(e){let t=new Map;for(let n of e??[]){let e=String(n?.domain??``).toLowerCase();t.set(e,(t.get(e)??0)+1)}return t}function Tw(e,t){return e.filter(({domain:e,error:n,attempted:r})=>!r||!gw(n)||!t.has(e))}function Ew(e,t){if(!e)return new Set;let n=new Set;for(let[r,i]of t)i>(e.get(r)??0)&&n.add(r);return n}function Dw(e){return e.map(({domain:e,message:t})=>`${e} — ${t}`).join(`; `)}function Ow(e,t){return e.status===`ACTIVE`&&!e.clusterId&&!ff(t)}function kw(e,t,n){return e.filter(e=>t?.some(t=>t.id===e&&Ow(t,n)))}var Aw=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function jw(e){let t=e.split(`.`);if(t.length<=2)return`@`;let n=t[t.length-1],r=t[t.length-2],i=n.length===2&&Aw.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Mw({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=jw(t),[i,a,o]=Gg(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function Nw({certificate:e,domain:t,cluster:n}){let r=jw(t.domain),[i,a,o]=Gg(r,n.fqdn||``,t.id),s=(0,G.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]}),(0,K.jsx)(Pw,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(ea,{className:`w-2.5 h-2.5`})})]})})]})]})}function Pw(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Fw(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return B({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l,u??null],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>Iw(e)})}async function Iw({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,responseType:l}){let u=i.attribute.length&&!(i.attribute===r&&!i.descending),d=await e.post(`/`,{operation:`search_by_value`,get_attributes:c??[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:u?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,responseType:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}var Lw=5e3,Rw=6e4,zw=18e4,Bw=new Map;function Vw(e){return!e.issueDate||e.inProgress}function Hw(e){return[e,`ChallengeCertificate`]}function Uw(e,t){return Bw.set(t,Date.now()+zw),e.invalidateQueries({queryKey:Hw(t)})}function Ww(e,t){return e&&(Bw.get(e)??0)>Date.now()||t?.some(Vw)?Lw:Rw}function Gw(e){return B({queryKey:Hw(e),queryFn:async()=>{if(!e)return[];let{data:t}=await Iw({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:n({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:t=>Gc(Ww(e,t.state.data))(t),retry:Kc()})}function Kw(e){return L(Gw(e))}function qw({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=jw(n),[o,s,c,l,u]=Gg(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}var Jw=new Set([`PROVISIONING`,`PENDING_UPGRADE`,`DRAINING`,`UPDATING`,`UPDATED`,`CLONE_PENDING`,`CLONE_READY`,`CLONING`,`UPDATING_HDB_NODES`,`GENERATE_TOKEN`,`TOKEN_GENERATED`,`STOPPING`,`STOPPED`,`STARTING`,`RESTARTING`]);function Yw(e){if(e.status!==`RUNNING`)return{message:`This cluster is ${e.status??`not running`}. Its domains can change once it is running again.`,needsSupport:!1};for(let t of e.instances??[]){let e=t.instanceFqdn||t.id;if(t.status===`FAILED`)return{message:`Instance ${e} has failed, and this cluster's domains can't change until it is recovered.`,needsSupport:!0};if(t.status&&Jw.has(t.status))return{message:`Instance ${e} is ${t.status}. This cluster's domains can change once every instance is running.`,needsSupport:!1}}}function Xw(e,t){if(!t)return`isn't one of this organization's domains`;if(t.status!==`ACTIVE`)return`is not verified`;if(t.clusterId&&t.clusterId!==e)return`is bound to cluster ${t.clusterId}`}function Zw(e,{add:t,remove:n},r){if(ff(e))return{message:`Custom domains can't be bound to a self-managed cluster.`,needsSupport:!1};let i=new Map(r.map(e=>[e.id,e])),a=e.domainIds??[];for(let t of a){let n=Xw(e.id,i.get(t));if(n)return{message:`This cluster still lists ${i.get(t)?.domain??t}, which ${n}. Its domains can't change until that is cleared.`,needsSupport:!0}}for(let n of t){let t=a.includes(n)?void 0:Xw(e.id,i.get(n));if(t)return{message:`${i.get(n)?.domain??n} ${t}, so it can't be bound. The list has been refreshed.`,needsSupport:!1}}if(n&&!a.includes(n)){let t=i.get(n);return t?.clusterId===e.id?{message:`${t.domain} is bound to this cluster without the cluster listing it, so it can't be unbound here.`,needsSupport:!0}:{message:`${t?.domain??n} is no longer bound to this cluster. The list has been refreshed.`,needsSupport:!1}}}async function Qw(e){let{data:t}=await P.get(`/Domain/?organizationId=${e}`);return t}function $w(e){return B({queryKey:[e,`domains`],queryFn:()=>Qw(e)})}function eT(e){return[...new Set(e)]}var tT=class extends Error{needsSupport;constructor({message:e,needsSupport:t}){super(e),this.name=`DomainChangeRefusedError`,this.needsSupport=t}};async function nT(e,t,n){await P.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0})}var rT=[`setDomainIdsOnCluster`];function iT(){let e=Ze(),t=I({mutationKey:rT,mutationFn:async({clusterId:t,organizationId:n,add:r=[],remove:i,generateDomainCerts:a})=>{let[o,s]=await Promise.all([hf(t),Qw(n)]);e.setQueryData(_f(t).queryKey,o),e.setQueryData($w(n).queryKey,s);let c=Yw(o)??Zw(o,{add:r,remove:i},s);if(c)throw new tT(c);await nT(t,eT((o.domainIds??[]).concat(r)).filter(e=>e!==i),a)},meta:{skipGlobalErrorToast:!0},onError:e=>{e instanceof tT||console.error(e)},onSuccess:(t,{clusterId:n})=>{e.invalidateQueries({queryKey:_f(n).queryKey,exact:!0}),Uw(e,n)}}),{mutate:n}=t,r=(0,G.useCallback)((t,r)=>{aT(e)||n(t,r)},[n,e]);return{...t,mutate:r}}function aT(e){return e.isMutating({mutationKey:rT})>0}function oT(){return Me({mutationKey:rT})>0}b({domainId:x(),organizationId:x()});async function sT(e){let{data:t}=await P.delete(`/Domain/${e.domainId}`);return t}var cT=[`deleteDomain`];function lT(){let e=Ze();return I({mutationKey:cT,mutationFn:e=>sT(e),onSuccess:(t,{domainId:n,organizationId:r})=>{e.setQueryData($w(r).queryKey,e=>e?.filter(e=>e.id!==n))}})}function uT(e){return e.isMutating({mutationKey:cT})>0}function dT(){return Me({mutationKey:cT})>0}var fT=Bb();function pT(e,t,n,r){let{data:i}=Kw(e.id),a=(0,G.useMemo)(()=>!!i?.some(Vw),[i]),o=oT(),{mutate:s,isPending:c}=lT(),l=o||c,u=Ze(),d=(0,G.useCallback)(t=>{aT(u)||s({domainId:t,organizationId:e.organizationId},{onSuccess:()=>{u.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[u,s,e.organizationId]);return(0,G.useMemo)(()=>[fT.display({id:`select`,header:`Bind`,size:50,cell:r=>{let i=r.row.original;return Ow(i,e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(i.id),onChange:()=>n(i.id),disabled:l||a})}):null}}),fT.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original,n=(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:t.clusterId?(0,K.jsx)(`div`,{className:`w-fit`,tabIndex:0,children:n}):n}),(0,K.jsx)(Xl,{side:`bottom`,align:`center`,children:t.clusterId?`To delete this domain, please unbind it from all clusters first.`:`Remember to clean up your DNS records!`})]})]})}}),fT.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,a=i?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),a&&Vw(a)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(Nw,{certificate:a,domain:n,cluster:e})}),(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>r(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,K.jsx)(qw,{domain:n,cluster:e}):ff(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(Mw,{cluster:e,domain:n}):n.status}})],[e,d,r,l,i,a,t,n])}var mT=`Enter a domain name.`,hT=b({domain:x().trim().min(1,mT),organizationId:x()});async function gT(e){let{data:t}=await P.post(`/Domain/`,e);return t}function _T(){return I({mutationFn:e=>gT(e),meta:{skipGlobalErrorToast:!0},networkMode:`always`})}async function vT(e){let{data:t}=await P.post(`/Domain/${e}/validate`);return t}function yT(e){return e instanceof tT?{message:e.message,needsSupport:e.needsSupport}:{message:`The domain change didn't go through: ${fc(e).message}`,needsSupport:!1}}function bT(){let{organizationId:e,clusterId:t}=z({strict:!1}),{data:n}=we(_f(t,!0)),{update:r}=fg(e),{data:i,refetch:a,isFetching:o,isPending:s,isRefetching:c}=L($w(e)),l=(0,G.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,G.useState)({attribute:`domain`,descending:!1}),d=(0,G.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Kb(a),[p,m]=(0,G.useState)([]),h=(0,G.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),g=(0,G.useMemo)(()=>kw(p,i,n),[n,i,p]),_=iT(),{mutate:v}=_,y=oT(),b=dT(),x=Ze(),S=(0,G.useCallback)(()=>{if(uT(x))return;let t=kw(p,x.getQueryData($w(e).queryKey),n);t.length!==0&&v({clusterId:n.id,organizationId:e,add:t,generateDomainCerts:!0},{onSuccess:()=>{x.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[x,n,e,p,v]),C=(0,G.useCallback)(t=>{v({clusterId:n.id,organizationId:e,remove:t},{onSuccess:()=>{x.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[x,n.id,n.organizationId,e,v]),w=_.error&&_.variables?.clusterId===n.id?yT(_.error):void 0,{mutateAsync:T}=_T(),E=on({resolver:mt(hT),defaultValues:{domain:``,organizationId:e}}),D=s||E.formState.isSubmitting,O=(0,G.useCallback)(async e=>{if(e.domain.length>5144){E.setError(`domain`,{type:`server`,message:`That is too much text to be domain names. Paste at most 20.`});return}let t=vw(e.domain);if(t.length===0){E.setError(`domain`,{type:`server`,message:mT});return}if(t.length>20){E.setError(`domain`,{type:`server`,message:`That is ${t.length} domains. Add at most 20 at a time.`});return}let n=i&&ww(i),{added:r,failures:o}=await bw(t,t=>T({...e,domain:t})),s=ke.isOnline()&&(r.length>0||o.some(({error:e,attempted:t})=>t&&gw(e)))?await Cw(a()):void 0,c=Tw(o,s?Ew(n,ww(s.data)):new Set),l=r.length+o.length-c.length;if(l>0&&U.success(`${oe(l,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`),c.length===0){E.reset();return}E.setValue(`domain`,c.map(({domain:e})=>e).join(`, `)),E.setError(`domain`,{type:`server`,message:Dw(c)})},[T,E,i,a]),k=(0,G.useCallback)(async()=>{let e=`Validating ${oe(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0,i=0;for(let a of l)try{U.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await vT(a.id)}catch(e){or(e)?i+=1:r+=1}i>0?(await a(),U.error(cr,{description:[ir(i),r>0&&`${oe(r,`other domain`,`other domains`)} failed to validate.`].filter(Boolean).join(` `),id:t})):r>0?U.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),A=pT(n,p,h,C),j=E.watch(`domain`),M=(0,G.useMemo)(()=>typeof j==`string`&&j.trim().split(`.`).length===2,[j]),ee=(0,G.useCallback)(()=>{typeof j==`string`&&E.setValue(`domain`,`${j.trim()}, www.${j.trim()}`)},[j,E]);return(0,K.jsx)(Hb,{data:i||[],isFetching:o||c,columns:A,sortingState:d,children:(0,K.jsxs)(`div`,{className:`w-full flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,K.jsx)(Od,{...E,children:(0,K.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:E.handleSubmit(O),className:`flex gap-1 flex-col md:flex-row`,children:[(0,K.jsx)(Y,{control:E.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,disabled:D,...e})}),M&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(H,{variant:`positiveOutline`,type:`button`,disabled:D,onClick:ee,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:D,children:[(0,K.jsx)(Uo,{}),` Add`]}),l.length>0&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:k,accessKey:`r`,type:`button`,disabled:o||c,children:[(0,K.jsx)(eo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||c,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),g.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(H,{variant:`submit`,onClick:S,disabled:y||b,children:[(0,K.jsx)($o,{}),` Bind `,oe(g.length,`Domain`,`Domains`)]})})]}),(0,K.jsx)(Kf,{message:w?.message,suggestSupport:w?.needsSupport})]})})}function xT(){return(0,K.jsx)(hw,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(bT,{})})}var ST=b({username:xf,role:x().nonempty({error:`Please select a role.`}),password:yf.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:x()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function CT(e){await P.patch(`/ResetPasswordUpdater/${e}`)}async function wT(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function TT(){return I({mutationFn:wT})}async function ET({username:e,password:t,role:n,active:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`alter_user`,username:e,password:t,role:n,active:r});return a}function DT(){return I({mutationFn:ET})}async function OT({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function kT(){return I({mutationFn:OT})}async function AT({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:a,instanceClient:o}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let s=o;try{let o=await Yd({username:t,password:a,instanceClient:s,entityId:e});return o.instanceClient&&(s=o.instanceClient),n===`HDB_ADMIN`?await ET({username:n,password:r,instanceClient:s}):(await wT({username:n,password:r,role:`super_user`,active:!0,instanceClient:s}),o=await Yd({username:n,password:r,instanceClient:s,entityId:e}),await OT({username:i,instanceClient:s})),await CT(e),o}catch(t){throw await d({entityId:e,instanceClient:s}),t}}function jT(){return I({mutationFn:AT})}function MT(){let{user:e}=Sr(),{clusterId:t}=z({strict:!1}),{data:n}=L(_f(t,!0)),r=De(),a=Ze(),o=(0,G.useMemo)(()=>c(n),[n]),s=Ql({operationsUrl:o}),{redirect:l}=Oe({strict:!1}),d=Ee(),f=on({resolver:mt(ST),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:p,control:m,handleSubmit:h}=f;(0,G.useEffect)(()=>{p(`password`)},[p]);let g=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=lf(n),{mutate:v,isPending:y}=jT(),b=(0,G.useCallback)(async e=>{if(!o){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:s,clusterId:t,newPassword:e.password,tempPassword:g,initialUsername:i,desiredUsername:e.username},{onSuccess:async({user:e})=>{U.success(`Admin user created. You're now signed in to your cluster.`),u.setUserForEntity(n,e),await gf(a,t),d.invalidate(),await r({to:l?.startsWith(`/`)?l:`../`})}})},[n,t,s,_,r,o,a,l,d,v,g]);return n&&!n.resetPassword?(0,K.jsx)(qe,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(qe,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`studio-subnav fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,K.jsx)(Dd,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,K.jsx)(Od,{...f,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:h(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:m,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(H,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Ir,{size:36,className:`flex-none`}),(0,K.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function NT({columns:e,data:t,renderRowWrapper:n}){let r=tt({features:Lb,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(wb,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:ot(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(G.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function PT({instance:e,className:t}){let n=Vm(e);return n?!n.waiting&&(n.lastProgressAt!==void 0||n.startedAt!==void 0)?(0,K.jsx)(FT,{progress:n,className:t}):(0,K.jsx)(IT,{waiting:n.waiting,description:Wm(n,Date.now()),className:t}):null}function FT({progress:e,className:t}){let n=Rl();return(0,K.jsx)(IT,{description:Wm(e,n),className:t})}function IT({description:e,waiting:t,className:n}){let r=t?Hi:Go;return(0,K.jsxs)(`div`,{className:F(`flex items-center gap-1.5 text-xs font-light text-muted-foreground`,n),children:[(0,K.jsx)(r,{"aria-hidden":`true`,className:F(`size-3.5 shrink-0`,t?`text-muted-foreground`:`text-yellow animate-[spin_2.5s_linear_infinite] motion-reduce:animate-none`)}),(0,K.jsx)(`span`,{children:e})]})}function LT({instances:e}){let t=(e??[]).filter(e=>tf(e.status)).sort(E_);return t.length?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`Instances syncing data`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-sm`,children:e.name||e.instanceFqdn}),(0,K.jsx)(PT,{instance:e})]},e.id))}):null}function RT(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}var zT={start:!1,restart:!1,stop:!1},BT={start:!1,restart:!0,stop:!0},VT={start:!0,restart:!1,stop:!1},HT={start:!0,restart:!0,stop:!0};function UT(e){switch(e){case`RUNNING`:return BT;case`STOPPED`:return VT;case`ERROR`:case`FAILED`:return HT;default:return zT}}async function WT({instance:e,instanceClient:t}){try{await d({instanceClient:t,entityId:e.id})}catch{}u.signOutLocally(e.id),e.clusterId&&u.signOutLocally(e.clusterId)}async function GT({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await P.post(`/HDBInstance/${e}/container/${t}`,r);return i}function KT(){return I({mutationFn:GT})}var qT={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function JT(e){let{clusterId:t}=z({strict:!1}),{mutateAsync:n,isPending:r}=KT(),i=Ze();return{run:(0,G.useCallback)(async(r,a)=>{let o=a?.label??qT[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),r!==`stop`&&de({instanceIds:[e.id],label:qT[r],allAtOnce:!0}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}var YT=`4.6.0`;function XT(e){return!!e&&vr(YT,e)}function ZT(e){return!!e&&!XT(e)&&vr(e,YT)}function QT({entityId:e,instanceClient:t},n){return B({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:Gc(1e4),retry:Kc(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function $T(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function eE({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function tE(){return I({mutationFn:eE,onSuccess:(e,t)=>hc.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var nE=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function rE(e,t,n){let{user:r}=Tr(e.id),{organizationId:i,clusterId:a}=z({strict:!1}),o=qg({organizationId:i,clusterId:a,instanceId:e.id}),s=qg({organizationId:i,clusterId:a,instanceId:e.id},`sign-in`),c=(0,G.useMemo)(()=>p(e),[e]),l=Ql({operationsUrl:c}),{update:d}=bg(),f=_g(),m=u.checkForFabricConnect(e.id),h=q({operationsUrl:c,instanceId:e.id,forceFabricConnect:!0}),g=XT(e.version),{data:_}=L(QT(h,n&&d&&!ef(e.status)&&g)),v=$T(_,`availability`)||`Unknown`,y=v===`Available`,b=v===`Unavailable`,{mutate:x,isPending:S}=tE(),{run:C,isPending:w}=JT(e),[T,E]=(0,G.useState)(null),D=e.instanceFqdn,O=eb({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[k,A]=Gg(D??``,O),j=(0,G.useCallback)(async()=>{await WT({instance:e,instanceClient:l})},[e,l]),M=!!e.status&&nE.includes(e.status),ee=!!r&&!m,te=M,N=!!D,P=d&&M&&g&&(y||b),F=UT(e.status),ne=f&&!t&&(F.start||F.restart||F.stop),re=[te&&ee&&{key:`direct-connect`,to:o,icon:(0,K.jsx)(ss,{className:`text-green`}),label:`Direct Connect`},te&&ee&&{key:`direct-sign-out`,onClick:j,variant:`destructive`,icon:(0,K.jsx)(uo,{}),label:`Direct Sign Out`},te&&!ee&&d&&!t&&{key:`fabric-connect`,to:o,icon:(0,K.jsx)(ss,{className:`text-green`}),label:`Fabric Connect`},te&&!ee&&{key:`direct-sign-in`,to:s,icon:(0,K.jsx)(co,{}),label:`Direct Sign In`},te&&N&&{type:`separator`,key:`copy-sep`},N&&{key:`copy-fqdn`,onClick:k,icon:(0,K.jsx)(Bi,{}),label:`Copy Instance FQDN`},N&&{key:`copy-api`,onClick:A,icon:(0,K.jsx)(Bi,{}),label:`Copy API URL`},(te||N)&&P&&{type:`separator`,key:`rotation-sep`},P&&y&&{key:`out-of-rotation`,variant:`destructive`,disabled:S,onClick:()=>x({...h,id:`availability`,status:`Unavailable`}),icon:(0,K.jsx)(ps,{}),label:`Bring out of rotation`},P&&b&&{key:`into-rotation`,disabled:S,onClick:()=>x({...h,id:`availability`,status:`Available`}),icon:(0,K.jsx)(ds,{}),label:`Bring back into rotation`},(te||N||P)&&ne&&{type:`separator`,key:`container-sep`},ne&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},ne&&F.start&&{key:`container-start`,disabled:w,onClick:()=>void C(`start`,{safeMode:!1}),icon:(0,K.jsx)(Vo,{}),label:`Start`},ne&&F.start&&{key:`container-start-safe`,disabled:w,onClick:()=>E(`start`),icon:(0,K.jsx)(Xa,{}),label:`Start in safe mode`},ne&&F.restart&&{key:`container-restart`,disabled:w,onClick:()=>void C(`restart`,{safeMode:!1}),icon:(0,K.jsx)(Zo,{}),label:`Restart`},ne&&F.restart&&{key:`container-restart-safe`,disabled:w,onClick:()=>E(`restart`),icon:(0,K.jsx)(Xa,{}),label:`Restart in safe mode`},ne&&F.stop&&{key:`container-stop`,variant:`destructive`,disabled:w,onClick:()=>void C(`stop`),icon:(0,K.jsx)(Ss,{}),label:`Stop`}].filter(fr),ie=(0,K.jsx)(Ig,{open:T!==null,setOpen:e=>{e||E(null)},action:T??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:w,onConfirm:()=>{let e=T;E(null),e&&C(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return re.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...re],dialog:ie}:{items:[],dialog:ie}}function iE({instance:e,isSelfManaged:t}){let[n,r]=(0,G.useState)(!1),{items:i,dialog:a}=rE(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{open:n,onOpenChange:r,children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ua,{})})}),(0,K.jsx)(vc,{align:`end`,className:`min-w-48`,children:Rm(i,`dropdown`)})]}),a]}):null}function aE({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Tr(t.id),{organizationId:i,clusterId:a}=z({strict:!1}),o=qg({organizationId:i,clusterId:a,instanceId:t.id}),s=qg({organizationId:i,clusterId:a,instanceId:t.id},`sign-in`),c=Ql({operationsUrl:(0,G.useMemo)(()=>p(t),[t])}),{update:l}=bg(),d=u.checkForFabricConnect(t.id),f=(0,G.useCallback)(async()=>{await WT({instance:t,instanceClient:c})},[t,c]);return $d(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(no,{className:`animate-spin`,color:`gray`}):!n||d?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[l&&!e&&(0,K.jsx)(V,{to:o,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(H,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{to:s,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,K.jsx)(H,{variant:l?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:o,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(H,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(H,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:f,children:`Direct Sign Out`})]})}function oE({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,G.useState)(!1),{items:a,dialog:o}=rE(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Am,{onOpenChange:i,children:[(0,K.jsx)(jm,{asChild:!0,children:n}),(0,K.jsx)(Mm,{className:`min-w-48`,children:Rm(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function sE(e,t=`0px`){let[n,r]=(0,G.useState)(null);return n!==null&&n.element!==e&&r(null),(0,G.useEffect)(()=>{if(!e||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(t=>{let n=t[t.length-1];n&&r({element:e,onScreen:n.isIntersecting})},{rootMargin:t});return n.observe(e),()=>n.disconnect()},[e,t]),typeof IntersectionObserver>`u`||n!==null&&n.element===e&&n.onScreen}function cE({instance:e,index:t}){let{update:n}=bg(),r=q({operationsUrl:(0,G.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=tE(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=sE(c,`200px`);(0,G.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let d=ef(e.status),f=XT(e.version),{data:m,isLoading:h,isFetching:g}=L(QT(r,o&&u&&n&&!d&&f)),_=$T(m,`availability`)||`Unknown`,v=_===`Available`,y=_===`Unavailable`;if(!n)return null;if(d||!f){let t=`Status unavailable`;return d&&$d(e.status)?t=`Not running`:!d&&ZT(e.version)&&(t=`Status needs Harper 4.6 or later`),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":t})}),(0,K.jsx)(Xl,{children:t})]})})}return(0,K.jsxs)(`div`,{ref:l,className:`flex items-center gap-2`,children:[(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:h||!o||(g||!u)&&!m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(no,{className:`animate-spin size-5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading status`})]}):(0,K.jsx)(ol,{variant:v?`success`:y?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:v?`Online`:`Offline`})})})}),(0,K.jsxs)(Xl,{children:[g&&m?`Refreshing... `:``,_]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[v&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,K.jsx)(no,{className:`animate-spin size-4`}):(0,K.jsx)(ps,{className:`size-4`})})}),(0,K.jsx)(Xl,{children:`Bring out of rotation`})]}),y&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,K.jsx)(no,{className:`animate-spin size-4`}):(0,K.jsx)(ds,{className:`size-4`})})}),(0,K.jsx)(Xl,{children:`Bring back into rotation`})]})]})]})}function lE(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=L(_f(e,!0)),r=ff(t),i=(0,G.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(aE,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>eb({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(cE,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(ol,{variant:Qd(t),children:_d(t)}):null,e.row.original.safeMode&&!$d(e.row.original.status)?(0,K.jsxs)(ol,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.jsx)(Xa,{}),`Safe mode`]}):null]}),(0,K.jsx)(PT,{instance:e.row.original,className:`w-64`})]})}},!r&&{accessorKey:`version`,size:1,minSize:1,header:`Version`},!r&&{accessorKey:`storageGb`,size:1,minSize:1,header:`Storage`,cell:e=>`${e.getValue()} GB`},!r&&{accessorKey:`usedStorageGb`,size:1,minSize:1,header:`Used Storage`,cell:e=>{let t=e.getValue();return t===void 0?`-`:`${t} GB`}},!r&&{accessorKey:`cpuCores`,size:1,minSize:1,header:`Cores/Threads`,cell:e=>(0,K.jsxs)(K.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(iE,{isSelfManaged:r,instance:e.row.original})})}].filter(fr),[r]),a=f_(),o=(0,G.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Pd.includes(e.status)).map(e=>se(e.id)?.reach===`down`&&!$d(e.status)?{...e,status:`RESTARTING`}:e).sort(E_):[],[t,a]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(Er,{className:`p-0 min-h-96`,children:(0,K.jsx)(Ar,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(my,{}):o.length?(0,K.jsx)(NT,{data:o,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(oE,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(RT,{})})})})]})}function uE(){let{clusterId:e}=z({strict:!1}),{immediate:t}=Oe({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=L(_f(e,2e3)),a=r?.status,o=(0,G.useMemo)(()=>a&&Nd.includes(a)&&df(r),[a,r]);return i||!r?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsx)(my,{})}):af(a)?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(Wi,{className:`w-24 h-24`}),(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Your cluster's update didn't finish`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Some of the changes may already be applied, so check the instances. The cluster can't take another update until it's healthy again, so get in touch and we'll help get it back into a state you can update.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We also get notified about these failures. `,(0,K.jsx)(Pf,{}),` if you want more help.`]})]}),(0,K.jsx)(V,{to:`/${r.organizationId}/${r.id}/instances`,children:(0,K.jsx)(H,{type:`button`,variant:`positiveOutline`,children:`View Instances`})})]})}):o?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Ag,{cluster:r})})]})}):(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(LT,{instances:r.instances}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function dE({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(`div`,{className:v(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function fE(){let e=Ee(),{clusterId:t}=z({strict:!1}),{data:n,isLoading:r}=L(_f(t,2e3)),i=n?.status,a=(0,G.useMemo)(()=>i&&Nd.includes(i)&&lf(n),[i,n]),o=af(i),[,s]=Zc(_r.SavedClusterState,null),c=(0,G.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsx)(my,{})}):o?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(Wi,{className:`w-24 h-24`}),(0,K.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,K.jsx)(Pf,{}),` if you want more help.`]}),(0,K.jsx)(H,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):Fd(n)?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsx)(mf,{cluster:n})}):a?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(Fg,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Ag,{cluster:n})})]})}):(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(Fg,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsx)(LT,{instances:n.instances}),(0,K.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function pE(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=ew(e);if(n)return(0,K.jsxs)(hw,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(no,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?yE(t.regions):null;return(0,K.jsxs)(hw,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(SE,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(SE,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(mE,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(hE,{header:(0,K.jsx)(gE,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(_E,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(CE,{})]})}function mE({region:e,showPlanInfo:t}){let n=XC.map(t=>ZC(t,e.metrics[t])),r=[e.planName?`${e.planName} plan`:null,e.status===`exhausted`?`consumed — awaiting renewal`:e.status===`lapsed`?`not renewed`:e.expiresAt?`renews ${vE(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(hE,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(gE,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-amber-800 dark:text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(QC,{...e},e.label))}),t&&(0,K.jsx)(_E,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function hE({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,G.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(Si,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function gE({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function _E({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?xE([[`Reads / minute`,n.readsPerMinute,By],[`Read bandwidth / minute`,n.readsPerMinuteBytes,zy],[`Writes / minute`,n.writesPerMinute,By],[`Write bandwidth / minute`,n.writesPerMinuteBytes,zy],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,By],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,zy],[`TLS handshakes (cycle)`,n.tlsHandshakes,By]]):[],i=t,a=i?bE([[`Storage`,i.storageGb,e=>`${By(e)} GB`],[`Memory`,i.memoryMb,e=>zy(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(wE,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(TE,{rows:r})}),a.length>0&&(0,K.jsx)(wE,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(TE,{rows:a})})]})}function vE(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function yE(e){if(e.length===0)return null;let t=e[0];if(t.rateLimits==null&&t.resourcesPerInstance==null)return null;let n=e=>JSON.stringify([e.rateLimits,e.resourcesPerInstance]),r=n(t),i=e.every(e=>e.planId===t.planId);return e.every(e=>n(e)===r)?{rateLimits:t.rateLimits,resourcesPerInstance:t.resourcesPerInstance,planId:i?t.planId:null}:null}function bE(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function xE(e){return e.filter(e=>e[1]!=null).map(([e,t,n])=>[e,t.unlimited?`Unlimited`:t.limitKnown&&t.limit!=null?n(t.limit):`—`])}function SE({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function CE(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function wE({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function TE({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}R({getParentRoute:()=>WC,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),beforeLoad:sm,component:lE}),R({getParentRoute:()=>WC,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:fE}),R({getParentRoute:()=>WC,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),beforeLoad:sm,component:uE}),R({getParentRoute:()=>WC,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),beforeLoad:sm,component:xT}),R({getParentRoute:()=>WC,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:pE});function EE({context:e,location:t,params:n}){if(Fd(e?.cluster))return;let r=u.checkForFabricConnect(n.clusterId);if(u.getConnectionById(n.clusterId).user&&!r){let e=t?.search?.redirect;throw Ne({to:e?.startsWith(`/`)?e:`../`})}}function DE({context:e,location:t,params:n}){if(Fd(e?.cluster))return;let r=u.checkForFabricConnect(n.instanceId);if(u.getConnectionById(n.instanceId).user&&!r){let e=t?.search?.redirect;throw Ne({to:e?.startsWith(`/`)?e:`../`})}}R({getParentRoute:()=>WC,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:EE}),R({getParentRoute:()=>WC,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:DE}),R({getParentRoute:()=>WC,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:MT}),R({getParentRoute:()=>WC,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:cw});function OE(e){return R({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>pe(()=>import(`./index.lazy-DgbjUxLo.js`).then(e=>e.route),__vite__mapDeps([21,1,22,7,6,23,4,2,3,24,25,8,9,12,11,26,27,28,29])))}function kE(e,t){return[R({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:je(()=>pe(()=>import(`./applications-XCds8-ZP.js`),__vite__mapDeps([30,1,22,7,6,23,4,2,3,24,25,8,9,12,11,31,32,15,33,34,26,16,17,28,35,18,19,20,36])),`ApplicationsEditor`)})]}async function AE({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function jE(e){return B({queryKey:[e.entityId,`list_certificates`],queryFn:()=>AE(e)})}var ME=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},Bb().display({header:`Expires At`,enableSorting:!1,id:`details.valid_to`,cell:e=>e.row.original.details.valid_to?new Date(e.row.original.details.valid_to).toLocaleString():`N/A`})];function NE({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`input`,className:F(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
|
|
20
|
+
selection:text-primary-foreground
|
|
21
|
+
dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
|
|
22
|
+
dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
|
|
23
|
+
aria-invalid:ring-destructive/20 aria-invalid:border-destructive/60 dark:aria-invalid:border-destructive
|
|
24
|
+
flex w-full min-w-0 rounded-md border bg-white text-foreground dark:bg-grey-700 dark:text-white px-3 py-2 text-base
|
|
25
|
+
file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium
|
|
26
|
+
focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
|
|
27
|
+
aria-invalid:focus-visible:ring-[1px] aria-invalid:focus-visible:outline-none md:text-sm dark:aria-invalid:focus-visible:ring-1`,e),...t})}async function PE({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`add_certificate`,...t});return n}var FE=b({name:x().min(1,`Name is required`),certificate:x().min(1,`Certificate is required`),private_key:x().optional(),is_authority:A().default(!1),hosts:x().optional(),uses:x().optional()});function IE(){return I({mutationFn:({instanceParams:e,certificateParams:t})=>PE(e,t)})}function LE({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=on({resolver:mt(FE),mode:`onTouched`,defaultValues:{name:``,certificate:``,private_key:``,is_authority:!1,hosts:``,uses:``}}),i=q(),{mutate:a,isPending:o}=IE(),s=(0,G.useCallback)(async e=>{let{hosts:o,uses:s,private_key:c,...l}=e,u=o?o.split(`,`).map(e=>e.trim()).filter(Boolean):void 0,d=s?s.split(`,`).map(e=>e.trim()).filter(Boolean):void 0;a({instanceParams:i,certificateParams:{...l,private_key:c||void 0,hosts:u&&u.length>0?u:void 0,uses:d&&d.length>0?d:void 0}},{onSuccess:()=>{r.reset(),t(),U.success(`Certificate added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,G.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,K.jsx)(_m,{onOpenChange:n,open:e,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...r,children:(0,K.jsxs)(`form`,{id:`instance-add-certificate-form`,name:`instance-add-certificate-form`,onSubmit:r.handleSubmit(s),onKeyDown:rx(r),className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add New Certificate`}),(0,K.jsx)(Om,{children:`Enter the details of your Certificate below.`})]}),(0,K.jsx)(Y,{control:r.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`is_authority`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex flex-row items-center justify-between rounded-lg border border-gray-800 p-3 shadow-sm`,children:[(0,K.jsx)(`div`,{className:`space-y-0.5`,children:(0,K.jsx)(Z,{children:`Is Authority`})}),(0,K.jsx)(J,{children:(0,K.jsx)(Kx,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,K.jsx)(Y,{control:r.control,name:`certificate`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Certificate`}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`hosts`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Hosts (optional)`}),(0,K.jsx)(ky,{children:`Comma-separated list of hostnames this certificate is valid for.`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. example.com, *.example.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`uses`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Uses (optional)`}),(0,K.jsx)(ky,{children:`Comma-separated list of intended uses, e.g. "https, operations, wss".`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. https, operations, wss`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`private_key`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Private Key (optional)`}),(0,K.jsx)(ky,{children:`PEM formatted private key string.`}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,K.jsx)($o,{}),` Add Certificate`]})]})})]})})})})}async function RE({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`remove_certificate`,name:t});return n}function zE(){return I({mutationFn:({instanceParams:e,name:t})=>RE(e,t)})}function BE({data:e,isModalOpen:t,closeModal:n,onSelectCertificate:r,onChangesSaved:i}){let{name:a}=e,o=q(),{mutate:s,isPending:c}=zE(),[l,u]=(0,G.useState)(!1),d=(0,G.useCallback)(()=>{u(!0)},[]),f=(0,G.useCallback)(()=>{s({instanceParams:o,name:a},{onSuccess:()=>{U.success(`Certificate removed successfully!`),r(void 0),i()}})},[a,s,o,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_m,{onOpenChange:n,open:t,children:(0,K.jsx)(wm,{className:`sm:max-w-[800px] max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:(0,K.jsxs)(`div`,{className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsxs)(Dm,{children:[`View Certificate: `,a]}),(0,K.jsx)(Om,{children:`Details of the selected certificate.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm bg-muted p-4 rounded-lg border border-border`,children:[(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Issuer`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.issuer||`N/A`})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Subject`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject||`N/A`})]}),e.details.subject_alt_name&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Subject Alternative Name`}),(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject_alt_name})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Valid From`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_from?new Date(e.details.valid_from).toLocaleString():`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Valid To (Expires At)`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_to?new Date(e.details.valid_to).toLocaleString():`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Serial Number`}),(0,K.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs break-all`,children:e.details.serial_number||`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Private Key Name`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.private_key_name||`N/A`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Is Authority`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_authority?`Yes`:`No`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Is Self-Signed`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_self_signed?`Yes`:`No`})]}),e.hosts&&e.hosts.length>0&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Hosts`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.hosts.join(`, `)})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Uses`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:e.uses?.join(`, `)||`N/A`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(Md,{children:`Certificate Content`}),(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,rows:8,readOnly:!0,className:`font-mono text-xs`,value:e.certificate})]})]}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:d,disabled:c,children:`Remove Certificate`}),(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>n(),children:`Close`})]})})]})})}),(0,K.jsx)(km,{isModalOpen:l,setIsModalOpen:u,deletionConfirmed:f,deletionPending:c,typeOfThingBeingDeleted:`certificate`,presentParticiple:`Removing`,transitiveVerb:`Remove`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function VE(){let e=De(),{certName:t}=z({strict:!1}),n=q(),{data:r,refetch:i,isFetching:a,isRefetching:o}=L(jE(n)),s=(0,G.useMemo)(()=>r?.find(e=>e.name===t),[r,t]),c=(0,G.useCallback)(n=>{let r=n?.original?.name,i=[t?`..`:``,r].filter(Boolean);e({to:i.join(`/`)})},[t,e]),l=!!t&&!!s,[u,d]=(0,G.useState)(!1),f=(0,G.useCallback)(()=>{d(!0)},[d]),p=Kb(i);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Hb,{columns:ME,data:r||[],isFetching:a,onRowClick:c,children:[(0,K.jsx)(V,{className:`inline-block underline text-sm text-muted-foreground hover:text-foreground`,to:`https://docs.harperdb.io/docs/developers/operations-api/certificate-management`,target:`_blank`,children:`Certificate Management Docs`}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:p,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:f,accessKey:`a`,disabled:u,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),u&&(0,K.jsx)(LE,{isModalOpen:u,onChangesSaved:i,setIsModalOpen:d}),l&&(0,K.jsx)(BE,{isModalOpen:l,closeModal:c,data:s,onSelectCertificate:c,onChangesSaved:i})]})}function HE({entityId:e,instanceClient:t}){return B({queryKey:[`registration_info`,e],staleTime:6e4,gcTime:5e3,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`registration_info`});return e}})}function UE(e){return!!e&&vr(`5.1.0`,e)}function WE(e){return!!e&&vr(`5.3.0`,e)}function GE(){let e=q(),{data:t}=L(HE(e));return WE(t?.version)}function KE(){let e=q(),{data:t}=L(HE(e));return UE(t?.version)}function qE(){let e=q();return KE()&&u.isDirectConnection(e.entityId)}var JE=new Set([`success`,`failed`,`rolled_back`,`staged`]);function YE(e){return!!e&&JE.has(e)}var XE=2e3,ZE=1e4;async function QE({instanceClient:e,project:t,status:n,since:r,until:i,limit:a,offset:o}){let{data:s}=await e.post(`/`,{operation:`list_deployments`,project:t,status:n,since:r,until:i,limit:a,offset:o});return s}function $E(e){let{entityId:t,project:n,status:r,since:i,until:a,limit:o,offset:s,pollWhileOpen:c}=e;return B({queryKey:[t,`list_deployments`,{project:n,status:r,since:i,until:a,limit:o,offset:s}],queryFn:()=>QE(e),retry:!1,enabled:e.enabled!==!1,refetchInterval:c?e=>Gc((e.state.data?.deployments??[]).some(e=>!YE(e.status))?XE:ZE)(e):!1})}var eD={pending:`warning`,extracting:`warning`,installing:`warning`,loading:`warning`,replicating:`warning`,restarting:`warning`,success:`success`,failed:`destructive`,rolled_back:`destructive`,staged:`secondary`},tD={pending:`Pending`,extracting:`Extracting`,installing:`Installing`,loading:`Loading`,replicating:`Replicating`,restarting:`Restarting`,success:`Success`,failed:`Failed`,rolled_back:`Rolled back`,staged:`Staged`};function nD({status:e}){return(0,K.jsx)(ol,{variant:eD[e]??`secondary`,children:tD[e]??e})}function rD(e,t){return qg(e,`config/deployments/${encodeURIComponent(t)}`)}function iD(){let e=De(),t=z({strict:!1});return(0,G.useCallback)(n=>n?{label:`View record`,onClick:()=>void e({to:rD(t,n)})}:void 0,[e,t])}function aD(e){return e.length>8?e.slice(0,8):e}function oD(e){if(e.activated_from)return{label:`Activation of ${aD(e.activated_from)}`,title:e.activated_from};if(e.package_identifier)return{label:e.package_identifier,title:e.package_identifier};if(e.payload_hash)return{label:`Payload ${e.payload_hash.slice(0,12)}`,title:e.payload_hash}}function sD({deployment:e}){let t=z({strict:!1});return(0,K.jsx)(V,{to:rD(t,e.deployment_id),title:e.deployment_id,className:`font-mono underline`,onClick:e=>e.stopPropagation(),children:aD(e.deployment_id)})}function cD({release:e}){return!e||e.kind===`unknown`?null:(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.kind===`waiting`&&`waiting to be activated`,e.kind===`activating`&&(0,K.jsxs)(K.Fragment,{children:[`being activated by `,(0,K.jsx)(sD,{deployment:e.activation})]}),e.kind===`live`&&(0,K.jsxs)(K.Fragment,{children:[`live, activated by `,(0,K.jsx)(sD,{deployment:e.activation})]}),e.kind===`replaced`&&(0,K.jsxs)(K.Fragment,{children:[`activated by `,(0,K.jsx)(sD,{deployment:e.activation}),`, replaced by`,` `,(0,K.jsx)(sD,{deployment:e.replacedBy})]}),e.kind===`uncertain`&&(e.activation?(0,K.jsxs)(K.Fragment,{children:[`activated by `,(0,K.jsx)(sD,{deployment:e.activation}),`, may not be live everywhere`]}):(0,K.jsxs)(K.Fragment,{children:[`activation `,(0,K.jsx)(sD,{deployment:e.failed}),` failed`]}))]})}var lD=Bb();function uD(e){return e?Bm((Date.now()-e)/1e3,e):`—`}var dD=[lD.display({header:`Deployment`,id:`deployment_id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs`,title:e.row.original.deployment_id,children:aD(e.row.original.deployment_id)})}),{header:`Component`,accessorKey:`project`,enableSorting:!1},lD.display({header:`Status`,id:`status`,enableSorting:!1,cell:e=>(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsx)(nD,{status:e.row.original.status}),e.row.original.status===`staged`&&(0,K.jsx)(cD,{release:e.row.original.release})]})}),lD.display({header:`Source`,id:`source`,enableSorting:!1,cell:e=>{let t=oD(e.row.original);return t?(0,K.jsx)(`span`,{className:`break-all text-xs`,title:t.title,children:t.label}):`—`}}),{header:`User`,accessorKey:`user`,enableSorting:!1},lD.display({header:`Started`,id:`started_at`,enableSorting:!1,cell:e=>uD(e.row.original.started_at)})],fD=[`pending`,`extracting`,`installing`,`loading`,`replicating`,`restarting`,`success`,`failed`,`staged`];function pD(e){return e?fD:fD.filter(e=>e!==`staged`)}function mD(e){let t=typeof e.project==`string`?e.project.trim():``,n=fD.find(t=>t===e.status),r=Number(e.page);return{project:t||void 0,status:n,page:Number.isInteger(r)&&r>1?r:void 0}}var hD=e=>e?.started_at??0;function gD(e,t){let n=t.filter(t=>t.project===e.project&&t.deployment_id!==e.deployment_id).sort((e,t)=>hD(t)-hD(e)),r=n.filter(e=>e.status===`success`),i=(e,t=()=>!0)=>n.find(n=>n.status===`failed`&&hD(n)>hD(e)&&t(n)),a=n.find(t=>!YE(t.status)&&t.activated_from===e.deployment_id&&hD(t)>hD(r[0]));if(a)return{kind:`activating`,activation:a};let o=r.find(t=>t.activated_from===e.deployment_id);if(!o){let t=i(r[0],t=>t.activated_from===e.deployment_id);return t?{kind:`uncertain`,failed:t}:{kind:`waiting`}}if(r[0]!==o)return{kind:`replaced`,activation:o,replacedBy:r[0]};let s=i(o)??(o.peer_results?.some(e=>e.status===`failed`)?o:void 0);return s?{kind:`uncertain`,activation:o,failed:s}:{kind:`live`,activation:o}}function _D(e){let t=new Map;for(let{project:n,status:r,started_at:i}of e){if(r!==`staged`)continue;if(!t.has(n)){t.set(n,i);continue}let e=t.get(n);e!==void 0&&(i===void 0||i<e)&&t.set(n,i)}return t}var vD={kind:`unknown`};function yD(e){return e.map(e=>e.data===void 0&&e.isError?null:e.data)}function bD(e){let t=q(),n=(0,G.useMemo)(()=>[..._D(e)],[e]),r=et({queries:n.map(([e,n])=>$E({...t,project:e,since:n,pollWhileOpen:!0})),combine:yD});return(0,G.useMemo)(()=>{let t=new Map(n.map(([e],t)=>[e,r[t]])),i=new Map;for(let n of e){if(n.status!==`staged`)continue;let e=t.get(n.project);i.set(n.deployment_id,e===null?vD:e&&gD(n,e.deployments))}return i},[e,n,r])}function xD({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,K.jsx)(nn,{"data-slot":`separator-root`,decorative:n,orientation:t,className:F(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}async function*SD(e,t){let n=e.getReader(),r=new TextDecoder(`utf-8`),i=``,a=!1;try{for(;;){if(t?.aborted)return;let{value:e,done:s}=await n.read();if(s){a=!0;break}i+=r.decode(e,{stream:!0}),yield*o()}if(i+=r.decode(),i.trim()){let e=CD(i);e&&(yield e)}}finally{a||n.cancel().catch(()=>{}),n.releaseLock()}function*o(){for(;;){let e=i.indexOf(`
|
|
28
|
+
|
|
29
|
+
`),t=i.indexOf(`\r
|
|
30
|
+
\r
|
|
31
|
+
`),n=-1,r=0;if(e!==-1&&(t===-1||e<t)?(n=e,r=2):t!==-1&&(n=t,r=4),n===-1)return;let a=i.slice(0,n);i=i.slice(n+r);let o=CD(a);o&&(yield o)}}}function CD(e){let t=e.split(/\r?\n/),n=`message`,r,i,a=[];for(let e of t){if(e===``||e.startsWith(`:`))continue;let t=e.indexOf(`:`),o=t===-1?e:e.slice(0,t),s=t===-1?``:e.slice(t+1);switch(s.startsWith(` `)&&(s=s.slice(1)),o){case`event`:n=s;break;case`data`:a.push(s);break;case`id`:r=s;break;case`retry`:{let e=Number(s);Number.isFinite(e)&&(i=e);break}}}return a.length===0&&n===`message`?null:{event:n,data:a.join(`
|
|
32
|
+
`),id:r,retry:i}}function wD(e){try{return JSON.parse(e.data)}catch{return e.data}}var TD=class extends Error{status;constructor(e,t){super(e,t),this.name=`SSEUnsupportedError`,this.status=t?.status}},ED=class extends Error{constructor(e,t){super(e,t),this.name=`SSEInconclusiveError`}},DD=class extends Error{code;phase;deploymentId;certification;constructor(e,t){super(e),this.name=`SSEOperationError`,this.code=t?.code,this.phase=t?.phase,this.deploymentId=t?.deploymentId,this.certification=t?.certification}};function OD({id:e=m,operationsUrl:t,port:n,secure:r,forceFabricConnect:i,disableFabricConnect:a}={}){let o=t||u.getOperationsUrl(e);if(o&&(n||r!==void 0)){let e=new URL(o);n&&(e.port=String(n)),r!==void 0&&(e.protocol=r?`https:`:`http:`),o=e.toString()}let s=u.checkForBasicAuth(e),c=i||a||s?void 0:u.getOperationToken(e),l=!c&&!a&&(i||u.checkForFabricConnect(e));if(l&&(e.startsWith(`clu-`)?o=P.defaults.baseURL+`/Cluster/${e}/operation`:e.startsWith(`ins-`)&&(o=P.defaults.baseURL+`/HDBInstance/${e}/operation`)),!o)throw Error(`No operations URL is known for "${e}"; cannot open an SSE stream.`);let d={"Content-Type":`application/json`,Accept:`text/event-stream`};return c?d.Authorization=`Bearer ${c}`:s&&!l&&(d.Authorization=`Basic ${btoa(`${s.username}:${s.password}`)}`),{url:o.replace(/\/+$/,``)+`/`,headers:d,credentials:l||!s&&!c?`include`:`same-origin`,mode:l?`proxy`:`direct`}}async function kD({connection:e,body:t,signal:n,idleTimeoutMs:r=12e4,onMessage:i}){let{url:a,headers:o,credentials:s}=OD(e),c=new AbortController,{signal:l,cleanup:u}=AD([n,c.signal]),d,f=()=>{d&&clearTimeout(d),d=setTimeout(()=>c.abort(),r)};try{let e;try{f(),e=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(t),signal:l})}catch(e){throw n?.aborted?e:new TD(`Failed to open the SSE stream.`,{cause:e})}let r=e.headers.get(`content-type`)??``;if(!e.ok||!r.includes(`text/event-stream`)||!e.body)throw await e.body?.cancel().catch(()=>{}),new TD(`Server did not return an event stream (status ${e.status}, content-type "${r}").`,{status:e.status});let u=!1,d;try{for await(let t of SD(e.body,l)){if(f(),i?.(t),t.event===`done`){u=!0;let e=wD(t);d=e?.result??e;break}if(t.event===`error`){u=!0;let e=wD(t);if(!e||typeof e!=`object`)throw new DD(typeof e==`string`&&e?e:`The operation failed.`);let n=e;throw new DD(pr(n.message)??`The operation failed.`,{code:n.code,phase:n.phase,deploymentId:n.deployment_id,certification:n.certification})}}}catch(e){throw c.signal.aborted&&!n?.aborted?new ED(`The stream went idle before completing.`,{cause:e}):e}if(!u)throw new ED(`The stream ended without a terminal event.`);return d}finally{clearTimeout(d),u()}}function AD(e){let t=()=>{},n=e.filter(e=>!!e);if(n.length===1)return{signal:n[0],cleanup:t};if(typeof AbortSignal.any==`function`)return{signal:AbortSignal.any(n),cleanup:t};let r=new AbortController;function i(){for(let e of n)e.removeEventListener(`abort`,a)}function a(e){r.abort(e.target.reason),i()}for(let e of n){if(e.aborted){r.abort(e.reason),i();break}e.addEventListener(`abort`,a)}return{signal:r.signal,cleanup:i}}var jD=[`prepare`,`load`,`replicate`,`restart`,`success`],MD=[`prepare`,`load`,`replicate`,`staged`];function ND(e){switch(e.event){case`phase`:return{type:`phase`,data:wD(e)};case`install`:return{type:`install`,data:wD(e)};case`peer`:return{type:`peer`,data:wD(e)};case`warning`:{let t=wD(e);return{type:`warning`,data:typeof t==`string`?{message:t}:t??{}}}}}async function PD({connection:e,body:t,signal:n,onEvent:r}){let i=[],a=await kD({connection:e,body:t,signal:n,onMessage:e=>{let t=ND(e);t&&(t.type===`warning`&&typeof t.data.message==`string`&&t.data.message&&i.push(t.data.message),r?.(t))}})??{};return i.length?{...a,warnings:i}:a}var FD=/Failed to deploy private repository\b|SSH access failed/i;function ID({title:e,message:t,deploymentId:n,onNavigateAway:r}){let i=z({strict:!1});return(0,K.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 text-sm text-destructive`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Ii,{className:`mt-0.5 size-4 shrink-0`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 break-words`,children:[e&&(0,K.jsx)(`span`,{className:`font-medium`,children:e}),(0,K.jsx)(`span`,{children:t})]})]}),FD.test(t)&&(0,K.jsx)(V,{to:qg(i,`config/ssh-keys`),onClick:r,className:`self-start pl-6 underline`,children:`Manage SSH keys`}),n&&(0,K.jsx)(V,{to:rD(i,n),onClick:r,className:`self-start pl-6 underline`,children:`View this deployment's record`})]})}function LD(e){switch(e){case`certified`:return{label:`Certified`,detail:`Its canary loaded the release before it served.`,certified:!0};case`uncertified`:return{label:`Not certified`,detail:`It went out unchecked: the component ran nothing as it loaded (dev-only loading, an absent if-installed component, or safe mode), or no worker was replaced.`,certified:!1};case`unavailable`:return{label:`Not certified`,detail:`It restarted unchecked: no worker on this node loads the component, its isolated setting changed with this deploy, it was already live, or it was deployed from a local directory.`,certified:!1};case`not-requested`:return{label:`Not certified`,detail:`The deploy did not restart, so nothing checked it.`,certified:!1};default:return{label:`Not certified (${e})`,certified:!1}}}function RD(e){let t=e.status===`rejected`?`Its canary rejected this release on the node that received the deploy.`:e.status===`interrupted`?`Its restart stopped before the canary decided, on the node that received the deploy.`:`It was not certified (${e.status}) on the node that received the deploy.`,n=e.restored?`Deployment ${e.restored}, the release it replaced, is live there again.`:e.failedClosed?`There was no earlier release to restore, so the component is failed closed there until it is deployed again.`:void 0;return{title:t,reason:e.reason,outcome:n}}function zD(e){switch(e.unfollowable){case`not-found`:return`Studio couldn't find this deploy's restart job on the node it reached, so it can't tell how the other nodes took the release. Check their status before relying on it.`;case`refused`:return`Studio couldn't read this deploy's restart job, so it can't tell how the other nodes took the release. Check their status before relying on it.`;case`timed-out`:return`The other nodes were still restarting after 30 minutes, so Studio stopped waiting. The restart may still finish; check their status before relying on it.`;case`unrecognized`:return`This deploy's restart job finished, but Studio couldn't read how the other nodes took the release. Check their status before relying on it.`}}function BD(e){switch(e.outcome){case`activated`:return e.certification?{label:LD(e.certification).label}:{label:`Took the release`};case`restarted`:return{label:`Restarted`};case`failed`:return{label:`Did not take the release`,detail:e.detail};case`unconfirmed`:return{label:`Restart not confirmed`,detail:e.detail}}}var VD={prepare:`Prepare`,load:`Load`,replicate:`Replicate`,restart:`Restart`,success:`Finish`,staged:`Staged`};function HD(e,t){let n=new Set,r=!1;for(let i=e.length-1;i>=0;i--)t[e[i]]?r=!0:r&&n.add(e[i]);return n}function UD({status:e,isCurrent:t,skipped:n}){return n?(0,K.jsx)(Mi,{className:`size-4 text-muted-foreground`}):e===`done`?(0,K.jsx)(tr,{className:`size-4 text-success`}):e===`error`?(0,K.jsx)(Ks,{className:`size-4 text-destructive`}):e===`start`||t?(0,K.jsx)(no,{className:`size-4 animate-spin text-primary`}):(0,K.jsx)(Ai,{className:`size-4 text-muted-foreground`})}function WD({state:e,onNavigateAway:t,staging:n=!1}){let r=(0,G.useRef)(null),i=z({strict:!1});(0,G.useEffect)(()=>{r.current?.scrollIntoView({block:`end`})},[e.installLog.length]);let a=e.lifecycle===`error`,o=n?MD:jD,s=HD(o,e.phases);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(`ol`,{className:`flex flex-col gap-2`,children:o.map(t=>{let n=e.phases[t],r=e.currentPhase===t&&n!==`done`,i=s.has(t);return(0,K.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(UD,{status:n,isCurrent:r,skipped:i}),(0,K.jsx)(`span`,{className:F(n?`text-foreground`:`text-muted-foreground`),children:VD[t]??t}),i&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`skipped`})]},t)})}),e.installLog.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(xD,{className:`mb-2`}),(0,K.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Install output`}),(0,K.jsx)(sl,{className:`h-40 rounded-md border bg-muted/40`,children:(0,K.jsxs)(`pre`,{className:`whitespace-pre-wrap break-words p-2 font-mono text-xs leading-relaxed`,children:[e.installLog.map(e=>(0,K.jsx)(`div`,{className:F(e.stream===`stderr`&&`text-destructive`),children:e.line},e.id)),(0,K.jsx)(`div`,{ref:r})]})})]}),e.peers.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(xD,{className:`mb-2`}),(0,K.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Replication`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.peers.map((e,t)=>{let n=e.status===`failed`,r=pr(e.error??e.reason);return(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[n?(0,K.jsx)(Ks,{className:`size-4 text-destructive`}):(0,K.jsx)(tr,{className:`size-4 text-success`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.node??`node ${t+1}`})]}),n&&r&&(0,K.jsx)(`span`,{className:`truncate text-xs text-destructive`,children:r})]},t)})})]}),!!e.warnings?.length&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(xD,{className:`mb-2`}),(0,K.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Warnings`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.warnings.map((e,t)=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Rs,{className:`mt-0.5 size-4 shrink-0 text-amber-500`}),(0,K.jsx)(`span`,{className:`break-words`,children:e})]},t))})]}),e.certification&&(0,K.jsx)(GD,{certification:e.certification}),e.rollout&&(0,K.jsx)(qD,{rollout:e.rollout}),a&&e.decision&&(0,K.jsx)(KD,{decision:e.decision}),a&&e.error&&!e.decision&&(0,K.jsx)(ID,{message:e.error,onNavigateAway:t}),e.lifecycle===`inconclusive`&&!e.rollout&&(0,K.jsx)(ol,{variant:`warning`,className:`self-start`,children:`Live updates ended early — verifying…`}),e.deploymentId&&(0,K.jsx)(V,{to:rD(i,e.deploymentId),onClick:t,className:`self-start text-sm underline`,children:`View this deployment's record`})]})}function GD({certification:e}){let{label:t,detail:n,certified:r}=LD(e);return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[r?(0,K.jsx)(ds,{className:`mt-0.5 size-4 shrink-0 text-success`}):(0,K.jsx)(Rs,{className:`mt-0.5 size-4 shrink-0 text-amber-500`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-medium`,children:t}),n&&(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,n]})]})]})}function KD({decision:e}){let{title:t,reason:n,outcome:r}=RD(e);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium text-destructive`,children:t}),n&&(0,K.jsx)(`span`,{className:`break-words`,children:n}),r&&(0,K.jsx)(`span`,{children:r}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`No other node received it.`})]})}function qD({rollout:e}){let t=zD(e);return e.state===`complete`&&e.nodes.length===0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(xD,{className:`mb-2`}),(0,K.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Other nodes`}),e.state===`following`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(no,{className:`size-4 animate-spin text-primary`}),(0,K.jsx)(`span`,{children:`Rolling out to the other nodes, one at a time…`})]}),!!e.nodes.length&&(0,K.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.nodes.map((e,t)=>{let{label:n,detail:r}=BD(e);return(0,K.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(JD,{outcome:e.outcome}),(0,K.jsx)(`span`,{className:`truncate`,children:e.node}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n})]}),r&&(0,K.jsx)(`span`,{className:F(`break-words pl-6 text-xs`,e.outcome===`failed`&&`text-destructive`),children:r})]},`${e.node}-${t}`)})}),e.state===`failed`&&e.message&&(0,K.jsx)(`div`,{className:`mt-1 break-words text-sm text-destructive`,children:e.message}),t&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,K.jsx)(Rs,{className:`mt-0.5 size-4 shrink-0 text-amber-500`}),(0,K.jsx)(`span`,{children:t})]})]})}function JD({outcome:e}){return e===`failed`?(0,K.jsx)(Ks,{className:`size-4 shrink-0 text-destructive`}):e===`unconfirmed`?(0,K.jsx)(Rs,{className:`size-4 shrink-0 text-amber-500`}):(0,K.jsx)(tr,{className:`size-4 shrink-0 text-success`})}async function YD({jobId:e,instanceClient:t,signal:n}){let{data:r}=await t.post(`/`,{operation:`get_job`,id:e},n?{signal:n}:void 0);return r?.[0]}var XD=class extends Error{constructor(e){super(e),this.name=`ImportJobError`}},ZD=e=>new Promise(t=>setTimeout(t,e));async function QD({jobId:e,instanceClient:t,pollIntervalMs:n=1500,timeoutMs:r=6e5,onUpdate:i}){let a=Date.now()+r,o=0;for(;;){let r;try{r=await YD({jobId:e,instanceClient:t}),o=0}catch(e){if(o+=1,o>=5)throw e}if(r&&i)try{i(r)}catch(e){console.debug(`waitForJob onUpdate failed`,e)}let s=r?.status?.toUpperCase();if(s===`ERROR`)throw new XD(pr(r?.message)??`The import job failed.`);if(s===`COMPLETE`&&r)return r;if(Date.now()>=a)throw Error(`Timed out waiting for the import job to finish. Check the table in a few minutes.`);await ZD(n)}}var $D=/^Successfully completed job\b/;function eO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tO(e){return typeof e.node==`string`&&e.node?e.node:`unknown node`}function nO(e){return e.filter(eO).map(e=>{let t=pr(e.error);return t?{node:tO(e),outcome:`failed`,detail:t}:{node:tO(e),outcome:`activated`,certification:typeof e.certification==`string`?e.certification:void 0}})}function rO(e){return e.filter(eO).map(e=>{let t=pr(e.message);return t&&$D.test(t)?{node:tO(e),outcome:`restarted`}:{node:tO(e),outcome:`unconfirmed`,detail:t}})}function iO(e,t){let n=typeof t.status==`string`?t.status.toUpperCase():void 0;if(n===`COMPLETE`){let n=eO(t.result)?t.result:void 0,r=Array.isArray(n?.activated)?nO(n.activated):Array.isArray(n?.replicated)?rO(n.replicated):void 0;return r?{jobId:e,state:r.some(e=>e.outcome===`failed`)?`failed`:`complete`,nodes:r}:{jobId:e,state:`unfollowable`,nodes:[],unfollowable:`unrecognized`}}if(n===`ERROR`){let n=eO(t.message)?t.message:void 0;return{jobId:e,state:`failed`,nodes:Array.isArray(n?.activated)?nO(n.activated):[],message:pr(n?n.error:t.message)??`The restart job failed.`}}return{jobId:e,state:`following`,nodes:[]}}function aO(e,t){return e<6e4?t:e<3e5?5e3:15e3}var oO=2e4;async function sO({instanceClient:e,jobId:t,onUpdate:n,signal:r,pollIntervalMs:i=2e3,timeoutMs:a=18e5}){let o=e=>(n?.(e),e),s=e=>o({jobId:t,state:`unfollowable`,nodes:[],unfollowable:e}),c=Date.now(),l;for(n?.({jobId:t,state:`following`,nodes:[]});;){r?.throwIfAborted();try{let n=await YD({jobId:t,instanceClient:e,signal:r});if(r?.throwIfAborted(),n){l=void 0;let e=iO(t,n);if(e.state!==`following`)return o(e)}else if(l??=Date.now(),Date.now()-l>=oO)return s(`not-found`)}catch(e){if(r?.throwIfAborted(),zc(e))return s(`refused`);l=void 0}let n=Date.now()-c;if(n>=a)return s(`timed-out`);await h(aO(n,i))}}var cO=class extends Error{rollout;deploymentId;constructor(e,t){let n=e.nodes.filter(e=>e.outcome===`failed`).map(e=>e.node);super(e.message??(n.length?`Not every node took this release: ${n.join(`, `)}.`:`The restart job failed.`)),this.name=`DeployRolloutError`,this.rollout=e,this.deploymentId=t}};function lO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function uO(e){if(lO(e)&&typeof e.status==`string`&&e.status)return{status:e.status,reason:typeof e.reason==`string`&&e.reason?e.reason:void 0,restored:typeof e.restored==`string`&&e.restored?e.restored:null,failedClosed:e.failed_closed===!0}}function dO(e){if(e instanceof DD)return{deploymentId:e.deploymentId,certification:uO(e.certification)};if(e instanceof cO)return{deploymentId:e.deploymentId};let t=e?.response?.data;return lO(t)?{deploymentId:typeof t.deployment_id==`string`&&t.deployment_id?t.deployment_id:void 0,certification:uO(t.certification)}:{}}var fO={lifecycle:`idle`,phases:{},installLog:[],peers:[]},pO=1e3;function mO(e,t){if(t?.result){let{certification:n,deployment_id:r,rollout:i,warnings:a}=t.result;return{certification:typeof n==`string`?n:void 0,deploymentId:r,...i?{rollout:i}:{},...!e.warnings?.length&&a?.length?{warnings:a}:{}}}if(t?.failure!==void 0){let{deploymentId:e,certification:n}=dO(t.failure);return{deploymentId:e,decision:n}}return{}}function hO(e,t){switch(t.kind){case`reset`:return fO;case`start`:return{...fO,lifecycle:`streaming`};case`event`:{let{event:n}=t;if(n.type===`phase`){let{phase:t,status:r}=n.data;return{...e,lifecycle:`streaming`,phases:{...e.phases,[t]:r},currentPhase:r===`start`?t:e.currentPhase}}if(n.type===`install`){let t=(e.installLog[e.installLog.length-1]?.id??0)+1,r=e.installLog.concat({id:t,stream:n.data.stream,line:n.data.line});return{...e,installLog:r.length>pO?r.slice(-1e3):r}}if(n.type===`warning`){let{message:t}=n.data;return typeof t==`string`&&t?{...e,warnings:(e.warnings??[]).concat(t)}:e}return n.type===`rollout`?{...e,rollout:n.data}:{...e,peers:e.peers.concat(n.data)}}case`settled`:return{...e,...mO(e,t.outcome),lifecycle:t.lifecycle,error:t.error}}}function gO(){let[e,t]=(0,G.useReducer)(hO,fO),n=(0,G.useCallback)(e=>t({kind:`event`,event:e}),[]),r=(0,G.useCallback)(()=>t({kind:`start`}),[]),i=(0,G.useCallback)(()=>t({kind:`reset`}),[]),a=(0,G.useCallback)((e,n,r)=>t({kind:`settled`,lifecycle:e,error:n,outcome:r}),[]);return(0,G.useMemo)(()=>({state:e,onEvent:n,markStarted:r,markSettled:a,reset:i}),[e,n,r,a,i])}var _O=/\bENOENT\b.*\bharper-git-clone-[^/\\\s]*[/\\]+package\.json\b/s,vO=`This repository has no package.json in its root folder. Harper deploys a git repository as an npm package, which needs one there, so add a package.json to the root of the repository and deploy again.`;function yO(e){let{message:t,title:n,detail:r,...i}=e;return i}function bO(e){return _O.test(e)?vO:e}function xO(e){if(e instanceof DD){let t=bO(e.message);return t===e.message?e:new DD(t,{code:e.code,phase:e.phase,deploymentId:e.deploymentId,certification:e.certification})}if(T(e)&&e.response){let{data:t}=e.response;if((typeof t==`string`?[t]:[t?.error,t?.message,t?.title,t?.detail].map(e=>pr(e))).some(e=>e!==void 0&&_O.test(e))){let n=typeof t==`string`?vO:{...yO(t),error:vO};return new E(vO,e.code,e.config,e.request,{...e.response,data:n})}}return e}async function SO({instanceClient:e,deploymentId:t}){let{data:n}=await e.post(`/`,{operation:`get_deployment`,deployment_id:t});return n}function CO(e){return B({queryKey:[e.entityId,`get_deployment`,e.deploymentId],queryFn:()=>SO(e),retry:!1,refetchInterval:t=>Gc(e.pollWhileActive&&!YE(t.state.data?.status)?2e3:!1)(t)})}async function wO({connection:e,deploymentId:t,signal:n,onEvent:r}){return await kD({connection:e,body:{operation:`get_deployment`,deployment_id:t},signal:n,onMessage:e=>{let t=r&&ND(e);t&&r(t)}})??{}}function TO(e){if(`install_matches`in e){if(e.install_matches===!0)return{label:`Installed the same as the node that received the deploy.`,matches:!0};if(e.install_matches===!1){let t=(e.install_differs??[]).map(t=>t===`source`&&e.install?.source?`source ${e.install.source}`:t);return{label:`Installed differently: ${t.length?t.join(`, `):`see the deploy log`}.`,matches:!1}}return{label:`Couldn't compare its install: a fingerprint is missing or unidentified.`,matches:null}}}function EO({...e}){return(0,K.jsx)(En,{"data-slot":`alert-dialog`,...e})}function DO({...e}){return(0,K.jsx)(vn,{"data-slot":`alert-dialog-portal`,...e})}function OO({className:e,...t}){return(0,K.jsx)(On,{"data-slot":`alert-dialog-overlay`,className:F(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-white/80 backdrop-blur-xs dark:bg-black/50 dark:backdrop-blur-none`,e),...t})}function kO({className:e,...t}){return(0,K.jsxs)(DO,{children:[(0,K.jsx)(OO,{}),(0,K.jsx)(mn,{"data-slot":`alert-dialog-content`,className:F(`bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg`,e),...t})]})}function AO({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:F(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function jO({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:F(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function MO({className:e,...t}){return(0,K.jsx)(gn,{"data-slot":`alert-dialog-title`,className:F(`text-lg font-semibold`,e),...t})}function NO({className:e,...t}){return(0,K.jsx)(Pn,{"data-slot":`alert-dialog-description`,className:F(`text-muted-foreground text-sm`,e),...t})}function PO({className:e,...t}){return(0,K.jsx)(Un,{className:F(pt(),e),...t})}function FO({className:e,...t}){return(0,K.jsx)(dn,{className:F(pt({variant:`outline`}),e),...t})}async function IO({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_components`});return t}function LO(e){return B({queryKey:[e.entityId,`get_components`],queryFn:()=>IO(e),retry:!1,enabled:e.enabled!==!1})}var RO=1500,zO=2e3,BO=8,VO=new Set([`healthy`,`warning`,`error`]);function HO(e,t){return e.entries.find(e=>e.name===t&&`entries`in e)}function UO(e){return(0,G.useCallback)(async t=>{await h(RO);let n={level:`indeterminate`};for(let r=0;r<BO;r++){try{let r=HO(await IO(e),t)?.status;if(r&&(n={level:r.status,message:r.message},VO.has(r.status)))return n}catch{}r<7&&await h(zO)}return n},[e])}function WO(e){let t=[],n=!1;if(typeof e?.certification==`string`){let{label:n,detail:r,certified:i}=LD(e.certification);i||t.push(r?`${n}: ${r}`:`${n}.`)}for(let r of e?.warnings??[])t.push(r),n=!0;let r=e?.rollout?.nodes.filter(e=>e.outcome===`unconfirmed`)??[];return r.length&&(t.push(`The restart was not confirmed on ${r.map(e=>e.node).join(`, `)}.`),n=!0),{lines:t,warn:n}}function GO(e,t){return[e,...t.lines].filter(Boolean).join(` `)||void 0}function KO(e,t,n={lines:[],warn:!1},r={}){switch(t.level){case`healthy`:if(n.warn){U.warning(`${e} deployed with warnings`,{...r,description:GO(t.message,n)});return}U.success(`${e} deployed and healthy`,{...r,description:GO(t.message,n)});return;case`warning`:U.warning(`${e} deployed with warnings`,{...r,description:GO(t.message??`The component loaded but reported a warning.`,n)});return;case`error`:U.error(`${e} deployed but failed to load`,{...r,description:GO(t.message??`The component reported an error after deploying.`,n)});return;default:U.success(`${e} deployed`,{...r,description:GO(`Still verifying — the component is loading. Check its status shortly.`,n)});return}}async function qO(e,t,n,r={}){return!$O(e,t,r)&&(KO(e,await n(e),WO(t),r),!0)}function JO(e,t,n,r={}){if($O(e,t,r))return;let i=WO(t);if(i.warn){U.warning(n.warningTitle??`${e} deployed with warnings`,{...r,description:GO(n.description,i)});return}U.success(n.title,{...r,description:GO(n.description,i)})}var YO={import:`imported`,stage:`staged`,redeploy:`redeployed`,activate:`activated`};function XO(e,t,n){return or(e)?`Couldn't confirm ${t} was ${YO[n]}`:`Failed to ${n} ${t}`}function ZO(e,t,n,r={}){if(t instanceof cO){U.error(`${e} did not reach every node`,{...r,description:t.message});return}U.error(XO(t,e,n),{...r,description:or(t)?ur:t instanceof Error?t.message:void 0})}function QO(e,t,n={}){let r=t?.deployment_id;JO(e,t,{title:`${e} staged`,warningTitle:`${e} staged with warnings`,description:`${r?`Deployment ${r}`:`It`} is installed on every node, waiting to be activated.`},n)}function $O(e,t,n){return t?.rollout?.state===`unfollowable`&&(U.warning(`${e} deployed on the node that received it`,{...n,description:zD(t.rollout)}),!0)}function ek(e,t){return e.kind===`activate`?{operation:`deploy_component`,project:e.project,deployment_id:e.deploymentId,replicated:t,restart:`rolling`}:{operation:`deploy_component`,package:e.package,project:e.project,replicated:t,install_command:e.installCommand||void 0,...e.kind===`stage`?{activate:!1}:{restart:`rolling`}}}function tk({status:e}){return e!==void 0&&e>=400&&e<500}async function nk(e){try{return await rk(e)}catch(e){throw xO(e)}}async function rk({request:e,entityType:t,entityId:n,instanceClient:r,useSSE:i,onEvent:a,signal:o}){let s=ek(e,t===`cluster`);if(i&&n)try{return await PD({connection:{id:n},body:s,signal:o,onEvent:a})}catch(e){if(!(e instanceof TD))throw e;if(!tk(e))throw new ED(`The live deploy did not stream and may already have started, so it was not sent again.`,{cause:e})}let{data:c}=await r.post(`/`,s,{timeout:3e5});return c}async function ik(e){let t=await nk(e),n=t?.restartJobId;if(typeof n!=`string`||!n)return t;let r=await sO({instanceClient:e.instanceClient,jobId:n,signal:e.signal,onUpdate:t=>e.onEvent?.({type:`rollout`,data:t})});if(r.state===`failed`)throw new cO(r,t.deployment_id);return{...t,rollout:r}}function ak(e){return I({mutationKey:e,mutationFn:ik,meta:{skipGlobalErrorToast:!0},onError:e=>console.error(e)})}function ok(e,t){return[`activate_deployment`,e,t]}var sk={activate:`Activate`,rollback:`Roll back to this release`,again:`Activate again`};function ck({deployment:e,intent:t=`activate`,offer:n=!0}){let r=q(),i=Ze(),a=qE(),o=GE(),s=gO(),c=UO(r),l=iD(),{project:u,deployment_id:d}=e,f=(0,G.useMemo)(()=>ok(r.entityId,d),[r.entityId,d]),{mutateAsync:p}=ak(f),m=Me({mutationKey:f})>0,[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),y=(0,G.useCallback)(async()=>{g(!1),v(!0),s.reset(),s.markStarted();try{let e=await p({request:{kind:`activate`,project:u,deploymentId:d},useSSE:a,onEvent:s.onEvent,...r});s.markSettled(e?.rollout?.state===`unfollowable`?`inconclusive`:`success`,void 0,{result:e}),mr(i,r.entityId),await qO(u,e,c,{action:l(e?.deployment_id)})}catch(e){if(mr(i,r.entityId),e instanceof ED){s.markSettled(`inconclusive`),U.warning(`${u} may not be activated`,{description:`Live updates ended before the activation finished. Check Deployments for its record.`});return}s.markSettled(`error`,e instanceof cO?void 0:or(e)?ur:e instanceof Error?e.message:String(e),{failure:e}),ZO(u,e,`activate`,{action:l(dO(e).deploymentId)})}},[p,u,d,a,s,r,i,c,l]);if(!o)return null;let b=_?s.state.lifecycle:`idle`,x=b===`error`||b===`inconclusive`,S=m||x||n&&b!==`success`,C=x&&!n?`again`:t;return(0,K.jsxs)(K.Fragment,{children:[S&&(0,K.jsxs)(H,{variant:`positiveOutline`,className:`self-start`,onClick:()=>g(!0),disabled:m,children:[(0,K.jsx)(qo,{}),` `,m?`Activating…`:sk[C]]}),_&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xD,{}),(0,K.jsx)(WD,{state:s.state})]}),(0,K.jsx)(EO,{open:h,onOpenChange:g,children:(0,K.jsxs)(kO,{children:[(0,K.jsxs)(AO,{children:[(0,K.jsx)(MO,{children:C===`rollback`?`Roll ${u} back to this release?`:`Activate this release of ${u}${C===`again`?` again`:``}?`}),(0,K.jsx)(NO,{children:C===`rollback`?(0,K.jsxs)(K.Fragment,{children:[`Deployment `,(0,K.jsx)(`span`,{className:`font-mono`,children:d}),` `,`goes live again on all nodes, which restart one at a time. Each node kept this release installed when it was replaced, so it just switches back. A node that no longer keeps it refuses.`]}):(0,K.jsxs)(K.Fragment,{children:[`Deployment `,(0,K.jsx)(`span`,{className:`font-mono`,children:d}),` `,`goes live on all nodes, which restart one at a time. Everything was installed when this release was staged, so each node just switches to it.`,C===`again`&&` A node already running it restarts without changing anything.`]})})]}),(0,K.jsxs)(jO,{children:[(0,K.jsx)(FO,{children:`Cancel`}),(0,K.jsx)(PO,{onClick:()=>void y(),children:sk[C]})]})]})})]})}var lk=e=>Bm((Date.now()-e)/1e3,e);function uk({release:e}){let{activation:t,failed:n}=e;return t?(0,K.jsxs)(K.Fragment,{children:[`Activated by `,(0,K.jsx)(sD,{deployment:t}),`, `,n===t?`but some nodes did not take it`:(0,K.jsxs)(K.Fragment,{children:[`but a later deploy, `,(0,K.jsx)(sD,{deployment:n}),`, failed and may have gone live on some nodes`]}),`, so it may not be live everywhere. Activating it again puts it back wherever it is missing.`]}):(0,K.jsxs)(K.Fragment,{children:[`Its activation,`,` `,(0,K.jsx)(sD,{deployment:n}),`, failed. Depending on where it failed, it may be live on some nodes. Activating it again retries it.`]})}function dk({deployment:e}){let t=bD((0,G.useMemo)(()=>[e],[e])).get(e.deployment_id);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[!t&&`Staged. Checking whether it has been activated…`,t?.kind===`waiting`&&`Staged: built and installed, but not live. Activating it just switches each node to it.`,t?.kind===`unknown`&&`Staged. Couldn't read the deployments since, so it may already be live: activating a live release restarts every node without changing anything.`,t?.kind===`activating`&&(0,K.jsxs)(K.Fragment,{children:[`Being activated by `,(0,K.jsx)(sD,{deployment:t.activation}),`, which`,` `,t.activation.started_at?`started ${lk(t.activation.started_at)} and `:``,`has not finished. While it runs, activating it again starts a second rolling restart. If it stopped without finishing, activate it again.`]}),t?.kind===`live`&&(0,K.jsxs)(K.Fragment,{children:[`Live: activated by `,(0,K.jsx)(sD,{deployment:t.activation}),`, and no other deploy of`,` `,e.project,` has finished since, so there is nothing to activate.`]}),t?.kind===`replaced`&&(0,K.jsxs)(K.Fragment,{children:[`Activated by `,(0,K.jsx)(sD,{deployment:t.activation}),`, then replaced by`,` `,(0,K.jsx)(sD,{deployment:t.replacedBy}),`. Activating it again rolls `,e.project,` `,`back to this release.`]}),t?.kind===`uncertain`&&(0,K.jsx)(uk,{release:t})]}),(0,K.jsx)(ck,{deployment:e,intent:t?.kind===`replaced`?`rollback`:t?.kind===`uncertain`||t?.kind===`activating`?`again`:`activate`,offer:t!==void 0&&t.kind!==`live`})]})}function fk({label:e,value:t}){return t==null||t===``?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,K.jsx)(`span`,{className:`break-words text-sm`,children:t})]})}function pk(e){return e?Bm((Date.now()-e)/1e3,e):void 0}function mk({deploymentId:e}){let t=q(),n=z({strict:!1}),r=qE(),i=Ze(),a=gO(),{data:o,isLoading:s,error:c}=L(CO({...t,deploymentId:e,pollWhileActive:!0})),l=!!o&&!YE(o.status);if((0,G.useEffect)(()=>{if(!r||!l)return;let n=new AbortController;return a.reset(),a.markStarted(),wO({connection:{id:t.entityId},deploymentId:e,signal:n.signal,onEvent:a.onEvent}).then(()=>a.markSettled(`success`)).catch(()=>{n.signal.aborted||a.markSettled(`inconclusive`)}).finally(()=>{n.signal.aborted||i.invalidateQueries({queryKey:[t.entityId,`get_deployment`,e]})}),()=>n.abort()},[r,l,e,t.entityId]),s)return(0,K.jsx)(Lc,{className:`flex h-full flex-col items-center justify-center`,text:`Loading deployment...`});if(c||!o)return(0,K.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:`Could not load this deployment.`});let u=l&&(a.state.installLog.length>0||Object.keys(a.state.phases).length>0);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 p-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:o.project}),(0,K.jsx)(nD,{status:o.status}),o.phase&&(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:o.phase})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3`,children:[(0,K.jsx)(fk,{label:`Deployment ID`,value:(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:o.deployment_id})}),(0,K.jsx)(fk,{label:`User`,value:o.user}),(0,K.jsx)(fk,{label:`Origin node`,value:o.origin_node}),(0,K.jsx)(fk,{label:`Started`,value:pk(o.started_at)}),(0,K.jsx)(fk,{label:`Completed`,value:pk(o.completed_at)}),(0,K.jsx)(fk,{label:`Restart mode`,value:o.restart_mode??void 0}),(0,K.jsx)(fk,{label:`Package`,value:o.package_identifier??void 0}),(0,K.jsx)(fk,{label:`Payload size`,value:o.payload_size==null?void 0:zy(o.payload_size)}),(0,K.jsx)(fk,{label:`Payload hash`,value:o.payload_hash?(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:o.payload_hash}):void 0}),(0,K.jsx)(fk,{label:`Installed from`,value:o.install_fingerprint?.source?(0,K.jsx)(`span`,{className:`break-all font-mono text-xs`,children:o.install_fingerprint.source}):void 0}),(0,K.jsx)(fk,{label:`Activation of`,value:o.activated_from?(0,K.jsx)(V,{to:rD(n,o.activated_from),className:`font-mono text-xs underline`,children:o.activated_from}):void 0})]}),o.status===`staged`&&(0,K.jsx)(dk,{deployment:o}),u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xD,{}),(0,K.jsx)(WD,{state:a.state})]}),o.error&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xD,{}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm`,children:[(0,K.jsxs)(`span`,{className:`font-medium text-destructive`,children:[`Error`,typeof o.error.phase==`string`&&o.error.phase?` during ${o.error.phase}`:``,typeof o.error.code==`string`||typeof o.error.code==`number`?` (${o.error.code})`:``]}),(0,K.jsx)(`span`,{className:`break-words`,children:bO(pr(o.error)??`Unknown error`)})]})]}),!!o.peer_results?.length&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xD,{}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Other nodes`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:o.peer_results.map((e,t)=>{let n=pr(e.error),r=TO(e);return(0,K.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.node}),(0,K.jsxs)(`span`,{className:e.status===`failed`?`text-destructive`:`text-success`,children:[e.status??`ok`,n?`: ${n}`:``]})]}),r&&(0,K.jsx)(`span`,{className:F(`text-xs`,r.matches===!1?`text-amber-600`:`text-muted-foreground`),children:r.label})]},e.node??t)})})]})]}),!!o.event_log?.length&&(0,K.jsx)(hk,{deployment:o})]})}function hk({deployment:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xD,{}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Activity`}),(0,K.jsx)(`ol`,{className:`flex flex-col gap-1 text-xs`,children:e.event_log.map((e,t)=>(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:new Date(e.t).toLocaleTimeString()}),(0,K.jsx)(`span`,{className:`font-medium`,children:e.event}),(0,K.jsx)(`span`,{className:`break-words text-muted-foreground`,children:bO(typeof e.data==`string`?e.data:JSON.stringify(e.data))})]},t))})]})]})}function gk({deploymentId:e,isModalOpen:t,closeModal:n}){return(0,K.jsx)(_m,{onOpenChange:n,open:t,children:(0,K.jsxs)(wm,{resizable:!0,"aria-describedby":void 0,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:`Deployment`})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,K.jsx)(mk,{deploymentId:e})})]})})}var _k=`all`;function vk(){let e=De(),t=Cg(),{deploymentId:n}=z({strict:!1}),{project:r,status:i,page:a=1}=Oe({strict:!1}),o=q(),{data:s,isError:c}=L(HE(o)),l=s!==void 0,u=!l&&c,d=UE(s?.version),f=pD(WE(s?.version)),p=i&&f.includes(i)?i:void 0,m=l&&!!i&&!p;(0,G.useEffect)(()=>{m&&e({to:`.`,search:e=>({...e,status:void 0}),replace:!0})},[m,e]);let{data:h,isFetching:g,isRefetching:_,refetch:v,error:y}=L($E({...o,project:r,status:p,limit:25,offset:(a-1)*25,enabled:t&&d,pollWhileOpen:!0})),b=(0,G.useMemo)(()=>h?.deployments??[],[h]),x=bD(b),S=(0,G.useMemo)(()=>b.map(e=>x.has(e.deployment_id)?{...e,release:x.get(e.deployment_id)}:e),[b,x]),C=h?.total??0,w=C===0?0:(a-1)*25+1,T=Math.min(C,(a-1)*25+b.length),E=!!r||!!p,D=(0,G.useCallback)(t=>{e({to:`.`,search:e=>({...e,...t})})},[e]),O=(0,G.useCallback)(e=>{let t=e.trim()||void 0;t!==r&&D({project:t,page:void 0})},[r,D]),k=(0,G.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)||`.`,search:!0})},[n,e]),A=(0,G.useCallback)(e=>k(e.original.deployment_id),[k]),j=(0,G.useCallback)(()=>k(void 0),[k]),M=Kb(v),ee=(0,G.useRef)(null);return(0,G.useEffect)(()=>{ee.current&&ee.current.value.trim()!==(r??``)&&(ee.current.value=r??``)},[r]),t?l&&!d?(0,K.jsx)(`div`,{className:`p-2 text-sm text-muted-foreground`,children:`Deployment history needs Harper 5.1 or later on this instance.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Hb,{data:S,isFetching:g||_||!l&&!u,columns:dD,onRowClick:A,children:[(0,K.jsxs)(`form`,{className:`flex grow flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),O(String(new FormData(e.currentTarget).get(`project`)??``))},children:[(0,K.jsx)($,{ref:ee,name:`project`,"aria-label":`Component`,placeholder:`Component (Enter to filter)`,defaultValue:r??``,className:`w-56`}),(0,K.jsxs)(hy,{value:p??_k,onValueChange:e=>D({status:e===_k?void 0:e,page:void 0}),children:[(0,K.jsx)(vy,{"aria-label":`Status`,className:`w-44`,children:(0,K.jsx)(_y,{})}),(0,K.jsxs)(yy,{children:[(0,K.jsx)(xy,{value:_k,children:`All statuses`}),f.map(e=>(0,K.jsx)(xy,{value:e,children:tD[e]},e))]})]})]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:M,accessKey:`r`,disabled:g||_,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]}),(y||u)&&(0,K.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`Could not load deployments. This instance may not support deployment history.`}),!y&&!g&&l&&b.length===0&&(0,K.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:C>0?(0,K.jsxs)(K.Fragment,{children:[`Nothing on this page.`,` `,(0,K.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>D({page:void 0}),children:`Go to the first page`})]}):E?`No deployments match these filters.`:`No deployments yet.`}),b.length>0&&(0,K.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,`–`,T,` of `,C]}),(0,K.jsx)(H,{variant:`ghostOutline`,size:`sm`,"aria-label":`Previous page`,disabled:a<=1,onClick:()=>D({page:a-1>1?a-1:void 0}),children:(0,K.jsx)(bi,{})}),(0,K.jsx)(H,{variant:`ghostOutline`,size:`sm`,"aria-label":`Next page`,disabled:a*25>=C,onClick:()=>D({page:a+1}),children:(0,K.jsx)(Si,{})})]}),!!n&&(0,K.jsx)(gk,{deploymentId:n,isModalOpen:!0,closeModal:j})]}):(0,K.jsx)(`div`,{className:`p-2 text-sm text-muted-foreground`,children:`Viewing deployments requires super-user permissions on this instance.`})}function yk(){return(0,K.jsx)(bT,{})}function bk(e){return!!e&&vr(`5.3.0-alpha.1`,e)}function xk(e){return!!e&&typeof e==`object`&&typeof e.id==`string`}async function Sk({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_oidc_trust`});return Array.isArray(t?.policies)?t.policies.filter(xk):[]}function Ck(e){return B({queryKey:[e.entityId,`list_oidc_trust`],queryFn:()=>Sk(e),enabled:e.enabled})}function wk(e){return e.operations!=null}var Tk=new Set([`invalid_reason`,`updated_by`,`__createdtime__`,`__updatedtime__`]);function Ek(e,t){let{operations:n}=e;if(n!=null&&!(Array.isArray(n)&&n.every(e=>typeof e==`string`)))throw Error(`Trust policy '${e.id}' has a malformed operations scope, so it cannot be re-saved.`);let r={};for(let[t,n]of Object.entries(e))n!=null&&!Tk.has(t)&&(r[t]=n);return{...r,operation:`add_oidc_trust`,enabled:t}}function Dk(e){if(Array.isArray(e))return`[${e.map(Dk).join(`,`)}]`;if(typeof e==`object`&&e){let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${Dk(t[e])}`).join(`,`)}}`}return JSON.stringify(e)??`null`}async function Ok(e,t){let n=(await Sk(e)).find(e=>e.id===t.id);if(!n)throw Error(`Trust policy '${t.id}' no longer exists.`);if(Dk(n)!==Dk(t))throw Error(`Trust policy '${t.id}' changed since this page loaded it. Review it and try again.`);return n}async function kk({loaded:e,enabled:t,...n}){let r=await Ok(n,e),{data:i}=await n.instanceClient.post(`/`,Ek(r,t));return i}function Ak(){return I({mutationFn:kk})}async function jk({loaded:e,...t}){await Ok(t,e);let{data:n}=await t.instanceClient.post(`/`,{operation:`drop_oidc_trust`,id:e.id});return n}function Mk(){return I({mutationFn:jk})}var Nk=`flex items-center p-2 rounded-lg group`,Pk={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-gray-700`},Fk={className:`text-black bg-white pointer-events-none cursor-default`};function Ik(){let e=z({strict:!1}),{version:t}=Ce({strict:!1}),n=vr(`4.6.0`,t),r=vr(`5.1.0`,t),i=vr(`5.2.0-alpha.1`,t),a=bk(t),{clusterId:o}=e,s=Cg(),{data:c}=L(_f(o,!1));c===void 0||ff(c);let l=s&&(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/certificates`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(ds,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Certificates`})]})}),r&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/deployments`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(qo,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Deployments`})]})}),!1,(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/roles`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(Ia,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Roles`})]})}),i&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/secrets`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(oo,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Secrets`})]})}),n&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/ssh-keys`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(Wa,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`SSH Keys`})]})}),a&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/trust-policies`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(Qr,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Trust Policies`})]})}),(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config/users`),className:Nk,inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(Ws,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Users`})]})})]});return(0,K.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-(--spacing(36)))]`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 text-foreground md:col-span-4 lg:col-span-3 md:border-r border-b md:border-b-0 md:pr-4 border-gray-700`,children:[(0,K.jsx)(Lk,{params:e,children:l}),(0,K.jsx)(Rk,{params:e,children:l})]}),(0,K.jsx)(`section`,{className:`col-span-1 text-foreground md:col-span-8 lg:col-span-9 md:pt-4`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:(0,K.jsx)(st,{})})})]})}function Lk({params:e,children:t}){return(0,K.jsxs)(`div`,{className:`hidden md:block pl-4 pt-4`,children:[(0,K.jsxs)(V,{to:qg(e,`config`),className:Nk,activeOptions:{exact:!0},inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(vi,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Overview`})]}),t&&(0,K.jsx)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:t})]})}function Rk({params:e,children:t}){return(0,K.jsxs)(`ul`,{className:`flex space-x-2 md:hidden py-2 px-4`,children:[(0,K.jsx)(`li`,{children:(0,K.jsxs)(V,{to:qg(e,`config`),className:Nk,activeOptions:{exact:!0},inactiveProps:Pk,activeProps:Fk,children:[(0,K.jsx)(vi,{className:`hidden md:inline-block`}),` `,(0,K.jsx)(`span`,{className:`ms-3`,children:`Overview`})]})}),t]})}async function zk(e){let t=await hf(e),r=t?.instances??[],i=!!t&&u.checkForFabricConnect(t.id);return{allInstances:r,targets:r.filter(e=>e.status===`RUNNING`).map(e=>({instance:e,instanceClient:n({id:e.id,forceFabricConnect:i,operationsUrl:p(e)})})).reverse()}}async function Bk(e,t=3,n=1e3){let r=0;if(t<=0)throw Error(`retries must be greater than 0`);let i;for(;r<t;)try{return await e()}catch(e){if(r++,i=e,r===t)break;await h(n)}throw i}var Vk=1e4,Hk=3e3,Uk=15e3,Wk=12,Gk=6e4,Kk=547e3;async function qk({operation:e,replicated:t,instanceClient:n,onSlowToReturn:r}){let{data:i}=await n.post(`/`,{operation:e,service:e===`restart_service`?`http`:void 0,replicated:t},{skipRestartGate:!0,timeout:Gk});try{await Jk({instanceClient:n,onSlowToReturn:r})}catch(e){throw new lr(e)}return i}async function Jk({instanceClient:e,onSlowToReturn:t}){let n=()=>r({instanceClient:e,timeout:Hk,skipRestartGate:!0,skipGatewayRetry:!0});await h(Vk);try{await Bk(n,Wk,Uk)}catch{try{t?.()}catch(e){console.error(e)}await h(Uk),await Bk(n,12,Uk)}}function Yk(){return I({mutationFn:qk})}function Xk({onRestartedSuccessfully:e}={}){let{clusterId:t}=z({strict:!1}),[n,i]=(0,G.useState)(!1);return{onRestartClick:(0,G.useCallback)(async()=>{if(!t)throw Error(`clusterId must be set in the route to invoke useRestartClusterClick`);i(!0);let n=!1,a={duration:6e4,action:{label:`Cancel`,onClick:()=>{n=!0}}},o=(e,t=e)=>n?{duration:a.duration,description:`${t} Cancelled: no other instance will be restarted.`.trim()}:{...a,description:e},s=U.loading(`Restarting`,{...a,description:(0,K.jsx)(A_,{animated:!0,width:`0%`})});try{let i;try{i=await zk(t)}catch{U.error(`Error`,{id:s,description:`Could not load the cluster's instances, so nothing was restarted.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});return}let{allInstances:c,targets:l}=i,u=0,d=0,f=0,p,m=!1,g=re([t],{reach:l.length===1?`down`:`rolling`,ttlMs:(l.length+1)*Kk});try{for(let e=0;e<l.length;e++){let{instance:t,instanceClient:i}=l[e];if(!n){U.loading(`Restarting Instance ${e+1} of ${l.length}`,{...a,id:s,description:(0,K.jsx)(A_,{animated:!0,width:(e===0?0:e/l.length*100)+`%`})});let c;try{if(await r({instanceClient:i,skipRestartGate:!0}),n)break;c=re([t.id],{reach:`down`,ttlMs:Kk}),await qk({operation:`restart`,replicated:!1,instanceClient:i,onSlowToReturn:()=>U.loading(`Waiting On Instance ${e+1} of ${l.length}`,{id:s,...o(`It accepted the restart but isn't back yet.`)})}),u+=1}catch(t){if(t instanceof lr){p=l.length-e-1;break}let n=or(t);if(d+=+!!n,f+=+!n,n&&(U.loading(`Could Not Confirm Instance ${e+1} of ${l.length}`,{id:s,...o(`Waiting for it to answer before carrying on.`,`Waiting for it to answer.`)}),!await Jk({instanceClient:i}).then(()=>!0,()=>!1))){p=l.length-e-1,m=!0;break}if(e+1!==l.length){let t=n?`Could Not Confirm`:`Failed Restarting`;U.loading(`${t} Instance ${e+1} of ${l.length}`,{id:s,...o(`We will carry on momentarily.`,``)}),await h(3e3)}}finally{c?.()}}}}finally{g()}let _=ar({total:c.length,confirmed:u,failed:f,unanswered:d,untouched:p,stoppedOnNoVerdict:m,canceled:n&&p===void 0?l.length-u-f-d:0},`restarted`);if(n&&!_)U.error(`Cancelled`,{id:s,description:`The restart was partially cancelled.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});else if(c.length>0&&c.length===u)e?.(),U.success(`Success`,{id:s,description:`Cluster fully restarted!`,duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});else{let e=oe(c.length,`instance`,`instances`),t=oe(u,`"RUNNING" instance was`,`"RUNNING" instances were`);U.error(_?.title??`Error`,{id:s,description:_?.description??`Failed to fully restart cluster.
|
|
33
|
+
`+([c.length===0&&`No instances were found within the cluster to restart.`,l.length===0&&`No instances were in a "RUNNING" state of ${e}.`,c.length!==u&&`Only ${t} restarted of ${e}.`].filter(fr).shift()||``),duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}}finally{i(!1)}},[t,e]),isRestartPending:n}}function Zk({operation:e,instanceClient:t,onRestartedSuccessfully:n}){let{clusterId:r,instanceId:i}=z({strict:!1}),a=`Instance`,{mutateAsync:o,isPending:s}=Yk(),c=Ze();return{onRestartClick:(0,G.useCallback)(async()=>{let s=U.loading(`Restarting`,{description:`Restarting instance. This may take up to 60 seconds.`,duration:18e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),l=m,u=e===`restart`&&l?re([l],{reach:`down`,ttlMs:Kk}):void 0,d=!1;try{await o({operation:e,replicated:e===`restart_service`&&!1,instanceClient:t,onSlowToReturn:()=>U.loading(`Still restarting`,{id:s,description:`Harper accepted the restart, but the instance isn't back yet. Still waiting for it.`})});for(let e of[r,i])(!u||e!==l)&&mr(c,e);U.dismiss(s),U.success(`Success`,{description:`${a} restarted!`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),n?.()}catch(e){U.dismiss(s),d=or(e),pc(e)&&U.error(`Error`,{description:`Failed to restart instance.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}finally{u&&d?Jk({instanceClient:t}).then(u,u):u?.()}},[r,t,i,n,e,c,o,a]),isRestartPending:s}}function Qk({className:e,disabled:t,hideText:n,instanceClient:r,operation:i,targetNoun:a,tooltip:o,variant:s}){let{onRestartClick:c,isRestartPending:l}=Xk(),{onRestartClick:u,isRestartPending:d}=Zk({operation:i,instanceClient:r});return(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(H,{type:`button`,variant:s||`positiveOutline`,className:v(`mx-0 md:mx-4`,e),onClick:a===`Cluster`&&i===`restart`?c:u,disabled:t||d||l,title:`Restart ${a}`,children:[(0,K.jsx)(Yo,{className:`pointer-events-none`}),n!==!0&&(0,K.jsxs)(`span`,{className:`hidden md:inline-block pointer-events-none`,children:[`Restart `,(0,K.jsx)(`span`,{className:`hidden 2xl:inline-block`,children:a})]})]})}),(0,K.jsx)(Xl,{side:`bottom`,children:o||(i===`restart_service`?`Restarts all service threads to apply changes. No downtime expected. Performance may be briefly slower during restart.`:`This fully restarts the Harper service and causes downtime.`)})]})}async function $k({clusterId:e,instanceId:t}){return null}function eA(e){return B({queryKey:[e.clusterId,e.instanceId],queryFn:()=>$k(e),retry:!1})}var tA=({loadingRegistration:e,registrationInfo:t})=>{let n=!!t?.version&&parseInt(t.version[0],10)>=5&&`https://github.com/HarperFast/harper/releases/tag/v${t.version}`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`font-bold text-sm/6`,children:`Harper Version`}),(0,K.jsx)(`dd`,{className:`text-sm/6 sm:mt-2`,children:e?(0,K.jsx)(my,{className:`w-10`}):n?(0,K.jsx)(`a`,{href:n,target:`_blank`,className:`underline hover:text-blue-300`,rel:`noopener noreferrer`,children:t.version}):t?.version||`Unknown`})]})},nA=({loading:e,timestamp:t})=>{let n=t?new Date(t).toLocaleString():`Never`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`font-bold text-sm/6`,children:`Last Deployed`}),(0,K.jsx)(`dd`,{className:`text-sm/6 sm:mt-2`,children:e?(0,K.jsx)(my,{className:`w-24`}):n})]})},rA=`5.2.0`;function iA(e){let t=e.filter(e=>!(e.status&&Pd.includes(e.status)));return t.length>1&&t.every(e=>!!e.version&&vr(rA,e.version))}async function aA({instanceClient:e,...t}){let{data:n}=await e.post(`/`,{operation:`set_configuration`,...t});return n}var oA=`Instances that were not restarted may already have the new configuration saved, and will apply it the next time they restart.`;async function sA(e){if(e.entityType!==`cluster`)return{allInstances:[{id:e.entityId,status:`RUNNING`}],targets:[{instanceClient:e.instanceClient}],fanOutAfterCanary:!1};let{allInstances:t,targets:n}=await zk(e.entityId);return{allInstances:t,targets:n.map(({instance:e,instanceClient:t})=>({instanceClient:t,replicationFqdn:e.replicationFqdn})),fanOutAfterCanary:iA(t)}}function cA({onRestartedSuccessfully:e}={}){let t=q(),n=Ze(),[i,a]=(0,G.useState)(!1);return{onConfigUpdate:(0,G.useCallback)(async i=>{a(!0);let o=!1,s={duration:6e4,action:{label:`Cancel`,onClick:()=>{o=!0}}},c=(e,t=e)=>o?{duration:s.duration,description:`${t} Cancelled: no other instance will be updated.`.trim()}:{...s,description:e},l=U.loading(`Restarting`,{...s,description:(0,K.jsx)(A_,{animated:!0,width:`0%`})});try{let n;try{n=await sA(t)}catch{U.error(`Error`,{id:l,description:`Could not load the cluster's instances, so no configuration was changed.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});return}let{allInstances:a,targets:u,fanOutAfterCanary:d}=n,f=!1,p=new Set,m=0,g=0,v=0,y,b=!1,x=!1;for(let e=0;e<u.length;e++){let{instanceClient:t,replicationFqdn:n}=u[e];if(o)break;U.loading(`Updating Instance ${e+1} of ${u.length}`,{...s,id:l,description:(0,K.jsx)(A_,{animated:!0,width:(e===0?0:e/u.length*100)+`%`})});let a=!1,S=!1;try{if(await r({instanceClient:t}),o)break;if((!n||!p.has(n.toLowerCase()))&&(await aA({...i,instanceClient:t}),o)){x=!0;break}S=!0,await qk({operation:`restart_service`,replicated:!1,instanceClient:t,onSlowToReturn:()=>U.loading(`Waiting On Instance ${e+1} of ${u.length}`,{id:l,...c(`It accepted the restart but isn't back yet.`)})}),m+=1,a=!0}catch(n){if(n instanceof lr){y=u.length-e-1;break}let r=or(n);if(g+=+!!r,v+=+!r,r&&S&&(U.loading(`Could Not Confirm Instance ${e+1} of ${u.length}`,{id:l,...c(`Waiting for it to answer before carrying on.`,`Waiting for it to answer.`)}),!await Jk({instanceClient:t}).then(()=>!0,()=>!1))){y=u.length-e-1,b=!0;break}if(e+1!==u.length){let t=r?`Could Not Confirm`:`Failed Restarting`;U.loading(`${t} Instance ${e+1} of ${u.length}`,{id:l,...c(`We will carry on momentarily.`,``)}),await h(3e3)}}a&&d&&!f&&!o&&(f=!0,U.loading(`Saving configuration to the cluster`,{...s,id:l,description:(0,K.jsx)(A_,{animated:!0,width:(e+1)/u.length*100+`%`})}),p=await aA({...i,replicated:!0,instanceClient:t}).then(_,()=>new Set))}let S=ar({total:a.length,confirmed:m,failed:v,unanswered:g,untouched:y,stoppedOnNoVerdict:b,canceled:o&&y===void 0?u.length-m-v-g:0},`updated`);if(o&&!S)U.error(`Cancelled`,{id:l,description:`The config update was partially cancelled.${f||x?` ${oA}`:``}`,duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});else if(a.length>0&&a.length===m)e?.(),U.success(`Success`,{id:l,description:`Your configuration has been updated successfully!`,duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});else{let e=oe(a.length,`instance`,`instances`),t=oe(m,`"RUNNING" instance was`,`"RUNNING" instances were`);U.error(S?.title??`Error`,{id:l,description:(S?.description??`Failed to fully update cluster.
|
|
34
|
+
`+([a.length===0&&`No instances were found within the cluster to restart.`,u.length===0&&`No instances were in a "RUNNING" state of ${e}.`,a.length!==m&&`Only ${t} restarted of ${e}.`].filter(fr).shift()||``))+(f||x?`
|
|
35
|
+
`+oA:``),duration:1e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}}finally{a(!1),n.invalidateQueries({queryKey:[`get_configuration`,t.entityId]})}},[t,e,n]),isPending:i}}function lA({entityId:e,instanceClient:t}){return B({queryKey:[`get_configuration`,e],queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_configuration`});return e}})}function uA({entityId:e,instanceClient:t},n){return B({queryKey:[`get_usage_licenses`,e],enabled:n,queryFn:async()=>{try{let{data:e}=await t.post(`/`,{operation:`get_usage_licenses`});return e}catch(e){return console.error(e),null}}})}var dA={http:{port:`blocked`,securePort:`blocked`},threads:`blocked`,authentication:{enableSessions:`blocked`},logging:{auditLog:`blocked`,root:`blocked`,rotation:{path:`blocked`}},mqtt:{network:{port:`blocked`,securePort:`blocked`}},operationsApi:{network:{domainSocket:`blocked`,port:`blocked`,securePort:`blocked`}},rootPath:`blocked`,replication:`blocked_except_databases`,storage:`blocked`,tls:`blocked`,node:`blocked`,license:`blocked`,componentsRoot:`blocked`,analytics:`allowed`,applications:`allowed`,localStudio:`allowed`};function fA(e,t,n){if(JSON.stringify(t)===JSON.stringify(n))return!1;let r=e.split(`.`),i=dA;for(let e=0;e<r.length;e++){let t=r[e];if(i===`blocked`)return!0;if(i===`blocked_except_databases`)return t!==`databases`;if(typeof i==`object`&&i&&t in i)i=i[t];else return!1}return i===`blocked`}function pA(e,t=dA){if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){let i=e[r],a=t?.[r];if(a!==`blocked`){if(a===`blocked_except_databases`){i&&typeof i==`object`&&`databases`in i&&(n.replication={databases:i.databases});continue}if(typeof a==`object`&&a){let e=pA(i,a);e!==void 0&&(typeof e!=`object`||Object.keys(e).length>0)&&(n[r]=e)}else n[r]=i}}return n}function mA(e,t){if(typeof e!=`object`||!e||typeof t!=`object`||!t)return JSON.stringify(e)===JSON.stringify(t)?void 0:t;let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r){let r=e[i],a=t[i];if(typeof r==`object`&&r&&typeof a==`object`&&a&&!Array.isArray(r)&&!Array.isArray(a)){let e=mA(r,a);Object.keys(e).length>0&&(n[i]=e)}else JSON.stringify(r)!==JSON.stringify(a)&&(n[i]=a)}return n}function hA(e,t=``){let n={};for(let r in e){let i=e[r],a=t?`${t}_${r}`:r;typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(n,hA(i,a)):n[a]=i}return n}var gA=JSON.parse(`{
|
|
36
|
+
"$schema": "https://json-schema.org/draft-06/schema",
|
|
37
|
+
"$id": "https://harper.fast/schema/config-root.schema.json",
|
|
38
|
+
"title": "HarperDB Root Configuration",
|
|
39
|
+
"description": "JSON Schema for harperdb-config.yaml as documented in docs.html. This focuses on the primary, documented configuration sections and keys. Unknown properties are allowed for forward compatibility.",
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"rootPath": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Root folder where Harper persists data, config, logs, and components. Default: user's home directory"
|
|
45
|
+
},
|
|
46
|
+
"componentsRoot": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Path to the folder containing local component files. Default: <ROOTPATH>/components"
|
|
49
|
+
},
|
|
50
|
+
"http": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"description": "HTTP server configuration for the main component server.",
|
|
53
|
+
"additionalProperties": true,
|
|
54
|
+
"properties": {
|
|
55
|
+
"sessionAffinity": {
|
|
56
|
+
"description": "Route multiple requests from the same client to the same thread. Use 'ip' or a header name.",
|
|
57
|
+
"type": ["string", "null"]
|
|
58
|
+
},
|
|
59
|
+
"compressionThreshold": {
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"minimum": 0,
|
|
62
|
+
"description": "Responses larger than this threshold (bytes) will be compressed for clients that accept compression. Default: 1200"
|
|
63
|
+
},
|
|
64
|
+
"cors": { "type": "boolean", "description": "Enable Cross Origin Resource Sharing. Default: true" },
|
|
65
|
+
"corsAccessList": {
|
|
66
|
+
"type": ["array", "null"],
|
|
67
|
+
"description": "List of allowed origins for CORS.",
|
|
68
|
+
"items": { "type": "string" }
|
|
69
|
+
},
|
|
70
|
+
"corsAccessControlAllowHeaders": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "Comma-separated list of header keys for Access-Control-Allow-Headers on OPTIONS requests. Default: 'Accept, Content-Type, Authorization'"
|
|
73
|
+
},
|
|
74
|
+
"headersTimeout": {
|
|
75
|
+
"type": "integer",
|
|
76
|
+
"description": "Milliseconds to wait for complete HTTP headers. Default: 60000"
|
|
77
|
+
},
|
|
78
|
+
"maxHeaderSize": {
|
|
79
|
+
"type": "integer",
|
|
80
|
+
"description": "Maximum allowed size of HTTP headers in bytes. Default: 16394"
|
|
81
|
+
},
|
|
82
|
+
"requestQueueLimit": {
|
|
83
|
+
"type": "integer",
|
|
84
|
+
"description": "Max estimated request queue time (ms) before rejecting with 503. Default: 20000"
|
|
85
|
+
},
|
|
86
|
+
"keepAliveTimeout": { "type": "integer", "description": "Keep-alive inactivity timeout in ms. Default: 30000" },
|
|
87
|
+
"port": { "type": "integer", "description": "HTTP port. Default: 9926" },
|
|
88
|
+
"securePort": { "type": ["integer", "null"], "description": "HTTPS port. Requires valid certificate + key." },
|
|
89
|
+
"http2": { "type": "boolean", "description": "Enable HTTP/2. Default: false" },
|
|
90
|
+
"timeout": { "type": "integer", "description": "Request timeout (ms). Default: 120000" },
|
|
91
|
+
"mtls": {
|
|
92
|
+
"description": "Enable and configure mTLS authentication for HTTP.",
|
|
93
|
+
"oneOf": [
|
|
94
|
+
{ "type": "boolean" },
|
|
95
|
+
{
|
|
96
|
+
"type": "object",
|
|
97
|
+
"additionalProperties": false,
|
|
98
|
+
"properties": {
|
|
99
|
+
"user": {
|
|
100
|
+
"type": ["string", "null"],
|
|
101
|
+
"description": "Authenticate all authorized mTLS connections as this user. Default: common name from certificate or null to not auto-auth."
|
|
102
|
+
},
|
|
103
|
+
"required": {
|
|
104
|
+
"type": "boolean",
|
|
105
|
+
"description": "Require client certificates for all HTTP connections. Default: false"
|
|
106
|
+
},
|
|
107
|
+
"certificateVerification": {
|
|
108
|
+
"description": "Enable certificate revocation checking (CRL/OCSP).",
|
|
109
|
+
"oneOf": [
|
|
110
|
+
{ "type": "boolean" },
|
|
111
|
+
{
|
|
112
|
+
"type": "object",
|
|
113
|
+
"additionalProperties": false,
|
|
114
|
+
"properties": {
|
|
115
|
+
"failureMode": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"enum": ["fail-open", "fail-closed"],
|
|
118
|
+
"description": "Global behavior when verification fails. Default: 'fail-closed'"
|
|
119
|
+
},
|
|
120
|
+
"crl": {
|
|
121
|
+
"type": "object",
|
|
122
|
+
"additionalProperties": false,
|
|
123
|
+
"properties": {
|
|
124
|
+
"enabled": { "type": "boolean", "description": "Enable CRL checking. Default: true" },
|
|
125
|
+
"timeout": {
|
|
126
|
+
"type": "number",
|
|
127
|
+
"description": "Max ms to wait for CRL download. Default: 10000"
|
|
128
|
+
},
|
|
129
|
+
"cacheTtl": { "type": "number", "description": "CRL cache TTL (ms). Default: 86400000" },
|
|
130
|
+
"gracePeriod": {
|
|
131
|
+
"type": "number",
|
|
132
|
+
"description": "Grace period after CRL nextUpdate (ms). Default: 86400000"
|
|
133
|
+
},
|
|
134
|
+
"failureMode": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"enum": ["fail-open", "fail-closed"],
|
|
137
|
+
"description": "CRL-specific failure mode. Default: 'fail-closed'"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"ocsp": {
|
|
142
|
+
"type": "object",
|
|
143
|
+
"additionalProperties": false,
|
|
144
|
+
"properties": {
|
|
145
|
+
"enabled": { "type": "boolean", "description": "Enable OCSP checking. Default: true" },
|
|
146
|
+
"timeout": {
|
|
147
|
+
"type": "number",
|
|
148
|
+
"description": "Max ms to wait for OCSP response. Default: 5000"
|
|
149
|
+
},
|
|
150
|
+
"cacheTtl": {
|
|
151
|
+
"type": "number",
|
|
152
|
+
"description": "Cache TTL for successful OCSP (ms). Default: 3600000"
|
|
153
|
+
},
|
|
154
|
+
"errorCacheTtl": {
|
|
155
|
+
"type": "number",
|
|
156
|
+
"description": "Cache TTL for OCSP errors (ms). Default: 300000"
|
|
157
|
+
},
|
|
158
|
+
"failureMode": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"enum": ["fail-open", "fail-closed"],
|
|
161
|
+
"description": "OCSP-specific failure mode. Default: 'fail-closed'"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
"logging": {
|
|
174
|
+
"allOf": [{ "$ref": "#/definitions/loggerConfig" }],
|
|
175
|
+
"properties": {
|
|
176
|
+
"timing": { "type": "boolean", "description": "Log timing information for HTTP requests." },
|
|
177
|
+
"headers": { "type": "boolean", "description": "Log HTTP headers (verbose)." },
|
|
178
|
+
"id": { "type": "boolean", "description": "Assign/log unique id per request." }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
"threads": {
|
|
185
|
+
"type": "object",
|
|
186
|
+
"description": "Harper worker thread configuration.",
|
|
187
|
+
"additionalProperties": true,
|
|
188
|
+
"properties": {
|
|
189
|
+
"count": { "type": "number", "description": "Number of worker threads. Default: logical CPU count minus one" },
|
|
190
|
+
"debug": {
|
|
191
|
+
"oneOf": [
|
|
192
|
+
{ "type": "boolean" },
|
|
193
|
+
{
|
|
194
|
+
"type": "object",
|
|
195
|
+
"additionalProperties": false,
|
|
196
|
+
"properties": {
|
|
197
|
+
"port": { "type": "integer", "description": "Port for debugging the main thread (default 9229)" },
|
|
198
|
+
"startingPort": {
|
|
199
|
+
"type": "integer",
|
|
200
|
+
"description": "Starting port to assign unique debugging ports per thread"
|
|
201
|
+
},
|
|
202
|
+
"host": { "type": "string", "description": "Debug host interface (default 127.0.0.1)" },
|
|
203
|
+
"waitForDebugger": { "type": "boolean", "description": "Wait for debugger before starting" }
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
"maxHeapMemory": { "type": "number", "description": "Heap memory limit per thread (MB)." },
|
|
209
|
+
"heapSnapshotNearLimit": { "type": "boolean", "description": "Take a heap snapshot when near the heap limit." }
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
"replication": {
|
|
214
|
+
"type": "object",
|
|
215
|
+
"description": "Harper replication configuration for clustering and data replication.",
|
|
216
|
+
"additionalProperties": true,
|
|
217
|
+
"properties": {
|
|
218
|
+
"hostname": { "type": "string", "description": "Hostname of this Harper instance." },
|
|
219
|
+
"url": { "type": "string", "description": "URL of this Harper instance." },
|
|
220
|
+
"databases": {
|
|
221
|
+
"description": "Databases to replicate. '*' for all, array of names, or array with objects to mark sharded databases.",
|
|
222
|
+
"oneOf": [
|
|
223
|
+
{ "type": "string" },
|
|
224
|
+
{
|
|
225
|
+
"type": "array",
|
|
226
|
+
"items": {
|
|
227
|
+
"oneOf": [
|
|
228
|
+
{ "type": "string" },
|
|
229
|
+
{
|
|
230
|
+
"type": "object",
|
|
231
|
+
"additionalProperties": false,
|
|
232
|
+
"properties": {
|
|
233
|
+
"name": { "type": "string" },
|
|
234
|
+
"sharded": { "type": "boolean" }
|
|
235
|
+
},
|
|
236
|
+
"required": ["name"]
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
"routes": {
|
|
244
|
+
"type": "array",
|
|
245
|
+
"description": "Routes to connect to other nodes. Each route can be a string or an object with hostname, port, and optional startTime.",
|
|
246
|
+
"items": {
|
|
247
|
+
"oneOf": [
|
|
248
|
+
{ "type": "string" },
|
|
249
|
+
{
|
|
250
|
+
"type": "object",
|
|
251
|
+
"additionalProperties": false,
|
|
252
|
+
"properties": {
|
|
253
|
+
"hostname": { "type": "string" },
|
|
254
|
+
"port": { "type": "integer" },
|
|
255
|
+
"startTime": {
|
|
256
|
+
"type": "string",
|
|
257
|
+
"format": "date-time",
|
|
258
|
+
"description": "ISO 8601 UTC start time to begin replication."
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"required": ["hostname", "port"]
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"startTime": { "type": "string", "format": "date-time", "description": "Start replication from this time." },
|
|
267
|
+
"revokedCertificates": {
|
|
268
|
+
"type": "array",
|
|
269
|
+
"items": { "type": "string" },
|
|
270
|
+
"description": "Array of revoked certificate serial numbers."
|
|
271
|
+
},
|
|
272
|
+
"port": { "type": "integer", "description": "Replication insecure port." },
|
|
273
|
+
"securePort": { "type": "integer", "description": "Replication secure port. Default: 9933" },
|
|
274
|
+
"enableRootCAs": {
|
|
275
|
+
"type": "boolean",
|
|
276
|
+
"description": "Verify certificates against Node.js bundled CA store. Default: true"
|
|
277
|
+
},
|
|
278
|
+
"mtls": {
|
|
279
|
+
"type": "object",
|
|
280
|
+
"description": "mTLS settings for replication connections (always required).",
|
|
281
|
+
"additionalProperties": true,
|
|
282
|
+
"properties": {
|
|
283
|
+
"certificateVerification": {
|
|
284
|
+
"description": "Enable certificate revocation checking (CRL/OCSP) for peer certificates.",
|
|
285
|
+
"oneOf": [
|
|
286
|
+
{ "type": "boolean" },
|
|
287
|
+
{
|
|
288
|
+
"type": "object",
|
|
289
|
+
"additionalProperties": false,
|
|
290
|
+
"properties": {
|
|
291
|
+
"failureMode": { "type": "string", "enum": ["fail-open", "fail-closed"] },
|
|
292
|
+
"crl": {
|
|
293
|
+
"type": "object",
|
|
294
|
+
"additionalProperties": false,
|
|
295
|
+
"properties": {
|
|
296
|
+
"enabled": { "type": "boolean" },
|
|
297
|
+
"timeout": { "type": "number" },
|
|
298
|
+
"cacheTtl": { "type": "number" },
|
|
299
|
+
"gracePeriod": { "type": "number" },
|
|
300
|
+
"failureMode": { "type": "string", "enum": ["fail-open", "fail-closed"] }
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"ocsp": {
|
|
304
|
+
"type": "object",
|
|
305
|
+
"additionalProperties": false,
|
|
306
|
+
"properties": {
|
|
307
|
+
"enabled": { "type": "boolean" },
|
|
308
|
+
"timeout": { "type": "number" },
|
|
309
|
+
"cacheTtl": { "type": "number" },
|
|
310
|
+
"errorCacheTtl": { "type": "number" },
|
|
311
|
+
"failureMode": { "type": "string", "enum": ["fail-open", "fail-closed"] }
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
"blobTimeout": { "type": "number", "description": "Max time (ms) to wait for blob transfer. Default: 120000" },
|
|
321
|
+
"failOver": {
|
|
322
|
+
"type": "boolean",
|
|
323
|
+
"description": "Attempt fail-over to different node when unreachable. Default: true"
|
|
324
|
+
},
|
|
325
|
+
"shard": { "type": "integer", "description": "Shard id for this instance." },
|
|
326
|
+
"logging": { "$ref": "#/definitions/loggerConfig" }
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
"localStudio": {
|
|
331
|
+
"type": "object",
|
|
332
|
+
"additionalProperties": false,
|
|
333
|
+
"properties": {
|
|
334
|
+
"enabled": { "type": "boolean", "description": "Enable local Harper Studio GUI. Default: false" }
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
"logging": {
|
|
339
|
+
"type": "object",
|
|
340
|
+
"description": "Logging configuration for Harper.",
|
|
341
|
+
"additionalProperties": true,
|
|
342
|
+
"properties": {
|
|
343
|
+
"auditLog": { "type": "boolean", "description": "Enable structured table transaction logging. Default: false" },
|
|
344
|
+
"file": { "type": "boolean", "description": "Log to file. Default: true" },
|
|
345
|
+
"auditRetention": {
|
|
346
|
+
"type": ["string", "number"],
|
|
347
|
+
"description": "Retention of audit logs (e.g. '3d'). Default: 3d"
|
|
348
|
+
},
|
|
349
|
+
"level": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"enum": ["trace", "debug", "info", "warn", "error", "fatal", "notify"],
|
|
352
|
+
"description": "Verbosity of text event logs. Default: warn"
|
|
353
|
+
},
|
|
354
|
+
"console": { "type": "boolean", "description": "Log console.* output to log file. Default: true" },
|
|
355
|
+
"root": { "type": "string", "description": "Directory where log files are written. Default: <ROOTPATH>/log" },
|
|
356
|
+
"path": { "type": "string", "description": "Log file path. Default: <ROOTPATH>/log/hdb.log" },
|
|
357
|
+
"rotation": {
|
|
358
|
+
"type": "object",
|
|
359
|
+
"additionalProperties": false,
|
|
360
|
+
"properties": {
|
|
361
|
+
"enabled": { "type": "boolean", "description": "Enable log rotation. Default: true" },
|
|
362
|
+
"compress": { "type": "boolean", "description": "Compress rotated logs with gzip. Default: false" },
|
|
363
|
+
"interval": { "type": ["string", "null"], "description": "Time between rotations (e.g. '1D','6H','30M')." },
|
|
364
|
+
"maxSize": { "type": ["string", "null"], "description": "Max size before rotation (e.g. '100M', '1G')." },
|
|
365
|
+
"path": { "type": "string", "description": "Directory to store rotated logs. Default: <ROOTPATH>/log" }
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"stdStreams": { "type": "boolean", "description": "Log to stdout/stderr. Default: false" },
|
|
369
|
+
"auditAuthEvents": {
|
|
370
|
+
"type": "object",
|
|
371
|
+
"additionalProperties": false,
|
|
372
|
+
"properties": {
|
|
373
|
+
"logFailed": { "type": "boolean", "description": "Log failed authentication events. Default: false" },
|
|
374
|
+
"logSuccessful": {
|
|
375
|
+
"type": "boolean",
|
|
376
|
+
"description": "Log successful authentication events. Default: false"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
"external": {
|
|
381
|
+
"$ref": "#/definitions/loggerConfig",
|
|
382
|
+
"description": "Logging configuration for external components that use the logger API."
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
"authentication": {
|
|
388
|
+
"type": "object",
|
|
389
|
+
"description": "Default authentication settings.",
|
|
390
|
+
"additionalProperties": true,
|
|
391
|
+
"properties": {
|
|
392
|
+
"authorizeLocal": {
|
|
393
|
+
"type": "boolean",
|
|
394
|
+
"description": "Automatically authorize requests from loopback IP as superuser. Default: true"
|
|
395
|
+
},
|
|
396
|
+
"cacheTTL": { "type": "number", "description": "Milliseconds an authentication can be cached. Default: 30000" },
|
|
397
|
+
"enableSessions": { "type": "boolean", "description": "Enable cookie-based sessions. Default: true" },
|
|
398
|
+
"operationTokenTimeout": {
|
|
399
|
+
"type": "string",
|
|
400
|
+
"description": "Operation token expiry duration (e.g. '1d'). Default: 1d"
|
|
401
|
+
},
|
|
402
|
+
"refreshTokenTimeout": {
|
|
403
|
+
"type": "string",
|
|
404
|
+
"description": "Refresh token expiry duration (e.g. '1d'). Default: 1d"
|
|
405
|
+
},
|
|
406
|
+
"logging": { "$ref": "#/definitions/loggerConfig" }
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
"operationsApi": {
|
|
411
|
+
"type": "object",
|
|
412
|
+
"description": "Operations API configuration. Values default to http configuration when not provided.",
|
|
413
|
+
"additionalProperties": true,
|
|
414
|
+
"properties": {
|
|
415
|
+
"network": {
|
|
416
|
+
"type": "object",
|
|
417
|
+
"additionalProperties": true,
|
|
418
|
+
"properties": {
|
|
419
|
+
"cors": { "type": "boolean" },
|
|
420
|
+
"corsAccessList": { "type": ["array", "null"], "items": { "type": "string" } },
|
|
421
|
+
"domainSocket": {
|
|
422
|
+
"type": "string",
|
|
423
|
+
"description": "Unix domain socket path for CLI access. Default: <ROOTPATH>/hdb/operations-server"
|
|
424
|
+
},
|
|
425
|
+
"headersTimeout": { "type": "integer" },
|
|
426
|
+
"keepAliveTimeout": { "type": "integer" },
|
|
427
|
+
"port": { "type": "integer", "description": "Operations API HTTP port. Default: 9925" },
|
|
428
|
+
"securePort": { "type": ["integer", "null"] },
|
|
429
|
+
"timeout": { "type": "integer" }
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"tls": {
|
|
433
|
+
"$ref": "#/definitions/tlsConfig",
|
|
434
|
+
"description": "TLS configuration overriding root TLS for Operations API"
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
|
|
439
|
+
"storage": {
|
|
440
|
+
"type": "object",
|
|
441
|
+
"description": "Storage engine configuration.",
|
|
442
|
+
"additionalProperties": true,
|
|
443
|
+
"properties": {
|
|
444
|
+
"writeAsync": {
|
|
445
|
+
"type": "boolean",
|
|
446
|
+
"description": "Disable fsync for faster writes (risk of data loss on crash). Default: false"
|
|
447
|
+
},
|
|
448
|
+
"caching": { "type": "boolean", "description": "Enable in-memory caching of records. Default: true" },
|
|
449
|
+
"compression": {
|
|
450
|
+
"oneOf": [
|
|
451
|
+
{ "type": "boolean" },
|
|
452
|
+
{
|
|
453
|
+
"type": "object",
|
|
454
|
+
"additionalProperties": false,
|
|
455
|
+
"properties": {
|
|
456
|
+
"dictionary": { "type": ["string", "null"], "description": "Path to compression dictionary file." },
|
|
457
|
+
"threshold": {
|
|
458
|
+
"type": "number",
|
|
459
|
+
"description": "Only entries larger than this many bytes will be compressed."
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
"description": "Enable/Configure compression (LZ4). Default: true"
|
|
465
|
+
},
|
|
466
|
+
"compactOnStart": { "type": "boolean", "description": "Compact non-system databases on start. Default: false" },
|
|
467
|
+
"compactOnStartKeepBackup": {
|
|
468
|
+
"type": "boolean",
|
|
469
|
+
"description": "Keep backups created by compactOnStart. Default: false"
|
|
470
|
+
},
|
|
471
|
+
"maxTransactionQueueTime": {
|
|
472
|
+
"type": "string",
|
|
473
|
+
"description": "Max write queue time before rejecting (e.g. '45s')."
|
|
474
|
+
},
|
|
475
|
+
"noReadAhead": { "type": "boolean", "description": "Advise OS to not read ahead. Default: false" },
|
|
476
|
+
"prefetchWrites": { "type": "boolean", "description": "Load data prior to write transactions. Default: true" },
|
|
477
|
+
"path": { "type": "string", "description": "Directory for all database files. Default: <rootPath>/database" },
|
|
478
|
+
"blobPaths": {
|
|
479
|
+
"oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }],
|
|
480
|
+
"description": "Path or array of paths for blob storage. Default: <rootPath>/blobs"
|
|
481
|
+
},
|
|
482
|
+
"pageSize": { "type": "number", "description": "Database page size (bytes). Default: OS default" },
|
|
483
|
+
"reclamation": {
|
|
484
|
+
"type": "object",
|
|
485
|
+
"description": "Reclamation process configuration.",
|
|
486
|
+
"additionalProperties": true
|
|
487
|
+
},
|
|
488
|
+
"logging": { "$ref": "#/definitions/loggerConfig" }
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
|
|
492
|
+
"tls": {
|
|
493
|
+
"description": "TLS certificates/keys/settings for HTTPS and MQTT. Can be a single object or an array (SNI).",
|
|
494
|
+
"oneOf": [
|
|
495
|
+
{ "$ref": "#/definitions/tlsConfig" },
|
|
496
|
+
{ "type": "array", "items": { "$ref": "#/definitions/tlsConfig" } }
|
|
497
|
+
]
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
"mqtt": {
|
|
501
|
+
"type": "object",
|
|
502
|
+
"description": "MQTT server configuration.",
|
|
503
|
+
"additionalProperties": true,
|
|
504
|
+
"properties": {
|
|
505
|
+
"port": { "type": "number", "description": "Insecure MQTT port. Default: 1883" },
|
|
506
|
+
"securePort": { "type": "number", "description": "Secure MQTT port. Default: 8883" },
|
|
507
|
+
"webSocket": { "type": "boolean", "description": "Enable MQTT over WebSockets (on http port). Default: true" },
|
|
508
|
+
"requireAuthentication": {
|
|
509
|
+
"type": "boolean",
|
|
510
|
+
"description": "Require authentication for MQTT connections. Default: true"
|
|
511
|
+
},
|
|
512
|
+
"mtls": {
|
|
513
|
+
"oneOf": [
|
|
514
|
+
{ "type": "boolean" },
|
|
515
|
+
{
|
|
516
|
+
"type": "object",
|
|
517
|
+
"additionalProperties": false,
|
|
518
|
+
"properties": {
|
|
519
|
+
"user": {
|
|
520
|
+
"type": ["string", "null"],
|
|
521
|
+
"description": "Authenticate all authorized mTLS connections as this user (or null for none). Default: Common Name"
|
|
522
|
+
},
|
|
523
|
+
"required": {
|
|
524
|
+
"type": "boolean",
|
|
525
|
+
"description": "Require client certificates for all MQTT connections. Default: false"
|
|
526
|
+
},
|
|
527
|
+
"certificateAuthority": {
|
|
528
|
+
"type": "string",
|
|
529
|
+
"description": "Override CA path for MQTT. Default: tls.certificateAuthority"
|
|
530
|
+
},
|
|
531
|
+
"certificateVerification": {
|
|
532
|
+
"oneOf": [
|
|
533
|
+
{ "type": "boolean" },
|
|
534
|
+
{
|
|
535
|
+
"type": "object",
|
|
536
|
+
"additionalProperties": false,
|
|
537
|
+
"properties": {
|
|
538
|
+
"timeout": {
|
|
539
|
+
"type": "number",
|
|
540
|
+
"description": "Max ms to wait for OCSP response. Default: 5000"
|
|
541
|
+
},
|
|
542
|
+
"cacheTtl": {
|
|
543
|
+
"type": "number",
|
|
544
|
+
"description": "Cache TTL (ms) for verification results. Default: 3600000"
|
|
545
|
+
},
|
|
546
|
+
"failureMode": {
|
|
547
|
+
"type": "string",
|
|
548
|
+
"enum": ["fail-open", "fail-closed"],
|
|
549
|
+
"description": "Behavior on verification failure. Default: 'fail-open'"
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
]
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
]
|
|
558
|
+
},
|
|
559
|
+
"logging": { "$ref": "#/definitions/loggerConfig" }
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
"databases": {
|
|
564
|
+
"type": "object",
|
|
565
|
+
"description": "Optional mapping of databases and tables to file system paths.",
|
|
566
|
+
"additionalProperties": {
|
|
567
|
+
"type": "object",
|
|
568
|
+
"additionalProperties": false,
|
|
569
|
+
"properties": {
|
|
570
|
+
"path": { "type": "string", "description": "Path for all files of this database." },
|
|
571
|
+
"auditPath": { "type": "string", "description": "Path for audit log database files for this database." },
|
|
572
|
+
"tables": {
|
|
573
|
+
"type": "object",
|
|
574
|
+
"additionalProperties": {
|
|
575
|
+
"type": "object",
|
|
576
|
+
"additionalProperties": false,
|
|
577
|
+
"properties": {
|
|
578
|
+
"path": { "type": "string", "description": "Path for this table's files." }
|
|
579
|
+
},
|
|
580
|
+
"required": ["path"]
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
|
|
587
|
+
"analytics": {
|
|
588
|
+
"type": "object",
|
|
589
|
+
"additionalProperties": false,
|
|
590
|
+
"properties": {
|
|
591
|
+
"aggregatePeriod": {
|
|
592
|
+
"type": "number",
|
|
593
|
+
"description": "Seconds between aggregation of raw analytics. Default: 60"
|
|
594
|
+
},
|
|
595
|
+
"replicate": {
|
|
596
|
+
"type": "boolean",
|
|
597
|
+
"description": "Replicate aggregated analytics across cluster. Default: false"
|
|
598
|
+
},
|
|
599
|
+
"storageInterval": {
|
|
600
|
+
"type": "number",
|
|
601
|
+
"description": "Number of aggregation cycles between node storage measurements. 0 to disable. Default: 10"
|
|
602
|
+
},
|
|
603
|
+
"logging": { "$ref": "#/definitions/loggerConfig" }
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
|
|
608
|
+
"additionalProperties": true,
|
|
609
|
+
|
|
610
|
+
"definitions": {
|
|
611
|
+
"loggerConfig": {
|
|
612
|
+
"type": "object",
|
|
613
|
+
"additionalProperties": true,
|
|
614
|
+
"properties": {
|
|
615
|
+
"path": { "type": "string" },
|
|
616
|
+
"root": { "type": "string" },
|
|
617
|
+
"level": { "type": "string", "enum": ["trace", "debug", "info", "warn", "error", "fatal", "notify"] },
|
|
618
|
+
"tag": { "type": "string" },
|
|
619
|
+
"stdStreams": { "type": "boolean" }
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
"tlsConfig": {
|
|
623
|
+
"type": "object",
|
|
624
|
+
"additionalProperties": false,
|
|
625
|
+
"properties": {
|
|
626
|
+
"certificate": {
|
|
627
|
+
"type": "string",
|
|
628
|
+
"description": "Path to certificate file. Default: <ROOTPATH>/keys/certificate.pem"
|
|
629
|
+
},
|
|
630
|
+
"certificateAuthority": { "type": "string", "description": "Path to CA file. Default: <ROOTPATH>/keys/ca.pem" },
|
|
631
|
+
"privateKey": {
|
|
632
|
+
"type": "string",
|
|
633
|
+
"description": "Path to private key file. Default: <ROOTPATH>/keys/privateKey.pem"
|
|
634
|
+
},
|
|
635
|
+
"ciphers": { "type": "string", "description": "Optional explicit cipher list." },
|
|
636
|
+
"host": { "type": "string", "description": "Optional SNI host this certificate applies to." }
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
"examples": [
|
|
642
|
+
{
|
|
643
|
+
"rootPath": "~/hdb",
|
|
644
|
+
"componentsRoot": "~/hdb/components",
|
|
645
|
+
"http": {
|
|
646
|
+
"port": 9926,
|
|
647
|
+
"cors": true,
|
|
648
|
+
"compressionThreshold": 1200,
|
|
649
|
+
"mtls": {
|
|
650
|
+
"required": false,
|
|
651
|
+
"certificateVerification": {
|
|
652
|
+
"failureMode": "fail-closed",
|
|
653
|
+
"crl": { "enabled": true, "timeout": 10000, "cacheTtl": 86400000, "gracePeriod": 86400000 },
|
|
654
|
+
"ocsp": { "enabled": true, "timeout": 5000, "cacheTtl": 3600000, "errorCacheTtl": 300000 }
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
"threads": { "count": 8, "maxHeapMemory": 300 },
|
|
659
|
+
"authentication": { "authorizeLocal": true, "enableSessions": true },
|
|
660
|
+
"operationsApi": { "network": { "port": 9925 } },
|
|
661
|
+
"logging": {
|
|
662
|
+
"level": "warn",
|
|
663
|
+
"file": true,
|
|
664
|
+
"rotation": { "enabled": true, "interval": "1D", "maxSize": "100M" }
|
|
665
|
+
},
|
|
666
|
+
"storage": { "path": "~/hdb/database", "blobPaths": ["~/hdb/blobs"] },
|
|
667
|
+
"tls": {
|
|
668
|
+
"certificate": "~/hdb/keys/certificate.pem",
|
|
669
|
+
"privateKey": "~/hdb/keys/privateKey.pem",
|
|
670
|
+
"certificateAuthority": "~/hdb/keys/ca.pem"
|
|
671
|
+
},
|
|
672
|
+
"mqtt": { "port": 1883, "securePort": 8883, "webSocket": true },
|
|
673
|
+
"analytics": { "aggregatePeriod": 60, "replicate": false },
|
|
674
|
+
"my-app": { "package": "git+https://github.com/example/my-app.git", "port": 4000 }
|
|
675
|
+
}
|
|
676
|
+
]
|
|
677
|
+
}
|
|
678
|
+
`),_A=`inmemory://harper/config-root.json`,vA=`harper://schemas/config-root.json`;async function yA(){let{json:e}=await pe(async()=>{let{json:e}=await import(`./languageServices-U3mWhpRL.js`).then(e=>e.t);return{json:e}},__vite__mapDeps([35,1,16,2,17])),t=e.jsonDefaults,{schemas:n=[],...r}=t.diagnosticsOptions;n.some(e=>e.uri===vA)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:vA,fileMatch:[_A],schema:gA}]})}var bA=({children:e})=>(0,K.jsx)(K.Fragment,{children:e});function xA(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n,isLoading:r}=L(eA({clusterId:e,instanceId:t})),i=q(),{version:a}=Ce({strict:!1}),{data:o}=L(uA(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=L(HE(i)),{data:u,isLoading:d}=L(lA(i)),f=Cg(),{data:p,isLoading:m}=L(LO({...i,enabled:f})),h=(0,G.useMemo)(()=>{if(!p)return null;let e=0,t=n=>{n.mtime&&(e=Math.max(e,new Date(n.mtime).getTime())),`entries`in n&&n.entries&&n.entries.forEach(t)};return t(p),e||null},[p]),g=(0,G.useMemo)(()=>u?pA(u):null,[u]),_=Tx(),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)([]),{onConfigUpdate:E,isPending:D}=cA();(0,G.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,G.useCallback)(e=>{if(x(e||``),e)try{let t=JSON.parse(e);C(null);let n=[],r=(e,t,i=``)=>{for(let a in e){let o=i?`${i}.${a}`:a,s=e[a],c=t?.[a];fA(o,s,c)?n.push(o):typeof s==`object`&&s&&!Array.isArray(s)&&r(s,c,o)}for(let r in t){let a=i?`${i}.${r}`:r;r in e||fA(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,G.useCallback)(()=>{yA().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,G.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=hA(mA(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,G.useMemo)(()=>[],[o,s]),(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsx)(bA,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(tA,{loadingRegistration:l,registrationInfo:c})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(nA,{loading:m,timestamp:h})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,K.jsx)(Qk,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,K.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(H,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,K.jsx)(Ks,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,K.jsxs)(H,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,K.jsx)($o,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,K.jsxs)(H,{size:`sm`,onClick:()=>y(!0),children:[(0,K.jsx)(vs,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,K.jsxs)(c_,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(wi,{className:`h-4 w-4`}),(0,K.jsx)(l_,{children:`Invalid JSON`}),(0,K.jsx)(u_,{children:S})]}),w.length>0&&(0,K.jsxs)(c_,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(wi,{className:`h-4 w-4`}),(0,K.jsx)(l_,{children:`Restricted Configuration`}),(0,K.jsxs)(u_,{children:[`The following fields cannot be modified via Studio:`,(0,K.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`code`,{children:e})},e))})]})]}),(0,K.jsx)(`div`,{className:`grow`,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(my,{className:`w-full`}),(0,K.jsx)(my,{className:`w-full`}),(0,K.jsx)(my,{className:`w-1/2`})]}):(0,K.jsx)(Dx,{className:`w-full min-h-full h-96`,path:_A,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function SA(){let e=q(),{data:t}=L(HE(e)),n=t?.version;return(0,G.useMemo)(()=>t===void 0?void 0:{supported:Th(n),band:Zm(n??``)},[t,n])}function CA(){return SA()?.supported}var wA=(0,G.createContext)(void 0);function TA({children:e}){return(0,K.jsx)(wA,{value:SA(),children:e})}var EA=Bb(),DA=[{header:`Role`,accessorKey:`role`,enableSorting:!1},EA.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),EA.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Bm((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),EA.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>Bm((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),EA.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),EA.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),EA.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,K.jsx)(OA,{permission:e.row.original.permission})})];function OA({permission:e}){let t=(0,G.useContext)(wA);if(t===void 0)return null;let n=Rh(e,t.supported);if(n===`absent`||n===`database`||n===`inert`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper cannot expand this value; assigning the role breaks authentication instance-wide`,children:`breaks auth`});if(n===`malformed`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(Nh(e))return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=Oh(Lh(e)??[],t.band),i=kh(r);return(0,K.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}var kA=[`read`,`insert`,`update`,`delete`],AA=[`read`,`insert`,`update`],jA=new Set([`__createdtime__`,`__updatedtime__`]),MA=new Set([...kA,`attribute_permissions`]),NA=new Set([`attribute_name`,...AA]);function PA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FA(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function IA(e,t,n){let r=!1,i=Object.entries(e).map(([e,i])=>e===t?(r=!0,[e,n]):[e,i]);return r||i.push([t,n]),Object.fromEntries(i)}function LA(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e)))}function RA(e){if(!e)return null;try{let t=JSON.parse(e);return PA(t)?t:null}catch{return null}}function zA(e){return JSON.stringify(zh(e),null,2)}function BA(e,t){let n=Th(t);return Object.keys(e).filter(e=>!jh.has(e)||e===`operations`&&!n)}function VA(e){return e.primary_key??e.hash_attribute??e.attributes?.find(e=>e.is_primary_key)?.attribute}function HA(e){return(e.attributes??[]).map(e=>e.attribute)}function UA(e,t){return Object.keys(e).filter(n=>!jh.has(n)||n===`operations`&&Mh(e,n,t)!==void 0)}function WA(e,t,n){if(KA(n))return[`This Harper version uses the role format from before 2.2, which only the JSON editor supports.`];let r=[],i=Th(n);for(let t of[`super_user`,`cluster_user`])Object.hasOwn(e,t)&&typeof e[t]!=`boolean`&&r.push(`"${t}" must be true or false.`);e.super_user===!0&&e.cluster_user===!0&&r.push(`"super_user" and "cluster_user" cannot both be true.`);let a=e.structure_user;a!==void 0&&typeof a!=`boolean`&&!(Array.isArray(a)&&a.every(e=>typeof e==`string`))&&r.push(`"structure_user" must be true, false, or a list of database names.`);let o=Rh(e,i);(o===`breaks-auth`||o===`malformed`)&&r.push(`"operations" is not a list of operation names.`);for(let i of BA(t,n)){if(!Object.hasOwn(e,i))continue;let n=e[i];if(!PA(n)){r.push(`The entry for database "${i}" is not an object.`);continue}let a=FA(n,`tables`);if(a!==void 0){if(!PA(a)){r.push(`"${i}.tables" is not an object.`);continue}for(let e of Object.keys(t[i])){let t=FA(a,e);t!==void 0&&r.push(...GA(t,`${i}.${e}`))}}}return[...new Set(r)]}function GA(e,t){if(!PA(e))return[`The entry for table "${t}" is not an object.`];if(Object.hasOwn(e,`attribute_restrictions`))return[`"${t}" uses "attribute_restrictions", the role format from before Harper 2.2.`];let n=[],r=kA.filter(t=>typeof e[t]!=`boolean`);r.length&&n.push(`"${t}": ${r.join(`, `)} must each be true or false.`);let i=FA(e,`attribute_permissions`);if(i===null)return n;if(i===void 0)return n.push(`"${t}" needs an "attribute_permissions" list ([] applies the table's access to every attribute).`),n;if(!Array.isArray(i))return n.push(`"${t}.attribute_permissions" must be a list.`),n;let a=new Set;for(let e of i){if(!PA(e)||typeof e.attribute_name!=`string`){n.push(`"${t}.attribute_permissions" has an entry without an attribute_name.`);continue}let r=e.attribute_name;a.has(r)&&n.push(`"${t}.attribute_permissions" lists "${r}" more than once.`),a.add(r),AA.some(t=>typeof e[t]!=`boolean`)&&n.push(`"${t}.attribute_permissions": "${r}" needs read, insert and update set to true or false.`)}return n}function KA(e){return yr(e,`0.0.0`)>=0&&yr(e,`2.2.0`)<0}function qA(e,t,n){let r=Th(n),i=new Set(BA(t,n)),a=[],o=[];if(Array.isArray(e.structure_user))for(let t of e.structure_user)i.has(t)||a.push(`structure_user database "${t}"`);!r&&e.operations!==void 0&&!UA(e,!1).includes(`operations`)&&o.push(`"operations" (has no effect before Harper 5.0)`);for(let n of UA(e,r)){if(!i.has(n)){a.push(`database "${n}"`);continue}let r=e[n];if(!PA(r))continue;for(let e of Object.keys(r))e!==`tables`&&o.push(`"${n}.${e}"`);let s=FA(r,`tables`);if(!PA(s))continue;let c=t[n];for(let e of Object.keys(s)){let t=Object.hasOwn(c,e)?c[e]:void 0;if(!t){a.push(`table "${n}.${e}"`);continue}let r=s[e];if(!PA(r))continue;let i=`${n}.${e}`;for(let e of Object.keys(r))MA.has(e)||o.push(`"${i}.${e}"`);let l=FA(r,`attribute_permissions`);if(!Array.isArray(l))continue;let u=new Set(HA(t));for(let e of l){if(!PA(e))continue;let t=String(e.attribute_name);u.has(t)||o.push(`attribute "${i}.${t}"`);for(let n of Object.keys(e))NA.has(n)||o.push(`"${n}" on attribute "${i}.${t}"`)}}}return{notInSchema:a,notShown:o}}function JA(e,t,n){let r=Th(n),i=new Set(BA(t,n)),a=LA(e,new Set(UA(e,r).filter(e=>!i.has(e))));Array.isArray(a.structure_user)&&(a=IA(a,`structure_user`,a.structure_user.filter(e=>i.has(e))));for(let e of i){let n=FA(a,e),r=PA(n)?FA(n,`tables`):void 0;if(!PA(n)||!PA(r))continue;let i=t[e],o=new Set(Object.keys(r).filter(e=>!Object.hasOwn(i,e)));o.size&&(a=IA(a,e,IA(n,`tables`,LA(r,o))))}return a}function YA(e){return e.super_user===!0?`super_user`:e.cluster_user===!0?`cluster_user`:`standard`}function XA(e,t){let n=e;for(let e of[`super_user`,`cluster_user`])t===e?n=IA(n,e,!0):Object.hasOwn(n,e)&&(n=IA(n,e,!1));return zh(n)}function ZA(e,t){return t===!1&&!Object.hasOwn(e,`structure_user`)?e:zh(IA(e,`structure_user`,t))}function QA(e,t){let n=FA(e,t);return PA(n)?n:void 0}function $A(e,t){let n=e&&FA(e,`tables`),r=PA(n)?FA(n,t):void 0;return PA(r)?r:void 0}function ej(e,t,n){return $A(QA(e,t),n)}function tj(e){let t=e?.attribute_permissions;return Array.isArray(t)&&t.length>0}function nj(){return{read:!1,insert:!1,update:!1,delete:!1,attribute_permissions:[]}}function rj(e,t,n,r){let i=FA(e,t),a=PA(i)?i:{},o=FA(a,`tables`);return IA(e,t,IA(a,`tables`,IA(PA(o)?o:{},n,r)))}function ij(e,t,n){let r={...e,[t]:n};return!n&&t!==`delete`&&Array.isArray(e.attribute_permissions)&&(r.attribute_permissions=e.attribute_permissions.map(e=>e[t]?{...e,[t]:!1}:e)),r}function aj(e,t,n,r,i){let a=ej(e,t,n);return!a&&!i?e:rj(e,t,n,ij(a??nj(),r,i))}function oj(e,t,n,r,i){let a=FA(e,t),o=PA(a)?a:{},s=FA(o,`tables`),c=PA(s)?s:{},l=new Map;for(let a of n){let n=ej(e,t,a);(n||i)&&l.set(a,ij(n??nj(),r,i))}if(!l.size)return e;let u=Object.entries(c).map(([e,t])=>{let n=l.get(e);return l.delete(e),[e,n??t]});return u.push(...l.entries()),IA(e,t,IA(o,`tables`,Object.fromEntries(u)))}function sj(e,t,n){let r=new Map((e.attribute_permissions??[]).map(e=>[e.attribute_name,e])),i=(e,t)=>{let n=jA.has(e);return{read:t?.read===!0,insert:!n&&t?.insert===!0,update:!n&&t?.update===!0}},a={read:!1,insert:!1,update:!1};for(let[e,t]of r)if(e!==n){let n=i(e,t);for(let e of AA)a[e]||=n[e]}return t.map(e=>{let t=r.get(e),o=e===n,s=o&&!t;return{name:e,...s?a:i(e,t),isPrimaryKey:o,isTimestamp:jA.has(e),derived:s}})}function cj(e,t,n,r,i,a){let o=ej(e,t,n)??nj(),s=r?a?.length?a.map(e=>({...e,read:e.read&&o.read,insert:e.insert&&o.insert,update:e.update&&o.update})):i.map(e=>({attribute_name:e,read:o.read,insert:!jA.has(e)&&o.insert,update:!jA.has(e)&&o.update})):[];return rj(e,t,n,{...o,attribute_permissions:s})}function lj(e,t,n,r,i,a,o,s){let c=ej(e,t,n);if(!c||!Array.isArray(c.attribute_permissions))return e;let l=c.attribute_permissions,u=l.findIndex(e=>e.attribute_name===a),d;if(u>=0)d=l.map((e,t)=>t===u?{...e,[o]:s}:e);else{let e=sj(c,r,i).find(e=>e.name===a);d=[...l,{attribute_name:a,read:e?.read??!1,insert:e?.insert??!1,update:e?.update??!1,[o]:s}]}return rj(e,t,n,{...c,attribute_permissions:d,...s&&!c[o]?{[o]:!0}:{}})}function uj({...e}){return(0,K.jsx)(bn,{"data-slot":`accordion`,...e})}function dj({className:e,...t}){return(0,K.jsx)(zn,{"data-slot":`accordion-item`,className:F(`border-b last:border-b-0`,e),...t})}function fj({className:e,children:t,...n}){return(0,K.jsx)(Mn,{className:`flex`,children:(0,K.jsxs)(ln,{"data-slot":`accordion-trigger`,className:F(`focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,K.jsx)(er,{className:`text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200`})]})})}function pj({className:e,children:t,...n}){return(0,K.jsx)(an,{"data-slot":`accordion-content`,className:`data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm`,...n,children:(0,K.jsx)(`div`,{className:F(`pt-0 pb-4`,e),children:t})})}function mj({className:e,...t}){return(0,K.jsx)(Vn,{"data-slot":`radio-group`,className:F(`grid gap-3`,e),...t})}function hj({className:e,...t}){return(0,K.jsx)(Ln,{"data-slot":`radio-group-item`,className:F(`border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(An,{"data-slot":`radio-group-indicator`,className:`relative flex items-center justify-center`,children:(0,K.jsx)(Ii,{className:`fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2`})})})}function gj({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=Dh(n),c=yh.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=Eh(n),u=Zm(n),d=Qm(u),f=new Set(e??[]),p=(e??[]).filter(e=>!wh(e)),m=e?Oh(e,u):[],h=m.some(e=>Sh(e)?.su),g=(0,G.useRef)([]),_=e=>{let n=new Set(e),r=yh.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!wh(e)).sort();t([...r,...i])},v=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),_(n)};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,K.jsxs)(Md,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kx,{checked:o,onCheckedChange:n=>{n?t(g.current):(g.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,K.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?d?`Only the operations below are allowed — anything unlisted is denied, SQL included: SQL statements need sql (or a group with it) listed here, and are then checked against table permissions as well. Listing an operation that normally requires super_user deliberately grants it to this role.`:`Only the operations below are allowed — anything unlisted is denied. Listing an operation that normally requires super_user deliberately grants it to this role. SQL statements are authorized against table permissions instead, so this list does not restrict them.`:`No operation-level restriction. Add one to limit this role to an explicit list of API operations (for example a deploy-only CI role).`}),r&&(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`Harper does not accept an operations allowlist on a super_user or cluster_user role — the save is rejected unless the list is dropped. Clear that flag to scope this role by operation; otherwise the allowlist is removed when you save.`}),i&&o&&(d?(0,K.jsx)(_j,{scope:i,effective:m}):(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:Fh.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:i.join(`, `)}),` `,`regardless of the list below — and listing them here cannot reach another database.`]}),` Every other operation is still gated by the list.`]})),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,K.jsx)(vj,{group:e,checked:f.has(e.name),onToggle:v,disabled:a},e.name)),c.map(e=>(0,K.jsx)(vj,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:v,disabled:a},e.name))]}),(0,K.jsx)(xj,{grantable:l,band:u,selectedSet:f,onToggle:v,disabled:a}),p.length>0&&(0,K.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:p.map(e=>(0,K.jsx)(Sj,{name:e,band:u,onRemove:()=>v(e),disabled:a},e))}),m.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e?.length?`Every entry here is inert`:`Nothing selected`,` `,`— this role cannot run any Operations API call`,d?`, not even SQL${i?` or its structure-user DDL`:``}.`:`${i?`, except the DDL noted above`:``} (SQL is gated by table permissions, not this list).`]}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:kh(m),children:[`Effectively allows `,oe(m.length,`operation`,`operations`),h?`, including some that normally require super_user`:``,`.`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,kh(m)]})]})]})]})}function _j({scope:e,effective:t}){let n=e===!0?[...Fh,...Ih]:Fh,r=n.filter(e=>!t.includes(e));return(0,K.jsxs)(`p`,{className:F(`text-xs`,r.length>0?`text-warning`:`text-muted-foreground`),children:[`This role is a structure user`,e===!0?``:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.join(`, `)})]}),`, but on this Harper version the list below gates its DDL too: it can run`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n.join(`, `)}),e===!0?` only when they are listed.`:` on those databases only when they are listed, and listing them cannot reach another database.`,r.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`Not listed, so Harper refuses them: `,(0,K.jsx)(`span`,{className:`font-mono`,children:r.join(`, `)}),`.`]})]})}function vj({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,K.jsxs)(Md,{className:`flex items-start gap-2 font-normal`,children:[(0,K.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var yj=`This instance's Harper checks this operation under its internal handler name, so listing it has no effect here (HarperFast/harper#2175). Harper 5.3.0 and later grant it, as do prereleases from ${Xm}.`,bj=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function xj({grantable:e,band:t,selectedSet:n,onToggle:r,disabled:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!a)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l.current?.focus())});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[a]);let d=s.trim(),f=d.toLowerCase(),p=f?e.filter(e=>e.name.includes(f)):e,m=D_(p,`category`),h=Sh(d),g=!h&&(wh(f)||_h.some(e=>e.name===f)),_=bj.test(d)&&!wh(d)&&!g&&!h?.nonDelegable&&!h?.aliasOf&&eh(d,t)!==`never`&&!e.some(e=>e.name===d)&&!n.has(d)?d:void 0;return(0,K.jsxs)(gc,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(_c,{asChild:!0,disabled:i,children:(0,K.jsxs)(H,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,K.jsx)(er,{className:`size-4 shrink-0 opacity-60`})]})}),(0,K.jsxs)(vc,{ref:u,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,K.jsx)(`input`,{ref:l,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=u.current?.querySelectorAll(`[role="menuitemcheckbox"]:not([data-disabled])`);t?.length&&(e.key===`ArrowDown`?t[0]:t[t.length-1]).focus();return}e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.stopPropagation()},placeholder:`Filter operations…`,"aria-label":`Filter operations`,className:`mb-1 w-full rounded-md border bg-transparent px-2 py-1 text-sm outline-none`}),gh.filter(e=>m[e]).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Cc,{className:`text-xs text-muted-foreground`,children:e}),m[e].map(e=>(0,K.jsxs)(bc,{checked:n.has(e.name),onCheckedChange:()=>r(e.name),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),eh(e.name,t)===`needs-5.3`?(0,K.jsx)(ol,{variant:`outline`,title:yj,children:`needs newer Harper`}):e.su&&(0,K.jsx)(ol,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),_&&(0,K.jsxs)(bc,{checked:!1,onCheckedChange:()=>r(_),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(Uo,{className:`size-3`}),(0,K.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,K.jsx)(`span`,{className:`font-mono`,children:_}),`" `,h?`(listed for newer Harper versions — this instance may reject it)`:`(component-registered operation)`]})]}),p.length===0&&!_&&(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function Sj({name:e,band:t,onRemove:n,disabled:r}){let i=Sh(e),a=th(e,t),o=eh(e,t),s=a?`destructive`:i?.su?`warning`:i?`secondary`:`outline`,c=i?.aliasOf?`Legacy alias: Harper authorizes this operation under '${i.aliasOf}', so this entry grants nothing. Grant '${i.aliasOf}' instead.`:o===`needs-5.3`?yj:o===`never`?`This instance's Harper version never lets an operations allowlist grant this operation, so this entry has no effect; only a super_user role can run it.`:i?.nonDelegable?`Always requires an actual super_user role; listing it cannot delegate the operation to a non-super_user role.`:$m(e,t)?i?.caveat:i?.su?`Normally requires super_user; listing it grants it to this role.`:i?void 0:`Not in the built-in catalog — kept as-is (for example a component-registered operation).`;return(0,K.jsxs)(ol,{variant:s,title:c,className:`gap-1 font-mono text-xs`,children:[e,!r&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:n,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,K.jsx)(Ks,{className:`size-3`})})]})}var Cj={read:`Read`,insert:`Insert`,update:`Update`,delete:`Delete`};function wj({permission:e,onChange:t,instanceDatabaseMap:n,version:r,readOnly:i}){let a=YA(e),o=e.structure_user,s=Th(r),c=(0,G.useMemo)(()=>BA(n,r),[n,r]),l=(0,G.useMemo)(()=>qA(e,n,r),[e,n,r]),u=JSON.stringify(Lh(e)??null),d=(0,G.useMemo)(()=>JSON.parse(u)??void 0,[u]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[l.notInSchema.length>0&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:`This role names things this instance's schema doesn't have`}),(0,K.jsxs)(u_,{children:[(0,K.jsxs)(`p`,{children:[l.notInSchema.join(`, `),`. Harper refuses to save a role that names a database or table that doesn't exist, so remove them before saving.`]}),!i&&(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,className:`mt-2`,onClick:()=>t(JA(e,n,r)),children:`Remove them`})]})]}),(0,K.jsx)(Ej,{permission:e,roleType:a,version:r,readOnly:i,onChange:t}),a===`standard`&&(0,K.jsx)(Oj,{permission:e,databaseNames:c,readOnly:i,onChange:t}),s&&(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Operations`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Operations`}),(0,K.jsx)(gj,{value:d,onChange:n=>t(Bh(e,n)),version:r,allowlistRejected:Nh(e),structureUserDdl:Ph(e),disabled:i})]}),a===`standard`&&o!==!0&&(0,K.jsx)(kj,{permission:e,instanceDatabaseMap:n,databaseNames:c,structureDatabases:Array.isArray(o)?o:[],readOnly:i,onChange:t}),l.notShown.length>0&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`Also kept as they are, but not shown here:`,` `,l.notShown.join(`, `),`. Use “Edit as JSON” to see or change them.`]})]})}function Tj(e,t){return Object.keys(e).some(n=>n!==t&&e[n]!==!1)}function Ej({permission:e,roleType:t,version:n,readOnly:r,onChange:i}){let a=(0,G.useId)(),o=yr(n,`0.0.0`)>=0&&yr(n,`5.0.0-0`)<0,s=t===`cluster_user`||o,c=t!==`standard`&&Tj(e,t);return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`${a}-heading`,children:[(0,K.jsx)(`h3`,{id:`${a}-heading`,className:`text-sm font-medium`,children:`Role type`}),(0,K.jsxs)(mj,{value:t,onValueChange:t=>i(XA(e,t)),disabled:r,"aria-labelledby":`${a}-heading`,children:[(0,K.jsx)(Dj,{id:`${a}-standard`,value:`standard`,label:`Standard`,children:`Access comes from the database and table permissions below.`}),(0,K.jsx)(Dj,{id:`${a}-super`,value:`super_user`,label:`Super user`,children:`Bypasses per-table permissions.`}),s&&(0,K.jsx)(Dj,{id:`${a}-cluster`,value:`cluster_user`,label:`Cluster user`,children:o?`For the user that connects cluster nodes. A user with this role can list every database, table and attribute, and Harper keeps its password in a recoverable form so clustering can use it.`:`Harper 5 doesn't use this role type. Harper 4 used it for the user that connects cluster nodes.`})]}),c&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Saving keeps only the `,(0,K.jsx)(`span`,{className:`font-mono`,children:t}),` flag: Harper rejects a`,` `,t===`super_user`?`super user`:`cluster user`,` `,`role that carries any other permission, so this role's other settings are removed.`]})]})}function Dj({id:e,value:t,label:n,children:r}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(hj,{id:e,value:t,className:`mt-0.5`}),(0,K.jsxs)(Md,{htmlFor:e,className:`flex flex-col items-start gap-1 font-normal`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})]})}function Oj({permission:e,databaseNames:t,readOnly:n,onChange:r}){let i=(0,G.useId)(),a=e.structure_user,o=a===!0?`all`:Array.isArray(a)?`selected`:`off`,s=Array.isArray(a)?a:[],c=(0,G.useRef)(s),l=[...t,...s.filter(e=>!t.includes(e))],u=Object.keys(e).some(e=>!jh.has(e)),d=t=>{Array.isArray(a)&&(c.current=a),r(ZA(e,t===`all`||t===`selected`&&c.current))},f=t=>{r(ZA(e,s.includes(t)?s.filter(e=>e!==t):[...s,t]))};return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`${i}-heading`,children:[(0,K.jsx)(`h3`,{id:`${i}-heading`,className:`text-sm font-medium`,children:`Structure user`}),(0,K.jsxs)(mj,{value:o,onValueChange:d,disabled:n,"aria-labelledby":`${i}-heading`,children:[(0,K.jsx)(Dj,{id:`${i}-off`,value:`off`,label:`No`,children:`Creating and dropping databases, tables and attributes needs super user, or an operations list that grants it.`}),(0,K.jsx)(Dj,{id:`${i}-all`,value:`all`,label:`All databases`,children:`Can create and drop databases, tables and attributes, and can read, insert, update and delete in every table.`}),(0,K.jsx)(Dj,{id:`${i}-selected`,value:`selected`,label:`Selected databases`,children:`Can create and drop tables and attributes in the selected databases, and can read, insert, update and delete in their tables. Creating and dropping databases isn't included.`})]}),o!==`off`&&e.operations!==void 0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The operations list below can still deny some of these.`}),o===`all`&&u&&(0,K.jsx)(`p`,{className:`text-xs text-warning`,children:`Per-table permissions don't apply to this role, so they are removed when you save.`}),o===`selected`&&(0,K.jsxs)(`div`,{className:`ml-6 flex flex-col gap-1`,children:[l.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This instance has no databases.`}),l.map(e=>(0,K.jsxs)(Md,{className:`flex items-center gap-2 font-normal`,children:[(0,K.jsx)(Nj,{checked:s.includes(e),onChange:()=>f(e),disabled:n,"aria-label":`Structure user on ${e}`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e}),!t.includes(e)&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(not in this instance's schema)`})]},e))]})]})}function kj({permission:e,instanceDatabaseMap:t,databaseNames:n,structureDatabases:r,readOnly:i,onChange:a}){let[o,s]=(0,G.useState)(()=>[n.find(n=>Object.keys(t[n]).some(t=>{let r=ej(e,n,t);return r&&kA.some(e=>r[e]===!0)}))??n[0]].filter(e=>e!==void 0)),c=(0,G.useRef)(new Map),l=(0,G.useRef)({permission:e,onChange:a});(0,G.useLayoutEffect)(()=>{l.current={permission:e,onChange:a}},[e,a]);let u=(0,G.useCallback)(e=>{l.current.onChange(e(l.current.permission))},[]);return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Table permissions`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Table permissions`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A table without a checked permission has no access. Delete always applies to whole records.`}),n.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This instance has no databases.`}),(0,K.jsx)(uj,{type:`multiple`,value:o,onValueChange:s,className:`rounded-md border`,children:n.map(n=>(0,K.jsx)(Aj,{databaseName:n,tables:t[n],record:QA(e,n),structureScoped:r.includes(n),readOnly:i,update:u,scopingRestore:c},n))})]})}var Aj=(0,G.memo)(function({databaseName:e,tables:t,record:n,structureScoped:r,readOnly:i,update:a,scopingRestore:o}){let s=Object.keys(t),c=s.map(e=>$A(n,e)),l=c.filter(e=>e&&kA.some(t=>e[t]===!0)).length;return(0,K.jsxs)(dj,{value:e,className:`px-3`,children:[(0,K.jsx)(fj,{className:`py-3`,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:r?`full access (structure user)`:`${l} of ${s.length} ${s.length===1?`table`:`tables`} with access`})]})}),(0,K.jsx)(pj,{children:r?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`As a structure user on this database, the role can read, insert, update and delete in every table here, so per-table permissions don't apply to it.`}):s.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No tables.`}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b text-xs text-muted-foreground`,children:[(0,K.jsx)(`th`,{className:`py-1 pr-2 text-left font-normal`,children:`Table`}),kA.map(e=>(0,K.jsx)(`th`,{className:`px-2 py-1 text-center font-normal`,children:Cj[e]},e)),(0,K.jsx)(`th`,{className:`py-1 pl-2 text-left font-normal`,children:`Attributes`})]})}),(0,K.jsxs)(`tbody`,{children:[(0,K.jsxs)(`tr`,{className:`border-b`,children:[(0,K.jsx)(`td`,{className:`py-1 pr-2 text-xs text-muted-foreground`,children:`All tables`}),kA.map(t=>{let n=c.filter(e=>e?.[t]===!0).length;return(0,K.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,K.jsx)(Nj,{checked:n===s.length,indeterminate:n>0&&n<s.length,disabled:i,"aria-label":`${Cj[t]} on every table in ${e}`,onChange:()=>a(r=>oj(r,e,s,t,n<s.length))})},t)}),(0,K.jsx)(`td`,{})]}),s.map((n,r)=>(0,K.jsx)(jj,{databaseName:e,tableName:n,schemaTable:t[n],entry:c[r],readOnly:i,update:a,scopingRestore:o},n))]})]})})})]})}),jj=(0,G.memo)(function({databaseName:e,tableName:t,schemaTable:n,entry:r,readOnly:i,update:a,scopingRestore:o}){let s=(0,G.useMemo)(()=>HA(n),[n]),c=VA(n),l=tj(r),[u,d]=(0,G.useState)(!1),f=`${e}.${t}`,p=l&&r?sj(r,s,c):[],m=p.filter(e=>AA.some(t=>e[t])).length,h=`${e}\u0000${t}`;return(0,K.jsxs)(G.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,K.jsx)(`td`,{className:`py-1 pr-2 font-mono text-xs`,children:t}),kA.map(n=>(0,K.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,K.jsx)(Nj,{checked:r?.[n]===!0,disabled:i,"aria-label":`${Cj[n]} on ${f}`,onChange:r=>{let{checked:i}=r.target;a(r=>aj(r,e,t,n,i))}})},n)),(0,K.jsx)(`td`,{className:`py-1 pl-2`,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),"aria-expanded":u,"aria-label":`Attribute permissions for ${f}`,children:[u?(0,K.jsx)(er,{className:`size-3`}):(0,K.jsx)(Si,{className:`size-3`}),l?`${m} of ${s.length}`:`All`]})})]}),u&&(0,K.jsx)(`tr`,{className:`border-b bg-muted/30`,children:(0,K.jsx)(`td`,{colSpan:kA.length+2,className:`px-3 py-2`,children:(0,K.jsx)(Mj,{label:f,scoped:l,views:p,disabled:i||s.length===0,onScopingChanged:n=>{!n&&r?.attribute_permissions&&o.current.set(h,r.attribute_permissions),a(r=>cj(r,e,t,n,s,n?o.current.get(h):void 0))},onActionChanged:(n,r,i)=>a(a=>lj(a,e,t,s,c,n,r,i))})})})]})});function Mj({label:e,scoped:t,views:n,disabled:r,onScopingChanged:i,onActionChanged:a}){let o=(0,G.useId)(),s=n.find(e=>e.derived);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kx,{id:o,checked:t,onCheckedChange:i,disabled:r,"aria-label":`Limit ${e} to specific attributes`}),(0,K.jsx)(Md,{htmlFor:o,className:`font-normal`,children:`Limit to specific attributes`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t?`Only the access checked here applies. An attribute with nothing checked has no access, including attributes added to the table later. Computed and relationship attributes may be missing from this list; grant those in the JSON.`:`The table's read, insert and update apply to every attribute. Limiting lists only the attributes this instance's schema shows, which can leave out computed and relationship attributes, and those then have no access until granted in the JSON.`}),t&&(0,K.jsxs)(`table`,{className:`w-full max-w-md text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,K.jsx)(`th`,{className:`py-1 pr-2 text-left font-normal`,children:`Attribute`}),AA.map(e=>(0,K.jsx)(`th`,{className:`px-2 py-1 text-center font-normal`,children:Cj[e]},e))]})}),(0,K.jsx)(`tbody`,{children:n.map(t=>(0,K.jsxs)(`tr`,{children:[(0,K.jsxs)(`td`,{className:`py-0.5 pr-2 font-mono`,children:[t.name,t.isPrimaryKey&&(0,K.jsx)(`span`,{className:`ml-1 font-sans text-muted-foreground`,children:`(primary key)`})]}),AA.map(n=>{let i=t.isTimestamp&&n!==`read`;return(0,K.jsx)(`td`,{className:`px-2 py-0.5 text-center`,children:(0,K.jsx)(Nj,{checked:t[n],disabled:r||i,title:i?`Harper applies only read to this timestamp attribute.`:void 0,"aria-label":`${Cj[n]} on ${e}.${t.name}`,onChange:e=>a(t.name,n,e.target.checked)})},n)})]},t.name))})]}),t&&s&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The primary key `,(0,K.jsx)(`span`,{className:`font-mono`,children:s.name}),` `,`isn't listed, so it gets whatever access any other attribute has. Changing it here sets it explicitly.`]}),t&&n.some(e=>e.isTimestamp)&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Harper applies only read to timestamp attributes.`})]})}function Nj({indeterminate:e=!1,className:t,...n}){let r=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{r.current&&(r.current.indeterminate=e)},[e]),(0,K.jsx)(`input`,{ref:r,type:`checkbox`,className:F(`size-4 cursor-pointer align-middle disabled:cursor-not-allowed disabled:opacity-50`,t),...n})}function Pj({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names. Harper still gates on it: a string is read one character at a time, so every operation is denied; an array with non-string members enforces whatever it does expand to; and a falsy value makes each of this role's requests fail outright. The role cannot be saved again until it is fixed.`,` `,t?`Correct it in the role editor.`:`Correct it in the JSON below.`]}):(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names — most often table permissions on a database of that name, kept from an older Harper. This version cannot expand it, and `,t?`assigning this role to a user breaks authentication for every user on the instance. Pick a different role, and repair this one in the role editor first.`:(0,K.jsxs)(K.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,K.jsxs)(K.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`stops every role from using one. Retiring it means migrating its data and table grants to a differently-named database and verifying them there first — dropping it destroys whatever it holds, so treat that as a planned migration rather than part of this repair.`]})]})]})}async function Fj({instanceClient:e,skipRecordCount:t,includeComputed:n}){let{data:r}=await e.post(`/`,{operation:`describe_all`,skip_record_count:t||void 0,exact_count:!t&&void 0,include_computed:n||void 0});return r}function Ij(e){return B({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount,!!e.includeComputed],queryFn:()=>Fj(e),staleTime:6e4,gcTime:5e3,retry:!1})}function Lj(){let e=q(),t=L(Ij({...e,skipRecordCount:!0})),n=L(HE(e));return{instanceDatabaseMap:t.data,version:n.data?.version,isLoading:t.isPending||n.isPending,isError:t.isError&&!t.data||n.isError&&!n.data,retry:()=>{t.refetch(),n.refetch()}}}function Rj(e,t){if(!e)return!1;if(!t)return e.operations!==void 0&&Lh(e)===void 0;let n=Rh(e,Th(t));return n===`breaks-auth`||n===`malformed`}var zj=5;function Bj({draft:e,schema:t,readOnly:n}){let{text:r,permission:i}=e,a=Tx(),{instanceDatabaseMap:o,version:s}=t,c=!!o&&!!s,[l,u]=(0,G.useState)(),d=(0,G.useDeferredValue)(i),f=l===!0?d:i,p=(0,G.useMemo)(()=>!o||!s?[]:f?WA(f,o,s):[`The JSON is not a valid object.`],[f,o,s]),m=c&&!!f&&p.length===0;l===void 0&&c&&u(!m);let h=i&&s?Rh(i,Th(s)):`absent`,g=i?.operations;return t.isLoading&&!t.isError?(0,K.jsx)(my,{}):l===!1&&m&&i&&o&&s?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:()=>u(!0),children:[(0,K.jsx)(Xi,{}),` Edit as JSON`]})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,K.jsx)(wj,{permission:i,onChange:e.setPermission,instanceDatabaseMap:o,version:s,readOnly:n})})]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.isError?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`The visual editor needs this instance's schema and version, which didn't load.`,(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:t.retry,children:[(0,K.jsx)(Go,{}),` Retry`]})]}):p.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:`The visual editor can't show this role until the JSON is fixed:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-4`,children:[p.slice(0,zj).map(e=>(0,K.jsx)(`li`,{children:e},e)),p.length>zj&&(0,K.jsxs)(`li`,{children:[`…and `,p.length-zj,` more.`]})]})]})}),c&&(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,className:`shrink-0`,disabled:!m,onClick:()=>u(!1),children:[(0,K.jsx)(Es,{}),` Visual editor`]})]}),(h===`breaks-auth`||h===`malformed`)&&(0,K.jsx)(Pj,{kind:h,databaseCollision:typeof g==`object`&&!!g&&!Array.isArray(g)}),(0,K.jsx)(`div`,{className:`min-h-64 flex-1`,children:(0,K.jsx)(Dx,{className:`h-full w-full`,theme:a,defaultLanguage:`json`,value:r,options:{readOnly:n,automaticLayout:!0},onChange:t=>e.setText(t??``)})})]})}function Vj(e){let[t,n]=(0,G.useState)(()=>Hj(e)),r=(0,G.useCallback)(e=>n({text:e,permission:RA(e)}),[]),i=(0,G.useCallback)(e=>n(Hj(e)),[]);return{...t,setText:r,setPermission:i}}function Hj(e){return{text:zA(e),permission:zh(e)}}function Uj(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return Wj(e);let t=Nh(e),n={...e};for(let e in n)(!jh.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||e===`structure_user`&&t||n[e]===!1)&&delete n[e];return n}function Wj(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Gj(t)]))}function Gj(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let{tables:t}=e;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,tables:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,typeof t==`object`&&t&&`attribute_permissions`in t&&t.attribute_permissions===null?{...t,attribute_permissions:[]}:t]))}}async function Kj({role:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`add_role`,role:e,permission:t});return r}function qj(){return I({mutationFn:Kj})}var Jj=b({role:x().nonempty({error:`Please enter a role.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role cannot be longer than 30 characters.`})}),Yj={super_user:!1,structure_user:!1};function Xj({onChangesSaved:e,closeModal:t}){let n=on({resolver:mt(Jj),defaultValues:{role:``}}),r=q(),i=Lj(),{mutate:a,isPending:o}=qj(),s=Vj(Yj),{permission:c}=s,l=Rj(c,i.version),u=(0,G.useCallback)(t=>{c&&!l&&a({role:t.role,permission:Uj(c),...r},{onSuccess:()=>{U.success(`Role added successfully!`),e()}})},[a,r,e,l,c]);return(0,K.jsx)(_m,{onOpenChange:t,open:!0,children:(0,K.jsx)(wm,{resizable:!0,"aria-describedby":void 0,children:(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`instance-add-role-form`,name:`instance-add-role-form`,onSubmit:n.handleSubmit(u),className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add New Role`}),(0,K.jsx)(Om,{children:`Name the role and choose what it can access.`})]}),(0,K.jsx)(Y,{control:n.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,maxLength:Jj.shape.role.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Bj,{draft:s,schema:i}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:t,disabled:o,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:o||!c||l,children:[(0,K.jsx)($o,{}),` Add Role`]})]})})]})})})})}function Zj({entityId:e,instanceClient:t}){return B({queryKey:[e,`list_roles`],queryFn:()=>Qj({instanceClient:t}),refetchInterval:Gc(1e4),retry:Kc()})}async function Qj({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}async function $j({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function eM(){return I({mutationFn:$j})}async function tM({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function nM(){return I({mutationFn:tM})}function rM({data:e,instanceId:t,clusterId:n,isModalOpen:r,closeModal:i,onSelectRole:a,onChangesSaved:o}){let{role:s}=e,c=q(),l=Lj(),u=Tr(t??n).user?.role?.id===e.id,d=Vj(e.permission),{permission:f}=d,[p,m]=(0,G.useState)(e.__updatedtime__),h=e.__updatedtime__!==p,{mutate:g,isPending:_}=eM(),{mutate:v,isPending:y}=nM(),[b,x]=(0,G.useState)(!1),S=Rj(f,l.version),C=(0,G.useCallback)(()=>{!f||S||h||g({id:e.id,permission:Uj(f),...c},{onSuccess:()=>{U.success(`Role updated successfully!`),a(void 0),o()}})},[g,h,e.id,c,o,a,S,f]),{setPermission:w}=d,[T,E]=(0,G.useState)(0),D=(0,G.useCallback)(()=>{w(e.permission),E(e=>e+1),m(e.__updatedtime__)},[e.__updatedtime__,e.permission,w]),O=(0,G.useCallback)(()=>m(e.__updatedtime__),[e.__updatedtime__]),k=(0,G.useCallback)(()=>{v({id:e.id,...c},{onSuccess:()=>{U.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,v,c,o,a]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_m,{onOpenChange:i,open:r,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsxs)(Dm,{children:[u?`View`:`Edit`,` Role "`,s,`"`]}),(0,K.jsx)(Om,{children:u?`You can view your own role, but you cannot edit it. Please assign yourself a different role to edit this role.`:`Choose what this role can access, or remove the role entirely.`}),h&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-warning`,role:`status`,children:[(0,K.jsx)(`span`,{children:`This role was changed somewhere else after you opened it. Load that version, or keep yours to replace it when you save.`}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,onClick:D,children:`Load the latest version`}),!u&&(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,onClick:O,children:`Keep my changes`})]}),(0,K.jsx)(Bj,{draft:d,schema:l,readOnly:u},T),(0,K.jsx)(Em,{children:!u&&(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:()=>x(!0),disabled:_,children:`Delete Role`}),(0,K.jsx)(H,{variant:`submit`,onClick:C,disabled:_||!f||S||h,children:`Save Changes`})]})})]})}),(0,K.jsx)(km,{isModalOpen:b,setIsModalOpen:x,deletionConfirmed:k,deletionPending:y,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:s,hideDataLossWarning:!0})]})}function iM(){let e=De(),{clusterId:t,instanceId:n,roleId:r}=z({strict:!1}),i=q(),{data:a,refetch:o,isFetching:s,isRefetching:c}=we(Zj(i)),l=(0,G.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,G.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,G.useState)(!1),m=(0,G.useCallback)(()=>{p(!0)},[p]),h=(0,G.useCallback)(()=>{o(),p(!1)},[o]),g=(0,G.useCallback)(()=>{p(!1)},[]),_=(0,G.useCallback)(e=>{u(e.original.id)},[u]),v=(0,G.useCallback)(()=>{u(void 0)},[u]),y=Kb(o);return(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsx)(TA,{children:(0,K.jsxs)(Hb,{columns:DA,data:a,isFetching:s,onRowClick:_,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:y,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),f&&(0,K.jsx)(Xj,{onChangesSaved:h,closeModal:g}),d&&(0,K.jsx)(rM,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:v,data:l,onSelectRole:u,onChangesSaved:()=>o()},l.id)]})}function aM(e){return!!e?.entries}function oM(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)aM(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function sM({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(!1),m=(0,G.useId)(),h=(0,G.useId)(),g=(0,G.useRef)(!1),_=(0,G.useRef)(!1),v=r||f,y=(0,G.useMemo)(()=>{if(e.length===0)return[];let n=o.trim(),r=n.toLowerCase(),i=new Set(t),a=e.filter(e=>!i.has(e)),s=(n?a.filter(e=>e.toLowerCase().includes(r)):a).map(e=>({value:e,custom:!1})),c=a.some(e=>e.toLowerCase()===r);return n&&!c&&s.push({value:n,custom:!0}),s},[e,t,o]),b=y.length===0?0:Math.min(u,y.length-1),x=(0,G.useCallback)(async e=>{if(_.current)return;let r=e.trim();if(!r||t.includes(r)){s(``);return}_.current=!0,p(!0);try{await n(r),s(``),l(!1)}catch{}finally{_.current=!1,p(!1)}},[t,n]),S=(0,G.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`){e.preventDefault(),l(!0),d(Math.min(b+1,Math.max(0,y.length-1)));return}if(e.key===`ArrowUp`){e.preventDefault(),d(Math.max(0,b-1));return}if(e.key===`Escape`){c&&(e.preventDefault(),e.stopPropagation(),l(!1));return}e.key===`Enter`&&(e.preventDefault(),S())},[c,y,b,S]),w=(0,G.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,K.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`text`,role:`combobox`,"aria-expanded":T,"aria-controls":T?m:void 0,"aria-autocomplete":`list`,"aria-activedescendant":T&&y[b]?`${h}-${b}`:void 0,autoComplete:`off`,autoCapitalize:`off`,placeholder:e.length>0?`Search applications…`:`application name`,value:o,onChange:e=>{s(e.target.value),d(0),l(!0)},onFocus:()=>l(!0),onKeyDown:C,onBlur:w,disabled:v}),(0,K.jsxs)(H,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,K.jsx)(Uo,{}),` `,i]})]}),T&&(0,K.jsx)(`ul`,{id:m,role:`listbox`,className:`bg-popover text-popover-foreground absolute top-11 z-10 max-h-56 w-full overflow-auto rounded-md border p-1 shadow-md`,children:y.map((e,t)=>{let n=t===b;return(0,K.jsx)(`li`,{id:`${h}-${t}`,role:`option`,"aria-selected":n,onMouseEnter:()=>d(t),onMouseDown:t=>{t.preventDefault(),g.current=!0,x(e.value).finally(()=>{g.current=!1})},className:F(`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm`,n&&`bg-accent text-accent-foreground`),children:e.custom?(0,K.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,K.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,K.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var cM=`enc:v1:`;function lM(e){let t=e.replace(/-----BEGIN [^-]+-----/,``).replace(/-----END [^-]+-----/,``).replace(/\s+/g,``),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function uM(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function dM(e){return uM(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function fM(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function pM(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function mM(e,t,n){let r=pM(),i=lM(t),a=await r.importKey(`spki`,fM(i),{name:`RSA-OAEP`,hash:`SHA-256`},!1,[`encrypt`]),o=crypto.getRandomValues(new Uint8Array(32)),s=crypto.getRandomValues(new Uint8Array(12)),c=await r.importKey(`raw`,fM(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:fM(s),tagLength:128},c,fM(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:uM(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,fM(o)))),iv:uM(s),ct:uM(u),tag:uM(d)};return cM+dM(new TextEncoder().encode(JSON.stringify(f)))}var hM=class extends Error{constructor(e){super(e),this.name=`SecretsOperationError`}};function gM(e){if(or(e))return e;let t=e?.response?.data,n=typeof t?.error==`string`?t.error:t?.message;return typeof n==`string`?new hM(n):e}var _M=`does not match`;function vM(e){return e.includes(_M)}async function yM({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var bM=P;async function xM(e){let{data:t}=await bM.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function SM(e){return B({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?xM(e.managedClusterId):yM(e),staleTime:3e5,retry:!1})}async function CM({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function wM(e){return B({queryKey:[e.entityId,`list_secrets`],queryFn:()=>CM(e)})}async function TM(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(SM(t)),a=await mM(t.value,r,i);try{let{data:e}=await t.instanceClient.post(`/`,{operation:`set_secret`,name:t.name,envelope:a,...t.processEnv===void 0?{}:{processEnv:t.processEnv},...t.grants===void 0?{}:{grants:t.grants}});return e}catch(r){let i=gM(r);if(!n&&i instanceof hM&&vM(i.message))return e.removeQueries({queryKey:SM(t).queryKey}),TM(e,t,!0);throw i}}function EM(){let e=Ze();return I({mutationFn:t=>TM(e,t,!1)})}async function DM({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw gM(e)}}function OM(){return I({mutationFn:DM})}async function kM(e,{instanceClient:t,name:n,component:r}){try{let{data:i}=await t.post(`/`,{operation:e,name:n,component:r});return i}catch(e){throw gM(e)}}function AM(){return I({mutationFn:e=>kM(`grant_secret`,e)})}function jM(){return I({mutationFn:e=>kM(`revoke_secret`,e)})}function MM({name:e,initialGrants:t,components:n,onChanged:r}){let i=q(),{mutateAsync:a,isPending:o}=AM(),{mutateAsync:s,isPending:c}=jM(),l=o||c,[u,d]=(0,G.useState)(t),f=(0,G.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw pc(e)&&U.error(fc(e).message),e}},[a,i,e,r]),p=(0,G.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){pc(e)&&U.error(fc(e).message)}},[s,i,e,r]);return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,K.jsxs)(ol,{variant:`secondary`,children:[e,(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,K.jsx)(Ks,{}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,K.jsx)(sM,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var NM=`********`,PM=/^[\w.-]+$/,FM=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function IM(e){return e.split(`/`).pop()??``}function LM(e){if(!e)return!1;let t=IM(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var RM=[`.example`,`.sample`,`.template`];function zM(e){if(!LM(e))return!1;let t=IM(e).toLowerCase();return RM.some(e=>t.endsWith(e))}function BM(e){return LM(e)&&!zM(e)}function VM(e){let t={};if(!e)return t;let n=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm,r=e.replace(/\r\n?/g,`
|
|
679
|
+
`),i;for(;(i=n.exec(r))!==null;){let e=i[1],n=(i[2]??``).trim(),r=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),r===`"`&&(n=n.replace(/\\n/g,`
|
|
680
|
+
`).replace(/\\r/g,`\r`)),t[e]=n}return t}function HM(e){return!e||e.length===0?``:e.map(e=>`${e}=${NM}`).join(`
|
|
681
|
+
`)+`
|
|
682
|
+
`}function UM(e){if(e===``)return``;if(!/[\s#'"`]/.test(e))return e;if(!e.includes(`'`))return`'${e}'`;if(!e.includes(`"`)&&!e.includes(`\\`)&&!e.includes(`\r`))return`"${e.replace(/\n/g,`\\n`)}"`;throw Error(`Environment value contains an unsupported combination of quote characters`)}function WM(e,t){let n=t!==`'`&&t!=="`";for(let r=0;r<e.length;r++){if(n&&e[r]===`\\`){r++;continue}if(e[r]===t)return!0}return!1}function GM(e,t,n){let r=n.replace(/^\s+/,``),i=r[0];if(i!==`"`&&i!==`'`&&i!=="`"||WM(r.slice(1),i))return t;for(let n=t+1;n<e.length;n++)if(WM(e[n],i))return n;return e.length-1}function KM(e){let t=e.includes(`\r
|
|
683
|
+
`)?`\r
|
|
684
|
+
`:`
|
|
685
|
+
`,n=/\r?\n$/.test(e),r=e.length?e.split(/\r?\n/):[];return n&&r.pop(),{eol:t,endedWithNewline:n,lines:r}}function qM(e,t){let n=new Map(Object.entries(t)),r=new Set,{eol:i,endedWithNewline:a,lines:o}=KM(e),s=[];for(let e=0;e<o.length;e++){let t=FM.exec(o[e]);if(t){let[,i,a]=t,c=GM(o,e,t[3]);if(n.has(a))r.has(a)||(s.push(`${i}${a}=${UM(n.get(a))}`),r.add(a));else for(let t=e;t<=c;t++)s.push(o[t]);e=c;continue}s.push(o[e])}let c=!1;for(let[e,t]of n)r.has(e)||(s.push(`${e}=${UM(t)}`),c=!0);let l=s.join(i);return l.length>0&&(a||c)&&(l+=i),l}function JM(e,t){let n=new Set(Array.isArray(t)?t:[t]);if(n.size===0||!e)return e;let{eol:r,endedWithNewline:i,lines:a}=KM(e),o=[];for(let e=0;e<a.length;e++){let t=FM.exec(a[e]);if(t){let r=GM(a,e,t[3]);if(!n.has(t[2]))for(let t=e;t<=r;t++)o.push(a[t]);e=r;continue}o.push(a[e])}let s=o.join(r);return s.length>0&&i&&(s+=r),s}function YM({grants:e,onChange:t,components:n,disabled:r}){let i=(0,G.useCallback)(n=>{e.includes(n)||t([...e,n])},[e,t]),a=(0,G.useCallback)(n=>{t(e.filter(e=>e!==n))},[e,t]);return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Only these applications will be able to read the secret. You can grant more later — leave it empty to add grants after creating the secret.`}),e.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>(0,K.jsxs)(ol,{variant:`secondary`,children:[e,(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e),disabled:r,title:`Remove ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,K.jsx)(Ks,{}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Remove `,e]})]})]},e))}),(0,K.jsx)(sM,{components:n,granted:e,onAdd:i,disabled:r,actionLabel:`Add`,commitOnBlur:!0})]})}function XM(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function ZM(e){return`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`}function QM(e,t){let n=e.trim()||`MY_SECRET`,r=XM(n);return t===`processEnv`?[`// Exposed on process.env for every component (and child processes).`,`const value = ${r?`process.env.${n}`:`process.env[${ZM(n)}]`};`].join(`
|
|
686
|
+
`):[`import { secrets } from 'harper';`,``,`// Use the current value right away — read at your module's top level.`,`let value = ${r?`secrets.${n}`:`secrets[${ZM(n)}]`};`,``,`// Then react to rotations without blocking startup. Subscribing in a background`,`// task lets module load finish, so the rest of your app keeps initializing.`,`(async () => {`,` try {`,` for await (const next of secrets.subscribe(${ZM(n)})) {`,` if (next === value) continue; // the first yield is the current value you already have`,` value = next; // rotated — rebuild anything bound to the secret (e.g. an API client) here`,` }`,` } catch (error) {`,` // Log and keep serving the last value; it stays valid until the next reload.`,` console.error('secret subscription ended for', ${ZM(n)}, error);`,` }`,`})();`].join(`
|
|
687
|
+
`)}function $M({name:e,tier:t}){let n=QM(e,t),[r,i]=(0,G.useState)(!1),a=(0,G.useRef)(void 0);(0,G.useEffect)(()=>()=>clearTimeout(a.current),[]);let o=(0,G.useCallback)(()=>{Ug(n).then(e=>{e&&(i(!0),clearTimeout(a.current),a.current=setTimeout(()=>i(!1),1200))})},[n]);return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`pre`,{className:`overflow-x-auto rounded-md border border-border bg-muted/50 p-3 pr-10 text-xs leading-relaxed`,children:(0,K.jsx)(`code`,{className:`font-mono text-foreground`,children:n})}),(0,K.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`absolute top-1.5 right-1.5 px-1`,onClick:o,title:`Copy example`,children:[r?(0,K.jsx)(tr,{className:`text-green-500`}):(0,K.jsx)(ea,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Copy example`})]})]})}var eN=`https://docs.harperdb.io/reference/v5/security/secrets`;function tN({name:e,tier:t,onTierChange:n,disabled:r,grantsSlot:i}){return(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`How should applications read this secret?`}),(0,K.jsxs)(mj,{value:t,onValueChange:e=>n(e),disabled:r,children:[(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(hj,{value:`scoped`,className:`mt-0.5`}),(0,K.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Scoped to specific apps`}),(0,K.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Exposed only to the applications you grant, through the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Never placed on `,(0,K.jsx)(`code`,{className:`font-mono`,children:`process.env`}),`.`]})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(hj,{value:`processEnv`,className:`mt-0.5`}),(0,K.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Environment variable`}),(0,K.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Materialized onto `,(0,K.jsx)(`code`,{className:`font-mono`,children:`process.env`}),` `,`for every component (and child processes). Global — it can't be scoped to specific apps.`]})]})]})]}),t===`scoped`&&i,(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`How to read it in your component`}),(0,K.jsx)($M,{name:e,tier:t}),(0,K.jsx)(`a`,{className:`inline-block underline text-sm text-muted-foreground hover:text-foreground`,href:eN,target:`_blank`,rel:`noreferrer`,children:`Learn more about secrets in the Harper docs`})]})]})}var nN=x().trim().min(1,{error:`Enter a key.`}).regex(PM,{error:`Letters, numbers, underscore, dash and dot only.`}),rN=x().min(1,{error:`Enter a value.`});function iN({description:e,valueDescription:t,existingKeys:n,onSubmit:r,isModalOpen:i,setIsModalOpen:a,delivery:o=!1,defaultTier:s=`scoped`,grantableComponents:c=[]}){let l=(0,G.useMemo)(()=>b({key:nN.refine(e=>!n?.includes(e),{error:`This key already exists — edit it instead.`}),value:rN}),[n]),u=on({resolver:mt(l),mode:`onTouched`,defaultValues:{key:``,value:``}}),{isDirty:d,isValid:f,isSubmitting:p}=u.formState,[m,h]=(0,G.useState)(s),[g,_]=(0,G.useState)([]),v=u.watch(`key`),y=(0,G.useCallback)(()=>{h(s),_([])},[s]),x=(0,G.useCallback)(async e=>{let t=o?{processEnv:m===`processEnv`,grants:m===`scoped`?g:void 0}:{};try{await r({...e,...t}),u.reset(),y(),U.success(`Secret "${e.key}" saved.`),a(!1)}catch(e){pc(e)&&U.error(fc(e).message)}},[r,u,a,o,m,g,y]),S=(0,G.useCallback)(()=>{u.reset(),y(),a(!1)},[u,a,y]);return(0,K.jsx)(_m,{onOpenChange:a,open:i,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...u,children:(0,K.jsxs)(`form`,{id:`add-secret-form`,name:`add-secret-form`,onSubmit:u.handleSubmit(x),onKeyDown:rx(u),className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add Secret`}),(0,K.jsx)(Om,{children:e})]}),(0,K.jsx)(Y,{control:u.control,name:`key`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Key`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:u.control,name:`value`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Value`}),t&&(0,K.jsx)(ky,{children:t}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,rows:3,...e})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsx)(tN,{name:v,tier:m,onTierChange:h,disabled:p,grantsSlot:(0,K.jsx)(YM,{grants:g,onChange:_,components:c,disabled:p})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:S,disabled:p,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:p||!d||!f,children:[(0,K.jsx)($o,{}),` Add Secret`]})]})})]})})})})}var aN=b({value:rN});function oN({name:e,description:t,valueDescription:n,currentValue:r,onSave:i,onDelete:a,closeModal:o,children:s,delivery:c=!1,currentTier:l=`scoped`}){let u=on({resolver:mt(aN),mode:`onTouched`,defaultValues:{value:``}}),{isDirty:d,isValid:f,isSubmitting:p}=u.formState,[m,h]=(0,G.useState)(!1),g=p||m,[_,v]=(0,G.useState)(l),y=c&&_!==l,[b,x]=(0,G.useState)(!1),S=(0,G.useCallback)(()=>{u.setValue(`value`,r??``,{shouldDirty:!1}),x(!0)},[u,r]),C=(0,G.useCallback)(async t=>{try{await i(t.value,c?{processEnv:_===`processEnv`}:void 0),U.success(`Secret "${e}" updated.`),o()}catch(e){pc(e)&&U.error(fc(e).message)}},[i,e,o,c,_]),[w,T]=(0,G.useState)(!1),E=(0,G.useCallback)(async()=>{if(!w){T(!0);return}h(!0);try{await a?.(),U.success(`Secret "${e}" deleted.`),o()}catch(e){pc(e)&&U.error(fc(e).message)}finally{h(!1)}},[w,a,e,o]);return(0,K.jsx)(_m,{onOpenChange:o,open:!0,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...u,children:(0,K.jsxs)(`form`,{onSubmit:u.handleSubmit(C),className:`grid gap-4 my-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:e}),(0,K.jsx)(Om,{children:t})]}),(0,K.jsx)(Y,{control:u.control,name:`value`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:r===void 0?`New value`:`Value`}),n&&(0,K.jsx)(ky,{children:n}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,rows:3,placeholder:r!==void 0&&!b?NM:void 0,...e})}),r!==void 0&&!b&&(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:S,children:[(0,K.jsx)(ga,{}),` Reveal current value`]}),(0,K.jsx)(Q,{})]})}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tN,{name:e,tier:_,onTierChange:v,disabled:g,grantsSlot:y?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Save this as a scoped secret first, then you can grant applications.`}):s}),y&&!d&&(0,K.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-500`,children:`Re-enter the value above to save this change — a stored secret can’t be read back to re-encrypt automatically.`})]}):s,(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[a?(0,K.jsxs)(H,{variant:`destructiveOutline`,type:`button`,onClick:E,disabled:g,children:[(0,K.jsx)(Is,{}),` `,w?`Confirm delete`:`Delete`]}):(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:o,disabled:g,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:g||!d||!f,children:[(0,K.jsx)($o,{}),` Save`]})]})})]})})})})}function sN({rows:e,isFetching:t,onRefresh:n,canManage:r=!0,selectedName:i,onSelectName:a,nameHeader:o=`Key`,addDescription:s,editDescription:c,valueDescription:l,onSet:u,onDelete:d,renderEditExtras:f,docsLink:p,children:m,delivery:h=!1,deliveryDefaultTier:g=`scoped`,grantableComponents:_}){let v=(0,G.useMemo)(()=>[{header:o,accessorKey:`name`,enableSorting:!1},{id:`value`,header:`Value`,enableSorting:!1,cell:({row:e})=>(0,K.jsx)(cN,{value:e.original.value,warning:e.original.warning})}],[o]),y=(0,G.useCallback)(e=>a(e?.original?.name),[a]),[b,x]=(0,G.useState)(!1),S=(0,G.useMemo)(()=>e.map(e=>e.name),[e]),C=(0,G.useMemo)(()=>e.find(e=>e.name===i),[e,i]),w=Kb(n??(()=>Promise.resolve()));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Hb,{columns:v,data:e,isFetching:t,onRowClick:r?y:void 0,children:[p,n&&(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:w,accessKey:`r`,disabled:t,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:()=>x(!0),accessKey:`a`,disabled:b,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]}),m]}),b&&(0,K.jsx)(iN,{isModalOpen:b,setIsModalOpen:x,description:s,valueDescription:l,existingKeys:S,delivery:h,defaultTier:g,grantableComponents:_,onSubmit:({key:e,value:t,...n})=>u(e,t,n)}),i&&C&&(0,K.jsx)(oN,{name:C.name,description:c,valueDescription:l,currentValue:C.value,delivery:h,currentTier:C.processEnv?`processEnv`:`scoped`,onSave:(e,t)=>u(C.name,e,t),onDelete:d&&(()=>d(C.name)),closeModal:()=>a(void 0),children:f?.(C.name)},C.name)]})}function cN({value:e,warning:t}){let[n,r]=(0,G.useState)(!1),i=t&&(0,K.jsx)(Rs,{className:`inline-block size-4 text-amber-500 shrink-0`,"aria-label":t,children:(0,K.jsx)(`title`,{children:t})});return e===void 0?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 max-w-full`,title:t,children:[NM,i]}):(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 max-w-full`,children:[(0,K.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`px-1`,onClick:e=>{e.stopPropagation(),r(e=>!e)},title:n?`Hide value`:`Reveal value`,children:[n?(0,K.jsx)(ma,{}):(0,K.jsx)(ga,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:n?`Hide value`:`Reveal value`})]}),(0,K.jsx)(`span`,{className:n?`font-mono`:void 0,children:n?e:NM}),i]})}function lN(){let e=De(),{secretName:t,clusterId:n}=z({strict:!1}),r=q(),{data:i,refetch:a,isFetching:o}=L(wM(r)),s=Cg(),{data:c}=L(LO({...r,enabled:s})),l=(0,G.useMemo)(()=>oM(c),[c]),u=L(_f(n,!1)),d=u.data,f=d===void 0||ff(d)?void 0:n,p=(0,G.useMemo)(()=>({...r,managedClusterId:f}),[r,f]),m=!n||u.isSuccess,h=L({...SM(p),enabled:m}),g=!!n&&u.isError,_=i?.secrets,v=(0,G.useMemo)(()=>(_??[]).map(e=>({name:e.name,processEnv:e.processEnv,warning:uN(e,i)})),[_,i]),y=(0,G.useMemo)(()=>_?.find(e=>e.name===t)?.name,[_,t]),b=(0,G.useCallback)(n=>{let r=[t?`..`:``,n].filter(Boolean);e({to:r.join(`/`)})},[e,t]),{mutateAsync:x,reset:S}=EM(),{mutateAsync:C}=OM(),w=(0,G.useCallback)(async(e,t,n)=>{try{await x({...p,name:e,value:t,processEnv:n?.processEnv,grants:n?.grants})}finally{S()}await a()},[x,S,p,a]),T=(0,G.useCallback)(async e=>{await C({...r,name:e}),await a()},[C,r,a]);return(0,K.jsxs)(K.Fragment,{children:[g?(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3 mb-4`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:`Secrets are read-only right now: this cluster's info couldn't be loaded, so its secret custody is unknown. Refresh once cluster info is available.`})]}):h.isError&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3 mb-4`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:`Secrets are read-only right now: this cluster has no secrets key, so values can't be encrypted. Key custody is provided by the Harper secret-custody component — once it's active, refresh this page.`})]}),(0,K.jsx)(sN,{rows:v,isFetching:o,onRefresh:a,canManage:h.isSuccess,selectedName:y,onSelectName:b,nameHeader:`Secret`,delivery:!0,docsLink:(0,K.jsx)(`a`,{className:`inline-block underline text-sm text-muted-foreground hover:text-foreground`,href:`https://docs.harperdb.io/reference/v5/security/secrets`,target:`_blank`,rel:`noreferrer`,children:`Secrets Docs`}),grantableComponents:l,addDescription:`The value is encrypted in your browser against the cluster's secrets key — plaintext never reaches the API, the operation log, or disk. It can be replaced or deleted, but never read back.`,editDescription:`The current value can't be shown — it's stored encrypted. Enter a new value to replace it, adjust how applications read it, or delete the secret.`,valueDescription:`Encrypted client-side before it leaves this page.`,onSet:w,onDelete:T,renderEditExtras:e=>{let t=_?.find(t=>t.name===e);return t&&(0,K.jsx)(MM,{name:t.name,initialGrants:t.grants,components:l,onChanged:()=>void a()},t.name)}})]})}function uN(e,t){if(t?.custody_fingerprint){if(!e.kid_matches_custody)return`Encrypted under a different key than the cluster's current secrets key — it may fail to decrypt at load time. Set a new value to re-encrypt.`;if(e.unverified)return`Stored without key-identity verification.`}}async function dN({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_ssh_keys`});return t}function fN(e){return B({queryKey:[e.entityId,`list_ssh_keys`],queryFn:()=>dN(e)})}var pN=[{header:`SSH Key Name`,accessorKey:`name`,enableSorting:!1},{header:`Host`,accessorKey:`host`,enableSorting:!1,cell:({getValue:e})=>e()||`—`},{header:`Hostname`,accessorKey:`hostname`,enableSorting:!1,cell:({getValue:e})=>e()||`—`}];async function mN({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_ssh_known_hosts`});return t}function hN(e){return B({queryKey:[e.entityId,`get_ssh_known_hosts`],queryFn:()=>mN(e)})}var gN=b({known_hosts:x().trim().nonempty({error:`Please enter at least one known host.`})});async function _N(e){let{instanceClient:t,entityType:n,...r}=e,{data:i}=await t.post(`/`,{operation:`set_ssh_known_hosts`,replicated:n===`cluster`,...r});return i}function vN(){return I({mutationFn:_N})}function yN(){let e=q(),{data:t}=we(hN(e)),n=on({resolver:mt(gN),mode:`onTouched`,defaultValues:{known_hosts:t?.known_hosts||``}}),{isDirty:r,isValid:i}=n.formState,{mutate:a,isPending:o}=vN(),s=(0,G.useCallback)(async t=>{a({known_hosts:t.known_hosts.trim()+`
|
|
688
|
+
`,...e},{onSuccess:()=>{n.reset(t),U.success(`Known hosts saved!`)}})},[a,n,e]);return(0,K.jsx)(Od,{...n,children:(0,K.jsx)(`form`,{id:`instance-edit-known-hosts-form`,name:`instance-edit-known-hosts-form`,onSubmit:n.handleSubmit(s),className:`grid my-4 md:grid-cols-2 overflow-x-auto rounded-md`,children:(0,K.jsx)(Y,{control:n.control,name:`known_hosts`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2 gap-0`,children:[(0,K.jsx)(Z,{className:`bg-muted dark:bg-black-dark py-3 px-2 m-0 text-left font-medium whitespace-nowrap`,children:`Known Hosts`}),(0,K.jsxs)(`div`,{className:`border border-grey-700 p-2 pb-3`,children:[(0,K.jsx)(ky,{className:`pb-2`,children:`Manage your known hosts here. When you add a SSH Key with a hostname of "github.com", we'll automatically attempt to resolve GitHub's known hosts for you.`}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,className:`whitespace-nowrap`,rows:10,...e})}),(0,K.jsx)(Q,{}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,className:`mt-2`,disabled:o||!r||!i,children:[(0,K.jsx)($o,{}),` `,o?`Saving`:`Save`,` Known Hosts`,o?`...`:``]})]})]})})})})}var bN=`enc:v1:`,xN=/^-----BEGIN ([A-Z0-9 ]+)-----$/,SN=new Set([`OPENSSH PRIVATE KEY`,`RSA PRIVATE KEY`,`DSA PRIVATE KEY`,`EC PRIVATE KEY`,`PRIVATE KEY`,`ENCRYPTED PRIVATE KEY`]),CN=new Set([`PUBLIC KEY`,`RSA PUBLIC KEY`]),wN=`---- BEGIN SSH2 PUBLIC KEY ----`,TN=/(?:^|\s)((?:ssh-(?:rsa|dss|ed25519)|ecdsa-sha2-nistp(?:256|384|521)|sk-(?:ssh-ed25519|ecdsa-sha2-nistp256)@openssh\.com)(?:-cert-v01@openssh\.com)?)\s+AAAA/m,EN=/^Proc-Type:\s*4,\s*ENCRYPTED$/i,DN=/^[A-Za-z0-9+/]+={0,2}$/,ON=`openssh-key-v1\0`,kN=`\x07*HÎ8`,AN=` — for example, a new deploy key from ssh-keygen -t ed25519 -N "".`,jN=`This key is protected by a passphrase, which Harper can't enter when it runs git. Use a key without one${AN}`,MN=`This is a DSA key, which current ssh no longer accepts. Use an Ed25519 key${AN}`,NN=`This key only works with its hardware security key attached, and the server Harper runs git on has none. Use a regular key${AN}`,PN=`This key is damaged and can't be read. Copy it again from the original file.`;function FN(e){return e.split(`
|
|
689
|
+
`).map(e=>e.trim()).filter(Boolean).join(`
|
|
690
|
+
`)}function IN(e){let t=FN(e);if(!t||t.startsWith(bN))return;let n=t.split(`
|
|
691
|
+
`),r=n.map(e=>xN.exec(e)?.[1]),i=r.findIndex(e=>e!==void 0&&SN.has(e));if(i===-1)return LN(t,n,r);let a=r[i];if(i>0&&a===`OPENSSH PRIVATE KEY`)return`Paste only the private key — remove the text before "${n[i]}".`;let o=`-----END ${a}-----`,s=n.indexOf(o,i+1);return s===-1?`This key is incomplete: its "${o}" line is missing. Copy the whole file.`:RN(a,n.slice(i+1,s))}function LN(e,t,n){if(e.startsWith(`PuTTY-User-Key-File-`))return`This is a PuTTY key (.ppk), which ssh can't read. In PuTTYgen, choose Conversions → Export OpenSSH key, and paste that file instead.`;if(t.includes(wN)||n.some(e=>e!==void 0&&CN.has(e)))return`This is a public key. Paste the private key — the file without the .pub extension.`;let r=n.find(e=>e!==void 0);if(r)return`Expected an SSH private key, but found "-----BEGIN ${r}-----".`;let i=TN.exec(e)?.[1];return i?`This looks like a public key ("${i} …"). Paste the private key — the file without the .pub extension.`:`This doesn't look like a private key. Paste the whole key file, including its "-----BEGIN" and "-----END" lines.`}function RN(e,t){if(e===`DSA PRIVATE KEY`)return MN;if(e===`ENCRYPTED PRIVATE KEY`||t.some(e=>EN.test(e)))return jN;let n=t.join(``).replace(/[ \t]+/g,``),r=DN.test(n)?BN(n):void 0;if(r===void 0)return PN;if(e!==`OPENSSH PRIVATE KEY`)return VN(r)===r.length?e===`PRIVATE KEY`&&r.slice(0,32).includes(kN)?MN:void 0:PN;let i=HN(r);return i?i.keyType===`ssh-dss`?MN:i.keyType.startsWith(`sk-`)?NN:i.cipherName===`none`?zN(i.privateSection,i.trailingBytes)?void 0:PN:jN:PN}function zN(e,t){if(!e||t!==0||e.length%8!=0)return!1;let n=UN(e,0),r=n.uint32();return r!==void 0&&r===n.uint32()}function BN(e){try{return atob(e)}catch{return}}function VN(e){if(e.length<2||e.charCodeAt(0)!==48)return;let t=e.charCodeAt(1);if(t<128)return 2+t;let n=t&127;if(n===0||n>3||e.length<2+n)return;let r=0;for(let t=0;t<n;t++)r=r*256+e.charCodeAt(2+t);return 2+n+r}function HN(e){if(!e.startsWith(ON))return;let t=UN(e,15),n=t.string(),r=t.string(),i=t.string(),a=t.uint32(),o=t.string();if(n===void 0||r===void 0||i===void 0||a!==1||!o)return;let s=UN(o,0).string();if(s!==void 0)return{cipherName:n,keyType:s,privateSection:t.string(),trailingBytes:t.remaining()}}function UN(e,t){let n=t,r=()=>{if(e.length<n+4)return;let t=(e.charCodeAt(n)<<24|e.charCodeAt(n+1)<<16|e.charCodeAt(n+2)<<8|e.charCodeAt(n+3))>>>0;return n+=4,t};return{uint32:r,string:()=>{let t=r();if(!(t===void 0||e.length<n+t))return n+=t,e.slice(n-t,n)},remaining:()=>e.length-n}}var WN=x().overwrite(FN).min(1,{error:`Key is required.`}).superRefine((e,t)=>{let n=IN(e);n&&t.addIssue({code:`custom`,message:n})}),GN=new Set([`github.com`,`ssh.github.com`,`gitlab.com`,`altssh.gitlab.com`,`bitbucket.org`]),KN=`Use a unique alias like "my-repo.github.com" instead of a bare registry hostname.`,qN=/^(?!-)[A-Za-z0-9._-]+$/,JN=S(),YN=b({name:x().trim().min(1,{error:`Name is required.`}).regex(/^[a-zA-Z0-9-_]*$/,{error:`Can only contain letters, numbers, dashes and underscores.`}),key:WN,host:x().trim().min(1,{error:`Host is required.`}).regex(qN,{error:`Can only contain letters, numbers, dots, dashes and underscores, and not start with a dash, like "my-repo.github.com".`}),hostname:x().trim().min(1,{error:`Hostname is required.`}).refine(e=>qN.test(e)||JN.safeParse(e).success,{error:`Enter just the hostname, like "github.com" — no "git@", scheme, port or path.`}),known_hosts:x().trim().optional()}).refine(e=>!GN.has(e.host.trim().toLowerCase()),{path:[`host`],error:KN}).refine(e=>e.host.trim().toLowerCase()!==e.hostname.trim().toLowerCase(),{path:[`host`],error:`Host alias must differ from the hostname. ${KN}`});function XN(e){return(t,n)=>{e.some(e=>e.name===t.name)&&n.addIssue({code:`custom`,path:[`name`],message:`A key with this name already exists. Pick another name, or edit that key to replace it.`});let r=t.host.toLowerCase(),i=e.find(e=>e.host?.toLowerCase()===r);i&&n.addIssue({code:`custom`,path:[`host`],message:`The key "${i.name}" already uses the alias "${i.host}". Each key needs its own.`})}}async function ZN(e){let{instanceClient:t,entityType:n,entityId:r,...i}=e,{data:a}=await t.post(`/`,{operation:`add_ssh_key`,replicated:n===`cluster`,...i});return a}function QN(){return I({mutationFn:ZN})}var $N=[];function eP({existingKeys:e,isModalOpen:t,onChangesSaved:n,setIsModalOpen:r}){let i=(0,G.useMemo)(()=>mt(YN.superRefine(XN(e??$N))),[e]),a=on({resolver:i,mode:`onChange`,defaultValues:{name:``,key:``,host:``,hostname:``,known_hosts:``}}),o=q(),{mutate:s,isPending:c}=QN(),l=(0,G.useCallback)(async e=>{if(e){let{name:t,key:i,host:c,hostname:l,known_hosts:u}=e;s({name:t,key:i.trim()+`
|
|
692
|
+
`,host:c,hostname:l,known_hosts:u?u+`
|
|
693
|
+
`:void 0,...o},{onSuccess:()=>{a.reset(),n(),U.success(`SSH Key added successfully!`),r(!1)}})}},[s,a,o,n,r]),u=(0,G.useCallback)(()=>{a.reset(),r(!1)},[a,r]);return(0,K.jsx)(_m,{onOpenChange:r,open:t,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...a,children:(0,K.jsxs)(`form`,{id:`instance-add-ssh-key-form`,name:`instance-add-ssh-key-form`,onSubmit:a.handleSubmit(l),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,K.jsxs)(Tm,{className:`md:col-span-2`,children:[(0,K.jsx)(Dm,{children:`Add New SSH Key`}),(0,K.jsx)(Om,{children:`Enter the details of your SSH Key below.`})]}),e===void 0&&(0,K.jsxs)(c_,{variant:`warning`,className:`md:col-span-2`,children:[(0,K.jsx)(Rs,{className:`h-4 w-4`}),(0,K.jsx)(u_,{children:`Studio couldn't load this instance's SSH keys, so it can't warn you about a name or host alias another key already uses. Refresh the list to check them.`})]}),(0,K.jsx)(Y,{control:a.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:a.control,name:`key`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Key`}),(0,K.jsx)(ky,{children:`Your private key: the file without the .pub extension, with no passphrase. Don't have one? Try out "ssh-keygen"! You'll want to add your public key (the .pub file) to your registry, i.e. GitHub.`}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,rows:3,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:a.control,name:`host`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Host`}),(0,K.jsx)(ky,{children:`A unique identifying name for the combination of this key and your hostname, i.e. "your-repo.github.com". You will use this instead of the direct hostname to pick your key when importing applications.`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:a.control,name:`hostname`,rules:{deps:[`host`]},render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Hostname`}),(0,K.jsx)(ky,{children:`When making the request, the actual hostname to use, i.e. "github.com".`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:a.control,name:`known_hosts`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Known Hosts`}),(0,K.jsx)(ky,{children:`Optionally, append known hosts, one per line. GitHub known hosts should resolve automatically.`}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,className:`whitespace-nowrap`,rows:3,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{className:`md:col-span-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:u,disabled:c,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:c||!a.formState.isDirty||!a.formState.isValid,children:[(0,K.jsx)($o,{}),` Add SSH Key`]})]})})]})})})})}async function tP(e){let{instanceClient:t,entityType:n,name:r}=e,{data:i}=await t.post(`/`,{operation:`delete_ssh_key`,replicated:n===`cluster`,name:r});return i}function nP(){return I({mutationFn:tP})}async function rP({name:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`get_ssh_key`,name:e});return n}function iP(e){return B({queryKey:[e.entityId,`get_ssh_key`,e.name],queryFn:()=>rP(e),refetchInterval:Gc(1e4),retry:Kc()})}var aP=b({name:x().trim(),key:WN});async function oP(e){let{instanceClient:t,entityType:n,name:r,key:i}=e,{data:a}=await t.post(`/`,{operation:`update_ssh_key`,replicated:n===`cluster`,name:r,key:i});return a}function sP(){return I({mutationFn:oP})}function cP({data:e,isModalOpen:t,closeModal:n,onSelectSSHKey:r,onChangesSaved:i}){let{name:a}=e,o=on({resolver:mt(aP),mode:`onChange`,defaultValues:{name:a,key:``}}),s=q(),{data:c}=L(iP({...s,name:a})),{mutate:l,isPending:u}=sP(),{mutate:d,isPending:f}=nP(),[p,m]=(0,G.useState)(!1),h=(0,G.useCallback)(async({key:e})=>{e&&l({name:a,key:e.trim()+`
|
|
694
|
+
`,...s},{onSuccess:()=>{U.success(`SSH Key updated successfully!`),r(void 0),i()}})},[l,a,s,r,i]),g=(0,G.useCallback)(()=>{m(!0)},[]),_=(0,G.useCallback)(()=>{d({name:a,...s},{onSuccess:()=>{U.success(`SSH Key deleted successfully!`),r(void 0),i()}})},[a,d,s,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_m,{onOpenChange:n,open:t,children:(0,K.jsx)(wm,{className:`sm:max-w-[750px]`,"aria-describedby":void 0,children:(0,K.jsx)(Od,{...o,children:(0,K.jsxs)(`form`,{id:`instance-edit-ssh-key-form`,name:`instance-edit-ssh-key-form`,onSubmit:o.handleSubmit(h),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,K.jsx)(Dm,{children:`Edit SSH Key`}),(0,K.jsx)(Y,{control:o.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,readOnly:!0,disabled:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:o.control,name:`key`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Key`}),(0,K.jsx)(ky,{children:`Replace your existing private key: the file without the .pub extension, with no passphrase. Lost it? Try out "ssh-keygen"! You'll want to add your public key (the .pub file) to your registry, i.e. GitHub.`}),(0,K.jsx)(J,{children:(0,K.jsx)(NE,{autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,autoFocus:!0,rows:3,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Host`}),(0,K.jsx)(ky,{children:`A unique identifying name for the combination of this key and your hostname, i.e. "your-repo.github.com". You will use this instead of the direct hostname to pick your key when importing applications.`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,value:c?.host||``,disabled:!0,readOnly:!0})}),(0,K.jsx)(Q,{})]}),(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Hostname`}),(0,K.jsx)(ky,{children:`When making the request, the actual hostname to use, i.e. "github.com".`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,value:c?.hostname||``,disabled:!0,readOnly:!0})}),(0,K.jsx)(Q,{})]}),(0,K.jsxs)(Em,{className:`md:col-span-2`,children:[(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:g,disabled:u,children:`Delete SSH Key`}),(0,K.jsx)(H,{type:`submit`,variant:`submit`,disabled:u||!o.formState.isValid,children:`Update SSH Key`})]})]})})})}),(0,K.jsx)(km,{isModalOpen:p,setIsModalOpen:m,deletionConfirmed:_,deletionPending:f,typeOfThingBeingDeleted:`SSH key`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function lP(){let e=De(),{keyName:t}=z({strict:!1}),n=q(),{data:r,refetch:i,isFetching:a,isLoading:o,isRefetching:s}=L(fN(n)),c=(0,G.useMemo)(()=>r?.find(e=>e.name===t),[r,t]),l=(0,G.useCallback)(n=>{let r=n?.original?.name,i=[t?`..`:``,r].filter(Boolean);e({to:i.join(`/`)})},[t,e]),u=!!t&&!!c,[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(()=>{f(!0)},[f]),m=Kb(i);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Hb,{columns:pN,data:r||[],isFetching:a,onRowClick:l,children:[(0,K.jsx)(V,{className:`inline-block underline text-sm text-muted-foreground hover:text-foreground`,to:`https://docs.harperdb.io/docs/developers/security/certificate-management`,target:`_blank`,children:`Certificate Management Docs`}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:m,accessKey:`r`,disabled:a||s,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:p,accessKey:`a`,disabled:d||o,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),d&&(0,K.jsx)(eP,{existingKeys:r,isModalOpen:d,onChangesSaved:i,setIsModalOpen:f}),u&&(0,K.jsx)(cP,{isModalOpen:u,closeModal:l,data:c,onSelectSSHKey:l,onChangesSaved:i}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Lc,{text:`Loading...`}),children:(0,K.jsx)(yN,{})})]})}var uP=`https://docs.harperdb.io/reference/v5/operations-api/operations#add_oidc_trust`;function dP(){let e=q(),t=Cg(),{data:n,isError:r}=L(HE(e)),i=n===void 0?void 0:bk(n.version),{data:a,isFetching:o,isError:s,refetch:c}=L(Ck({...e,enabled:t&&i===!0})),l=Kb(c),{mutateAsync:u,isPending:d}=Ak(),{mutateAsync:f,isPending:p}=Mk(),[m,h]=(0,G.useState)(),g=d||p||o;if(!t)return(0,K.jsx)(fP,{children:`Only super users can view or change trust policies.`});if(i===void 0)return r?(0,K.jsx)(fP,{children:`This instance's Harper version could not be read, so its trust policies are not shown.`}):(0,K.jsx)(Lc,{text:`Loading...`});if(!i)return(0,K.jsxs)(fP,{children:[`Trust policies need Harper 5.3 or later. This instance runs `,n?.version,`.`]});let _=async(t,n)=>{try{await u({...e,loaded:t,enabled:n}),U.success(`${n?`Enabled`:`Disabled`} trust policy '${t.id}'`)}finally{await c()}},v=async()=>{if(m)try{await f({...e,loaded:m}),U.success(`Dropped trust policy '${m.id}'`)}finally{h(void 0),await c()}};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 md:px-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`max-w-2xl space-y-1`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Trust Policies`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A trust policy lets a CI workflow, such as GitHub Actions, sign in as a Harper user with its OIDC identity token instead of a stored password or token. Policies replicate to every node in the cluster.`}),(0,K.jsx)(`a`,{className:`inline-block text-sm text-muted-foreground underline hover:text-foreground`,href:uP,target:`_blank`,rel:`noreferrer`,children:`Trust policy docs`})]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:l,disabled:o,children:[(0,K.jsx)(Go,{}),(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Refresh`})]})]}),s?(0,K.jsx)(fP,{children:`The trust policies could not be loaded.`}):a===void 0?(0,K.jsx)(Lc,{text:`Loading...`}):a.length===0?(0,K.jsxs)(fP,{children:[`No trust policies yet. Create one with the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`add_oidc_trust`}),` operation.`]}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,children:a.map(e=>(0,K.jsx)(hP,{policy:e,disabled:g,onToggle:t=>void _(e,t).catch(()=>void 0),onDrop:()=>h(e)},e.id))}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`trust policy '${m?.id??``}'`,isModalOpen:m!==void 0,setIsModalOpen:e=>!e&&h(void 0),deletionConfirmed:()=>void v().catch(()=>void 0),deletionPending:p,hideDataLossWarning:!0,transitiveVerb:`Drop`,presentParticiple:`Dropping`})]})}function fP({children:e}){return(0,K.jsx)(`p`,{className:`rounded-md border p-4 text-sm text-muted-foreground`,children:e})}function pP(e,t=`, `){if(typeof e==`string`)return e;if(Array.isArray(e)&&e.every(e=>typeof e==`string`))return e.join(t);try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function mP(e){return!e||typeof e!=`object`||Array.isArray(e)?[[`claims`,pP(e)]]:Object.entries(e).map(([e,t])=>[e,pP(t,` or `)])}function hP({policy:e,disabled:t,onToggle:n,onDrop:r}){let i=e.invalid_reason?pP(e.invalid_reason):void 0,a=e.enabled===!0,o=!i&&typeof e.enabled==`boolean`,s=pP(e.user);return(0,K.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-4`,"aria-label":`Trust policy ${e.id}`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),i?(0,K.jsx)(ol,{variant:`destructive`,children:`Can't match`}):a?(0,K.jsx)(ol,{variant:`success`,children:`Enabled`}):(0,K.jsx)(ol,{variant:`outline`,children:`Disabled`})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[o&&(0,K.jsx)(H,{size:`sm`,variant:`defaultOutline`,disabled:t,onClick:()=>n(!a),title:a?`Stops new runs from signing in. A token already issued keeps working until it expires, within an hour.`:void 0,children:a?`Disable`:`Enable`}),(0,K.jsx)(H,{size:`sm`,variant:`destructiveOutline`,disabled:t,onClick:r,children:`Drop`})]})]}),i&&(0,K.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`Harper refuses every token for this policy: `,i,`.`]}),typeof e.description==`string`&&e.description&&(0,K.jsx)(`p`,{className:`text-sm`,children:e.description}),(0,K.jsxs)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Issuer`}),(0,K.jsx)(`dd`,{className:`break-all font-mono text-xs`,children:pP(e.issuer)}),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Audience`}),(0,K.jsx)(`dd`,{className:`break-all font-mono text-xs`,children:pP(e.audience)}),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Claims`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`ul`,{children:mP(e.claims).map(([e,t])=>(0,K.jsxs)(`li`,{className:`break-all font-mono text-xs`,children:[e,` = `,t]},e))})}),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Signs in as`}),(0,K.jsx)(`dd`,{className:`font-mono text-xs`,children:s}),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Operations`}),(0,K.jsx)(`dd`,{className:`text-xs`,title:wk(e)?`Enforced on the Operations API and SQL. Application REST and GraphQL endpoints authorize by the user's role alone.`:void 0,children:wk(e)?(0,K.jsx)(`span`,{className:`font-mono`,children:pP(e.operations)}):`Not limited: the token carries everything ${s}'s role allows.`})]})]})}var gP=[{header:`Username`,accessorKey:`username`,enableSorting:!0},{header:`Role`,id:`role`,accessorFn:e=>e.role.role,enableSorting:!0},{header:`Active`,accessorKey:`active`,enableSorting:!0},{header:`Created`,accessorKey:`__createdtime__`,enableSorting:!0,enableGlobalFilter:!1,cell:e=>Bm((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)},{header:`Updated`,accessorKey:`__updatedtime__`,enableSorting:!0,enableGlobalFilter:!1,cell:e=>Bm((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}];function _P(e){let t=e.operations;return typeof t==`object`&&!!t&&!Array.isArray(t)}function vP({role:e}){let t=SA(),n=e?.permission;if(n===void 0||t===void 0)return null;let r=Rh(n,t.supported);if(r===`absent`||r===`database`||r===`inert`)return null;if(r===`breaks-auth`||r===`malformed`)return(0,K.jsx)(Pj,{kind:r,assigning:!0,databaseCollision:_P(n)});if(Nh(n))return(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`This role sets super_user or cluster_user, which Harper does not allow alongside an operations allowlist — the role cannot be saved until one of them is removed.`});let i=Qm(t.band),a=Ph(n),o=a?i?` (its structure-user DDL${a===!0?``:` on ${a.join(`, `)}`} needs listing too)`:a===!0?`, except that it is a structure user: table and attribute DDL — and create/drop database — apply on any database regardless of the list.`:`, except that it is a structure user: table and attribute DDL applies on ${a.join(`, `)} regardless of the list, and listing those operations cannot reach another database.`:``,s=Oh(Lh(n)??[],t.band);if(s.length===0)return(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[(Lh(n)??[]).length?`Every entry in this role's operations allowlist is inert`:`This role's operations allowlist is empty`,` — users with it cannot run any Operations API call`,i?`, not even SQL${a?` or its structure-user DDL`:``}.`:(0,K.jsxs)(K.Fragment,{children:[` `,`(SQL is authorized by table permissions instead, so it is unaffected)`,a?``:`.`,o]})]});let c=kh(s);return(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:c,children:[`This role is restricted to `,oe(s.length,`operation`,`operations`),`: `,(0,K.jsx)(`span`,{className:`font-mono`,children:s.slice(0,5).join(`, `)}),s.length>5?`, …`:``,o,s.length>5&&(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Full list: `,c]})]})}function yP(e){let t=CA();return e===void 0||t===void 0?!1:Rh(e.permission,t)===`breaks-auth`}function bP({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=q(),{data:i,isLoading:a}=L({...Zj(r),throwOnError:!0}),o=on({resolver:mt(ST),defaultValues:{username:``,role:``,password:``,confirmPassword:``}}),{mutate:s,isPending:c}=TT(),l=o.watch(`role`),u=yP(i?.find(e=>e.id===l)),d=(0,G.useCallback)(async e=>{e&&s({active:!0,password:e.password,role:e.role,username:e.username,...r},{onSuccess:()=>{let r=e.role;o.reset(),o.setValue(`role`,r),t(),U.success(`User added successfully!`),n(!1)}})},[s,o,r,t,n]);return(0,K.jsx)(_m,{onOpenChange:n,open:e,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...o,children:(0,K.jsxs)(`form`,{id:`instance-add-user-form`,name:`instance-add-user-form`,onSubmit:o.handleSubmit(d),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:`Add New User`})}),(0,K.jsx)(Y,{control:o.control,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`next`,autoComplete:`username`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:o.control,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:o.control,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:o.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role`}),a?(0,K.jsx)(my,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Role`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(by,{children:`Role`}),i?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.role,id:e.id})},e.id))]})})]})}),(0,K.jsx)(vP,{role:i?.find(t=>t.id===e.value)}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:c||u,children:[(0,K.jsx)($o,{}),` Add User`]})})})]})})})})}var xP=b({username:ST.shape.username,role:ST.shape.role,newPassword:ST.shape.password.or(O(``)).optional(),confirmPassword:ST.shape.confirmPassword}).refine(e=>!e.newPassword||e.newPassword.length>=8,{error:`Password must be at least 8 characters long.`,path:[`password`]}).refine(e=>!e.newPassword||e.newPassword===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function SP({data:e,onUserUpdated:t}){let n=q(),{data:r,isLoading:i}=L({...Zj(n),throwOnError:!0}),{mutate:a,isPending:o}=DT(),s=on({resolver:mt(xP),defaultValues:{username:e.username,role:e.role?.id??``,newPassword:``,confirmPassword:``}}),c=s.watch(`role`),l=yP(r?.find(e=>e.id===c)),u=(0,G.useCallback)(r=>{let i={username:e.username,role:r.role,...n};r.newPassword&&(i.password=r.newPassword),a(i,{onSuccess:()=>{s.reset(),U.success(`User edited successfully!`),t()}})},[s,a,e.username,n,t]);return(0,K.jsx)(Od,{...s,children:(0,K.jsxs)(`form`,{id:`instance-edit-user-form`,name:`instance-edit-user-form`,onSubmit:s.handleSubmit(u),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:`Edit User`})}),(0,K.jsx)(Y,{control:s.control,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`next`,autoComplete:`username`,disabled:!0,readOnly:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:s.control,name:`newPassword`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Change Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:s.control,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,enterKeyHint:`next`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:s.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role`}),i?(0,K.jsx)(my,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Role`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(by,{children:`Role`}),r?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.role,id:e.id})},e.id))]})})]})}),(0,K.jsx)(vP,{role:r?.find(t=>t.id===e.value)}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{variant:`submit`,disabled:o||l,children:[(0,K.jsx)($o,{}),` Save Changes`]})})})]})})}var CP=b({username:xf,confirmUsernameForDeletion:x().nonempty({error:`Please type the username again to confirm deletion.`})}).refine(e=>e.username.toLowerCase()===e.confirmUsernameForDeletion.toLowerCase(),{error:`Username does not match.`,path:[`confirmUsernameForDeletion`]});function wP({data:e,onUserDeleted:t}){let{mutate:n,isPending:r}=kT(),i=on({resolver:mt(CP),mode:`onTouched`,defaultValues:{username:e.username,confirmUsernameForDeletion:``}}),a=$l(),o=(0,G.useCallback)(()=>{n({username:e.username,...a},{onSuccess:()=>{i.reset(),U.success(`User deleted successfully!`),t()}})},[e.username,i,n,a,t]);return(0,K.jsx)(Od,{...i,children:(0,K.jsxs)(`form`,{id:`instance-delete-user-form`,name:`instance-delete-user-form`,onSubmit:i.handleSubmit(o),onKeyDown:rx(i),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Y,{control:i.control,name:`confirmUsernameForDeletion`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Confirm Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`next`,autoComplete:`username`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{variant:`destructive`,disabled:r||!i.formState.isValid,children:[(0,K.jsx)(Is,{}),` Delete User`]})})})]})})}function TP({closeModal:e,clusterId:t,instanceId:n,data:r,isModalOpen:i,onUserDeleted:a,onUserUpdated:o}){let s=u.checkForFabricConnect(n??t),c=Tr(n??t),l=!(!s&&c.user?.username===r.username);return(0,K.jsx)(_m,{onOpenChange:e,open:i,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsx)(SP,{data:r,onUserUpdated:o}),l&&(0,K.jsx)(wP,{data:r,onUserDeleted:a})]})})}function EP({entityId:e,instanceClient:t}){return B({queryKey:[e,`list_users`],queryFn:()=>DP({instanceClient:t}),refetchInterval:Gc(1e4),retry:Kc()})}async function DP({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_users`});return t}function OP(){let e=De(),{instanceId:t,clusterId:n,username:r}=z({strict:!1}),i=q(),{data:a,refetch:o,isFetching:s,isRefetching:c}=we(EP(i)),l=(0,G.useMemo)(()=>a?.find(e=>e.username===r),[a,r]),u=(0,G.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,G.useState)(!1),[m]=(0,G.useState)({attribute:`username`,descending:!1}),h=(0,G.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),g=(0,G.useCallback)(()=>{p(!0)},[p]),_=(0,G.useCallback)(()=>{o(),p(!1)},[o,p]),v=(0,G.useCallback)(e=>{u(e.original.username)},[u]),y=(0,G.useCallback)(()=>{u(void 0)},[u]),b=(0,G.useCallback)(()=>{o(),u(void 0)},[u,o]),x=(0,G.useCallback)(()=>{o(),u(void 0)},[u,o]),S=Kb(o);return(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:a,isFetching:s||c,columns:gP,onRowClick:v,sortingState:h,filter:{label:`Filter users`,placeholder:`Filter by username or role`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:g,accessKey:`a`,disabled:f,children:[(0,K.jsx)(Uo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),(0,K.jsx)(bP,{isModalOpen:f,onChangesSaved:_,setIsModalOpen:p}),d&&(0,K.jsx)(TP,{instanceId:t,clusterId:n,closeModal:y,data:l,isModalOpen:d,onUserDeleted:x,onUserUpdated:b})]})}function kP(e){return RC(e,HE(eu(e.params)))}function AP(e){let t=R({getParentRoute:()=>e,path:`config`,head:()=>({meta:[{title:`Config — Harper Fabric`}]}),component:Ik,loader:kP}),n=R({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Overview — Harper Fabric`}]}),component:xA,loader:kP}),r=R({getParentRoute:()=>t,path:`roles`,head:()=>({meta:[{title:`Instance Roles — Harper Fabric`}]}),component:iM}),i=R({getParentRoute:()=>t,path:`roles/$roleId`,head:()=>({meta:[{title:`Instance Roles — Harper Fabric`}]}),component:iM}),a=R({getParentRoute:()=>t,path:`users`,head:()=>({meta:[{title:`Instance Users — Harper Fabric`}]}),component:OP}),o=R({getParentRoute:()=>t,path:`users/$username`,head:()=>({meta:[{title:`Instance Users — Harper Fabric`}]}),component:OP}),s=R({getParentRoute:()=>t,path:`domains`,head:()=>({meta:[{title:`Instance Domains — Harper Fabric`}]}),component:yk}),c=R({getParentRoute:()=>t,path:`ssh-keys`,head:()=>({meta:[{title:`SSH Keys — Harper Fabric`}]}),component:lP}),l=R({getParentRoute:()=>t,path:`ssh-keys/$keyName`,head:()=>({meta:[{title:`SSH Keys — Harper Fabric`}]}),component:lP}),u=R({getParentRoute:()=>t,path:`deployments`,validateSearch:mD,head:()=>({meta:[{title:`Deployments — Harper Fabric`}]}),component:vk}),d=R({getParentRoute:()=>t,path:`deployments/$deploymentId`,validateSearch:mD,head:()=>({meta:[{title:`Deployments — Harper Fabric`}]}),component:vk}),f=R({getParentRoute:()=>t,path:`secrets`,head:()=>({meta:[{title:`Secrets — Harper Fabric`}]}),component:lN}),p=R({getParentRoute:()=>t,path:`secrets/$secretName`,head:()=>({meta:[{title:`Secrets — Harper Fabric`}]}),component:lN}),m=R({getParentRoute:()=>t,path:`trust-policies`,head:()=>({meta:[{title:`Trust Policies — Harper Fabric`}]}),component:dP}),h=R({getParentRoute:()=>t,path:`certificates`,head:()=>({meta:[{title:`Certificates — Harper Fabric`}]}),component:VE}),g=R({getParentRoute:()=>t,path:`certificates/$certName`,head:()=>({meta:[{title:`Certificates — Harper Fabric`}]}),component:VE});return t.addChildren([n,r,i,a,o,s,u,d,c,l,f,p,m,h,g])}function jP({clusterId:e,databaseName:t,instanceId:n,organizationId:r,tableName:i}){let a=[`databases`,t,i].filter(fr).join(`/`);return qg({organizationId:r,instanceId:n,clusterId:e},a)}function MP(e){for(let t of e.split(`
|
|
695
|
+
`)){let e=t.match(/^(\t+| +)\S/);if(!e)continue;let n=e[1];return n[0]===` `?` `:n}return` `}function NP(e){return/\r\n/.test(e)?`\r
|
|
696
|
+
`:`
|
|
697
|
+
`}function PP(e){return e.kind===`named`?e.name:PP(e.of)}function FP(e){return e.kind===`list`}function IP(e){return e.kind===`named`?`${e.name}${e.nonNull?`!`:``}`:`[${IP(e.of)}]${e.nonNull?`!`:``}`}function LP(e,t){return e.find(e=>e.name===t)}function RP(e,t){return e?.args.find(e=>e.name===t)}function zP(e){if(e===void 0)return;let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}}function BP(e){if(e===void 0)return;let t=Number(e.trim());return Number.isFinite(t)?t:void 0}function VP(e){let t=e?.trim();return t===`true`||t!==`false`&&void 0}function HP(e){return JSON.stringify(e)}function UP(e){return String(Math.trunc(e))}function WP(e){return e?`true`:`false`}var GP=0;function KP(){return`f${GP++}`}function qP(e=``){return{key:KP(),leadingComments:[],name:e,type:{kind:`named`,name:`String`,nonNull:!1},directives:[]}}function JP(e){return{id:e,leading:``,typeName:``,directives:[{name:`table`,args:[],hadParens:!1},{name:`export`,args:[],hadParens:!1},{name:`sealed`,args:[],hadParens:!1}],fields:[{key:KP(),leadingComments:[],name:`id`,type:{kind:`named`,name:`ID`,nonNull:!1},directives:[{name:`primaryKey`,args:[],hadParens:!1}]}],trailingComments:[],raw:``,edited:!0}}function YP(e,t){return e.some(e=>e.name===t)}function XP(e,t,n){return n===YP(e,t)?e:n?[...e,{name:t,args:[],hadParens:!1}]:e.filter(e=>e.name!==t)}function ZP(e,t,n){return e.find(e=>e.name===t)?.args.find(e=>e.name===n)?.value}function QP(e,t,n,r){return(YP(e,t)?e:[...e,{name:t,args:[],hadParens:!1}]).map(e=>{if(e.name!==t)return e;let i=e.args.filter(e=>e.name!==n),a=r===void 0?i:[...i,{name:n,value:r}];return{...e,args:a}})}function $P(e,t,n,r){return QP(e,t,n,r?HP(r):void 0)}function eF(e,t,n,r){return QP(e,t,n,r===void 0||Number.isNaN(r)?void 0:UP(r))}function tF(e,t,n,r,i){return QP(e,t,n,r===i?void 0:WP(r))}function nF(e,t,n){let r={kind:`named`,name:e,nonNull:!t&&n};return t?{kind:`list`,of:r,nonNull:n}:r}function rF(e){return PP(e.type)}function iF(e){return e.type.kind===`list`}function aF(e){return e.type.nonNull}function oF(e){return/[A-Za-z0-9_]/.test(e)}function sF(e,t){if(e.startsWith(`"""`,t)){let n=t+3;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e.startsWith(`"""`,n))return n+3;n++}return-1}let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===`"`)return n+1;if(t===`
|
|
698
|
+
`)return-1;n++}return-1}function cF(e,t){let n=t;for(;n<e.length&&e[n]!==`
|
|
699
|
+
`;)n++;return n}function lF(e,t,n,r){let i=0,a=t;for(;a<e.length;){let t=e[a];if(t===`"`){if(a=sF(e,a),a<0)return-1;continue}if(t===`#`){a=cF(e,a);continue}if(t===n)i++;else if(t===r&&(i--,i===0))return a+1;a++}return-1}function uF(e,t){let n=t;for(;n<e.length&&/[\s,]/.test(e[n]);)n++;return n}function dF(e,t,n){if(!e.startsWith(n,t)||t>0&&oF(e[t-1]))return!1;let r=e[t+n.length];return r===void 0||!oF(r)}function fF(e,t){let n=uF(e,t+4),r=n;for(;n<e.length&&oF(e[n]);)n++;if(n===r)return-1;for(;n<e.length;){let t=e[n];if(t===`"`){if(n=sF(e,n),n<0)return-1;continue}if(t===`#`){n=cF(e,n);continue}if(t===`(`){if(n=lF(e,n,`(`,`)`),n<0)return-1;continue}if(t===`{`)break;if(t===`}`)return-1;n++}return n>=e.length||e[n]!==`{`?-1:lF(e,n,`{`,`}`)}function pF(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`"`){if(n=sF(e,n),n<0)return{blocks:t,ok:!1};continue}if(r===`#`){n=cF(e,n);continue}if(dF(e,n,`type`)){let r=fF(e,n);if(r>0){t.push({start:n,end:r}),n=r;continue}}n++}return{blocks:t,ok:!0}}function mF(e,t){let n=e[t];if(n===`"`){let n=sF(e,t);return n<0?e.length:n}if(n===`[`){let n=lF(e,t,`[`,`]`);return n<0?e.length:n}if(n===`{`){let n=lF(e,t,`{`,`}`);return n<0?e.length:n}let r=t;for(;r<e.length&&!/[\s,)]/.test(e[r]);)r++;return r}function hF(e){let t=[],n=0;for(;n<e.length&&(n=uF(e,n),!(n>=e.length));){if(e[n]===`#`){n=cF(e,n);continue}let r=n;for(;n<e.length&&oF(e[n]);)n++;let i=e.slice(r,n);if(!i){n++;continue}if(n=uF(e,n),e[n]!==`:`)continue;n=uF(e,n+1);let a=n;n=mF(e,n),t.push({name:i,value:e.slice(a,n).trim()})}return t}function gF(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`#`){n=cF(e,n);continue}if(r!==`@`){n++;continue}n++;let i=n;for(;n<e.length&&oF(e[n]);)n++;let a=e.slice(i,n);if(!a)continue;let o=n;for(;o<e.length&&/\s/.test(e[o]);)o++;let s=[],c=!1;if(e[o]===`(`){let t=lF(e,o,`(`,`)`);t>0&&(c=!0,s=hF(e.slice(o+1,t-1)),n=t)}t.push({name:a,args:s,hadParens:c})}return t}function _F(e,t){if(t=uF(e,t),e[t]===`[`){let n=_F(e,t+1);if(!n)return null;let r=uF(e,n.end);if(e[r]!==`]`)return null;r++;let i=!1;return e[r]===`!`&&(i=!0,r++),{type:{kind:`list`,of:n.type,nonNull:i},end:r}}let n=t;for(;t<e.length&&oF(e[t]);)t++;if(t===n)return null;let r=e.slice(n,t),i=!1;return e[t]===`!`&&(i=!0,t++),{type:{kind:`named`,name:r,nonNull:i},end:t}}function vF(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `||e[n]===`,`);)n++;return n}function yF(e){let t=[],n=[],r=0;for(;r<e.length;){let i=e[r];if(/[\s,]/.test(i)){r++;continue}if(i===`#`){let t=cF(e,r);n.push(e.slice(r,t).replace(/\r$/,``).trim()),r=t;continue}if(i===`"`){let t=sF(e,r);if(t<0)return null;n.push(e.slice(r,t)),r=t;continue}let a=r;for(;r<e.length&&oF(e[r]);)r++;let o=e.slice(a,r);if(!o||(r=uF(e,r),e[r]!==`:`))return null;let s=_F(e,r+1);if(!s)return null;r=s.end;let c=r;for(r=vF(e,r);e[r]===`@`;){for(r++;r<e.length&&oF(e[r]);)r++;let t=vF(e,r);if(e[t]===`(`){let n=lF(e,t,`(`,`)`);if(n<0)return null;t=n}r=t,r=vF(e,r)}let l=gF(e.slice(c,r));r=vF(e,r);let u;if(e[r]===`#`){let t=cF(e,r);u=e.slice(r,t).replace(/\r$/,``).trim(),r=t}t.push({key:KP(),leadingComments:n,name:o,type:s.type,directives:l,lineComment:u}),n=[]}return{fields:t,trailingComments:n}}function bF(e){let t=e.indexOf(`
|
|
700
|
+
`);if(t<0)return{body:e};let n=e.slice(0,t);return n.replace(/^[ \t,]+/,``).startsWith(`#`)?{headerComment:n.replace(/\r$/,``).trim(),body:e.slice(t+1)}:{body:e}}function xF(e,t){let n=uF(e,4),r=n;for(;n<e.length&&oF(e[n]);)n++;let i=e.slice(r,n);if(!i)return null;let a=e.indexOf(`{`,n);if(a<0)return null;let o=gF(e.slice(n,a));if(!LP(o,`table`))return null;let s=e.lastIndexOf(`}`);if(s<a)return null;let{headerComment:c,body:l}=bF(e.slice(a+1,s)),u=yF(l);return u?{id:t,leading:``,typeName:i,headerComment:c,directives:o,fields:u.fields,trailingComments:u.trailingComments,raw:e,edited:!1}:null}function SF(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
701
|
+
`&&t.push(n+1);let n=t.length,r=r=>e.slice(t[r],r+1<n?t[r+1]-1:e.length).replace(/\r$/,``),i=Array.from({length:n},()=>!1),a=!1;for(let e=0;e<n;e++){let t=a,n=0;for(let t=r(e).indexOf(`"""`);t!==-1;t=r(e).indexOf(`"""`,t+3))n++,a=!a;i[e]=t||n>0}let o=t[n-1];for(let e=n-2;e>=0;e--){let n=r(e).trim();if(i[e]||n.startsWith(`#`)){o=t[e];continue}break}return[e.slice(0,o),e.slice(o)]}function CF(e){let t=MP(e),n=NP(e),{blocks:r,ok:i}=pF(e);if(!i)return{document:{segments:[{kind:`raw`,text:e}],indent:t,newline:n},ok:!1};let a=[],o=e=>{e&&a.push({kind:`raw`,text:e})},s=0,c=0;for(let t of r){let n=e.slice(s,t.start),r=e.slice(t.start,t.end),i=xF(r,`t${c}`);if(i){let[e,t]=SF(n);o(e),i.leading=t,a.push({kind:`table`,table:i}),c++}else o(n+r);s=t.end}return o(e.slice(s)),{document:{segments:a,indent:t,newline:n},ok:!0}}function wF(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}var TF={apng:{kind:`image`,mime:`image/apng`},avif:{kind:`image`,mime:`image/avif`},bmp:{kind:`image`,mime:`image/bmp`},gif:{kind:`image`,mime:`image/gif`},ico:{kind:`image`,mime:`image/x-icon`},jfif:{kind:`image`,mime:`image/jpeg`},jpeg:{kind:`image`,mime:`image/jpeg`},jpg:{kind:`image`,mime:`image/jpeg`},png:{kind:`image`,mime:`image/png`},webp:{kind:`image`,mime:`image/webp`},m4v:{kind:`video`,mime:`video/mp4`},mov:{kind:`video`,mime:`video/quicktime`},mp4:{kind:`video`,mime:`video/mp4`},ogv:{kind:`video`,mime:`video/ogg`},webm:{kind:`video`,mime:`video/webm`}};function EF(e){return TF[wF(e).toLowerCase()]}function DF(e){return EF(e)!==void 0}async function OF({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,project:n,file:t,encoding:r??(DF(t)?`base64`:`utf8`)});return{project:n,file:t,...i}}function kF(e){return B({queryKey:AF(e),queryFn:()=>OF(e),enabled:!!e.file&&!!e.project,retry:!1})}function AF(e){return[e.entityId,`get_component_file`,e.project,e.file,e.encoding]}function jF(e,t){return{queryKey:[e,`get_component_file`],predicate:({queryKey:[,,e,n]})=>{if(typeof e!=`string`)return!1;let r=n?`${e}/${n}`:e;return r===t||r.startsWith(`${t}/`)}}}var MF=`data`,NF=25;function PF(e){return B({queryKey:[e.entityId,`schema-relationships`],staleTime:6e4,retry:!1,enabled:e.enabled!==!1,queryFn:async()=>{try{let t=FF(await IO(e)).slice(0,NF);return IF((await Promise.all(t.map(({project:t,file:n})=>OF({...e,project:t,file:n}).then(e=>e.message).catch(()=>void 0)))).filter(e=>typeof e==`string`))}catch{return{}}}})}function FF(e){let t=[];for(let n of e?.entries??[]){if(!(`entries`in n))continue;let e=(r,i)=>{for(let a of r)`entries`in a?e(a.entries,`${i}${a.name}/`):a.name.endsWith(`.graphql`)&&t.push({project:n.name,file:`${i}${a.name}`})};e(n.entries,``)}return t}function IF(e){let t=[];for(let n of e){let{document:e,ok:r}=CF(n);if(r)for(let n of e.segments){if(n.kind!==`table`)continue;let{table:e}=n,r=LP(e.directives,`table`),i=zP(RP(r,`table`)?.value)??e.typeName,a=zP(RP(r,`database`)?.value)??MF,o=[];for(let t of e.fields){let e=LP(t.directives,`relationship`);e&&o.push({attribute:t.name,relatedTypeName:PP(t.type),isToMany:FP(t.type),from:zP(RP(e,`from`)?.value),to:zP(RP(e,`to`)?.value)})}t.push({typeName:e.typeName,tableName:i,database:a,relationships:o})}}let n={};for(let e of t){if(!e.relationships.length)continue;let r=[];for(let{relatedTypeName:n,...i}of e.relationships){let a=t.find(t=>t.typeName===n&&t.database===e.database);a&&r.push({...i,relatedTableName:a.tableName})}r.length&&((n[e.database]??={})[e.tableName]=r)}return n}function LF(e,t){let n=e.type===`array`?e.elements:e.type;return n&&Object.hasOwn(t,n)?n:void 0}function RF(e,t,n){if(!t||e.is_primary_key||e.computed)return;let r=LF(e,t),i=r?t[r]:void 0;if(!r||!i)return;let a=i.primary_key??i.hash_attribute;if(!a)return;let o=e.type===`array`;return{relatedTableName:r,relatedPrimaryKey:a,relatedAttributes:zF(i,t),isToMany:o,resolvable:!0,reverseForeignKey:o&&n?BF(n,i,t):void 0}}function zF(e,t){return(e.attributes??[]).filter(e=>!e.computed&&!LF(e,t))}function BF(e,t,n){let r=t.attributes??[];for(let t of r){let i=RF(t,n);if(i&&!i.isToMany&&i.relatedTableName===e.name){let e=WF(t.attribute,i,r,n);if(e)return e}}let i=e.name.toLowerCase(),a=new Set([i,i.replace(/s$/,``)].flatMap(e=>[`${e}id`,`${e}_id`]));return r.find(e=>!e.is_primary_key&&!e.computed&&a.has(e.attribute.toLowerCase()))?.attribute}function VF(e,t,n){let r={};for(let n of e?.attributes??[]){let i=RF(n,t,e);i&&(r[n.attribute]=i)}for(let e of n??[]){let n=t?.[e.relatedTableName],i=n?.primary_key??n?.hash_attribute;if(!n||!i||!t)continue;let a=r[e.attribute];r[e.attribute]={relatedTableName:e.relatedTableName,relatedPrimaryKey:i,relatedAttributes:zF(n,t),isToMany:e.isToMany,resolvable:a?.resolvable??!1,reverseForeignKey:(e.isToMany?e.to:void 0)??a?.reverseForeignKey,foreignKeyAttribute:e.from}}return r}function HF(e,t,n){return!!e.computed||RF(e,t)!==void 0||!!n?.some(t=>t.attribute===e.attribute)}function UF(e,t,n){return(e??[]).filter(e=>HF(e,t,n)).map(e=>e.attribute)}function WF(e,t,n,r){let i=[e];t.isToMany&&e.endsWith(`s`)&&i.push(e.slice(0,-1));let a=t.isToMany?[`ids`,`_ids`]:[`id`,`_id`],o=new Set(i.flatMap(e=>a.map(t=>(e+t).toLowerCase())));return n.find(e=>!e.is_primary_key&&!e.computed&&!RF(e,r)&&o.has(e.attribute.toLowerCase()))?.attribute}function GF(e){let t=new Set;for(let n of Object.values(e))n.foreignKeyAttribute&&t.add(n.foreignKeyAttribute);return[...t]}function KF(e,t){let n=[];for(let r of e?.attributes??[]){if(r.computed){n.push(r.attribute);continue}let e=RF(r,t);e?.resolvable&&n.push({name:r.attribute,select:[e.relatedPrimaryKey]})}return n.length?[...n,`*`]:void 0}async function qF({databaseName:e,tableName:t,records:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`insert`,database:e,table:t,records:n});return i}function JF(){return I({mutationFn:qF})}function YF(e,t=!1){let n=e.length,r=0,i=``,a=0,o=16,s=0,c=0,l=0,u=0,d=0;function f(t,n){let i=0,a=0;for(;i<t;){let t=e.charCodeAt(r);if(t>=48&&t<=57)a=a*16+t-48;else if(t>=65&&t<=70)a=a*16+t-65+10;else if(t>=97&&t<=102)a=a*16+t-97+10;else break;r++,i++}return i<t&&(a=-1),a}function p(e){r=e,i=``,a=0,o=16,d=0}function m(){let t=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&QF(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46){if(r++,r<e.length&&QF(e.charCodeAt(r)))for(r++;r<e.length&&QF(e.charCodeAt(r));)r++;else return d=3,e.substring(t,r)}let n=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101)){if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&QF(e.charCodeAt(r))){for(r++;r<e.length&&QF(e.charCodeAt(r));)r++;n=r}else d=3}return e.substring(t,n)}function h(){let t=``,i=r;for(;;){if(r>=n){t+=e.substring(i,r),d=2;break}let a=e.charCodeAt(r);if(a===34){t+=e.substring(i,r),r++;break}if(a===92){if(t+=e.substring(i,r),r++,r>=n){d=2;break}switch(e.charCodeAt(r++)){case 34:t+=`"`;break;case 92:t+=`\\`;break;case 47:t+=`/`;break;case 98:t+=`\b`;break;case 102:t+=`\f`;break;case 110:t+=`
|
|
702
|
+
`;break;case 114:t+=`\r`;break;case 116:t+=` `;break;case 117:let e=f(4);e>=0?t+=String.fromCharCode(e):d=4;break;default:d=5}i=r;continue}if(a>=0&&a<=31){if(ZF(a)){t+=e.substring(i,r),d=2;break}d=6}r++}return t}function g(){if(i=``,d=0,a=r,c=s,u=l,r>=n)return a=n,o=17;let t=e.charCodeAt(r);if(XF(t)){do r++,i+=String.fromCharCode(t),t=e.charCodeAt(r);while(XF(t));return o=15}if(ZF(t))return r++,i+=String.fromCharCode(t),t===13&&e.charCodeAt(r)===10&&(r++,i+=`
|
|
703
|
+
`),s++,l=r,o=14;switch(t){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=h(),o=10;case 47:let c=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!ZF(e.charCodeAt(r));)r++;return i=e.substring(c,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;let t=n-1,a=!1;for(;r<t;){let t=e.charCodeAt(r);if(t===42&&e.charCodeAt(r+1)===47){r+=2,a=!0;break}r++,ZF(t)&&(t===13&&e.charCodeAt(r)===10&&r++,s++,l=r)}return a||(r++,d=1),i=e.substring(c,r),o=13}return i+=String.fromCharCode(t),r++,o=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!QF(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=m(),o=11;default:for(;r<n&&_(t);)r++,t=e.charCodeAt(r);if(a!==r){switch(i=e.substring(a,r),i){case`true`:return o=8;case`false`:return o=9;case`null`:return o=7}return o=16}return i+=String.fromCharCode(t),r++,o=16}}function _(e){if(XF(e)||ZF(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function v(){let e;do e=g();while(e>=12&&e<=15);return e}return{setPosition:p,getPosition:()=>r,scan:t?v:g,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>a,getTokenLength:()=>r-a,getTokenStartLine:()=>c,getTokenStartCharacter:()=>a-u,getTokenError:()=>d}}function XF(e){return e===32||e===9}function ZF(e){return e===10||e===13}function QF(e){return e>=48&&e<=57}var $F;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})($F||={}),Array(20).fill(0).map((e,t)=>` `.repeat(t));var eI=200;Array(eI).fill(0).map((e,t)=>`
|
|
704
|
+
`+` `.repeat(t)),Array(eI).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(eI).fill(0).map((e,t)=>`\r
|
|
705
|
+
`+` `.repeat(t)),Array(eI).fill(0).map((e,t)=>`
|
|
706
|
+
`+` `.repeat(t)),Array(eI).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(eI).fill(0).map((e,t)=>`\r
|
|
707
|
+
`+` `.repeat(t));var tI;(function(e){e.DEFAULT={allowTrailingComma:!1}})(tI||={});var nI=YF,rI;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(rI||={});var iI;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(iI||={});var aI;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(aI||={});function oI(e){return{getInitialState:()=>new yI(null,null,!1,null),tokenize:(t,n)=>bI(e,t,n)}}var sI=`delimiter.bracket.json`,cI=`delimiter.array.json`,lI=`delimiter.colon.json`,uI=`delimiter.comma.json`,dI=`keyword.json`,fI=`keyword.json`,pI=`string.value.json`,mI=`number.json`,hI=`string.key.json`,gI=`comment.block.json`,_I=`comment.line.json`,vI=class e{constructor(e,t){this.parent=e,this.type=t}static pop(e){return e?e.parent:null}static push(t,n){return new e(t,n)}static equals(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;for(;e&&t;){if(e===t)return!0;if(e.type!==t.type)return!1;e=e.parent,t=t.parent}return!0}},yI=class e{constructor(e,t,n,r){this._state=e,this.scanError=t,this.lastWasColon=n,this.parents=r}clone(){return new e(this._state,this.scanError,this.lastWasColon,this.parents)}equals(t){return t===this?!0:!t||!(t instanceof e)?!1:this.scanError===t.scanError&&this.lastWasColon===t.lastWasColon&&vI.equals(this.parents,t.parents)}getStateData(){return this._state}setStateData(e){this._state=e}};function bI(e,t,n,r=0){let i=0,a=!1;switch(n.scanError){case 2:t=`"`+t,i=1;break;case 1:t=`/*`+t,i=2}let o=nI(t),s=n.lastWasColon,c=n.parents,l={tokens:[],endState:n.clone()};for(;;){let e=r+o.getPosition(),u=``,d=o.scan();if(d===17)break;if(e===r+o.getPosition())throw Error(`Scanner did not advance, next 3 characters are: `+t.substr(o.getPosition(),3));switch(a&&(e-=i),a=i>0,d){case 1:c=vI.push(c,0),u=sI,s=!1;break;case 2:c=vI.pop(c),u=sI,s=!1;break;case 3:c=vI.push(c,1),u=cI,s=!1;break;case 4:c=vI.pop(c),u=cI,s=!1;break;case 6:u=lI,s=!0;break;case 5:u=uI,s=!1;break;case 8:case 9:u=dI,s=!1;break;case 7:u=fI,s=!1;break;case 10:let e=(c?c.type:0)===1;u=s||e?pI:hI,s=!1;break;case 11:u=mI,s=!1}switch(d){case 12:u=_I;break;case 13:u=gI}l.endState=new yI(n.getStateData(),o.getTokenError(),s,c),l.tokens.push({startIndex:e,scopes:u})}return l}var xI=`json-worker-free`,SI={wordPattern:/(-?\d*\.\d\w*)|([^[{\]}:"\s,]+)/g,comments:{lineComment:`//`,blockComment:[`/*`,`*/`]},brackets:[[`{`,`}`],[`[`,`]`]],autoClosingPairs:[{open:`{`,close:`}`,notIn:[`string`]},{open:`[`,close:`]`,notIn:[`string`]},{open:`"`,close:`"`,notIn:[`string`]}]},CI=!1;function wI(e){CI||(CI=!0,e.register({id:xI}),e.setLanguageConfiguration(xI,SI),e.setTokensProvider(xI,oI(!0)))}function TI(e){if(!e.trim())return{ok:!1,error:{message:`The editor is empty, so there is nothing to save.`}};let t=EI(e);if(!t.ok)return t;let n=MI(t.value);return n?{ok:!1,error:{message:n}}:{ok:!0,value:t.value}}function EI(e){try{return{ok:!0,value:JSON.parse(e)}}catch(t){let n=t instanceof Error?t.message:String(t);return{ok:!1,error:{message:PI(n),location:AI(n,e)}}}}function DI({message:e,location:t}){return t?`Line ${t.lineNumber}, column ${t.column}: ${e}`:e}var OI=/\bline (\d+) column (\d+)/i,kI=/\bposition (\d+)/i;function AI(e,t){let n=OI.exec(e);if(n)return{lineNumber:Number(n[1]),column:Number(n[2])};let r=kI.exec(e);return r?jI(t,Number(r[1])):void 0}function jI(e,t){let n=Math.max(0,Math.min(t,e.length)),r=1,i=0;for(let t=e.indexOf(`
|
|
708
|
+
`);t!==-1&&t<n;t=e.indexOf(`
|
|
709
|
+
`,t+1))r++,i=t+1;return{lineNumber:r,column:n-i+1}}function MI(e){if(Array.isArray(e)){let t=e.findIndex(e=>!NI(e));return t===-1?void 0:`Item ${t+1} of the array isn't a JSON object.`}return NI(e)?void 0:`A record has to be a JSON object, or an array of them.`}function NI(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function PI(e){return e.replace(/^JSON\.parse:\s*/,``).replace(/\s*(?:in JSON )?at position \d+.*$/i,``).replace(/\s*at line \d+ column \d+ of the JSON data\.?$/i,``).trim()}var FI=`record-json`;function II(){let e=(0,G.useRef)(null),t=(0,G.useRef)(null);return{onEditorMount:(0,G.useCallback)((n,r)=>{e.current=n,t.current=r},[]),showRecordJsonError:(0,G.useCallback)(n=>{e.current&&t.current&&LI(e.current,t.current,n)},[]),clearRecordJsonError:(0,G.useCallback)(()=>{e.current&&t.current&&RI(e.current,t.current)},[])}}function LI(e,t,n){let r=e.getModel();if(!r)return;let i=n.location&&zI(r,n.location);t.editor.setModelMarkers(r,FI,i?[{severity:t.MarkerSeverity.Error,message:n.message,startLineNumber:i.lineNumber,startColumn:i.column,endLineNumber:i.lineNumber,endColumn:Math.max(r.getLineMaxColumn(i.lineNumber),i.column+1)}]:[]),i&&(e.revealLineInCenter(i.lineNumber),e.setPosition(i),e.focus())}function RI(e,t){let n=e.getModel();n&&t.editor.setModelMarkers(n,FI,[])}function zI(e,{lineNumber:t,column:n}){let r=Math.min(Math.max(t,1),e.getLineCount());return{lineNumber:r,column:Math.min(Math.max(n,1),e.getLineMaxColumn(r))}}function BI({isModalOpen:e,instanceTable:t,databaseTables:n,schemaRelationships:r,setIsModalOpen:i,refreshTable:a}){let o=Tx(),{mutate:s,isPending:c}=JF(),l=q(),[u,d]=(0,G.useState)(),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)([]),{onEditorMount:g,showRecordJsonError:_,clearRecordJsonError:v}=II(),y=(0,G.useMemo)(()=>{let e={};for(let i of t.attributes)i.is_primary_key||i.attribute===`__createdtime__`||i.attribute===`__updatedtime__`||HF(i,n,r)||(e[i.attribute]=VI(i.type));return JSON.stringify(e,null,4)},[t,n,r]),b=(0,G.useCallback)(()=>{if(u===void 0)return;let e=TI(u);if(!e.ok){U.error(`This record isn't valid JSON`,{description:DI(e.error)}),_(e.error);return}let n=Array.isArray(e.value)?e.value:[e.value],r=U.loading(`Adding ${n.length} records...`);s({...l,databaseName:t.schema,tableName:t.name,records:n},{onSuccess:e=>{a(),e.skipped_hashes?.length||i(!1),h(e.skipped_hashes),(e.skipped_hashes?.length>0?U.warning:U.success)(e.skipped_hashes?.length>0?`Warning!`:`Success!`,{id:r,description:(0,K.jsxs)(K.Fragment,{children:[e.inserted_hashes.length>0&&(0,K.jsxs)(`p`,{children:[`Added `,oe(e.inserted_hashes.length,`record`,`records`)]}),e.skipped_hashes.length>0&&(0,K.jsxs)(`p`,{children:[`Skipped `,oe(e.skipped_hashes.length,`record`,`records`)]})]})})}})},[u,s,l,t.name,t.schema,a,i,_]),x=(0,G.useCallback)((e,t)=>{g(e,t),e?.focus()},[g]);return(0,K.jsx)(_m,{onOpenChange:i,open:e,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,onEscapeKeyDown:e=>{f&&e.preventDefault()},children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[`Add New `,t.name]})}),(t?.primary_key??t?.hash_attribute)&&(0,K.jsxs)(`div`,{className:`text-sm text-gray-500`,children:[`The primary key for this table is`,` `,(0,K.jsxs)(`strong`,{children:[`“`,t.primary_key??t.hash_attribute,`”`]}),`, and will auto-generate. You may manually add it if you want to specify its value.`]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 w-full`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:xI,theme:o,value:y,onChange:e=>{d(e),p(!0),v()},options:{minimap:{enabled:!1},automaticLayout:!0},onMount:x})}),(0,K.jsxs)(`div`,{className:`text-sm text-gray-500`,children:[(0,K.jsx)(`strong`,{children:`Provide an [array]`}),` if you want to add more than one record at a time.`]}),m.length>0&&(0,K.jsxs)(c_,{className:`mt-2`,children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),(0,K.jsxs)(l_,{children:[`Skipped `,m.length===1?`Hash`:`Hashes`,` Detected`]}),(0,K.jsx)(u_,{className:`max-h-36 overflow-auto`,children:(0,K.jsx)(`ol`,{children:m.map(e=>(0,K.jsx)(`li`,{children:e},e))})})]}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{variant:`submit`,onClick:b,accessKey:`s`,disabled:u===void 0||c,children:[(0,K.jsx)($o,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`S`}),`ave Changes`]})]})})})]})})}function VI(e){switch(e){case`Date`:return new Date().toISOString();case`Id`:case`ID`:case`String`:return``;case`Boolean`:return!1;case`Int`:case`Long`:case`Float`:case`BigInt`:return 0;default:return null}}async function HI({databaseName:e,tableName:t,primaryKey:n,replicated:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`create_table`,database:e,table:t,primary_key:n,replicated:r});return a}function UI(){return I({mutationFn:HI})}var WI=/^[\x20-\x2E|\x30-\x5F|\x61-\x7E]*$/,GI=x().regex(WI,{error:`Database name cannot include backticks or forward slashes.`}).max(75,{error:`Database name cannot be longer than 75 characters.`}),KI=x().nonempty({error:`Table name is required.`}).regex(WI,{error:`Table name cannot include backticks or forward slashes.`}).max(250,{error:`Table name cannot be longer than 250 characters.`}),qI=b({databaseName:GI,tableName:KI,primaryKey:x().regex(WI,{error:`Primary key cannot include backticks or forward slashes.`}).max(250,{error:`Primary key cannot be longer than 250 characters.`})});function JI({isModalOpen:e,setIsModalOpen:t,databaseName:n,onCreated:r}){let i=Ze(),a=q(),o=Ee(),s=on({resolver:mt(qI),defaultValues:{databaseName:n||``,tableName:``,primaryKey:``}}),{mutate:c}=UI(),l=async e=>{let n=e.databaseName||`data`,l=e.tableName;c({databaseName:n,tableName:l,primaryKey:e.primaryKey||`id`,...a,replicated:a.entityType===`cluster`},{onSuccess:async()=>{await i.invalidateQueries({queryKey:[a.entityId,`describe_all`],refetchType:`all`}),U.success(`Table ${l} created successfully`),t(!1),s.reset(),r(n,l),await o.invalidate()}})};return(0,K.jsx)(_m,{open:e,onOpenChange:t,children:(0,K.jsxs)(wm,{className:`sm:max-w-[425px]`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Create a New Table`}),(0,K.jsx)(Om,{children:`What would you like to create?`})]}),(0,K.jsx)(Od,{...s,children:(0,K.jsxs)(`form`,{id:`instance-new-table-form`,name:`instance-new-table-form`,onSubmit:s.handleSubmit(l),className:`grid gap-6 text-popover-foreground`,children:[(0,K.jsx)(Y,{control:s.control,name:`tableName`,render:({field:e})=>(0,K.jsxs)(X,{className:``,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Table Name`}),(0,K.jsx)(cy,{...e,type:`text`,maxLength:qI.shape.tableName.maxLength,autoFocus:!0,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:s.control,name:`primaryKey`,render:({field:e})=>(0,K.jsxs)(X,{className:``,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Primary Key`}),(0,K.jsx)(cy,{...e,placeholder:`id`,type:`text`,maxLength:qI.shape.primaryKey.maxLength,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:s.control,name:`databaseName`,render:({field:e})=>(0,K.jsxs)(X,{className:``,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Database Name`}),(0,K.jsx)(cy,{...e,type:`text`,placeholder:`data`,maxLength:qI.shape.databaseName.maxLength,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,children:[(0,K.jsx)(Os,{}),`Create New Table`]})})]})})]})})}async function YI({databaseName:e,replicated:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`drop_database`,database:e,replicated:t});return r}function XI(){return I({mutationFn:YI})}var ZI={};function QI(e,t,n){let r=(0,G.useCallback)((e,n)=>t(e,n),[n]);(0,G.useEffect)(()=>(ZI[e]||(ZI[e]=[]),ZI[e].push(r),function(){let t=ZI[e].indexOf(r);t>=0&&ZI[e].splice(t,1)}),[e,t,r])}function $I(e,t,n){let r=ZI[e];if(r)for(let e of r)e(t,n)}function eL(e,t,n){return r=>$I(e,t,n??r)}function tL(e,t,n){return(0,G.useCallback)(r=>$I(e,t,n??r),[e,t,n])}function nL(e,t){let[n,r]=(0,G.useState)({value:t});return QI(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function rL(e,t,n){$I(e,t,n)}function iL(e,t,n){return r=>rL(e,t,n??r)}function aL(e,t,n){return(0,G.useCallback)(r=>{rL(e,t,n??r)},[e,t,n])}function oL({onDeleted:e}){let{value:t}=nL(`ShowDeleteDatabase`,!1),n=!!t,r=t?t.databaseName:``,i=(0,G.useCallback)(()=>{rL(`ShowDeleteDatabase`,!1)},[]),a=wg(),o=Ze(),s=q(),c=Ee(),{mutate:l,isPending:u}=XI(),d=(0,G.useCallback)(()=>{l({databaseName:r,...s,replicated:s.entityType===`cluster`},{onSuccess:async()=>{i(),await o.invalidateQueries({queryKey:[s.entityId,`describe_all`],refetchType:`all`}),await c.invalidate(),U.success(`Database ${r} dropped successfully`),e({databaseName:r})}})},[i,r,l,s,e,o,c]);return!a||!r?(0,K.jsx)(K.Fragment,{}):(0,K.jsx)(km,{typeOfThingBeingDeleted:`database`,nameOfThingBeingDeleted:r,transitiveVerb:`Drop`,presentParticiple:`Dropping`,isModalOpen:n,setIsModalOpen:i,deletionConfirmed:d,deletionPending:u})}async function sL({databaseName:e,tableName:t,replicated:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`drop_table`,database:e,table:t,replicated:n});return i}function cL(){return I({mutationFn:sL})}function lL({onDeleted:e}){let{value:t}=nL(`ShowDeleteTable`,!1),n=!!t,r=t?t.databaseName:``,i=t?t.tableName:``,a=(0,G.useCallback)(()=>{rL(`ShowDeleteTable`,!1)},[]),o=wg(),s=Ze(),c=q(),l=Ee(),{mutate:u,isPending:d}=cL(),f=(0,G.useCallback)(()=>{u({databaseName:r,tableName:i,...c,replicated:c.entityType===`cluster`},{onSuccess:async()=>{a(),await s.invalidateQueries({queryKey:[c.entityId,`describe_all`],refetchType:`all`}),await l.invalidate(),U.success(`Table ${i} dropped successfully`),e({databaseName:r,tableName:i})}})},[a,r,u,c,e,s,l,i]);return!o||!r?(0,K.jsx)(K.Fragment,{}):(0,K.jsx)(km,{typeOfThingBeingDeleted:`table`,nameOfThingBeingDeleted:`${r} > ${i}`,transitiveVerb:`Drop`,presentParticiple:`Dropping`,isModalOpen:n,setIsModalOpen:a,deletionConfirmed:f,deletionPending:d})}var uL=[`Ada`,`Alan`,`Grace`,`Linus`,`Margaret`,`Dennis`,`Barbara`,`Ken`,`Radia`,`Donald`,`Katherine`,`Edsger`,`Frances`,`John`,`Hedy`],dL=[`Lovelace`,`Turing`,`Hopper`,`Hamilton`,`Ritchie`,`Liskov`,`Thompson`,`Perlman`,`Knuth`,`Johnson`,`Dijkstra`,`Allen`,`Backus`,`Lamarr`,`Shannon`],fL=[`amber`,`birch`,`cedar`,`delta`,`ember`,`fjord`,`grove`,`harbor`,`indigo`,`juniper`,`krypton`,`lagoon`,`meadow`,`nimbus`,`onyx`,`prairie`,`quartz`,`ridge`,`summit`,`tundra`],pL=[`Denver`,`Austin`,`Seattle`,`Boston`,`Chicago`,`Portland`,`Nashville`,`Phoenix`,`Atlanta`],mL=[`USA`,`Canada`,`Germany`,`Japan`,`Brazil`,`Australia`,`France`,`India`,`Spain`],hL=e=>e[Math.floor(Math.random()*e.length)],gL=(e,t)=>e+Math.floor(Math.random()*(t-e+1)),_L=e=>e[0].toUpperCase()+e.slice(1),vL=()=>new Date(Date.now()-gL(0,365)*24*60*60*1e3).toISOString();function yL(e){let t=e.toLowerCase();return/email/.test(t)?`${hL(uL).toLowerCase()}.${hL(dL).toLowerCase()}@example.com`:/phone/.test(t)?`555-${gL(100,999)}-${gL(1e3,9999)}`:/(^|_)(url|link|website)($|_)/.test(t)?`https://example.com/${hL(fL)}`:/name/.test(t)?/(first|given)/.test(t)?hL(uL):/(last|family|sur)/.test(t)?hL(dL):`${hL(uL)} ${hL(dL)}`:/age/.test(t)?gL(1,90):/year/.test(t)?gL(1970,2026):/(price|cost|amount|total|salary)/.test(t)?Number((Math.random()*500).toFixed(2)):/(count|qty|quantity|weight|height|size|pages|score|rating|number|num_)/.test(t)?gL(0,500):/(^is_|^has_|enabled|active|flag|adorable|verified)/.test(t)?Math.random()<.5:/(date|time|_at$|created|updated)/.test(t)?vL():/city/.test(t)?hL(pL):/country/.test(t)?hL(mL):/(description|notes|comment|bio|summary)/.test(t)?`A ${hL(fL)} ${hL(fL)} with a hint of ${hL(fL)}.`:`${_L(hL(fL))} ${_L(hL(fL))}`}function bL(e){switch(e.type){case`ID`:return crypto.randomUUID();case`Int`:case`Long`:case`BigInt`:{let t=yL(e.attribute);return typeof t==`number`?Math.round(t):gL(0,1e3)}case`Float`:{let t=yL(e.attribute);return typeof t==`number`?t:Number((Math.random()*1e3).toFixed(2))}case`Boolean`:return Math.random()<.5;case`Date`:return vL();case`String`:{let t=yL(e.attribute);return typeof t==`string`?t:String(t)}case`array`:return e.elements?Array.from({length:gL(1,3)},()=>bL({attribute:e.attribute,type:e.elements})):[];default:return yL(e.attribute)}}function xL(e,t,n){return(e??[]).filter(e=>!e.is_primary_key&&e.attribute!==`__createdtime__`&&e.attribute!==`__updatedtime__`&&e.type!==`Bytes`&&e.type!==`Blob`&&!HF(e,t,n))}function SL(e,t){let n=xL(e);return Array.from({length:t},()=>{let e={};for(let t of n)e[t.attribute]=bL(t);return e})}function CL(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${Math.round(e)} ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${String(r).padStart(2,`0`)}m`:r>0?`${r}m ${String(i).padStart(2,`0`)}s`:`${i}s`}var wL=`Importing data…`;function TL(e,t){return`${e.status?.toUpperCase()===`CREATED`?`Queued`:`Running`} · ${CL(t)} · job ${e.id}`}function EL(e=Date.now){let t=e(),n;return{onJobUpdate(r){n=U.loading(wL,{id:n,description:TL(r,e()-t)})},onSuccess({message:e}){U.success(e,{id:n,description:void 0})},onError(){n!==void 0&&U.dismiss(n)}}}function DL(e){let t;try{t=JSON.parse(e)}catch{throw Error(`The file is not valid JSON.`)}let n=Array.isArray(t)?t:[t];if(n.length===0)throw Error(`The JSON file contains no records.`);if(n.some(e=>typeof e!=`object`||!e||Array.isArray(e)))throw Error(`The JSON file must contain an object or an array of objects.`);return n}var OL=[{id:`dogs`,name:`Dogs`,description:`The classic Harper demo — dogs and their humans`,table:`dog`,csv:`id,dog_name,owner_name,breed,age,weight_lbs,adorable
|
|
710
|
+
1,Penny,Kyle,Dachshund,7,12,true
|
|
711
|
+
2,Harper,Stephen,Great Dane,5,127,true
|
|
712
|
+
3,Alby,Kaylan,Pit Bull Mix,8,58,true
|
|
713
|
+
4,Billy,Zach,Labrador Retriever,6,64,true
|
|
714
|
+
5,Rose Merry,Zach,Beagle Mix,9,31,true
|
|
715
|
+
6,Kato,Kyle,German Shepherd,4,74,true
|
|
716
|
+
7,Simon,Fred,Corgi,3,26,true
|
|
717
|
+
8,Gemma,Stephen,Boxer Mix,5,55,true
|
|
718
|
+
9,Yeti,Jaxon,Great Pyrenees,2,89,true
|
|
719
|
+
10,Monkey,Aron,Shiba Inu,7,21,true
|
|
720
|
+
11,Bode,Margo,Bernese Mountain Dog,8,91,true
|
|
721
|
+
12,Tucker,David,Golden Retriever,2,60,true
|
|
722
|
+
13,Jagger,Margo,Australian Shepherd,4,49,true
|
|
723
|
+
14,Frankie,Alex,French Bulldog,3,24,true
|
|
724
|
+
15,Winnie,Sam,Cavalier King Charles Spaniel,6,17,true
|
|
725
|
+
`},{id:`books`,name:`Books`,description:`Classic literature with authors, genres, and ratings`,table:`book`,csv:`id,title,author,year,genre,pages,rating
|
|
726
|
+
1,Pride and Prejudice,Jane Austen,1813,Romance,432,4.6
|
|
727
|
+
2,Moby-Dick,Herman Melville,1851,Adventure,635,3.9
|
|
728
|
+
3,Great Expectations,Charles Dickens,1861,Coming-of-age,544,4.1
|
|
729
|
+
4,Middlemarch,George Eliot,1871,Realist,880,4.2
|
|
730
|
+
5,Anna Karenina,Leo Tolstoy,1878,Realist,864,4.5
|
|
731
|
+
6,The Adventures of Huckleberry Finn,Mark Twain,1884,Adventure,366,4.0
|
|
732
|
+
7,The Picture of Dorian Gray,Oscar Wilde,1890,Gothic,254,4.3
|
|
733
|
+
8,Dracula,Bram Stoker,1897,Gothic,418,4.1
|
|
734
|
+
9,Heart of Darkness,Joseph Conrad,1899,Novella,96,3.8
|
|
735
|
+
10,The Call of the Wild,Jack London,1903,Adventure,232,4.0
|
|
736
|
+
11,A Room with a View,E. M. Forster,1908,Romance,256,4.0
|
|
737
|
+
12,Ethan Frome,Edith Wharton,1911,Tragedy,128,3.9
|
|
738
|
+
13,My Antonia,Willa Cather,1918,Historical,272,4.1
|
|
739
|
+
14,Ulysses,James Joyce,1922,Modernist,730,3.7
|
|
740
|
+
15,The Great Gatsby,F. Scott Fitzgerald,1925,Tragedy,180,4.4
|
|
741
|
+
16,Mrs Dalloway,Virginia Woolf,1925,Modernist,194,3.9
|
|
742
|
+
17,The Sun Also Rises,Ernest Hemingway,1926,Modernist,251,4.0
|
|
743
|
+
18,All Quiet on the Western Front,Erich Maria Remarque,1929,War,296,4.5
|
|
744
|
+
19,Brave New World,Aldous Huxley,1932,Dystopian,311,4.2
|
|
745
|
+
20,Their Eyes Were Watching God,Zora Neale Hurston,1937,Southern,219,4.3
|
|
746
|
+
21,Of Mice and Men,John Steinbeck,1937,Tragedy,107,4.2
|
|
747
|
+
22,The Grapes of Wrath,John Steinbeck,1939,Historical,464,4.4
|
|
748
|
+
23,The Stranger,Albert Camus,1942,Philosophical,123,4.0
|
|
749
|
+
24,Animal Farm,George Orwell,1945,Satire,112,4.3
|
|
750
|
+
25,1984,George Orwell,1949,Dystopian,328,4.6
|
|
751
|
+
26,The Catcher in the Rye,J. D. Salinger,1951,Coming-of-age,277,3.9
|
|
752
|
+
27,Invisible Man,Ralph Ellison,1952,Social,581,4.3
|
|
753
|
+
28,East of Eden,John Steinbeck,1952,Family saga,601,4.6
|
|
754
|
+
29,Fahrenheit 451,Ray Bradbury,1953,Dystopian,194,4.1
|
|
755
|
+
30,Lord of the Flies,William Golding,1954,Allegory,224,3.9
|
|
756
|
+
31,Doctor Zhivago,Boris Pasternak,1957,Historical,592,4.2
|
|
757
|
+
32,Things Fall Apart,Chinua Achebe,1958,Historical,209,4.2
|
|
758
|
+
33,To Kill a Mockingbird,Harper Lee,1960,Southern,281,4.7
|
|
759
|
+
34,Catch-22,Joseph Heller,1961,Satire,453,4.1
|
|
760
|
+
35,A Wrinkle in Time,Madeleine L'Engle,1962,Science fiction,256,4.0
|
|
761
|
+
36,One Hundred Years of Solitude,Gabriel Garcia Marquez,1967,Magical realism,417,4.5
|
|
762
|
+
37,Slaughterhouse-Five,Kurt Vonnegut,1969,Satire,275,4.2
|
|
763
|
+
38,Beloved,Toni Morrison,1987,Historical,324,4.3
|
|
764
|
+
39,The Remains of the Day,Kazuo Ishiguro,1989,Historical,258,4.4
|
|
765
|
+
40,The Road,Cormac McCarthy,2006,Post-apocalyptic,287,4.2
|
|
766
|
+
`},{id:`animals`,name:`Animals`,description:`Animal species with class, diet, and habitat data`,table:`animal`,csv:`id,name,class,diet,habitat,avg_lifespan_years,endangered
|
|
767
|
+
1,African Elephant,Mammal,Herbivore,Savanna,60,true
|
|
768
|
+
2,Blue Whale,Mammal,Carnivore,Ocean,85,true
|
|
769
|
+
3,Giant Panda,Mammal,Herbivore,Temperate forest,20,false
|
|
770
|
+
4,Snow Leopard,Mammal,Carnivore,Alpine mountains,15,true
|
|
771
|
+
5,Red Kangaroo,Mammal,Herbivore,Grassland,22,false
|
|
772
|
+
6,Gray Wolf,Mammal,Carnivore,Forest,13,false
|
|
773
|
+
7,Polar Bear,Mammal,Carnivore,Arctic sea ice,25,true
|
|
774
|
+
8,Chimpanzee,Mammal,Omnivore,Tropical forest,40,true
|
|
775
|
+
9,Giraffe,Mammal,Herbivore,Savanna,25,false
|
|
776
|
+
10,Bottlenose Dolphin,Mammal,Carnivore,Ocean,45,false
|
|
777
|
+
11,Bald Eagle,Bird,Carnivore,Coastal forest,20,false
|
|
778
|
+
12,Emperor Penguin,Bird,Carnivore,Antarctic coast,20,false
|
|
779
|
+
13,Peregrine Falcon,Bird,Carnivore,Cliffs and cities,15,false
|
|
780
|
+
14,Scarlet Macaw,Bird,Omnivore,Tropical forest,50,false
|
|
781
|
+
15,Common Ostrich,Bird,Omnivore,Savanna,40,false
|
|
782
|
+
16,Snowy Owl,Bird,Carnivore,Arctic tundra,10,false
|
|
783
|
+
17,Ruby-throated Hummingbird,Bird,Omnivore,Woodland,5,false
|
|
784
|
+
18,Kakapo,Bird,Herbivore,Island forest,60,true
|
|
785
|
+
19,Komodo Dragon,Reptile,Carnivore,Island scrubland,30,true
|
|
786
|
+
20,Green Sea Turtle,Reptile,Herbivore,Ocean,70,true
|
|
787
|
+
21,American Alligator,Reptile,Carnivore,Freshwater wetland,50,false
|
|
788
|
+
22,King Cobra,Reptile,Carnivore,Tropical forest,20,false
|
|
789
|
+
23,Galapagos Tortoise,Reptile,Herbivore,Island grassland,100,true
|
|
790
|
+
24,Chameleon,Reptile,Carnivore,Tropical forest,8,false
|
|
791
|
+
25,Poison Dart Frog,Amphibian,Carnivore,Rainforest floor,10,false
|
|
792
|
+
26,Axolotl,Amphibian,Carnivore,Freshwater lake,15,true
|
|
793
|
+
27,American Bullfrog,Amphibian,Carnivore,Pond,9,false
|
|
794
|
+
28,Fire Salamander,Amphibian,Carnivore,Deciduous forest,24,false
|
|
795
|
+
29,Great White Shark,Fish,Carnivore,Ocean,70,true
|
|
796
|
+
30,Clownfish,Fish,Omnivore,Coral reef,10,false
|
|
797
|
+
31,Atlantic Salmon,Fish,Carnivore,Ocean and rivers,8,false
|
|
798
|
+
32,Seahorse,Fish,Carnivore,Seagrass beds,4,false
|
|
799
|
+
33,Whale Shark,Fish,Carnivore,Ocean,80,true
|
|
800
|
+
34,Monarch Butterfly,Insect,Herbivore,Meadow,1,true
|
|
801
|
+
35,Honey Bee,Insect,Herbivore,Meadow,1,false
|
|
802
|
+
36,Atlas Moth,Insect,Herbivore,Tropical forest,1,false
|
|
803
|
+
37,Ladybug,Insect,Carnivore,Garden,1,false
|
|
804
|
+
38,Giant Pacific Octopus,Invertebrate,Carnivore,Ocean,4,false
|
|
805
|
+
39,Christmas Island Red Crab,Invertebrate,Omnivore,Island forest,30,false
|
|
806
|
+
40,Chambered Nautilus,Invertebrate,Carnivore,Deep ocean,20,true
|
|
807
|
+
`}];async function kL(e){let{database:t,table:n,fileData:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`csv_data_load`,database:t,action:`insert`,table:n,data:r});return a}function AL(e,t,n){return[e,`search_by_id`,t,n]}function jL({enabled:e,entityId:t,instanceClient:n,databaseName:r,tableName:i,ids:a}){let o=a?.filter(e=>e!=null)??null;return B({queryKey:[t,`search_by_id`,r,i,o],queryFn:()=>n.post(`/`,{get_attributes:[`*`],ids:o,noCacheStore:!0,onlyIfCached:!1,operation:`search_by_id`,database:r,table:i}),enabled:e&&!!o?.length,retry:!1})}function ML(e){let t=e?.response?.data;return typeof t==`string`?t:t?.error||t?.message||e?.message||String(e)}async function NL({database:e,table:t,tableExists:n,replicated:r,source:i,instanceClient:a,progress:o}){let s=e=>o?.onJobUpdate(e);if(!n)try{await a.post(`/`,{operation:`create_table`,database:e,table:t,primary_key:`id`,replicated:r})}catch(e){if(!/already exists/i.test(ML(e)))throw e}switch(i.kind){case`csv-data`:{let{job_id:n}=await kL({database:e,table:t,fileData:i.data,instanceClient:a}),r=await QD({jobId:n,instanceClient:a,onUpdate:s});return{message:pr(r.message)??`CSV data imported successfully`}}case`csv-url`:{let{data:n}=await a.post(`/`,{operation:`csv_url_load`,csv_url:i.url,database:e,table:t,action:`insert`}),r=await QD({jobId:n.job_id,instanceClient:a,onUpdate:s});return{message:pr(r.message)??`CSV data imported successfully`}}case`json-records`:{let n=await qF({databaseName:e,tableName:t,records:i.records,instanceClient:a}),r=n.inserted_hashes?.length??0,o=n.skipped_hashes?.length??0;return{message:o?`Inserted ${r} records (${o} skipped)`:`Inserted ${r} records`}}}}function PL(e,t){try{t()}catch(t){console.debug(`${e} failed`,t)}}function FL(e,{entityId:t,database:n,table:r}){e.invalidateQueries({queryKey:[t,n,r]}),e.invalidateQueries({queryKey:AL(t,n,r)}),e.invalidateQueries({queryKey:[t,`describe_all`],refetchType:`all`})}function IL(e,t){return e.invalidateQueries({queryKey:[t,`describe_all`],refetchType:`all`},{cancelRefetch:!1})}function LL(){let e=Ze();return I({mutationFn:NL,onSuccess:(e,{progress:t})=>PL(`Import progress listener`,()=>t?.onSuccess(e)),onError:(e,{progress:t})=>PL(`Import progress listener`,()=>t?.onError()),onSettled:(t,n,r)=>PL(`Refreshing the imported table`,()=>FL(e,r))})}var RL=`__random__`,zL=10485760,BL=b({method:j([`sample`,`file`,`url`]),database:GI,table:KI,datasetId:x(),rowCount:x(),fileData:x(),fileName:x(),url:x()}).superRefine((e,t)=>{if(e.method===`sample`&&!e.datasetId&&t.addIssue({code:`custom`,path:[`datasetId`],message:`Please choose a sample dataset.`}),e.method===`sample`&&e.datasetId===`__random__`){let n=Number(e.rowCount);(!Number.isInteger(n)||n<1||n>1e3)&&t.addIssue({code:`custom`,path:[`rowCount`],message:`Enter a row count between 1 and 1000.`})}if(e.method===`file`&&!e.fileData&&t.addIssue({code:`custom`,path:[`fileData`],message:`Please choose a CSV or JSON file.`}),e.method===`url`){let n=!1;try{n=/^https?:$/.test(new URL(e.url).protocol)}catch{}n||t.addIssue({code:`custom`,path:[`url`],message:`Please enter a valid http(s) URL to a CSV file.`})}}),VL=[{value:`sample`,title:`Sample Datasets`,description:`Choose from pre-loaded sample datasets to get started quickly`,Icon:Fo},{value:`file`,title:`Import from File`,description:`Upload a CSV or JSON file`,Icon:va},{value:`url`,title:`Load from URL`,description:`Import a CSV file from a URL the instance can reach`,Icon:Aa}];function HL({isModalOpen:e,setIsModalOpen:t,instanceDatabaseMap:n,schemaRelationshipMap:r,databaseName:i,tableName:a,initialMethod:o,onImported:s}){let c=q(),{mutate:l,isPending:u}=LL(),[d,f]=(0,G.useState)(null),p=kg(),m=(0,G.useMemo)(()=>VL.filter(({value:e})=>p.methods[e]),[p]),h=o??(a?`file`:`sample`),g=p.methods[h]?h:m[0]?.value??h,_=on({resolver:mt(BL),defaultValues:{method:g,database:i||``,table:a||``,datasetId:``,rowCount:`25`,fileData:``,fileName:``,url:``}}),{reset:v}=_;(0,G.useEffect)(()=>{e&&(v({method:g,database:i||``,table:a||``,datasetId:``,rowCount:`25`,fileData:``,fileName:``,url:``}),f(null))},[e,i,a,g,v]);let y=_.watch(`method`),b=_.watch(`datasetId`),x=_.watch(`database`),S=_.watch(`table`),C=OL.find(e=>e.id===b),w=n?.[x||`data`]?.[S],T=!!w,E=!!n&&!!S&&!T,D=xL(w?.attributes,n?.[x||`data`],r?.[x||`data`]?.[S]),O=D.length>0,k=b===RL,A=e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>10485760){let n=(t.size/1048576).toFixed(1),r=zL/1048576;_.setError(`fileData`,{message:`That file is ${n} MB — uploads are limited to ${r} MB. For larger files, host the CSV and use Load from URL.`}),e.target.value=``;return}let n=new FileReader;n.onload=e=>{let n=e.target?.result;typeof n==`string`&&(f(t.name),_.setValue(`fileData`,n,{shouldValidate:!0}),_.setValue(`fileName`,t.name))},n.onerror=()=>{U.error(`Failed to read the selected file.`)},n.readAsText(t)},j=e=>{_.setValue(`datasetId`,e,{shouldValidate:!0});let t=OL.find(t=>t.id===e);t&&_.setValue(`table`,t.table,{shouldValidate:!0})},M=()=>{t(!1)},ee=e=>{let t=e.database||`data`,i=e.table,a;if(e.method===`sample`&&e.datasetId===`__random__`){let o=xL(n?.[t]?.[i]?.attributes,n?.[t],r?.[t]?.[i]);if(o.length===0){_.setError(`datasetId`,{message:`Random data needs an existing table with columns — pick a table that has some.`});return}a={kind:`json-records`,records:SL(o,Number(e.rowCount))}}else if(e.method===`sample`){let t=OL.find(t=>t.id===e.datasetId);if(!t)return;a={kind:`csv-data`,data:t.csv}}else if(e.method===`file`){if(e.fileName.toLowerCase().endsWith(`.json`))try{a={kind:`json-records`,records:DL(e.fileData)}}catch(e){_.setError(`fileData`,{message:e.message});return}else a={kind:`csv-data`,data:e.fileData}}else a={kind:`csv-url`,url:e.url};if(T&&!p.allowsDestination(t,i)){_.setError(`table`,{message:`This role cannot insert into "${i}".`});return}if(!p.allowsSource(a.kind)){_.setError(`method`,{message:a.kind===`json-records`?`This role cannot insert records. Choose a CSV source instead.`:`This role cannot run CSV loads. Choose a JSON file or random sample data instead.`});return}l({database:t,table:i,tableExists:T,replicated:c.entityType===`cluster`,source:a,progress:EL(),...c},{onSuccess:()=>{M(),s(t,i)}})};return(0,K.jsx)(_m,{open:e,onOpenChange:e=>{!e&&!u&&M()},children:(0,K.jsxs)(wm,{className:`sm:max-w-[550px]`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Import Data`}),(0,K.jsx)(Om,{children:`Choose how you want to import data into your database.`})]}),(0,K.jsx)(Od,{..._,children:(0,K.jsxs)(`form`,{id:`instance-import-data-form`,name:`instance-import-data-form`,onSubmit:_.handleSubmit(ee),className:`grid gap-4`,children:[(0,K.jsx)(Y,{control:_.control,name:`method`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Select Import Method`}),(0,K.jsx)(J,{children:(0,K.jsx)(mj,{value:e.value,onValueChange:e.onChange,className:`gap-3`,children:m.map(({value:e,title:t,description:n,Icon:r})=>(0,K.jsxs)(Z,{htmlFor:`import-method-${e}`,className:`flex items-start gap-3 rounded-lg border border-border p-4 cursor-pointer font-normal hover:bg-accent/50 has-[[data-state=checked]]:border-primary`,children:[(0,K.jsx)(hj,{value:e,id:`import-method-${e}`,className:`mt-1`}),(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,K.jsx)(r,{className:`size-4`}),t]}),(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:n})]})]},e))})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(xD,{}),y===`sample`&&(0,K.jsx)(Y,{control:_.control,name:`datasetId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Choose a Sample Dataset`}),(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{name:e.name,value:e.value,onValueChange:j,children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Select a dataset...`})}),(0,K.jsxs)(yy,{children:[p.allowsSource(`csv-data`)&&(0,K.jsx)(gy,{children:OL.map(e=>(0,K.jsx)(xy,{value:e.id,children:e.name},e.id))}),O&&p.allowsSource(`json-records`)&&(0,K.jsxs)(gy,{children:[(0,K.jsx)(by,{children:`This table`}),(0,K.jsx)(xy,{value:`__random__`,children:`Random Data`})]})]})]})}),C&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:C.description}),k&&(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Generates rows for "`,S,`" based on its `,D.length,` `,`column`,D.length===1?``:`s`,` and their data types.`]}),(0,K.jsx)(Q,{})]})}),y===`sample`&&k&&(0,K.jsx)(Y,{control:_.control,name:`rowCount`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Number of Rows`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`number`,min:1,max:1e3,inputMode:`numeric`,autoComplete:`off`})}),(0,K.jsx)(Q,{})]})}),y===`file`&&(0,K.jsx)(Y,{control:_.control,name:`fileData`,render:({field:e})=>(0,K.jsxs)(X,{className:`relative`,children:[(0,K.jsx)(Z,{htmlFor:`import-data-file`,className:`flex flex-col items-center justify-center w-full h-40 border-2 border-border border-dashed rounded-lg cursor-pointer bg-muted dark:bg-grey-700 hover:bg-muted/80 dark:hover:bg-grey-700/80`,children:(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center pt-5 pb-6`,children:[(0,K.jsx)(Ji,{className:`text-muted-foreground`,size:40}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:d??(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:`Click to upload`}),` `,`or drag and drop a CSV or JSON file`]})})]}),(0,K.jsx)($,{id:`import-data-file`,type:`file`,className:`opacity-0 w-full h-full absolute left-0 top-0 cursor-pointer`,accept:`.csv,.json,text/csv,application/json`,name:e.name,ref:e.ref,onBlur:e.onBlur,disabled:e.disabled,onChange:A})]})})}),(0,K.jsx)(Q,{})]})}),y===`url`&&(0,K.jsx)(Y,{control:_.control,name:`url`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`CSV URL`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`text`,inputMode:`url`,placeholder:`https://example.com/data.csv`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`})}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The URL is fetched by the Harper instance, so it must be reachable from there.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:_.control,name:`database`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Database`}),(0,K.jsx)(cy,{...e,type:`text`,placeholder:`data`,maxLength:BL.shape.database.maxLength,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:_.control,name:`table`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Table`}),(0,K.jsx)(cy,{...e,type:`text`,maxLength:BL.shape.table.maxLength,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`}),(0,K.jsx)(Q,{})]})})]}),E&&(0,K.jsxs)(c_,{children:[(0,K.jsx)(Ba,{}),(0,K.jsx)(l_,{children:`New table`}),(0,K.jsxs)(u_,{children:[`The table "`,S,`" doesn't exist yet — it will be created with primary key "id" before the data is imported.`]})]}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,onClick:M,disabled:u,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:u,children:[u?(0,K.jsx)(no,{className:`animate-spin`}):(0,K.jsx)(Ji,{}),u?`Importing...`:`Import Data`]})]})]})})]})})}async function UL({databaseName:e,tableName:t,instanceClient:n,includeComputed:r}){let{data:i}=await n.post(`/`,{operation:`describe_table`,database:e,table:t,exact_count:!1,include_computed:r||void 0});return i}function WL(e){return B({queryKey:[e.entityId,e.databaseName,e.tableName,`describe_table`],queryFn:()=>UL({...e,includeComputed:!0}),staleTime:6e4,gcTime:5e3,enabled:!!e.databaseName&&!!e.tableName,retry:!1})}function GL({instanceDatabaseMap:e}){let t=z({strict:!1}),n=De(),r=Ee(),i=Ze(),a=q(),o=(0,G.useCallback)((e,r)=>{n({to:jP({...t,databaseName:e,tableName:r})})},[n,t]),{value:s}=nL(`ShowCreateTable`,!1),{value:c}=nL(`ShowAddTableRecords`,!1),{value:l}=nL(`ShowImportData`,!1),{data:u}=L(PF({...a,enabled:!!c||!!l})),d=c?e?.[c.databaseName]?.[c.tableName]:void 0,[f,p]=(0,G.useState)(),m=d??(c&&f?.target===c?f.table:void 0);(0,G.useEffect)(()=>{if(!c||d)return;let{databaseName:e,tableName:t}=c,n=!0,r=U.loading(`Opening "${t}"…`);return UL({...a,databaseName:e,tableName:t,includeComputed:!0}).then(e=>{n&&(U.dismiss(r),p({target:c,table:e}))},e=>{n&&(U.dismiss(r),U.error(`Couldn't open "${t}"`,{description:fc(e).message}),rL(`ShowAddTableRecords`,!1))}),()=>{n=!1,U.dismiss(r)}},[c,d,a]);let h=(0,G.useCallback)(async(e,t)=>{await IL(i,a.entityId),o(e,t),await r.invalidate()},[i,a.entityId,o,r]),g=(0,G.useCallback)(({databaseName:e,tableName:n})=>{t.databaseName===e&&t.tableName===n&&o(e,void 0)},[t.databaseName,t.tableName,o]),_=(0,G.useCallback)(({databaseName:e})=>{t.databaseName===e&&o(void 0,void 0)},[t.databaseName,o]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(JI,{isModalOpen:!!s,setIsModalOpen:e=>rL(`ShowCreateTable`,e?s||{}:!1),databaseName:s?s.databaseName:void 0,onCreated:o},s?`create-${s.databaseName??``}`:`create-closed`),c&&m&&(0,K.jsx)(BI,{instanceTable:m,databaseTables:e?.[c.databaseName],schemaRelationships:u?.[c.databaseName]?.[c.tableName],isModalOpen:!0,setIsModalOpen:e=>{e||rL(`ShowAddTableRecords`,!1)},refreshTable:()=>void i.invalidateQueries({queryKey:[a.entityId,c.databaseName,c.tableName]})},`add-${c.databaseName}/${c.tableName}`),(0,K.jsx)(HL,{isModalOpen:!!l,setIsModalOpen:e=>rL(`ShowImportData`,e?l||{}:!1),instanceDatabaseMap:e,schemaRelationshipMap:u,databaseName:l?l.databaseName:void 0,tableName:l?l.tableName:void 0,initialMethod:l?l.method:void 0,onImported:h},l?`import-${l.databaseName??``}/${l.tableName??``}/${l.method??``}`:`import-closed`),(0,K.jsx)(lL,{onDeleted:g}),(0,K.jsx)(oL,{onDeleted:_})]})}function KL(e){e.stopPropagation()}var qL=3,JL=`text-blue dark:text-blue-300 border-blue/40 dark:border-blue-300/40 [a&]:hover:bg-blue/10 [a&]:hover:underline`;function YL(e,t){return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>typeof e==`object`&&e?e[t.relatedPrimaryKey]:e).filter(e=>e!=null)}function XL({value:e,record:t,primaryKey:n,info:r}){let i=z({strict:!1}),a=n?t?.[n]:void 0,o=YL(e,r);!o.length&&r.foreignKeyAttribute&&t&&(o=YL(t[r.foreignKeyAttribute],r));let s=jP({...i,tableName:r.relatedTableName}),c=r.reverseForeignKey&&a!=null?{filters:{[r.reverseForeignKey]:String(a)}}:void 0;if(!o.length)return c?(0,K.jsx)(ol,{variant:`outline`,className:JL,asChild:!0,children:(0,K.jsxs)(V,{to:s,search:c,onClick:KL,title:`${r.relatedTableName} where ${r.reverseForeignKey} = ${String(a)}`,children:[r.relatedTableName,` →`]})}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let l=o.length-qL;return(0,K.jsxs)(`span`,{className:`inline-flex gap-1 items-center`,children:[o.slice(0,qL).map((e,t)=>(0,K.jsx)(ol,{variant:`outline`,className:JL,asChild:!0,children:(0,K.jsx)(V,{to:s,search:{filters:{[r.relatedPrimaryKey]:String(e)}},onClick:KL,title:`${r.relatedTableName} where ${r.relatedPrimaryKey} = ${String(e)}`,children:String(e)})},t)),l>0&&(c?(0,K.jsxs)(V,{to:s,search:c,onClick:KL,className:`text-blue dark:text-blue-300 hover:underline text-xs whitespace-nowrap`,title:`${r.relatedTableName} where ${r.reverseForeignKey} = ${String(a)}`,children:[`+`,l,` more`]}):(0,K.jsxs)(`span`,{className:`text-muted-foreground text-xs whitespace-nowrap`,children:[`+`,l,` more`]}))]})}var ZL={text:[`Jo* starts with`,`*hn ends with`,`*oh* contains`,`== Jo* exactly, star and all`,`!= Jo not equal`,`a & b both`],number:[`5 equals`,`>5 >=5 <5 <=5`,`!= 5 not equal`,`>1 & <9 both`],date:[`2026-01-31 equals`,`>2026-01-01 <=2026-12-31`,`>2026-01-01 & <2026-02-01 both`],boolean:[`true or false`,`!= true not equal`]},QL=new Set([`Int`,`Long`,`Float`,`BigInt`]);function $L(e){return QL.has(e??``)?`number`:e===`Date`?`date`:e===`Boolean`?`boolean`:`text`}var eR=`Not indexed: a filter on this alone reads every record, so you are asked first.`,tR=`!= reads every record unless another filter uses an index.`,nR={text:`Ends with, contains and != read every record unless another filter uses an index.`,number:tR,date:tR,boolean:tR},rR=e=>({indexed:[...ZL[e],nR[e]].join(`
|
|
808
|
+
`),unindexed:[...ZL[e],eR].join(`
|
|
809
|
+
`)}),iR={text:rR(`text`),number:rR(`number`),date:rR(`date`),boolean:rR(`boolean`)};function aR(e,t){let n=iR[$L(e)];return t?n.unindexed:n.indexed}var oR=new Set([`Blob`,`Bytes`]);function sR(e,t={},n=[]){if(!e)return{dataTableColumns:[],primaryKey:``};let r=cR(e),{attributes:i}=e,a=[],o=[],s=[],c=[],l=[],u=e=>t=>(0,G.createElement)(XL,{value:t.getValue(),record:t.row.original,primaryKey:r,info:e});for(let e=i.length-1;e>=0;e--){let{attribute:n,type:r,is_primary_key:c,indexed:d}=i[e],f=Object.hasOwn(t,n)?t[n]:void 0,p=!!(c||d),m=!f&&!p&&!oR.has(r??``),h=!f&&(p||m),g={header:n,accessorKey:n,enableSorting:p,enableColumnFilter:h||!!f,size:dR(r),cell:f?u(f):uR,meta:f?{relationshipInfo:f}:h?{filterHint:aR(r,m),unindexed:m||void 0}:void 0};c?a.push(g):lR(n)?l.push(g):g.enableSorting?o.push(g):s.push(g)}let d=new Set(i.map(e=>e.attribute));for(let[e,n]of Object.entries(t))d.has(e)||s.push({header:e,accessorKey:e,enableSorting:!1,enableColumnFilter:!0,size:dR(`String`),cell:u(n),meta:{relationshipInfo:n}});for(let{attribute:e,type:r}of n)d.has(e)||Object.hasOwn(t,e)||(lR(e)?l:c).push({id:e,header:e,accessorFn:t=>Object.hasOwn(t,e)?t[e]:void 0,enableSorting:!1,enableColumnFilter:!1,size:dR(r),cell:uR});return{dataTableColumns:[...a,...o,...s,...c,...l],primaryKey:r}}function cR(e){return e?.primary_key??e?.hash_attribute??``}function lR(e){return e===`__createdtime__`||e===`__updatedtime__`}function uR(e){let t=e.getValue();return t==null?null:typeof t==`object`?JSON.stringify(t):String(t)}function dR(e){switch(e){case`Id`:case`ID`:return 220;case`Boolean`:return 90;case`Int`:case`Long`:case`Float`:case`BigInt`:return 120;case`Date`:return 190;default:return 200}}function fR(e,t,n=25){let r=new Map;for(let n of e)for(let e of Object.keys(n)){if(t.has(e))continue;let i=r.get(e);i?(i.count++,i.sample??=n[e]):r.set(e,{count:1,sample:n[e]})}let i=[];for(let[e,{count:t}]of r)(i[t]??=[]).push(e);let a=[];for(let e=i.length-1;e>0&&a.length<n;e--){let t=i[e];if(t)for(let e of t){if(a.length===n)break;a.push({attribute:e,type:mR(r.get(e).sample)})}}return a}function pR(e,t){return e===t||e.length===t.length&&e.every((e,n)=>e.attribute===t[n].attribute&&e.type===t[n].type)}function mR(e){switch(typeof e){case`number`:return Number.isInteger(e)?`Int`:`Float`;case`boolean`:return`Boolean`;case`string`:return`String`;default:return`Any`}}function hR(e){let t=(e?.attributes??[]).filter(e=>e.computed).map(e=>e.attribute);return t.length?[...t,`*`]:void 0}function gR(e,t,n,r){let i=t?.attributes??[],a=i.filter(e=>e.computed||!HF(e,n,r)).map(e=>e.attribute),o=fR(e,new Set([...i.map(e=>e.attribute),...(r??[]).map(e=>e.attribute)]),1/0).map(({attribute:e})=>e);return[...a,...o]}var _R=1e4,vR=1<<24,yR=Object.freeze({});function bR(e,t){let n=[new Blob([t.map(e=>SR(e,!0)).join(`,`)+`
|
|
810
|
+
`])],r=``,i=0;for(let a=0;a<e.length;a++){r+=xR(e[a],t);let o=a+1;(o-i===_R||r.length>=vR||o===e.length)&&(n.push(new Blob([r])),e.fill(yR,i,o),i=o,r=``)}return e.length=0,new Blob(n,{type:`text/csv`})}function xR(e,t){let n=``;for(let r=0;r<t.length;r++){let i=t[r];n+=(r?`,`:``)+SR(Object.hasOwn(e,i)?e[i]:void 0,!1)}return n+`
|
|
811
|
+
`}function SR(e,t){return e==null||e===``?``:typeof e==`number`&&!t?String(e):`"${(typeof e==`object`?JSON.stringify(e):String(e)).replace(/"/g,`""`)}"`}function CR(e){let t=typeof e==`string`?ER(e):e;if(!Array.isArray(t))throw Error(`The export did not come back as a list of records.`);return t}var wR=/[[,:]\s*-?\d{16,}/,TR=/^-?\d+$/;function ER(e){return JSON.parse(wR.test(e)?DR(e):e)}function DR(e){let t=``,n=0,r=!1;for(let i=0;i<e.length;i++){let a=e.charCodeAt(i);if(r)a===kR?i++:a===OR&&(r=!1);else if(a===OR)r=!0;else if(a===AR||FR(a)){let r=i+1;for(;r<e.length&&IR(e.charCodeAt(r));)r++;if(r-i>=16){let a=e.slice(i,r);TR.test(a)&&String(Number(a))!==a&&(t+=`${e.slice(n,i)}"${a}"`,n=r)}i=r-1}}return n?t+e.slice(n):e}var OR=34,kR=92,AR=45,jR=43,MR=46,NR=101,PR=69;function FR(e){return e>=48&&e<=57}function IR(e){return FR(e)||e===MR||e===jR||e===AR||e===NR||e===PR}var LR=[`1`,`bet`,`k`,`ok`,`si`,`tru`,`true`,`yes`,`yup`];function RR(e){let t=e.toLowerCase().trim();return LR.includes(t)}function zR(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function BR(e){if(e.startsWith(`0.`)&&zR(e))return!0;let t=e.toUpperCase().includes(`E`);return!(e!==`0`&&e.startsWith(`0`))&&!t&&zR(e)}var VR={true:!0,TRUE:!0,false:!1,FALSE:!1,undefined:null,null:null,NULL:null,NaN:NaN},HR=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/;function UR(e){return e==null||e===``||typeof e!=`string`?e:VR[e]===void 0?BR(e)?Number(e):HR.test(e)?new Date(e):e:VR[e]}function WR(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,conditions:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return B({enabled:t&&!!a,queryKey:[n,r,i,`search_by_conditions`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l,u??null],staleTime:6e4,gcTime:5e3,retry:!1,queryFn:()=>GR(e)})}async function GR(e){let{data:t}=await KR({...e,limit:e.pageSize+1});return{data:t.slice(0,e.pageSize),hasNextPage:t.length>e.pageSize}}function KR({instanceClient:e,databaseName:t,tableName:n,conditions:r,sort:i,pageIndex:a,pageSize:o,limit:s=o,onlyIfCached:c,getAttributes:l,allowFullScan:u,responseType:d}){return e.post(`/`,{operation:`search_by_conditions`,get_attributes:l??[`*`],database:t,table:n,conditions:r,sort:i.attribute.length?i:void 0,offset:a*o,limit:s,allowFullScan:u||void 0,onlyIfCached:c,noCacheStore:c},{timeout:0,responseType:d})}function qR(e,t,n,r){return t.split(/ & /).map(t=>JR(e,t,n,r))}function JR(e,t,n,r){if(t.startsWith(e)&&(t=t.substring(e.length)),r)return YR(e,t,r);let{comparator:i,value:a}=QR(t);switch(n?.type){case`ID`:case`String`:return{search_attribute:e,search_type:i,search_value:a};case`Int`:case`BigInt`:case`Long`:case`Float`:{let t=n.type.includes(`Int`)?parseInt(a,10):parseFloat(a);if(isNaN(t))throw Error(`${a} does not appear to be a valid number.`);return{search_attribute:e,search_type:i,search_value:t}}case`Date`:return{search_attribute:e,search_type:i,search_value:new Date(a).toISOString()};case`Boolean`:return{search_attribute:e,search_type:i,search_value:RR(a)};case`Blob`:case`Bytes`:return{search_attribute:e,search_type:i,search_value:a};default:return{search_attribute:e,search_type:i,search_value:UR(a)}}}function YR(e,t,n){let r=t.match(/^\s*\.([^.\s]+)\s*(.*)$/);if(!r)throw Error(`Filter ${e} on a property of ${n.relatedTableName}, e.g. ".${n.relatedPrimaryKey} value".`);let[,i,a]=r,o=JR(i,a,n.relatedAttributes.find(e=>e.attribute===i));return i===n.relatedPrimaryKey&&n.foreignKeyAttribute?{...o,search_attribute:n.foreignKeyAttribute}:{...o,search_attribute:[e,i]}}var XR={"=== ":`equals`,"== ":`eq`,"equals ":`equals`,"equal ":`equals`,"eq ":`eq`,"!== ":`not_equal`,"!= ":`ne`,"notequals ":`not_equal`,"notequal ":`not_equal`,"ne ":`ne`},ZR={">":`greater_than`,g:`greater_than`,gt:`greater_than`,"=gt":`greater_than`,greater:`greater_than`,greaterthan:`greater_than`,">=":`greater_than_equal`,ge:`greater_than_equal`,"=ge":`greater_than_equal`,gte:`greater_than_equal`,greaterorequal:`greater_than_equal`,greaterthanequal:`greater_than_equal`,greaterthanorequal:`greater_than_equal`,"<":`less_than`,l:`less_than`,lt:`less_than`,"=lt":`less_than`,less:`less_than`,lessthan:`less_than`,"<=":`less_than_equal`,lte:`less_than_equal`,le:`less_than_equal`,"=le":`less_than_equal`,lessorequal:`less_than_equal`,lessthanequal:`less_than_equal`,lessthanorequal:`less_than_equal`};function QR(e){let t=e.toLowerCase(),n=t.match(/^ *([>=<]+[a-z]*[_ ]*|[a-z]+[>=<]+[_ ]*|[a-z]+[_ ]+)([\d._:tz-]+) *$/);if(n){let e=n[1].replace(/[_ ]+/g,``).replace(/^([a-z]+)=$/g,`$1`),t=n[2],r=ZR[e];if(r)return{comparator:r,value:t}}for(let n in XR)if(t.startsWith(n))return{comparator:XR[n],value:e.slice(n.length)};return e.length>1&&e.startsWith(`*`)?e.endsWith(`*`)?{comparator:`contains`,value:e.slice(1,-1)}:{comparator:`ends_with`,value:e.slice(1)}:e.endsWith(`*`)?{comparator:`starts_with`,value:e.slice(0,-1)}:{comparator:`equals`,value:e}}function $R(){let e=q(),t=Ze(),[n,r]=(0,G.useState)(!1);return{exportCsv:(0,G.useCallback)(async({databaseName:n,tableName:i,primaryKey:a,sort:o,conditions:s,allowFullScan:c,instanceTable:l,databaseTables:u})=>{if(!a){U.error(`Cannot export "${i}": no primary key found.`);return}let d=U.loading(`Loading CSV...`);r(!0);try{let r={...e,databaseName:n,tableName:i,sort:o??{attribute:a,descending:!1},pageIndex:0,pageSize:1e6,onlyIfCached:!1,getAttributes:hR(l),responseType:`text`},[f,p]=await Promise.all([(s?.length?KR({...r,conditions:s,allowFullScan:c}):Iw({...r,searchAttribute:a})).then(({data:e})=>(U.loading(`Preparing CSV...`,{id:d}),CR(e))),t.fetchQuery(PF(e))]),m=bR(f,gR(f,l,u,p[n]?.[i])),h=URL.createObjectURL(m),g=document.createElement(`a`);g.href=h,g.setAttribute(`download`,`${n}.${i}.${new Date().toISOString()}.csv`),g.click(),setTimeout(()=>URL.revokeObjectURL(h),1e3),U.success(`CSV Exported!`,{id:d})}catch(e){U.error(e instanceof Error?e.message:`Failed to export CSV`,{id:d})}finally{r(!1)}},[e,t]),isExporting:n}}function ez({databaseName:e,tableName:t,instanceDatabaseMap:n}){let{clusterId:r,instanceId:i}=z({strict:!1}),a=wg(),o=Tg(i??r,e,t,`insert`),s=Dg(i??r,e,t),{exportCsv:c}=$R(),l=Object.keys(n?.[e]||{}).length<=1,u=n?.[e]?.[t],d=!u||!!(u.primary_key??u.hash_attribute);return(0,K.jsxs)(K.Fragment,{children:[o&&d&&(0,K.jsxs)(Nm,{onSelect:()=>rL(`ShowAddTableRecords`,{databaseName:e,tableName:t}),children:[(0,K.jsx)(Uo,{}),`Add New Record(s)`]}),s&&d&&(0,K.jsxs)(Nm,{onSelect:()=>rL(`ShowImportData`,{databaseName:e,tableName:t}),children:[(0,K.jsx)(Ji,{}),`Import Data`]}),(0,K.jsxs)(Nm,{onSelect:()=>{let{primaryKey:r}=sR(u);c({databaseName:e,tableName:t,primaryKey:r,conditions:null,instanceTable:u,databaseTables:n?.[e]})},disabled:!d,children:[(0,K.jsx)(Ki,{}),`Export CSV`]}),a&&!l&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Fm,{}),(0,K.jsxs)(Nm,{variant:`destructive`,onSelect:()=>rL(`ShowDeleteTable`,{databaseName:e,tableName:t}),children:[(0,K.jsx)(Is,{}),`Drop Table`]})]})]})}function tz({databaseName:e,instanceDatabaseMap:t,children:n}){let[r,i]=(0,G.useState)(void 0),[a,o]=(0,G.useState)(``),s=(0,G.useCallback)(e=>{let t=e.target.closest(`[data-table-name]`)?.getAttribute(`data-table-name`);if(!t){i(void 0),e.preventDefault();return}i(t),o(`${e.clientX},${e.clientY}`)},[]);return(0,K.jsxs)(Am,{modal:!1,children:[(0,K.jsx)(jm,{asChild:!0,children:(0,K.jsx)(`div`,{onContextMenu:s,children:n})}),r&&(0,K.jsx)(Mm,{className:`min-w-44`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,K.jsx)(ez,{databaseName:e,tableName:r,instanceDatabaseMap:t})},a)]})}var nz=`…`;function rz(e,t){return`${t?`~`:``}${e.toLocaleString()}`}var iz=`One or more tables’ counts couldn’t be loaded and are left out`;function az(e,t,n){let r=`${e.toLocaleString()} ${e===1?`record`:`records`}`;return t&&n?{spoken:`At least about ${r}`,reason:`${iz}, and some counts are estimates.`}:t?{spoken:`At least ${r}`,reason:`${iz}.`}:n?{spoken:`Approximately ${r} (estimated)`,reason:`One or more tables’ counts are estimates.`}:void 0}function oz(e,t){let n=0,r=!1,i=!1,a=e.map((e,a)=>{let o=t[a]?.data;if(o?.record_count===void 0)return i=!0,nz;let s=!!o.estimated_record_range;return r||=s,n+=o.record_count,rz(o.record_count,s)});return t.some(e=>e.isPending)?{totalLabel:nz,recordLabels:a}:{totalLabel:`${i?`≥`:r?`~`:``}${n.toLocaleString()}`,totalNote:az(n,i,r),recordLabels:a}}function sz(e,t,n){if(e==null||!Number.isFinite(e))return`—`;let r=cz(e,t);return n?`${r}${n}`:r}function cz(e,t){switch(t){case`percent`:return`${(e*100).toFixed(1)}%`;case`ms`:return`${e.toFixed(1)} ms`;case`count`:return`${e.toFixed(0)}`;case`count-si`:{let t=Math.abs(e);if(t<1e3)return`${e}`;let n=e<0?`-`:``,r=e=>{if(e>=10)return`${Math.round(e)}`;let t=e.toFixed(1);return t.endsWith(`.0`)?t.slice(0,-2):t};return t<1e6?`${n}${r(t/1e3)}k`:t<1e9?`${n}${r(t/1e6)}M`:`${n}${r(t/1e9)}B`}case`cores`:return`${e.toFixed(2)} cores`;case`bytes-si`:case`bytes-iec`:{let n=t===`bytes-iec`?1024:1e3,r=t===`bytes-iec`?[`B`,`KiB`,`MiB`,`GiB`,`TiB`]:[`B`,`KB`,`MB`,`GB`,`TB`],i=e,a=0;for(;Math.abs(i)>=n&&a<r.length-1;)i/=n,a++;let o=+(i!==0&&Math.abs(i)<10);return`${i.toFixed(o)} ${r[a]}`}default:return`${e}`}}var lz=e=>sz(e,`bytes-si`);function uz({label:e,value:t,note:n}){return(0,K.jsxs)(`div`,{className:`rounded-md border border-border dark:border-grey-700 p-4`,children:[(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e}),(0,K.jsx)(`div`,{className:`text-2xl font-medium`,children:n?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:`cursor-help underline decoration-dotted underline-offset-4`,"aria-label":n.spoken,children:t})}),(0,K.jsx)(Xl,{side:`top`,align:`start`,className:`max-w-60`,children:n.reason})]}):t})]})}function dz({instanceDatabaseMap:e,databaseName:t}){let n=z({strict:!1}),r=De(),i=q(),a=wg(),o=Og(),s=e?.[t]??{},c=Object.keys(s).sort(),{totalLabel:l,totalNote:u,recordLabels:d}=oz(c,et({queries:c.map(e=>WL({...i,databaseName:t,tableName:e}))})),f=c.length?s[c[0]]:void 0,p=f?.db_size??0,m=f?.db_audit_size??0,h=(0,G.useCallback)(e=>{r({to:jP({...n,databaseName:t,tableName:e})})},[r,n,t]);return(0,K.jsxs)(`div`,{className:`pt-15 pb-4 px-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row items-start md:items-center justify-between gap-3 pb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,K.jsx)(`h1`,{className:`text-3xl truncate`,children:t})}),a&&(0,K.jsxs)(`div`,{className:`flex space-x-2 shrink-0`,children:[(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:()=>rL(`ShowCreateTable`,{databaseName:t}),children:[(0,K.jsx)(Uo,{}),(0,K.jsx)(`span`,{children:`Create a Table`})]}),o&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:()=>rL(`ShowImportData`,{databaseName:t}),children:[(0,K.jsx)(Ji,{}),(0,K.jsx)(`span`,{children:`Import Data`})]}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,children:(0,K.jsx)(ua,{"aria-label":`Database options`})})}),(0,K.jsx)(vc,{side:`bottom`,align:`end`,children:(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3 pb-6`,children:[(0,K.jsx)(uz,{label:`Tables`,value:c.length.toLocaleString()}),(0,K.jsx)(uz,{label:`Records`,value:l,note:u}),(0,K.jsx)(uz,{label:`Size`,value:lz(p)}),(0,K.jsx)(uz,{label:`Audit Size`,value:lz(m)})]}),c.length===0?(0,K.jsxs)(`div`,{className:`rounded-md border border-border dark:border-grey-700 p-8 text-center text-muted-foreground`,children:[(0,K.jsx)(`p`,{className:`pb-2`,children:`This database has no tables yet.`}),a&&(0,K.jsx)(`p`,{children:`Use “Create a Table” above, or right-click the database in the sidebar.`})]}):(0,K.jsx)(tz,{databaseName:t,instanceDatabaseMap:e,children:(0,K.jsx)(`div`,{className:`rounded-md border border-border dark:border-grey-700 overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-left text-muted-foreground border-b border-border dark:border-grey-700`,children:[(0,K.jsx)(`th`,{className:`p-3 font-medium`,children:`Table`}),(0,K.jsx)(`th`,{className:`p-3 font-medium text-right`,children:`Records`}),(0,K.jsx)(`th`,{className:`p-3 font-medium text-right`,children:`Size`}),(0,K.jsx)(`th`,{className:`p-3 font-medium text-right`,children:`Columns`}),(0,K.jsx)(`th`,{className:`p-3 font-medium`,children:`Primary Key`}),(0,K.jsx)(`th`,{className:`p-3 font-medium`,children:`Last Updated`})]})}),(0,K.jsx)(`tbody`,{children:c.map((e,t)=>{let n=s[e],r=n.primary_key??n.hash_attribute??`—`;return(0,K.jsxs)(`tr`,{"data-table-name":e,onClick:()=>h(e),className:`border-b border-border dark:border-grey-700 last:border-0 cursor-pointer hover:bg-accent dark:hover:bg-grey-700/80`,children:[(0,K.jsx)(`td`,{className:`p-3 font-medium`,children:e}),(0,K.jsx)(`td`,{className:`p-3 text-right tabular-nums`,children:d[t]}),(0,K.jsx)(`td`,{className:`p-3 text-right tabular-nums`,children:lz(n.table_size??0)}),(0,K.jsx)(`td`,{className:`p-3 text-right tabular-nums`,children:n.attributes.length.toLocaleString()}),(0,K.jsx)(`td`,{className:`p-3`,children:r}),(0,K.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:n.last_updated_record?new Date(n.last_updated_record).toLocaleString():`—`})]},e)})})]})})})]})}function fz({item:e,context:t}){return e.isFolder?(0,K.jsx)(`div`,{className:F(`rct-tree-item-arrow`,`rct-tree-item-arrow-isFolder`,t.isExpanded&&`rct-tree-item-arrow-expanded`),"aria-hidden":!0,tabIndex:-1,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.stopPropagation(),t.toggleExpandedState()},children:t.isExpanded?(0,K.jsx)(`svg`,{viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z`,className:`rct-tree-item-arrow-path`})}):(0,K.jsx)(`svg`,{viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z`,className:`rct-tree-item-arrow-path`})})}):(0,K.jsx)(`div`,{className:`rct-tree-item-arrow`,"aria-hidden":!0})}var pz;(function(e){e.DoubleClickItemToExpand=`double-click-item-to-expand`,e.ClickItemToExpand=`click-item-to-expand`,e.ClickArrowToExpand=`click-arrow-to-expand`})(pz||={});var mz=function(){return mz=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},mz.apply(this,arguments)},hz=function(e,t){return{mode:e.mode,createInteractiveElementProps:function(n,r,i,a){return mz(mz({},t.createInteractiveElementProps(n,r,i,a)),e.createInteractiveElementProps(n,r,i,a))}}},gz=function(e){return e.ctrlKey||navigator.platform.toUpperCase().indexOf(`MAC`)>=0&&e.metaKey},_z=function(){function e(e){this.mode=pz.DoubleClickItemToExpand,this.environment=e}return e.prototype.createInteractiveElementProps=function(e,t,n,r){var i=this;return{onClick:function(e){var t=e.detail===0;n.focusItem(),e.shiftKey&&!t?n.selectUpTo(!gz(e)):gz(e)&&!t?r.isSelected?n.unselectItem():n.addToSelectedItems():n.selectItem()},onDoubleClick:function(){n.focusItem(),n.selectItem(),e.isFolder&&n.toggleExpandedState(),(!e.isFolder||i.environment.canInvokePrimaryActionOnItemContainer)&&n.primaryAction()},onFocus:function(){n.focusItem()},onDragStart:function(e){e.dataTransfer.dropEffect=`move`,n.startDragging()},onDragOver:function(e){e.preventDefault()},draggable:r.canDrag&&!r.isRenaming,tabIndex:r.isRenaming?void 0:r.isFocused?0:-1}},e}(),vz=function(){function e(e){this.mode=pz.ClickItemToExpand,this.environment=e}return e.prototype.createInteractiveElementProps=function(e,t,n,r){var i=this;return{onClick:function(t){var a=t.detail===0;n.focusItem(),t.shiftKey&&!a?n.selectUpTo(!gz(t)):gz(t)&&!a?r.isSelected?n.unselectItem():n.addToSelectedItems():(e.isFolder&&n.toggleExpandedState(),n.selectItem(),(!e.isFolder||i.environment.canInvokePrimaryActionOnItemContainer)&&n.primaryAction())},onFocus:function(){n.focusItem()},onDragStart:function(e){e.dataTransfer.dropEffect=`move`,n.startDragging()},onDragOver:function(e){e.preventDefault()},draggable:r.canDrag&&!r.isRenaming,tabIndex:r.isRenaming?void 0:r.isFocused?0:-1}},e}(),yz=function(){function e(e){this.mode=pz.ClickItemToExpand,this.environment=e}return e.prototype.createInteractiveElementProps=function(e,t,n,r){var i=this;return{onClick:function(t){var a=t.detail===0;n.focusItem(),t.shiftKey&&!a?n.selectUpTo(!gz(t)):gz(t)&&!a?r.isSelected?n.unselectItem():n.addToSelectedItems():(n.selectItem(),(!e.isFolder||i.environment.canInvokePrimaryActionOnItemContainer)&&n.primaryAction())},onFocus:function(){n.focusItem()},onDragStart:function(e){e.dataTransfer.dropEffect=`move`,n.startDragging()},onDragOver:function(e){e.preventDefault()},draggable:r.canDrag&&!r.isRenaming,tabIndex:r.isRenaming?void 0:r.isFocused?0:-1}},e}(),bz=function(e,t){switch(e){case pz.DoubleClickItemToExpand:return new _z(t);case pz.ClickItemToExpand:return new vz(t);case pz.ClickArrowToExpand:return new yz(t);default:throw Error(`Unknown interaction mode ${e}`)}},xz=G.createContext(null),Sz=function(){return G.useContext(xz)},Cz=function(e){var t=e.children,n=lB(),r=n.defaultInteractionMode,i=(0,G.useMemo)(function(){return r&&typeof r!=`string`?r.extends?hz(r,bz(r.extends,n)):r:bz(r??pz.ClickItemToExpand,n)},[]);return G.createElement(xz.Provider,{value:i},t)},wz=function(){var e=lB();return(0,G.useCallback)(function(t,n){if(t.targetType===`between-items`){if(!e.canReorderItems)return!1}else if(t.targetType===`root`){if(!e.canDropOnFolder)return!1}else{var r=e.items[t.targetItem];if(!r||!e.canDropOnFolder&&r.isFolder||!e.canDropOnNonFolder&&!r.isFolder||n.some(function(e){return e.index===t.targetItem}))return!1}return!(e.canDropAt&&(!n||!e.canDropAt(n,t)))},[e])},Tz=function(){var e=lB();return(0,G.useCallback)(function(t,n){for(var r=e.linearItems[n],i=r[t].depth,a=t;r[a]&&r[a].depth!==i-1;--a);var o=r[a];return o||(o={item:e.trees[n].rootItem,depth:0},a=0),{parent:o,parentLinearIndex:a}},[e.linearItems,e.trees])},Ez=function(){var e=lB(),t=Tz(),n=wz(),r=(0,G.useCallback)(function(e,n,i){var a=t(n,e),o=a.parent,s=a.parentLinearIndex;return i.some(function(e){return e.index===o.item})?!0:o.depth!==0&&r(e,s,i)},[t]);return(0,G.useCallback)(function(i,a){for(var o=e.linearItems[i],s=[],c=-1,l=0;l<o.length;l++){var u=o[l],d=u.item,f=u.depth;if(!(c!==-1&&f>c)){c=-1;var p=t(l,i).parent,m=e.items[p.item].children.indexOf(d);if(r(i,l,a)){c=f+1;continue}var h={targetType:`item`,parentItem:p.item,targetItem:d,linearIndex:l,depth:f,treeId:i},g={targetType:`between-items`,parentItem:p.item,linePosition:`top`,childIndex:m,depth:f,treeId:i,linearIndex:l},_={targetType:`between-items`,parentItem:p.item,linePosition:`bottom`,linearIndex:l+1,childIndex:m+1,depth:f,treeId:i},v=o[l-1]?.depth??-1,y=o[l+1]?.depth??-1,b=f===v,x=f===y-1;!b&&n(g,a)&&s.push(g),n(h,a)&&s.push(h),!x&&n(_,a)&&s.push(_)}}return s},[n,e.items,e.linearItems,t,r])},Dz=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Oz=function(e,t,n){var r=(0,G.useRef)();(0,G.useEffect)(function(){r.current?r.current.some(function(e,t){return e!==n[t]})&&(r.current=Dz([],n,!0),e()):(r.current=Dz([],n,!0),e())},Dz(Dz([],t,!0),n,!0))},kz=function(){return kz=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},kz.apply(this,arguments)},Az=function(e,t){return e.map(function(e){return[e,t(e)]}).reduce(function(e,t){var n,r=t[0],i=t[1];return kz(kz({},e),(n={},n[r]=i,n))},{})},jz=function(){return typeof document<`u`?document:void 0};function Mz(e){e===void 0&&(e=!1);var t=(0,G.useRef)([]);return(0,G.useEffect)(function(){if(e)return function(){};var n=t.current;return function(){return n.forEach(function(e){return cancelAnimationFrame(e)})}},[e,t]),(0,G.useCallback)(function(e){var n=requestAnimationFrame(function(){t.current.splice(t.current.indexOf(n),1),e()});t.current.push(n)},[t])}var Nz=function(e){var t=(0,G.useRef)(e);return t.current=e,t},Pz=function(e){var t=Nz(e);return(0,G.useCallback)((function(){var e=[...arguments];return t.current.apply(t,e)}),[t])},Fz=function(){var e=lB();return Pz(function(t,n){return n.map(function(n){return[n,e.linearItems[t].findIndex(function(e){return e.item===n.index})]}).sort(function(e,t){e[0];var n=e[1];return t[0],n-t[1]}).map(function(e){return e[0]})})},Iz=function(e){var t=jz()?.querySelector(`[data-rct-tree="${e}"] [data-rct-item-container="true"]`);if(t){var n=getComputedStyle(t);return t.offsetHeight+Math.max(parseFloat(n.marginTop),parseFloat(n.marginBottom))}return 5},Lz=function(e,t){return e.clientX<=t.left||e.clientX>=t.right||e.clientY<=t.top||e.clientY>=t.bottom},Rz=function(){function e(e,t,n,r,i,a){this.env=e,this.e=t,this.treeId=n,this.linearIndex=r.linearIndex,this.offset=r.offset,this.indentation=r.indentation,this.targetItem=this.env.linearItems[this.treeId][this.linearIndex],this.getParentOfLinearItem=a,this.draggingItems=i}return e.prototype.getEmptyTreeDragPosition=function(){return{targetType:`root`,treeId:this.treeId,depth:0,linearIndex:0,targetItem:this.env.trees[this.treeId].rootItem}},e.prototype.maybeRedirectToParent=function(){if(!this.env.canReorderItems&&!this.env.canDropOnNonFolder&&!this.env.items[this.targetItem.item].isFolder){var e=this.getParentOfLinearItem(this.linearIndex,this.treeId),t=e.parentLinearIndex,n=e.parent;this.targetItem=n,this.linearIndex=t}},e.prototype.maybeReparentUpwards=function(){if(this.indentation!==void 0){var e=this.env.linearItems[this.treeId],t=e[this.linearIndex].depth,n=t-(e[this.linearIndex+1]?.depth??0);if(this.offset===`bottom`&&n>0){for(var r=Math.max(t-n,this.indentation),i={parentLinearIndex:this.linearIndex,parent:this.targetItem},a,o=t;o>=r;--o)a=i,i=this.getParentOfLinearItem(i.parentLinearIndex,this.treeId);if(this.indentation!==e[this.linearIndex].depth&&a){var s=this.env.items[i.parent.item].children.indexOf(a.parent.item)+1;if(!(this.draggingItems&&this.isDescendant(this.treeId,i.parentLinearIndex+1,this.draggingItems)))return{targetType:`between-items`,treeId:this.treeId,parentItem:i.parent.item,depth:r,linearIndex:this.linearIndex+1,childIndex:s,linePosition:`bottom`}}}}},e.prototype.maybeRedirectInsideOpenFolder=function(){var e=this.env.linearItems[this.treeId][this.linearIndex+1];!this.env.canDropBelowOpenFolders&&e&&this.targetItem.depth===e.depth-1&&this.offset===`bottom`&&(this.targetItem=e,this.linearIndex+=1,this.offset=`top`)},e.prototype.maybeMapToBottomOffset=function(){var e=this.env.linearItems[this.treeId][this.linearIndex-1];if(e&&e?.depth!==void 0){var t=e.depth-this.targetItem.depth;this.offset===`top`&&(t===0||t>0&&this.indentation!==void 0)&&(this.offset=`bottom`,--this.linearIndex,this.targetItem=this.env.linearItems[this.treeId][this.linearIndex])}},e.prototype.canDropAtCurrentTarget=function(){var e=this,t=this.env.items[this.targetItem.item];return!(!this.offset&&!this.env.canDropOnNonFolder&&!t.isFolder||!this.offset&&!this.env.canDropOnFolder&&t.isFolder||this.offset&&!this.env.canReorderItems||this.draggingItems?.some(function(t){return t.index===e.targetItem.item}))},e.prototype.getDraggingPosition=function(){if(this.env.linearItems[this.treeId].length===0)return this.getEmptyTreeDragPosition();if(!(!this.draggingItems||this.linearIndex<0||this.linearIndex>=this.env.linearItems[this.treeId].length)){this.maybeRedirectToParent(),this.maybeRedirectInsideOpenFolder(),this.maybeMapToBottomOffset();var e=this.maybeReparentUpwards();if(e)return e;if(this.areDraggingItemsDescendantOfTarget()||!this.canDropAtCurrentTarget())return`invalid`;var t=this.getParentOfLinearItem(this.linearIndex,this.treeId).parent,n=this.env.items[t.item].children.indexOf(this.targetItem.item)+(this.offset===`top`?0:1);return this.offset?{targetType:`between-items`,treeId:this.treeId,parentItem:t.item,depth:this.targetItem.depth,linearIndex:this.linearIndex+(this.offset===`top`?0:1),childIndex:n,linePosition:this.offset}:{targetType:`item`,treeId:this.treeId,parentItem:t.item,targetItem:this.targetItem.item,depth:this.targetItem.depth,linearIndex:this.linearIndex}}},e.prototype.isDescendant=function(e,t,n){var r=this.getParentOfLinearItem(t,e),i=r.parentLinearIndex,a=r.parent;return n.some(function(e){return e.index===a.item})?!0:a.depth!==0&&this.isDescendant(e,i,n)},e.prototype.areDraggingItemsDescendantOfTarget=function(){return this.draggingItems&&this.isDescendant(this.treeId,this.linearIndex,this.draggingItems)},e}(),zz=function(){var e=(0,G.useRef)(`initial`),t=(0,G.useState)(void 0),n=t[0],r=t[1],i=(0,G.useRef)(0),a=lB(),o=Tz(),s=Pz(function(t,n,r){if(!r)return!1;var i=r.offset,a=`${n}__${r.linearIndex}__${i??``}__${r.indentation}`;return a!==e.current&&(e.current=a,!0)}),c=Pz(function(e,t,n){if(n.current){var r=n.current.getBoundingClientRect();if(!Lz(e,r)){var o=(e.clientY-r.top)/i.current,s=a.linearItems[t],c=Math.min(Math.max(0,Math.floor(o)),s.length-1);if(s.length===0)return{linearIndex:0,offset:`bottom`,indentation:0};var l=s[c],u=a.items[l.item],d=a.renderDepthOffset?Math.max(Math.floor((e.clientX-r.left)/a.renderDepthOffset),0):void 0,f,p=a.canReorderItems?u?.isFolder&&a.canDropOnFolder||a.canDropOnNonFolder?.2:.5:0;return o-.5>=s.length-1?f=`bottom`:o%1<p?f=`top`:o%1>1-p&&(f=`bottom`),{linearIndex:c,offset:f,indentation:d}}}}),l=Pz(function(e,t,r){var i=c(e,t,r);if(s(e,t,i))return!n||!a.canDragAndDrop||!i||e.clientX<0||e.clientY<0?`invalid`:new Rz(a,e,t,i,n,o).getDraggingPosition()});return{initiateDraggingPosition:Pz(function(t,n){r(n),e.current=`initial`,i.current=Iz(t)}),resetDraggingPosition:Pz(function(){r(void 0),e.current=`initial`,i.current=0}),draggingItems:n,getDraggingPosition:l,itemHeight:i}},Bz=G.createContext(null),Vz=function(){return G.useContext(Bz)},Hz=function(e){var t=e.children,n=lB(),r=(0,G.useState)(!1),i=r[0],a=r[1],o=(0,G.useState)({}),s=o[0],c=o[1],l=(0,G.useState)(0),u=l[0],d=l[1],f=(0,G.useState)(),p=f[0],m=f[1],h=Ez(),g=Mz(),_=Fz(),v=zz(),y=v.initiateDraggingPosition,b=v.resetDraggingPosition,x=v.draggingItems,S=v.getDraggingPosition,C=v.itemHeight,w=(0,G.useCallback)(function(e,t){if(n.activeTreeId&&n.viewState[n.activeTreeId]?.focusedItem&&n.linearItems&&t){var r=n.viewState[n.activeTreeId].focusedItem,i=h(n.activeTreeId,t),a=i.findIndex(function(e){return e.targetType===`item`?e.targetItem===r:e.targetType===`between-items`&&n.items[e.parentItem].children[e.childIndex]===r});d(a?Math.min(a+1,i.length-1):0)}else d(0)},[n.activeTreeId,n.items,n.linearItems,n.viewState,h]),T=Pz(function(){a(!1),c({}),d(0),m(void 0),b()});Oz(function(){n.activeTreeId&&n.linearItems[n.activeTreeId]&&s[n.activeTreeId]&&w(s[n.activeTreeId],x)},[x,n.activeTreeId,n.linearItems,w,s],[n.activeTreeId]),Oz(function(){i&&n.activeTreeId&&m(s[n.activeTreeId][u])},[u,n.activeTreeId,i,s],[u,n.activeTreeId]);var E=wz(),D=function(e){var t;(!x||E(e,x))&&(m(e),n.setActiveTree(e.treeId),x&&n.activeTreeId!==e.treeId&&((t=n.onSelectItems)==null||t.call(n,x.map(function(e){return e.index}),e.treeId)))},O=Pz(function(e,t,n){if(x){var r=S(e,t,n);if(r){if(r===`invalid`){m(void 0);return}D(r)}}}),k=Pz(function(e,t){t.current&&Lz(e,t.current.getBoundingClientRect())&&m(void 0)}),A=Pz(function(){x&&p&&n.onDrop&&(n.onDrop(x,p),g(function(){var e;(e=n.onFocusItem)==null||e.call(n,x[0],p.treeId),T()}))}),j=(0,G.useCallback)(function(e,t){var r=Az(n.treeIds,function(t){return h(t,e)});y(t,e),c(r),n.activeTreeId&&w(r[n.activeTreeId],e)},[n.activeTreeId,n.treeIds,h,y,w]),M=(0,G.useCallback)(function(){if(n.canDragAndDrop&&n.activeTreeId){var e=n.viewState[n.activeTreeId]?.selectedItems??[n.viewState[n.activeTreeId]?.focusedItem];if(e.length===0||e[0]===void 0)return;var t=_(n.activeTreeId,e.map(function(e){return n.items[e]}));if(n.canDrag&&!n.canDrag(t))return;j(t,n.activeTreeId),setTimeout(function(){a(!0)})}},[n,_,j]),ee=(0,G.useCallback)(function(){T()},[T]),te=(0,G.useCallback)(function(){A(),T()},[A,T]),N=(0,G.useCallback)(function(){d(function(e){return Math.max(0,e-1)})},[]),P=(0,G.useCallback)(function(){n.activeTreeId&&d(function(e){return Math.min(s[n.activeTreeId].length-1,e+1)})},[n.activeTreeId,s]),F=(0,G.useMemo)(function(){return{onStartDraggingItems:j,startProgrammaticDrag:M,abortProgrammaticDrag:ee,completeProgrammaticDrag:te,programmaticDragUp:N,programmaticDragDown:P,draggingItems:x,draggingPosition:p,itemHeight:C.current,isProgrammaticallyDragging:i,onDragOverTreeHandler:O,onDragLeaveContainerHandler:k,viableDragPositions:s}},[ee,te,x,p,i,C,O,k,j,P,N,M,s]);return(0,G.useEffect)(function(){return window.addEventListener(`dragend`,T),window.addEventListener(`drop`,A),function(){window.removeEventListener(`dragend`,T),window.removeEventListener(`drop`,A)}},[A,T]),G.createElement(Bz.Provider,{value:F},t)},Uz=function(){return Uz=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Uz.apply(this,arguments)},Wz=function(e,t){var n=lB(),r=Vz();(0,G.useImperativeHandle)(e,function(){return Uz(Uz(Uz({},t),n),{treeEnvironmentContext:n,dragAndDropContext:r})})},Gz=function(e,t,n){return t===void 0&&(t=50),n===void 0&&(n=1e4),new Promise(function(r){e()&&r();var i,a=setInterval(function(){e()&&i()},t),o=setTimeout(function(){i()},n);i=function(){clearInterval(a),clearTimeout(o),r()}})},Kz=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},qz=function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o={next:s(0),throw:s(1),return:s(2)};return typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Jz=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Yz=G.createContext(null),Xz=function(){return G.useContext(Yz)},Zz=function(e,t,n){return Kz(void 0,void 0,void 0,function(){var r,i,a,o;return qz(this,function(s){for(r=function(e){Gz(function(){return!!t.current?.[e]}).then(function(){var r=t.current?.[e];r?.isFolder&&(n(r),Zz(e,t,n))})},i=0,a=t.current?.[e]?.children??[];i<a.length;i++)o=a[i],r(o);return[2]})})},Qz=G.forwardRef(function(e,t){var n=lB(),r=n.onCollapseItem,i=n.items,a=n.trees,o=n.viewState,s=n.onExpandItem,c=n.onFocusItem,l=n.setActiveTree,u=n.onRenameItem,d=n.onSelectItems,f=n.onPrimaryAction,p=n.linearItems,m=Vz(),h=m.abortProgrammaticDrag,g=m.completeProgrammaticDrag,_=m.programmaticDragDown,v=m.programmaticDragUp,y=m.startProgrammaticDrag,b=Nz(i),x=(0,G.useCallback)(function(e,t){r?.(i[e],t)},[i,r]),S=(0,G.useCallback)(function(e,t){s?.(i[e],t)},[i,s]),C=(0,G.useCallback)(function(e,t,n){n===void 0&&(n=!0),c?.(i[e],t,n)},[i,c]),w=(0,G.useCallback)(function(e,t){t===void 0&&(t=!0),l(e,t)},[l]),T=(0,G.useCallback)(function(e){var t=p[e],n=t.findIndex(function(t){return t.item===o[e]?.focusedItem}),r=i[t[n===void 0?0:Math.min(t.length-1,n+1)].item];c?.(r,e)},[i,p,c,o]),E=(0,G.useCallback)(function(e){var t=p[e],n=t.findIndex(function(t){return t.item===o[e]?.focusedItem}),r=i[t[n===void 0?0:Math.max(0,n-1)].item];c?.(r,e)},[i,p,c,o]),D=(0,G.useCallback)(function(e,t,n){u?.(i[e],t,n)},[i,u]),O=(0,G.useCallback)(function(e,t){d?.(e,t)},[d]),k=(0,G.useCallback)(function(e,t){(o[t]?.expandedItems)?.includes(e)?r?.(i[e],t):s?.(i[e],t)},[i,r,s,o]),A=(0,G.useCallback)(function(e,t){(o[t]?.selectedItems)?.includes(e)?d?.(o[t].selectedItems?.filter(function(t){return t!==e})??[],t):d?.(Jz(Jz([],o[t].selectedItems??[],!0),[e],!1),t)},[d,o]),j=(0,G.useCallback)(function(e,t){f?.(i[e],t)},[i,f]),M=(0,G.useCallback)(function(e,t){return Kz(void 0,void 0,void 0,function(){var n,r;return qz(this,function(i){switch(i.label){case 0:return n=t[0],r=t.slice(1),[4,Gz(function(){return!!b.current?.[n]}).then(function(){var t=b.current[n];return t?(s?.(t,e),r.length>0?M(e,r):Promise.resolve()):Promise.resolve()})];case 1:return i.sent(),[2]}})})},[b,s]),ee=(0,G.useCallback)(function(e){return Kz(void 0,void 0,void 0,function(){return qz(this,function(t){switch(t.label){case 0:return[4,Zz(a[e].rootItem,b,function(t){return s?.(t,e)})];case 1:return t.sent(),[2]}})})},[b,s,a]),te=(0,G.useCallback)(function(e){for(var t=0,n=o[e]?.expandedItems??[];t<n.length;t++){var a=n[t];r?.(i[a],e)}},[i,r,o]),N=(0,G.useMemo)(function(){return{collapseItem:x,expandItem:S,focusItem:C,focusTree:w,moveFocusDown:T,moveFocusUp:E,renameItem:D,selectItems:O,toggleItemExpandedState:k,toggleItemSelectStatus:A,invokePrimaryAction:j,expandAll:ee,expandSubsequently:M,collapseAll:te,abortProgrammaticDrag:h,completeProgrammaticDrag:g,moveProgrammaticDragPositionDown:_,moveProgrammaticDragPositionUp:v,startProgrammaticDrag:y}},[x,S,C,w,T,E,D,O,k,A,j,ee,M,te,h,g,_,v,y]);return Wz(t,N),G.createElement(Yz.Provider,{value:N},e.children)}),$z=function(e){if(e){if(e.scrollIntoViewIfNeeded)e.scrollIntoViewIfNeeded();else{var t=e.getBoundingClientRect();t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||!!jz()?.documentElement?.clientHeight)&&t.right<=(window.innerWidth||!!jz()?.documentElement?.clientWidth)||e.scrollIntoView()}}},eB=function(){return eB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},eB.apply(this,arguments)},tB=function(){return[...arguments].filter(function(e){return!!e}).join(` `)},nB=function(e,t){return{renderItemTitle:function(e){var t=e.title,n=e.context,r=e.info;if(!r.isSearching||!n.isSearchMatching)return t;var i=t.toLowerCase().indexOf(r.search.toLowerCase());return G.createElement(G.Fragment,null,i>0&&G.createElement(`span`,null,t.slice(0,i)),G.createElement(`span`,{className:`rct-tree-item-search-highlight`},t.slice(i,i+r.search.length)),i+r.search.length<t.length&&G.createElement(`span`,null,t.slice(i+r.search.length,t.length)))},renderItemArrow:function(e){var t=e.item,n=e.context;return G.createElement(`div`,eB({className:tB(t.isFolder&&`rct-tree-item-arrow-isFolder`,n.isExpanded&&`rct-tree-item-arrow-expanded`,`rct-tree-item-arrow`)},n.arrowProps),t.isFolder&&(n.isExpanded?G.createElement(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,viewBox:`0 0 16 16`,enableBackground:`new 0 0 16 16`,xmlSpace:`preserve`},G.createElement(`g`,null,G.createElement(`g`,null,G.createElement(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z`,className:`rct-tree-item-arrow-path`})))):G.createElement(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,viewBox:`0 0 16 16`,enableBackground:`new 0 0 16 16`,xmlSpace:`preserve`},G.createElement(`g`,null,G.createElement(`g`,null,G.createElement(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z`,className:`rct-tree-item-arrow-path`}))))))},renderItem:function(t){var n=t.item,r=t.depth,i=t.children,a=t.title,o=t.context,s=t.arrow,c=o.isRenaming?`div`:`button`,l=o.isRenaming?void 0:`button`;return G.createElement(`li`,eB({},o.itemContainerWithChildrenProps,{className:tB(`rct-tree-item-li`,n.isFolder&&`rct-tree-item-li-isFolder`,o.isSelected&&`rct-tree-item-li-selected`,o.isExpanded&&`rct-tree-item-li-expanded`,o.isFocused&&`rct-tree-item-li-focused`,o.isDraggingOver&&`rct-tree-item-li-dragging-over`,o.isSearchMatching&&`rct-tree-item-li-search-match`)}),G.createElement(`div`,eB({},o.itemContainerWithoutChildrenProps,{style:{"--depthOffset":`${(r+1)*e}px`},className:tB(`rct-tree-item-title-container`,n.isFolder&&`rct-tree-item-title-container-isFolder`,o.isSelected&&`rct-tree-item-title-container-selected`,o.isExpanded&&`rct-tree-item-title-container-expanded`,o.isFocused&&`rct-tree-item-title-container-focused`,o.isDraggingOver&&`rct-tree-item-title-container-dragging-over`,o.isSearchMatching&&`rct-tree-item-title-container-search-match`)}),s,G.createElement(c,eB({type:l},o.interactiveElementProps,{className:tB(`rct-tree-item-button`,n.isFolder&&`rct-tree-item-button-isFolder`,o.isSelected&&`rct-tree-item-button-selected`,o.isExpanded&&`rct-tree-item-button-expanded`,o.isFocused&&`rct-tree-item-button-focused`,o.isDraggingOver&&`rct-tree-item-button-dragging-over`,o.isSearchMatching&&`rct-tree-item-button-search-match`)}),a)),i)},renderRenameInput:function(e){var t=e.inputProps,n=e.inputRef,r=e.submitButtonProps,i=e.submitButtonRef,a=e.formProps;return G.createElement(`form`,eB({},a,{className:`rct-tree-item-renaming-form`}),G.createElement(`input`,eB({},t,{ref:n,className:`rct-tree-item-renaming-input`})),G.createElement(`input`,eB({},r,{ref:i,type:`submit`,className:`rct-tree-item-renaming-submit-button`,value:`🗸`})))},renderTreeContainer:function(e){var n=e.children,r=e.containerProps,i=e.info;return G.createElement(`div`,{className:tB(`rct-tree-root`,i.isFocused&&`rct-tree-root-focus`,i.isRenaming&&`rct-tree-root-renaming`,i.areItemsSelected&&`rct-tree-root-itemsselected`,t&&`rct-rtl`)},G.createElement(`div`,eB({},r,{style:eB({minHeight:`30px`},r.style)}),n))},renderItemsContainer:function(e){var t=e.children,n=e.containerProps;return G.createElement(`ul`,eB({},n,{className:`rct-tree-items-container`}),t)},renderDragBetweenLine:function(t){var n=t.draggingPosition,r=t.lineProps;return G.createElement(`div`,eB({},r,{style:{left:`${n.depth*e}px`},className:tB(`rct-tree-drag-between-line`,n.targetType===`between-items`&&n.linePosition===`top`&&`rct-tree-drag-between-line-top`,n.targetType===`between-items`&&n.linePosition===`bottom`&&`rct-tree-drag-between-line-bottom`)}))},renderSearchInput:function(e){var t=e.inputProps;return G.createElement(`div`,{className:tB(`rct-tree-search-input-container`)},G.createElement(`span`,{className:`rct-tree-input-icon`}),G.createElement(`input`,eB({},t,{className:tB(`rct-tree-search-input`)})))},renderLiveDescriptorContainer:function(e){var t=e.tree,n=e.children;return G.createElement(`div`,{id:`rct-livedescription-${t.treeId}`,style:{clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,height:`1px`,overflow:`hidden`,position:`absolute`,whiteSpace:`nowrap`,width:`1px`}},n)},renderDepthOffset:e}},rB=function(e){var t=e.renderItem,n=e.renderItemTitle,r=e.renderItemArrow,i=e.renderRenameInput,a=e.renderItemsContainer,o=e.renderTreeContainer,s=e.renderDragBetweenLine,c=e.renderSearchInput,l=e.renderLiveDescriptorContainer,u=e.renderDepthOffset,d=(0,G.useMemo)(function(){return nB(u??10)},[u]),f={renderItem:t,renderItemTitle:n,renderItemArrow:r,renderRenameInput:i,renderItemsContainer:a,renderTreeContainer:o,renderDragBetweenLine:s,renderSearchInput:c,renderLiveDescriptorContainer:l,renderDepthOffset:u},p=Object.entries(d).reduce(function(e,t){var n=t[0],r=t[1],i=n;return e[i]=f[i]?f[i]:r,e},{});return p.renderItem.displayName=`RenderItem`,p.renderItemTitle.displayName=`RenderItemTitle`,p.renderItemArrow.displayName=`RenderItemArrow`,p.renderRenameInput.displayName=`RenderRenameInput`,p.renderItemsContainer.displayName=`RenderItemsContainer`,p.renderTreeContainer.displayName=`RenderTreeContainer`,p.renderDragBetweenLine.displayName=`RenderDragBetweenLine`,p.renderSearchInput.displayName=`RenderSearchInput`,p},iB=function(e,t,n,r){r===void 0&&(r=0);for(var i=[],a=0,o=n[e]?.children??[];a<o.length;a++){var s=o[a],c=n[s];i.push({item:s,depth:r}),c&&c.isFolder&&c.children&&t.expandedItems?.includes(s)&&i.push.apply(i,iB(s,t,n,r+1))}return i},aB=function(){return aB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},aB.apply(this,arguments)},oB=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},sB=function(e){var t=e.onExpandItem,n=e.onCollapseItem,r=e.onDrop,i=oB(e,[`onExpandItem`,`onCollapseItem`,`onDrop`]),a=(0,G.useState)({}),o=a[0],s=a[1],c=(0,G.useState)(),l=c[0],u=c[1],d=(0,G.useMemo)(function(){return Object.keys(o)},[o]),f=i.onFocusItem,p=i.autoFocus,m=i.onRegisterTree,h=i.onUnregisterTree,g=i.items,_=i.viewState,v=Nz(f),y=Nz(_),b=(0,G.useMemo)(function(){return Az(d,function(e){return iB(o[e].rootItem,_[e]??{},g)})},[o,g,d,_]),x=(0,G.useCallback)(function(e,t,n){var r,i;if(n===void 0&&(n=!0),(p??!0)&&n){var a=jz()?.querySelector(`[data-rct-tree="${t}"] [data-rct-item-id="${e.index}"]`)??jz()?.querySelector(`[data-rct-tree="${t}"] [data-rct-item-id]`);(jz()?.activeElement)?.attributes.getNamedItem(`data-rct-search-input`)?.value===`true`?$z(a):(r=a?.focus)==null||r.call(a)}y.current[t]?.focusedItem!==e.index&&((i=v.current)==null||i.call(v,e,t))},[p,v,y]),S=(0,G.useCallback)(function(e){s(function(t){var n;return aB(aB({},t),(n={},n[e.treeId]=e,n))}),m?.(e)},[m]),C=(0,G.useCallback)(function(e){h?.(o[e]),s(function(t){var n=aB({},t);return delete n[e],n})},[h,o]),w=(0,G.useCallback)(function(e,t){n?.(e,t),s(function(e){return e})},[n]),T=(0,G.useCallback)(function(e,n){t?.(e,n),s(function(e){return e})},[t]),E=(0,G.useCallback)(function(e,t){r?.(e,t),s(function(e){return e})},[r]),D=(0,G.useCallback)(function(e){var t,n=jz()?.querySelector(`[data-rct-tree="${e}"] [data-rct-item-focus="true"]`);(t=n?.focus)==null||t.call(n)},[]),O=(0,G.useCallback)(function(e,t){t===void 0&&(t=!0);var n=function(e){t&&(p??!0)&&e&&!(jz()?.querySelector(`[data-rct-tree="${e}"]`))?.contains(document.activeElement)&&D(e)};if(typeof e==`function`)u(function(t){var r=e(t);return r!==t&&n(r),r});else{var r=e;u(r),n(r)}},[p,D]),k=rB(i);return aB(aB(aB({},k),i),{onFocusItem:x,registerTree:S,unregisterTree:C,onExpandItem:T,onCollapseItem:w,onDrop:E,setActiveTree:O,treeIds:d,trees:o,activeTreeId:l,linearItems:b})},cB=G.createContext(null),lB=function(){return(0,G.useContext)(cB)},uB=G.forwardRef(function(e,t){var n=sB(e),r=e.viewState,i=e.onFocusItem;return(0,G.useEffect)(function(){for(var t=0,a=Object.keys(n.trees);t<a.length;t++){var o=a[t],s=e.items[n.trees[o].rootItem]?.children?.[0],c=s&&e.items[s];!r[o]?.focusedItem&&n.trees[o]&&c&&i?.(c,o,!1)}},[n.trees,i,e.items,r]),G.createElement(cB.Provider,{value:n},G.createElement(Cz,null,G.createElement(Hz,null,G.createElement(Qz,{ref:t},e.children))))}),dB=function(e){var t=e.treeId,n=Vz(),r=n.draggingPosition,i=n.itemHeight,a=KB().renderers;return r&&r.targetType===`between-items`&&r.treeId===t?G.createElement(`div`,{style:{position:`absolute`,left:`0`,right:`0`,top:`${(r?.linearIndex??0)*i}px`}},a.renderDragBetweenLine({draggingPosition:r,lineProps:{onDragOver:function(e){return e.preventDefault()}}})):null},fB=function(e,t,n){var r=Pz(n);(0,G.useEffect)(function(){return e?(e.addEventListener(t,r),function(){return e.removeEventListener(t,r)}):function(){}},[e,r,t])},pB=function(e,t,n){var r=(0,G.useState)(!1),i=r[0],a=r[1],o=(0,G.useRef)(!1),s=Mz();return fB(e,`focusin`,function(){i||(a(!0),t?.()),o.current&&=!1}),fB(e,`focusout`,function(){o.current=!0,s(function(){o.current&&!e?.contains(document.activeElement)&&(n?.(),o.current=!1,a(!1))})}),i},mB=function(e,t,n){fB(jz(),`keydown`,function(r){n&&n&&e.toLowerCase()===r.key.toLowerCase()&&t(r)})},hB={expandSiblings:[`control+*`],moveFocusToFirstItem:[`home`],moveFocusToLastItem:[`end`],primaryAction:[`enter`],renameItem:[`f2`],abortRenameItem:[`escape`],toggleSelectItem:[`control+ `],abortSearch:[`escape`,`enter`],startSearch:[],selectAll:[`control+a`],startProgrammaticDnd:[`control+shift+d`],completeProgrammaticDnd:[`enter`],abortProgrammaticDnd:[`escape`]},gB=function(){return gB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},gB.apply(this,arguments)},_B=function(){var e=lB();return(0,G.useMemo)(function(){return e.keyboardBindings?gB(gB({},hB),e.keyboardBindings):hB},[e.keyboardBindings])},vB=[`input`,`textarea`],yB=function(e,t,n,r){r===void 0&&(r=!1);var i=(0,G.useRef)([]),a=_B(),o=Mz(),s=(0,G.useMemo)(function(){return a[e].map(function(e){return e.split(`+`)})},[e,a]);fB(jz(),`keydown`,function(e){if(n!==!1&&(!vB.includes(e.target.tagName?.toLowerCase())&&!e.target.isContentEditable||r)&&!i.current.includes(e.key)){i.current.push(e.key);var t=i.current.map(function(e){return e.toLowerCase()});s.map(function(e){return t.map(function(t){return e.includes(t.toLowerCase())}).reduce(function(e,t){return e&&t},!0)}).reduce(function(e,t){return e||t},!1)&&(i.current.length>1||!/^[a-zA-Z\s]$/.test(e.key))&&e.preventDefault()}}),fB(jz(),`keyup`,function(e){if(n!==!1){var r=i.current.map(function(e){return e.toLowerCase()});s.map(function(e){return e.map(function(e){return r.includes(e.toLowerCase())}).reduce(function(e,t){return e&&t},!0)}).reduce(function(e,t){return e||t},!1)&&o(function(){return t(e)}),i.current=i.current.filter(function(t){return t!==e.key})}})},bB=function(){var e=KB().treeId;return lB().viewState[e]??{}},xB=function(e){return lB().linearItems[e]},SB=function(){var e=KB().treeId,t=lB(),n=t.onFocusItem,r=t.items,i=xB(e),a=bB();return Pz(function(t){var o=t(i.findIndex(function(e){return e.item===a.focusedItem})??0,i),s=r[i[Math.max(0,Math.min(i.length-1,o))].item];return n?.(s,e),s})},CB=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},wB=function(e){var t=(0,G.useRef)({target:e,previous:void 0});return t.current.target!==e&&(t.current.previous=t.current.target,t.current.target=e),t.current.previous},TB=function(e){var t=bB(),n=KB().treeId,r=xB(n),i=lB().onSelectItems,a=wB(t.focusedItem);return(0,G.useCallback)(function(o,s){s===void 0&&(s=!1);var c=o.index,l=function(e,t){var r=CB(CB([],s?[]:e,!0),t.filter(function(t){return s||!e.includes(t)}),!0);i?.(r,n)};if(t&&t.selectedItems&&t.selectedItems.length>0){var u=t.focusedItem===c?a:t.focusedItem,d=e===`last-focus`?r.findIndex(function(e){return u===e.item}):r.findIndex(function(e){return t.selectedItems?.includes(e.item)}),f=r.findIndex(function(e){return e.item===c});if(d<f){var p=r.slice(d,f+1).map(function(e){return e.item});l(t.selectedItems??[],p)}else{var p=r.slice(f,d+1).map(function(e){return e.item});l(t.selectedItems??[],p)}}else i?.([c],n)},[t,i,n,e,r,a])},EB=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},DB=function(){var e=lB(),t=KB(),n=t.treeId,r=t.setRenamingItem,i=t.setSearch,a=t.renamingItem,o=xB(n),s=Vz(),c=bB(),l=SB(),u=TB(`first-selected`),d=e.activeTreeId===n,f=!!a,p=!e.disableArrowKeys&&d&&!f;mB(`arrowdown`,function(e){if(e.preventDefault(),s.isProgrammaticallyDragging)s.programmaticDragDown();else{var t=l(function(e){return e+1});e.shiftKey&&u(t)}},p),mB(`arrowup`,function(e){if(e.preventDefault(),s.isProgrammaticallyDragging)s.programmaticDragUp();else{var t=l(function(e){return e-1});e.shiftKey&&u(t)}},p),yB(`moveFocusToFirstItem`,function(e){e.preventDefault(),l(function(){return 0})},d&&!s.isProgrammaticallyDragging&&!f),yB(`moveFocusToLastItem`,function(e){e.preventDefault(),l(function(e,t){return t.length-1})},d&&!s.isProgrammaticallyDragging&&!f),mB(`arrowright`,function(t){t.preventDefault(),l(function(t,r){var i,a=e.items[r[t].item];if(a.isFolder){if(c.expandedItems?.includes(a.index))return t+1;(i=e.onExpandItem)==null||i.call(e,a,n)}return t})},p&&!s.isProgrammaticallyDragging),mB(`arrowleft`,function(t){t.preventDefault(),l(function(t,r){var i,a=e.items[r[t].item],o=r[t].depth;if(a.isFolder&&c.expandedItems?.includes(a.index))(i=e.onCollapseItem)==null||i.call(e,a,n);else if(o>0){for(var s=t;r[s].depth!==o-1;--s);return s}return t})},p&&!s.isProgrammaticallyDragging),yB(`primaryAction`,function(t){var r,i;t.preventDefault(),c.focusedItem!==void 0&&((r=e.onSelectItems)==null||r.call(e,[c.focusedItem],n),(i=e.onPrimaryAction)==null||i.call(e,e.items[c.focusedItem],n))},d&&!s.isProgrammaticallyDragging&&!f),yB(`toggleSelectItem`,function(t){var r,i;t.preventDefault(),t.stopPropagation(),c.focusedItem!==void 0&&(c.selectedItems&&c.selectedItems.includes(c.focusedItem)?(r=e.onSelectItems)==null||r.call(e,c.selectedItems.filter(function(e){return e!==c.focusedItem}),n):(i=e.onSelectItems)==null||i.call(e,EB(EB([],c.selectedItems??[],!0),[c.focusedItem],!1),n))},d&&!s.isProgrammaticallyDragging&&!f),yB(`selectAll`,function(t){var r;t.preventDefault(),(r=e.onSelectItems)==null||r.call(e,o.map(function(e){return e.item}),n)},d&&!s.isProgrammaticallyDragging&&!f),yB(`renameItem`,function(t){var i;if(c.focusedItem!==void 0){t.preventDefault();var a=e.items[c.focusedItem];a.canRename!==!1&&((i=e.onStartRenamingItem)==null||i.call(e,a,n),r(a.index))}},d&&(e.canRename??!0)&&!f),yB(`startSearch`,function(e){var t,n;e.preventDefault(),i(``),(n=(t=document.querySelector(`[data-rct-search-input="true"]`))?.focus)==null||n.call(t)},d&&!s.isProgrammaticallyDragging&&!f),yB(`startProgrammaticDnd`,function(e){e.preventDefault(),s.startProgrammaticDrag()},d&&!f),yB(`completeProgrammaticDnd`,function(e){e.preventDefault(),s.completeProgrammaticDrag()},d&&s.isProgrammaticallyDragging&&!f),yB(`abortProgrammaticDnd`,function(e){e.preventDefault(),s.abortProgrammaticDrag()},d&&s.isProgrammaticallyDragging&&!f)},OB=function(e,t,n){return n.toLowerCase().includes(e.toLowerCase())},kB=function(){var e=lB(),t=e.doesSearchMatchItem,n=e.items,r=e.getItemTitle,i=e.onFocusItem,a=KB(),o=a.search,s=a.treeId,c=xB(s),l=Mz();Oz(function(){o&&o.length>0&&l(function(){var e=c.find(function(e){var i=e.item;return(t??OB)(o,n[i],r(n[i]))});e&&i?.(n[e.item],s)})},[t,r,c,n,i,o,s,l],[o])},AB=function(){return AB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},AB.apply(this,arguments)},jB=function(e){var t=e.containerRef,n=KB(),r=n.search,i=n.setSearch,a=n.treeId,o=n.renderers,s=n.renamingItem,c=lB();bB();var l=c.activeTreeId===a,u=Mz();kB();var d=function(){var e;if(i(null),c.autoFocus??!0){var t=jz()?.querySelector(`[data-rct-tree="${a}"] [data-rct-item-focus="true"]`);(e=t?.focus)==null||e.call(t)}};return yB(`abortSearch`,function(){u(function(){d()})},l&&r!==null,!0),fB(t,`keydown`,function(e){var t=e.key.charCodeAt(0);(c.canSearch??!0)&&(c.canSearchByStartingTyping??!0)&&l&&r===null&&!s&&!e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&(t>=48&&t<=57||t>=97&&t<=122)&&i(``)}),!(c.canSearch??!0)||r===null?null:o.renderSearchInput({inputProps:AB({value:r,onChange:function(e){return i(e.target.value)},onBlur:function(){d()},ref:function(e){var t;(t=e?.focus)==null||t.call(e)},"aria-label":`Search for items`},{"data-rct-search-input":`true`})})},MB={introduction:`
|
|
812
|
+
<p>Accessibility guide for tree {treeLabel}.</p>
|
|
813
|
+
<p>
|
|
814
|
+
Navigate the tree with the arrow keys. Common tree hotkeys apply. Further keybindings are available:
|
|
815
|
+
</p>
|
|
816
|
+
<ul>
|
|
817
|
+
<li>{keybinding:primaryAction} to execute primary action on focused item</li>
|
|
818
|
+
<li>{keybinding:renameItem} to start renaming the focused item</li>
|
|
819
|
+
<li>{keybinding:abortRenameItem} to abort renaming an item</li>
|
|
820
|
+
<li>{keybinding:startProgrammaticDnd} to start dragging selected items</li>
|
|
821
|
+
</ul>
|
|
822
|
+
`,renamingItem:`
|
|
823
|
+
<p>Renaming the item {renamingItem}.</p>
|
|
824
|
+
<p>Use the keybinding {keybinding:abortRenameItem} to abort renaming.</p>
|
|
825
|
+
`,searching:`
|
|
826
|
+
<p>Searching</p>
|
|
827
|
+
`,programmaticallyDragging:`
|
|
828
|
+
<p>Dragging items {dragItems}.</p>
|
|
829
|
+
<p>Press the arrow keys to move the drag target.</p>
|
|
830
|
+
<p>Press {keybinding:completeProgrammaticDnd} to drop or {keybinding:abortProgrammaticDnd} to abort.</p>
|
|
831
|
+
`,programmaticallyDraggingTarget:`
|
|
832
|
+
<p>Drop target is {dropTarget}.</p>
|
|
833
|
+
`},NB=function(e,t,n,r,i){var a=function(e){return t.getItemTitle(t.items[e])};return e.replace(/({[^\s}]+)}/g,function(e){var o=e.slice(1,-1);switch(o){case`treeLabel`:return r.treeLabel??``;case`renamingItem`:return r.renamingItem?a(r.renamingItem):`None`;case`dragItems`:return n.draggingItems?.map(function(e){return t.getItemTitle(e)}).join(`, `)??`None`;case`dropTarget`:if(!n.draggingPosition)return`None`;if(n.draggingPosition.targetType===`item`||n.draggingPosition.targetType===`root`)return`within ${a(n.draggingPosition.targetItem)}`;var s=t.items[n.draggingPosition.parentItem],c=t.getItemTitle(s);return n.draggingPosition.childIndex===0?`within ${c} at the start`:`within ${c} after ${a(s.children[n.draggingPosition.childIndex-1])}`;default:if(o.startsWith(`keybinding:`))return i[o.slice(11)][0];throw Error(`Unknown live descriptor variable {${o}}`)}})},PB=function(e){var t=e.children,n=e.live;return G.createElement(`div`,{"aria-live":n,dangerouslySetInnerHTML:{__html:t}})},FB=function(){var e=lB(),t=KB(),n=Vz(),r=_B(),i=(0,G.useMemo)(function(){return e.liveDescriptors??MB},[e.liveDescriptors]),a=t.renderers.renderLiveDescriptorContainer;return t.treeInformation.isRenaming?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.renamingItem,e,n,t,r))):t.treeInformation.isSearching?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.searching,e,n,t,r))):t.treeInformation.isProgrammaticallyDragging?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.programmaticallyDragging,e,n,t,r)),G.createElement(PB,{live:`assertive`},NB(i.programmaticallyDraggingTarget,e,n,t,r))):G.createElement(a,{tree:t},G.createElement(PB,{live:`off`},NB(i.introduction,e,n,t,r)))},IB=function(){return lB().showLiveDescription??!0?G.createElement(FB,null):null},LB=function(){return LB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},LB.apply(this,arguments)},RB=function(){var e=KB(),t=e.treeId,n=e.rootItem,r=e.renderers,i=e.treeInformation,a=lB(),o=(0,G.useRef)(),s=Vz();DB(),pB(o.current,function(){a.setActiveTree(t)},function(){a.setActiveTree(function(e){return e===t?void 0:e})});var c=a.items[n].children,l=G.createElement(G.Fragment,null,G.createElement(IB,null),G.createElement(JB,{depth:0,parentId:n},c??[]),G.createElement(dB,{treeId:t}),G.createElement(jB,{containerRef:o.current})),u=LB({onDragOver:function(e){e.preventDefault(),s.onDragOverTreeHandler(e,t,o)},onDragLeave:function(e){s.onDragLeaveContainerHandler(e,o)},onMouseDown:function(){return s.abortProgrammaticDrag()},ref:o,style:{position:`relative`},role:`tree`,"aria-label":i.treeLabelledBy?void 0:i.treeLabel,"aria-labelledby":i.treeLabelledBy},{"data-rct-tree":t});return r.renderTreeContainer({children:l,info:i,containerProps:u})},zB=function(e,t,n){var r=lB(),i=Vz(),a=r.viewState[e.treeId]?.selectedItems;return(0,G.useMemo)(function(){return{isFocused:r.activeTreeId===e.treeId,isRenaming:!!t,areItemsSelected:(a?.length??0)>0,isSearching:n!==null,search:n,isProgrammaticallyDragging:i.isProgrammaticallyDragging??!1,treeId:e.treeId,rootItem:e.rootItem,treeLabel:e.treeLabel,treeLabelledBy:e.treeLabelledBy}},[r.activeTreeId,e.treeId,e.rootItem,e.treeLabel,e.treeLabelledBy,t,a?.length,n,i.isProgrammaticallyDragging])},BB=function(){return BB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},BB.apply(this,arguments)},VB=function(e,t){var n=lB(),r=KB(),i=Vz();(0,G.useImperativeHandle)(e,function(){return BB(BB(BB({},t),{treeEnvironmentContext:n,dragAndDropContext:i,treeContext:r}),r.treeInformation)})},HB=G.createContext(null),UB=G.forwardRef(function(e,t){lB();var n=KB();Vz();var r=Xz(),i=(0,G.useMemo)(function(){return{abortRenamingItem:function(){n.setRenamingItem(null)},abortSearch:function(){n.setSearch(null)},collapseItem:function(e){r.collapseItem(e,n.treeId)},completeRenamingItem:function(){},expandItem:function(e){r.expandItem(e,n.treeId)},focusItem:function(e,t){t===void 0&&(t=!0),r.focusItem(e,n.treeId,t)},focusTree:function(e){e===void 0&&(e=!0),r.focusTree(n.treeId,e)},invokePrimaryAction:function(e){r.invokePrimaryAction(e,n.treeId)},moveFocusDown:function(){r.moveFocusDown(n.treeId)},moveFocusUp:function(){r.moveFocusUp(n.treeId)},renameItem:function(e,t){r.renameItem(e,t,n.treeId)},selectItems:function(e){r.selectItems(e,n.treeId)},setSearch:function(e){n.setSearch(e)},startRenamingItem:function(e){n.setRenamingItem(e)},stopRenamingItem:function(){n.setRenamingItem(null)},toggleItemExpandedState:function(e){r.toggleItemExpandedState(e,n.treeId)},toggleItemSelectStatus:function(e){r.toggleItemSelectStatus(e,n.treeId)},expandAll:function(){r.expandAll(n.treeId)},collapseAll:function(){r.collapseAll(n.treeId)},expandSubsequently:function(e){return r.expandSubsequently(n.treeId,e)}}},[r,n]);return VB(t,i),G.createElement(HB.Provider,{value:i},e.children)}),WB=function(){return WB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},WB.apply(this,arguments)},GB=G.createContext(null),KB=function(){return(0,G.useContext)(GB)},qB=G.forwardRef(function(e,t){var n,r=lB(),i=(0,G.useMemo)(function(){return WB(WB({},r),e)},[e,r]),a=(0,G.useState)(null),o=a[0],s=a[1],c=(0,G.useState)(null),l=c[0],u=c[1],d=r.items[e.rootItem],f=r.viewState[e.treeId];(0,G.useEffect)(function(){return r.registerTree({treeId:e.treeId,rootItem:e.rootItem}),function(){return r.unregisterTree(e.treeId)}},[e.treeId,e.rootItem]);var p=zB(e,l,o),m=(0,G.useMemo)(function(){return{treeId:e.treeId,rootItem:e.rootItem,treeLabel:e.treeLabel,treeLabelledBy:e.treeLabelledBy,getItemsLinearly:function(){return iB(e.rootItem,f??{},r.items)},treeInformation:p,search:o,setSearch:s,renamingItem:l,setRenamingItem:u,renderers:i}},[r.items,e.rootItem,e.treeId,e.treeLabel,e.treeLabelledBy,l,i,o,p,f]);return d===void 0?((n=r.onMissingItems)==null||n.call(r,[e.rootItem]),null):G.createElement(GB.Provider,{value:m},G.createElement(UB,{ref:t},G.createElement(RB,null)))}),JB=function(e){for(var t=KB(),n=t.renderers,r=t.treeInformation,i=[],a=0,o=e.children;a<o.length;a++){var s=o[a];i.push(G.createElement($B,{key:s,itemIndex:s,depth:e.depth}))}if(i.length===0)return null;var c={role:e.depth===0?void 0:`group`};return n.renderItemsContainer({children:i,info:r,containerProps:c,depth:e.depth,parentId:e.parentId})},YB=function(){return YB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},YB.apply(this,arguments)},XB=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},ZB=function(e){var t=KB(),n=t.treeId,r=t.search,i=t.renamingItem,a=t.setRenamingItem,o=lB(),s=Sz(),c=Vz(),l=TB(`last-focus`),u=e&&o.getItemTitle(e),d=Fz(),f=(0,G.useMemo)(function(){return r===null||r.length===0||!e||!u?!1:(o.doesSearchMatchItem??OB)(r,e,u)},[r,e,u,o.doesSearchMatchItem]),p=e&&(o.viewState[n]?.selectedItems)?.includes(e.index),m=e&&(o.viewState[n]?.expandedItems)?.includes(e.index),h=e&&i===e.index;return(0,G.useMemo)(function(){if(e){var t=o.viewState[n],r=((t?.selectedItems)?.map(function(e){return o.items[e]})??(t?.focusedItem?[o.items[t?.focusedItem]]:[])).filter(function(e){return!!e}),i=!!r.find(function(t){return t.index===e.index}),u=r&&(o.canDrag?.call(o,r)??!0)&&r.map(function(e){return e.canMove??!0}).reduce(function(e,t){return e&&t},!0),g=(o.canDrag?.call(o,[e])??!0)&&(e.canMove??!0),_=o.canDragAndDrop&&(i&&u||!i&&g),v=o.canDragAndDrop&&!!(c.viableDragPositions?.[n])?.find(function(t){return t.targetType===`item`&&t.targetItem===e.index}),y={primaryAction:function(){var t;(t=o.onPrimaryAction)==null||t.call(o,o.items[e.index],n)},collapseItem:function(){var t;(t=o.onCollapseItem)==null||t.call(o,e,n)},expandItem:function(){var t;(t=o.onExpandItem)==null||t.call(o,e,n)},toggleExpandedState:function(){var t,r;m?(t=o.onCollapseItem)==null||t.call(o,e,n):(r=o.onExpandItem)==null||r.call(o,e,n)},selectItem:function(){var t;(t=o.onSelectItems)==null||t.call(o,[e.index],n)},addToSelectedItems:function(){var r;(r=o.onSelectItems)==null||r.call(o,XB(XB([],t?.selectedItems??[],!0),[e.index],!1),n)},unselectItem:function(){var r;(r=o.onSelectItems)==null||r.call(o,(t?.selectedItems)?.filter(function(t){return t!==e.index})??[],n)},selectUpTo:function(t){l(e,t)},startRenamingItem:function(){a(e.index)},stopRenamingItem:function(){a(null)},focusItem:function(t){var r;t===void 0&&(t=!0),(r=o.onFocusItem)==null||r.call(o,e,n,t)},startDragging:function(){var r,i=t?.selectedItems??[];if(i.includes(e.index)||(i=[e.index],(r=o.onSelectItems)==null||r.call(o,i,n)),_){var a=d(n,i.map(function(e){return o.items[e]}));c.onStartDraggingItems(a,n)}}},b={isSelected:p,isExpanded:m,isFocused:t?.focusedItem===e.index,isRenaming:h,isDraggingOver:c.draggingPosition&&c.draggingPosition.targetType===`item`&&c.draggingPosition.targetItem===e.index&&c.draggingPosition.treeId===n,isDraggingOverParent:!1,isSearchMatching:f,canDrag:_,canDropOn:v},x=YB(YB({},s.createInteractiveElementProps(e,n,y,b,t)),{"data-rct-item-interactive":!0,"data-rct-item-focus":b.isFocused?`true`:`false`,"data-rct-item-id":e.index}),S=YB({},{"data-rct-item-container":`true`}),C={role:`treeitem`,"aria-selected":b.isSelected,"aria-expanded":e.isFolder?b.isExpanded?`true`:`false`:void 0},w={onClick:function(){e.isFolder&&y.toggleExpandedState(),y.selectItem()},onFocus:function(){y.focusItem()},onDragOver:function(e){e.preventDefault()},"aria-hidden":!0,tabIndex:-1},T=t?Object.entries(t).reduce(function(t,n){var r=n[0],i=n[1];return t[r]=Array.isArray(i)?i.includes(e.index):i===e.index,t},{}):{};return YB(YB(YB({},y),b),{interactiveElementProps:x,itemContainerWithChildrenProps:C,itemContainerWithoutChildrenProps:S,arrowProps:w,viewStateFlags:T})}},[e,o,n,c,p,m,h,f,s,l,a,d])},QB=function(e){var t=KB(),n=t.renderers,r=t.treeInformation,i=t.setRenamingItem,a=t.treeId,o=lB(),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=o.items[e.itemIndex],u=(0,G.useState)(o.getItemTitle(l)),d=u[0],f=u[1],p=Mz(!0),m=function(){var e;(e=o.onAbortRenamingItem)==null||e.call(o,l,r.treeId),i(null),p(function(){o.setActiveTree(a)})},h=function(){var e;(e=o.onRenameItem)==null||e.call(o,l,d,r.treeId),i(null),p(function(){o.setActiveTree(a)})};Oz(function(){var e,t,n;o.setActiveTree(a),(o.autoFocus??!0)&&((e=s.current)==null||e.select(),(n=(t=s.current)?.focus)==null||n.call(t))},[o,a],[]),yB(`abortRenameItem`,function(){m()},!0,!0);var g={value:d,onChange:function(e){f(e.target.value)},onBlur:function(e){(!e.relatedTarget||e.relatedTarget!==c.current)&&m()},"aria-label":`New item name`,tabIndex:0};return n.renderRenameInput({item:l,inputRef:s,submitButtonProps:{onClick:function(e){e.stopPropagation(),h()}},submitButtonRef:c,formProps:{onSubmit:function(e){e.preventDefault(),h()}},inputProps:g})},$B=function(e){var t,n=(0,G.useState)(!1),r=n[0],i=n[1],a=KB(),o=a.renderers,s=a.treeInformation,c=a.renamingItem,l=lB(),u=bB(),d=l.items[e.itemIndex],f=(0,G.useMemo)(function(){return u.expandedItems?.includes(e.itemIndex)},[e.itemIndex,u.expandedItems]),p=ZB(d);if(d===void 0||p===void 0)return r||(i(!0),(t=l.onMissingItems)==null||t.call(l,[e.itemIndex])),null;var m=l.shouldRenderChildren?.call(l,d,p)??(d.isFolder&&f),h=d.children&&m&&G.createElement(JB,{depth:e.depth+1,parentId:e.itemIndex},d.children),g=l.getItemTitle(d),_=c===e.itemIndex?G.createElement(QB,{itemIndex:e.itemIndex}):o.renderItemTitle({info:s,context:p,title:g,item:d}),v=o.renderItemArrow({info:s,context:p,item:l.items[e.itemIndex]});return o.renderItem({item:l.items[e.itemIndex],depth:e.depth,title:_,arrow:v,context:p,info:s,children:h})??null},eV=`__db_root__`,tV=`__create_table__`;function nV(e,t){return`${e}/${t}`}function rV(e,{canManage:t}){let n={},r=Object.keys(e||{}).sort();for(let t of r){let r=Object.keys(e?.[t]||{}).sort();n[t]={index:t,isFolder:!0,children:r.map(e=>nV(t,e)),data:{kind:`database`,databaseName:t},canMove:!1,canRename:!1};for(let e of r){let r=nV(t,e);n[r]={index:r,isFolder:!1,data:{kind:`table`,databaseName:t,tableName:e},canMove:!1,canRename:!1}}}return n[tV]={index:tV,isFolder:!1,data:{kind:`createTable`},canMove:!1,canRename:!1},n[eV]={index:eV,isFolder:!0,children:[...t?[tV]:[],...r],data:{kind:`root`},canMove:!1,canRename:!1},{items:n,rootId:eV}}function iV({items:e,instanceDatabaseMap:t,children:n}){let r=wg(),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)(``),c=(0,G.useCallback)(t=>{let n=t.target.closest(`[data-rct-item-id]`)?.getAttribute(`data-rct-item-id`),r=n?e[n]?.data:void 0;if(!r||r.kind===`root`||r.kind===`createTable`){a(void 0),t.preventDefault();return}a(r),s(`${t.clientX},${t.clientY}`)},[e]);return(0,K.jsxs)(Am,{modal:!1,children:[(0,K.jsx)(jm,{asChild:!0,children:(0,K.jsx)(`div`,{onContextMenu:c,className:`min-h-full`,children:n})}),i&&(0,K.jsxs)(Mm,{className:`min-w-44`,onCloseAutoFocus:e=>e.preventDefault(),children:[i.kind===`database`&&r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Nm,{onSelect:()=>rL(`ShowCreateTable`,{databaseName:i.databaseName}),children:[(0,K.jsx)(Uo,{}),`Create a Table`]}),(0,K.jsx)(Fm,{}),(0,K.jsxs)(Nm,{variant:`destructive`,onSelect:()=>rL(`ShowDeleteDatabase`,{databaseName:i.databaseName}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})]}),i.kind===`table`&&(0,K.jsx)(ez,{databaseName:i.databaseName,tableName:i.tableName,instanceDatabaseMap:t})]},o)]})}function aV(e){switch(e.data.kind){case`createTable`:return`Create a Table`;case`database`:return e.data.databaseName;case`table`:return e.data.tableName;default:return``}}var oV=`mr-1.5 h-4 w-4 shrink-0 pointer-events-none`;function sV({title:e,item:t}){let n=t.data.kind;return(0,K.jsxs)(K.Fragment,{children:[n===`createTable`?(0,K.jsx)(Uo,{className:F(oV,`text-green-500`)}):n===`database`?(0,K.jsx)(ia,{className:F(oV,`text-orange-400`)}):(0,K.jsx)(Es,{className:oV}),(0,K.jsx)(`span`,{className:`text-nowrap pointer-events-none`,children:e})]})}function cV({databaseName:e,tableName:t}){let{entityId:n}=q(),r=(0,G.useMemo)(()=>e&&t?[nV(e,t)]:e?[e]:[],[e,t]),[i,a]=(0,G.useState)(r[0]);(0,G.useEffect)(()=>{r[0]!==void 0&&a(r[0])},[r]);let[o,s]=FC(`DatabaseTreeExpanded/${n}`,e?[e]:[]);return(0,G.useEffect)(()=>{e&&s(t=>t.includes(e)?t:[...t,e])},[e,s]),{focusedItem:i,setFocusedItem:a,expandedItems:o,setExpandedItems:s,selectedItems:r}}var lV={"--rct-drop-target-height":`0px`};function uV({instanceDatabaseMap:e}){let t=z({strict:!1}),n=De(),r=wg(),{items:i,rootId:a}=(0,G.useMemo)(()=>rV(e,{canManage:r}),[e,r]),{focusedItem:o,setFocusedItem:s,expandedItems:c,setExpandedItems:l,selectedItems:u}=cV(t),d=(0,G.useCallback)((e,r)=>{n({to:jP({...t,databaseName:e,tableName:r})})},[n,t]),f=(0,G.useCallback)(e=>{switch(e.kind){case`createTable`:rL(`ShowCreateTable`,{databaseName:t.databaseName});break;case`database`:(t.databaseName!==e.databaseName||t.tableName)&&d(e.databaseName,void 0);break;case`table`:(t.databaseName!==e.databaseName||t.tableName!==e.tableName)&&d(e.databaseName,e.tableName)}},[t.databaseName,t.tableName,d]),p=(0,G.useCallback)(e=>{let t=e[e.length-1],n=t===void 0?void 0:i[t]?.data;n&&f(n)},[i,f]);return(0,K.jsx)(`div`,{className:`app-tree-scroll h-full overflow-auto pr-1.5`,style:lV,children:(0,K.jsx)(iV,{items:i,instanceDatabaseMap:e,children:(0,K.jsx)(uB,{canDragAndDrop:!1,canReorderItems:!1,canSearch:!0,canRename:!1,defaultInteractionMode:pz.DoubleClickItemToExpand,getItemTitle:aV,items:i,renderItemArrow:fz,renderItemTitle:sV,viewState:{databasesTree:{focusedItem:o,expandedItems:c,selectedItems:u}},onFocusItem:e=>s(e.index),onExpandItem:e=>l(t=>t.includes(e.index)?t:[...t,e.index]),onCollapseItem:e=>l(t=>t.filter(t=>t!==e.index)),onSelectItems:p,children:(0,K.jsx)(qB,{treeId:`databasesTree`,rootItem:a,treeLabel:`Databases tree`})})})})}function dV({instanceDatabaseMap:e}){return(0,K.jsxs)(`div`,{className:`pl-3 flex flex-col h-full min-h-0`,children:[(0,K.jsx)(`h1`,{className:`pt-3 pb-3 text-3xl shrink-0`,children:`Databases`}),e?(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(uV,{instanceDatabaseMap:e})}):(0,K.jsx)(my,{className:`w-full flex-1 min-h-0 rounded-md`})]})}var fV=new Set([`contains`,`ends_with`,`ne`,`not_equal`]);function pV(e,t,n={}){let r=new Map;for(let{search_attribute:i,search_type:a}of e){let[e,o]=Array.isArray(i)?i:[i],s=o!==void 0&&Object.hasOwn(n,e)?n[e]:void 0,c=s?s.relatedAttributes.find(e=>e.attribute===o):t[e];if((c?.is_primary_key||c?.indexed)&&!fV.has(a))return[];let l=o===void 0?e:`${e}.${o}`;r.set(l,{attribute:l,relatedTableName:s?.relatedTableName})}return[...r.values()]}function mV(e,t){return`No index can answer this filter on ${t.map(({attribute:e})=>`"${e}"`).join(`, `)}, so Harper will read every record in ${[...new Set(t.map(t=>t.relatedTableName??e))].map(e=>`"${e}"`).join(` and `)} to find the matches. On a large table that can take a long time and slow the server down for everyone using it.\n\nRun it anyway?`}function hV(e,t,n){if(!n||!e?.length)return;let r=new Set;for(let t of e){let e=t[n];e!=null&&r.add(e)}let i=new Set;for(let e of t){let t=e[n];t!=null&&i.add(t)}let a=[...r].filter(e=>!i.has(e));if(a.length)return{kind:`lost`,keys:a};let o=[...i].filter(e=>!r.has(e));if(o.length)return{kind:`unknown`,keys:o};let s=e.filter(e=>e[n]==null).length,c=t.filter(e=>e[n]==null).length;if(c!==s)return{kind:`keyless`,added:Math.max(0,c-s),dropped:Math.max(0,s-c)}}function gV(e,t,n){if(!n||!e?.length)return[];let r=new Map(e.map(e=>[e[n],e])),i=[];for(let[e,a]of t.entries()){let t=a[n];if(t==null)continue;let o=r.get(t);if(!o)continue;let s=Object.keys(o).filter(e=>!Object.hasOwn(a,e));s.length&&i.push({index:e,removed:s})}return i}function _V(e){return[...new Set(e.flatMap(e=>e.removed))]}function vV({canEditRecords:e,canDeleteRecords:t,canReplaceRecords:n,replaceBlockedReason:r,setIsModalOpen:i,isModalOpen:a,primaryKey:o,missingPrimaryKey:s,recordUnavailable:c,syntheticAttributes:l,recordNavigation:u,data:d,onSaveChanges:f,onReplaceRecord:p,onDeleteRecord:m,isUpdateTableRecordsPending:h,isDeleteTableRecordsPending:g}){let _=Tx(),v=(0,G.useRef)(null),y=!!s||!!c,b=!e||y,[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(),{onEditorMount:T,showRecordJsonError:E,clearRecordJsonError:D}=II(),O=(0,G.useMemo)(()=>d?.map(({__createdtime__:e,__updatedtime__:t,...n})=>{for(let e of l??[])delete n[e];return n}),[d,l]),k=(0,G.useMemo)(()=>O&&JSON.stringify(O,null,4),[O]),A=k??``,j=(0,G.useRef)(A),M=(0,G.useRef)(null);(0,G.useLayoutEffect)(()=>{j.current!==A&&(j.current=A,M.current=A)},[A]);let ee=(0,G.useMemo)(()=>d&&JSON.stringify(d.map(e=>e[o]??null)),[d,o]),te=a?k:null,N=a?ee:null,[P,F]=(0,G.useState)(te),[ne,re]=(0,G.useState)(N),[ie,ae]=(0,G.useState)(!1),[oe,se]=(0,G.useState)(!1);te!==P&&(ae(a&&N!=null&&N===ne&&x),F(te),re(N),w(void 0),S(!1));let ce=a&&(d!==void 0||oe);oe!==ce&&se(ce);let le=h||g,ue=e=>{(!x||confirm(`Discard your unsaved changes to this record?`))&&(w(void 0),S(!1),ae(!1),e())};return(0,K.jsx)(_m,{onOpenChange:i,open:a,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,autoFocus:!b,onKeyDown:e=>{if(!u||le||v.current?.contains(e.target))return;let t=e.key===`ArrowLeft`||e.key===`ArrowUp`?u.hasPrevious?u.onPrevious:void 0:(e.key===`ArrowRight`||e.key===`ArrowDown`)&&u.hasNext?u.onNext:void 0;t&&(e.preventDefault(),ue(t))},onEscapeKeyDown:b?void 0:e=>{x&&e.preventDefault()},children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[b?`View`:`Edit`,` Record`]})}),y&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:s?`This record has no primary key value`:`This record couldn't be loaded`}),(0,K.jsxs)(u_,{children:[(0,K.jsx)(`p`,{children:s?o?(0,K.jsxs)(K.Fragment,{children:[`It has no value for the primary key`,` `,(0,K.jsx)(`code`,{children:o}),`, so it can't be looked up, edited, or deleted individually.`]}):`It has no primary key value, so it can't be looked up, edited, or deleted individually.`:o?(0,K.jsxs)(K.Fragment,{children:[`Nothing is stored under its primary key`,` `,(0,K.jsx)(`code`,{children:o}),`, so it can't be edited or deleted individually.`]}):`Nothing is stored under its primary key, so it can't be edited or deleted individually.`}),(0,K.jsx)(`p`,{children:`This usually means the table's primary key was changed after the record was created, so the value shown here isn't the key the record is actually stored under. To remove it, recreate the table or restore the original primary key attribute.`})]})]}),ie&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:`This record changed while you were editing it`}),(0,K.jsx)(u_,{children:`The editor was refreshed with the stored record, so the unsaved changes were discarded. Make them again and save.`})]}),d||oe?(0,K.jsx)(`div`,{ref:v,className:`flex-1 min-h-0 w-full`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:xI,theme:_,options:{readOnly:b||!d,automaticLayout:!0},value:A,onMount:T,onChange:e=>{let t=M.current!==null&&e===M.current;M.current=null,!t&&(w(e),S(!0),ae(!1),D())}})}):(0,K.jsx)(Lc,{}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 w-full`,children:[(0,K.jsx)(`div`,{className:`flex`,children:t&&!y&&(0,K.jsxs)(H,{variant:`destructive`,type:`button`,autoFocus:!1,onClick:()=>{let e=d?.[0]?.[o];e!=null&&m([e])},disabled:g||h,children:[(0,K.jsx)(Is,{}),` Delete Record`]})}),u&&(0,K.jsx)(yV,{...u,disabled:le,onPrevious:()=>ue(u.onPrevious),onNext:()=>ue(u.onNext)}),(0,K.jsx)(`div`,{className:`flex`,children:e&&!y&&(0,K.jsxs)(H,{variant:`submit`,autoFocus:!0,accessKey:`s`,onClick:()=>{if(C===void 0){i(!1);return}let e=TI(C);if(!e.ok){U.error(`This record isn't valid JSON`,{description:DI(e.error)}),E(e.error);return}let t=Array.isArray(e.value)?e.value:[e.value],a=hV(O,t,o);if(a){U.error(a.kind===`lost`?`This record's ${o} is missing from the save`:a.kind===`unknown`?`This edit names a ${o} the editor didn't load`:`This edit ${a.added?`adds`:`drops`} ${(a.added||a.dropped)===1?`a record`:`${a.added||a.dropped} records`} with no ${o}`,{description:a.kind===`lost`?`${o} identifies the record, so restore ${a.keys.join(`, `)} to save this edit. Changing it doesn't rename a record — the save would do nothing, or overwrite whatever is stored under the new value. To delete the record, use Delete Record.`:a.kind===`unknown`?`Saving would edit the record stored under ${a.keys.join(`, `)}, which isn't the record open here. Remove it from the JSON and edit that record directly.`:a.added?`A record with no ${o} can't be written from here — the save would skip it and still report success. Remove it, and use Add Record to create a record.`:`Removing a record from the JSON doesn't delete it, so the save would report success having left it alone. Put it back, and use Delete Record to delete a record.`});return}let s=gV(O,t,o);if(s.length){if(s.length<t.length){U.error(`Removing an attribute can't be combined with other record edits`,{description:`Removing an attribute replaces the whole record, which would overwrite any concurrent change to the other records in this payload. Remove the same attribute from every record here, or put it back and save the value changes on their own — the records loaded together have to be saved together.`});return}if(!n){let e=_V(s),t=e.length===1?`an attribute`:`attributes`,n=`Removing ${e.join(`, `)}`;U.error(r===`permission`?`You don't have permission to remove ${t}`:`This Harper version can't remove ${t}`,{description:r===`permission`?`${n} rewrites the record through the 'put' operation, which needs both insert and update on this table, and 'put' in the role's allowed operations. Ask an administrator for those grants, or set the value to null instead of removing it.`:`${n} needs the 'put' operation, added in Harper 5.3.0. On this instance the update operation can only merge, so the attribute would silently stay. Upgrade the instance, or set the value to null instead of removing it.`});return}p(t);return}f(t)},disabled:h||g,children:[(0,K.jsx)($o,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`S`}),`ave Changes`]})]})})]})})]})})}function yV({position:e,total:t,isTotalEstimated:n,hasPrevious:r,hasNext:i,onPrevious:a,onNext:o,disabled:s}){return(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-border text-sm text-muted-foreground`,children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Previous record`,disabled:s||!r,onClick:a,children:(0,K.jsx)(bi,{})}),(0,K.jsxs)(`span`,{className:`whitespace-nowrap px-1 tabular-nums`,"aria-live":`polite`,children:[`Record `,e===void 0?`…`:By(e),t!==void 0&&(0,K.jsxs)(K.Fragment,{children:[` of `,n?`~`:``,By(t)]})]}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Next record`,disabled:s||!i,onClick:o,children:(0,K.jsx)(Si,{})})]})}function bV(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||e[i]!==t[i])return!1;return!0}function xV(e,t){let[n,r]=(0,G.useState)(t),[i,a]=(0,G.useState)(e);return(0,G.useEffect)(()=>{bV(n,t)||(r(t),a(e))},[n,t,e]),bV(n,t)?[i,a]:[e,a]}function SV(e=!1){let[t,n]=(0,G.useState)(e),r=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(e=>!e)},[]),i=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(!0)},[]),a=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(!1)},[]);return(0,G.useMemo)(()=>({toggled:t,setToggled:n,toggle:r,toggleOn:i,toggleOff:a}),[r,n,a,i,t])}async function CV({databaseName:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`cleanup_orphan_blobs`,database:e});return n}function wV(){return I({mutationFn:CV})}function TV(e){return e!==void 0&&!Array.isArray(e)}var EV=`Harper's response didn't report which records it wrote, so the change may not have been saved.`;function DV(e,t){if(!Array.isArray(e?.deleted_hashes)||TV(e?.skipped_hashes))return{message:EV,wroteNothing:!1};let n=e.skipped_hashes?.length??0,r=e.deleted_hashes.length;if(!(n===0&&r>=t))return{message:`Harper deleted ${r} of ${t} records${n>0?` and skipped ${n}`:``}. A record is skipped when nothing is stored under its primary key.`,wroteNothing:r===0}}async function OV({databaseName:e,tableName:t,hashValues:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`delete`,database:e,table:t,hash_values:n});return i}function kV(){return I({mutationFn:OV})}async function AV({databaseName:e,tableName:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`describe_table`,database:e,table:t,exact_count:!0},{timeout:0});return r.record_count}function jV(e){return B({enabled:e.enabled&&!!e.databaseName&&!!e.tableName,queryKey:[e.entityId,e.databaseName,e.tableName,`record_count`,`exact`],queryFn:()=>AV(e),staleTime:6e4,gcTime:5e3,retry:!1})}function MV(e){return!!e&&vr(`5.3.0`,e)}function NV(e,t){if(!t)return`permission`;if(e!==void 0&&!MV(e))return`version`}async function PV({databaseName:e,tableName:t,records:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`put`,database:e,table:t,records:n});return i}function FV(e,t){if(!Array.isArray(e?.put_hashes))return{message:EV,wroteNothing:!1};if(!(e.put_hashes.length>=t))return{message:`Harper reported writing ${e.put_hashes.length} of ${t} records, so the change may not have been saved.`,wroteNothing:e.put_hashes.length===0}}function IV(){return I({mutationFn:PV})}function LV(e,t){if(TV(e?.update_hashes)||TV(e?.skipped_hashes))return{message:EV,wroteNothing:!1};let n=e?.skipped_hashes?.length??0,r=e?.update_hashes?.length??t;if(!(n===0&&r>=t))return{message:`Harper updated ${r} of ${t} records${n>0?` and skipped ${n}`:``}. A record is skipped when nothing is stored under its primary key.`,wroteNothing:Array.isArray(e?.update_hashes)&&r===0}}async function RV(e){let{databaseName:t,tableName:n,records:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`update`,database:t,table:n,records:r});return a}function zV(){return I({mutationFn:RV})}var BV=ee(x(),x());function VV({applyFilters:e,columnFiltersForm:t,headerGroups:n,selectColumnWidth:r}){let i=(0,G.useCallback)(t=>{if(t.key===`Enter`)return t.preventDefault(),e(),!1},[e]);return(0,K.jsx)(xb,{children:(0,K.jsx)(Od,{...t,children:n.map(e=>(0,K.jsxs)(Cb,{className:`border-none`,children:[r!==void 0&&(0,K.jsx)(Eb,{style:{width:`${r}px`},className:`sticky top-10 left-0 z-20 bg-card dark:bg-black-dark border-b border-border shadow-[inset_-1px_0_0_var(--color-border)]`}),e.headers.map(e=>{let n=e.column.columnDef.meta?.relationshipInfo,r=e.column.columnDef.meta?.unindexed;return(0,K.jsx)(Eb,{style:{width:`${e.column.getSize()}px`},className:`sticky top-10 z-10 bg-card dark:bg-black-dark border-b border-border`,children:e.column.columnDef.enableColumnFilter&&(0,K.jsx)(Y,{control:t.control,name:e.id,render:({field:t})=>(0,K.jsxs)(X,{className:`border-r border-r-black`,children:[(0,K.jsxs)(`div`,{className:`flex items-center`,children:[n&&(0,K.jsx)(HV,{relationshipInfo:n,value:t.value??``,onChange:t.onChange}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,className:`rounded-none`,onKeyDown:i,value:t.value??``,placeholder:n?`.${n.relatedPrimaryKey} value`:r?`not indexed`:void 0,"aria-label":`Filter ${e.column.id}`,title:e.column.columnDef.meta?.filterHint})})]}),(0,K.jsx)(Q,{})]})})},e.id)})]},e.id))})})}function HV({relationshipInfo:e,value:t,onChange:n}){return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`rounded-none shrink-0`,title:`Filter by a ${e.relatedTableName} property`,children:(0,K.jsx)(er,{})})}),(0,K.jsx)(vc,{side:`bottom`,align:`start`,children:e.relatedAttributes.map(e=>(0,K.jsxs)(yc,{onClick:()=>{let r=t.replace(/^\s*\.\S*\s*/,``);n(`.${e.attribute} ${r}`)},children:[e.attribute,e.type&&(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.type})]},e.attribute))})]})}function UV({tableName:e,hasPrimaryKey:t,isFiltered:n,isPastFirstPage:r,recordCount:i,canImportFile:a,canImportUrl:o,canSeedSample:s,canSeedRandom:c,canAddRecords:l,onImport:u,onSeed:d,onAddRecords:f,onClearFilters:p}){if(!t)return(0,K.jsxs)(KV,{children:[(0,K.jsxs)(qV,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),` has no primary key`]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`It reports ${oe(By(i),`record`,`records`)}, but Studio`:`Studio`,` `,`lists and opens records by their primary key, so it can't browse this table. To browse its records here, copy them into a new table that has a primary key.`]})]});if(r)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records on this page`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`There are fewer records than this page starts at. Try an earlier page.`})]});if(n)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records match these filters`}),(0,K.jsxs)(H,{variant:`ghost`,onClick:p,children:[(0,K.jsx)(Sa,{}),`Clear Filters`]})]});if(i)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records came back`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This table reports records, but the page returned none. Try refreshing, or turn off Only If Cached in the table options menu.`})]});let m=a||o,h=s||c;return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:i===0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),` has no records yet`]}):`No records to show`}),m&&h&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Two ways to get some in — bring your own, or start from data we provide.`}),(m||h)&&(0,K.jsxs)(`div`,{className:`flex w-full flex-col gap-3 sm:flex-row`,children:[m&&(0,K.jsx)(JV,{Icon:Ji,title:`Import your data`,description:WV(a,o),action:`Import data`,onClick:u}),h&&(0,K.jsx)(JV,{Icon:Fo,title:`Seed some data`,description:GV(s,c),action:`Seed data`,onClick:d})]}),l&&(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m||h?`Or write one yourself: `:`Write one yourself: `,(0,K.jsxs)(H,{variant:`link`,className:`h-auto p-0 text-sm dark:text-violet-300`,onClick:f,children:[(0,K.jsx)(Uo,{}),`Add New Record(s)`]})]})]})}function WV(e,t){return e?t?`Upload a CSV or JSON file, or load a CSV from a URL the instance can reach.`:`Upload a CSV or JSON file.`:`Load a CSV from a URL the instance can reach.`}function GV(e,t){return e?t?`Fill this table with random records, or load a ready-made sample dataset into a table of its own.`:`Load a ready-made sample dataset. It arrives in a table of its own.`:`Fill this table with random records modelled on its columns.`}function KV({children:e}){return(0,K.jsx)(`div`,{className:`h-full overflow-y-auto p-6`,children:(0,K.jsx)(`div`,{className:`flex min-h-full items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col items-center gap-4 text-center`,children:[(0,K.jsx)(Os,{"aria-hidden":!0,className:`size-8 text-muted-foreground/50`}),e]})})})}function qV({children:e}){return(0,K.jsx)(`h2`,{className:`text-base font-medium`,children:e})}function JV({Icon:e,title:t,description:n,action:r,onClick:i}){return(0,K.jsxs)(`button`,{type:`button`,onClick:i,className:`group flex flex-1 cursor-pointer flex-col items-start gap-1.5 rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:ring-1 focus-visible:ring-purple-200 focus-visible:outline-1 dark:border-grey-700 dark:hover:border-violet-300`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,K.jsx)(e,{className:`size-4 text-primary dark:text-violet-300`}),t]}),(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:n}),(0,K.jsxs)(`span`,{className:`mt-1 text-sm text-primary group-hover:underline dark:text-violet-300`,children:[r,` →`]})]})}var YV={text:`Text`,number:`Numbers`,date:`Dates`,boolean:`Booleans`};function XV({id:e}){return(0,K.jsxs)(`section`,{id:e,"aria-label":`Filter syntax`,className:`mx-4 mb-3 rounded-md border border-border p-3 text-sm [font-variant-ligatures:none]`,children:[(0,K.jsx)(`dl`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2 lg:grid-cols-4`,children:Object.keys(ZL).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`font-semibold`,children:YV[e]}),ZL[e].map(e=>(0,K.jsx)(`dd`,{className:`font-mono text-xs`,children:e},e))]},e))}),(0,K.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`A relationship column filters on a property of the related table:`,` `,(0,K.jsx)(`code`,{children:`.name Anvil`}),`. A filter that no index can answer (a column marked “not indexed”, an ends with, a contains or a !=) asks before it runs, unless another filter in it uses an index.`]})]})}function ZV({columns:e,columnVisibility:t,setColumnVisibility:n}){let r=(0,G.useMemo)(()=>e.map(e=>typeof e.header==`string`?e.header:void 0).filter(fr),[e]),i=(0,G.useCallback)((e,r)=>{n({...t,[e]:r})},[t,n]),a=(0,G.useCallback)(e=>{n({...t,...Object.fromEntries(r.map(t=>[t,e]))})},[r,t,n]),o=(0,G.useMemo)(()=>r.every(e=>t[e]??!0),[r,t]),s=(0,G.useMemo)(()=>r.every(e=>!(t[e]??!0)),[r,t]);return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`ghost`,children:[(0,K.jsx)(Qi,{className:`inline-block `}),`Columns`]})}),(0,K.jsxs)(vc,{children:[r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yc,{inset:!0,disabled:o,onSelect:e=>{e.preventDefault(),a(!0)},children:`Select all`}),(0,K.jsx)(yc,{inset:!0,disabled:s,onSelect:e=>{e.preventDefault(),a(!1)},children:`Deselect all`}),(0,K.jsx)(wc,{})]}),r.map(e=>(0,K.jsx)(QV,{columnHeader:e,isChecked:t[e]??!0,toggleColumn:i},e))]})]})}function QV({columnHeader:e,isChecked:t,toggleColumn:n}){let r=(0,G.useCallback)(t=>{n(e,t)},[e,n]);return(0,K.jsx)(bc,{checked:t,onCheckedChange:r,onSelect:e=>e.preventDefault(),children:e})}function $V({className:e}){return(0,K.jsx)(no,{className:v(`animate-spin`,e)})}var eH=32,tH=`shadow-[inset_-1px_0_0_var(--color-border)]`;function nH(e,t){return!t||typeof e!=`object`||!e||!Object.hasOwn(e,t)?void 0:e[t]??void 0}function rH({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,emptyState:s,isFetching:c,onColumnClick:l,onRowClick:u,pageIndex:d,pageSize:f,primaryKey:p,rowSelection:m,resultSetKey:h,tableIdentity:g,setPageIndex:_,setPageSize:v,filtersToggled:y,totalPages:b,totalRecords:x,uncountedPage:S,isEstimatedCount:C,estimatedRange:w,isExactCountFetching:T,isExactCountError:E,onRequestExactCount:D}){let O=tt({features:Lb,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),k=!!m&&!!p,A=(0,G.useMemo)(()=>k?(o??[]).map(e=>nH(e,p)).filter(e=>e!==void 0):[],[k,o,p]),j=m?A.filter(e=>m.selectedKeys.has(e)).length:0,M=A.length>0&&j===A.length,ee=j>0&&!M,[te,N]=(0,G.useState)(void 0),P=(0,G.useCallback)((e,t)=>{if(!m)return;let n=t?A.indexOf(te):-1,r=A.indexOf(e);if(n===-1||r===-1){m.toggleRow(e),N(e);return}let[i,a]=n<=r?[n,r]:[r,n];m.setRangeSelected(A.slice(i,a+1),!m.selectedKeys.has(e))},[m,A,te]),ne=(0,G.useRef)(null),re=(0,G.useRef)(!1),ie=(0,G.useRef)(!1),ae=(0,G.useCallback)((e,t)=>{!m||e===void 0||t.button!==0||t.shiftKey||t.ctrlKey||t.metaKey||(re.current=!0,ne.current={originKey:e,selected:!m.selectedKeys.has(e),snapshot:new Set(m.selectedKeys),applied:[],lastKey:e})},[m]),oe=(0,G.useCallback)((e,t)=>{let n=ne.current;if(!n)return;if(!(t&1)){ne.current=null;return}if(!m||e===void 0||e===n.lastKey)return;let r=A.indexOf(n.originKey),i=A.indexOf(e);if(r===-1||i===-1)return;n.lastKey=e;let[a,o]=r<=i?[r,i]:[i,r],s=A.slice(a,o+1),c=new Set(s),l=n.applied.filter(e=>!c.has(e)),u=l.filter(e=>n.snapshot.has(e)),d=l.filter(e=>!n.snapshot.has(e));u.length&&m.setRangeSelected(u,!0),d.length&&m.setRangeSelected(d,!1),m.setRangeSelected(s,n.selected),n.applied=s,N(n.originKey),ie.current=!0},[m,A]);(0,G.useEffect)(()=>{let e=()=>{ne.current=null},t=()=>{re.current=!1,ie.current=!1};return window.addEventListener(`mouseup`,e),window.addEventListener(`mousedown`,t,!0),()=>{window.removeEventListener(`mouseup`,e),window.removeEventListener(`mousedown`,t,!0)}},[]),(0,G.useLayoutEffect)(()=>{N(void 0),ne.current=null},[h]);let se=(0,G.useRef)(null),[ce,le]=(0,G.useState)(0);(0,G.useLayoutEffect)(()=>{let e=se.current;e&&(e.scrollTop=0)},[h]),(0,G.useLayoutEffect)(()=>{let e=se.current;e&&(e.scrollTop=0,e.scrollLeft=0)},[g]);let ue=O.state.columnResizing,de=ue.isResizingColumn;(0,G.useLayoutEffect)(()=>{de&&le(se.current?.scrollLeft??0)},[de]);let fe=null;if(de){let e=O.options.defaultColumn?.minSize??20,t=O.getColumn(de)?.getSize()??0,n=k?eH:0;for(let e of O.getVisibleLeafColumns())if(n+=e.getSize(),e.id===de)break;fe=n+Math.max(ue.deltaOffset??0,e-t)-ce}let pe=O.getRowModel().rows.length>0,me=o===void 0,he=!pe&&!me&&!!s;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow min-h-0`,children:[(0,K.jsxs)(bb,{containerRef:se,containerClassName:F(`rounded-t-md bg-card dark:bg-black-dark min-h-0 overflow-y-auto`,he?`shrink-0`:`rounded-b-md grow`),className:`table-fixed`,children:[(0,K.jsx)(xb,{children:O.getHeaderGroups().map(e=>(0,K.jsxs)(Cb,{className:`border-none`,children:[k&&(0,K.jsx)(wb,{style:{width:`${eH}px`},className:F(`sticky top-0 left-0 z-20 p-0 bg-card dark:bg-black-dark border-b border-border`,tH),children:(0,K.jsx)(iH,{checked:M,indeterminate:ee,disabled:A.length===0,onToggle:()=>{m.toggleAll(A,!M),N(M?void 0:A[0])}})}),e.headers.map(e=>(0,K.jsx)(Tb,{header:e,onColumnClick:l,className:`sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border font-mono text-[0.8rem] [&_button]:text-[0.8rem]`},e.id)),(0,K.jsx)(wb,{"aria-hidden":!0,className:`w-full p-0 sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),y&&(0,K.jsx)(VV,{applyFilters:e,columnFiltersForm:t,headerGroups:O.getHeaderGroups(),selectColumnWidth:k?eH:void 0}),!he&&(0,K.jsx)(Sb,{className:`bg-background dark:bg-black border-y border-border dark:border-grey-700`,children:pe?O.getRowModel().rows.map(e=>(0,K.jsx)(oH,{row:e,onRowClick:u,primaryKey:p,rowSelection:k?m:void 0,onSelectRow:P,onBeginDrag:ae,onDragOver:oe,pressedInGutterRef:re,dragMovedRef:ie},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:n.length+1+ +!!k,className:`h-24 text-center`,children:c||me?(0,K.jsx)($V,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),he&&(0,K.jsx)(`div`,{className:`grow min-h-0 rounded-b-md bg-background dark:bg-black border border-t-0 border-border dark:border-grey-700`,children:s}),fe!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${fe}px`}})]}),(0,K.jsx)(Ob,{pageIndex:d,pageSize:f,totalPages:b,totalRecords:x,uncountedPage:S,isEstimatedCount:C,estimatedRange:w,isExactCountFetching:T,isExactCountError:E,onRequestExactCount:D,setPageIndex:_,setPageSize:v})]})}function iH({checked:e,indeterminate:t,disabled:n,onToggle:r}){let i=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{i.current&&(i.current.indeterminate=t)},[t]),(0,K.jsx)(aH,{children:(0,K.jsx)(`input`,{ref:i,type:`checkbox`,"aria-label":e?`Deselect all records on this page`:`Select all records on this page`,checked:e,disabled:n,onChange:r})})}function aH({children:e}){return(0,K.jsx)(`label`,{className:`flex h-full w-full items-center justify-center py-2`,children:e})}function oH({row:e,primaryKey:t,onRowClick:n,rowSelection:r,onSelectRow:i,onBeginDrag:a,onDragOver:o,pressedInGutterRef:s,dragMovedRef:c}){let l=e.getVisibleCells(),u=(0,G.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?l[0]?.column?.id===t?[(0,K.jsx)(cH,{cell:l[0]},l[0].id),(0,K.jsx)(lH,{colSpan:l.length-1},`expired`)]:[(0,K.jsx)(lH,{colSpan:l.length},`expired`)]:l.map(e=>(0,K.jsx)(cH,{cell:e},e.id))},[e,t,l]),d=r?nH(e.original,t):void 0,f=d!==void 0&&!!r?.selectedKeys.has(d);return(0,K.jsxs)(Cb,{"data-state":f?`selected`:void 0,onMouseOver:e=>o?.(d,e.buttons),onMouseDown:e=>{r&&e.shiftKey&&e.preventDefault()},onClick:t=>{if(!s?.current){if(r&&d!==void 0&&(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault(),i?.(d,t.shiftKey);return}n?.(e)}},className:F(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[r&&(0,K.jsx)(Eb,{className:F(`sticky left-0 z-10 p-0`,tH,f?`bg-muted`:`bg-background dark:bg-black`),onClick:KL,onMouseDown:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus(),a?.(d,e)},children:(0,K.jsx)(aH,{children:(0,K.jsx)(`input`,{type:`checkbox`,"aria-label":f?`Deselect record`:`Select record`,checked:f,disabled:d===void 0,onClick:e=>{c?.current&&e.detail!==0||d===void 0||i?.(d,e.shiftKey)},onChange:sH})})}),u,(0,K.jsx)(Eb,{"aria-hidden":!0,className:`p-0`})]})}function sH(){}function cH({cell:e}){let t=e.column.getSize();return(0,K.jsx)(Eb,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 font-mono text-[0.8rem] overflow-hidden text-ellipsis whitespace-nowrap`,children:ot(e.column.columnDef.cell,e.getContext())})}function lH({colSpan:e}){return(0,K.jsx)(Eb,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}var uH=new Set,dH=[],fH=[];function pH({instanceDatabaseMap:e,instanceDatabaseMapLoading:t=!1,databaseName:n,tableName:r}){let i=z({strict:!1}),a=q(),{clusterId:o,instanceId:s}=i,{toggled:c,toggle:l}=SV(!0),u=wr(`instance:update`),d=Tg(s??o,n,r,`insert`),f=Dg(s??o,n,r),p=kg(),m=Tg(s??o,n,r,`update`),h=Tg(s??o,n,r,`delete`),g=wg(),{data:_}=L(WL({...a,databaseName:n,tableName:r})),v=e?.[n],y=v?.[r],b=_??y,x=f&&p.methods.file,S=f&&p.methods.url,C=f&&p.allowsSource(`csv-data`),w=(0,G.useMemo)(()=>O_(b?.attributes??[],`attribute`),[b]),{data:T,isLoading:E}=L(PF(a)),{data:D}=L(HE(a)),O=Eg(s??o,n,r),k=NV(D?.version,O),A=k===void 0,j=T?.[n]?.[r],M=(0,G.useMemo)(()=>xL(y?.attributes,v,j),[y,v,j]),ee=f&&p.allowsSource(`json-records`)&&M.length>0,te=(0,G.useMemo)(()=>VF(b,v,j),[b,v,j]),N=(0,G.useMemo)(()=>KF(b,v),[b,v]),P=(0,G.useMemo)(()=>UF(b?.attributes,v,j),[b,v,j]),[F,ne]=xV(null,i),[re,ie]=(0,G.useState)(!1),[ae,se]=xV(null,i),[ce,le]=xV(null,i),[ue,de]=(0,G.useState)(null),fe=ue!==null,pe=(0,G.useMemo)(()=>g&&!!v&&Object.keys(v).length>1,[g,v]),{toggled:me,toggleOn:he,toggleOff:ge}=SV(!1),{toggled:_e,toggle:ve}=SV(!1),ye=on({resolver:mt(BV)}),{reset:be}=ye,xe=ye.watch(),[Se,Ce]=xV(null,[i.clusterId,i.instanceId,n,r]),[we,I]=xV(!1,[i.clusterId,i.instanceId,n,r]),Te=(0,G.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...qR(n,r,w[n],Object.hasOwn(te,n)?te[n]:void 0))}catch(e){U.error(String(e))}}return t},[w,te]),Ee=(0,G.useCallback)(e=>{let t=pV(e,w,te);return t.length&&!confirm(mV(r,t))?!1:(I(t.length>0),Ce(e.length?e:null),!0)},[w,te,r,I,Ce]),De=(0,G.useCallback)(()=>{Ee(Te(xe))&&be({...xe})},[Ee,Te,be,xe]),R=(0,G.useCallback)(()=>{be({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),be(),Ce(null),I(!1),ge()},[ge,be,Ce,I]);(0,G.useEffect)(function(){return R()},[i,R]);let{filters:ke}=Oe({strict:!1}),Ae=JSON.stringify([n,r,ke??null]),je=(0,G.useRef)(null);(0,G.useEffect)(function(){if(!b||je.current===Ae||ke&&(E||t))return;let e=je.current===null;je.current=Ae,ke?(Ee(Te(ke))?be({...ke}):be({...ke},{keepDefaultValues:!0}),he()):e||R()},[ke,Ae,b,E,t,be,Te,Ee,he,R]);let Me=cR(b),Ne=!b||!!Me,[B,Pe]=xV(null,i),Fe=(0,G.useMemo)(()=>B??{attribute:Me,descending:!1},[B,Me]),[Ie,Le]=xV(0,[n,r,Se]),[Re,ze]=(0,G.useState)(20),[Be,Ve]=xV(null,[n,r,Se,Re,c]),He=_?.record_count??y?.record_count,Ue=_?.estimated_record_range??y?.estimated_record_range,[We,Ge]=xV(!1,[n,r]),{data:Ke,isFetching:qe,isError:Je,refetch:Ye}=L(jV({...a,enabled:We,databaseName:n,tableName:r})),Xe=(0,G.useCallback)(()=>{We?Ye():Ge(!0)},[We,Ye,Ge]),Qe=Ke??He,$e=Qe&&Ne?Math.ceil(Qe/Re):0,et=Ke===void 0&&Ue!==void 0,tt=me&&!!Se,nt=JSON.stringify([n,r]),rt=JSON.stringify([a.entityId,n,r,Ie,Re,Fe,tt?Se:null,c]),[it,at]=xV(uH,[rt]),ot=(0,G.useCallback)(e=>{at(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[at]),st=(0,G.useCallback)((e,t)=>{at(t?new Set(e):uH)},[at]),ct=(0,G.useCallback)((e,t)=>{at(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},[at]),lt=(0,G.useMemo)(()=>h?{selectedKeys:it,toggleRow:ot,toggleAll:st,setRangeSelected:ct}:void 0,[h,it,ot,st,ct]),ut=Fw({...a,enabled:!tt&&!!Me,databaseName:n,tableName:r,searchAttribute:Me,sort:Fe,pageSize:Re,pageIndex:Ie,onlyIfCached:c,getAttributes:N}),{data:dt,isFetching:ft,isError:pt}=L(ut),ht=WR({...a,enabled:tt&&!!Me,databaseName:n,tableName:r,conditions:Se,sort:Fe,pageSize:Re,pageIndex:Ie,onlyIfCached:c,getAttributes:N,allowFullScan:we}),{data:gt,isFetching:_t,isError:vt}=L(ht),yt=tt?gt:dt,bt=ft||_t,xt=tt?vt:pt,St=yt?.data,Ct=(0,G.useMemo)(()=>new Set([...(b?.attributes??[]).map(({attribute:e})=>e),...Object.keys(te)]),[b,te]),wt=(0,G.useMemo)(()=>St&&fR(St,Ct),[St,Ct]),Tt=JSON.stringify([a.entityId,n,r]),[Et,Dt]=(0,G.useState)({key:Tt,extras:fH});wt&&(Et.key!==Tt||!pR(Et.extras,wt))&&Dt({key:Tt,extras:wt});let{dataTableColumns:Ot}=sR(b,te,wt??(Et.key===Tt?Et.extras:fH)),kt=tt?{rowCount:gt?.data.length,hasNextPage:gt?.hasNextPage}:void 0,At=kt?!!kt.hasNextPage:!!St&&St.length===Re&&Be!==Ie,jt=(0,G.useMemo)(()=>(St??[]).map(e=>nH(e,Me)).filter(e=>e!==void 0&&it.has(e)),[St,Me,it]),{data:Mt,isFetching:Nt,isError:Pt}=L(jL({...a,enabled:re,databaseName:n,tableName:r,ids:F})),Ft=re&&!fe&&!!ae&&(!Me||ae[Me]==null),It=Mt?.data,Lt=!Ft&&!fe&&!!F?.length&&!Nt&&(Pt||Array.isArray(It)&&It.length===0),{mutate:Rt,isPending:zt}=zV(),{mutate:Bt,isPending:Vt}=kV(),{mutate:Ht,isPending:Ut}=IV(),{mutate:Wt,isPending:Gt}=wV(),Kt=Ze(),qt=(0,G.useCallback)(()=>(Ve(null),at(uH),Kt.invalidateQueries({queryKey:[a.entityId,n,r]})),[Kt,a.entityId,n,r,Ve,at]),Jt=(0,G.useCallback)(()=>Kt.invalidateQueries({queryKey:AL(a.entityId,n,r)}),[Kt,a.entityId,n,r]),Yt=(0,G.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${n}"?`)&&Wt({...a,databaseName:n},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),qt()},onError:e=>{pc(e)&&U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Wt,n,a,qt]),{exportCsv:Xt,isExporting:Zt}=$R(),Qt=(0,G.useCallback)(()=>{Xt({databaseName:n,tableName:r,primaryKey:Me,sort:Fe,conditions:tt?Se:null,allowFullScan:tt&&we,instanceTable:b,databaseTables:v})},[Xt,n,r,Me,Fe,tt,Se,we,b,v]),$t=(0,G.useCallback)(e=>{if(e?.wroteNothing){U.error(`The record wasn't updated`,{description:e.message});return}if(qt(),Jt(),ie(!1),e){U.error(`The record wasn't fully updated`,{description:e.message});return}U.success(`Record updated successfully`)},[qt,Jt]),en=(0,G.useCallback)(e=>{Rt({...a,databaseName:n,tableName:r,records:e},{onSuccess:t=>$t(LV(t,e.length))})},[Rt,a,n,r,$t]),tn=(0,G.useCallback)(e=>{Ht({...a,databaseName:n,tableName:r,records:e},{onSuccess:t=>$t(FV(t,e.length))})},[Ht,a,n,r,$t]),nn=(0,G.useCallback)(e=>{Bt({...a,databaseName:n,tableName:r,hashValues:e},{onSuccess:t=>{let n=DV(t,e.length);if(n?.wroteNothing){U.error(`The record wasn't deleted`,{description:n.message});return}if(qt(),Jt(),ie(!1),n){U.error(`The record wasn't fully deleted`,{description:n.message});return}U.success(`Record deleted successfully`)}})},[Bt,a,n,r,qt,Jt]),rn=(0,G.useCallback)(()=>{let e=jt;e.length&&confirm(`Permanently delete ${oe(e.length,`record`,`records`)} from "${r}"?`)&&Bt({...a,databaseName:n,tableName:r,hashValues:e},{onSuccess:t=>{qt(),Jt();let n=DV(t,e.length);if(n){U.error(`The records weren't all deleted`,{description:n.message});return}U.success(`${oe(e.length,`record`,`records`)} deleted successfully`)}})},[Bt,a,n,r,qt,Jt,jt]),an=(0,G.useCallback)((e,t)=>{let n=Me?t[Me]:void 0;se(t),ne(n==null?null:[n]),le(e)},[Me,se,ne,le]),sn=(0,G.useCallback)(e=>{if(ce===null||!St)return;let t=ce+e,n=St[t];if(n){an(t,n);return}let r=Ie+e;r<0||(Le(r),de({end:e===1?`first`:`last`,fromPage:Ie}))},[ce,St,an,Ie,Le]);(0,G.useEffect)(function(){if(!ue)return;if(!re){de(null);return}let e=ue.end===`first`?0:(St?.length??0)-1,t=e>=0?St?.[e]:void 0;if(t){de(null),an(e,t);return}if(St||xt){if(de(null),Le(ue.fromPage),xt){U.error(`Couldn't load the next page of records`);return}if(ue.end===`first`){Ve(ue.fromPage),U.info(`This is the last record`);return}U.info(`This is the first record`)}},[ue,St,xt,re,an,Le,Ve]);let cn=e=>{an(e.index,e.original),ie(!0)},ln=(e,t)=>{Pe({attribute:e,descending:!t})},un=Kb(qt),dn=(0,G.useCallback)(()=>{rL(`ShowAddTableRecords`,{databaseName:n,tableName:r})},[n,r]),fn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r})},[n,r]),pn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r,method:x?`file`:`url`})},[n,r,x]),mn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r,method:`sample`})},[n,r]),[hn,gn]=FC(`ColumnDisplayed/${n}/${r}`,{}),_n=(0,G.useMemo)(()=>({...Object.fromEntries(GF(te).map(e=>[e,!1])),...hn}),[te,hn]),vn=ce===null?void 0:{position:fe?void 0:Ie*Re+ce+1,total:kt?kb(Ie,Re,kt):Qe,isTotalEstimated:!kt&&et,hasPrevious:!fe&&(ce>0||Ie>0),hasNext:!fe&&!!St&&(ce+1<St.length||At),onPrevious:()=>sn(-1),onNext:()=>sn(1)},[yn,bn]=FC(`ColumnSizing/${n}/${r}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`shrink-0 flex flex-col md:flex-row md:flex-wrap items-center justify-between gap-3 pt-15 pb-4 px-4`,children:[(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[d&&Ne&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:dn,accessKey:`n`,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),h&&jt.length>0&&(0,K.jsxs)(H,{variant:`destructiveOutline`,onClick:rn,disabled:Vt,children:[(0,K.jsx)(Is,{className:`text-destructive`}),(0,K.jsxs)(`span`,{children:[`Delete Selected (`,jt.length,`)`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[me&&Se&&(0,K.jsxs)(H,{type:`button`,variant:`ghost`,onClick:R,accessKey:`f`,children:[(0,K.jsx)(Sa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),me&&ye.formState.isDirty&&(0,K.jsxs)(H,{variant:`default`,onClick:De,children:[(0,K.jsx)(ba,{className:`inline-block `}),`Apply Filters`]}),me&&!Se&&(0,K.jsxs)(H,{variant:`ghost`,onClick:ge,accessKey:`f`,children:[(0,K.jsx)(Sa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),me&&(0,K.jsxs)(H,{variant:`ghost`,onClick:ve,"aria-expanded":_e,"aria-controls":`filter-syntax-help`,children:[(0,K.jsx)(Pi,{className:`inline-block `}),`Filter Syntax`]}),!me&&Ne&&(0,K.jsxs)(H,{variant:`ghost`,onClick:he,accessKey:`f`,children:[(0,K.jsx)(wa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(H,{variant:`defaultOutline`,onClick:un,disabled:bt,children:(0,K.jsx)(Go,{"aria-label":`Refresh table`,role:`img`})}),(0,K.jsx)(ZV,{columns:Ot,columnVisibility:_n,setColumnVisibility:gn}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,children:(0,K.jsx)(ua,{"aria-label":`Table options`})})}),(0,K.jsxs)(vc,{side:`bottom`,align:`end`,children:[f&&Ne&&(0,K.jsxs)(yc,{onClick:fn,children:[(0,K.jsx)(Ji,{}),`Import Data`]}),(0,K.jsxs)(yc,{onClick:Qt,disabled:Zt||!Ne,children:[(0,K.jsx)(Ki,{}),`Export CSV`]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{className:`focus:bg-primary/70 focus:text-white`,onClick:l,children:[c?(0,K.jsx)(Ei,{className:`text-green`}):(0,K.jsx)(Ii,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:KL,children:(0,K.jsx)(fa,{})})]}),g&&u&&!!s&&(0,K.jsxs)(yc,{className:`focus:bg-yellow/70 focus:text-white`,onClick:Yt,disabled:Gt,children:[(0,K.jsx)(ci,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),g&&(0,K.jsx)(wc,{}),pe&&(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteTable`,{databaseName:n,tableName:r}),children:[(0,K.jsx)(Is,{className:`inline-block `}),`Drop Table`]}),g&&(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteDatabase`,{databaseName:n}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})]})]})]})]}),me&&_e&&(0,K.jsx)(XV,{id:`filter-syntax-help`}),(0,K.jsx)(rH,{primaryKey:Me,data:Ne?St:dH,emptyState:(0,K.jsx)(UV,{tableName:r,hasPrimaryKey:Ne,isFiltered:tt,isPastFirstPage:Ie>0,recordCount:Qe,canImportFile:x,canImportUrl:S,canSeedSample:C,canSeedRandom:ee,canAddRecords:d,onImport:pn,onSeed:mn,onAddRecords:dn,onClearFilters:R}),isFetching:bt,filtersToggled:me,columns:Ot,columnVisibility:_n,columnSizing:yn,setColumnSizing:bn,onRowClick:cn,onColumnClick:ln,rowSelection:lt,totalPages:$e,totalRecords:Qe,uncountedPage:kt,isEstimatedCount:et,estimatedRange:Ue,isExactCountFetching:qe,isExactCountError:Je,onRequestExactCount:Xe,pageIndex:Ie,pageSize:Re,resultSetKey:rt,tableIdentity:nt,columnFiltersForm:ye,applyFilters:De,setPageIndex:Le,setPageSize:ze}),(0,K.jsx)(vV,{canEditRecords:m,canDeleteRecords:h,canReplaceRecords:A,replaceBlockedReason:k,setIsModalOpen:ie,isModalOpen:re,primaryKey:Me,missingPrimaryKey:Ft,recordUnavailable:Lt,syntheticAttributes:P,recordNavigation:vn,data:fe?void 0:Ft||Lt?ae?[ae]:void 0:Mt?.data,onSaveChanges:en,onReplaceRecord:tn,onDeleteRecord:nn,isUpdateTableRecordsPending:zt||Ut,isDeleteTableRecordsPending:Vt})]})}function mH(e,t){if(!e)return null;if(!(t.databaseName&&e[t.databaseName])){let n=Object.keys(e).sort()[0];return n&&n!==t.databaseName?{databaseName:n,tableName:void 0}:null}return t.tableName&&!e[t.databaseName][t.tableName]?{databaseName:t.databaseName,tableName:void 0}:null}var hH=10;function gH(e,t){return Math.max(e,Math.floor(t/2))}function _H(e,t,{minWidth:n,defaultWidth:r}){return Math.round(Math.min(Math.max(Number.isFinite(e)?e:r,n),gH(n,t)))}function vH({storageKey:e,defaultWidth:t,minWidth:n,cssVariable:r}){let[i,a]=Zc(e,t),o=(0,G.useRef)(i);(0,G.useLayoutEffect)(()=>{o.current=i},[i]);let s=(0,G.useMemo)(()=>({minWidth:n,defaultWidth:t}),[n,t]),c=(0,G.useCallback)(e=>_H(e,window.innerWidth,s),[s]),[l,u]=(0,G.useState)(()=>c(i)),d=(0,G.useRef)(l),f=(0,G.useCallback)(e=>{d.current=e,u(e)},[]),[p,m]=(0,G.useState)(!1),h=(0,G.useRef)(null),g=(0,G.useRef)(new Set),_=(0,G.useCallback)(e=>{let t=`${e}px`;for(let e of g.current)e.style.setProperty(r,t)},[r]),v=(0,G.useCallback)(e=>{if(e)return g.current.add(e),e.style.setProperty(r,`${h.current?.liveWidth??d.current}px`),()=>{g.current.delete(e)}},[r]);(0,G.useLayoutEffect)(()=>_(l),[_,l]),(0,G.useEffect)(()=>{let e=()=>{let e=h.current;e?(e.liveWidth=c(e.dragWidth??o.current),_(e.liveWidth)):f(c(o.current))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c,_,f]);let y=(0,G.useCallback)(e=>{if(e.button!==0||h.current)return;e.preventDefault();let t=e.currentTarget;h.current={pointerId:e.pointerId,target:t,startX:e.clientX,startWidth:d.current,dragWidth:null,liveWidth:d.current};try{t.setPointerCapture?.(e.pointerId)}catch{}m(!0)},[]);(0,G.useEffect)(()=>{if(!p)return;let e=e=>{let t=h.current;if(!t)return;h.current=null,t.target.hasPointerCapture?.(t.pointerId)&&t.target.releasePointerCapture(t.pointerId);let n=e&&t.dragWidth!==null&&t.dragWidth!==t.startWidth?t.dragWidth:null,r=c(n??o.current);_(r),f(r),n!==null&&a(n),m(!1)},t=e=>{let t=h.current;t?.pointerId===e.pointerId&&(t.dragWidth=c(t.startWidth+(e.clientX-t.startX)),t.liveWidth=t.dragWidth,_(t.liveWidth))},n=t=>{h.current?.pointerId===t.pointerId&&e(!0)},r=t=>{h.current?.pointerId===t.pointerId&&e(!1)},i=()=>e(!1),s=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),window.addEventListener(`lostpointercapture`,r),window.addEventListener(`blur`,i),()=>{document.body.style.userSelect=s,window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`lostpointercapture`,r),window.removeEventListener(`blur`,i)}},[p,c,_,f,a]);let b=(0,G.useCallback)(e=>{let t=e.key===`ArrowLeft`?-10:e.key===`ArrowRight`?hH:0;if(!t)return;e.preventDefault();let n=c(d.current+t);n!==d.current&&(f(n),a(n))},[c,f,a]);return{width:l,minWidth:n,maxWidth:gH(n,window.innerWidth),isResizing:p,sidebarRef:v,startResizing:y,handleKeyDown:b}}var yH={storageKey:_r.DatabasesSidebarWidth,defaultWidth:320,minWidth:200,cssVariable:`--db-sidebar-width`};function bH(){return vH(yH)}function xH(){let e=z({strict:!1}),t=q(),{data:n,isLoading:r}=L(Ij({...t,skipRecordCount:!0,includeComputed:!0})),{width:i,minWidth:a,maxWidth:o,isResizing:s,sidebarRef:c,startResizing:l,handleKeyDown:u}=bH(),d=mH(n,e);return d?(0,K.jsx)(qe,{to:jP({...e,...d}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:gap-0 md:flex-row md:items-start`,children:[(0,K.jsxs)(`section`,{ref:c,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r-2 border-border flex flex-col min-h-0 md:sticky md:top-32 md:h-[calc(100vh-(--spacing(32)))] md:max-h-[calc(100vh-(--spacing(32)))] overflow-y-clip`,children:[(0,K.jsx)(dV,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":i,"aria-valuemin":a,"aria-valuemax":o,onPointerDown:l,onKeyDown:u,className:`group hidden md:block absolute top-0 bottom-0 left-full w-2 z-40 cursor-col-resize touch-none outline-none`,children:(0,K.jsx)(`div`,{className:F(`absolute inset-y-0 left-0 w-1 -translate-x-1/2 transition-colors`,`group-hover:bg-violet-400/60 dark:group-hover:bg-violet-500/60 group-focus-visible:bg-violet-500/80`,s&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0 h-[calc(100vh-(--spacing(32)))]`,children:e.databaseName&&e.tableName?(0,K.jsx)(pH,{instanceDatabaseMap:n,instanceDatabaseMapLoading:r,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:(0,K.jsx)(dz,{instanceDatabaseMap:n,databaseName:e.databaseName})}):null})]}),n&&(0,K.jsx)(GL,{instanceDatabaseMap:n})]})}function SH(e){return R({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:xH})}var CH={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function wH(){let e=Cg(),t=z({strict:!1}),{version:n}=Ce({strict:!1}),r=XT(n)&&e,i=vr(`4.7.0-beta.7`,n),a=q(),{data:o}=L(QT(a,r)),s=o?.restartRequired??!1,c=(0,G.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?qg(t,`apps`):qg(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Fo,{className:`inline-block`})},{to:qg(t,`databases`),icon:(0,K.jsx)(ia,{className:`inline-block`}),name:`Databases`},e&&i&&{to:qg(t,`apis`),name:`APIs`,icon:(0,K.jsx)(ss,{className:`inline-block`})},e&&{to:qg(t,`operations`),name:`Operations`,icon:(0,K.jsx)(bs,{className:`inline-block`})},e&&r&&{to:qg(t,`status`),icon:(0,K.jsx)(Ea,{className:`inline-block`}),name:`Status`},e&&{to:qg(t,`logs`),icon:(0,K.jsx)(jo,{className:`inline-block`}),name:`Logs`},e&&{to:qg(t,`config`),icon:(0,K.jsx)(ls,{className:`inline-block`}),name:`Config`}].filter(fr),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(TH,{links:c,restartRequired:s}),(0,K.jsx)(EH,{links:c,restartRequired:s})]})}function TH({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Dd,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:CH,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:n}),(0,K.jsx)(Xl,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function EH({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Dd,{restartRequired:t}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Co,{className:`h-8 w-8`})})}),(0,K.jsxs)(vc,{children:[(0,K.jsx)(Cc,{children:`Instance Menu`}),(0,K.jsx)(wc,{}),e.map(e=>(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:CH,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,G.lazy)(()=>pe(()=>import(`./FloatingChat-CFypO7kh.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([37,1,2,3,12,26,25])));function DH(){let{instanceId:e,clusterId:t}=z({strict:!1});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`studio-subnav fixed top-20 w-full z-39 h-12 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsx)(wH,{})}),(0,K.jsxs)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:[(0,K.jsx)(m_,{entityId:m,clusterId:t,noun:`instance`,className:`px-4 pt-4 md:px-12`}),(0,K.jsx)(st,{})]}),!1]})}function OH(e){switch(e){case`local`:return R({getParentRoute:()=>Uu,id:`_instanceLayout`,component:DH,loader:kP});case`cluster`:return R({getParentRoute:()=>WC,id:`_instanceLayout`,component:DH,beforeLoad:kH,loader:kP});case`instance`:return R({getParentRoute:()=>WC,path:`instance/$instanceId`,component:DH,beforeLoad:kH,loader:kP})}}async function kH({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await AH(n,e.cluster,t.instanceId)))return;u.startSignInCheck(n);let i=u.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[m];if(!a||a.isLoading)return;let{update:o}=t.instanceId?xg(a.user,t.organizationId,t.clusterId):hg(a.user,t.organizationId,t.clusterId);if(!r&&o&&await AH(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw Ne({to:s,search:Mu()})}async function AH(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:jH(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function jH(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?p(n):void 0}return c(e)??void 0}function MH(e){switch(e){case`warn`:return`warning`;case`notify`:return`success`;case`info`:case`debug`:case`trace`:case void 0:case`stdout`:return`secondary`;case`stderr`:case`error`:return`destructive`;default:return e}}var NH=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],PH=0,FH=new Map,IH=e=>{if(FH.has(e))return FH.get(e);PH++;let t=NH[PH%NH.length];return FH.set(e,t),t};function LH(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function RH({columns:e,data:t,onRowClick:n,containerRef:r}){let i=tt({features:Lb,data:t,columns:e});return(0,K.jsxs)(bb,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(xb,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(wb,{className:`p-4 max-w-96 sticky top-0 z-10 border-b border-border bg-card dark:bg-black-dark`,children:e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,className:F(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,LH(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`p-2`,children:ot(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var zH=524288,BH=class{totalChars=0;spent=!1;get isSpent(){return this.spent}admit(e){return this.spent?{admitted:!1,justExhausted:!1,oversize:!1}:e>524288?{admitted:!1,justExhausted:!1,oversize:!0}:this.totalChars+e>8388608?(this.spent=!0,{admitted:!1,justExhausted:!0,oversize:!1}):(this.totalChars+=e,{admitted:!0,justExhausted:!1,oversize:!1})}};function VH(e){try{JSON.parse(e)}catch{return!1}return!0}function HH(e){return!e||e.length>524288?`plaintext`:VH(e)?`json`:`plaintext`}function UH({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function WH({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?IH(n.node):`default`,i=Tx();return(0,K.jsx)(_m,{onOpenChange:e,open:t,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(UH,{label:`Level`,children:(0,K.jsx)(ol,{variant:MH(n.level),children:_d(n.level)})}),(0,K.jsx)(UH,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(UH,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(UH,{label:`Node`,children:(0,K.jsx)(ol,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(UH,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:HH(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Lc,{})]})})}var GH=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/;function KH(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function qH(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999)}var JH=KH(new Date(0));function YH(e=new Date){return KH(qH(e))}function XH(e,t){if(!e)return;let n=Date.parse(e);if(!GH.test(e)||Number.isNaN(n))return`Enter a valid date and time with a 4-digit year`;if(n<0)return`Date cannot be before 1970 (UTC)`;if(n>qH(t??new Date).getTime())return`Date cannot be after today`}var ZH=x().or(w()).or(k()).optional().superRefine((e,t)=>{let n=XH(e);n&&t.addIssue({code:`custom`,message:n})}),QH=b({limit:x().or(w()).or(k()).optional(),level:j([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(k()).optional(),from:ZH,until:ZH,log_name:j([`hdb.log`,`system.log`]).or(w()).or(k()).optional(),filter:x().or(w()).or(k()).optional()});function $H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e4)}function eU(e){return e.replace(/[^a-z0-9-]+/gi,`-`).replace(/(^-|-$)/g,``).toLowerCase()}function tU(e){return new Date(e).toISOString().replace(/[:.]/g,`-`)}function nU(e){let t=Array.isArray(e.tags)?e.tags:[],n=[e.thread??``,e.level??``,...e.node?[e.node]:[],...t];return`${e.timestamp} ${n.map(e=>`[${e}]`).join(` `)}: ${e.message??``}`}function rU(e,t){return t===`json`?JSON.stringify(e,null,` `):e.map(e=>`${nU(e)}\n`).join(``)}function iU(e,t,n=Date.now()){return`${eU(e)}-${tU(n)}.${t}`}function aU(e,t,n){let r=t===`json`?`application/json`:`text/plain;charset=utf-8`;$H(new Blob([rU(e,t)],{type:r}),iU(n,t))}function oU({logs:e,logName:t,iconOnly:n,className:r}){return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`defaultOutline`,size:n?`icon`:`default`,disabled:e.length===0,"aria-label":`Download logs`,className:F(`shrink-0`,r),children:[(0,K.jsx)(oa,{}),!n&&`Download`]})}),(0,K.jsxs)(vc,{align:`end`,children:[(0,K.jsxs)(Cc,{className:`text-xs font-normal text-muted-foreground`,children:[`Saves the `,oe(e.length,`entry`,`entries`),` shown`]}),(0,K.jsx)(yc,{onSelect:()=>aU(e,`txt`,t),children:`Text (.txt)`}),(0,K.jsx)(yc,{onSelect:()=>aU(e,`json`,t),children:`JSON (.json)`})]})]})}var sU=`dark:bg-grey-600 dark:border-grey-500`,cU=[{name:`from`,label:`Start date`},{name:`until`,label:`End date`}];function lU({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){let[s,c]=(0,G.useState)(YH),l=()=>c(YH());return(0,K.jsxs)(Er,{className:F(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(Dr,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(Or,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(gs,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Ar,{id:`logs-filters-content`,children:(0,K.jsx)(Od,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(rs,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:F(`pl-9`,sU),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Select log file`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(xy,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Limit`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`1000`,children:`1000`}),(0,K.jsx)(xy,{value:`500`,children:`500`}),(0,K.jsx)(xy,{value:`250`,children:`250`}),(0,K.jsx)(xy,{value:`100`,children:`100`}),(0,K.jsx)(xy,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Level`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`undefined`,children:`All`}),(0,K.jsx)(xy,{value:`notify`,children:`Notify`}),(0,K.jsx)(xy,{value:`error`,children:`Error`}),(0,K.jsx)(xy,{value:`warn`,children:`Warn`}),(0,K.jsx)(xy,{value:`info`,children:`Info`}),(0,K.jsx)(xy,{value:`debug`,children:`Debug`}),(0,K.jsx)(xy,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),cU.map(({name:t,label:n})=>(0,K.jsx)(Y,{control:e.control,name:t,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:n}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,step:1,min:JH,max:s,onFocus:l,className:sU,value:e.value??``,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})},t)),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(H,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var uU=1e4;function dU(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,uU)}function fU(e,t){return{operation:`read_log`,start:0,replicated:t,limit:dU(e.limit),level:e.level===`undefined`?void 0:e.level,from:e.from?new Date(e.from).toISOString():void 0,until:e.until?new Date(e.until).toISOString():void 0,log_name:e.log_name??void 0,filter:e.filter?e.filter:void 0,order:`desc`}}async function pU({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,fU(t,n));return r}function mU(e){let t=e.logFilters;return B({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>pU(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?Gc(5e3):!1})}async function hU({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=OD(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(fU(t,n)),signal:r})}catch(e){throw r?.aborted?e:new TD(`Failed to open the read_log SSE stream.`,{cause:e})}let l=c.headers.get(`content-type`)??``;if(!c.ok||!l.includes(`text/event-stream`)||!c.body)throw await c.body?.cancel().catch(()=>{}),new TD(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of SD(c.body,r)){if(e.event===`error`){let t=wD(e);if(!t||typeof t!=`object`)throw new DD(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new DD(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of gU(wD(e)))i(t)}}function gU(e){return Array.isArray(e)?e.filter(_U):_U(e)?[e]:[]}function _U(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.timestamp==`string`&&(typeof t.level==`string`||typeof t.message==`string`)}function vU(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function yU(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=vU(n);r.has(e)||(r.add(e),i.push(n))}return i.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),n>0&&i.length>n?i.slice(0,n):i}var bU={entries:[],fellBack:!1};function xU(e,t){switch(t.kind){case`reset`:return bU;case`retry`:return e.fellBack?{...e,fellBack:!1}:e;case`append`:{if(t.entries.length===0)return e;let n=e.entries.concat(t.entries);return n.length<=t.cap?{...e,entries:n}:(n.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),{...e,entries:n.slice(0,t.cap)})}case`fellBack`:return{...e,fellBack:!0}}}function SU(){let e=q();return u.isDirectConnection(e.entityId)}var CU=1e3,wU=2e3,TU=250;function EU(e){return dU(e)??CU}function DU(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function OU({params:e,logFilters:t,replicated:n,live:r}){let i=SU(),[a,o]=(0,G.useReducer)(xU,bU),s=r&&i&&!a.fellBack,c=DU(t,n),l=EU(t.limit),u=Math.max(wU,l),d=L(mU({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,G.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,G.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,G.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,G.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,TU);return hU({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,G.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:yU(e,a.entries,l)},[d.data,a.entries,l]),m=s?`streaming`:r?`polling`:`idle`;return{logs:p,isLoading:d.isLoading,isFetching:d.isFetching,refetch:()=>d.refetch(),transport:m}}var kU={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},AU={error:(0,K.jsx)(wi,{className:`size-3`}),stderr:(0,K.jsx)(wi,{className:`size-3`}),warn:(0,K.jsx)(Rs,{className:`size-3`}),notify:(0,K.jsx)(ni,{className:`size-3`}),info:(0,K.jsx)(Ba,{className:`size-3`}),debug:(0,K.jsx)(ui,{className:`size-3`}),trace:(0,K.jsx)(Ir,{className:`size-3`}),stdout:(0,K.jsx)(Ms,{className:`size-3`})},jU=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(ol,{variant:MH(t),children:[AU[t],_d(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=IH(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(ol,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Xl,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],MU=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function NU(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(aC,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(aC,{className:`h-5 w-14`}),(0,K.jsx)(aC,{className:`h-5 w-32`}),(0,K.jsx)(aC,{className:`h-5 w-10`}),(0,K.jsx)(aC,{className:`h-5 w-20`}),(0,K.jsx)(aC,{className:`h-5 w-12`}),(0,K.jsx)(aC,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function PU(){let[e,t]=(0,G.useState)(kU),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(!1),[c,l]=Zc(_r.LogsOrderReversed,!1),[u,d]=(0,G.useState)(!1),f=q(),{data:p}=L(HE(f)),m=p?.version,h=!!m&&vr(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=OU({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,G.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=e.log_name??`hdb.log`,C=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=C.current;!_&&e&&e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,G.useEffect)(()=>{let e=C.current;o&&!_&&e&&e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let w=on({resolver:mt(QH),defaultValues:kU,mode:`onChange`}),T=e=>{a(e.original),r(!0)},E=async e=>{if(!MU(e.from,e.until)){w.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),w.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},D=async()=>{w.reset(),t(kU)},O=Kb(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:hidden`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(gs,{}),`Filters`]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:O,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Go,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(H,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(Kr,{}),`Reverse`]}),(0,K.jsx)(oU,{logs:x,logName:S,iconOnly:!0})]}),(0,K.jsx)(lU,{form:w,resetFilters:D,submitFilters:E,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:O,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Go,{}),`Refresh`]}),(0,K.jsx)(oU,{logs:x,logName:S,className:`w-full`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Kx,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Go,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Kx,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Kr,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(NU,{}):(0,K.jsx)(RH,{columns:jU,data:x,onRowClick:T,containerRef:C})}),(0,K.jsx)(WH,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function FU(e){return R({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:PU})}function IU(e){return R({getParentRoute:()=>e,path:`operations`,head:()=>({meta:[{title:`Operations — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./operations-D8aaKYty.js`),__vite__mapDeps([38,1,7,23,2,3,4,8,6,9,32,34,29])),`OperationsIndex`)})}var LU=6e4,RU=60*LU,zU=24*RU,BU=[{id:`1h`,label:`Last 1 hour`,durationMs:RU,bucketMs:1*LU,expandedBucketMs:1*LU},{id:`6h`,label:`Last 6 hours`,durationMs:6*RU,bucketMs:2*LU,expandedBucketMs:1*LU},{id:`24h`,label:`Last 24 hours`,durationMs:zU,bucketMs:10*LU,expandedBucketMs:5*LU},{id:`7d`,label:`Last 7 days`,durationMs:7*zU,bucketMs:RU,expandedBucketMs:15*LU},{id:`30d`,label:`Last 30 days`,durationMs:30*zU,bucketMs:4*RU,expandedBucketMs:RU}];function VU(e){let t=BU.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function HU(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=RU&&e%RU===0?t(e/RU,`hour`):e>=LU&&e%LU===0?t(e/LU,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function UU(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(BU[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of BU)if(e<=t.durationMs*1.01)return n(t);let i=BU[BU.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var WU=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],GU=6e4,KU=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`,`jobs`],qU={tab:`health`,range:`1h`,refresh:GU,jobsRefresh:0};function JU(e,t){let n=e===``?NaN:Number(e);return WU.find(e=>e.value===n)?.value??t}function YU(e){return{tab:KU.find(t=>t===e.tab)??qU.tab,range:BU.find(t=>t.id===e.range)?.id??qU.range,refresh:JU(e.refresh,qU.refresh),jobsRefresh:JU(e.jobsRefresh,qU.jobsRefresh)}}function XU(e){return R({getParentRoute:()=>e,path:`status`,validateSearch:YU,search:{middlewares:[ut(qU)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./status-CYoonm9V.js`),__vite__mapDeps([39,1,7,6,2,3,4,8,9,12,32,40,41,42,43,44,45,46,47])),`StatusIndex`)})}function ZU(e){let t=OH(e),n=[FU(t),...kE(t,e),OE(t),IU(t),XU(t),AP(t),SH(t)];return t.addChildren(n)}R({getParentRoute:()=>Uu,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./notifications-D_VqhHnx.js`),__vite__mapDeps([48,1,6,7,2,3,8,9])),`NotificationsCenter`)}),R({getParentRoute:()=>Uu,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./profile-DM5E6Xls.js`),__vite__mapDeps([49,1,22,7,6,23,4,2,3,24,25,8,9])),`ProfileIndex`)});var QU=Hu.addChildren([...om,Uu.addChildren([ZU(`local`)])]);function $U({routeTree:e=QU,authentication:t}){let[n]=(0,G.useState)(()=>Ae({routeTree:e,history:be(),defaultNotFoundComponent:sc,defaultErrorComponent:oc,defaultPreload:!cc()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:hc,authentication:t||{}}}));return n}function eW(){let e=br(),t=$U({authentication:e}),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ct,{router:t,context:{authentication:e}}),(0,K.jsx)(Xe,{router:t,position:`bottom-right`})]})}var tW=({...e})=>(0,K.jsx)(Gt,{className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground font-medium`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground font-medium`}},...e}),nW=!1;function rW(){(0,G.useEffect)(()=>{nW||=!0},[])}function iW(){return Qu(),Bu(),rW(),(0,K.jsxs)(el,{children:[(0,K.jsxs)(it,{client:hc,children:[(0,K.jsx)(eW,{}),(0,K.jsx)(rt,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(tW,{richColors:!0})]})}var aW=1e4,oW=100,sW=new Map;function cW(e){return typeof e==`string`||typeof e==`number`?String(e):e==null?null:typeof e}function lW(e){if(e instanceof Error)return null;try{return JSON.stringify(e)??null}catch{return Object.keys(e).join(`,`)}}function uW(e,t){if(typeof e!=`object`||!e)return JSON.stringify([typeof e,String(e),t??null]);let{name:n,message:r,stack:i,config:a}=e;return JSON.stringify([typeof e,cW(n),cW(r),cW(i),t??null,cW(a?.method),cW(a?.baseURL),cW(a?.url),lW(e)])}function dW(e,t){for(let[e,n]of sW){if(t-n<aW)break;sW.delete(e)}sW.delete(e),sW.set(e,t),sW.size>oW&&sW.delete(sW.keys().next().value)}function fW(e,t){let n;try{n=uW(e,t.componentStack)}catch{n=void 0}let r=performance.now();if(n!==void 0){let e=sW.get(n);if(e!==void 0&&r-e<aW)return}try{me(e,t)}catch{return}n!==void 0&&dW(n,r)}var pW={onUncaughtError:(e,t)=>{fW(e,t),console.warn(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{fW(e,t),console.warn(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{fW(e,t),console.warn(`Recoverable error:`,e,t)}};function mW(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var hW=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],gW=`authUserAtSend`;function _W(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var vW=!1;function yW(){vW||(vW=!0,P.interceptors.request.use(e=>(e[gW]=_W(),e)),P.interceptors.response.use(e=>e,mW(pu,e=>hW.some(t=>e.startsWith(t)),e=>e?.[gW]===_W())))}var bW=!1;function xW(){bW||=(u.onAppSignedOutElsewhere(mu),!0)}var SW=`Studio:StaleDeployReloadedAt`,CW=6e4,wW=`__harperStaleDeployReloadState__`;function TW(){if(typeof window<`u`)return window[wW]}function EW(){let e=TW();if(e){try{let e=Number(sessionStorage.getItem(SW)??0);if(Date.now()-e<CW)return;sessionStorage.setItem(SW,String(Date.now()))}catch{return}e.reload()}}function DW(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[wW];if(n){n.reload=e;return}t[wW]={reload:e},window.addEventListener(`vite:preloadError`,()=>EW())}var OW=ve();ge(),DW(),yW(),xW(),a(),u.installExplorerCrossTabCleanup(),(0,OW.createRoot)(document.getElementById(`root`),pW).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(iW,{})}));export{iF as $,Ar as $i,Sh as $n,Gc as $r,cO as $t,nL as A,Uo as Ai,pb as An,lu as Ar,Zk as At,oI as B,ia as Bi,A_ as Bn,kl as Br,UO as Bt,KR as C,ds as Ci,rx as Cn,J as Cr,hj as Ct,iL as D,Yo as Di,wb as Dn,gu as Dr,fj as Dt,CL as E,$o as Ei,Eb as En,Au as Er,dj as Et,II as F,no as Fi,xy as Fn,Xl as Fr,XO as Ft,kF as G,Si as Gi,Kg as Gn,wl as Gr,FO as Gt,jF as H,Xi as Hi,u_ as Hn,xl as Hr,LO as Ht,DI as I,Qa as Ii,vy as In,Yl as Ir,WO as It,CF as J,Wr as Ji,wg as Jn,hl as Jr,jO as Jt,EF as K,fi as Ki,Gg as Kn,pl as Kr,kO as Kt,EI as L,Ha as Li,_y as Ln,zl as Lr,qO as Lt,$I as M,zo as Mi,ky as Mn,q as Mr,qk as Mt,tL as N,Fo as Ni,hy as Nn,$l as Nr,Jk as Nt,rL as O,qo as Oi,xb as On,cu as Or,lA as Ot,QI as P,oo as Pi,yy as Pn,Jl as Pr,ak as Pt,rF as Q,Er as Qi,eh as Qn,Rc as Qr,dO as Qt,xI as R,Ba as Ri,cy as Rn,Rl as Rr,JO as Rt,sz as S,Es as Si,lx as Sn,Y as Sr,mj as St,UL as T,rs as Ti,Sb as Tn,Gu as Tr,pj as Tt,OF as U,Oi as Ui,l_ as Un,El as Ur,EO as Ut,qF as V,ea as Vi,c_ as Vn,Sl as Vr,IO as Vt,AF as W,wi as Wi,qg as Wn,Ol as Wr,PO as Wt,qP as X,Br as Xi,Zh as Xn,Zc as Xr,MO as Xt,nF as Y,Hr as Yi,Cg as Yn,ol as Yr,AO as Yt,JP as Z,Nr as Zi,Lh as Zn,Yc as Zr,gO as Zt,SV as _,Hs as _i,Dx as _n,$ as _r,JM as _t,HU as a,wr as aa,yc as ai,KE as an,Fm as ar,eF as at,pz as b,Ms as bi,ux as bn,Md as br,aM as bt,pU as c,Ec as ci,HE as cn,_m as cr,IP as ct,$H as d,_c as di,NT as dn,Em as dr,iP as dt,kr as ea,Kc as ei,WD as en,Zm as er,aF as et,BH as f,fc as fi,eT as fn,Tm as fr,fN as ft,OV as g,Ks as gi,Kx as gn,_f as gr,VM as gt,RV as h,oc as hi,aC as hn,bf as hr,BM as ht,BU as i,Tr as ia,vc as ii,iD as in,Nm as ir,XP as it,eL as j,Vo as ji,zy as jn,Ql as jr,Kk as jt,aL as k,Go as ki,Cb as kn,su as kr,cA as kt,tU as l,Oc as li,NE as ln,wm as lr,BP as lt,vH as m,hc as mi,FC as mn,Sp as mr,LM as mt,YU as n,Or as na,gc as ni,ED as nn,Am as nr,YP as nt,VU as o,wc as oi,GE as on,Im as or,$P as ot,zH as p,mc as pi,Iw as pn,Dm as pr,sN as pt,wF as q,Xr as qi,hg as qn,ml as qr,NO as qt,WU as r,Sr as ra,bc as ri,xD as rn,Mm as rr,tF as rt,UU as s,Tc as si,qE as sn,jm as sr,VP as st,EW as t,Dr as ta,Lc as ti,ID as tn,Bm as tr,ZP as tt,eU as u,Dc as ui,QT as un,Om as ur,zP as ut,qB as v,Rs as vi,Tx as vn,Q as vr,HM as vt,KL as w,ss as wi,bb as wn,Od as wr,uj as wt,fz as x,Os as xi,cx as xn,X as xr,Fj as xt,uB as y,Is as yi,sx as yn,Z as yr,qM as yt,wI as z,oa as zi,z_ as zn,Al as zr,QO as zt};
|