efficient-shell 15.2.0 → 15.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +10 -0
  2. package/dist/{Browser-42QAXKYW.js → Browser-SJKIWRIF.js} +19 -19
  3. package/dist/Calculator-NS2NGCHN.js +29 -0
  4. package/dist/{CurrencyConverter-VFTDSYQ3.js → CurrencyConverter-ES5SWCOZ.js} +9 -9
  5. package/dist/{Files-OAVWF6EW.js → Files-KM3OX5LC.js} +76 -76
  6. package/dist/{Notepad-LNNSVEFG.js → Notepad-VZ2Y3NAY.js} +9 -9
  7. package/dist/PdfViewer-AIAVQYZ6.js +1 -0
  8. package/dist/PomodoroTimer-BRSRBMEG.js +91 -0
  9. package/dist/{Preview-GDNUQKGN.js → Preview-YWS265UV.js} +24 -24
  10. package/dist/Sidebar-KAALEIIX.js +44 -0
  11. package/dist/{Stock-NNDDNQBJ.js → Stock-GMWRXTKR.js} +2 -2
  12. package/dist/{Weather-NGQALCXO.js → Weather-QSQ2TZKG.js} +17 -17
  13. package/dist/{WorldClock-LX4BQPZJ.js → WorldClock-YPP2KHIV.js} +7 -7
  14. package/dist/ai/index.js +42 -42
  15. package/dist/apps/index.js +1 -1
  16. package/dist/bin/browser-check.js +1 -1
  17. package/dist/bin/media-host-check.js +1 -1
  18. package/dist/bin/ui-check.js +1 -1
  19. package/dist/brand.css +1 -1
  20. package/dist/charts/ChordChart.js +1 -1
  21. package/dist/charts/FlowChart.js +1 -1
  22. package/dist/charts/RadarChart.js +1 -1
  23. package/dist/charts/SankeyChart.js +1 -1
  24. package/dist/charts/SpecChart.js +1 -1
  25. package/dist/charts/SunburstChart.js +1 -1
  26. package/dist/charts/TreemapChart.js +1 -1
  27. package/dist/{chunk-ZC2FZLYX.js → chunk-345FP3IX.js} +4 -4
  28. package/dist/chunk-35Q7ZMQD.js +8 -0
  29. package/dist/{chunk-ZYWLX5EK.js → chunk-3AVXNZY5.js} +1 -1
  30. package/dist/chunk-3FININUU.js +1 -0
  31. package/dist/chunk-3H476JWK.js +4 -0
  32. package/dist/{chunk-TWSROAS7.js → chunk-4MDSZSLC.js} +1 -1
  33. package/dist/{chunk-DXTRHNP4.js → chunk-4NTAZLT3.js} +2 -2
  34. package/dist/{chunk-TVMDDQJP.js → chunk-52RSW6TO.js} +1 -1
  35. package/dist/{chunk-26I3OTGP.js → chunk-5B7CLXHC.js} +1 -1
  36. package/dist/{chunk-MDGM5NUO.js → chunk-5CGGHE2O.js} +9 -9
  37. package/dist/{chunk-SXNT73VT.js → chunk-5LB7LCEG.js} +19 -19
  38. package/dist/{chunk-CMC25URA.js → chunk-5LG6TOV6.js} +6 -6
  39. package/dist/{chunk-IIUFCTT6.js → chunk-5OXQ5M5S.js} +1 -1
  40. package/dist/{chunk-AVUH35GW.js → chunk-5QHNDAZ6.js} +1 -1
  41. package/dist/{chunk-52YTUQW3.js → chunk-5QRHQCRG.js} +1 -1
  42. package/dist/{chunk-T43ATI2N.js → chunk-5RCKE4X2.js} +6 -6
  43. package/dist/{chunk-LFGJUJRZ.js → chunk-5Y2JZL3I.js} +13 -13
  44. package/dist/{chunk-QIAJ3QNV.js → chunk-62UNBUTU.js} +1 -1
  45. package/dist/{chunk-NBV3XK3Q.js → chunk-7533CPNQ.js} +3 -3
  46. package/dist/{chunk-HBAATSUS.js → chunk-75NYUMNV.js} +1 -1
  47. package/dist/{chunk-BMZL5BHA.js → chunk-A3RD7AQ2.js} +1 -1
  48. package/dist/chunk-A4ROXNUF.js +2 -0
  49. package/dist/{chunk-2QUACZ6O.js → chunk-A7GOVTCI.js} +1 -1
  50. package/dist/{chunk-PAD65HG7.js → chunk-ABIWAS5K.js} +1 -1
  51. package/dist/{chunk-3TVMQCYR.js → chunk-AKEED2BC.js} +1 -1
  52. package/dist/chunk-APFDZ2HG.js +1 -0
  53. package/dist/{chunk-S3F2TY7X.js → chunk-ASNRA3ZL.js} +1 -1
  54. package/dist/chunk-B36ZROD7.js +8 -0
  55. package/dist/{chunk-QI2LJ7OL.js → chunk-B4Y5NGHR.js} +9 -9
  56. package/dist/{chunk-ZZKBCNK6.js → chunk-BTMZ5MUY.js} +11 -11
  57. package/dist/{chunk-NXPIX7NO.js → chunk-C75ICYHF.js} +1 -1
  58. package/dist/{chunk-JJ5W4BRW.js → chunk-CGX2IGQO.js} +1 -1
  59. package/dist/{chunk-HKXP3JJ5.js → chunk-CHWZGSYG.js} +1 -1
  60. package/dist/{chunk-2MUZFHZW.js → chunk-CIZAUBWA.js} +6 -6
  61. package/dist/{chunk-5JQCWXIQ.js → chunk-CMEPDSYB.js} +1 -1
  62. package/dist/{chunk-JHEHW5BE.js → chunk-D7MRZZVV.js} +3 -3
  63. package/dist/chunk-DEV3ZHPP.js +8 -0
  64. package/dist/chunk-DVKOVZJ2.js +13 -0
  65. package/dist/{chunk-7ZJ7VK2N.js → chunk-EJ5NIA42.js} +1 -1
  66. package/dist/{chunk-M5JEYZ3A.js → chunk-EJMCK7E3.js} +4 -4
  67. package/dist/{chunk-GBCLIWUQ.js → chunk-EULBBS5L.js} +1 -1
  68. package/dist/{chunk-7FYTL6SD.js → chunk-FAPZFMS3.js} +1 -1
  69. package/dist/chunk-FGP2IOFN.js +15 -0
  70. package/dist/{chunk-ABRCV7DQ.js → chunk-FHTL7ZZR.js} +1 -1
  71. package/dist/{chunk-JVITCC65.js → chunk-GGLS6JZ3.js} +1 -1
  72. package/dist/{chunk-KWBYE5MN.js → chunk-GGNQEZ2D.js} +8 -8
  73. package/dist/chunk-GML6FVPA.js +6 -0
  74. package/dist/{chunk-VQ3OSYTA.js → chunk-GUOAPXUY.js} +4 -4
  75. package/dist/{chunk-IJWRJPX6.js → chunk-HU5FTTW2.js} +7 -7
  76. package/dist/{chunk-SKPAIZSC.js → chunk-INQQUAIO.js} +4 -4
  77. package/dist/{chunk-ZQWKVLSY.js → chunk-JGN27L4Q.js} +12 -12
  78. package/dist/{chunk-BN37AISA.js → chunk-JIHDUZJZ.js} +3 -3
  79. package/dist/chunk-JRKD7SD3.js +24 -0
  80. package/dist/{chunk-FYHUCRLU.js → chunk-JWS77LQE.js} +1 -1
  81. package/dist/{chunk-6F3XQJR6.js → chunk-KERCZSIA.js} +1 -1
  82. package/dist/{chunk-ECZEJ6BE.js → chunk-KIIZNION.js} +6 -6
  83. package/dist/{chunk-L664TIIV.js → chunk-KJ4CHRRC.js} +7 -7
  84. package/dist/{chunk-HMTZP7NJ.js → chunk-KTI4ZJVX.js} +1 -1
  85. package/dist/{chunk-VIBGF2HJ.js → chunk-L2WQOJ3T.js} +1 -1
  86. package/dist/{chunk-3CIJFWB4.js → chunk-LFUXWZV7.js} +1 -1
  87. package/dist/{chunk-OCKOZV46.js → chunk-LGVVXYW7.js} +1 -1
  88. package/dist/{chunk-ZS36DB4X.js → chunk-MF7OELXP.js} +2 -2
  89. package/dist/{chunk-OCITNQGF.js → chunk-MQNSKFZY.js} +10 -10
  90. package/dist/{chunk-M6ODRWTM.js → chunk-NJY4HPNB.js} +5 -5
  91. package/dist/{chunk-QBR73AJX.js → chunk-OEWBWKKD.js} +11 -11
  92. package/dist/chunk-OHPDB4UN.js +14 -0
  93. package/dist/{chunk-LKNDLXL3.js → chunk-OHWP24DL.js} +1 -1
  94. package/dist/{chunk-VNKLIWNQ.js → chunk-OK2J6WSC.js} +1 -1
  95. package/dist/{chunk-3HPCQMYH.js → chunk-P56YLT73.js} +12 -12
  96. package/dist/{chunk-VTYALYW4.js → chunk-PCNFY6EK.js} +12 -12
  97. package/dist/{chunk-FM5ASDVN.js → chunk-PM6HY5BH.js} +1 -1
  98. package/dist/{chunk-ABAUJLI4.js → chunk-PO2KNVCC.js} +1 -1
  99. package/dist/chunk-PRN2QDX6.js +7 -0
  100. package/dist/{chunk-7M7GKYHS.js → chunk-QE2F4YQQ.js} +9 -9
  101. package/dist/chunk-QGWUZAG7.js +28 -0
  102. package/dist/{chunk-QJY52ZHG.js → chunk-QSFQTMWV.js} +1 -1
  103. package/dist/{chunk-YVI2XJCB.js → chunk-QSOBETAI.js} +5 -5
  104. package/dist/chunk-QXEZBS3H.js +6 -0
  105. package/dist/{chunk-32HTOZFT.js → chunk-QYOIS4BN.js} +3 -3
  106. package/dist/chunk-R6YVKP6D.js +3 -0
  107. package/dist/chunk-R72SBGYR.js +9 -0
  108. package/dist/{chunk-QMUW35QL.js → chunk-RIA6KKIB.js} +6 -6
  109. package/dist/{chunk-D3L2QCGF.js → chunk-RTZFWH5U.js} +1 -1
  110. package/dist/{chunk-HVWRF7N4.js → chunk-S6C7X6CR.js} +19 -19
  111. package/dist/{chunk-7T6NWAPG.js → chunk-SJUEGYT2.js} +1 -1
  112. package/dist/chunk-T5TKMIV2.js +1 -0
  113. package/dist/{chunk-JE4BGFDJ.js → chunk-TAB3K2WF.js} +1 -1
  114. package/dist/{chunk-4H4HJIWI.js → chunk-TAIH2VIW.js} +1 -1
  115. package/dist/{chunk-NTVACRKD.js → chunk-TALQMTCE.js} +3 -3
  116. package/dist/{chunk-KKZXGWSX.js → chunk-TEYG2W7A.js} +2 -2
  117. package/dist/{chunk-FZZBBZXZ.js → chunk-TMXMIRWG.js} +8 -8
  118. package/dist/{chunk-J43RRDEP.js → chunk-TSZPGDU3.js} +1 -1
  119. package/dist/{chunk-T65TAQLW.js → chunk-TXGVSWH6.js} +13 -13
  120. package/dist/{chunk-UA7SWROJ.js → chunk-U7PA4KNZ.js} +3 -3
  121. package/dist/{chunk-2M3KB4RH.js → chunk-UYM7562M.js} +2 -2
  122. package/dist/{chunk-JFTLFF52.js → chunk-V62FEHS4.js} +3 -3
  123. package/dist/{chunk-QQ6TGD7K.js → chunk-VANF2TL3.js} +47 -47
  124. package/dist/{chunk-PYGXSGXC.js → chunk-VB4ZPIZF.js} +1 -1
  125. package/dist/{chunk-K3OLOLFT.js → chunk-VHBRVW5O.js} +3 -3
  126. package/dist/chunk-W7HTHKN2.js +19 -0
  127. package/dist/{chunk-5R25GNE2.js → chunk-WNHDYTTI.js} +2 -2
  128. package/dist/{chunk-WHHHECBC.js → chunk-WSQ73CRR.js} +2 -2
  129. package/dist/{chunk-M4NT6HGJ.js → chunk-YEDAXZYO.js} +1 -1
  130. package/dist/{chunk-ILH7RDAD.js → chunk-YGNJIOOH.js} +10 -10
  131. package/dist/{chunk-C5Q4AKXO.js → chunk-YXMXATYP.js} +1 -1
  132. package/dist/{chunk-OEZC5N6J.js → chunk-ZVKUOJNS.js} +1 -1
  133. package/dist/data/DataTable.js +1 -1
  134. package/dist/data/EntityList.js +1 -1
  135. package/dist/data/Gantt.js +1 -1
  136. package/dist/data/ListLoadError.js +1 -1
  137. package/dist/data/ListToolbar.js +1 -1
  138. package/dist/data/ResizableTable.js +1 -1
  139. package/dist/data/statusColumn.js +1 -1
  140. package/dist/forms/AlignmentGrid.js +1 -1
  141. package/dist/forms/BorderInput.js +1 -1
  142. package/dist/forms/BrandAssetEditor.js +1 -1
  143. package/dist/forms/Button.js +1 -1
  144. package/dist/forms/ColorPicker.js +1 -1
  145. package/dist/forms/ComposerAttachments.js +1 -1
  146. package/dist/forms/CornersInput.js +1 -1
  147. package/dist/forms/DatePicker.js +1 -1
  148. package/dist/forms/DateRangePicker.js +1 -1
  149. package/dist/forms/DisplayChips.js +1 -1
  150. package/dist/forms/FilePicker.js +1 -1
  151. package/dist/forms/IconButton.js +1 -1
  152. package/dist/forms/IconPicker.js +1 -1
  153. package/dist/forms/Input.js +1 -1
  154. package/dist/forms/InputNumber.js +1 -1
  155. package/dist/forms/LinkPicker.js +1 -1
  156. package/dist/forms/MediaLibrary.js +1 -1
  157. package/dist/forms/MediaUploadField.js +1 -1
  158. package/dist/forms/MediaUploadGrid.js +1 -1
  159. package/dist/forms/MediaUsedInList.js +1 -1
  160. package/dist/forms/NumericKeypad.js +1 -1
  161. package/dist/forms/PictureTiles.js +1 -1
  162. package/dist/forms/PositionInput.js +1 -1
  163. package/dist/forms/RenameField.js +1 -1
  164. package/dist/forms/SearchInput.js +1 -1
  165. package/dist/forms/Segmented.js +1 -1
  166. package/dist/forms/Select.d.ts +6 -5
  167. package/dist/forms/Select.js +1 -1
  168. package/dist/forms/SidesInput.js +1 -1
  169. package/dist/forms/Slider.js +1 -1
  170. package/dist/forms/Snippet.js +1 -1
  171. package/dist/forms/SplitButton.js +1 -1
  172. package/dist/forms/TagInput.js +1 -1
  173. package/dist/forms/TextToolbar.js +1 -1
  174. package/dist/forms/UnitMenu.js +1 -1
  175. package/dist/forms/WidthsBar.js +1 -1
  176. package/dist/index.d.ts +1 -0
  177. package/dist/index.js +381 -381
  178. package/dist/map/index.js +5 -5
  179. package/dist/optionItems-Cxd85rTy.d.ts +26 -0
  180. package/dist/page-tabs/index.js +5 -5
  181. package/dist/pdf/index.js +1 -1
  182. package/dist/routine-index.json +1 -1
  183. package/dist/shell/AppUpdateBanner.js +1 -1
  184. package/dist/shell/ColoredBadge.js +1 -1
  185. package/dist/shell/ConfirmDialog.js +1 -1
  186. package/dist/shell/ContextMenu.js +1 -1
  187. package/dist/shell/Dialog.js +1 -1
  188. package/dist/shell/Drawer.js +1 -1
  189. package/dist/shell/DropdownMenu.js +1 -1
  190. package/dist/shell/EditableGrid.js +1 -1
  191. package/dist/shell/FloatingBar.js +1 -1
  192. package/dist/shell/GlobalSearch.js +1 -1
  193. package/dist/shell/HelpCenter.js +1 -1
  194. package/dist/shell/IconRail.js +1 -1
  195. package/dist/shell/ImageLightbox.js +1 -1
  196. package/dist/shell/ItemCount.js +1 -1
  197. package/dist/shell/LanguageSelect.js +1 -1
  198. package/dist/shell/Markdown.js +1 -1
  199. package/dist/shell/Popover.js +1 -1
  200. package/dist/shell/PopupMenu.js +1 -1
  201. package/dist/shell/ResizeHandle.js +1 -1
  202. package/dist/shell/SearchableSelect.d.ts +3 -9
  203. package/dist/shell/SearchableSelect.js +1 -1
  204. package/dist/shell/SettingReset.js +1 -1
  205. package/dist/shell/SidebarLayout.js +1 -1
  206. package/dist/shell/SidebarNav.js +1 -1
  207. package/dist/shell/SortableList.js +1 -1
  208. package/dist/shell/StatusBadge.js +1 -1
  209. package/dist/shell/Tabs.js +1 -1
  210. package/dist/shell/Tooltip.js +1 -1
  211. package/dist/shell/TopNav.js +1 -1
  212. package/dist/shell/TransferProgress.js +1 -1
  213. package/dist/shell/Tree.js +1 -1
  214. package/dist/shell/discardGuard.js +1 -1
  215. package/dist/telemetry/index.js +1 -1
  216. package/dist/templates/AuthScreen.js +1 -1
  217. package/dist/templates/ChatTemplate.js +1 -1
  218. package/dist/templates/CheckoutTemplate.js +1 -1
  219. package/dist/templates/DashboardTemplate.js +1 -1
  220. package/dist/templates/DataTablePage.js +1 -1
  221. package/dist/templates/EmailTemplate.js +1 -1
  222. package/dist/templates/ErrorBoundary.js +1 -1
  223. package/dist/templates/FormLayoutPage.js +1 -1
  224. package/dist/templates/GalleryTemplate.js +1 -1
  225. package/dist/ui/index.d.ts +1 -0
  226. package/dist/ui/index.js +1 -1
  227. package/dist/ui.css +0 -1
  228. package/dist/value-index.json +1 -1
  229. package/dist/version.js +1 -1
  230. package/package.json +1 -1
  231. package/dist/Calculator-C7APPCLE.js +0 -29
  232. package/dist/PdfViewer-ADPTYOAO.js +0 -1
  233. package/dist/PomodoroTimer-AGSHX2JO.js +0 -91
  234. package/dist/Sidebar-SWLVNJ6L.js +0 -44
  235. package/dist/chunk-7QFXUNFA.js +0 -8
  236. package/dist/chunk-7YJBWOQG.js +0 -2
  237. package/dist/chunk-CIT4YPEO.js +0 -8
  238. package/dist/chunk-DTZDOXK3.js +0 -19
  239. package/dist/chunk-EQDYCSUX.js +0 -13
  240. package/dist/chunk-IBPJJO4N.js +0 -28
  241. package/dist/chunk-K5YT5PMJ.js +0 -5
  242. package/dist/chunk-M6T7N4SN.js +0 -14
  243. package/dist/chunk-MQERW3QR.js +0 -3
  244. package/dist/chunk-NJJG2VAW.js +0 -24
  245. package/dist/chunk-QVGASI5H.js +0 -9
  246. package/dist/chunk-QZYV4TDD.js +0 -1
  247. package/dist/chunk-S6IW2F4J.js +0 -8
  248. package/dist/chunk-TB7BO2XS.js +0 -6
  249. package/dist/chunk-UMLXFQVC.js +0 -1
  250. package/dist/chunk-XQMVECQM.js +0 -15
  251. package/dist/chunk-YX4QGW7Z.js +0 -4
  252. package/dist/chunk-Z2MP46QJ.js +0 -1
  253. package/dist/chunk-ZUQ72WER.js +0 -7
  254. /package/dist/{chunk-LPQQNPH5.js → chunk-TEQ5ZPAL.js} +0 -0
