agentworkshop 0.7.23 → 0.7.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/0jKrzLuM.js +19 -0
  3. package/.output/public/_nuxt/2jaJHWIJ.js +1 -0
  4. package/.output/public/_nuxt/{Cor9siSf.js → 6PZPfFcO.js} +1 -1
  5. package/.output/public/_nuxt/B7gZokg82.js +209 -0
  6. package/.output/public/_nuxt/B8kt898d.js +1 -0
  7. package/.output/public/_nuxt/{B-xskWta.js → BCJFMBQ6.js} +1 -1
  8. package/.output/public/_nuxt/BFGpEo8S.js +1 -0
  9. package/.output/public/_nuxt/BG4zduPf.js +14 -0
  10. package/.output/public/_nuxt/{DNxVTfhe.js → BGhOrgle.js} +1 -1
  11. package/.output/public/_nuxt/{n3vMFfrv.js → BHcpzI2n.js} +3 -3
  12. package/.output/public/_nuxt/{CEHmSufQ.js → BTLEvDxM.js} +1 -1
  13. package/.output/public/_nuxt/{CYBq3kS7.js → BWyR3awA.js} +1 -1
  14. package/.output/public/_nuxt/Bc89zKq2.js +1 -0
  15. package/.output/public/_nuxt/BetmGSO4.js +1 -0
  16. package/.output/public/_nuxt/{DAR70Lf5.js → BgCrZKv_2.js} +1 -1
  17. package/.output/public/_nuxt/BowTbasd.js +1 -0
  18. package/.output/public/_nuxt/BvtknqSC2.js +1 -0
  19. package/.output/public/_nuxt/CJviSvm-.js +1 -0
  20. package/.output/public/_nuxt/CTfqWGdy.js +1 -0
  21. package/.output/public/_nuxt/Cb3SnTM8.js +1 -0
  22. package/.output/public/_nuxt/Chc5pfAA.js +1 -0
  23. package/.output/public/_nuxt/CmHzfVc5.js +3 -0
  24. package/.output/public/_nuxt/Cn3J3NXR.js +23 -0
  25. package/.output/public/_nuxt/CobSUzQv.js +2 -0
  26. package/.output/public/_nuxt/{kZV5TQvh2.js → CucID8qg2.js} +1 -1
  27. package/.output/public/_nuxt/{CfVAr2nf.js → Cz9gD2Yo.js} +1 -1
  28. package/.output/public/_nuxt/{E88a-JCG.js → DGAOugLt.js} +1 -1
  29. package/.output/public/_nuxt/DHbTyoAV.js +1 -0
  30. package/.output/public/_nuxt/{BxtpDtzC.js → DNQF_TXX.js} +1 -1
  31. package/.output/public/_nuxt/DfLUN8kY.js +1 -0
  32. package/.output/public/_nuxt/DjU9Dx5Y.js +1 -0
  33. package/.output/public/_nuxt/DnziMlcX.js +1 -0
  34. package/.output/public/_nuxt/{BBwMH_hG.js → DoAlYsiF.js} +1 -1
  35. package/.output/public/_nuxt/{DA4lxCWC2.js → DosOJEmZ2.js} +2 -2
  36. package/.output/public/_nuxt/{DWcEk1ur2.js → DvgKXPgu2.js} +1 -1
  37. package/.output/public/_nuxt/{ed5qX-x5.js → Q_SJDSgx.js} +1 -1
  38. package/.output/public/_nuxt/{TownView.zu2rU5nS.css → TownView.CtskuMXS.css} +1 -1
  39. package/.output/public/_nuxt/XY2z78rj.js +1 -0
  40. package/.output/public/_nuxt/_id_.DdbYeLqn.css +1 -0
  41. package/.output/public/_nuxt/bFnZa2yd.js +1 -0
  42. package/.output/public/_nuxt/builds/latest.json +1 -1
  43. package/.output/public/_nuxt/builds/meta/f7a8e33d-5422-45ac-895d-27168f97e3ad.json +1 -0
  44. package/.output/public/_nuxt/daq.DGV9QS8d.css +1 -0
  45. package/.output/public/_nuxt/entry.BN02X8iR.css +1 -0
  46. package/.output/public/_nuxt/monitor.B--1dPzs.css +1 -0
  47. package/.output/public/_nuxt/permissions.B1pjGChZ.css +1 -0
  48. package/.output/public/_nuxt/plugins.DpCuwaJt.css +1 -0
  49. package/.output/public/_nuxt/rkVgzg62.js +1 -0
  50. package/.output/public/_nuxt/settings.W6qrYAui.css +1 -0
  51. package/.output/public/_nuxt/teams.BBXVkyKq.css +1 -0
  52. package/.output/public/_nuxt/tokens.xRb1fSPU.css +1 -0
  53. package/.output/public/_nuxt/users.DuAt_Zwf.css +1 -0
  54. package/.output/public/_nuxt/workshop.BJg84pOK.css +1 -0
  55. package/.output/public/assets/game/character/yangyang-walk.glb +0 -0
  56. package/.output/server/chunks/_/host-bindings.mjs +1 -1
  57. package/.output/server/chunks/_/nitro.mjs +1073 -925
  58. package/.output/server/chunks/_/nitro.mjs.map +1 -1
  59. package/.output/server/chunks/build/{OmpTerminalPanel-Ban3yJZ4.mjs → OmpTerminalPanel-Cw_Vw9oO.mjs} +3 -3
  60. package/.output/server/chunks/build/{OmpTerminalPanel-Ban3yJZ4.mjs.map → OmpTerminalPanel-Cw_Vw9oO.mjs.map} +1 -1
  61. package/.output/server/chunks/build/{TownView-DxeQe1Bl.mjs → TownView-ftIylqiD.mjs} +178 -151
  62. package/.output/server/chunks/build/{TownView-DxeQe1Bl.mjs.map → TownView-ftIylqiD.mjs.map} +1 -1
  63. package/.output/server/chunks/build/{_id_-DQDqj-cZ.mjs → _id_-3Axz2-gV.mjs} +35 -35
  64. package/.output/server/chunks/build/{_id_-DQDqj-cZ.mjs.map → _id_-3Axz2-gV.mjs.map} +1 -1
  65. package/.output/server/chunks/build/{_id_-DY6v6sqB.mjs → _id_-CahfkmEt.mjs} +5 -5
  66. package/.output/server/chunks/build/{_id_-DY6v6sqB.mjs.map → _id_-CahfkmEt.mjs.map} +1 -1
  67. package/.output/server/chunks/build/{_wsId_-C2O5zZsI.mjs → _wsId_-BymlQhzS.mjs} +13 -15
  68. package/.output/server/chunks/build/{_wsId_-C2O5zZsI.mjs.map → _wsId_-BymlQhzS.mjs.map} +1 -1
  69. package/.output/server/chunks/build/{agents--6bzGtES.mjs → agents-DuMiSWKp.mjs} +7 -9
  70. package/.output/server/chunks/build/agents-DuMiSWKp.mjs.map +1 -0
  71. package/.output/server/chunks/build/button-DEcZFcqN.mjs +1 -1
  72. package/.output/server/chunks/build/{card-CCPQoKlh.mjs → card-Dipvaykh.mjs} +4 -4
  73. package/.output/server/chunks/build/{card-CCPQoKlh.mjs.map → card-Dipvaykh.mjs.map} +1 -1
  74. package/.output/server/chunks/build/{channel-templates-C1Bb-U75.mjs → channel-templates-BStqJ-of.mjs} +5 -7
  75. package/.output/server/chunks/build/channel-templates-BStqJ-of.mjs.map +1 -0
  76. package/.output/server/chunks/build/{checkbox-Dv1kjaUZ.mjs → checkbox-C1gABOca.mjs} +5 -5
  77. package/.output/server/chunks/build/{checkbox-Dv1kjaUZ.mjs.map → checkbox-C1gABOca.mjs.map} +1 -1
  78. package/.output/server/chunks/build/{daq-B-3xCp_2.mjs → daq-ChYCABz1.mjs} +312 -426
  79. package/.output/server/chunks/build/daq-ChYCABz1.mjs.map +1 -0
  80. package/.output/server/chunks/build/{dcw-BL2dhuz7.mjs → dcw-CcQNGggh.mjs} +3 -3
  81. package/.output/server/chunks/build/{dcw-BL2dhuz7.mjs.map → dcw-CcQNGggh.mjs.map} +1 -1
  82. package/.output/server/chunks/build/{default-DdV642BY.mjs → default-95-zOTPt.mjs} +3 -4
  83. package/.output/server/chunks/build/{default-DdV642BY.mjs.map → default-95-zOTPt.mjs.map} +1 -1
  84. package/.output/server/chunks/build/dropdown-vhn1NPFs.mjs +1 -1
  85. package/.output/server/chunks/build/{input-number-CZ3ZrCsy.mjs → input-number-Bd55elNN.mjs} +3 -3
  86. package/.output/server/chunks/build/{input-number-CZ3ZrCsy.mjs.map → input-number-Bd55elNN.mjs.map} +1 -1
  87. package/.output/server/chunks/build/{input-DxDqeyQW.mjs → input-sf_BT6o6.mjs} +553 -5
  88. package/.output/server/chunks/build/input-sf_BT6o6.mjs.map +1 -0
  89. package/.output/server/chunks/build/{logs-Dto_umFY.mjs → logs-D-2UyGtE.mjs} +3 -3
  90. package/.output/server/chunks/build/{logs-Dto_umFY.mjs.map → logs-D-2UyGtE.mjs.map} +1 -1
  91. package/.output/server/chunks/build/menu-WCrlpYVh.mjs +2 -2
  92. package/.output/server/chunks/build/modal-yvUquPj5.mjs +2 -2
  93. package/.output/server/chunks/build/{monitor-miqq9xHB.mjs → monitor-mfG5jBtz.mjs} +70 -192
  94. package/.output/server/chunks/build/monitor-mfG5jBtz.mjs.map +1 -0
  95. package/.output/server/chunks/build/{pages-D9tOoJsf.mjs → pages-Dfosfchr.mjs} +5 -6
  96. package/.output/server/chunks/build/pages-Dfosfchr.mjs.map +1 -0
  97. package/.output/server/chunks/build/{permissions-CxEgXic0.mjs → permissions-B-hhZuzm.mjs} +288 -194
  98. package/.output/server/chunks/build/permissions-B-hhZuzm.mjs.map +1 -0
  99. package/.output/server/chunks/build/{plugins-wLIKHcIE.mjs → plugins-DZR0T4Mh.mjs} +17 -17
  100. package/.output/server/chunks/build/{plugins-wLIKHcIE.mjs.map → plugins-DZR0T4Mh.mjs.map} +1 -1
  101. package/.output/server/chunks/build/popconfirm-CRaHcz5O.mjs +1 -1
  102. package/.output/server/chunks/build/{segmented-ChmQZwz6.mjs → segmented-LPPREMtZ.mjs} +336 -5
  103. package/.output/server/chunks/build/{segmented-ChmQZwz6.mjs.map → segmented-LPPREMtZ.mjs.map} +1 -1
  104. package/.output/server/chunks/build/{settings-BPBll_7K.mjs → settings-BajN9TQW.mjs} +254 -27
  105. package/.output/server/chunks/build/settings-BajN9TQW.mjs.map +1 -0
  106. package/.output/server/chunks/build/space-CCBYAkXt.mjs +1 -1
  107. package/.output/server/chunks/build/switch-CelRXpcy.mjs +1 -1
  108. package/.output/server/chunks/build/{table-BtksyDlQ.mjs → table-Bf1r2JjE.mjs} +5 -5
  109. package/.output/server/chunks/build/{table-BtksyDlQ.mjs.map → table-Bf1r2JjE.mjs.map} +1 -1
  110. package/.output/server/chunks/build/{tabs-DQv-_-R6.mjs → tabs-BM3tAh_J.mjs} +2 -2
  111. package/.output/server/chunks/build/{tabs-DQv-_-R6.mjs.map → tabs-BM3tAh_J.mjs.map} +1 -1
  112. package/.output/server/chunks/build/{tag-A0tZ2Ouq.mjs → tag-NO9jEqKy.mjs} +3 -3
  113. package/.output/server/chunks/build/{tag-A0tZ2Ouq.mjs.map → tag-NO9jEqKy.mjs.map} +1 -1
  114. package/.output/server/chunks/build/{teams-DD8ZXTKL.mjs → teams-t2SkRlJP.mjs} +349 -51
  115. package/.output/server/chunks/build/teams-t2SkRlJP.mjs.map +1 -0
  116. package/.output/server/chunks/build/{tokens-Dxnuw96_.mjs → tokens-DiCojbN8.mjs} +296 -200
  117. package/.output/server/chunks/build/tokens-DiCojbN8.mjs.map +1 -0
  118. package/.output/server/chunks/build/{town-Dsh0jlwZ.mjs → town-C7QM8DYK.mjs} +5 -5
  119. package/.output/server/chunks/build/{town-Dsh0jlwZ.mjs.map → town-C7QM8DYK.mjs.map} +1 -1
  120. package/.output/server/chunks/build/{useDaqStream-DkRL3tEW.mjs → useDaqStream-BeA2X8KR.mjs} +26 -11
  121. package/.output/server/chunks/build/useDaqStream-BeA2X8KR.mjs.map +1 -0
  122. package/.output/server/chunks/build/{useDcwStream-DyB2ufQI.mjs → useDcwStream-BJW_MitY.mjs} +14 -6
  123. package/.output/server/chunks/build/useDcwStream-BJW_MitY.mjs.map +1 -0
  124. package/.output/server/chunks/build/{useDeviceTwins-ZbT86L9O.mjs → useDeviceTwins-Dwz_EY_i.mjs} +2 -2
  125. package/.output/server/chunks/build/{useDeviceTwins-ZbT86L9O.mjs.map → useDeviceTwins-Dwz_EY_i.mjs.map} +1 -1
  126. package/.output/server/chunks/build/{useOpsLog-8HCYFb6n.mjs → useOpsLog-Dm8QEb1I.mjs} +2 -2
  127. package/.output/server/chunks/build/{useOpsLog-8HCYFb6n.mjs.map → useOpsLog-Dm8QEb1I.mjs.map} +1 -1
  128. package/.output/server/chunks/build/{useWorkshopApi-D2gq06N2.mjs → useWorkshopApi-B-L3MmIX.mjs} +9 -2
  129. package/.output/server/chunks/build/{useWorkshopApi-D2gq06N2.mjs.map → useWorkshopApi-B-L3MmIX.mjs.map} +1 -1
  130. package/.output/server/chunks/build/{users-D6RNylrW.mjs → users-B9SAdEtH.mjs} +12 -13
  131. package/.output/server/chunks/build/users-B9SAdEtH.mjs.map +1 -0
  132. package/.output/server/chunks/build/{workshop-CTcYDq2i.mjs → workshop-81xhz368.mjs} +21 -22
  133. package/.output/server/chunks/build/workshop-81xhz368.mjs.map +1 -0
  134. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs +14 -2
  135. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs.map +1 -1
  136. package/.output/server/chunks/routes/api/workshop/channel-templates/_id/instantiate.post.mjs +1 -1
  137. package/.output/server/chunks/routes/api/workshop/channels/_id/index.put.mjs +40 -0
  138. package/.output/server/chunks/routes/api/workshop/channels/_id/index.put.mjs.map +1 -0
  139. package/.output/server/chunks/routes/api/workshop/channels/_id/index4.get.mjs +21 -9
  140. package/.output/server/chunks/routes/api/workshop/channels/_id/index4.get.mjs.map +1 -1
  141. package/.output/server/chunks/routes/api/workshop/channels/_id/index5.get.mjs +33 -0
  142. package/.output/server/chunks/routes/api/workshop/channels/_id/index5.get.mjs.map +1 -0
  143. package/.output/server/chunks/routes/api/workshop/channels/_id/terminals.get.mjs +1 -1
  144. package/.output/server/chunks/routes/api/workshop/channels.post.mjs +15 -1
  145. package/.output/server/chunks/routes/api/workshop/channels.post.mjs.map +1 -1
  146. package/.output/server/chunks/routes/api/workshop/daq/_id/bind.post.mjs +1 -1
  147. package/.output/server/chunks/routes/api/workshop/daq/_id/bindings.put.mjs +1 -1
  148. package/.output/server/chunks/routes/api/workshop/daq/_id/frames/content.get.mjs +1 -1
  149. package/.output/server/chunks/routes/api/workshop/daq/_id/frames.get.mjs +1 -1
  150. package/.output/server/chunks/routes/api/workshop/daq/_id/samples.get.mjs +1 -1
  151. package/.output/server/chunks/routes/api/workshop/daq/_id/test.post.mjs +1 -1
  152. package/.output/server/chunks/routes/api/workshop/daq/_id_.delete.mjs +1 -1
  153. package/.output/server/chunks/routes/api/workshop/daq/_id_.patch.mjs +1 -1
  154. package/.output/server/chunks/routes/api/workshop/daq/alarms/_id/ack.post.mjs +1 -1
  155. package/.output/server/chunks/routes/api/workshop/daq/controller.post.mjs +1 -1
  156. package/.output/server/chunks/routes/api/workshop/daq/index.post.mjs +1 -1
  157. package/.output/server/chunks/routes/api/workshop/daq/infra/reconnect.post.mjs +1 -1
  158. package/.output/server/chunks/routes/api/workshop/daq/infra.get.mjs +1 -1
  159. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.delete.mjs +1 -1
  160. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.patch.mjs +1 -1
  161. package/.output/server/chunks/routes/api/workshop/daq/test-driver.post.mjs +1 -1
  162. package/.output/server/chunks/routes/api/workshop/dcw/_id/bind.post.mjs +1 -1
  163. package/.output/server/chunks/routes/api/workshop/dcw/_id/bindings.put.mjs +1 -1
  164. package/.output/server/chunks/routes/api/workshop/dcw/_id/param-ledger.get.mjs +1 -1
  165. package/.output/server/chunks/routes/api/workshop/dcw/_id/read.post.mjs +1 -1
  166. package/.output/server/chunks/routes/api/workshop/dcw/_id/test.post.mjs +1 -1
  167. package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs +1 -1
  168. package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs +1 -1
  169. package/.output/server/chunks/routes/api/workshop/dcw/_id_.patch.mjs +1 -1
  170. package/.output/server/chunks/routes/api/workshop/dcw/controller.post.mjs +1 -1
  171. package/.output/server/chunks/routes/api/workshop/dcw/index.get.mjs +1 -1
  172. package/.output/server/chunks/routes/api/workshop/dcw/index.post.mjs +1 -1
  173. package/.output/server/chunks/routes/api/workshop/dcw/index2.get.mjs +1 -1
  174. package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs +1 -1
  175. package/.output/server/chunks/routes/api/workshop/dcw/index3.get.mjs +1 -1
  176. package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs +1 -1
  177. package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs +1 -1
  178. package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs +1 -1
  179. package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs +1 -1
  180. package/.output/server/chunks/routes/api/workshop/dcw/journal/node/_nodeId/rollback.post.mjs +1 -1
  181. package/.output/server/chunks/routes/api/workshop/dcw/line/query.get.mjs +1 -1
  182. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/start.post.mjs +1 -1
  183. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/stop.post.mjs +1 -1
  184. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.delete.mjs +1 -1
  185. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/judge.post.mjs +1 -1
  186. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/rollback.post.mjs +1 -1
  187. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/series.get.mjs +1 -1
  188. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id_.get.mjs +1 -1
  189. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.delete.mjs +1 -1
  190. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.patch.mjs +1 -1
  191. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/apply.post.mjs +1 -1
  192. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/mark-good.post.mjs +1 -1
  193. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/rollback-good.post.mjs +1 -1
  194. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id_.delete.mjs +1 -1
  195. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/close.post.mjs +1 -1
  196. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/data.get.mjs +1 -1
  197. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/rollback.post.mjs +1 -1
  198. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.delete.mjs +1 -1
  199. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.patch.mjs +1 -1
  200. package/.output/server/chunks/routes/api/workshop/dcw/test-driver.post.mjs +1 -1
  201. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.delete.mjs +1 -1
  202. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.patch.mjs +1 -1
  203. package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs +1 -1
  204. package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs +1 -1
  205. package/.output/server/chunks/routes/api/workshop/hitl/pending.get.mjs +1 -1
  206. package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs +1 -1
  207. package/.output/server/chunks/routes/api/workshop/index.put.mjs +1 -1
  208. package/.output/server/chunks/routes/api/workshop/index3.post.mjs +1 -1
  209. package/.output/server/chunks/routes/api/workshop/index4.get.mjs +1 -1
  210. package/.output/server/chunks/routes/api/workshop/index4.post.mjs +1 -1
  211. package/.output/server/chunks/routes/api/workshop/index5.get.mjs +1 -1
  212. package/.output/server/chunks/routes/api/workshop/index5.post.mjs +1 -1
  213. package/.output/server/chunks/routes/api/workshop/index6.post.mjs +1 -1
  214. package/.output/server/chunks/routes/api/workshop/plugins/_name/disable.post.mjs +1 -1
  215. package/.output/server/chunks/routes/api/workshop/plugins/_name/enable.post.mjs +1 -1
  216. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.delete.mjs +1 -1
  217. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.put.mjs +1 -1
  218. package/.output/server/chunks/routes/api/workshop/workspaces/_id/channel-templates/_tplId_.post.mjs +1 -1
  219. package/.output/server/chunks/routes/renderer.mjs +3 -3
  220. package/.output/server/chunks/virtual/entry.mjs +381 -438
  221. package/.output/server/chunks/virtual/entry.mjs.map +1 -1
  222. package/.output/server/chunks/virtual/precomputed.mjs +1 -1
  223. package/.output/server/package.json +1 -1
  224. package/app/app.vue +7 -0
  225. package/app/assets/css/main.css +12 -1
  226. package/app/components/workshop/DaqNodeRow.vue +398 -0
  227. package/app/components/workshop/town/ModelPreview3D.vue +26 -4
  228. package/app/components/workshop/town/TownScene3D.ts +60 -12
  229. package/app/components/workshop/town/TownView.vue +4 -3
  230. package/app/composables/workshop/useCharacterAssets.ts +1 -0
  231. package/app/composables/workshop/useDaqStream.ts +24 -5
  232. package/app/composables/workshop/useDcwStream.ts +13 -4
  233. package/app/composables/workshop/useWorkshopApi.ts +294 -259
  234. package/app/pages/daq/[id].vue +27 -3
  235. package/app/pages/daq/index.vue +8 -355
  236. package/app/pages/monitor.vue +56 -68
  237. package/app/pages/permissions/index.vue +86 -82
  238. package/app/pages/plugins/index.vue +12 -7
  239. package/app/pages/settings.vue +253 -2
  240. package/app/pages/tokens.vue +94 -96
  241. package/app/pages/users.vue +10 -18
  242. package/app/pages/workshop/index.vue +34 -5
  243. package/app/pages/workshop/teams.vue +212 -2
  244. package/i18n/dicts/_en.json +361 -1
  245. package/i18n/dicts/plugins.json +10 -0
  246. package/i18n/dicts/settings.json +1 -0
  247. package/i18n/dicts/teamPlugins.json +10 -0
  248. package/i18n/locales/en.ts +1861 -1901
  249. package/i18n/locales/zh-CN.ts +1789 -1830
  250. package/package.json +149 -148
  251. package/public/assets/game/character/yangyang-walk.glb +0 -0
  252. package/scripts/_dbg-cpu-profile.mjs +53 -0
  253. package/scripts/_dbg-logs-ui-e2e.py +3 -2
  254. package/scripts/_dbg-render-perf.mjs +142 -0
  255. package/scripts/_dbg-render-regression.mjs +130 -0
  256. package/scripts/_dbg-ui-survey.py +52 -0
  257. package/scripts/i18n-merge.mjs +152 -30
  258. package/scripts/production-closed-loop-e2e.mjs +254 -0
  259. package/scripts/team-plugins-api-smoke.mjs +149 -0
  260. package/scripts/three-system-e2e.mjs +448 -0
  261. package/server/api/plugins/[name]/[...path].ts +46 -31
  262. package/server/api/workshop/channels/[id]/plugins/index.get.ts +35 -0
  263. package/server/api/workshop/channels/[id]/plugins/index.put.ts +39 -0
  264. package/server/api/workshop/channels.post.ts +17 -0
  265. package/server/data/dcw-lines.json +14 -0
  266. package/server/data/dcw-products.json +14 -0
  267. package/server/data/dcw-recipes.json +23 -1
  268. package/server/data/dcw-rollback.json +585 -10
  269. package/server/data/dcw-runs.json +27 -27
  270. package/server/data/dcw-writes.json +96 -0
  271. package/server/data/dcws.json +394 -366
  272. package/server/data/scene-layouts.json +66 -0
  273. package/server/plugins/aw-plugins.ts +35 -27
  274. package/server/plugins-builtin/diag-bridge/index.mjs +556 -0
  275. package/server/plugins-builtin/rag-bridge/index.mjs +364 -0
  276. package/server/services/workshop/agents/host-tool-bridge.ts +659 -642
  277. package/server/services/workshop/agents/omp-agent.ts +1178 -1178
  278. package/server/services/workshop/agents/plugin-tools.ts +10 -1
  279. package/server/services/workshop/db/channel-plugins.repo.ts +65 -0
  280. package/server/services/workshop/plugins/host.mjs +52 -4
  281. package/server/services/workshop/runtime/manager.ts +2976 -2968
  282. package/shared/config/schema.json +4 -0
  283. package/.output/public/_nuxt/BJbhwS5o.js +0 -1
  284. package/.output/public/_nuxt/BUcmySDa2.js +0 -209
  285. package/.output/public/_nuxt/BWC4HQHQ.js +0 -1
  286. package/.output/public/_nuxt/BbZAzXjZ2.js +0 -1
  287. package/.output/public/_nuxt/BgOhoDTI.js +0 -1
  288. package/.output/public/_nuxt/Bo8t5fkJ.js +0 -1
  289. package/.output/public/_nuxt/BuiGDfMB.js +0 -1
  290. package/.output/public/_nuxt/BxPPAkGA.js +0 -3
  291. package/.output/public/_nuxt/C53drffV.js +0 -1
  292. package/.output/public/_nuxt/CcwJ2mrD2.js +0 -1
  293. package/.output/public/_nuxt/Cr9DkD1d.js +0 -1
  294. package/.output/public/_nuxt/DTYBfjRY.js +0 -1
  295. package/.output/public/_nuxt/DVoWWlUW.js +0 -1
  296. package/.output/public/_nuxt/Dc32T41C.js +0 -1
  297. package/.output/public/_nuxt/Dhqra7NB.js +0 -1
  298. package/.output/public/_nuxt/DlRO_q5L.js +0 -1
  299. package/.output/public/_nuxt/DsUUYP292.js +0 -1
  300. package/.output/public/_nuxt/Dsdy4Ua-.js +0 -1
  301. package/.output/public/_nuxt/DtzZqC0z.js +0 -1
  302. package/.output/public/_nuxt/Ko9mMsJj.js +0 -14
  303. package/.output/public/_nuxt/RzXYI9FM.js +0 -23
  304. package/.output/public/_nuxt/UtviM1bg.js +0 -1
  305. package/.output/public/_nuxt/_id_.C-YXjn8Q.css +0 -1
  306. package/.output/public/_nuxt/bAFueD6a.js +0 -1
  307. package/.output/public/_nuxt/builds/meta/1adc96e0-8bbd-4a79-ac7e-b6952556fef8.json +0 -1
  308. package/.output/public/_nuxt/daq.3OKj58HH.css +0 -1
  309. package/.output/public/_nuxt/dbi5bHkY.js +0 -2
  310. package/.output/public/_nuxt/eHYnGew0.js +0 -19
  311. package/.output/public/_nuxt/entry.OR_psZHp.css +0 -1
  312. package/.output/public/_nuxt/jyQyulh-.js +0 -1
  313. package/.output/public/_nuxt/monitor.CmwpEUCI.css +0 -1
  314. package/.output/public/_nuxt/permissions.DTRtZeTw.css +0 -1
  315. package/.output/public/_nuxt/plugins.BcSEwwGb.css +0 -1
  316. package/.output/public/_nuxt/settings.BqMF2nfj.css +0 -1
  317. package/.output/public/_nuxt/teams.DN0pAGGu.css +0 -1
  318. package/.output/public/_nuxt/tokens.BVXU1jOK.css +0 -1
  319. package/.output/public/_nuxt/users.D8lcLE62.css +0 -1
  320. package/.output/public/_nuxt/workshop.CbymC2LY.css +0 -1
  321. package/.output/public/_nuxt/zVkqCZ78.js +0 -1
  322. package/.output/server/chunks/build/Col-biaNnEPf.mjs +0 -338
  323. package/.output/server/chunks/build/Col-biaNnEPf.mjs.map +0 -1
  324. package/.output/server/chunks/build/agents--6bzGtES.mjs.map +0 -1
  325. package/.output/server/chunks/build/channel-templates-C1Bb-U75.mjs.map +0 -1
  326. package/.output/server/chunks/build/daq-B-3xCp_2.mjs.map +0 -1
  327. package/.output/server/chunks/build/hasIn-vQ9LWt-J.mjs +0 -554
  328. package/.output/server/chunks/build/hasIn-vQ9LWt-J.mjs.map +0 -1
  329. package/.output/server/chunks/build/input-DxDqeyQW.mjs.map +0 -1
  330. package/.output/server/chunks/build/monitor-miqq9xHB.mjs.map +0 -1
  331. package/.output/server/chunks/build/pages-D9tOoJsf.mjs.map +0 -1
  332. package/.output/server/chunks/build/permissions-CxEgXic0.mjs.map +0 -1
  333. package/.output/server/chunks/build/settings-BPBll_7K.mjs.map +0 -1
  334. package/.output/server/chunks/build/teams-DD8ZXTKL.mjs.map +0 -1
  335. package/.output/server/chunks/build/tokens-Dxnuw96_.mjs.map +0 -1
  336. package/.output/server/chunks/build/useDaqStream-DkRL3tEW.mjs.map +0 -1
  337. package/.output/server/chunks/build/useDcwStream-DyB2ufQI.mjs.map +0 -1
  338. package/.output/server/chunks/build/useSiteConfig-DJe_KMVr.mjs +0 -27
  339. package/.output/server/chunks/build/useSiteConfig-DJe_KMVr.mjs.map +0 -1
  340. package/.output/server/chunks/build/users-D6RNylrW.mjs.map +0 -1
  341. package/.output/server/chunks/build/workshop-CTcYDq2i.mjs.map +0 -1
  342. /package/.output/public/_nuxt/{CNs_Ozdc.js → CNs_Ozdc2.js} +0 -0
  343. /package/.output/public/_nuxt/{Cno6kYiO.js → Cno6kYiO2.js} +0 -0
  344. /package/.output/public/_nuxt/{ORt9oDIy2.js → ORt9oDIy.js} +0 -0
