@webority/ui-elements 0.150.0 → 0.153.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 (110) hide show
  1. package/dist/{WuiCommentThread-By-u3c5S.js → WuiCommentThread-BmRsl0K1.js} +1 -1
  2. package/dist/{WuiDataTable-D8UW2DMH.js → WuiDataTable-B4BYCd_s.js} +1 -1
  3. package/dist/WuiInlineEdit-BlBuWkHG.js +1 -0
  4. package/dist/{WuiLightbox-D7Nf1SbH.js → WuiLightbox-C2A14vHx.js} +1 -1
  5. package/dist/{WuiMarkdown-N96OX-To.js → WuiMarkdown-BXY0QKaO.js} +1 -1
  6. package/dist/{WuiMentionInput-BFB57FZI.js → WuiMentionInput-8Xjkzdqg.js} +1 -1
  7. package/dist/{WuiNotificationCenter-C6e13nCh.js → WuiNotificationCenter-ClkCTUnp.js} +1 -1
  8. package/dist/{WuiOverflow-CeLUmJR-.js → WuiOverflow-B0wA6aDe.js} +1 -1
  9. package/dist/{WuiPhone-rtex3VDC.js → WuiPhone-BVNVerap.js} +1 -1
  10. package/dist/{WuiRelativeTime-RdC80Zii.js → WuiRelativeTime-DyeUQOQ8.js} +1 -1
  11. package/dist/{WuiRollingNumber-YRMeRCGW.js → WuiRollingNumber-sfgNzaP0.js} +1 -1
  12. package/dist/WuiSavedViews-UaiP6YNG.js +1 -0
  13. package/dist/WuiSelect-DBPre2oe.js +9 -0
  14. package/dist/WuiTour-Cx61ijsm.js +1 -0
  15. package/dist/{WuiTree-ZD9GGmtg.js → WuiTree-0Yqu199O.js} +1 -1
  16. package/dist/{chips-2yXiMhK4.js → chips-Dony2fgq.js} +1 -1
  17. package/dist/{dataTable-D23oUOhU.js → dataTable-B-7oAeii.js} +1 -1
  18. package/dist/{drawerDiscard-CUN8L47U.js → drawerDiscard-C0yRSl1I.js} +1 -1
  19. package/dist/elements/comment-thread.js +1 -1
  20. package/dist/elements/data-table.js +1 -1
  21. package/dist/elements/inline-edit.js +1 -1
  22. package/dist/elements/kanban.js +1 -1
  23. package/dist/elements/lightbox.js +1 -1
  24. package/dist/elements/markdown.js +1 -1
  25. package/dist/elements/mention-input.js +1 -1
  26. package/dist/elements/notification-center.js +1 -1
  27. package/dist/elements/overflow.js +1 -1
  28. package/dist/elements/phone.js +1 -1
  29. package/dist/elements/relative-time.js +1 -1
  30. package/dist/elements/rolling-number.js +1 -1
  31. package/dist/elements/saved-views.js +1 -1
  32. package/dist/elements/select.js +1 -1
  33. package/dist/elements/tour.js +1 -1
  34. package/dist/elements/tree.js +1 -1
  35. package/dist/{fileViewerImage-tzF4DDq7.js → fileViewerImage-Bt1jeArm.js} +1 -1
  36. package/dist/{fileViewerPdf-BLMhF8NT.js → fileViewerPdf-CdaDuaRJ.js} +1 -1
  37. package/dist/formatters-ljfITOZ3.js +1 -0
  38. package/dist/helpers.js +1 -1
  39. package/dist/{inlineEditText-H7Pr8IU9.js → inlineEditText-CsLCQbcg.js} +1 -1
  40. package/dist/{kanban-CJ587-XT.js → kanban-Dz8m-17x.js} +1 -1
  41. package/dist/{kanbanModel-BdqSa1lJ.js → kanbanModel-C2IOPJ8L.js} +1 -1
  42. package/dist/{notificationDays-BKVW7xYD.js → notificationDays-BIWczft0.js} +1 -1
  43. package/dist/{relativeTime-YTAOONRy.js → relativeTime-BahImc8F.js} +1 -1
  44. package/dist/{search-BXcvm716.js → search-C8xIzt6h.js} +1 -1
  45. package/dist/server.js +1 -1
  46. package/dist/ui-calendar.global.js +1 -1
  47. package/dist/ui-calendar.js +1 -1
  48. package/dist/ui-chart.global.js +2 -2
  49. package/dist/ui-chart.js +2 -2
  50. package/dist/ui-elements/carousel.global.js +1 -1
  51. package/dist/ui-elements/code-block.global.js +1 -1
  52. package/dist/ui-elements/command-palette.global.js +1 -1
  53. package/dist/ui-elements/comment-thread.global.js +1 -1
  54. package/dist/ui-elements/consent-banner.global.js +1 -1
  55. package/dist/ui-elements/context-menu.global.js +1 -1
  56. package/dist/ui-elements/date-range.global.js +1 -1
  57. package/dist/ui-elements/drawer.global.js +1 -1
  58. package/dist/ui-elements/glyphs.global.js +1 -1
  59. package/dist/ui-elements/image-crop.global.js +1 -1
  60. package/dist/ui-elements/inline-edit.global.js +1 -1
  61. package/dist/ui-elements/kanban.global.js +1 -1
  62. package/dist/ui-elements/lead-popup.global.js +1 -1
  63. package/dist/ui-elements/lightbox.global.js +1 -1
  64. package/dist/ui-elements/markdown.global.js +2 -2
  65. package/dist/ui-elements/org-tree.global.js +1 -1
  66. package/dist/ui-elements/phone.global.js +2 -2
  67. package/dist/ui-elements/resizable.global.js +1 -1
  68. package/dist/ui-elements/saved-views.global.js +1 -1
  69. package/dist/ui-elements/select-chips.global.js +1 -1
  70. package/dist/ui-elements/select-recents.global.js +1 -1
  71. package/dist/ui-elements/select-search.global.js +1 -1
  72. package/dist/ui-elements/slider.global.js +1 -1
  73. package/dist/ui-elements/sortable.global.js +1 -1
  74. package/dist/ui-elements/status-icon.global.js +1 -1
  75. package/dist/ui-elements/timepicker.global.js +1 -1
  76. package/dist/ui-elements/tour.global.js +1 -1
  77. package/dist/ui-elements/tree.global.js +1 -1
  78. package/dist/ui-elements/wizard.global.js +1 -1
  79. package/dist/ui-elements.global.js +9 -9
  80. package/dist/ui-elements.js +1 -1
  81. package/dist/ui-file-viewer.global.js +1 -1
  82. package/dist/ui-file-viewer.js +1 -1
  83. package/dist/ui-tour.global.js +1 -1
  84. package/dist/{wuiHttp-523iN_RF.js → wuiHttp-DGbD7Fra.js} +1 -1
  85. package/package.json +4 -3
  86. package/types/WuiCommentThread.d.ts +2 -2
  87. package/types/WuiImageCrop.d.ts +4 -4
  88. package/types/WuiSelect.d.ts +9 -0
  89. package/types/WuiTour.d.ts +1 -1
  90. package/types/chartSpec.d.ts +20 -20
  91. package/types/fileValidation.d.ts +2 -2
  92. package/types/fileViewerPdf.d.ts +3 -3
  93. package/types/formatters.d.ts +19 -14
  94. package/types/inputMask.d.ts +3 -3
  95. package/types/kanban.d.ts +1 -1
  96. package/types/listQuery.d.ts +10 -10
  97. package/types/razor-js/modules/api.d.ts +3 -0
  98. package/types/razor-js/modules/buttons.d.ts +1 -0
  99. package/types/razor-js/modules/widgets.d.ts +1 -0
  100. package/types/razor-js/webority-ui.d.ts +3 -0
  101. package/types/select/list.d.ts +8 -8
  102. package/types/server/remoteModal.d.ts +12 -12
  103. package/types/server/wuiHttp.d.ts +5 -5
  104. package/types/stepperHeader.d.ts +2 -2
  105. package/types/themeTransition.d.ts +2 -2
  106. package/dist/WuiInlineEdit-r55qgh8A.js +0 -1
  107. package/dist/WuiSavedViews-DtyAoZKb.js +0 -1
  108. package/dist/WuiSelect-D9ABfsdZ.js +0 -9
  109. package/dist/WuiTour-CrIFLmSK.js +0 -1
  110. package/dist/formatters-C3V6M5zV.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./filterPopover-D8BOb-Hz.js";import{t as n}from"./kanban-CJ587-XT.js";import{n as r}from"./statusIcons-CRtqA_1C.js";import{t as i}from"./WuiCarousel-DthhDxH-.js";import{t as a}from"./WuiCodeBlock-DHpmEskS.js";import{t as o}from"./WuiCommandPalette-DqHh4lH6.js";import{t as s}from"./WuiCommentThread-By-u3c5S.js";import{t as c}from"./WuiConsentBanner-Bm7tT3_5.js";import{t as l}from"./WuiContextMenu-sPTmEEVn.js";import{t as u}from"./WuiDataTable-D8UW2DMH.js";import{t as d}from"./WuiDatePicker-DLEsnzqG.js";import{t as f}from"./WuiDateRange-9Xqs5nvv.js";import{t as p}from"./WuiDock-d5abaLkL.js";import{t as m}from"./WuiDrawer-B3YFmxl2.js";import{t as h}from"./WuiHoverCard-CE3dHKaM.js";import{t as g}from"./WuiImageCrop-ChvH8GKb.js";import{t as _}from"./WuiInlineEdit-r55qgh8A.js";import{t as v}from"./WuiLeadPopup-YN4YCbOe.js";import{t as y}from"./WuiLightbox-D7Nf1SbH.js";import{t as b}from"./WuiMarkdown-N96OX-To.js";import{i as x}from"./WuiMentionInput-BFB57FZI.js";import{t as S}from"./WuiNavigationMenu-CZ3XhFam.js";import{t as C}from"./WuiNotificationCenter-C6e13nCh.js";import{t as w}from"./WuiOnboardingChecklist-Cx-TgpBY.js";import{t as T}from"./WuiOrgTree-DzeLFQxy.js";import{t as E}from"./WuiOtp-DonxSwVn.js";import{t as D}from"./WuiOverflow-CeLUmJR-.js";import{t as O}from"./WuiPhone-rtex3VDC.js";import{t as k}from"./WuiRating-DLVduJZ_.js";import{t as A}from"./WuiRecordPager-7HVGoFlP.js";import{t as j}from"./WuiRelativeTime-RdC80Zii.js";import{t as M}from"./WuiResizable-DQZdQVCz.js";import{t as N}from"./WuiRollingNumber-YRMeRCGW.js";import{t as P}from"./WuiSavedViews-DtyAoZKb.js";import{t as F}from"./WuiSelect-D9ABfsdZ.js";import{t as I}from"./WuiShortcuts-D3rWkaOm.js";import{t as L}from"./WuiShowMore-CvdNQXrA.js";import{t as R}from"./WuiSlider-D33Y3_t9.js";import{t as z}from"./WuiSortable-CBLMNRuZ.js";import{t as B}from"./WuiTimePicker-DOodgU2O.js";import{t as V}from"./WuiTour-CrIFLmSK.js";import{t as H}from"./WuiTree-ZD9GGmtg.js";import{t as U}from"./WuiTruncate-C2WV1-NN.js";import{n as W,t as ee}from"./WuiWhatsNew-dLGyA4g1.js";import{n as G,t as K}from"./WuiWizardStep-Cencr-mT.js";import{c as q,f as J,l as Y,m as X,p as Z,s as Q,u as te}from"./formatters-C3V6M5zV.js";import{_ as ne,r as re}from"./themeTransition-9LQC6fx8.js";import{t as ie}from"./drawerDiscard-CUN8L47U.js";import{i as ae}from"./shortcutKeys-COVLox98.js";function $(){t(),e(`wui-select`,F),e(`wui-saved-views`,P),e(`wui-phone`,O),e(`wui-datepicker`,d),e(`wui-date-range`,f),e(`wui-dock`,p),e(`wui-image-crop`,g),e(`wui-kanban`,n),e(`wui-lead-popup`,v),e(`wui-inline-edit`,_),e(`wui-consent-banner`,c),e(`wui-slider`,R),e(`wui-sortable`,z),e(`wui-timepicker`,B),e(`wui-tour`,V),e(`wui-tree`,H),e(`wui-org-tree`,T),e(`wui-command-palette`,o),e(`wui-context-menu`,l),e(`wui-otp`,E),e(`wui-status-icon`,r),e(`wui-shortcuts`,I),e(`wui-record-pager`,A),e(`wui-carousel`,i),e(`wui-code-block`,a),e(`wui-markdown`,b),e(`wui-data-table`,u),e(`wui-drawer`,m),e(`wui-hover-card`,h),e(`wui-lightbox`,y),e(`wui-navigation-menu`,S),e(`wui-notification-center`,C),e(`wui-onboarding-checklist`,w),e(`wui-overflow`,D),e(`wui-rating`,k),e(`wui-relative-time`,j),e(`wui-resizable`,M),e(`wui-rolling-number`,N),e(`wui-show-more`,L),e(`wui-truncate`,U),e(`wui-whats-new`,W),e(`wui-mention-input`,x),e(`wui-comment-thread`,s),e(`wui-wizard-step`,K),e(`wui-wizard`,G)}$();export{ie as DISCARD_EVENT,ne as ROW_DROP_EVENT,ae as SHORTCUT_EVENT,re as THEME_CHANGE_EVENT,ee as WHATS_NEW_READ_EVENT,i as WuiCarousel,a as WuiCodeBlock,o as WuiCommandPalette,s as WuiCommentThread,c as WuiConsentBanner,l as WuiContextMenu,u as WuiDataTable,d as WuiDatePicker,f as WuiDateRange,p as WuiDock,m as WuiDrawer,h as WuiHoverCard,g as WuiImageCrop,_ as WuiInlineEdit,n as WuiKanban,v as WuiLeadPopup,y as WuiLightbox,b as WuiMarkdown,x as WuiMentionInput,S as WuiNavigationMenu,C as WuiNotificationCenter,w as WuiOnboardingChecklist,T as WuiOrgTree,E as WuiOtp,D as WuiOverflow,O as WuiPhone,k as WuiRating,A as WuiRecordPager,j as WuiRelativeTime,M as WuiResizable,N as WuiRollingNumber,P as WuiSavedViews,F as WuiSelect,I as WuiShortcuts,L as WuiShowMore,R as WuiSlider,z as WuiSortable,r as WuiStatusIcon,B as WuiTimePicker,V as WuiTour,H as WuiTree,U as WuiTruncate,W as WuiWhatsNew,G as WuiWizard,K as WuiWizardStep,$ as defineWeborityElements,Q as formatCompact,q as formatCurrency,Y as formatDate,te as formatDateTime,J as formatNumber,Z as formatPercent,X as formatValue};
1
+ import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./filterPopover-D8BOb-Hz.js";import{t as n}from"./kanban-Dz8m-17x.js";import{n as r}from"./statusIcons-CRtqA_1C.js";import{t as i}from"./WuiCarousel-DthhDxH-.js";import{t as a}from"./WuiCodeBlock-DHpmEskS.js";import{t as o}from"./WuiCommandPalette-DqHh4lH6.js";import{t as s}from"./WuiCommentThread-BmRsl0K1.js";import{t as c}from"./WuiConsentBanner-Bm7tT3_5.js";import{t as l}from"./WuiContextMenu-sPTmEEVn.js";import{t as u}from"./WuiDataTable-B4BYCd_s.js";import{t as d}from"./WuiDatePicker-DLEsnzqG.js";import{t as f}from"./WuiDateRange-9Xqs5nvv.js";import{t as p}from"./WuiDock-d5abaLkL.js";import{t as m}from"./WuiDrawer-B3YFmxl2.js";import{t as h}from"./WuiHoverCard-CE3dHKaM.js";import{t as g}from"./WuiImageCrop-ChvH8GKb.js";import{t as _}from"./WuiInlineEdit-BlBuWkHG.js";import{t as v}from"./WuiLeadPopup-YN4YCbOe.js";import{t as y}from"./WuiLightbox-C2A14vHx.js";import{t as b}from"./WuiMarkdown-BXY0QKaO.js";import{i as x}from"./WuiMentionInput-8Xjkzdqg.js";import{t as S}from"./WuiNavigationMenu-CZ3XhFam.js";import{t as C}from"./WuiNotificationCenter-ClkCTUnp.js";import{t as w}from"./WuiOnboardingChecklist-Cx-TgpBY.js";import{t as T}from"./WuiOrgTree-DzeLFQxy.js";import{t as E}from"./WuiOtp-DonxSwVn.js";import{t as D}from"./WuiOverflow-B0wA6aDe.js";import{t as O}from"./WuiPhone-BVNVerap.js";import{t as k}from"./WuiRating-DLVduJZ_.js";import{t as A}from"./WuiRecordPager-7HVGoFlP.js";import{t as j}from"./WuiRelativeTime-DyeUQOQ8.js";import{t as M}from"./WuiResizable-DQZdQVCz.js";import{t as N}from"./WuiRollingNumber-sfgNzaP0.js";import{t as P}from"./WuiSavedViews-UaiP6YNG.js";import{t as F}from"./WuiSelect-DBPre2oe.js";import{t as I}from"./WuiShortcuts-D3rWkaOm.js";import{t as L}from"./WuiShowMore-CvdNQXrA.js";import{t as R}from"./WuiSlider-D33Y3_t9.js";import{t as z}from"./WuiSortable-CBLMNRuZ.js";import{t as B}from"./WuiTimePicker-DOodgU2O.js";import{t as V}from"./WuiTour-Cx61ijsm.js";import{t as H}from"./WuiTree-0Yqu199O.js";import{t as U}from"./WuiTruncate-C2WV1-NN.js";import{n as W,t as ee}from"./WuiWhatsNew-dLGyA4g1.js";import{n as G,t as K}from"./WuiWizardStep-Cencr-mT.js";import{c as q,f as J,l as Y,m as X,p as Z,s as Q,u as te}from"./formatters-ljfITOZ3.js";import{_ as ne,r as re}from"./themeTransition-9LQC6fx8.js";import{t as ie}from"./drawerDiscard-C0yRSl1I.js";import{i as ae}from"./shortcutKeys-COVLox98.js";function $(){t(),e(`wui-select`,F),e(`wui-saved-views`,P),e(`wui-phone`,O),e(`wui-datepicker`,d),e(`wui-date-range`,f),e(`wui-dock`,p),e(`wui-image-crop`,g),e(`wui-kanban`,n),e(`wui-lead-popup`,v),e(`wui-inline-edit`,_),e(`wui-consent-banner`,c),e(`wui-slider`,R),e(`wui-sortable`,z),e(`wui-timepicker`,B),e(`wui-tour`,V),e(`wui-tree`,H),e(`wui-org-tree`,T),e(`wui-command-palette`,o),e(`wui-context-menu`,l),e(`wui-otp`,E),e(`wui-status-icon`,r),e(`wui-shortcuts`,I),e(`wui-record-pager`,A),e(`wui-carousel`,i),e(`wui-code-block`,a),e(`wui-markdown`,b),e(`wui-data-table`,u),e(`wui-drawer`,m),e(`wui-hover-card`,h),e(`wui-lightbox`,y),e(`wui-navigation-menu`,S),e(`wui-notification-center`,C),e(`wui-onboarding-checklist`,w),e(`wui-overflow`,D),e(`wui-rating`,k),e(`wui-relative-time`,j),e(`wui-resizable`,M),e(`wui-rolling-number`,N),e(`wui-show-more`,L),e(`wui-truncate`,U),e(`wui-whats-new`,W),e(`wui-mention-input`,x),e(`wui-comment-thread`,s),e(`wui-wizard-step`,K),e(`wui-wizard`,G)}$();export{ie as DISCARD_EVENT,ne as ROW_DROP_EVENT,ae as SHORTCUT_EVENT,re as THEME_CHANGE_EVENT,ee as WHATS_NEW_READ_EVENT,i as WuiCarousel,a as WuiCodeBlock,o as WuiCommandPalette,s as WuiCommentThread,c as WuiConsentBanner,l as WuiContextMenu,u as WuiDataTable,d as WuiDatePicker,f as WuiDateRange,p as WuiDock,m as WuiDrawer,h as WuiHoverCard,g as WuiImageCrop,_ as WuiInlineEdit,n as WuiKanban,v as WuiLeadPopup,y as WuiLightbox,b as WuiMarkdown,x as WuiMentionInput,S as WuiNavigationMenu,C as WuiNotificationCenter,w as WuiOnboardingChecklist,T as WuiOrgTree,E as WuiOtp,D as WuiOverflow,O as WuiPhone,k as WuiRating,A as WuiRecordPager,j as WuiRelativeTime,M as WuiResizable,N as WuiRollingNumber,P as WuiSavedViews,F as WuiSelect,I as WuiShortcuts,L as WuiShowMore,R as WuiSlider,z as WuiSortable,r as WuiStatusIcon,B as WuiTimePicker,V as WuiTour,H as WuiTree,U as WuiTruncate,W as WuiWhatsNew,G as WuiWizard,K as WuiWizardStep,$ as defineWeborityElements,Q as formatCompact,q as formatCurrency,Y as formatDate,te as formatDateTime,J as formatNumber,Z as formatPercent,X as formatValue};
@@ -14,6 +14,6 @@ ${n.map((e,t)=>`@page s${t} { size: ${e}; margin: 0; }`).join(`
14
14
  `)}
15
15
  html, body { margin: 0; padding: 0; }
16
16
  img { display: block; break-after: page; }