@@ -0,0 +1,91 @@
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-A7GOVTCI.js";import{subscribePomo as o,getPomoSnapshot as n,setPomoDurations as a,setPomoAlarm as r,setPomoAlarmConfig as s,setPomoBehaviour as i,setPomoFocusSound as l,useTodoTasks as c,pomodoroToday as u,migratePomodoroTasksOnce as m,pomoSwitchMode as d,pomoPause as h,pomoStart as p,ALARM_OPTIONS as g,playAlarm as k,FOCUS_SOUND_OPTIONS as f,previewFocusSound as b}from"./chunk-GUUBFQ6L.js";import{PLACEHOLDER_INK as x}from"./chunk-AYZY3YNC.js";import{formatTime as v}from"./chunk-NHKT5IH6.js";import"./chunk-36BRD5J3.js";import"./chunk-JRQMX4PK.js";import{pad2 as y}from"./chunk-LF27WIN2.js";import{useWidgetSettings as N}from"./chunk-VANF2TL3.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-PSVGB7KT.js";import"./chunk-YI4T5I5D.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-JRKD7SD3.js";import"./chunk-5RCKE4X2.js";import"./chunk-EIFNESXS.js";import"./chunk-PO2KNVCC.js";import"./chunk-CJ4OEY3T.js";import"./chunk-5QHNDAZ6.js";import"./chunk-TEQ5ZPAL.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-L2WQOJ3T.js";import"./chunk-SH7PJC4P.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import{useShellPrefs as C}from"./chunk-POBVGDZP.js";import"./chunk-NJY4HPNB.js";import"./chunk-PM6HY5BH.js";import"./chunk-DWGYC7OD.js";import"./chunk-APFDZ2HG.js";import"./chunk-ABIWAS5K.js";import"./chunk-P56YLT73.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-A4ROXNUF.js";import"./chunk-TSZPGDU3.js";import{Icon as j}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-FAPZFMS3.js";import"./chunk-CIZAUBWA.js";import"./chunk-PGN5ME7B.js";import"./chunk-5QRHQCRG.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-3FININUU.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-I2NVBDKH.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useSyncExternalStore as S,useEffect as w,useMemo as B,useState as T,useRef as M,useCallback as P}from"react";import{jsxs as I,Fragment as A,jsx as D}from"react/jsx-runtime";var V="pomodoro_appearance",R="pomodoro_active_task_id",L={focus:"Pomodoro",short:"Short Break",long:"Long Break"},F={focus:"#0f172a",short:"#508a52",long:"#5b7898"};var H=25,W=5,Z=15,$=!1,J=!1,U=4,G=!0,Q=!0,Y="bell",E=100,K=1,O="none",X=50,_=(e,t,o,n)=>"number"==typeof e&&isFinite(e)?Math.max(t,Math.min(o,Math.round(e))):n;function z(){const t=S(o,n,n),{prefs:k,save:b}=C(),x=function(e){const t=e&&"object"==typeof e?e:{};return{focusMinutes:_(t.focusMinutes,1,120,H),shortBreakMinutes:_(t.shortBreakMinutes,1,120,W),longBreakMinutes:_(t.longBreakMinutes,1,120,Z),autoStartBreaks:"boolean"==typeof t.autoStartBreaks?t.autoStartBreaks:$,autoStartPomodoros:"boolean"==typeof t.autoStartPomodoros?t.autoStartPomodoros:J,longBreakInterval:_(t.longBreakInterval,1,20,U),autoCheckTasks:"boolean"==typeof t.autoCheckTasks?t.autoCheckTasks:G,checkToBottom:"boolean"==typeof t.checkToBottom?t.checkToBottom:Q,alarmSound:g.some(e=>e.id===t.alarmSound)?t.alarmSound:Y,alarmVolume:_(t.alarmVolume,0,100,E),alarmRepeat:_(t.alarmRepeat,1,5,K),focusSound:f.some(e=>e.id===t.focusSound)?t.focusSound:O,focusVolume:_(t.focusVolume,0,100,X)}}(k.pomodoro_settings);w(()=>{a({focus:60*x.focusMinutes,short:60*x.shortBreakMinutes,long:60*x.longBreakMinutes})},[x.focusMinutes,x.shortBreakMinutes,x.longBreakMinutes]),w(()=>{r(x.alarmSound),s(x.alarmVolume,x.alarmRepeat)},[x.alarmSound,x.alarmVolume,x.alarmRepeat]),w(()=>{i({autoStartBreaks:x.autoStartBreaks,autoStartPomodoros:x.autoStartPomodoros,longBreakInterval:x.longBreakInterval})},[x.autoStartBreaks,x.autoStartPomodoros,x.longBreakInterval]),w(()=>{l(x.focusSound,x.focusVolume)},[x.focusSound,x.focusVolume]),w(()=>{if("undefined"!=typeof Notification&&"default"===Notification.permission)try{Notification.requestPermission()}catch{}},[]);const z=c(),ee=z.tasks,te=B(()=>u(),[]),oe=function(e,t){return B(()=>t?(e=>{const t=[],o=[];for(const n of e)(n.done?o:t).push(n);return[...t,...o]})(e):e,[e,t])}(B(()=>ee.filter(e=>!!e.dueDate&&(e.dueDate===te||e.dueDate<te&&!e.done)),[ee,te]),x.checkToBottom),[ne,ae]=T(()=>localStorage.getItem(R)),[re,se]=T(!1),[ie,le]=T(null),ce=M(!1);w(()=>{ce.current||(ce.current=!0,m(ee,z.setAllTasks))},[]),w(()=>{try{ne?localStorage.setItem(R,ne):localStorage.removeItem(R)}catch{}},[ne]),w(()=>{if(!ie)return;const e=()=>le(null),t=setTimeout(()=>document.addEventListener("click",e),0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[ie]);const ue=M(t.streak);w(()=>{if(t.streak>ue.current&&ne){const e=ee.find(e=>e.id===ne);if(e){const t=(e.completed??0)+1,o=e.estimated??0,n=x.autoCheckTasks&&o>0&&t>=o;z.updateTask(ne,{completed:t,done:e.done||n})}}ue.current=t.streak},[t.streak,ne,x.autoCheckTasks,ee,z]);const de=oe.reduce((e,t)=>e+(t.completed??0),0),he=oe.reduce((e,t)=>e+Math.max(t.estimated??0,t.completed??0),0),pe=oe.reduce((e,t)=>t.done?e:e+Math.max(0,(t.estimated??0)-(t.completed??0)),0),ge=t.running&&"focus"===t.mode?t.remaining:0,ke=pe*x.focusMinutes*60+ge,fe=new Date(Date.now()+1e3*ke),be=v(fe.toISOString(),{clock:{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}}),xe=(ke/3600).toFixed(1),ve=ne?ee.find(e=>e.id===ne)??null:null,ye=y(Math.floor(t.remaining/60)),Ne=y(t.remaining%60),[Ce,je]=T(()=>e(V)),[Se,we]=T(!1),[Be,Te]=T(Ce),[Me,Pe]=T(x);N(P(()=>{Te({...Ce}),Pe({...x}),we(!0)},[Ce,x]));const Ie="focus"!==t.mode,Ae=F[t.mode],De=Ie?(Ve=Ae,Re=Ce.activeOpacity/100,`rgba(${parseInt(Ve.slice(1,3),16)}, ${parseInt(Ve.slice(3,5),16)}, ${parseInt(Ve.slice(5,7),16)}, ${Re})`):`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${Ce.activeOpacity/100})`;var Ve,Re;const Le={primary:Ie?"text-white":"text-gray-900",secondary:Ie?"text-white/85":"text-gray-700",muted:Ie?"text-white/65":"text-gray-500",tabActive:Ie?"bg-white/15 text-white":"bg-gray-200 text-gray-900",tabInactive:Ie?"text-white/75 hover:bg-white/10":"text-gray-500 hover:bg-gray-200",divider:Ie?"border-white/30":"border-gray-200",softDivider:Ie?"border-white/20":"border-gray-200",iconBtn:Ie?"bg-black/15 hover:bg-black/25 text-white/85":"bg-gray-200 hover:bg-gray-300 text-gray-600",addTaskBtn:Ie?"border-white/45 text-white/90 hover:bg-white/[0.06]":"border-gray-300 text-gray-500 hover:bg-gray-200/50"},Fe=Ie?Ae:"#0f172a";/* @__PURE__ */
2
+ return I(A,{children:[
3
+ /* @__PURE__ */I("div",{className:`flex flex-col h-full select-none transition-colors duration-300 ${Le.primary}`,style:{backgroundColor:De,backdropFilter:Ce.activeBlur>0?`blur(${Ce.activeBlur}px)`:void 0},children:[
4
+ /* @__PURE__ */D("div",{className:"px-3 pt-3 flex justify-center gap-2",children:["focus","short","long"].map(e=>/* @__PURE__ */D("button",{onClick:()=>d(e),className:`px-3 py-1 text-sm font-bold rounded transition-colors ${t.mode===e?Le.tabActive:Le.tabInactive}`,children:L[e]},e))}),
5
+ /* @__PURE__ */I("div",{className:"text-center font-bold tabular-nums leading-none tracking-tight mt-3",style:{fontSize:"4.5rem"},children:[ye,":",Ne]}),
6
+ /* @__PURE__ */D("div",{className:"flex justify-center mt-3 mb-2",children:/* @__PURE__ */D("button",{onClick:()=>t.running?h():p(),className:"bg-surface px-12 py-3 rounded-md font-bold text-base shadow-[0_4px_0_rgba(0,0,0,0.12)] hover:shadow-[0_3px_0_rgba(0,0,0,0.12)] active:translate-y-1 active:shadow-none transition-all",style:{color:Fe,letterSpacing:"0.08em"},children:t.running?"PAUSE":"START"})}),
7
+ /* @__PURE__ */D("div",{className:"px-3 py-3 text-center",children:ve?/* @__PURE__ */I(A,{children:[
8
+ /* @__PURE__ */I("div",{className:`text-xs leading-tight ${Le.muted}`,children:["#",(ve.completed??0)+1]}),
9
+ /* @__PURE__ */D("div",{className:`text-base font-medium leading-tight truncate mt-0.5 ${Le.primary}`,children:ve.name})]}):/* @__PURE__ */D("div",{className:`text-xs italic ${Le.muted}`,children:"No task selected"})}),
10
+ /* @__PURE__ */I("div",{className:"px-3 mt-1 flex items-center justify-between",children:[
11
+ /* @__PURE__ */D("h3",{className:`text-base font-bold tracking-tight ${Le.primary}`,children:"Tasks"}),
12
+ /* @__PURE__ */D("button",{className:`rounded p-1 transition-colors ${Le.iconBtn}`,"aria-label":"Tasks menu",tabIndex:-1,children:/* @__PURE__ */D(j,{name:"more-vertical",look:"solid",className:"h-4 w-4"})})]}),
13
+ /* @__PURE__ */D("div",{className:`border-t mx-3 mt-2 ${Le.divider}`}),
14
+ /* @__PURE__ */I("div",{className:"flex-1 px-3 py-3 space-y-2 overflow-y-auto",children:[oe.map(e=>{const t=e.id===ne;/* @__PURE__ */
15
+ return I("div",{onClick:()=>ae(e.id),className:"bg-surface text-ink-strong rounded-md flex items-center pr-2 py-3 shadow-sm cursor-pointer transition-shadow hover:shadow-(--elevation-panel) "+(t?"border-l-4 border-gray-700 pl-2":"pl-3 border-l-4 border-transparent"),children:[
16
+ /* @__PURE__ */D("button",{onClick:t=>{var o;t.stopPropagation(),o=e.id,z.toggleDone(o)},className:"shrink-0",children:e.done?/* @__PURE__ */D("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",style:{color:Fe},children:/* @__PURE__ */D("path",{d:"M10 0a10 10 0 100 20 10 10 0 000-20zm-1 14.5l-4.5-4.5 1.4-1.4 3.1 3.1 6.1-6.1 1.4 1.4z"})}):/* @__PURE__ */D("svg",{className:"h-5 w-5 text-gray-300",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:/* @__PURE__ */D("circle",{cx:"12",cy:"12",r:"10"})})}),
17
+ /* @__PURE__ */D("span",{className:"ml-3 flex-1 font-semibold truncate "+(e.done?"line-through text-gray-400":"text-gray-800"),children:e.name}),
18
+ /* @__PURE__ */I("span",{className:"text-sm tabular-nums mr-2 shrink-0",children:[
19
+ /* @__PURE__ */D("span",{className:"font-bold text-gray-500",children:e.completed??0}),
20
+ /* @__PURE__ */D("span",{className:"text-gray-400",children:" / "}),
21
+ /* @__PURE__ */D("span",{className:"text-gray-400",children:e.estimated??"–"})]}),
22
+ /* @__PURE__ */I("div",{className:"relative",children:[
23
+ /* @__PURE__ */D("button",{onClick:t=>{t.stopPropagation(),le(ie===e.id?null:e.id)},className:"rounded p-1 bg-gray-100 hover:bg-gray-200",children:/* @__PURE__ */D(j,{name:"more-vertical",look:"solid",className:"h-4 w-4 text-ink-faint"})}),ie===e.id&&/* @__PURE__ */D("div",{className:"absolute right-0 top-full mt-1 bg-white text-gray-800 rounded shadow-lg border border-gray-200 z-10 min-w-[110px] overflow-hidden",onClick:e=>e.stopPropagation(),children:/* @__PURE__ */D("button",{onClick:t=>{var o;t.stopPropagation(),o=e.id,z.removeTask(o),ne===o&&ae(null),le(null)},className:"block w-full px-3 h-8 text-sm text-left hover:bg-red-50 text-red-600",children:"Delete"})})]})]},e.id)}),re?/* @__PURE__ */D(me,{onSubmit:(e,t)=>{const o=e.trim();if(!o)return;const n=z.addTask({name:o,estimated:t,completed:0,dueDate:te});ne||ae(n),se(!1)},onCancel:()=>se(!1),accentColor:Fe}):/* @__PURE__ */I("button",{onClick:()=>se(!0),className:`w-full border-2 border-dashed rounded-md py-3 font-semibold flex items-center justify-center gap-2 transition-colors ${Le.addTaskBtn}`,children:[
24
+ /* @__PURE__ */D(j,{name:"add-circle",className:"h-5 w-5",strokeWidth:2}),"Add Task"]})]}),
25
+ /* @__PURE__ */I("div",{className:`border-t px-3 py-3 flex items-center justify-center gap-5 text-sm ${Le.softDivider}`,children:[
26
+ /* @__PURE__ */I("span",{className:Le.secondary,children:["Pomos: ",
27
+ /* @__PURE__ */D("span",{className:`font-bold ${Le.primary}`,children:de}),
28
+ /* @__PURE__ */D("span",{className:Le.muted,children:" / "}),
29
+ /* @__PURE__ */D("span",{className:`font-bold ${Le.primary}`,children:he})]}),ke>0&&/* @__PURE__ */I("span",{className:Le.secondary,children:["Finish At: ",
30
+ /* @__PURE__ */D("span",{className:`font-bold ${Le.primary}`,children:be}),
31
+ /* @__PURE__ */I("span",{className:Le.muted,children:[" (",xe,"h)"]})]})]})]}),
32
+ /* @__PURE__ */D(q,{open:Se,onClose:()=>we(!1),onSave:()=>{je(Be),localStorage.setItem(V,JSON.stringify(Be)),b({pomodoro_settings:Me}),we(!1)},configAppearance:Be,setConfigAppearance:Te,configPrefs:Me,setConfigPrefs:Pe})]})}function q({open:e,onClose:o,onSave:n,configAppearance:a,setConfigAppearance:r,configPrefs:s,setConfigPrefs:i}){const l=(e,t)=>i(o=>({...o,[e]:t}));/* @__PURE__ */
33
+ return I(t,{open:e,onClose:o,title:"Pomodoro Settings",appearance:a,onAppearanceChange:r,onSave:n,children:[
34
+ /* @__PURE__ */I(ee,{icon:/* @__PURE__ */D(le,{}),label:"TIMER",children:[
35
+ /* @__PURE__ */I("div",{children:[
36
+ /* @__PURE__ */D("p",{className:"text-sm font-bold text-gray-800 mb-2",children:"Time (minutes)"}),
37
+ /* @__PURE__ */I("div",{className:"grid grid-cols-3 gap-3",children:[
38
+ /* @__PURE__ */D(ne,{label:"Pomodoro",value:s.focusMinutes,onChange:e=>l("focusMinutes",e),max:120}),
39
+ /* @__PURE__ */D(ne,{label:"Short Break",value:s.shortBreakMinutes,onChange:e=>l("shortBreakMinutes",e),max:120}),
40
+ /* @__PURE__ */D(ne,{label:"Long Break",value:s.longBreakMinutes,onChange:e=>l("longBreakMinutes",e),max:120})]})]}),
41
+ /* @__PURE__ */D(te,{label:"Auto Start Breaks",children:/* @__PURE__ */D(se,{checked:s.autoStartBreaks,onChange:e=>l("autoStartBreaks",e)})}),
42
+ /* @__PURE__ */D(te,{label:"Auto Start Pomodoros",children:/* @__PURE__ */D(se,{checked:s.autoStartPomodoros,onChange:e=>l("autoStartPomodoros",e)})}),
43
+ /* @__PURE__ */D(te,{label:"Long Break interval",children:/* @__PURE__ */D(ae,{value:s.longBreakInterval,onChange:e=>l("longBreakInterval",e),min:1,max:20,className:"w-14 text-center"})})]}),
44
+ /* @__PURE__ */I(ee,{icon:/* @__PURE__ */D(ce,{}),label:"TASK",children:[
45
+ /* @__PURE__ */D(te,{label:"Auto Check Tasks",info:'If you enable "Auto Check Tasks", the active task will be automatically checked when the actual pomodoro count reaches the estimated count.',children:/* @__PURE__ */D(se,{checked:s.autoCheckTasks,onChange:e=>l("autoCheckTasks",e)})}),
46
+ /* @__PURE__ */D(te,{label:"Check to Bottom",info:'If you enable "Check to Bottom", the checked task will be automatically moved to the bottom of the task list.',children:/* @__PURE__ */D(se,{checked:s.checkToBottom,onChange:e=>l("checkToBottom",e)})})]}),
47
+ /* @__PURE__ */I(ee,{icon:/* @__PURE__ */D(ue,{}),label:"SOUND",children:[
48
+ /* @__PURE__ */D(te,{label:"Alarm Sound",children:/* @__PURE__ */I("div",{className:"flex items-center gap-2",children:[
49
+ /* @__PURE__ */D(re,{value:s.alarmSound,onChange:e=>l("alarmSound",e),options:g.map(e=>({id:e.id,label:e.label}))}),"off"!==s.alarmSound&&/* @__PURE__ */D("button",{type:"button",onClick:()=>k(s.alarmSound,{volume:s.alarmVolume,repeat:1}),className:"px-2 py-1 text-2xs rounded border border-line-strong text-gray-600 hover:bg-gray-100",children:"Play"})]})}),
50
+ /* @__PURE__ */D(oe,{value:s.alarmVolume,onChange:e=>l("alarmVolume",e)}),
51
+ /* @__PURE__ */D(te,{label:"repeat",children:/* @__PURE__ */D(ae,{value:s.alarmRepeat,onChange:e=>l("alarmRepeat",e),min:1,max:5,className:"w-14 text-center"})}),
52
+ /* @__PURE__ */D(te,{label:"Focus Sound",children:/* @__PURE__ */I("div",{className:"flex items-center gap-2",children:[
53
+ /* @__PURE__ */D(re,{value:s.focusSound,onChange:e=>l("focusSound",e),options:f}),"none"!==s.focusSound&&/* @__PURE__ */D("button",{type:"button",onClick:()=>b(s.focusSound,s.focusVolume),className:"px-2 py-1 text-2xs rounded border border-line-strong text-gray-600 hover:bg-gray-100",children:"Play"})]})}),
54
+ /* @__PURE__ */D(oe,{value:s.focusVolume,onChange:e=>l("focusVolume",e)})]})]})}function ee({icon:e,label:t,children:o}){/* @__PURE__ */
55
+ return I("div",{className:"border-t border-gray-200 pt-3 first:border-0 first:pt-0",children:[
56
+ /* @__PURE__ */I("div",{className:"flex items-center gap-2 mb-3 text-ink-faintest",children:[e,
57
+ /* @__PURE__ */D("span",{className:"text-xs font-bold tracking-[0.15em]",children:t})]}),
58
+ /* @__PURE__ */D("div",{className:"space-y-3",children:o})]})}function te({label:e,info:t,children:o}){/* @__PURE__ */
59
+ return I("div",{className:"flex items-center justify-between gap-3",children:[
60
+ /* @__PURE__ */I("div",{className:"flex items-center gap-2 min-w-0",children:[
61
+ /* @__PURE__ */D("span",{className:"text-sm font-semibold text-gray-800",children:e}),t&&/* @__PURE__ */D(ie,{title:t})]}),
62
+ /* @__PURE__ */D("div",{className:"shrink-0",children:o})]})}function oe({value:e,onChange:t}){/* @__PURE__ */
63
+ return I("div",{className:"flex items-center justify-end gap-3",children:[
64
+ /* @__PURE__ */D("span",{className:"text-xs text-gray-400 w-7 text-right tabular-nums",children:e}),
65
+ /* @__PURE__ */D("input",{type:"range",min:0,max:100,value:e,onChange:e=>t(parseInt(e.target.value,10)),className:"w-40 accent-blue-500"})]})}function ne({label:e,value:t,onChange:o,min:n=1,max:a=99}){/* @__PURE__ */
66
+ return I("label",{className:"flex flex-col",children:[
67
+ /* @__PURE__ */D("span",{className:"text-xs font-semibold text-gray-500 mb-1",children:e}),
68
+ /* @__PURE__ */D(ae,{value:t,onChange:o,min:n,max:a})]})}function ae({value:e,onChange:t,min:o=1,max:n=99,className:a=""}){/* @__PURE__ */
69
+ return D("input",{type:"number",min:o,max:n,value:e,onChange:e=>t(Math.max(o,Math.min(n,parseInt(e.target.value,10)||o))),className:`bg-gray-100 border-0 rounded-md px-2 h-8 text-sm font-medium text-ink-strong focus:outline-none focus:ring-2 focus:ring-blue-500 w-full ${a}`})}function re({value:e,onChange:t,options:o}){/* @__PURE__ */
70
+ return I("div",{className:"relative",children:[
71
+ /* @__PURE__ */D("select",{value:e,onChange:e=>t(e.target.value),className:"appearance-none bg-gray-100 border-0 rounded-md pl-3 pr-8 h-8 text-sm font-medium text-ink-strong focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer",children:o.map(e=>/* @__PURE__ */D("option",{value:e.id,children:e.label},e.id))}),
72
+ /* @__PURE__ */D(j,{name:"chevron-down",className:`absolute right-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 pointer-events-none ${x}`,strokeWidth:2.5})]})}function se({checked:e,onChange:t}){/* @__PURE__ */
73
+ return D("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(!e),className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors "+(e?"bg-emerald-500":"bg-gray-300"),children:/* @__PURE__ */D("span",{className:"absolute h-5 w-5 rounded-full bg-white shadow transition-transform "+(e?"translate-x-[22px]":"translate-x-0.5")})})}function ie({title:e}){/* @__PURE__ */
74
+ return D("span",{title:e,className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-gray-300 text-on-accent text-3xs font-bold cursor-help",children:"i"})}function le(){/* @__PURE__ */
75
+ return I("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
76
+ /* @__PURE__ */D("circle",{cx:"12",cy:"12",r:"9"}),
77
+ /* @__PURE__ */D("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7v5l3 2"})]})}function ce(){/* @__PURE__ */
78
+ return I("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
79
+ /* @__PURE__ */D("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),
80
+ /* @__PURE__ */D("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4"})]})}function ue(){/* @__PURE__ */
81
+ return I("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
82
+ /* @__PURE__ */D("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5L6 9H2v6h4l5 4V5z"}),
83
+ /* @__PURE__ */D("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.5 8.5a5 5 0 010 7M19 5a9 9 0 010 14"})]})}function me({onSubmit:e,onCancel:t,accentColor:o}){const[n,a]=T(""),[r,s]=T(1),i=()=>e(n,r);/* @__PURE__ */
84
+ return I("div",{className:"bg-surface text-ink-strong rounded-md p-3 shadow-(--elevation-panel)",children:[
85
+ /* @__PURE__ */D("input",{autoFocus:!0,value:n,onChange:e=>a(e.target.value),placeholder:"What are you working on?",onKeyDown:e=>{"Enter"===e.key&&i(),"Escape"===e.key&&t()},className:"w-full text-base font-medium bg-transparent border-0 outline-none placeholder-gray-400"}),
86
+ /* @__PURE__ */I("div",{className:"flex items-center justify-between mt-2",children:[
87
+ /* @__PURE__ */D("span",{className:"text-xs font-semibold text-gray-500",children:"Est Pomodoros"}),
88
+ /* @__PURE__ */D("input",{type:"number",min:1,max:20,value:r,onChange:e=>s(Math.max(1,Math.min(20,parseInt(e.target.value,10)||1))),className:"w-16 bg-gray-100 rounded px-2 py-1 text-sm text-right border-0 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),
89
+ /* @__PURE__ */I("div",{className:"flex gap-2 mt-3 justify-end",children:[
90
+ /* @__PURE__ */D("button",{onClick:t,className:"px-3 py-1 text-sm text-gray-500 hover:bg-gray-100 rounded",children:"Cancel"}),
91
+ /* @__PURE__ */D("button",{onClick:i,className:"px-4 py-1 text-sm font-semibold text-white rounded shadow-sm",style:{backgroundColor:o},children:"Save"})]})]})}export{z as default};
@@ -1,14 +1,14 @@
1
- import{PdfViewer as e,ToolbarSlotContext as t,PanelActions as n}from"./chunk-QBR73AJX.js";import{ImageAnnotator_default as r}from"./chunk-TDUOBP55.js";import{AboutApp as s}from"./chunk-NBV3XK3Q.js";import{peekPdfPreviewStage as i,claimPdfPreviewStage as o,PDF_PREVIEW_UPDATE_EVENT as a,previewStepForKey as l}from"./chunk-I4RJAMLJ.js";import{WindowTitle as c}from"./chunk-QQ6TGD7K.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-PSVGB7KT.js";import"./chunk-YI4T5I5D.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-NJJG2VAW.js";import"./chunk-T43ATI2N.js";import"./chunk-EIFNESXS.js";import"./chunk-ABAUJLI4.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AVUH35GW.js";import"./chunk-LPQQNPH5.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-VIBGF2HJ.js";import"./chunk-SH7PJC4P.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import{getActiveModalId as d}from"./chunk-F3ZOO23R.js";import"./chunk-Z2MP46QJ.js";import"./chunk-M6ODRWTM.js";import"./chunk-FM5ASDVN.js";import"./chunk-DWGYC7OD.js";import{IconButton_default as u}from"./chunk-QZYV4TDD.js";import"./chunk-PAD65HG7.js";import"./chunk-3HPCQMYH.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-7YJBWOQG.js";import"./chunk-J43RRDEP.js";import{Icon as p}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import{SpinnerRing as m,LoadingSpinner as h}from"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-7FYTL6SD.js";import"./chunk-2MUZFHZW.js";import"./chunk-PGN5ME7B.js";import"./chunk-52YTUQW3.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-UMLXFQVC.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import{toast_default as f}from"./chunk-I2NVBDKH.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import{registerModalEscapeInterceptor as x}from"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import{useShellStrings as y,splitAround as g}from"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useRef as b,useState as w,useEffect as v}from"react";import{jsxs as k,jsx as N,Fragment as C}from"react/jsx-runtime";var A=!1;function E(e,t){return e?.url&&e.url!==t.url&&e.url.startsWith("blob:")&&URL.revokeObjectURL(e.url),t}function L(){const n=b(void 0);void 0===n.current&&(n.current=i());const[r,m]=w(n.current?.data??null);v(()=>{const e=n.current;null!=e&&(o(e),m(t=>t===e.data?t:E(t,e.data)))},[]),v(()=>{const e=n.current?.token;if(null==e)return;const t=t=>{const n=t.detail;n&&n.token===e&&m(e=>E(e,n.data))};return window.addEventListener(a,t),()=>window.removeEventListener(a,t)},[]);const h=b(void 0);v(()=>{h.current=r?.url},[r?.url]);const x=b(null);v(()=>(null!==x.current&&(clearTimeout(x.current),x.current=null),()=>{const e=h.current;e?.startsWith("blob:")&&(x.current=setTimeout(()=>URL.revokeObjectURL(e),0))}),[]);const A=y().preview,L=r?.filename?(S=r.filename).length>24?`${S.slice(0,23)}…`:S:A.untitled;var S;const j=r?.position&&r.position.count>1?r.position:null,z=j?A.namedPosition(L,A.position(j.index+1,j.count)):L,R=b(null),D=b(null),[F,P]=w(null),[I,O]=w(!1),B=b(0),G=()=>R.current?.click(),X=()=>{B.current=0,O(!1)},U=e=>{const t=e.closest("[data-modal-id]");return!t||d()===t.dataset.modalId};v(()=>{const e=()=>X(),t=()=>X(),n=e=>{"Escape"===e.key&&X()};return window.addEventListener("dragend",e),window.addEventListener("drop",t),window.addEventListener("keydown",n),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",t),window.removeEventListener("keydown",n)}},[]);const V=b(r);v(()=>{V.current=r},[r]),v(()=>{const e=e=>{const t=D.current;if(!t)return;const n=t.closest("[data-modal-id]"),r=n?d()===n.dataset.modalId:t.contains(document.activeElement),s=l(e,{active:r,data:V.current});s&&(e.preventDefault(),"previous"===s?V.current?.onPrevious?.():V.current?.onNext?.())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]);const Y=e=>{const t=(e.name.split(".").pop()||"").toLowerCase(),n="pdf"===t?"pdf":"dxf"===t?"dxf":["jpg","jpeg","png","gif","webp","svg","avif","bmp"].includes(t)?"image":["stp","step","stl","obj","gltf","glb","3mf","iges","igs","ply","fbx"].includes(t)?"3d":void 0;if(!n)return void("dwg"===t?f.error(A.dwgUnsupported):f.error(A.unsupportedType(t)));const r=URL.createObjectURL(e);m(t=>(t?.url?.startsWith("blob:")&&t.url!==r&&URL.revokeObjectURL(t.url),{url:r,filename:e.name,kind:n}))},_=/* @__PURE__ */k("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
1
+ import{PdfViewer as e,ToolbarSlotContext as t,PanelActions as n}from"./chunk-OEWBWKKD.js";import{ImageAnnotator_default as r}from"./chunk-TDUOBP55.js";import{AboutApp as s}from"./chunk-7533CPNQ.js";import{peekPdfPreviewStage as i,claimPdfPreviewStage as o,PDF_PREVIEW_UPDATE_EVENT as a,previewStepForKey as l}from"./chunk-I4RJAMLJ.js";import{WindowTitle as c}from"./chunk-VANF2TL3.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-PSVGB7KT.js";import"./chunk-YI4T5I5D.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-JRKD7SD3.js";import"./chunk-5RCKE4X2.js";import"./chunk-EIFNESXS.js";import"./chunk-PO2KNVCC.js";import"./chunk-CJ4OEY3T.js";import"./chunk-5QHNDAZ6.js";import"./chunk-TEQ5ZPAL.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-L2WQOJ3T.js";import"./chunk-SH7PJC4P.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import{getActiveModalId as d}from"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-T5TKMIV2.js";import"./chunk-NJY4HPNB.js";import"./chunk-PM6HY5BH.js";import"./chunk-DWGYC7OD.js";import{IconButton_default as u}from"./chunk-APFDZ2HG.js";import"./chunk-ABIWAS5K.js";import"./chunk-P56YLT73.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-A4ROXNUF.js";import"./chunk-TSZPGDU3.js";import{Icon as p}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import{SpinnerRing as m,LoadingSpinner as h}from"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-FAPZFMS3.js";import"./chunk-CIZAUBWA.js";import"./chunk-PGN5ME7B.js";import"./chunk-5QRHQCRG.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-3FININUU.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import{toast_default as f}from"./chunk-I2NVBDKH.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import{registerModalEscapeInterceptor as x}from"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import{useShellStrings as y,splitAround as g}from"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useRef as b,useState as w,useEffect as v}from"react";import{jsxs as k,jsx as N,Fragment as C}from"react/jsx-runtime";var A=!1;function E(e,t){return e?.url&&e.url!==t.url&&e.url.startsWith("blob:")&&URL.revokeObjectURL(e.url),t}function L(){const n=b(void 0);void 0===n.current&&(n.current=i());const[r,m]=w(n.current?.data??null);v(()=>{const e=n.current;null!=e&&(o(e),m(t=>t===e.data?t:E(t,e.data)))},[]),v(()=>{const e=n.current?.token;if(null==e)return;const t=t=>{const n=t.detail;n&&n.token===e&&m(e=>E(e,n.data))};return window.addEventListener(a,t),()=>window.removeEventListener(a,t)},[]);const h=b(void 0);v(()=>{h.current=r?.url},[r?.url]);const x=b(null);v(()=>(null!==x.current&&(clearTimeout(x.current),x.current=null),()=>{const e=h.current;e?.startsWith("blob:")&&(x.current=setTimeout(()=>URL.revokeObjectURL(e),0))}),[]);const A=y().preview,L=r?.filename?(S=r.filename).length>24?`${S.slice(0,23)}…`:S:A.untitled;var S;const j=r?.position&&r.position.count>1?r.position:null,z=j?A.namedPosition(L,A.position(j.index+1,j.count)):L,R=b(null),D=b(null),[F,P]=w(null),[W,O]=w(!1),B=b(0),U=()=>R.current?.click(),X=()=>{B.current=0,O(!1)},G=e=>{const t=e.closest("[data-modal-id]");return!t||d()===t.dataset.modalId};v(()=>{const e=()=>X(),t=()=>X(),n=e=>{"Escape"===e.key&&X()};return window.addEventListener("dragend",e),window.addEventListener("drop",t),window.addEventListener("keydown",n),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",t),window.removeEventListener("keydown",n)}},[]);const V=b(r);v(()=>{V.current=r},[r]),v(()=>{const e=e=>{const t=D.current;if(!t)return;const n=t.closest("[data-modal-id]"),r=n?d()===n.dataset.modalId:t.contains(document.activeElement),s=l(e,{active:r,data:V.current});s&&(e.preventDefault(),"previous"===s?V.current?.onPrevious?.():V.current?.onNext?.())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]);const Y=e=>{const t=(e.name.split(".").pop()||"").toLowerCase(),n="pdf"===t?"pdf":"dxf"===t?"dxf":["jpg","jpeg","png","gif","webp","svg","avif","bmp"].includes(t)?"image":["stp","step","stl","obj","gltf","glb","3mf","iges","igs","ply","fbx"].includes(t)?"3d":void 0;if(!n)return void("dwg"===t?f.error(A.dwgUnsupported):f.error(A.unsupportedType(t)));const r=URL.createObjectURL(e);m(t=>(t?.url?.startsWith("blob:")&&t.url!==r&&URL.revokeObjectURL(t.url),{url:r,filename:e.name,kind:n}))},_=/* @__PURE__ */k("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
2
2
  /* @__PURE__ */N("input",{ref:R,type:"file",accept:".pdf,.dxf,.jpg,.jpeg,.png,.gif,.webp,.svg,.avif,.bmp,.stp,.step,.stl,.obj,.gltf,.glb,.3mf,.iges,.igs,.ply,.fbx",onChange:e=>{const t=e.target.files?.[0];t&&Y(t),R.current&&(R.current.value="")},className:"hidden"}),
3
- /* @__PURE__ */k("button",{onClick:G,className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
3
+ /* @__PURE__ */k("button",{onClick:U,className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
4
4
  /* @__PURE__ */N(p,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),A.open]}),
5
5
  /* @__PURE__ */N("span",{className:"text-2xs text-ink-faintest ml-1",children:A.formats}),r?.filename&&/* @__PURE__ */k(C,{children:[
6
6
  /* @__PURE__ */N("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
7
7
  /* @__PURE__ */N("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:r.filename,children:r.filename})]}),
8
- /* @__PURE__ */N("div",{ref:P,className:"ml-auto flex items-center gap-1 text-xs"})]});let Z;if(r)Z=r.converting||!r.url?/* @__PURE__ */N(M,{filename:r.filename,message:r.convertingMessage}):"dxf"===r.kind?/* @__PURE__ */N(T,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):"3d"===r.kind?/* @__PURE__ */N(H,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):"image"===r.kind?/* @__PURE__ */N(W,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):/* @__PURE__ */N(e,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url);else{const[e,t]=g(A.dropHere),[n,r]=g(A.formatDxf),[s,i]=g(A.format3d);Z=/* @__PURE__ */k("div",{className:"flex flex-1 flex-col items-center justify-center text-gray-500 text-sm gap-3 p-8 text-center",children:[
8
+ /* @__PURE__ */N("div",{ref:P,className:"ml-auto flex items-center gap-1 text-xs"})]});let Z;if(r)Z=r.converting||!r.url?/* @__PURE__ */N(M,{filename:r.filename,message:r.convertingMessage}):"dxf"===r.kind?/* @__PURE__ */N(T,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):"3d"===r.kind?/* @__PURE__ */N(H,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):"image"===r.kind?/* @__PURE__ */N(I,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):/* @__PURE__ */N(e,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url);else{const[e,t]=g(A.dropHere),[n,r]=g(A.formatDxf),[s,i]=g(A.format3d);Z=/* @__PURE__ */k("div",{className:"flex flex-1 flex-col items-center justify-center text-gray-500 text-sm gap-3 p-8 text-center",children:[
9
9
  /* @__PURE__ */N(p,{name:"page",className:"h-12 w-12 text-gray-300",strokeWidth:1.5}),
10
10
  /* @__PURE__ */k("p",{className:"font-medium text-gray-700",children:[e,
11
- /* @__PURE__ */N("button",{onClick:G,className:"text-blue-600 hover:underline",children:A.open}),t]}),
11
+ /* @__PURE__ */N("button",{onClick:U,className:"text-blue-600 hover:underline",children:A.open}),t]}),
12
12
  /* @__PURE__ */k("div",{className:"text-xs text-gray-500 max-w-sm",children:[
13
13
  /* @__PURE__ */N("p",{className:"font-semibold uppercase tracking-wide text-3xs text-ink-faintest mb-1",children:A.supportedFormats}),
14
14
  /* @__PURE__ */k("ul",{className:"space-y-0.5",children:[
@@ -23,17 +23,17 @@ import{PdfViewer as e,ToolbarSlotContext as t,PanelActions as n}from"./chunk-QBR
23
23
  /* @__PURE__ */k("li",{children:[
24
24
  /* @__PURE__ */N("span",{className:"font-mono text-gray-700",children:".jpg .jpeg .png .gif .webp .svg .avif .bmp"})," — ",A.formatImage]})]}),
25
25
  /* @__PURE__ */N("p",{className:"mt-2 text-2xs text-ink-faintest italic",children:A.dwgNote})]})]})}/* @__PURE__ */
26
- return k("div",{className:"relative flex flex-col h-full",ref:D,onDragEnter:e=>{e.dataTransfer?.types?.includes?.("Files")&&U(e.currentTarget)&&(e.preventDefault(),B.current++,I||O(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&U(e.currentTarget)&&e.preventDefault()},onDragLeave:()=>{B.current>0&&B.current--,0===B.current&&O(!1)},onDrop:e=>{U(e.currentTarget)?(e=>{e.preventDefault(),X();const t=e.dataTransfer.files?.[0];t&&Y(t)})(e):X()},children:[
26
+ return k("div",{className:"relative flex flex-col h-full",ref:D,onDragEnter:e=>{e.dataTransfer?.types?.includes?.("Files")&&G(e.currentTarget)&&(e.preventDefault(),B.current++,W||O(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&G(e.currentTarget)&&e.preventDefault()},onDragLeave:()=>{B.current>0&&B.current--,0===B.current&&O(!1)},onDrop:e=>{G(e.currentTarget)?(e=>{e.preventDefault(),X();const t=e.dataTransfer.files?.[0];t&&Y(t)})(e):X()},children:[
27
27
  /* @__PURE__ */N(c,{title:A.windowTitle(z)}),
28
28
  /* @__PURE__ */N(s,{app:"preview"}),_,
29
- /* @__PURE__ */N(t.Provider,{value:F,children:/* @__PURE__ */k("div",{className:"relative flex-1 min-h-0",children:[Z,r?.onPrevious&&/* @__PURE__ */N("div",{className:"absolute inset-y-0 left-3 z-10 flex items-center pointer-events-none",children:/* @__PURE__ */N(u,{variant:"secondary",size:"lg","aria-label":A.previousFile,title:A.previousFile,onClick:r.onPrevious,className:"pointer-events-auto rounded-full! shadow-lg",children:/* @__PURE__ */N(p,{name:"chevron-left",className:"h-5 w-5",strokeWidth:2})})}),r?.onNext&&/* @__PURE__ */N("div",{className:"absolute inset-y-0 right-3 z-10 flex items-center pointer-events-none",children:/* @__PURE__ */N(u,{variant:"secondary",size:"lg","aria-label":A.nextFile,title:A.nextFile,onClick:r.onNext,className:"pointer-events-auto rounded-full! shadow-lg",children:/* @__PURE__ */N(p,{name:"chevron-right",className:"h-5 w-5",strokeWidth:2})})})]})}),I&&/* @__PURE__ */N("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */N("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:A.dropToOpen})})]})}function M({filename:e,message:t}){const n=y().preview;/* @__PURE__ */
29
+ /* @__PURE__ */N(t.Provider,{value:F,children:/* @__PURE__ */k("div",{className:"relative flex-1 min-h-0",children:[Z,r?.onPrevious&&/* @__PURE__ */N("div",{className:"absolute inset-y-0 left-3 z-10 flex items-center pointer-events-none",children:/* @__PURE__ */N(u,{variant:"secondary",size:"lg","aria-label":A.previousFile,title:A.previousFile,onClick:r.onPrevious,className:"pointer-events-auto rounded-full! shadow-lg",children:/* @__PURE__ */N(p,{name:"chevron-left",className:"h-5 w-5",strokeWidth:2})})}),r?.onNext&&/* @__PURE__ */N("div",{className:"absolute inset-y-0 right-3 z-10 flex items-center pointer-events-none",children:/* @__PURE__ */N(u,{variant:"secondary",size:"lg","aria-label":A.nextFile,title:A.nextFile,onClick:r.onNext,className:"pointer-events-auto rounded-full! shadow-lg",children:/* @__PURE__ */N(p,{name:"chevron-right",className:"h-5 w-5",strokeWidth:2})})})]})}),W&&/* @__PURE__ */N("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */N("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:A.dropToOpen})})]})}function M({filename:e,message:t}){const n=y().preview;/* @__PURE__ */
30
30
  return k("div",{className:"flex flex-col items-center justify-center h-full bg-gray-100 gap-4 px-8",children:[
31
31
  /* @__PURE__ */k("div",{className:"flex flex-col items-center gap-3",children:[
32
32
  /* @__PURE__ */N(m,{className:"h-12 w-12"}),
33
33
  /* @__PURE__ */N("div",{className:"text-base font-semibold tracking-wide text-gray-700 uppercase",children:t||n.converting}),
34
34
  /* @__PURE__ */N("div",{className:"text-xs text-gray-400 truncate max-w-md",children:e})]}),
35
35
  /* @__PURE__ */N("div",{className:"w-72 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */N("div",{className:"h-full w-1/3 bg-blue-500 rounded-full animate-pulse",style:{animation:"preview-bar 1.4s ease-in-out infinite"}})}),
36
- /* @__PURE__ */N("style",{children:"@keyframes preview-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }"})]})}var S=["https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/Roboto-LightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NotoSansDisplay-SemiCondensedLightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NanumGothic-Regular.ttf"],j={l:"LINE",line:"LINE",pl:"PLINE",pline:"PLINE",ex:"EXTEND",extend:"EXTEND",tr:"TRIM",trim:"TRIM",e:"ERASE",erase:"ERASE",m:"MOVE",move:"MOVE",co:"COPY",cp:"COPY",copy:"COPY",o:"OFFSET",offset:"OFFSET",f:"FILLET",fillet:"FILLET",cha:"CHAMFER",chamfer:"CHAMFER",x:"EXPLODE",explode:"EXPLODE",mi:"MIRROR",mirror:"MIRROR",ro:"ROTATE",rotate:"ROTATE",sc:"SCALE",scale:"SCALE",s:"STRETCH",stretch:"STRETCH",ar:"ARRAY",array:"ARRAY",rec:"RECTANG",rectang:"RECTANG",rectangle:"RECTANG",c:"CIRCLE",circle:"CIRCLE",a:"ARC",arc:"ARC",el:"ELLIPSE",ellipse:"ELLIPSE",t:"MTEXT",mt:"MTEXT",mtext:"MTEXT",text:"TEXT",b:"BLOCK",block:"BLOCK",i:"INSERT",insert:"INSERT",ha:"HATCH",hatch:"HATCH"};function T({url:e,filename:t,onDownload:r,onEmail:s}){const i=b(null),o=b(null),[a,l]=w(!0),[c,u]=w(null),[m,f]=w([]),[A,E]=w(!1),[L,M]=w(!0),T=y(),z=T.drawing,R=T.preview,D=b(z);D.current=z;const[F,H]=w(!1),[W,I]=w("auto"),[O,B]=w(null),[G,X]=w(null),[U,V]=w(null),[Y,_]=w(""),Z=b(W),J=b(U);v(()=>{Z.current=W},[W]),v(()=>{J.current=U},[U]);const Q=b(null),$=b(null),K=b(null),[q,ee]=w(""),[te,ne]=w(null),re=b(""),se=b(null),ie=b(null),oe=b(null);v(()=>{let t=!1,n=null;return l(!0),u(null),f([]),(async()=>{let r;try{r=(await(import("dxf-viewer"))).DxfViewer}catch(e){return void(t||(u(D.current.notInstalled),l(!1)))}if(!t&&i.current)try{if(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),t||!i.current)return;const s={autoResize:!0},a=r.DefaultOptions?.clearColor;"function"==typeof a?.clone&&(s.clearColor=a.clone().setHex(16777215)),n=new r(i.current,s),o.current=n;const c="undefined"!=typeof window&&window.__REACT_OS_SHELL_DXF_FONTS__||S;if(await n.Load({url:e,fonts:c,workerFactory:null}),t)return;try{const e=n.GetLayers?.()??[];Array.isArray(e)&&f(e.map(e=>({name:e.name,displayName:e.displayName??e.name,color:"number"==typeof e.color?e.color:void 0,visible:!0})))}catch{}const d=()=>{try{const e=i.current?.getBoundingClientRect();e&&e.width>0&&e.height>0&&n.SetSize?.(Math.round(e.width),Math.round(e.height));const t=n.GetBounds?.(),r=n.GetOrigin?.();t&&r&&n.FitView(t.minX-r.x,t.maxX-r.x,t.minY-r.y,t.maxY-r.y),n.Render?.()}catch(e){console.warn("[Preview] DXF refit failed",e)}};d(),requestAnimationFrame(d),l(!1)}catch(e){t||(u(e?.message||D.current.renderFailed),l(!1))}})(),()=>{t=!0;try{n?.Destroy?.()}catch{}o.current=null}},[e]),v(()=>{if(!L||a)return;const e=setTimeout(()=>M(!1),5e3);return()=>clearTimeout(e)},[L,a]);const ae=m.map(e=>e.visible?"1":"0").join("");v(()=>{const e=o.current;if(a||c||!e)return;const t=e.GetScene?.(),n=e.GetCamera?.(),r=e.GetCanvas?.();if(!(t&&n&&r&&i.current))return;const s=()=>{const e=oe.current;e&&(e.overlay&&e.overlay.parentElement&&e.overlay.parentElement.removeChild(e.overlay),oe.current=null)};if(!F)return s(),B(null),void X(null);const l=document.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:5;",i.current.appendChild(l);const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;pointer-events:none;");const u=document.createElementNS("http://www.w3.org/2000/svg","defs"),p=document.createElementNS("http://www.w3.org/2000/svg","marker");p.setAttribute("id","dxf-measure-arrow"),p.setAttribute("viewBox","0 0 10 10"),p.setAttribute("refX","9"),p.setAttribute("refY","5"),p.setAttribute("markerWidth","6"),p.setAttribute("markerHeight","6"),p.setAttribute("orient","auto-start-reverse");const m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),m.setAttribute("fill","#ff8800"),p.appendChild(m),u.appendChild(p),d.appendChild(u),l.appendChild(d);const h=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","line");return e.setAttribute("stroke","#ff8800"),e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","6,4"),e.setAttribute("opacity","0.55"),e.style.display="none",d.appendChild(e),e},f=h(),x=h(),y=document.createElementNS("http://www.w3.org/2000/svg","line");y.setAttribute("stroke","#ff8800"),y.setAttribute("stroke-width","1"),y.setAttribute("opacity","0.85"),y.style.display="none",d.appendChild(y);const g=document.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("stroke","#ff8800"),g.setAttribute("stroke-width","1"),g.setAttribute("opacity","0.85"),g.style.display="none",d.appendChild(g);const b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("stroke","#ff8800"),b.setAttribute("stroke-width","1.5"),b.setAttribute("stroke-linecap","round"),b.style.display="none",d.appendChild(b);const w=document.createElementNS("http://www.w3.org/2000/svg","line");w.setAttribute("stroke","#ff8800"),w.setAttribute("stroke-width","1.5"),w.setAttribute("stroke-linecap","round"),w.style.display="none",d.appendChild(w);const v=document.createElement("div");v.style.cssText="position:absolute;transform:translate(-50%,-50%);pointer-events:none;display:none;";const k="http://www.w3.org/2000/svg",N=document.createElementNS(k,"svg");N.setAttribute("width","22"),N.setAttribute("height","22"),N.setAttribute("viewBox","0 0 22 22"),N.setAttribute("style","overflow:visible;display:block"),v.appendChild(N);const C=e=>{const t=document.createElementNS(k,"g");return e(t),t.style.display="none",N.appendChild(t),t},A=C(e=>{const t=document.createElementNS(k,"rect");t.setAttribute("x","4"),t.setAttribute("y","4"),t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t)}),E=C(e=>{const t=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","2.2"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(t(4,4,18,18)),e.appendChild(t(18,4,4,18))}),L=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","4,4 18,4 4,18 18,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),M=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","11,3 19,18 3,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),S=C(e=>{const t=document.createElementNS(k,"circle");t.setAttribute("cx","11"),t.setAttribute("cy","11"),t.setAttribute("r","7"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t);const n=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","1.6"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(n(6.5,6.5,15.5,15.5)),e.appendChild(n(15.5,6.5,6.5,15.5))});l.appendChild(v),oe.current={picks:[],rawSecondClick:null,overlay:l,svg:d,line:b,fixedLine:w,fixedLabel:null,refLine:f,refLineV:x,extLineA:y,extLineB:g,markers:[],label:null,snap:v,segs:null,nodes:null};const j=n?.position?.constructor??t?.position?.constructor??null;let T=!1;const z=(e,t)=>{if(!j)return{x:0,y:0};const s=new j(e,t,0).project(n),i=r.clientWidth,o=r.clientHeight;return{x:(s.x+1)/2*i,y:(1-s.y)/2*o}};(()=>{try{const e=oe.current;if(!e)return;const n=[],r=[];let s=!1;const i=e=>{const t=e?.attributes?.instanceTransform0,n=e?.attributes?.instanceTransform1;if(t&&n){const e=[],r=Math.min(t.count,n.count);for(let s=0;s<r;s++)e.push([t.getX(s),t.getY(s),t.getZ(s),n.getX(s),n.getY(s),n.getZ(s)]);return e}const r=e?.attributes?.instanceTransform;if(r){const e=[];for(let t=0;t<r.count;t++)e.push([1,0,r.getX(t),0,1,r.getY(t)]);return e}return[[1,0,0,0,1,0]]},o=e=>{const t=!!e?.isLineSegments;if(!t&&!!!e?.isPoints)return;const o=e.geometry,a=o?.attributes?.position;if(!a)return;const l=i(o);if(t){const e=o.index,t=Math.floor((e?e.count:a.count)/2);for(let r=0;r<t;r++){const t=e?e.getX(2*r):2*r,i=e?e.getX(2*r+1):2*r+1,o=a.getX(t),c=a.getY(t),d=a.getX(i),u=a.getY(i);if(Number.isFinite(o+c+d+u))for(const e of l){if(n.length>=16e5)return void(s=!0);const t=e[0]*o+e[1]*c+e[2],r=e[3]*o+e[4]*c+e[5],i=e[0]*d+e[1]*u+e[2],a=e[3]*d+e[4]*u+e[5];t===i&&r===a||n.push(t,r,i,a)}}}else for(let e=0;e<a.count;e++){const t=a.getX(e),n=a.getY(e);if(Number.isFinite(t+n))for(const e of l)r.push(e[0]*t+e[1]*n+e[2],e[3]*t+e[4]*n+e[5])}};"function"==typeof t.traverseVisible?t.traverseVisible(o):t.traverse(o),e.segs=new Float64Array(n),e.nodes=new Float64Array(r),s&&console.warn("[Preview] DXF snap cache truncated at 400000 segments — snapping may miss some geometry."),T=!0}catch{}})();const R=(e,t,n,r,s,i,o,a)=>{const l=(n-e)*(a-i)-(r-t)*(o-s);if(Math.abs(l)<1e-9)return null;const c=((s-e)*(a-i)-(i-t)*(o-s))/l,d=((s-e)*(r-t)-(i-t)*(n-e))/l,u=1e-4;return c<-u||c>1+u||d<-u||d>1+u?null:{px:e+c*(n-e),py:t+c*(r-t),t:c}},W=()=>{const e=document.createElement("div");return e.style.cssText="position:absolute;width:10px;height:10px;border-radius:50%;background:#ff8800;border:2px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,0.25);transform:translate(-50%,-50%);pointer-events:none;",l.appendChild(e),e},I=(e,t,n)=>{const r=z(t,n);e.style.left=`${r.x}px`,e.style.top=`${r.y}px`},O=()=>{const e=oe.current;if(!e||!e.rawSecondClick||e.picks.length<2)return;const t=e.picks[0],n=e.rawSecondClick,r=J.current,s=Z.current;if(null===r||!Number.isFinite(r)||"horizontal"!==s&&"vertical"!==s)e.picks[1]={x:n.x,y:n.y};else if("horizontal"===s){const s=n.x>=t.x?1:-1;e.picks[1]={x:t.x+s*Math.abs(r),y:n.y}}else{const s=n.y>=t.y?1:-1;e.picks[1]={x:n.x,y:t.y+s*Math.abs(r)}}},G=(e,t)=>{const n=Z.current;return"auto"!==n?n:e&&t?Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?"horizontal":"vertical":"horizontal"},U=()=>{const e=oe.current;if(!e)return;O();const t=Z.current,n=J.current,s=null!==n&&Number.isFinite(n)&&("horizontal"===t||"vertical"===t);e.markers[0]&&I(e.markers[0],e.picks[0].x,e.picks[0].y),e.markers[1]&&I(e.markers[1],e.picks[1].x,e.picks[1].y);const i=(t,n,s)=>{if(!t)return;if(!s||e.picks.length<1)return void(t.style.display="none");const i=e.picks[0],o=r.clientWidth,a=r.clientHeight,l=4*Math.hypot(o,a),c=z(i.x,i.y),d=z(i.x+n.dx,i.y+n.dy),u=l/(Math.hypot(d.x-c.x,d.y-c.y)||1),p=z(i.x-n.dx*u,i.y-n.dy*u),m=z(i.x+n.dx*u,i.y+n.dy*u);t.setAttribute("x1",String(p.x)),t.setAttribute("y1",String(p.y)),t.setAttribute("x2",String(m.x)),t.setAttribute("y2",String(m.y)),t.style.display=""};let o="horizontal"===t,a="vertical"===t;if("auto"===t)if(e.picks.length>=2){const t=G(e.picks[0],e.picks[1]);o="horizontal"===t,a="vertical"===t}else o=!0,a=!0;if(i(e.refLine,{dx:1,dy:0},o),i(e.refLineV,{dx:0,dy:1},a),2===e.picks.length){const t=e.picks[0],i=e.picks[1],o=G(t,i),a=(()=>{const e=oe.current,t=e.picks[0],n=e.picks[1],r=G(t,n),s=Z.current,i=J.current;return null!==i&&Number.isFinite(i)&&"horizontal"===s?{from:{x:n.x,y:t.y},to:{x:n.x,y:n.y}}:null!==i&&Number.isFinite(i)&&"vertical"===s?{from:{x:t.x,y:n.y},to:{x:n.x,y:n.y}}:"horizontal"===r?{from:t,to:{x:n.x,y:t.y}}:"vertical"===r?{from:t,to:{x:t.x,y:n.y}}:{from:t,to:n}})(),l=z(a.from.x,a.from.y),c=z(a.to.x,a.to.y);e.line.setAttribute("x1",String(l.x)),e.line.setAttribute("y1",String(l.y)),e.line.setAttribute("x2",String(c.x)),e.line.setAttribute("y2",String(c.y)),e.line.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.line.setAttribute("marker-end","url(#dxf-measure-arrow)");const d=Math.hypot(c.x-l.x,c.y-l.y);if(e.line.style.display=d>.5?"":"none",s&&e.fixedLine){const s="horizontal"===o?{x:i.x,y:t.y}:{x:t.x,y:i.y},a=z(t.x,t.y),l=z(s.x,s.y);e.fixedLine.setAttribute("x1",String(a.x)),e.fixedLine.setAttribute("y1",String(a.y)),e.fixedLine.setAttribute("x2",String(l.x)),e.fixedLine.setAttribute("y2",String(l.y)),e.fixedLine.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.fixedLine.setAttribute("marker-end","url(#dxf-measure-arrow)"),e.fixedLine.style.display="";const c=V();c.textContent=P(Math.abs(n));const d=(a.x+l.x)/2,u=(a.y+l.y)/2;c.style.left=`${d}px`,c.style.top=`${u}px`;const p=r.clientWidth,m=r.clientHeight;c.style.display=d<0||u<0||d>p||u>m?"none":""}else e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none");const u=e.extLineA,p=e.extLineB;if(!s&&"horizontal"===o&&Math.abs(i.y-t.y)>1e-9){const e=z(i.x,t.y),n=z(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else if(!s&&"vertical"===o&&Math.abs(i.x-t.x)>1e-9){const e=z(t.x,i.y),n=z(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else u.style.display="none",p.style.display="none";if(e.label){const t=(l.x+c.x)/2,n=(l.y+c.y)/2;e.label.style.left=`${t}px`,e.label.style.top=`${n}px`;const s=r.clientWidth,i=r.clientHeight;e.label.style.display=t<0||n<0||t>s||n>i?"none":"",d<=.5&&(e.label.style.display="none")}}else e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none")},V=()=>{const e=oe.current;if(e.fixedLabel)return e.fixedLabel;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.75);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.fixedLabel=t,t};let Y=0,_=0,q=0,ee=!1,te=!1,re=null;const se=e=>{const t=e?.detail;t&&0===t.domEvent?.button&&(Y=t.canvasCoord.x,_=t.canvasCoord.y,q=performance.now(),te=!1,ee=!0)},ie=e=>{const t=r.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;ee&&(n-Y)**2+(s-_)**2>16&&(te=!0);const i=oe.current;var o;if(i&&i.snap)if(ee&&te)i.snap.style.display="none";else if(re=((e,t)=>{const n=oe.current;if(!n||!T||!n.segs)return null;const r=z(0,0),s=z(1,0),i=z(0,1),o=s.x-r.x,a=s.y-r.y,l=i.x-r.x,c=i.y-r.y,d=o*c-l*a;if(!d)return null;const u=((e-r.x)*c-(t-r.y)*l)/d,p=((t-r.y)*o-(e-r.x)*a)/d,m=18/(Math.hypot(o,a)||1),h=18/(Math.hypot(l,c)||1),f=u-m,x=u+m,y=p-h,g=p+h,b=324;let w=null,v=b,k=null,N=b,C=null,A=b,E=null,L=b;const M=[],S=n.segs;for(let n=0;n<S.length;n+=4){const s=S[n],i=S[n+1],d=S[n+2],u=S[n+3];if(s<f&&d<f||s>x&&d>x||i<y&&u<y||i>g&&u>g)continue;const p=r.x+o*s+l*i,m=r.y+a*s+c*i,h=r.x+o*d+l*u,E=r.y+a*d+c*u;let L=!1,j=e-p,T=t-m,z=j*j+T*T;z<b&&(L=!0,z<v&&(v=z,w={sx:s,sy:i,type:"endpoint"})),j=e-h,T=t-E,z=j*j+T*T,z<b&&(L=!0,z<v&&(v=z,w={sx:d,sy:u,type:"endpoint"})),j=e-(p+h)/2,T=t-(m+E)/2,z=j*j+T*T,z<b&&(L=!0,z<N&&(N=z,k={sx:(s+d)/2,sy:(i+u)/2,type:"midpoint"}));const R=h-p,D=E-m,F=R*R+D*D;if(F>0){const n=((e-p)*R+(t-m)*D)/F;n>0&&n<1&&(j=e-(p+n*R),T=t-(m+n*D),z=j*j+T*T,z<b&&(L=!0,z<A&&(A=z,C={sx:s+n*(d-s),sy:i+n*(u-i),type:"line"})))}L&&M.push({ax:s,ay:i,bx:d,by:u,apx:p,apy:m,bpx:h,bpy:E})}const j=n.nodes;if(j)for(let n=0;n<j.length;n+=2){const s=j[n],i=j[n+1];if(s<f||s>x||i<y||i>g)continue;const d=e-(r.x+o*s+l*i),u=t-(r.y+a*s+c*i),p=d*d+u*u;p<v&&(v=p,w={sx:s,sy:i,type:"node"})}for(let n=0;n<M.length;n++){const r=M[n];for(let s=n+1;s<M.length;s++){const n=M[s],i=R(r.apx,r.apy,r.bpx,r.bpy,n.apx,n.apy,n.bpx,n.bpy);if(!i)continue;const o=e-i.px,a=t-i.py,l=o*o+a*a;l>=b||l>=L||(L=l,E={sx:r.ax+i.t*(r.bx-r.ax),sy:r.ay+i.t*(r.by-r.ay),type:"intersection"})}}return(E&&w?L<v-1?E:w:E??w)??k??C})(n,s),re){const e=z(re.sx,re.sy);i.snap.style.left=`${e.x}px`,i.snap.style.top=`${e.y}px`,i.snap.style.display="",o=re.type,A.style.display="endpoint"===o?"":"none",E.style.display="intersection"===o?"":"none",L.style.display="line"===o?"":"none",M.style.display="midpoint"===o?"":"none",S.style.display="node"===o?"":"none"}else i.snap.style.display="none"},ae=e=>{if(!ee)return;ee=!1;const t=performance.now()-q;if(te||t>350)return;const n=e?.detail?.position;if(!n)return;const r=re?{x:re.sx,y:re.sy}:{x:n.x,y:n.y};ue(r)},le=()=>{const e=oe.current;if(!e||2!==e.picks.length)return;O();const t=e.picks[0],n=e.picks[1],r=Z.current,s=G(t,n),i=J.current,o=null!==i&&Number.isFinite(i)&&("horizontal"===r||"vertical"===r);let a,c,d="",u=s;const p=Math.abs(n.x-t.x),m=Math.abs(n.y-t.y);if(o&&"horizontal"===r?(a=m,d=" ↕",u="vertical",c=D.current.echoLocked("ΔY",P(m),"ΔX",P(Math.abs(i)))):o&&"vertical"===r?(a=p,d=" ↔",u="horizontal",c=D.current.echoLocked("ΔX",P(p),"ΔY",P(Math.abs(i)))):"horizontal"===s?(a=p,d=" ↔",c=D.current.echoLinear(P(p),"ΔX")):"vertical"===s?(a=m,d=" ↕",c=D.current.echoLinear(P(m),"ΔY")):(a=Math.hypot(n.x-t.x,n.y-t.y),c=D.current.echoDistance(P(a),P(p),P(m))),!Number.isFinite(a))return B(null),X(null),void(e.label&&(e.label.style.opacity="0"));B(a),X(u),ne(c);const h=(()=>{const e=oe.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.95);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.label=t,t})();h.style.opacity="1",h.textContent=`${P(a)}${d}`};Q.current=()=>{le(),U()};const ce=e=>{e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none"),e.label&&(e.label.style.opacity="0"),B(null),X(null)},de=()=>{const e=oe.current;if(e){for(const t of e.markers)t.parentElement?.removeChild(t);e.markers=[],e.picks=[],e.rawSecondClick=null,e.refLine&&(e.refLine.style.display="none"),e.refLineV&&(e.refLineV.style.display="none"),ce(e)}};$.current=de,K.current=()=>{const e=oe.current;if(!e||0===e.picks.length)return;e.picks.pop();const t=e.markers.pop();t?.parentElement?.removeChild(t),e.rawSecondClick=null,ce(e),U()};const ue=e=>{const t=oe.current;t&&(2===t.picks.length&&de(),0===t.picks.length?(t.picks.push({x:e.x,y:e.y}),t.markers.push(W())):(t.rawSecondClick={x:e.x,y:e.y},t.picks.push({x:e.x,y:e.y}),t.markers.push(W()),le()),U())},pe=e=>{"Escape"===e.key&&H(!1)};r.style.cursor="crosshair";try{e.Subscribe?.("pointerdown",se)}catch{}try{e.Subscribe?.("pointerup",ae)}catch{}try{e.Subscribe?.("viewChanged",U)}catch{}return r.addEventListener("pointermove",ie),window.addEventListener("keydown",pe),()=>{r.style.cursor="";try{e.Unsubscribe?.("pointerdown",se)}catch{}try{e.Unsubscribe?.("pointerup",ae)}catch{}try{e.Unsubscribe?.("viewChanged",U)}catch{}r.removeEventListener("pointermove",ie),window.removeEventListener("keydown",pe),Q.current=null,$.current=null,K.current=null,s(),B(null),X(null)}},[F,a,c,ae]),v(()=>{Q.current?.()},[W,U]);const le=e=>{f(t=>t.map(t=>{if(t.visible===e)return t;try{o.current?.ShowLayer?.(t.name,e)}catch{}return{...t,visible:e}}))},ce=()=>{try{const e=o.current,t=e?.GetBounds?.(),n=e?.GetOrigin?.();t&&n?e.FitView(t.minX-n.x,t.maxX-n.x,t.minY-n.y,t.maxY-n.y):e?.FitView?.(),e?.Render?.()}catch{}};v(()=>{const e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;if(1!==e.key.length||" "===e.key)return;const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=ie.current;if(!n)return;const r=n.closest("[data-modal-id]");r&&d()!==r.dataset.modalId||se.current?.focus()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);const de=b(q),ue=b(F);v(()=>{de.current=q},[q]),v(()=>{ue.current=F},[F]),v(()=>x(()=>{const e=ie.current;if(!e)return!1;const t=e.closest("[data-modal-id]");return!(!t||d()!==t.dataset.modalId)&&(de.current?(ee(""),ne(D.current.cancelled),!0):!!ue.current&&(H(!1),ne(D.current.measureOff),!0))}),[]);const pe="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1",[me,he]=g(z.typeToMeasure);/* @__PURE__ */
36
+ /* @__PURE__ */N("style",{children:"@keyframes preview-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }"})]})}var S=["https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/Roboto-LightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NotoSansDisplay-SemiCondensedLightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NanumGothic-Regular.ttf"],j={l:"LINE",line:"LINE",pl:"PLINE",pline:"PLINE",ex:"EXTEND",extend:"EXTEND",tr:"TRIM",trim:"TRIM",e:"ERASE",erase:"ERASE",m:"MOVE",move:"MOVE",co:"COPY",cp:"COPY",copy:"COPY",o:"OFFSET",offset:"OFFSET",f:"FILLET",fillet:"FILLET",cha:"CHAMFER",chamfer:"CHAMFER",x:"EXPLODE",explode:"EXPLODE",mi:"MIRROR",mirror:"MIRROR",ro:"ROTATE",rotate:"ROTATE",sc:"SCALE",scale:"SCALE",s:"STRETCH",stretch:"STRETCH",ar:"ARRAY",array:"ARRAY",rec:"RECTANG",rectang:"RECTANG",rectangle:"RECTANG",c:"CIRCLE",circle:"CIRCLE",a:"ARC",arc:"ARC",el:"ELLIPSE",ellipse:"ELLIPSE",t:"MTEXT",mt:"MTEXT",mtext:"MTEXT",text:"TEXT",b:"BLOCK",block:"BLOCK",i:"INSERT",insert:"INSERT",ha:"HATCH",hatch:"HATCH"};function T({url:e,filename:t,onDownload:r,onEmail:s}){const i=b(null),o=b(null),[a,l]=w(!0),[c,u]=w(null),[m,f]=w([]),[A,E]=w(!1),[L,M]=w(!0),T=y(),z=T.drawing,R=T.preview,D=b(z);D.current=z;const[F,H]=w(!1),[I,W]=w("auto"),[O,B]=w(null),[U,X]=w(null),[G,V]=w(null),[Y,_]=w(""),Z=b(I),$=b(G);v(()=>{Z.current=I},[I]),v(()=>{$.current=G},[G]);const K=b(null),J=b(null),Q=b(null),[q,ee]=w(""),[te,ne]=w(null),re=b(""),se=b(null),ie=b(null),oe=b(null);v(()=>{let t=!1,n=null;return l(!0),u(null),f([]),(async()=>{let r;try{r=(await(import("dxf-viewer"))).DxfViewer}catch(e){return void(t||(u(D.current.notInstalled),l(!1)))}if(!t&&i.current)try{if(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),t||!i.current)return;const s={autoResize:!0},a=r.DefaultOptions?.clearColor;"function"==typeof a?.clone&&(s.clearColor=a.clone().setHex(16777215)),n=new r(i.current,s),o.current=n;const c="undefined"!=typeof window&&window.__REACT_OS_SHELL_DXF_FONTS__||S;if(await n.Load({url:e,fonts:c,workerFactory:null}),t)return;try{const e=n.GetLayers?.()??[];Array.isArray(e)&&f(e.map(e=>({name:e.name,displayName:e.displayName??e.name,color:"number"==typeof e.color?e.color:void 0,visible:!0})))}catch{}const d=()=>{try{const e=i.current?.getBoundingClientRect();e&&e.width>0&&e.height>0&&n.SetSize?.(Math.round(e.width),Math.round(e.height));const t=n.GetBounds?.(),r=n.GetOrigin?.();t&&r&&n.FitView(t.minX-r.x,t.maxX-r.x,t.minY-r.y,t.maxY-r.y),n.Render?.()}catch(e){console.warn("[Preview] DXF refit failed",e)}};d(),requestAnimationFrame(d),l(!1)}catch(e){t||(u(e?.message||D.current.renderFailed),l(!1))}})(),()=>{t=!0;try{n?.Destroy?.()}catch{}o.current=null}},[e]),v(()=>{if(!L||a)return;const e=setTimeout(()=>M(!1),5e3);return()=>clearTimeout(e)},[L,a]);const ae=m.map(e=>e.visible?"1":"0").join("");v(()=>{const e=o.current;if(a||c||!e)return;const t=e.GetScene?.(),n=e.GetCamera?.(),r=e.GetCanvas?.();if(!(t&&n&&r&&i.current))return;const s=()=>{const e=oe.current;e&&(e.overlay&&e.overlay.parentElement&&e.overlay.parentElement.removeChild(e.overlay),oe.current=null)};if(!F)return s(),B(null),void X(null);const l=document.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:5;",i.current.appendChild(l);const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;pointer-events:none;");const u=document.createElementNS("http://www.w3.org/2000/svg","defs"),p=document.createElementNS("http://www.w3.org/2000/svg","marker");p.setAttribute("id","dxf-measure-arrow"),p.setAttribute("viewBox","0 0 10 10"),p.setAttribute("refX","9"),p.setAttribute("refY","5"),p.setAttribute("markerWidth","6"),p.setAttribute("markerHeight","6"),p.setAttribute("orient","auto-start-reverse");const m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),m.setAttribute("fill","#ff8800"),p.appendChild(m),u.appendChild(p),d.appendChild(u),l.appendChild(d);const h=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","line");return e.setAttribute("stroke","#ff8800"),e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","6,4"),e.setAttribute("opacity","0.55"),e.style.display="none",d.appendChild(e),e},f=h(),x=h(),y=document.createElementNS("http://www.w3.org/2000/svg","line");y.setAttribute("stroke","#ff8800"),y.setAttribute("stroke-width","1"),y.setAttribute("opacity","0.85"),y.style.display="none",d.appendChild(y);const g=document.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("stroke","#ff8800"),g.setAttribute("stroke-width","1"),g.setAttribute("opacity","0.85"),g.style.display="none",d.appendChild(g);const b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("stroke","#ff8800"),b.setAttribute("stroke-width","1.5"),b.setAttribute("stroke-linecap","round"),b.style.display="none",d.appendChild(b);const w=document.createElementNS("http://www.w3.org/2000/svg","line");w.setAttribute("stroke","#ff8800"),w.setAttribute("stroke-width","1.5"),w.setAttribute("stroke-linecap","round"),w.style.display="none",d.appendChild(w);const v=document.createElement("div");v.style.cssText="position:absolute;transform:translate(-50%,-50%);pointer-events:none;display:none;";const k="http://www.w3.org/2000/svg",N=document.createElementNS(k,"svg");N.setAttribute("width","22"),N.setAttribute("height","22"),N.setAttribute("viewBox","0 0 22 22"),N.setAttribute("style","overflow:visible;display:block"),v.appendChild(N);const C=e=>{const t=document.createElementNS(k,"g");return e(t),t.style.display="none",N.appendChild(t),t},A=C(e=>{const t=document.createElementNS(k,"rect");t.setAttribute("x","4"),t.setAttribute("y","4"),t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t)}),E=C(e=>{const t=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","2.2"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(t(4,4,18,18)),e.appendChild(t(18,4,4,18))}),L=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","4,4 18,4 4,18 18,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),M=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","11,3 19,18 3,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),S=C(e=>{const t=document.createElementNS(k,"circle");t.setAttribute("cx","11"),t.setAttribute("cy","11"),t.setAttribute("r","7"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t);const n=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","1.6"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(n(6.5,6.5,15.5,15.5)),e.appendChild(n(15.5,6.5,6.5,15.5))});l.appendChild(v),oe.current={picks:[],rawSecondClick:null,overlay:l,svg:d,line:b,fixedLine:w,fixedLabel:null,refLine:f,refLineV:x,extLineA:y,extLineB:g,markers:[],label:null,snap:v,segs:null,nodes:null};const j=n?.position?.constructor??t?.position?.constructor??null;let T=!1;const z=(e,t)=>{if(!j)return{x:0,y:0};const s=new j(e,t,0).project(n),i=r.clientWidth,o=r.clientHeight;return{x:(s.x+1)/2*i,y:(1-s.y)/2*o}};(()=>{try{const e=oe.current;if(!e)return;const n=[],r=[];let s=!1;const i=e=>{const t=e?.attributes?.instanceTransform0,n=e?.attributes?.instanceTransform1;if(t&&n){const e=[],r=Math.min(t.count,n.count);for(let s=0;s<r;s++)e.push([t.getX(s),t.getY(s),t.getZ(s),n.getX(s),n.getY(s),n.getZ(s)]);return e}const r=e?.attributes?.instanceTransform;if(r){const e=[];for(let t=0;t<r.count;t++)e.push([1,0,r.getX(t),0,1,r.getY(t)]);return e}return[[1,0,0,0,1,0]]},o=e=>{const t=!!e?.isLineSegments;if(!t&&!!!e?.isPoints)return;const o=e.geometry,a=o?.attributes?.position;if(!a)return;const l=i(o);if(t){const e=o.index,t=Math.floor((e?e.count:a.count)/2);for(let r=0;r<t;r++){const t=e?e.getX(2*r):2*r,i=e?e.getX(2*r+1):2*r+1,o=a.getX(t),c=a.getY(t),d=a.getX(i),u=a.getY(i);if(Number.isFinite(o+c+d+u))for(const e of l){if(n.length>=16e5)return void(s=!0);const t=e[0]*o+e[1]*c+e[2],r=e[3]*o+e[4]*c+e[5],i=e[0]*d+e[1]*u+e[2],a=e[3]*d+e[4]*u+e[5];t===i&&r===a||n.push(t,r,i,a)}}}else for(let e=0;e<a.count;e++){const t=a.getX(e),n=a.getY(e);if(Number.isFinite(t+n))for(const e of l)r.push(e[0]*t+e[1]*n+e[2],e[3]*t+e[4]*n+e[5])}};"function"==typeof t.traverseVisible?t.traverseVisible(o):t.traverse(o),e.segs=new Float64Array(n),e.nodes=new Float64Array(r),s&&console.warn("[Preview] DXF snap cache truncated at 400000 segments — snapping may miss some geometry."),T=!0}catch{}})();const R=(e,t,n,r,s,i,o,a)=>{const l=(n-e)*(a-i)-(r-t)*(o-s);if(Math.abs(l)<1e-9)return null;const c=((s-e)*(a-i)-(i-t)*(o-s))/l,d=((s-e)*(r-t)-(i-t)*(n-e))/l,u=1e-4;return c<-u||c>1+u||d<-u||d>1+u?null:{px:e+c*(n-e),py:t+c*(r-t),t:c}},I=()=>{const e=document.createElement("div");return e.style.cssText="position:absolute;width:10px;height:10px;border-radius:50%;background:#ff8800;border:2px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,0.25);transform:translate(-50%,-50%);pointer-events:none;",l.appendChild(e),e},W=(e,t,n)=>{const r=z(t,n);e.style.left=`${r.x}px`,e.style.top=`${r.y}px`},O=()=>{const e=oe.current;if(!e||!e.rawSecondClick||e.picks.length<2)return;const t=e.picks[0],n=e.rawSecondClick,r=$.current,s=Z.current;if(null===r||!Number.isFinite(r)||"horizontal"!==s&&"vertical"!==s)e.picks[1]={x:n.x,y:n.y};else if("horizontal"===s){const s=n.x>=t.x?1:-1;e.picks[1]={x:t.x+s*Math.abs(r),y:n.y}}else{const s=n.y>=t.y?1:-1;e.picks[1]={x:n.x,y:t.y+s*Math.abs(r)}}},U=(e,t)=>{const n=Z.current;return"auto"!==n?n:e&&t?Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?"horizontal":"vertical":"horizontal"},G=()=>{const e=oe.current;if(!e)return;O();const t=Z.current,n=$.current,s=null!==n&&Number.isFinite(n)&&("horizontal"===t||"vertical"===t);e.markers[0]&&W(e.markers[0],e.picks[0].x,e.picks[0].y),e.markers[1]&&W(e.markers[1],e.picks[1].x,e.picks[1].y);const i=(t,n,s)=>{if(!t)return;if(!s||e.picks.length<1)return void(t.style.display="none");const i=e.picks[0],o=r.clientWidth,a=r.clientHeight,l=4*Math.hypot(o,a),c=z(i.x,i.y),d=z(i.x+n.dx,i.y+n.dy),u=l/(Math.hypot(d.x-c.x,d.y-c.y)||1),p=z(i.x-n.dx*u,i.y-n.dy*u),m=z(i.x+n.dx*u,i.y+n.dy*u);t.setAttribute("x1",String(p.x)),t.setAttribute("y1",String(p.y)),t.setAttribute("x2",String(m.x)),t.setAttribute("y2",String(m.y)),t.style.display=""};let o="horizontal"===t,a="vertical"===t;if("auto"===t)if(e.picks.length>=2){const t=U(e.picks[0],e.picks[1]);o="horizontal"===t,a="vertical"===t}else o=!0,a=!0;if(i(e.refLine,{dx:1,dy:0},o),i(e.refLineV,{dx:0,dy:1},a),2===e.picks.length){const t=e.picks[0],i=e.picks[1],o=U(t,i),a=(()=>{const e=oe.current,t=e.picks[0],n=e.picks[1],r=U(t,n),s=Z.current,i=$.current;return null!==i&&Number.isFinite(i)&&"horizontal"===s?{from:{x:n.x,y:t.y},to:{x:n.x,y:n.y}}:null!==i&&Number.isFinite(i)&&"vertical"===s?{from:{x:t.x,y:n.y},to:{x:n.x,y:n.y}}:"horizontal"===r?{from:t,to:{x:n.x,y:t.y}}:"vertical"===r?{from:t,to:{x:t.x,y:n.y}}:{from:t,to:n}})(),l=z(a.from.x,a.from.y),c=z(a.to.x,a.to.y);e.line.setAttribute("x1",String(l.x)),e.line.setAttribute("y1",String(l.y)),e.line.setAttribute("x2",String(c.x)),e.line.setAttribute("y2",String(c.y)),e.line.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.line.setAttribute("marker-end","url(#dxf-measure-arrow)");const d=Math.hypot(c.x-l.x,c.y-l.y);if(e.line.style.display=d>.5?"":"none",s&&e.fixedLine){const s="horizontal"===o?{x:i.x,y:t.y}:{x:t.x,y:i.y},a=z(t.x,t.y),l=z(s.x,s.y);e.fixedLine.setAttribute("x1",String(a.x)),e.fixedLine.setAttribute("y1",String(a.y)),e.fixedLine.setAttribute("x2",String(l.x)),e.fixedLine.setAttribute("y2",String(l.y)),e.fixedLine.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.fixedLine.setAttribute("marker-end","url(#dxf-measure-arrow)"),e.fixedLine.style.display="";const c=V();c.textContent=P(Math.abs(n));const d=(a.x+l.x)/2,u=(a.y+l.y)/2;c.style.left=`${d}px`,c.style.top=`${u}px`;const p=r.clientWidth,m=r.clientHeight;c.style.display=d<0||u<0||d>p||u>m?"none":""}else e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none");const u=e.extLineA,p=e.extLineB;if(!s&&"horizontal"===o&&Math.abs(i.y-t.y)>1e-9){const e=z(i.x,t.y),n=z(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else if(!s&&"vertical"===o&&Math.abs(i.x-t.x)>1e-9){const e=z(t.x,i.y),n=z(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else u.style.display="none",p.style.display="none";if(e.label){const t=(l.x+c.x)/2,n=(l.y+c.y)/2;e.label.style.left=`${t}px`,e.label.style.top=`${n}px`;const s=r.clientWidth,i=r.clientHeight;e.label.style.display=t<0||n<0||t>s||n>i?"none":"",d<=.5&&(e.label.style.display="none")}}else e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none")},V=()=>{const e=oe.current;if(e.fixedLabel)return e.fixedLabel;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.75);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.fixedLabel=t,t};let Y=0,_=0,q=0,ee=!1,te=!1,re=null;const se=e=>{const t=e?.detail;t&&0===t.domEvent?.button&&(Y=t.canvasCoord.x,_=t.canvasCoord.y,q=performance.now(),te=!1,ee=!0)},ie=e=>{const t=r.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;ee&&(n-Y)**2+(s-_)**2>16&&(te=!0);const i=oe.current;var o;if(i&&i.snap)if(ee&&te)i.snap.style.display="none";else if(re=((e,t)=>{const n=oe.current;if(!n||!T||!n.segs)return null;const r=z(0,0),s=z(1,0),i=z(0,1),o=s.x-r.x,a=s.y-r.y,l=i.x-r.x,c=i.y-r.y,d=o*c-l*a;if(!d)return null;const u=((e-r.x)*c-(t-r.y)*l)/d,p=((t-r.y)*o-(e-r.x)*a)/d,m=18/(Math.hypot(o,a)||1),h=18/(Math.hypot(l,c)||1),f=u-m,x=u+m,y=p-h,g=p+h,b=324;let w=null,v=b,k=null,N=b,C=null,A=b,E=null,L=b;const M=[],S=n.segs;for(let n=0;n<S.length;n+=4){const s=S[n],i=S[n+1],d=S[n+2],u=S[n+3];if(s<f&&d<f||s>x&&d>x||i<y&&u<y||i>g&&u>g)continue;const p=r.x+o*s+l*i,m=r.y+a*s+c*i,h=r.x+o*d+l*u,E=r.y+a*d+c*u;let L=!1,j=e-p,T=t-m,z=j*j+T*T;z<b&&(L=!0,z<v&&(v=z,w={sx:s,sy:i,type:"endpoint"})),j=e-h,T=t-E,z=j*j+T*T,z<b&&(L=!0,z<v&&(v=z,w={sx:d,sy:u,type:"endpoint"})),j=e-(p+h)/2,T=t-(m+E)/2,z=j*j+T*T,z<b&&(L=!0,z<N&&(N=z,k={sx:(s+d)/2,sy:(i+u)/2,type:"midpoint"}));const R=h-p,D=E-m,F=R*R+D*D;if(F>0){const n=((e-p)*R+(t-m)*D)/F;n>0&&n<1&&(j=e-(p+n*R),T=t-(m+n*D),z=j*j+T*T,z<b&&(L=!0,z<A&&(A=z,C={sx:s+n*(d-s),sy:i+n*(u-i),type:"line"})))}L&&M.push({ax:s,ay:i,bx:d,by:u,apx:p,apy:m,bpx:h,bpy:E})}const j=n.nodes;if(j)for(let n=0;n<j.length;n+=2){const s=j[n],i=j[n+1];if(s<f||s>x||i<y||i>g)continue;const d=e-(r.x+o*s+l*i),u=t-(r.y+a*s+c*i),p=d*d+u*u;p<v&&(v=p,w={sx:s,sy:i,type:"node"})}for(let n=0;n<M.length;n++){const r=M[n];for(let s=n+1;s<M.length;s++){const n=M[s],i=R(r.apx,r.apy,r.bpx,r.bpy,n.apx,n.apy,n.bpx,n.bpy);if(!i)continue;const o=e-i.px,a=t-i.py,l=o*o+a*a;l>=b||l>=L||(L=l,E={sx:r.ax+i.t*(r.bx-r.ax),sy:r.ay+i.t*(r.by-r.ay),type:"intersection"})}}return(E&&w?L<v-1?E:w:E??w)??k??C})(n,s),re){const e=z(re.sx,re.sy);i.snap.style.left=`${e.x}px`,i.snap.style.top=`${e.y}px`,i.snap.style.display="",o=re.type,A.style.display="endpoint"===o?"":"none",E.style.display="intersection"===o?"":"none",L.style.display="line"===o?"":"none",M.style.display="midpoint"===o?"":"none",S.style.display="node"===o?"":"none"}else i.snap.style.display="none"},ae=e=>{if(!ee)return;ee=!1;const t=performance.now()-q;if(te||t>350)return;const n=e?.detail?.position;if(!n)return;const r=re?{x:re.sx,y:re.sy}:{x:n.x,y:n.y};ue(r)},le=()=>{const e=oe.current;if(!e||2!==e.picks.length)return;O();const t=e.picks[0],n=e.picks[1],r=Z.current,s=U(t,n),i=$.current,o=null!==i&&Number.isFinite(i)&&("horizontal"===r||"vertical"===r);let a,c,d="",u=s;const p=Math.abs(n.x-t.x),m=Math.abs(n.y-t.y);if(o&&"horizontal"===r?(a=m,d=" ↕",u="vertical",c=D.current.echoLocked("ΔY",P(m),"ΔX",P(Math.abs(i)))):o&&"vertical"===r?(a=p,d=" ↔",u="horizontal",c=D.current.echoLocked("ΔX",P(p),"ΔY",P(Math.abs(i)))):"horizontal"===s?(a=p,d=" ↔",c=D.current.echoLinear(P(p),"ΔX")):"vertical"===s?(a=m,d=" ↕",c=D.current.echoLinear(P(m),"ΔY")):(a=Math.hypot(n.x-t.x,n.y-t.y),c=D.current.echoDistance(P(a),P(p),P(m))),!Number.isFinite(a))return B(null),X(null),void(e.label&&(e.label.style.opacity="0"));B(a),X(u),ne(c);const h=(()=>{const e=oe.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.95);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.label=t,t})();h.style.opacity="1",h.textContent=`${P(a)}${d}`};K.current=()=>{le(),G()};const ce=e=>{e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none"),e.label&&(e.label.style.opacity="0"),B(null),X(null)},de=()=>{const e=oe.current;if(e){for(const t of e.markers)t.parentElement?.removeChild(t);e.markers=[],e.picks=[],e.rawSecondClick=null,e.refLine&&(e.refLine.style.display="none"),e.refLineV&&(e.refLineV.style.display="none"),ce(e)}};J.current=de,Q.current=()=>{const e=oe.current;if(!e||0===e.picks.length)return;e.picks.pop();const t=e.markers.pop();t?.parentElement?.removeChild(t),e.rawSecondClick=null,ce(e),G()};const ue=e=>{const t=oe.current;t&&(2===t.picks.length&&de(),0===t.picks.length?(t.picks.push({x:e.x,y:e.y}),t.markers.push(I())):(t.rawSecondClick={x:e.x,y:e.y},t.picks.push({x:e.x,y:e.y}),t.markers.push(I()),le()),G())},pe=e=>{"Escape"===e.key&&H(!1)};r.style.cursor="crosshair";try{e.Subscribe?.("pointerdown",se)}catch{}try{e.Subscribe?.("pointerup",ae)}catch{}try{e.Subscribe?.("viewChanged",G)}catch{}return r.addEventListener("pointermove",ie),window.addEventListener("keydown",pe),()=>{r.style.cursor="";try{e.Unsubscribe?.("pointerdown",se)}catch{}try{e.Unsubscribe?.("pointerup",ae)}catch{}try{e.Unsubscribe?.("viewChanged",G)}catch{}r.removeEventListener("pointermove",ie),window.removeEventListener("keydown",pe),K.current=null,J.current=null,Q.current=null,s(),B(null),X(null)}},[F,a,c,ae]),v(()=>{K.current?.()},[I,G]);const le=e=>{f(t=>t.map(t=>{if(t.visible===e)return t;try{o.current?.ShowLayer?.(t.name,e)}catch{}return{...t,visible:e}}))},ce=()=>{try{const e=o.current,t=e?.GetBounds?.(),n=e?.GetOrigin?.();t&&n?e.FitView(t.minX-n.x,t.maxX-n.x,t.minY-n.y,t.maxY-n.y):e?.FitView?.(),e?.Render?.()}catch{}};v(()=>{const e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;if(1!==e.key.length||" "===e.key)return;const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=ie.current;if(!n)return;const r=n.closest("[data-modal-id]");r&&d()!==r.dataset.modalId||se.current?.focus()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);const de=b(q),ue=b(F);v(()=>{de.current=q},[q]),v(()=>{ue.current=F},[F]),v(()=>x(()=>{const e=ie.current;if(!e)return!1;const t=e.closest("[data-modal-id]");return!(!t||d()!==t.dataset.modalId)&&(de.current?(ee(""),ne(D.current.cancelled),!0):!!ue.current&&(H(!1),ne(D.current.measureOff),!0))}),[]);const pe="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1",[me,he]=g(z.typeToMeasure);/* @__PURE__ */
37
37
  return k("div",{ref:ie,className:"flex flex-col h-full",children:[
38
38
  /* @__PURE__ */k(n,{children:[
39
39
  /* @__PURE__ */k("button",{onClick:()=>E(e=>!e),className:pe+(A?" bg-gray-200":""),title:z.layersHint,disabled:0===m.length,children:[
@@ -44,11 +44,11 @@ return k("div",{ref:ie,className:"flex flex-col h-full",children:[
44
44
  /* @__PURE__ */N("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 14.25l6-6 6 6 4.5-4.5M9.75 8.25v3M12.75 11.25v3M15.75 14.25v3"}),
45
45
  /* @__PURE__ */N("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 18.75h19.5"})]}),z.measure]}),F&&/* @__PURE__ */k(C,{children:[
46
46
  /* @__PURE__ */k("div",{className:"flex items-stretch h-7 rounded border border-line overflow-hidden text-2xs font-semibold",children:[
47
- /* @__PURE__ */N("button",{onClick:()=>I("auto"),className:"px-2 transition-colors "+("auto"===W?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.autoHint,children:z.auto}),
48
- /* @__PURE__ */N("button",{onClick:()=>I("horizontal"),className:"px-2 transition-colors "+("horizontal"===W?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.horizontalHint,children:"H"}),
49
- /* @__PURE__ */N("button",{onClick:()=>I("vertical"),className:"px-2 transition-colors "+("vertical"===W?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.verticalHint,children:"V"}),
50
- /* @__PURE__ */N("button",{onClick:()=>I("point"),className:"px-2 transition-colors "+("point"===W?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.pointHint,children:z.point})]}),("horizontal"===W||"vertical"===W)&&/* @__PURE__ */k("div",{className:"flex items-center gap-1",children:[
51
- /* @__PURE__ */N("input",{type:"number",inputMode:"decimal",step:"any",value:Y,placeholder:"horizontal"===W?z.fixX:z.fixY,onChange:e=>{const t=e.target.value;if(_(t),""===t.trim())V(null);else{const e=parseFloat(t);V(Number.isFinite(e)&&0!==e?e:null)}},className:"h-7 w-20 px-2 text-2xs font-mono rounded border border-line bg-surface text-ink focus:outline-none focus:border-orange-400",title:z.fixHint}),null!==U&&/* @__PURE__ */N("button",{onClick:()=>{V(null),_("")},className:"text-ink-faintest hover:text-gray-600 text-2xs px-1",title:z.clearFixed,children:"×"})]})]}),F&&null!==O&&/* @__PURE__ */k("div",{className:"px-2 py-1 text-2xs font-mono font-semibold text-orange-600 bg-orange-50 border border-orange-200 rounded whitespace-nowrap",title:"horizontal"===G?z.horizontalDistance("auto"===W):"vertical"===G?z.verticalDistance("auto"===W):z.straightDistance,children:[P(O),"horizontal"===G?" ↔":"vertical"===G?" ↕":""]}),
47
+ /* @__PURE__ */N("button",{onClick:()=>W("auto"),className:"px-2 transition-colors "+("auto"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.autoHint,children:z.auto}),
48
+ /* @__PURE__ */N("button",{onClick:()=>W("horizontal"),className:"px-2 transition-colors "+("horizontal"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.horizontalHint,children:"H"}),
49
+ /* @__PURE__ */N("button",{onClick:()=>W("vertical"),className:"px-2 transition-colors "+("vertical"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.verticalHint,children:"V"}),
50
+ /* @__PURE__ */N("button",{onClick:()=>W("point"),className:"px-2 transition-colors "+("point"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:z.pointHint,children:z.point})]}),("horizontal"===I||"vertical"===I)&&/* @__PURE__ */k("div",{className:"flex items-center gap-1",children:[
51
+ /* @__PURE__ */N("input",{type:"number",inputMode:"decimal",step:"any",value:Y,placeholder:"horizontal"===I?z.fixX:z.fixY,onChange:e=>{const t=e.target.value;if(_(t),""===t.trim())V(null);else{const e=parseFloat(t);V(Number.isFinite(e)&&0!==e?e:null)}},className:"h-7 w-20 px-2 text-2xs font-mono rounded border border-line bg-surface text-ink focus:outline-none focus:border-orange-400",title:z.fixHint}),null!==G&&/* @__PURE__ */N("button",{onClick:()=>{V(null),_("")},className:"text-ink-faintest hover:text-gray-600 text-2xs px-1",title:z.clearFixed,children:"×"})]})]}),F&&null!==O&&/* @__PURE__ */k("div",{className:"px-2 py-1 text-2xs font-mono font-semibold text-orange-600 bg-orange-50 border border-orange-200 rounded whitespace-nowrap",title:"horizontal"===U?z.horizontalDistance("auto"===I):"vertical"===U?z.verticalDistance("auto"===I):z.straightDistance,children:[P(O),"horizontal"===U?" ↔":"vertical"===U?" ↕":""]}),
52
52
  /* @__PURE__ */N("button",{onClick:ce,className:pe,title:z.fitHint,children:z.fit}),
53
53
  /* @__PURE__ */k("button",{onClick:r??(()=>{const n=document.createElement("a");n.href=e,n.download=t,n.click()}),className:pe,children:[
54
54
  /* @__PURE__ */N(p,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),R.download]}),s&&/* @__PURE__ */k("button",{onClick:s,className:pe,children:[
@@ -79,7 +79,7 @@ return k("div",{ref:ie,className:"flex flex-col h-full",children:[
79
79
  /* @__PURE__ */k("div",{className:"shrink-0 border-t border-gray-200 bg-gray-50",children:[te&&/* @__PURE__ */N("div",{className:"px-3 pt-1 text-2xs font-mono text-ink-faint truncate",title:te,children:te}),
80
80
  /* @__PURE__ */k("div",{className:"flex items-center gap-2 px-3 h-7",children:[
81
81
  /* @__PURE__ */N("span",{className:"text-2xs font-mono font-semibold text-ink-faintest select-none",children:">"}),
82
- /* @__PURE__ */N("input",{ref:se,value:q,onChange:e=>ee(e.target.value),onKeyDown:e=>{"Enter"===e.key||" "===e.key?(e.preventDefault(),(e=>{const t=e.trim()||re.current;if(ee(""),!t)return;const n=t.toLowerCase().split(/\s+/)[0],r=()=>{re.current=t},s=(e,t)=>{H(!0),I(e),$.current?.(),ne(t),r()};if(/^-?(\d+\.?\d*|\.\d+)$/.test(n))if(!F||"horizontal"!==W&&"vertical"!==W)ne(z.fixedNeedsAxis);else{const e=parseFloat(n);e?(_(n),V(e),ne(z.axisLocked("horizontal"===W?"ΔX":"ΔY",P(Math.abs(e))))):(_(""),V(null),ne(z.fixedCleared))}else switch(n){case"di":case"dist":case"mea":case"measuregeom":s("point",z.echoDist);break;case"dim":case"dli":case"dimlin":case"dimlinear":s("auto",z.echoDimLinear);break;case"h":case"hor":case"horizontal":H(!0),I("horizontal"),ne(z.echoHorizontal),r();break;case"v":case"ver":case"vertical":H(!0),I("vertical"),ne(z.echoVertical),r();break;case"au":case"auto":H(!0),I("auto"),ne(z.echoAuto),r();break;case"measure":H(!F),ne(F?z.measureOff:z.measureOn),r();break;case"u":case"undo":K.current?.(),ne(z.pickRemoved),r();break;case"z":case"ze":case"zoom":case"fit":case"zoomextents":ce(),ne(z.zoomExtents),r();break;case"la":case"layer":case"layers":E(e=>!e),ne(z.layersToggled),r();break;case"off":case"clear":V(null),_(""),$.current?.(),ne(z.measurementCleared),r();break;case"?":case"help":ne(z.commandHelp);break;default:{const e=j[n];ne(e?z.readOnly(e):z.unknownCommand(n.toUpperCase()))}}})(q)):"Escape"===e.key&&(q?(e.stopPropagation(),ee(""),ne(z.cancelled)):e.target.blur())},placeholder:z.commandPlaceholder,spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent text-2xs font-mono text-ink focus:outline-none placeholder:text-gray-300"})]})]})]})}var z="https://cdn.jsdelivr.net/npm/online-3d-viewer@0.18.0/libs/";function R(e,t,n=0){return{id:e.GetId?.()??0,name:e.GetName?.()||(0===n?t.root:t.node),isMeshNode:!!e.IsMeshNode?.(),meshIndices:e.GetMeshIndices?.()??[],children:(e.GetChildNodes?.()??[]).map(e=>R(e,t,n+1))}}function D(e,t){t.add(e.id);for(const n of e.children)D(n,t)}function F(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(t),r=n?parseInt(n[1],16):0;return new e.RGBColor(r>>16&255,r>>8&255,255&r)}function P(e){return e>=1e3?`${(e/1e3).toFixed(3)} m`:`${e.toFixed(2)} mm`}function H({url:e,filename:t,onDownload:r,onEmail:s}){const i=b(null),o=b(null),a=b(null),[l,c]=w(!0),[d,u]=w(null),[m,f]=w(!0),x=y(),g=x.model,C=x.preview,E=b(g);E.current=g;const[L,M]=w(null),[S,j]=w({}),[T,H]=w(/* @__PURE__ */new Set),[W,I]=w("#f5f6f8"),[O,B]=w(!0),[G,X]=w("#000000"),[U,V]=w(1),[Y,_]=w(!1),[Z,J]=w(!1),[Q,$]=w(!1),[K,q]=w(!1),[ee,te]=w("x"),[ne,re]=w(!1),[se,ie]=w(.5),[oe,ae]=w(0),[le,ce]=w(!1),[de,ue]=w("point"),[pe,me]=w(null),he=b(null),fe=b(null);v(()=>{let n=!1,r=null,s=null;return c(!0),u(null),M(null),j({}),H(/* @__PURE__ */new Set),(async()=>{let l;try{l=await(import("online-3d-viewer"))}catch{return void(n||(u(E.current.notInstalled),c(!1)))}if(a.current=l,!n&&i.current&&(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),!n&&i.current))try{const a="undefined"!=typeof window&&window.__REACT_OS_SHELL_O3DV_LIBS__||z;l.SetExternalLibLocation?.(a),function(){if(A)return;if("undefined"==typeof HTMLCanvasElement)return;A=!0;const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,n){return"webgl"!==t&&"webgl2"!==t&&"experimental-webgl"!==t||(n={...n||{},stencil:!0}),e.call(this,t,n)},console.info("[Preview] section: canvas getContext patched (force stencil=true)")}(),r=new l.EmbeddedViewer(i.current,{backgroundColor:new l.RGBAColor(245,246,248,255),defaultColor:new l.RGBColor(180,188,200),edgeSettings:new l.EdgeSettings(!0,new l.RGBColor(0,0,0),1),onModelLoaded:()=>{if(!n){try{const e=r.GetModel?.(),t=e?.GetRootNode?.();if(t){const e=R(t,{root:E.current.rootNode,node:E.current.node});M(e);const n={[e.id]:!0};for(const t of e.children)n[t.id]=!0;j(n)}}catch(e){console.warn("[Preview] mesh tree extraction failed",e)}c(!1)}},onModelLoadFailed:()=>{n||(u(E.current.loadFailed),c(!1))}}),o.current=r;const d=new l.InputFile(t,l.FileSource.Url,e);r.LoadModelFromInputFiles([d]),i.current&&"undefined"!=typeof ResizeObserver&&(s=new ResizeObserver(()=>{try{const e=o.current;e?.Resize?e.Resize():e?.viewer?.Resize&&e.viewer.Resize(),e?.viewer?.Render?.()}catch{}}),s.observe(i.current))}catch(e){n||(u(e?.message||E.current.loadFailed),c(!1))}})(),()=>{n=!0;try{s?.disconnect()}catch{}try{r?.Destroy?.()}catch{}o.current=null}},[e,t]),v(()=>{const e=o.current;if(e?.viewer)try{const t=e=>{if(e.userData?.__sectionHelper)return;const t=e.userData?.originalMeshInstance??e.userData,n=t?.id?.nodeId??t?.nodeId;"number"==typeof n&&(e.visible=!T.has(n))};e.viewer.mainModel?.EnumerateMeshesAndLines?.(t),e.viewer.mainModel?.EnumerateEdges?.(t),e.viewer.Render?.()}catch(e){console.warn("[Preview] visibility update failed",e)}},[T,L]),v(()=>{const e=a.current,t=o.current;if(e&&t?.viewer)try{t.viewer.SetEdgeSettings(new e.EdgeSettings(O,F(e,G),U));const n=fe.current;if(n){const e=[];t.viewer.mainModel?.EnumerateEdges?.(t=>{t.userData?.__sectionHelper&&e.push(t)});for(const t of e)t.parent?.remove(t),t.geometry?.dispose?.(),t.material?.dispose?.();const r=n.plane,s=e=>{e&&!n.materialState.has(e)&&(n.materialState.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[r],e.clipShadows=!0,e.needsUpdate=!0)};t.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)s(e);else s(t)})}t.viewer.Render?.()}catch{}},[O,G,U]),v(()=>{const e=a.current,t=o.current;if(e&&t?.viewer)try{const n=F(e,W);t.viewer.SetBackgroundColor(new e.RGBAColor(n.r,n.g,n.b,255)),t.viewer.Render?.()}catch{}},[W]),v(()=>{const e=o.current;if(!e?.viewer||l)return;const t=e.viewer.renderer,n=e.viewer.scene;if(!t||!n)return;if(fe.current){const e=fe.current;for(const[t,n]of e.materialState.entries())t.clippingPlanes=n.clippingPlanes,t.clipShadows=n.clipShadows,t.needsUpdate=!0;for(const t of e.helpers)t.parent?.remove(t),t.material?.dispose?.();e.capMesh&&(n.remove(e.capMesh),e.capMesh.geometry?.dispose?.(),e.capMesh.material?.dispose?.()),fe.current=null}if(!K)return t.localClippingEnabled=!1,void e.viewer.Render?.();const r=e.viewer.GetBoundingBox?.(()=>!0);if(!r)return;const s=[];if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{e.userData?.__sectionHelper||s.push(e)}),!s.length)return t.localClippingEnabled=!1,void e.viewer.Render?.();const i=s[0],a=i.constructor,c=i.material?.constructor,d=i.geometry?.constructor,u=i.geometry?.attributes?.position?.constructor;a&&c&&d&&u||console.warn("[Preview] section: missing THREE constructors, falling back to no cap");const p=7681;let m=!0;try{const e=t.getContext?.(),n=e?.getContextAttributes?.();m=!1!==n?.stencil,t.autoClearStencil=!0,console.info("[Preview] section: stencil buffer =",m,"targets =",s.length)}catch{}t.localClippingEnabled=!0;const h={normal:{x:0,y:0,z:-1},constant:0,clone:function e(){const t={normal:{x:this.normal.x,y:this.normal.y,z:this.normal.z},constant:this.constant};return t.clone=e,t}},f=[],x=/* @__PURE__ */new Map,y=e=>{e&&!x.has(e)&&(x.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[h],e.clipShadows=!0,e.needsUpdate=!0)};for(const e of s){const t=e.material;if(Array.isArray(t))for(const e of t)y(e);else y(t);const n=Array.isArray(t)?t[0]:t;if(a&&m&&n?.clone){const t=(t,r)=>{const s=n.clone();s.depthWrite=!1,s.depthTest=!1,s.colorWrite=!1,s.stencilWrite=!0,s.stencilFunc=519,s.stencilFail=r,s.stencilZFail=r,s.stencilZPass=r,s.side=t,s.transparent=!1,s.clippingPlanes=[h],s.clipShadows=!0,s.needsUpdate=!0;const i=new a(e.geometry,s);i.matrixAutoUpdate=!1,i.renderOrder=1,i.userData.__sectionHelper=!0,e.add(i),f.push(i)};t(1,7682),t(0,7683)}}e.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)y(e);else y(t)});let g=null;const b=s[0]?.material&&(Array.isArray(s[0].material)?s[0].material[0]:s[0].material);if(m&&a&&d&&u&&b?.clone){const e=r.max.x-r.min.x,t=r.max.y-r.min.y,s=r.max.z-r.min.z,i=2*Math.max(e,t,s,1)/2,o=new d,l=new Float32Array([-i,-i,0,i,-i,0,i,i,0,-i,i,0]),c=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]);o.setAttribute("position",new u(l,3)),o.setAttribute("normal",new u(c,3)),o.setIndex([0,1,2,0,2,3]);const m=b.clone(),h=b.color?.getHex?.()??11844808;m.emissive?.setHex?.(h),"emissiveIntensity"in m&&(m.emissiveIntensity=.25),m.side=2,m.transparent=!1,m.opacity=1,m.stencilWrite=!0,m.stencilRef=0,m.stencilFunc=517,m.stencilFail=p,m.stencilZFail=p,m.stencilZPass=p,m.clippingPlanes=[],m.polygonOffset=!0,m.polygonOffsetFactor=-1,m.polygonOffsetUnits=-1,m.needsUpdate=!0,g=new a(o,m),g.renderOrder=2,g.userData.__sectionHelper=!0,n.add(g)}fe.current={plane:h,capMesh:g,helpers:f,materialState:x,bbox:r},console.info("[Preview] section: helpers =",f.length,"cap =",!!g),e.viewer.Render?.()},[K,l,L]),v(()=>{const e=o.current,t=fe.current;if(e?.viewer&&t&&K)try{const n=t.bbox,r="x"===ee?0:"y"===ee?1:2,s=[n.min.x,n.min.y,n.min.z][r],i=s+([n.max.x,n.max.y,n.max.z][r]-s)*se,o=oe*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=ne?-1:1;let d=0,u=0,p=0;"x"===ee?(d=c*a,p=c*l):"y"===ee?(u=c*a,d=c*l):(p=c*a,u=c*l);const m={x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2,z:(n.min.z+n.max.z)/2},h="x"===ee?i:m.x,f="y"===ee?i:m.y,x="z"===ee?i:m.z;if(t.plane.normal.x=d,t.plane.normal.y=u,t.plane.normal.z=p,t.plane.constant=-(d*h+u*f+p*x),t.capMesh){const e=m.x,n=m.y,r=m.z,s=d*e+u*n+p*r+t.plane.constant,i=e-d*s,o=n-u*s,a=r-p*s;t.capMesh.position.set(i,o,a),t.capMesh.lookAt?.(i+d,o+u,a+p)}e.viewer.Render?.()}catch(e){console.warn("[Preview] section update failed",e)}},[K,ee,ne,se,oe]),v(()=>{const e=o.current;if(!e?.viewer||l||!i.current)return;const t=e.viewer.renderer,n=e.viewer.scene,r=t?.domElement;if(!t||!n||!r)return;let s=null;if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{s||e.userData?.__sectionHelper||e.userData?.__measureHelper||(s=e)}),!s)return;const c=s.position.constructor,d=s.constructor,u=(Array.isArray(s.material)?s.material[0]:s.material)?.constructor,p=s.geometry.constructor,m=s.geometry.attributes?.position?.constructor;if(!(c&&d&&u&&p&&m))return;let h=null,f=null;n.traverse(e=>{if(h&&f)return;if(!e?.isLineSegments)return;h=e.constructor;const t=Array.isArray(e.material)?e.material[0]:e.material;t?.constructor&&(f=t.constructor)});const x=()=>{const t=he.current;if(t){null!==t.rafId&&cancelAnimationFrame(t.rafId);for(const e of t.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();t.line&&(n.remove(t.line),t.line.geometry?.dispose?.(),t.line.material?.dispose?.()),t.label&&t.label.parentElement&&t.label.parentElement.removeChild(t.label),he.current=null,e.viewer.Render?.()}};if(!le)return x(),void me(null);he.current={points:[],normals:[],markers:[],line:null,label:null,rafId:null};const y=a.current,g=y?.IntersectionMode?.MeshOnly??1,b=e.viewer.GetBoundingBox?.(()=>!0),w=b?Math.sqrt((b.max.x-b.min.x)**2+(b.max.y-b.min.y)**2+(b.max.z-b.min.z)**2):100,v=Math.max(.005*w,.2),k=e=>{const t=[],r=[];for(let e=0;e<=12;e++){const n=e/12*Math.PI;for(let e=0;e<=16;e++){const r=e/16*Math.PI*2;t.push(v*Math.sin(n)*Math.cos(r),v*Math.cos(n),v*Math.sin(n)*Math.sin(r))}}for(let e=0;e<12;e++)for(let t=0;t<16;t++){const n=17*e+t,s=n+16+1;r.push(n,s,n+1,s,s+1,n+1)}const s=new p;s.setAttribute("position",new m(new Float32Array(t),3)),s.setIndex(r),s.computeVertexNormals?.();const i=new u;i.color?.setHex?.(16746496),i.depthTest=!1,i.depthWrite=!1,i.transparent=!0,i.opacity=.95;const o=new d(s,i);return o.position.copy(e),o.renderOrder=9999,o.userData.__measureHelper=!0,n.add(o),o},N=()=>{const t=he.current;t&&((()=>{const t=he.current;if(!t||t.points.length<2||!t.label)return;const n=e.viewer.camera;if(!n)return;const s=t.points[0],i=t.points[1],o=new c((s.x+i.x)/2,(s.y+i.y)/2,(s.z+i.z)/2).clone();o.project?.(n);const a=r.getBoundingClientRect(),l=(o.x+1)/2*a.width,d=(1-o.y)/2*a.height;t.label.style.left=`${l}px`,t.label.style.top=`${d}px`;const u=l<0||d<0||l>a.width||d>a.height;t.label.style.opacity=o.z>1||u?"0":"1"})(),t.rafId=requestAnimationFrame(N))};he.current.rafId=requestAnimationFrame(N);let C=0,A=0,E=0,L=!1,M=!1;const S=t=>{if(!e.viewer.camera)return;const s=r.getBoundingClientRect(),o={x:t.clientX-s.left,y:t.clientY-s.top},a=e.viewer.GetMeshIntersectionUnderMouse?.(g,o);if(!a)return;const l=he.current,x=new c(a.point.x,a.point.y,a.point.z),y=(e=>{const t=e?.face?.normal,n=e?.object;if(!t||!n)return null;try{const e=new c(t.x,t.y,t.z);return e.transformDirection?.(n.matrixWorld),{x:e.x,y:e.y,z:e.z}}catch{return{x:t.x,y:t.y,z:t.z}}})(a);if(2===l.points.length){for(const e of l.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();l.line&&(n.remove(l.line),l.line.geometry?.dispose?.(),l.line.material?.dispose?.()),l.label&&(l.label.style.opacity="0"),l.points=[],l.markers=[],l.line=null,l.normals=[],me(null)}if(l.points.push(x),l.normals.push(y),"perp"===de){const e=((e,t)=>{const r=e?.geometry,s=r?.attributes?.position;if(!r||!s||!t?.face?.normal)return null;const i=s.array,o=r.index?r.index.array:null,a=new c(t.point.x,t.point.y,t.point.z);e.worldToLocal?.(a);const l=t.face.normal,h=-(l.x*a.x+l.y*a.y+l.z*a.z);r.computeBoundingBox?.();const f=r.boundingBox,x=f?Math.sqrt((f.max.x-f.min.x)**2+(f.max.y-f.min.y)**2+(f.max.z-f.min.z)**2):100,y=Math.max(.001*x,.005),g=o?o.length/3:s.count/3,b=[],w=new c;for(let t=0;t<g;t++){const n=o?o[3*t]:3*t,r=o?o[3*t+1]:3*t+1,s=o?o[3*t+2]:3*t+2,a=i[3*n],c=i[3*n+1],d=i[3*n+2],u=i[3*r],p=i[3*r+1],m=i[3*r+2],f=i[3*s],x=i[3*s+1],g=i[3*s+2],v=u-a,k=p-c,N=m-d,C=f-a,A=x-c,E=g-d;let L=k*E-N*A,M=N*C-v*E,S=v*A-k*C;const j=Math.sqrt(L*L+M*M+S*S);if(0===j)continue;if(L/=j,M/=j,S/=j,L*l.x+M*l.y+S*l.z<.9995)continue;const T=(a+u+f)/3,z=(c+p+x)/3,R=(d+m+g)/3;if(!(Math.abs(l.x*T+l.y*z+l.z*R+h)>y))for(const[t,n,r]of[[a,c,d],[u,p,m],[f,x,g]])w.set?.(t,n,r),e.localToWorld?.(w),b.push(w.x,w.y,w.z)}if(0===b.length)return null;const v=new p;v.setAttribute("position",new m(new Float32Array(b),3)),v.computeVertexNormals?.();const k=new u;k.color?.setHex?.(16746496),k.transparent=!0,k.opacity=.45,k.depthWrite=!1,k.polygonOffset=!0,k.polygonOffsetFactor=-2,k.polygonOffsetUnits=-2;const N=new d(v,k);return N.renderOrder=9998,N.userData.__measureHelper=!0,n.add(N),N})(a.object,a);l.markers.push(e??k(x))}else l.markers.push(k(x));if(2===l.points.length){const e=l.points[0];let t,r=l.points[1],s="";if("perp"===de){const n=l.normals[0]??l.normals[1];if(n){const i=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)||1,o=n.x/i,a=n.y/i,d=n.z/i,u=(r.x-e.x)*o+(r.y-e.y)*a+(r.z-e.z)*d,p=new c(e.x+o*u,e.y+a*u,e.z+d*u);l.points[1]=p,r=p,t=Math.abs(u),s=" ⊥"}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}l.line=((e,t)=>{const r=new p;r.setAttribute("position",new m(new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z]),3));const s=new(h??d)(r,new(f??u)({color:16746496,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95}));return s.renderOrder=9998,s.userData.__measureHelper=!0,n.add(s),s})(e,r),me(t);const o=(()=>{const e=he.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.transform="translate(-50%, -50%)",t.style.padding="2px 6px",t.style.fontSize="11px",t.style.fontWeight="600",t.style.fontFamily="system-ui, -apple-system, sans-serif",t.style.background="rgba(255, 136, 0, 0.95)",t.style.color="#fff",t.style.borderRadius="4px",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.boxShadow="0 1px 4px rgba(0,0,0,0.25)",t.style.zIndex="5",i.current.appendChild(t),e.label=t,t})();o.textContent=`${P(t)}${s}`}e.viewer.Render?.()},j=e=>{0===e.button&&(C=e.clientX,A=e.clientY,E=performance.now(),L=!1,M=!0)},T=e=>{if(!M)return;const t=e.clientX-C,n=e.clientY-A;t*t+n*n>16&&(L=!0)},z=e=>{if(0!==e.button||!M)return;const t=performance.now()-E;M=!1,!L&&t<350&&S(e)},R=e=>{"Escape"===e.key&&ce(!1)};return r.style.cursor="crosshair",r.addEventListener("pointerdown",j),r.addEventListener("pointermove",T),r.addEventListener("pointerup",z),r.addEventListener("pointercancel",z),window.addEventListener("keydown",R),()=>{r.style.cursor="",r.removeEventListener("pointerdown",j),r.removeEventListener("pointermove",T),r.removeEventListener("pointerup",z),r.removeEventListener("pointercancel",z),window.removeEventListener("keydown",R),x(),me(null)}},[le,de,l,L]),v(()=>{if(!m||l)return;const e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[m,l]);const xe=e=>{const t=/* @__PURE__ */new Set;D(e,t),H(e=>{const n=new Set(e),r=[...t].some(e=>!n.has(e));for(const e of t)r?n.add(e):n.delete(e);return n})},ye=()=>{try{const e=o.current,t=e?.viewer?.GetBoundingSphere?.(()=>!0);t&&e.viewer.FitSphereToWindow(t,!0),e?.viewer?.Render?.()}catch{}};v(()=>{const e=a.current,t=o.current;if(e&&t?.viewer&&!l)try{t.viewer.SetProjectionMode(Q?e.ProjectionMode.Perspective:e.ProjectionMode.Orthographic)}catch{}},[Q,l]);const ge=e=>{const t=a.current,n=o.current;if(t&&n?.viewer)try{const r=n.viewer.GetBoundingSphere?.(()=>!0);if(!r)return;const s=r.center,i=3*(r.radius||1),o=s.x??0,a=s.y??0,l=s.z??0;let c,d;switch(e){case"top":c=new t.Coord3D(o,a,l+i),d=new t.Coord3D(0,1,0);break;case"front":c=new t.Coord3D(o,a-i,l),d=new t.Coord3D(0,0,1);break;case"side":c=new t.Coord3D(o+i,a,l),d=new t.Coord3D(0,0,1);break;default:{const e=i/Math.sqrt(3);c=new t.Coord3D(o+e,a-e,l+e),d=new t.Coord3D(0,0,1);break}}const u=new t.Coord3D(o,a,l),p=new t.Camera(c,u,d,45);n.viewer.SetCamera(p),n.viewer.AdjustClippingPlanesToSphere?.(r),n.viewer.Render?.()}catch{}},be=(t.split(".").pop()||"").toUpperCase(),we=(e,t=0)=>{const n=e.children.length>0,r=!1!==S[e.id],s=!T.has(e.id);/* @__PURE__ */
82
+ /* @__PURE__ */N("input",{ref:se,value:q,onChange:e=>ee(e.target.value),onKeyDown:e=>{"Enter"===e.key||" "===e.key?(e.preventDefault(),(e=>{const t=e.trim()||re.current;if(ee(""),!t)return;const n=t.toLowerCase().split(/\s+/)[0],r=()=>{re.current=t},s=(e,t)=>{H(!0),W(e),J.current?.(),ne(t),r()};if(/^-?(\d+\.?\d*|\.\d+)$/.test(n))if(!F||"horizontal"!==I&&"vertical"!==I)ne(z.fixedNeedsAxis);else{const e=parseFloat(n);e?(_(n),V(e),ne(z.axisLocked("horizontal"===I?"ΔX":"ΔY",P(Math.abs(e))))):(_(""),V(null),ne(z.fixedCleared))}else switch(n){case"di":case"dist":case"mea":case"measuregeom":s("point",z.echoDist);break;case"dim":case"dli":case"dimlin":case"dimlinear":s("auto",z.echoDimLinear);break;case"h":case"hor":case"horizontal":H(!0),W("horizontal"),ne(z.echoHorizontal),r();break;case"v":case"ver":case"vertical":H(!0),W("vertical"),ne(z.echoVertical),r();break;case"au":case"auto":H(!0),W("auto"),ne(z.echoAuto),r();break;case"measure":H(!F),ne(F?z.measureOff:z.measureOn),r();break;case"u":case"undo":Q.current?.(),ne(z.pickRemoved),r();break;case"z":case"ze":case"zoom":case"fit":case"zoomextents":ce(),ne(z.zoomExtents),r();break;case"la":case"layer":case"layers":E(e=>!e),ne(z.layersToggled),r();break;case"off":case"clear":V(null),_(""),J.current?.(),ne(z.measurementCleared),r();break;case"?":case"help":ne(z.commandHelp);break;default:{const e=j[n];ne(e?z.readOnly(e):z.unknownCommand(n.toUpperCase()))}}})(q)):"Escape"===e.key&&(q?(e.stopPropagation(),ee(""),ne(z.cancelled)):e.target.blur())},placeholder:z.commandPlaceholder,spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent text-2xs font-mono text-ink focus:outline-none placeholder:text-gray-300"})]})]})]})}var z="https://cdn.jsdelivr.net/npm/online-3d-viewer@0.18.0/libs/";function R(e,t,n=0){return{id:e.GetId?.()??0,name:e.GetName?.()||(0===n?t.root:t.node),isMeshNode:!!e.IsMeshNode?.(),meshIndices:e.GetMeshIndices?.()??[],children:(e.GetChildNodes?.()??[]).map(e=>R(e,t,n+1))}}function D(e,t){t.add(e.id);for(const n of e.children)D(n,t)}function F(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(t),r=n?parseInt(n[1],16):0;return new e.RGBColor(r>>16&255,r>>8&255,255&r)}function P(e){return e>=1e3?`${(e/1e3).toFixed(3)} m`:`${e.toFixed(2)} mm`}function H({url:e,filename:t,onDownload:r,onEmail:s}){const i=b(null),o=b(null),a=b(null),[l,c]=w(!0),[d,u]=w(null),[m,f]=w(!0),x=y(),g=x.model,C=x.preview,E=b(g);E.current=g;const[L,M]=w(null),[S,j]=w({}),[T,H]=w(/* @__PURE__ */new Set),[I,W]=w("#f5f6f8"),[O,B]=w(!0),[U,X]=w("#000000"),[G,V]=w(1),[Y,_]=w(!1),[Z,$]=w(!1),[K,J]=w(!1),[Q,q]=w(!1),[ee,te]=w("x"),[ne,re]=w(!1),[se,ie]=w(.5),[oe,ae]=w(0),[le,ce]=w(!1),[de,ue]=w("point"),[pe,me]=w(null),he=b(null),fe=b(null);v(()=>{let n=!1,r=null,s=null;return c(!0),u(null),M(null),j({}),H(/* @__PURE__ */new Set),(async()=>{let l;try{l=await(import("online-3d-viewer"))}catch{return void(n||(u(E.current.notInstalled),c(!1)))}if(a.current=l,!n&&i.current&&(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),!n&&i.current))try{const a="undefined"!=typeof window&&window.__REACT_OS_SHELL_O3DV_LIBS__||z;l.SetExternalLibLocation?.(a),function(){if(A)return;if("undefined"==typeof HTMLCanvasElement)return;A=!0;const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,n){return"webgl"!==t&&"webgl2"!==t&&"experimental-webgl"!==t||(n={...n||{},stencil:!0}),e.call(this,t,n)},console.info("[Preview] section: canvas getContext patched (force stencil=true)")}(),r=new l.EmbeddedViewer(i.current,{backgroundColor:new l.RGBAColor(245,246,248,255),defaultColor:new l.RGBColor(180,188,200),edgeSettings:new l.EdgeSettings(!0,new l.RGBColor(0,0,0),1),onModelLoaded:()=>{if(!n){try{const e=r.GetModel?.(),t=e?.GetRootNode?.();if(t){const e=R(t,{root:E.current.rootNode,node:E.current.node});M(e);const n={[e.id]:!0};for(const t of e.children)n[t.id]=!0;j(n)}}catch(e){console.warn("[Preview] mesh tree extraction failed",e)}c(!1)}},onModelLoadFailed:()=>{n||(u(E.current.loadFailed),c(!1))}}),o.current=r;const d=new l.InputFile(t,l.FileSource.Url,e);r.LoadModelFromInputFiles([d]),i.current&&"undefined"!=typeof ResizeObserver&&(s=new ResizeObserver(()=>{try{const e=o.current;e?.Resize?e.Resize():e?.viewer?.Resize&&e.viewer.Resize(),e?.viewer?.Render?.()}catch{}}),s.observe(i.current))}catch(e){n||(u(e?.message||E.current.loadFailed),c(!1))}})(),()=>{n=!0;try{s?.disconnect()}catch{}try{r?.Destroy?.()}catch{}o.current=null}},[e,t]),v(()=>{const e=o.current;if(e?.viewer)try{const t=e=>{if(e.userData?.__sectionHelper)return;const t=e.userData?.originalMeshInstance??e.userData,n=t?.id?.nodeId??t?.nodeId;"number"==typeof n&&(e.visible=!T.has(n))};e.viewer.mainModel?.EnumerateMeshesAndLines?.(t),e.viewer.mainModel?.EnumerateEdges?.(t),e.viewer.Render?.()}catch(e){console.warn("[Preview] visibility update failed",e)}},[T,L]),v(()=>{const e=a.current,t=o.current;if(e&&t?.viewer)try{t.viewer.SetEdgeSettings(new e.EdgeSettings(O,F(e,U),G));const n=fe.current;if(n){const e=[];t.viewer.mainModel?.EnumerateEdges?.(t=>{t.userData?.__sectionHelper&&e.push(t)});for(const t of e)t.parent?.remove(t),t.geometry?.dispose?.(),t.material?.dispose?.();const r=n.plane,s=e=>{e&&!n.materialState.has(e)&&(n.materialState.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[r],e.clipShadows=!0,e.needsUpdate=!0)};t.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)s(e);else s(t)})}t.viewer.Render?.()}catch{}},[O,U,G]),v(()=>{const e=a.current,t=o.current;if(e&&t?.viewer)try{const n=F(e,I);t.viewer.SetBackgroundColor(new e.RGBAColor(n.r,n.g,n.b,255)),t.viewer.Render?.()}catch{}},[I]),v(()=>{const e=o.current;if(!e?.viewer||l)return;const t=e.viewer.renderer,n=e.viewer.scene;if(!t||!n)return;if(fe.current){const e=fe.current;for(const[t,n]of e.materialState.entries())t.clippingPlanes=n.clippingPlanes,t.clipShadows=n.clipShadows,t.needsUpdate=!0;for(const t of e.helpers)t.parent?.remove(t),t.material?.dispose?.();e.capMesh&&(n.remove(e.capMesh),e.capMesh.geometry?.dispose?.(),e.capMesh.material?.dispose?.()),fe.current=null}if(!Q)return t.localClippingEnabled=!1,void e.viewer.Render?.();const r=e.viewer.GetBoundingBox?.(()=>!0);if(!r)return;const s=[];if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{e.userData?.__sectionHelper||s.push(e)}),!s.length)return t.localClippingEnabled=!1,void e.viewer.Render?.();const i=s[0],a=i.constructor,c=i.material?.constructor,d=i.geometry?.constructor,u=i.geometry?.attributes?.position?.constructor;a&&c&&d&&u||console.warn("[Preview] section: missing THREE constructors, falling back to no cap");const p=7681;let m=!0;try{const e=t.getContext?.(),n=e?.getContextAttributes?.();m=!1!==n?.stencil,t.autoClearStencil=!0,console.info("[Preview] section: stencil buffer =",m,"targets =",s.length)}catch{}t.localClippingEnabled=!0;const h={normal:{x:0,y:0,z:-1},constant:0,clone:function e(){const t={normal:{x:this.normal.x,y:this.normal.y,z:this.normal.z},constant:this.constant};return t.clone=e,t}},f=[],x=/* @__PURE__ */new Map,y=e=>{e&&!x.has(e)&&(x.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[h],e.clipShadows=!0,e.needsUpdate=!0)};for(const e of s){const t=e.material;if(Array.isArray(t))for(const e of t)y(e);else y(t);const n=Array.isArray(t)?t[0]:t;if(a&&m&&n?.clone){const t=(t,r)=>{const s=n.clone();s.depthWrite=!1,s.depthTest=!1,s.colorWrite=!1,s.stencilWrite=!0,s.stencilFunc=519,s.stencilFail=r,s.stencilZFail=r,s.stencilZPass=r,s.side=t,s.transparent=!1,s.clippingPlanes=[h],s.clipShadows=!0,s.needsUpdate=!0;const i=new a(e.geometry,s);i.matrixAutoUpdate=!1,i.renderOrder=1,i.userData.__sectionHelper=!0,e.add(i),f.push(i)};t(1,7682),t(0,7683)}}e.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)y(e);else y(t)});let g=null;const b=s[0]?.material&&(Array.isArray(s[0].material)?s[0].material[0]:s[0].material);if(m&&a&&d&&u&&b?.clone){const e=r.max.x-r.min.x,t=r.max.y-r.min.y,s=r.max.z-r.min.z,i=2*Math.max(e,t,s,1)/2,o=new d,l=new Float32Array([-i,-i,0,i,-i,0,i,i,0,-i,i,0]),c=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]);o.setAttribute("position",new u(l,3)),o.setAttribute("normal",new u(c,3)),o.setIndex([0,1,2,0,2,3]);const m=b.clone(),h=b.color?.getHex?.()??11844808;m.emissive?.setHex?.(h),"emissiveIntensity"in m&&(m.emissiveIntensity=.25),m.side=2,m.transparent=!1,m.opacity=1,m.stencilWrite=!0,m.stencilRef=0,m.stencilFunc=517,m.stencilFail=p,m.stencilZFail=p,m.stencilZPass=p,m.clippingPlanes=[],m.polygonOffset=!0,m.polygonOffsetFactor=-1,m.polygonOffsetUnits=-1,m.needsUpdate=!0,g=new a(o,m),g.renderOrder=2,g.userData.__sectionHelper=!0,n.add(g)}fe.current={plane:h,capMesh:g,helpers:f,materialState:x,bbox:r},console.info("[Preview] section: helpers =",f.length,"cap =",!!g),e.viewer.Render?.()},[Q,l,L]),v(()=>{const e=o.current,t=fe.current;if(e?.viewer&&t&&Q)try{const n=t.bbox,r="x"===ee?0:"y"===ee?1:2,s=[n.min.x,n.min.y,n.min.z][r],i=s+([n.max.x,n.max.y,n.max.z][r]-s)*se,o=oe*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=ne?-1:1;let d=0,u=0,p=0;"x"===ee?(d=c*a,p=c*l):"y"===ee?(u=c*a,d=c*l):(p=c*a,u=c*l);const m={x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2,z:(n.min.z+n.max.z)/2},h="x"===ee?i:m.x,f="y"===ee?i:m.y,x="z"===ee?i:m.z;if(t.plane.normal.x=d,t.plane.normal.y=u,t.plane.normal.z=p,t.plane.constant=-(d*h+u*f+p*x),t.capMesh){const e=m.x,n=m.y,r=m.z,s=d*e+u*n+p*r+t.plane.constant,i=e-d*s,o=n-u*s,a=r-p*s;t.capMesh.position.set(i,o,a),t.capMesh.lookAt?.(i+d,o+u,a+p)}e.viewer.Render?.()}catch(e){console.warn("[Preview] section update failed",e)}},[Q,ee,ne,se,oe]),v(()=>{const e=o.current;if(!e?.viewer||l||!i.current)return;const t=e.viewer.renderer,n=e.viewer.scene,r=t?.domElement;if(!t||!n||!r)return;let s=null;if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{s||e.userData?.__sectionHelper||e.userData?.__measureHelper||(s=e)}),!s)return;const c=s.position.constructor,d=s.constructor,u=(Array.isArray(s.material)?s.material[0]:s.material)?.constructor,p=s.geometry.constructor,m=s.geometry.attributes?.position?.constructor;if(!(c&&d&&u&&p&&m))return;let h=null,f=null;n.traverse(e=>{if(h&&f)return;if(!e?.isLineSegments)return;h=e.constructor;const t=Array.isArray(e.material)?e.material[0]:e.material;t?.constructor&&(f=t.constructor)});const x=()=>{const t=he.current;if(t){null!==t.rafId&&cancelAnimationFrame(t.rafId);for(const e of t.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();t.line&&(n.remove(t.line),t.line.geometry?.dispose?.(),t.line.material?.dispose?.()),t.label&&t.label.parentElement&&t.label.parentElement.removeChild(t.label),he.current=null,e.viewer.Render?.()}};if(!le)return x(),void me(null);he.current={points:[],normals:[],markers:[],line:null,label:null,rafId:null};const y=a.current,g=y?.IntersectionMode?.MeshOnly??1,b=e.viewer.GetBoundingBox?.(()=>!0),w=b?Math.sqrt((b.max.x-b.min.x)**2+(b.max.y-b.min.y)**2+(b.max.z-b.min.z)**2):100,v=Math.max(.005*w,.2),k=e=>{const t=[],r=[];for(let e=0;e<=12;e++){const n=e/12*Math.PI;for(let e=0;e<=16;e++){const r=e/16*Math.PI*2;t.push(v*Math.sin(n)*Math.cos(r),v*Math.cos(n),v*Math.sin(n)*Math.sin(r))}}for(let e=0;e<12;e++)for(let t=0;t<16;t++){const n=17*e+t,s=n+16+1;r.push(n,s,n+1,s,s+1,n+1)}const s=new p;s.setAttribute("position",new m(new Float32Array(t),3)),s.setIndex(r),s.computeVertexNormals?.();const i=new u;i.color?.setHex?.(16746496),i.depthTest=!1,i.depthWrite=!1,i.transparent=!0,i.opacity=.95;const o=new d(s,i);return o.position.copy(e),o.renderOrder=9999,o.userData.__measureHelper=!0,n.add(o),o},N=()=>{const t=he.current;t&&((()=>{const t=he.current;if(!t||t.points.length<2||!t.label)return;const n=e.viewer.camera;if(!n)return;const s=t.points[0],i=t.points[1],o=new c((s.x+i.x)/2,(s.y+i.y)/2,(s.z+i.z)/2).clone();o.project?.(n);const a=r.getBoundingClientRect(),l=(o.x+1)/2*a.width,d=(1-o.y)/2*a.height;t.label.style.left=`${l}px`,t.label.style.top=`${d}px`;const u=l<0||d<0||l>a.width||d>a.height;t.label.style.opacity=o.z>1||u?"0":"1"})(),t.rafId=requestAnimationFrame(N))};he.current.rafId=requestAnimationFrame(N);let C=0,A=0,E=0,L=!1,M=!1;const S=t=>{if(!e.viewer.camera)return;const s=r.getBoundingClientRect(),o={x:t.clientX-s.left,y:t.clientY-s.top},a=e.viewer.GetMeshIntersectionUnderMouse?.(g,o);if(!a)return;const l=he.current,x=new c(a.point.x,a.point.y,a.point.z),y=(e=>{const t=e?.face?.normal,n=e?.object;if(!t||!n)return null;try{const e=new c(t.x,t.y,t.z);return e.transformDirection?.(n.matrixWorld),{x:e.x,y:e.y,z:e.z}}catch{return{x:t.x,y:t.y,z:t.z}}})(a);if(2===l.points.length){for(const e of l.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();l.line&&(n.remove(l.line),l.line.geometry?.dispose?.(),l.line.material?.dispose?.()),l.label&&(l.label.style.opacity="0"),l.points=[],l.markers=[],l.line=null,l.normals=[],me(null)}if(l.points.push(x),l.normals.push(y),"perp"===de){const e=((e,t)=>{const r=e?.geometry,s=r?.attributes?.position;if(!r||!s||!t?.face?.normal)return null;const i=s.array,o=r.index?r.index.array:null,a=new c(t.point.x,t.point.y,t.point.z);e.worldToLocal?.(a);const l=t.face.normal,h=-(l.x*a.x+l.y*a.y+l.z*a.z);r.computeBoundingBox?.();const f=r.boundingBox,x=f?Math.sqrt((f.max.x-f.min.x)**2+(f.max.y-f.min.y)**2+(f.max.z-f.min.z)**2):100,y=Math.max(.001*x,.005),g=o?o.length/3:s.count/3,b=[],w=new c;for(let t=0;t<g;t++){const n=o?o[3*t]:3*t,r=o?o[3*t+1]:3*t+1,s=o?o[3*t+2]:3*t+2,a=i[3*n],c=i[3*n+1],d=i[3*n+2],u=i[3*r],p=i[3*r+1],m=i[3*r+2],f=i[3*s],x=i[3*s+1],g=i[3*s+2],v=u-a,k=p-c,N=m-d,C=f-a,A=x-c,E=g-d;let L=k*E-N*A,M=N*C-v*E,S=v*A-k*C;const j=Math.sqrt(L*L+M*M+S*S);if(0===j)continue;if(L/=j,M/=j,S/=j,L*l.x+M*l.y+S*l.z<.9995)continue;const T=(a+u+f)/3,z=(c+p+x)/3,R=(d+m+g)/3;if(!(Math.abs(l.x*T+l.y*z+l.z*R+h)>y))for(const[t,n,r]of[[a,c,d],[u,p,m],[f,x,g]])w.set?.(t,n,r),e.localToWorld?.(w),b.push(w.x,w.y,w.z)}if(0===b.length)return null;const v=new p;v.setAttribute("position",new m(new Float32Array(b),3)),v.computeVertexNormals?.();const k=new u;k.color?.setHex?.(16746496),k.transparent=!0,k.opacity=.45,k.depthWrite=!1,k.polygonOffset=!0,k.polygonOffsetFactor=-2,k.polygonOffsetUnits=-2;const N=new d(v,k);return N.renderOrder=9998,N.userData.__measureHelper=!0,n.add(N),N})(a.object,a);l.markers.push(e??k(x))}else l.markers.push(k(x));if(2===l.points.length){const e=l.points[0];let t,r=l.points[1],s="";if("perp"===de){const n=l.normals[0]??l.normals[1];if(n){const i=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)||1,o=n.x/i,a=n.y/i,d=n.z/i,u=(r.x-e.x)*o+(r.y-e.y)*a+(r.z-e.z)*d,p=new c(e.x+o*u,e.y+a*u,e.z+d*u);l.points[1]=p,r=p,t=Math.abs(u),s=" ⊥"}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}l.line=((e,t)=>{const r=new p;r.setAttribute("position",new m(new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z]),3));const s=new(h??d)(r,new(f??u)({color:16746496,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95}));return s.renderOrder=9998,s.userData.__measureHelper=!0,n.add(s),s})(e,r),me(t);const o=(()=>{const e=he.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.transform="translate(-50%, -50%)",t.style.padding="2px 6px",t.style.fontSize="11px",t.style.fontWeight="600",t.style.fontFamily="system-ui, -apple-system, sans-serif",t.style.background="rgba(255, 136, 0, 0.95)",t.style.color="#fff",t.style.borderRadius="4px",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.boxShadow="0 1px 4px rgba(0,0,0,0.25)",t.style.zIndex="5",i.current.appendChild(t),e.label=t,t})();o.textContent=`${P(t)}${s}`}e.viewer.Render?.()},j=e=>{0===e.button&&(C=e.clientX,A=e.clientY,E=performance.now(),L=!1,M=!0)},T=e=>{if(!M)return;const t=e.clientX-C,n=e.clientY-A;t*t+n*n>16&&(L=!0)},z=e=>{if(0!==e.button||!M)return;const t=performance.now()-E;M=!1,!L&&t<350&&S(e)},R=e=>{"Escape"===e.key&&ce(!1)};return r.style.cursor="crosshair",r.addEventListener("pointerdown",j),r.addEventListener("pointermove",T),r.addEventListener("pointerup",z),r.addEventListener("pointercancel",z),window.addEventListener("keydown",R),()=>{r.style.cursor="",r.removeEventListener("pointerdown",j),r.removeEventListener("pointermove",T),r.removeEventListener("pointerup",z),r.removeEventListener("pointercancel",z),window.removeEventListener("keydown",R),x(),me(null)}},[le,de,l,L]),v(()=>{if(!m||l)return;const e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[m,l]);const xe=e=>{const t=/* @__PURE__ */new Set;D(e,t),H(e=>{const n=new Set(e),r=[...t].some(e=>!n.has(e));for(const e of t)r?n.add(e):n.delete(e);return n})},ye=()=>{try{const e=o.current,t=e?.viewer?.GetBoundingSphere?.(()=>!0);t&&e.viewer.FitSphereToWindow(t,!0),e?.viewer?.Render?.()}catch{}};v(()=>{const e=a.current,t=o.current;if(e&&t?.viewer&&!l)try{t.viewer.SetProjectionMode(K?e.ProjectionMode.Perspective:e.ProjectionMode.Orthographic)}catch{}},[K,l]);const ge=e=>{const t=a.current,n=o.current;if(t&&n?.viewer)try{const r=n.viewer.GetBoundingSphere?.(()=>!0);if(!r)return;const s=r.center,i=3*(r.radius||1),o=s.x??0,a=s.y??0,l=s.z??0;let c,d;switch(e){case"top":c=new t.Coord3D(o,a,l+i),d=new t.Coord3D(0,1,0);break;case"front":c=new t.Coord3D(o,a-i,l),d=new t.Coord3D(0,0,1);break;case"side":c=new t.Coord3D(o+i,a,l),d=new t.Coord3D(0,0,1);break;default:{const e=i/Math.sqrt(3);c=new t.Coord3D(o+e,a-e,l+e),d=new t.Coord3D(0,0,1);break}}const u=new t.Coord3D(o,a,l),p=new t.Camera(c,u,d,45);n.viewer.SetCamera(p),n.viewer.AdjustClippingPlanesToSphere?.(r),n.viewer.Render?.()}catch{}},be=(t.split(".").pop()||"").toUpperCase(),we=(e,t=0)=>{const n=e.children.length>0,r=!1!==S[e.id],s=!T.has(e.id);/* @__PURE__ */
83
83
  return k("div",{children:[
84
84
  /* @__PURE__ */k("div",{className:"group flex items-center gap-1 px-2 py-1 hover:bg-gray-100 cursor-default text-xs text-ink",style:{paddingLeft:12*t+6+"px"},children:[n?/* @__PURE__ */N("button",{onClick:()=>{return t=e.id,void j(e=>({...e,[t]:!e[t]}));var t},className:"h-4 w-4 shrink-0 flex items-center justify-center text-gray-500 hover:text-gray-900",title:r?g.collapse:g.expand,children:/* @__PURE__ */N(p,r?{name:"chevron-down",className:"h-3 w-3",strokeWidth:2}:{name:"chevron-right",className:"h-3 w-3",strokeWidth:2})}):/* @__PURE__ */N("span",{className:"h-4 w-4 shrink-0 flex items-center justify-center",children:/* @__PURE__ */N("span",{className:"h-1 w-1 rounded-full bg-gray-400"})}),
85
85
  /* @__PURE__ */N("span",{className:"flex-1 truncate "+(s?"":"opacity-40"),title:e.name,children:e.name}),
@@ -93,7 +93,7 @@ return k("div",{className:"flex flex-col h-full bg-white",children:[
93
93
  /* @__PURE__ */N("button",{onClick:()=>ge("top"),className:ve,title:g.topView,children:/* @__PURE__ */N("span",{className:"text-2xs font-semibold",children:g.top})}),
94
94
  /* @__PURE__ */N("button",{onClick:()=>ge("front"),className:ve,title:g.frontView,children:/* @__PURE__ */N("span",{className:"text-2xs font-semibold",children:g.front})}),
95
95
  /* @__PURE__ */N("button",{onClick:()=>ge("side"),className:ve,title:g.sideView,children:/* @__PURE__ */N("span",{className:"text-2xs font-semibold",children:g.side})}),
96
- /* @__PURE__ */N("button",{onClick:()=>$(e=>!e),className:Q?"h-8 shrink-0 flex items-center justify-center px-2 rounded bg-gray-200 text-gray-900":"h-8 shrink-0 flex items-center justify-center px-2 rounded text-gray-600 hover:bg-gray-200 hover:text-gray-900 transition-colors",title:Q?g.toOrthographic:g.toPerspective,children:/* @__PURE__ */N("span",{className:"text-2xs font-semibold whitespace-nowrap",children:Q?g.perspective:g.orthographic})}),
96
+ /* @__PURE__ */N("button",{onClick:()=>J(e=>!e),className:K?"h-8 shrink-0 flex items-center justify-center px-2 rounded bg-gray-200 text-gray-900":"h-8 shrink-0 flex items-center justify-center px-2 rounded text-gray-600 hover:bg-gray-200 hover:text-gray-900 transition-colors",title:K?g.toOrthographic:g.toPerspective,children:/* @__PURE__ */N("span",{className:"text-2xs font-semibold whitespace-nowrap",children:K?g.perspective:g.orthographic})}),
97
97
  /* @__PURE__ */N("div",{className:Ne}),
98
98
  /* @__PURE__ */N("button",{onClick:()=>{try{const e=o.current,n=e?.viewer?.GetCanvasSize?.()??{width:1280,height:720},r=e?.viewer?.GetImageAsDataUrl?.(n.width,n.height,!1);if(!r)return;const s=document.createElement("a");s.href=r,s.download=`${t.replace(/\.[^.]+$/,"")}-snapshot.png`,s.click()}catch{}},className:ve,title:g.snapshot,children:/* @__PURE__ */N(p,{name:"camera",className:"h-4 w-4",strokeWidth:1.5})}),
99
99
  /* @__PURE__ */N("button",{onClick:()=>f(e=>!e),className:ve,title:C.howToNavigate,children:/* @__PURE__ */N(p,{name:"help",className:"h-4 w-4",strokeWidth:1.5})}),
@@ -104,9 +104,9 @@ return k("div",{className:"flex flex-col h-full bg-white",children:[
104
104
  /* @__PURE__ */N("button",{onClick:()=>ue("perp"),className:"px-2 text-xs font-semibold transition-colors "+("perp"===de?"bg-orange-500 text-on-accent":"bg-surface text-gray-600 hover:bg-row-hover"),title:g.perpendicularHint,children:"⊥"})]}),le&&null!==pe&&/* @__PURE__ */k("div",{className:"px-2 py-1 text-2xs font-mono font-semibold text-orange-600 bg-orange-50 border border-orange-200 rounded whitespace-nowrap",title:"perp"===de?g.perpendicularDistance:g.straightDistance,children:[P(pe),"perp"===de?" ⊥":""]}),
105
105
  /* @__PURE__ */N("div",{className:Ne}),
106
106
  /* @__PURE__ */N("button",{onClick:()=>_(e=>!e),className:Y?ke:ve,title:g.meshesHint,children:/* @__PURE__ */N(p,{name:"menu",className:"h-4 w-4",strokeWidth:1.5})}),
107
- /* @__PURE__ */N("button",{onClick:()=>J(e=>!e),className:Z?ke:ve,title:g.displayHint,children:/* @__PURE__ */N(p,{name:"settings",className:"h-4 w-4",strokeWidth:1.5})}),
107
+ /* @__PURE__ */N("button",{onClick:()=>$(e=>!e),className:Z?ke:ve,title:g.displayHint,children:/* @__PURE__ */N(p,{name:"settings",className:"h-4 w-4",strokeWidth:1.5})}),
108
108
  /* @__PURE__ */N("button",{onClick:r??(()=>{const n=document.createElement("a");n.href=e,n.download=t,n.click()}),className:ve,title:g.downloadOriginal,children:/* @__PURE__ */N(p,{name:"download",className:"h-4 w-4",strokeWidth:1.5})}),s&&/* @__PURE__ */N("button",{onClick:s,className:ve,title:C.email,children:/* @__PURE__ */N(p,{name:"email",className:"h-4 w-4",strokeWidth:1.5})})]}),
109
- /* @__PURE__ */N("div",{className:"flex-1 flex min-h-0",children:/* @__PURE__ */k("div",{className:"relative flex-1 min-w-0",style:{background:W},children:[
109
+ /* @__PURE__ */N("div",{className:"flex-1 flex min-h-0",children:/* @__PURE__ */k("div",{className:"relative flex-1 min-w-0",style:{background:I},children:[
110
110
  /* @__PURE__ */N("div",{ref:i,style:{width:"100%",height:"100%"}}),Y&&/* @__PURE__ */k("div",{className:"absolute top-2 left-2 w-64 max-h-[80%] flex flex-col bg-white/95 backdrop-blur border border-gray-200 rounded-md shadow-xl z-10 text-xs",children:[
111
111
  /* @__PURE__ */k("div",{className:"flex items-center justify-between px-2 min-h-8 py-1 border-b border-line bg-surface-sunken",children:[
112
112
  /* @__PURE__ */N("span",{className:"font-medium text-gray-700",children:g.meshes}),
@@ -120,27 +120,27 @@ return k("div",{className:"flex flex-col h-full bg-white",children:[
120
120
  /* @__PURE__ */N(h,{size:"sm",padding:"",label:g.loading}),"STP"===be||"STEP"===be?/* @__PURE__ */N("span",{className:"text-2xs text-ink-faintest",children:g.stepNote}):null]}),d&&/* @__PURE__ */N("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-600 px-6 text-center bg-white/85",children:d}),Z&&/* @__PURE__ */k("div",{className:"absolute top-2 right-2 w-64 max-h-[80%] flex flex-col bg-white/95 backdrop-blur border border-gray-200 rounded-md shadow-xl z-10 text-xs",children:[
121
121
  /* @__PURE__ */k("div",{className:"flex items-center justify-between px-2 min-h-8 py-1 border-b border-line bg-surface-sunken",children:[
122
122
  /* @__PURE__ */N("span",{className:"font-medium text-gray-700",children:g.display}),
123
- /* @__PURE__ */N("button",{onClick:()=>J(!1),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-600",title:C.closePanel,children:"×"})]}),
123
+ /* @__PURE__ */N("button",{onClick:()=>$(!1),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-600",title:C.closePanel,children:"×"})]}),
124
124
  /* @__PURE__ */k("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-3 text-xs text-ink",children:[
125
125
  /* @__PURE__ */k("label",{className:"flex items-center justify-between gap-2",children:[
126
126
  /* @__PURE__ */N("span",{children:g.backgroundColor}),
127
- /* @__PURE__ */N("input",{type:"color",value:W,onChange:e=>I(e.target.value),className:"h-6 w-10 rounded border border-gray-300 bg-white"})]}),
127
+ /* @__PURE__ */N("input",{type:"color",value:I,onChange:e=>W(e.target.value),className:"h-6 w-10 rounded border border-gray-300 bg-white"})]}),
128
128
  /* @__PURE__ */k("label",{className:"flex items-center justify-between gap-2",children:[
129
129
  /* @__PURE__ */N("span",{children:g.showEdges}),
130
130
  /* @__PURE__ */N("button",{onClick:()=>B(e=>!e),role:"switch","aria-checked":O,className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors "+(O?"bg-blue-500":"bg-gray-300"),children:/* @__PURE__ */N("span",{className:"inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform "+(O?"translate-x-[18px]":"translate-x-0.5")})})]}),
131
131
  /* @__PURE__ */k("label",{className:"flex items-center justify-between gap-2",children:[
132
132
  /* @__PURE__ */N("span",{className:O?"":"opacity-40",children:g.edgeColor}),
133
- /* @__PURE__ */N("input",{type:"color",value:G,onChange:e=>X(e.target.value),disabled:!O,className:"h-6 w-10 rounded border border-gray-300 bg-white disabled:opacity-40"})]}),
133
+ /* @__PURE__ */N("input",{type:"color",value:U,onChange:e=>X(e.target.value),disabled:!O,className:"h-6 w-10 rounded border border-gray-300 bg-white disabled:opacity-40"})]}),
134
134
  /* @__PURE__ */k("div",{className:O?"":"opacity-40 pointer-events-none",children:[
135
135
  /* @__PURE__ */k("div",{className:"flex items-center justify-between gap-2 mb-1",children:[
136
136
  /* @__PURE__ */N("span",{children:g.edgeThreshold}),
137
- /* @__PURE__ */k("span",{className:"text-gray-500 tabular-nums",children:[U,"°"]})]}),
138
- /* @__PURE__ */N("input",{type:"range",min:0,max:45,step:1,value:U,onChange:e=>V(Number(e.target.value)),className:"w-full accent-blue-500"})]}),
137
+ /* @__PURE__ */k("span",{className:"text-gray-500 tabular-nums",children:[G,"°"]})]}),
138
+ /* @__PURE__ */N("input",{type:"range",min:0,max:45,step:1,value:G,onChange:e=>V(Number(e.target.value)),className:"w-full accent-blue-500"})]}),
139
139
  /* @__PURE__ */k("div",{className:"border-t border-gray-200 -mx-3 px-3 pt-3 mt-1",children:[
140
140
  /* @__PURE__ */k("label",{className:"flex items-center justify-between gap-2",children:[
141
141
  /* @__PURE__ */N("span",{className:"font-medium",children:g.sectionView}),
142
- /* @__PURE__ */N("button",{onClick:()=>q(e=>!e),role:"switch","aria-checked":K,className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors "+(K?"bg-blue-500":"bg-gray-300"),children:/* @__PURE__ */N("span",{className:"inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform "+(K?"translate-x-[18px]":"translate-x-0.5")})})]}),
143
- /* @__PURE__ */k("div",{className:K?"mt-2 space-y-2":"mt-2 space-y-2 opacity-40 pointer-events-none",children:[
142
+ /* @__PURE__ */N("button",{onClick:()=>q(e=>!e),role:"switch","aria-checked":Q,className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors "+(Q?"bg-blue-500":"bg-gray-300"),children:/* @__PURE__ */N("span",{className:"inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform "+(Q?"translate-x-[18px]":"translate-x-0.5")})})]}),
143
+ /* @__PURE__ */k("div",{className:Q?"mt-2 space-y-2":"mt-2 space-y-2 opacity-40 pointer-events-none",children:[
144
144
  /* @__PURE__ */k("div",{children:[
145
145
  /* @__PURE__ */k("div",{className:"flex items-center justify-between gap-2 mb-1",children:[
146
146
  /* @__PURE__ */N("span",{children:g.angle}),
@@ -156,7 +156,7 @@ return k("div",{className:"flex flex-col h-full bg-white",children:[
156
156
  /* @__PURE__ */N("span",{children:g.position}),
157
157
  /* @__PURE__ */k("span",{className:"text-gray-500 tabular-nums",children:[Math.round(100*se),"%"]})]}),
158
158
  /* @__PURE__ */N("input",{type:"range",min:0,max:1,step:.01,value:se,onChange:e=>ie(Number(e.target.value)),className:"w-full accent-blue-500"})]})]})]})]}),
159
- /* @__PURE__ */N("div",{className:"px-3 py-2 border-t border-gray-200",children:/* @__PURE__ */N("button",{onClick:()=>{I("#f5f6f8"),B(!0),X("#000000"),V(1),q(!1),te("x"),re(!1),ie(.5),ae(0)},className:"w-full text-2xs text-ink bg-gray-100 hover:bg-gray-200 rounded py-2 transition-colors",children:g.resetDisplay})})]})]})})]})}function W({url:e,filename:t,onDownload:s,onEmail:i}){const[o,a]=w(1),[l,c]=w(!1),[d,u]=w(!1),m=b(null),h=y().preview,x="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
159
+ /* @__PURE__ */N("div",{className:"px-3 py-2 border-t border-gray-200",children:/* @__PURE__ */N("button",{onClick:()=>{W("#f5f6f8"),B(!0),X("#000000"),V(1),q(!1),te("x"),re(!1),ie(.5),ae(0)},className:"w-full text-2xs text-ink bg-gray-100 hover:bg-gray-200 rounded py-2 transition-colors",children:g.resetDisplay})})]})]})})]})}function I({url:e,filename:t,onDownload:s,onEmail:i}){const[o,a]=w(1),[l,c]=w(!1),[d,u]=w(!1),m=b(null),h=y().preview,x="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
160
160
  return k("div",{className:"flex flex-col h-full",children:[
161
161
  /* @__PURE__ */k(n,{children:[!d&&/* @__PURE__ */k(C,{children:[
162
162
  /* @__PURE__ */N("button",{onClick:()=>a(e=>Math.max(.1,Math.round(100*(e-.25))/100)),className:x,children:"−"}),