@@ -22,6 +22,10 @@
22
22
  { "key": "security.approvalGate", "type": "boolean", "group": "security", "label": "高危操作双人复核", "labelKey": "settings.runtime.security.approvalGate", "description": "R3:开启后写控/删除等高风险操作需另一位管理员批核", "applies": "live", "default": false },
23
23
  { "key": "security.hitl_timeout_ms", "type": "number", "group": "security", "label": "HITL 审批超时(ms)", "labelKey": "settings.runtime.security.hitlTimeoutMs", "description": "手动确认模式下发审批的等待超时(超时按拒绝收敛)", "applies": "restart", "default": 180000, "min": 1000, "max": 86400000, "aliases": ["HITL_TIMEOUT_MS"] },
24
24
 
25
+ { "key": "plugins.kb.base_url", "type": "string", "group": "plugins", "label": "知识库插件 API 地址", "labelKey": "settings.runtime.plugins.kbBaseUrl", "description": "rag-bridge 连接的 rag-knowledge 后端(http/https,host 限 127.0.0.1/localhost);保存即热生效", "applies": "live", "default": "http://127.0.0.1:8770" },
26
+ { "key": "plugins.kb.web_url", "type": "string", "group": "plugins", "label": "知识库 Web 地址", "labelKey": "settings.runtime.plugins.kbWebUrl", "description": "rag-knowledge Web(文档写盘/目录);保存即热生效", "applies": "live", "default": "http://127.0.0.1:6789" },
27
+ { "key": "plugins.diag.base_url", "type": "string", "group": "plugins", "label": "诊断插件 API 地址", "labelKey": "settings.runtime.plugins.diagBaseUrl", "description": "diag-bridge 连接的 industrial-deep-diagnostic 后端(http/https,host 限 127.0.0.1/localhost);保存即热生效", "applies": "live", "default": "http://127.0.0.1:3210" },
28
+
25
29
  { "key": "daq.startInfrastructure", "type": "select", "group": "daq", "label": "数采基础设施拉起策略", "labelKey": "settings.runtime.daq.startInfrastructure", "description": "auto=启动探测,不通且有 Docker 则自动拉起;always=仅 Docker 拉起;never=只直连", "applies": "live", "default": "auto", "options": ["auto", "always", "never"] },
26
30
  { "key": "daq.mqtt.host", "type": "string", "group": "daq", "label": "MQTT Broker 地址", "labelKey": "settings.runtime.daq.mqttHost", "description": "数采事件总线 MQTT 主机", "applies": "restart", "default": "127.0.0.1" },
27
31
  { "key": "daq.mqtt.port", "type": "number", "group": "daq", "label": "MQTT Broker 端口", "labelKey": "settings.runtime.daq.mqttPort", "description": "数采事件总线 MQTT 端口", "applies": "restart", "default": 1883, "min": 1, "max": 65535 },