17
- img:last-child { break-after: auto; }`,pages:e.map(e=>({url:e.url,width:e.width,height:e.height,page:`s${n.indexOf(t(e))}`}))}}function ka(e,t,n){let r=e.textContent??``,i=[],a=0;for(let{from:e,to:o,n:s}of t){e>a&&i.push(document.createTextNode(r.slice(a,e)));let t=document.createElement(`mark`);t.className=s===n?`wui-file-viewer-hit wui-file-viewer-hit-current`:`wui-file-viewer-hit`,t.textContent=r.slice(e,o),i.push(t),a=o}a<r.length&&i.push(document.createTextNode(r.slice(a))),e.replaceChildren(...i)}function $(e,t){let n=e[t];if(n===void 0)throw RangeError(`No item at index ${t}.`);return n}function Aa(e){let t=[...e].sort((e,t)=>e-t);return $(t,Math.floor(t.length/2))}var ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no=n((()=>{pa(),ha(),Sa(),j(),ee(),ja=[.5,.75,1,1.25,1.5,2,3],Ma=[.5,.75,1,1.25,1.5,2],Na=[{key:`fit-width`,label:`Fit width`},{key:`fit-page`,label:`Fit page`}],Pa=96/72,Fa=12,Ia=10,La=168,Ra=150,za=2,Ba=2e3,Va=5,Ha=150,Ua=16777216,Wa=null,Ga=e=>Na.some(t=>t.key===e),Ka=e=>{if(Ga(e))return e;let t=Number(e);return ja.includes(t)?t:`fit-width`},qa=e=>e instanceof Element&&e.closest(`input, textarea, select, [contenteditable='true'], .dropdown-menu`),Ja=e=>/^(https?:|mailto:)/i.test(e),Ya=class{constructor(e,t){this.shell=e,this.source=t;let n=e.prefs;this.zoom=Ka(n.zoom),this.twoPage=n.twoPage===!0,this.showThumbs=n.thumbnails===!0,this.sizes=[],this.rows=[],this.rowOf=[],this.scale=0,this.drawnScale=0,this.pages=new Map,this.thumbsDrawn=new Set,this.area={width:0,height:0},this.scrollPos={top:0,left:0},this.jumpTarget=null,this.search={open:!1,query:``,index:null,indexing:!1,hits:[],current:-1,marked:new Map},this.printRun=null,this.destroyed=!1,this._timers=new Set}load(){return this._loading=this._load(),this._loading}async _load(){wa(this.source.workerSrc),this.task=ht({url:this.source.src,...Ta(this.source.assetBase)});let e;try{e=await this.task.promise}catch(e){this.destroyed||this.shell.fail(e);return}if(this.destroyed){e.destroy();return}this.pdf=e;let t=await Promise.all(Array.from({length:e.numPages},(t,n)=>e.getPage(n+1)));this.destroyed||(this.sizes=t.map(e=>{let t=e.getViewport({scale:Pa});return{width:t.width,height:t.height}}),this._buildToolbar(),this._buildBody(),this._layout(),this.shell.loaded({kind:`pdf`,pages:e.numPages}))}destroy(){this.destroyed=!0;for(let e of this._timers)window.clearTimeout(e);this._scrollFrame!==void 0&&window.cancelAnimationFrame(this._scrollFrame),this._resizeObserver?.disconnect(),this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this._thumbObserver?.disconnect();for(let e of[...this.pages.keys()])this._release(e);this._releasePrint();let e=this.task;e&&(this._loading??Promise.resolve()).catch(e=>{d(`PDF load failed before the viewer closed.`,e)}).finally(()=>e.destroy())}_buildToolbar(){let{start:e,center:t,end:n,host:r}=this.shell;this.thumbsButton=O(`menu`,``,{size:17}),this.thumbsButton.addEventListener(`click`,()=>this._setThumbs(!this.showThumbs)),e.prepend(this.thumbsButton),this.prevButton=O(`chevron-up`,`Previous page`),this.prevButton.addEventListener(`click`,()=>this.goToPage(this.current()-this.cols()));let i=document.createElement(`span`);i.className=`wui-file-viewer-page`,this.pageInput=document.createElement(`input`),this.pageInput.className=`wui-file-viewer-page-input`,this.pageInput.setAttribute(`aria-label`,`Page number`),this.pageInput.inputMode=`numeric`,this.pageInput.addEventListener(`input`,()=>{this.pageInput.value=this.pageInput.value.replace(/[^\d]/g,``)}),this.pageInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&this.pageInput.blur()}),this.pageInput.addEventListener(`blur`,()=>this._commitPageInput());let a=document.createElement(`span`);a.className=`wui-file-viewer-page-total`,a.textContent=`/ ${this.pdf.numPages}`,i.append(this.pageInput,a),this.nextButton=O(`chevron-down`,`Next page`),this.nextButton.addEventListener(`click`,()=>this.goToPage(this.current()+this.cols())),t.append(this.prevButton,i,this.nextButton),this.searchButton=O(`search`,`Search the document`,{className:`wui-file-viewer-search-toggle`}),this.searchButton.setAttribute(`aria-controls`,`${r.uid}-search`),this.searchButton.addEventListener(`click`,()=>this.search.open?this._closeSearch():this._openSearch()),this.zoomOutButton=O(`zoom-out`,`Zoom out`),this.zoomOutButton.addEventListener(`click`,()=>this._stepZoom(-1)),this.zoomButton=document.createElement(`button`),this.zoomButton.type=`button`,this.zoomButton.className=`wui-file-viewer-zoom`,te(this.zoomButton,{label:`Zoom`,items:()=>[...Ma.map(e=>({key:String(e),label:`${Math.round(e*100)}%`,checked:this.zoom===e})),{key:`fit-divider`,divider:!0},...Na.map(e=>({key:e.key,label:e.label,checked:this.zoom===e.key}))],onPick:e=>this._setZoom(Ka(e))}),this.zoomInButton=O(`zoom-in`,`Zoom in`),this.zoomInButton.addEventListener(`click`,()=>this._stepZoom(1));let o=document.createElement(`span`);o.className=`wui-file-viewer-divider`,this.twoPageButton=O(`two-page`,`Two-page view`),this.twoPageButton.addEventListener(`click`,()=>this._setTwoPage(!this.twoPage)),this.printButton=O(`printer`,`Print`,{className:`wui-file-viewer-print`}),this.printButton.addEventListener(`click`,()=>this.print()),this.printButton.hidden=!this.shell.print(),n.prepend(this.searchButton,this.zoomOutButton,this.zoomButton,this.zoomInButton,o,this.twoPageButton,this.printButton),this._buildSearchRow(),this._syncToolbar()}_buildSearchRow(){let e=this.shell.search;e.id=`${this.shell.host.uid}-search`;let t=document.createElement(`div`);t.className=`wui-file-viewer-search-field`,this.searchInput=document.createElement(`input`),this.searchInput.type=`search`,this.searchInput.className=`form-control form-control-sm`,this.searchInput.placeholder=`Search the document`,this.searchInput.setAttribute(`aria-label`,`Search the document`),this.searchInput.addEventListener(`input`,()=>this._setQuery(this.searchInput.value)),this.searchInput.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this._goToHit(this.search.current+(e.shiftKey?-1:1))):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._closeSearch())}),t.append(this.searchInput),this.searchStatus=document.createElement(`span`),this.searchStatus.className=`wui-file-viewer-search-count`,this.searchStatus.setAttribute(`aria-live`,`polite`),this.prevHitButton=O(`chevron-up`,`Previous match`),this.prevHitButton.addEventListener(`click`,()=>this._goToHit(this.search.current-1)),this.nextHitButton=O(`chevron-down`,`Next match`),this.nextHitButton.addEventListener(`click`,()=>this._goToHit(this.search.current+1));let n=O(`x`,`Close search`);n.addEventListener(`click`,()=>this._closeSearch()),e.append(t,this.searchStatus,this.prevHitButton,this.nextHitButton,n)}_syncToolbar(){let e=this.current(),t=this.rows.length-1;document.activeElement!==this.pageInput&&(this.pageInput.value=String(e)),this.prevButton.disabled=e<=1,this.nextButton.disabled=(this.rowOf[e]??0)>=t,this.zoomOutButton.disabled=this._zoomStep(-1)==null,this.zoomInButton.disabled=this._zoomStep(1)==null;let n=Math.round((this.scale||1)*100);this._shownPercent!==n&&(this._shownPercent=n,this.zoomButton.innerHTML=`${n}%${E(`chevron-down`,{size:12})}`,this.zoomButton.setAttribute(`aria-label`,`Zoom, ${n}%`)),A(this.thumbsButton,this.showThumbs?`Hide thumbnails`:`Show thumbnails`),this.thumbsButton.setAttribute(`aria-pressed`,String(this.showThumbs)),this.twoPageButton.setAttribute(`aria-pressed`,String(this.twoPage)),this.printButton.disabled=this.printRun!=null&&!this.printRun.ready,A(this.printButton,this.printButton.disabled?`Preparing to print`:`Print`),A(this.searchButton,this.search.open?`Close search`:`Search the document`),this.searchButton.setAttribute(`aria-expanded`,String(this.search.open)),this._syncSearchStatus()}_buildBody(){let e=this.shell.body;this.thumbRail=document.createElement(`div`),this.thumbRail.className=`wui-file-viewer-thumbs wui-scroll${this.showThumbs?` open`:``}`,this.scroller=document.createElement(`div`),this.scroller.className=`wui-file-viewer-scroll wui-scroll`,this.scroller.tabIndex=0,this.scroller.setAttribute(`role`,`region`),this.scroller.setAttribute(`aria-label`,`Document pages`),this.pagesEl=document.createElement(`div`),this.pagesEl.className=`wui-file-viewer-pages`,this.scroller.append(this.pagesEl),e.replaceChildren(this.thumbRail,this.scroller),this.pageEls=[];for(let e=1;e<=this.pdf.numPages;e++){let t=document.createElement(`div`);t.className=`wui-file-viewer-sheet`,t.dataset.page=String(e),this.pageEls[e]=t}this.showThumbs&&this._buildThumbs(),this.scroller.addEventListener(`scroll`,()=>this._onScroll(),{passive:!0}),this.scroller.addEventListener(`pointerdown`,e=>this._panStart(e)),this.scroller.addEventListener(`pointermove`,e=>this._panMove(e));for(let e of[`pointerup`,`pointercancel`,`lostpointercapture`])this.scroller.addEventListener(e,()=>this._panEnd());this.scroller.addEventListener(`wheel`,e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=performance.now();t-(this._lastWheelZoom??0)<120||(this._lastWheelZoom=t,this._stepZoom(e.deltaY<0?1:-1))},{passive:!1}),this._onKeyDown=e=>this._keyDown(e),this.shell.host.addEventListener(`keydown`,this._onKeyDown),this._resizeObserver=new ResizeObserver(()=>{let e=this.scroller.clientWidth,t=this.scroller.clientHeight;(e!==this.area.width||t!==this.area.height)&&(this.area={width:e,height:t},this._layout())}),this._resizeObserver.observe(this.scroller),this.area={width:this.scroller.clientWidth,height:this.scroller.clientHeight}}cols(){return this.twoPage?2:1}_targetScale(){if(typeof this.zoom==`number`)return this.zoom;let e=this.cols(),t=Aa(this.sizes.map(e=>e.width)),n=Aa(this.sizes.map(e=>e.height)),r=(this.area.width-24-(e-1)*Ia)/(t*e);return this.zoom===`fit-page`&&(r=Math.min(r,(this.area.height-24)/n)),Math.max(r,.1)}_layout(){if(!this.pdf||!this.area.width)return;let e=this._anchor();this.scale=this._targetScale();let t=this.cols();this.rows=[],this.rowOf=[];let n=Fa,r=document.createDocumentFragment();for(let e=1;e<=this.pdf.numPages;e+=t){let i=[];for(let n=e;n<e+t&&n<=this.pdf.numPages;n++)i.push(n);let a=document.createElement(`div`);a.className=`wui-file-viewer-row`;let o=0;for(let e of i){let{width:t,height:n}=$(this.sizes,e-1),r=$(this.pageEls,e);r.style.width=`${Math.floor(t*this.scale)}px`,r.style.height=`${Math.floor(n*this.scale)}px`,r.style.setProperty(`--scale-factor`,String(this.scale*Pa)),o=Math.max(o,Math.floor(n*this.scale)),a.append(r),this.rowOf[e]=this.rows.length}this.rows.push({pages:i,top:n,height:o}),n+=o+Ia,r.append(a)}let i=this.scroller.scrollWidth;this.pagesEl.replaceChildren(r),this._restore(e,i),this._scheduleRedraw(),this._update()}_anchor(){if(!this.rows.length)return null;let e=this._rowAt(this.scrollPos.top),t=$(this.rows,e);return{page:$(t.pages,0),within:(this.scrollPos.top-t.top)/Math.max(t.height+Ia,1),left:this.scrollPos.left}}_restore(e,t){let n=this.scroller;if(e){let r=$(this.rows,$(this.rowOf,e.page));n.scrollTop=r.top+e.within*(r.height+Ia),n.scrollLeft=(t?(e.left+n.clientWidth/2)/t:.5)*n.scrollWidth-n.clientWidth/2}this.scrollPos={top:n.scrollTop,left:n.scrollLeft}}_rowAt(e){let t=0,n=this.rows.length-1;for(;t<n;){let r=t+n+1>>1;$(this.rows,r).top<=e+1?t=r:n=r-1}return t}current(){if(this.jumpTarget!=null)return this.jumpTarget;if(!this.rows.length)return 1;let e=this.scrollPos.top,t=e+this.area.height,n=this._rowAt(e),r=-1;for(let i=n;i<this.rows.length&&$(this.rows,i).top<t;i++){let{top:a,height:o}=$(this.rows,i),s=Math.min(a+o,t)-Math.max(a,e);s>r&&(r=s,n=i)}return $($(this.rows,n).pages,0)}_onScroll(){this.scrollPos={top:this.scroller.scrollTop,left:this.scroller.scrollLeft},this._scrollFrame!==void 0&&window.cancelAnimationFrame(this._scrollFrame),this._scrollFrame=window.requestAnimationFrame(()=>this._update())}_update(){if(!this.rows.length||this.destroyed)return;let e=Math.max(0,this._rowAt(this.scrollPos.top)-za),t=Math.min(this.rows.length-1,this._rowAt(this.scrollPos.top+this.area.height)+za),n=new Set;for(let r=e;r<=t;r++)for(let e of $(this.rows,r).pages)n.add(e);for(let e of[...this.pages.keys()])n.has(e)||this._release(e);this.visibleRow=this._rowAt(this.scrollPos.top);for(let e of n)this.pages.has(e)||this._mount(e);this._pump(),this._syncToolbar(),this.showThumbs&&this._followThumb()}_scheduleRedraw(){if(this.scale===this.drawnScale)return;window.clearTimeout(this._redrawTimer),this._timers.delete(this._redrawTimer);let e=this.drawnScale?Ra:0;this._redrawTimer=window.setTimeout(()=>{this._timers.delete(this._redrawTimer),this.drawnScale=this.scale,this._pump()},e),this._timers.add(this._redrawTimer)}_mount(e){let t=$(this.pageEls,e),n={n:e,drawnAt:0,task:null,canvas:null,text:null,textLayer:null,links:null};this.pages.set(e,n);let r=document.createElement(`div`);r.className=`wui-file-viewer-skeleton`,t.replaceChildren(r),this._drawText(n),this._drawLinks(n)}_release(e){let t=this.pages.get(e);t&&(t.released=!0,t.task?.cancel(),t.textLayer?.cancel(),t.canvas&&(t.canvas.width=0,t.canvas.height=0),this.pages.delete(e),this.search.marked.delete(e),$(this.pageEls,e).replaceChildren())}_pump(){if(this._drawing||!this.drawnScale||this.destroyed)return;let e=this.visibleRow??0,t=null,n=1/0;for(let r of this.pages.values()){if(r.drawnAt===this.drawnScale)continue;let i=Math.abs((this.rowOf[r.n]??NaN)-e);i<n&&(n=i,t=r)}t&&(this._drawing=!0,this._drawCanvas(t).finally(()=>{this._drawing=!1,this._pump()}))}async _drawCanvas(e){let t=this.drawnScale,n=await this.pdf.getPage(e.n);if(e.released||this.destroyed)return;let r=n.getViewport({scale:t*Pa}),i=window.devicePixelRatio||1,a=Math.sqrt(Ua/(r.width*r.height)),o=Math.min(i,a),s=document.createElement(`canvas`);s.className=`wui-file-viewer-canvas`,s.width=Math.floor(r.width*o),s.height=Math.floor(r.height*o),s.setAttribute(`aria-hidden`,`true`),e.task=n.render({canvas:s,viewport:r,transform:o===1?void 0:[o,0,0,o,0,0]});try{await e.task.promise}catch(e){s.width=0,s.height=0,Qa(e)!==`RenderingCancelledException`&&this._warn(`page draw failed`,e);return}finally{e.task=null}if(e.released||this.destroyed){s.width=0,s.height=0;return}let c=$(this.pageEls,e.n);e.canvas?(e.canvas.replaceWith(s),e.canvas.width=0,e.canvas.height=0):(c.querySelector(`.wui-file-viewer-skeleton`)?.remove(),c.prepend(s)),e.canvas=s,e.drawnAt=t,this.showThumbs&&!this.thumbsDrawn.has(e.n)&&this._thumbFromCanvas(e.n,s)}async _drawText(e){let t=await this.pdf.getPage(e.n);if(e.released||this.destroyed)return;let n=document.createElement(`div`);n.className=`wui-file-viewer-text`,e.text=n,e.textLayer=new Jr({textContentSource:t.streamTextContent({includeMarkedContent:!0,disableNormalization:!0}),container:n,viewport:t.getViewport({scale:this.scale*Pa})});try{await e.textLayer.render()}catch(e){Qa(e)!==`AbortException`&&this._warn(`text layer failed`,e);return}e.released||this.destroyed||($(this.pageEls,e.n).append(n),this._markPage(e.n),this._revealHit(e.n))}async _drawLinks(e){let t=await this.pdf.getPage(e.n),n=await t.getAnnotations({intent:`display`});if(e.released||this.destroyed)return;let r=n.filter(e=>e.subtype===`Link`&&(e.dest||e.url&&Ja(e.url))),i=(await Promise.all(r.map(async e=>e.url?{link:e,target:void 0}:{link:e,target:await this._destPage(e.dest)}))).filter(({link:e,target:t})=>e.url||t);if(!i.length||e.released||this.destroyed)return;let a=t.getViewport({scale:1}),o=document.createElement(`div`);o.className=`wui-file-viewer-links`;for(let{link:e,target:t}of i){let[n=NaN,r=NaN,i=NaN,s=NaN]=a.convertToViewportRectangle(e.rect),c=document.createElement(`a`);if(c.style.left=`${Math.min(n,i)/a.width*100}%`,c.style.top=`${Math.min(r,s)/a.height*100}%`,c.style.width=`${Math.abs(i-n)/a.width*100}%`,c.style.height=`${Math.abs(s-r)/a.height*100}%`,e.url)c.href=e.url,c.target=`_blank`,c.rel=`noopener noreferrer`,c.title=e.url,c.setAttribute(`aria-label`,e.url);else if(t){let e=t;c.href=`#page=${e}`,c.setAttribute(`aria-label`,`Go to page ${e}`),c.addEventListener(`click`,t=>{t.preventDefault(),this.goToPage(e)})}o.append(c)}e.links=o,$(this.pageEls,e.n).append(o)}async _destPage(e){try{let t=(typeof e==`string`?await this.pdf.getDestination(e):e)?.[0];if(t==null)return null;let n=Xa(t)?await this.pdf.getPageIndex(t):t;if(typeof n!=`number`)throw TypeError(`The link destination is not a page.`);return n+1}catch(e){return this._warn(`link target not found`,e),null}}goToPage(e){let t=Math.min(Math.max(1,e),this.pdf.numPages),n=Math.min($(this.rows,$(this.rowOf,t)).top-Fa,this.scroller.scrollHeight-this.scroller.clientHeight);window.clearTimeout(this._jumpTimer);let r=this._endJump;r&&this.scroller.removeEventListener(`scrollend`,r),this._endJump=()=>{window.clearTimeout(this._jumpTimer);let e=this._endJump;e&&this.scroller.removeEventListener(`scrollend`,e),this.jumpTarget=null,this._syncToolbar()},Math.abs(n-this.scroller.scrollTop)>=1&&(this.jumpTarget=t,this.scroller.addEventListener(`scrollend`,this._endJump),this._jumpTimer=window.setTimeout(this._endJump,Ba),this._timers.add(this._jumpTimer),this.scroller.scrollTo({top:n,behavior:to()})),this._syncToolbar()}_commitPageInput(){let e=Number.parseInt(this.pageInput.value,10);Number.isNaN(e)?this.pageInput.value=String(this.current()):this.goToPage(e)}_zoomStep(e){let t=Math.round((this.scale||1)*100);return e>0?ja.find(e=>Math.round(e*100)>t)??null:[...ja].reverse().find(e=>Math.round(e*100)<t)??null}_stepZoom(e){let t=this._zoomStep(e);t!=null&&this._setZoom(t)}_setZoom(e){this.zoom=e,this.shell.savePrefs({zoom:String(e)}),this._layout()}_setTwoPage(e){this.twoPage=e,this.shell.savePrefs({twoPage:e}),this._layout()}_setThumbs(e){this.showThumbs=e,this.shell.savePrefs({thumbnails:e}),this.thumbRail.classList.toggle(`open`,e),e&&!this.thumbRail.childElementCount&&this._buildThumbs(),this._syncToolbar(),e&&(this._activeThumb=void 0,this._followThumb())}_buildThumbs(){this.thumbEls=[],this._thumbObserver=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&t.target instanceof HTMLElement&&this._drawThumb(Number(t.target.dataset.page))},{root:this.thumbRail,rootMargin:`200px 0px`});for(let e=1;e<=this.pdf.numPages;e++){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-file-viewer-thumb`,t.dataset.page=String(e),t.setAttribute(`aria-label`,`Go to page ${e}`);let{width:n,height:r}=$(this.sizes,e-1),i=document.createElement(`span`);i.className=`wui-file-viewer-thumb-frame`,i.style.aspectRatio=`${n} / ${r}`;let a=document.createElement(`span`);a.className=`wui-file-viewer-thumb-no`,a.textContent=String(e),t.append(i,a),t.addEventListener(`click`,()=>this.goToPage(e)),this.thumbRail.append(t),this.thumbEls[e]=t,this._thumbObserver.observe(t)}}async _drawThumb(e){if(this.thumbsDrawn.has(e))return;this.thumbsDrawn.add(e);let t=this.pages.get(e)?.canvas;if(t){this._thumbFromCanvas(e,t);return}let n=await this.pdf.getPage(e);if(this.destroyed)return;let r=window.devicePixelRatio||1,i=n.getViewport({scale:La*r/n.getViewport({scale:1}).width}),a=document.createElement(`canvas`);a.width=Math.floor(i.width),a.height=Math.floor(i.height);try{await n.render({canvas:a,viewport:i}).promise}catch(t){this.thumbsDrawn.delete(e),Qa(t)!==`RenderingCancelledException`&&this._warn(`thumbnail draw failed`,t);return}this._setThumbImage(e,a)}_thumbFromCanvas(e,t){this.thumbsDrawn.add(e);let n=window.devicePixelRatio||1,r=document.createElement(`canvas`);r.width=Math.floor(La*n),r.height=Math.floor(r.width*t.height/t.width),r.getContext(`2d`)?.drawImage(t,0,0,r.width,r.height),this._setThumbImage(e,r)}_setThumbImage(e,t){let n=this.thumbEls?.[e]?.querySelector(`.wui-file-viewer-thumb-frame`);n&&(t.setAttribute(`aria-hidden`,`true`),n.replaceChildren(t))}_followThumb(){let e=this.current();e!==this._activeThumb&&this.thumbEls&&(this._activeThumb!==void 0&&this.thumbEls[this._activeThumb]?.classList.remove(`active`),this._activeThumb=e,this.thumbEls[e]?.classList.add(`active`),this.thumbEls[e]?.scrollIntoView({behavior:to(),block:`nearest`}))}_openSearch(){this.search.open=!0,this.shell.search.hidden=!1,this._syncToolbar(),this.searchInput.focus(),this.searchInput.select(),!this.search.index&&!this.search.indexing&&(this.search.indexing=!0,this._syncSearchStatus(),_a(this.pdf).then(e=>{this.search.index=e}).catch(e=>{this._warn(`text index failed`,e),this.search.index=!1}).finally(()=>{this.search.indexing=!1,this.destroyed||this._setQuery(this.search.query)}))}_closeSearch(){this.search.open=!1,this.shell.search.hidden=!0,this._applyHits([],-1),this._syncToolbar(),this.searchButton.focus()}_setQuery(e){this.search.query=e;let t=this.search.index?ya(this.search.index,e):[],n=this.current(),r=t.findIndex(e=>e.page>=n);this._applyHits(t,t.length?Math.max(r,0):-1),this._revealPending=t.length>0,t.length&&this._bringHitIntoView()}_goToHit(e){let{hits:t}=this.search;t.length&&(this._applyHits(t,(e+t.length)%t.length),this._revealPending=!0,this._bringHitIntoView())}_applyHits(e,t){let n=e!==this.search.hits,r=this.search;if(this.search={...r,hits:e,current:t},n){let t=new Map;e.forEach((e,n)=>{let r=t.get(e.page)??[];r.push({...e,n}),t.set(e.page,r)}),this.search.byPage=t}let i=n?new Set([...r.marked.keys(),...this.search.byPage?.keys()??[]]):new Set([r.hits[r.current]?.page,e[t]?.page].filter(e=>e!==void 0));for(let e of i)this._markPage(e);this._syncSearchStatus()}_markPage(e){let t=this.pages.get(e),n=t?.textLayer?.textDivs;if(!n||!t?.text?.isConnected)return;let r=this.search.index,i=Array.isArray(r)?r[e-1]?.items:void 0,a=this.search.open?this.search.byPage?.get(e)??[]:[],o=this.search.marked.get(e)??new Set,s=new Set;i&&a.length&&i.forEach((e,t)=>{let r=ba(e,a),i=n[t];r.length&&i&&(s.add(t),ka(i,r,this.search.current))});for(let e of o){let t=n[e];!s.has(e)&&t&&t.replaceChildren(t.textContent??``)}s.size?this.search.marked.set(e,s):this.search.marked.delete(e)}_bringHitIntoView(){let e=this.search.hits[this.search.current];if(!e)return;let t=$(this.rows,$(this.rowOf,e.page)),n=this.scrollPos.top;(t.top+t.height<n||t.top>n+this.area.height)&&(this.scroller.scrollTop=t.top-Fa),this._revealHit(e.page)}_revealHit(e){let t=this.search.hits[this.search.current];if(!this._revealPending||!t||t.page!==e)return;let n=$(this.pageEls,e).querySelector(`.wui-file-viewer-hit-current`);if(!n)return;this._revealPending=!1;let r=this.scroller.getBoundingClientRect(),i=n.getBoundingClientRect();(i.top<r.top||i.bottom>r.bottom)&&(this.scroller.scrollTop+=i.top-r.top-this.scroller.clientHeight/2),(i.left<r.left||i.right>r.right)&&(this.scroller.scrollLeft+=i.left-r.left-this.scroller.clientWidth/2)}_syncSearchStatus(){this.searchStatus&&(this.searchStatus.textContent=ga(this.search),this.prevHitButton.disabled=!this.search.hits.length,this.nextHitButton.disabled=!this.search.hits.length)}_keyDown(e){if(e.defaultPrevented||e.altKey)return;if(e.ctrlKey||e.metaKey){if(e.key===`f`||e.key===`F`)this._openSearch();else if(e.key===`+`||e.key===`=`)this._stepZoom(1);else if(e.key===`-`||e.key===`_`)this._stepZoom(-1);else if(e.key===`0`)this._setZoom(`fit-width`);else return;e.preventDefault();return}if(e.shiftKey||qa(e.target))return;let t=this.cols();if(e.key===`PageDown`)this.goToPage(this.current()+t);else if(e.key===`PageUp`)this.goToPage(this.current()-t);else if(e.key===`Home`)this.goToPage(1);else if(e.key===`End`)this.goToPage(this.pdf.numPages);else return;e.preventDefault()}_panStart(e){let t=this.scroller;e.button!==0||t.scrollWidth<=t.clientWidth&&t.scrollHeight<=t.clientHeight||e.target instanceof Element&&e.target.closest(`a`)||(this._pan={id:e.pointerId,x:e.clientX,y:e.clientY,left:t.scrollLeft,top:t.scrollTop,active:!1})}_panMove(e){let t=this._pan;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.active){if(Math.abs(n)<Va&&Math.abs(r)<Va)return;t.active=!0,this.scroller.setPointerCapture(t.id),this.scroller.classList.add(`wui-file-viewer-panning`)}this.scroller.scrollLeft=t.left-n,this.scroller.scrollTop=t.top-r}_panEnd(){let e=this._pan;e?.active&&(this.scroller.hasPointerCapture(e.id)&&this.scroller.releasePointerCapture(e.id),this.scroller.classList.remove(`wui-file-viewer-panning`)),this._pan=null}async print(){this._releasePrint();let e={ready:!1,urls:[]};this.printRun=e,this._syncToolbar();try{let t=[];for(let n=1;n<=this.pdf.numPages;n++){let r=await this.pdf.getPage(n),i=r.getViewport({scale:Ha/72}),a=document.createElement(`canvas`);a.width=Math.floor(i.width),a.height=Math.floor(i.height),await r.render({canvas:a,viewport:i,intent:`print`}).promise;let o=await new Promise((e,t)=>a.toBlob(n=>n?e(n):t(Error(`Page image failed`)),`image/png`));a.width=0,a.height=0;let s=URL.createObjectURL(o);if(e.urls.push(s),t.push({url:s,width:i.width/Ha*25.4,height:i.height/Ha*25.4}),this.printRun!==e)throw new DOMException(`Print replaced`,`AbortError`)}let n=document.createElement(`iframe`);n.className=`wui-file-viewer-print-frame`,n.title=`Document for printing`,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),e.frame=n,n.srcdoc=Da(this.shell.name()),n.addEventListener(`load`,async()=>{if(this.printRun===e)try{let{css:r,pages:i}=Oa(t),a=n.contentWindow,o=n.contentDocument;if(!a||!o)throw TypeError(`The print frame has no document.`);let s=Reflect.get(a,`CSSStyleSheet`);if(!Za(s))throw TypeError(`The print frame has no CSSStyleSheet.`);let c=new s;c.replaceSync(r),o.adoptedStyleSheets=[c];let l=i.map(e=>{let t=o.createElement(`img`);return t.src=e.url,t.alt=``,t.style.setProperty(`width`,`${e.width}mm`),t.style.setProperty(`height`,`${e.height}mm`),t.style.setProperty(`page`,e.page),t});if(o.body.append(...l),await Promise.all(l.map($a)),this.printRun!==e)return;e.ready=!0,this._syncToolbar(),a.addEventListener(`afterprint`,()=>{this.printRun===e&&this._releasePrint()},{once:!0}),a.focus(),a.print()}catch(e){this._printFallback(e)}},{once:!0}),document.body.append(n)}catch(t){if(this.printRun!==e){for(let t of e.urls)URL.revokeObjectURL(t);return}this._printFallback(t)}}_printFallback(e){this._releasePrint(),this._warn(`print failed`,e),window.open(this.source.src,`_blank`,`noopener`)}_releasePrint(){let e=this.printRun;if(this.printRun=null,e){e.frame?.remove();for(let t of e.urls)URL.revokeObjectURL(t)}this.printButton&&this._syncToolbar()}_warn(e,t){u(`[wui-file-viewer] ${e}:`,t instanceof Error?t.message:t)}},Xa=e=>typeof e==`object`&&!!e,Za=e=>typeof e==`function`,Qa=e=>e instanceof Error?e.name:void 0,$a=e=>e.complete?null:new Promise(t=>{e.addEventListener(`load`,t,{once:!0}),e.addEventListener(`error`,t,{once:!0})}),eo=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),to=()=>window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})),ro=r({ImageView:()=>so}),io,ao,oo,so,co,lo,uo=n((()=>{f(),j(),ee(),io=[.1,.25,.5,.75,1,1.5,2,3,4],ao=[.25,.5,1,2,4],oo=5,so=class{constructor(e,t){this.shell=e,this.source=t,this.zoom=`fit`,this.rotation=0,this.area={width:0,height:0},this.destroyed=!1}load(){let e=document.createElement(`img`);e.className=`wui-file-viewer-image`,e.alt=this.shell.name(),e.decoding=`async`,e.draggable=!1,e.addEventListener(`load`,()=>{this.destroyed||(this.natural={width:e.naturalWidth||300,height:e.naturalHeight||150},this._build(e),this.shell.loaded({kind:`image`,pages:1}))}),e.addEventListener(`error`,()=>{this.destroyed||this.shell.fail(Error(`The image could not be decoded.`))}),e.src=this.source.src,this.img=e}destroy(){this.destroyed=!0,this._resizeObserver?.disconnect(),this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this._printFrame?.remove(),this.img?.removeAttribute(`src`)}_build(e){let{center:t,end:n,body:r,host:i}=this.shell;this.zoomOutButton=O(`zoom-out`,`Zoom out`),this.zoomOutButton.addEventListener(`click`,()=>this._stepZoom(-1)),this.zoomButton=document.createElement(`button`),this.zoomButton.type=`button`,this.zoomButton.className=`wui-file-viewer-zoom`,te(this.zoomButton,{label:`Zoom`,items:()=>[...ao.map(e=>({key:String(e),label:`${Math.round(e*100)}%`,checked:this.zoom===e})),{key:`fit-divider`,divider:!0},{key:`fit`,label:`Fit`,checked:this.zoom===`fit`}],onPick:e=>this._setZoom(e===`fit`?`fit`:Number(e))}),this.zoomInButton=O(`zoom-in`,`Zoom in`),this.zoomInButton.addEventListener(`click`,()=>this._stepZoom(1));let a=O(`rotate-ccw`,`Rotate left`);a.addEventListener(`click`,()=>this._rotate(-90));let o=O(`rotate-cw`,`Rotate right`);o.addEventListener(`click`,()=>this._rotate(90));let s=document.createElement(`span`);s.className=`wui-file-viewer-divider wui-file-viewer-print`;let c=O(`printer`,`Print`,{className:`wui-file-viewer-print`});c.addEventListener(`click`,()=>this.print()),s.hidden=c.hidden=!this.shell.print(),t.append(this.zoomOutButton,this.zoomButton,this.zoomInButton),n.prepend(a,o,s,c),this.scroller=document.createElement(`div`),this.scroller.className=`wui-file-viewer-scroll wui-file-viewer-image-scroll wui-scroll`,this.scroller.tabIndex=0,this.scroller.setAttribute(`role`,`region`),this.scroller.setAttribute(`aria-label`,`Image`),this.stage=document.createElement(`div`),this.stage.className=`wui-file-viewer-image-stage`,this.stage.append(e),this.scroller.append(this.stage),r.replaceChildren(this.scroller),this.scroller.addEventListener(`pointerdown`,e=>this._panStart(e)),this.scroller.addEventListener(`pointermove`,e=>this._panMove(e));for(let e of[`pointerup`,`pointercancel`,`lostpointercapture`])this.scroller.addEventListener(e,()=>this._panEnd());this.scroller.addEventListener(`wheel`,e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=performance.now();t-(this._lastWheelZoom??0)<120||(this._lastWheelZoom=t,this._stepZoom(e.deltaY<0?1:-1))},{passive:!1}),this._onKeyDown=e=>this._keyDown(e),i.addEventListener(`keydown`,this._onKeyDown),this._resizeObserver=new ResizeObserver(()=>{let e=this.scroller.clientWidth,t=this.scroller.clientHeight;(e!==this.area.width||t!==this.area.height)&&(this.area={width:e,height:t},this._layout())}),this._resizeObserver.observe(this.scroller),this.area={width:this.scroller.clientWidth,height:this.scroller.clientHeight},this._layout()}_turned(){let{width:e,height:t}=this.natural;return this.rotation%180==0?{width:e,height:t}:{width:t,height:e}}scale(){if(typeof this.zoom==`number`)return this.zoom;let{width:e,height:t}=this._turned(),n=Math.min((this.area.width-32)/e,(this.area.height-32)/t);return Math.max(n,.01)}_layout(){if(!this.stage)return;let e=this.scale(),t=this._turned();this.stage.style.width=`${Math.round(t.width*e)}px`,this.stage.style.height=`${Math.round(t.height*e)}px`,this.img.style.width=`${Math.round(this.natural.width*e)}px`,this.img.style.height=`${Math.round(this.natural.height*e)}px`,this.img.style.transform=`translate(-50%, -50%) rotate(${this.rotation}deg)`;let n=Math.round(e*100);this.zoomButton.innerHTML=`${n}%${E(`chevron-down`,{size:12})}`,this.zoomButton.setAttribute(`aria-label`,`Zoom, ${n}%`),this.zoomOutButton.disabled=this._zoomStep(-1)==null,this.zoomInButton.disabled=this._zoomStep(1)==null}_zoomStep(e){let t=Math.round(this.scale()*100);return e>0?io.find(e=>Math.round(e*100)>t)??null:[...io].reverse().find(e=>Math.round(e*100)<t)??null}_stepZoom(e){let t=this._zoomStep(e);t!=null&&this._setZoom(t)}_setZoom(e){let t=this.scroller,n=(t.scrollLeft+t.clientWidth/2)/Math.max(t.scrollWidth,1),r=(t.scrollTop+t.clientHeight/2)/Math.max(t.scrollHeight,1);this.zoom=e,this._layout(),t.scrollLeft=n*t.scrollWidth-t.clientWidth/2,t.scrollTop=r*t.scrollHeight-t.clientHeight/2}_rotate(e){this.rotation=(this.rotation+e+360)%360,this._setZoom(this.zoom)}_keyDown(e){if(!(e.defaultPrevented||e.altKey||!(e.ctrlKey||e.metaKey))){if(e.key===`+`||e.key===`=`)this._stepZoom(1);else if(e.key===`-`||e.key===`_`)this._stepZoom(-1);else if(e.key===`0`)this._setZoom(`fit`);else return;e.preventDefault()}}_panStart(e){let t=this.scroller;e.button!==0||t.scrollWidth<=t.clientWidth&&t.scrollHeight<=t.clientHeight||(this._pan={id:e.pointerId,x:e.clientX,y:e.clientY,left:t.scrollLeft,top:t.scrollTop,active:!1})}_panMove(e){let t=this._pan;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.active){if(Math.abs(n)<oo&&Math.abs(r)<oo)return;t.active=!0,this.scroller.setPointerCapture(t.id),this.scroller.classList.add(`wui-file-viewer-panning`)}this.scroller.scrollLeft=t.left-n,this.scroller.scrollTop=t.top-r}_panEnd(){let e=this._pan;e?.active&&(this.scroller.hasPointerCapture(e.id)&&this.scroller.releasePointerCapture(e.id),this.scroller.classList.remove(`wui-file-viewer-panning`)),this._pan=null}print(){this._printFrame?.remove();let e=document.createElement(`iframe`);e.className=`wui-file-viewer-print-frame`,e.title=`Image for printing`,e.tabIndex=-1,e.setAttribute(`aria-hidden`,`true`);let t=this.rotation%180!=0,n=new URL(this.source.src,document.baseURI).href;e.srcdoc=`<!doctype html><html><head><title>${lo(this.shell.name())}</title></head><body></body></html>`,e.addEventListener(`load`,async()=>{try{let r=e.contentWindow,i=e.contentDocument;if(!r||!i)throw TypeError(`The print frame has no document.`);let a=Reflect.get(r,`CSSStyleSheet`);if(!co(a))throw TypeError(`The print frame has no CSSStyleSheet.`);let o=new a;o.replaceSync(`@page { margin: 10mm; }
17
+ img:last-child { break-after: auto; }`,pages:e.map(e=>({url:e.url,width:e.width,height:e.height,page:`s${n.indexOf(t(e))}`}))}}function ka(e,t,n){let r=e.textContent??``,i=[],a=0;for(let{from:e,to:o,n:s}of t){e>a&&i.push(document.createTextNode(r.slice(a,e)));let t=document.createElement(`mark`);t.className=s===n?`wui-file-viewer-hit wui-file-viewer-hit-current`:`wui-file-viewer-hit`,t.textContent=r.slice(e,o),i.push(t),a=o}a<r.length&&i.push(document.createTextNode(r.slice(a))),e.replaceChildren(...i)}function $(e,t){let n=e[t];if(n===void 0)throw RangeError(`No item at index ${t}.`);return n}function Aa(e){let t=[...e].sort((e,t)=>e-t);return $(t,Math.floor(t.length/2))}var ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no=n((()=>{pa(),ha(),Sa(),j(),ee(),ja=[.5,.75,1,1.25,1.5,2,3],Ma=[.5,.75,1,1.25,1.5,2],Na=[{key:`fit-width`,label:`Fit width`},{key:`fit-page`,label:`Fit page`}],Pa=96/72,Fa=12,Ia=10,La=168,Ra=150,za=2,Ba=2e3,Va=5,Ha=150,Ua=16777216,Wa=null,Ga=e=>Na.some(t=>t.key===e),Ka=e=>{if(Ga(e))return e;let t=Number(e);return ja.includes(t)?t:`fit-width`},qa=e=>e instanceof Element&&e.closest(`input, textarea, select, [contenteditable='true'], .dropdown-menu`),Ja=e=>/^(https?:|mailto:)/i.test(e),Ya=class{constructor(e,t){this.shell=e,this.source=t;let n=e.prefs;this.zoom=Ka(n.zoom),this.twoPage=n.twoPage===!0,this.showThumbs=n.thumbnails===!0,this.sizes=[],this.rows=[],this.rowOf=[],this.scale=0,this.drawnScale=0,this.pages=new Map,this.thumbsDrawn=new Set,this.area={width:0,height:0},this.scrollPos={top:0,left:0},this.jumpTarget=null,this.search={open:!1,query:``,index:null,indexing:!1,hits:[],current:-1,marked:new Map},this.printRun=null,this.destroyed=!1,this._timers=new Set}load(){return this._loading=this._load(),this._loading}async _load(){wa(this.source.workerSrc),this.task=ht({url:this.source.src,...Ta(this.source.assetBase)});let e;try{e=await this.task.promise}catch(e){this.destroyed||this.shell.fail(e);return}if(this.destroyed){e.destroy();return}this.pdf=e;let t=await Promise.all(Array.from({length:e.numPages},(t,n)=>e.getPage(n+1)));this.destroyed||(this.sizes=t.map(e=>{let t=e.getViewport({scale:Pa});return{width:t.width,height:t.height}}),this._buildToolbar(),this._buildBody(),this._layout(),this.shell.loaded({kind:`pdf`,pages:e.numPages}))}destroy(){this.destroyed=!0;for(let e of this._timers)window.clearTimeout(e);this._scrollFrame!==void 0&&window.cancelAnimationFrame(this._scrollFrame),this._resizeObserver?.disconnect(),this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this._thumbObserver?.disconnect();for(let e of[...this.pages.keys()])this._release(e);this._releasePrint();let e=this.task;e&&(this._loading??Promise.resolve()).catch(e=>{d(`PDF load failed before the viewer closed.`,e)}).finally(()=>e.destroy())}_buildToolbar(){let{start:e,center:t,end:n,host:r}=this.shell;this.thumbsButton=O(`menu`,``,{size:17}),this.thumbsButton.addEventListener(`click`,()=>this._setThumbs(!this.showThumbs)),e.prepend(this.thumbsButton),this.prevButton=O(`chevron-up`,`Previous page`),this.prevButton.addEventListener(`click`,()=>this.goToPage(this.current()-this.cols()));let i=document.createElement(`span`);i.className=`wui-file-viewer-page`,this.pageInput=document.createElement(`input`),this.pageInput.className=`wui-file-viewer-page-input`,this.pageInput.setAttribute(`aria-label`,`Page number`),this.pageInput.inputMode=`numeric`,this.pageInput.addEventListener(`input`,()=>{this.pageInput.value=this.pageInput.value.replace(/[^\d]/g,``)}),this.pageInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&this.pageInput.blur()}),this.pageInput.addEventListener(`blur`,()=>this._commitPageInput());let a=document.createElement(`span`);a.className=`wui-file-viewer-page-total`,a.textContent=`/ ${this.pdf.numPages}`,i.append(this.pageInput,a),this.nextButton=O(`chevron-down`,`Next page`),this.nextButton.addEventListener(`click`,()=>this.goToPage(this.current()+this.cols())),t.append(this.prevButton,i,this.nextButton),this.searchButton=O(`search`,`Search the document`,{className:`wui-file-viewer-search-toggle`}),this.searchButton.setAttribute(`aria-controls`,`${r.uid}-search`),this.searchButton.addEventListener(`click`,()=>this.search.open?this._closeSearch():this._openSearch()),this.zoomOutButton=O(`zoom-out`,`Zoom out`),this.zoomOutButton.addEventListener(`click`,()=>this._stepZoom(-1)),this.zoomButton=document.createElement(`button`),this.zoomButton.type=`button`,this.zoomButton.className=`wui-file-viewer-zoom`,te(this.zoomButton,{label:`Zoom`,items:()=>[...Ma.map(e=>({key:String(e),label:`${Math.round(e*100)}%`,checked:this.zoom===e})),{key:`fit-divider`,divider:!0},...Na.map(e=>({key:e.key,label:e.label,checked:this.zoom===e.key}))],onPick:e=>this._setZoom(Ka(e))}),this.zoomInButton=O(`zoom-in`,`Zoom in`),this.zoomInButton.addEventListener(`click`,()=>this._stepZoom(1));let o=document.createElement(`span`);o.className=`wui-file-viewer-divider`,this.twoPageButton=O(`two-page`,`Two-page view`),this.twoPageButton.addEventListener(`click`,()=>this._setTwoPage(!this.twoPage)),this.printButton=O(`printer`,`Print`,{className:`wui-file-viewer-print`}),this.printButton.addEventListener(`click`,()=>this.print()),this.printButton.hidden=!this.shell.print(),n.prepend(this.searchButton,this.zoomOutButton,this.zoomButton,this.zoomInButton,o,this.twoPageButton,this.printButton),this._buildSearchRow(),this._syncToolbar()}_buildSearchRow(){let e=this.shell.search;e.id=`${this.shell.host.uid}-search`;let t=document.createElement(`div`);t.className=`wui-file-viewer-search-field`,this.searchInput=document.createElement(`input`),this.searchInput.type=`search`,this.searchInput.className=`form-control form-control-sm`,this.searchInput.placeholder=`Search the document`,this.searchInput.setAttribute(`aria-label`,`Search the document`),this.searchInput.addEventListener(`input`,()=>this._setQuery(this.searchInput.value)),this.searchInput.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this._goToHit(this.search.current+(e.shiftKey?-1:1))):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._closeSearch())}),t.append(this.searchInput),this.searchStatus=document.createElement(`span`),this.searchStatus.className=`wui-file-viewer-search-count`,this.searchStatus.setAttribute(`aria-live`,`polite`),this.prevHitButton=O(`chevron-up`,`Previous match`),this.prevHitButton.addEventListener(`click`,()=>this._goToHit(this.search.current-1)),this.nextHitButton=O(`chevron-down`,`Next match`),this.nextHitButton.addEventListener(`click`,()=>this._goToHit(this.search.current+1));let n=O(`x`,`Close search`);n.addEventListener(`click`,()=>this._closeSearch()),e.append(t,this.searchStatus,this.prevHitButton,this.nextHitButton,n)}_syncToolbar(){let e=this.current(),t=this.rows.length-1;document.activeElement!==this.pageInput&&(this.pageInput.value=String(e)),this.prevButton.disabled=e<=1,this.nextButton.disabled=(this.rowOf[e]??0)>=t,this.zoomOutButton.disabled=this._zoomStep(-1)==null,this.zoomInButton.disabled=this._zoomStep(1)==null;let n=Math.round((this.scale||1)*100);this._shownPercent!==n&&(this._shownPercent=n,this.zoomButton.innerHTML=`${n}%${E(`chevron-down`,{size:12})}`,this.zoomButton.setAttribute(`aria-label`,`Zoom, ${n}%`)),A(this.thumbsButton,this.showThumbs?`Hide thumbnails`:`Show thumbnails`),this.thumbsButton.setAttribute(`aria-pressed`,String(this.showThumbs)),this.twoPageButton.setAttribute(`aria-pressed`,String(this.twoPage)),this.printButton.disabled=this.printRun!=null&&!this.printRun.ready,A(this.printButton,this.printButton.disabled?`Preparing to print`:`Print`),A(this.searchButton,this.search.open?`Close search`:`Search the document`),this.searchButton.setAttribute(`aria-expanded`,String(this.search.open)),this._syncSearchStatus()}_buildBody(){let e=this.shell.body;this.thumbRail=document.createElement(`div`),this.thumbRail.className=`wui-file-viewer-thumbs wui-scroll${this.showThumbs?` open`:``}`,this.scroller=document.createElement(`div`),this.scroller.className=`wui-file-viewer-scroll wui-scroll`,this.scroller.tabIndex=0,this.scroller.setAttribute(`role`,`region`),this.scroller.setAttribute(`aria-label`,`Document pages`),this.pagesEl=document.createElement(`div`),this.pagesEl.className=`wui-file-viewer-pages`,this.scroller.append(this.pagesEl),e.replaceChildren(this.thumbRail,this.scroller),this.pageEls=[];for(let e=1;e<=this.pdf.numPages;e++){let t=document.createElement(`div`);t.className=`wui-file-viewer-sheet`,t.dataset.page=String(e),this.pageEls[e]=t}this.showThumbs&&this._buildThumbs(),this.scroller.addEventListener(`scroll`,()=>this._onScroll(),{passive:!0}),this.scroller.addEventListener(`pointerdown`,e=>this._panStart(e)),this.scroller.addEventListener(`pointermove`,e=>this._panMove(e));for(let e of[`pointerup`,`pointercancel`,`lostpointercapture`])this.scroller.addEventListener(e,()=>this._panEnd());this.scroller.addEventListener(`wheel`,e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=performance.now();t-(this._lastWheelZoom??0)<120||(this._lastWheelZoom=t,this._stepZoom(e.deltaY<0?1:-1))},{passive:!1}),this._onKeyDown=e=>this._keyDown(e),this.shell.host.addEventListener(`keydown`,this._onKeyDown),this._resizeObserver=new ResizeObserver(()=>{let e=this.scroller.clientWidth,t=this.scroller.clientHeight;(e!==this.area.width||t!==this.area.height)&&(this.area={width:e,height:t},this._layout())}),this._resizeObserver.observe(this.scroller),this.area={width:this.scroller.clientWidth,height:this.scroller.clientHeight}}cols(){return this.twoPage?2:1}_targetScale(){if(typeof this.zoom==`number`)return this.zoom;let e=this.cols(),t=Aa(this.sizes.map(e=>e.width)),n=Aa(this.sizes.map(e=>e.height)),r=(this.area.width-24-(e-1)*Ia)/(t*e);return this.zoom===`fit-page`&&(r=Math.min(r,(this.area.height-24)/n)),Math.max(r,.1)}_layout(){if(!this.pdf||!this.area.width)return;let e=this._anchor();this.scale=this._targetScale();let t=this.cols();this.rows=[],this.rowOf=[];let n=Fa,r=document.createDocumentFragment();for(let e=1;e<=this.pdf.numPages;e+=t){let i=[];for(let n=e;n<e+t&&n<=this.pdf.numPages;n++)i.push(n);let a=document.createElement(`div`);a.className=`wui-file-viewer-row`;let o=0;for(let e of i){let{width:t,height:n}=$(this.sizes,e-1),r=$(this.pageEls,e);r.style.width=`${Math.floor(t*this.scale)}px`,r.style.height=`${Math.floor(n*this.scale)}px`,r.style.setProperty(`--scale-factor`,String(this.scale*Pa)),o=Math.max(o,Math.floor(n*this.scale)),a.append(r),this.rowOf[e]=this.rows.length}this.rows.push({pages:i,top:n,height:o}),n+=o+Ia,r.append(a)}let i=this.scroller.scrollWidth;this.pagesEl.replaceChildren(r),this._restore(e,i),this._scheduleRedraw(),this._update()}_anchor(){if(!this.rows.length)return null;let e=this._rowAt(this.scrollPos.top),t=$(this.rows,e);return{page:$(t.pages,0),within:(this.scrollPos.top-t.top)/Math.max(t.height+Ia,1),left:this.scrollPos.left}}_restore(e,t){let n=this.scroller;if(e){let r=$(this.rows,$(this.rowOf,e.page));n.scrollTop=r.top+e.within*(r.height+Ia),n.scrollLeft=(t?(e.left+n.clientWidth/2)/t:.5)*n.scrollWidth-n.clientWidth/2}this.scrollPos={top:n.scrollTop,left:n.scrollLeft}}_rowAt(e){let t=0,n=this.rows.length-1;for(;t<n;){let r=t+n+1>>1;$(this.rows,r).top<=e+1?t=r:n=r-1}return t}current(){if(this.jumpTarget!=null)return this.jumpTarget;if(!this.rows.length)return 1;let e=this.scrollPos.top,t=e+this.area.height,n=this._rowAt(e),r=-1;for(let i=n;i<this.rows.length&&$(this.rows,i).top<t;i++){let{top:a,height:o}=$(this.rows,i),s=Math.min(a+o,t)-Math.max(a,e);s>r&&(r=s,n=i)}return $($(this.rows,n).pages,0)}_onScroll(){this.scrollPos={top:this.scroller.scrollTop,left:this.scroller.scrollLeft},this._scrollFrame!==void 0&&window.cancelAnimationFrame(this._scrollFrame),this._scrollFrame=window.requestAnimationFrame(()=>this._update())}_update(){if(!this.rows.length||this.destroyed)return;let e=Math.max(0,this._rowAt(this.scrollPos.top)-za),t=Math.min(this.rows.length-1,this._rowAt(this.scrollPos.top+this.area.height)+za),n=new Set;for(let r=e;r<=t;r++)for(let e of $(this.rows,r).pages)n.add(e);for(let e of[...this.pages.keys()])n.has(e)||this._release(e);this.visibleRow=this._rowAt(this.scrollPos.top);for(let e of n)this.pages.has(e)||this._mount(e);this._pump(),this._syncToolbar(),this.showThumbs&&this._followThumb()}_scheduleRedraw(){if(this.scale===this.drawnScale)return;window.clearTimeout(this._redrawTimer),this._timers.delete(this._redrawTimer);let e=this.drawnScale?Ra:0;this._redrawTimer=window.setTimeout(()=>{this._timers.delete(this._redrawTimer),this.drawnScale=this.scale,this._pump()},e),this._timers.add(this._redrawTimer)}_mount(e){let t=$(this.pageEls,e),n={n:e,drawnAt:0,task:null,canvas:null,text:null,textLayer:null,links:null};this.pages.set(e,n);let r=document.createElement(`div`);r.className=`wui-file-viewer-skeleton`,t.replaceChildren(r),this._drawText(n),this._drawLinks(n)}_release(e){let t=this.pages.get(e);t&&(t.released=!0,t.task?.cancel(),t.textLayer?.cancel(),t.canvas&&(t.canvas.width=0,t.canvas.height=0),this.pages.delete(e),this.search.marked.delete(e),$(this.pageEls,e).replaceChildren())}_pump(){if(this._drawing||!this.drawnScale||this.destroyed)return;let e=this.visibleRow??0,t=null,n=1/0;for(let r of this.pages.values()){if(r.drawnAt===this.drawnScale)continue;let i=Math.abs((this.rowOf[r.n]??NaN)-e);i<n&&(n=i,t=r)}t&&(this._drawing=!0,this._drawCanvas(t).finally(()=>{this._drawing=!1,this._pump()}))}async _drawCanvas(e){let t=this.drawnScale,n=await this.pdf.getPage(e.n);if(e.released||this.destroyed)return;let r=n.getViewport({scale:t*Pa}),i=window.devicePixelRatio||1,a=Math.sqrt(Ua/(r.width*r.height)),o=Math.min(i,a),s=document.createElement(`canvas`);s.className=`wui-file-viewer-canvas`,s.width=Math.floor(r.width*o),s.height=Math.floor(r.height*o),s.setAttribute(`aria-hidden`,`true`),e.task=n.render({canvas:s,viewport:r,transform:o===1?void 0:[o,0,0,o,0,0]});try{await e.task.promise}catch(e){s.width=0,s.height=0,Qa(e)!==`RenderingCancelledException`&&this._warn(`page draw failed`,e);return}finally{e.task=null}if(e.released||this.destroyed){s.width=0,s.height=0;return}let c=$(this.pageEls,e.n);e.canvas?(e.canvas.replaceWith(s),e.canvas.width=0,e.canvas.height=0):(c.querySelector(`.wui-file-viewer-skeleton`)?.remove(),c.prepend(s)),e.canvas=s,e.drawnAt=t,this.showThumbs&&!this.thumbsDrawn.has(e.n)&&this._thumbFromCanvas(e.n,s)}async _drawText(e){let t=await this.pdf.getPage(e.n);if(e.released||this.destroyed)return;let n=document.createElement(`div`);n.className=`wui-file-viewer-text`,e.text=n,e.textLayer=new Jr({textContentSource:t.streamTextContent({includeMarkedContent:!0,disableNormalization:!0}),container:n,viewport:t.getViewport({scale:this.scale*Pa})});try{await e.textLayer.render()}catch(e){Qa(e)!==`AbortException`&&this._warn(`text layer failed`,e);return}e.released||this.destroyed||($(this.pageEls,e.n).append(n),this._markPage(e.n),this._revealHit(e.n))}async _drawLinks(e){let t=await this.pdf.getPage(e.n),n=await t.getAnnotations({intent:`display`});if(e.released||this.destroyed)return;let r=n.filter(e=>e.subtype===`Link`&&(e.dest||e.url&&Ja(e.url))),i=(await Promise.all(r.map(async e=>e.url?{link:e,target:void 0}:{link:e,target:await this._destPage(e.dest)}))).filter(({link:e,target:t})=>e.url||t);if(!i.length||e.released||this.destroyed)return;let a=t.getViewport({scale:1}),o=document.createElement(`div`);o.className=`wui-file-viewer-links`;for(let{link:e,target:t}of i){let[n=NaN,r=NaN,i=NaN,s=NaN]=a.convertToViewportRectangle(e.rect),c=document.createElement(`a`);if(c.style.left=`${Math.min(n,i)/a.width*100}%`,c.style.top=`${Math.min(r,s)/a.height*100}%`,c.style.width=`${Math.abs(i-n)/a.width*100}%`,c.style.height=`${Math.abs(s-r)/a.height*100}%`,e.url)c.href=e.url,c.target=`_blank`,c.rel=`noopener noreferrer`,c.title=e.url,c.setAttribute(`aria-label`,e.url);else if(t){let e=t;c.href=`#page=${e}`,c.setAttribute(`aria-label`,`Go to page ${e}`),c.addEventListener(`click`,t=>{t.preventDefault(),this.goToPage(e)})}o.append(c)}e.links=o,$(this.pageEls,e.n).append(o)}async _destPage(e){try{let t=(typeof e==`string`?await this.pdf.getDestination(e):e)?.[0];if(t==null)return null;let n=Xa(t)?await this.pdf.getPageIndex(t):t;if(typeof n!=`number`)throw TypeError(`The link destination is not a page.`);return n+1}catch(e){return this._warn(`link target not found`,e),null}}goToPage(e){let t=Math.min(Math.max(1,e),this.pdf.numPages),n=Math.min($(this.rows,$(this.rowOf,t)).top-Fa,this.scroller.scrollHeight-this.scroller.clientHeight);window.clearTimeout(this._jumpTimer);let r=this._endJump;r&&this.scroller.removeEventListener(`scrollend`,r),this._endJump=()=>{window.clearTimeout(this._jumpTimer);let e=this._endJump;e&&this.scroller.removeEventListener(`scrollend`,e),this.jumpTarget=null,this._syncToolbar()},Math.abs(n-this.scroller.scrollTop)>=1&&(this.jumpTarget=t,this.scroller.addEventListener(`scrollend`,this._endJump),this._jumpTimer=window.setTimeout(this._endJump,Ba),this._timers.add(this._jumpTimer),this.scroller.scrollTo({top:n,behavior:to()})),this._syncToolbar()}_commitPageInput(){let e=Number.parseInt(this.pageInput.value,10);Number.isNaN(e)?this.pageInput.value=String(this.current()):this.goToPage(e)}_zoomStep(e){let t=Math.round((this.scale||1)*100);return e>0?ja.find(e=>Math.round(e*100)>t)??null:[...ja].reverse().find(e=>Math.round(e*100)<t)??null}_stepZoom(e){let t=this._zoomStep(e);t!=null&&this._setZoom(t)}_setZoom(e){this.zoom=e,this.shell.savePrefs({zoom:String(e)}),this._layout()}_setTwoPage(e){this.twoPage=e,this.shell.savePrefs({twoPage:e}),this._layout()}_setThumbs(e){this.showThumbs=e,this.shell.savePrefs({thumbnails:e}),this.thumbRail.classList.toggle(`open`,e),e&&!this.thumbRail.childElementCount&&this._buildThumbs(),this._syncToolbar(),e&&(this._activeThumb=void 0,this._followThumb())}_buildThumbs(){this.thumbEls=[],this._thumbObserver=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&t.target instanceof HTMLElement&&this._drawThumb(Number(t.target.dataset.page))},{root:this.thumbRail,rootMargin:`200px 0px`});for(let e=1;e<=this.pdf.numPages;e++){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-file-viewer-thumb`,t.dataset.page=String(e),t.setAttribute(`aria-label`,`Go to page ${e}`);let{width:n,height:r}=$(this.sizes,e-1),i=document.createElement(`span`);i.className=`wui-file-viewer-thumb-frame`,i.style.aspectRatio=`${n} / ${r}`;let a=document.createElement(`span`);a.className=`wui-file-viewer-thumb-no`,a.textContent=String(e),t.append(i,a),t.addEventListener(`click`,()=>this.goToPage(e)),this.thumbRail.append(t),this.thumbEls[e]=t,this._thumbObserver.observe(t)}}async _drawThumb(e){if(this.thumbsDrawn.has(e))return;this.thumbsDrawn.add(e);let t=this.pages.get(e)?.canvas;if(t){this._thumbFromCanvas(e,t);return}let n=await this.pdf.getPage(e);if(this.destroyed)return;let r=window.devicePixelRatio||1,i=n.getViewport({scale:La*r/n.getViewport({scale:1}).width}),a=document.createElement(`canvas`);a.width=Math.floor(i.width),a.height=Math.floor(i.height);try{await n.render({canvas:a,viewport:i}).promise}catch(t){this.thumbsDrawn.delete(e),Qa(t)!==`RenderingCancelledException`&&this._warn(`thumbnail draw failed`,t);return}this._setThumbImage(e,a)}_thumbFromCanvas(e,t){this.thumbsDrawn.add(e);let n=window.devicePixelRatio||1,r=document.createElement(`canvas`);r.width=Math.floor(La*n),r.height=Math.floor(r.width*t.height/t.width),r.getContext(`2d`)?.drawImage(t,0,0,r.width,r.height),this._setThumbImage(e,r)}_setThumbImage(e,t){let n=this.thumbEls?.[e]?.querySelector(`.wui-file-viewer-thumb-frame`);n&&(t.setAttribute(`aria-hidden`,`true`),n.replaceChildren(t))}_followThumb(){let e=this.current();e!==this._activeThumb&&this.thumbEls&&(this._activeThumb!==void 0&&this.thumbEls[this._activeThumb]?.classList.remove(`active`),this._activeThumb=e,this.thumbEls[e]?.classList.add(`active`),this.thumbEls[e]?.scrollIntoView({behavior:to(),block:`nearest`}))}_openSearch(){this.search.open=!0,this.shell.search.hidden=!1,this._syncToolbar(),this.searchInput.focus(),this.searchInput.select(),!this.search.index&&!this.search.indexing&&(this.search.indexing=!0,this._syncSearchStatus(),_a(this.pdf).then(e=>{this.search.index=e}).catch(e=>{this._warn(`text index failed`,e),this.search.index=!1}).finally(()=>{this.search.indexing=!1,this.destroyed||this._setQuery(this.search.query)}))}_closeSearch(){this.search.open=!1,this.shell.search.hidden=!0,this._applyHits([],-1),this._syncToolbar(),this.searchButton.focus()}_setQuery(e){this.search.query=e;let t=this.search.index?ya(this.search.index,e):[],n=this.current(),r=t.findIndex(e=>e.page>=n);this._applyHits(t,t.length?Math.max(r,0):-1),this._revealPending=t.length>0,t.length&&this._bringHitIntoView()}_goToHit(e){let{hits:t}=this.search;t.length&&(this._applyHits(t,(e+t.length)%t.length),this._revealPending=!0,this._bringHitIntoView())}_applyHits(e,t){let n=e!==this.search.hits,r=this.search;if(this.search={...r,hits:e,current:t},n){let t=new Map;e.forEach((e,n)=>{let r=t.get(e.page)??[];r.push({...e,n}),t.set(e.page,r)}),this.search.byPage=t}let i=n?new Set([...r.marked.keys(),...this.search.byPage?.keys()??[]]):new Set([r.hits[r.current]?.page,e[t]?.page].filter(e=>e!==void 0));for(let e of i)this._markPage(e);this._syncSearchStatus()}_markPage(e){let t=this.pages.get(e),n=t?.textLayer?.textDivs;if(!n||!t?.text?.isConnected)return;let r=this.search.index,i=Array.isArray(r)?r[e-1]?.items:void 0,a=this.search.open?this.search.byPage?.get(e)??[]:[],o=this.search.marked.get(e)??new Set,s=new Set;i&&a.length&&i.forEach((e,t)=>{let r=ba(e,a),i=n[t];r.length&&i&&(s.add(t),ka(i,r,this.search.current))});for(let e of o){let t=n[e];!s.has(e)&&t&&t.replaceChildren(t.textContent??``)}s.size?this.search.marked.set(e,s):this.search.marked.delete(e)}_bringHitIntoView(){let e=this.search.hits[this.search.current];if(!e)return;let t=$(this.rows,$(this.rowOf,e.page)),n=this.scrollPos.top;(t.top+t.height<n||t.top>n+this.area.height)&&(this.scroller.scrollTop=t.top-Fa),this._revealHit(e.page)}_revealHit(e){let t=this.search.hits[this.search.current];if(!this._revealPending||!t||t.page!==e)return;let n=$(this.pageEls,e).querySelector(`.wui-file-viewer-hit-current`);if(!n)return;this._revealPending=!1;let r=this.scroller.getBoundingClientRect(),i=n.getBoundingClientRect();(i.top<r.top||i.bottom>r.bottom)&&(this.scroller.scrollTop+=i.top-r.top-this.scroller.clientHeight/2),(i.left<r.left||i.right>r.right)&&(this.scroller.scrollLeft+=i.left-r.left-this.scroller.clientWidth/2)}_syncSearchStatus(){this.searchStatus&&(this.searchStatus.textContent=ga(this.search),this.prevHitButton.disabled=!this.search.hits.length,this.nextHitButton.disabled=!this.search.hits.length)}_keyDown(e){if(e.defaultPrevented||e.altKey)return;if(e.ctrlKey||e.metaKey){if(e.key===`f`||e.key===`F`)this._openSearch();else if(e.key===`+`||e.key===`=`)this._stepZoom(1);else if(e.key===`-`||e.key===`_`)this._stepZoom(-1);else if(e.key===`0`)this._setZoom(`fit-width`);else return;e.preventDefault();return}if(e.shiftKey||qa(e.target))return;let t=this.cols();if(e.key===`PageDown`)this.goToPage(this.current()+t);else if(e.key===`PageUp`)this.goToPage(this.current()-t);else if(e.key===`Home`)this.goToPage(1);else if(e.key===`End`)this.goToPage(this.pdf.numPages);else return;e.preventDefault()}_panStart(e){let t=this.scroller;e.button!==0||t.scrollWidth<=t.clientWidth&&t.scrollHeight<=t.clientHeight||e.target instanceof Element&&e.target.closest(`a`)||(this._pan={id:e.pointerId,x:e.clientX,y:e.clientY,left:t.scrollLeft,top:t.scrollTop,active:!1})}_panMove(e){let t=this._pan;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.active){if(Math.abs(n)<Va&&Math.abs(r)<Va)return;t.active=!0,this.scroller.setPointerCapture(t.id),this.scroller.classList.add(`wui-file-viewer-panning`)}this.scroller.scrollLeft=t.left-n,this.scroller.scrollTop=t.top-r}_panEnd(){let e=this._pan;e?.active&&(this.scroller.hasPointerCapture(e.id)&&this.scroller.releasePointerCapture(e.id),this.scroller.classList.remove(`wui-file-viewer-panning`)),this._pan=null}async print(){this._releasePrint();let e={ready:!1,urls:[]};this.printRun=e,this._syncToolbar();try{let t=[];for(let n=1;n<=this.pdf.numPages;n++){let r=await this.pdf.getPage(n),i=r.getViewport({scale:Ha/72}),a=document.createElement(`canvas`);a.width=Math.floor(i.width),a.height=Math.floor(i.height),await r.render({canvas:a,viewport:i,intent:`print`}).promise;let o=await new Promise((e,t)=>a.toBlob(n=>n?e(n):t(Error(`Page image failed`)),`image/png`));a.width=0,a.height=0;let s=URL.createObjectURL(o);if(e.urls.push(s),t.push({url:s,width:i.width/Ha*25.4,height:i.height/Ha*25.4}),this.printRun!==e)throw new DOMException(`Print replaced`,`AbortError`)}let n=document.createElement(`iframe`);n.className=`wui-file-viewer-print-frame`,n.title=`Document for printing`,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),e.frame=n,n.srcdoc=Da(this.shell.name()),n.addEventListener(`load`,async()=>{if(this.printRun===e)try{let{css:r,pages:i}=Oa(t),a=n.contentWindow,o=n.contentDocument;if(!a||!o)throw TypeError(`The print frame has no document.`);let s=`CSSStyleSheet`in a?a.CSSStyleSheet:void 0;if(!Za(s))throw TypeError(`The print frame has no CSSStyleSheet.`);let c=new s;c.replaceSync(r),o.adoptedStyleSheets=[c];let l=i.map(e=>{let t=o.createElement(`img`);return t.src=e.url,t.alt=``,t.style.setProperty(`width`,`${e.width}mm`),t.style.setProperty(`height`,`${e.height}mm`),t.style.setProperty(`page`,e.page),t});if(o.body.append(...l),await Promise.all(l.map($a)),this.printRun!==e)return;e.ready=!0,this._syncToolbar(),a.addEventListener(`afterprint`,()=>{this.printRun===e&&this._releasePrint()},{once:!0}),a.focus(),a.print()}catch(e){this._printFallback(e)}},{once:!0}),document.body.append(n)}catch(t){if(this.printRun!==e){for(let t of e.urls)URL.revokeObjectURL(t);return}this._printFallback(t)}}_printFallback(e){this._releasePrint(),this._warn(`print failed`,e),window.open(this.source.src,`_blank`,`noopener`)}_releasePrint(){let e=this.printRun;if(this.printRun=null,e){e.frame?.remove();for(let t of e.urls)URL.revokeObjectURL(t)}this.printButton&&this._syncToolbar()}_warn(e,t){u(`[wui-file-viewer] ${e}:`,t instanceof Error?t.message:t)}},Xa=e=>typeof e==`object`&&!!e,Za=e=>typeof e==`function`,Qa=e=>e instanceof Error?e.name:void 0,$a=e=>e.complete?null:new Promise(t=>{e.addEventListener(`load`,t,{once:!0}),e.addEventListener(`error`,t,{once:!0})}),eo=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),to=()=>window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})),ro=r({ImageView:()=>so}),io,ao,oo,so,co,lo,uo=n((()=>{f(),j(),ee(),io=[.1,.25,.5,.75,1,1.5,2,3,4],ao=[.25,.5,1,2,4],oo=5,so=class{constructor(e,t){this.shell=e,this.source=t,this.zoom=`fit`,this.rotation=0,this.area={width:0,height:0},this.destroyed=!1}load(){let e=document.createElement(`img`);e.className=`wui-file-viewer-image`,e.alt=this.shell.name(),e.decoding=`async`,e.draggable=!1,e.addEventListener(`load`,()=>{this.destroyed||(this.natural={width:e.naturalWidth||300,height:e.naturalHeight||150},this._build(e),this.shell.loaded({kind:`image`,pages:1}))}),e.addEventListener(`error`,()=>{this.destroyed||this.shell.fail(Error(`The image could not be decoded.`))}),e.src=this.source.src,this.img=e}destroy(){this.destroyed=!0,this._resizeObserver?.disconnect(),this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this._printFrame?.remove(),this.img?.removeAttribute(`src`)}_build(e){let{center:t,end:n,body:r,host:i}=this.shell;this.zoomOutButton=O(`zoom-out`,`Zoom out`),this.zoomOutButton.addEventListener(`click`,()=>this._stepZoom(-1)),this.zoomButton=document.createElement(`button`),this.zoomButton.type=`button`,this.zoomButton.className=`wui-file-viewer-zoom`,te(this.zoomButton,{label:`Zoom`,items:()=>[...ao.map(e=>({key:String(e),label:`${Math.round(e*100)}%`,checked:this.zoom===e})),{key:`fit-divider`,divider:!0},{key:`fit`,label:`Fit`,checked:this.zoom===`fit`}],onPick:e=>this._setZoom(e===`fit`?`fit`:Number(e))}),this.zoomInButton=O(`zoom-in`,`Zoom in`),this.zoomInButton.addEventListener(`click`,()=>this._stepZoom(1));let a=O(`rotate-ccw`,`Rotate left`);a.addEventListener(`click`,()=>this._rotate(-90));let o=O(`rotate-cw`,`Rotate right`);o.addEventListener(`click`,()=>this._rotate(90));let s=document.createElement(`span`);s.className=`wui-file-viewer-divider wui-file-viewer-print`;let c=O(`printer`,`Print`,{className:`wui-file-viewer-print`});c.addEventListener(`click`,()=>this.print()),s.hidden=c.hidden=!this.shell.print(),t.append(this.zoomOutButton,this.zoomButton,this.zoomInButton),n.prepend(a,o,s,c),this.scroller=document.createElement(`div`),this.scroller.className=`wui-file-viewer-scroll wui-file-viewer-image-scroll wui-scroll`,this.scroller.tabIndex=0,this.scroller.setAttribute(`role`,`region`),this.scroller.setAttribute(`aria-label`,`Image`),this.stage=document.createElement(`div`),this.stage.className=`wui-file-viewer-image-stage`,this.stage.append(e),this.scroller.append(this.stage),r.replaceChildren(this.scroller),this.scroller.addEventListener(`pointerdown`,e=>this._panStart(e)),this.scroller.addEventListener(`pointermove`,e=>this._panMove(e));for(let e of[`pointerup`,`pointercancel`,`lostpointercapture`])this.scroller.addEventListener(e,()=>this._panEnd());this.scroller.addEventListener(`wheel`,e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=performance.now();t-(this._lastWheelZoom??0)<120||(this._lastWheelZoom=t,this._stepZoom(e.deltaY<0?1:-1))},{passive:!1}),this._onKeyDown=e=>this._keyDown(e),i.addEventListener(`keydown`,this._onKeyDown),this._resizeObserver=new ResizeObserver(()=>{let e=this.scroller.clientWidth,t=this.scroller.clientHeight;(e!==this.area.width||t!==this.area.height)&&(this.area={width:e,height:t},this._layout())}),this._resizeObserver.observe(this.scroller),this.area={width:this.scroller.clientWidth,height:this.scroller.clientHeight},this._layout()}_turned(){let{width:e,height:t}=this.natural;return this.rotation%180==0?{width:e,height:t}:{width:t,height:e}}scale(){if(typeof this.zoom==`number`)return this.zoom;let{width:e,height:t}=this._turned(),n=Math.min((this.area.width-32)/e,(this.area.height-32)/t);return Math.max(n,.01)}_layout(){if(!this.stage)return;let e=this.scale(),t=this._turned();this.stage.style.width=`${Math.round(t.width*e)}px`,this.stage.style.height=`${Math.round(t.height*e)}px`,this.img.style.width=`${Math.round(this.natural.width*e)}px`,this.img.style.height=`${Math.round(this.natural.height*e)}px`,this.img.style.transform=`translate(-50%, -50%) rotate(${this.rotation}deg)`;let n=Math.round(e*100);this.zoomButton.innerHTML=`${n}%${E(`chevron-down`,{size:12})}`,this.zoomButton.setAttribute(`aria-label`,`Zoom, ${n}%`),this.zoomOutButton.disabled=this._zoomStep(-1)==null,this.zoomInButton.disabled=this._zoomStep(1)==null}_zoomStep(e){let t=Math.round(this.scale()*100);return e>0?io.find(e=>Math.round(e*100)>t)??null:[...io].reverse().find(e=>Math.round(e*100)<t)??null}_stepZoom(e){let t=this._zoomStep(e);t!=null&&this._setZoom(t)}_setZoom(e){let t=this.scroller,n=(t.scrollLeft+t.clientWidth/2)/Math.max(t.scrollWidth,1),r=(t.scrollTop+t.clientHeight/2)/Math.max(t.scrollHeight,1);this.zoom=e,this._layout(),t.scrollLeft=n*t.scrollWidth-t.clientWidth/2,t.scrollTop=r*t.scrollHeight-t.clientHeight/2}_rotate(e){this.rotation=(this.rotation+e+360)%360,this._setZoom(this.zoom)}_keyDown(e){if(!(e.defaultPrevented||e.altKey||!(e.ctrlKey||e.metaKey))){if(e.key===`+`||e.key===`=`)this._stepZoom(1);else if(e.key===`-`||e.key===`_`)this._stepZoom(-1);else if(e.key===`0`)this._setZoom(`fit`);else return;e.preventDefault()}}_panStart(e){let t=this.scroller;e.button!==0||t.scrollWidth<=t.clientWidth&&t.scrollHeight<=t.clientHeight||(this._pan={id:e.pointerId,x:e.clientX,y:e.clientY,left:t.scrollLeft,top:t.scrollTop,active:!1})}_panMove(e){let t=this._pan;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.active){if(Math.abs(n)<oo&&Math.abs(r)<oo)return;t.active=!0,this.scroller.setPointerCapture(t.id),this.scroller.classList.add(`wui-file-viewer-panning`)}this.scroller.scrollLeft=t.left-n,this.scroller.scrollTop=t.top-r}_panEnd(){let e=this._pan;e?.active&&(this.scroller.hasPointerCapture(e.id)&&this.scroller.releasePointerCapture(e.id),this.scroller.classList.remove(`wui-file-viewer-panning`)),this._pan=null}print(){this._printFrame?.remove();let e=document.createElement(`iframe`);e.className=`wui-file-viewer-print-frame`,e.title=`Image for printing`,e.tabIndex=-1,e.setAttribute(`aria-hidden`,`true`);let t=this.rotation%180!=0,n=new URL(this.source.src,document.baseURI).href;e.srcdoc=`<!doctype html><html><head><title>${lo(this.shell.name())}</title></head><body></body></html>`,e.addEventListener(`load`,async()=>{try{let r=e.contentWindow,i=e.contentDocument;if(!r||!i)throw TypeError(`The print frame has no document.`);let a=`CSSStyleSheet`in r?r.CSSStyleSheet:void 0;if(!co(a))throw TypeError(`The print frame has no CSSStyleSheet.`);let o=new a;o.replaceSync(`@page { margin: 10mm; }
18
18
  html, body { margin: 0; height: 100%; }
