@webority/ui-elements 0.85.1 → 0.86.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 (92) hide show
  1. package/dist/{WuiAutocomplete-DpPpa4FC.js → WuiAutocomplete-CVTtzE8O.js} +1 -1
  2. package/dist/{WuiCodeBlock-DIPE7V93.js → WuiCodeBlock-DsSayJ8U.js} +1 -1
  3. package/dist/{WuiCommandPalette-BROO_xyP.js → WuiCommandPalette-CBg6i4WJ.js} +1 -1
  4. package/dist/{WuiCommentThread-DqKktFs2.js → WuiCommentThread-CfOeJvxg.js} +1 -1
  5. package/dist/{WuiConsentBanner-BDeCCk6b.js → WuiConsentBanner-DMWHSFsl.js} +1 -1
  6. package/dist/{WuiCountrySelect-8zZAl6bH.js → WuiCountrySelect-BHHVP7lK.js} +1 -1
  7. package/dist/{WuiDatePicker-CEabNb5D.js → WuiDatePicker-BQn1d_RD.js} +1 -1
  8. package/dist/{WuiDateRange-CshFgseR.js → WuiDateRange-la8pKreY.js} +1 -1
  9. package/dist/{WuiInlineEdit-BkzYdhpE.js → WuiInlineEdit-CpyX_apm.js} +1 -1
  10. package/dist/{WuiLightbox-D6aI_3tH.js → WuiLightbox-B4dopmSI.js} +1 -1
  11. package/dist/WuiMarkdown-C2flvSIt.js +4 -0
  12. package/dist/{WuiMentionInput-DWuua2rm.js → WuiMentionInput-ix9Wljhc.js} +1 -1
  13. package/dist/{WuiMultiSelect-C1XQnhfW.js → WuiMultiSelect-D9PgSeYk.js} +1 -1
  14. package/dist/{WuiNotificationCenter-D8z-xECD.js → WuiNotificationCenter-DDSPUlD7.js} +1 -1
  15. package/dist/{WuiPhone-BwFv7s0F.js → WuiPhone-CUwTgWQV.js} +1 -1
  16. package/dist/WuiRollingNumber-C85kOshZ.js +1 -0
  17. package/dist/{WuiSelect-1nRsHfEt.js → WuiSelect-mCt7_AzU.js} +1 -1
  18. package/dist/{WuiTagInput-hAQ14Wgk.js → WuiTagInput-Dh7bbhJr.js} +1 -1
  19. package/dist/{WuiTimePicker-DXljDDxI.js → WuiTimePicker-Ct7kghAZ.js} +1 -1
  20. package/dist/{WuiTree-B7TFIZWp.js → WuiTree-y0l3zwAg.js} +1 -1
  21. package/dist/WuiWizardStep-C9fh4xOu.js +1 -0
  22. package/dist/elements/autocomplete.js +1 -1
  23. package/dist/elements/code-block.js +1 -1
  24. package/dist/elements/command-palette.js +1 -1
  25. package/dist/elements/comment-thread.js +1 -1
  26. package/dist/elements/consent-banner.js +1 -1
  27. package/dist/elements/country-select.js +1 -1
  28. package/dist/elements/date-range.js +1 -1
  29. package/dist/elements/datepicker.js +1 -1
  30. package/dist/elements/inline-edit.js +1 -1
  31. package/dist/elements/kanban.js +1 -1
  32. package/dist/elements/lightbox.js +1 -1
  33. package/dist/elements/markdown.js +1 -1
  34. package/dist/elements/mention-input.js +1 -1
  35. package/dist/elements/multiselect.js +1 -1
  36. package/dist/elements/notification-center.js +1 -1
  37. package/dist/elements/phone.js +1 -1
  38. package/dist/elements/rolling-number.js +1 -1
  39. package/dist/elements/select.js +1 -1
  40. package/dist/elements/taginput.js +1 -1
  41. package/dist/elements/timepicker.js +1 -1
  42. package/dist/elements/tree.js +1 -1
  43. package/dist/elements/wizard.js +1 -1
  44. package/dist/{fileViewerImage-Bcsaoyei.js → fileViewerImage-_A5O4Prg.js} +1 -1
  45. package/dist/{fileViewerMedia-B2kIU6tb.js → fileViewerMedia-Cbw07F8S.js} +1 -1
  46. package/dist/{fileViewerPdf-DuRqS6OC.js → fileViewerPdf-vDzO8lfR.js} +1 -1
  47. package/dist/fileViewerUi-Ct9zwiaF.js +1 -0
  48. package/dist/helpers.js +1 -1
  49. package/dist/iconGlyphs.g-BNrdQ7It.js +1 -0
  50. package/dist/{kanban-CxpZlQDL.js → kanban-DRF61Mib.js} +1 -1
  51. package/dist/{optionLabel-Bd3vP-XI.js → optionLabel-Bul5mgul.js} +1 -1
  52. package/dist/ui-chat-core.js +1 -1
  53. package/dist/ui-chat.global.js +2 -2
  54. package/dist/ui-chat.js +2 -2
  55. package/dist/ui-consent-banner.global.js +1 -1
  56. package/dist/ui-elements/autocomplete.global.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 +1 -1
  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 +1 -1
  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/lightbox.global.js +1 -1
  69. package/dist/ui-elements/markdown.global.js +2 -2
  70. package/dist/ui-elements/menubar.global.js +1 -1
  71. package/dist/ui-elements/multiselect.global.js +1 -1
  72. package/dist/ui-elements/phone.global.js +1 -1
  73. package/dist/ui-elements/resizable.global.js +1 -1
  74. package/dist/ui-elements/slider.global.js +1 -1
  75. package/dist/ui-elements/sortable.global.js +1 -1
  76. package/dist/ui-elements/status-icon.global.js +1 -1
  77. package/dist/ui-elements/taginput.global.js +1 -1
  78. package/dist/ui-elements/timepicker.global.js +1 -1
  79. package/dist/ui-elements/tour.global.js +1 -1
  80. package/dist/ui-elements/tree.global.js +1 -1
  81. package/dist/ui-elements/wizard.global.js +1 -1
  82. package/dist/ui-elements.global.js +3 -3
  83. package/dist/ui-elements.js +1 -1
  84. package/dist/ui-file-viewer.global.js +1 -1
  85. package/dist/ui-file-viewer.js +1 -1
  86. package/dist/{wuiHttp-Cu7OPWr2.js → wuiHttp-DJ1oIvtB.js} +1 -1
  87. package/package.json +1 -1
  88. package/dist/WuiMarkdown-DZ5CMeCz.js +0 -4
  89. package/dist/WuiRollingNumber-fiD54wsj.js +0 -1
  90. package/dist/WuiWizardStep-D46JBR4c.js +0 -1
  91. package/dist/fileViewerUi-CmfISSyD.js +0 -1
  92. package/dist/iconGlyphs.g-Bk8AzmSO.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as a,t as o}from"./focusOrigin-2imUSs-u.js";import{t as s}from"./formMirror-BgY7zkC3.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{a as u,i as d,n as f,r as p,t as m}from"./optionLabel-Bd3vP-XI.js";var h=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`]}constructor(){super(),this._value=``,this._label=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();return}if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),s(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?d(t):``,this._syncInput(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=d(t)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),this._renderOptions()}get loading(){return this._loading}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>d(e).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){let e=+!!this._remote,t=this.getAttribute(`min-chars`);if(t==null||t.trim()===``)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[m]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r,this.innerHTML=`
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-BNrdQ7It.js";import{n as a,t as o}from"./focusOrigin-2imUSs-u.js";import{t as s}from"./formMirror-BgY7zkC3.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{a as u,i as d,n as f,r as p,t as m}from"./optionLabel-Bul5mgul.js";var h=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`]}constructor(){super(),this._value=``,this._label=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();return}if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),s(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?d(t):``,this._syncInput(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=d(t)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),this._renderOptions()}get loading(){return this._loading}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>d(e).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){let e=+!!this._remote,t=this.getAttribute(`min-chars`);if(t==null||t.trim()===``)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[m]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r,this.innerHTML=`
2
2
  <div class="search-select${n}">
