@luzmo/analytics-components-kit 1.0.9-beta.3 → 1.0.9-beta.5
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/README.md +1 -1
- package/package.json +2 -2
- package/react/package.json +2 -2
- package/standalone/chunks/base-Cgmw1Vq_.js +2 -0
- package/standalone/chunks/display-settings-binning-CxpvhW7Y.js +38 -0
- package/standalone/chunks/display-settings-datetime-Cqptoxuq.js +199 -0
- package/standalone/chunks/display-settings-grand-totals-BJp7zJPj.js +26 -0
- package/standalone/chunks/display-settings-numeric-BskLgQmz.js +172 -0
- package/standalone/chunks/{display-settings-period-over-period-Bwjoji3a.js → display-settings-period-over-period-CbUd7uc9.js} +1 -1
- package/standalone/chunks/embed-EnSdYTW8.js +228 -0
- package/standalone/chunks/{filters-C1yU7w2V.js → filters-CTsIpQ2T.js} +68 -68
- package/standalone/chunks/{formula-codemirror-BAlhe79s.js → formula-codemirror-4wlUAHrO.js} +1 -1
- package/standalone/chunks/item-option-action-button-group-DZW0HRGd.js +35 -0
- package/standalone/chunks/item-option-base-BlSnktzl.js +38 -0
- package/standalone/chunks/item-option-color-palette-picker-jnEt02PP.js +22 -0
- package/standalone/chunks/{item-option-color-picker-59il-pkm.js → item-option-color-picker-CcElYCgD.js} +1 -1
- package/standalone/chunks/item-option-color-range-DTFbs7JK.js +80 -0
- package/standalone/chunks/item-option-guidelines-DFlj41ZE.js +117 -0
- package/standalone/chunks/{item-option-multi-language-field-BNn4WFUG.js → item-option-multi-language-field-DVc8-FVc.js} +1 -1
- package/standalone/chunks/{item-option-number-field-_lCPA_qC.js → item-option-number-field-B1V-8Nq-.js} +1 -1
- package/standalone/chunks/item-option-panel-CpyguQjh.js +298 -0
- package/standalone/chunks/{item-option-picker-CeK7QDTm.js → item-option-picker-BCrQSP1O.js} +1 -1
- package/standalone/chunks/item-option-position-picker-CLiGzaZ1.js +14 -0
- package/standalone/chunks/item-option-positions-number-field-DmFdahh8.js +31 -0
- package/standalone/chunks/{item-option-radio-button-group-DR7gdaTr.js → item-option-radio-button-group-nioc7wyo.js} +1 -1
- package/standalone/chunks/item-option-slider-BfXB8U09.js +15 -0
- package/standalone/chunks/{item-option-switch-DJfnhpf_.js → item-option-switch-DPF9lIX0.js} +1 -1
- package/standalone/chunks/{item-option-text-field-DNqL7Evw.js → item-option-text-field-CRbhs_g4.js} +1 -1
- package/standalone/chunks/item-slot-picker-panel-B_7VXYPs.js +439 -0
- package/standalone/chunks/load-data-fields-for-datasets-fBp1YEFi.js +25 -0
- package/standalone/chunks/{load-formula-codemirror-Cyqo4LoE.js → load-formula-codemirror-DcjxFIW6.js} +1 -1
- package/standalone/chunks/localized-mixin-YSDMfLKU.js +2 -0
- package/standalone/chunks/{luzmo-icon-markup-GqF25og5.js → luzmo-icon-markup-JO3eup7O.js} +1 -1
- package/standalone/chunks/luzmoCog-C4v4vc5N.js +2 -0
- package/standalone/chunks/luzmoLockOutline-Dctb86HR.js +2 -0
- package/standalone/chunks/luzmoTable-BYeZ8pW6.js +2 -0
- package/standalone/chunks/task-CTUsEtxU.js +2 -0
- package/standalone/chunks/themes-BD5sKr3j.js +2 -0
- package/standalone/chunks/v4-CI0qP0ur.js +2 -0
- package/standalone/interactive-viz-item.js +20 -246
- package/standalone/item-grid.js +115 -0
- package/standalone/manifest.json +40 -33
- package/standalone/chunks/base-DOKoeL4P.js +0 -2
- package/standalone/chunks/display-settings-binning-CTWsdo0F.js +0 -38
- package/standalone/chunks/display-settings-datetime-CdxMI-9Q.js +0 -199
- package/standalone/chunks/display-settings-grand-totals-BCW8hefp.js +0 -26
- package/standalone/chunks/display-settings-numeric-D04OO7n9.js +0 -172
- package/standalone/chunks/item-option-action-button-group-B3cugMc_.js +0 -35
- package/standalone/chunks/item-option-base-R8-N5_rE.js +0 -38
- package/standalone/chunks/item-option-color-palette-picker-CMZyo1NH.js +0 -22
- package/standalone/chunks/item-option-color-range-BWaElfwS.js +0 -80
- package/standalone/chunks/item-option-guidelines-BzvrNruz.js +0 -117
- package/standalone/chunks/item-option-panel-CyE_83Hf.js +0 -298
- package/standalone/chunks/item-option-position-picker-BAWZpDBA.js +0 -14
- package/standalone/chunks/item-option-positions-number-field-DjhFmMAp.js +0 -31
- package/standalone/chunks/item-option-slider-C_jierlR.js +0 -15
- package/standalone/chunks/item-slot-picker-panel-Bqmx51Yb.js +0 -439
- package/standalone/chunks/load-data-fields-for-datasets-_VJWUFPO.js +0 -25
- package/standalone/chunks/localized-mixin-BEfBwOPN.js +0 -2
- package/standalone/chunks/task-C3c3OWyi.js +0 -2
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n}from"./lit-localize-CIGP-NUw.js";import{t as r}from"./localized-decorator-Buib6Rq1.js";import{r as i,t as a}from"./calculate-data-field-icon-CrEVAfzJ.js";import{c as o}from"./type-check-CC6bgirK.js";import{t as s}from"./localize-BXHWaHdZ.js";import{n as c}from"./periods.const-Cie50jR4.js";import{t as l}from"./data-broker-CbKNAOhf.js";import{html as u,property as d,unsafeCSS as f}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/lit.js";import{ElementSizes as p,LuzmoElement as m,SizedMixin as h}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/utils.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/select.js";var g=e=>!!(e&&Object.keys(e).length>0),_=(e,t,n={})=>{if(t.hidden===!0&&!n.includeHidden||!t.id||!t.type)return null;let r=g(t.name)?t.name:{en:`Untitled`},i={datasetId:e,columnId:t.id,type:t.type,name:r};return t.description&&g(t.description)&&(i.description=t.description),t.subtype&&(i.subtype=t.subtype),t.format&&(i.format=t.format),typeof t.lowestLevel==`number`&&(i.lowestLevel=t.lowestLevel),typeof t.highestLevel==`number`&&(i.highestLevel=t.highestLevel),typeof t.hierarchy_enabled==`boolean`&&(i.hierarchy_enabled=t.hierarchy_enabled),t.expression&&(i.expression=t.expression),Array.isArray(t.duration_levels)&&t.duration_levels.length>0&&(i.duration_levels=[...t.duration_levels]),t.duration_format&&(i.duration_format=t.duration_format),Array.isArray(t.hierarchyLevels)&&t.hierarchyLevels.length>0&&(i.hierarchyLevels=t.hierarchyLevels.map(({id:e,level:t,name:n})=>({id:e,level:t,name:n}))),t.currency?.id&&t.currency.symbol&&(i.currency={id:t.currency.id,name:t.currency.name,symbol:t.currency.symbol}),i},v=(e,t,n={})=>{if(t.hidden===!0&&!n.includeHidden||!t.id||!t.type)return null;let r=g(t.name)?t.name:{en:`Untitled`},i={datasetId:e,formulaId:t.id,type:t.type,name:r};return t.description&&g(t.description)&&(i.description=t.description),t.subtype&&(i.subtype=t.subtype),t.format&&(i.format=t.format),typeof t.lowestLevel==`number`&&(i.lowestLevel=t.lowestLevel),t.expression&&(i.expression=t.expression),Array.isArray(t.duration_levels)&&t.duration_levels.length>0&&(i.duration_levels=[...t.duration_levels]),t.duration_format&&(i.duration_format=t.duration_format),t.currency?.id&&t.currency.symbol&&(i.currency={id:t.currency.id,name:t.currency.name,symbol:t.currency.symbol}),i},y=(e,t={})=>{if(!e?.id)return[];let n=[];return Array.isArray(e.columns)&&e.columns.forEach(r=>{let i=_(e.id,r,t);i&&n.push(i)}),Array.isArray(e.formulas)&&e.formulas.forEach(r=>{let i=v(e.id,r,t);i&&n.push(i)}),n},b=(e,t={})=>e.map(e=>({id:e.id,name:e.name,description:e.description,dataFields:y(e,t)})),x=`:host{font-family:var(--luzmo-font-family)}luzmo-select{--luzmo-option-icon-width:var(--data-fields-select-option-icon-width);width:100%}:host{--data-fields-select-option-icon-width:calc(var(--luzmo-font-size) * 1.4)}:host([size=xxs]),:host([size=xs]),:host([size=s]){--data-fields-select-option-icon-width:calc(var(--luzmo-font-size-s) * 1.4)}:host([size=l]){--data-fields-select-option-icon-width:calc(var(--luzmo-font-size-l) * 1.4)}:host([size=xl]),:host([size=xxl]){--data-fields-select-option-icon-width:calc(var(--luzmo-font-size-xl) * 1.4)}`,S=`::level::`,C=(e,t)=>`${e}${S}${t}`,w=e=>{let t=e.indexOf(S);return t===-1?null:{columnId:e.slice(0,t),level:Number(e.slice(t+9))}},T=class extends t(h(m,{validSizes:Object.values(p)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.icons=`menu-only`,this.levels=`on`,this.allowEmpty=!1,this.selects=`single`,this.value=[],this.retrieving=!1,this.invalid=!1,this.clearable=!1,this.pending=!1,this.disabled=!1,this.readonly=!1,this.quiet=!1,this.search=`auto`,this.placement=`bottom-start`,this.datasetsDataFields=[],this._dataFieldsSelected=[],this._lastEmittedValue=`[]`,this._pendingAutoSelectEvent=!1}static get styles(){return[f(x)]}_isAdHocFormula(e){return`formula`in e&&typeof e.formula==`string`}_sendChangeEvent(){let e=JSON.stringify(this.value);e!==this._lastEmittedValue&&(this._lastEmittedValue=e,this.dispatchEvent(new CustomEvent(`luzmo-data-fields-selected`,{bubbles:!0,composed:!0,cancelable:!0,detail:{dataFields:this._dataFieldsSelected}})))}_toDataFieldData(e,t,n=!1){return n?v(t,e,{includeHidden:!0}):_(t,e,{includeHidden:!0})}_toAdHocFormulaFieldData(e,t){return{datasetId:t,formula:e.formula,type:e.type,name:e.label??{en:`Ad-hoc formula`},subtype:e.subtype??void 0,format:e.format}}_findFormulaMatch(e,t,n){for(let r of e)if(this._isAdHocFormula(r)){if(r.formula===t)return this._toAdHocFormulaFieldData(r,n)}else if(r.id===t)return this._toDataFieldData(r,n,!0);return null}_resolveDataFieldFromValue(e,t){let n=w(e),r=n?n.columnId:e;for(let i of t){let t=i.columns??[],a=i.formulas??[],o=t.find(e=>e.id===r);if(o){let e=this._toDataFieldData(o,i.id,!1);if(e&&n&&(e.level=n.level,this._isExpandableHierarchy(o))){let t=o.hierarchyLevels?.find(e=>e.level===n.level);t&&(e.name=t.name)}return e}let s=this._findFormulaMatch(a,e,i.id);if(s)return s}return null}setDataField(e){if(this.disabled||this.readonly)return;let t=e?.detail?.value??[];this._dataFieldsSelected=[];for(let e of t){let t=this._resolveDataFieldFromValue(e,this.datasetsDataFields);t&&this._dataFieldsSelected.push(t)}this.value=t,this._sendChangeEvent()}_normalizeValueForLevels(e){if(this.levels!==`off`)return e;let t=[];for(let n of e){let e=w(n)?.columnId??n;t.includes(e)||t.push(e)}return t}_findDataFieldsInDatasetsDataFields(e){this._dataFieldsSelected=[];for(let t of e){let e=this._resolveDataFieldFromValue(t,this.datasetsDataFields);e&&this._dataFieldsSelected.push(e)}}_getAutoSelectValue(){for(let e of this.datasetsDataFields){if(e?.columns?.length>0){let t=e.columns[0];return this._isExpandableDatetime(t)?this._buildDatetimeChildren(t)[0]?.value??null:this._isExpandableHierarchy(t)?this._buildHierarchyChildren(t)[0]?.value??null:t.id}for(let t of e?.formulas??[])if(!this._isAdHocFormula(t))return t.id}return null}_autoSelectInitialDataField(){if(this.readonly||this.value.length>0||this.allowEmpty||this.retrieving)return;let e=this._getAutoSelectValue();e&&this._resolveDataFieldFromValue(e,this.datasetsDataFields)&&(this._pendingAutoSelectEvent=!0,this.value=[e])}willUpdate(e){if(super.willUpdate(e),(e.has(`value`)||e.has(`datasetsDataFields`)||e.has(`allowEmpty`)||e.has(`retrieving`)||e.has(`levels`)||e.has(`readonly`))&&this._autoSelectInitialDataField(),e.has(`value`)||e.has(`datasetsDataFields`)||e.has(`levels`)){if(e.has(`levels`)&&this.levels===`off`){let e=this._normalizeValueForLevels(this.value);JSON.stringify(e)!==JSON.stringify(this.value)&&(this._pendingAutoSelectEvent=!0,this.value=e)}this._findDataFieldsInDatasetsDataFields(this.value)}}updated(e){super.updated(e),this._pendingAutoSelectEvent&&e.has(`value`)&&this._dataFieldsSelected.length>0?(this._pendingAutoSelectEvent=!1,this._sendChangeEvent()):e.has(`value`)&&(this._lastEmittedValue=JSON.stringify(this.value))}_buildDatetimeChildren(e){let t=[],n=Math.min(Math.max(e.lowestLevel??1,1),c.length),r=Math.min(Math.max(e.highestLevel??1,1),c.length);for(let i=r;i<=n;i++)t.push({value:C(e.id,i),label:c[i-1]?.i18n()??``});return t}_buildHierarchyChildren(e){let t=[],n=e.hierarchyLevels??[];for(let r of n)r.level<1||t.push({value:C(e.id,r.level),label:s(r.name??{},this.contentLanguage)??``});return t}_isExpandableDatetime(e){let t=e.type;return this.levels!==`off`&&(t===`datetime`||t===`array[datetime]`)&&typeof e.lowestLevel==`number`}_isExpandableHierarchy(e){return this.levels!==`off`&&Array.isArray(e.hierarchyLevels)&&e.hierarchyLevels.length>2&&e.hierarchy_enabled===!0}render(){let e=[],t=this.icons!==`none`;for(let r of this.datasetsDataFields??[]){let o=r?.columns??[],c=r?.formulas??[];for(let n of o){let r={value:n.id,label:s(n?.name??{},this.contentLanguage)??``};t&&(r.icon=a(n,this.size)),this._isExpandableDatetime(n)?r.children=this._buildDatetimeChildren(n):this._isExpandableHierarchy(n)&&(r.children=this._buildHierarchyChildren(n)),e.push(r)}for(let r of c)if(this._isAdHocFormula(r)){let a=r.label?s(r.label,this.contentLanguage):n(`Ad-hoc formula`),o={value:r.formula,label:a??n(`Ad-hoc formula`)};t&&(o.icon=i),e.push(o)}else{let n={value:r.id,label:s(r?.name??{},this.contentLanguage)??``};t&&(n.icon=a(r,this.size)),e.push(n)}}let r=n(`Select...`),o=this.pending?``:this.label||this.placeholder||r,c=this.pending||this.value.length===0?[]:this.value,l=this.icons===`none`||this.icons===`menu-only`?`none`:void 0;return u`<luzmo-select
|
|
3
|
-
id="data-fields"
|
|
4
|
-
.size=${this.size}
|
|
5
|
-
.label=${o}
|
|
6
|
-
.pendingLabel=${this.label||this.placeholder||r}
|
|
7
|
-
.retrieving=${this.retrieving}
|
|
8
|
-
.icons=${l}
|
|
9
|
-
.selects=${this.selects}
|
|
10
|
-
.variant=${this.selects===`multiple`?`checkmarks`:`highlight`}
|
|
11
|
-
.placement=${this.placement}
|
|
12
|
-
.search=${this.search}
|
|
13
|
-
?emphasized=${!this.quiet}
|
|
14
|
-
.quiet=${this.quiet}
|
|
15
|
-
no-wrap
|
|
16
|
-
?invalid=${this.invalid}
|
|
17
|
-
?clearable=${this.clearable&&this.allowEmpty}
|
|
18
|
-
?pending=${this.pending}
|
|
19
|
-
?disabled=${this.disabled}
|
|
20
|
-
.readonly=${this.readonly}
|
|
21
|
-
.options=${e}
|
|
22
|
-
.value=${c}
|
|
23
|
-
@change=${this.setDataField}
|
|
24
|
-
>
|
|
25
|
-
</luzmo-select>`}};e([d({type:String,attribute:`content-language`,reflect:!0})],T.prototype,`contentLanguage`,void 0),e([d({type:String,reflect:!0})],T.prototype,`label`,void 0),e([d({type:String,reflect:!0})],T.prototype,`icons`,void 0),e([d({type:String,reflect:!0})],T.prototype,`levels`,void 0),e([d({type:Boolean,attribute:`allow-empty`,reflect:!0})],T.prototype,`allowEmpty`,void 0),e([d({type:String,attribute:`placeholder`,reflect:!0})],T.prototype,`placeholder`,void 0),e([d({type:String,reflect:!0})],T.prototype,`selects`,void 0),e([d({type:Array,reflect:!0})],T.prototype,`value`,void 0),e([d({type:Boolean,attribute:`retrieving`,reflect:!0})],T.prototype,`retrieving`,void 0),e([d({type:Boolean,attribute:`invalid`,reflect:!0})],T.prototype,`invalid`,void 0),e([d({type:Boolean,attribute:`clearable`,reflect:!0})],T.prototype,`clearable`,void 0),e([d({type:Boolean,attribute:`pending`,reflect:!0})],T.prototype,`pending`,void 0),e([d({type:Boolean,attribute:`disabled`,reflect:!0})],T.prototype,`disabled`,void 0),e([d({type:Boolean,reflect:!0})],T.prototype,`readonly`,void 0),e([d({type:Boolean,reflect:!0})],T.prototype,`quiet`,void 0),e([d({type:String,attribute:`search`,reflect:!0})],T.prototype,`search`,void 0),e([d({type:String,reflect:!0})],T.prototype,`placement`,void 0),e([d({type:Array,reflect:!1})],T.prototype,`datasetsDataFields`,void 0),T=e([r()],T),customElements.get(`luzmo-data-fields-select`)||customElements.define(`luzmo-data-fields-select`,T);var E=async(e,t)=>{if(!Array.isArray(e)||e.length===0)throw Error(`At least one dataset ID is required`);let{valid:n,invalid:r}=o(e);if(r.length>0&&console.warn(`[loadDataFieldsForDatasets] Invalid dataset IDs provided (not valid UUIDs): ${r.join(`, `)}. These will be skipped.`),n.length===0)throw Error(`No valid dataset IDs provided. Dataset IDs must be valid UUIDs.`);let{dataBrokerConfig:i}=t;if(!i)throw Error(`dataBrokerConfig is required`);(!i.authKey||!i.authToken)&&console.warn(`Both authKey and authToken are missing in the DataBroker configuration. This only works for public datasets and should not be used for secured data.`),l.configure({...i,authKey:i.authKey??``,authToken:i.authToken??``});try{return b(await l.fetchDatasetsWithColumnsAndFormulas(n))}catch(e){throw e instanceof Error&&e.message.includes(`Authentication failed`)?Error(`Failed to load datasets: Authentication failed. Please verify your API credentials are correct.`,{cause:e}):e}};export{E as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import{t as e}from"./lit-localize-CIGP-NUw.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/tokens.js";import{property as t}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/lit.js";var n=`:where(:root){--luzmo-font-color-hard:#000;--luzmo-background-color-alt-1:#fafafa;--luzmo-background-color-alt-2:#efefef;--luzmo-secondary-outline:#f0f3;--luzmo-color-informative:#1a77e9;--luzmo-color-informative-rgb:26, 119, 233;--luzmo-color-disabled:var(--luzmo-disabled-color)}:where(html.dark,html.dark-theme,.dark-theme){--luzmo-font-color-hard:#f8f9fa;--luzmo-background-color-alt-1:#2d2d32;--luzmo-background-color-alt-2:#313131;--luzmo-secondary-outline:#c8db0033;--luzmo-color-informative-rgb:26, 119, 233;--luzmo-color-disabled:var(--luzmo-disabled-color)}`;if(typeof document<`u`&&!document.querySelector(`style[data-luzmo-ack-vars]`)){let e=document.createElement(`style`);e.dataset.luzmoAckVars=``,e.textContent=n,document.head.append(e)}function r(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var i=(e,t,n)=>{let r=t.lastIndexOf(`?`),i=e[r===-1||r<t.lastIndexOf(`/`)?t:t.slice(0,r)];return i?typeof i==`function`?i():Promise.resolve(i):new Promise((e,r)=>{(typeof queueMicrotask==`function`?queueMicrotask:setTimeout)(r.bind(null,Error(`Unknown variable dynamic import: `+t+(t.split(`/`).length===n?``:`. Note that variables only represent file names one level deep.`))))})},a=`en`,o=[`de`,`es`,`fr`,`nl`],{getLocale:s,setLocale:c}=e({sourceLocale:a,targetLocales:o,loadLocale:e=>i(Object.assign({"../../generated/locales/de.ts":()=>import(`./de-ClGscYPh.js`),"../../generated/locales/es.ts":()=>import(`./es-C56MpCO9.js`),"../../generated/locales/fr.ts":()=>import(`./fr-BpNJieSH.js`),"../../generated/locales/nl.ts":()=>import(`./nl-BpTxEv-1.js`)}),`../../generated/locales/${e}.ts`,6)}),l=e=>{class n extends e{constructor(...e){super(...e),this.language=`en`}firstUpdated(e){super.firstUpdated(e),this._syncLocale()}willUpdate(e){super.willUpdate(e),e.has(`language`)&&this._syncLocale()}_syncLocale(){this.language!==s()&&(o.includes(this.language)||this.language===`en`)&&c(this.language)}}return r([t({type:String,reflect:!0})],n.prototype,`language`,void 0),n};export{r as n,l as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import{notEqual as e}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/lit.js";var t=Symbol(),n=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((e,t)=>{this.o=e,this.h=t})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(e,t,n){this.p=0,this.i=0,(this._=e).addController(this);let i=typeof t==`object`?t:{task:t,args:n};this.v=i.task,this.j=i.args,this.m=i.argsEqual??r,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,`initialValue`in i&&(this.u=i.initialValue,this.i=2,this.O=this.T?.())}hostUpdate(){!0===this.autoRun&&this.S()}hostUpdated(){this.autoRun===`afterUpdate`&&this.S()}T(){if(this.j===void 0)return;let e=this.j();if(!Array.isArray(e))throw Error(`The args function must return an array`);return e}async S(){let e=this.T(),t=this.O;this.O=e,e===t||e===void 0||t!==void 0&&this.m(t,e)||await this.run(e)}async run(e){let n,r;e??=this.T(),this.O=e,this.i===1?this.q?.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun===`afterUpdate`?queueMicrotask((()=>this._.requestUpdate())):this._.requestUpdate();let i=++this.p;this.q=new AbortController;let a=!1;try{n=await this.v(e,{signal:this.q.signal})}catch(e){a=!0,r=e}if(this.p===i){if(n===t)this.i=0;else{if(!1===a){try{this.k?.(n)}catch{}this.i=2,this.o?.(n)}else{try{this.A?.(r)}catch{}this.i=3,this.h?.(r)}this.u=n,this.l=r}this._.requestUpdate()}}abort(e){this.i===1&&this.q?.abort(e)}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(e){switch(this.i){case 0:return e.initial?.();case 1:return e.pending?.();case 2:return e.complete?.(this.value);case 3:return e.error?.(this.error);default:throw Error(`Unexpected status: `+this.i)}}},r=(t,n)=>t===n||t.length===n.length&&t.every(((t,r)=>!e(t,n[r])));export{n as t};
|