@webority/ui-elements 0.146.2 → 0.148.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 (102) hide show
  1. package/dist/WuiCommandPalette-Bfrbocu6.js +2 -0
  2. package/dist/{WuiCommentThread-B9bkBMIq.js → WuiCommentThread-Dx3vvBWp.js} +1 -1
  3. package/dist/{WuiContextMenu-BvDHn1cP.js → WuiContextMenu-KXD8TFfy.js} +1 -1
  4. package/dist/{WuiDataTable-XscBy1ct.js → WuiDataTable-DAxAegnG.js} +1 -1
  5. package/dist/{WuiDatePicker-_h8R3HSU.js → WuiDatePicker-kEyyILbM.js} +2 -2
  6. package/dist/{WuiDateRange-BtkmxMSN.js → WuiDateRange-B05PsdJ3.js} +2 -2
  7. package/dist/{WuiHoverCard-sq6EZZYD.js → WuiHoverCard-Bqapy8Is.js} +1 -1
  8. package/dist/{WuiInlineEdit-CBw0bupF.js → WuiInlineEdit-BqgKfVMy.js} +1 -1
  9. package/dist/WuiMarkdown-D5vm4sp4.js +4 -0
  10. package/dist/{WuiMentionInput-9iC7Tur2.js → WuiMentionInput-Bi3VQoKo.js} +1 -1
  11. package/dist/WuiNavigationMenu-DmH3waKW.js +1 -0
  12. package/dist/WuiNotificationCenter-DawJRGBc.js +1 -0
  13. package/dist/WuiOverflow-DP3qEbDp.js +1 -0
  14. package/dist/{WuiPhone-oEkvgH1D.js → WuiPhone-CFne_6XG.js} +2 -2
  15. package/dist/WuiSavedViews-BMBQUv2K.js +1 -0
  16. package/dist/WuiSelect-oSJPev4N.js +9 -0
  17. package/dist/WuiShortcuts-BEvFCIu9.js +1 -0
  18. package/dist/{WuiTimePicker-CLS7ahpd.js → WuiTimePicker-DqqZPv0T.js} +2 -2
  19. package/dist/{WuiTour-Cz_SaC60.js → WuiTour-B-V1PZnw.js} +1 -1
  20. package/dist/{WuiTree-BZaGfmr9.js → WuiTree-B3cnH1PG.js} +1 -1
  21. package/dist/WuiWhatsNew-B5jK2zwZ.js +1 -0
  22. package/dist/{anchorOverlay-CBMAnDUt.js → anchorOverlay-DDrc2k6y.js} +1 -1
  23. package/dist/{chips-CjCv74bk.js → chips-DbhCYoAp.js} +1 -1
  24. package/dist/{dataTable-BGZc5iC1.js → dataTable-BoyxeUL4.js} +1 -1
  25. package/dist/drawerDiscard-D6YgF59q.js +1 -0
  26. package/dist/elements/command-palette.js +1 -1
  27. package/dist/elements/comment-thread.js +1 -1
  28. package/dist/elements/context-menu.js +1 -1
  29. package/dist/elements/data-table.js +1 -1
  30. package/dist/elements/date-range.js +1 -1
  31. package/dist/elements/datepicker.js +1 -1
  32. package/dist/elements/filter-popover.js +1 -1
  33. package/dist/elements/hover-card.js +1 -1
  34. package/dist/elements/inline-edit.js +1 -1
  35. package/dist/elements/kanban.js +1 -1
  36. package/dist/elements/markdown.js +1 -1
  37. package/dist/elements/mention-input.js +1 -1
  38. package/dist/elements/navigation-menu.js +1 -1
  39. package/dist/elements/notification-center.js +1 -1
  40. package/dist/elements/overflow.js +1 -1
  41. package/dist/elements/phone.js +1 -1
  42. package/dist/elements/saved-views.js +1 -1
  43. package/dist/elements/select.js +1 -1
  44. package/dist/elements/shortcuts.js +1 -1
  45. package/dist/elements/timepicker.js +1 -1
  46. package/dist/elements/tour.js +1 -1
  47. package/dist/elements/tree.js +1 -1
  48. package/dist/elements/whats-new.js +1 -1
  49. package/dist/filterPopover-DniNyLWI.js +1 -0
  50. package/dist/{kanban-D-ljbA4A.js → kanban-BtgxVDE-.js} +1 -1
  51. package/dist/loader-Dw3IkGM0.js +1 -0
  52. package/dist/recents-BzN7j9kV.js +1 -0
  53. package/dist/{search-rosjW6Tp.js → search-CdAH8NGK.js} +1 -1
  54. package/dist/server.js +1 -1
  55. package/dist/ui-calendar.global.js +1 -1
  56. package/dist/ui-calendar.js +1 -1
  57. package/dist/ui-elements/carousel.global.js +1 -1
  58. package/dist/ui-elements/code-block.global.js +1 -1
  59. package/dist/ui-elements/command-palette.global.js +2 -2
  60. package/dist/ui-elements/comment-thread.global.js +1 -1
  61. package/dist/ui-elements/consent-banner.global.js +1 -1
  62. package/dist/ui-elements/context-menu.global.js +1 -1
  63. package/dist/ui-elements/date-range.global.js +2 -2
  64. package/dist/ui-elements/drawer.global.js +1 -1
  65. package/dist/ui-elements/image-crop.global.js +1 -1
  66. package/dist/ui-elements/inline-edit.global.js +1 -1
  67. package/dist/ui-elements/kanban.global.js +1 -1
  68. package/dist/ui-elements/lead-popup.global.js +1 -1
  69. package/dist/ui-elements/lightbox.global.js +1 -1
  70. package/dist/ui-elements/markdown.global.js +3 -3
  71. package/dist/ui-elements/org-tree.global.js +1 -1
  72. package/dist/ui-elements/phone.global.js +2 -2
  73. package/dist/ui-elements/resizable.global.js +1 -1
  74. package/dist/ui-elements/saved-views.global.js +1 -1
  75. package/dist/ui-elements/select-chips.global.js +1 -1
  76. package/dist/ui-elements/select-recents.global.js +1 -0
  77. package/dist/ui-elements/select-search.global.js +1 -1
  78. package/dist/ui-elements/slider.global.js +1 -1
  79. package/dist/ui-elements/sortable.global.js +1 -1
  80. package/dist/ui-elements/status-icon.global.js +1 -1
  81. package/dist/ui-elements/timepicker.global.js +2 -2
  82. package/dist/ui-elements/tour.global.js +1 -1
  83. package/dist/ui-elements/tree.global.js +1 -1
  84. package/dist/ui-elements/wizard.global.js +1 -1
  85. package/dist/ui-elements.global.js +18 -18
  86. package/dist/ui-elements.js +1 -1
  87. package/dist/ui-tour.global.js +1 -1
  88. package/dist/wuiHttp-BuaTcumE.js +1 -0
  89. package/package.json +6 -6
  90. package/dist/WuiCommandPalette-Bk9UuXmZ.js +0 -2
  91. package/dist/WuiMarkdown-DmgLFkB-.js +0 -4
  92. package/dist/WuiNavigationMenu-CGqTADvr.js +0 -1
  93. package/dist/WuiNotificationCenter-CClYbyQ2.js +0 -1
  94. package/dist/WuiOverflow-Bn68qgAQ.js +0 -1
  95. package/dist/WuiSavedViews-CQSrMJUb.js +0 -1
  96. package/dist/WuiSelect-BEhh06ZD.js +0 -9
  97. package/dist/WuiShortcuts-Cerbe67I.js +0 -1
  98. package/dist/WuiWhatsNew-Biolggw8.js +0 -1
  99. package/dist/drawerDiscard-Cvwk_Yke.js +0 -1
  100. package/dist/filterPopover-DrwHiZiL.js +0 -1
  101. package/dist/loader-CVFmEPjv.js +0 -1
  102. package/dist/wuiHttp-DgnM7K2Q.js +0 -1