3
3
  <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${g(r)}" aria-label="${g(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}>
4
4
  <input class="search-select-input search-select-ac-input" placeholder="${g(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``} />
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{t}from"./iconGlyphs.g-Bk8AzmSO.js";import{n,t as r}from"./copyText-DM5HhXjf.js";var i=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),a=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),o=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),s=`(?![\\s\\S])`,c=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${s})`).source,l=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,o([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],u=[[`comment`,RegExp(`//[^\\n]*|${c}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,o(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,o([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],d=[[`comment`,RegExp(`//[^\\n]*|${c}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,o(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,o([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],f=[[`comment`,RegExp(`--[^\\n]*|${c}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,o(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,o([`true`,`false`])],[`type`,o([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],p=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,o([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,o(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],m=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],h=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${s})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],g={json:l,js:u,cs:d,sql:f,bash:p,http:m,css:[[`comment`,new RegExp(c)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:h,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},_=new Map;function v(e){let t=_.get(e);if(!t){let n=g[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},_.set(e,t)}return t}function y(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function b(e,t,n=[]){let{re:r,types:i}=v(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;y(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?b(`htmlTag`,o[0],n):y(n,i[r],o[0]),a=o.index+o[0].length}return y(n,`plain`,t.slice(a)),n}function x(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return b(`http`,e);let n=b(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?b(`json`,r,n):i===`<`?b(`html`,r,n):(y(n,`plain`,r),n)}function S(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?x(n):!Object.hasOwn(g,t)||t===`htmlTag`?[[`plain`,n]]:b(t,n)}function C(e,t){let n=[[]];for(let[r,i]of S(e,t))i.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&n.push([]),e&&n[n.length-1].push([r,e])});return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var w=class extends e{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._observer=null,this._timer=0}connectedCallback(){this._render(),!(typeof MutationObserver>`u`)&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,clearTimeout(this._timer)}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_render(){let e=this._source();if(!e)return;clearTimeout(this._timer);let t=this.ownerDocument,n=(e.textContent??``).replace(/\r?\n$/,``),r=this.getAttribute(`language`),o=i.includes(r)?r:`text`,s=this.getAttribute(`label`)||``,c=C(n,o),l=t.createElement(`div`);l.className=`wui-code-chrome`,l.append(this._bar(t,s||a[o],n));let u=t.createElement(`div`);u.className=`wui-code-view`,u.setAttribute(`role`,`region`),u.setAttribute(`aria-label`,s||`Code`),u.tabIndex=0,u.style.setProperty(`--wui-code-digits`,String(String(c.length).length));let d=t.createElement(`pre`);d.className=`wui-code-pre`;let f=t.createElement(`code`);for(let e of c){let n=t.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of e){if(r===`plain`){n.append(i);continue}let e=t.createElement(`span`);e.className=`wui-code-t-${r}`,e.textContent=i,n.append(e)}f.append(n)}d.append(f),u.append(d),l.append(u),this._chrome?.remove(),this._chrome=l,this.append(l),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_bar(e,i,a){let o=e.createElement(`div`);o.className=`wui-code-bar`;let s=e.createElement(`span`);s.className=`wui-code-title`,s.textContent=i;let c=this.getAttribute(`copy-label`)||`Copy`,l=this.getAttribute(`copied-label`)||`Copied`,u=e.createElement(`button`);u.type=`button`,u.className=`btn btn-ghost btn-sm wui-code-copy`,u.setAttribute(`aria-live`,`polite`);let d=e.createElement(`span`);d.className=`wui-code-copy-icon`;let f=e.createElement(`span`),p=e=>{d.innerHTML=t(e?`check`:`files`,{size:14}),f.textContent=e?l:c};return p(!1),u.append(d,f),u.addEventListener(`click`,async()=>{await n(a)&&(p(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>p(!1),r))}),o.append(s,u),o}};export{w as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{t}from"./iconGlyphs.g-BNrdQ7It.js";import{n,t as r}from"./copyText-DM5HhXjf.js";var i=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),a=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),o=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),s=`(?![\\s\\S])`,c=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${s})`).source,l=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,o([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],u=[[`comment`,RegExp(`//[^\\n]*|${c}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,o(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,o([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],d=[[`comment`,RegExp(`//[^\\n]*|${c}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,o(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,o([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],f=[[`comment`,RegExp(`--[^\\n]*|${c}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,o(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,o([`true`,`false`])],[`type`,o([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],p=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,o([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,o(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],m=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],h=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${s})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],g={json:l,js:u,cs:d,sql:f,bash:p,http:m,css:[[`comment`,new RegExp(c)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:h,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},_=new Map;function v(e){let t=_.get(e);if(!t){let n=g[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},_.set(e,t)}return t}function y(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function b(e,t,n=[]){let{re:r,types:i}=v(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;y(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?b(`htmlTag`,o[0],n):y(n,i[r],o[0]),a=o.index+o[0].length}return y(n,`plain`,t.slice(a)),n}function x(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return b(`http`,e);let n=b(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?b(`json`,r,n):i===`<`?b(`html`,r,n):(y(n,`plain`,r),n)}function S(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?x(n):!Object.hasOwn(g,t)||t===`htmlTag`?[[`plain`,n]]:b(t,n)}function C(e,t){let n=[[]];for(let[r,i]of S(e,t))i.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&n.push([]),e&&n[n.length-1].push([r,e])});return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var w=class extends e{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._observer=null,this._timer=0}connectedCallback(){this._render(),!(typeof MutationObserver>`u`)&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,clearTimeout(this._timer)}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_render(){let e=this._source();if(!e)return;clearTimeout(this._timer);let t=this.ownerDocument,n=(e.textContent??``).replace(/\r?\n$/,``),r=this.getAttribute(`language`),o=i.includes(r)?r:`text`,s=this.getAttribute(`label`)||``,c=C(n,o),l=t.createElement(`div`);l.className=`wui-code-chrome`,l.append(this._bar(t,s||a[o],n));let u=t.createElement(`div`);u.className=`wui-code-view`,u.setAttribute(`role`,`region`),u.setAttribute(`aria-label`,s||`Code`),u.tabIndex=0,u.style.setProperty(`--wui-code-digits`,String(String(c.length).length));let d=t.createElement(`pre`);d.className=`wui-code-pre`;let f=t.createElement(`code`);for(let e of c){let n=t.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of e){if(r===`plain`){n.append(i);continue}let e=t.createElement(`span`);e.className=`wui-code-t-${r}`,e.textContent=i,n.append(e)}f.append(n)}d.append(f),u.append(d),l.append(u),this._chrome?.remove(),this._chrome=l,this.append(l),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_bar(e,i,a){let o=e.createElement(`div`);o.className=`wui-code-bar`;let s=e.createElement(`span`);s.className=`wui-code-title`,s.textContent=i;let c=this.getAttribute(`copy-label`)||`Copy`,l=this.getAttribute(`copied-label`)||`Copied`,u=e.createElement(`button`);u.type=`button`,u.className=`btn btn-ghost btn-sm wui-code-copy`,u.setAttribute(`aria-live`,`polite`);let d=e.createElement(`span`);d.className=`wui-code-copy-icon`;let f=e.createElement(`span`),p=e=>{d.innerHTML=t(e?`check`:`files`,{size:14}),f.textContent=e?l:c};return p(!1),u.append(d,f),u.addEventListener(`click`,async()=>{await n(a)&&(p(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>p(!1),r))}),o.append(s,u),o}};export{w as t};
@@ -1,2 +1,2 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t}from"./optionLabel-Bd3vP-XI.js";import{t as n}from"./textMatch-wdY7XLIc.js";var r=`[role="option"]`,i=`No results`,a=`All`,o=`Recent`,s=5,c=20,l=`.wui-cmd-back, [data-depth]`,u=0,d=class extends e{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++u}`,this._onModalHidden=()=>this._reset(),this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=e.target?.closest?.(l);if(t&&this.contains(t)){let e=t.matches(`.wui-cmd-back`)?this._path.length-1:Number(t.dataset.depth);this._goTo(this._path.slice(0,e));return}let n=this._optionFrom(e.target);n&&this._select(n)},this._onMouseDown=e=>{let t=e.target?.closest?.(l);(t&&this.contains(t)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{!this.hasAttribute(`filter`)||e.target!==this._input()||(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`.modal`),this._modal?.addEventListener(`hidden.bs.modal`,this._onModalHidden),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??i}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t}from"./optionLabel-Bul5mgul.js";import{t as n}from"./textMatch-wdY7XLIc.js";var r=`[role="option"]`,i=`No results`,a=`All`,o=`Recent`,s=5,c=20,l=`.wui-cmd-back, [data-depth]`,u=0,d=class extends e{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++u}`,this._onModalHidden=()=>this._reset(),this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=e.target?.closest?.(l);if(t&&this.contains(t)){let e=t.matches(`.wui-cmd-back`)?this._path.length-1:Number(t.dataset.depth);this._goTo(this._path.slice(0,e));return}let n=this._optionFrom(e.target);n&&this._select(n)},this._onMouseDown=e=>{let t=e.target?.closest?.(l);(t&&this.contains(t)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{!this.hasAttribute(`filter`)||e.target!==this._input()||(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`.modal`),this._modal?.addEventListener(`hidden.bs.modal`,this._onModalHidden),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??i}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
2
2
  `),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1),this._setActive(o??r[0]??null,n)}_input(){return this.querySelector(`[role="combobox"]`)}_optionFrom(e,t=!1){let n=e?.closest?.(r);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden||!!e.closest(`[role="group"]`)?.hidden}_selectableOptions(){return[...this.querySelectorAll(r)].filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of this.querySelectorAll(r))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setActive(t[r],!0)}_handleKeyDown(e){if(e.target===this._input()){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!e.target.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=[...this.querySelectorAll(`.wui-cmd-page`)].find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_restart(){let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=this.querySelector(`.wui-cmd-crumbs`);if(!e)return;let t=this.getAttribute(`root-label`)??a,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=e.querySelector(`.wui-cmd-trail`);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);return a.className=`wui-cmd-crumb`,a.textContent=e,r?a.setAttribute(`aria-current`,`page`):(a.type=`button`,a.dataset.depth=String(t)),n.append(a),n}))}_recentsHost(){return this.querySelector(`.wui-cmd-recents`)}_realOptions(){let e=this._recentsHost();return[...this.querySelectorAll(r)].filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>!(e.g===n&&e.k===r))];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch{}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries():[],r=this._realOptions(),i=[];for(let e of n){let t=r.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&i.push(t),i.length>=this._recentsLimit())break}if(!i.length){e.firstChild&&e.replaceChildren();return}let a=`${this._recentsId}-label`,s=document.createElement(`div`);s.className=`wui-cmd-group`,s.setAttribute(`role`,`group`),s.setAttribute(`aria-labelledby`,a);let c=document.createElement(`div`);c.className=`wui-cmd-group-label`,c.setAttribute(`role`,`presentation`),c.id=a,c.textContent=this.getAttribute(`recents-label`)??o,s.append(c);for(let e of i){let t=e.cloneNode(!0);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),s.append(t)}e.replaceChildren(s)}_inScope(e,t){return!t||(e.closest(`.wui-cmd-page`)?.dataset.page??null)===(this._path.at(-1)?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),i=(e?e.value:``).trim(),a=i.toLowerCase(),o=this.highlight,s=[...this.querySelectorAll(`.wui-cmd-page`)],c=s.length>0,l=this._path.at(-1)?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=0;for(let e of this._realOptions()){let r=e.querySelector(`.wui-cmd-item-label`),s=e.dataset.label??r?.textContent??``,l=this._inScope(e,c)&&(!a||s.toLowerCase().includes(a));e.hidden=!l,l&&u++,r&&(r.innerHTML=n(s,o?i:``).map(e=>e.match?`<mark class="wui-cmd-mark">${t(e.text)}</mark>`:t(e.text)).join(``))}let d=this._recentsHost();for(let e of this.querySelectorAll(`[role="group"]`))d?.contains(e)||(e.hidden=![...e.querySelectorAll(r)].some(e=>!e.hidden));let f=this.querySelector(`[role="listbox"]`);f&&(f.hidden=u===0);let p=this.querySelector(`.wui-cmd-empty`);p&&(p.textContent=a&&u===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`hidden.bs.modal`,this._onModalHidden),this._modal=null}};export{d as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{c as i}from"./wuiHttp-Cu7OPWr2.js";var a=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),o=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),s=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),c=`[data-wui-items]`,l=`[data-wui-picker]`,u=`[data-wui-composer]`,d=`[data-wui-comment]`,f=`[data-wui-live]`,p=e=>typeof e?.message==`string`&&e.message?e.message:s.failed.server,m=class extends e{constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(l)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&r(this._pickerFor.button,this.querySelector(l))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),this._handPeople(this.querySelector(`${u} wui-mention-input`)))}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:a}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(l),n=e?this._pickerFor?.comment:t.closest(d);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(d);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n);break}}_onKeyDown(e){let t=this.querySelector(l);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(d),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){let n=e?.querySelector(`:scope > [data-wui-reply]`);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e.querySelector(`.wui-comment-author`)?.textContent.trim()||``;this._fillSlot(n,{label:s.replyLabel(r),placeholder:s.replyPlaceholder,value:``,send:s.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n||!n.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:s.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:s.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,c=o.createElement(`wui-mention-input`);c.className=`wui-mention-input`,c.setAttribute(`label`,t),n&&c.setAttribute(`placeholder`,n),c.setAttribute(`rows`,`2`),c.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&c.setAttribute(e,this.getAttribute(e));let l=o.createElement(`div`);l.className=`wui-comment-form-actions`,l.append(this._button(`btn btn-primary btn-sm`,`send`,i),this._button(`btn btn-ghost btn-sm`,`cancel`,s.cancel));let u=o.createElement(`div`);u.className=`wui-comment-error`,u.setAttribute(`data-wui-error`,``),u.hidden=!0,e.replaceChildren(c,l,u),this._handPeople(c),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),c.focus();let d=c.querySelector(`textarea`);d?.setSelectionRange(d.value.length,d.value.length)}_button(e,t,n){let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=e,r.setAttribute(`data-wui-action`,t),r.textContent=n,r}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(e,n){let i=this.querySelector(l);!i||!e||(this._closePicker(!1),this._pickerFor={comment:e,button:n},n.setAttribute(`aria-expanded`,`true`),i.hidden=!1,r(n,i),t(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),i.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;this._pickerFor=null;let r=this.querySelector(l);r&&(r.hidden=!0),t.button.setAttribute(`aria-expanded`,`false`),n(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&t.button.isConnected&&t.button.focus()}_react(e,t){t&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,s.emptyBody),n?.focus();return}let i=t.closest(d);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let c=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let l=t.commentId??null,u=t.parentId??null;if(c.ok){c.html!=null&&this._swapItems(c.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),s.done[e]&&this._announce(s.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:l,parentId:u}}));return}c.kind===`session`||c.kind===`aborted`||(this._showError(a.isConnected?a:this,c.message),this._announce(c.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:c.kind,message:c.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:p(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:s.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await i(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||s.failed[r.kind]||s.failed.server}}_swapItems(e){let t=this.querySelector(c);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(c);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(d)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${u} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${f}`);!t||!e||(t.textContent=``,t.textContent=e)}};export{m as i,a as n,s as r,o as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{c as i}from"./wuiHttp-DJ1oIvtB.js";var a=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),o=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),s=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),c=`[data-wui-items]`,l=`[data-wui-picker]`,u=`[data-wui-composer]`,d=`[data-wui-comment]`,f=`[data-wui-live]`,p=e=>typeof e?.message==`string`&&e.message?e.message:s.failed.server,m=class extends e{constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(l)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&r(this._pickerFor.button,this.querySelector(l))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),this._handPeople(this.querySelector(`${u} wui-mention-input`)))}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:a}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(l),n=e?this._pickerFor?.comment:t.closest(d);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(d);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n);break}}_onKeyDown(e){let t=this.querySelector(l);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(d),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){let n=e?.querySelector(`:scope > [data-wui-reply]`);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e.querySelector(`.wui-comment-author`)?.textContent.trim()||``;this._fillSlot(n,{label:s.replyLabel(r),placeholder:s.replyPlaceholder,value:``,send:s.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n||!n.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:s.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:s.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,c=o.createElement(`wui-mention-input`);c.className=`wui-mention-input`,c.setAttribute(`label`,t),n&&c.setAttribute(`placeholder`,n),c.setAttribute(`rows`,`2`),c.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&c.setAttribute(e,this.getAttribute(e));let l=o.createElement(`div`);l.className=`wui-comment-form-actions`,l.append(this._button(`btn btn-primary btn-sm`,`send`,i),this._button(`btn btn-ghost btn-sm`,`cancel`,s.cancel));let u=o.createElement(`div`);u.className=`wui-comment-error`,u.setAttribute(`data-wui-error`,``),u.hidden=!0,e.replaceChildren(c,l,u),this._handPeople(c),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),c.focus();let d=c.querySelector(`textarea`);d?.setSelectionRange(d.value.length,d.value.length)}_button(e,t,n){let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=e,r.setAttribute(`data-wui-action`,t),r.textContent=n,r}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(e,n){let i=this.querySelector(l);!i||!e||(this._closePicker(!1),this._pickerFor={comment:e,button:n},n.setAttribute(`aria-expanded`,`true`),i.hidden=!1,r(n,i),t(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),i.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;this._pickerFor=null;let r=this.querySelector(l);r&&(r.hidden=!0),t.button.setAttribute(`aria-expanded`,`false`),n(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&t.button.isConnected&&t.button.focus()}_react(e,t){t&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,s.emptyBody),n?.focus();return}let i=t.closest(d);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let c=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let l=t.commentId??null,u=t.parentId??null;if(c.ok){c.html!=null&&this._swapItems(c.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),s.done[e]&&this._announce(s.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:l,parentId:u}}));return}c.kind===`session`||c.kind===`aborted`||(this._showError(a.isConnected?a:this,c.message),this._announce(c.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:c.kind,message:c.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:p(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:s.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await i(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||s.failed[r.kind]||s.failed.server}}_swapItems(e){let t=this.querySelector(c);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(c);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(d)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${u} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${f}`);!t||!e||(t.textContent=``,t.textContent=e)}};export{m as i,a as n,s as r,o as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t}from"./devWarn-DXdRWZs3.js";import{t as n}from"./tourOpenMark-nPeAJFSo.js";var r={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-ink":`#4F46E5`,"--color-primary-text":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},i=e=>`var(${e}, ${r[e]})`,a=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${i(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${i(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${i(`--color-surface`)}; border: 1px solid ${i(`--color-border`)}; border-radius: ${i(`--wui-radius-lg`)}; box-shadow: ${i(`--wui-shadow-overlay-lg`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${i(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${i(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${i(`--color-primary-ink`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${i(`--color-border`)}; border-bottom: 1px solid ${i(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${i(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${i(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${i(`--color-primary`)}; background: ${i(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${i(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; 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; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${i(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${i(`--color-primary`)}; border-color: ${i(`--color-primary`)}; color: ${i(`--color-primary-text`)}; } .btn-primary:hover { background: ${i(`--color-primary-hover`)}; border-color: ${i(`--color-primary-hover`)}; } .btn-outline-secondary { border-color: ${i(`--color-text-muted`)}; color: ${i(`--color-text-muted`)}; } .btn-outline-secondary:hover { background: ${i(`--color-bg-muted`)}; color: ${i(`--color-text`)}; } .btn-link { font-weight: 400; color: ${i(`--color-primary-ink`)}; text-decoration: underline; } .btn-link:hover { color: ${i(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } `,o=`wui-consent-save`,s=`[data-consent-settings]`,c=`tour-open`,l=`--wui-consent-banner-block`,u=`--wui-consent-banner-inline`,d={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},f=[`analytics`,`functional`,`marketing`],p={analytics:{label:d.analyticsLabel,description:`analyticsDescription`},functional:{label:d.functionalLabel,description:`functionalDescription`},marketing:{label:d.marketingLabel,description:`marketingDescription`}},m=new Set;function h(e){m.has(e)||(m.add(e),t(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${f.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var g=0,_=null;function v(e){_||(_=new CSSStyleSheet,_.replaceSync(a)),e.adoptedStyleSheets=[_]}var y=class extends e{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g+=1,this._uid=`wui-consent-${g}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(s)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||d.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||d.description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||d.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||d.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||d.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||d.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...f];let t=e.split(/\s+/).filter(Boolean);for(let e of t)f.includes(e)||h(e);let n=f.filter(e=>t.includes(e));return n.length?n:[...f]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(f.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[n]}),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(c,document.documentElement.hasAttribute(n))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,n=this.policyHref?` <a class="wui-consent-banner-policy" href="${S(this.policyHref)}">${x(this.policyLabel)}</a>`:``,r=this._root();r!==this&&v(r),r.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden> <h2 class="wui-consent-banner-heading" id="${t}-heading">${x(this.heading)}</h2> <p class="wui-consent-banner-description" id="${t}-description">${x(this.description)}${n}</p> <div class="wui-consent-banner-settings" hidden> ${b(t,`essential`,d.essentialLabel,d.essentialDescription,!0)} ${this.categories.map(e=>b(t,e,p[e].label,this[p[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${d.settingsLabel}</button> <button type="button" class="btn btn-sm btn-outline-secondary wui-consent-banner-reject">${d.rejectLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-accept">${d.acceptLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-save" hidden>${d.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(l),document.documentElement.style.removeProperty(u)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(l,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(u,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(f.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of f)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of f){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function b(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${x(n)}</label> </div> <p class="wui-consent-banner-category-description">${x(r)}</p> </div>`}var x=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),S=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{y as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t}from"./devWarn-DXdRWZs3.js";import{t as n}from"./tourOpenMark-nPeAJFSo.js";var r={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-ink":`#4F46E5`,"--color-primary-text":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},i=e=>`var(${e}, ${r[e]})`,a=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${i(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${i(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${i(`--color-surface`)}; border: 1px solid ${i(`--color-border`)}; border-radius: ${i(`--wui-radius-lg`)}; box-shadow: ${i(`--wui-shadow-overlay-lg`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${i(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${i(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${i(`--color-primary-ink`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${i(`--color-border`)}; border-bottom: 1px solid ${i(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${i(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${i(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${i(`--color-primary`)}; background: ${i(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${i(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; 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; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${i(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${i(`--color-primary`)}; border-color: ${i(`--color-primary`)}; color: ${i(`--color-primary-text`)}; } .btn-primary:hover { background: ${i(`--color-primary-hover`)}; border-color: ${i(`--color-primary-hover`)}; } .btn-outline-secondary { border-color: ${i(`--color-text-muted`)}; color: ${i(`--color-text-muted`)}; } .btn-outline-secondary:hover { background: ${i(`--color-bg-muted`)}; color: ${i(`--color-text`)}; } .btn-link { font-weight: 400; color: ${i(`--color-primary-ink`)}; text-decoration: underline; } .btn-link:hover { color: ${i(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } `,o=`wui-consent-save`,s=`[data-consent-settings]`,c=`tour-open`,l=`--wui-consent-banner-block`,u=`--wui-consent-banner-inline`,d={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},f=[`analytics`,`functional`,`marketing`],p={analytics:{label:d.analyticsLabel,description:`analyticsDescription`},functional:{label:d.functionalLabel,description:`functionalDescription`},marketing:{label:d.marketingLabel,description:`marketingDescription`}},m=new Set;function h(e){m.has(e)||(m.add(e),t(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${f.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var g=0,_=null;function v(e){_||(_=new CSSStyleSheet,_.replaceSync(a)),e.adoptedStyleSheets=[_]}var y=class extends e{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g+=1,this._uid=`wui-consent-${g}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(s)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||d.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||d.description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||d.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||d.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||d.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||d.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...f];let t=e.split(/\s+/).filter(Boolean);for(let e of t)f.includes(e)||h(e);let n=f.filter(e=>t.includes(e));return n.length?n:[...f]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(f.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[n]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(c,document.documentElement.hasAttribute(n))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,n=this.policyHref?` <a class="wui-consent-banner-policy" href="${S(this.policyHref)}">${x(this.policyLabel)}</a>`:``,r=this._root();r!==this&&v(r),r.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden> <h2 class="wui-consent-banner-heading" id="${t}-heading">${x(this.heading)}</h2> <p class="wui-consent-banner-description" id="${t}-description">${x(this.description)}${n}</p> <div class="wui-consent-banner-settings" hidden> ${b(t,`essential`,d.essentialLabel,d.essentialDescription,!0)} ${this.categories.map(e=>b(t,e,p[e].label,this[p[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${d.settingsLabel}</button> <button type="button" class="btn btn-sm btn-outline-secondary wui-consent-banner-reject">${d.rejectLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-accept">${d.acceptLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-save" hidden>${d.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){!this.isConnected||this.preview||(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(l),document.documentElement.style.removeProperty(u)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(l,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(u,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(f.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of f)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of f){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function b(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${x(n)}</label> </div> <p class="wui-consent-banner-category-description">${x(r)}</p> </div>`}var x=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),S=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{y as t};
@@ -1 +1 @@
1
- import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-1nRsHfEt.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
1
+ import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-mCt7_AzU.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{t as a}from"./formMirror-BgY7zkC3.js";import{n as o}from"./optionLabel-Bd3vP-XI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`disabled-weekdays`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,a(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Choose a date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-BNrdQ7It.js";import{t as a}from"./formMirror-BgY7zkC3.js";import{n as o}from"./optionLabel-Bul5mgul.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`disabled-weekdays`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,a(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Choose a date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
2
  <div class="datepicker">
3
3
  <button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
4
  <span data-trigger-label class="${t?``:`search-select-placeholder`}">${o(t?d(this._value,this.getAttribute(`display-format`)):e)}</span>
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as o}from"./optionLabel-Bd3vP-XI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=`Asia/Kolkata`,g=3,_=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],v={today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisFinancialYear:`This financial year`},y=e=>String(e).padStart(2,`0`),b=e=>`${e.getUTCFullYear()}-${y(e.getUTCMonth()+1)}-${y(e.getUTCDate())}`;function x(e=new Date){let t=new Intl.DateTimeFormat(`en-US`,{timeZone:h,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(e),n=e=>t.find(t=>t.type===e).value;return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}function S(e,t=new Date){let{y:n,m:r,d:i}=p(x(t)),a=(e,t,n)=>b(new Date(Date.UTC(e,t,n))),o=v[e];switch(e){case`today`:return{label:o,start:a(n,r,i),end:a(n,r,i)};case`yesterday`:return{label:o,start:a(n,r,i-1),end:a(n,r,i-1)};case`last7Days`:return{label:o,start:a(n,r,i-6),end:a(n,r,i)};case`last30Days`:return{label:o,start:a(n,r,i-29),end:a(n,r,i)};case`thisMonth`:return{label:o,start:a(n,r,1),end:a(n,r+1,0)};case`lastMonth`:return{label:o,start:a(n,r-1,1),end:a(n,r,0)};case`thisFinancialYear`:{let e=r>=g?n:n-1;return{label:o,start:a(e,g,1),end:a(e+1,g,0)}}default:return null}}function C(e){i(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function w(e,t=new Date){let n=String(e??``).trim();if(!n)return[];let r;if(n.startsWith(`[`))try{r=JSON.parse(n)}catch{return C(`the attribute is not valid JSON`),[]}else r=n.split(`,`).map(e=>e.trim());let i=[];for(let e of r)if(typeof e==`string`){let n=S(e,t);n?i.push(n):C(`"${e}" is not one of ${_.join(`, `)}`)}else e&&typeof e.label==`string`&&e.label&&p(e.start)&&p(e.end)?i.push({label:e.label,start:e.start,end:e.end}):C(`an item needs a label and ISO start and end dates, or a preset name`);return i}var T=class extends e{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return s(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${d(this._start)||`Start`} to ${d(this._end)||`End`}`,empty:!1}}render(){this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=p(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:i}=this._label(),s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-BNrdQ7It.js";import{n as o}from"./optionLabel-Bul5mgul.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=`Asia/Kolkata`,g=3,_=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],v={today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisFinancialYear:`This financial year`},y=e=>String(e).padStart(2,`0`),b=e=>`${e.getUTCFullYear()}-${y(e.getUTCMonth()+1)}-${y(e.getUTCDate())}`;function x(e=new Date){let t=new Intl.DateTimeFormat(`en-US`,{timeZone:h,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(e),n=e=>t.find(t=>t.type===e).value;return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}function S(e,t=new Date){let{y:n,m:r,d:i}=p(x(t)),a=(e,t,n)=>b(new Date(Date.UTC(e,t,n))),o=v[e];switch(e){case`today`:return{label:o,start:a(n,r,i),end:a(n,r,i)};case`yesterday`:return{label:o,start:a(n,r,i-1),end:a(n,r,i-1)};case`last7Days`:return{label:o,start:a(n,r,i-6),end:a(n,r,i)};case`last30Days`:return{label:o,start:a(n,r,i-29),end:a(n,r,i)};case`thisMonth`:return{label:o,start:a(n,r,1),end:a(n,r+1,0)};case`lastMonth`:return{label:o,start:a(n,r-1,1),end:a(n,r,0)};case`thisFinancialYear`:{let e=r>=g?n:n-1;return{label:o,start:a(e,g,1),end:a(e+1,g,0)}}default:return null}}function C(e){i(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function w(e,t=new Date){let n=String(e??``).trim();if(!n)return[];let r;if(n.startsWith(`[`))try{r=JSON.parse(n)}catch{return C(`the attribute is not valid JSON`),[]}else r=n.split(`,`).map(e=>e.trim());let i=[];for(let e of r)if(typeof e==`string`){let n=S(e,t);n?i.push(n):C(`"${e}" is not one of ${_.join(`, `)}`)}else e&&typeof e.label==`string`&&e.label&&p(e.start)&&p(e.end)?i.push({label:e.label,start:e.start,end:e.end}):C(`an item needs a label and ISO start and end dates, or a preset name`);return i}var T=class extends e{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return s(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${d(this._start)||`Start`} to ${d(this._end)||`End`}`,empty:!1}}render(){this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=p(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:i}=this._label(),s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
2
  <div class="daterange">
3
3
  <button type="button" class="input daterange-trigger${n}${i?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
4
  <span data-range-label class="${i?`search-select-placeholder`:``}">${o(r)}</span>
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import"./formatters-BAE__8ye.js";import{c as t}from"./wuiHttp-Cu7OPWr2.js";import{o as n}from"./calendarMath-BC2wGCD-.js";var r=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),i=2e3,a=Object.freeze({edit:e=>`Edit ${e}: `,readOnly:e=>`${e}: `,saved:e=>`${e} saved.`,notSaved:(e,t)=>`${e} was not saved. ${t}`,failed:Object.freeze({forbidden:`You do not have permission to change this.`,client:`This could not be saved. Refresh the page and try again.`,validation:`This value was not accepted. Check it and try again.`,server:`Something went wrong on our side, so this was not saved. Try again in a moment.`,network:`Could not reach the server, so this was not saved. Check your connection and try again.`})});function o(e,{type:t=`text`,options:r,placeholder:i}={}){let a=e==null?``:String(e);if(a===``)return{text:i||`-`,empty:!0};if(t===`date`)return{text:n(a)||a,empty:!1};if(t===`select`){let e=r?.find(e=>String(e.value)===a);return{text:typeof e?.label==`string`?e.label:a,empty:!1}}return{text:a,empty:!1}}var s=`[data-wui-display]`,c=`[data-wui-value]`,l=`[data-wui-editor]`,u=`[data-wui-control]`,d=`[data-wui-error]`,f=`[data-wui-live]`,p=`[aria-expanded="true"]`,m=new Set([`select`,`date`]),h=e=>typeof e?.message==`string`&&e.message?e.message:a.failed.server,g=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=this.querySelector(s),t=this.querySelector(l),n=this._control();!e||!t||!n||(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),e.hidden=!0,t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n))}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation(),e.type===`click`&&!this._editing&&this.querySelector(s)?.contains(e.target)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(l)?.querySelector(p))}_onKeyDown(e){if(!this._editing){(e.key===`Enter`||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||m.has(t)||t===`textarea`&&!(e.ctrlKey||e.metaKey)||(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!m.has(this._type()))return;let t=this._control();!t||e.target!==t||queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let o=r?null:this._readShown();r||this._showValue(e),this._close();let s=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let c=this.getAttribute(`label`)||``;if(s.ok){this.setAttribute(`value`,e),!r&&s.text&&this._showText(s.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),i),this._announce(a.saved(c)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t});return}if(o&&this._restoreShown(o),s.kind===`session`||s.kind===`aborted`){this._setState(null);return}this._draft=e,this._setState(`error`),this._setError(s.message),this._announce(a.notSaved(c,s.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:s.kind,message:s.message})}async _persist(e,n){if(n){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:h(e)}}}let r=this.getAttribute(`action`);if(!r)return{ok:!0};let i=await t(r,{method:`POST`,body:new URLSearchParams({[this.getAttribute(`name`)||`value`]:e})});return i.ok?{ok:!0,text:i.html.trim()}:{ok:!1,kind:i.kind,message:i.message||a.failed[i.kind]||a.failed.server}}_close(){let e=this.querySelector(s),t=this.querySelector(l),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),t?.querySelector(p)?.click(),n&&e?.focus()}_focusControl(e){if(!m.has(this._type())){e.focus(),e.select?.();return}let t=e.querySelector(`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||`-`,!0);return}let t=this._type(),r=e;if(t===`date`)r=n(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(r=t.textContent.trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(c);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(c);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(c);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=this.querySelector(d),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(f);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){return this.querySelector(u)}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return r.includes(e)?e:`text`}};export{o as a,g as i,a as n,r,i as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import"./formatters-BAE__8ye.js";import{c as t}from"./wuiHttp-DJ1oIvtB.js";import{o as n}from"./calendarMath-BC2wGCD-.js";var r=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),i=2e3,a=Object.freeze({edit:e=>`Edit ${e}: `,readOnly:e=>`${e}: `,saved:e=>`${e} saved.`,notSaved:(e,t)=>`${e} was not saved. ${t}`,failed:Object.freeze({forbidden:`You do not have permission to change this.`,client:`This could not be saved. Refresh the page and try again.`,validation:`This value was not accepted. Check it and try again.`,server:`Something went wrong on our side, so this was not saved. Try again in a moment.`,network:`Could not reach the server, so this was not saved. Check your connection and try again.`})});function o(e,{type:t=`text`,options:r,placeholder:i}={}){let a=e==null?``:String(e);if(a===``)return{text:i||`-`,empty:!0};if(t===`date`)return{text:n(a)||a,empty:!1};if(t===`select`){let e=r?.find(e=>String(e.value)===a);return{text:typeof e?.label==`string`?e.label:a,empty:!1}}return{text:a,empty:!1}}var s=`[data-wui-display]`,c=`[data-wui-value]`,l=`[data-wui-editor]`,u=`[data-wui-control]`,d=`[data-wui-error]`,f=`[data-wui-live]`,p=`[aria-expanded="true"]`,m=new Set([`select`,`date`]),h=e=>typeof e?.message==`string`&&e.message?e.message:a.failed.server,g=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=this.querySelector(s),t=this.querySelector(l),n=this._control();!e||!t||!n||(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),e.hidden=!0,t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n))}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation(),e.type===`click`&&!this._editing&&this.querySelector(s)?.contains(e.target)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(l)?.querySelector(p))}_onKeyDown(e){if(!this._editing){(e.key===`Enter`||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||m.has(t)||t===`textarea`&&!(e.ctrlKey||e.metaKey)||(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!m.has(this._type()))return;let t=this._control();!t||e.target!==t||queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let o=r?null:this._readShown();r||this._showValue(e),this._close();let s=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let c=this.getAttribute(`label`)||``;if(s.ok){this.setAttribute(`value`,e),!r&&s.text&&this._showText(s.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),i),this._announce(a.saved(c)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t});return}if(o&&this._restoreShown(o),s.kind===`session`||s.kind===`aborted`){this._setState(null);return}this._draft=e,this._setState(`error`),this._setError(s.message),this._announce(a.notSaved(c,s.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:s.kind,message:s.message})}async _persist(e,n){if(n){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:h(e)}}}let r=this.getAttribute(`action`);if(!r)return{ok:!0};let i=await t(r,{method:`POST`,body:new URLSearchParams({[this.getAttribute(`name`)||`value`]:e})});return i.ok?{ok:!0,text:i.html.trim()}:{ok:!1,kind:i.kind,message:i.message||a.failed[i.kind]||a.failed.server}}_close(){let e=this.querySelector(s),t=this.querySelector(l),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),t?.querySelector(p)?.click(),n&&e?.focus()}_focusControl(e){if(!m.has(this._type())){e.focus(),e.select?.();return}let t=e.querySelector(`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||`-`,!0);return}let t=this._type(),r=e;if(t===`date`)r=n(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(r=t.textContent.trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(c);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(c);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(c);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=this.querySelector(d),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(f);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){return this.querySelector(u)}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return r.includes(e)?e:`text`}};export{o as a,g as i,a as n,r,i as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{f as t}from"./formatters-BAE__8ye.js";import{t as n}from"./iconGlyphs.g-Bk8AzmSO.js";var r=`a.wui-lightbox-item`,i=1,a=4,o=.5,s=2,c=50,l=6,u=300,d=300;function f(e){return Number.isFinite(e)?Math.min(a,Math.max(i,e)):i}function p(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function m(e,t){return Math.abs(e)<c||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function h(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function g(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function _(e,t,r){let i=g(`button`,`u-action wui-lightbox-btn ${r}`,{type:`button`,"aria-label":t,title:t});return i.style.setProperty(`--wui-action-size`,`40px`),i.innerHTML=n(e,{size:20}),i}var v=class extends e{constructor(){super(),this._ui=null,this._index=0,this._zoom=i,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target?.closest?.(r);if(!t||!this.contains(t))return;let n=this._links().indexOf(t);n<0||(e.preventDefault(),this.open(n))}}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick)}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}_links(){return[...this.querySelectorAll(r)]}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||h(t)}})}open(e=0){let t=this._items();return t.length?(this._ui||(this._returnTo=document.activeElement,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))),this._show(e,t),this._ui.close.focus(),!0):!1}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=g(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=g(`div`,`wui-lightbox-bar`),r=g(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),i=g(`div`,`wui-lightbox-tools`),a=_(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),s=_(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),c=g(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});c.style.setProperty(`--wui-action-size`,`40px`),c.innerHTML=n(`download`,{size:20}),c.hidden=!this.download;let l=_(`x`,`Close`,`wui-lightbox-close`);i.append(a,s,c,l),t.append(r,i);let u=g(`div`,`wui-lightbox-stage`),d=_(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=_(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=g(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=g(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=g(`p`,`wui-lightbox-caption`);e.append(t,u,h);let v={root:e,count:r,zoomOut:a,zoomIn:s,download:c,close:l,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=v,l.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-o)),s.addEventListener(`click`,()=>this._setZoom(this._zoom+o)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===v&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===v&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,n){let r=this._ui,a=Math.min(n.length-1,Math.max(0,Math.trunc(Number(e))||0)),o=n[a],s=a!==this._index||!r.image.getAttribute(`src`);if(this._index=a,this._zoom=i,this._pan={x:0,y:0},r.count.textContent=`${t(a+1,{decimals:0})} of ${t(n.length,{decimals:0})}`,r.caption.textContent=o.caption,r.caption.hidden=!o.caption,r.download.href=o.src,r.download.setAttribute(`download`,o.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=o.alt||o.caption,r.image.src=o.src,this._applyTransform(),this._syncZoomButtons(),n.length>1)for(let e of[n[(a+1)%n.length],n[(a-1+n.length)%n.length]])new Image().src=e.src;s&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:a}}))}_syncZoomButtons(){this._ui.zoomOut.disabled=this._zoom<=i,this._ui.zoomIn.disabled=this._zoom>=a;let e=document.activeElement;(e===this._ui.zoomOut||e===this._ui.zoomIn)&&e.disabled&&this._ui.close.focus()}_setZoom(e){this._ui&&(this._zoom=f(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._ui;return p(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._ui;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>i)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+o)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-o)):e.key===`0`&&(e.preventDefault(),this._setZoom(i))}_trapTab(e){let t=[...this._ui.root.querySelectorAll(`button, a[href]`)].filter(e=>!e.hidden&&!e.disabled);if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!this._ui.root.contains(i))?(e.preventDefault(),r.focus()):!e.shiftKey&&(i===r||!this._ui.root.contains(i))&&(e.preventDefault(),n.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){if(!e.target.closest(`.wui-lightbox-nav`))if(this._ui.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let[e,t]=[...this._pointers.values()];this._gesture={kind:`pinch`,distance:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===this._ui.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(!(!t||!this._pointers.has(e.pointerId))){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._setZoom(t.zoom*Math.hypot(e.x-n.x,e.y-n.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>l&&(t.moved=!0),this._zoom>i&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._ui.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,a=e.clientY-n.startY;if(n.moved){this._zoom===i&&this.step(m(r,a));return}if(!(e.timeStamp-n.startTime>u)){if(!n.onImage){this.close();return}e.timeStamp-this._lastTap<d?(this._lastTap=-1/0,this._setZoom(this._zoom>i?i:s)):this._lastTap=e.timeStamp}}};export{v as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{f as t}from"./formatters-BAE__8ye.js";import{t as n}from"./iconGlyphs.g-BNrdQ7It.js";var r=`a.wui-lightbox-item`,i=1,a=4,o=.5,s=2,c=50,l=6,u=300,d=300;function f(e){return Number.isFinite(e)?Math.min(a,Math.max(i,e)):i}function p(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function m(e,t){return Math.abs(e)<c||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function h(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function g(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function _(e,t,r){let i=g(`button`,`u-action wui-lightbox-btn ${r}`,{type:`button`,"aria-label":t,title:t});return i.style.setProperty(`--wui-action-size`,`40px`),i.innerHTML=n(e,{size:20}),i}var v=class extends e{constructor(){super(),this._ui=null,this._index=0,this._zoom=i,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target?.closest?.(r);if(!t||!this.contains(t))return;let n=this._links().indexOf(t);n<0||(e.preventDefault(),this.open(n))}}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick)}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}_links(){return[...this.querySelectorAll(r)]}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||h(t)}})}open(e=0){let t=this._items();return t.length?(this._ui||(this._returnTo=document.activeElement,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))),this._show(e,t),this._ui.close.focus(),!0):!1}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=g(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=g(`div`,`wui-lightbox-bar`),r=g(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),i=g(`div`,`wui-lightbox-tools`),a=_(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),s=_(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),c=g(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});c.style.setProperty(`--wui-action-size`,`40px`),c.innerHTML=n(`download`,{size:20}),c.hidden=!this.download;let l=_(`x`,`Close`,`wui-lightbox-close`);i.append(a,s,c,l),t.append(r,i);let u=g(`div`,`wui-lightbox-stage`),d=_(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=_(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=g(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=g(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=g(`p`,`wui-lightbox-caption`);e.append(t,u,h);let v={root:e,count:r,zoomOut:a,zoomIn:s,download:c,close:l,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=v,l.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-o)),s.addEventListener(`click`,()=>this._setZoom(this._zoom+o)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===v&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===v&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,n){let r=this._ui,a=Math.min(n.length-1,Math.max(0,Math.trunc(Number(e))||0)),o=n[a],s=a!==this._index||!r.image.getAttribute(`src`);if(this._index=a,this._zoom=i,this._pan={x:0,y:0},r.count.textContent=`${t(a+1,{decimals:0})} of ${t(n.length,{decimals:0})}`,r.caption.textContent=o.caption,r.caption.hidden=!o.caption,r.download.href=o.src,r.download.setAttribute(`download`,o.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=o.alt||o.caption,r.image.src=o.src,this._applyTransform(),this._syncZoomButtons(),n.length>1)for(let e of[n[(a+1)%n.length],n[(a-1+n.length)%n.length]])new Image().src=e.src;s&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:a}}))}_syncZoomButtons(){this._ui.zoomOut.disabled=this._zoom<=i,this._ui.zoomIn.disabled=this._zoom>=a;let e=document.activeElement;(e===this._ui.zoomOut||e===this._ui.zoomIn)&&e.disabled&&this._ui.close.focus()}_setZoom(e){this._ui&&(this._zoom=f(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._ui;return p(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._ui;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>i)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+o)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-o)):e.key===`0`&&(e.preventDefault(),this._setZoom(i))}_trapTab(e){let t=[...this._ui.root.querySelectorAll(`button, a[href]`)].filter(e=>!e.hidden&&!e.disabled);if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!this._ui.root.contains(i))?(e.preventDefault(),r.focus()):!e.shiftKey&&(i===r||!this._ui.root.contains(i))&&(e.preventDefault(),n.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){if(!e.target.closest(`.wui-lightbox-nav`))if(this._ui.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let[e,t]=[...this._pointers.values()];this._gesture={kind:`pinch`,distance:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===this._ui.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(!(!t||!this._pointers.has(e.pointerId))){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._setZoom(t.zoom*Math.hypot(e.x-n.x,e.y-n.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>l&&(t.moved=!0),this._zoom>i&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._ui.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,a=e.clientY-n.startY;if(n.moved){this._zoom===i&&this.step(m(r,a));return}if(!(e.timeStamp-n.startTime>u)){if(!n.onImage){this.close();return}e.timeStamp-this._lastTap<d?(this._lastTap=-1/0,this._setZoom(this._zoom>i?i:s)):this._lastTap=e.timeStamp}}};export{v as t};
@@ -0,0 +1,4 @@
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";var t=/^\s*```/,n=/^\s*[-*+]\s+(.*)$/,r=/^\s*(\d{1,9})[.)]\s+(.*)$/,i=/^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/,a=/^\s*([-*_])(\s*\1){2,}\s*$/,o=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,s=e=>e.includes(`|`);function c(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function l(e,t){return s(e[t])&&t+1<e.length&&o.test(e[t+1])}function u(e,o){let s=e[o];return t.test(s)||n.test(s)||r.test(s)||i.test(s)||a.test(s)||l(e,o)}function d(e){let o=String(e??``).replace(/\r\n?/g,`
2
+ `).split(`
3
+ `),d=[],f=0;for(;f<o.length;){let e=o[f];if(!e.trim()){f+=1;continue}if(t.test(e)){let e=[];for(f+=1;f<o.length&&!t.test(o[f]);)e.push(o[f]),f+=1;f+=1,d.push({type:`code`,text:e.join(`
4
+ `)});continue}if(l(o,f)){let t=c(e),n=[];for(f+=2;f<o.length&&o[f].trim()&&s(o[f]);)n.push(c(o[f])),f+=1;d.push({type:`table`,header:t,rows:n});continue}if(a.test(e)){d.push({type:`rule`}),f+=1;continue}let p=i.exec(e);if(p){d.push({type:`heading`,text:p[1]}),f+=1;continue}let m=r.exec(e);if(m||n.test(e)){let e=!!m,t=e?r:n,i=[];for(;f<o.length&&o[f].trim();){let n=t.exec(o[f]);if(n)i.push(e?n[2]:n[1]);else if(u(o,f))break;else i[i.length-1]+=` ${o[f].trim()}`;f+=1}d.push({type:`list`,ordered:e,start:e?Number(m[1]):1,items:i});continue}let h=[e];for(f+=1;f<o.length&&o[f].trim()&&!u(o,f);)h.push(o[f]),f+=1;d.push({type:`paragraph`,lines:h})}return d.map((e,t)=>({...e,key:t}))}var f=e=>!!e&&/[\p{L}\p{N}]/u.test(e);function p(e,t,n){let r=e.indexOf(n,t);for(;r!==-1;){let i=e.slice(t,r),a=n.length===1&&(e[r+1]===n||e[r-1]===n),o=n[0]===`_`&&f(e[r+n.length]);if(i.trim()&&!/^\s/.test(i)&&!/\s$/.test(i)&&!a&&!o)return r;r=e.indexOf(n,r+1)}return-1}function m(e){let t=[],n=``,r=()=>{n&&t.push({type:`text`,text:n}),n=``},i=0;for(;i<e.length;){let a=e[i];if(a==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({type:`code`,text:e.slice(i+1,n)}),i=n+1;continue}}if((a===`*`||a===`_`)&&e[i+1]===a){let o=a+a,s=p(e,i+2,o);if(s!==-1&&!(a===`_`&&f(e[i-1]))){r(),t.push({type:`strong`,children:m(e.slice(i+2,s))}),i=s+2;continue}n+=o,i+=2;continue}if(a===`*`||a===`_`){let n=p(e,i+1,a);if(n!==-1&&!(a===`_`&&f(e[i-1]))){r(),t.push({type:`em`,children:m(e.slice(i+1,n))}),i=n+1;continue}}if(a===`[`){let n=/^\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/.exec(e.slice(i));if(n){r(),t.push({type:`link`,href:n[2],children:m(n[1])}),i+=n[0].length;continue}}n+=a,i+=1}return r(),t.map((e,t)=>({...e,key:t}))}var h=/^https?:/i,g=/^(mailto|tel):/i,_=class extends e{constructor(){super(),this._drawn=[],this._observer=null}connectedCallback(){this._render(),!(typeof MutationObserver>`u`)&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();if(!e)return;let t=this.ownerDocument;for(let e of this._drawn)e.remove();this._drawn=d(e.textContent??``).map(e=>y(t,e)).filter(Boolean),e.hidden=!0,this.append(...this._drawn),this._observer?.takeRecords()}};function v(e,t,n=[]){let r=e.createElement(t);return r.append(...n),r}function y(e,t){switch(t.type){case`paragraph`:{let n=e.createElement(`p`);return t.lines.forEach((t,r)=>{r>0&&n.append(e.createElement(`br`)),n.append(...S(e,t))}),n}case`heading`:return v(e,`h2`,S(e,t.text));case`list`:{let n=t.items.map(t=>v(e,`li`,S(e,t))),r=v(e,t.ordered?`ol`:`ul`,n);return t.ordered&&t.start!==1&&r.setAttribute(`start`,String(t.start)),r}case`table`:return b(e,t);case`code`:return x(e,t.text);case`rule`:return e.createElement(`hr`);default:return null}}function b(e,t){let n=t.header.map(t=>{let n=v(e,`th`,S(e,t));return n.setAttribute(`scope`,`col`),n}),r=t.rows.map(n=>v(e,`tr`,t.header.map((t,r)=>v(e,`td`,S(e,n[r]??``))))),i=v(e,`table`,[v(e,`thead`,[v(e,`tr`,n)]),v(e,`tbody`,r)]);i.className=`table`;let a=v(e,`div`,[i]);return a.className=`table-responsive`,a}function x(e,t){let n=v(e,`pre`,[v(e,`code`,[e.createTextNode(t)])]);n.className=`wui-code-source`;let r=v(e,`wui-code-block`,[n]);return r.className=`wui-code-block`,r}function S(e,t){return C(e,m(t))}function C(e,t){return D(t).flatMap(t=>w(e,t))}function w(e,t){switch(t.type){case`code`:return[v(e,`code`,[e.createTextNode(t.text)])];case`strong`:return[v(e,`strong`,C(e,t.children))];case`em`:return[v(e,`em`,C(e,t.children))];case`image`:return[e.createTextNode(`[`),...C(e,t.children),e.createTextNode(`]`)];case`link`:return T(e,t);default:return[e.createTextNode(t.text)]}}function T(e,t){let n=C(e,t.children);return h.test(t.href)?[E(e,t.href,n,!0)]:g.test(t.href)?[E(e,t.href,n,!1)]:n}function E(e,t,n,r){let i=v(e,`span`,n);i.className=`wui-link__label`;let a=v(e,`a`,[i]);return a.className=`wui-link wui-link--static`,a.setAttribute(`data-wui`,`AppLink`),a.setAttribute(`href`,t),r&&(a.setAttribute(`target`,`_blank`),a.setAttribute(`rel`,`noopener noreferrer`)),a}function D(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n],i=e[n+1];if(r.type===`text`&&r.text.endsWith(`!`)&&i?.type===`link`){let e=r.text.slice(0,-1);e&&t.push({type:`text`,text:e,key:r.key}),t.push({type:`image`,children:i.children,key:i.key}),n+=1}else t.push(r)}return t}export{_ as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{f as i}from"./formatters-BAE__8ye.js";import{c as a}from"./wuiHttp-Cu7OPWr2.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";var s=/^[A-Za-z0-9_.:-]{1,64}$/,c=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,l=/@(\\*)\[/g;function u(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var d=e=>e.replace(l,(e,t)=>`@\\${t}[`);function f(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(c))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function p(e){let t=``,n=[];for(let r of f(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function m(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!s.test(e.id)||(i+=d(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+d(n.slice(a))}function h(e){let t=[];for(let n of f(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var g=8,_=40,v=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${i(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),y=`[data-wui-control]`,b=`[data-wui-field]`,x=`[data-wui-menu]`,S=`[data-wui-live]`,C=0,w=e=>e&&s.test(String(e.value??``))&&u(e.label)!==``;function T(e){let t=e.ownerDocument;e.id||=`wui-mention-${++C}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,v.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var E=class extends e{static get observedAttributes(){return[`disabled`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(y)||T(this);let e=this._control(),t=this.querySelector(b)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return m(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);if(!this._wired){this._pendingValue=t;return}t!==this.value&&this._load(t)}get mentions(){let e=new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(w):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading}set loading(e){this._loading=!!e,this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(y)}_menu(){return this.querySelector(x)}_load(e){let{text:t,mentions:n}=p(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(b);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();if(!t){this._close();return}this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh())}_queryAtCaret(){let e=this._control();if(!e||e.disabled||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>u(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);if(!n){this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}));return}this._fetchPeople(n,e,t)},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=await a(`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!i.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=i.html,this._peopleProp=[...o.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(w),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!!(e&&!e.hidden)}_renderMenu(){let e=this._menu(),n=this._control();if(!e||!n||!this._query)return;let r=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),t.src){let e=r.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=u(t.label),a.appendChild(o),t.description){let e=r.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=r.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this._loading?v.searching:`${v.noMatch} “${this._query.text}”`,e.appendChild(t)}let i=this._isOpen();e.hidden=!1,i||t(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this._loading||this._announce(this._results.length?v.found(this._results.length):`${v.noMatch}.`)}_position(){r(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),n(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);o(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}));return}e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=u(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(v.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(S);t&&(t.textContent=``,t.textContent=e)}};export{s as a,m as c,E as i,h as l,g as n,u as o,v as r,p as s,_ as t,f as u};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{f as i}from"./formatters-BAE__8ye.js";import{c as a}from"./wuiHttp-DJ1oIvtB.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";var s=/^[A-Za-z0-9_.:-]{1,64}$/,c=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,l=/@(\\*)\[/g;function u(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var d=e=>e.replace(l,(e,t)=>`@\\${t}[`);function f(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(c))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function p(e){let t=``,n=[];for(let r of f(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function m(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!s.test(e.id)||(i+=d(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+d(n.slice(a))}function h(e){let t=[];for(let n of f(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var g=8,_=40,v=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${i(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),y=`[data-wui-control]`,b=`[data-wui-field]`,x=`[data-wui-menu]`,S=`[data-wui-live]`,C=0,w=e=>e&&s.test(String(e.value??``))&&u(e.label)!==``;function T(e){let t=e.ownerDocument;e.id||=`wui-mention-${++C}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,v.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var E=class extends e{static get observedAttributes(){return[`disabled`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(y)||T(this);let e=this._control(),t=this.querySelector(b)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return m(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);if(!this._wired){this._pendingValue=t;return}t!==this.value&&this._load(t)}get mentions(){let e=new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(w):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading}set loading(e){this._loading=!!e,this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(y)}_menu(){return this.querySelector(x)}_load(e){let{text:t,mentions:n}=p(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(b);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();if(!t){this._close();return}this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh())}_queryAtCaret(){let e=this._control();if(!e||e.disabled||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>u(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);if(!n){this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}));return}this._fetchPeople(n,e,t)},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=await a(`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!i.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=i.html,this._peopleProp=[...o.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(w),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!!(e&&!e.hidden)}_renderMenu(){let e=this._menu(),n=this._control();if(!e||!n||!this._query)return;let r=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),t.src){let e=r.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=u(t.label),a.appendChild(o),t.description){let e=r.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=r.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this._loading?v.searching:`${v.noMatch} “${this._query.text}”`,e.appendChild(t)}let i=this._isOpen();e.hidden=!1,i||t(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this._loading||this._announce(this._results.length?v.found(this._results.length):`${v.noMatch}.`)}_position(){r(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),n(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);o(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}));return}e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=u(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(v.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(S);t&&(t.textContent=``,t.textContent=e)}};export{s as a,m as c,E as i,h as l,g as n,u as o,v as r,p as s,_ as t,f as u};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as o,t as s}from"./focusOrigin-2imUSs-u.js";import{n as c}from"./formMirror-BgY7zkC3.js";import{n as l,t as u}from"./listboxKeyNav-DMIvs9d6.js";import{a as d,i as f,n as p,r as m,t as h}from"./optionLabel-Bd3vP-XI.js";import{i as g,t as _}from"./tokenCommit-BKckxgtg.js";var v=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],c(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_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,icon:e.getAttribute(`icon`)||void 0,[h]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of b){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?f(t):d(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?m(t):p(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),o=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;c(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let s=`${this.id}-listbox`;this._listboxId=s;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-BNrdQ7It.js";import{n as o,t as s}from"./focusOrigin-2imUSs-u.js";import{n as c}from"./formMirror-BgY7zkC3.js";import{n as l,t as u}from"./listboxKeyNav-DMIvs9d6.js";import{a as d,i as f,n as p,r as m,t as h}from"./optionLabel-Bul5mgul.js";import{i as g,t as _}from"./tokenCommit-BKckxgtg.js";var v=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],c(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_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,icon:e.getAttribute(`icon`)||void 0,[h]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of b){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?f(t):d(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?m(t):p(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),o=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;c(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let s=`${this.id}-listbox`;this._listboxId=s;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
2
2
  <div class="search-select${o}">
3
3
  <div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:``}>
4
4
  ${r?a(r,{className:`search-select-icon`}):``}
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{c as t}from"./wuiHttp-Cu7OPWr2.js";import{c as n,i as r,n as i,s as a}from"./notificationDays-BUoh4mG6.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f})`).length}_click(e){let t=e.target.closest?.(`${o}, ${u}, ${d}`);if(!(!t||!this.contains(t))){if(t.matches(o)){this.toggle();return}this.hasAttribute(`controlled`)||(t.matches(u)?this._markAll():this._markItem(t))}}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)];if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),this._unread=Math.max(0,this._unread-1),this._render(),this._say(n(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let n=e.map(e=>e.dataset.id).filter(Boolean),r=this.getAttribute(`read-action`);if(r){this._setBusy(!0);let e=new URLSearchParams;for(let t of n)e.append(`ids`,t);let a=await t(r,{method:`POST`,body:e});if(this._setBusy(!1),!a.ok){if(a.kind===`session`||a.kind===`aborted`)return;let e=a.message||i.failed[a.kind]||i.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:a.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(i.allRead),this._emitRead(n,!0)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=r(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,a(this.getAttribute(`label`)||i.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{m as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{c as t}from"./wuiHttp-DJ1oIvtB.js";import{c as n,i as r,n as i,s as a}from"./notificationDays-BUoh4mG6.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f})`).length}_click(e){let t=e.target.closest?.(`${o}, ${u}, ${d}`);if(!(!t||!this.contains(t))){if(t.matches(o)){this.toggle();return}this.hasAttribute(`controlled`)||(t.matches(u)?this._markAll():this._markItem(t))}}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)];if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),this._unread=Math.max(0,this._unread-1),this._render(),this._say(n(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let n=e.map(e=>e.dataset.id).filter(Boolean),r=this.getAttribute(`read-action`);if(r){this._setBusy(!0);let e=new URLSearchParams;for(let t of n)e.append(`ids`,t);let a=await t(r,{method:`POST`,body:e});if(this._setBusy(!1),!a.ok){if(a.kind===`session`||a.kind===`aborted`)return;let e=a.message||i.failed[a.kind]||i.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:a.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(i.allRead),this._emitRead(n,!0)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=r(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,a(this.getAttribute(`label`)||i.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{m as t};