@webority/ui-elements 0.111.0 → 0.112.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.
- package/dist/{WuiCodeBlock-D1KRl0ET.js → WuiCodeBlock-C6OjA3tc.js} +1 -1
- package/dist/WuiMarkdown-DdsyCxS8.js +4 -0
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/kanban-qLE8HS5b.js +1 -0
- package/dist/types/chatCore.d.ts +0 -1
- package/dist/ui-chat-core.js +1 -4
- package/dist/ui-chat.global.js +4 -4
- package/dist/ui-chat.js +4 -4
- package/dist/ui-elements/autocomplete.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +3 -3
- package/dist/ui-elements/multiselect.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/resizable.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/taginput.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +21 -21
- package/dist/ui-elements.js +1 -1
- package/package.json +3 -2
- package/dist/WuiMarkdown-C2flvSIt.js +0 -4
- package/dist/kanban-CzHKjz5z.js +0 -1
- package/dist/types/markdownParse.d.ts +0 -77
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,t as n}from"./buttonClass-FD57QNey.js";import{t as r}from"./iconGlyphs.g-CrodCkbV.js";import{n as i,t as a}from"./copyText-DM5HhXjf.js";var o=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),s=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),c=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),l=`(?![\\s\\S])`,u=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${l})`).source,d=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,c([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],f=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,c(`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`,c([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],p=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,c(`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`,c([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],m=[[`comment`,RegExp(`--[^\\n]*|${u}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,c(`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`,c([`true`,`false`])],[`type`,c([`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`,/[(),;]/]],h=[[`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`,c([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,c(`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`,/[|&;<>(){}[\]]+/]],g=[[`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]],_=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${l})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],v={json:d,js:f,cs:p,sql:m,bash:h,http:g,css:[[`comment`,new RegExp(u)],[`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:_,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},y=new Map;function b(e){let t=y.get(e);if(!t){let n=v[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)},y.set(e,t)}return t}function x(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function S(e,t,n=[]){let{re:r,types:i}=b(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;x(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?S(`htmlTag`,o[0],n):x(n,i[r],o[0]),a=o.index+o[0].length}return x(n,`plain`,t.slice(a)),n}function C(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return S(`http`,e);let n=S(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?S(`json`,r,n):i===`<`?S(`html`,r,n):(x(n,`plain`,r),n)}function w(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?C(n):!Object.hasOwn(v,t)||t===`htmlTag`?[[`plain`,n]]:S(t,n)}function T(e,t){let n=[[]];for(let[r,i]of w(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 E=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.
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,t as n}from"./buttonClass-FD57QNey.js";import{t as r}from"./iconGlyphs.g-CrodCkbV.js";import{n as i,t as a}from"./copyText-DM5HhXjf.js";var o=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),s=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),c=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),l=`(?![\\s\\S])`,u=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${l})`).source,d=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,c([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],f=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,c(`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`,c([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],p=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,c(`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`,c([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],m=[[`comment`,RegExp(`--[^\\n]*|${u}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,c(`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`,c([`true`,`false`])],[`type`,c([`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`,/[(),;]/]],h=[[`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`,c([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,c(`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`,/[|&;<>(){}[\]]+/]],g=[[`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]],_=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${l})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],v={json:d,js:f,cs:p,sql:m,bash:h,http:g,css:[[`comment`,new RegExp(u)],[`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:_,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},y=new Map;function b(e){let t=y.get(e);if(!t){let n=v[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)},y.set(e,t)}return t}function x(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function S(e,t,n=[]){let{re:r,types:i}=b(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;x(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?S(`htmlTag`,o[0],n):x(n,i[r],o[0]),a=o.index+o[0].length}return x(n,`plain`,t.slice(a)),n}function C(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return S(`http`,e);let n=S(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?S(`json`,r,n):i===`<`?S(`html`,r,n):(x(n,`plain`,r),n)}function w(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?C(n):!Object.hasOwn(v,t)||t===`htmlTag`?[[`plain`,n]]:S(t,n)}function T(e,t){let n=[[]];for(let[r,i]of w(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 E=class extends e{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._title=null,this._view=null,this._codeEl=null,this._copyIcon=null,this._copyText=null,this._copied=!1,this._observer=null,this._timer=0,this._cancelFrame=null}connectedCallback(){this._render(),!(typeof MutationObserver>`u`)&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=o.includes(t)?t:`text`,r=this.getAttribute(`label`)||``,i=T(this._code(),n);this._title.textContent=r||s[n],this._view.setAttribute(`aria-label`,r||`Code`),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>D(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=e.createElement(`div`);n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,this._codeEl=e.createElement(`code`),r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this._view=n,this.append(t)}_bar(e){let r=e.createElement(`div`);r.className=`wui-code-bar`,this._title=e.createElement(`span`),this._title.className=`wui-code-title`;let o=e.createElement(`button`);return o.type=`button`,o.className=`${t(`ghost`,`sm`)} wui-code-copy`,o.dataset.wui=n,o.setAttribute(`aria-live`,`polite`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`),this._setCopied(!1),o.append(this._copyIcon,this._copyText),o.addEventListener(`click`,async()=>{await i(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>this._setCopied(!1),a))}),r.append(this._title,o),r}_setCopied(e){this._copied=e,this._copyIcon.innerHTML=r(e?`check`:`files`,{size:14}),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||`Copied`:this.getAttribute(`copy-label`)||`Copy`}};function D(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}export{E as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";var t=new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),n=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,r=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,i=e=>/[\p{L}\p{N}]/u.test(e);function a(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function o(e,t,n){let r=n.length===1;for(let o=e.indexOf(n,t);o!==-1;o=e.indexOf(n,o+1)){let s=o>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(o-1)),c=r&&(e.charAt(o+1)===n||e.charAt(o-1)===n),l=n===`_`&&i(e.charAt(o+n.length));if(s&&!c&&!l&&!a(e,o))return o}return-1}function s(e){let a=[],c=``,l=()=>{c&&=(a.push({type:`text`,text:c}),``)},u=0;for(;u<e.length;){let d=e.charAt(u),f=e.charAt(u+1);if(d===`\\`&&t.has(f)){c+=f,u+=2;continue}if(d==="`"){let t=e.indexOf("`",u+1);if(t>u+1){l(),a.push({type:`code`,text:e.slice(u+1,t)}),u=t+1;continue}}let p=d+f;if(p===`**`||p===`__`||p===`~~`){let t=o(e,u+2,p);if(t!==-1&&!(p===`__`&&i(e.charAt(u-1)))){l();let n=s(e.slice(u+2,t));p===`~~`?a.push({type:`strike`,children:n}):a.push({type:`strong`,children:n}),u=t+2;continue}c+=p,u+=2;continue}if(d===`*`||d===`_`){let t=o(e,u+1,d);if(t!==-1&&!(d===`_`&&i(e.charAt(u-1)))){l(),a.push({type:`em`,children:s(e.slice(u+1,t))}),u=t+1;continue}}if(d===`[`){n.lastIndex=u;let t=n.exec(e);if(t){l(),a.push({type:`link`,href:t[2],children:s(t[1])}),u+=t[0].length;continue}}if(d===`!`){r.lastIndex=u;let t=r.exec(e);if(t){l(),a.push({type:`image`,children:s(t[1])}),u+=t[0].length;continue}}c+=d,u+=1}return l(),a.map((e,t)=>({...e,key:t}))}var c=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,l=/^https?:/i,u=/^(mailto|tel):/i;function d(e,t,n){if(n&&c.test(e)){let t=n(e);if(t!=null)return{kind:`app`,target:t}}return t===`app`?null:l.test(e)?{kind:`web`,href:e}:u.test(e)?{kind:`contact`,href:e}:null}function f(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var p=/^\s*```/,m=/^\s*```\s*(\S*)/,h=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,g=/^\s*([-*_])(\s*\1){2,}\s*$/,_=/^(\s*)[-*+]\s+(.*)$/,v=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,y=/^\s*>\s?(.*)$/,b=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,x=e=>e.includes(`|`);function S(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 C(e,t){return x(e[t])&&t+1<e.length&&e[t+1].includes(`|`)&&b.test(e[t+1])}function w(e,t){let n=e[t];return p.test(n)||y.test(n)||_.test(n)||v.test(n)||h.test(n)||g.test(n)||C(e,t)}function T(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function E(e){let t=v.exec(e);if(t)return{text:t[3],depth:T(t[1]),ordered:!0,number:Number(t[2])};let n=_.exec(e);return n?{text:n[2],depth:T(n[1]),ordered:!1,number:0}:null}function D(e){let t=(e??``).replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(p.test(e)){let i=m.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length&&!p.test(t[r]);)a.push(t[r]),r+=1;r+=1,n.push({type:`code`,text:a.join(`
|
|
4
|
+
`),language:i});continue}if(C(t,r)){let i=S(e),a=[];for(r+=2;r<t.length&&t[r].trim()&&x(t[r]);)a.push(S(t[r])),r+=1;n.push({type:`table`,header:i,rows:a});continue}if(g.test(e)){n.push({type:`rule`}),r+=1;continue}let i=h.exec(e);if(i){n.push({type:`heading`,level:i[1].length,text:i[2]}),r+=1;continue}if(y.test(e)){let e=[];for(;r<t.length;){let n=y.exec(t[r]);if(!n)break;e.push(n[1]),r+=1}n.push({type:`quote`,lines:e});continue}let a=E(e);if(a){let e=[];for(;r<t.length&&t[r].trim();){let n=E(t[r]);if(n){if(n.depth===0&&n.ordered!==a.ordered)break;e.push(n)}else if(w(t,r))break;else e[e.length-1].text+=` ${t[r].trim()}`;r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length&&t[r].trim()&&!w(t,r);)o.push(t[r]),r+=1;n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var O=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`];function k(e,t,n,r,i=null){let a=A(e.ownerDocument,n,r).map((e,n)=>{let r=t[n]?.sig===e.sig?t[n].nodes:null;return{sig:e.sig,nodes:r??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.remove();let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function A(e,t,n){let r={doc:e,links:n.links===`app`?`app`:`web`,headings:n.headings===`text`?`text`:`outline`,resolveLink:n.resolveLink},i=n.resolverGeneration??0;return D(t).map(e=>({sig:`${JSON.stringify(e)}|${r.links}|${r.headings}|${i}`,build:()=>N(r,e)}))}var j=class extends e{static get observedAttributes(){return[`links`,`headings`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._resolverGeneration=0}connectedCallback(){this._connected=!0,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._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=k(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,resolveLink:this._resolveLink,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function M(e,t,n=[]){let r=e.createElement(t);return r.append(...n),r}function N(e,t){switch(t.type){case`paragraph`:return[M(e.doc,`p`,P(e,t.lines))];case`heading`:return[F(e,t)];case`list`:return I(e,t.items);case`table`:return[R(e,t)];case`code`:return[z(e.doc,t)];case`quote`:return[M(e.doc,`blockquote`,P(e,t.lines))];case`rule`:return[e.doc.createElement(`hr`)];default:return[]}}function P(e,t){let n=[];return t.forEach((t,r)=>{r>0&&n.push(e.doc.createElement(`br`)),n.push(...B(e,t))}),n}function F(e,t){let n=B(e,t.text);if(e.headings===`text`){let t=M(e.doc,`p`,n);return t.className=`fw-semibold`,t}return M(e.doc,`h2`,n)}function I(e,t){let n=[];for(let r=0;r<t.length;){let i=L(e,t,r);n.push(i.list),r=i.next}return n}function L(e,t,n){let{depth:r,ordered:i,number:a}=t[n],o=e.doc.createElement(i?`ol`:`ul`);i&&a!==1&&o.setAttribute(`start`,String(a));let s=null,c=n;for(;c<t.length&&t[c].depth>=r;)if(t[c].depth===r)s=M(e.doc,`li`,B(e,t[c].text)),o.append(s),c+=1;else{let n=L(e,t,c);s.append(n.list),c=n.next}return{list:o,next:c}}function R(e,t){let n=t.header.map(t=>{let n=M(e.doc,`th`,B(e,t));return n.setAttribute(`scope`,`col`),n}),r=t.rows.map(n=>M(e.doc,`tr`,t.header.map((t,r)=>M(e.doc,`td`,B(e,n[r]??``))))),i=M(e.doc,`table`,[M(e.doc,`thead`,[M(e.doc,`tr`,n)]),M(e.doc,`tbody`,r)]);i.className=`table`;let a=M(e.doc,`div`,[i]);return a.className=`table-responsive`,a}function z(e,t){let n=M(e,`pre`,[M(e,`code`,[e.createTextNode(t.text)])]);n.className=`wui-code-source`;let r=M(e,`wui-code-block`,[n]);return r.className=`wui-code-block`,r.setAttribute(`language`,O.includes(t.language)?t.language:`text`),r}function B(e,t){return V(e,s(t))}function V(e,t){return t.flatMap(t=>H(e,t))}function H(e,t){let{doc:n}=e;switch(t.type){case`code`:return[M(n,`code`,[n.createTextNode(t.text)])];case`strong`:return[M(n,`strong`,V(e,t.children))];case`em`:return[M(n,`em`,V(e,t.children))];case`strike`:return[M(n,`del`,V(e,t.children))];case`image`:return[n.createTextNode(`[`),...V(e,t.children),n.createTextNode(`]`)];case`link`:return U(e,t);default:return[n.createTextNode(t.text)]}}function U(e,t){let n=V(e,t.children),r=d(t.href,e.links,e.resolveLink);if(!r)return n;if(r.kind===`app`){let t=f(r.target);return t?[W(e.doc,t,n,!1)]:n}return[W(e.doc,r.href,n,r.kind===`web`)]}function W(e,t,n,r){let i=M(e,`span`,n);i.className=`wui-link__label`;let a=M(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}export{j as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiCodeBlock-
|
|
1
|
+
import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiCodeBlock-C6OjA3tc.js";e(`wui-code-block`,t);export{t as WuiCodeBlock};
|
package/dist/elements/kanban.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-DV9IZZCu.js";import{a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"../kanban-
|
|
1
|
+
import{n as e}from"../elementBase-DV9IZZCu.js";import{a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"../kanban-qLE8HS5b.js";e(`wui-kanban`,n);export{h as KANBAN_DRAG_THRESHOLD_PX,u as KANBAN_LONG_PRESS_MS,p as KANBAN_PHONE_QUERY,s as KANBAN_STORAGE_PREFIX,t as KANBAN_SUMMARY_FORMATS,d as KANBAN_TEXT,m as KANBAN_TONES,n as WuiKanban,c as kanbanCardLabel,g as kanbanOverflow,r as kanbanStorageKey,i as kanbanSummaryFormat,f as kanbanVisibleLimit,l as readKanbanCollapsed,o as sumKanbanValues,a as writeKanbanCollapsed};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiMarkdown-
|
|
1
|
+
import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiMarkdown-DdsyCxS8.js";e(`wui-markdown`,t);export{t as WuiMarkdown};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,t as n}from"./devWarn-DXdRWZs3.js";import{h as r,s as i,t as a}from"./formatters-6DhcQIjT.js";import{n as o,t as s}from"./buttonClass-FD57QNey.js";import{c,o as l}from"./wuiHttp-BHNgUXr_.js";function u(e,t){if(e){if(!e.tip?.isConnected){e.dispose();return}t.addEventListener(`hidden${e.constructor.EVENT_KEY}`,()=>e.dispose(),{once:!0}),e.hide()}}var d=`wui-remote-modal`,f=`wui-remote-drawer`,p=Object.freeze({sm:360,md:480,lg:640,xl:720}),m=`wui-modal-fullscreen`,h=Object.freeze({sm:380,md:440,lg:640,xl:880}),g=Object.freeze({loading:`Loading`,close:`Close`,retry:`Try again`,errorTitle:`This could not be loaded`,forbidden:`You do not have access to this.`,client:`It may have been moved or deleted.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`,submitFailed:`Your changes were not saved.`,invalid:`Some fields need attention.`}),_=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,ee=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,te=`[aria-invalid="true"], .is-invalid, .input-validation-error`,ne=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,v=`[data-wui-modal-content]`,re=`[data-wui-pane-close], [data-bs-dismiss="modal"]`,ie=`<button type="button" class="wui-modal-close" data-bs-dismiss="modal" aria-label="Close"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"></path></svg></button>`,y=new WeakMap,ae=new WeakSet,b=()=>Object.assign(Error(`The remote modal load was aborted.`),{name:`AbortError`}),oe=e=>{let t=window.bootstrap?.Modal;if(!t)throw Error(`WUI.modal.load(${String(e)}): Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return t},x=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML};function se(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Object.hasOwn(h,e))return{px:h[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, fullscreen or a px number.`)}var ce=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:h.md}},S=(e,t)=>{e.classList.toggle(m,!!t.fullscreen),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},le=[`center`,`top`];function ue(e){if(e==null||e===``)return null;if(Object.hasOwn(p,e))return{px:p[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var de=e=>e.container===`drawer`,C=e=>e.container===`pane`,w=e=>e.container!==`modal`,fe=(e,t)=>de(e)?ue(t):se(t),pe=()=>document.getElementById(`wui-remote-drawer`)?.classList.contains(`show`)??!1,me=e=>{let t=typeof e==`string`?document.querySelector(e):e;return t?.matches?.(`[data-wui-pane-host]`)?t:null},he=e=>C(e)?e.shell:e.shell.querySelector(`.modal-dialog`);function ge(e=`modal`){let t=e===`drawer`,n=t?f:d,r=document.getElementById(n);return r||(r=document.createElement(`div`),r.id=n,r.className=t?`modal fade wui-modal-shell wui-remote-drawer`:`modal fade wui-modal-shell`,r.tabIndex=-1,r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.style.setProperty(`--wui-modal-max-width`,`${t?p.md:h.md}px`),r.innerHTML=t?`<div class="modal-dialog wui-remote-drawer-dialog"><div class="modal-content wui-modal"></div></div>`:`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal"></div></div>`,document.body.appendChild(r),r)}var _e=e=>`<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${x(e)}</div></div></div>${ie}</div>`,ve=e=>`<div class="modal-content wui-modal" aria-busy="true">${_e(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${x(g.loading)}</span><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton wui-modal-skeleton--short"></div></div></div></div>`,ye=(e,t)=>`<div class="modal-content wui-modal" data-wui-modal-error="${x(t)}">${_e(e)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${x(g.errorTitle)}</p><p class="wui-modal-state-text">${x(g[t]||g.server)}</p><div class="wui-modal-state-actions"><button type="button" class="${o(`secondary`,`md`)}" data-bs-dismiss="modal" data-wui="${s}">${x(g.close)}</button><button type="button" class="${o(`primary`,`md`)}" data-wui-modal-retry data-wui="${s}">${x(g.retry)}</button></div></div></div></div>`,T=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelector(`.modal-content`)},E=e=>e.shell.querySelector(`.modal-content`);function be(e){if(!e)return;e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));let t=window.bootstrap,n=[t?.Tooltip,t?.Popover].filter(e=>e?.getInstance);for(let r of[e,...e.querySelectorAll(`*`)]){for(let e of n)u(e.getInstance(r),r);t?.Dropdown?.getInstance?.(r)?.dispose()}}function D(e,t){let n=E(e),r=n?Se(n):new Map;be(n),n?n.replaceWith(t):he(e).appendChild(t),Ce(t,r),window.WUI?.refresh?.()}var xe=`input[type="file"][name]`;function Se(e){let t=new Map;for(let n of e.querySelectorAll(xe))n.files.length>0&&t.set(n.name,[...n.files]);return t}function Ce(e,t){if(!(t.size===0||typeof DataTransfer>`u`))for(let n of e.querySelectorAll(xe)){let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var O=e=>C(e)?!e.shell.hidden:e.shell.classList.contains(`show`);function k(e,t,n=!1){let r=t&&e.querySelector(te),i=r?r.matches(_)?r:r.querySelector(_)||r:null;if(!i&&n)i=e.querySelector(`[data-autofocus]`)||e.querySelector(ee)||e.querySelector(`.wui-modal-close`);else if(!i){let t=[...e.querySelectorAll(_)];i=e.querySelector(`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}i?.focus?.()}function we(e,t){let n=[...e.querySelectorAll(_)].filter(e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`);if(!n.length){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;!e.contains(a)||a===e?(t.preventDefault(),(t.shiftKey?i:r).focus()):t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}function Te(e,t){let n=e.shell.querySelector(`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),he(e).appendChild(n)),n.textContent=``,n.textContent=t}var Ee=e=>{let t=e.shell.querySelector(`[data-wui-modal-live]`);t&&(t.textContent=``)},A=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}));function j(e,t,n,r){let i={...r,container:e.container};A(t,`wui:modal:${n}`,i),de(e)&&A(t,`wui:drawer:${n}`,i),C(e)&&A(t,`wui:pane:${n}`,i)}var De=e=>e.matches(`[data-wui-pane-host]`)?`pane`:e.classList.contains(`wui-remote-drawer`)?`drawer`:`modal`;function Oe(e){let t=y.get(e);return t||(t={shell:e,container:De(e),queue:l(),defaultSize:ce(e),defaultLabel:e.getAttribute(`aria-label`),placeholder:E({shell:e})?.outerHTML||`<div class="modal-content wui-modal"></div>`,remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null},y.set(e,t),e.addEventListener(`submit`,e=>Ue(t,e)),e.addEventListener(`click`,e=>{!e.target.closest?.(`[data-wui-modal-retry]`)||!t.session||(e.preventDefault(),P(t,t.session))}),C(t)&&e.addEventListener(`click`,e=>{let n=e.target.closest?.(re);!n||!e.currentTarget.contains(n)||!t.session||N(t,t.session,`dismissed`,null)}),e.addEventListener(`hidden.bs.modal`,n=>{n.target===e&&(e.classList.contains(`wui-modal-stacked`)&&Ae(t),je(t))}),e.addEventListener(`shown.bs.modal`,n=>{if(n.target!==e)return;e.classList.contains(`wui-modal-stacked`)&&[...document.querySelectorAll(`.modal-backdrop`)].at(-1)?.classList.add(`wui-modal-backdrop-stacked`);let r=E(t);t.session&&r?.matches(v)&&!r.contains(document.activeElement)&&k(r,!1,w(t))}),t.remoteUrl&&e.addEventListener(`show.bs.modal`,n=>{n.target===e&&Me(t,n)}),t)}function M(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r,i=new Promise(e=>{r=e}),a={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:r,handle:null};return a.handle={el:e.shell,closed:i,close:()=>N(e,a,`dismissed`,null),reload:()=>P(e,a)},e.session=a,a}function N(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},C(e)?ke(e,t):window.bootstrap?.Modal?.getOrCreateInstance(e.shell).hide())}function ke(e,t){let n=e.shell,{status:r,detail:i}=t.closing,a=n.contains(document.activeElement);e.queue.abort(),e.session=null,be(E(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),j(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Ae(e){e.shell.classList.remove(`wui-modal-stacked`),pe()&&(document.body.classList.add(`modal-open`),document.body.style.overflow=`hidden`)}function je(e){let t=e.session;if(e.queue.abort(),e.session=null,Ee(e),t){let{status:n,detail:r}=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n,detail:r}),j(e,e.shell,`closed`,{status:n,url:t.url});let i=document.activeElement;t.trigger?.isConnected&&(!i||i===document.body||e.shell.contains(i))&&t.trigger.focus?.()}e.cache||(D(e,T(e.placeholder)),e.loadedUrl=null,S(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Me(e,t){let n=t.relatedTarget instanceof Element?t.relatedTarget:null,r=n?.getAttribute(`data-wui-url`)||e.remoteUrl,i=M(e,r,{trigger:n});i.explicitSize=Ne(e,n?.getAttribute(`data-wui-size`)),i.explicitSize&&S(e.shell,i.explicitSize),!(e.cache&&e.loadedUrl===r)&&(e.loadedUrl&&D(e,T(e.placeholder)),P(e,i,{keepPlaceholder:!0}))}function Ne(e,t){try{return fe(e,t)}catch(e){return n(e),null}}async function P(e,t,{keepPlaceholder:n=!1}={}){n||D(e,T(ve(t.options.title||Pe(e))));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if((r.kind===`ok`||r.kind===`validation`)&&F(e,t,r.html,!1))return e.loadedUrl=t.url,j(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return D(e,T(ye(t.options.title||Pe(e),i))),O(e)&&k(E(e),!1,w(e)),j(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Pe=e=>E(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,Fe=`/_content/Webority.Ui.Razor/js/`,Ie=e=>new URL(e,window.location.href).pathname.includes(Fe);function Le(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function F(e,r,i,a){let o=document.createElement(`template`);o.innerHTML=i;let s=!1;for(let e of o.content.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Ie(t)?Le(t):s=!0}s&&t(`WUI.modal: ${r.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let c=o.content.querySelector(v);if(!c)return n(`WUI.modal: ${r.url} did not answer with an <app-modal-content> fragment.`),!1;if(D(e,c),a||Ee(e),!C(e)){S(e.shell,r.explicitSize||Ne(e,c.getAttribute(`data-wui-size`))||e.defaultSize);let t=c.getAttribute(`data-wui-title`);t&&e.shell.setAttribute(`aria-label`,t)}return O(e)&&k(c,a,w(e)),!0}var Re=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function ze(e,t,n){let r=[...e.elements].filter(e=>e.matches(Re));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.insertAdjacentHTML(`afterbegin`,`<span class="spinner-border spinner-border-sm me-2" aria-hidden="true" data-wui-submit-spinner></span>`));return}e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}function Be(e){for(let t of e.querySelectorAll(ne))t.remove();for(let t of e.querySelectorAll(te))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}function Ve(e,t,n){let r=t.closest(`.wui-modal-body`)||t;r.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Be(r);let i=document.createElement(`div`);i.className=`alert alert-danger wui-modal-submit-error`,i.setAttribute(`role`,`alert`),i.setAttribute(`data-wui-modal-submit-error`,``),i.textContent=`${g.submitFailed} ${g[n]||g.server}`,r.prepend(i),Te(e,i.textContent)}var He=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Ue(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(v)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=t.submitter||null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;ze(n,i,!0);let l=await e.queue.run(c?He(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate});if(e.session===r){if(n.isConnected&&ze(n,i,!1),l.kind===`ok`&&l.result===`success`){We(e,r,l);return}if(!(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)){if(l.kind===`validation`&&F(e,r,l.html,!0)){let t=E(e).querySelector(ne)?.textContent.replace(/\s+/g,` `).trim();Te(e,t||g.invalid);return}l.kind===`ok`&&l.html&&F(e,r,l.html,!1)||Ve(e,n,l.kind===`ok`||l.kind===`validation`?`server`:l.kind)}}}function We(e,t,n){let r=n.message,i=n.redirect||null,a={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};if(r&&window.WUI?.toast?.(r,{variant:`success`}),j(e,t.trigger?.isConnected?t.trigger:document,`success`,a),t.options.onSuccess?.(a,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),n.next&&!i){t.url=n.next,t.method=`GET`,t.body=void 0,P(e,t);return}if(n.keepOpen){n.html&&F(e,t,n.html,!1);return}N(e,t,`success`,a)}function Ge(e){let t=e.target.closest?.(`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);if(t&&!(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0))){if(e.preventDefault(),t.hasAttribute(`data-wui-pane`)){Ze(t.getAttribute(`data-wui-pane`),{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{e?.name!==`AbortError`&&n(e)});return}if(!t.hasAttribute(`data-wui-modal`)){Ye(t.getAttribute(`data-wui-drawer`),{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{e?.name!==`AbortError`&&n(e)});return}L(t.getAttribute(`data-wui-modal`),{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{e?.name!==`AbortError`&&n(e)})}}function Ke(e){if(e.key!==`Tab`||e.defaultPrevented)return;let t=e.currentTarget.querySelectorAll(`.modal.show`),n=e.currentTarget.querySelector(`.modal.show.wui-modal-stacked`)??t[t.length-1];n&&we(n,e)}function qe(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target.closest?.(Xe),n=t&&y.get(t);!n?.session||e.currentTarget.querySelector(`.modal.show`)||N(n,n.session,`dismissed`,null)}function I(e=document){let t=e.ownerDocument||e;ae.has(t)||(ae.add(t),t.addEventListener(`click`,Ge),t.addEventListener(`keydown`,Ke),t.addEventListener(`keydown`,qe));let n=[...e.querySelectorAll?.(`.modal[data-wui-remote-url]`)||[]];e.matches?.(`.modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)Oe(e)}function L(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=oe(e),r=t.container===`drawer`,i=r?ue(t.size):se(t.size),a=t.placement||`center`;if(!le.includes(a))throw TypeError(`WUI.modal.load: unsupported placement "${a}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(b());let o=ge(r?`drawer`:`modal`);I(document);let s=Oe(o),c=O(s),l=M(s,e,t);l.explicitSize=i,S(o,i||s.defaultSize),r||o.querySelector(`.modal-dialog`).classList.toggle(`modal-dialog-centered`,a===`center`),t.title&&o.setAttribute(`aria-label`,t.title),c||(!r&&pe()&&(document.body.appendChild(o),o.classList.add(`wui-modal-stacked`)),n.getInstance(o)?.dispose(),n.getOrCreateInstance(o,{backdrop:!t.staticBackdrop||`static`,keyboard:!t.staticBackdrop}));let u=c?Promise.resolve():new Promise(e=>o.addEventListener(`shown.bs.modal`,()=>e(),{once:!0})),d=P(s,l);return c||n.getOrCreateInstance(o).show(),Je(s,l,t,u,d,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Je(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),N(e,t,`dismissed`,{aborted:!0})),i(b())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw b();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function Ye(e,t={}){return L(e,{...t,container:`drawer`,placement:void 0})}var Xe=`[data-wui-pane-host]`;function Ze(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=me(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(b());I(document);let r=Oe(n),i=M(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=P(r,i);return Je(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Qe(e){let t=me(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=y.get(t);n?.session&&N(n,n.session,`dismissed`,null)}var $e=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),R=Object.freeze([`number`,`currency`,`compact`]),et=`wui-kanban:`,tt=`(max-width: 767.98px)`,nt=400,rt=6,z=Object.freeze({help:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,empty:`Nothing here`,collapse:e=>`Collapse ${e}`,expand:e=>`Expand ${e}`,lifted:(e,t)=>`Picked up ${e} in ${t}. Use the Left and Right arrow keys to choose a column.`,over:(e,t)=>`${e}, ${t===1?`1 card`:`${t} cards`}. Drop allowed.`,overSource:e=>`${e}, where the card started.`,overRefused:(e,t)=>`${e}. ${t}`,dropHere:(e,t)=>`Drop here to move ${e} to ${t}.`,refused:(e,t)=>`Cards in ${e} cannot move to ${t}.`,moved:(e,t)=>`Moved ${e} to ${t}.`,saving:(e,t)=>`Moving ${e} to ${t}.`,cancelled:e=>`${e} was not moved.`,rolledBack:(e,t)=>`${e} went back to ${t}.`,locked:e=>`${e} cannot be moved.`,more:e=>`Show ${e} more`,fewer:`Show fewer`,swipeHint:`Swipe sideways or tap a column`,busy:`This card is still saving. Try again in a moment.`,failed:Object.freeze({forbidden:`You do not have permission to move this card.`,client:`This card could not be moved. Refresh the board and try again.`,validation:`This card could not be moved. Refresh the board and try again.`,server:`Something went wrong on our side, so the card went back. Try again in a moment.`,network:`Could not reach the server, so the card went back. Check your connection and try again.`})}),B=`[data-wui-column]`,V=`[data-wui-body]`,H=`[data-wui-card]`,it=`[data-wui-count]`,at=`[data-wui-summary]`,ot=`[data-wui-empty]`,st=`[data-wui-drop-note]`,ct=`[data-wui-live]`,lt=`[data-wui-help]`,U=`[data-wui-switch]`,ut=`[data-wui-scroller]`,dt=`[data-wui-collapse]`,ft=`[data-wui-more]`,pt=`data-wui-visible-limit`,W=`data-wui-overflow`,mt=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,G=48,K=16,q=e=>e.getAttribute(`data-wui-column`),J=e=>e.getAttribute(`data-wui-card`),Y=e=>e.hidden||e.hasAttribute(`hidden`),ht=e=>Y(e)||e.hasAttribute(W);function gt(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function _t(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function X(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||J(e)||`Card`}function Z(e){return e?`${et}${e}`:null}function Q(e,t=globalThis.localStorage){let n=Z(e);if(!n||!t)return{};try{let e=JSON.parse(t.getItem(n)||`null`);return e&&typeof e.collapsed==`object`&&e.collapsed?e.collapsed:{}}catch{return{}}}function vt(e,t,n,r=globalThis.localStorage){let i=Z(e);if(!i||!r)return;let a={...Q(e,r),[t]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch{}}function yt(e,t){if(!R.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${R.join(`, `)}.`);if(t!=null&&t!==``&&!i.includes(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.join(`, `)}.`);return e===`currency`?{style:`currency`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:a[0],unit:t||`rupees`}:{style:`number`,decimals:0}}function bt(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var $=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},xt=class extends e{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)}}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`dragstart`,e=>{e.target.closest?.(H)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1}),this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e.nodeType===1&&e.matches(H)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(V))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=q(t),i=gt(t.getAttribute(pt)),a=[],o=[];for(let e of this._cardsIn(t)){if(this._filter&&(e.hidden=this._filter(e)===!1),Y(e)){e.removeAttribute(W);continue}a.push(e),o.push(e.getAttribute(`data-wui-value`))}let s=this._expanded.has(n),c=_t(a.map(J),i,s,this._revealed);for(let e of a)e.toggleAttribute(W,c.has(J(e)));let l=String(a.length);for(let e of this._countsOf(t))e.textContent!==l&&(e.textContent=l);let u=t.querySelector(ot);if(u&&(u.hidden=a.length>0),e){let n=t.querySelector(at);n&&(n.textContent=r(bt(o),e))}let d=t.querySelector(ft);if(d){d.hidden=i==null||(s?a.length<=i:c.size===0),d.setAttribute(`aria-expanded`,s?`true`:`false`);let e=s?z.fewer:z.more(c.size);d.textContent!==e&&(d.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return[...this.querySelectorAll(B)]}_columnByKey(e){return this._columns().find(t=>q(t)===e)||null}_columnOf(e){return e.closest(B)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||q(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return e.querySelector(V)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e.matches(H)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!ht(e))}_allCards(){return[...this.querySelectorAll(`${V} > ${H}`)]}_cardByKey(e){return this._allCards().find(t=>J(t)===e)||null}_countsOf(e){let t=q(e),n=[...this.querySelectorAll(U)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(it),...n.flatMap(e=>[...e.querySelectorAll(it)])]}_scroller(){return this.querySelector(ut)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?yt(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(lt);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=this.querySelector(ct);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=X(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce(z.locked(t)),this._fire(`wui:kanban:locked`,{key:J(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)===`true`?(this._announce(z.busy),$(z.busy,`info`),!1):!0}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=z.refused(r?this._titleOf(r):t,i?this._titleOf(i):n),o=i?.getAttribute(`data-accept-from`);if(o!=null&&!o.split(/\s+/).filter(Boolean).includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=X(e),r=new Map;for(let i of this._columns()){let a=q(i),o=this._check(e,t,a);r.set(a,o),i.setAttribute(`data-wui-drop`,o.source?`source`:o.ok?`ok`:`refused`);let s=i.querySelector(st);s&&!o.source&&(s.textContent=o.ok?z.dropHere(n,this._titleOf(i)):o.reason,s.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=e.querySelector(st);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e),i=q(r),a=this._columnByKey(t),o=X(e);if(i===t||!this._canLift(e))return!1;let s=this._check(e,i,t);if(!s.ok)return this._announce(s.reason),$(s.reason,`info`),!1;let l=this._cardsIn(a),u=Number.isInteger(n)?Math.max(0,Math.min(n,l.length)):l.length,d={key:J(e),card:e,from:i,to:t,index:u},f=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,d),this._announce(z.moved(o,this._titleOf(a))),f&&this._refocusSoon(d.key),!0;if(!this._fire(`wui:kanban:move`,d,!0))return!1;let p=a.hasAttribute(pt)&&!this._revealed.has(d.key);p&&this._revealed.add(d.key);let m={parent:e.parentNode,next:e.nextSibling,column:r,revealed:p};this._bodyOf(a).insertBefore(e,l[u]||null),f&&this._focusMoved(e),this.refresh();let h=a.getAttribute(`data-wui-step`);if(h)return this._runStep(e,d,m,h,a.getAttribute(`data-wui-step-size`));let g=this.getAttribute(`move-url`);if(!g)return this._announce(z.moved(o,this._titleOf(a))),this._fire(`wui:kanban:moved`,{...d,result:null}),!0;this._lock(e,!0),this._announce(z.saving(o,this._titleOf(a)));let _=await c(g,{method:`POST`,body:new URLSearchParams({card:d.key,from:i,to:t,index:String(u)})});if(this._lock(e,!1),_.kind===`session`)return!1;if(_.ok){let t=this._applyFragment(_.html)||e;return $(_.message,`success`),this._announce(z.moved(X(t),this._titleOf(a))),this._fire(`wui:kanban:moved`,{...d,card:t,result:_}),!0}return this._rollback(e,m),_.kind!==`aborted`&&$(_.message||z.failed[_.kind]||z.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...d,kind:_.kind,status:_.status,message:_.message}),!1}async _runStep(e,t,n,r,i){let a=X(e),o=this._columnByKey(t.to),s=new URLSearchParams({card:t.key,from:t.from,to:t.to}).toString(),l=r+(r.includes(`?`)?`&`:`?`)+s;this._lock(e,!0);let u;try{u=await(await L(l,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),r?.name!==`AbortError`&&$(z.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:r?.message??null}),!1}if(u?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce(z.cancelled(a)),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let d=e,f=this.getAttribute(`card-url`);if(f){let n=await c(`${f}${f.includes(`?`)?`&`:`?`}${new URLSearchParams({card:t.key})}`);n.ok&&(d=this._applyFragment(n.html)||e)}return this._lock(d,!1),this._announce(z.moved(X(d),this._titleOf(o))),this._fire(`wui:kanban:moved`,{...t,card:d,result:u}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;t.revealed&&this._revealed.delete(J(e)),t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce(z.rolledBack(X(e),this._titleOf(t.column)))}_applyFragment(e){if(!e)return null;let n=document.createElement(`template`);n.innerHTML=e;for(let e of n.content.querySelectorAll(`script`))t(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of[...n.content.querySelectorAll(H)]){if(e.closest(`template`))continue;let t=this._cardByKey(J(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of n.content.querySelectorAll(`template[data-wui-kanban-summary]`))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(at)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),window.WUI?.refresh?.(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=e.target.closest?.(H);if(!t||!this.contains(t)||e.target.closest(mt))return;let n={card:t,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=n,e.pointerType===`touch`&&(n.timer=setTimeout(()=>{this._press===n&&this._startDrag(n,n.x,n.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(!(!t||e.pointerId!==t.id)){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){!this._press||e.pointerId!==this._press.id||this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=q(this._columnOf(r)),a=r.getBoundingClientRect(),o=r.cloneNode(!0);for(let e of[o,...o.querySelectorAll(`[id]`)])e.removeAttribute(`id`);o.removeAttribute(`data-wui-card`),o.removeAttribute(`tabindex`),o.setAttribute(`aria-hidden`,`true`),o.classList.add(`wui-kanban-ghost`),o.style.width=`${a.width}px`,this.appendChild(o),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:i,ghost:o,dx:t-a.left,dy:n-a.top,over:null,verdicts:this._markTargets(r,i)},this._announce(z.lifted(X(r),this._titleOf(this._columnOf(r)))),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+G?r.scrollBy?.({left:-16}):e>t.right-G&&r.scrollBy?.({left:K}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<G?window.scrollBy?.({top:-16}):t>i-G&&window.scrollBy?.({top:K}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+G&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-G&&n.scrollTop+n.clientHeight<n.scrollHeight-1?(n.scrollBy?.({top:K}),!0):!1}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce(z.cancelled(X(n.card)));return}let i=q(r),a=n.verdicts.get(i);if(a?.source){this._announce(z.cancelled(X(n.card)));return}if(!a?.ok){this._announce(a?.reason),$(a?.reason,`info`);return}this._commit(n.card,i,this._indexAt(r,n.y))}_click(e){if(this._suppressClick&&e.target.closest?.(H)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let t=e.target.closest?.(dt);if(t&&this.contains(t)){let e=t.closest(B);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let n=e.target.closest?.(ft);if(n&&this.contains(n)){this._controlled()||this._toggleMore(n.closest(B));return}let r=e.target.closest?.(U);r&&this.contains(r)&&this._showColumn(r.getAttribute(`data-wui-switch`))}_keyDown(e){if(this._kbd){this._liftedKey(e);return}let t=e.target;if(!t.matches?.(H)||!this.contains(t))return;let n=this._columnOf(t);switch(e.key){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(t))return;let r=q(n),i=this._columns();this._kbd={card:t,from:r,target:i.indexOf(n),verdicts:this._markTargets(t,r)},t.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),n.setAttribute(`data-wui-target`,``),this._announce(z.lifted(X(t),this._titleOf(n)));return}case`ArrowDown`:case`ArrowUp`:{let r=this._visibleCardsIn(n),i=r[r.indexOf(t)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),r=e.key===`ArrowRight`?1:-1;for(let i=t.indexOf(n)+r;i>=0&&i<t.length;i+=r){let n=this._visibleCardsIn(t[i])[0];if(n&&!t[i].hasAttribute(`data-collapsed`)){e.preventDefault(),n.focus();return}}return}default:}}_liftedKey(e){let t=this._kbd,n=this._columns();switch(e.key){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let r=t.target+(e.key===`ArrowRight`?1:-1);if(r<0||r>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=r;let i=n[r];i.setAttribute(`data-wui-target`,``),this._showColumn(q(i),!1);let a=t.verdicts.get(q(i)),o=this._titleOf(i);this._announce(a.source?z.overSource(o):a.ok?z.over(o,this._cardsIn(i).filter(e=>!Y(e)).length):z.overRefused(o,a.reason));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target],i=q(r),a=t.verdicts.get(i);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce(z.cancelled(X(t.card))):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce(z.cancelled(X(t.card)));return;default:}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=Q(this.getAttribute(`board-id`));for(let t of this._columns()){let n=q(t);t.hasAttribute(`data-collapsible`)&&Object.hasOwn(e,n)&&this._setCollapsed(t,e[n],!1)}}_setCollapsed(e,t,n){let r=q(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(dt))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?z.expand(i):z.collapse(i));n&&(vt(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=q(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(J(t));else this._expanded.add(t);this.refresh()}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(U))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(U))e.getAttribute(`data-wui-switch`)===q(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};export{u as C,Ze as S,h as _,R as a,Ye as b,xt as c,Z as d,yt as f,vt as g,bt as h,et as i,X as l,Q as m,nt as n,z as o,gt as p,tt as r,$e as s,rt as t,_t as u,Qe as v,L as x,I as y};
|
package/dist/types/chatCore.d.ts
CHANGED
package/dist/ui-chat-core.js
CHANGED
|
@@ -4,7 +4,4 @@ function e(e){let t=``;function n(t){let n=`message`,r=[];for(let e of t.split(`
|
|
|
4
4
|
`).replace(/\r(?!$)/g,`
|
|
5
5
|
`);let r=t.split(`
|
|
6
6
|
|
|
7
|
-
`);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`tool`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDone:`Done.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}
|
|
8
|
-
`).split(`
|
|
9
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(f.test(e)){let e=[];for(r+=1;r<t.length&&!f.test(t[r]);)e.push(t[r]),r+=1;r+=1,n.push({type:`code`,text:e.join(`
|
|
10
|
-
`)});continue}if(b(t,r)){let i=y(e),a=[];for(r+=2;r<t.length&&t[r].trim()&&v(t[r]);)a.push(y(t[r])),r+=1;n.push({type:`table`,header:i,rows:a});continue}if(g.test(e)){n.push({type:`rule`}),r+=1;continue}let i=h.exec(e);if(i){n.push({type:`heading`,text:i[1]}),r+=1;continue}let a=m.exec(e);if(a||p.test(e)){let e=!!a,i=e?m:p,o=[];for(;r<t.length&&t[r].trim();){let n=i.exec(t[r]);if(n)o.push(e?n[2]:n[1]);else if(x(t,r))break;else o[o.length-1]+=` ${t[r].trim()}`;r+=1}n.push({type:`list`,ordered:e,start:e?Number(a[1]):1,items:o});continue}let o=[e];for(r+=1;r<t.length&&t[r].trim()&&!x(t,r);)o.push(t[r]),r+=1;n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var C=e=>!!e&&/[\p{L}\p{N}]/u.test(e);function w(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]===`_`&&C(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 T(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=w(e,i+2,o);if(s!==-1&&!(a===`_`&&C(e[i-1]))){r(),t.push({type:`strong`,children:T(e.slice(i+2,s))}),i=s+2;continue}n+=o,i+=2;continue}if(a===`*`||a===`_`){let n=w(e,i+1,a);if(n!==-1&&!(a===`_`&&C(e[i-1]))){r(),t.push({type:`em`,children:T(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:T(n[1])}),i+=n[0].length;continue}}n+=a,i+=1}return r(),t.map((e,t)=>({...e,key:t}))}function E(e,t){if(!t||!d.test(e))return null;let n=t(e);return typeof n==`string`&&n.startsWith(`/`)&&!n.startsWith(`//`)?n:null}export{n as ChatApiError,l as DEFAULT_CHAT_LABELS,c as createChatClient,e as createSseParser,E as linkRoute,u as mergeLabels,S as parseBlocks,T as parseInline};
|
|
7
|
+
`);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`tool`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDone:`Done.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}export{n as ChatApiError,l as DEFAULT_CHAT_LABELS,c as createChatClient,e as createSseParser,u as mergeLabels};
|