19
19
  body { display: flex; align-items: center; justify-content: center; }`),i.adoptedStyleSheets=[o];let s=i.createElement(`img`);s.src=n,s.alt=``,s.style.setProperty(`max-width`,t?`100vh`:`100vw`),s.style.setProperty(`max-height`,t?`100vw`:`100vh`),s.style.setProperty(`transform`,`rotate(${this.rotation}deg)`),i.body.append(s),s.complete||await new Promise(e=>{s.addEventListener(`load`,e,{once:!0}),s.addEventListener(`error`,e,{once:!0})}),r.focus(),r.print()}catch(e){u(`[wui-file-viewer] print failed:`,e instanceof Error?e.message:void 0),window.open(this.source.src,`_blank`,`noopener`)}},{once:!0}),this._printFrame=e,document.body.append(e)}},co=e=>typeof e==`function`,lo=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)})),fo=r({MediaView:()=>yo,formatTime:()=>po});function po(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n?`${n}:${String(r).padStart(2,`0`)}:${i}`:`${r}:${i}`}var mo,ho,go,_o,vo,yo,bo=n((()=>{f(),j(),ee(),mo=[.5,.75,1,1.25,1.5,2],ho=5,go=.1,_o=e=>typeof e==`number`&&mo.includes(e),vo=e=>e instanceof Element&&e.closest(`input, textarea, select, button, a, .dropdown-menu`),yo=class{constructor(e,t){this.shell=e,this.source=t,this.destroyed=!1}load(){let{kind:e,src:t,captions:n}=this.source,r=e===`video`?document.createElement(`video`):document.createElement(`audio`);if(r.className=`wui-file-viewer-${e}`,r.preload=`metadata`,Object.assign(r,{playsInline:!0}),e===`video`&&n){let e=document.createElement(`track`);e.kind=`captions`,e.label=`Captions`,e.srclang=`en`,e.src=n,r.append(e)}let i=this.shell.prefs;typeof i.volume==`number`&&(r.volume=Math.min(Math.max(i.volume,0),1)),r.muted=i.muted===!0,r.addEventListener(`loadedmetadata`,()=>{this.destroyed||(r.playbackRate=_o(i.speed)?i.speed:1,this._build(),this.shell.loaded({kind:e,pages:1}))},{once:!0}),r.addEventListener(`error`,()=>{this.destroyed||this.shell.fail(Error(`The file could not be played.`))}),r.src=t,this.media=r}destroy(){this.destroyed=!0,this._onKeyDown&&this.shell.host.removeEventListener(`keydown`,this._onKeyDown),this.media&&(this.media.pause(),this.media.removeAttribute(`src`),this.media.load())}_build(){let{body:e,host:t}=this.shell,n=this.media,r=this.source.kind,i=document.createElement(`div`);i.className=`wui-file-viewer-player wui-file-viewer-player-${r}`;let a=document.createElement(`div`);if(a.className=`wui-file-viewer-stage`,a.tabIndex=0,a.setAttribute(`role`,`group`),a.setAttribute(`aria-label`,r===`video`?`Video`:`Audio`),r===`audio`){let e=document.createElement(`div`);e.className=`wui-file-viewer-audio-art`,e.innerHTML=E(`music`,{size:40}),a.append(e,n)}else a.append(n),n.addEventListener(`click`,()=>this.togglePlay());let o=document.createElement(`div`);o.className=`wui-file-viewer-controls`,this.playButton=O(`play`,`Play`,{size:18}),this.playButton.addEventListener(`click`,()=>this.togglePlay()),this.timeNow=document.createElement(`span`),this.timeNow.className=`wui-file-viewer-time`,this.seek=document.createElement(`input`),this.seek.type=`range`,this.seek.className=`form-range wui-file-viewer-seek`,this.seek.min=`0`,this.seek.step=`any`,this.seek.setAttribute(`aria-label`,`Seek`),this.seek.addEventListener(`input`,()=>{n.currentTime=Number(this.seek.value)}),this.timeTotal=document.createElement(`span`),this.timeTotal.className=`wui-file-viewer-time`,this.muteButton=O(`volume-high`,`Mute`,{size:18}),this.muteButton.addEventListener(`click`,()=>this._setMuted(!n.muted)),this.volume=document.createElement(`input`),this.volume.type=`range`,this.volume.className=`form-range wui-file-viewer-volume`,this.volume.min=`0`,this.volume.max=`1`,this.volume.step=`0.05`,this.volume.setAttribute(`aria-label`,`Volume`),this.volume.addEventListener(`input`,()=>this._setVolume(Number(this.volume.value))),this.speedButton=document.createElement(`button`),this.speedButton.type=`button`,this.speedButton.className=`wui-file-viewer-zoom wui-file-viewer-speed`,te(this.speedButton,{label:`Playback speed`,items:()=>mo.map(e=>({key:String(e),label:`${e}x`,checked:n.playbackRate===e})),onPick:e=>this._setSpeed(Number(e))}),o.append(this.playButton,this.timeNow,this.seek,this.timeTotal,this.muteButton,this.volume,this.speedButton),r===`video`&&this.source.captions&&(this.captionsButton=O(`subtitle`,`Show captions`,{size:18}),this.captionsButton.addEventListener(`click`,()=>this._setCaptions(!this._captionsOn())),o.append(this.captionsButton)),i.append(a,o),e.replaceChildren(i);for(let e of[`play`,`pause`,`ended`])n.addEventListener(e,()=>this._syncPlay());n.addEventListener(`timeupdate`,()=>this._syncTime()),n.addEventListener(`durationchange`,()=>this._syncTime()),n.addEventListener(`volumechange`,()=>this._syncVolume()),n.addEventListener(`ratechange`,()=>this._syncSpeed()),this._onKeyDown=e=>this._keyDown(e),t.addEventListener(`keydown`,this._onKeyDown),this._syncPlay(),this._syncTime(),this._syncVolume(),this._syncSpeed(),this._syncCaptions()}seekTo(e){let t=this.media.duration;this.media.currentTime=Math.min(Math.max(e,0),Number.isFinite(t)?t:1/0)}togglePlay(){this.media.paused||this.media.ended?this.media.play().catch(e=>{u(`[wui-file-viewer] play refused:`,e instanceof Error?e.message:void 0)}):this.media.pause()}_setMuted(e){this.media.muted=e,!e&&this.media.volume===0&&(this.media.volume=.5),this.shell.savePrefs({muted:this.media.muted,volume:this.media.volume})}_setVolume(e){this.media.volume=Math.min(Math.max(e,0),1),this.media.muted=this.media.volume===0,this.shell.savePrefs({muted:this.media.muted,volume:this.media.volume})}_setSpeed(e){this.media.playbackRate=e,this.shell.savePrefs({speed:e})}_captionsOn(){return this.media.textTracks?.[0]?.mode===`showing`}_setCaptions(e){let t=this.media.textTracks?.[0];t&&(t.mode=e?`showing`:`hidden`),this._syncCaptions()}_syncPlay(){let e=!this.media.paused&&!this.media.ended;k(this.playButton,e?`pause`:`play`,18),A(this.playButton,e?`Pause`:`Play`),this.shell.host.classList.toggle(`wui-file-viewer-playing`,e)}_syncTime(){let e=this.media.currentTime,t=this.media.duration;this.timeNow.textContent=po(e),this.timeTotal.textContent=po(t),this.seek.max=String(Number.isFinite(t)?t:0),this.seek.value=String(e),this.seek.setAttribute(`aria-valuetext`,`${po(e)} of ${po(t)}`)}_syncVolume(){let e=this.media.muted||this.media.volume===0;k(this.muteButton,e?`volume-mute`:`volume-high`,18),A(this.muteButton,e?`Unmute`:`Mute`),this.volume.value=String(this.media.muted?0:this.media.volume)}_syncSpeed(){let e=`${this.media.playbackRate}x`;this.speedButton.textContent=e,this.speedButton.setAttribute(`aria-label`,`Playback speed, ${e}`)}_syncCaptions(){if(!this.captionsButton)return;let e=this._captionsOn();this.captionsButton.setAttribute(`aria-pressed`,String(e)),A(this.captionsButton,e?`Hide captions`:`Show captions`)}_keyDown(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||vo(e.target))return;let t=this.media,n=e.key.toLowerCase();if(n===` `||n===`k`)this.togglePlay();else if(n===`arrowleft`)t.currentTime=Math.max(0,t.currentTime-ho);else if(n===`arrowright`)t.currentTime=Math.min(t.duration||0,t.currentTime+ho);else if(n===`arrowup`)this._setVolume(t.volume+go);else if(n===`arrowdown`)this._setVolume(t.volume-go);else if(n===`m`)this._setMuted(!t.muted);else if(n===`c`&&this.captionsButton)this._setCaptions(!this._captionsOn());else return;e.preventDefault()}}}));f(),j();var xo={pdf:`pdf`,jpg:`image`,jpeg:`image`,png:`image`,webp:`image`,gif:`image`,avif:`image`,bmp:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,ogv:`video`,mp3:`audio`,m4a:`audio`,aac:`audio`,wav:`audio`,ogg:`audio`,oga:`audio`,opus:`audio`,flac:`audio`},So={"application/pdf":`pdf`,"image/jpeg":`image`,"image/png":`image`,"image/webp":`image`,"image/gif":`image`,"image/avif":`image`,"image/bmp":`image`,"image/svg+xml":`image`,"video/mp4":`video`,"video/webm":`video`,"video/ogg":`video`,"audio/mpeg":`audio`,"audio/mp4":`audio`,"audio/aac":`audio`,"audio/wav":`audio`,"audio/x-wav":`audio`,"audio/ogg":`audio`,"audio/opus":`audio`,"audio/webm":`audio`,"audio/flac":`audio`},Co=`wui-file-viewer:load`,wo=`wui-file-viewer:error`,To=`wui-file-viewer:prefs-change`;function Eo(e,t){let n=(String(e??``).split(`;`)[0]??``).trim().toLowerCase();if(n)return So[n]??null;let r=String(t??``).split(/[?#]/)[0]??``;return xo[r.includes(`.`)?(r.split(`.`).pop()??``).toLowerCase():``]??null}function Do(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var Oo={pdf:()=>Promise.resolve().then(()=>(no(),Ca)).then(e=>e.PdfView),image:()=>Promise.resolve().then(()=>(uo(),ro)).then(e=>e.ImageView),video:()=>Promise.resolve().then(()=>(bo(),fo)).then(e=>e.MediaView),audio:()=>Promise.resolve().then(()=>(bo(),fo)).then(e=>e.MediaView)},ko=0,Ao=class e extends m{static defaultAssetBase=``;static get observedAttributes(){return[`src`,`name`,`type`,`download`,`print`,`worker-src`,`asset-base`,`captions`]}uid;_prefs;_hostPrefs;_onFullscreen;_view;_loadId;_actionsBox;constructor(){super(),ko+=1,this.uid=`wui-file-viewer-${ko}`,this._prefs={},this._onFullscreen=()=>this._syncFullscreen()}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,String(e??``))}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,String(e??``))}get type(){return this.getAttribute(`type`)??``}set type(e){this.setAttribute(`type`,String(e??``))}get viewKey(){return this.getAttribute(`view-key`)??``}set viewKey(e){this.setAttribute(`view-key`,String(e??``))}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get print(){return this.getAttribute(`print`)!==`false`}set print(e){this.setAttribute(`print`,e===!1||e===`false`?`false`:`true`)}get workerSrc(){return this.getAttribute(`worker-src`)??``}set workerSrc(e){this.setAttribute(`worker-src`,String(e??``))}get captions(){return this.getAttribute(`captions`)??``}set captions(e){this.setAttribute(`captions`,String(e??``))}get assetBase(){return this.getAttribute(`asset-base`)??``}set assetBase(e){this.setAttribute(`asset-base`,String(e??``))}get prefs(){return{...this._prefs}}set prefs(e){this._hostPrefs=!0,this._prefs=e&&typeof e==`object`?{...e}:{}}get actionsContainer(){return this._actionsBox??null}seekTo(e){if(typeof e!=`number`||!Number.isFinite(e))throw TypeError(`[wui-file-viewer] seekTo takes a number of seconds; got ${String(e)}.`);return this._view?.seekTo?(this._view.seekTo(e),!0):!1}displayName(){return this.name||Do(this.src)||`Document`}connectedCallback(){if(Object.hasOwn(this,`prefs`)){let e=this.prefs;Reflect.deleteProperty(this,`prefs`),this.prefs=e}document.addEventListener(`fullscreenchange`,this._onFullscreen),this._open()}disconnectedCallback(){document.removeEventListener(`fullscreenchange`,this._onFullscreen),this._close()}attributeChangedCallback(e,t,n){this.isConnected&&this._parts&&t!==n&&(e===`name`?this._parts.name.textContent=this.displayName():e===`download`?this._syncDownload():e===`print`?this._syncPrint():this._open())}_close(){this._view?.destroy(),this._view=null,this._loadId=(this._loadId??0)+1}async _open(){this._close();let t=this._loadId;this._render(),this._prefs=this._readPrefs();let n=Eo(this.type,this.name||this.src);if(!this.src){this._settle(`No file to show.`);return}if(!n){this._settle(`This file can't be shown here.`,{offerDownload:!0});return}this._status(`Loading...`);let r;try{r=await Oo[n]()}catch(e){t===this._loadId&&this._fail(e);return}t===this._loadId&&(this._view=new r(this._shell(t),{src:this.src,kind:n,captions:this.captions,workerSrc:this.workerSrc,assetBase:Mo(this.assetBase||e.defaultAssetBase)}),this._view.load())}_shell(e){let t=()=>e===this._loadId,n=this._parts;return{host:this,start:n.start,center:n.center,end:n.viewEnd,search:n.search,body:n.body,prefs:{...this._prefs},name:()=>this.displayName(),print:()=>this.print,savePrefs:e=>{t()&&this._savePrefs(e)},loaded:e=>{t()&&(n.body.removeAttribute(`aria-busy`),this.dispatchEvent(new CustomEvent(Co,{bubbles:!0,detail:e})))},fail:e=>{t()&&this._fail(e)}}}_render(){let e=(e,t)=>{let n=document.createElement(e);return n.className=t,n},t=e(`div`,`wui-file-viewer-toolbar`),n=e(`div`,`wui-file-viewer-group wui-file-viewer-start`),r=e(`span`,`wui-file-viewer-name`);r.textContent=this.displayName(),r.title=this.displayName(),n.append(r);let i=e(`div`,`wui-file-viewer-group wui-file-viewer-center`),a=e(`div`,`wui-file-viewer-group wui-file-viewer-end`),o=e(`div`,`wui-file-viewer-group wui-file-viewer-view-end`),s=document.createElement(`a`);s.className=`u-action wui-file-viewer-download`,s.style.setProperty(`--wui-action-size`,`32px`),k(s,`download`),A(s,`Download`);let c=O(`maximize-4`,`Full screen`,{className:`wui-file-viewer-fullscreen`});c.addEventListener(`click`,()=>this.toggleFullscreen()),c.hidden=!document.fullscreenEnabled,this._actionsBox??=e(`div`,`wui-file-viewer-actions`);let l=this._actionsBox;l.append(...this.querySelectorAll(`:scope > [slot="actions"]`)),a.append(o,s,c,l);let u=e(`search`,`wui-file-viewer-search`);u.hidden=!0,t.append(n,i,a,u);let d=e(`div`,`wui-file-viewer-body`);d.setAttribute(`aria-busy`,`true`),this.replaceChildren(t,d),this._parts={toolbar:t,start:n,name:r,center:i,end:a,viewEnd:o,downloadLink:s,fullscreen:c,actionsBox:l,search:u,body:d},this._syncDownload(),this._syncFullscreen()}_syncDownload(){let e=this._parts.downloadLink;e.hidden=!this.download||!this.src,e.href=this.src,e.setAttribute(`download`,this.displayName())}_syncPrint(){for(let e of this._parts.toolbar.querySelectorAll(`.wui-file-viewer-print`))e instanceof HTMLElement&&(e.hidden=!this.print)}_status(e,{offerDownload:t=!1}={}){let n=document.createElement(`div`);n.className=`wui-file-viewer-status`;let r=document.createElement(`p`);if(r.textContent=e,n.append(r),t&&this.src){let e=document.createElement(`a`);e.className=l(`neutral`,`outline`,`sm`),e.dataset.wui=a,e.href=this.src,e.setAttribute(`download`,this.displayName()),e.textContent=`Download`,n.append(e)}this._parts.body.replaceChildren(n)}_settle(e,t){this._parts.body.removeAttribute(`aria-busy`),this._status(e,t)}_fail(e){this._view?.destroy(),this._view=null,this._settle(`Couldn't open this file.`,{offerDownload:!0});let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;this.dispatchEvent(new CustomEvent(wo,{bubbles:!0,detail:{message:t??String(e)}}))}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.requestFullscreen().catch(e=>{u(`[wui-file-viewer] full screen refused:`,e?.message)})}_syncFullscreen(){if(!this._parts)return;let e=document.fullscreenElement===this,t=this._parts.fullscreen;k(t,e?`x`:`maximize-4`),A(t,e?`Exit full screen`:`Full screen`),this._parts.actionsBox.hidden=e}_readPrefs(){if(this._hostPrefs||!this.viewKey)return{...this._prefs};try{let e=JSON.parse(window.localStorage.getItem(`wui-view:${this.viewKey}`)??`{}`);return jo(e)?e:{}}catch{return{}}}_savePrefs(e){if(this._prefs={...this._prefs,...e},this.dispatchEvent(new CustomEvent(To,{bubbles:!0,detail:{...this._prefs}})),!this._hostPrefs&&this.viewKey)try{window.localStorage.setItem(`wui-view:${this.viewKey}`,JSON.stringify(this._prefs))}catch{}}};function jo(e){return typeof e==`object`&&!!e}function Mo(e){return e&&new URL(e,document.baseURI).href}var No=typeof document>`u`?null:document.currentScript;return No instanceof HTMLScriptElement&&No.src&&(Ao.defaultAssetBase=new URL(`pdfjs/`,No.src).href),i(`wui-file-viewer`,Ao),e.WuiFileViewer=Ao,e.fileKind=Eo,e.fileNameFromUrl=Do,e.renderPdfFirstPage=(e,t)=>Promise.resolve().then(()=>(no(),Ca)).then(n=>n.renderFirstPage(e,{assetBase:Ao.defaultAssetBase||void 0,...t})),e})({});
@@ -1 +1 @@
1
- import{i as e,r as t,s as n,t as r}from"./fileViewerUi-ResPjO1o.js";function i(e,t){if(typeof customElements>`u`||customElements.get(e))return;let n=[];if(typeof document<`u`)for(let r of document.querySelectorAll(e))for(let i of Object.keys(r)){let a=Object.getOwnPropertyDescriptor(t.prototype,i);if(a&&(a.set||a.get)&&(n.push([r,i,Reflect.get(r,i)]),!Reflect.deleteProperty(r,i)))throw Error(`defineElement: could not clear the early "${i}" property on <${e}>.`)}customElements.define(e,t);for(let[t,r,i]of n)if(!Reflect.set(t,r,i))throw Error(`defineElement: could not restore the "${r}" property on <${e}>.`)}var a=`AppButton`,o=/* @__PURE__ */ new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),s={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function c(e){return Object.hasOwn(s,e)}function l(e=`primary`,t=`solid`,n=`md`){if(!o.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!c(t))throw RangeError(`buttonClass: unknown variant "${t}"`);let r=s[t](e);return n===`md`?`btn ${r}`:`btn ${r} btn-${n}`}var u=`@webority/ui-elements needs a browser DOM; import its types or helpers entry on the server`;if(typeof HTMLElement>`u`)throw Error(u);var d=HTMLElement,f={pdf:`pdf`,jpg:`image`,jpeg:`image`,png:`image`,webp:`image`,gif:`image`,avif:`image`,bmp:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,ogv:`video`,mp3:`audio`,m4a:`audio`,aac:`audio`,wav:`audio`,ogg:`audio`,oga:`audio`,opus:`audio`,flac:`audio`},p={"application/pdf":`pdf`,"image/jpeg":`image`,"image/png":`image`,"image/webp":`image`,"image/gif":`image`,"image/avif":`image`,"image/bmp":`image`,"image/svg+xml":`image`,"video/mp4":`video`,"video/webm":`video`,"video/ogg":`video`,"audio/mpeg":`audio`,"audio/mp4":`audio`,"audio/aac":`audio`,"audio/wav":`audio`,"audio/x-wav":`audio`,"audio/ogg":`audio`,"audio/opus":`audio`,"audio/webm":`audio`,"audio/flac":`audio`},m=`wui-file-viewer:load`,h=`wui-file-viewer:error`,g=`wui-file-viewer:prefs-change`;function _(e,t){let n=(String(e??``).split(`;`)[0]??``).trim().toLowerCase();if(n)return p[n]??null;let r=String(t??``).split(/[?#]/)[0]??``;return f[r.includes(`.`)?(r.split(`.`).pop()??``).toLowerCase():``]??null}function v(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var y={pdf:()=>import(`./fileViewerPdf-BLMhF8NT.js`).then(e=>e.PdfView),image:()=>import(`./fileViewerImage-tzF4DDq7.js`).then(e=>e.ImageView),video:()=>import(`./fileViewerMedia-Bp1uHJvC.js`).then(e=>e.MediaView),audio:()=>import(`./fileViewerMedia-Bp1uHJvC.js`).then(e=>e.MediaView)},b=0,x=class i extends d{static defaultAssetBase=``;static get observedAttributes(){return[`src`,`name`,`type`,`download`,`print`,`worker-src`,`asset-base`,`captions`]}uid;_prefs;_hostPrefs;_onFullscreen;_view;_loadId;_actionsBox;constructor(){super(),b+=1,this.uid=`wui-file-viewer-${b}`,this._prefs={},this._onFullscreen=()=>this._syncFullscreen()}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,String(e??``))}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,String(e??``))}get type(){return this.getAttribute(`type`)??``}set type(e){this.setAttribute(`type`,String(e??``))}get viewKey(){return this.getAttribute(`view-key`)??``}set viewKey(e){this.setAttribute(`view-key`,String(e??``))}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get print(){return this.getAttribute(`print`)!==`false`}set print(e){this.setAttribute(`print`,e===!1||e===`false`?`false`:`true`)}get workerSrc(){return this.getAttribute(`worker-src`)??``}set workerSrc(e){this.setAttribute(`worker-src`,String(e??``))}get captions(){return this.getAttribute(`captions`)??``}set captions(e){this.setAttribute(`captions`,String(e??``))}get assetBase(){return this.getAttribute(`asset-base`)??``}set assetBase(e){this.setAttribute(`asset-base`,String(e??``))}get prefs(){return{...this._prefs}}set prefs(e){this._hostPrefs=!0,this._prefs=e&&typeof e==`object`?{...e}:{}}get actionsContainer(){return this._actionsBox??null}seekTo(e){if(typeof e!=`number`||!Number.isFinite(e))throw TypeError(`[wui-file-viewer] seekTo takes a number of seconds; got ${String(e)}.`);return this._view?.seekTo?(this._view.seekTo(e),!0):!1}displayName(){return this.name||v(this.src)||`Document`}connectedCallback(){if(Object.hasOwn(this,`prefs`)){let e=this.prefs;Reflect.deleteProperty(this,`prefs`),this.prefs=e}document.addEventListener(`fullscreenchange`,this._onFullscreen),this._open()}disconnectedCallback(){document.removeEventListener(`fullscreenchange`,this._onFullscreen),this._close()}attributeChangedCallback(e,t,n){this.isConnected&&this._parts&&t!==n&&(e===`name`?this._parts.name.textContent=this.displayName():e===`download`?this._syncDownload():e===`print`?this._syncPrint():this._open())}_close(){this._view?.destroy(),this._view=null,this._loadId=(this._loadId??0)+1}async _open(){this._close();let e=this._loadId;this._render(),this._prefs=this._readPrefs();let t=_(this.type,this.name||this.src);if(!this.src){this._settle(`No file to show.`);return}if(!t){this._settle(`This file can't be shown here.`,{offerDownload:!0});return}this._status(`Loading...`);let n;try{n=await y[t]()}catch(t){e===this._loadId&&this._fail(t);return}e===this._loadId&&(this._view=new n(this._shell(e),{src:this.src,kind:t,captions:this.captions,workerSrc:this.workerSrc,assetBase:C(this.assetBase||i.defaultAssetBase)}),this._view.load())}_shell(e){let t=()=>e===this._loadId,n=this._parts;return{host:this,start:n.start,center:n.center,end:n.viewEnd,search:n.search,body:n.body,prefs:{...this._prefs},name:()=>this.displayName(),print:()=>this.print,savePrefs:e=>{t()&&this._savePrefs(e)},loaded:e=>{t()&&(n.body.removeAttribute(`aria-busy`),this.dispatchEvent(new CustomEvent(m,{bubbles:!0,detail:e})))},fail:e=>{t()&&this._fail(e)}}}_render(){let n=(e,t)=>{let n=document.createElement(e);return n.className=t,n},i=n(`div`,`wui-file-viewer-toolbar`),a=n(`div`,`wui-file-viewer-group wui-file-viewer-start`),o=n(`span`,`wui-file-viewer-name`);o.textContent=this.displayName(),o.title=this.displayName(),a.append(o);let s=n(`div`,`wui-file-viewer-group wui-file-viewer-center`),c=n(`div`,`wui-file-viewer-group wui-file-viewer-end`),l=n(`div`,`wui-file-viewer-group wui-file-viewer-view-end`),u=document.createElement(`a`);u.className=`u-action wui-file-viewer-download`,u.style.setProperty(`--wui-action-size`,`32px`),t(u,`download`),e(u,`Download`);let d=r(`maximize-4`,`Full screen`,{className:`wui-file-viewer-fullscreen`});d.addEventListener(`click`,()=>this.toggleFullscreen()),d.hidden=!document.fullscreenEnabled,this._actionsBox??=n(`div`,`wui-file-viewer-actions`);let f=this._actionsBox;f.append(...this.querySelectorAll(`:scope > [slot="actions"]`)),c.append(l,u,d,f);let p=n(`search`,`wui-file-viewer-search`);p.hidden=!0,i.append(a,s,c,p);let m=n(`div`,`wui-file-viewer-body`);m.setAttribute(`aria-busy`,`true`),this.replaceChildren(i,m),this._parts={toolbar:i,start:a,name:o,center:s,end:c,viewEnd:l,downloadLink:u,fullscreen:d,actionsBox:f,search:p,body:m},this._syncDownload(),this._syncFullscreen()}_syncDownload(){let e=this._parts.downloadLink;e.hidden=!this.download||!this.src,e.href=this.src,e.setAttribute(`download`,this.displayName())}_syncPrint(){for(let e of this._parts.toolbar.querySelectorAll(`.wui-file-viewer-print`))e instanceof HTMLElement&&(e.hidden=!this.print)}_status(e,{offerDownload:t=!1}={}){let n=document.createElement(`div`);n.className=`wui-file-viewer-status`;let r=document.createElement(`p`);if(r.textContent=e,n.append(r),t&&this.src){let e=document.createElement(`a`);e.className=l(`neutral`,`outline`,`sm`),e.dataset.wui=a,e.href=this.src,e.setAttribute(`download`,this.displayName()),e.textContent=`Download`,n.append(e)}this._parts.body.replaceChildren(n)}_settle(e,t){this._parts.body.removeAttribute(`aria-busy`),this._status(e,t)}_fail(e){this._view?.destroy(),this._view=null,this._settle(`Couldn't open this file.`,{offerDownload:!0});let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;this.dispatchEvent(new CustomEvent(h,{bubbles:!0,detail:{message:t??String(e)}}))}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.requestFullscreen().catch(e=>{n(`[wui-file-viewer] full screen refused:`,e?.message)})}_syncFullscreen(){if(!this._parts)return;let n=document.fullscreenElement===this,r=this._parts.fullscreen;t(r,n?`x`:`maximize-4`),e(r,n?`Exit full screen`:`Full screen`),this._parts.actionsBox.hidden=n}_readPrefs(){if(this._hostPrefs||!this.viewKey)return{...this._prefs};try{let e=JSON.parse(window.localStorage.getItem(`wui-view:${this.viewKey}`)??`{}`);return S(e)?e:{}}catch{return{}}}_savePrefs(e){if(this._prefs={...this._prefs,...e},this.dispatchEvent(new CustomEvent(g,{bubbles:!0,detail:{...this._prefs}})),!this._hostPrefs&&this.viewKey)try{window.localStorage.setItem(`wui-view:${this.viewKey}`,JSON.stringify(this._prefs))}catch{}}};function S(e){return typeof e==`object`&&!!e}function C(e){return e&&new URL(e,document.baseURI).href}var w=typeof document>`u`?null:document.currentScript;w instanceof HTMLScriptElement&&w.src&&(x.defaultAssetBase=new URL(`pdfjs/`,w.src).href),i(`wui-file-viewer`,x);var T=(e,t)=>import(`./fileViewerPdf-BLMhF8NT.js`).then(n=>n.renderFirstPage(e,{assetBase:x.defaultAssetBase||void 0,...t}));export{x as WuiFileViewer,_ as fileKind,v as fileNameFromUrl,T as renderPdfFirstPage};
1
+ import{i as e,r as t,s as n,t as r}from"./fileViewerUi-ResPjO1o.js";function i(e,t){if(typeof customElements>`u`||customElements.get(e))return;let n=[];if(typeof document<`u`)for(let r of document.querySelectorAll(e))for(let i of Object.keys(r)){let a=Object.getOwnPropertyDescriptor(t.prototype,i);if(a&&(a.set||a.get)&&(n.push([r,i,Reflect.get(r,i)]),!Reflect.deleteProperty(r,i)))throw Error(`defineElement: could not clear the early "${i}" property on <${e}>.`)}customElements.define(e,t);for(let[t,r,i]of n)if(!Reflect.set(t,r,i))throw Error(`defineElement: could not restore the "${r}" property on <${e}>.`)}var a=`AppButton`,o=/* @__PURE__ */ new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),s={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function c(e){return Object.hasOwn(s,e)}function l(e=`primary`,t=`solid`,n=`md`){if(!o.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!c(t))throw RangeError(`buttonClass: unknown variant "${t}"`);let r=s[t](e);return n===`md`?`btn ${r}`:`btn ${r} btn-${n}`}var u=`@webority/ui-elements needs a browser DOM; import its types or helpers entry on the server`;if(typeof HTMLElement>`u`)throw Error(u);var d=HTMLElement,f={pdf:`pdf`,jpg:`image`,jpeg:`image`,png:`image`,webp:`image`,gif:`image`,avif:`image`,bmp:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,ogv:`video`,mp3:`audio`,m4a:`audio`,aac:`audio`,wav:`audio`,ogg:`audio`,oga:`audio`,opus:`audio`,flac:`audio`},p={"application/pdf":`pdf`,"image/jpeg":`image`,"image/png":`image`,"image/webp":`image`,"image/gif":`image`,"image/avif":`image`,"image/bmp":`image`,"image/svg+xml":`image`,"video/mp4":`video`,"video/webm":`video`,"video/ogg":`video`,"audio/mpeg":`audio`,"audio/mp4":`audio`,"audio/aac":`audio`,"audio/wav":`audio`,"audio/x-wav":`audio`,"audio/ogg":`audio`,"audio/opus":`audio`,"audio/webm":`audio`,"audio/flac":`audio`},m=`wui-file-viewer:load`,h=`wui-file-viewer:error`,g=`wui-file-viewer:prefs-change`;function _(e,t){let n=(String(e??``).split(`;`)[0]??``).trim().toLowerCase();if(n)return p[n]??null;let r=String(t??``).split(/[?#]/)[0]??``;return f[r.includes(`.`)?(r.split(`.`).pop()??``).toLowerCase():``]??null}function v(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var y={pdf:()=>import(`./fileViewerPdf-CdaDuaRJ.js`).then(e=>e.PdfView),image:()=>import(`./fileViewerImage-Bt1jeArm.js`).then(e=>e.ImageView),video:()=>import(`./fileViewerMedia-Bp1uHJvC.js`).then(e=>e.MediaView),audio:()=>import(`./fileViewerMedia-Bp1uHJvC.js`).then(e=>e.MediaView)},b=0,x=class i extends d{static defaultAssetBase=``;static get observedAttributes(){return[`src`,`name`,`type`,`download`,`print`,`worker-src`,`asset-base`,`captions`]}uid;_prefs;_hostPrefs;_onFullscreen;_view;_loadId;_actionsBox;constructor(){super(),b+=1,this.uid=`wui-file-viewer-${b}`,this._prefs={},this._onFullscreen=()=>this._syncFullscreen()}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,String(e??``))}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,String(e??``))}get type(){return this.getAttribute(`type`)??``}set type(e){this.setAttribute(`type`,String(e??``))}get viewKey(){return this.getAttribute(`view-key`)??``}set viewKey(e){this.setAttribute(`view-key`,String(e??``))}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get print(){return this.getAttribute(`print`)!==`false`}set print(e){this.setAttribute(`print`,e===!1||e===`false`?`false`:`true`)}get workerSrc(){return this.getAttribute(`worker-src`)??``}set workerSrc(e){this.setAttribute(`worker-src`,String(e??``))}get captions(){return this.getAttribute(`captions`)??``}set captions(e){this.setAttribute(`captions`,String(e??``))}get assetBase(){return this.getAttribute(`asset-base`)??``}set assetBase(e){this.setAttribute(`asset-base`,String(e??``))}get prefs(){return{...this._prefs}}set prefs(e){this._hostPrefs=!0,this._prefs=e&&typeof e==`object`?{...e}:{}}get actionsContainer(){return this._actionsBox??null}seekTo(e){if(typeof e!=`number`||!Number.isFinite(e))throw TypeError(`[wui-file-viewer] seekTo takes a number of seconds; got ${String(e)}.`);return this._view?.seekTo?(this._view.seekTo(e),!0):!1}displayName(){return this.name||v(this.src)||`Document`}connectedCallback(){if(Object.hasOwn(this,`prefs`)){let e=this.prefs;Reflect.deleteProperty(this,`prefs`),this.prefs=e}document.addEventListener(`fullscreenchange`,this._onFullscreen),this._open()}disconnectedCallback(){document.removeEventListener(`fullscreenchange`,this._onFullscreen),this._close()}attributeChangedCallback(e,t,n){this.isConnected&&this._parts&&t!==n&&(e===`name`?this._parts.name.textContent=this.displayName():e===`download`?this._syncDownload():e===`print`?this._syncPrint():this._open())}_close(){this._view?.destroy(),this._view=null,this._loadId=(this._loadId??0)+1}async _open(){this._close();let e=this._loadId;this._render(),this._prefs=this._readPrefs();let t=_(this.type,this.name||this.src);if(!this.src){this._settle(`No file to show.`);return}if(!t){this._settle(`This file can't be shown here.`,{offerDownload:!0});return}this._status(`Loading...`);let n;try{n=await y[t]()}catch(t){e===this._loadId&&this._fail(t);return}e===this._loadId&&(this._view=new n(this._shell(e),{src:this.src,kind:t,captions:this.captions,workerSrc:this.workerSrc,assetBase:C(this.assetBase||i.defaultAssetBase)}),this._view.load())}_shell(e){let t=()=>e===this._loadId,n=this._parts;return{host:this,start:n.start,center:n.center,end:n.viewEnd,search:n.search,body:n.body,prefs:{...this._prefs},name:()=>this.displayName(),print:()=>this.print,savePrefs:e=>{t()&&this._savePrefs(e)},loaded:e=>{t()&&(n.body.removeAttribute(`aria-busy`),this.dispatchEvent(new CustomEvent(m,{bubbles:!0,detail:e})))},fail:e=>{t()&&this._fail(e)}}}_render(){let n=(e,t)=>{let n=document.createElement(e);return n.className=t,n},i=n(`div`,`wui-file-viewer-toolbar`),a=n(`div`,`wui-file-viewer-group wui-file-viewer-start`),o=n(`span`,`wui-file-viewer-name`);o.textContent=this.displayName(),o.title=this.displayName(),a.append(o);let s=n(`div`,`wui-file-viewer-group wui-file-viewer-center`),c=n(`div`,`wui-file-viewer-group wui-file-viewer-end`),l=n(`div`,`wui-file-viewer-group wui-file-viewer-view-end`),u=document.createElement(`a`);u.className=`u-action wui-file-viewer-download`,u.style.setProperty(`--wui-action-size`,`32px`),t(u,`download`),e(u,`Download`);let d=r(`maximize-4`,`Full screen`,{className:`wui-file-viewer-fullscreen`});d.addEventListener(`click`,()=>this.toggleFullscreen()),d.hidden=!document.fullscreenEnabled,this._actionsBox??=n(`div`,`wui-file-viewer-actions`);let f=this._actionsBox;f.append(...this.querySelectorAll(`:scope > [slot="actions"]`)),c.append(l,u,d,f);let p=n(`search`,`wui-file-viewer-search`);p.hidden=!0,i.append(a,s,c,p);let m=n(`div`,`wui-file-viewer-body`);m.setAttribute(`aria-busy`,`true`),this.replaceChildren(i,m),this._parts={toolbar:i,start:a,name:o,center:s,end:c,viewEnd:l,downloadLink:u,fullscreen:d,actionsBox:f,search:p,body:m},this._syncDownload(),this._syncFullscreen()}_syncDownload(){let e=this._parts.downloadLink;e.hidden=!this.download||!this.src,e.href=this.src,e.setAttribute(`download`,this.displayName())}_syncPrint(){for(let e of this._parts.toolbar.querySelectorAll(`.wui-file-viewer-print`))e instanceof HTMLElement&&(e.hidden=!this.print)}_status(e,{offerDownload:t=!1}={}){let n=document.createElement(`div`);n.className=`wui-file-viewer-status`;let r=document.createElement(`p`);if(r.textContent=e,n.append(r),t&&this.src){let e=document.createElement(`a`);e.className=l(`neutral`,`outline`,`sm`),e.dataset.wui=a,e.href=this.src,e.setAttribute(`download`,this.displayName()),e.textContent=`Download`,n.append(e)}this._parts.body.replaceChildren(n)}_settle(e,t){this._parts.body.removeAttribute(`aria-busy`),this._status(e,t)}_fail(e){this._view?.destroy(),this._view=null,this._settle(`Couldn't open this file.`,{offerDownload:!0});let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;this.dispatchEvent(new CustomEvent(h,{bubbles:!0,detail:{message:t??String(e)}}))}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.requestFullscreen().catch(e=>{n(`[wui-file-viewer] full screen refused:`,e?.message)})}_syncFullscreen(){if(!this._parts)return;let n=document.fullscreenElement===this,r=this._parts.fullscreen;t(r,n?`x`:`maximize-4`),e(r,n?`Exit full screen`:`Full screen`),this._parts.actionsBox.hidden=n}_readPrefs(){if(this._hostPrefs||!this.viewKey)return{...this._prefs};try{let e=JSON.parse(window.localStorage.getItem(`wui-view:${this.viewKey}`)??`{}`);return S(e)?e:{}}catch{return{}}}_savePrefs(e){if(this._prefs={...this._prefs,...e},this.dispatchEvent(new CustomEvent(g,{bubbles:!0,detail:{...this._prefs}})),!this._hostPrefs&&this.viewKey)try{window.localStorage.setItem(`wui-view:${this.viewKey}`,JSON.stringify(this._prefs))}catch{}}};function S(e){return typeof e==`object`&&!!e}function C(e){return e&&new URL(e,document.baseURI).href}var w=typeof document>`u`?null:document.currentScript;w instanceof HTMLScriptElement&&w.src&&(x.defaultAssetBase=new URL(`pdfjs/`,w.src).href),i(`wui-file-viewer`,x);var T=(e,t)=>import(`./fileViewerPdf-CdaDuaRJ.js`).then(n=>n.renderFirstPage(e,{assetBase:x.defaultAssetBase||void 0,...t}));export{x as WuiFileViewer,_ as fileKind,v as fileNameFromUrl,T as renderPdfFirstPage};
@@ -1 +1 @@
1
- var WeborityTour=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){if(typeof customElements>`u`||customElements.get(e))return;let n=[];if(typeof document<`u`)for(let r of document.querySelectorAll(e))for(let i of Object.keys(r)){let a=Object.getOwnPropertyDescriptor(t.prototype,i);if(a&&(a.set||a.get)&&(n.push([r,i,Reflect.get(r,i)]),!Reflect.deleteProperty(r,i)))throw Error(`defineElement: could not clear the early "${i}" property on <${e}>.`)}customElements.define(e,t);for(let[t,r,i]of n)if(!Reflect.set(t,r,i))throw Error(`defineElement: could not restore the "${r}" property on <${e}>.`)}var n=`@webority/ui-elements needs a browser DOM; import its types or helpers entry on the server`;if(typeof HTMLElement>`u`)throw Error(n);var r=HTMLElement;function i(e,t){a(e),e._reanchor=t,e._reanchorScroll=n=>{n.composedPath().includes(e)||t()},window.addEventListener(`resize`,e._reanchor),window.addEventListener(`scroll`,e._reanchorScroll,!0)}function a(e){if(!e?._reanchor)return;window.removeEventListener(`resize`,e._reanchor);let t=e._reanchorScroll;t&&window.removeEventListener(`scroll`,t,!0),e._reanchor=null,e._reanchorScroll=null}var o=`AppButton`,s=new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),c={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function l(e){return Object.hasOwn(c,e)}function u(e=`primary`,t=`solid`,n=`md`){if(!s.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!l(t))throw RangeError(`buttonClass: unknown variant "${t}"`);let r=c[t](e);return n===`md`?`btn ${r}`:`btn ${r} btn-${n}`}var d=`data-advance`,f=`wui-tour-hint`,p=`wui-tour-pointer`,m=`Click {actionName} to continue.`,h=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,g=(e,t)=>e?.advanceOn===`click`&&!!t,_=e=>(e??``).replace(/\s+/g,` `).trim(),v=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLMeterElement||e instanceof HTMLOutputElement||e instanceof HTMLProgressElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,ee=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLFieldSetElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement?e.disabled:!1;function te(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(v(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=_(e);if(t)return t}return``}function ne(e){for(let t of[e,...e.querySelectorAll(h)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!ee(t))return t;return null}function y(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function b(e,t){let n=e.querySelector(`.${f}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&y(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=f,i&&(n.id=i);let t=e.querySelector(`.wui-tour-actions`);if(!t)throw Error(`Tour card has no actions row.`);t.before(n)}n.textContent=t,i&&y(e,i,!0)}}function x(e,t){let n=e.querySelector(`.${p}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=p,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var re=e=>getComputedStyle(e).animationName;function S(e,{layer:t,spot:n,card:r},i,a){let o=g(i,a);t.toggleAttribute(d,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(d)&&(n.removeAttribute(d),o&&re(n)),o&&n.setAttribute(d,``),x(n,o);let s=r.querySelector(`.wui-tour-next`);if(!(s instanceof HTMLElement))throw Error(`Tour card has no next button.`);s.classList.toggle(`btn-primary`,!o),s.classList.toggle(`btn-link`,o);let c=o?_(i?.actionLabel)||te(a):``,l=e.getAttribute(`advance-label`)||m,u=c?l.replace(/\{actionName\}/g,()=>c):``;return b(r,u),u}function ie(e,t,n){if(!g(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ae(e,t,n,r){return e.contains(r)||g(t,n)&&n.contains(r)}function oe(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=g(r,i)?ne(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i?.contains(n));e.preventDefault();let c=a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length];if(!c)throw Error(`Tour card has no focus stop.`);c.focus()}var se=2/3,ce=1e3,C=new Set([`top`,`left`,`width`,`height`]),w=new WeakMap,T=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],E=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,le=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&C.has(e.transitionProperty),ue=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function D(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,ce);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function de(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?T(t,le):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*se-r)}return n}function O(e){let t=de(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};w.set(e,n);let r=()=>{w.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=T(e,ue);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function k(e){return e.dataset.state=`leaving`,D(T(e,E))}function fe(e){let t=e.shadowRoot?.querySelector(`.wui-tour-layer`),n=e.classList.contains(`wui-tour-layer`)?e:t instanceof HTMLElement?t:null;n&&(n.dataset.state=`leaving`);let r=n?D(T(n,E)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var pe=2,A=12,j=8,M=4,N=20,me=`(max-width: 575.98px)`,he=[`bottom`,`top`,`right`,`left`],P=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],F,I=(e,t,n)=>Math.max(t,Math.min(e,n)),L=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function R(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=B(e),r=e.offsetHeight+A;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+pe}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function z(e,t,n){let r=e.style,i=t.style,a=be(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of P)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,ge(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=B(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-A,top:o.top-A-l.top,right:l.right-o.right-A,left:o.left-A-l.left},f=window.matchMedia(me).matches,p=he.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+j)-Math.max(o.top,l.top-j);p?_e(t,a,p,o,l,c):m>=Math.min(c.height,u)+8?ve(t,a,o,l,c):ye(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function ge(e,t){F??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of P)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),F&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function _e(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=L(r.left,r.right,i.left,i.right);s=I(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+A:r.top-A-a.height,l=I(e-s,N,a.width-N)}else{let e=L(r.top,r.bottom,i.top,i.bottom);c=I(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+A:r.left-A-a.width,l=I(e-c,N,a.height-N)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function ve(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-M;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${I(n.left+M,r.left,r.right-i.width)}px`}function ye(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+A:r.top-A-c}px`;let l=L(r.left,r.right,i.left,i.right);e.style.left=`${I(l-a.width/2,i.left,i.right-a.width)}px`}function B(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+j,bottom:window.innerHeight-r(`paddingBottom`)-j,left:r(`paddingLeft`)+j,right:window.innerWidth-r(`paddingRight`)-j}}function be(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);if(t instanceof HTMLElement)return t;let n=document.createElement(`span`);return n.className=`wui-tour-arrow`,n.setAttribute(`aria-hidden`,`true`),n.hidden=!0,e.append(n),n}var xe=0,Se=`btn btn-sm btn-link`;function V(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function Ce(e,t,n){let r=`wui-tour-end-${++xe}`,i=!!(t.nextLabel&&t.nextHref),a=e.createElement(`div`);a.className=`wui-tour-card wui-tour-end`,a.dataset.layout=`center`,i&&(a.dataset.next=``),a.setAttribute(`role`,`dialog`),n&&a.setAttribute(`aria-modal`,`true`),a.tabIndex=-1,a.setAttribute(`aria-labelledby`,`${r}-title`),a.setAttribute(`aria-describedby`,`${r}-message`),a.innerHTML=` <div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div> <h2 class="wui-tour-title wui-tour-end-title" id="${r}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${r}-message"></p> <div class="wui-tour-actions">${i?`<a class="${u(`primary`,`solid`,`sm`)} wui-tour-end-next" data-wui="${o}"></a>`:``}<button type="button" class="${i?Se:u(`primary`,`solid`,`sm`)} wui-tour-end-button" data-wui="${o}"></button></div>`,V(a,`.wui-tour-end-title`,HTMLElement).textContent=t.title,V(a,`.wui-tour-end-message`,HTMLElement).textContent=t.message,V(a,`.wui-tour-end-button`,HTMLButtonElement).textContent=t.button;let{nextLabel:s,nextHref:c}=t;if(i&&s&&c){let e=V(a,`.wui-tour-end-next`,HTMLAnchorElement);e.textContent=s,e.setAttribute(`href`,c)}return a}var we=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function Te(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=Ce(r,t,i),o=V(a,`.wui-tour-end-button`,HTMLButtonElement),s=a.querySelector(`.wui-tour-end-next`);if(s!==null&&!(s instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let c=s,l=c?[c,o]:[o],u=c??o,d=new AbortController;return new Promise(s=>{let f=e=>{d.abort(),s(e)};if(n?.aborted){f(`done`);return}let p=V(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),m=V(e,`.wui-tour-spot`,HTMLElement),h=V(e,`[role=status]`,HTMLElement),g={signal:d.signal};n?.addEventListener(`abort`,()=>f(`done`),g),o.addEventListener(`click`,()=>f(`done`),g),c&&c.addEventListener(`click`,e=>{we(e)&&(e.preventDefault(),f(`next`))},g),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),f(`done`);else if(e.key===`Enter`&&c&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===c)e.preventDefault(),f(`next`);else if(e.key===`Tab`&&i){e.preventDefault();let t=r.activeElement,n=t instanceof HTMLElement?l.indexOf(t):-1,i=n===-1?e.shiftKey?l.length-1:0:(n+(e.shiftKey?-1:1)+l.length)%l.length,a=l[i];if(!a)throw Error(`The end dialog has no focus stop.`);a.focus()}}},{capture:!0,signal:d.signal}),i&&r.addEventListener(`focusin`,e=>{let t=e.target;if(t!==null&&!(t instanceof Node))throw Error(`Focus moved to a target that is not a node.`);a.contains(t)||u.focus()},g);let _=()=>{d.signal.aborted||(p.hidden=!0,z(m,p,null),e.append(a),O(a),h.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},v=k(p);v?v.then(_):_()})}var Ee=` :host { all: initial; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in 120ms linear; } .wui-tour-layer[data-state=leaving] { transition: opacity 120ms linear; } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in 120ms linear both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: 2px; } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check 300ms var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + 120ms) both; } } `,H=`wui-tour-media`,U=`wui-tour-media-toggle`,W=`http://www.w3.org/2000/svg`,De=`M6 5h4v14H6zM14 5h4v14h-4z`,Oe=`M8 5v14l11-7z`,ke={pause:`Pause animation`,play:`Play animation`},Ae=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function je(e){let t=document.createElementNS(W,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(W,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Me(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media??``),t}function Ne(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media??``),n}function Pe(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=U;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(je(r?De:Oe))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function Fe(e){let t=e.querySelector(`:scope > .${H}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ie(e,t,n=ke){if(Fe(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=H,t.mediaType===`video`){let e=Ne(t,!Ae());r.append(e,Pe(e,n))}else r.appendChild(Me(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var G=`data-wui-tour-open`,Le=`Step {current} of {total}`;function K(e){let t=new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function Re(e,t,n){return(e.getAttribute(`progress-label`)||Le).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function ze(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);if(!(i instanceof HTMLElement))throw Error(`tour position label missing`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;){let e=a.lastElementChild;if(!e)throw Error(`progress bar segment missing`);e.remove()}for(let e=0;e<o.length;e++){let t=o[e];if(!t)throw Error(`progress bar segment missing`);t.toggleAttribute(`data-filled`,e<n)}}var Be=`wui-tour-seen:`;function Ve(e=Be,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var He=`wui-tour-step`,Ue=`wui-tour-host`,q=`data-tracking`,We={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},Ge={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},Ke=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},qe=0,Y=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,X=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Z(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var Je=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},Q=null;function Ye(e){Q||(Q=new CSSStyleSheet,Q.replaceSync(Ee)),e.adoptedStyleSheets=[Q]}var Xe=class extends r{seenStore;onBeforeStep;_run;_running;_layer;_outer;_shadow;_unbindAdvance;_ending;_seenMark;_steps=[];_progress=K(0);_firstIndex=0;_returnFocus=null;_current=null;_moving=!1;_card=null;_spot=null;_live=null;_onKey=null;_onFocusIn=null;static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${He}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of Ke)e.hasAttribute(r)&&(t[n]=e.getAttribute(r)??void 0);return t})}_stepAt(e){let t=this._steps[e];if(!t)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);return t}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?Ve():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Ge[e])||We[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=K(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!Y(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(!e)break;if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target),a=t instanceof HTMLElement||t instanceof SVGElement?t:null;if(Y(a))return this._progress.position(i),{index:i,target:a};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let e=`wui-tour-${++qe}`,t=document.createElement(`div`);t.className=`wui-tour-layer`,t.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${e}-title"></h2> <p class="wui-tour-text" id="${e}-text"></p> <div class="wui-tour-actions"> <button type="button" class="btn btn-sm btn-link wui-tour-skip"></button> <div class="wui-tour-nav"> <button type="button" class="${u(`neutral`,`outline`,`sm`)} wui-tour-back" data-wui="${o}"></button> <button type="button" class="${u(`primary`,`solid`,`sm`)} wui-tour-next" data-wui="${o}"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let n=t;this._shadow=null,this.isolated&&(n=document.createElement(Ue),this._shadow=n.attachShadow({mode:`open`}),Ye(this._shadow),this._shadow.appendChild(t)),document.body.appendChild(n),document.documentElement.setAttribute(G,``),this._outer=n,this._layer=t;let r=Z(t,`.wui-tour-spot`,HTMLDivElement),a=Z(t,`.wui-tour-card`,HTMLDivElement),s=Z(t,`[role=status]`,HTMLElement);this._spot=r,this._card=a,this._live=s,Z(a,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Z(a,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Z(a,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1)),this._shadow&&a.removeAttribute(`aria-modal`);let c=e=>this._key(e);this._onKey=c;let l=e=>{let t=this._layer;if(!t||this._ending)return;let n=this._current,r=n?this._stepAt(n.index):null;if(!(e.target instanceof Node))throw Error(`<wui-tour> saw a focus change from a non-node target`);ae(t,r,n?.target??null,e.target)||a.focus()};this._onFocusIn=l,document.addEventListener(`keydown`,c,!0),this._shadow||document.addEventListener(`focusin`,l),i(n,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._stepAt(t),i=this._layer,a=this._spot,o=this._card,s=this._live;if(!i||!a||!o||!s)throw Error(`<wui-tour> shows a step before its layer is built`);let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=Re(this,c,l);ze(o,{text:d,position:c,total:l}),Ie(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=S(this,{layer:i,spot:a,card:o},r,n),p=Z(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Z(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Z(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Z(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Z(o,`.wui-tour-next`,HTMLElement).textContent=this._label(u?`done`:`next`);let h=[d,r.title,r.description].filter(Boolean).join(`. `);s.textContent=f?[h,f].join(/[.!?]$/.test(h)?` `:`. `):h,R(o,n),a.removeAttribute(q),this._place(),O(o),this._unbindAdvance?.(),this._unbindAdvance=ie(r,n,()=>this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&X(Je()))||o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:c,total:l}}))}_place(){if(!this._current||!this._layer)return;let e=this._spot,t=this._card;if(!e||!t)throw Error(`<wui-tour> places a step before its layer is built`);z(e,t,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot;if(!e)throw Error(`<wui-tour> follows a step before its spot is built`);let t=e.style.cssText;this._place(),e.style.cssText!==t&&e.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=this._card;if(!e)throw Error(`<wui-tour> moved with no card showing`);let t=k(e);if(t&&await t,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);if(t===`next`&&r&&e){let t=this.ownerDocument.defaultView;if(!t)throw Error(`<wui-tour> has no window to follow its next link in`);t.location.assign(e.nextHref)}}}finally{this._moving=!1}}_showEnd(e){this._unbindAdvance?.(),this._unbindAdvance=null;let t=this._layer,n=this._spot,r=this._card;if(!t||!n||!r)throw Error(`<wui-tour> ends a tour before its layer is built`);return S(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),Te(t,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(X(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),e.key===`ArrowRight`)this._move(1);else{let e=this._current;if(!e)throw Error(`<wui-tour> moved back with no step showing`);e.index>this._firstIndex&&this._move(-1)}}else if(e.key===`Tab`&&!this._shadow){let t=this._current,n=this._card;if(!t||!n)throw Error(`<wui-tour> cycled focus with no step showing`);oe(e,{card:n,active:this._active(),step:this._stepAt(t.index),target:t.target})}}}_teardown(){if(!this._layer)return;this._onKey&&document.removeEventListener(`keydown`,this._onKey,!0),this._onFocusIn&&document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null;let t=this._outer;if(a(t),!t)throw Error(`<wui-tour> has a layer with no host to remove`);fe(t),document.documentElement.removeAttribute(G),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&(n instanceof HTMLElement||n instanceof SVGElement)&&n.focus()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:J,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=J,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}},$=class extends r{constructor(){super(),this.shadowRoot||this.attachShadow({mode:`open`})}};return t(`wui-tour`,Xe),t(`wui-tour-step`,$),e.WuiTourStep=$,e})({});
1
+ var WeborityTour=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){if(typeof customElements>`u`||customElements.get(e))return;let n=[];if(typeof document<`u`)for(let r of document.querySelectorAll(e))for(let i of Object.keys(r)){let a=Object.getOwnPropertyDescriptor(t.prototype,i);if(a&&(a.set||a.get)&&(n.push([r,i,Reflect.get(r,i)]),!Reflect.deleteProperty(r,i)))throw Error(`defineElement: could not clear the early "${i}" property on <${e}>.`)}customElements.define(e,t);for(let[t,r,i]of n)if(!Reflect.set(t,r,i))throw Error(`defineElement: could not restore the "${r}" property on <${e}>.`)}var n=`@webority/ui-elements needs a browser DOM; import its types or helpers entry on the server`;if(typeof HTMLElement>`u`)throw Error(n);var r=HTMLElement;function i(e,t){a(e),e._reanchor=t,e._reanchorScroll=n=>{n.composedPath().includes(e)||t()},window.addEventListener(`resize`,e._reanchor),window.addEventListener(`scroll`,e._reanchorScroll,!0)}function a(e){if(!e?._reanchor)return;window.removeEventListener(`resize`,e._reanchor);let t=e._reanchorScroll;t&&window.removeEventListener(`scroll`,t,!0),e._reanchor=null,e._reanchorScroll=null}var o=`AppButton`,s=new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),c={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function l(e){return Object.hasOwn(c,e)}function u(e=`primary`,t=`solid`,n=`md`){if(!s.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!l(t))throw RangeError(`buttonClass: unknown variant "${t}"`);let r=c[t](e);return n===`md`?`btn ${r}`:`btn ${r} btn-${n}`}var d=`data-advance`,f=`wui-tour-hint`,p=`wui-tour-pointer`,m=`Click {actionName} to continue.`,h=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,g=(e,t)=>e?.advanceOn===`click`&&!!t,_=e=>(e??``).replace(/\s+/g,` `).trim(),v=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLMeterElement||e instanceof HTMLOutputElement||e instanceof HTMLProgressElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,ee=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLFieldSetElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement?e.disabled:!1;function te(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(v(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=_(e);if(t)return t}return``}function ne(e){for(let t of[e,...e.querySelectorAll(h)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!ee(t))return t;return null}function y(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function b(e,t){let n=e.querySelector(`.${f}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&y(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=f,i&&(n.id=i);let t=e.querySelector(`.wui-tour-actions`);if(!t)throw Error(`Tour card has no actions row.`);t.before(n)}n.textContent=t,i&&y(e,i,!0)}}function x(e,t){let n=e.querySelector(`.${p}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=p,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var re=e=>getComputedStyle(e).animationName;function S(e,{layer:t,spot:n,card:r},i,a){let o=g(i,a);t.toggleAttribute(d,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(d)&&(n.removeAttribute(d),o&&re(n)),o&&n.setAttribute(d,``),x(n,o);let s=r.querySelector(`.wui-tour-next`);if(!(s instanceof HTMLElement))throw Error(`Tour card has no next button.`);s.classList.toggle(`btn-primary`,!o),s.classList.toggle(`btn-link`,o);let c=o?_(i?.actionLabel)||te(a):``,l=e.getAttribute(`advance-label`)||m,u=c?l.replace(/\{actionName\}/g,()=>c):``;return b(r,u),u}function ie(e,t,n){if(!g(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ae(e,t,n,r){return e.contains(r)||g(t,n)&&n.contains(r)}function oe(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=g(r,i)?ne(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i?.contains(n));e.preventDefault();let c=a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length];if(!c)throw Error(`Tour card has no focus stop.`);c.focus()}var se=2/3,ce=1e3,C=new Set([`top`,`left`,`width`,`height`]),w=new WeakMap,T=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],E=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,le=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&C.has(e.transitionProperty),ue=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function D(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,ce);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function de(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?T(t,le):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*se-r)}return n}function O(e){let t=de(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};w.set(e,n);let r=()=>{w.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=T(e,ue);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function k(e){return e.dataset.state=`leaving`,D(T(e,E))}function fe(e){let t=e.shadowRoot?.querySelector(`.wui-tour-layer`),n=e.classList.contains(`wui-tour-layer`)?e:t instanceof HTMLElement?t:null;n&&(n.dataset.state=`leaving`);let r=n?D(T(n,E)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var pe=2,A=12,j=8,M=4,N=20,me=`(max-width: 575.98px)`,he=[`bottom`,`top`,`right`,`left`],P=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],F,I=(e,t,n)=>Math.max(t,Math.min(e,n)),L=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function R(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=B(e),r=e.offsetHeight+A;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+pe}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function z(e,t,n){let r=e.style,i=t.style,a=be(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of P)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,ge(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=B(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-A,top:o.top-A-l.top,right:l.right-o.right-A,left:o.left-A-l.left},f=window.matchMedia(me).matches,p=he.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+j)-Math.max(o.top,l.top-j);p?_e(t,a,p,o,l,c):m>=Math.min(c.height,u)+8?ve(t,a,o,l,c):ye(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function ge(e,t){F??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of P)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),F&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function _e(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=L(r.left,r.right,i.left,i.right);s=I(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+A:r.top-A-a.height,l=I(e-s,N,a.width-N)}else{let e=L(r.top,r.bottom,i.top,i.bottom);c=I(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+A:r.left-A-a.width,l=I(e-c,N,a.height-N)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function ve(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-M;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${I(n.left+M,r.left,r.right-i.width)}px`}function ye(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+A:r.top-A-c}px`;let l=L(r.left,r.right,i.left,i.right);e.style.left=`${I(l-a.width/2,i.left,i.right-a.width)}px`}function B(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+j,bottom:window.innerHeight-r(`paddingBottom`)-j,left:r(`paddingLeft`)+j,right:window.innerWidth-r(`paddingRight`)-j}}function be(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);if(t instanceof HTMLElement)return t;let n=document.createElement(`span`);return n.className=`wui-tour-arrow`,n.setAttribute(`aria-hidden`,`true`),n.hidden=!0,e.append(n),n}var xe=0,Se=`btn btn-sm btn-link`;function V(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function Ce(e,t,n){let r=`wui-tour-end-${++xe}`,i=!!(t.nextLabel&&t.nextHref),a=e.createElement(`div`);a.className=`wui-tour-card wui-tour-end`,a.dataset.layout=`center`,i&&(a.dataset.next=``),a.setAttribute(`role`,`dialog`),n&&a.setAttribute(`aria-modal`,`true`),a.tabIndex=-1,a.setAttribute(`aria-labelledby`,`${r}-title`),a.setAttribute(`aria-describedby`,`${r}-message`),a.innerHTML=` <div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div> <h2 class="wui-tour-title wui-tour-end-title" id="${r}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${r}-message"></p> <div class="wui-tour-actions">${i?`<a class="${u(`primary`,`solid`,`sm`)} wui-tour-end-next" data-wui="${o}"></a>`:``}<button type="button" class="${i?Se:u(`primary`,`solid`,`sm`)} wui-tour-end-button" data-wui="${o}"></button></div>`,V(a,`.wui-tour-end-title`,HTMLElement).textContent=t.title,V(a,`.wui-tour-end-message`,HTMLElement).textContent=t.message,V(a,`.wui-tour-end-button`,HTMLButtonElement).textContent=t.button;let{nextLabel:s,nextHref:c}=t;if(i&&s&&c){let e=V(a,`.wui-tour-end-next`,HTMLAnchorElement);e.textContent=s,e.setAttribute(`href`,c)}return a}var we=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function Te(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=Ce(r,t,i),o=V(a,`.wui-tour-end-button`,HTMLButtonElement),s=a.querySelector(`.wui-tour-end-next`);if(s!==null&&!(s instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let c=s,l=c?[c,o]:[o],u=c??o,d=new AbortController;return new Promise(s=>{let f=e=>{d.abort(),s(e)};if(n?.aborted){f(`done`);return}let p=V(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),m=V(e,`.wui-tour-spot`,HTMLElement),h=V(e,`[role=status]`,HTMLElement),g={signal:d.signal};n?.addEventListener(`abort`,()=>f(`done`),g),o.addEventListener(`click`,()=>f(`done`),g),c&&c.addEventListener(`click`,e=>{we(e)&&(e.preventDefault(),f(`next`))},g),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),f(`done`);else if(e.key===`Enter`&&c&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===c)e.preventDefault(),f(`next`);else if(e.key===`Tab`&&i){e.preventDefault();let t=r.activeElement,n=t instanceof HTMLElement?l.indexOf(t):-1,i=n===-1?e.shiftKey?l.length-1:0:(n+(e.shiftKey?-1:1)+l.length)%l.length,a=l[i];if(!a)throw Error(`The end dialog has no focus stop.`);a.focus()}}},{capture:!0,signal:d.signal}),i&&r.addEventListener(`focusin`,e=>{let t=e.target;if(t!==null&&!(t instanceof Node))throw Error(`Focus moved to a target that is not a node.`);a.contains(t)||u.focus()},g);let _=()=>{d.signal.aborted||(p.hidden=!0,z(m,p,null),e.append(a),O(a),h.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},v=k(p);v?v.then(_):_()})}var Ee=` :host { all: initial; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-ease-linear":`cubic-bezier(0, 0, 1, 1)`,"--wui-duration-fast":`150ms`,"--wui-duration-default":`250ms`,"--wui-duration-slow":`400ms`,"--wui-space-xs":`4px`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear) both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: 2px; } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check var(--wui-duration-default) var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + var(--wui-duration-fast)) both; } } `,H=`wui-tour-media`,U=`wui-tour-media-toggle`,W=`http://www.w3.org/2000/svg`,De=`M6 5h4v14H6zM14 5h4v14h-4z`,Oe=`M8 5v14l11-7z`,ke={pause:`Pause animation`,play:`Play animation`},Ae=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function je(e){let t=document.createElementNS(W,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(W,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Me(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media??``),t}function Ne(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media??``),n}function Pe(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=U;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(je(r?De:Oe))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function Fe(e){let t=e.querySelector(`:scope > .${H}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ie(e,t,n=ke){if(Fe(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=H,t.mediaType===`video`){let e=Ne(t,!Ae());r.append(e,Pe(e,n))}else r.appendChild(Me(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var G=`data-wui-tour-open`,Le=`Step {current} of {total}`;function K(e){let t=new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function Re(e,t,n){return(e.getAttribute(`progress-label`)||Le).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function ze(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);if(!(i instanceof HTMLElement))throw Error(`tour position label missing`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;){let e=a.lastElementChild;if(!e)throw Error(`progress bar segment missing`);e.remove()}for(let e=0;e<o.length;e++){let t=o[e];if(!t)throw Error(`progress bar segment missing`);t.toggleAttribute(`data-filled`,e<n)}}var Be=`wui-tour-seen:`;function Ve(e=Be,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var He=`wui-tour-step`,Ue=`wui-tour-host`,q=`data-tracking`,We={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},Ge={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},Ke=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},qe=0,Y=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,X=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Z(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var Je=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},Q=null;function Ye(e){Q||(Q=new CSSStyleSheet,Q.replaceSync(Ee)),e.adoptedStyleSheets=[Q]}var Xe=class extends r{seenStore;onBeforeStep;_run;_running;_layer;_outer;_shadow;_unbindAdvance;_ending;_seenMark;_steps=[];_progress=K(0);_firstIndex=0;_returnFocus=null;_current=null;_moving=!1;_card=null;_spot=null;_live=null;_onKey=null;_onFocusIn=null;static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${He}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of Ke)e.hasAttribute(r)&&(t[n]=e.getAttribute(r)??``);return t})}_stepAt(e){let t=this._steps[e];if(!t)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);return t}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?Ve():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Ge[e])||We[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=K(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!Y(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(!e)break;if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target),a=t instanceof HTMLElement||t instanceof SVGElement?t:null;if(Y(a))return this._progress.position(i),{index:i,target:a};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let e=`wui-tour-${++qe}`,t=document.createElement(`div`);t.className=`wui-tour-layer`,t.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${e}-title"></h2> <p class="wui-tour-text" id="${e}-text"></p> <div class="wui-tour-actions"> <button type="button" class="btn btn-sm btn-link wui-tour-skip"></button> <div class="wui-tour-nav"> <button type="button" class="${u(`neutral`,`outline`,`sm`)} wui-tour-back" data-wui="${o}"></button> <button type="button" class="${u(`primary`,`solid`,`sm`)} wui-tour-next" data-wui="${o}"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let n=t;this._shadow=null,this.isolated&&(n=document.createElement(Ue),this._shadow=n.attachShadow({mode:`open`}),Ye(this._shadow),this._shadow.appendChild(t)),document.body.appendChild(n),document.documentElement.setAttribute(G,``),this._outer=n,this._layer=t;let r=Z(t,`.wui-tour-spot`,HTMLDivElement),a=Z(t,`.wui-tour-card`,HTMLDivElement),s=Z(t,`[role=status]`,HTMLElement);this._spot=r,this._card=a,this._live=s,Z(a,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Z(a,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Z(a,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1)),this._shadow&&a.removeAttribute(`aria-modal`);let c=e=>this._key(e);this._onKey=c;let l=e=>{let t=this._layer;if(!t||this._ending)return;let n=this._current,r=n?this._stepAt(n.index):null;if(!(e.target instanceof Node))throw Error(`<wui-tour> saw a focus change from a non-node target`);ae(t,r,n?.target??null,e.target)||a.focus()};this._onFocusIn=l,document.addEventListener(`keydown`,c,!0),this._shadow||document.addEventListener(`focusin`,l),i(n,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._stepAt(t),i=this._layer,a=this._spot,o=this._card,s=this._live;if(!i||!a||!o||!s)throw Error(`<wui-tour> shows a step before its layer is built`);let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=Re(this,c,l);ze(o,{text:d,position:c,total:l}),Ie(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=S(this,{layer:i,spot:a,card:o},r,n),p=Z(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Z(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Z(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Z(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Z(o,`.wui-tour-next`,HTMLElement).textContent=this._label(u?`done`:`next`);let h=[d,r.title,r.description].filter(Boolean).join(`. `);s.textContent=f?[h,f].join(/[.!?]$/.test(h)?` `:`. `):h,R(o,n),a.removeAttribute(q),this._place(),O(o),this._unbindAdvance?.(),this._unbindAdvance=ie(r,n,()=>this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&X(Je()))||o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:c,total:l}}))}_place(){if(!this._current||!this._layer)return;let e=this._spot,t=this._card;if(!e||!t)throw Error(`<wui-tour> places a step before its layer is built`);z(e,t,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot;if(!e)throw Error(`<wui-tour> follows a step before its spot is built`);let t=e.style.cssText;this._place(),e.style.cssText!==t&&e.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=this._card;if(!e)throw Error(`<wui-tour> moved with no card showing`);let t=k(e);if(t&&await t,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);if(t===`next`&&r&&e){let t=this.ownerDocument.defaultView;if(!t)throw Error(`<wui-tour> has no window to follow its next link in`);t.location.assign(e.nextHref)}}}finally{this._moving=!1}}_showEnd(e){this._unbindAdvance?.(),this._unbindAdvance=null;let t=this._layer,n=this._spot,r=this._card;if(!t||!n||!r)throw Error(`<wui-tour> ends a tour before its layer is built`);return S(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),Te(t,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(X(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),e.key===`ArrowRight`)this._move(1);else{let e=this._current;if(!e)throw Error(`<wui-tour> moved back with no step showing`);e.index>this._firstIndex&&this._move(-1)}}else if(e.key===`Tab`&&!this._shadow){let t=this._current,n=this._card;if(!t||!n)throw Error(`<wui-tour> cycled focus with no step showing`);oe(e,{card:n,active:this._active(),step:this._stepAt(t.index),target:t.target})}}}_teardown(){if(!this._layer)return;this._onKey&&document.removeEventListener(`keydown`,this._onKey,!0),this._onFocusIn&&document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null;let t=this._outer;if(a(t),!t)throw Error(`<wui-tour> has a layer with no host to remove`);fe(t),document.documentElement.removeAttribute(G),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&(n instanceof HTMLElement||n instanceof SVGElement)&&n.focus()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:J,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=J,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}},$=class extends r{constructor(){super(),this.shadowRoot||this.attachShadow({mode:`open`})}};return t(`wui-tour`,Xe),t(`wui-tour-step`,$),e.WuiTourStep=$,e})({});
@@ -1 +1 @@
1
- import{n as e}from"./devWarn-DXdRWZs3.js";var t=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),n=t=>(e(`[@webority/ui-elements] Wui-Toast-Action: ${t}; the toast shows no action.`),null),r=e=>typeof e==`object`&&!!e;function i(e){if(e==null||e===``)return null;let i;try{i=JSON.parse(e)}catch{return n(`the value is not JSON`)}let a=r(i)?i:{},o=a.label,s=a.url,c=String(a.method??`POST`).toUpperCase();return typeof o!=`string`||o===``||typeof s!=`string`||s===``?n(`label and url must be non-empty strings`):t.includes(c)?{label:o,url:s,method:c}:n(`method must be one of ${t.join(`, `)}`)}var a=`wui-csrf`,o=`RequestVerificationToken`,s={metaName:a,header:o};function c({metaName:e=a,header:t=o}={}){s={metaName:e,header:t}}var l=`Wui-Request`,u=Object.freeze({fragment:`Wui-Fragment`,message:`Wui-Message`,redirect:`Wui-Redirect`,result:`Wui-Result`,keepOpen:`Wui-Keep-Open`,toastVariant:`Wui-Toast-Variant`,toastAction:`Wui-Toast-Action`,data:`Wui-Data`,next:`Wui-Next`}),d=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`aborted`,`stale`,`session`]),f=/* @__PURE__ */ new Set([`GET`,`HEAD`]);function p(e=document){let t=[...e.querySelectorAll(`meta`)].find(e=>e.getAttribute(`name`)===s.metaName),n=t?.getAttribute(`content`);return!t||!n?null:{header:t.getAttribute(`data-header`)||s.header,token:n}}var m=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function h(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var g=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,_=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch(e){throw TypeError(`The ${u.data} response header is not JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}};async function v(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),a={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[l]:`1`,...t.headers};if(!f.has(n)&&m(e)){let e=p();e&&(a[e.header]=e.token)}let o=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},s=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:o(r(u.message)),redirect:r(u.redirect),result:r(u.result),keepOpen:r(u.keepOpen)===`1`,toastVariant:r(u.toastVariant),toastAction:i(r(u.toastAction)),fragment:r(u.fragment)===`1`,data:_(o(r(u.data))),next:r(u.next)}},c;try{c=await fetch(e,{method:n,body:t.body,headers:a,signal:t.signal,credentials:`same-origin`})}catch(e){return s(g(e)||t.signal?.aborted?`aborted`:`network`)}let d=h(c.status);if(d===`ok`&&c.redirected&&c.headers.get(u.fragment)!==`1`&&(d=`session`),d===`session`)return r(c.status===401?c.headers.get(`Location`)||window.location.href:c.url),s(d,c);let v=``;if(d===`ok`||d===`validation`)try{v=await c.text()}catch(e){return s(g(e)||t.signal?.aborted?`aborted`:`network`,c)}return s(d,c,v)}function y(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s;try{s=await v(n,{...r,signal:i.signal})}finally{e===i&&(e=null)}return a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{h as a,p as c,i as d,u as i,v as l,o as n,c as o,d as r,y as s,a as t,t as u};
1
+ import{n as e}from"./devWarn-DXdRWZs3.js";var t=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),n=t=>(e(`[@webority/ui-elements] Wui-Toast-Action: ${t}; the toast shows no action.`),null),r=e=>typeof e==`object`&&!!e;function i(e){if(e==null||e===``)return null;let i;try{i=JSON.parse(e)}catch{return n(`the value is not JSON`)}let a=r(i)?i:{},o=a.label,s=a.url,c=String(a.method??`POST`).toUpperCase();return typeof o!=`string`||o===``||typeof s!=`string`||s===``?n(`label and url must be non-empty strings`):t.includes(c)?{label:o,url:s,method:c}:n(`method must be one of ${t.join(`, `)}`)}var a=`wui-csrf`,o=`RequestVerificationToken`,s={metaName:a,header:o};function c({metaName:e=a,header:t=o}={}){s={metaName:e,header:t}}var l=`Wui-Request`,u=Object.freeze({fragment:`Wui-Fragment`,message:`Wui-Message`,redirect:`Wui-Redirect`,result:`Wui-Result`,keepOpen:`Wui-Keep-Open`,toastVariant:`Wui-Toast-Variant`,toastAction:`Wui-Toast-Action`,data:`Wui-Data`,next:`Wui-Next`}),d=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`aborted`,`stale`,`session`]),f=/* @__PURE__ */ new Set([`GET`,`HEAD`]);function p(e=document){let t=[...e.querySelectorAll(`meta`)].find(e=>e.getAttribute(`name`)===s.metaName),n=t?.getAttribute(`content`);return!t||!n?null:{header:t.getAttribute(`data-header`)||s.header,token:n}}var m=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function h(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var g=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,_=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch(e){throw TypeError(`The ${u.data} response header is not JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}};async function v(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),a={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[l]:`1`,...t.headers};if(!f.has(n)&&m(e)){let e=p();e&&(a[e.header]=e.token)}let o=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},s=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:o(r(u.message)),redirect:r(u.redirect),result:r(u.result),keepOpen:r(u.keepOpen)===`1`,toastVariant:r(u.toastVariant),toastAction:i(r(u.toastAction)),fragment:r(u.fragment)===`1`,data:_(o(r(u.data))),next:r(u.next)}},c;try{c=await fetch(e,{method:n,...t.body===void 0?{}:{body:t.body},headers:a,...t.signal===void 0?{}:{signal:t.signal},credentials:`same-origin`})}catch(e){return s(g(e)||t.signal?.aborted?`aborted`:`network`)}let d=h(c.status);if(d===`ok`&&c.redirected&&c.headers.get(u.fragment)!==`1`&&(d=`session`),d===`session`)return r(c.status===401?c.headers.get(`Location`)||window.location.href:c.url),s(d,c);let v=``;if(d===`ok`||d===`validation`)try{v=await c.text()}catch(e){return s(g(e)||t.signal?.aborted?`aborted`:`network`,c)}return s(d,c,v)}function y(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s;try{s=await v(n,{...r,signal:i.signal})}finally{e===i&&(e=null)}return a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{h as a,p as c,i as d,u as i,v as l,o as n,c as o,d as r,y as s,a as t,t as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-elements",
3
- "version": "0.150.0",
3
+ "version": "0.153.0",
4
4
  "description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -250,8 +250,9 @@
250
250
  "@tiptap/starter-kit": "3.31.4",
251
251
  "@types/node": "25.6.0",
252
252
  "@vitest/coverage-v8": "5.1.0",
253
- "@webority/markdown-core": "0.150.0",
254
- "@webority/theme": "0.150.0",
253
+ "@webority/biome-config": "0.153.0",
254
+ "@webority/markdown-core": "0.153.0",
255
+ "@webority/theme": "0.153.0",
255
256
  "echarts": "6.1.0",
256
257
  "jsdom": "30.1.1",
257
258
  "libphonenumber-js": "^1.13.9",
@@ -5,8 +5,8 @@ import { WuiMentionInput } from "./WuiMentionInput.ts";
5
5
  type CommentPerson = {
6
6
  value: string;
7
7
  label: string;
8
- description?: string;
9
- src?: string;
8
+ description?: string | undefined;
9
+ src?: string | undefined;
10
10
  };
11
11
  type CommentFields = {
12
12
  commentId?: string | null;
@@ -27,12 +27,12 @@ export interface CropPinch {
27
27
  done: boolean;
28
28
  }
29
29
  export interface CropOutputOptions {
30
- type?: string;
31
- maxBytes?: number;
32
- size?: number;
30
+ type?: string | undefined;
31
+ maxBytes?: number | undefined;
32
+ size?: number | undefined;
33
33
  }
34
34
  export interface CropFileOptions extends CropOutputOptions {
35
- name?: string;
35
+ name?: string | undefined;
36
36
  }
37
37
  export interface CropView {
38
38
  scale: number;
@@ -23,10 +23,15 @@ export declare class WuiSelect extends ElementBase {
23
23
  _partsMounted: boolean;
24
24
  _partToken: number;
25
25
  _rendered: boolean;
26
+ _searchShown: boolean;
26
27
  _defaultValue: string | string[] | undefined;
27
28
  _warnedMode: string | null;
28
29
  _warnedDensity: string | null | undefined;
29
30
  _reposition: () => void;
31
+ _hoverTimer: ReturnType<typeof setTimeout> | null;
32
+ _hoverOpened: boolean;
33
+ _onHoverOver: (e: PointerEvent) => void;
34
+ _onHoverOut: (e: PointerEvent) => void;
30
35
  _onDocClick: ((e: MouseEvent) => void) | null | undefined;
31
36
  _bindGlobal: () => void;
32
37
  _reanchor?: (() => void) | null;
@@ -81,6 +86,10 @@ export declare class WuiSelect extends ElementBase {
81
86
  _syncError(): void;
82
87
  _refs(): Refs;
83
88
  _menuOpen(): boolean;
89
+ _hoverZone(target: EventTarget | null): boolean;
90
+ _hoverEligible(): boolean;
91
+ _clearHover(): void;
92
+ _autoSearch(): boolean;
84
93
  _visible(): HTMLElement[];
85
94
  _setActive(index: number, { reveal }?: {
86
95
  reveal?: boolean;
@@ -15,7 +15,7 @@ declare const DEFAULT_LABELS: {
15
15
  type LabelKey = keyof typeof DEFAULT_LABELS;
16
16
  type TourStep = {
17
17
  target: string;
18
- title?: string;
18
+ title?: string | undefined;
19
19
  description: string;
20
20
  media?: string;
21
21
  mediaAlt?: string;