@@ -1 +0,0 @@
1
- import{H as e,U as t,W as n,q as r}from"./rqZ-1SoP.js";import{C as i,F as a,G as o,H as s,Ht as c,St as l,Wt as u,a as d,b as f,et as p,f as m,ft as ee,g as h,h as g,mt as _,nt as v,p as y,rt as b,t as x,x as S,z as C}from"./BSCpFtzG.js";import{a as te}from"./vJ4FPb-_.js";import{t as ne}from"./D8CqF0yy.js";import{n as re}from"./BeIfu4N3.js";import{t as ie}from"./DXRZPxGs.js";import{t as ae}from"./G0qIw7Gq2.js";import{t as oe}from"./CNs_Ozdc.js";import{t as se}from"./DAR70Lf5.js";import{a as ce,n as w,t as le}from"./BuiGDfMB.js";import{t as ue}from"./BWC4HQHQ.js";var de={class:`page`},fe={class:`aw-kicker`},pe={class:`aw-page-head`},me={key:0,class:`err`},he={key:1,class:`grid`},ge={class:`col-live`},_e={class:`aw-tile value-card`},ve={class:`aw-kicker`},ye={class:`big-val mono`},be={class:`facts mono`},xe={class:`col-form aw-tile pad`},Se={class:`sec`},Ce={class:`field`},we={class:`field`},Te={value:``},Ee=[`value`],De={class:`field`},Oe=[`value`,`disabled`],ke={class:`field row`},Ae=[`disabled`],je={class:`field row`},Me=[`disabled`],Ne=[`disabled`],Pe={class:`field row`},Fe=[`disabled`],Ie={class:`field`},Le={class:`field`},Re={class:`field-row`},ze={class:`field`},Be={class:`field`},Ve={class:`field`},He={class:`field`},Ue=[`disabled`],We={class:`sec mt`},Ge={class:`driver-grid`},Ke={key:0},qe=[`onUpdate:modelValue`],Je=[`value`],Ye=[`onUpdate:modelValue`,`type`,`placeholder`],Xe={class:`test-row`},Ze=[`disabled`],Qe={class:`sec mt`},$e={class:`bind-row`},et={value:``},tt=[`value`],nt={class:`col-hist aw-tile pad`},rt={class:`hist-hd`},it={class:`sec`},at={class:`hist-ctl mono`},ot=[`value`],st={class:`raw-table mono`},ct={key:2,class:`aw-tile pad frames-tile`},lt={class:`hist-hd`},ut={class:`sec`},dt={class:`mono frames-n`},ft=[`viewBox`],pt=[`points`],mt={class:`raw-table mono`},ht={key:0,class:`gal`},gt=[`title`,`onClick`],_t=[`src`],vt={class:`mono`},yt={key:1,class:`frames-empty`},bt=[`src`],T=320,xt=84,St=`#35e0a0`,Ct=`rgba(120,135,160,0.18)`,E=`rgba(140,155,175,0.8)`,D=x(i({__name:`[id]`,setup(i){let{t:x}=re();oe({layout:`default`});let D=te(),O=m(()=>String(D.params.id??``)),k=le(),A=se();A.load();let j=ue(),M=m(()=>k.nodeById(O.value)??null),N=m(()=>{let e=M.value?ce(M.value.templateRef):``;return k.templates.find(t=>t.key===e)??null}),wt={ok:x(`daqDetail.k41k5c026`),warn:x(`daqDetail.k49z8v027`),alarm:x(`daqDetail.k3xmid028`),offline:x(`daqDetail.k44c2n029`)},P=()=>{let e=M.value;return!e||!k.controller.running||!e.enabled?`offline`:e.state},F=null;C(()=>{F=k.ensureWsFeed(),k.load(),j.load(),L.value&&z()}),a(()=>F?.());let I=m(()=>N.value?.signalKind??`scalar`),L=m(()=>I.value!==`scalar`),R=m(()=>k.framesOf(O.value));async function z(){O.value&&await k.fetchFrames(O.value,{limit:24}).catch(()=>{})}p(O,()=>{L.value&&z()});let B=e=>new Date(e).toLocaleTimeString(`zh-CN`,{hour12:!1}),V=e=>Object.entries(e.metrics??{}).slice(0,3).map(([e,t])=>`${e}=${t}`).join(` `),Tt=m(()=>R.value.find(e=>e.kind===`vector`&&e.points?.length)),Et=m(()=>{let e=Tt.value?.points??[];if(e.length<2)return``;let t=Math.min(...e),n=Math.max(...e)-t||1;return e.map((r,i)=>`${(i/(e.length-1)*T).toFixed(1)},${(78-(r-t)/n*72).toFixed(1)}`).join(` `)}),H=_(null);function Dt(e){return e==null?x(`daqDetail.k9vnp9h053`,{p0:k.controller.defaultPublishIntervalMs}):e===0?x(`daqDetail.k1m1zwux030`):`${e}ms`}let U=ee({enabled:!0,driver:`mock`,lineId:``,followGlobal:!0,intervalMs:5e3,calKind:`none`,calScale:1,calOffset:0,publishFollow:!0,publishEveryFrame:!1,publishMs:1e3,unit:``,decimals:1,min:0,max:100,warnLow:null,warnHigh:null});p(M,e=>{e&&(U.enabled=e.enabled,U.lineId=e.lineId??``,U.driver=e.driver,U.followGlobal=e.intervalMs==null,U.intervalMs=e.intervalMs??k.controller.defaultIntervalMs,U.publishFollow=e.publishIntervalMs==null,U.publishEveryFrame=e.publishIntervalMs===0,U.publishMs=e.publishIntervalMs==null?k.controller.defaultPublishIntervalMs:e.publishIntervalMs,U.unit=e.unit,U.decimals=e.decimals,U.min=e.min,U.max=e.max,U.warnLow=e.warnLow,U.warnHigh=e.warnHigh)},{immediate:!0});let W=_({}),G=m(()=>w.find(e=>e.kind===U.driver)?.configFields??[]);p(M,e=>{e&&(W.value={...e.driverConfig})},{immediate:!0}),p(()=>U.driver,()=>{if(G.value.length&&Object.keys(W.value).length===0){let e={};for(let t of G.value)t.default!==void 0&&(e[t.key]=t.default);W.value=e}},{immediate:!0});let K=_(!1),q=_(null);async function Ot(){K.value=!0,q.value=null;try{await k.patchNode(O.value,{driver:U.driver,driverConfig:{...W.value}}),q.value=await k.testNode(O.value)}catch(e){q.value={ok:!1,message:ae(e)}}finally{K.value=!1}}let J=_(!1);async function kt(){let e=M.value;if(!(!e||J.value)){J.value=!0;try{await k.patchNode(e.id,{enabled:U.enabled,driver:U.driver,lineId:U.lineId,driverConfig:{...W.value},intervalMs:U.followGlobal?null:Math.max(1e3,Math.min(6e4,Math.round(U.intervalMs))),publishIntervalMs:U.publishFollow?null:U.publishEveryFrame?0:Math.max(0,Math.min(6e4,Math.round(U.publishMs))),unit:U.unit,decimals:Math.max(0,Math.min(6,Math.round(U.decimals))),min:U.min,max:U.max,warnLow:U.warnLow,warnHigh:U.warnHigh})}finally{J.value=!1}}}function At(e){return k.meta.drivers.find(t=>t.kind===e)?.status===`planned`}let Y=_(``),jt=m(()=>(M.value?.deviceIds??(M.value?.deviceBindingId?[M.value.deviceBindingId]:[])).map(e=>j.twins.find(t=>t.id===e)?.name??`${e.slice(0,8)}…`).join(` / `));function Mt(){k.bindNode(O.value,M.value?.deviceBindingId?null:Y.value||null)}let Nt=m(()=>j.twins.filter(e=>e.kind!==`daq`&&e.id!==M.value?.id)),X=_([]),Z=_(15e3),Pt=_(!1),Ft=[{label:`1s 桶`,ms:1e3},{label:`5s 桶`,ms:5e3},{label:`15s 桶(默认)`,ms:15e3},{label:`30s 桶`,ms:3e4},{label:`1min 桶`,ms:6e4}];async function Q(){if(O.value){Pt.value=!0;try{let e=await k.samplesOf(O.value,{toMs:Date.now(),bucketMs:Z.value||void 0,limit:400});X.value=[...e].reverse()}finally{Pt.value=!1,Lt()}}}let It=_(null);function Lt(){let e=It.value;if(!e)return;let t=Math.min(window.devicePixelRatio||1,2),n=e.clientWidth,r=e.clientHeight;(e.width!==n*t||e.height!==r*t)&&(e.width=n*t,e.height=r*t);let i=e.getContext(`2d`);if(!i)return;i.setTransform(t,0,0,t,0,0),i.clearRect(0,0,n,r);for(let e=1;e<4;e++)i.strokeStyle=Ct,i.beginPath(),i.moveTo(0,r/4*e),i.lineTo(n,r/4*e),i.stroke();let a=X.value;if(a.length<2)return;let o=1/0,s=-1/0;for(let e of a){let t=e.value??e.avg??e.min??0;o=Math.min(o,t),s=Math.max(s,t)}let c=Math.max(s-o,1e-9);i.strokeStyle=E,i.font=`10px monospace`,i.fillStyle=E,i.fillText(s.toFixed(2),4,11),i.fillText(o.toFixed(2),4,r-4),i.strokeStyle=St,i.lineWidth=1.6,i.beginPath(),a.forEach((e,t)=>{let s=t/(a.length-1)*n,l=r-((e.value??e.avg??0)-o)/c*(r-16)-8;t===0?i.moveTo(s,l):i.lineTo(s,l)}),i.stroke()}let Rt=_(null),$=null;function zt(){let e=Rt.value,t=M.value;if(!e||!t||t.hist.length<2)return;let n=Math.min(window.devicePixelRatio||1,2),r=e.clientWidth,i=e.clientHeight;(e.width!==r*n||e.height!==i*n)&&(e.width=r*n,e.height=i*n);let a=e.getContext(`2d`);if(!a)return;a.setTransform(n,0,0,n,0,0),a.clearRect(0,0,r,i);let o=Math.max(...t.hist),s=Math.min(...t.hist),c=Math.max(o-s,1e-9);a.strokeStyle=`rgba(65,200,244,0.9)`,a.lineWidth=1.5,a.beginPath(),t.hist.forEach((e,n)=>{let o=n/(t.hist.length-1)*r,l=i-(e-s)/c*(i-6)-3;n===0?a.moveTo(o,l):a.lineTo(o,l)}),a.stroke()}return C(()=>{Q(),$=ie(()=>{zt()},800)}),a(()=>{$&&clearInterval($)}),p(Z,()=>void Q()),(i,a)=>{let p=ne;return s(),h(`div`,de,[y(`p`,fe,[S(p,{to:`/daq`,class:`back`},{default:v(()=>[f(u(i.$t(`daqDetail.k1emg364001`)),1)]),_:1}),f(` / NODE `+u(O.value.slice(0,8).toUpperCase()),1)]),y(`div`,pe,[y(`h1`,null,u(M.value?.name??O.value),1),y(`span`,{class:c([`st-pill`,[P()]])},u(wt[P()]),3)]),!M.value&&l(k).error?(s(),h(`p`,me,[f(u(l(k).error)+`(`,1),S(p,{to:`/workshop`},{default:v(()=>[f(u(i.$t(`daqDetail.k1bhhheq002`)),1)]),_:1}),a[20]||=f(`) `,-1)])):g(``,!0),M.value?(s(),h(`div`,he,[y(`section`,ge,[y(`div`,_e,[y(`p`,ve,u(i.$t(`daqDetail.k1fx2vik032`))+` `+u(N.value?.ch??`-`),1),y(`div`,ye,[f(u(M.value.value==null?`--`:M.value.value.toFixed(M.value.decimals)),1),y(`small`,null,u(M.value.unit),1)]),y(`canvas`,{ref_key:`liveCanvas`,ref:Rt,class:`live-canvas`},null,512),y(`dl`,be,[y(`div`,null,[y(`dt`,null,u(i.$t(`daqDetail.k4a0la003`)),1),y(`dd`,null,u(M.value.driver)+u(At(M.value.driver)?i.$t(`daqDetail.kz8zr9v035`):``),1)]),y(`div`,null,[y(`dt`,null,u(i.$t(`daqDetail.k3xg3w004`)),1),y(`dd`,null,u(M.value.intervalMs??i.$t(`daqDetail.k9vnp9h053`,{p0:l(k).controller.defaultIntervalMs})),1)]),y(`div`,null,[y(`dt`,null,u(i.$t(`daqDetail.k3w6td005`)),1),y(`dd`,null,u(Dt(M.value.publishIntervalMs)),1)]),y(`div`,null,[y(`dt`,null,u(i.$t(`daqDetail.k3x5tpx006`)),1),y(`dd`,null,u(M.value.warnLow??`-∞`)+` ~ `+u(M.value.warnHigh??`+∞`),1)]),y(`div`,null,[y(`dt`,null,u(i.$t(`daqDetail.k1hjj0jf007`)),1),y(`dd`,null,u(M.value.min)+` ~ `+u(M.value.max),1)]),y(`div`,null,[y(`dt`,null,u(i.$t(`daqDetail.k1i8rtqt008`)),1),y(`dd`,null,u(jt.value||i.$t(`daqDetail.k3own4q036`)),1)])])])]),y(`section`,xe,[y(`h3`,Se,u(i.$t(`daqDetail.kd9d69j009`)),1),y(`form`,{class:`form-grid`,onSubmit:r(kt,[`prevent`])},[y(`label`,Ce,[y(`span`,null,u(i.$t(`daqDetail.k1iw7tbf010`)),1),y(`button`,{type:`button`,class:c([`toggle`,{on:U.enabled}]),onClick:a[0]||=e=>U.enabled=!U.enabled},u(U.enabled?i.$t(`daqDetail.k3w3j8f037`):i.$t(`daqDetail.k3n5aaj045`)),3)]),y(`label`,we,[y(`span`,null,u(i.$t(`daqDetail.k12k23od011`)),1),b(y(`select`,{"onUpdate:modelValue":a[1]||=e=>U.lineId=e,class:`input`},[y(`option`,Te,u(i.$t(`daqDetail.k3ootr6012`)),1),(s(!0),h(d,null,o(l(A).lines,e=>(s(),h(`option`,{key:e.id,value:e.id},u(e.name),9,Ee))),128))],512),[[t,U.lineId]])]),y(`label`,De,[y(`span`,null,u(i.$t(`daqDetail.k1l6smxo013`)),1),b(y(`select`,{"onUpdate:modelValue":a[2]||=e=>U.driver=e,class:`input`},[(s(!0),h(d,null,o(l(w),e=>(s(),h(`option`,{key:e.kind,value:e.kind,disabled:e.status===`planned`},u(e.label)+u(e.status===`planned`?i.$t(`daqDetail.kz8zr9v035`):``),9,Oe))),128))],512),[[t,U.driver]])]),y(`label`,ke,[y(`button`,{type:`button`,class:c([`toggle slim`,{on:U.followGlobal}]),onClick:a[3]||=e=>U.followGlobal=!U.followGlobal},u(U.followGlobal?i.$t(`daqDetail.k1k2ueyq038`):i.$t(`daqDetail.k1cgi8fy046`)),3),b(y(`input`,{"onUpdate:modelValue":a[4]||=e=>U.intervalMs=e,type:`number`,min:`1000`,max:`60000`,step:`500`,class:`input`,disabled:U.followGlobal},null,8,Ae),[[n,U.intervalMs,void 0,{number:!0}]]),a[21]||=y(`small`,null,`ms`,-1)]),y(`label`,je,[y(`button`,{type:`button`,class:c([`toggle slim`,{on:U.calKind===`linear`}]),title:`采集标定 decoder:物理值 = scale × PLC采集值 + offset`,onClick:a[5]||=e=>U.calKind=U.calKind===`linear`?`none`:`linear`},u(U.calKind===`linear`?i.$t(`daqDetail.k1eru4r1039`):i.$t(`daqDetail.k3oktae047`)),3),b(y(`input`,{"onUpdate:modelValue":a[6]||=e=>U.calScale=e,type:`number`,step:`0.1`,class:`input`,disabled:U.calKind!==`linear`,title:`decode 斜率(≠0)`},null,8,Me),[[n,U.calScale,void 0,{number:!0}]]),b(y(`input`,{"onUpdate:modelValue":a[7]||=e=>U.calOffset=e,type:`number`,step:`0.1`,class:`input`,disabled:U.calKind!==`linear`,title:`decode 截距`},null,8,Ne),[[n,U.calOffset,void 0,{number:!0}]]),a[22]||=y(`small`,null,`decoder`,-1)]),y(`label`,Pe,[y(`button`,{type:`button`,class:c([`toggle slim`,{on:U.publishFollow}]),onClick:a[8]||=e=>U.publishFollow=!U.publishFollow},u(U.publishFollow?i.$t(`daqDetail.k1k2t5o7040`):i.$t(`daqDetail.k1cggz5f048`)),3),y(`span`,{class:c([`toggle slim`,{on:U.publishEveryFrame}]),style:{cursor:`pointer`},onClick:a[9]||=e=>U.publishEveryFrame=!U.publishEveryFrame},u(U.publishEveryFrame?i.$t(`daqDetail.k41mvv041`):i.$t(`daqDetail.k3n42dj049`)),3),b(y(`input`,{"onUpdate:modelValue":a[10]||=e=>U.publishMs=e,type:`number`,min:`0`,max:`60000`,step:`100`,class:`input`,disabled:U.publishFollow||U.publishEveryFrame},null,8,Fe),[[n,U.publishMs,void 0,{number:!0}]]),a[23]||=y(`small`,null,`ms`,-1)]),y(`label`,Ie,[y(`span`,null,u(i.$t(`daqDetail.k3x4ef014`)),1),b(y(`input`,{"onUpdate:modelValue":a[11]||=e=>U.unit=e,class:`input`},null,512),[[n,U.unit]])]),y(`label`,Le,[y(`span`,null,u(i.$t(`daqDetail.k3mxmcx015`)),1),b(y(`input`,{"onUpdate:modelValue":a[12]||=e=>U.decimals=e,type:`number`,min:`0`,max:`6`,class:`input`},null,512),[[n,U.decimals,void 0,{number:!0}]])]),y(`div`,Re,[y(`label`,ze,[y(`span`,null,u(i.$t(`daqDetail.k1l9jv5m016`)),1),b(y(`input`,{"onUpdate:modelValue":a[13]||=e=>U.min=e,type:`number`,step:`any`,class:`input`},null,512),[[n,U.min,void 0,{number:!0}]])]),y(`label`,Be,[y(`span`,null,u(i.$t(`daqDetail.k1md63hm017`)),1),b(y(`input`,{"onUpdate:modelValue":a[14]||=e=>U.warnLow=e,type:`number`,step:`any`,class:`input`},null,512),[[n,U.warnLow,void 0,{number:!0}]])]),y(`label`,Ve,[y(`span`,null,u(i.$t(`daqDetail.k1md63gp018`)),1),b(y(`input`,{"onUpdate:modelValue":a[15]||=e=>U.warnHigh=e,type:`number`,step:`any`,class:`input`},null,512),[[n,U.warnHigh,void 0,{number:!0}]])]),y(`label`,He,[y(`span`,null,u(i.$t(`daqDetail.k1l9jv4p019`)),1),b(y(`input`,{"onUpdate:modelValue":a[16]||=e=>U.max=e,type:`number`,step:`any`,class:`input`},null,512),[[n,U.max,void 0,{number:!0}]])])]),y(`button`,{class:`aw-pill`,type:`submit`,disabled:J.value},u(J.value?i.$t(`daqDetail.k1as0g50042`):i.$t(`daqDetail.ksn9cgo050`)),9,Ue)],32),G.value.length?(s(),h(d,{key:0},[y(`h3`,We,u(i.$t(`daqDetail.k1p9gioa033`))+` `+u(l(w).find(e=>e.kind===U.driver)?.label),1),y(`div`,Ge,[(s(!0),h(d,null,o(G.value,n=>(s(),h(`label`,{key:n.key,class:`field`},[y(`span`,null,[f(u(n.label),1),n.required?(s(),h(`em`,Ke,`*`)):g(``,!0)]),n.type===`select`?b((s(),h(`select`,{key:0,"onUpdate:modelValue":e=>W.value[n.key]=e,class:`input`},[(s(!0),h(d,null,o(n.options,e=>(s(),h(`option`,{key:e.value,value:e.value},u(e.label),9,Je))),128))],8,qe)),[[t,W.value[n.key]]]):b((s(),h(`input`,{key:1,"onUpdate:modelValue":e=>W.value[n.key]=e,type:n.type===`number`?`number`:`text`,placeholder:n.placeholder,class:`input`},null,8,Ye)),[[e,W.value[n.key]]])]))),128))]),y(`div`,Xe,[y(`button`,{class:`pill-btn`,disabled:K.value,onClick:Ot},u(K.value?i.$t(`daqDetail.k1fsh720043`):i.$t(`daqDetail.k1fstglk051`)),9,Ze),q.value?(s(),h(`span`,{key:0,class:c([`test-out mono`,q.value.ok?`ok`:`bad`])},u(q.value.ok?`✓`:`✗`)+` `+u(q.value.message),3)):g(``,!0)])],64)):g(``,!0),y(`h3`,Qe,u(i.$t(`daqDetail.k1ie6qju020`)),1),y(`div`,$e,[b(y(`select`,{"onUpdate:modelValue":a[17]||=e=>Y.value=e,class:`input grow`},[y(`option`,et,u(i.$t(`daqDetail.kjobzu3021`)),1),(s(!0),h(d,null,o(Nt.value,e=>(s(),h(`option`,{key:e.id,value:e.id},u(e.name),9,tt))),128))],512),[[t,Y.value]]),y(`button`,{class:`pill-btn`,onClick:Mt},u(jt.value?i.$t(`daqDetail.k479eh044`):i.$t(`daqDetail.k452a8052`)),1)])]),y(`section`,nt,[y(`div`,rt,[y(`h3`,it,u(i.$t(`daqDetail.k1i535i5034`))+u(l(k).meta.tsdb)+`) `,1),y(`div`,at,[b(y(`select`,{"onUpdate:modelValue":a[18]||=e=>Z.value=e,class:`input`},[(s(),h(d,null,o(Ft,e=>y(`option`,{key:e.ms,value:e.ms},u(e.label),9,ot)),64))],512),[[t,Z.value,void 0,{number:!0}]]),y(`button`,{class:`pill-btn`,onClick:Q},u(i.$t(`daqDetail.k3x1jg022`)),1)])]),y(`canvas`,{ref_key:`chartCanvas`,ref:It,class:`hist-canvas`},null,512),y(`table`,st,[y(`thead`,null,[y(`tr`,null,[y(`th`,null,u(i.$t(`daqDetail.k40vsf023`)),1),y(`th`,null,u(i.$t(`daqDetail.k48v5024`)),1),y(`th`,null,u(i.$t(`daqDetail.k4bza025`)),1)])]),y(`tbody`,null,[(s(!0),h(d,null,o(X.value.filter(e=>e.value!=null).slice(-12).reverse(),(e,t)=>(s(),h(`tr`,{key:t},[y(`td`,null,u(new Date(e.at).toLocaleTimeString(`zh-CN`,{hour12:!1})),1),y(`td`,null,u(e.value.toFixed(M.value?.decimals??2)),1),y(`td`,null,u(e.state),1)]))),128))])])])])):g(``,!0),L.value?(s(),h(`section`,ct,[y(`div`,lt,[y(`h3`,ut,[f(u(I.value===`image`?i.$t(`daqDetail.kfrm0001`):i.$t(`daqDetail.kfrm0002`))+` `,1),y(`span`,dt,u(R.value.length),1)]),y(`button`,{class:`pill-btn`,onClick:z},u(i.$t(`daqDetail.k3x1jg022`)),1)]),I.value===`vector`?(s(),h(d,{key:0},[(s(),h(`svg`,{class:`vec-svg`,viewBox:`0 0 ${T} ${xt}`,preserveAspectRatio:`none`},[y(`polyline`,{points:Et.value,fill:`none`,stroke:`var(--accent)`,"stroke-width":`1.5`},null,8,pt)],8,ft)),y(`table`,mt,[y(`thead`,null,[y(`tr`,null,[y(`th`,null,u(i.$t(`daqDetail.k40vsf023`)),1),y(`th`,null,u(i.$t(`daqDetail.kfrm0004`)),1),y(`th`,null,u(i.$t(`daqDetail.kfrm0005`)),1)])]),y(`tbody`,null,[(s(!0),h(d,null,o(R.value.filter(e=>e.kind===`vector`).slice(0,12),e=>(s(),h(`tr`,{key:e.at},[y(`td`,null,u(B(e.at)),1),y(`td`,null,u(e.points?.length??0),1),y(`td`,null,u(V(e)),1)]))),128))])])],64)):(s(),h(d,{key:1},[R.value.length?(s(),h(`div`,ht,[(s(!0),h(d,null,o(R.value,e=>(s(),h(`figure`,{key:e.at,class:`gal-item`,title:i.$t(`daqDetail.kfrm0006`),onClick:t=>H.value=e},[y(`img`,{src:e.thumbUrl,loading:`lazy`,alt:`daq frame`},null,8,_t),y(`figcaption`,vt,u(B(e.at))+` · `+u(V(e)),1)],8,gt))),128))])):(s(),h(`p`,yt,u(i.$t(`daqDetail.kfrm0003`)),1)),H.value?(s(),h(`div`,{key:2,class:`gal-full`,onClick:a[19]||=e=>H.value=null},[y(`img`,{src:H.value.contentUrl??H.value.thumbUrl,alt:`daq frame full`},null,8,bt)])):g(``,!0)],64))])):g(``,!0)])}}}),[[`__scopeId`,`data-v-9c77bd7c`]]);export{D as default};
@@ -1,209 +0,0 @@
1
- import{t as e}from"./BBrRELH32.js";import{n as t,t as n}from"./CWKEp1wx2.js";import{$ as r,A as i,B as a,C as o,Ct as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,O as y,P as b,Q as x,R as S,S as ee,St as C,T as w,U as te,V as ne,W as T,X as re,Y as E,Z as ie,_ as ae,_t as oe,a as D,at as se,b as ce,bt as O,ct as k,d as A,dt as le,et as ue,f as de,ft as j,g as fe,gt as pe,h as me,ht as M,i as N,it as P,j as he,k as F,l as ge,lt as I,m as L,mt as _e,n as R,nt as ve,o as ye,ot as be,p as xe,pt as Se,q as z,r as B,rt as Ce,s as we,st as Te,t as Ee,tt as De,u as V,v as Oe,vt as ke,w as H,x as Ae,xt as U,y as je,yt as W,z as Me}from"./BFjGV-RV2.js";var G=new be,K=new C,q=new C,J=new P,Ne={X:new C(1,0,0),Y:new C(0,1,0),Z:new C(0,0,1)},Pe={type:`change`},Fe={type:`mouseDown`,mode:null},Ie={type:`mouseUp`,mode:null},Le={type:`objectChange`},Re=class extends he{constructor(e,t=null){super(void 0,t);let n=new nt(this);this._root=n;let r=new rt;this._gizmo=r,n.add(r);let i=new it;this._plane=i,n.add(i);let a=this;function o(e,t){let n=t;Object.defineProperty(a,e,{get:function(){return n===void 0?t:n},set:function(t){n!==t&&(n=t,i[e]=t,r[e]=t,a.dispatchEvent({type:e+`-changed`,value:t}),a.dispatchEvent(Pe))}}),a[e]=t,i[e]=t,r[e]=t}o(`camera`,e),o(`object`,void 0),o(`enabled`,!0),o(`axis`,null),o(`mode`,`translate`),o(`translationSnap`,null),o(`rotationSnap`,null),o(`scaleSnap`,null),o(`space`,`world`),o(`size`,1),this.viewport=null,o(`dragging`,!1),o(`showX`,!0),o(`showY`,!0),o(`showZ`,!0),o(`showXY`,!0),o(`showYZ`,!0),o(`showXZ`,!0),o(`showXYZE`,!0),o(`showE`,!0),o(`minX`,-1/0),o(`maxX`,1/0),o(`minY`,-1/0),o(`maxY`,1/0),o(`minZ`,-1/0),o(`maxZ`,1/0);let s=new C,c=new C,l=new P,u=new P,d=new C,f=new P,p=new C,m=new C,h=new C,g=new C;o(`worldPosition`,s),o(`worldPositionStart`,c),o(`worldQuaternion`,l),o(`worldQuaternionStart`,u),o(`cameraPosition`,d),o(`cameraQuaternion`,f),o(`pointStart`,p),o(`pointEnd`,m),o(`rotationAxis`,h),o(`rotationAngle`,0),o(`eye`,g),this._offset=new C,this._startNorm=new C,this._endNorm=new C,this._cameraScale=new C,this._parentPosition=new C,this._parentQuaternion=new P,this._parentQuaternionInv=new P,this._parentScale=new C,this._worldScaleStart=new C,this._worldQuaternionInv=new P,this._worldScale=new C,this._positionStart=new C,this._quaternionStart=new P,this._scaleStart=new C,this._getPointer=ze.bind(this),this._onPointerDown=Ve.bind(this),this._onPointerHover=Be.bind(this),this._onPointerMove=He.bind(this),this._onPointerUp=Ue.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointermove`,this._onPointerHover),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerHover),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=``}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&G.setFromCamera(e,this.camera);let t=We(this._gizmo.picker[this.mode],G);this.axis=t?t.object.name:null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&G.setFromCamera(e,this.camera);let t=We(this._plane,G,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Fe.mode=this.mode,this.dispatchEvent(Fe)}}pointerMove(e){let t=this.axis,n=this.mode,r=this.object,i=this.space;if(n===`scale`?i=`local`:(t===`E`||t===`XYZE`||t===`XYZ`)&&(i=`world`),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&G.setFromCamera(e,this.camera);let a=We(this._plane,G,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n===`translate`)this._offset.copy(this.pointEnd).sub(this.pointStart),i===`local`&&t!==`XYZ`&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf(`X`)===-1&&(this._offset.x=0),t.indexOf(`Y`)===-1&&(this._offset.y=0),t.indexOf(`Z`)===-1&&(this._offset.z=0),i===`local`&&t!==`XYZ`?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i===`local`&&(r.position.applyQuaternion(J.copy(this._quaternionStart).invert()),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i===`world`&&(r.getWorldPosition(K),t.search(`X`)!==-1&&(K.x=Math.round(K.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(K.y=Math.round(K.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(K.z=Math.round(K.z/this.translationSnap)*this.translationSnap),r.position.copy(r.parent.worldToLocal(K)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(n===`scale`){if(t.search(`XYZ`)!==-1){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),q.set(e,e,e)}else K.copy(this.pointStart),q.copy(this.pointEnd),K.applyQuaternion(this._worldQuaternionInv),q.applyQuaternion(this._worldQuaternionInv),q.divide(K),t.search(`X`)===-1&&(q.x=1),t.search(`Y`)===-1&&(q.y=1),t.search(`Z`)===-1&&(q.z=1);r.scale.copy(this._scaleStart).multiply(q),this.scaleSnap&&(t.search(`X`)!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Y`)!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Z`)!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n===`rotate`){this._offset.copy(this.pointEnd).sub(this.pointStart);let e=20/this.worldPosition.distanceTo(K.setFromMatrixPosition(this.camera.matrixWorld)),n=!1;t===`XYZE`?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(K.copy(this.rotationAxis).cross(this.eye))*e):(t===`X`||t===`Y`||t===`Z`)&&(this.rotationAxis.copy(Ne[t]),K.copy(Ne[t]),i===`local`&&K.applyQuaternion(this.worldQuaternion),K.cross(this.eye),K.length()===0?n=!0:this.rotationAngle=this._offset.dot(K.normalize())*e),(t===`E`||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i===`local`&&t!==`E`&&t!==`XYZE`?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(J.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(J.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Pe),this.dispatchEvent(Le)}}pointerUp(e){(e===null||e.button===0)&&(this.dragging&&this.axis!==null&&(Ie.mode=this.mode,this.dispatchEvent(Ie)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Pe),this.dispatchEvent(Le),this.pointStart.copy(this.pointEnd))}getRaycaster(){return G}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,r){let i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(n),i.active.color.set(r),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(n),i.activeTransparent.color.set(r),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(n),i.active._color&&i.active._color.set(r),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(n),i.activeTransparent._color&&i.activeTransparent._color.set(r)}};function ze(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{let t=this.domElement.getBoundingClientRect(),n=this.viewport,r,i,a,o;return n===null?(r=0,i=0,a=t.width,o=t.height):(r=n.x,i=t.height-n.y-n.w,a=n.z,o=n.w),{x:(e.clientX-t.left-r)/a*2-1,y:-(e.clientY-t.top-i)/o*2+1,button:e.button}}}function Be(e){if(this.enabled)switch(e.pointerType){case`mouse`:case`pen`:this.pointerHover(this._getPointer(e))}}function Ve(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function He(e){this.enabled&&this.pointerMove(this._getPointer(e))}function Ue(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.pointerUp(this._getPointer(e)))}function We(e,t,n){let r=t.intersectObject(e,!0);for(let e=0;e<r.length;e++)if(r[e].object.visible||n)return r[e];return!1}var Ge=new b,Y=new C(0,1,0),Ke=new C(0,0,0),qe=new d,Je=new P,Ye=new P,X=new C,Xe=new d,Ze=new C(1,0,0),Z=new C(0,1,0),Qe=new C(0,0,1),$e=new C,et=new C,tt=new C,nt=class extends re{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){let t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error(`TransformControls: The attached 3D object must be a part of the scene graph.`):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),this.parent&&(Xe.copy(this.parent.matrixWorld).invert(),Xe.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}},rt=class extends re{constructor(){super(),this.isTransformControlsGizmo=!0,this.type=`TransformControlsGizmo`;let e=new z({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new ne({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;let r=t.clone();r.opacity=.5;let i=e.clone();i.color.setHex(16711680);let o=e.clone();o.color.setHex(65280);let s=e.clone();s.color.setHex(255);let c=e.clone();c.color.setHex(16711680),c.opacity=.5;let l=e.clone();l.color.setHex(65280),l.opacity=.5;let d=e.clone();d.color.setHex(255),d.opacity=.5;let f=e.clone();f.opacity=.25;let p=e.clone();p.color.setHex(16776960),p.opacity=.25;let m=e.clone();m.color.setHex(16776960);let g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:i,yAxis:o,zAxis:s,active:m,xAxisTransparent:c,yAxisTransparent:l,zAxisTransparent:d,activeTransparent:p};let v=new _(0,.04,.1,12);v.translate(0,.05,0);let y=new H(.08,.08,.08);y.translate(0,.04,0);let b=new w;b.setAttribute(`position`,new u([0,0,0,1,0,0],3));let x=new _(.0075,.0075,.5,3);x.translate(0,.25,0);function S(e,t){let n=new W(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}function ee(){let e=new w;return e.setAttribute(`position`,new u([0,0,0,1,1,1],3)),e}let C={X:[[new h(v,i),[.5,0,0],[0,0,-Math.PI/2]],[new h(v,i),[-.5,0,0],[0,0,Math.PI/2]],[new h(x,i),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new h(v,o),[0,.5,0]],[new h(v,o),[0,-.5,0],[Math.PI,0,0]],[new h(x,o)]],Z:[[new h(v,s),[0,0,.5],[Math.PI/2,0,0]],[new h(v,s),[0,0,-.5],[-Math.PI/2,0,0]],[new h(x,s),null,[Math.PI/2,0,0]]],XYZ:[[new h(new ie(.1,0),f),[0,0,0]]],XY:[[new h(new H(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new h(new H(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new h(new H(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]]},te={X:[[new h(new _(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new h(new _(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new h(new _(.2,0,.6,4),n),[0,.3,0]],[new h(new _(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new h(new _(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new h(new _(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new h(new ie(.2,0),n)]],XY:[[new h(new H(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new h(new H(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new h(new H(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},T={START:[[new h(new ie(.01,2),r),null,null,null,`helper`]],END:[[new h(new ie(.01,2),r),null,null,null,`helper`]],DELTA:[[new a(ee(),r),null,null,null,`helper`]],X:[[new a(b,r),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new a(b,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new a(b,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},E={XYZE:[[new h(S(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new h(S(.5,.5),i)]],Y:[[new h(S(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new h(S(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new h(S(.75,1),p),null,[0,Math.PI/2,0]]]},ae={AXIS:[[new a(b,r),[-1e3,0,0],null,[1e6,1,1],`helper`]]},oe={XYZE:[[new h(new M(.25,10,8),n)]],X:[[new h(new W(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new h(new W(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new h(new W(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new h(new W(.75,.1,2,24),n)]]},D={X:[[new h(y,i),[.5,0,0],[0,0,-Math.PI/2]],[new h(x,i),[0,0,0],[0,0,-Math.PI/2]],[new h(y,i),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new h(y,o),[0,.5,0]],[new h(x,o)],[new h(y,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new h(y,s),[0,0,.5],[Math.PI/2,0,0]],[new h(x,s),[0,0,0],[Math.PI/2,0,0]],[new h(y,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new h(new H(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new h(new H(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new h(new H(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new h(new H(.1,.1,.1),f)]]},se={X:[[new h(new _(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new h(new _(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new h(new _(.2,0,.6,4),n),[0,.3,0]],[new h(new _(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new h(new _(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new h(new _(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new h(new H(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new h(new H(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new h(new H(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new h(new H(.2,.2,.2),n),[0,0,0]]]},ce={X:[[new a(b,r),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new a(b,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new a(b,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]};function O(e){let t=new re;for(let n in e)for(let r=e[n].length;r--;){let i=e[n][r][0].clone(),a=e[n][r][1],o=e[n][r][2],s=e[n][r][3],c=e[n][r][4];i.name=n,i.tag=c,a&&i.position.set(a[0],a[1],a[2]),o&&i.rotation.set(o[0],o[1],o[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix();let l=i.geometry.clone();l.applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),t.add(i)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=O(C)),this.add(this.gizmo.rotate=O(E)),this.add(this.gizmo.scale=O(D)),this.add(this.picker.translate=O(te)),this.add(this.picker.rotate=O(oe)),this.add(this.picker.scale=O(se)),this.add(this.helper.translate=O(T)),this.add(this.helper.rotate=O(ae)),this.add(this.helper.scale=O(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){let t=(this.mode===`scale`?`local`:this.space)===`local`?this.worldQuaternion:Ye;this.gizmo.translate.visible=this.mode===`translate`,this.gizmo.rotate.visible=this.mode===`rotate`,this.gizmo.scale.visible=this.mode===`scale`,this.helper.translate.visible=this.mode===`translate`,this.helper.rotate.visible=this.mode===`rotate`,this.helper.scale.visible=this.mode===`scale`;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e<n.length;e++){let r=n[e];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let i;if(i=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(i*this.size/4),r.tag===`helper`){r.visible=!1,r.name===`AXIS`?(r.visible=!!this.axis,this.axis===`X`&&(J.setFromEuler(Ge.set(0,0,0)),r.quaternion.copy(t).multiply(J),Math.abs(Y.copy(Ze).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Y`&&(J.setFromEuler(Ge.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(J),Math.abs(Y.copy(Z).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Z`&&(J.setFromEuler(Ge.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(J),Math.abs(Y.copy(Qe).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`XYZE`&&(J.setFromEuler(Ge.set(0,Math.PI/2,0)),Y.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(qe.lookAt(Ke,Y,Z)),r.quaternion.multiply(J),r.visible=this.dragging),this.axis===`E`&&(r.visible=!1)):r.name===`START`?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name===`END`?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name===`DELTA`?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),K.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),K.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(K),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}if(r.quaternion.copy(t),this.mode===`translate`||this.mode===`scale`){let e=.99,n=.2;r.name===`X`&&Math.abs(Y.copy(Ze).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Y`&&Math.abs(Y.copy(Z).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Z`&&Math.abs(Y.copy(Qe).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XY`&&Math.abs(Y.copy(Qe).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`YZ`&&Math.abs(Y.copy(Ze).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XZ`&&Math.abs(Y.copy(Z).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)}else this.mode===`rotate`&&(Je.copy(t),Y.copy(this.eye).applyQuaternion(J.copy(t).invert()),r.name.search(`E`)!==-1&&r.quaternion.setFromRotationMatrix(qe.lookAt(this.eye,Ke,Z)),r.name===`X`&&(J.setFromAxisAngle(Ze,Math.atan2(-Y.y,Y.z)),J.multiplyQuaternions(Je,J),r.quaternion.copy(J)),r.name===`Y`&&(J.setFromAxisAngle(Z,Math.atan2(Y.x,Y.z)),J.multiplyQuaternions(Je,J),r.quaternion.copy(J)),r.name===`Z`&&(J.setFromAxisAngle(Qe,Math.atan2(Y.y,Y.x)),J.multiplyQuaternions(Je,J),r.quaternion.copy(J)));r.visible=r.visible&&(r.name.indexOf(`X`)===-1||this.showX),r.visible=r.visible&&(r.name.indexOf(`Y`)===-1||this.showY),r.visible=r.visible&&(r.name.indexOf(`Z`)===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf(`E`)===-1||this.showX&&this.showY&&this.showZ),r.visible=r.visible&&(r.name.indexOf(`XY`)===-1||this.showXY),r.visible=r.visible&&(r.name.indexOf(`YZ`)===-1||this.showYZ),r.visible=r.visible&&(r.name.indexOf(`XZ`)===-1||this.showXZ),r.visible=r.visible&&(r.name!==`E`||this.showE),r.visible=r.visible&&(r.name!==`XYZE`||this.showXYZE),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split(``).some(function(e){return r.name===e}))&&(r.material.color.copy(this.materialLib.active.color),r.material.opacity=1)}super.updateMatrixWorld(e)}},it=class extends h{constructor(){super(new ve(1e5,1e5,2,2),new z({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type=`TransformControlsPlane`}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode===`scale`&&(t=`local`),$e.copy(Ze).applyQuaternion(t===`local`?this.worldQuaternion:Ye),et.copy(Z).applyQuaternion(t===`local`?this.worldQuaternion:Ye),tt.copy(Qe).applyQuaternion(t===`local`?this.worldQuaternion:Ye),Y.copy(et),this.mode){case`translate`:case`scale`:switch(this.axis){case`X`:Y.copy(this.eye).cross($e),X.copy($e).cross(Y);break;case`Y`:Y.copy(this.eye).cross(et),X.copy(et).cross(Y);break;case`Z`:Y.copy(this.eye).cross(tt),X.copy(tt).cross(Y);break;case`XY`:X.copy(tt);break;case`YZ`:X.copy($e);break;case`XZ`:Y.copy(tt),X.copy(et);break;case`XYZ`:case`E`:X.set(0,0,0)}break;default:X.set(0,0,0)}X.length()===0?this.quaternion.copy(this.cameraQuaternion):(Xe.lookAt(K.set(0,0,0),X,Y),this.quaternion.setFromRotationMatrix(Xe)),super.updateMatrixWorld(e)}},at={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
2
-
3
- varying vec2 vUv;
4
-
5
- void main() {
6
-
7
- vUv = uv;
8
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
9
-
10
- }`,fragmentShader:`
11
-
12
- uniform float opacity;
13
-
14
- uniform sampler2D tDiffuse;
15
-
16
- varying vec2 vUv;
17
-
18
- void main() {
19
-
20
- vec4 texel = texture2D( tDiffuse, vUv );
21
- gl_FragColor = opacity * texel;
22
-
23
-
24
- }`},Q=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},ot=new x(-1,1,1,-1,0,1),st=new class extends w{constructor(){super(),this.setAttribute(`position`,new u([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new u([0,2,0,0,2,0],2))}},ct=class{constructor(e){this._mesh=new h(st,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ot)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},lt=class extends Q{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof j?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=O.clone(e.uniforms),this.material=new j({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new ct(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},ut=class extends Q{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},dt=class extends Q{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},ft=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new U);this._width=n.width,this._height=n.height,t=new s(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:S}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new lt(at),this.copyPass.material.blending=0,this.timer=new ke}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}ut!==void 0&&(r instanceof ut?n=!0:r instanceof dt&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new U);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},pt=class extends Q{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new F}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}},mt={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new F(0)},defaultOpacity:{value:0}},vertexShader:`
25
-
26
- varying vec2 vUv;
27
-
28
- void main() {
29
-
30
- vUv = uv;
31
-
32
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
33
-
34
- }`,fragmentShader:`
35
-
36
- uniform sampler2D tDiffuse;
37
- uniform vec3 defaultColor;
38
- uniform float defaultOpacity;
39
- uniform float luminosityThreshold;
40
- uniform float smoothWidth;
41
-
42
- varying vec2 vUv;
43
-
44
- void main() {
45
-
46
- vec4 texel = texture2D( tDiffuse, vUv );
47
-
48
- float v = luminance( texel.xyz );
49
-
50
- vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
51
-
52
- float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
53
-
54
- gl_FragColor = mix( outputColor, texel, alpha );
55
-
56
- }`},ht=class e extends Q{constructor(e,t=1,n,r){super(),this.strength=t,this.radius=n,this.threshold=r,this.resolution=e===void 0?new U(256,256):new U(e.x,e.y),this.clearColor=new F(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new s(i,a,{type:S}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new s(i,a,{type:S});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new s(i,a,{type:S});n.texture.name=`UnrealBloomPass.v`+e,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),i=Math.round(i/2),a=Math.round(a/2)}let o=mt;this.highPassUniforms=O.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new j({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];let c=[6,10,14,18,22];i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(c[e])),this.separableBlurMaterials[e].uniforms.invSize.value=new U(1/i,1/a),i=Math.round(i/2),a=Math.round(a/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;let l=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=l,this.bloomTintColors=[new C(1,1,1),new C(1,1,1),new C(1,1,1),new C(1,1,1),new C(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=O.clone(at.uniforms),this.blendMaterial=new j({uniforms:this.copyUniforms,vertexShader:at.vertexShader,fragmentShader:at.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new F,this._oldClearAlpha=1,this._basic=new z,this._fsQuad=new ct(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(n,r),this.renderTargetsVertical[e].setSize(n,r),this.separableBlurMaterials[e].uniforms.invSize.value=new U(1/n,1/r),n=Math.round(n/2),r=Math.round(r/2)}render(t,n,r,i,a){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();let o=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=r.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let s=this.renderTargetBright;for(let n=0;n<this.nMips;n++)this._fsQuad.material=this.separableBlurMaterials[n],this.separableBlurMaterials[n].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[n]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[n].uniforms.colorTexture.value=this.renderTargetsHorizontal[n].texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[n]),t.clear(),this._fsQuad.render(t),s=this.renderTargetsVertical[n];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(r),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=o}_getSeparableBlurMaterial(e){let t=[],n=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(n*n))/n);return new j({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new U(.5,.5)},direction:{value:new U(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
57
-
58
- varying vec2 vUv;
59
-
60
- void main() {
61
-
62
- vUv = uv;
63
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
64
-
65
- }`,fragmentShader:`
66
-
67
- #include <common>
68
-
69
- varying vec2 vUv;
70
-
71
- uniform sampler2D colorTexture;
72
- uniform vec2 invSize;
73
- uniform vec2 direction;
74
- uniform float gaussianCoefficients[KERNEL_RADIUS];
75
-
76
- void main() {
77
-
78
- float weightSum = gaussianCoefficients[0];
79
- vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
80
-
81
- for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
82
-
83
- float x = float( i );
84
- float w = gaussianCoefficients[i];
85
- vec2 uvOffset = direction * invSize * x;
86
- vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
87
- vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
88
- diffuseSum += ( sample1 + sample2 ) * w;
89
-
90
- }
91
-
92
- gl_FragColor = vec4( diffuseSum, 1.0 );
93
-
94
- }`})}_getCompositeMaterial(e){return new j({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`
95
-
96
- varying vec2 vUv;
97
-
98
- void main() {
99
-
100
- vUv = uv;
101
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
102
-
103
- }`,fragmentShader:`
104
-
105
- varying vec2 vUv;
106
-
107
- uniform sampler2D blurTexture1;
108
- uniform sampler2D blurTexture2;
109
- uniform sampler2D blurTexture3;
110
- uniform sampler2D blurTexture4;
111
- uniform sampler2D blurTexture5;
112
- uniform float bloomStrength;
113
- uniform float bloomRadius;
114
- uniform float bloomFactors[NUM_MIPS];
115
- uniform vec3 bloomTintColors[NUM_MIPS];
116
-
117
- float lerpBloomFactor( const in float factor ) {
118
-
119
- float mirrorFactor = 1.2 - factor;
120
- return mix( factor, mirrorFactor, bloomRadius );
121
-
122
- }
123
-
124
- void main() {
125
-
126
- // 3.0 for backwards compatibility with previous alpha-based intensity
127
- vec3 bloom = 3.0 * bloomStrength * (
128
- lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
129
- lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
130
- lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
131
- lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
132
- lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
133
- );
134
-
135
- float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
136
- gl_FragColor = vec4( bloom, bloomAlpha );
137
-
138
- }`})}};ht.BlurDirectionX=new U(1,0),ht.BlurDirectionY=new U(0,1);var gt={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
139
- precision highp float;
140
-
141
- uniform mat4 modelViewMatrix;
142
- uniform mat4 projectionMatrix;
143
-
144
- attribute vec3 position;
145
- attribute vec2 uv;
146
-
147
- varying vec2 vUv;
148
-
149
- void main() {
150
-
151
- vUv = uv;
152
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
153
-
154
- }`,fragmentShader:`
155
-
156
- precision highp float;
157
-
158
- uniform sampler2D tDiffuse;
159
-
160
- #include <tonemapping_pars_fragment>
161
- #include <colorspace_pars_fragment>
162
-
163
- varying vec2 vUv;
164
-
165
- void main() {
166
-
167
- gl_FragColor = texture2D( tDiffuse, vUv );
168
-
169
- // tone mapping
170
-
171
- #ifdef LINEAR_TONE_MAPPING
172
-
173
- gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
174
-
175
- #elif defined( REINHARD_TONE_MAPPING )
176
-
177
- gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
178
-
179
- #elif defined( CINEON_TONE_MAPPING )
180
-
181
- gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
182
-
183
- #elif defined( ACES_FILMIC_TONE_MAPPING )
184
-
185
- gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
186
-
187
- #elif defined( AGX_TONE_MAPPING )
188
-
189
- gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
190
-
191
- #elif defined( NEUTRAL_TONE_MAPPING )
192
-
193
- gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
194
-
195
- #elif defined( CUSTOM_TONE_MAPPING )
196
-
197
- gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
198
-
199
- #endif
200
-
201
- // color space
202
-
203
- #ifdef SRGB_TRANSFER
204
-
205
- gl_FragColor = sRGBTransferOETF( gl_FragColor );
206
-
207
- #endif
208
-
209
- }`},_t=class extends Q{constructor(){super(),this.isOutputPass=!0,this.uniforms=O.clone(gt.uniforms),this.material=new se({name:gt.name,uniforms:this.uniforms,vertexShader:gt.vertexShader,fragmentShader:gt.fragmentShader}),this._fsQuad=new ct(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},i.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},vt=class{channelId;name;x;z;radiusX;radiusZ;shape;rotationY;color;platform;padRing;beacon;boundary;label;members=[];host;constructor(e){Object.assign(this,e)}layout(){return{channelId:this.channelId,x:this.x,z:this.z,radiusX:this.radiusX,radiusZ:this.radiusZ,shape:this.shape,rotationY:this.rotationY}}normLayout(){return L(this.layout())}handlePoints(){return this.shape===`rect`?[[this.radiusX,this.radiusZ],[-this.radiusX,this.radiusZ],[-this.radiusX,-this.radiusZ],[this.radiusX,-this.radiusZ]]:[[this.radiusX,0],[-this.radiusX,0],[0,this.radiusZ],[0,-this.radiusZ]]}pointIn(e,t){return me(this.layout(),e,t)}moveBy(e,t){this.x+=e,this.z+=t,this.platform.position.set(this.x,.16,this.z),this.padRing.position.set(this.x,.32,this.z),this.beacon.position.set(this.x,0,this.z),this.boundary.position.set(this.x,.3,this.z),this.boundary.rotation.y=this.rotationY*Math.PI/180,this.label.position.set(this.x,30,this.z);for(let n of this.members)n.root.position.x+=e,n.root.position.z+=t,n.homeX+=e,n.homeZ+=t,n.range&&(n.range.x+=e,n.range.z+=t,n.renderRangeLine());this.host.trackLayout(this)}applyPatch(e){e.x!==void 0&&(this.x=e.x),e.z!==void 0&&(this.z=e.z),e.radiusX!==void 0&&(this.radiusX=e.radiusX),e.radiusZ!==void 0&&(this.radiusZ=e.radiusZ),e.shape!==void 0&&(this.shape=e.shape),e.rotationY!==void 0&&(this.rotationY=e.rotationY)}clampMembersAndRanges(){let e=this.layout();for(let t of this.members){let n=A(e,t.root.position.x,t.root.position.z,16);if(t.root.position.x=n.x,t.root.position.z=n.z,t.homeX=n.x,t.homeZ=n.z,t.range){t.renderRangeLine();let e=V(t.range,t.homeX,t.homeZ,0);(e.x!==t.homeX||e.z!==t.homeZ)&&(t.homeX=e.x,t.homeZ=e.z,t.root.position.x=e.x,t.root.position.z=e.z)}}this.host.markDirty()}};function $(e,t,n,r){let i=ye(e,t,n,48).map(([e,t])=>new C(e,0,t)),a=new w().setFromPoints(i);return new te(a,new ne({color:r,transparent:!0,opacity:.75,depthTest:!1}))}var yt=class{channelId;agentId;name;role;root;model;mixer;clips;colorNum;nameSprite;bubble;bubbleText;bubbleTimer;state;progress;behavior;dragging;homeX;homeZ;range;rangeLine;textureKey;modelRef;animState=`idle`;activeAction=null;host;moving=!1;aura=null;auraMats=[];auraPhase=0;attachAura(e,t){let n=new g,r=[],i=(t,i,a,o)=>{let s=new z({color:e,transparent:!0,opacity:o,side:2,depthWrite:!1,blending:2});s.userData.baseOp=o,r.push(s);let c=new h(new k(t,i,44),s);c.rotation.x=-Math.PI/2,c.position.y=a,n.add(c)};i(34,40,.36,.26),t===`lead`&&i(46,50,.42,.2),this.root.add(n),this.aura=n,this.auraMats=r,this.auraPhase=Math.random()*Math.PI*2}constructor(e){Object.assign(this,e)}reached(e){return Math.hypot(this.root.position.x-e.x,this.root.position.z-e.z)<=48}driveToward(e,n,r){this.moving=!0;let i={x:this.root.position.x,z:this.root.position.z},a=t({x:i.x,y:i.z},{x:e.x,y:e.z},n,r),o=a.x,s=a.y;if(this.range){let e=V(this.range,o,s,6);o=e.x,s=e.z}else{let e=this.host.blockLayoutOf(this.channelId);if(e){let t=A(e,o,s,6);o=t.x,s=t.z}}this.root.position.x=o,this.root.position.z=s;let c=a.dir===`left`?Math.PI:0,l=this.root.rotation.y,u=c-l;u>Math.PI?u-=Math.PI*2:u<-Math.PI&&(u+=Math.PI*2);let d=r*3.2;this.root.rotation.y=l+Math.max(-d,Math.min(d,u))}update(e){this.moving=!1;try{this.updateBehavior(e)}finally{this.playWalkAnim(this.moving)}}updateBehavior(e){let t=this.behavior;if(t.mode===`idle`||t.mode===`roam`){if(t.engaged||this.dragging)return;if(t.mode=`roam`,!t.roamTarget){if(performance.now()<t.pauseUntil)return;let e=this.host.blockLayoutOf(this.channelId),n,r;if(this.range){n=this.homeX+(Math.random()*2-1)*this.range.radiusX*.9,r=this.homeZ+(Math.random()*2-1)*this.range.radiusZ*.9;let e=V(this.range,n,r,8);n=e.x,r=e.z}else{let t=e?Math.min(e.radiusX,e.radiusZ)*.45:80;if(n=this.homeX+(Math.random()*2-1)*t,r=this.homeZ+(Math.random()*2-1)*t*.6,e){let t=A(e,n,r,16);n=t.x,r=t.z}}t.roamTarget={x:n,z:r}}this.driveToward(t.roamTarget,48,e),this.reached(t.roamTarget)&&(t.roamTarget=null,t.pauseUntil=performance.now()+350+Math.random()*900);return}if(t.mode===`approach`){let n=t.targetId?this.host.getAgent(t.targetId):void 0;if(!n){t.mode=`idle`;return}let r={x:n.root.position.x,z:n.root.position.z};if(this.range){let e=V(this.range,r.x,r.z,8);r={x:e.x,z:e.z}}this.driveToward(r,96,e),this.reached(r)&&(this.host.deliverBehavior(this,n),t.action?.requireReply?(t.mode=`wait`,t.waitUntil=performance.now()+Ee):(t.mode=`returnHome`,this.host.releaseEngaged(this),t.targetId=null));return}if(t.mode===`wait`){if(this.dragging)return;let n=t.targetId?this.host.getAgent(t.targetId):void 0;if(n&&!n.dragging){let t={x:n.root.position.x+28,z:n.root.position.z+8};this.driveToward(t,96*.6,e)}performance.now()>=t.waitUntil&&(t.mode=`returnHome`,this.host.releaseEngaged(this));return}if(t.mode===`returnHome`){if(this.dragging)return;let n={x:this.homeX,z:this.homeZ};this.driveToward(n,96*.7,e),this.reached(n)&&(this.root.position.set(this.homeX,0,this.homeZ),t.mode=`idle`,t.targetId=null,t.action=void 0)}}playWalkAnim(e){let t=e?`walk`:`idle`;if(this.animState!==t&&(this.animState=t,this.host.notifyMotion(this)),this.clips.length===0){let t=performance.now(),n=1.2+Math.sin(t*.0016)*1.6,r=Math.abs(Math.sin(t*.005))*6;this.model.position.y=e?r:n;let i=e?Math.sin(t*.006)*.07:0;this.model.rotation.z+=(i-this.model.rotation.z)*.12;return}if(!this.mixer)return;let n=e?+(this.clips.length>1):0,r=this.clips[n];if(!r)return;let i=this.mixer.clipAction(r);if(this.activeAction===i){i.timeScale=e?1.3:.9;return}i.reset().setEffectiveTimeScale(e?1.3:.9).fadeIn(.15).play(),this.activeAction&&this.activeAction.fadeOut(.15),this.activeAction=i}setHome(e,t){this.homeX=e,this.homeZ=t}renderRangeLine(){if(this.rangeLine&&=(this.host.threeScene.remove(this.rangeLine),null),!this.range)return;let e=4311284,t=$(this.range.shape,this.range.radiusX,this.range.radiusZ,e);t.material=new f({color:e,transparent:!0,opacity:.75,depthTest:!1,dashSize:14,gapSize:9}),t.computeLineDistances(),t.position.set(this.range.x,.5,this.range.z),t.rotation.y=this.range.rotationY*Math.PI/180,t.visible=this.host.rangeLineVisibleFor(this),this.host.threeScene.add(t),this.rangeLine=t,this.host.markDirty()}attachBubble(e,t){this.bubble&&(this.host.threeScene.remove(this.bubble),this.bubbleText=null),this.bubble=e,this.bubbleText=t}clearBubble(){this.bubble&&(this.host.threeScene.remove(this.bubble),this.bubble=null,this.bubbleText=null)}},bt=class{twinId;name;modelRef;root;holder;ring;arc=null;label;state;telemetry;host;constructor(e){Object.assign(this,e)}topYCache=null;lineColor=``;applyLine=null;updateRing(){let e=this.ring.material;this.lineColor?e.color.set(this.lineColor):e.color.setHex(this.state===`alarm`?16739179:this.state===`offline`?8689317:this.state===`running`?3530912:16172115),this.arc&&(this.arc.visible=this.state===`running`)}applyTwin(e){e.state&&(this.state=e.state),e.telemetry&&(this.telemetry={...this.telemetry,...e.telemetry}),e.name&&e.name!==this.name&&this.host.renameDeviceSprite(this,e.name),e.modelRef&&e.modelRef!==this.modelRef&&this.host.swapDeviceModelSprite(this,e.modelRef),(e.lineColor??``)!==this.lineColor&&(this.lineColor=e.lineColor??``,this.applyLine?.(this.lineColor)),this.updateRing(),this.host.markDirty()}rememberTransform(){return{posX:Math.round(this.root.position.x*10)/10,posZ:Math.round(this.root.position.z*10)/10,rotationY:Math.round(T.radToDeg(this.root.rotation.y)*10)/10}}},xt=class t{renderer;composer;camera;camTarget=new C(R,20,B);keyLight;scene;ground;skyDome=null;blocks=new Map;agents=new Map;deviceNodes=new Map;daqLedRings=new Map;daqLinkGroup=new g;daqLinks=[];static _wDir=new C;static _wRel=new C;static _wVec=new C;static _wVec2=new U;static _groundPlane=new De(new C(0,1,0),0);static _raycaster=new be;daqLinkSig=``;daqLinksWanted=[];filmWebGroup=new g;filmWebSig=``;filmWebMat=null;pendingDeviceTwins=new Map;pendingDeviceCreates=new Map;cancelledDeviceCreates=new Set;scalables=new Map;selected=null;modelsById=new Map;gltfCache=new Map;gltfLoader=new Oe;el;raf=0;clock=new y;frameCount=0;fpsAccum=0;frameBudgetMs=25;setFpsCap(e){this.frameBudgetMs=e>0?1e3/e:0,this.frameAcc=0}frameAcc=0;baseDpr=Math.min(window.devicePixelRatio,2);dirty=!0;flagBy=new Map;disposed=!1;dolly=1;autoOrbit=!1;viewCur={yaw:0,pitch:.7,radius:1178};viewTarget={yaw:0,pitch:.7,radius:1178};tControls=null;resizeOb=null;mode=`browse`;pointerDrag=null;snapEnabled=!0;selRing=null;resizeHandles=[];agentRangeHandles=[];rangeDrawLine=null;rangeDrawAgent=null;rangeDrawPreviewState=null;rangeHomeMoved=null;lastActivity=null;recentActivity=[];dbgBubbles=[];receivers=new Map;container;resolveTaskAssignee=null;devices=null;agentApi=null;channelApi=null;busHandlers=new Map;constructor(e,t){this.el=t,this.container=t,this.initRenderer(),this.buildBlocks(e)}initRenderer(){this.renderer=new ce({antialias:!0,alpha:!0,powerPreference:`high-performance`}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(this.el.clientWidth||1100,this.el.clientHeight||700),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=2,this.renderer.shadowMap.autoUpdate=!1,this.renderer.outputColorSpace=I,this.renderer.toneMapping=4,this.renderer.toneMappingExposure=1.12,this.el.appendChild(this.renderer.domElement),this.resizeOb=new ResizeObserver(()=>{let e=this.el.clientWidth,t=this.el.clientHeight;e<2||t<2||(this.renderer.setSize(e,t),this.composer.setSize(e,t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.dirty=!0)}),this.resizeOb.observe(this.el);let e=null;this.renderer.domElement.addEventListener(`pointerdown`,t=>{e=t.button===0?{x:t.clientX,y:t.clientY}:null}),this.renderer.domElement.addEventListener(`pointerup`,t=>{if(t.button!==0||this.pointerDrag||this.tControls?.dragging)return;if(e&&Math.hypot(t.clientX-e.x,t.clientY-e.y)>8){e=null;return}e=null;let n=this.screenToWorld(t.clientX,t.clientY),r=this.pickBeacon(n.x,n.z);if(r){this.setSelected(null),this.selectChannel(r.cid),this.focusTo(r.x,r.z);return}let i=this.pickAt(n.x,n.z);if(i){this.setSelected(i),this.selectedChannel&&this.selectChannel(null);return}let a=this.pickChannel(n.x,n.z);this.setSelected(null),a&&this.mode===`edit`&&this.selectChannel(a)}),this.renderer.domElement.addEventListener(`dblclick`,e=>{if(this.pointerDrag)return;let t=this.screenToWorld(e.clientX,e.clientY),n=this.pickAt(t.x,t.z);if(n?.kind===`agent`){let e=this.agents.get(n.id);e&&this.focusTo(e.root.position.x,e.root.position.z)}else if(n?.kind===`device`){let e=this.deviceNodes.get(n.id);e&&this.focusTo(e.root.position.x,e.root.position.z)}else{let e=this.pickChannel(t.x,t.z),n=e?this.blocks.get(e):void 0;n&&(this.selectChannel(e),this.focusTo(n.x,n.z))}}),this.scene=new le,this.scene.background=new F(659224),this.scene.fog=new p(1779766,1400,8800);try{let e=new je(this.renderer);this.scene.environment=e.fromScene(new ae,.04).texture,this.scene.environmentIntensity=.42,e.dispose()}catch{}this.skyDome=this.makeSkyDome(),this.scene.add(this.skyDome);for(let e=0;e<4;e++){let t=new h(new W(16,6,8,20),new z({color:16172115,transparent:!0,opacity:.95,depthTest:!1}));t.rotation.x=Math.PI/2,t.position.y=1.4,t.visible=!1,this.scene.add(t),this.resizeHandles.push({mesh:t,cid:``,handle:e})}for(let e=0;e<4;e++){let t=new h(new W(10,4,8,16),new z({color:4311284,transparent:!0,opacity:.95,depthTest:!1}));t.rotation.x=Math.PI/2,t.position.y=1.2,t.visible=!1,this.scene.add(t),this.agentRangeHandles.push({mesh:t,agentId:``,handle:e})}let t=new h(new k(.92,1,56),new z({color:16172115,transparent:!0,opacity:.85,side:2,depthWrite:!1,blending:2}));t.rotation.x=-Math.PI/2,t.position.y=.5,t.visible=!1,t.renderOrder=5,this.scene.add(t),this.selRing=t,this.camera=new ue(55,(this.el.clientWidth||1100)/(this.el.clientHeight||700),1,12e3),this.camera.position.set(R,760,B+900),this.camera.lookAt(R,20,B);let n=new Re(this.camera,this.renderer.domElement);n.size=.85,n.setMode(`translate`),n.showY=!1,n.addEventListener(`dragging-changed`,e=>{if(!e.value){let e=this.selected;e?.kind===`device`&&this.deviceNodes.has(e.id)&&this.persistDeviceTransform(e.id)}}),n.addEventListener(`objectChange`,()=>{let e=this.selected;if(!e||e.kind!==`device`)return;let t=this.deviceNodes.get(e.id);if(t){if(n.mode===`scale`&&Math.abs(t.root.scale.x-1)>1e-4){let n=this.scalables.get(`device:${e.id}`)?.userScale??1;this.setModelScale(e.id,Math.min(50,Math.max(.02,n*t.root.scale.x)),`device`),t.root.scale.set(1,1,1)}this.dirty=!0}}),this.tControls=n,this.scene.add(n.getHelper()),this.scene.add(new Ae(13690094,1.6));let r=new Me(10471400,3813157,.7);this.scene.add(r);let i=new v(16774368,3.2);i.position.set(R+500,900,B+300),i.castShadow=!0,this.keyLight=i,i.shadow.mapSize.set(2048,2048),i.shadow.camera.left=-1400,i.shadow.camera.right=1400,i.shadow.camera.top=2e3,i.shadow.camera.bottom=-2e3,i.shadow.normalBias=2,i.shadow.bias=-2e-4,i.shadow.radius=6,this.scene.add(i);let a=new v(8961023,.75);a.position.set(R-1200,900,B-800),this.scene.add(a);let o=new v(4311284,1.4);o.position.set(R-1400,620,B-1e3),this.scene.add(o);let c=new v(3530912,.4);c.position.set(R+700,380,B+900),this.scene.add(c);let l=new E({color:16777215,roughness:.62,metalness:.3,envMapIntensity:.42});this.ground=new h(new ve(D*16,N*16),l),this.ground.rotation.x=-Math.PI/2,this.ground.receiveShadow=!0,this.scene.add(this.ground),this.scene.add(this.daqLinkGroup,this.filmWebGroup);let u=new s(1,1,{type:S,samples:4});this.composer=new ft(this.renderer,u),this.composer.setPixelRatio(this.renderer.getPixelRatio()),this.composer.setSize(this.el.clientWidth||1100,this.el.clientHeight||700),this.composer.addPass(new pt(this.scene,this.camera)),this.composer.addPass(new ht(new U(this.el.clientWidth||1100,this.el.clientHeight||700),.32,.35,3)),this.composer.addPass(new _t),this.applyGroundTexture(),globalThis.__townScene3d=this,this.loop()}makeIndustrialGroundTexture(){let e=1024,t=document.createElement(`canvas`);t.width=e,t.height=e;let n=t.getContext(`2d`),r=n.createLinearGradient(0,0,e,e);r.addColorStop(0,`#151f36`),r.addColorStop(.5,`#101a2d`),r.addColorStop(1,`#131c31`),n.fillStyle=r,n.fillRect(0,0,e,e),n.strokeStyle=`rgba(42,63,102,0.32)`,n.lineWidth=2;for(let t=0;t<=8;t++){let r=t/8*e;n.beginPath(),n.moveTo(r,0),n.lineTo(r,e),n.stroke(),n.beginPath(),n.moveTo(0,r),n.lineTo(e,r),n.stroke()}n.strokeStyle=`rgba(42,63,102,0.2)`,n.lineWidth=1;for(let t=0;t<=32;t++){let r=t/32*e;n.beginPath(),n.moveTo(r,0),n.lineTo(r,e),n.stroke(),n.beginPath(),n.moveTo(0,r),n.lineTo(e,r),n.stroke()}n.fillStyle=`rgba(255,255,255,0.02)`;for(let t=0;t<900;t++){let r=t*733%e,i=t*151%e;n.fillRect(r,i,2,2)}let i=new l(t);return i.colorSpace=I,i.wrapS=Te,i.wrapT=Te,i.repeat.set(23,17),i.anisotropy=Math.min(8,this.renderer.capabilities.getMaxAnisotropy()),i}makeSkyDome(){let e=document.createElement(`canvas`);e.width=1024,e.height=256;let t=e.getContext(`2d`),n=t.createLinearGradient(0,0,0,256);n.addColorStop(0,`#080d16`),n.addColorStop(.4,`#121b27`),n.addColorStop(.64,`#22303e`),n.addColorStop(.84,`#3b4b5b`),n.addColorStop(1,`#2a3644`),t.fillStyle=n,t.fillRect(0,0,e.width,e.height);let r=20260831,i=()=>(r=(r*1103515245+12345)%2147483648,r/2147483648);for(let n=0;n<220;n++){let n=i()*e.width,r=i()*i()*118,a=i()<.88?1:2,o=.12+i()*.5;t.fillStyle=i()<.24?`rgba(160,220,255,${o.toFixed(2)})`:`rgba(232,240,250,${o.toFixed(2)})`,t.beginPath(),t.arc(n,r,a,0,Math.PI*2),t.fill()}let a=new l(e);a.colorSpace=I;let o=new M(5600,24,16),s=new z({map:a,side:1,fog:!1,depthWrite:!1}),c=new h(o,s);return c.position.set(R,0,B),c.renderOrder=-10,c}applyGroundTexture(){try{let e=this.ground.material;e.map=this.makeIndustrialGroundTexture(),e.color.set(16777215),e.roughness=.94,e.metalness=.06,e.envMapIntensity=.28,e.needsUpdate=!0,this.dirty=!0}catch{}}on(e,t){return this.busHandlers.set(e,t),()=>this.busHandlers.delete(e)}emit(e,t){let n=this.busHandlers.get(e);n&&n(t)}buildBlocks(e){this.entityIndex.clear();for(let t of e){this.entityIndex.set(t.channelId,t);let e=this.layouts.get(t.channelId);e&&this.placeChannel(t,e)}this.emit(`blockCount`,this.blocks.size),this.emit(`agentCount`,this.agents.size)}placeChannel(e,t){let n=L(t),r=ge(e.channelId),i=this.makeBlock(e.channelName,r,n),a=new vt({channelId:e.channelId,name:e.channelName,x:n.x,z:n.z,radiusX:n.radiusX,radiusZ:n.radiusZ,shape:n.shape,rotationY:n.rotationY,color:r,platform:i.platform,padRing:i.padRing,beacon:i.beacon,boundary:$(n.shape,n.radiusX,n.radiusZ,r),label:this.makeLabel(e.channelName,n.x,30,n.z)});a.host=this,a.boundary.position.set(n.x,.3,n.z),a.boundary.rotation.y=n.rotationY*Math.PI/180,this.scene.add(a.boundary),this.blocks.set(e.channelId,a),this.layoutAgentsInBlock(e,a);for(let t of this.agents.values())t.channelId===e.channelId&&!a.members.includes(t)&&a.members.push(t)}layoutAgentsInBlock(e,t){let{x:n,z:r,radiusX:i,radiusZ:a}=t,o=.6,s=Math.max(1,e.agents.length);e.agents.forEach((c,l)=>{let u,d;if(typeof c.homeX==`number`&&typeof c.homeZ==`number`)u=c.homeX,d=c.homeZ;else{let e=s<=1?0:l/(s-1)*2-1;u=n+e*i*o*.8,d=r+(c.role===`lead`?0:(l%2==0?-1:1)*a*o*.4)}this.ensureAgent({...c,channelId:e.channelId},u,d,t.color)})}makeBlock(e,t,n){let r=n.rotationY*Math.PI/180,i=new h(this.makePadShapeGeometry(n.shape,n.radiusX,n.radiusZ),new E({color:t,transparent:!0,opacity:.24,roughness:.85,metalness:.12,emissive:t,emissiveIntensity:.12,side:2}));i.rotation.set(0,r,0),i.position.set(n.x,.16,n.z),i.receiveShadow=!1,this.scene.add(i);let a=new h(this.makePadRingGeometry(n.shape,n.radiusX,n.radiusZ),new z({color:t,transparent:!0,opacity:.52,side:2,depthWrite:!1}));a.rotation.set(0,r,0),a.position.set(n.x,.34,n.z),this.scene.add(a);let o=this.makeBeacon(t);return o.position.set(n.x,0,n.z),this.scene.add(o),{platform:i,padRing:a,beacon:o}}makeBeacon(e){let t=new g,n=new E({color:2766146,roughness:.45,metalness:.65}),r=new h(new _(7,9,5,12),n);r.position.y=2.5;let i=new h(new _(1.6,1.6,30,8),n);i.position.y=18;let a=new h(new ie(6.5),new z({color:e}));return a.material.color.multiplyScalar(4.5),a.position.y=37,t.add(r,i,a),t}pickBeacon(e,t){for(let n of this.blocks.values())if(Math.hypot(n.x-e,n.z-t)<34)return{cid:n.channelId,x:n.x,z:n.z};return null}makePadShapeGeometry(e,t,n){let r=new Se;e===`rect`?(r.moveTo(-t,-n),r.lineTo(t,-n),r.lineTo(t,n),r.lineTo(-t,n),r.closePath()):r.absellipse(0,0,t,n,0,Math.PI*2);let i=new _e(r,e===`rect`?1:56);return i.rotateX(Math.PI/2),i}makePadRingGeometry(e,t,n,i=13){let a=Math.max(4,t-i),o=Math.max(4,n-i),s=new Se,c=new r;e===`rect`?(s.moveTo(-t,-n),s.lineTo(t,-n),s.lineTo(t,n),s.lineTo(-t,n),s.closePath(),c.moveTo(-a,-o),c.lineTo(a,-o),c.lineTo(a,o),c.lineTo(-a,o),c.closePath()):(s.absellipse(0,0,t,n,0,Math.PI*2),c.absellipse(0,0,a,o,0,Math.PI*2)),s.holes.push(c);let l=new _e(s,e===`rect`?1:56);return l.rotateX(Math.PI/2),l}applyPadToBlock(e){let t=e.rotationY*Math.PI/180;e.platform.rotation.set(0,t,0),e.padRing.rotation.set(0,t,0);let n=e.platform.geometry;e.platform.geometry=this.makePadShapeGeometry(e.shape,e.radiusX,e.radiusZ),n.dispose();let r=e.padRing.geometry;e.padRing.geometry=this.makePadRingGeometry(e.shape,e.radiusX,e.radiusZ),r.dispose()}makeLabel(e,t,n,r,i=`#41c8f4`){let a=document.createElement(`canvas`),o=a.getContext(`2d`),s=`600 21px "Geist Mono", Geist, "PingFang SC", monospace`;o.font=s;let c=Math.max(104,Math.ceil(o.measureText(e).width)+26+14);a.width=c,a.height=48,o.font=s,o.fillStyle=`rgba(10,14,20,0.8)`,o.fillRect(0,0,c,48),o.strokeStyle=`${i}66`,o.lineWidth=1,o.strokeRect(.5,.5,c-1,47),o.fillStyle=i,o.fillRect(0,0,3,48),o.fillStyle=`#dce7f0`,o.textAlign=`left`,o.textBaseline=`middle`,o.fillText(e,26,25);let u=new l(a);u.colorSpace=I;let d=new pe(new oe({map:u,transparent:!0,depthTest:!1}));return d.scale.set(c/6,8,1),d.position.set(t,n,r),this.scene.add(d),d}hexOf(e){return`#${e.toString(16).padStart(6,`0`)}`}ensureAgent(e,t,n,r){let i=e.agentId;if(this.agents.has(i))return;let a=this.blockLayout(e.channelId),o=e.homeX??t,s=e.homeZ??n;if(a){let e=A(a,o,s,20);o=e.x,s=e.z}let c=e.range??null,l=new g;l.position.set(o,0,s);let u=this.makeLabel(e.name,o,48,s,this.hexOf(r)),d=e.modelRef||`hero-anime-1`,f=new g;l.add(f),this.scene.add(l);let p=new yt({channelId:e.channelId,agentId:i,name:e.name,role:e.role,root:l,model:f,mixer:null,clips:[],colorNum:r,nameSprite:u,bubble:null,bubbleText:null,bubbleTimer:null,state:e.state,progress:e.currentTaskProgress??null,dragging:!1,homeX:o,homeZ:s,range:c,rangeLine:null,textureKey:d,modelRef:e.modelRef??``,behavior:{mode:`idle`,roamTarget:null,targetId:null,waitUntil:0,pauseUntil:0,engaged:!1}});p.host=this,p.attachAura(r,e.role),this.agents.set(i,p);let m=this.modelsById.get(d)??(d.startsWith(`hero-anime-`)?{id:d,file:`/assets/game/character/${d}.glb`,name:`二次元角色`}:this.modelsById.get(`hero-3d`)??{id:`hero-3d`,file:`/assets/game/character/hero-3d.glb`,name:`标准员工模型`});this.mountModel(p,m.file,m.name),p.renderRangeLine(),this.emit(`agentCount`,this.agents.size)}async mountModel(e,t,n){let r=this.gltfCache.get(t),i,a;if(r)i=r.scene.clone(!0),a=r.height;else try{let e=await this.loadGltf(t);i=e.scene;let n=new o().setFromObject(i);a=Math.max(.5,n.max.y-n.min.y),this.gltfCache.set(t,{file:t,scene:i,height:a}),this.agentAnimClips.set(t,e.animations)}catch{i=this.makeFallbackBot(),a=1.4}i.position.y=0,i.scale.setScalar(120/a),i.traverse(e=>{e.isMesh&&(e.castShadow=!0)}),this.enhancePbrMaterials(i,`character`),e.model.clear(),e.model.add(i),this.registerScalable(`agent`,e.agentId,e.model),e.mixer=null,e.activeAction=null;let s=this.agentAnimClips.get(t)??[],c=s[0];if(c){e.mixer=new ee(i),e.clips=s;let t=e.mixer.clipAction(c);t.play(),e.activeAction=t}this.dirty=!0}agentAnimClips=new Map;loadGltf(e){return new Promise((t,n)=>{this.gltfLoader.load(e,e=>t({scene:e.scene,animations:e.animations??[]}),void 0,n)})}makeFallbackBot(){let e=new g,t=new E({color:2766146,roughness:.42,metalness:.62}),n=new E({color:1317668,roughness:.6,metalness:.4}),r=new z({color:4311284}),i=new h(new c(.42,.62,8,16),t);i.position.y=.86;let a=new h(new M(.32,16,12),t);a.position.y=1.62;let o=new h(new H(.4,.1,.12),r);o.position.set(0,1.66,.27);let s=new h(new M(.14,12,8),r);s.position.set(0,1.1,.36);let l=new h(new _(.5,.62,.26,16),n);l.position.y=.16;let u=new h(new _(.03,.03,.5,6),n);u.position.set(0,2.04,0);let d=new h(new M(.08,10,8),r);return d.position.set(0,2.34,0),e.add(i,a,o,s,l,u,d),e}registerModelsFromList(e){if(this.disposed)return;let t=new Set;for(let n of e){let e=this.modelsById.get(n.id);(!e||e.file!==n.file||e.name!==n.name||e.kind!==n.kind||e.hFactor!==(n.hFactor??1))&&(this.modelsById.set(n.id,{...n,hFactor:n.hFactor??1}),t.add(n.id))}if(t.size>0){for(let e of this.agents.values()){if(!e.modelRef||!t.has(e.modelRef))continue;let n=this.modelsById.get(e.modelRef);n&&this.mountModel(e,n.file,n.name)}for(let e of this.deviceNodes.values())t.has(e.modelRef)&&this.swapDeviceModelSprite(e,e.modelRef)}for(let e of[...this.pendingDeviceTwins.values()])!(e.kind===`daq`||(e.modelRef??``).startsWith(`daq-`))&&!this.modelsById.get(e.modelRef)?.file||(this.pendingDeviceTwins.delete(e.id),this.recreateDeviceNode(e))}applySceneLayouts(e){this.layouts.clear();for(let t of e){let e=L(t);this.layouts.set(e.channelId,e)}}hasChannel(e){return this.blocks.has(e)}blockLayout(e){let t=this.blocks.get(e);return t?t.layout():null}placedChannels(){return[...this.blocks.keys()]}getChannelLayout(e){let t=this.blocks.get(e);return t?t.layout():null}get threeScene(){return this.scene}markDirty(){this.dirty=!0}trackLayout(e){this.layouts.set(e.channelId,e.normLayout())}renameDeviceSprite(e,t){e.name=t.trim(),this.scene.remove(e.label),e.label=this.makeLabel(`⚙ ${e.name}`,e.root.position.x,60,e.root.position.z),this.dirty=!0}swapDeviceModelSprite(e,t){let n=this.modelsById.get(t);n?.file&&(e.modelRef!==t||e.holder.userData.modelFile!==n.file)&&(e.modelRef=t,e.holder.clear(),e.holder.userData.modelFile=n.file,this.loadGltfToGroup(n.file,e.holder,192),this.dirty=!0)}hydrate(e,t,n){this.applySceneLayouts(t),this.rebuild(e),this.syncDevices(n),this.emit(`blockCount`,this.blocks.size),this.emit(`agentCount`,this.agents.size)}rebuild(e){this.resetAll(),this.buildBlocks(e),this.emit(`blockCount`,this.blocks.size),this.emit(`agentCount`,this.agents.size)}focusChannel(e){let t=this.blocks.get(e);t&&this.focusTo(t.x,t.z)}dropChannelOnWorld(e,t,n,r,i){let a=this.blocks.get(n);if(a)return this.focusTo(a.x,a.z),{x:Math.round(a.x),z:Math.round(a.z),channelId:n,name:a.name};let o={channelId:n,x:e,z:t,radiusX:Math.max(120,110+i*18),radiusZ:Math.max(80,70+i*14),shape:`ellipse`,rotationY:0};this.layouts.set(n,L(o));let s=this.entityIndex.get(n);if(s)this.placeChannel(s,o);else{let i=ge(n),a=this.makeBlock(r,i,o),s=new vt({channelId:n,name:r,x:e,z:t,radiusX:o.radiusX,radiusZ:o.radiusZ,shape:o.shape,rotationY:o.rotationY,color:i,platform:a.platform,padRing:a.padRing,beacon:a.beacon,boundary:$(o.shape,o.radiusX,o.radiusZ,i),label:this.makeLabel(r,e,30,t)});s.host=this,s.boundary.position.set(e,.3,t),this.scene.add(s.boundary),this.blocks.set(n,s)}return this.emit(`blockCount`,this.blocks.size),this.emit(`agentCount`,this.agents.size),{x:Math.round(e),z:Math.round(t),channelId:n,name:r}}updateChannelLayout(e,t){let n=this.blocks.get(e);if(!n)return;t.x!==void 0&&(n.x=t.x),t.z!==void 0&&(n.z=t.z),t.radiusX!==void 0&&(n.radiusX=Math.max(60,t.radiusX)),t.radiusZ!==void 0&&(n.radiusZ=Math.max(40,t.radiusZ)),t.shape!==void 0&&(n.shape=t.shape),t.rotationY!==void 0&&(n.rotationY=t.rotationY);let r=L({channelId:e,x:n.x,z:n.z,radiusX:n.radiusX,radiusZ:n.radiusZ,shape:n.shape,rotationY:n.rotationY});this.layouts.set(e,r),this.scene.remove(n.boundary),this.applyPadToBlock(n),n.boundary=$(r.shape,r.radiusX,r.radiusZ,n.color),n.boundary.position.set(r.x,.3,r.z),n.boundary.rotation.y=r.rotationY*Math.PI/180,this.scene.add(n.boundary),this.clampAgentsToBoundary(e),this.dirty=!0}removeChannel(e){let t=this.blocks.get(e);if(t){this.scene.remove(t.platform),this.scene.remove(t.padRing),this.scene.remove(t.beacon),t.boundary&&this.scene.remove(t.boundary),this.scene.remove(t.label);for(let[t,n]of[...this.agents.entries()])n.channelId===e&&(this.scene.remove(n.root),n.nameSprite&&this.scene.remove(n.nameSprite),n.bubble&&this.scene.remove(n.bubble),n.rangeLine&&this.scene.remove(n.rangeLine),this.disposeAgentAssets(n),this.agents.delete(t));t.label&&this.disposeCanvasTextures(t.label),this.rangeDrawAgent&&this.agents.get(this.rangeDrawAgent)===void 0&&this.cancelRangeDraw(),this.blocks.delete(e),this.layouts.delete(e),this.receivers.delete(e);for(let e of this.resizeHandles)e.mesh.visible=!1;for(let e of this.agentRangeHandles)e.mesh.visible=!1;this.selectedChannel===e&&(this.selectedChannel=null,this.emit(`selectChannel`,null)),this.emit(`blockCount`,this.blocks.size),this.emit(`agentCount`,this.agents.size),this.dirty=!0}}applyBlockMove(e,t,n){e.moveBy(t-e.x,n-e.z),this.refreshAgentRangeHandles(),this.dirty=!0}applyLayoutToBlock(e){let t={channelId:e.channelId,x:e.x,z:e.z,radiusX:e.radiusX,radiusZ:e.radiusZ,shape:e.shape,rotationY:e.rotationY};this.layouts.set(e.channelId,L(t)),e.platform.position.set(e.x,.16,e.z),e.padRing.position.set(e.x,.34,e.z),this.applyPadToBlock(e),e.boundary&&this.scene.remove(e.boundary),e.boundary=$(e.shape,e.radiusX,e.radiusZ,e.color),e.boundary.position.set(e.x,.3,e.z),e.boundary.rotation.y=e.rotationY*Math.PI/180,this.scene.add(e.boundary),this.dirty=!0}boundaryHandlePoints(e){return e.shape===`rect`?[[e.radiusX,e.radiusZ],[-e.radiusX,e.radiusZ],[-e.radiusX,-e.radiusZ],[e.radiusX,-e.radiusZ]]:[[e.radiusX,0],[-e.radiusX,0],[0,e.radiusZ],[0,-e.radiusZ]]}refreshChannelHandles(){for(let e of this.resizeHandles)e.mesh.visible=!1;if(this.mode!==`edit`||!this.selectedChannel)return;let e=this.blocks.get(this.selectedChannel);if(!e)return;let t=e.rotationY*Math.PI/180,n=this.boundaryHandlePoints(e);for(let r=0;r<this.resizeHandles.length&&r<n.length;r++){let[i,a]=n[r],o=e.x+i*Math.cos(t)-a*Math.sin(t),s=e.z+i*Math.sin(t)+a*Math.cos(t);this.resizeHandles[r].cid=e.channelId,this.resizeHandles[r].mesh.position.set(o,1.4,s),this.resizeHandles[r].mesh.visible=!0}}pickResizeHandle(e,t){if(this.mode!==`edit`)return null;for(let n of this.resizeHandles)if(n.mesh.visible&&Math.hypot(n.mesh.position.x-e,n.mesh.position.z-t)<90)return{cid:n.cid,handle:n.handle};return null}applyResize(e,t,n,r){let i=-e.rotationY*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=n-e.x,c=r-e.z,l=s*a-c*o,u=s*o+c*a;e.shape===`rect`?(e.radiusX=Math.max(60,Math.abs(l)),e.radiusZ=Math.max(40,Math.abs(u))):t===0||t===1?e.radiusX=Math.max(60,Math.abs(l)):e.radiusZ=Math.max(40,Math.abs(u)),this.applyLayoutToBlock(e),this.refreshChannelHandles(),this.autoFrameTo(e.radiusX,e.radiusZ),this.dirty=!0}clampAgentsToBoundary(e){let t=this.blocks.get(e);t&&(t.clampMembersAndRanges(),this.dirty=!0)}getSelectedChannel(){return this.selectedChannel}selectChannel(e){this.selectedChannel=e,this.emit(`selectChannel`,e),this.refreshChannelHandles(),this.cancelRangeDraw(),this.refreshAgentRangeHandles();for(let t of this.blocks.values()){let n=t.boundary.material;n.color.setHex(t.channelId===e?16172115:t.color),n.opacity=t.channelId===e?1:.75}e&&!this.pointerDrag&&this.focusTo(this.blocks.get(e)?.x??1600,this.blocks.get(e)?.z??1200)}getAllChannelLayouts(){return[...this.blocks.values()].map(e=>({channelId:e.channelId,x:e.x,z:e.z,radiusX:e.radiusX,radiusZ:e.radiusZ,shape:e.shape,rotationY:e.rotationY}))}handleTownEvent(t){if(t.type===`channel.snapshot`)return;if(t.type===`scene.layout.saved`){let e=t.payload;this.blocks.has(e.channelId)&&(this.applySceneLayouts([...this.layouts.values(),e]),this.getChannelLayout(e.channelId)&&this.updateChannelLayout(e.channelId,e));return}if(t.type===`scene.layout.removed`){let{channelId:e}=t.payload;this.removeChannel(e);return}let r=e(t);if(!r)return;if(r.agentId){let e=this.agents.get(r.agentId);e&&(t.type===`agent.status`&&(e.state=t.payload.state,e.state!==`busy`&&(e.progress=null)),t.type===`task.progress`&&(e.progress=t.payload.progress),this.dirty=!0)}r.bubble&&this.enqueueBubble(r.bubble.channelId,r.bubble.agentId,r.bubble.kind,r.bubble.text,r.bubble.ttlMs),this.emitResonance(t);let i=n(t,{resolveTaskAssignee:this.resolveTaskAssignee??void 0});i&&this.startBehavior(i)}startBehavior(e){let t=this.agents.get(e.fromId),n=this.agents.get(e.toId);!t||!n||t.dragging||(t.behavior.mode=`approach`,t.behavior.targetId=n.agentId,t.behavior.action=e,n.dragging||(n.behavior.engaged=!0,n.behavior.roamTarget=null),this.emit(`behavior`,{agentName:t.name,action:this.behaviorActionLabel(e.kind),targetName:n.name}))}behaviorActionLabel(e){return e===`task`?`下发任务`:`回复`}notifyMotion(e){this.emit(`motion`,{agentName:e.name,anim:e.animState,at:Date.now()})}deliverBehavior(e,t){let n=e.behavior.action?.text??``;n&&this.enqueueBubble(e.channelId,e.agentId,`info`,n,2600),this.emit(`behavior`,{agentName:e.name,action:this.behaviorActionLabel(e.behavior.action?.kind??`message`),targetName:t.name})}releaseEngaged(e){let t=e.behavior.targetId?this.agents.get(e.behavior.targetId):void 0;t&&(t.behavior.engaged=!1)}getAgent(e){return this.agents.get(e)}blockLayoutOf(e){return this.blockLayout(e)}resolveFile(e){return this.modelsById.get(e)?.file??``}getCameraTarget(){return{x:Math.round(this.camTarget.x),z:Math.round(this.camTarget.z)}}swapAgentModel(e,t){let n=this.agents.get(e);if(!n)return;let r=this.modelsById.get(t),i=r?.file??`/assets/game/character/hero-3d.glb`;n.modelRef=t,n.textureKey=t,this.mountModel(n,i,r?.name??t)}emitResonance(e){let t=this.blocks.get(e.channelId),n=e.agentId?this.agents.get(e.agentId):void 0,r=n?.root.position.x??t?.x,i=n?.root.position.z??t?.z;r!==void 0&&i!==void 0&&(e.type===`agent.message`||e.type===`agent.status.message`||e.type===`a2a.message`?this.pulseRing(r,i,n?4311284:t?.color??4311284):e.type===`error`||e.type===`task.status`&&(e.payload.state===`failed`||e.payload.state===`canceled`)?this.pulseRing(r,i,16739179):e.type===`task.status`&&e.payload.state===`completed`&&this.lightColumn(r,i,3530912))}pulseRing(e,t,n){let r=new h(new k(10,22,24),new z({color:n,transparent:!0,opacity:.8,side:2,depthWrite:!1}));r.rotation.x=-Math.PI/2,r.position.set(e,.4,t),this.scene.add(r);let i=performance.now(),a=()=>{let e=Math.min(1,(performance.now()-i)/800),t=1-(1-e)**3;if(r.scale.setScalar(1+t*1.6),r.material.opacity=.8*(1-t),e>=1){this.scene.remove(r),r.geometry.dispose(),r.material.dispose();return}this.rafAnims.push(a)};this.rafAnims.push(a)}lightColumn(e,t,n){let r=new _(6,12,120,16);r.translate(0,60,0);let i=new h(r,new z({color:n,transparent:!0,opacity:.8,depthWrite:!1}));i.position.set(e,0,t),i.scale.y=.01,this.scene.add(i);let a=performance.now(),o=()=>{let e=Math.min(1,(performance.now()-a)/900),t=1-(1-e)**2;if(i.scale.y=.01+t*.99,i.material.opacity=.8*(1-e),e>=1){this.scene.remove(i),i.geometry.dispose(),i.material.dispose();return}this.rafAnims.push(o)};this.rafAnims.push(o)}rafAnims=[];layouts=new Map;entityIndex=new Map;selectedChannel=null;enqueueBubble(e,t,n,r,i){this.dbgBubbles.push({text:r,at:Date.now()}),this.dbgBubbles.length>30&&this.dbgBubbles.splice(0,this.dbgBubbles.length-30);let a=t?this.agents.get(t)?.name:void 0;this.lastActivity={channelId:e,agentName:a??this.blocks.get(e)?.name??`系统`,text:r,at:Date.now()},this.recentActivity.push(this.lastActivity),this.recentActivity.length>30&&this.recentActivity.splice(0,this.recentActivity.length-30),this.emit(`lastActivity`,this.lastActivity);let o=this.receivers.get(e);o||(o={channelId:e,queue:[],current:null,currentUntil:0},this.receivers.set(e,o)),o.queue.length>=24&&o.queue.splice(0,o.queue.length-24),o.queue.push({agentId:t??null,kind:n,text:r,ttlMs:i}),this.dirty=!0}drainReceivers(e){for(let t of this.receivers.values()){if(t.current){if(e<t.currentUntil)continue;this.clearReceiverBubble(t.channelId,t.current),t.current=null}let n=t.queue.shift();n&&(t.current=n,t.currentUntil=e+xe(n.text,t.queue.length),this.renderReceiverBubble(t.channelId,n))}}clearReceiverBubble(e,t){if(!t.agentId)return;let n=this.agents.get(t.agentId);n?.bubble&&(this.scene.remove(n.bubble),n.bubble=null,n.bubbleText=null,n.bubbleTimer&&=(clearTimeout(n.bubbleTimer),null))}renderReceiverBubble(e,t){let n=t.agentId?this.agents.get(t.agentId):void 0,r=this.blocks.get(e);if(!n&&!r)return;let i=n?.name??r?.name??`系统`,a=n?n.colorNum:r?.color??4311284,o=(t.kind===`artifact`&&!t.text.startsWith(`📦`)?`📦 ${t.text}`:t.text)||`…`,s=this.makeChatBubble(o,i,a,t.kind),c=n?.root.position.x??r.x,l=n?.root.position.z??r.z;if(s.position.set(c,n?108+Math.max(0,n.model.scale.y-1)*22:64,l),this.scene.add(s),!n){window.setTimeout(()=>{this.scene.remove(s)},we(t.text)+500);return}n.bubble&&(this.scene.remove(n.bubble),this.disposeCanvasTextures(n.bubble),n.bubbleText=null),n.bubble=s,n.bubbleText=o,this.popInSprite(s),this.dirty=!0}makeChatBubble(e,t,n,r){let i=`#${n.toString(16).padStart(6,`0`)}`,a=document.createElement(`canvas`),o=a.getContext(`2d`),s=`18px Geist, "PingFang SC", sans-serif`;o.font=s;let c=this.wrapBubbleLines(o,e.replace(/\s+/g,` `).trim()||`…`,470,6),u=Math.max(...c.map(e=>o.measureText(e).width)),d=Math.min(680,Math.max(140,Math.ceil(u)+36)),f=26+c.length*24+24,p=f+13;a.width=d,a.height=p,o.clearRect(0,0,d,p);let m=d/2,h=Math.min(24,d*.32),g=()=>{o.beginPath(),o.moveTo(4,0),o.lineTo(d-4,0),o.quadraticCurveTo(d,0,d,4),o.lineTo(d,f-4),o.quadraticCurveTo(d,f,d-4,f),o.lineTo(m+h/2,f),o.lineTo(m,f+13),o.lineTo(m-h/2,f),o.lineTo(4,f),o.quadraticCurveTo(0,f,0,f-4),o.lineTo(0,4),o.quadraticCurveTo(0,0,4,0),o.closePath()};o.save(),o.shadowColor=`rgba(0,0,0,0.55)`,o.shadowBlur=14,o.shadowOffsetY=4,g(),o.fillStyle=`rgba(14,18,27,0.94)`,o.fill(),o.restore(),o.save(),g(),o.clip(),o.fillStyle=`rgba(255,255,255,0.045)`,o.fillRect(0,0,d,38),o.restore(),o.globalAlpha=.28,o.fillStyle=`#fff`,o.fillRect(18,30,d-36,1),o.globalAlpha=1,g(),o.lineWidth=1.2,o.strokeStyle=`rgba(140,170,195,0.4)`,o.stroke(),o.save(),g(),o.clip(),o.fillStyle=i,o.fillRect(0,0,3,f),o.restore(),o.font=`600 13px "Geist Mono", Geist, "PingFang SC", monospace`,o.fillStyle=i,o.textBaseline=`middle`,o.textAlign=`left`,o.fillText(t,18,22);let _=r===`artifact`?`ARTIFACT`:r===`error`?`FAULT`:``;if(_){let e=o.measureText(_).width+12;o.font=`600 10px "Geist Mono", Geist, monospace`,o.fillStyle=r===`error`?`#ff8d80`:`#9fc3e8`,o.strokeStyle=r===`error`?`rgba(255,141,128,0.55)`:`rgba(159,195,232,0.45)`,o.lineWidth=1;let t=d-18-e;o.beginPath(),o.rect(t,14,e,16),o.fill(),o.stroke(),o.textAlign=`center`,o.fillText(_,t+e/2,22.5)}o.font=s,o.fillStyle=r===`error`?`#ff9d9d`:`#eef2fb`,o.textAlign=`left`,c.forEach((e,t)=>o.fillText(e,18,48+t*24));let v=new l(a);v.colorSpace=I;let y=new pe(new oe({map:v,transparent:!0,depthTest:!1,depthWrite:!1})),b=2.4;return y.scale.set(d/b,p/b,1),y}popInSprite(e){let t=e.scale.x,n=e.scale.y;e.scale.set(t*.62,n*.62,1);let r=performance.now(),i=()=>{if(this.disposed)return;let a=Math.min(1,(performance.now()-r)/180),o=.62+.38*(1-(1-a)**3);e.scale.set(t*o,n*o,1),a<1&&this.rafAnims.push(i)};this.rafAnims.push(i)}wrapBubbleLines(e,t,n,r){let i=[],a=``;for(let o of t)if(e.measureText(a+o).width>n&&a){if(i.push(a),a=o,i.length>=r)return i[r-1]=`${i[r-1]??``}…`,i}else a+=o;return a&&i.push(a),i.length===0&&i.push(`…`),i}get canvas(){return this.renderer.domElement}worldToScreen(e,n,r){let i=this.renderer.domElement.getBoundingClientRect(),a=t._wDir;if(this.camera.getWorldDirection(a),t._wRel.set(e-this.camera.position.x,n-this.camera.position.y,r-this.camera.position.z).dot(a)<=.1)return null;let o=t._wVec.set(e,n,r).project(this.camera);return o.z>1||Math.abs(o.x)>1.6||Math.abs(o.y)>1.6?null:{x:i.left+(o.x+1)/2*i.width,y:i.top+(1-o.y)/2*i.height}}screenToWorld(e,n){let r=this.renderer.domElement.getBoundingClientRect(),i=(e-r.left)/r.width*2-1,a=-((n-r.top)/r.height)*2+1,o=t._raycaster;o.setFromCamera(t._wVec2.set(i,a),this.camera);let s=t._wVec;return o.ray.intersectPlane(t._groundPlane,s),s?{x:s.x,z:s.z}:{x:this.camera.position.x,z:this.camera.position.z}}panBy(e,t){this.camTarget.x-=e,this.camTarget.z-=t}autoDolly=null;fitDollyFor(e,t){let n=this.camera.aspect||1.6;return Math.max(e/(.82*613*n),t/779)}autoFrameTo(e,t){let n=this.fitDollyFor(e,t);n>this.dolly&&(this.autoDolly=Math.min(40,n*1.18))}setTransformMode(e){this.tControls&&(this.tControls.setMode(e),this.tControls.showX=e!==`rotate`,this.tControls.showY=e!==`translate`,this.tControls.showZ=e!==`rotate`)}isGizmoBusy(){return!!this.tControls&&(this.tControls.dragging||!!this.tControls.axis)}setViewPreset(e){let t={std:{yaw:0,pitch:.7,radius:1178},top:{yaw:0,pitch:1.51,radius:2400},front:{yaw:0,pitch:.09,radius:1510},side:{yaw:Math.PI/2,pitch:.33,radius:1320}},n=t[e]??t.std;this.viewTarget={...n}}orbitBy(e,t){let n=this.viewCur.yaw-e*.0052,r=Math.min(1.52,Math.max(.06,this.viewCur.pitch+t*.0052));this.viewCur={yaw:n,pitch:r,radius:this.viewCur.radius},this.viewTarget={...this.viewCur},this.dirty=!0}setAutoOrbit(e){this.autoOrbit=e}getAutoOrbit(){return this.autoOrbit}panByScreen(e,t){let n=this.viewCur.radius*this.dolly*.0011,r=Math.sin(this.viewCur.yaw),i=Math.cos(this.viewCur.yaw),a=Math.sin(this.viewCur.pitch),o=(i*e+a*r*t)*n,s=(-r*e+a*i*t)*n;this.panBy(o,s)}flyToPreset(e,t=900){this.setViewPreset(e)}getCameraPose(){return{pos:{x:this.camera.position.x,y:this.camera.position.y,z:this.camera.position.z},target:{x:this.camTarget.x,z:this.camTarget.z},yaw:this.viewCur.yaw,dolly:this.dolly}}panWorldBy(e,t){this.camTarget.x-=e,this.camTarget.z-=t,this.camera.position.x-=e,this.camera.position.z-=t,this.dirty=!0}setExposure(e){this.renderer.toneMappingExposure=Math.min(2.2,Math.max(.2,e))}setTerritoryOpacity(e){let t=Math.min(1,Math.max(.05,e));for(let e of this.blocks.values())e.platform.material.opacity=.24*t;this.dirty=!0}resetView(){this.dolly=1,this.autoDolly=null,this.tweenCamTo(R,B),this.setViewPreset(`std`)}zoomBy(e){this.autoDolly=null,this.dolly=Math.min(1e3,Math.max(.001,this.dolly+e))}focusTo(e,t){this.tweenCamTo(e,t)}tweenCamTo(e,t){let n=performance.now(),r=this.camTarget.x,i=this.camTarget.z,a=()=>{let o=Math.min(1,(performance.now()-n)/600),s=1-(1-o)**3;this.camTarget.x=r+(e-r)*s,this.camTarget.z=i+(t-i)*s,o<1&&this.rafAnims.push(a)};this.rafAnims.push(a)}dropModelOnWorld(e,t,n){let r=this.nearestAgent(e,t,80),i=this.modelsById.get(n),a=i?.id??n;if(i?.kind===`dev`)return{mode:`spawn`,agentId:this.spawnDeviceNode(e,t,a,i.file,i.name),textureKey:a,x:Math.round(e),y:Math.round(t)};if(r)return this.swapTexture(r,a),this.enqueueBubble(r.channelId,r.agentId,`info`,`换装 → ${i?.name??n}`,2200),{mode:`rebind`,agentId:r.agentId,textureKey:a,x:Math.round(r.root.position.x),y:Math.round(r.root.position.z)};let o=i??{id:n,file:``,name:n};return this.spawnResident(e,t,a,o.name),{mode:`spawn`,textureKey:a,x:Math.round(e),y:Math.round(t)}}nearestAgent(e,t,n){let r,i=n;for(let n of this.agents.values()){let a=Math.hypot(n.root.position.x-e,n.root.position.z-t);a<i&&(r=n,i=a)}return r}swapTexture(e,t){let n=this.modelsById.get(t),r=n?.file??this.resolveFile(t)??`/assets/game/character/hero-3d.glb`;e.modelRef=t,e.textureKey=t,this.mountModel(e,r,n?.name??t)}spawnResident(e,t,n,r){let i=new g;i.position.set(e,0,t);let a=new g;i.add(a);let o=this.makeLabel(r,e,48,t,this.hexOf(16771524));this.scene.add(i);let s=new yt({channelId:``,agentId:`resident-${Date.now().toString(36)}`,name:r,role:`worker`,root:i,model:a,mixer:null,clips:[],colorNum:16771524,nameSprite:o,bubble:null,bubbleText:null,bubbleTimer:null,state:`idle`,progress:null,dragging:!1,homeX:e,homeZ:t,range:null,rangeLine:null,textureKey:n,modelRef:n,behavior:{mode:`idle`,roamTarget:null,targetId:null,waitUntil:0,pauseUntil:0,engaged:!1}});s.host=this,s.attachAura(16771524,`worker`),this.agents.set(s.agentId,s);let c=this.modelsById.get(n);this.mountModel(s,c?.file??`/assets/game/character/hero-3d.glb`,c?.name??r)}makeDeviceRing(){let e=new h(new k(20,26,32),new z({color:16172115,transparent:!0,opacity:.8,side:2}));e.rotation.x=-Math.PI/2,e.position.y=.3;let t=new h(new k(20,26,32,1,0,Math.PI*1.5),new z({color:3530912,transparent:!0,opacity:.55,side:2,depthWrite:!1,blending:2}));return t.rotation.x=-Math.PI/2,t.position.y=.34,t.visible=!1,{ring:e,arc:t}}spawnDeviceNode(e,t,n,r,i){let a=`dev-${Date.now().toString(36)}`,o=new g;o.position.set(e,0,t);let{ring:s,arc:c}=this.makeDeviceRing();o.add(s,c);let l=new g;o.add(l),l.userData.modelFile=r;let u=this.makeLabel(`⚙ ${i}`,e,60,t);this.scene.add(o);let d=new bt({twinId:a,name:i,modelRef:n,root:o,holder:l,ring:s,label:u,state:`idle`,telemetry:{}});d.host=this,d.arc=c,d.updateRing(),this.deviceNodes.set(a,d),this.registerScalable(`device`,a,l),this.loadGltfToGroup(r,l,192);let f=this.scalables.get(`device:${a}`),p=this.devices?.create({name:i,modelRef:n,kind:`device`,controls:[`power_on`,`power_off`,`set_speed`],posX:Math.round(e*10)/10,posZ:Math.round(t*10)/10,scale:f?Math.round(f.userScale*100)/100:1});return p?(this.pendingDeviceCreates.set(a,{name:i,modelRef:n,posX:e,posZ:t}),p.then(e=>{let t=this.cancelledDeviceCreates.delete(a);if(this.pendingDeviceCreates.delete(a),t){this.devices?.remove?.(e.id).catch(()=>{});return}this.disposed||this.adoptDeviceNode(a,e.id)}).catch(()=>{this.cancelledDeviceCreates.delete(a),this.pendingDeviceCreates.delete(a)}),a):a}adoptDeviceNode(e,t){this.pendingDeviceCreates.delete(e);let n=this.deviceNodes.get(e);if(!n)return;let r=this.deviceNodes.get(t);if(r&&r!==n){this.removeDeviceNode(e),this.selected?.kind===`device`&&this.selected.id===e&&this.setSelected({kind:`device`,id:t});return}this.deviceNodes.delete(e),n.twinId=t,this.deviceNodes.set(t,n);let i=this.scalables.get(`device:${e}`);this.scalables.delete(`device:${e}`),i&&(i.id=t,this.scalables.set(`device:${t}`,i));let a=this.pendingSaveTimers.get(e);this.pendingSaveTimers.delete(e),a&&this.pendingSaveTimers.set(t,a),this.pointerDrag?.kind===`device`&&this.pointerDrag.id===e&&(this.pointerDrag.id=t),this.selected?.kind===`device`&&this.selected.id===e&&this.setSelected({kind:`device`,id:t}),this.persistDeviceTransform(t)}async loadGltfToGroup(e,t,n){try{let r=await this.loadGltf(e),i=new o().setFromObject(r.scene),a=n/Math.max(.5,i.max.y-i.min.y);r.scene.scale.setScalar(a),r.scene.position.y=0,r.scene.traverse(e=>{e.isMesh&&(e.castShadow=!0)}),this.enhancePbrMaterials(r.scene,`device`),t.add(r.scene)}catch{}}enhancePbrMaterials(e,t){e.traverse(e=>{let n=e;if(!n.isMesh)return;n.receiveShadow=!0;let r=e=>{let n=e,r;if(n?.isMeshBasicMaterial){if(t===`device`&&/led|lamp|light/i.test(n.name??``)){let e=n.userData??={};return e.hdrBoost||=(n.color.multiplyScalar(4.5),!0),n}r=new E({map:n.map??null,color:n.color.clone().multiplyScalar(t===`character`?.38:.5),transparent:n.transparent,opacity:n.opacity,alphaTest:n.alphaTest,side:n.side,roughness:t===`character`?.92:.6,metalness:t===`character`?0:.25}),r.name=n.name??``,n.dispose()}else{let t=e;if(!t||!(`envMapIntensity`in t))return e;r=t}if(t===`character`)return r.envMapIntensity=.45,r.metalness>.3&&(r.metalness=0),r;if(r.transparent)return r.envMapIntensity=.42,r.emissive&&r.emissive.setScalar(Math.max(r.emissive.r,.06)),r;if(r.metalness>=.5)return r.envMapIntensity=.85,r;if(r.isMeshPhysicalMaterial){let e=r;return e.clearcoat=.35,e.clearcoatRoughness=.4,e.envMapIntensity=.7,e.needsUpdate=!0,e}let i=new m({color:r.color,map:r.map,normalMap:r.normalMap,roughnessMap:r.roughnessMap,aoMap:r.aoMap,emissive:r.emissive,emissiveMap:r.emissiveMap,emissiveIntensity:r.emissiveIntensity,roughness:Math.min(r.roughness,.55),metalness:r.metalness,clearcoat:.35,clearcoatRoughness:.4});return i.name=r.name,i.side=r.side,r.dispose(),i};n.material=Array.isArray(n.material)?n.material.map(r):r(n.material)}),this.dirty=!0}getDebugState(){return{blocks:this.blocks.size,agents:[...this.agents.values()].map(e=>({agentId:e.agentId,name:e.name,role:e.role,channelId:e.channelId,state:e.state,progress:e.progress,x:Math.round(e.root.position.x),y:Math.round(e.root.position.z),visible:!0,draggable:!0,auraColor:e.colorNum,behavior:e.behavior.mode,targetId:e.behavior.targetId,homeX:Math.round(e.homeX),homeY:Math.round(e.homeZ),textureKey:e.textureKey,modelRef:e.modelRef,decorated:!e.channelId,range:e.range?{x:Math.round(e.range.x),z:Math.round(e.range.z),radiusX:Math.round(e.range.radiusX),radiusZ:Math.round(e.range.radiusZ),shape:e.range.shape}:null,bubbleText:e.bubbleText,anim:e.animState})),bubbles:this.dbgBubbles.slice(-8),activity:this.lastActivity,player:{x:Math.round(this.camera.position.x),y:Math.round(this.camera.position.z)}}}getMinimapState(){let e=e=>e===`alarm`?16739179:e===`offline`?8689317:e===`running`?3530912:16172115;return{world:{w:D,h:N},blocks:[...this.blocks.values()].map(e=>({x:e.x/D,y:e.z/N,color:e.color,name:e.name,shape:e.shape,rx:e.radiusX/D,rz:e.radiusZ/N,rot:e.rotationY})),agents:[...this.agents.values()].map(e=>({x:e.root.position.x/D,y:e.root.position.z/N,color:e.colorNum,busy:e.state===`busy`})),devices:[...this.deviceNodes.values()].map(t=>({twinId:t.twinId,x:t.root.position.x/D,y:t.root.position.z/N,color:e(t.state),state:t.state,daq:t.modelRef.startsWith(`daq-`)||t.modelRef.includes(`daq`),bound:!1})),player:{x:this.camTarget.x/D,y:this.camTarget.z/N}}}getRecentActivity(){return[...this.recentActivity]}updateDeviceNode(e,t,n){let r=this.deviceNodes.get(e);r&&(t&&(r.state=t,r.updateRing()),n&&(r.telemetry={...r.telemetry,...n}),this.dirty=!0)}renameDevice(e,t){let n=this.deviceNodes.get(e);!n||!t.trim()||t.trim()===n.name||this.renameDeviceSprite(n,t)}swapDeviceModel(e,t){let n=this.deviceNodes.get(e);n&&this.swapDeviceModelSprite(n,t)}getDeviceName(e){return this.deviceNodes.get(e)?.name??``}getDeviceModelRef(e){return this.deviceNodes.get(e)?.modelRef??``}async removeDevice(e){if(this.deviceNodes.get(e)){if(this.pendingDeviceCreates.has(e)){this.cancelledDeviceCreates.add(e),this.removeDeviceNode(e);return}try{await this.devices?.remove?.(e)}catch{}this.removeDeviceNode(e)}}getDeviceNodes(){return[...this.deviceNodes.values()].map(e=>({twinId:e.twinId,name:e.name,x:Math.round(e.root.position.x),z:Math.round(e.root.position.z),topY:Math.round(this.deviceTopY(e)),state:e.state,telemetry:e.telemetry}))}setAnimPref(e,t){let n=this.agents.get(e);if(!n||n.clips.length===0||!n.mixer)return;let r=n.clips.findIndex(e=>e.name.toLowerCase().includes(t.toLowerCase()));r<0&&(r=t===`work`?n.clips.length-1:t===`walk`?Math.min(1,n.clips.length-1):0);let i=n.clips[r];i&&(n.mixer.stopAllAction(),n.mixer.clipAction(i).reset().play())}getAgentModel(e){return this.agents.get(e)?.modelRef??null}getAgentName(e){return this.agents.get(e)?.name??e.slice(0,8)}getAgentClips(e){let t=this.agents.get(e);return t?t.clips.map(e=>({name:e.name,duration:Math.round(e.duration*10)/10})):[]}pickAt(e,t){let n=null;for(let r of this.agents.values()){let i=Math.hypot(r.root.position.x-e,r.root.position.z-t);i<90&&(!n||i<n.d)&&(n={kind:`agent`,id:r.agentId,d:i})}for(let r of this.deviceNodes.values()){let i=Math.hypot(r.root.position.x-e,r.root.position.z-t);i<90&&(!n||i<n.d)&&(n={kind:`device`,id:r.twinId,d:i})}return n?{kind:n.kind,id:n.id}:null}pickChannel(e,t){for(let n of this.blocks.values()){let r={channelId:n.channelId,x:n.x,z:n.z,radiusX:n.radiusX,radiusZ:n.radiusZ,shape:n.shape,rotationY:n.rotationY};if(me(r,e,t))return n.channelId}return null}pickChannelEdge(e,t){for(let n of this.blocks.values()){let r=fe(n,e,t),i=Math.hypot(r.x/n.radiusX,r.z/n.radiusZ),a=42/Math.min(n.radiusX,n.radiusZ);if(Math.abs(i-1)<=a)return{cid:n.channelId,rx0:n.radiusX,rz0:n.radiusZ,rd0:i}}return null}setSelected(e){if((!e||e.kind!==`agent`||e.id!==this.rangeDrawAgent)&&this.cancelRangeDraw(),this.selected=e,this.tControls&&(e?.kind===`device`&&this.mode===`edit`&&this.deviceNodes.has(e.id)?this.tControls.attach(this.deviceNodes.get(e.id).root):this.tControls.detach()),this.refreshAgentRangeLines(),this.refreshAgentRangeHandles(),!e){this.emit(`select`,null);return}let t=this.scalables.get(`${e.kind}:${e.id}`);t&&this.emit(`select`,{kind:e.kind,id:e.id,scale:t.userScale,rotation:Math.round(this.getModelRotation(e.id,e.kind)*10)/10})}setModelScale(e,t,n){let r=n??(this.scalables.has(`device:${e}`)?`device`:`agent`),i=`${r}:${e}`,a=this.scalables.get(i);if(a){if(a.userScale=t,a.holder.scale.setScalar(a.userScale),r===`device`){let t=this.deviceNodes.get(e);t&&(t.topYCache=null)}this.dirty=!0}}getSelectedScale(){if(!this.selected)return null;let e=this.scalables.get(`${this.selected.kind}:${this.selected.id}`);return e?{kind:this.selected.kind,id:this.selected.id,scale:e.userScale,rotation:Math.round(this.getModelRotation(this.selected.id,this.selected.kind)*10)/10}:null}registerScalable(e,t,n,r){let i=r===void 0?typeof localStorage<`u`?Number(localStorage.getItem(`town.scale.${e}:${t}`)??1):1:r,a=Number.isFinite(i)&&i>0?i:1;if(this.scalables.set(`${e}:${t}`,{kind:e,id:t,userScale:a,holder:n}),n.scale.setScalar(a),e===`device`){let e=this.deviceNodes.get(t);e&&(e.topYCache=null)}}persistScale(e,t){let n=this.scalables.get(`${e}:${t}`);!n||typeof localStorage>`u`||(localStorage.setItem(`town.scale.${e}:${t}`,String(n.userScale)),e===`device`&&this.persistDeviceTransform(t))}setMode(e){if(this.mode!==e){this.mode=e,e===`browse`&&(this.pointerDrag&&this.endPointerDrag(),this.cancelRangeDraw(),this.setSelected(null),this.tControls?.detach()),this.refreshChannelHandles(),this.refreshAgentRangeHandles();for(let e of this.agents.values())e.renderRangeLine();this.dirty=!0}}getMode(){return this.mode}setSnap(e){this.snapEnabled=e}getSnap(){return this.snapEnabled}tryStartPointerDrag(e,t){if(this.mode!==`edit`||this.isGizmoBusy())return!1;let n=this.screenToWorld(e,t),r=this.pickAgentRangeHandle(n.x,n.z);if(r)return this.pointerDrag={kind:`agentRangeResize`,id:r.agentId,handle:r.handle},this.emitSaveState(`dirty`),!0;let i=this.pickResizeHandle(n.x,n.z);if(i)return this.pointerDrag={kind:`resize`,id:i.cid,handle:i.handle},this.setSelected(null),this.emitSaveState(`dirty`),!0;if(this.rangeDrawAgent)return this.pointerDrag={kind:`rangeDraw`,id:this.rangeDrawAgent,x0:n.x,z0:n.z},this.rangeDrawPreviewState=null,!0;let a=this.pickAt(n.x,n.z);if(a){if(a.kind===`device`)return this.deviceNodes.has(a.id)?(this.pointerDrag=a,this.setSelected(a),this.emitSaveState(`dirty`),!0):!1;let e=this.agents.get(a.id);return!e||!e.channelId?!1:(e.bubbleTimer&&=(clearTimeout(e.bubbleTimer),null),e.dragging=!0,e.behavior.mode=`idle`,e.behavior.targetId=null,this.pointerDrag=a,this.setSelected(a),this.emitSaveState(`dirty`),!0)}let o=this.hitAgentRangeBoundary(n.x,n.z);if(o&&o.range)return this.pointerDrag={kind:`agentRange`,id:o.agentId,dx:o.range.x-n.x,dz:o.range.z-n.z},this.setSelected({kind:`agent`,id:o.agentId}),this.emitSaveState(`dirty`),!0;let s=this.pickChannelEdge(n.x,n.z);if(s)return this.pointerDrag={kind:`channelEdge`,id:s.cid,rx0:s.rx0,rz0:s.rz0,rd0:s.rd0},this.setSelected(null),this.selectChannel(s.cid),this.emitSaveState(`dirty`),!0;if(this.pickBeacon(n.x,n.z))return!1;let c=this.pickChannel(n.x,n.z);if(c){let e=this.blocks.get(c);return e?(this.pointerDrag={kind:`channel`,id:c,dx:e.x-n.x,dz:e.z-n.z},this.setSelected(null),this.selectChannel(c),this.emitSaveState(`dirty`),!0):!1}return!1}isPointerDragging(){return this.pointerDrag!==null}snapWorld(e){return this.snapEnabled?Math.round(e/16)*16:Math.round(e*10)/10}movePointerDrag(e,t){if(!this.pointerDrag)return;let n=this.screenToWorld(e,t),r=this.snapWorld(n.x),i=this.snapWorld(n.z),a=this.pointerDrag;if(a.kind===`device`){let e=this.deviceNodes.get(a.id);e&&(e.root.position.x=r,e.root.position.z=i,this.dirty=!0)}else if(a.kind===`agent`){let e=this.agents.get(a.id);if(e){let t=r,n=i,a=this.blockLayout(e.channelId);if(a){let e=A(a,r,i,20);t=e.x,n=e.z}e.root.position.x=t,e.root.position.z=n,this.dirty=!0}}else if(a.kind===`rangeDraw`){let e=this.agents.get(a.id);if(!e)return;let t=this.blockLayout(e.channelId),r=n.x,i=n.z;if(t){let e=A(t,r,i,12);r=e.x,i=e.z}this.rangeDrawPreviewState={x0:a.x0,z0:a.z0,x1:r,z1:i},this.updateRangeDrawPreview(a.x0,a.z0,r,i),this.dirty=!0}else if(a.kind===`agentRange`){let e=this.agents.get(a.id);if(!e||!e.range)return;let t=r+a.dx,n=i+a.dz;e.range={...e.range,x:t,z:n},e.renderRangeLine(),this.refreshAgentRangeHandles(),this.dirty=!0}else if(a.kind===`agentRangeResize`){let e=this.agents.get(a.id);if(!e||!e.range)return;e.range=this.applyAgentRangeResize(e.range,a.handle,n.x,n.z),e.renderRangeLine(),this.refreshAgentRangeHandles(),this.autoFrameTo(e.range.radiusX,e.range.radiusZ),this.dirty=!0}else if(a.kind===`channel`){let e=this.blocks.get(a.id);e&&this.applyBlockMove(e,r+a.dx,i+a.dz)}else if(a.kind===`resize`){let e=this.blocks.get(a.id);e&&this.applyResize(e,a.handle,n.x,n.z)}else if(a.kind===`channelEdge`){let e=this.blocks.get(a.id);if(e){let t=fe(e,r,i),n=Math.hypot(t.x/a.rx0,t.z/a.rz0),o=a.rd0>.05?n/a.rd0:1;e.radiusX=Math.max(60,Math.round(a.rx0*o)),e.radiusZ=Math.max(40,Math.round(a.rz0*o)),this.applyLayoutToBlock(e),this.autoFrameTo(e.radiusX,e.radiusZ)}}}endPointerDrag(){if(!this.pointerDrag)return;let e=this.pointerDrag;if(this.pointerDrag=null,e.kind===`device`)this.deviceNodes.get(e.id)&&this.persistDeviceTransform(e.id);else if(e.kind===`agent`){let t=this.agents.get(e.id);t&&(t.homeX=t.root.position.x,t.homeZ=t.root.position.z,t.dragging=!1,this.emitSaveState(`saving`),this.agentApi?.updateHome(e.id,t.channelId,t.homeX,t.homeZ).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`)))}else if(e.kind===`rangeDraw`){let t=this.agents.get(e.id);if(t&&this.rangeDrawPreviewState){let n=this.rangeDrawPreviewState,r={x:(n.x0+n.x1)/2,z:(n.z0+n.z1)/2,radiusX:Math.abs(n.x1-n.x0)/2,radiusZ:Math.abs(n.z1-n.z0)/2,shape:`rect`,rotationY:0};if(r.radiusX>=40&&r.radiusZ>=40){t.range=r,t.renderRangeLine();let n=V(t.range,t.homeX,t.homeZ,0);(n.x!==t.homeX||n.z!==t.homeZ)&&(t.homeX=n.x,t.homeZ=n.z,t.root.position.x=n.x,t.root.position.z=n.z,this.agentApi?.updateHome(e.id,t.channelId,n.x,n.z).catch(()=>{})),this.emitSaveState(`saving`),this.agentApi?.updateRange(e.id,t.channelId,t.range).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`))}}this.cancelRangeDraw(),this.refreshAgentRangeHandles(),this.emitAgentRangeChanged(e.id)}else if(e.kind===`agentRange`||e.kind===`agentRangeResize`){let t=this.agents.get(e.id);t&&t.range&&(this.emitSaveState(`saving`),this.agentApi?.updateRange(e.id,t.channelId,t.range).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`))),this.refreshAgentRangeHandles(),this.emitAgentRangeChanged(e.id)}else if(this.blocks.get(e.id)){this.clampAgentsToBoundary(e.id),this.refreshChannelHandles();let t=this.getChannelLayout(e.id);t&&(this.emitSaveState(`saving`),this.channelApi?.save(e.id,t).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`)),this.emit(`channelResized`,{channelId:e.id,layout:t}))}}rangeLineVisible(e){return this.mode===`edit`||this.selected?.kind===`agent`&&this.selected.id===e.agentId}emitAgentRangeChanged(e){this.emit(`agentRangeChanged`,{agentId:e})}refreshAgentRangeLines(){for(let e of this.agents.values())e.rangeLine&&(e.rangeLine.visible=this.rangeLineVisibleFor(e))}rangeLineVisibleFor(e){return this.mode===`edit`||this.selected?.kind===`agent`&&this.selected.id===e.agentId}refreshAgentRangeHandles(){for(let e of this.agentRangeHandles)e.mesh.visible=!1;if(this.mode!==`edit`||!this.selected||this.selected.kind!==`agent`)return;let e=this.agents.get(this.selected.id);if(!e||!e.range)return;let t=e.range.rotationY*Math.PI/180,n=this.boundaryHandlePoints(e.range);for(let r=0;r<this.agentRangeHandles.length&&r<n.length;r++){let[i,a]=n[r],o=e.range.x+i*Math.cos(t)-a*Math.sin(t),s=e.range.z+i*Math.sin(t)+a*Math.cos(t);this.agentRangeHandles[r].agentId=e.agentId,this.agentRangeHandles[r].mesh.position.set(o,1.2,s),this.agentRangeHandles[r].mesh.visible=!0}}pickAgentRangeHandle(e,t){if(this.mode!==`edit`)return null;for(let n of this.agentRangeHandles)if(n.mesh.visible&&Math.hypot(n.mesh.position.x-e,n.mesh.position.z-t)<40)return{agentId:n.agentId,handle:n.handle};return null}hitAgentRangeBoundary(e,t){if(this.mode===`edit`){for(let n of this.agents.values())if(!(!n.range||!n.channelId)&&de(n.range,e,t)<26)return n}}applyAgentRangeResize(e,t,n,r){let i=-e.rotationY*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=n-e.x,c=r-e.z,l=s*a-c*o,u=s*o+c*a,d;return d=e.shape===`rect`?{...e,radiusX:Math.max(30,Math.abs(l)),radiusZ:Math.max(30,Math.abs(u))}:t===0||t===1?{...e,radiusX:Math.max(30,Math.abs(l))}:{...e,radiusZ:Math.max(30,Math.abs(u))},d}updateRangeDrawPreview(e,t,n,r){let i=Math.min(e,n),a=Math.max(e,n),o=Math.min(t,r),s=Math.max(t,r),c=(i+a)/2,l=(o+s)/2,u=Math.max(8,(a-i)/2),d=Math.max(8,(s-o)/2);if(!this.rangeDrawLine){let e=$(`rect`,1,1,4311284);e.material.opacity=.95,e.position.y=.5,this.scene.add(e),this.rangeDrawLine=e}this.rangeDrawLine.position.set(c,.5,l),this.rangeDrawLine.rotation.y=0;let f=new w().setFromPoints([new C(-u,0,-d),new C(u,0,-d),new C(u,0,d),new C(-u,0,d)]);this.rangeDrawLine.geometry.dispose(),this.rangeDrawLine.geometry=f}cancelRangeDraw(){this.rangeDrawAgent===null&&!this.rangeDrawLine||(this.rangeDrawAgent=null,this.rangeDrawPreviewState=null,this.rangeDrawLine&&=(this.scene.remove(this.rangeDrawLine),null),this.dirty=!0)}startRangeDraw(e){let t=this.agents.get(e);!t||!t.channelId||this.mode!==`edit`||(this.setSelected({kind:`agent`,id:e}),this.cancelRangeDraw(),this.rangeDrawAgent=e,this.rangeDrawPreviewState=null,this.refreshAgentRangeHandles(),this.dirty=!0)}isRangeDrawing(e){return this.rangeDrawAgent?e===void 0||this.rangeDrawAgent===e:!1}debugAdvanceReceiver(e){let t=this.receivers.get(e);t&&(t.currentUntil=0)}getAgentRange(e){return this.agents.get(e)?.range??null}setAgentRangeScene(e,t){let n=this.agents.get(e);if(!n)return;n.range||={x:n.homeX,z:n.homeZ,radiusX:120,radiusZ:90,shape:`ellipse`,rotationY:0},n.range={...n.range,...t};let r=V(n.range,n.homeX,n.homeZ,0);(r.x!==n.homeX||r.z!==n.homeZ)&&(n.homeX=r.x,n.homeZ=r.z,n.root.position.x=r.x,n.root.position.z=r.z,this.rangeHomeMoved={agentId:e,x:r.x,z:r.z}),n.renderRangeLine(),this.refreshAgentRangeHandles(),this.dirty=!0}commitAgentRange(e){let t=this.agents.get(e);if(t){if(this.rangeHomeMoved?.agentId===e){let{x:n,z:r}=this.rangeHomeMoved;this.rangeHomeMoved=null,this.agentApi?.updateHome(e,t.channelId,n,r).catch(()=>{})}this.emitSaveState(`saving`),this.agentApi?.updateRange(e,t.channelId,t.range).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`)),this.emitAgentRangeChanged(e)}}clearAgentRange(e){let t=this.agents.get(e);t&&(t.rangeLine&&=(this.scene.remove(t.rangeLine),null),t.range=null,this.rangeHomeMoved=null,this.refreshAgentRangeHandles(),this.emitSaveState(`saving`),this.agentApi?.updateRange(e,t.channelId,null).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`)),this.emitAgentRangeChanged(e),this.dirty=!0)}setModelRotation(e,t,n){if((n??(this.deviceNodes.has(e)?`device`:`agent`))===`device`){let n=this.deviceNodes.get(e);if(!n)return;n.root.rotation.y=t*Math.PI/180}else{let n=this.agents.get(e);if(!n)return;n.root.rotation.y=t*Math.PI/180}this.dirty=!0}getModelRotation(e,t){if((t??(this.deviceNodes.has(e)?`device`:`agent`))===`device`){let t=this.deviceNodes.get(e);return t?T.radToDeg(t.root.rotation.y):0}let n=this.agents.get(e);return n?T.radToDeg(n.root.rotation.y):0}emitSaveState(e,t=Date.now()){this.emit(`saveState`,{state:e,at:t})}persistDeviceTransform(e){let t=this.deviceNodes.get(e);if(!t||!this.devices?.update||this.pendingDeviceCreates.has(e))return;let n=this.scalables.get(`device:${e}`),r=this.pendingSaveTimers.get(e);r&&clearTimeout(r),this.pendingSaveTimers.set(e,setTimeout(()=>{this.pendingSaveTimers.delete(e),!(this.disposed||this.pendingDeviceCreates.has(e))&&(this.emitSaveState(`saving`),this.devices.update(e,{posX:Math.round(t.root.position.x*10)/10,posZ:Math.round(t.root.position.z*10)/10,rotationY:Math.round(T.radToDeg(t.root.rotation.y)*10)/10,scale:n?Math.round(n.userScale*100)/100:void 0}).then(()=>this.emitSaveState(`saved`,Date.now())).catch(()=>this.emitSaveState(`error`)))},350)),this.emitSaveState(`dirty`)}persistAllDevices(){for(let e of[...this.deviceNodes.keys()])this.persistDeviceTransform(e)}pendingSaveTimers=new Map;syncDevices(e){let t=new Set(e.map(e=>e.id));for(let e of[...this.deviceNodes.keys()])!t.has(e)&&!this.pendingDeviceCreates.has(e)&&this.removeDeviceNode(e);for(let t of e){let e=this.deviceNodes.get(t.id);if(!e){let n=[...this.pendingDeviceCreates.entries()].find(([,e])=>e.name===t.name&&e.modelRef===t.modelRef);n&&(this.adoptDeviceNode(n[0],t.id),e=this.deviceNodes.get(t.id))}if(!e){(t.kind===`daq`||(t.modelRef??``).startsWith(`daq-`)||(t.modelRef??``).startsWith(`dcw-`)||this.resolveDeviceModel(t.modelRef)?.file)&&typeof t.posX==`number`&&typeof t.posZ==`number`?this.recreateDeviceNode(t):this.pendingDeviceTwins.set(t.id,t);continue}if(this.pendingDeviceTwins.delete(t.id),e.applyTwin(t),this.pointerDrag?.id!==t.id){let n=typeof t.posX==`number`&&t.posX!==e.root.position.x||typeof t.posZ==`number`&&t.posZ!==e.root.position.z;typeof t.posX==`number`&&(e.root.position.x=t.posX),typeof t.posZ==`number`&&(e.root.position.z=t.posZ),typeof t.rotationY==`number`&&(e.root.rotation.y=t.rotationY*Math.PI/180);let r=this.scalables.get(`device:${t.id}`);typeof t.scale==`number`&&r&&(r.userScale=t.scale,r.holder.scale.setScalar(t.scale)),n&&(this.dirty=!0)}this.dirty=!0}this.daqLinksWanted.length&&this.syncDaqLinks(this.daqLinksWanted);for(let e of[...this.pendingDeviceTwins.keys()])t.has(e)||this.pendingDeviceTwins.delete(e)}resolveDeviceModel(e){let t=this.modelsById.get(e);if(t?.file)return{id:t.id,file:t.file,hFactor:t.hFactor??1};for(let[t,n]of this.modelsById)if(!(n.kind!==`dev`||!n.file)&&(t===`dev-folder-${e}`||t.endsWith(`-${e}`)))return{id:t,file:n.file,hFactor:n.hFactor??1};return null}recreateDeviceNode(e){if(e.kind===`daq`||(e.modelRef??``).startsWith(`daq-`)||(e.modelRef??``).startsWith(`dcw-`)){this.recreateDaqNode(e);return}let t=this.resolveDeviceModel(e.modelRef),n=t?.file??``;if(!n)return;let r=typeof e.posX==`number`?e.posX:R,i=typeof e.posZ==`number`?e.posZ:B,a=new g;a.position.set(r,0,i),a.rotation.y=typeof e.rotationY==`number`?e.rotationY*Math.PI/180:0;let{ring:o,arc:s}=this.makeDeviceRing();a.add(o,s);let c=new g;a.add(c);let l=this.makeLabel(`⚙ ${e.name}`,r,60,i);c.userData.modelFile=n,this.scene.add(a);let u=new bt({twinId:e.id,name:e.name,modelRef:e.modelRef,root:a,holder:c,ring:o,label:l,state:e.state??`idle`,telemetry:e.telemetry??{}});u.host=this,u.arc=s,u.updateRing(),this.deviceNodes.set(e.id,u),this.registerScalable(`device`,e.id,c,typeof e.scale==`number`?e.scale:void 0),this.loadGltfToGroup(n,c,192*(t?.hFactor??1)),this.dirty=!0}makeDaqMesh(e){let t=new g,n=new E({color:10465992,metalness:.85,roughness:.32}),r=new E({color:7636636,metalness:.35,roughness:.5}),i=new E({color:5596282,metalness:.4,roughness:.55}),a=new E({color:2831426,metalness:.7,roughness:.45}),o=new E({color:14674162,metalness:1,roughness:.14}),s=new E({color:12941893,metalness:.9,roughness:.35}),c=new z({color:4311284});c.color.multiplyScalar(5);let l=(e,t,n,r)=>{let i=new h(new H(e*34,t*34,n*34),r);return i.castShadow=!0,i},u=(e,t,n,r,i=20)=>{let a=new h(new _(e*34,t*34,n*34,i),r);return a.castShadow=!0,a},d=(e,n,r,i)=>(e.position.set(n*34,r*34,i*34),t.add(e),e);d(u(.17,.22,.09,a),0,.045,0),d(u(.028,.028,.95,n,10),0,.55,0);let f=new h(new W(3.06,.68,10,28),new z({color:3530912}));if(f.material.color.multiplyScalar(6),f.rotation.x=Math.PI/2,t.add(f),f.position.y=34.68,e.endsWith(`temp-tc`)){d(l(.24,.32,.24,r),0,1.2,0);let e=d(u(.014,.014,.4,n,8),.14,.85,0);e.rotation.z=-.5}else if(e.endsWith(`pressure-tx`))d(u(.13,.16,.3,n),0,1.22,0),d(u(.12,.12,.05,a),0,1.4,0),d(l(.05,.05,.2,s),0,1.1,.2);else if(e.endsWith(`tension-cell`)){d(l(.34,.2,.2,r),0,1.25,0);for(let e of[-.11,.11]){let t=d(u(.06,.06,.26,o),e,1.25,0);t.rotation.x=Math.PI/2}}else if(e.endsWith(`line-encoder`)){d(l(.34,.05,.05,n),.14,1.28,0);let e=d(u(.16,.16,.05,a),.32,1.28,0);e.rotation.z=Math.PI/2,d(new h(new W(.1*34,.51,10,26),f.material),.35,1.28,0)}else if(e.endsWith(`vision-cam`)){d(l(.28,.2,.36,i),0,1.3,0);let e=d(u(.07,.09,.14,a),0,1.3,.24);e.rotation.x=Math.PI/2,d(new h(new W(2.55,.012*34,10,24),f.material),0,1.3,.3)}else e.endsWith(`power-meter`)&&(d(l(.32,.42,.18,r),0,1.3,0),d(u(.012,.012,.42,n,8),.1,1.7,0),d(new h(new M(.028*34,10,8),f.material),.1,1.92,0),d(l(.2,.06,.02,c),0,1.42,.1));return{group:t,ledRing:f}}recreateDaqNode(e){let t=typeof e.posX==`number`?e.posX:R,n=typeof e.posZ==`number`?e.posZ:B,r=new g;r.position.set(t,0,n),r.rotation.y=typeof e.rotationY==`number`?e.rotationY*Math.PI/180:0;let{group:i,ledRing:a}=this.makeDaqMesh(e.modelRef);r.add(i);let o=new h(new k(16,21,36),new z({color:3530912,transparent:!0,opacity:.5,side:2,depthWrite:!1}));o.rotation.x=-Math.PI/2,o.position.y=.35,r.add(o);let s=new h(new k(24,34,48),new z({color:3530912,transparent:!0,opacity:.16,side:2,depthWrite:!1,blending:2}));s.rotation.x=-Math.PI/2,s.position.y=.28,r.add(s);let c=e.lineColor||`#35e0a0`,l=this.makeLabel(e.name,t,62,n,c);this.scene.add(r);let u=new bt({twinId:e.id,name:e.name,modelRef:e.modelRef,root:r,holder:r,ring:o,label:l,state:e.state??`running`,telemetry:e.telemetry??{}});u.host=this,u.lineColor=e.lineColor??``,u.applyLine=e=>{let t=new F(e||`#35e0a0`);o.material.color.copy(t),s.material.color.copy(t),a.material.color.copy(t).multiplyScalar(6),this.scene.remove(l),l.material.dispose();let n=this.makeLabel(u.name,r.position.x,62,r.position.z,e||`#35e0a0`);u.label=n,this.scene.add(n),this.dirty=!0},e.lineColor&&u.applyLine(e.lineColor),u.updateRing(),this.deviceNodes.set(e.id,u),this.daqLedRings.set(e.id,a),this.registerScalable(`device`,e.id,r,typeof e.scale==`number`?e.scale:void 0),this.dirty=!0}removeDeviceNode(e){let t=this.deviceNodes.get(e);t&&(this.scene.remove(t.root),this.scene.remove(t.label),this.disposeDeviceAssets(t),this.selected?.kind===`device`&&this.selected.id===e&&this.setSelected(null),this.scalables.delete(`device:${e}`),this.deviceNodes.delete(e),this.daqLedRings.delete(e),this.daqLinkSig=``,this.filmWebSig=``,this.dirty=!0)}deviceTopY(e){if(e.topYCache!=null)return e.topYCache;let t=new o().setFromObject(e.holder),n=Number.isFinite(t.max.y)?Math.max(40,t.max.y):64;return e.topYCache=n,n}syncDaqLinks(e){this.daqLinksWanted=e;let t=e.filter(e=>this.deviceNodes.has(e.daqId)&&this.deviceNodes.has(e.deviceId)),n=t.map(e=>`${e.daqId}>${e.deviceId}`).sort().join(`|`);if(n!==this.daqLinkSig){this.daqLinkSig=n;for(let e of this.daqLinks)this.daqLinkGroup.remove(e.line),this.daqLinkGroup.remove(e.pulse),e.line.geometry.dispose();this.daqLinks=[];for(let e of t){let t=this.deviceNodes.get(e.daqId),n=this.deviceNodes.get(e.deviceId),r=new C(t.root.position.x,42,t.root.position.z),i=new C(n.root.position.x,this.deviceTopY(n)+6,n.root.position.z),o=r.clone().add(i).multiplyScalar(.5);o.y=Math.max(r.y,i.y)+42;let s=new Ce(r,o,i),c=new w().setFromPoints(s.getPoints(28)),l=new a(c,new f({color:3530912,transparent:!0,opacity:.55,dashSize:8,gapSize:5}));l.computeLineDistances();let u=new h(new M(2.6,10,8),new z({color:4311284}));u.material.color.multiplyScalar(5),this.daqLinkGroup.add(l,u),this.daqLinks.push({...e,line:l,pulse:u,curve:s,pt:Math.random(),ptSig:``})}this.dirty=!0}}static _lkA=new C;static _lkB=new C;static _lkM=new C;refreshDaqLinks(){for(let e of this.daqLinks){let n=this.deviceNodes.get(e.daqId),r=this.deviceNodes.get(e.deviceId);if(!n||!r)continue;let i=this.deviceTopY(r)+6,a=`${Math.round(n.root.position.x)},${Math.round(n.root.position.z)},${Math.round(r.root.position.x)},${Math.round(r.root.position.z)},${Math.round(i)}`;if(a===e.ptSig)continue;e.ptSig=a;let o=t._lkA.set(n.root.position.x,42,n.root.position.z),s=t._lkB.set(r.root.position.x,i,r.root.position.z),c=t._lkM.copy(o).add(s).multiplyScalar(.5);c.y=Math.max(o.y,s.y)+42,e.curve.v0.copy(o),e.curve.v1.copy(c),e.curve.v2.copy(s);let l=e.curve.getPoints(28);e.line.geometry.setFromPoints(l),e.line.computeLineDistances()}}isLineDevice(e){let t=e.toLowerCase();return/extruder|caster|mdo|tdo|winder/.test(t)}rebuildFilmWeb(){let e=[...this.deviceNodes.values()].filter(e=>this.isLineDevice(e.modelRef)&&!e.modelRef.startsWith(`daq-`)).sort((e,t)=>e.root.position.x-t.root.position.x),t=e.map(e=>`${e.twinId}:${Math.round(e.root.position.x)},${Math.round(e.root.position.z)}`).join(`|`);if(t!==this.filmWebSig){for(this.filmWebSig=t;this.filmWebGroup.children.length;){let e=this.filmWebGroup.children[0];this.filmWebGroup.remove(e),e.geometry.dispose()}this.filmWebMat||=new E({color:11196671,metalness:.1,roughness:.35,transparent:!0,opacity:.28,emissive:2845583,emissiveIntensity:.25,side:2,depthWrite:!1});for(let t=0;t<e.length-1;t++){let n=e[t].root.position,r=e[t+1].root.position,i=Math.abs(r.x-n.x)-110;if(i<30)continue;let a=new h(new H(i,1.2,46),this.filmWebMat);a.position.set((n.x+r.x)/2,48,(n.z+r.z)/2),this.filmWebGroup.add(a)}this.dirty=!0}}loop(){let e=()=>{if(this.disposed)return;this.raf=requestAnimationFrame(e);let t=this.clock.getDelta();if(this.frameBudgetMs>0){if(this.frameAcc+=t*1e3,this.frameAcc<this.frameBudgetMs-.5)return;this.frameAcc=0}let n=Math.min(t,.1),r=this.clock.elapsedTime;this.drainReceivers(performance.now());for(let e of this.agents.values())e.state!==`stopped`&&!e.dragging&&e.update(n);for(let e of this.agents.values())e.mixer&&e.mixer.update(n);for(let e of this.blocks.values())e.beacon.rotation.y+=n*.4;for(let e of this.agents.values())if(e.nameSprite.position.set(e.root.position.x,48,e.root.position.z),e.bubble&&e.bubble.position.set(e.root.position.x,108+Math.max(0,e.model.scale.y-1)*22,e.root.position.z),e.auraMats.length){let t=.8+.2*Math.sin(r*2.2+e.auraPhase);for(let n of e.auraMats)n.opacity=n.userData.baseOp*t}for(let e of this.deviceNodes.values())e.label.position.set(e.root.position.x,60,e.root.position.z),e.arc?.visible&&(e.arc.rotation.z+=n*1.6);for(let e of this.daqLedRings.values()){e.rotation.z+=n*1.2;let t=1+Math.sin(r*3.2)*.08;e.scale.setScalar(t)}if(this.daqLinks.length){this.dirty&&this.refreshDaqLinks();for(let e of this.daqLinks)e.pt=(e.pt+n*.3)%1,e.pulse.position.copy(e.curve.getPoint(e.pt))}if(this.dirty&&this.rebuildFilmWeb(),this.selRing){let e=this.selected,t=0,r=0,i=0;if(e?.kind===`agent`){let n=this.agents.get(e.id);n&&(t=n.root.position.x,r=n.root.position.z,i=46*Math.max(.6,n.model.scale.y))}else if(e?.kind===`device`){let n=this.deviceNodes.get(e.id);n&&(t=n.root.position.x,r=n.root.position.z,i=Math.max(34,this.deviceTopY(n)*.42))}this.selRing.visible=i>0,i>0&&(this.selRing.position.set(t,.5,r),this.selRing.scale.setScalar(i),this.selRing.rotation.z+=n*.9)}let i=this.rafAnims;this.rafAnims=[];for(let e of i)e();let a=1-Math.exp(-n*7.2);this.autoDolly!==null&&(this.dolly+=(this.autoDolly-this.dolly)*a,Math.abs(this.autoDolly-this.dolly)<.01&&(this.autoDolly=null));let o=1-Math.exp(-n*4.8);for(let e of[`yaw`,`pitch`,`radius`])this.viewCur[e]+=(this.viewTarget[e]-this.viewCur[e])*o;this.autoOrbit&&!this.pointerDrag&&(this.viewCur.yaw-=n*.156,this.viewTarget.yaw=this.viewCur.yaw);let s=this.viewCur.radius*this.dolly,c=Math.cos(this.viewCur.pitch);this.camera.position.set(this.camTarget.x+s*c*Math.sin(this.viewCur.yaw),20+s*Math.sin(this.viewCur.pitch),this.camTarget.z+s*c*Math.cos(this.viewCur.yaw)),this.camera.lookAt(this.camTarget.x,20,this.camTarget.z);let l=Math.max(.05,1.2*this.dolly),u=16e3*this.dolly;(Math.abs(this.camera.near-l)>.005||Math.abs(this.camera.far-u)>1)&&(this.camera.near=l,this.camera.far=u,this.camera.updateProjectionMatrix()),this.skyDome&&(this.skyDome.position.set(this.camTarget.x,0,this.camTarget.z),this.skyDome.scale.setScalar(Math.max(1,this.dolly*1.3))),this.ground.position.set(this.camTarget.x,0,this.camTarget.z);let d=this.ground.material.map;d&&d.offset.set(this.camTarget.x/(D*16/d.repeat.x),-this.camTarget.z/(N*16/d.repeat.y));let f=this.scene.fog;f instanceof p&&(f.near=1400*this.dolly,f.far=8800*this.dolly);let m=this.keyLight.shadow.camera,h=1600*Math.max(1,this.dolly);Math.abs(m.right-h)>1&&(m.left=-h,m.right=h,m.top=2300*Math.max(1,this.dolly),m.bottom=-2300*Math.max(1,this.dolly),m.updateProjectionMatrix(),this.renderer.shadowMap.needsUpdate=!0);let g=!1;for(let e of this.agents.values())if(e.mixer){g=!0;break}this.renderer.shadowMap.needsUpdate=this.dirty||g,this.composer.render(n),this.dirty=!1,this.frameCount+=1,this.fpsAccum+=n*1e3,this.fpsAccum>=1e3&&(this.emit(`fps`,this.frameCount),this.adaptQuality(this.frameCount),this.frameCount=0,this.fpsAccum=0)};e()}static Q_TIERS=[{scale:1,shadow:2048,bloom:!0},{scale:.8,shadow:2048,bloom:!0},{scale:.65,shadow:1024,bloom:!0},{scale:.55,shadow:1024,bloom:!1}];qTier=0;qLowStreak=0;qHighStreak=0;qualityMode=`auto`;static USER_QUALITY={ultra:{scale:1,shadow:2048,bloom:!0},hd:{scale:.8,shadow:2048,bloom:!0},normal:{scale:.6,shadow:1024,bloom:!0}};setQualityMode(e){if(this.qualityMode=e,e===`auto`){this.applyQuality();return}let n=t.USER_QUALITY[e];this.applyPixelRatio(Math.max(.5,this.baseDpr*n.scale));let r=this.keyLight;(r.shadow.mapSize.x??0)!==n.shadow&&(r.shadow.mapSize.set(n.shadow,n.shadow),r.shadow.map?.dispose(),r.shadow.map=null,this.renderer.shadowMap.needsUpdate=!0);let i=this.composer.passes.find(e=>e instanceof ht);i&&(i.enabled=n.bloom)}adaptQuality(e){if(this.qualityMode!==`auto`)return;let n=t.Q_TIERS.length-1;e<17&&this.qTier<n?++this.qLowStreak>=2&&(this.qTier++,this.applyQuality(),this.qLowStreak=0,this.qHighStreak=0):e>=27&&this.qTier>0?++this.qHighStreak>=4&&(this.qTier--,this.applyQuality(),this.qHighStreak=0,this.qLowStreak=0):(this.qLowStreak=0,this.qHighStreak=0)}applyQuality(){let e=t.Q_TIERS[this.qTier];this.applyPixelRatio(Math.max(.5,this.baseDpr*e.scale));let n=this.keyLight;(n.shadow.mapSize.x??0)!==e.shadow&&(n.shadow.mapSize.set(e.shadow,e.shadow),n.shadow.map?.dispose(),n.shadow.map=null,this.renderer.shadowMap.needsUpdate=!0);let r=this.composer.passes.find(e=>e instanceof ht);r&&(r.enabled=e.bloom)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e);let t=this.el.clientWidth||1100,n=this.el.clientHeight||700;this.renderer.setSize(t,n),this.composer.setSize(t,n)}disposeCanvasTextures(e){e&&e.traverse(e=>{let t=e.material,n=Array.isArray(t)?t:t?[t]:[];for(let e of n){let t=e;t.map&&t.map.image instanceof HTMLCanvasElement&&t.map.dispose(),e.dispose()}})}disposeDeviceAssets(e){e.ring.geometry.dispose(),e.ring.material.dispose(),e.arc&&(e.arc.geometry.dispose(),e.arc.material.dispose()),this.disposeCanvasTextures(e.label)}disposeAgentAssets(e){this.disposeCanvasTextures(e.nameSprite??null),this.disposeCanvasTextures(e.bubble??null),e.rangeLine?.geometry.dispose(),e.aura&&=(e.aura.traverse(e=>{let t=e;t.isMesh&&(t.geometry.dispose(),t.material.dispose())}),null)}resetAll(){for(let e of this.agents.values())this.scene.remove(e.root),e.nameSprite&&this.scene.remove(e.nameSprite),e.bubble&&this.scene.remove(e.bubble),e.rangeLine&&this.scene.remove(e.rangeLine),this.disposeAgentAssets(e);for(let e of this.blocks.values())this.scene.remove(e.platform),this.scene.remove(e.padRing),this.scene.remove(e.beacon),this.scene.remove(e.boundary),this.scene.remove(e.label),this.disposeCanvasTextures(e.label);for(let e of this.deviceNodes.values())this.scene.remove(e.root),this.scene.remove(e.label),this.disposeDeviceAssets(e);this.deviceNodes.clear(),this.scalables.clear(),this.receivers.clear(),this.pointerDrag=null,this.cancelRangeDraw(),this.selected=null,this.selectedChannel=null;for(let e of this.resizeHandles)e.mesh.visible=!1;for(let e of this.agentRangeHandles)e.mesh.visible=!1;this.agents.clear(),this.blocks.clear()}dispose(){this.disposed=!0,cancelAnimationFrame(this.raf),delete globalThis.__townScene3d;for(let e of this.pendingSaveTimers.values())clearTimeout(e);this.pendingSaveTimers.clear(),this.receivers.clear(),this.resizeOb?.disconnect(),this.resizeOb=null,this.tControls?.dispose(),this.tControls=null,this.composer?.dispose(),this.renderer.dispose(),this.renderer.domElement.parentElement===this.el&&this.renderer.domElement.remove()}};export{xt as TownScene3D};
@@ -1 +0,0 @@
1
- import{ft as e}from"./BSCpFtzG.js";import{t}from"./G0qIw7Gq2.js";import{i as n}from"./DAR70Lf5.js";var r=`__deviceTwins`;function i(){let r=[],i=e({twins:r,loaded:!1,error:``,async load(){return i.__loading||=(async()=>{try{let e=await n({base:`/api/workshop/device-twins`,retries:2});i.twins.splice(0,i.twins.length,...e?.twins??[]),i.loaded=!0,i.error=``}catch(e){i.loaded=!1,i.error=t(e)}finally{i.__loading=null}})(),i.__loading},applyRemote(e){let t=i.twins.findIndex(t=>t.id===e.id);t>=0?Object.assign(i.twins[t],e):i.twins.push({...e})},removeRemote(e){let t=i.twins.findIndex(t=>t.id===e);t>=0&&i.twins.splice(t,1)},byId(e){return r.find(t=>t.id===e)},async create(e){let t=await n({base:`/api/workshop/device-twins`,init:{method:`POST`,body:JSON.stringify(e)}});return i.loaded=!1,await i.load(),t.twin},async update(e,t){let r=await n({base:`/api/workshop/device-twins/${e}`,init:{method:`PATCH`,body:JSON.stringify(t)}});return i.loaded=!1,await i.load(),r.twin},async control(e,t,r){let a=await n({base:`/api/workshop/device-twins/${e}/control`,init:{method:`POST`,body:JSON.stringify({command:t,args:r??{}})}});return i.loaded=!1,await i.load(),a.twin},async pushTelemetry(e,t){let r=await n({base:`/api/workshop/device-twins/${e}/telemetry`,init:{method:`POST`,body:JSON.stringify({telemetry:t})}});return i.loaded=!1,await i.load(),r.twin},async remove(e){await n({base:`/api/workshop/device-twins/${e}`,init:{method:`DELETE`}}),i.loaded=!1,await i.load()}});return i}function a(){let e=globalThis;e[r]||(e[r]=i());let t=e[r];return t.load(),t}export{a as t};
@@ -1 +0,0 @@
1
- import{C as e,F as t,O as n,U as r,f as i,mt as a,x as o,z as s}from"./BSCpFtzG.js";import{At as c,Ct as l,d as u,et as d,kt as f,n as p,u as m}from"./BDUjyaF4.js";import{n as h,t as g}from"./D95h62Jn.js";import{r as _}from"./ORt9oDIy2.js";var v=Symbol(`rowContextKey`),y=e=>{r(v,e)},b=()=>n(v,{gutter:i(()=>void 0),wrap:i(()=>void 0),supportFlexGap:i(()=>void 0)}),x=e=>{let{componentCls:t}=e;return{[t]:{display:`flex`,flexFlow:`row wrap`,minWidth:0,"&::before, &::after":{display:`flex`},"&-no-wrap":{flexWrap:`nowrap`},"&-start":{justifyContent:`flex-start`},"&-center":{justifyContent:`center`},"&-end":{justifyContent:`flex-end`},"&-space-between":{justifyContent:`space-between`},"&-space-around ":{justifyContent:`space-around`},"&-space-evenly ":{justifyContent:`space-evenly`},"&-top":{alignItems:`flex-start`},"&-middle":{alignItems:`center`},"&-bottom":{alignItems:`flex-end`}}}},S=e=>{let{componentCls:t}=e;return{[t]:{position:`relative`,maxWidth:`100%`,minHeight:1}}},C=(e,t)=>{let{componentCls:n,gridColumns:r}=e,i={};for(let e=r;e>=0;e--)e===0?(i[`${n}${t}-${e}`]={display:`none`},i[`${n}-push-${e}`]={insetInlineStart:`auto`},i[`${n}-pull-${e}`]={insetInlineEnd:`auto`},i[`${n}${t}-push-${e}`]={insetInlineStart:`auto`},i[`${n}${t}-pull-${e}`]={insetInlineEnd:`auto`},i[`${n}${t}-offset-${e}`]={marginInlineEnd:0},i[`${n}${t}-order-${e}`]={order:0}):(i[`${n}${t}-${e}`]={display:`block`,flex:`0 0 ${e/r*100}%`,maxWidth:`${e/r*100}%`},i[`${n}${t}-push-${e}`]={insetInlineStart:`${e/r*100}%`},i[`${n}${t}-pull-${e}`]={insetInlineEnd:`${e/r*100}%`},i[`${n}${t}-offset-${e}`]={marginInlineStart:`${e/r*100}%`},i[`${n}${t}-order-${e}`]={order:e});return i},w=(e,t)=>C(e,t),T=(e,t,n)=>({[`@media (min-width: ${t}px)`]:f({},w(e,n))}),E=u(`Grid`,e=>[x(e)]),D=u(`Grid`,e=>{let t=m(e,{gridColumns:24}),n={"-sm":t.screenSMMin,"-md":t.screenMDMin,"-lg":t.screenLGMin,"-xl":t.screenXLMin,"-xxl":t.screenXXLMin};return[S(t),w(t,``),w(t,`-xs`),Object.keys(n).map(e=>T(t,n[e],e)).reduce((e,t)=>f(f({},e),t),{})]}),O=e({compatConfig:{MODE:3},name:`ARow`,inheritAttrs:!1,props:{align:d([String,Object]),justify:d([String,Object]),prefixCls:String,gutter:d([Number,Array,Object],0),wrap:{type:Boolean,default:void 0}},setup(e,n){let{slots:r,attrs:u}=n,{prefixCls:d,direction:m}=p(`row`,e),[v,b]=E(d),x,S=h(),C=a({xs:!0,sm:!0,md:!0,lg:!0,xl:!0,xxl:!0}),w=a({xs:!1,sm:!1,md:!1,lg:!1,xl:!1,xxl:!1}),T=t=>i(()=>{if(typeof e[t]==`string`)return e[t];if(typeof e[t]!=`object`)return``;for(let n=0;n<g.length;n++){let r=g[n];if(!w.value[r])continue;let i=e[t][r];if(i!==void 0)return i}return``}),D=T(`align`),O=T(`justify`),k=_();s(()=>{x=S.value.subscribe(t=>{w.value=t;let n=e.gutter||0;(!Array.isArray(n)&&typeof n==`object`||Array.isArray(n)&&(typeof n[0]==`object`||typeof n[1]==`object`))&&(C.value=t)})}),t(()=>{S.value.unsubscribe(x)});let A=i(()=>{let t=[void 0,void 0],{gutter:n=0}=e;return(Array.isArray(n)?n:[n,void 0]).forEach((e,n)=>{if(typeof e==`object`)for(let r=0;r<g.length;r++){let i=g[r];if(C.value[i]&&e[i]!==void 0){t[n]=e[i];break}}else t[n]=e}),t});y({gutter:A,supportFlexGap:k,wrap:i(()=>e.wrap)});let j=i(()=>l(d.value,{[`${d.value}-no-wrap`]:e.wrap===!1,[`${d.value}-${O.value}`]:O.value,[`${d.value}-${D.value}`]:D.value,[`${d.value}-rtl`]:m.value===`rtl`},u.class,b.value)),M=i(()=>{let e=A.value,t={},n=e[0]!=null&&e[0]>0?`${e[0]/-2}px`:void 0,r=e[1]!=null&&e[1]>0?`${e[1]/-2}px`:void 0;return n&&(t.marginLeft=n,t.marginRight=n),k.value?t.rowGap=`${e[1]}px`:r&&(t.marginTop=r,t.marginBottom=r),t});return()=>v(o(`div`,c(c({},u),{},{class:j.value,style:f(f({},M.value),u.style)}),[r.default?.call(r)]))}});function k(e){return typeof e==`number`?`${e} ${e} auto`:/^\d+(\.\d+)?(px|em|rem|%)$/.test(e)?`0 0 ${e}`:e}var A=()=>({span:[String,Number],order:[String,Number],offset:[String,Number],push:[String,Number],pull:[String,Number],xs:{type:[String,Number,Object],default:void 0},sm:{type:[String,Number,Object],default:void 0},md:{type:[String,Number,Object],default:void 0},lg:{type:[String,Number,Object],default:void 0},xl:{type:[String,Number,Object],default:void 0},xxl:{type:[String,Number,Object],default:void 0},prefixCls:String,flex:[String,Number]}),j=[`xs`,`sm`,`md`,`lg`,`xl`,`xxl`],M=e({compatConfig:{MODE:3},name:`ACol`,inheritAttrs:!1,props:A(),setup(e,t){let{slots:n,attrs:r}=t,{gutter:a,supportFlexGap:s,wrap:u}=b(),{prefixCls:d,direction:m}=p(`col`,e),[h,g]=D(d),_=i(()=>{let{span:t,order:n,offset:i,push:a,pull:o}=e,s=d.value,c={};return j.forEach(t=>{let n={},r=e[t];typeof r==`number`?n.span=r:typeof r==`object`&&(n=r||{}),c=f(f({},c),{[`${s}-${t}-${n.span}`]:n.span!==void 0,[`${s}-${t}-order-${n.order}`]:n.order||n.order===0,[`${s}-${t}-offset-${n.offset}`]:n.offset||n.offset===0,[`${s}-${t}-push-${n.push}`]:n.push||n.push===0,[`${s}-${t}-pull-${n.pull}`]:n.pull||n.pull===0,[`${s}-rtl`]:m.value===`rtl`})}),l(s,{[`${s}-${t}`]:t!==void 0,[`${s}-order-${n}`]:n,[`${s}-offset-${i}`]:i,[`${s}-push-${a}`]:a,[`${s}-pull-${o}`]:o},c,r.class,g.value)}),v=i(()=>{let{flex:t}=e,n=a.value,r={};if(n&&n[0]>0){let e=`${n[0]/2}px`;r.paddingLeft=e,r.paddingRight=e}if(n&&n[1]>0&&!s.value){let e=`${n[1]/2}px`;r.paddingTop=e,r.paddingBottom=e}return t&&(r.flex=k(t),u.value===!1&&!r.minWidth&&(r.minWidth=0)),r});return()=>h(o(`div`,c(c({},r),{},{class:_.value,style:[v.value,r.style]}),[n.default?.call(n)]))}});export{O as n,M as t};
@@ -1 +0,0 @@
1
- import{G as e,w as t}from"./rqZ-1SoP.js";import{C as n,G as r,H as i,Ht as a,St as o,Ut as ee,Wt as s,a as c,b as l,et as u,f as d,g as f,h as p,m,mt as h,nt as g,p as _,rt as v,t as y,x as b}from"./BSCpFtzG.js";import{t as x}from"./CfVAr2nf.js";import{n as S}from"./BeIfu4N3.js";import{t as te}from"./BN_PdN3J.js";import{r as C}from"./D-Ca4BGY.js";import{t as ne}from"./RzXYI9FM.js";import{t as re}from"./niDwBOZW.js";import{t as ie}from"./Cor9siSf.js";import{n as ae,r as oe,t as se}from"./DWcEk1ur2.js";import{t as ce}from"./DoLasgPj2.js";import{t as w}from"./BcrN7QEl2.js";import{t as T}from"./BytVi9VX2.js";import{t as le}from"./DsUUYP292.js";var ue={class:`settings-page`},de={class:`aw-page-head`},fe={class:`aw-kicker`},pe={class:`aw-stamp`},me={class:`settings-layout`},he={class:`settings-nav`},ge=[`onClick`],E={class:`settings-body`},D={class:`section-title`},O={class:`section-desc`},k={class:`set-row`},A={class:`set-text`},j={class:`set-title`},M={class:`set-sub`},N={class:`color-swatches`},P=[`title`,`onClick`],F={class:`swatch-label`},I={key:0,class:`i-tabler-check swatch-check`},L={class:`toggle-row`},_e={class:`set-text`},ve={class:`set-title`},ye={class:`set-sub`},be=[`aria-checked`],xe={class:`toggle-row`},Se={class:`set-text`},Ce={class:`set-title`},we={class:`set-sub`},Te={class:`section-title`},Ee={class:`section-desc`},De={class:`rt-group-title`},Oe={class:`rt-main`},ke={class:`rt-title`},Ae={class:`rt-sub`},je={class:`rt-ctrl`},Me={key:3,class:`rt-color`},Ne=[`value`,`onInput`],Pe=[`title`,`onClick`],Fe={class:`rt-actions`},Ie=[`disabled`],Le={class:`rt-path aw-mono`},Re={class:`section-title`},ze={class:`section-desc`},Be={class:`aw-mono`},Ve={class:`identity-note`},R=y(n({__name:`settings`,setup(n){let{t:y,locale:R,locales:He,setLocale:Ue}=S(),z=x(),B=le(),V=t().public,H=w(),U=h(`appearance`),W=T(),G=h({}),K=h(new Set),q=h(!1),J=h(null);function Y(){G.value={...W.effective},K.value=new Set}u(()=>W.loaded,e=>{e&&Y()}),u(()=>W.effective,()=>{K.value.size===0&&Y()},{deep:!0});function X(e){K.value.add(e),J.value=null}async function We(){if(K.value.size){q.value=!0,J.value=null;try{let e={};for(let t of K.value)e[t]=G.value[t];let t=await W.patch(e);Y();let n=t.restartRequired??[];J.value=n.length?{type:`warning`,text:y(`settings.runtime.restartNotice`,{keys:n.join(`, `)})}:{type:`success`,text:y(`settings.runtime.savedLive`)}}catch(e){J.value={type:`error`,text:e?.response?.data?.message||e?.message||String(e)}}finally{q.value=!1}}}async function Ge(e){try{await W.patch({[e]:null}),K.value.delete(e),G.value[e]=W.effective[e],J.value={type:`success`,text:y(`settings.runtime.keyReset`,{key:e})}}catch(e){J.value={type:`error`,text:e?.response?.data?.message||e?.message||String(e)}}}async function Ke(){try{await W.resetAll(),Y(),J.value={type:`success`,text:y(`settings.runtime.resetAllDone`)}}catch(e){J.value={type:`error`,text:e?.response?.data?.message||e?.message||String(e)}}}function Z(e){return{server:y(`settings.runtime.groupServer`),app:y(`settings.runtime.groupApp`),api:y(`settings.runtime.groupApi`),theme:y(`settings.runtime.groupTheme`),i18n:y(`settings.runtime.groupI18n`),security:y(`settings.runtime.groupSecurity`),daq:y(`settings.runtime.groupDaq`),memory:y(`settings.runtime.groupMemory`),omp:y(`settings.runtime.groupOmp`),harness:y(`settings.runtime.groupHarness`),dcw:y(`settings.runtime.groupDcw`),workshop:y(`settings.runtime.groupWorkshop`),backup:y(`settings.runtime.groupBackup`),retention:y(`settings.runtime.groupRetention`),log:y(`settings.runtime.groupLog`)}[e]??e}function qe(e){return e===`runtime`?`src-runtime`:e===`env`?`src-env`:`src-yaml`}function Je(e){let t=e.labelKey;return t&&y(t)!==t?y(t):e.label}let Q=String(V.primaryColor),Ye=[{value:Q,label:y(`settings.accentInk`)},{value:`#c9963f`,label:y(`settings.accentStone`)},{value:`#44615a`,label:y(`settings.accentMoss`)},{value:`#3f6094`,label:y(`settings.accentSlate`)},{value:`#6b5aa0`,label:y(`settings.accentPlum`)},{value:`#9c5744`,label:y(`settings.accentClay`)}],$=d(()=>z.accent??Q);function Xe(e){z.setAccent(e===Q?null:e),C.success(y(`settings.accentApplied`))}function Ze(){z.setAccent(null),C.success(y(`settings.accentReset`))}let Qe=d(()=>He.value.map(e=>({label:e.name,value:e.code}))),$e=e=>{e!=null&&(localStorage.setItem(`aw.locale`,String(e)),Ue(String(e)),window.location.reload())},et=d(()=>[{label:y(`home.fields.name`),value:B.name},{label:y(`home.fields.version`),value:`v${B.version}`},{label:y(`home.fields.mode`),value:B.mode},{label:y(`home.fields.apiBase`),value:`${B.apiBase} (${V.apiTimeout}ms)`},{label:y(`home.fields.primary`),value:Q},{label:`i18n`,value:R.value}]),tt=d(()=>[{key:`appearance`,icon:`i-tabler-palette`,label:y(`settings.theme`)},{key:`runtime`,icon:`i-tabler-settings`,label:y(`settings.runtimeTab`)},{key:`system`,icon:`i-tabler-server-2`,label:y(`settings.systemTab`)}]);return(t,n)=>{let u=te,d=re,h=se,x=ce,S=ne,C=oe,w=ae,T=ie;return i(),f(`div`,ue,[_(`div`,de,[_(`div`,null,[_(`p`,fe,s(o(y)(`menu.system`))+` / settings `,1),_(`h1`,null,s(o(y)(`settings.title`)),1)]),_(`span`,pe,`v`+s(o(B).version),1)]),b(T,{bordered:!1,class:`settings-card`},{default:g(()=>[_(`div`,me,[_(`div`,he,[(i(!0),f(c,null,r(o(tt),e=>(i(),f(`button`,{key:e.key,class:a([`nav-item`,{active:o(U)===e.key}]),onClick:t=>U.value=e.key},[_(`span`,{class:a(e.icon)},null,2),_(`span`,null,s(e.label),1)],10,ge))),128))]),_(`div`,E,[v(_(`div`,null,[_(`h3`,D,s(o(y)(`settings.theme`)),1),_(`p`,O,s(o(y)(`settings.appearanceDesc`)),1),_(`div`,k,[_(`div`,A,[_(`div`,j,s(o(y)(`settings.primaryColor`)),1),_(`div`,M,s(o(y)(`settings.accentDesc`)),1)])]),_(`div`,N,[(i(),f(c,null,r(Ye,e=>_(`button`,{key:e.value,class:a([`swatch`,{on:o($).toLowerCase()===e.value.toLowerCase()}]),style:ee({"--sw":e.value}),title:e.label,onClick:t=>Xe(e.value)},[n[1]||=_(`span`,{class:`swatch-dot`},null,-1),_(`span`,F,s(e.label),1),o($).toLowerCase()===e.value.toLowerCase()?(i(),f(`span`,I)):p(``,!0)],14,P)),64))]),_(`button`,{class:`aw-pill outline reset-btn`,onClick:Ze},[n[2]||=_(`span`,{class:`i-tabler-rotate`},null,-1),l(` `+s(o(y)(`settings.accentResetAction`)),1)]),_(`div`,L,[_(`div`,_e,[_(`div`,ve,s(o(z).isDark?o(y)(`common.dark`):o(y)(`common.light`)),1),_(`div`,ye,s(o(y)(`settings.darkDesc`)),1)]),_(`button`,{class:a([`switch`,{on:o(z).isDark}]),role:`switch`,"aria-checked":o(z).isDark,onClick:n[0]||=e=>o(z).toggleDark()},[...n[3]||=[_(`span`,{class:`knob`},null,-1)]],10,be)]),_(`div`,xe,[_(`div`,Se,[_(`div`,Ce,s(o(y)(`header.language`)),1),_(`div`,we,s(o(y)(`settings.languageDesc`)),1)]),b(u,{value:o(R),options:o(Qe),style:{width:`140px`},onChange:$e},null,8,[`value`,`options`])])],512),[[e,o(U)===`appearance`]]),v(_(`div`,null,[_(`h3`,Te,s(o(y)(`settings.runtimeTab`)),1),_(`p`,Ee,s(o(y)(`settings.runtime.desc`)),1),o(J)?(i(),m(d,{key:0,type:o(J).type,"show-icon":``,class:`rt-notice`,message:o(J).text},null,8,[`type`,`message`])):p(``,!0),(i(!0),f(c,null,r(o(W).groups,e=>(i(),f(c,{key:e.group},[_(`h4`,De,s(Z(e.group)),1),(i(!0),f(c,null,r(e.items,e=>(i(),f(`div`,{key:e.key,class:`rt-row`},[_(`div`,Oe,[_(`div`,ke,[l(s(Je(e))+` `,1),_(`span`,{class:a([`rt-tag`,qe(o(W).sourceOf(e.key))])},s(o(W).sourceOf(e.key)),3),_(`span`,{class:a([`rt-tag`,e.applies])},s(e.applies===`live`?o(y)(`settings.runtime.live`):o(y)(`settings.runtime.restart`)),3)]),_(`div`,Ae,s(e.description),1)]),_(`div`,je,[e.type===`number`?(i(),m(h,{key:0,value:o(G)[e.key],"onUpdate:value":t=>o(G)[e.key]=t,min:e.min,max:e.max,onChange:t=>X(e.key)},null,8,[`value`,`onUpdate:value`,`min`,`max`,`onChange`])):e.type===`boolean`?(i(),m(x,{key:1,checked:o(G)[e.key],"onUpdate:checked":t=>o(G)[e.key]=t,onChange:t=>X(e.key)},null,8,[`checked`,`onUpdate:checked`,`onChange`])):e.type===`select`?(i(),m(u,{key:2,value:o(G)[e.key],"onUpdate:value":t=>o(G)[e.key]=t,style:{width:`160px`},options:(e.options??[]).map(e=>({label:e,value:e})),onChange:t=>X(e.key)},null,8,[`value`,`onUpdate:value`,`options`,`onChange`])):e.type===`color`?(i(),f(`span`,Me,[_(`input`,{type:`color`,value:String(o(G)[e.key]??`#35e0a0`),onInput:t=>{o(G)[e.key]=t.target.value,X(e.key)}},null,40,Ne),b(S,{value:String(o(G)[e.key]??``),style:{width:`110px`},class:`aw-mono`,onChange:t=>{o(G)[e.key]=t.target.value,X(e.key)}},null,8,[`value`,`onChange`])])):(i(),m(S,{key:4,value:o(G)[e.key],"onUpdate:value":t=>o(G)[e.key]=t,style:{width:`220px`},onChange:t=>X(e.key)},null,8,[`value`,`onUpdate:value`,`onChange`])),_(`button`,{class:`aw-pill outline rt-reset`,title:o(y)(`settings.runtime.resetKey`),onClick:t=>Ge(e.key)},[...n[4]||=[_(`span`,{class:`i-tabler-rotate`},null,-1)]],8,Pe)])]))),128))],64))),128)),_(`div`,Fe,[_(`button`,{class:`aw-pill primary`,disabled:!o(K).size||o(q),onClick:We},[n[5]||=_(`span`,{class:`i-tabler-device-floppy`},null,-1),l(` `+s(o(q)?`…`:o(y)(`settings.runtime.save`)),1)],8,Ie),_(`button`,{class:`aw-pill outline`,onClick:Ke},s(o(y)(`settings.runtime.resetAll`)),1),_(`span`,Le,s(o(W).settingsPath),1)])],512),[[e,o(U)===`runtime`]]),v(_(`div`,null,[_(`h3`,Re,s(o(y)(`settings.systemTab`)),1),_(`p`,ze,s(o(y)(`settings.systemDesc`)),1),b(w,{bordered:``,column:1,size:`small`},{default:g(()=>[(i(!0),f(c,null,r(o(et),e=>(i(),m(C,{key:e.label,label:e.label},{default:g(()=>[_(`span`,Be,s(e.value),1)]),_:2},1032,[`label`]))),128))]),_:1}),_(`p`,Ve,s(o(H).isLoggedIn?`${o(y)(`settings.identity`)}: ${o(H).user?.name} (${o(H).user?.role})`:o(y)(`settings.identityGuest`)),1)],512),[[e,o(U)===`system`]])])])]),_:1})])}}}),[[`__scopeId`,`data-v-1145bd88`]]);export{R as default};
@@ -1 +0,0 @@
1
- import{C as e,K as t,U as n,W as r,q as ee}from"./rqZ-1SoP.js";import{C as i,G as a,H as o,Ht as s,St as c,Wt as l,a as u,b as d,c as te,f,ft as p,g as m,h,m as ne,mt as g,p as _,rt as v,t as y,z as re}from"./BSCpFtzG.js";import{r as b}from"./D-Ca4BGY.js";import{t as ie}from"./G0qIw7Gq2.js";import{t as ae}from"./arUY5dyq2.js";import{t as oe}from"./DAR70Lf5.js";import{t as se}from"./UtviM1bg.js";var ce={class:`page`},le={class:`aw-page-head`},ue={class:`sub`},de={class:`head-actions`},fe=[`title`],pe={class:`live-txt mono`},x={class:`filter-card`},S={class:`flt`},C={value:``},w=[`value`],T={class:`flt`},E={value:``},D=[`value`],O={class:`flt`},k={value:``},A=[`value`],j={class:`flt`},M={value:``},N={value:`user`},P={value:`system`},F={class:`flt`},I={value:``},L=[`value`],R={class:`flt flt-grow`},z=[`placeholder`],B=[`disabled`],me={class:`table-card`},he={key:0,class:`err`},ge={class:`log-table`},_e={class:`th-time`},ve={class:`th-src`},ye={class:`th-kind`},be={class:`th-scope`},xe={class:`th-detail`},Se={class:`mono dim`},Ce={class:`actor`},we={class:`summary`},Te={class:`mono dim action`},Ee={class:`scope`},De=[`title`],Oe=[`title`],ke={key:2,class:`scope-chip`,title:`Recipe`},Ae={key:3,class:`dim`},je={class:`detail-cell`},Me=[`onClick`],V={key:1,class:`dim`},Ne={key:0},Pe={colspan:`7`,class:`detail-td`},Fe={class:`detail-box mono`},Ie={key:0,colspan:`7`,class:`empty`},Le={class:`modal`},Re={class:`m-title`},ze={class:`m-f`},Be=[`placeholder`],Ve={class:`m-f`},He=[`placeholder`],Ue={class:`m-grid`},We={class:`m-f`},Ge={value:``},Ke=[`value`],qe={class:`m-f`},Je={value:``},Ye=[`value`],Xe={class:`m-f`},Ze={value:``},Qe=[`value`],$e={key:0,class:`err`},et={class:`m-actions`},tt=[`disabled`],H=y(i({name:`OpsLogsPage`,setup(i){let y=t=>e().$i18n.t(t),H=oe(),nt=ae(),U=se(),rt=[`write`,`manual`,`alarm`,`line`,`recipe`,`rollback`,`daq`,`system`],W=p({lineId:``,productId:``,recipeId:``,actorKind:``,kind:``,text:``}),G=g(null),K=g(!1),q=p({summary:``,detail:``,lineId:``,productId:``,recipeId:``}),it=f(()=>!!(W.lineId||W.productId||W.recipeId||W.actorKind||W.kind||W.text.trim())),J=f(()=>H.products.filter(e=>!W.lineId||e.lineId===W.lineId)),Y=f(()=>H.recipes.filter(e=>(!W.lineId||e.lineId===W.lineId)&&(!W.productId||e.productId===W.productId)));function X(){U.fetchLogs({lineId:W.lineId,productId:W.productId,recipeId:W.recipeId,actorKind:W.actorKind,kind:W.kind,q:W.text.trim(),limit:300}),G.value=null}function at(){W.lineId=``,W.productId=``,W.recipeId=``,W.actorKind=``,W.kind=``,W.text=``,X()}function ot(){q.summary=``,q.detail=``,q.lineId=W.lineId,q.productId=W.productId,q.recipeId=W.recipeId,K.value=!0}async function st(){try{let e=q.detail.trim();await U.postManual({summary:q.summary.trim(),lineId:q.lineId,productId:q.productId,recipeId:q.recipeId,...e?{detail:{note:e}}:{}}),b.success(y(`logs.mOk`)),K.value=!1,X()}catch(e){b.error(ie(e))}}function ct(e){return!!e.detailJson&&e.detailJson!==`{}`}function lt(e){G.value=G.value===e.id?null:e.id}function ut(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function dt(e){let t=new Date(e);if(!Number.isFinite(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function ft(e){return e===`agent`?`Agent`:y(e===`user`?`logs.src.user`:`logs.src.system`)}function pt(e){return e?y(`logs.kind.${e}`):`—`}function Z(e){return H.lines.find(t=>t.id===e)?.name??``}function Q(e){return H.products.find(t=>t.id===e)?.name??``}function $(e){return H.recipes.find(t=>t.id===e)?.name??``}return re(()=>{nt.ensureConnected(),U.ensureLive(),H.load(),X()}),(e,i)=>(o(),m(`div`,ce,[_(`header`,le,[_(`div`,null,[i[17]||=_(`p`,{class:`aw-kicker`},` agentworkshop / audit log `,-1),_(`h1`,null,l(e.$t(`logs.title`)),1),_(`p`,ue,l(e.$t(`logs.sub`)),1)]),_(`div`,de,[_(`span`,{class:`live-dot`,title:e.$t(`logs.liveHint`)},null,8,fe),_(`span`,pe,l(e.$t(`logs.live`))+` `+l(c(U).recent.length),1),_(`button`,{class:`pill-btn`,onClick:ot},[i[18]||=_(`span`,{class:`i-tabler-plus`},null,-1),d(` `+l(e.$t(`logs.manual`)),1)])])]),_(`section`,x,[_(`label`,S,[_(`span`,null,l(e.$t(`logs.fLine`)),1),v(_(`select`,{"onUpdate:modelValue":i[0]||=e=>W.lineId=e,class:`inp-sel`,onChange:i[1]||=e=>{W.productId=``,W.recipeId=``}},[_(`option`,C,l(e.$t(`logs.all`)),1),(o(!0),m(u,null,a(c(H).lines,e=>(o(),m(`option`,{key:e.id,value:e.id},l(e.name),9,w))),128))],544),[[n,W.lineId]])]),_(`label`,T,[_(`span`,null,l(e.$t(`logs.fProduct`)),1),v(_(`select`,{"onUpdate:modelValue":i[2]||=e=>W.productId=e,class:`inp-sel`,onChange:i[3]||=e=>W.recipeId=``},[_(`option`,E,l(e.$t(`logs.all`)),1),(o(!0),m(u,null,a(J.value,e=>(o(),m(`option`,{key:e.id,value:e.id},l(e.name),9,D))),128))],544),[[n,W.productId]])]),_(`label`,O,[i[19]||=_(`span`,null,`Recipe`,-1),v(_(`select`,{"onUpdate:modelValue":i[4]||=e=>W.recipeId=e,class:`inp-sel`},[_(`option`,k,l(e.$t(`logs.all`)),1),(o(!0),m(u,null,a(Y.value,e=>(o(),m(`option`,{key:e.id,value:e.id},l(e.name),9,A))),128))],512),[[n,W.recipeId]])]),_(`label`,j,[_(`span`,null,l(e.$t(`logs.fSource`)),1),v(_(`select`,{"onUpdate:modelValue":i[5]||=e=>W.actorKind=e,class:`inp-sel`},[_(`option`,M,l(e.$t(`logs.all`)),1),_(`option`,N,l(e.$t(`logs.src.user`)),1),i[20]||=_(`option`,{value:`agent`},` Agent `,-1),_(`option`,P,l(e.$t(`logs.src.system`)),1)],512),[[n,W.actorKind]])]),_(`label`,F,[_(`span`,null,l(e.$t(`logs.fKind`)),1),v(_(`select`,{"onUpdate:modelValue":i[6]||=e=>W.kind=e,class:`inp-sel`},[_(`option`,I,l(e.$t(`logs.all`)),1),(o(),m(u,null,a(rt,t=>_(`option`,{key:t,value:t},l(e.$t(`logs.kind.${t}`)),9,L)),64))],512),[[n,W.kind]])]),_(`label`,R,[_(`span`,null,l(e.$t(`logs.fKeyword`)),1),v(_(`input`,{"onUpdate:modelValue":i[7]||=e=>W.text=e,class:`inp-sel`,type:`search`,placeholder:e.$t(`logs.fKeywordPh`),onKeydown:t(X,[`enter`])},null,40,z),[[r,W.text]])]),_(`button`,{class:`pill-btn`,disabled:c(U).loading.list,onClick:X},[i[21]||=_(`span`,{class:`i-tabler-search`},null,-1),d(` `+l(e.$t(`logs.query`)),1)],8,B),it.value?(o(),m(`button`,{key:0,class:`mini-btn`,onClick:at},l(e.$t(`logs.reset`)),1)):h(``,!0)]),_(`section`,me,[c(U).error.list?(o(),m(`p`,he,l(c(U).error.list),1)):h(``,!0),_(`table`,ge,[_(`thead`,null,[_(`tr`,null,[_(`th`,_e,l(e.$t(`logs.thTime`)),1),_(`th`,ve,l(e.$t(`logs.fSource`)),1),_(`th`,null,l(e.$t(`logs.thActor`)),1),_(`th`,ye,l(e.$t(`logs.fKind`)),1),_(`th`,null,l(e.$t(`logs.thSummary`)),1),_(`th`,be,l(e.$t(`logs.thScope`)),1),_(`th`,xe,l(e.$t(`logs.thDetail`)),1)])]),_(`tbody`,null,[(o(!0),m(u,null,a(c(U).results,t=>(o(),m(u,{key:t.id},[_(`tr`,null,[_(`td`,Se,l(dt(t.at)),1),_(`td`,null,[_(`span`,{class:s([`src-badge`,t.actorKind])},l(ft(t.actorKind)),3)]),_(`td`,Ce,l(t.actorName||t.actor||`—`),1),_(`td`,null,[_(`span`,{class:s([`kind-chip`,t.kind])},l(pt(t.kind)),3)]),_(`td`,we,[d(l(t.summary)+` `,1),_(`small`,Te,l(t.action),1)]),_(`td`,Ee,[Z(t.lineId)?(o(),m(`span`,{key:0,class:`scope-chip`,title:e.$t(`logs.fLine`)},l(Z(t.lineId)),9,De)):h(``,!0),Q(t.productId)?(o(),m(`span`,{key:1,class:`scope-chip`,title:e.$t(`logs.fProduct`)},l(Q(t.productId)),9,Oe)):h(``,!0),$(t.recipeId)?(o(),m(`span`,ke,l($(t.recipeId)),1)):h(``,!0),!t.lineId&&!t.productId&&!t.recipeId?(o(),m(`span`,Ae,`—`)):h(``,!0)]),_(`td`,je,[ct(t)?(o(),m(`button`,{key:0,class:`mini-btn`,onClick:e=>lt(t)},l(G.value===t.id?e.$t(`logs.fold`):e.$t(`logs.expand`)),9,Me)):(o(),m(`span`,V,l(e.$t(`logs.noDetail`)),1))])]),G.value===t.id?(o(),m(`tr`,Ne,[_(`td`,Pe,[_(`pre`,Fe,l(ut(t.detailJson)),1)])])):h(``,!0)],64))),128)),_(`tr`,null,[c(U).results.length===0?(o(),m(`td`,Ie,[c(U).loading.list?(o(),m(u,{key:0},[d(l(e.$t(`logs.loading`)),1)],64)):(o(),m(u,{key:1},[d(l(e.$t(`logs.empty`)),1)],64))])):h(``,!0)])])])]),(o(),ne(te,{to:`body`},[K.value?(o(),m(`div`,{key:0,class:`modal-mask`,onClick:i[16]||=ee(e=>K.value=!1,[`self`])},[_(`div`,Le,[_(`h3`,Re,l(e.$t(`logs.manual`)),1),_(`label`,ze,[_(`span`,null,l(e.$t(`logs.mSummary`))+` *`,1),v(_(`textarea`,{"onUpdate:modelValue":i[8]||=e=>q.summary=e,rows:`3`,placeholder:e.$t(`logs.mSummaryPh`)},null,8,Be),[[r,q.summary]])]),_(`label`,Ve,[_(`span`,null,l(e.$t(`logs.mDetail`)),1),v(_(`textarea`,{"onUpdate:modelValue":i[9]||=e=>q.detail=e,rows:`2`,placeholder:e.$t(`logs.mDetailPh`)},null,8,He),[[r,q.detail]])]),_(`div`,Ue,[_(`label`,We,[_(`span`,null,l(e.$t(`logs.fLine`)),1),v(_(`select`,{"onUpdate:modelValue":i[10]||=e=>q.lineId=e,class:`inp-sel`,onChange:i[11]||=e=>{q.productId=``,q.recipeId=``}},[_(`option`,Ge,l(e.$t(`logs.all`)),1),(o(!0),m(u,null,a(c(H).lines,e=>(o(),m(`option`,{key:e.id,value:e.id},l(e.name),9,Ke))),128))],544),[[n,q.lineId]])]),_(`label`,qe,[_(`span`,null,l(e.$t(`logs.fProduct`)),1),v(_(`select`,{"onUpdate:modelValue":i[12]||=e=>q.productId=e,class:`inp-sel`,onChange:i[13]||=e=>q.recipeId=``},[_(`option`,Je,l(e.$t(`logs.all`)),1),(o(!0),m(u,null,a(J.value,e=>(o(),m(`option`,{key:e.id,value:e.id},l(e.name),9,Ye))),128))],544),[[n,q.productId]])]),_(`label`,Xe,[i[22]||=_(`span`,null,`Recipe`,-1),v(_(`select`,{"onUpdate:modelValue":i[14]||=e=>q.recipeId=e,class:`inp-sel`},[_(`option`,Ze,l(e.$t(`logs.all`)),1),(o(!0),m(u,null,a(Y.value,e=>(o(),m(`option`,{key:e.id,value:e.id},l(e.name),9,Qe))),128))],512),[[n,q.recipeId]])])]),c(U).error.post?(o(),m(`p`,$e,l(c(U).error.post),1)):h(``,!0),_(`div`,et,[_(`button`,{class:`ghost-btn`,onClick:i[15]||=e=>K.value=!1},l(e.$t(`common.cancel`)),1),_(`button`,{class:`pill-btn`,disabled:c(U).loading.posting||!q.summary.trim(),onClick:st},l(e.$t(`logs.mSubmit`)),9,tt)])])])):h(``,!0)]))]))}}),[[`__scopeId`,`data-v-0b613117`]]);export{H as default};