@@ -1,4 +1,4 @@
1
- import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{n as r,t as i}from"./countries-CvmZ2xpG.js";import{t as a}from"./elementBase-DV9IZZCu.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{t as c}from"./formMirror-BMQTenSi.js";import{t as l}from"./iconGlyphs.g-BlwTSNXS.js";import{n as u}from"./listboxKeyNav-DMIvs9d6.js";var d={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:/* @__PURE__ */ `America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:/* @__PURE__ */ `Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:/* @__PURE__ */ `America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},f=new Set(i.map(([e])=>e)),p=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(d))for(let n of t)p.set(n,e);function m(e){let t=p.get(e);return t&&f.has(t)?t:null}function h(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&f.has(t)?t:null}function g(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return m(e)||h(t)||null}function _(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>v(e,t.default||t))}function v(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var y=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,b=e=>e?`+${r(e)}`:``,x=null,S=null;function C(){return x?Promise.resolve(x):(S||=_().then(e=>(x=e,x)).catch(()=>null),S)}function w(e,t){let n=`+${r(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function T(e,t){if(!x||!t||!e)return t;try{return w(e,new x.AsYouType(e).input(`+${r(e)}${t}`))||t}catch{return t}}function E(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function D(e){if(!x||!e)return null;try{return w(e,x.getExampleNumber(e,x.examples)?.formatInternational())||null}catch{return null}}function O(e){let t=D(e);return t?`For example ${t}`:null}function k(e){if(!x||!e)return null;try{if(!x.isValidPhoneNumber(e))return!1;let t=x.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function A(e){if(!x||!e)return null;try{let t=x.getExampleNumber(e,x.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function j(e,t,n){try{let r=x.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function M(e){if(!x||!e?.trim().startsWith(`+`))return null;try{let t=new x.AsYouType;t.input(e.trim());let n=t.getCountry();return n?{country:n,national:t.getNationalNumber()||``}:null}catch{return null}}function N(e,t){let n=String(t??``).trim();if(!n.startsWith(`+`))return null;let i=n.replace(/[^0-9]/g,``),a=String(r(e));return{country:e,national:i.startsWith(a)?i.slice(a.length):i}}var P=class extends a{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=g()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${r(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim();this._locked&&(this._country=this._locked);let n=this._locked?null:M(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(r(this._locked||this.getAttribute(`country`)||this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){c(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||O(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?`<div class="phone-country-adornment"><span class="wui-phone-prefix"><span class="${y(this._country)}" data-flag aria-hidden="true"></span><span class="phone-dial" data-dial>${b(this._country)}</span></span></div>`:`<div class="phone-country-adornment">
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-DDrc2k6y.js";import{n as r,t as i}from"./countries-CvmZ2xpG.js";import{t as a}from"./elementBase-DV9IZZCu.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{t as c}from"./formMirror-BMQTenSi.js";import{t as l}from"./iconGlyphs.g-BlwTSNXS.js";import{n as u}from"./listboxKeyNav-DMIvs9d6.js";var d={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:/* @__PURE__ */ `America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:/* @__PURE__ */ `Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:/* @__PURE__ */ `America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},f=new Set(i.map(([e])=>e)),p=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(d))for(let n of t)p.set(n,e);function m(e){let t=p.get(e);return t&&f.has(t)?t:null}function h(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&f.has(t)?t:null}function g(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return m(e)||h(t)||null}function _(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>v(e,t.default||t))}function v(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var y=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,b=e=>e?`+${r(e)}`:``,x=null,S=null;function C(){return x?Promise.resolve(x):(S||=_().then(e=>(x=e,x)).catch(()=>null),S)}function w(e,t){let n=`+${r(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function T(e,t){if(!x||!t||!e)return t;try{return w(e,new x.AsYouType(e).input(`+${r(e)}${t}`))||t}catch{return t}}function E(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function D(e){if(!x||!e)return null;try{return w(e,x.getExampleNumber(e,x.examples)?.formatInternational())||null}catch{return null}}function O(e){let t=D(e);return t?`For example ${t}`:null}function k(e){if(!x||!e)return null;try{if(!x.isValidPhoneNumber(e))return!1;let t=x.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function A(e){if(!x||!e)return null;try{let t=x.getExampleNumber(e,x.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function j(e,t,n){try{let r=x.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function M(e){if(!x||!e?.trim().startsWith(`+`))return null;try{let t=new x.AsYouType;t.input(e.trim());let n=t.getCountry();return n?{country:n,national:t.getNationalNumber()||``}:null}catch{return null}}function N(e,t){let n=String(t??``).trim();if(!n.startsWith(`+`))return null;let i=n.replace(/[^0-9]/g,``),a=String(r(e));return{country:e,national:i.startsWith(a)?i.slice(a.length):i}}var P=class extends a{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=g()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${r(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim();this._locked&&(this._country=this._locked);let n=this._locked?null:M(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(r(this._locked||this.getAttribute(`country`)||this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){c(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||O(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?`<div class="phone-country-adornment"><span class="wui-phone-prefix"><span class="${y(this._country)}" data-flag aria-hidden="true"></span><span class="phone-dial" data-dial>${b(this._country)}</span></span></div>`:`<div class="phone-country-adornment">
2
2
  <button type="button" class="country-toggle" aria-label="Choose country" aria-haspopup="listbox" aria-expanded="false" aria-controls="${F(t)}"${this.hasAttribute(`disabled`)?` disabled`:``}>
3
3
  <span class="${y(this._country)}" data-flag aria-hidden="true"></span>
4
4
  ${l(`chevron-down`,{className:`phone-chevron`})}
@@ -13,4 +13,4 @@ import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{n as r,t as
13
13
  <div class="phone-input-wrap">
14
14
  ${n}
15
15
  <input type="tel" class="input" placeholder="${F(e)}" value="${F(T(this._country,this._national))}"${this.getAttribute(`aria-label`)?` aria-label="${F(this.getAttribute(`aria-label`))}"`:``}${this.getAttribute(`aria-describedby`)?` aria-describedby="${F(this.getAttribute(`aria-describedby`))}"`:``}${this.hasAttribute(`required`)?` required aria-required="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s(this)?` readonly`:``} />
16
- </div>`,this._rendered=!0,o(this,this.querySelector(`input.input`)),c(this,this.value),this._wire()}_ensureItems(){let e=this.querySelector(`.country-list-scroll`);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=i.map(([e,n,r],i)=>`<button type="button" role="option" id="${F(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${y(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)]}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let i=this.querySelector(`.country-toggle`),a=this.querySelector(`.phone-input-wrap`),o=this.querySelector(`.country-dropdown-menu`),c=this.querySelector(`.dropdown-search-input`),l=this.querySelector(`.country-list-scroll`),d=this.querySelector(`.country-empty`),f=this.querySelector(`input[type=tel]`),p=this.querySelector(`[data-flag]`),m=this.querySelector(`[data-dial]`),h=()=>!!o&&!o.hidden,g=()=>n(a||i,o),_=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),c?.setAttribute(`aria-activedescendant`,n[e].id)):c?.removeAttribute(`aria-activedescendant`)},v=()=>{h()&&g()},b=()=>{s(this)||(this._ensureItems(),o.hidden=!1,i.setAttribute(`aria-expanded`,`true`),c.value=``,S(``),g(),e(this,v),c.focus(),_(this._visibleItems().findIndex(e=>e.classList.contains(`selected`))))},x=()=>{o.hidden=!0,i.setAttribute(`aria-expanded`,`false`),_(-1),t(this)},S=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}d&&(d.hidden=n>0)},w=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),p&&(p.className=y(e)),m&&(m.textContent=`+${r(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}!this.getAttribute(`placeholder`)&&f&&(f.placeholder=O(e)||`Enter phone number`),f&&this._national&&(f.value=T(e,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&F(I()),f?.focus()},P=e=>{let t=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!h()){b();return}_(Math.min(this._active+1,t.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!h())return;_(Math.max(this._active-1,0))}else e.key===`Enter`?(e.preventDefault(),h()&&t[this._active]&&w(t[this._active].dataset.iso)):e.key===`Escape`&&h()&&(e.preventDefault(),e.stopPropagation(),x(),i.focus())};i?.addEventListener(`click`,()=>h()?x():b()),i?.addEventListener(`keydown`,e=>{h()?P(e):(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),b())}),c?.addEventListener(`input`,()=>{S(c.value);let e=this._visibleItems();_(e.length?0:-1)}),l?.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&w(t.dataset.iso)}),l?.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&!t.classList.contains(`is-active`)&&_(this._visibleItems().indexOf(t),{reveal:!1})}),l?.addEventListener(`mouseleave`,()=>_(-1)),o?.addEventListener(`keydown`,P);let F=e=>{f.classList.toggle(`is-invalid`,e),e?f.setAttribute(`aria-invalid`,`true`):f.removeAttribute(`aria-invalid`);let t=this.querySelector(`[data-phone-error]`);if(e&&!this.hasAttribute(`external-error`)){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),a.after(t));let e=D(this._country);t.textContent=this._country?e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`:`Choose a country`}else t?.remove();this._syncDescribedBy()},I=()=>this._national.length>0&&(!this._country||k(this.value)===!1);f.addEventListener(`input`,e=>{e.stopPropagation();let t=f.selectionStart??f.value.length,n=f.value.slice(0,t).replace(/[^0-9]/g,``).length,r=f.value.replace(/[^0-9]/g,``),i=A(this._country);if(i&&r.length>i){let e=j(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=T(this._country,this._national);if(f.value!==a){f.value=a;let e=E(a,Math.min(n,r.length));f.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&F(I())}),f.addEventListener(`change`,e=>e.stopPropagation()),f.addEventListener(`blur`,()=>{let e=I();F(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),f.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?N(this._locked,t):M(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?f.value=T(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&f.isConnected&&F(I()),this.querySelector(`input[type=tel]`)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{h()&&!this.contains(e.target)&&x()},document.addEventListener(`click`,this._onDocClick),h()&&e(this,v)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this)},this._bindGlobal(),this._validateOnInput&&F(I()),C().then(e=>{if(e&&f.isConnected&&(this._national&&(f.value=T(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=O(this._country);e&&(f.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}},F=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{P as t};
16
+ </div>`,this._rendered=!0,o(this,this.querySelector(`input.input`)),c(this,this.value),this._wire()}_ensureItems(){let e=this.querySelector(`.country-list-scroll`);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=i.map(([e,n,r],i)=>`<button type="button" role="option" id="${F(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${y(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)]}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let i=this.querySelector(`.country-toggle`),a=this.querySelector(`.phone-input-wrap`),o=this.querySelector(`.country-dropdown-menu`),c=this.querySelector(`.dropdown-search-input`),l=this.querySelector(`.country-list-scroll`),d=this.querySelector(`.country-empty`),f=this.querySelector(`input[type=tel]`),p=this.querySelector(`[data-flag]`),m=this.querySelector(`[data-dial]`),h=()=>!!o&&!o.hidden,g=()=>n(a||i,o),_=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),c?.setAttribute(`aria-activedescendant`,n[e].id)):c?.removeAttribute(`aria-activedescendant`)},v=()=>{h()&&g()},b=()=>{s(this)||(this._ensureItems(),o.hidden=!1,i.setAttribute(`aria-expanded`,`true`),c.value=``,S(``),g(),e(this,v),c.focus(),_(this._visibleItems().findIndex(e=>e.classList.contains(`selected`))))},x=()=>{o.hidden=!0,i.setAttribute(`aria-expanded`,`false`),_(-1),t(this)},S=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}d&&(d.hidden=n>0)},w=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),p&&(p.className=y(e)),m&&(m.textContent=`+${r(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}!this.getAttribute(`placeholder`)&&f&&(f.placeholder=O(e)||`Enter phone number`),f&&this._national&&(f.value=T(e,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&F(I()),f?.focus()},P=e=>{let t=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!h()){b();return}_(Math.min(this._active+1,t.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!h())return;_(Math.max(this._active-1,0))}else e.key===`Enter`?(e.preventDefault(),h()&&t[this._active]&&w(t[this._active].dataset.iso)):e.key===`Escape`&&h()&&(e.preventDefault(),e.stopPropagation(),x(),i.focus())};i?.addEventListener(`click`,()=>h()?x():b()),i?.addEventListener(`keydown`,e=>{h()?P(e):(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),b())}),c?.addEventListener(`input`,()=>{S(c.value);let e=this._visibleItems();_(e.length?0:-1)}),l?.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&w(t.dataset.iso)}),l?.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&!t.classList.contains(`is-active`)&&_(this._visibleItems().indexOf(t),{reveal:!1})}),l?.addEventListener(`mouseleave`,()=>_(-1)),o?.addEventListener(`keydown`,P);let F=e=>{f.classList.toggle(`is-invalid`,e),e?f.setAttribute(`aria-invalid`,`true`):f.removeAttribute(`aria-invalid`);let t=this.querySelector(`[data-phone-error]`);if(e&&!this.hasAttribute(`external-error`)){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),a.after(t));let e=D(this._country);t.textContent=this._country?e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`:`Choose a country`}else t?.remove();this._syncDescribedBy()},I=()=>this._national.length>0&&(!this._country||k(this.value)===!1);f.addEventListener(`input`,e=>{e.stopPropagation();let t=f.selectionStart??f.value.length,n=f.value.slice(0,t).replace(/[^0-9]/g,``).length,r=f.value.replace(/[^0-9]/g,``),i=A(this._country);if(i&&r.length>i){let e=j(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=T(this._country,this._national);if(f.value!==a){f.value=a;let e=E(a,Math.min(n,r.length));f.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&F(I())}),f.addEventListener(`change`,e=>e.stopPropagation()),f.addEventListener(`blur`,()=>{let e=I();F(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),f.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?N(this._locked,t):M(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?f.value=T(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&f.isConnected&&F(I()),this.querySelector(`input[type=tel]`)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{h()&&!e.composedPath().includes(this)&&x()},document.addEventListener(`click`,this._onDocClick),h()&&e(this,v)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this)},this._bindGlobal(),this._validateOnInput&&F(I()),C().then(e=>{if(e&&f.isConnected&&(this._national&&(f.value=T(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=O(this._country);e&&(f.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}},F=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{P as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./buttonClass-Yk0Fwgs6.js";import{t as n}from"./elementBase-DV9IZZCu.js";import{l as r}from"./wuiHttp-BuaTcumE.js";var i=`wui-saved-views:`,a=20,o=0,s=e=>typeof e?.name==`string`&&typeof e?.query==`string`,c=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}constructor(){super(),this._doc=null,this._views=[],this._open=!1,this._busy=!1,this._error=null,this._trigger=null,this._menu=null,this._divider=null,this._form=null,this._input=null,this._save=null,this._shareRow=null,this._share=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&this.contains(e.target)&&(e.key===`Escape`?(e.stopPropagation(),this._setOpen(!1),this._trigger.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._menu.contains(e.target)&&!/input|textarea/i.test(e.target.tagName)&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._doc.location.search};this._canShare()&&(e.shared=String(this._share.checked)),await this._request(`save`,e)&&(this._input.value=``,this._share.checked=!1);return}let n=this._doc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,a)),this._input.value=``}}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`),i=this.getAttribute(`key`),o=n,c;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:i}):c={method:`POST`,body:new URLSearchParams({intent:e,key:i,...t})},this._busy=!0,this._render();let l=await r(o,c);if(this._busy=!1,this._doc===null)return!1;if(l.ok){let e=new DOMParser().parseFromString(l.html,`text/html`);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(s).slice(0,a),this._error=null,this._render(),!0}return this._error=l.message||`The views could not be updated. Try again.`,this._render(),!1}_build(){let n=this._doc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=`Views`,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick),this._menu=n.createElement(`div`),this._menu.className=`dropdown-menu`,this._divider=n.createElement(`div`),this._divider.className=`dropdown-divider`,this._input=n.createElement(`input`),this._input.type=`text`,this._input.className=`form-control form-control-sm`,this._input.setAttribute(`aria-label`,`View name`),this._input.placeholder=`Name this view`;let r=n.createElement(`button`);r.type=`submit`,r.className=e(`primary`,`solid`,`sm`),r.dataset.wui=t,r.textContent=`Save this view`,this._save=r,this._form=n.createElement(`form`),this._form.className=`d-flex gap-2 px-3 py-2`,this._form.append(this._input,r),this._form.addEventListener(`submit`,this._onSubmit),this._share=n.createElement(`input`),this._share.type=`checkbox`,this._share.className=`form-check-input`,this._share.setAttribute(`role`,`switch`),this._share.id=`wui-saved-views-share-${o++}`;let i=n.createElement(`label`);i.className=`form-check-label`,i.htmlFor=this._share.id,i.textContent=`Share with the team`;let a=n.createElement(`div`);a.className=`form-check form-switch mb-0`,a.append(this._share,i),this._shareRow=n.createElement(`div`),this._shareRow.className=`px-3 pb-2`,this._shareRow.hidden=!0,this._shareRow.append(a),this.append(this._trigger,this._menu)}_render(){let e=this._doc,t=[];for(let n of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+n.query),r.textContent=n.name,n.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=`Shared`,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=`Delete`,i.setAttribute(`aria-label`,`Delete ${n.name}`),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:n.name}):this._commit(this._views.filter(e=>e.name!==n.name))),t.push(r,i)}if(this._error){let n=e.createElement(`div`);n.className=`dropdown-item-text text-danger small`,n.setAttribute(`role`,`alert`),n.textContent=this._error,t.push(n)}this._save.disabled=this._busy,this._share.disabled=this._busy,this._shareRow.hidden=!this._canShare(),this._menu.replaceChildren(...t,this._divider,this._form,this._shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._menu.classList.toggle(`show`,e),this._trigger.setAttribute(`aria-expanded`,String(e)),e?this._doc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._doc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{return{store:this._doc.defaultView.localStorage,key:i+e}}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(s).slice(0,a):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch{}}};export{c as t};
@@ -0,0 +1,9 @@
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-DDrc2k6y.js";import{i as r,n as i,r as a,t as o}from"./optionLabel-CLemms21.js";import{n as s}from"./devWarn-DXdRWZs3.js";import{t as c}from"./elementBase-DV9IZZCu.js";import{r as l,t as u}from"./fieldState-D-zQcXUS.js";import{n as d,t as f}from"./formMirror-BMQTenSi.js";import{n as p}from"./loader-Dw3IkGM0.js";import{t as m}from"./iconGlyphs.g-BlwTSNXS.js";import{n as h,t as g}from"./listboxKeyNav-DMIvs9d6.js";var _=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},v=(e,t=`wui-opt-avatar`)=>{let n=_(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${i(e.initials??``)}</span>${n?`<img class="avatar-img" src="${y(n)}" alt="" />`:``}</span>`},y=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);function b(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[r(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var x=/* @__PURE__ */ new WeakMap;function S(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=`No matches`,searchingText:c=`Searching…`,hintText:l=`Type to search…`,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=b(t,a),m=e.id,h=0,g=()=>`${m}-opt-${h++}`,_=e=>`<button type="button" role="option" id="${i(g())}" class="wui-select-option wui-select-add" data-value="${i(e.value)}" data-custom="true" aria-selected="false">${i(e.label)}</button>`,v=u.filter(e=>e.position===`top`).map(_).join(``),y=d?.options.length?`<div class="wui-select-group">${i(d.label)}</div>${d.options.map(e=>C(e,g(),f.has(String(e.value)))).join(``)}<div class="wui-select-sep" aria-hidden="true"></div>`:``,S=``,w=``;for(let e of p)e.group&&e.group!==S&&(w+=`<div class="wui-select-group">${i(e.group)}</div>`),S=e.group??``,w+=C(e,g(),f.has(String(e.value)));let T=u.filter(e=>e.position===`bottom`).map(_).join(``),E=``;o===`loading`?E=`<div class="wui-select-loading"><span class="wui-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>${i(c)}</div>`:o===`hint`?E=`<div class="wui-select-hint">${i(l)}</div>`:(o===`empty`||p.length===0&&u.length===0)&&(E=`<div class="wui-select-empty">${i(s)}</div>`);let D=v+y+w+T+E;x.get(e)!==D&&(x.set(e,D),e.innerHTML=D)}function C(e,t,n){let r=!!e.disabled,o=r&&e.disabledHint?` title="${i(e.disabledHint)}"`:``,s=`id="${i(t)}" role="option" data-value="${i(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}${o}`,c=`<span class="wui-select-check" aria-hidden="true">${m(`check`)}</span>`;if(!e.description&&!e.meta)return`<button type="button" class="wui-select-option${n?` selected`:``}" ${s}>${v(e)}<span class="wui-select-opt-name">${a(e)}</span>${c}</button>`;let l=e.description?`<span class="wui-select-opt-desc">${i(e.description)}</span>`:``,u=e.meta?`<span class="wui-select-opt-meta">${i(e.meta)}</span>`:``;return`<div class="wui-select-option wui-select-option-rich${n?` selected`:``}" ${s}>${v(e)}<span class="wui-select-option-text"><span class="wui-opt-label">${a(e)}</span>${l}</span>${u}${c}</div>`}var w=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),T=e=>e===`multiple`||e===`tag`,E={recents:()=>import(`./recents-BzN7j9kV.js`),chips:()=>import(`./chips-DbhCYoAp.js`),search:()=>import(`./search-CdAH8NGK.js`),country:()=>import(`./country-3uo7no9r.js`)};function D(e){return Object.hasOwn(E,e)?E[e]():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var O=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),k=class extends c{static formAssociated=!0;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._defaultValue=void 0,this._warnedMode=null,this._reposition=()=>{this._menuOpen()&&this._place()}}connectedCallback(){this._rendered?this._bindGlobal():this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=F(n,T(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):(e===`mode`&&(this._value=F(this._value,T(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),N.has(e)?this._rendered&&(this._drawValue(),this.renderList()):M.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null||w.includes(e)?e??`single`:(e!==this._warnedMode&&(this._warnedMode=e,s(`<wui-select> mode "${e}" is not one of ${w.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||A.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,s(`<wui-select> density "${e}" is not one of ${A.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=F(e,T(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();this._rendered&&(this._drawValue(),this.renderList())}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){u(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();e.list&&(S(e.list,this._listOptions(),{selected:this._selectedValues(),query:this._ownsFilter?``:this._query,status:this._status,emptyText:this.getAttribute(`empty-text`)||`No matches`,searchingText:this.getAttribute(`searching-text`)||`Searching…`,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:this._actionRows(),recents:this._recents()}),this._active>=this._visible().length&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._menuOpen()&&this._place())}render(){let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=T(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=F(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=F(this._value,n));let o=this.getAttribute(`size`),s=o===`sm`?` wui-select-sm`:o===`lg`?` wui-select-lg`:``,c=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),d=this.hasAttribute(`clearable`),f=this.hasAttribute(`disabled`);this.id||=`wui-select-${Math.random().toString(36).slice(2,9)}`;let p=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||this._error?` aria-invalid="true"`:``,y=this.hasAttribute(`required`)&&!a?` aria-required="true"`:``,b=` aria-label="${i(this._accessibleName())}" aria-describedby="${i(_)}"${v}${y}`,x=a?``:` role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${i(p)}"`,S=n?`<div class="input wui-select-control wui-select-multi"${x}${b}${f?` aria-disabled="true"`:r?``:` tabindex="0"`}>`:`<button type="button" class="input wui-select-control"${x}${b}${f?` disabled`:``}>`,C=`${c?m(c,{className:`wui-select-icon`}):``}${u?`<span class="wui-select-prefix">${i(u)}</span>`:``}<span class="wui-select-value" data-label></span>${d?`<span class="wui-select-reset" role="button" aria-label="Clear selection" hidden>${m(`x`)}</span>`:``}${m(`chevron-down`,{className:`wui-select-caret`})}`,w=this.getAttribute(`searchable`),E=t===`search`||(w===null?t===`multiple`||t===`country`:w!==`false`)&&!a,D=this.getAttribute(`search-placeholder`)||(t===`country`?`Search countries…`:`Search…`),O=E?`<div class="wui-select-search">${m(`search`)}<input class="wui-select-input" placeholder="${i(D)}" aria-label="${i(D)}" aria-autocomplete="list" /><button type="button" class="wui-select-clear" aria-label="Clear search" hidden>${m(`x`)}</button></div>`:``;this.innerHTML=`
2
+ <div class="wui-select${s}">
3
+ ${S}${C}${n?`</div>`:`</button>`}
4
+ <div class="wui-select-menu wui-select-menu-fixed" hidden>
5
+ ${O}
6
+ <div class="wui-select-options" role="listbox" id="${i(p)}" tabindex="-1"${n?` aria-multiselectable="true"`:``}></div>
7
+ </div>
8
+ </div>
9
+ <div class="field-error wui-select-error" id="${i(h)}" aria-live="polite"${this._error?``:` hidden`}>${i(this._error)}</div>`,this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),l(this,this.querySelector(`.wui-select-control`)),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,[o]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of P){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>e.selected);t&&(this._value=String(t.value))}_optionFor(e){if(e===``)return;let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||j[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._hasValue()?[this._value]:[]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){T(this.mode)?d(this,this._value):f(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=T(this.mode),n=t?void 0:this._optionFor(this._value);this._syncTitle(n),this._syncValueAvatar(),this._partsMounted&&this._parts.some(e=>e.renderValue?.()===!0)||(t?(e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``):(e.value.classList.toggle(`wui-select-placeholder`,!n),e.value.innerHTML=n?a(n):i(this._placeholder())))}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?r(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let t=!T(this.mode)&&this._hasValue()?v({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):``;e.classList.toggle(`wui-has-value-avatar`,!!t),t&&e.insertAdjacentHTML(`afterbegin`,`<span class="wui-select-value-avatar" aria-hidden="true">${t}</span>`)}_syncValidity(){let e=this._internals;typeof e?.setValidity==`function`&&(this.hasAttribute(`required`)&&!this._hasValue()?e.setValidity({valueMissing:!0},`Please fill in this field.`,this.querySelector(`.wui-select-control`)):e.setValidity({}))}_syncReset(){let e=this.querySelector(`.wui-select-reset`);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!u(this)))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=this.querySelector(`.wui-select-error`);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:this.querySelector(`.wui-select-control`),value:this.querySelector(`.wui-select-value`),menu:this.querySelector(`.wui-select-menu`),list:this.querySelector(`.wui-select-options`),search:this.querySelector(`.wui-select-search input`),input:this.querySelector(`.wui-select-draft`)}}_menuOpen(){let e=this.querySelector(`.wui-select-menu`);return!!e&&!e.hidden}_visible(){let e=this._refs();return e.list?[...e.list.querySelectorAll(`.wui-select-option`)]:[]}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;let r=this._visible();this._active=e;let i=e>=0?r[e]??null:null;h(n.list,i),i?(t&&i.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,i.id)):n.control.removeAttribute(`aria-activedescendant`)}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_place(){let e=this._refs();if(!e.control||!e.menu)return;let t=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)===`compact`){let r=e.control.getBoundingClientRect();e.menu.style.width=`max-content`,e.menu.style.minWidth=`${r.width}px`,e.menu.style.maxWidth=`280px`,n(e.control,e.menu,t)}else n(e.control,e.menu,{matchWidth:!0,...t})}_open({focus:t=!0}={}){let n=this._refs();if(!n.menu||!n.control)return;let r=!n.menu.hidden;n.menu.hidden=!1,n.control.setAttribute(`aria-expanded`,`true`),n.control.classList.add(`open`),this._query=n.input?n.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let i=this.querySelector(`.wui-select-search .wui-select-clear`);if(i&&(i.hidden=!0),n.search&&(n.search.value=``),this.renderList(),e(this,this._reposition),t&&(n.search?.focus(),this._setActive(this._visible().findIndex(e=>e.classList.contains(`selected`)))),!r){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let n=this._refs();if(!n.menu||!n.control)return;let r=!n.menu.hidden;n.menu.hidden=!0,n.control.setAttribute(`aria-expanded`,`false`),n.control.classList.remove(`open`),this._setActive(-1),this._nav?.clearTypeahead(),t(this),r&&this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0}))}_onQueryChange(e){this._query=e,this._setActive(-1);let t=this.querySelector(`.wui-select-search .wui-select-clear`);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:e.textContent.trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);T(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&O(this)}_onKeyDown(e){if(!u(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),this._nav.handler(e)}}_wire(){this._teardown();let t=this._refs();if(!t.control||!t.menu||!t.list)return;let n=this.querySelector(`.wui-select`),r=this.querySelector(`.wui-select-search .wui-select-clear`),i=this.querySelector(`.wui-select-reset`);this._nav=g({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);e?this._pick(e):t.length===1&&this._pick(t[0])}},onEscape:()=>{this._nav.clearTypeahead(),this._close(),t.control.focus()}}),n.addEventListener(`keydown`,e=>this._onKeyDown(e)),n.addEventListener(`input`,e=>{if(!e.target.matches?.(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(e.target.value);let t=e.target.matches(`.wui-select-draft`),n=this._visible().length>0||this._actionRows().length>0;t&&n&&!this._menuOpen()&&!u(this)&&this._draftOpens()&&this._open({focus:!1})}),n.addEventListener(`focusout`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&e.relatedTarget&&this._close()}),r?.addEventListener(`click`,()=>{t.search.value=``,this._onQueryChange(``),t.search.focus()}),t.control.addEventListener(`click`,e=>{if(!e.target.closest?.(`[data-remove]`)){if(this.mode===`tag`){if(u(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1})}else e.target instanceof HTMLInputElement?!this._menuOpen()&&!u(this)&&this._open({focus:!1}):this._menuOpen()?this._close():u(this)||this._open({focus:!0})}}),i?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(T(this.mode)?[]:``),this._close(),t.control.focus()}),t.list.addEventListener(`click`,e=>{let n=e.target.closest(`.wui-select-option`);n&&(this._pick(n),T(this.mode)&&(t.search??this.querySelector(`.wui-select-draft`)??t.control).focus())}),t.list.addEventListener(`mousedown`,e=>{T(this.mode)&&e.target.closest?.(`.wui-select-option`)&&e.preventDefault()}),t.list.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.wui-select-option`);t&&!t.classList.contains(`is-active`)&&this._setActive(this._visible().indexOf(t),{reveal:!1})}),t.list.addEventListener(`mouseleave`,()=>this._setActive(-1)),t.list.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{this._menuOpen()&&!e.composedPath().includes(this)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._menuOpen()&&e(this,this._reposition)},this.hasAttribute(`open`)&&this._open({focus:!1}),this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this),this._nav?.teardown()}_activePartsList(){return this._partsMounted?this._parts:[]}_ensureParts(){if(!this.isConnected)return;let e=L(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>z(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(Boolean),this._mountParts())})}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=this._refs();for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){if(this._partsMounted){this._partsMounted=!1;for(let e of this._parts)e.teardown()}}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},A=[`comfortable`,`compact`],j={single:`Select…`,search:`Select…`,multiple:`Select…`,tag:`Add…`,country:`Select country`},M=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),N=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),P=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],F=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),I=(e,t)=>t===`multiple`?[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?O(e)?[`chips`,`search`]:[`chips`]:[],L=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...I(e,t)]:I(e,t),R=`This control could not load. Reload the page.`,z=(e,t)=>D(t).then(e=>e.default()).catch(()=>(document.dispatchEvent(new CustomEvent(p,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(R),null));export{O as n,b as r,k as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{a as t,c as n,d as r,f as i,l as a,m as o,p as s,u as c}from"./shortcutKeys-CvxSh3bV.js";var l=`wui-shortcuts-open-change`,u=class extends e{static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),this._doc=null,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let t=(e.target instanceof Element?e.target.closest(`[data-wui-shortcuts-open]`):null)?.getAttribute(`data-wui-shortcuts-open`);t&&this.matches(t)?this.setOpen(!0):this.open&&!e.composedPath().includes(this)&&this.setOpen(!1,{focus:!1})}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this.addEventListener(`click`,this._onClick),this.hasAttribute(`open`)&&!this.open&&this.setOpen(!0,{focus:!1}),this._place(),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null)}disconnectedCallback(){this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this.removeEventListener(`click`,this._onClick),this._doc=null}get open(){let e=this._sheet();return!(!e||e.hidden)}set open(e){let t=e===!0||e===``||e===`true`;this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(e,{focus:t=!0}={}){let n=this._sheet();if(!n)return;let r=n.hidden===e;n.hidden=!e,this.toggleAttribute(`open`,e),e&&this._place();let i=this.querySelector(`.wui-shortcut-toggle`);i?.setAttribute(`aria-expanded`,String(e)),r&&this.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:{open:e}})),t&&(e?n.querySelector(`.wui-shortcut-close`)?.focus():i?.focus())}_sheet(){return this.querySelector(`.wui-shortcut-sheet`)}_syncTrigger(){let e=this.querySelector(`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_place(){let e=this._sheet();if(!e||e.hidden)return;e.classList.remove(`wui-shortcut-sheet-below`,`wui-shortcut-sheet-start`);let t=this.ownerDocument.defaultView,n={top:0,left:0,right:t.innerWidth,bottom:t.innerHeight};for(let e=this.parentElement;e&&e!==this.ownerDocument.documentElement;e=e.parentElement){let r=t.getComputedStyle(e);if(r.overflowX===`visible`&&r.overflowY===`visible`)continue;let i=e.getBoundingClientRect();n.top=Math.max(n.top,i.top),n.left=Math.max(n.left,i.left),n.right=Math.min(n.right,i.right),n.bottom=Math.min(n.bottom,i.bottom)}let r=e.getBoundingClientRect();r.top<n.top&&e.classList.add(`wui-shortcut-sheet-below`),r.left<n.left&&e.classList.add(`wui-shortcut-sheet-start`)}_scope(){return this.closest(`[${t}]`)}_items(){let e=this.getAttribute(`items`);return e?[...(this._scope()??this._doc).querySelectorAll(e)]:[]}_click(e){let t=e.target;t instanceof Element&&(t.closest(`.wui-shortcut-toggle`)?this.setOpen(!this.open):t.closest(`.wui-shortcut-close`)&&this.setOpen(!1))}_tickFocused(){let e=this._items(),t=this._doc.activeElement,n=t?.closest?.(`li, tr`),r=e.find(e=>e===t||e.contains(t)||n?.contains(e));(r?.closest(`li, tr`)??r)?.querySelector(`input[type="checkbox"]`)?.click()}_focusSearch(){let e=this.getAttribute(`search`);((this._scope()??this._doc).querySelector(e)??this._doc.querySelector(e))?.focus()}_keydown(e){if(e.defaultPrevented)return;let t=s(e);if(!t)return;if(t===`esc`&&this.open){e.preventDefault(),this.setOpen(!1);return}let l=this._scope(),u={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(u.j=()=>c(this._items(),1),u.k=()=>c(this._items(),-1),u.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(u.slash=()=>this._focusSearch()),u[t]){r(e,u,l);return}if(t===`enter`||o(this._doc)||!n(e.target,l)||a(e.target))return;let d=i(t),f=[...this.querySelectorAll(`.wui-shortcut-keys [data-shortcut]`)].find(e=>e.dataset.shortcut===d);if(!f)return;let p=(l??this._doc).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`)?.dataset.key??null;if(!this.dispatchEvent(new CustomEvent(`wui:shortcut`,{bubbles:!0,cancelable:!0,detail:{key:d,itemKey:p}}))){e.preventDefault();return}let m=f.dataset.target?this._doc.querySelector(f.dataset.target):null;m&&(e.preventDefault(),m.click())}};export{u as t};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{r as i,t as a}from"./fieldState-D-zQcXUS.js";import{t as o}from"./formMirror-BMQTenSi.js";import{t as s}from"./iconGlyphs.g-BlwTSNXS.js";var c=e=>String(e).padStart(2,`0`),l=(e,t)=>`${c(e)}:${c(t)}`,u=e=>{let t=/^(\d{2}):(\d{2})$/.exec(e||``);return t?{h:+t[1],m:+t[2]}:null},d=(e,t=`24`)=>{if(!e)return``;if(t===`24`)return l(e.h,e.m);let n=e.h%12||12,r=e.h>=12?`PM`:`AM`;return`${n}:${c(e.m)} ${r}`},f=e=>{let t=String(e||``).trim().toLowerCase(),n=/^(\d{1,2})(?:[:.](\d{2})|(\d{2}))?\s*(?:([ap])\.?\s*(?:m\.?)?)?$/.exec(t);if(!n)return null;let r=+n[1],i=+(n[2]??n[3]??`0`);if(i>59)return null;if(n[4]){if(r<1||r>12)return null;r=r%12+(n[4]===`p`?12:0)}else if(r>23)return null;return{h:r,m:i}},p=0,m=class extends r{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`step`,`format`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._uid=`wui-tp-${++p}`,this._typedError=``,this._typeahead=``,this._typeaheadTimer=null,this.addEventListener(`focusout`,e=>{this._isOpen?.()&&e.relatedTarget&&!this.contains(e.relatedTarget)&&this._close({commit:!0})})}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(this._rendered)switch(e){case`value`:this._value=n||``,this._typedError=``,this._syncFormValue(),this._syncText(),this._syncInvalid();return;case`aria-invalid`:case`aria-describedby`:this._syncInvalid();return;case`aria-label`:case`placeholder`:case`disabled`:case`readonly`:case`loading`:case`required`:this._syncAttrs();return;default:this.render()}}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,this._typedError=``,o(this,this._value),this._syncText(),this._syncInvalid()}_format(){return this.getAttribute(`format`)||`24`}_step(){return Math.max(1,parseInt(this.getAttribute(`step`)||`30`,10)||30)}_bounds(){let e=u(this.getAttribute(`min`))||{h:0,m:0},t=u(this.getAttribute(`max`))||{h:23,m:59};return{min:e.h*60+e.m,max:t.h*60+t.m}}_allowed(e,t){let n=e*60+t,{min:r,max:i}=this._bounds();return n>=r&&n<=i&&n%this._step()===0}_times(){let e=[];for(let t=0;t<1440;t+=this._step()){let n=Math.floor(t/60),r=t%60;this._allowed(n,r)&&e.push({h:n,m:r})}return e}_refusal(e){if(this._allowed(e.h,e.m))return``;let t=this._format(),{min:n,max:r}=this._bounds(),i=e.h*60+e.m,a=e=>d({h:Math.floor(e/60),m:e%60},t);if(i<n||i>r){let e=!!u(this.getAttribute(`min`)),t=!!u(this.getAttribute(`max`));return e&&t?`Enter a time between ${a(n)} and ${a(r)}.`:e?`Enter a time at or after ${a(n)}.`:`Enter a time at or before ${a(r)}.`}return`Enter a time in ${this._step()}-minute steps.`}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value),this._isOpen=null;let e=this.getAttribute(`size`),t=e===`sm`?` input-sm`:e===`lg`?` input-lg`:``,n=this._uid;this.innerHTML=`
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-DDrc2k6y.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{r as i,t as a}from"./fieldState-D-zQcXUS.js";import{t as o}from"./formMirror-BMQTenSi.js";import{t as s}from"./iconGlyphs.g-BlwTSNXS.js";var c=e=>String(e).padStart(2,`0`),l=(e,t)=>`${c(e)}:${c(t)}`,u=e=>{let t=/^(\d{2}):(\d{2})$/.exec(e||``);return t?{h:+t[1],m:+t[2]}:null},d=(e,t=`24`)=>{if(!e)return``;if(t===`24`)return l(e.h,e.m);let n=e.h%12||12,r=e.h>=12?`PM`:`AM`;return`${n}:${c(e.m)} ${r}`},f=e=>{let t=String(e||``).trim().toLowerCase(),n=/^(\d{1,2})(?:[:.](\d{2})|(\d{2}))?\s*(?:([ap])\.?\s*(?:m\.?)?)?$/.exec(t);if(!n)return null;let r=+n[1],i=+(n[2]??n[3]??`0`);if(i>59)return null;if(n[4]){if(r<1||r>12)return null;r=r%12+(n[4]===`p`?12:0)}else if(r>23)return null;return{h:r,m:i}},p=0,m=class extends r{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`step`,`format`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._uid=`wui-tp-${++p}`,this._typedError=``,this._typeahead=``,this._typeaheadTimer=null,this.addEventListener(`focusout`,e=>{this._isOpen?.()&&e.relatedTarget&&!this.contains(e.relatedTarget)&&this._close({commit:!0})})}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(this._rendered)switch(e){case`value`:this._value=n||``,this._typedError=``,this._syncFormValue(),this._syncText(),this._syncInvalid();return;case`aria-invalid`:case`aria-describedby`:this._syncInvalid();return;case`aria-label`:case`placeholder`:case`disabled`:case`readonly`:case`loading`:case`required`:this._syncAttrs();return;default:this.render()}}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,this._typedError=``,o(this,this._value),this._syncText(),this._syncInvalid()}_format(){return this.getAttribute(`format`)||`24`}_step(){return Math.max(1,parseInt(this.getAttribute(`step`)||`30`,10)||30)}_bounds(){let e=u(this.getAttribute(`min`))||{h:0,m:0},t=u(this.getAttribute(`max`))||{h:23,m:59};return{min:e.h*60+e.m,max:t.h*60+t.m}}_allowed(e,t){let n=e*60+t,{min:r,max:i}=this._bounds();return n>=r&&n<=i&&n%this._step()===0}_times(){let e=[];for(let t=0;t<1440;t+=this._step()){let n=Math.floor(t/60),r=t%60;this._allowed(n,r)&&e.push({h:n,m:r})}return e}_refusal(e){if(this._allowed(e.h,e.m))return``;let t=this._format(),{min:n,max:r}=this._bounds(),i=e.h*60+e.m,a=e=>d({h:Math.floor(e/60),m:e%60},t);if(i<n||i>r){let e=!!u(this.getAttribute(`min`)),t=!!u(this.getAttribute(`max`));return e&&t?`Enter a time between ${a(n)} and ${a(r)}.`:e?`Enter a time at or after ${a(n)}.`:`Enter a time at or before ${a(r)}.`}return`Enter a time in ${this._step()}-minute steps.`}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value),this._isOpen=null;let e=this.getAttribute(`size`),t=e===`sm`?` input-sm`:e===`lg`?` input-lg`:``,n=this._uid;this.innerHTML=`
2
2
  <div class="timepicker">
3
3
  <div class="wui-timepicker-field">
4
4
  <input type="text" class="input timepicker-trigger${t}" id="${n}-input" role="combobox" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop" aria-autocomplete="none" autocomplete="off" spellcheck="false">
@@ -6,4 +6,4 @@ import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{t as r}from
6
6
  </div>
7
7
  <div class="timepicker-pop" id="${n}-pop" role="dialog" aria-label="Choose time" hidden></div>
8
8
  <div class="field-error wui-timepicker-error" id="${n}-error" hidden></div>
9
- </div>`,this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),o(this,this._value),this._wire()}_input(){return this.querySelector(`.timepicker-trigger`)}_pop(){return this.querySelector(`.timepicker-pop`)}_syncFormValue(){o(this,this._value)}_syncAttrs(){let e=this._input(),t=this.querySelector(`.wui-timepicker-toggle`);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,e.readOnly=a(this),t&&(t.disabled=n),i(this,e),e.placeholder=this.getAttribute(`placeholder`)||`Select time`,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let r=this.getAttribute(`aria-label`);r?e.setAttribute(`aria-label`,r):e.removeAttribute(`aria-label`),o(this,this._value),a(this)&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=d(u(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=this.querySelector(`.wui-timepicker-error`);if(!e||!t)return;let n=this._typedError;t.textContent=n,t.hidden=!n,this.hasAttribute(`aria-invalid`)||n?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`);let r=[this.getAttribute(`aria-describedby`),n?t.id:null].filter(Boolean).join(` `);r?e.setAttribute(`aria-describedby`,r):e.removeAttribute(`aria-describedby`),e.setCustomValidity?.(n)}_commitText(){let e=this._input();if(!e||e.value===d(u(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=f(t),r=e?this._refusal(e):`Enter a time like ${this._format()===`12`?`7:45 PM`:`19:45`}.`;if(r)return this._typedError=r,this._syncInvalid(),!1;n=l(e.h,e.m)}let r=n!==this._value;return this.value=n,r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),!0}_pending(){let e=f(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsHtml(){let e=this._format(),t=this._times(),n=(e,t,n)=>`<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map(e=>`<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join(``)}</div>`,r=[...new Set(t.map(e=>e.h))],i=[...new Set(t.map(e=>e.m))].sort((e,t)=>e-t),a;if(e===`12`){let e=[...new Set(r.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(r.map(e=>e>=12?`pm`:`am`))].sort();a=n(`hour`,`Hour`,e.map(e=>({v:e,text:String(e||12)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:c(e)})))+n(`period`,`AM or PM`,t.map(e=>({v:e,text:e.toUpperCase()})))}else a=n(`hour`,`Hour`,r.map(e=>({v:e,text:c(e)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:c(e)})));return`<div class="wui-timepicker-cols">${a}</div>`}_selectedIn(e,t){return t?e===`minute`?String(t.m):e===`period`?t.h>=12?`pm`:`am`:String(this._format()===`12`?t.h%12:t.h):null}_optionEnabled(e,t,n){if(!n)return!0;let r=this._format()===`12`,i=n.h>=12,a=e=>r?[e+(i?12:0)]:[e],o=Array.from({length:60},(e,t)=>t);if(e===`hour`)return a(+t).some(e=>o.some(t=>this._allowed(e,t)));if(e===`minute`)return this._allowed(n.h,+t);let s=t===`pm`?12:0;return Array.from({length:12},(e,t)=>s+t).some(e=>o.some(t=>this._allowed(e,t)))}_syncColumns({scroll:e=!1}={}){let t=this._pop();if(!t)return;let n=this._pending();for(let r of t.querySelectorAll(`.wui-timepicker-col`)){let t=r.dataset.col,i=this._selectedIn(t,n),a=[...r.querySelectorAll(`.timepicker-option`)],o=null;for(let e of a){let r=e.dataset.v===i;e.classList.toggle(`is-selected`,r),e.setAttribute(`aria-selected`,r?`true`:`false`),e.disabled=!r&&!this._optionEnabled(t,e.dataset.v,n),r&&(o=e)}o=o||a.find(e=>!e.disabled)||null;for(let e of a)e.tabIndex=e===o?0:-1;e&&o&&(r.scrollTop=o.offsetTop-(r.clientHeight-o.offsetHeight)/2)}}_pick(e,t){let n=this._times();if(!n.length)return;let r=this._pending()||n[0],i=this._format()===`12`,a=r.h,o=r.m;if(e===`minute`?o=+t:a=e===`period`?a%12+(t===`pm`?12:0):i?+t+(r.h>=12?12:0):+t,!this._allowed(a,o)){let t=a*60+o,r=n.filter(t=>e===`minute`?t.m===o:e===`period`?t.h>=12==a>=12:i?t.h%12==a%12&&t.h>=12==a>=12:t.h===a).sort((e,n)=>Math.abs(e.h*60+e.m-t)-Math.abs(n.h*60+n.m-t))[0];if(!r)return;a=r.h,o=r.m}let s=this._input();s.value=d({h:a,m:o},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns()}_position(){n(this.querySelector(`.wui-timepicker-field`),this._pop())}_onColumnKey(e){let t=e.target.closest?.(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);if(!t||!n)return;let r=[...n.querySelectorAll(`.timepicker-option`)].filter(e=>!e.disabled),i=r.indexOf(t),a=[...this._pop().querySelectorAll(`.wui-timepicker-col`)],o=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(n.querySelector(`.timepicker-option.is-selected`)||e).focus())};switch(e.key){case`ArrowDown`:e.preventDefault(),o(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),o(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),o(r[0]);return;case`End`:e.preventDefault(),o(r[r.length-1]);return;case`PageDown`:e.preventDefault(),o(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),o(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:e.preventDefault(),a[a.indexOf(n)+(e.key===`ArrowRight`?1:-1)]?.querySelector(`.timepicker-option[tabindex="0"]`)?.focus();return;case`Enter`:e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),o(t);return;case`Escape`:e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0});return;default:e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=setTimeout(()=>{this._typeahead=``,this._typeaheadTimer=null},500),o(r.find(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let n=this._input(),r=this.querySelector(`.wui-timepicker-toggle`),i=this._pop(),o=this.querySelector(`.timepicker`);if(!n||!i)return;let s=()=>!i.hidden;this._isOpen=s;let c=()=>{s()&&this._position()},l=()=>i.querySelector(`.wui-timepicker-col .timepicker-option[tabindex="0"]`)?.focus();this._open=({focus:t=!1}={})=>{a(this)||(s()||(i.innerHTML=this._columnsHtml(),i.hidden=!1,o?.classList.add(`open`),n.setAttribute(`aria-expanded`,`true`),r?.setAttribute(`aria-expanded`,`true`),this._position(),e(this,c),this._syncColumns({scroll:!0})),t&&l())},this._close=({commit:e=!0,refocus:a=!1}={})=>{if(!s())return;let c=i.contains(document.activeElement);i.hidden=!0,i.innerHTML=``,o?.classList.remove(`open`),n.setAttribute(`aria-expanded`,`false`),r?.setAttribute(`aria-expanded`,`false`),t(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,e?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(a||c)&&n.focus()},n.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),n.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!s()&&this._open(),this._lastPointer=null}),r?.addEventListener(`click`,()=>{s()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),n.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(e.key===`Enter`){let t=s(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&s()?(e.preventDefault(),e.stopPropagation(),this._close({commit:!1})):e.key===`Tab`&&s()&&this._close({commit:!0})}),n.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),s()&&this._syncColumns({scroll:!0})}),n.addEventListener(`change`,e=>{e.stopPropagation(),s()||this._commitText()}),i.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),i.addEventListener(`keydown`,e=>{s()&&this._onColumnKey(e)}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,s()&&!t&&!this.contains(e.target)&&this._close({commit:!0})},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{s()&&e.key===`Escape`&&this._close({commit:!1})},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{s()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0}))},this.addEventListener(`keydown`,this._onHostKey),s()&&e(this,c)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),t(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}};export{m as t};
9
+ </div>`,this._rendered=!0,this._syncAttrs(),this._syncText(),this._syncInvalid(),o(this,this._value),this._wire()}_input(){return this.querySelector(`.timepicker-trigger`)}_pop(){return this.querySelector(`.timepicker-pop`)}_syncFormValue(){o(this,this._value)}_syncAttrs(){let e=this._input(),t=this.querySelector(`.wui-timepicker-toggle`);if(!e)return;let n=this.hasAttribute(`disabled`);e.disabled=n,e.readOnly=a(this),t&&(t.disabled=n),i(this,e),e.placeholder=this.getAttribute(`placeholder`)||`Select time`,this.hasAttribute(`required`)?e.setAttribute(`aria-required`,`true`):e.removeAttribute(`aria-required`);let r=this.getAttribute(`aria-label`);r?e.setAttribute(`aria-label`,r):e.removeAttribute(`aria-label`),o(this,this._value),a(this)&&this._isOpen?.()&&this._close({commit:!1})}_syncText(){let e=this._input();e&&(e.value=d(u(this._value),this._format()),this._isOpen?.()&&this._syncColumns())}_syncInvalid(){let e=this._input(),t=this.querySelector(`.wui-timepicker-error`);if(!e||!t)return;let n=this._typedError;t.textContent=n,t.hidden=!n,this.hasAttribute(`aria-invalid`)||n?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`);let r=[this.getAttribute(`aria-describedby`),n?t.id:null].filter(Boolean).join(` `);r?e.setAttribute(`aria-describedby`,r):e.removeAttribute(`aria-describedby`),e.setCustomValidity?.(n)}_commitText(){let e=this._input();if(!e||e.value===d(u(this._value),this._format()))return!0;let t=e.value.trim(),n=``;if(t){let e=f(t),r=e?this._refusal(e):`Enter a time like ${this._format()===`12`?`7:45 PM`:`19:45`}.`;if(r)return this._typedError=r,this._syncInvalid(),!1;n=l(e.h,e.m)}let r=n!==this._value;return this.value=n,r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),!0}_pending(){let e=f(this._input()?.value);return e&&this._allowed(e.h,e.m)?e:null}_columnsHtml(){let e=this._format(),t=this._times(),n=(e,t,n)=>`<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map(e=>`<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join(``)}</div>`,r=[...new Set(t.map(e=>e.h))],i=[...new Set(t.map(e=>e.m))].sort((e,t)=>e-t),a;if(e===`12`){let e=[...new Set(r.map(e=>e%12))].sort((e,t)=>e-t),t=[...new Set(r.map(e=>e>=12?`pm`:`am`))].sort();a=n(`hour`,`Hour`,e.map(e=>({v:e,text:String(e||12)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:c(e)})))+n(`period`,`AM or PM`,t.map(e=>({v:e,text:e.toUpperCase()})))}else a=n(`hour`,`Hour`,r.map(e=>({v:e,text:c(e)})))+n(`minute`,`Minute`,i.map(e=>({v:e,text:c(e)})));return`<div class="wui-timepicker-cols">${a}</div>`}_selectedIn(e,t){return t?e===`minute`?String(t.m):e===`period`?t.h>=12?`pm`:`am`:String(this._format()===`12`?t.h%12:t.h):null}_optionEnabled(e,t,n){if(!n)return!0;let r=this._format()===`12`,i=n.h>=12,a=e=>r?[e+(i?12:0)]:[e],o=Array.from({length:60},(e,t)=>t);if(e===`hour`)return a(+t).some(e=>o.some(t=>this._allowed(e,t)));if(e===`minute`)return this._allowed(n.h,+t);let s=t===`pm`?12:0;return Array.from({length:12},(e,t)=>s+t).some(e=>o.some(t=>this._allowed(e,t)))}_syncColumns({scroll:e=!1}={}){let t=this._pop();if(!t)return;let n=this._pending();for(let r of t.querySelectorAll(`.wui-timepicker-col`)){let t=r.dataset.col,i=this._selectedIn(t,n),a=[...r.querySelectorAll(`.timepicker-option`)],o=null;for(let e of a){let r=e.dataset.v===i;e.classList.toggle(`is-selected`,r),e.setAttribute(`aria-selected`,r?`true`:`false`),e.disabled=!r&&!this._optionEnabled(t,e.dataset.v,n),r&&(o=e)}o=o||a.find(e=>!e.disabled)||null;for(let e of a)e.tabIndex=e===o?0:-1;e&&o&&(r.scrollTop=o.offsetTop-(r.clientHeight-o.offsetHeight)/2)}}_pick(e,t){let n=this._times();if(!n.length)return;let r=this._pending()||n[0],i=this._format()===`12`,a=r.h,o=r.m;if(e===`minute`?o=+t:a=e===`period`?a%12+(t===`pm`?12:0):i?+t+(r.h>=12?12:0):+t,!this._allowed(a,o)){let t=a*60+o,r=n.filter(t=>e===`minute`?t.m===o:e===`period`?t.h>=12==a>=12:i?t.h%12==a%12&&t.h>=12==a>=12:t.h===a).sort((e,n)=>Math.abs(e.h*60+e.m-t)-Math.abs(n.h*60+n.m-t))[0];if(!r)return;a=r.h,o=r.m}let s=this._input();s.value=d({h:a,m:o},this._format()),this._typedError=``,this._syncInvalid(),this._syncColumns()}_position(){n(this.querySelector(`.wui-timepicker-field`),this._pop())}_onColumnKey(e){let t=e.target.closest?.(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);if(!t||!n)return;let r=[...n.querySelectorAll(`.timepicker-option`)].filter(e=>!e.disabled),i=r.indexOf(t),a=[...this._pop().querySelectorAll(`.wui-timepicker-col`)],o=e=>{e&&(this._pick(n.dataset.col,e.dataset.v),(n.querySelector(`.timepicker-option.is-selected`)||e).focus())};switch(e.key){case`ArrowDown`:e.preventDefault(),o(r[Math.min(i+1,r.length-1)]);return;case`ArrowUp`:e.preventDefault(),o(r[Math.max(i-1,0)]);return;case`Home`:e.preventDefault(),o(r[0]);return;case`End`:e.preventDefault(),o(r[r.length-1]);return;case`PageDown`:e.preventDefault(),o(r[Math.min(i+8,r.length-1)]);return;case`PageUp`:e.preventDefault(),o(r[Math.max(i-8,0)]);return;case`ArrowRight`:case`ArrowLeft`:e.preventDefault(),a[a.indexOf(n)+(e.key===`ArrowRight`?1:-1)]?.querySelector(`.timepicker-option[tabindex="0"]`)?.focus();return;case`Enter`:e.preventDefault(),this._close({commit:!0,refocus:!0});return;case` `:e.preventDefault(),o(t);return;case`Escape`:e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0});return;default:e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=setTimeout(()=>{this._typeahead=``,this._typeaheadTimer=null},500),o(r.find(e=>e.textContent.trim().toLowerCase().startsWith(this._typeahead))))}}_wire(){this._teardown();let n=this._input(),r=this.querySelector(`.wui-timepicker-toggle`),i=this._pop(),o=this.querySelector(`.timepicker`);if(!n||!i)return;let s=()=>!i.hidden;this._isOpen=s;let c=()=>{s()&&this._position()},l=()=>i.querySelector(`.wui-timepicker-col .timepicker-option[tabindex="0"]`)?.focus();this._open=({focus:t=!1}={})=>{a(this)||(s()||(i.innerHTML=this._columnsHtml(),i.hidden=!1,o?.classList.add(`open`),n.setAttribute(`aria-expanded`,`true`),r?.setAttribute(`aria-expanded`,`true`),this._position(),e(this,c),this._syncColumns({scroll:!0})),t&&l())},this._close=({commit:e=!0,refocus:a=!1}={})=>{if(!s())return;let c=i.contains(document.activeElement);i.hidden=!0,i.innerHTML=``,o?.classList.remove(`open`),n.setAttribute(`aria-expanded`,`false`),r?.setAttribute(`aria-expanded`,`false`),t(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,e?this._commitText():(this._typedError=``,this._syncText(),this._syncInvalid()),(a||c)&&n.focus()},n.addEventListener(`pointerdown`,e=>{this._lastPointer=e.pointerType}),n.addEventListener(`click`,()=>{this._lastPointer!==`touch`&&!s()&&this._open(),this._lastPointer=null}),r?.addEventListener(`click`,()=>{s()?this._close({commit:!0,refocus:!0}):this._open({focus:!0})}),n.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._open({focus:!0});else if(e.key===`Enter`){let t=s(),n=this._commitText();t&&n&&this._close({commit:!1}),(!n||t)&&e.preventDefault()}else e.key===`Escape`&&s()?(e.preventDefault(),e.stopPropagation(),this._close({commit:!1})):e.key===`Tab`&&s()&&this._close({commit:!0})}),n.addEventListener(`input`,e=>{e.stopPropagation(),this._typedError&&(this._typedError=``,this._syncInvalid()),s()&&this._syncColumns({scroll:!0})}),n.addEventListener(`change`,e=>{e.stopPropagation(),s()||this._commitText()}),i.addEventListener(`click`,e=>{let t=e.target.closest(`.timepicker-option`),n=t?.closest(`.wui-timepicker-col`);t&&n&&!t.disabled&&this._pick(n.dataset.col,t.dataset.v)}),i.addEventListener(`keydown`,e=>{s()&&this._onColumnKey(e)}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{s()&&!e.composedPath().includes(this)&&this._close({commit:!0})},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{s()&&e.key===`Escape`&&this._close({commit:!1})},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{s()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._close({commit:!1,refocus:!0}))},this.addEventListener(`keydown`,this._onHostKey),s()&&e(this,c)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),t(this),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``}disconnectedCallback(){this._teardown()}};export{m as t};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./anchorOverlay-CBMAnDUt.js";import{n,t as r}from"./buttonClass-Yk0Fwgs6.js";import{t as i}from"./elementBase-DV9IZZCu.js";import{t as a}from"./tourOpenMark-nPeAJFSo.js";var o=`data-advance`,s=`wui-tour-hint`,c=`wui-tour-pointer`,l=`Click {actionName} to continue.`,u=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,d=(e,t)=>e?.advanceOn===`click`&&!!t,f=e=>(e??``).replace(/\s+/g,` `).trim();function p(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e.tagName===`INPUT`&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(e.labels??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=f(e);if(t)return t}return``}function m(e){for(let t of[e,...e.querySelectorAll(u)])if(t.tabIndex>=0&&!t.disabled)return t;return null}function h(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 g(e,t){let n=e.querySelector(`.${s}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;t?(n||(n=e.ownerDocument.createElement(`p`),n.className=s,i&&(n.id=i),e.querySelector(`.wui-tour-actions`).before(n)),n.textContent=t,i&&h(e,i,!0)):(n?.remove(),i&&h(e,i,!1))}function _(e,t){let n=e.querySelector(`.${c}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=c,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ee=e=>getComputedStyle(e).animationName;function v(e,{layer:t,spot:n,card:r},i,a){let s=d(i,a);t.toggleAttribute(o,s&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(o)&&(n.removeAttribute(o),s&&ee(n)),s&&n.setAttribute(o,``),_(n,s);let c=r.querySelector(`.wui-tour-next`);c.classList.toggle(`btn-primary`,!s),c.classList.toggle(`btn-link`,s);let u=s?f(i.actionLabel)||p(a):``,m=e.getAttribute(`advance-label`)||l,h=u?m.replace(/\{actionName\}/g,()=>u):``;return g(r,h),h}function te(e,t,n){if(!d(e,t))return()=>{};let r=null,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ne(e,t,n,r){return e.contains(r)||d(t,n)&&n.contains(r)}function re(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=d(r,i)?m(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i.contains(n));e.preventDefault(),a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length].focus()}var y=2/3,b=1e3,ie=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),x=/* @__PURE__ */ new WeakMap,S=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],C=e=>e.transitionProperty===`opacity`,ae=e=>ie.has(e.transitionProperty),oe=e=>typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function w(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,b);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function se(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?S(t,ae):[]){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*y-r)}return n}function T(e){let t=se(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={};x.set(e,n);let r=()=>{x.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=S(e,oe);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function E(e){return e.dataset.state=`leaving`,w(S(e,C))}function D(e){let t=e.classList.contains(`wui-tour-layer`)?e:e.shadowRoot?.querySelector(`.wui-tour-layer`);t&&(t.dataset.state=`leaving`);let n=t?w(S(t,C)):null;n?(e.setAttribute(`inert`,``),n.then(()=>e.remove())):e.remove()}var O=2,k=12,A=8,j=4,M=20,ce=`(max-width: 575.98px)`,le=[`bottom`,`top`,`right`,`left`],N=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],P,F=(e,t,n)=>Math.max(t,Math.min(e,n)),I=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function L(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=U(e),r=e.offsetHeight+k;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+O}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function R(e,t,n){let r=e.style,i=t.style,a=W(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 N)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`,z(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=U(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-k,top:o.top-k-l.top,right:l.right-o.right-k,left:o.left-k-l.left},f=window.matchMedia(ce).matches,p=le.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+A)-Math.max(o.top,l.top-A);p?B(t,a,p,o,l,c):m>=Math.min(c.height,u)+8?V(t,a,o,l,c):H(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function z(e,t){P??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of N)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),P&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function B(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=I(r.left,r.right,i.left,i.right);s=F(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+k:r.top-k-a.height,l=F(e-s,M,a.width-M)}else{let e=I(r.top,r.bottom,i.top,i.bottom);c=F(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+k:r.left-k-a.width,l=F(e-c,M,a.height-M)}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 V(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)-j;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${F(n.left+j,r.left,r.right-i.width)}px`}function H(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+k:r.top-k-c}px`;let l=I(r.left,r.right,i.left,i.right);e.style.left=`${F(l-a.width/2,i.left,i.right-a.width)}px`}function U(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e])||0;return{top:r(`paddingTop`)+A,bottom:window.innerHeight-r(`paddingBottom`)-A,left:r(`paddingLeft`)+A,right:window.innerWidth-r(`paddingRight`)-A}}function W(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);return t||(t=document.createElement(`span`),t.className=`wui-tour-arrow`,t.setAttribute(`aria-hidden`,`true`),t.hidden=!0,e.append(t)),t}var ue=0,de=`btn btn-sm btn-link`;function fe(e,t,i){let a=`wui-tour-end-${++ue}`,o=!!(t.nextLabel&&t.nextHref),s=e.createElement(`div`);if(s.className=`wui-tour-card wui-tour-end`,s.dataset.layout=`center`,o&&(s.dataset.next=``),s.setAttribute(`role`,`dialog`),i&&s.setAttribute(`aria-modal`,`true`),s.tabIndex=-1,s.setAttribute(`aria-labelledby`,`${a}-title`),s.setAttribute(`aria-describedby`,`${a}-message`),s.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="${a}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${a}-message"></p> <div class="wui-tour-actions">${o?`<a class="${n(`primary`,`solid`,`sm`)} wui-tour-end-next" data-wui="${r}"></a>`:``}<button type="button" class="${o?de:n(`primary`,`solid`,`sm`)} wui-tour-end-button" data-wui="${r}"></button></div>`,s.querySelector(`.wui-tour-end-title`).textContent=t.title,s.querySelector(`.wui-tour-end-message`).textContent=t.message,s.querySelector(`.wui-tour-end-button`).textContent=t.button,o){let e=s.querySelector(`.wui-tour-end-next`);e.textContent=t.nextLabel,e.setAttribute(`href`,t.nextHref)}return s}var pe=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function me(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=e.querySelector(`.wui-tour-card:not(.wui-tour-end)`),o=e.querySelector(`.wui-tour-spot`),s=e.querySelector(`[role=status]`),c=fe(r,t,i),l=c.querySelector(`.wui-tour-end-button`),u=c.querySelector(`.wui-tour-end-next`),d=u?[u,l]:[l],f=new AbortController;return new Promise(p=>{let m=e=>{f.abort(),p(e)};if(n?.aborted){m(`done`);return}let h={signal:f.signal};n?.addEventListener(`abort`,()=>m(`done`),h),l.addEventListener(`click`,()=>m(`done`),h),u&&u.addEventListener(`click`,e=>{pe(e)&&(e.preventDefault(),m(`next`))},h),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),m(`done`);else if(e.key===`Enter`&&u&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===u)e.preventDefault(),m(`next`);else if(e.key===`Tab`&&i){e.preventDefault();let t=d.indexOf(r.activeElement),n=t===-1?e.shiftKey?d.length-1:0:(t+(e.shiftKey?-1:1)+d.length)%d.length;d[n].focus()}}},{capture:!0,signal:f.signal}),i&&r.addEventListener(`focusin`,e=>{c.contains(e.target)||d[0].focus()},h);let g=()=>{f.signal.aborted||(a.hidden=!0,R(o,a,null),e.append(c),T(c),s.textContent=[t.title,t.message].filter(Boolean).join(`. `),d[0].focus())},_=E(a);_?_.then(g):g()})}var he=` :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; } } `,G=`wui-tour-media`,ge=`wui-tour-media-toggle`,K=`http://www.w3.org/2000/svg`,_e=`M6 5h4v14H6zM14 5h4v14h-4z`,ve=`M8 5v14l11-7z`,ye={pause:`Pause animation`,play:`Play animation`},be=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function xe(e){let t=document.createElementNS(K,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(K,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Se(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 Ce(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 we(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=ge;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(xe(r?_e:ve))};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 Te(e){let t=e.querySelector(`:scope > .${G}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ee(e,t,n=ye){if(Te(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=G,t.mediaType===`video`){let e=Ce(t,!be());r.append(e,we(e,n))}else r.appendChild(Se(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var De=`Step {current} of {total}`;function Oe(e){let t=/* @__PURE__ */ 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 ke(e,t,n){return(e.getAttribute(`progress-label`)||De).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Ae(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);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;)a.lastElementChild.remove();for(let e=0;e<o.length;e++)o[e].toggleAttribute(`data-filled`,e<n)}var je=`wui-tour-step`,Me=`wui-tour-host`,Ne=`wui-tour-seen:`,q=`data-tracking`,Pe={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`},Fe={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`},Ie=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},Le=0;function Y(e=Ne,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),Q=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Re(e){$||($=new CSSStyleSheet,$.replaceSync(he)),e.adoptedStyleSheets=[$]}var ze=class extends i{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 > ${je}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()};for(let[n,r]of Ie)e.hasAttribute(r)&&(t[n]=e.getAttribute(r));return t})}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?Y():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Fe[e])||Pe[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=Oe(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&&!X(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(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target);if(X(t))return this._progress.position(i),{index:i,target:t};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 t=`wui-tour-${++Le}`,i=document.createElement(`div`);i.className=`wui-tour-layer`,i.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${t}-title" aria-describedby="${t}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${t}-title"></h2> <p class="wui-tour-text" id="${t}-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="${n(`neutral`,`outline`,`sm`)} wui-tour-back" data-wui="${r}"></button> <button type="button" class="${n(`primary`,`solid`,`sm`)} wui-tour-next" data-wui="${r}"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let o=i;this._shadow=null,this.isolated&&(o=document.createElement(Me),this._shadow=o.attachShadow({mode:`open`}),Re(this._shadow),this._shadow.appendChild(i)),document.body.appendChild(o),document.documentElement.setAttribute(a,``),this._outer=o,this._layer=i,this._spot=i.querySelector(`.wui-tour-spot`),this._card=i.querySelector(`.wui-tour-card`),this._live=i.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`,`button`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._shadow&&this._card.removeAttribute(`aria-modal`),this._onKey=e=>this._key(e),this._onFocusIn=e=>{if(!this._layer||this._ending)return;let t=this._current,n=t?this._steps[t.index]:null;ne(this._layer,n,t?.target??null,e.target)||this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),this._shadow||document.addEventListener(`focusin`,this._onFocusIn),e(o,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._card,a=this._progress.position(t),o=this._progress.total(),s=a===o&&!this._endDialogText(),c=ke(this,a,o);Ae(i,{text:c,position:a,total:o}),Ee(i,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),i.toggleAttribute(`data-welcome`,!n);let l=v(this,{layer:this._layer,spot:this._spot,card:i},r,n),u=i.querySelector(`.wui-tour-title`);u.textContent=r.title||``,u.hidden=!r.title,i.querySelector(`.wui-tour-text`).textContent=r.description||``,i.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),i.querySelector(`.wui-tour-back`).textContent=this._label(`back`),i.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,i.querySelector(`.wui-tour-next`).textContent=this._label(s?`done`:`next`);let d=[c,r.title,r.description].filter(Boolean).join(`. `);this._live.textContent=l?[d,l].join(/[.!?]$/.test(d)?` `:`. `):d,L(i,n),this._spot.removeAttribute(q),this._place(),T(i),this._unbindAdvance?.(),this._unbindAdvance=te(r,n,()=>this._move(1));let f=this._active();(i.contains(f)?!f.hidden:this._shadow!==null&&Z(Q()))||i.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:a,total:o}}))}_place(){this._current&&this._layer&&R(this._spot,this._card,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot.style.cssText;this._place(),this._spot.style.cssText!==e&&this._spot.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=E(this._card);if(e&&await e,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`);t===`next`&&r&&this.ownerDocument.defaultView.location.assign(e.nextHref)}}finally{this._moving=!1}}_showEnd(e){return this._unbindAdvance?.(),this._unbindAdvance=null,v(this,{layer:this._layer,spot:this._spot,card:this._card},null,null),this._spot.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),me(this._layer,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(Z(e.composedPath?.()[0]??e.target))return;e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1)}else if(e.key===`Tab`&&!this._shadow){let{index:t,target:n}=this._current;re(e,{card:this._card,active:this._active(),step:this._steps[t],target:n})}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),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,t(this._outer),D(this._outer),document.documentElement.removeAttribute(a),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&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}}))}};export{Y as n,ze as t};
1
+ import{n as e,r as t}from"./anchorOverlay-DDrc2k6y.js";import{n,t as r}from"./buttonClass-Yk0Fwgs6.js";import{t as i}from"./elementBase-DV9IZZCu.js";import{t as a}from"./tourOpenMark-nPeAJFSo.js";var o=`data-advance`,s=`wui-tour-hint`,c=`wui-tour-pointer`,l=`Click {actionName} to continue.`,u=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,d=(e,t)=>e?.advanceOn===`click`&&!!t,f=e=>(e??``).replace(/\s+/g,` `).trim();function p(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e.tagName===`INPUT`&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(e.labels??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=f(e);if(t)return t}return``}function m(e){for(let t of[e,...e.querySelectorAll(u)])if(t.tabIndex>=0&&!t.disabled)return t;return null}function h(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 g(e,t){let n=e.querySelector(`.${s}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;t?(n||(n=e.ownerDocument.createElement(`p`),n.className=s,i&&(n.id=i),e.querySelector(`.wui-tour-actions`).before(n)),n.textContent=t,i&&h(e,i,!0)):(n?.remove(),i&&h(e,i,!1))}function _(e,t){let n=e.querySelector(`.${c}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=c,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ee=e=>getComputedStyle(e).animationName;function v(e,{layer:t,spot:n,card:r},i,a){let s=d(i,a);t.toggleAttribute(o,s&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(o)&&(n.removeAttribute(o),s&&ee(n)),s&&n.setAttribute(o,``),_(n,s);let c=r.querySelector(`.wui-tour-next`);c.classList.toggle(`btn-primary`,!s),c.classList.toggle(`btn-link`,s);let u=s?f(i.actionLabel)||p(a):``,m=e.getAttribute(`advance-label`)||l,h=u?m.replace(/\{actionName\}/g,()=>u):``;return g(r,h),h}function te(e,t,n){if(!d(e,t))return()=>{};let r=null,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ne(e,t,n,r){return e.contains(r)||d(t,n)&&n.contains(r)}function re(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=d(r,i)?m(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i.contains(n));e.preventDefault(),a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length].focus()}var y=2/3,b=1e3,ie=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),x=/* @__PURE__ */ new WeakMap,S=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],C=e=>e.transitionProperty===`opacity`,ae=e=>ie.has(e.transitionProperty),oe=e=>typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function w(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,b);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function se(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?S(t,ae):[]){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*y-r)}return n}function T(e){let t=se(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={};x.set(e,n);let r=()=>{x.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=S(e,oe);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function E(e){return e.dataset.state=`leaving`,w(S(e,C))}function D(e){let t=e.classList.contains(`wui-tour-layer`)?e:e.shadowRoot?.querySelector(`.wui-tour-layer`);t&&(t.dataset.state=`leaving`);let n=t?w(S(t,C)):null;n?(e.setAttribute(`inert`,``),n.then(()=>e.remove())):e.remove()}var O=2,k=12,A=8,j=4,M=20,ce=`(max-width: 575.98px)`,le=[`bottom`,`top`,`right`,`left`],N=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],P,F=(e,t,n)=>Math.max(t,Math.min(e,n)),I=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function L(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=U(e),r=e.offsetHeight+k;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+O}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function R(e,t,n){let r=e.style,i=t.style,a=W(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 N)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`,z(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=U(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-k,top:o.top-k-l.top,right:l.right-o.right-k,left:o.left-k-l.left},f=window.matchMedia(ce).matches,p=le.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+A)-Math.max(o.top,l.top-A);p?B(t,a,p,o,l,c):m>=Math.min(c.height,u)+8?V(t,a,o,l,c):H(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function z(e,t){P??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of N)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),P&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function B(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=I(r.left,r.right,i.left,i.right);s=F(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+k:r.top-k-a.height,l=F(e-s,M,a.width-M)}else{let e=I(r.top,r.bottom,i.top,i.bottom);c=F(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+k:r.left-k-a.width,l=F(e-c,M,a.height-M)}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 V(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)-j;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${F(n.left+j,r.left,r.right-i.width)}px`}function H(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+k:r.top-k-c}px`;let l=I(r.left,r.right,i.left,i.right);e.style.left=`${F(l-a.width/2,i.left,i.right-a.width)}px`}function U(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e])||0;return{top:r(`paddingTop`)+A,bottom:window.innerHeight-r(`paddingBottom`)-A,left:r(`paddingLeft`)+A,right:window.innerWidth-r(`paddingRight`)-A}}function W(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);return t||(t=document.createElement(`span`),t.className=`wui-tour-arrow`,t.setAttribute(`aria-hidden`,`true`),t.hidden=!0,e.append(t)),t}var ue=0,de=`btn btn-sm btn-link`;function fe(e,t,i){let a=`wui-tour-end-${++ue}`,o=!!(t.nextLabel&&t.nextHref),s=e.createElement(`div`);if(s.className=`wui-tour-card wui-tour-end`,s.dataset.layout=`center`,o&&(s.dataset.next=``),s.setAttribute(`role`,`dialog`),i&&s.setAttribute(`aria-modal`,`true`),s.tabIndex=-1,s.setAttribute(`aria-labelledby`,`${a}-title`),s.setAttribute(`aria-describedby`,`${a}-message`),s.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="${a}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${a}-message"></p> <div class="wui-tour-actions">${o?`<a class="${n(`primary`,`solid`,`sm`)} wui-tour-end-next" data-wui="${r}"></a>`:``}<button type="button" class="${o?de:n(`primary`,`solid`,`sm`)} wui-tour-end-button" data-wui="${r}"></button></div>`,s.querySelector(`.wui-tour-end-title`).textContent=t.title,s.querySelector(`.wui-tour-end-message`).textContent=t.message,s.querySelector(`.wui-tour-end-button`).textContent=t.button,o){let e=s.querySelector(`.wui-tour-end-next`);e.textContent=t.nextLabel,e.setAttribute(`href`,t.nextHref)}return s}var pe=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function me(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=e.querySelector(`.wui-tour-card:not(.wui-tour-end)`),o=e.querySelector(`.wui-tour-spot`),s=e.querySelector(`[role=status]`),c=fe(r,t,i),l=c.querySelector(`.wui-tour-end-button`),u=c.querySelector(`.wui-tour-end-next`),d=u?[u,l]:[l],f=new AbortController;return new Promise(p=>{let m=e=>{f.abort(),p(e)};if(n?.aborted){m(`done`);return}let h={signal:f.signal};n?.addEventListener(`abort`,()=>m(`done`),h),l.addEventListener(`click`,()=>m(`done`),h),u&&u.addEventListener(`click`,e=>{pe(e)&&(e.preventDefault(),m(`next`))},h),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),m(`done`);else if(e.key===`Enter`&&u&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===u)e.preventDefault(),m(`next`);else if(e.key===`Tab`&&i){e.preventDefault();let t=d.indexOf(r.activeElement),n=t===-1?e.shiftKey?d.length-1:0:(t+(e.shiftKey?-1:1)+d.length)%d.length;d[n].focus()}}},{capture:!0,signal:f.signal}),i&&r.addEventListener(`focusin`,e=>{c.contains(e.target)||d[0].focus()},h);let g=()=>{f.signal.aborted||(a.hidden=!0,R(o,a,null),e.append(c),T(c),s.textContent=[t.title,t.message].filter(Boolean).join(`. `),d[0].focus())},_=E(a);_?_.then(g):g()})}var he=` :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; } } `,G=`wui-tour-media`,ge=`wui-tour-media-toggle`,K=`http://www.w3.org/2000/svg`,_e=`M6 5h4v14H6zM14 5h4v14h-4z`,ve=`M8 5v14l11-7z`,ye={pause:`Pause animation`,play:`Play animation`},be=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function xe(e){let t=document.createElementNS(K,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(K,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Se(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 Ce(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 we(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=ge;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(xe(r?_e:ve))};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 Te(e){let t=e.querySelector(`:scope > .${G}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ee(e,t,n=ye){if(Te(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=G,t.mediaType===`video`){let e=Ce(t,!be());r.append(e,we(e,n))}else r.appendChild(Se(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var De=`Step {current} of {total}`;function Oe(e){let t=/* @__PURE__ */ 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 ke(e,t,n){return(e.getAttribute(`progress-label`)||De).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Ae(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);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;)a.lastElementChild.remove();for(let e=0;e<o.length;e++)o[e].toggleAttribute(`data-filled`,e<n)}var je=`wui-tour-step`,Me=`wui-tour-host`,Ne=`wui-tour-seen:`,q=`data-tracking`,Pe={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`},Fe={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`},Ie=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},Le=0;function Y(e=Ne,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),Q=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Re(e){$||($=new CSSStyleSheet,$.replaceSync(he)),e.adoptedStyleSheets=[$]}var ze=class extends i{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 > ${je}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()};for(let[n,r]of Ie)e.hasAttribute(r)&&(t[n]=e.getAttribute(r));return t})}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?Y():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Fe[e])||Pe[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=Oe(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&&!X(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(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target);if(X(t))return this._progress.position(i),{index:i,target:t};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 t=`wui-tour-${++Le}`,i=document.createElement(`div`);i.className=`wui-tour-layer`,i.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${t}-title" aria-describedby="${t}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${t}-title"></h2> <p class="wui-tour-text" id="${t}-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="${n(`neutral`,`outline`,`sm`)} wui-tour-back" data-wui="${r}"></button> <button type="button" class="${n(`primary`,`solid`,`sm`)} wui-tour-next" data-wui="${r}"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let o=i;this._shadow=null,this.isolated&&(o=document.createElement(Me),this._shadow=o.attachShadow({mode:`open`}),Re(this._shadow),this._shadow.appendChild(i)),document.body.appendChild(o),document.documentElement.setAttribute(a,``),this._outer=o,this._layer=i,this._spot=i.querySelector(`.wui-tour-spot`),this._card=i.querySelector(`.wui-tour-card`),this._live=i.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`,`button`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._shadow&&this._card.removeAttribute(`aria-modal`),this._onKey=e=>this._key(e),this._onFocusIn=e=>{if(!this._layer||this._ending)return;let t=this._current,n=t?this._steps[t.index]:null;ne(this._layer,n,t?.target??null,e.target)||this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),this._shadow||document.addEventListener(`focusin`,this._onFocusIn),e(o,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._card,a=this._progress.position(t),o=this._progress.total(),s=a===o&&!this._endDialogText(),c=ke(this,a,o);Ae(i,{text:c,position:a,total:o}),Ee(i,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),i.toggleAttribute(`data-welcome`,!n);let l=v(this,{layer:this._layer,spot:this._spot,card:i},r,n),u=i.querySelector(`.wui-tour-title`);u.textContent=r.title||``,u.hidden=!r.title,i.querySelector(`.wui-tour-text`).textContent=r.description||``,i.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),i.querySelector(`.wui-tour-back`).textContent=this._label(`back`),i.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,i.querySelector(`.wui-tour-next`).textContent=this._label(s?`done`:`next`);let d=[c,r.title,r.description].filter(Boolean).join(`. `);this._live.textContent=l?[d,l].join(/[.!?]$/.test(d)?` `:`. `):d,L(i,n),this._spot.removeAttribute(q),this._place(),T(i),this._unbindAdvance?.(),this._unbindAdvance=te(r,n,()=>this._move(1));let f=this._active();(i.contains(f)?!f.hidden:this._shadow!==null&&Z(Q()))||i.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:a,total:o}}))}_place(){this._current&&this._layer&&R(this._spot,this._card,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot.style.cssText;this._place(),this._spot.style.cssText!==e&&this._spot.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=E(this._card);if(e&&await e,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`);t===`next`&&r&&this.ownerDocument.defaultView.location.assign(e.nextHref)}}finally{this._moving=!1}}_showEnd(e){return this._unbindAdvance?.(),this._unbindAdvance=null,v(this,{layer:this._layer,spot:this._spot,card:this._card},null,null),this._spot.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),me(this._layer,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(Z(e.composedPath?.()[0]??e.target))return;e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1)}else if(e.key===`Tab`&&!this._shadow){let{index:t,target:n}=this._current;re(e,{card:this._card,active:this._active(),step:this._steps[t],target:n})}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),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,t(this._outer),D(this._outer),document.documentElement.removeAttribute(a),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&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}}))}};export{Y as n,ze as t};
@@ -1 +1 @@
1
- import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-DV9IZZCu.js";import{n,t as r}from"./formMirror-BMQTenSi.js";import{t as i}from"./iconGlyphs.g-BlwTSNXS.js";import{t as a}from"./listboxKeyNav-DMIvs9d6.js";import{l as o}from"./wuiHttp-DgnM7K2Q.js";var s=[`none`,`single`,`multiple`],c=`parentId`,l=`Loading`,u=`Could not load. Try again.`,d=`:scope > input[data-wui-mirror]`,f=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],p=0;function m(e,t,n){let r=document.createElement(e);t&&(r.className=t);for(let[e,t]of Object.entries(n??{}))t!=null&&r.setAttribute(e,String(t));return r}var h=class extends t{static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++p}`,this._seq=0,this._roots=[],this._byId=/* @__PURE__ */ new Map,this._prev=null,this._staged=null,this._els=/* @__PURE__ */ new Map,this._checked=/* @__PURE__ */ new Set,this._selected=null,this._focusId=null,this._loader=null,this._list=null,this._live=null,this._ready=!1,this._nav=a({getVisibleOptions:()=>this._visible().map(e=>this._els.get(e.id)?.row),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[e]),onEnter:()=>{let e=this._byId.get(this._focusId);e&&this._activate(e)}}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>{let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e={};for(let t of f)Object.hasOwn(this,t)&&(e[t]=this[t],delete this[t]);if(!this._ready){this._ready=!0;let e=this._readScript();this.replaceChildren(),this._list=m(`ul`,`wui-tree`),this._list.setAttribute(`role`,`tree`),this._live=m(`div`,`visually-hidden`,{role:`status`,"aria-live":`polite`}),this.append(this._list,this._live),e&&this._adoptAll(e)}for(let[t,n]of Object.entries(e))this[t]=n;this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this._render(),this._loadOpenNodes()}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this._nav.teardown()}attributeChangedCallback(e,t,n){e===`selected`&&(this._selected=n),this._ready&&this.isConnected&&this._render()}get nodes(){return this._roots.map(e=>e.raw)}set nodes(e){this._adoptAll(e??[]),this._render(),this._loadOpenNodes()}get selection(){let e=this.getAttribute(`selection`);return s.includes(e)?e:`none`}set selection(e){this.setAttribute(`selection`,String(e))}get selected(){return this._selected}set selected(e){this._selected=e==null?null:String(e),this._render()}get values(){let e=[],t=n=>{for(let r of n)this._state(r)===`checked`&&e.push(r.id),r.children&&t(r.children)};return t(this._roots),[...e,...[...this._checked].filter(e=>!this._byId.has(e))]}set values(e){this._checked.clear();for(let t of e??[]){let e=this._byId.get(String(t));e?this._setChecked(e,!0):this._checked.add(String(t))}this._render()}get loadChildren(){return this._loader}set loadChildren(e){this._loader=typeof e==`function`?e:null}get loadUrl(){return this.getAttribute(`load-url`)}set loadUrl(e){e==null?this.removeAttribute(`load-url`):this.setAttribute(`load-url`,String(e))}get name(){return this.getAttribute(`name`)}set name(e){e==null?this.removeAttribute(`name`):this.setAttribute(`name`,String(e))}get loadingText(){return this.getAttribute(`loading-text`)??l}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??u}set errorText(e){this.setAttribute(`error-text`,String(e??``))}_readScript(){let t=this.querySelector(`:scope > script[type='application/json']`);if(!t)return null;try{return JSON.parse(t.textContent)}catch(t){return e(`[@webority/ui-elements] <wui-tree> could not read its JSON nodes:`,t?.message),null}}_adoptAll(e){let t=this._byId;this._prev=t,this._byId=/* @__PURE__ */ new Map;let n;try{n=this._adoptStaged(e,null,1)}catch(e){throw this._byId=t,e}finally{this._prev=null}this._roots=n;for(let e of t.keys())this._byId.has(e)||this._checked.delete(e);for(let e of this._roots)this._passChecksDown(e);this._focusId&&!this._byId.has(this._focusId)&&(this._focusId=null)}_adoptStaged(e,t,n){let r=[],i=[];this._staged={ids:r,checks:i};try{let r=this._adopt(e,t,n);for(let e of i)this._checked.add(e);return r}catch(e){for(let e of r)this._byId.delete(e);throw e}finally{this._staged=null}}_adopt(e,t,n){if(!Array.isArray(e))throw Error(`<wui-tree> nodes must be an array.`);return e.map(e=>{let r=e?.id==null?``:String(e.id);if(!r)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(r))throw Error(`<wui-tree> node id "${r}" is used twice.`);let i=this._prev?.get(r),a={id:r,raw:e,parent:t,level:n,seq:++this._seq,label:e.label==null?r:String(e.label),icon:e.icon||null,badge:e.badge==null||e.badge===``?null:String(e.badge),badgeTone:e.badgeTone||null,disabled:!!e.disabled,hasChildren:!!e.hasChildren,children:null,expanded:i?i.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(r,a),this._staged.ids.push(r);let o=e.children??(e.hasChildren?i?.children?.map(e=>e.raw):void 0);return Array.isArray(o)&&(a.children=this._adopt(o,a,n+1)),a.loading=!!i?.loading&&a.children===null&&a.hasChildren,e.checked&&!i&&this._staged.checks.push(r),a})}_passChecksDown(e){e.children?.length&&this._checked.has(e.id)&&(this._checked.delete(e.id),this._setChecked(e,!0));for(let t of e.children??[])this._passChecksDown(t)}_loadOpenNodes(){queueMicrotask(()=>{if(this.isConnected)for(let e of[...this._byId.values()])e.expanded&&e.children===null&&e.hasChildren&&!e.loading&&this._load(e)})}_isBranch(e){return e.children?e.children.length>0:e.hasChildren}_visible(){let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),e}_state(e){if(e.children?.length){let t=0,n=0;for(let r of e.children){let e=this._state(r);e===`checked`?t++:e===`unchecked`&&n++}return t===e.children.length?`checked`:n===e.children.length?`unchecked`:`mixed`}return this._checked.has(e.id)?`checked`:`unchecked`}_setChecked(e,t){if(e.children?.length)for(let n of e.children)n.disabled||this._setChecked(n,t);else t?this._checked.add(e.id):this._checked.delete(e.id)}_nodeFrom(e){let t=e?.closest?.(`li.wui-tree-item`);if(!t)return null;for(let[e,n]of this._els)if(n.li===t)return this._byId.get(e)??null;return null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-tree:${e}`,{detail:t,bubbles:!0,composed:!0}))}_announce(e){this._live&&(this._live.textContent=e)}_setRoving(e){let t=this._els.get(this._focusId);t&&(t.li.tabIndex=-1),this._focusId=e.id;let n=this._els.get(e.id);n&&(n.li.tabIndex=0)}_focusNode(e){e&&(this._setRoving(e),this._els.get(e.id)?.li.focus())}_activate(e){e.disabled||(this.selection===`single`&&(this._selected=e.id,this._render(),this._syncForm()),this._emit(`select`,{id:e.id,node:e.raw}))}_enabledLeaves(e){return e.disabled?[]:e.children?.length?e.children.flatMap(e=>this._enabledLeaves(e)):[e]}_toggleCheck(e){let t=this._enabledLeaves(e);if(!t.length)return;let n=!t.every(e=>this._checked.has(e.id));this._setChecked(e,n),this._render(),this._syncForm(),this._emit(`check`,{id:e.id,checked:n,values:this.values})}_toggleExpand(e){!e.disabled&&this._isBranch(e)&&(e.expanded?(e.expanded=!1,this._render()):this._expand(e))}_expand(e){e.expanded=!0,e.children===null?this._load(e):this._render()}async _load(e){if(e.loading)return;e.loading=!0,e.failed=!1,this._announce(this.loadingText),this._render();let t,n=null;try{t=await this._fetchChildren(e)}catch(e){n=e}let r=this._byId.get(e.id);if(!r)this._announce(``);else if(r.loading){if(r.loading=!1,!n)try{r.children=this._adoptStaged(t,r,r.level+1),this._passChecksDown(r),this._announce(``)}catch(e){n=e}n&&(r.failed=!0,r.expanded=!1,this._announce(this.errorText),this._emit(`error`,{id:r.id,message:n?.message??String(n)})),this._render(),this._syncForm()}}async _fetchChildren(e){if(this._loader)return this._loader(e.raw);let t=this.getAttribute(`load-url`);if(!t)throw Error(`<wui-tree> has a node with children to load but no loadChildren or load-url.`);let n=new URL(t,window.location.href);n.searchParams.set(c,e.id);let r=await o(n.href,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`Loading children answered ${r.kind}.`);return JSON.parse(r.html)}_handleClick(e){let t=this._nodeFrom(e.target);t&&!t.disabled&&(this._focusNode(t),e.target.closest(`.wui-tree-toggle`)?this._toggleExpand(t):e.target.closest(`.wui-tree-check`)?(e.preventDefault(),this._toggleCheck(t)):this._activate(t))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=this._nodeFrom(e.target);if(t&&e.target===this._els.get(t.id)?.li){if(e.key===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else e.key===`ArrowLeft`?(e.preventDefault(),t.expanded&&this._isBranch(t)&&!t.disabled?this._toggleExpand(t):t.parent&&this._focusNode(t.parent)):e.key===` `?(e.preventDefault(),this.selection===`multiple`?this._toggleCheck(t):this.selection===`single`&&this._activate(t)):this._nav.handler(e)}}_syncForm(){let e=this.selection;if(e===`multiple`)n(this,this.values);else if(e===`single`)r(this,this._selected??``);else for(let e of this.querySelectorAll(d))e.remove()}_render(){if(!this._list)return;let e=document.activeElement,t=!!e&&this._list.contains(e),n=this._visible();n.some(e=>e.id===this._focusId)||(this._focusId=(n.find(e=>e.id===this._selected)??n[0])?.id??null),this._els=/* @__PURE__ */ new Map;let r=this.getAttribute(`aria-label`);r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),this._list.replaceChildren(...this._buildLevel(this._roots)),t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_buildLevel(e){return e.map((t,n)=>this._buildItem(t,n+1,e.length))}_buildItem(e,t,n){let r=this.selection,a=this._isBranch(e),o=this._state(e),s=m(`li`,`wui-tree-item`,{role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":t,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});a&&s.setAttribute(`aria-expanded`,String(e.expanded)),e.disabled&&s.setAttribute(`aria-disabled`,`true`),e.loading&&s.setAttribute(`aria-busy`,`true`),r===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),r===`multiple`&&s.setAttribute(`aria-checked`,o===`mixed`?`mixed`:String(o===`checked`));let c=m(`div`,`wui-tree-row`,{role:`presentation`});c.style.setProperty(`--wui-tree-level`,String(e.level-1)),r===`single`&&e.id===this._selected&&c.classList.add(`wui-tree-row-selected`),e.failed&&c.classList.add(`wui-tree-row-error`);let l=m(`span`,a?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,{"aria-hidden":`true`});if(a&&(l.innerHTML=i(`chevron-right`,{size:16})),c.append(l),r===`multiple`){let t=m(`input`,`form-check-input wui-tree-check`,{type:`checkbox`,tabindex:-1,"aria-hidden":`true`});t.checked=o===`checked`,t.indeterminate=o===`mixed`,t.disabled=e.disabled,t.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(t)}if(e.icon){let t=m(`span`,`wui-tree-icon`,{"aria-hidden":`true`});t.innerHTML=i(e.icon,{size:16}),c.append(t)}let u=m(`span`,`wui-tree-label`,{id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let t=m(`span`,`badge wui-tree-badge${e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``}`,{id:`${this._uid}-${e.seq}-badge`});t.textContent=e.badge,c.append(t)}if(e.loading&&c.append(m(`span`,`wui-tree-spinner`,{"aria-hidden":`true`})),s.append(c),e.expanded&&e.children?.length){let t=m(`ul`,`wui-tree-group`,{role:`group`});t.append(...this._buildLevel(e.children)),s.append(t)}return this._els.set(e.id,{li:s,row:c}),s}};export{h as t};
1
+ import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-DV9IZZCu.js";import{n,t as r}from"./formMirror-BMQTenSi.js";import{t as i}from"./iconGlyphs.g-BlwTSNXS.js";import{t as a}from"./listboxKeyNav-DMIvs9d6.js";import{l as o}from"./wuiHttp-BuaTcumE.js";var s=[`none`,`single`,`multiple`],c=`parentId`,l=`Loading`,u=`Could not load. Try again.`,d=`:scope > input[data-wui-mirror]`,f=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],p=0;function m(e,t,n){let r=document.createElement(e);t&&(r.className=t);for(let[e,t]of Object.entries(n??{}))t!=null&&r.setAttribute(e,String(t));return r}var h=class extends t{static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++p}`,this._seq=0,this._roots=[],this._byId=/* @__PURE__ */ new Map,this._prev=null,this._staged=null,this._els=/* @__PURE__ */ new Map,this._checked=/* @__PURE__ */ new Set,this._selected=null,this._focusId=null,this._loader=null,this._list=null,this._live=null,this._ready=!1,this._nav=a({getVisibleOptions:()=>this._visible().map(e=>this._els.get(e.id)?.row),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[e]),onEnter:()=>{let e=this._byId.get(this._focusId);e&&this._activate(e)}}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>{let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e={};for(let t of f)Object.hasOwn(this,t)&&(e[t]=this[t],delete this[t]);if(!this._ready){this._ready=!0;let e=this._readScript();this.replaceChildren(),this._list=m(`ul`,`wui-tree`),this._list.setAttribute(`role`,`tree`),this._live=m(`div`,`visually-hidden`,{role:`status`,"aria-live":`polite`}),this.append(this._list,this._live),e&&this._adoptAll(e)}for(let[t,n]of Object.entries(e))this[t]=n;this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this._render(),this._loadOpenNodes()}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this._nav.teardown()}attributeChangedCallback(e,t,n){e===`selected`&&(this._selected=n),this._ready&&this.isConnected&&this._render()}get nodes(){return this._roots.map(e=>e.raw)}set nodes(e){this._adoptAll(e??[]),this._render(),this._loadOpenNodes()}get selection(){let e=this.getAttribute(`selection`);return s.includes(e)?e:`none`}set selection(e){this.setAttribute(`selection`,String(e))}get selected(){return this._selected}set selected(e){this._selected=e==null?null:String(e),this._render()}get values(){let e=[],t=n=>{for(let r of n)this._state(r)===`checked`&&e.push(r.id),r.children&&t(r.children)};return t(this._roots),[...e,...[...this._checked].filter(e=>!this._byId.has(e))]}set values(e){this._checked.clear();for(let t of e??[]){let e=this._byId.get(String(t));e?this._setChecked(e,!0):this._checked.add(String(t))}this._render()}get loadChildren(){return this._loader}set loadChildren(e){this._loader=typeof e==`function`?e:null}get loadUrl(){return this.getAttribute(`load-url`)}set loadUrl(e){e==null?this.removeAttribute(`load-url`):this.setAttribute(`load-url`,String(e))}get name(){return this.getAttribute(`name`)}set name(e){e==null?this.removeAttribute(`name`):this.setAttribute(`name`,String(e))}get loadingText(){return this.getAttribute(`loading-text`)??l}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??u}set errorText(e){this.setAttribute(`error-text`,String(e??``))}_readScript(){let t=this.querySelector(`:scope > script[type='application/json']`);if(!t)return null;try{return JSON.parse(t.textContent)}catch(t){return e(`[@webority/ui-elements] <wui-tree> could not read its JSON nodes:`,t?.message),null}}_adoptAll(e){let t=this._byId;this._prev=t,this._byId=/* @__PURE__ */ new Map;let n;try{n=this._adoptStaged(e,null,1)}catch(e){throw this._byId=t,e}finally{this._prev=null}this._roots=n;for(let e of t.keys())this._byId.has(e)||this._checked.delete(e);for(let e of this._roots)this._passChecksDown(e);this._focusId&&!this._byId.has(this._focusId)&&(this._focusId=null)}_adoptStaged(e,t,n){let r=[],i=[];this._staged={ids:r,checks:i};try{let r=this._adopt(e,t,n);for(let e of i)this._checked.add(e);return r}catch(e){for(let e of r)this._byId.delete(e);throw e}finally{this._staged=null}}_adopt(e,t,n){if(!Array.isArray(e))throw Error(`<wui-tree> nodes must be an array.`);return e.map(e=>{let r=e?.id==null?``:String(e.id);if(!r)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(r))throw Error(`<wui-tree> node id "${r}" is used twice.`);let i=this._prev?.get(r),a={id:r,raw:e,parent:t,level:n,seq:++this._seq,label:e.label==null?r:String(e.label),icon:e.icon||null,badge:e.badge==null||e.badge===``?null:String(e.badge),badgeTone:e.badgeTone||null,disabled:!!e.disabled,hasChildren:!!e.hasChildren,children:null,expanded:i?i.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(r,a),this._staged.ids.push(r);let o=e.children??(e.hasChildren?i?.children?.map(e=>e.raw):void 0);return Array.isArray(o)&&(a.children=this._adopt(o,a,n+1)),a.loading=!!i?.loading&&a.children===null&&a.hasChildren,e.checked&&!i&&this._staged.checks.push(r),a})}_passChecksDown(e){e.children?.length&&this._checked.has(e.id)&&(this._checked.delete(e.id),this._setChecked(e,!0));for(let t of e.children??[])this._passChecksDown(t)}_loadOpenNodes(){queueMicrotask(()=>{if(this.isConnected)for(let e of[...this._byId.values()])e.expanded&&e.children===null&&e.hasChildren&&!e.loading&&this._load(e)})}_isBranch(e){return e.children?e.children.length>0:e.hasChildren}_visible(){let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),e}_state(e){if(e.children?.length){let t=0,n=0;for(let r of e.children){let e=this._state(r);e===`checked`?t++:e===`unchecked`&&n++}return t===e.children.length?`checked`:n===e.children.length?`unchecked`:`mixed`}return this._checked.has(e.id)?`checked`:`unchecked`}_setChecked(e,t){if(e.children?.length)for(let n of e.children)n.disabled||this._setChecked(n,t);else t?this._checked.add(e.id):this._checked.delete(e.id)}_nodeFrom(e){let t=e?.closest?.(`li.wui-tree-item`);if(!t)return null;for(let[e,n]of this._els)if(n.li===t)return this._byId.get(e)??null;return null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-tree:${e}`,{detail:t,bubbles:!0,composed:!0}))}_announce(e){this._live&&(this._live.textContent=e)}_setRoving(e){let t=this._els.get(this._focusId);t&&(t.li.tabIndex=-1),this._focusId=e.id;let n=this._els.get(e.id);n&&(n.li.tabIndex=0)}_focusNode(e){e&&(this._setRoving(e),this._els.get(e.id)?.li.focus())}_activate(e){e.disabled||(this.selection===`single`&&(this._selected=e.id,this._render(),this._syncForm()),this._emit(`select`,{id:e.id,node:e.raw}))}_enabledLeaves(e){return e.disabled?[]:e.children?.length?e.children.flatMap(e=>this._enabledLeaves(e)):[e]}_toggleCheck(e){let t=this._enabledLeaves(e);if(!t.length)return;let n=!t.every(e=>this._checked.has(e.id));this._setChecked(e,n),this._render(),this._syncForm(),this._emit(`check`,{id:e.id,checked:n,values:this.values})}_toggleExpand(e){!e.disabled&&this._isBranch(e)&&(e.expanded?(e.expanded=!1,this._render()):this._expand(e))}_expand(e){e.expanded=!0,e.children===null?this._load(e):this._render()}async _load(e){if(e.loading)return;e.loading=!0,e.failed=!1,this._announce(this.loadingText),this._render();let t,n=null;try{t=await this._fetchChildren(e)}catch(e){n=e}let r=this._byId.get(e.id);if(!r)this._announce(``);else if(r.loading){if(r.loading=!1,!n)try{r.children=this._adoptStaged(t,r,r.level+1),this._passChecksDown(r),this._announce(``)}catch(e){n=e}n&&(r.failed=!0,r.expanded=!1,this._announce(this.errorText),this._emit(`error`,{id:r.id,message:n?.message??String(n)})),this._render(),this._syncForm()}}async _fetchChildren(e){if(this._loader)return this._loader(e.raw);let t=this.getAttribute(`load-url`);if(!t)throw Error(`<wui-tree> has a node with children to load but no loadChildren or load-url.`);let n=new URL(t,window.location.href);n.searchParams.set(c,e.id);let r=await o(n.href,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`Loading children answered ${r.kind}.`);return JSON.parse(r.html)}_handleClick(e){let t=this._nodeFrom(e.target);t&&!t.disabled&&(this._focusNode(t),e.target.closest(`.wui-tree-toggle`)?this._toggleExpand(t):e.target.closest(`.wui-tree-check`)?(e.preventDefault(),this._toggleCheck(t)):this._activate(t))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=this._nodeFrom(e.target);if(t&&e.target===this._els.get(t.id)?.li){if(e.key===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else e.key===`ArrowLeft`?(e.preventDefault(),t.expanded&&this._isBranch(t)&&!t.disabled?this._toggleExpand(t):t.parent&&this._focusNode(t.parent)):e.key===` `?(e.preventDefault(),this.selection===`multiple`?this._toggleCheck(t):this.selection===`single`&&this._activate(t)):this._nav.handler(e)}}_syncForm(){let e=this.selection;if(e===`multiple`)n(this,this.values);else if(e===`single`)r(this,this._selected??``);else for(let e of this.querySelectorAll(d))e.remove()}_render(){if(!this._list)return;let e=document.activeElement,t=!!e&&this._list.contains(e),n=this._visible();n.some(e=>e.id===this._focusId)||(this._focusId=(n.find(e=>e.id===this._selected)??n[0])?.id??null),this._els=/* @__PURE__ */ new Map;let r=this.getAttribute(`aria-label`);r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),this._list.replaceChildren(...this._buildLevel(this._roots)),t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_buildLevel(e){return e.map((t,n)=>this._buildItem(t,n+1,e.length))}_buildItem(e,t,n){let r=this.selection,a=this._isBranch(e),o=this._state(e),s=m(`li`,`wui-tree-item`,{role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":t,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});a&&s.setAttribute(`aria-expanded`,String(e.expanded)),e.disabled&&s.setAttribute(`aria-disabled`,`true`),e.loading&&s.setAttribute(`aria-busy`,`true`),r===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),r===`multiple`&&s.setAttribute(`aria-checked`,o===`mixed`?`mixed`:String(o===`checked`));let c=m(`div`,`wui-tree-row`,{role:`presentation`});c.style.setProperty(`--wui-tree-level`,String(e.level-1)),r===`single`&&e.id===this._selected&&c.classList.add(`wui-tree-row-selected`),e.failed&&c.classList.add(`wui-tree-row-error`);let l=m(`span`,a?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,{"aria-hidden":`true`});if(a&&(l.innerHTML=i(`chevron-right`,{size:16})),c.append(l),r===`multiple`){let t=m(`input`,`form-check-input wui-tree-check`,{type:`checkbox`,tabindex:-1,"aria-hidden":`true`});t.checked=o===`checked`,t.indeterminate=o===`mixed`,t.disabled=e.disabled,t.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(t)}if(e.icon){let t=m(`span`,`wui-tree-icon`,{"aria-hidden":`true`});t.innerHTML=i(e.icon,{size:16}),c.append(t)}let u=m(`span`,`wui-tree-label`,{id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let t=m(`span`,`badge wui-tree-badge${e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``}`,{id:`${this._uid}-${e.seq}-badge`});t.textContent=e.badge,c.append(t)}if(e.loading&&c.append(m(`span`,`wui-tree-spinner`,{"aria-hidden":`true`})),s.append(c),e.expanded&&e.children?.length){let t=m(`ul`,`wui-tree-group`,{role:`group`});t.append(...this._buildLevel(e.children)),s.append(t)}return this._els.set(e.id,{li:s,row:c}),s}};export{h as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-DDrc2k6y.js";import{t as r}from"./elementBase-DV9IZZCu.js";var i=`wui-whats-new-read`,a=`wui-whats-new:`,o=`data-open`,s=`data-wui-unread`,c=0,l=e=>{let t=Date.parse(e);return Number.isNaN(t)?-1/0:t},u=(e,t)=>l(t)>l(e)?t:e,d=class extends r{static get observedAttributes(){return[`storage-key`,`read-through`,`indicator`]}constructor(){super(),this._doc=null,this._stored=``,this._observer=null,this._onTriggerClick=()=>this.isOpen?this.close(!0):this.open(),this._onKeyDown=e=>{e.key===`Escape`&&this.isOpen&&(e.stopPropagation(),this.close(!0))},this._onPointerDown=e=>{this.isOpen&&!e.composedPath().includes(this)&&this.close(!1)}}get isOpen(){return this.hasAttribute(o)}get _trigger(){return this.querySelector(`.wui-whats-new-trigger`)}get _panel(){return this.querySelector(`.wui-whats-new-panel`)}get _dot(){return this.querySelector(`.wui-whats-new-dot`)}connectedCallback(){this._doc=this.ownerDocument;let e=this._panel,t=this._trigger;e&&t&&(e.id||=`wui-whats-new-${++c}`,t.setAttribute(`aria-controls`,e.id),t.setAttribute(`aria-expanded`,`false`),t.addEventListener(`click`,this._onTriggerClick),this.addEventListener(`keydown`,this._onKeyDown),this._stored=this._load(),this._refresh(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(()=>this._refresh()),this._observer.observe(e,{childList:!0,subtree:!0})))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._trigger?.removeEventListener(`click`,this._onTriggerClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`pointerdown`,this._onPointerDown,!0),t(this),this.removeAttribute(o),this._doc=null}attributeChangedCallback(e,t,n){t!==n&&this._doc&&(e===`storage-key`&&(this._stored=this._load()),this._refresh())}open(){let t=this._panel;t&&!this.isOpen&&(this.setAttribute(o,``),this._trigger?.setAttribute(`aria-expanded`,`true`),this._place(),e(this,()=>this._place()),this._doc.addEventListener(`pointerdown`,this._onPointerDown,!0),t.focus({preventScroll:!0}),this._markRead())}close(e){this.isOpen&&(this.removeAttribute(o),this._trigger?.setAttribute(`aria-expanded`,`false`),this._doc.removeEventListener(`pointerdown`,this._onPointerDown,!0),t(this),this._refresh(),e&&this._trigger?.focus())}_place(){n(this._trigger,this._panel,{clampHeight:!0})}_entries(){return[...this.querySelectorAll(`.wui-whats-new-entry`)].map(e=>({entry:e,date:e.querySelector(`time[datetime]`)?.getAttribute(`datetime`)??``}))}_newest(){return this._entries().reduce((e,{date:t})=>u(e,t),``)}_seenPoint(){return u(this._stored,this.getAttribute(`read-through`)??``)}_refresh(){let e=this._seenPoint(),t=this._entries(),n=0;for(let{entry:r,date:i}of t){let t=l(i)>l(e);t&&n++,this.isOpen&&r.hasAttribute(s)||r.toggleAttribute(s,t)}this.toggleAttribute(s,n>0);let r=this._dot;r&&(r.textContent=this.getAttribute(`indicator`)===`count`&&n>0?String(n):``)}_markRead(){let e=this._newest();!e||l(e)<=l(this._seenPoint())||(this._stored=u(this._stored,e),this._save(this._stored),this._refresh(),this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:{through:e}})))}_storage(){let e=this.getAttribute(`storage-key`);if(!e)return null;try{return{store:this.ownerDocument.defaultView.localStorage,key:a+e}}catch{return null}}_load(){let e=this._storage();return e?e.store.getItem(e.key)??``:this._stored}_save(e){let t=this._storage();t&&t.store.setItem(t.key,e)}};export{d as n,i as t};
@@ -1 +1 @@
1
- function e(e,t){let n=t.offsetWidth,r=t.offsetHeight,i=e.right+4+n>window.innerWidth-4,a=i?e.left-4-n:e.right+4;t.style.left=`${Math.max(4,a)}px`,t.style.top=`${Math.max(4,Math.min(e.top,window.innerHeight-r-4))}px`,t.dataset.side=i?`start`:`end`}function t(t,n,r={}){if(!t||!n)return;n.style.position=`fixed`;let i=t.getBoundingClientRect();if(r.beside){e(i,n);return}let a=r.clampHeight?n.scrollTop:0;r.clampHeight&&(n.style.maxHeight=``);let o=n.offsetHeight,s=window.innerHeight-i.bottom,c=!r.below&&s<o+4&&i.top>s;if(n.classList.toggle(`drop-up`,c),n.style.top=c?`${Math.max(4,i.top-o-4)}px`:`${i.bottom+4}px`,r.clampHeight){let e=c?i.top-8:window.innerHeight-i.bottom-8;e<o&&(n.style.maxHeight=`${Math.max(e,0)}px`),n.scrollTop=a}r.matchWidth&&(i.width>=300?(n.style.minWidth=`${i.width}px`,n.style.width=`${i.width}px`,n.style.maxWidth=`${i.width}px`):(n.style.minWidth=`${i.width}px`,n.style.width=`max-content`,n.style.maxWidth=`${Math.min(400,window.innerWidth-8)}px`));let l=n.offsetWidth;if(r.alignEnd){let e=i.right-l,t=e>=8?e:i.left,r=Math.max(8,Math.min(t,window.innerWidth-l-8));n.style.left=`${r}px`}else{let e=Math.min(i.left,window.innerWidth-l-4);n.style.left=`${Math.max(4,e)}px`}}function n(e,t){r(e),e._reanchor=t,e._reanchorScroll=n=>{n.target instanceof Node&&typeof e.contains==`function`&&e.contains(n.target)||t()},window.addEventListener(`resize`,e._reanchor),window.addEventListener(`scroll`,e._reanchorScroll,!0)}function r(e){e?._reanchor&&(window.removeEventListener(`resize`,e._reanchor),window.removeEventListener(`scroll`,e._reanchorScroll,!0),e._reanchor=null,e._reanchorScroll=null)}export{n,r,t};
1
+ function e(e,t){let n=t.offsetWidth,r=t.offsetHeight,i=e.right+4+n>window.innerWidth-4,a=i?e.left-4-n:e.right+4;t.style.left=`${Math.max(4,a)}px`,t.style.top=`${Math.max(4,Math.min(e.top,window.innerHeight-r-4))}px`,t.dataset.side=i?`start`:`end`}function t(t,n,r={}){if(!t||!n)return;n.style.position=`fixed`;let i=t.getBoundingClientRect();if(r.beside){e(i,n);return}let a=r.clampHeight?n.scrollTop:0;r.clampHeight&&(n.style.maxHeight=``);let o=n.offsetHeight,s=window.innerHeight-i.bottom,c=!r.below&&s<o+4&&i.top>s;if(n.classList.toggle(`drop-up`,c),n.style.top=c?`${Math.max(4,i.top-o-4)}px`:`${i.bottom+4}px`,r.clampHeight){let e=c?i.top-8:window.innerHeight-i.bottom-8;e<o&&(n.style.maxHeight=`${Math.max(e,0)}px`),n.scrollTop=a}r.matchWidth&&(i.width>=300?(n.style.minWidth=`${i.width}px`,n.style.width=`${i.width}px`,n.style.maxWidth=`${i.width}px`):(n.style.minWidth=`${i.width}px`,n.style.width=`max-content`,n.style.maxWidth=`${Math.min(400,window.innerWidth-8)}px`));let l=n.offsetWidth;if(r.alignEnd){let e=i.right-l,t=e>=8?e:i.left,r=Math.max(8,Math.min(t,window.innerWidth-l-8));n.style.left=`${r}px`}else{let e=Math.min(i.left,window.innerWidth-l-4);n.style.left=`${Math.max(4,e)}px`}}function n(e,t){r(e),e._reanchor=t,e._reanchorScroll=n=>{n.composedPath().includes(e)||t()},window.addEventListener(`resize`,e._reanchor),window.addEventListener(`scroll`,e._reanchorScroll,!0)}function r(e){e?._reanchor&&(window.removeEventListener(`resize`,e._reanchor),window.removeEventListener(`scroll`,e._reanchorScroll,!0),e._reanchor=null,e._reanchorScroll=null)}export{n,r,t};
@@ -1,2 +1,2 @@
1
- import{n as e,t}from"./fieldState-D-zQcXUS.js";import{t as n}from"./iconGlyphs.g-BlwTSNXS.js";import{a as r,i,n as a,r as o}from"./optionLabel-CLemms21.js";import{t as s}from"./customRule-BE7CusA3.js";import{r as c}from"./WuiSelect-BEhh06ZD.js";var l={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},u={enter:`
1
+ import{n as e,t}from"./fieldState-D-zQcXUS.js";import{t as n}from"./iconGlyphs.g-BlwTSNXS.js";import{a as r,i,n as a,r as o}from"./optionLabel-CLemms21.js";import{t as s}from"./customRule-BE7CusA3.js";import{r as c}from"./WuiSelect-oSJPev4N.js";var l={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},u={enter:`
2
2
  `,comma:`,`,space:` `,tab:` `},d=e=>l[e],ee=e=>u[e];function te(e,t){let n=[String(e??``)];for(let e of t)n=n.flatMap(t=>t.split(e));return n.map(e=>e.trim()).filter(Boolean)}var ne=(e,t)=>t.some(t=>String(e??``).includes(t)),f=(e,t)=>{let n=document.createElement(e);return n.className=t,n};function p(){let l=null,u=null,p=null,m=null,h=null,g=null,_=null,v=null,y=null,b=null,x=!1,S=()=>l.mode===`tag`,C=()=>Array.isArray(l.value)?l.value.slice():[],w=()=>(l.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()).filter(Boolean),re=()=>new Set(w().map(d).filter(Boolean)),T=()=>{let e=parseInt(l.getAttribute(`max-tags`),10);return e>0?e:0},E=()=>{let e=T();return e>0&&C().length>=e},D=(e,t)=>!l.hasAttribute(`allow-duplicates`)&&e.some(e=>e.toLowerCase()===t.toLowerCase()),O=e=>(l.options||[]).find(t=>String(t.value)===String(e)),k=e=>{let t=e.trim().toLowerCase();return(l.options||[]).find(e=>String(e.value??``).toLowerCase()===t||i(e).trim().toLowerCase()===t)},A=e=>{for(let t of w()){let n=ee(t)??t;if(ne(e,[n]))return te(e,[n])}return[e.trim()]},j=()=>m?m.value:l._query||``,ie=()=>S()||l.hasAttribute(`allow-custom`),M=()=>l.getAttribute(`placeholder`)||(S()?`Add…`:`Select…`),N=()=>{let e=l.getAttribute(`aria-label`);if(e)return e;let t=l.closest(`label`)?.textContent.trim();if(t)return t;let n=l.id;return(n?[...document.querySelectorAll(`label[for]`)].find(e=>e.htmlFor===n):null)?.textContent.trim()||(S()?`Add tags`:`Select`)},P=()=>{m&&(m.setAttribute(`aria-expanded`,String(!u.menu.hidden)),u.list.id&&m.setAttribute(`aria-controls`,u.list.id),m.setAttribute(`aria-label`,N()))},F=()=>!e(l)&&!l.hasAttribute(`loading`),ae=e=>{x=!0,m.setAttribute(`aria-invalid`,`true`),l.setError(e)},I=()=>{x&&(x=!1,m.removeAttribute(`aria-invalid`),l.setError(null))},L=(e,{quiet:t=!1,strip:n=!1}={})=>{let r=C(),i=r.slice(),a=T(),o=[],c=``,u=!1;for(let t of e){let e=(n?t.trim().replace(/,+$/,``):t).trim();if(!e)continue;if(a&&i.length>=a)break;let r=k(e);if(r){if(r.disabled){o.push(e),c||=r.disabledHint||l.getAttribute(`invalid-message`)||`That option is not available.`;continue}D(i,String(r.value))||i.push(String(r.value));continue}let d=s(l,e);d?(o.push(e),c||=d):D(i,e)||(i.push(e),u=!0)}i.length!==r.length&&(u?l.commit(i,{isCustom:!0}):l.commit(i)),m.value=o.join(`, `),c?t||ae(c):I()},R=e=>{t(l)||L([m.value],e)},z=e=>l.commit(C().filter(t=>t!==e)),oe=()=>{let e=f(`span`,`wui-select-placeholder`);return e.textContent=l.getAttribute(`placeholder`)||`Select…`,e},B=e=>{let t=O(e),s=f(`span`,`chip chip-sm`),c=f(`span`,`chip-label`);if(c.innerHTML=t?o(t):a(e),s.append(c),F()){let a=f(`button`,`chip-remove`);a.type=`button`,a.dataset.remove=e;let o=t?i(t):r(e);a.setAttribute(`aria-label`,`Remove ${o}`),a.innerHTML=n(`x`),s.append(a)}return s};function V(){if(!p)return;p.querySelector(`:scope > .chip-more`)?.remove();let e=[...p.querySelectorAll(`:scope > .chip`)];for(let t of e)t.style.display=``;if(!l.hasAttribute(`collapse-chips`)||!e.length)return;let t=p.clientWidth,n=e=>e.offsetLeft+e.offsetWidth;if(n(e[e.length-1])<=t)return;let r=f(`span`,`chip chip-sm chip-more`);r.textContent=`+${e.length}`,e[e.length-1].after(r);let i=r.offsetWidth+6,a=0;for(let r of e)if(n(r)<=t-i)a+=1;else break;a<1&&(a=1);for(let t=a;t<e.length;t+=1)e[t].style.display=`none`;r.textContent=`+${e.length-a}`}function H(){if(!p)return!1;p.parentNode!==u.value&&u.value.append(p);for(let e of p.querySelectorAll(`:scope > .chip, :scope > .wui-select-placeholder`))e.remove();let e=C(),n=e=>m?p.insertBefore(e,m):p.append(e);S()||m||e.length||n(oe());for(let t of e)n(B(t));return m&&(m.placeholder=S()||!e.length?M():``,m.disabled=l.hasAttribute(`disabled`),m.readOnly=t(l),P()),S()||(g.textContent=(l.getAttribute(`selected-text`)||`{n} selected`).replace(`{n}`,()=>String(e.length)),_.textContent=l.getAttribute(`clear-all-label`)||`Clear all`),V(),!0}function U(e){if(e.key===`Backspace`)return!(m?!j():!j()&&!u.menu.hidden)||!C().length?!1:(e.preventDefault(),z(C().at(-1)),!0);if(!m)return!1;let t=m.value;if(e.key===`Escape`){if(!S())return!1;let n=!u.menu.hidden;return!n&&!t?!1:(n&&(e.preventDefault(),e.stopPropagation()),m.value=``,I(),l.closeMenu({focusControl:!1}),!0)}let n=!S()&&!t.trim(),r=re();return e.key===`Enter`&&r.has(`Enter`)?n||u.list.querySelector(`.is-active`)?!1:(e.preventDefault(),R(),!0):e.key===`,`&&r.has(`,`)?!n&&(e.preventDefault(),R({strip:!0}),!0):e.key===` `&&r.has(` `)&&t.trim()||e.key===`Tab`&&r.has(`Tab`)&&!n?(e.preventDefault(),R(),!0):!1}function W(e){let t=String(e.value);if(S()||m&&!O(t))return L([t]),!0;let n=C();return n.includes(t)?l.commit(n.filter(e=>e!==t)):m?L([t]):l.commit([...n,t]),m?.value&&(m.value=``,I()),!0}function G(e){if(!m)return null;let t=String(e??``).trim().replace(/,+$/,``).trim();if(!t||E()||k(t)||D(C(),t))return null;let n=l.getAttribute(`create-label`)||`Create '{text}'`;return{position:S()?`top`:`bottom`,label:n.replace(`{text}`,()=>t),value:t}}function K(e){let n=e.target.closest?.(`[data-remove]`);if(n){if(t(l))return;e.stopPropagation(),z(n.dataset.remove),m?.focus()}else m&&!t(l)&&m.focus()}function q(){I();let e=m.value.trim();!S()&&e&&u.menu.hidden&&(G(e)||c(l.options||[],e).length)&&l.openMenu()}function J(e){e.preventDefault(),t(l)||L(A(e.clipboardData?.getData(`text/plain`)??``))}function Y(){m.value.trim()&&R({quiet:!0,strip:!0}),l.closeMenu({focusControl:!1})}function X(e){e.relatedTarget&&l.contains(e.relatedTarget)||Y()}function se(){return m?(Y(),!0):!1}function Z(){m.value.trim()&&R({strip:!0})}function Q(){t(l)||l.commit([])}function $(e){e.target!==m&&e.preventDefault()}function ce(e,t,n={}){l=e,u=t,p=f(`div`,`wui-select-chips`),p.addEventListener(`click`,K),u.value.append(p),ie()&&(m=f(`input`,`wui-select-draft`),m.type=`text`,m.setAttribute(`autocomplete`,`off`),m.setAttribute(`role`,`combobox`),m.setAttribute(`aria-autocomplete`,`list`),l.hasAttribute(`required`)&&m.setAttribute(`aria-required`,`true`),b=new MutationObserver(P),b.observe(u.menu,{attributes:!0,attributeFilter:[`hidden`]}),p.append(m),m.value=n.carry?.draft??``,u.input=m,m.addEventListener(`input`,q),m.addEventListener(`paste`,J),m.addEventListener(`blur`,X),p.addEventListener(`mousedown`,$),v=l.closest(`form`),v?.addEventListener(`submit`,Z,!0)),S()||(h=f(`div`,`wui-select-footer`),g=document.createElement(`span`),_=f(`button`,`wui-select-clear-all`),_.type=`button`,_.addEventListener(`click`,Q),h.append(g,_),u.menu.append(h)),typeof ResizeObserver<`u`&&(y=new ResizeObserver(V),y.observe(p)),H()}function le(){p?.removeEventListener(`click`,K),p?.removeEventListener(`mousedown`,$),m&&(m.removeEventListener(`input`,q),m.removeEventListener(`paste`,J),m.removeEventListener(`blur`,X),u.input=null),_&&_.removeEventListener(`click`,Q),v?.removeEventListener(`submit`,Z,!0),v=null,y?.disconnect(),y=null,b?.disconnect(),b=null,h?.remove(),p?.remove(),p=null,m=null,h=null,x=!1}return{mount:ce,onKey:U,onPick:W,renderValue:H,actionRow:G,onQuery:()=>!1,onBlur:se,teardown:le}}export{p as default};