@luzmo/analytics-components-kit 1.0.1-alpha.50 → 1.0.1-alpha.51
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/components/display-settings-numeric/helpers/constants.d.ts +1 -0
- package/components/display-settings-numeric/index.cjs +16 -10
- package/components/display-settings-numeric/index.js +52 -34
- package/components/draggable-data-item/draggable-data-item.d.ts +0 -1
- package/components/draggable-data-item/index.cjs +5 -8
- package/components/draggable-data-item/index.js +32 -38
- package/components/draggable-data-item-level/draggable-data-item-level.d.ts +1 -1
- package/components/draggable-data-item-level/index.cjs +6 -6
- package/components/draggable-data-item-level/index.js +106 -113
- package/components/droppable-slot/droppable-slot.d.ts +4 -1
- package/components/droppable-slot/index.cjs +14 -12
- package/components/droppable-slot/index.js +138 -118
- package/components/filter-item/index.cjs +1 -1
- package/components/filter-item/index.js +1 -1
- package/components/filter-value-picker-hierarchy/index.cjs +1 -1
- package/components/filter-value-picker-hierarchy/index.js +1 -1
- package/components/filter-value-picker-numeric/index.cjs +1 -1
- package/components/filter-value-picker-numeric/index.js +1 -1
- package/components/{index-Delpl7qa.js → index-Cyo2hwg7.js} +1 -1
- package/components/{index-eBsINoH9.cjs → index-DpHum3lw.cjs} +1 -1
- package/components/slot-menu/index.cjs +11 -11
- package/components/slot-menu/index.js +165 -157
- package/components/slot-menu/slot-menu.d.ts +1 -1
- package/custom-elements.json +19 -42
- package/item-definitions/box-plot/box-plot-options.config.d.ts +1 -1
- package/item-definitions/choropleth-map/choropleth-map-options.config.d.ts +1 -1
- package/item-definitions/hexbin-map/hexbin-map-options.config.d.ts +1 -1
- package/item-definitions/route-map/route-map-options.config.d.ts +1 -1
- package/item-definitions/spike-map/spike-map-options.config.d.ts +1 -1
- package/package.json +1 -1
- package/utils/data-broker/index.d.ts +1 -1
@@ -17,7 +17,7 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-MPM_B4re.cjs");require("../index-1oIrlkAr.cjs");const c=require("../property-Cu4Q1hS4.cjs"),d=require("../set-locale-DCPlazsZ.cjs"),F=require("../localized-decorator-DIXYZ3RL.cjs"),v=require("../base-D76d76ww-tT6yr8eb.cjs");require("../focusable-BxtpnzWp-CkK9AeMt.cjs");const z=require("../index-
|
20
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-MPM_B4re.cjs");require("../index-1oIrlkAr.cjs");const c=require("../property-Cu4Q1hS4.cjs"),d=require("../set-locale-DCPlazsZ.cjs"),F=require("../localized-decorator-DIXYZ3RL.cjs"),v=require("../base-D76d76ww-tT6yr8eb.cjs");require("../focusable-BxtpnzWp-CkK9AeMt.cjs");const z=require("../index-DpHum3lw.cjs"),b=require("../state-fyl3IYMu.cjs"),T=".missing-value{opacity:.4}:host{--var: blue}";var I=Object.defineProperty,w=Object.getOwnPropertyDescriptor,n=(V,e,t,r)=>{for(var i=r>1?void 0:r?w(e,t):e,s=V.length-1,a;s>=0;s--)(a=V[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&I(e,t,i),i};const k=5e3;exports.LuzmoFilterValuePickerNumeric=class extends v.m(v.It,{validSizes:Object.values(v.d$1)}){constructor(){super(...arguments),this.language="en",this.contentLanguage="en",this._numericValues=[],this._retrieving=!0,this._search="",this._error=null,this._allValuesRetrieved=!1,this._runningQueries=[]}static get styles(){return[c.r(T)]}connectedCallback(){super.connectedCallback();const e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),z.dataBroker.configure(e)}willUpdate(e){var i,s,a,u,m,o,_,p,f,l,h,g,L,y;const t=e.has("filter");if(e.has("language")&&this.language!==d.getLocale()&&([...d.targetLocales].includes(this.language??"en")||this.language==="en")&&d.setLocale(this.language),t&&this.filter){const N=(i=e.get("filter"))==null?void 0:i.expression,S=(s=this.filter)==null?void 0:s.expression,P=((m=(u=(a=e.get("filter"))==null?void 0:a.parameters)==null?void 0:u[0])==null?void 0:m.columnId)||((p=(_=(o=e.get("filter"))==null?void 0:o.parameters)==null?void 0:_[0])==null?void 0:p.formulaId),$=((h=(l=(f=this.filter)==null?void 0:f.parameters)==null?void 0:l[0])==null?void 0:h.columnId)||((y=(L=(g=this.filter)==null?void 0:g.parameters)==null?void 0:L[0])==null?void 0:y.formulaId);(P!==$||!["? in ?","? not in ?"].includes(N))&&["? in ?","? not in ?"].includes(S)&&(this._numericValues=[],this._allValuesRetrieved=!1,this._retrieving=!0)}}async _fetchNumericValues(e=0){var p,f;if(this._allValuesRetrieved){this._retrieving=!1;return}if(!((f=(p=this.filter)==null?void 0:p.parameters)!=null&&f[0])){this._retrieving=!1,this._error="Missing column parameters";return}const t=this.filter.parameters[0],r=t.columnId,i=t.formulaId,s=t.datasetId;if(!r&&!i){this._retrieving=!1,this._error="Missing column id or formula id";return}else if(!s){this._retrieving=!1,this._error="Missing dataset id";return}this._retrieving=!0,this._error=null;const a={expression:"? like ?",parameters:[{dataset_id:s,expression:`CAST({${s}:${r??i}},hierarchy)`},this._search]},u={dimensions:[{column_id:r,formula_id:i,dataset_id:s}],where:[],order:[{column_id:r,formula_id:i,dataset_id:s,order:"asc"}],limit:{by:k,offset:e}};this._search&&!this._allValuesRetrieved&&u.where.push(a);const m=new AbortController,o=new Promise((l,h)=>{z.dataBroker.fetchData(u).then(l).catch(h),m.signal.addEventListener("abort",()=>{console.warn("Request aborted"),h({status:"aborted"})})}),_={promise:o,abortController:m};this._runningQueries.push(_);try{const l=await o,h=l&&Array.isArray(l.data)?l.data.map(g=>g[0]):[];this._search||(this._allValuesRetrieved=h.length<k),this._numericValues=e>0?[...this._numericValues,...h]:h}catch(l){if((l==null?void 0:l.status)==="aborted")return;this._error=l instanceof Error?l.message:"Unknown error",this._numericValues=[]}finally{this._runningQueries=this._runningQueries.filter(l=>l.promise!==o),this._retrieving=!1}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent("filter-value-changed",{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setValue(e){var r,i,s,a,u;const t=["? in ?","? not in ?"].includes((r=this.filter)==null?void 0:r.expression)?(i=e==null?void 0:e.detail)==null?void 0:i.value:(s=e==null?void 0:e.target)==null?void 0:s.value;this._value!==t&&(this._value=t,this.filter={...this.filter,parameters:[{...(u=(a=this.filter)==null?void 0:a.parameters)==null?void 0:u[0]},t]},this._sendChangeEvent())}selectValue(e){var i,s,a;const r=(((i=e.detail)==null?void 0:i.value)??"").map(u=>Number.parseFloat(u));this.filter={...this.filter,parameters:[{...(a=(s=this.filter)==null?void 0:s.parameters)==null?void 0:a[0]},r]},this._value=r,this._sendChangeEvent()}onScrolled(e){var t;!this._retrieving&&!this._allValuesRetrieved&&((t=e==null?void 0:e.detail)==null?void 0:t.last)===this._numericValues.length-1&&this._fetchNumericValues(this._numericValues.length)}renderNumberField(){var e,t;return c.x`<luzmo-number-field
|
21
21
|
.size=${this.size}
|
22
22
|
@change=${this.setValue}
|
23
23
|
@input=${this.setValue}
|
@@ -24,7 +24,7 @@ import { g as T, t as E, s as N, m as z } from "../set-locale-GI34z_M7.js";
|
|
24
24
|
import { l as R } from "../localized-decorator-Bl5gcI6n.js";
|
25
25
|
import { m as O, b as D, I as Q } from "../base-D76d76ww-BGkuhs54.js";
|
26
26
|
import "../focusable-BxtpnzWp-DJQkL8Zv.js";
|
27
|
-
import { d as V } from "../index-
|
27
|
+
import { d as V } from "../index-Cyo2hwg7.js";
|
28
28
|
import { r as _ } from "../state-nDsQPund.js";
|
29
29
|
const C = () => {
|
30
30
|
if (typeof document < "u" && !document.querySelector("style[data-luzmo-vars]")) {
|
@@ -1717,7 +1717,7 @@ class _ {
|
|
1717
1717
|
getAvailableDatasets() {
|
1718
1718
|
return this.availableDatasets;
|
1719
1719
|
}
|
1720
|
-
|
1720
|
+
getLinkedDatasetsIds(e) {
|
1721
1721
|
const t = this.queryClient.getQueryData(["dataset", e]);
|
1722
1722
|
return t ? (t.outgoingJoins ?? []).map((i) => i.securable_id).filter((i) => i && i !== e) : [];
|
1723
1723
|
}
|
@@ -17,4 +17,4 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";var Fe=s=>{throw TypeError(s)};var be=(s,e,t)=>e.has(s)||Fe("Cannot "+t);var r=(s,e,t)=>(be(s,e,"read from private field"),t?t.call(s):e.get(s)),f=(s,e,t)=>e.has(s)?Fe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),o=(s,e,t,i)=>(be(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),P=(s,e,t)=>(be(s,e,"access private method"),t);var pe=(s,e,t,i)=>({set _(n){o(s,e,n,t)},get _(){return r(s,e,i)}});var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(s){return this.listeners.add(s),this.onSubscribe(),()=>{this.listeners.delete(s),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},we=typeof window>"u"||"Deno"in globalThis;function M(){}function _e(s,e){return typeof s=="function"?s(e):s}function ze(s){return typeof s=="number"&&s>=0&&s!==1/0}function We(s,e){return Math.max(s+(e||0)-Date.now(),0)}function Se(s,e){return typeof s=="function"?s(e):s}function Xe(s,e){return typeof s=="function"?s(e):s}function De(s,e){const{type:t="all",exact:i,fetchStatus:n,predicate:u,queryKey:h,stale:a}=s;if(h){if(i){if(e.queryHash!==Ce(h,e.options))return!1}else if(!ce(e.queryKey,h))return!1}if(t!=="all"){const l=e.isActive();if(t==="active"&&!l||t==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||n&&n!==e.state.fetchStatus||u&&!u(e))}function Ae(s,e){const{exact:t,status:i,predicate:n,mutationKey:u}=s;if(u){if(!e.options.mutationKey)return!1;if(t){if(oe(e.options.mutationKey)!==oe(u))return!1}else if(!ce(e.options.mutationKey,u))return!1}return!(i&&e.state.status!==i||n&&!n(e))}function Ce(s,e){return((e==null?void 0:e.queryKeyHashFn)||oe)(s)}function oe(s){return JSON.stringify(s,(e,t)=>qe(t)?Object.keys(t).sort().reduce((i,n)=>(i[n]=t[n],i),{}):t)}function ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?Object.keys(e).every(t=>ce(s[t],e[t])):!1}function He(s,e){if(s===e)return s;const t=Ee(s)&&Ee(e);if(t||qe(s)&&qe(e)){const i=t?s:Object.keys(s),n=i.length,u=t?e:Object.keys(e),h=u.length,a=t?[]:{};let l=0;for(let y=0;y<h;y++){const p=t?y:u[y];(!t&&i.includes(p)||t)&&s[p]===void 0&&e[p]===void 0?(a[p]=void 0,l++):(a[p]=He(s[p],e[p]),a[p]===s[p]&&s[p]!==void 0&&l++)}return n===h&&l===n?s:a}return e}function Ee(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function qe(s){if(!Qe(s))return!1;const e=s.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!Qe(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(s)!==Object.prototype)}function Qe(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ye(s){return new Promise(e=>{setTimeout(e,s)})}function Ze(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?He(s,e):e}function et(s,e,t=0){const i=[...s,e];return t&&i.length>t?i.slice(1):i}function tt(s,e,t=0){const i=[e,...s];return t&&i.length>t?i.slice(0,-1):i}var Oe=Symbol();function Ge(s,e){return!s.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!s.queryFn||s.queryFn===Oe?()=>Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)):s.queryFn}var _,G,Z,Re,st=(Re=class extends ge{constructor(){super();f(this,_);f(this,G);f(this,Z);o(this,Z,e=>{if(!we&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){r(this,G)||this.setEventListener(r(this,Z))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,G))==null||e.call(this),o(this,G,void 0))}setEventListener(e){var t;o(this,Z,e),(t=r(this,G))==null||t.call(this),o(this,G,e(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(e){r(this,_)!==e&&(o(this,_,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return typeof r(this,_)=="boolean"?r(this,_):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},_=new WeakMap,G=new WeakMap,Z=new WeakMap,Re),Ne=new st,ee,N,te,Ke,it=(Ke=class extends ge{constructor(){super();f(this,ee,!0);f(this,N);f(this,te);o(this,te,e=>{if(!we&&window.addEventListener){const t=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,N)||this.setEventListener(r(this,te))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,N))==null||e.call(this),o(this,N,void 0))}setEventListener(e){var t;o(this,te,e),(t=r(this,N))==null||t.call(this),o(this,N,e(this.setOnline.bind(this)))}setOnline(e){r(this,ee)!==e&&(o(this,ee,e),this.listeners.forEach(i=>{i(e)}))}isOnline(){return r(this,ee)}},ee=new WeakMap,N=new WeakMap,te=new WeakMap,Ke),ve=new it;function rt(){let s,e;const t=new Promise((n,u)=>{s=n,e=u});t.status="pending",t.catch(()=>{});function i(n){Object.assign(t,n),delete t.resolve,delete t.reject}return t.resolve=n=>{i({status:"fulfilled",value:n}),s(n)},t.reject=n=>{i({status:"rejected",reason:n}),e(n)},t}function nt(s){return Math.min(1e3*2**s,3e4)}function Ve(s){return(s??"online")==="online"?ve.isOnline():!0}var $e=class extends Error{constructor(s){super("CancelledError"),this.revert=s==null?void 0:s.revert,this.silent=s==null?void 0:s.silent}};function Pe(s){return s instanceof $e}function Je(s){let e=!1,t=0,i=!1,n;const u=rt(),h=d=>{var v;i||(m(new $e(d)),(v=s.abort)==null||v.call(s))},a=()=>{e=!0},l=()=>{e=!1},y=()=>Ne.isFocused()&&(s.networkMode==="always"||ve.isOnline())&&s.canRun(),p=()=>Ve(s.networkMode)&&s.canRun(),c=d=>{var v;i||(i=!0,(v=s.onSuccess)==null||v.call(s,d),n==null||n(),u.resolve(d))},m=d=>{var v;i||(i=!0,(v=s.onError)==null||v.call(s,d),n==null||n(),u.reject(d))},S=()=>new Promise(d=>{var v;n=D=>{(i||y())&&d(D)},(v=s.onPause)==null||v.call(s)}).then(()=>{var d;n=void 0,i||(d=s.onContinue)==null||d.call(s)}),C=()=>{if(i)return;let d;const v=t===0?s.initialPromise:void 0;try{d=v??s.fn()}catch(D){d=Promise.reject(D)}Promise.resolve(d).then(c).catch(D=>{var j;if(i)return;const Q=s.retry??(we?0:3),w=s.retryDelay??nt,A=typeof w=="function"?w(t,D):w,K=Q===!0||typeof Q=="number"&&t<Q||typeof Q=="function"&&Q(t,D);if(e||!K){m(D);return}t++,(j=s.onFail)==null||j.call(s,t,D),Ye(A).then(()=>y()?void 0:S()).then(()=>{e?m(D):C()})})};return{promise:u,cancel:h,continue:()=>(n==null||n(),u),cancelRetry:a,continueRetry:l,canStart:p,start:()=>(p()?C():S().then(C),u)}}var at=s=>setTimeout(s,0);function ut(){let s=[],e=0,t=a=>{a()},i=a=>{a()},n=at;const u=a=>{e?s.push(a):n(()=>{t(a)})},h=()=>{const a=s;s=[],a.length&&n(()=>{i(()=>{a.forEach(l=>{t(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||h()}return l},batchCalls:a=>(...l)=>{u(()=>{a(...l)})},schedule:u,setNotifyFunction:a=>{t=a},setBatchNotifyFunction:a=>{i=a},setScheduler:a=>{n=a}}}var F=ut(),z,je,Be=(je=class{constructor(){f(this,z)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ze(this.gcTime)&&o(this,z,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(s){this.gcTime=Math.max(this.gcTime||0,s??(we?1/0:5*60*1e3))}clearGcTimeout(){r(this,z)&&(clearTimeout(r(this,z)),o(this,z,void 0))}},z=new WeakMap,je),se,ie,E,W,q,le,X,T,L,ke,ht=(ke=class extends Be{constructor(e){super();f(this,T);f(this,se);f(this,ie);f(this,E);f(this,W);f(this,q);f(this,le);f(this,X);o(this,X,!1),o(this,le,e.defaultOptions),this.setOptions(e.options),this.observers=[],o(this,W,e.client),o(this,E,r(this,W).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,o(this,se,ct(this.options)),this.state=e.state??r(this,se),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=r(this,q))==null?void 0:e.promise}setOptions(e){this.options={...r(this,le),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&r(this,E).remove(this)}setData(e,t){const i=Ze(this.state.data,e,this.options);return P(this,T,L).call(this,{data:i,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),i}setState(e,t){P(this,T,L).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var i,n;const t=(i=r(this,q))==null?void 0:i.promise;return(n=r(this,q))==null||n.cancel(e),t?t.then(M).catch(M):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(r(this,se))}isActive(){return this.observers.some(e=>Xe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!We(this.state.dataUpdatedAt,e)}onFocus(){var t;const e=this.observers.find(i=>i.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}onOnline(){var t;const e=this.observers.find(i=>i.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),r(this,E).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(r(this,q)&&(r(this,X)?r(this,q).cancel({revert:!0}):r(this,q).cancelRetry()),this.scheduleGc()),r(this,E).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||P(this,T,L).call(this,{type:"invalidate"})}fetch(e,t){var l,y,p;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(t!=null&&t.cancelRefetch))this.cancel({silent:!0});else if(r(this,q))return r(this,q).continueRetry(),r(this,q).promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(m=>m.options.queryFn);c&&this.setOptions(c.options)}const i=new AbortController,n=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(o(this,X,!0),i.signal)})},u=()=>{const c=Ge(this.options,t),m={client:r(this,W),queryKey:this.queryKey,meta:this.meta};return n(m),o(this,X,!1),this.options.persister?this.options.persister(c,m,this):c(m)},h={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:r(this,W),state:this.state,fetchFn:u};n(h),(l=this.options.behavior)==null||l.onFetch(h,this),o(this,ie,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=h.fetchOptions)==null?void 0:y.meta))&&P(this,T,L).call(this,{type:"fetch",meta:(p=h.fetchOptions)==null?void 0:p.meta});const a=c=>{var m,S,C,d;Pe(c)&&c.silent||P(this,T,L).call(this,{type:"error",error:c}),Pe(c)||((S=(m=r(this,E).config).onError)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,this.state.data,c,this)),this.scheduleGc()};return o(this,q,Je({initialPromise:t==null?void 0:t.initialPromise,fn:h.fetchFn,abort:i.abort.bind(i),onSuccess:c=>{var m,S,C,d;if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(v){a(v);return}(S=(m=r(this,E).config).onSuccess)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,m)=>{P(this,T,L).call(this,{type:"failed",failureCount:c,error:m})},onPause:()=>{P(this,T,L).call(this,{type:"pause"})},onContinue:()=>{P(this,T,L).call(this,{type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay,networkMode:h.options.networkMode,canRun:()=>!0})),r(this,q).start()}},se=new WeakMap,ie=new WeakMap,E=new WeakMap,W=new WeakMap,q=new WeakMap,le=new WeakMap,X=new WeakMap,T=new WeakSet,L=function(e){const t=i=>{switch(e.type){case"failed":return{...i,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...ot(i.data,this.options),fetchMeta:e.meta??null};case"success":return{...i,data:e.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Pe(n)&&n.revert&&r(this,ie)?{...r(this,ie),fetchStatus:"idle"}:{...i,error:n,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...e.state}}};this.state=t(this.state),F.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),r(this,E).notify({query:this,type:"updated",action:e})})},ke);function ot(s,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(e.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}function ct(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=e!==void 0,i=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var k,Ue,lt=(Ue=class extends ge{constructor(e={}){super();f(this,k);this.config=e,o(this,k,new Map)}build(e,t,i){const n=t.queryKey,u=t.queryHash??Ce(n,t);let h=this.get(u);return h||(h=new ht({client:e,queryKey:n,queryHash:u,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(n)}),this.add(h)),h}add(e){r(this,k).has(e.queryHash)||(r(this,k).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=r(this,k).get(e.queryHash);t&&(e.destroy(),t===e&&r(this,k).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){F.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return r(this,k).get(e)}getAll(){return[...r(this,k).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(i=>De(t,i))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(i=>De(e,i)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},k=new WeakMap,Ue),U,O,Y,I,H,Ie,dt=(Ie=class extends Be{constructor(e){super();f(this,I);f(this,U);f(this,O);f(this,Y);this.mutationId=e.mutationId,o(this,O,e.mutationCache),o(this,U,[]),this.state=e.state||ft(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){r(this,U).includes(e)||(r(this,U).push(e),this.clearGcTimeout(),r(this,O).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){o(this,U,r(this,U).filter(t=>t!==e)),this.scheduleGc(),r(this,O).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){r(this,U).length||(this.state.status==="pending"?this.scheduleGc():r(this,O).remove(this))}continue(){var e;return((e=r(this,Y))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var u,h,a,l,y,p,c,m,S,C,d,v,D,Q,w,A,K,j,fe,he;const t=()=>{P(this,I,H).call(this,{type:"continue"})};o(this,Y,Je({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(b,ye)=>{P(this,I,H).call(this,{type:"failed",failureCount:b,error:ye})},onPause:()=>{P(this,I,H).call(this,{type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>r(this,O).canRun(this)}));const i=this.state.status==="pending",n=!r(this,Y).canStart();try{if(i)t();else{P(this,I,H).call(this,{type:"pending",variables:e,isPaused:n}),await((h=(u=r(this,O).config).onMutate)==null?void 0:h.call(u,e,this));const ye=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));ye!==this.state.context&&P(this,I,H).call(this,{type:"pending",context:ye,variables:e,isPaused:n})}const b=await r(this,Y).start();return await((p=(y=r(this,O).config).onSuccess)==null?void 0:p.call(y,b,e,this.state.context,this)),await((m=(c=this.options).onSuccess)==null?void 0:m.call(c,b,e,this.state.context)),await((C=(S=r(this,O).config).onSettled)==null?void 0:C.call(S,b,null,this.state.variables,this.state.context,this)),await((v=(d=this.options).onSettled)==null?void 0:v.call(d,b,null,e,this.state.context)),P(this,I,H).call(this,{type:"success",data:b}),b}catch(b){try{throw await((Q=(D=r(this,O).config).onError)==null?void 0:Q.call(D,b,e,this.state.context,this)),await((A=(w=this.options).onError)==null?void 0:A.call(w,b,e,this.state.context)),await((j=(K=r(this,O).config).onSettled)==null?void 0:j.call(K,void 0,b,this.state.variables,this.state.context,this)),await((he=(fe=this.options).onSettled)==null?void 0:he.call(fe,void 0,b,e,this.state.context)),b}finally{P(this,I,H).call(this,{type:"error",error:b})}}finally{r(this,O).runNext(this)}}},U=new WeakMap,O=new WeakMap,Y=new WeakMap,I=new WeakSet,H=function(e){const t=i=>{switch(e.type){case"failed":return{...i,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...i,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:e.error,failureCount:i.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),F.batch(()=>{r(this,U).forEach(i=>{i.onMutationUpdate(e)}),r(this,O).notify({mutation:this,type:"updated",action:e})})},Ie);function ft(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var x,R,de,Le,yt=(Le=class extends ge{constructor(e={}){super();f(this,x);f(this,R);f(this,de);this.config=e,o(this,x,new Set),o(this,R,new Map),o(this,de,0)}build(e,t,i){const n=new dt({mutationCache:this,mutationId:++pe(this,de)._,options:e.defaultMutationOptions(t),state:i});return this.add(n),n}add(e){r(this,x).add(e);const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);i?i.push(e):r(this,R).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(r(this,x).delete(e)){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);if(i)if(i.length>1){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}else i[0]===e&&r(this,R).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t),n=i==null?void 0:i.find(u=>u.state.status==="pending");return!n||n===e}else return!0}runNext(e){var i;const t=me(e);if(typeof t=="string"){const n=(i=r(this,R).get(t))==null?void 0:i.find(u=>u!==e&&u.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){F.batch(()=>{r(this,x).forEach(e=>{this.notify({type:"removed",mutation:e})}),r(this,x).clear(),r(this,R).clear()})}getAll(){return Array.from(r(this,x))}find(e){const t={exact:!0,...e};return this.getAll().find(i=>Ae(t,i))}findAll(e={}){return this.getAll().filter(t=>Ae(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return F.batch(()=>Promise.all(e.map(t=>t.continue().catch(M))))}},x=new WeakMap,R=new WeakMap,de=new WeakMap,Le);function me(s){var e;return(e=s.options.scope)==null?void 0:e.id}function Me(s){return{onFetch:(e,t)=>{var p,c,m,S,C;const i=e.options,n=(m=(c=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:c.fetchMore)==null?void 0:m.direction,u=((S=e.state.data)==null?void 0:S.pages)||[],h=((C=e.state.data)==null?void 0:C.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const y=async()=>{let d=!1;const v=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},D=Ge(e.options,e.fetchOptions),Q=async(w,A,K)=>{if(d)return Promise.reject();if(A==null&&w.pages.length)return Promise.resolve(w);const j={client:e.client,queryKey:e.queryKey,pageParam:A,direction:K?"backward":"forward",meta:e.options.meta};v(j);const fe=await D(j),{maxPages:he}=e.options,b=K?tt:et;return{pages:b(w.pages,fe,he),pageParams:b(w.pageParams,A,he)}};if(n&&u.length){const w=n==="backward",A=w?pt:Te,K={pages:u,pageParams:h},j=A(i,K);a=await Q(K,j,w)}else{const w=s??u.length;do{const A=l===0?h[0]??i.initialPageParam:Te(i,a);if(l>0&&A==null)break;a=await Q(a,A),l++}while(l<w)}return a};e.options.persister?e.fetchFn=()=>{var d,v;return(v=(d=e.options).persister)==null?void 0:v.call(d,y,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t)}:e.fetchFn=y}}}function Te(s,{pages:e,pageParams:t}){const i=e.length-1;return e.length>0?s.getNextPageParam(e[i],e,t[i],t):void 0}function pt(s,{pages:e,pageParams:t}){var i;return e.length>0?(i=s.getPreviousPageParam)==null?void 0:i.call(s,e[0],e,t[0],t):void 0}var g,V,$,re,ne,J,ae,ue,xe,mt=(xe=class{constructor(s={}){f(this,g);f(this,V);f(this,$);f(this,re);f(this,ne);f(this,J);f(this,ae);f(this,ue);o(this,g,s.queryCache||new lt),o(this,V,s.mutationCache||new yt),o(this,$,s.defaultOptions||{}),o(this,re,new Map),o(this,ne,new Map),o(this,J,0)}mount(){pe(this,J)._++,r(this,J)===1&&(o(this,ae,Ne.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onFocus())})),o(this,ue,ve.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onOnline())})))}unmount(){var s,e;pe(this,J)._--,r(this,J)===0&&((s=r(this,ae))==null||s.call(this),o(this,ae,void 0),(e=r(this,ue))==null||e.call(this),o(this,ue,void 0))}isFetching(s){return r(this,g).findAll({...s,fetchStatus:"fetching"}).length}isMutating(s){return r(this,V).findAll({...s,status:"pending"}).length}getQueryData(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state.data}ensureQueryData(s){const e=this.defaultQueryOptions(s),t=r(this,g).build(this,e),i=t.state.data;return i===void 0?this.fetchQuery(s):(s.revalidateIfStale&&t.isStaleByTime(Se(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(s){return r(this,g).findAll(s).map(({queryKey:e,state:t})=>{const i=t.data;return[e,i]})}setQueryData(s,e,t){const i=this.defaultQueryOptions({queryKey:s}),n=r(this,g).get(i.queryHash),u=n==null?void 0:n.state.data,h=_e(e,u);if(h!==void 0)return r(this,g).build(this,i).setData(h,{...t,manual:!0})}setQueriesData(s,e,t){return F.batch(()=>r(this,g).findAll(s).map(({queryKey:i})=>[i,this.setQueryData(i,e,t)]))}getQueryState(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state}removeQueries(s){const e=r(this,g);F.batch(()=>{e.findAll(s).forEach(t=>{e.remove(t)})})}resetQueries(s,e){const t=r(this,g);return F.batch(()=>(t.findAll(s).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...s},e)))}cancelQueries(s,e={}){const t={revert:!0,...e},i=F.batch(()=>r(this,g).findAll(s).map(n=>n.cancel(t)));return Promise.all(i).then(M).catch(M)}invalidateQueries(s,e={}){return F.batch(()=>(r(this,g).findAll(s).forEach(t=>{t.invalidate()}),(s==null?void 0:s.refetchType)==="none"?Promise.resolve():this.refetchQueries({...s,type:(s==null?void 0:s.refetchType)??(s==null?void 0:s.type)??"active"},e)))}refetchQueries(s,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},i=F.batch(()=>r(this,g).findAll(s).filter(n=>!n.isDisabled()).map(n=>{let u=n.fetch(void 0,t);return t.throwOnError||(u=u.catch(M)),n.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(i).then(M)}fetchQuery(s){const e=this.defaultQueryOptions(s);e.retry===void 0&&(e.retry=!1);const t=r(this,g).build(this,e);return t.isStaleByTime(Se(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(s){return this.fetchQuery(s).then(M).catch(M)}fetchInfiniteQuery(s){return s.behavior=Me(s.pages),this.fetchQuery(s)}prefetchInfiniteQuery(s){return this.fetchInfiniteQuery(s).then(M).catch(M)}ensureInfiniteQueryData(s){return s.behavior=Me(s.pages),this.ensureQueryData(s)}resumePausedMutations(){return ve.isOnline()?r(this,V).resumePausedMutations():Promise.resolve()}getQueryCache(){return r(this,g)}getMutationCache(){return r(this,V)}getDefaultOptions(){return r(this,$)}setDefaultOptions(s){o(this,$,s)}setQueryDefaults(s,e){r(this,re).set(oe(s),{queryKey:s,defaultOptions:e})}getQueryDefaults(s){const e=[...r(this,re).values()],t={};return e.forEach(i=>{ce(s,i.queryKey)&&Object.assign(t,i.defaultOptions)}),t}setMutationDefaults(s,e){r(this,ne).set(oe(s),{mutationKey:s,defaultOptions:e})}getMutationDefaults(s){const e=[...r(this,ne).values()],t={};return e.forEach(i=>{ce(s,i.mutationKey)&&Object.assign(t,i.defaultOptions)}),t}defaultQueryOptions(s){if(s._defaulted)return s;const e={...r(this,$).queries,...this.getQueryDefaults(s.queryKey),...s,_defaulted:!0};return e.queryHash||(e.queryHash=Ce(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Oe&&(e.enabled=!1),e}defaultMutationOptions(s){return s!=null&&s._defaulted?s:{...r(this,$).mutations,...(s==null?void 0:s.mutationKey)&&this.getMutationDefaults(s.mutationKey),...s,_defaulted:!0}}clear(){r(this,g).clear(),r(this,V).clear()}},g=new WeakMap,V=new WeakMap,$=new WeakMap,re=new WeakMap,ne=new WeakMap,J=new WeakMap,ae=new WeakMap,ue=new WeakMap,xe);class B{constructor(e={}){this.availableDatasets=[],this.apiUrl=e.apiUrl||"https://api.luzmo.com",this.apiVersion=e.apiVersion||"0.1.0",this.authKey=e.authKey||"",this.authToken=e.authToken||"",this.queryClient=new mt({defaultOptions:{queries:{staleTime:e.staleTime||5*60*1e3,gcTime:e.gcTime||10*60*1e3,retry:e.retry||3,retryDelay:e.retryDelay||(t=>Math.min(1e3*2**t,3e4))}}}),this.initNetworkListeners()}configure(e={}){if(e.apiVersion&&(this.apiVersion=e.apiVersion),e.apiUrl&&(this.apiUrl=e.apiUrl),e.authKey&&(this.authKey=e.authKey),e.authToken&&(this.authToken=e.authToken),e.staleTime||e.gcTime||e.retry){const t={};e.staleTime&&(t.staleTime=e.staleTime),e.gcTime&&(t.gcTime=e.gcTime),e.retry&&(t.retry=e.retry),this.queryClient.setDefaultOptions({queries:{...this.queryClient.getDefaultOptions().queries,...t}})}}initNetworkListeners(){typeof window<"u"&&window.addEventListener("online",()=>{console.warn("Network connection restored, refreshing data..."),this.refreshAll()})}getHeaders(e={}){return{"Content-Type":"application/json",...e}}async fetchApi(e,t,i={}){const n=`${this.apiUrl}/${this.apiVersion}${e}`,h={method:i.method||"POST",headers:this.getHeaders(i.headers),mode:"cors",...i};t!==void 0&&(t.key=this.authKey,t.token=this.authToken,h.body=JSON.stringify(t));try{const a=await fetch(n,h);if(!a.ok){const l=await a.json().catch(()=>null);throw a.status===401||a.status===403?new Error("Authentication failed. Please check your API token."):a.status===404?new Error(`Resource not found: ${e}`):a.status===429?new Error("Rate limit exceeded. Please try again later."):new Error((l==null?void 0:l.message)||`API request failed with status ${a.status}`)}return await a.json()}catch(a){throw console.error(`API request to ${e} failed:`,a),a instanceof Error&&(a.endpoint=e,a.timestamp=new Date().toISOString()),a}}async fetchAllDatasets(e={}){const t=e.offset||0,i=e.limit||50,n=["datasets",t,i];return await this.queryClient.fetchQuery({queryKey:n,queryFn:async()=>{const u={action:"get",version:this.apiVersion,find:{where:{type:"dataset"},limit:i,offset:t}},h=await this.fetchApi("/securable",u);return{data:(h==null?void 0:h.rows)||[],pagination:{offset:t,limit:i,total:(h==null?void 0:h.count)??0,pages:Math.ceil(((h==null?void 0:h.count)??0)/i)}}}})}async searchDatasets(e,t){if(!e)return[];const i=["datasets","search",e,t];return await this.queryClient.fetchQuery({queryKey:i,queryFn:async()=>{const n={action:"get",version:this.apiVersion,find:{where:{type:"dataset"}}};(e==null?void 0:e.length)>0&&(n.find.search={match_types:["name"],keyphrase:e}),t!=null&&t.offset&&(n.find.offset=t==null?void 0:t.offset),t!=null&&t.limit&&(n.find.limit=t==null?void 0:t.limit);const u=await this.fetchApi("/securable",n),h={data:(u==null?void 0:u.rows)||[]};return t!=null&&t.limit&&(h.pagination={offset:(t==null?void 0:t.offset)??0,limit:t==null?void 0:t.limit,total:(u==null?void 0:u.count)??0,pages:Math.ceil(((u==null?void 0:u.count)??0)/(t==null?void 0:t.limit))}),h}})}async fetchDatasetsWithColumnsAndFormulas(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=["datasets",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:{in:e}},attributes:["name","id"],include:[{model:"Column",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"],separate:!0,order:[["order","asc"]],include:[{model:"Column",attributes:["id","securable_id","hierarchy_enabled","currency_id"],as:"Joins"}]},{model:"Formula",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"]}]}},n=await this.fetchApi("/securable",i);return(n==null?void 0:n.rows)||[]}})}async fetchDataset(e){if(!e)throw new Error("Dataset ID is required");const t=["dataset",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{var u;const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:e},attributes:["name","id"],include:[{model:"Column"},{model:"Formula"}]}},n=await this.fetchApi("/securable",i);return((u=n==null?void 0:n.rows)==null?void 0:u[0])||null}})}async fetchData(e){if(!e)throw new Error("Query is required");const t=["data",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{queries:[e]}},n=await this.fetchApi("/data",i);return{data:(n==null?void 0:n.data)||[],performance:(n==null?void 0:n.performance)||{}}}})}refreshAll(){this.queryClient.refetchQueries()}invalidateDatasetData(e){e?(this.queryClient.invalidateQueries({queryKey:["dataset",e]}),this.queryClient.invalidateQueries({queryKey:["columns",e]})):this.queryClient.invalidateQueries({queryKey:["datasets"]})}invalidateAll(){this.queryClient.clear()}static getInstance(e={}){return B.instance?Object.keys(e).length>0&&B.instance.configure(e):B.instance=new B(e),B.instance}async fetchDatasetsRecursive(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=[...new Set(e)],i=new Set,n=new Map,u=h=>{h&&!i.has(h)&&!t.includes(h)&&t.push(h)};for(;t.length>0;){const h=[];for(;t.length>0&&h.length<50;){const a=t.shift();i.has(a)||h.push(a)}if(h.length!==0)try{(await this.fetchDatasetsWithColumnsAndFormulas(h)).forEach(l=>{const y=this.postProcessDatasetMetadata(l);i.add(y.id),this.queryClient.setQueryData(["dataset",y.id],y),(y.outgoingJoins??[]).map(c=>c.securable_id).filter(c=>c&&c!==y.id).forEach(c=>{u(c)}),n.set(y.id,y),this.availableDatasets.some(c=>c.id===y.id)||this.availableDatasets.push({id:y.id,name:y.name,columns:y.columns})})}catch(a){console.error("Error fetching datasets recursively:",a)}}return[...n.values()]}postProcessDatasetMetadata(e){var t;e.dateLoaded=new Date,e.outgoingJoins=[];for(const i of e.columns)if(((t=i.joins)==null?void 0:t.length)>0)for(const n of i.joins)e.outgoingJoins.push(n);return e}getAvailableDatasets(){return this.availableDatasets}getLinkedDatasetIds(e){const t=this.queryClient.getQueryData(["dataset",e]);return t?(t.outgoingJoins??[]).map(i=>i.securable_id).filter(i=>i&&i!==e):[]}}const vt=B.getInstance();exports.dataBroker=vt;
|
20
|
+
"use strict";var Fe=s=>{throw TypeError(s)};var be=(s,e,t)=>e.has(s)||Fe("Cannot "+t);var r=(s,e,t)=>(be(s,e,"read from private field"),t?t.call(s):e.get(s)),f=(s,e,t)=>e.has(s)?Fe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),o=(s,e,t,i)=>(be(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),P=(s,e,t)=>(be(s,e,"access private method"),t);var pe=(s,e,t,i)=>({set _(n){o(s,e,n,t)},get _(){return r(s,e,i)}});var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(s){return this.listeners.add(s),this.onSubscribe(),()=>{this.listeners.delete(s),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},we=typeof window>"u"||"Deno"in globalThis;function M(){}function _e(s,e){return typeof s=="function"?s(e):s}function ze(s){return typeof s=="number"&&s>=0&&s!==1/0}function We(s,e){return Math.max(s+(e||0)-Date.now(),0)}function Se(s,e){return typeof s=="function"?s(e):s}function Xe(s,e){return typeof s=="function"?s(e):s}function De(s,e){const{type:t="all",exact:i,fetchStatus:n,predicate:u,queryKey:h,stale:a}=s;if(h){if(i){if(e.queryHash!==Ce(h,e.options))return!1}else if(!ce(e.queryKey,h))return!1}if(t!=="all"){const l=e.isActive();if(t==="active"&&!l||t==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||n&&n!==e.state.fetchStatus||u&&!u(e))}function Ae(s,e){const{exact:t,status:i,predicate:n,mutationKey:u}=s;if(u){if(!e.options.mutationKey)return!1;if(t){if(oe(e.options.mutationKey)!==oe(u))return!1}else if(!ce(e.options.mutationKey,u))return!1}return!(i&&e.state.status!==i||n&&!n(e))}function Ce(s,e){return((e==null?void 0:e.queryKeyHashFn)||oe)(s)}function oe(s){return JSON.stringify(s,(e,t)=>qe(t)?Object.keys(t).sort().reduce((i,n)=>(i[n]=t[n],i),{}):t)}function ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?Object.keys(e).every(t=>ce(s[t],e[t])):!1}function He(s,e){if(s===e)return s;const t=Ee(s)&&Ee(e);if(t||qe(s)&&qe(e)){const i=t?s:Object.keys(s),n=i.length,u=t?e:Object.keys(e),h=u.length,a=t?[]:{};let l=0;for(let y=0;y<h;y++){const p=t?y:u[y];(!t&&i.includes(p)||t)&&s[p]===void 0&&e[p]===void 0?(a[p]=void 0,l++):(a[p]=He(s[p],e[p]),a[p]===s[p]&&s[p]!==void 0&&l++)}return n===h&&l===n?s:a}return e}function Ee(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function qe(s){if(!Qe(s))return!1;const e=s.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!Qe(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(s)!==Object.prototype)}function Qe(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ye(s){return new Promise(e=>{setTimeout(e,s)})}function Ze(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?He(s,e):e}function et(s,e,t=0){const i=[...s,e];return t&&i.length>t?i.slice(1):i}function tt(s,e,t=0){const i=[e,...s];return t&&i.length>t?i.slice(0,-1):i}var Oe=Symbol();function Ge(s,e){return!s.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!s.queryFn||s.queryFn===Oe?()=>Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)):s.queryFn}var _,G,Z,Re,st=(Re=class extends ge{constructor(){super();f(this,_);f(this,G);f(this,Z);o(this,Z,e=>{if(!we&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){r(this,G)||this.setEventListener(r(this,Z))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,G))==null||e.call(this),o(this,G,void 0))}setEventListener(e){var t;o(this,Z,e),(t=r(this,G))==null||t.call(this),o(this,G,e(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(e){r(this,_)!==e&&(o(this,_,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return typeof r(this,_)=="boolean"?r(this,_):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},_=new WeakMap,G=new WeakMap,Z=new WeakMap,Re),Ne=new st,ee,N,te,Ke,it=(Ke=class extends ge{constructor(){super();f(this,ee,!0);f(this,N);f(this,te);o(this,te,e=>{if(!we&&window.addEventListener){const t=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,N)||this.setEventListener(r(this,te))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,N))==null||e.call(this),o(this,N,void 0))}setEventListener(e){var t;o(this,te,e),(t=r(this,N))==null||t.call(this),o(this,N,e(this.setOnline.bind(this)))}setOnline(e){r(this,ee)!==e&&(o(this,ee,e),this.listeners.forEach(i=>{i(e)}))}isOnline(){return r(this,ee)}},ee=new WeakMap,N=new WeakMap,te=new WeakMap,Ke),ve=new it;function rt(){let s,e;const t=new Promise((n,u)=>{s=n,e=u});t.status="pending",t.catch(()=>{});function i(n){Object.assign(t,n),delete t.resolve,delete t.reject}return t.resolve=n=>{i({status:"fulfilled",value:n}),s(n)},t.reject=n=>{i({status:"rejected",reason:n}),e(n)},t}function nt(s){return Math.min(1e3*2**s,3e4)}function Ve(s){return(s??"online")==="online"?ve.isOnline():!0}var $e=class extends Error{constructor(s){super("CancelledError"),this.revert=s==null?void 0:s.revert,this.silent=s==null?void 0:s.silent}};function Pe(s){return s instanceof $e}function Je(s){let e=!1,t=0,i=!1,n;const u=rt(),h=d=>{var v;i||(m(new $e(d)),(v=s.abort)==null||v.call(s))},a=()=>{e=!0},l=()=>{e=!1},y=()=>Ne.isFocused()&&(s.networkMode==="always"||ve.isOnline())&&s.canRun(),p=()=>Ve(s.networkMode)&&s.canRun(),c=d=>{var v;i||(i=!0,(v=s.onSuccess)==null||v.call(s,d),n==null||n(),u.resolve(d))},m=d=>{var v;i||(i=!0,(v=s.onError)==null||v.call(s,d),n==null||n(),u.reject(d))},S=()=>new Promise(d=>{var v;n=D=>{(i||y())&&d(D)},(v=s.onPause)==null||v.call(s)}).then(()=>{var d;n=void 0,i||(d=s.onContinue)==null||d.call(s)}),C=()=>{if(i)return;let d;const v=t===0?s.initialPromise:void 0;try{d=v??s.fn()}catch(D){d=Promise.reject(D)}Promise.resolve(d).then(c).catch(D=>{var j;if(i)return;const Q=s.retry??(we?0:3),w=s.retryDelay??nt,A=typeof w=="function"?w(t,D):w,K=Q===!0||typeof Q=="number"&&t<Q||typeof Q=="function"&&Q(t,D);if(e||!K){m(D);return}t++,(j=s.onFail)==null||j.call(s,t,D),Ye(A).then(()=>y()?void 0:S()).then(()=>{e?m(D):C()})})};return{promise:u,cancel:h,continue:()=>(n==null||n(),u),cancelRetry:a,continueRetry:l,canStart:p,start:()=>(p()?C():S().then(C),u)}}var at=s=>setTimeout(s,0);function ut(){let s=[],e=0,t=a=>{a()},i=a=>{a()},n=at;const u=a=>{e?s.push(a):n(()=>{t(a)})},h=()=>{const a=s;s=[],a.length&&n(()=>{i(()=>{a.forEach(l=>{t(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||h()}return l},batchCalls:a=>(...l)=>{u(()=>{a(...l)})},schedule:u,setNotifyFunction:a=>{t=a},setBatchNotifyFunction:a=>{i=a},setScheduler:a=>{n=a}}}var F=ut(),z,je,Be=(je=class{constructor(){f(this,z)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ze(this.gcTime)&&o(this,z,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(s){this.gcTime=Math.max(this.gcTime||0,s??(we?1/0:5*60*1e3))}clearGcTimeout(){r(this,z)&&(clearTimeout(r(this,z)),o(this,z,void 0))}},z=new WeakMap,je),se,ie,E,W,q,le,X,T,L,ke,ht=(ke=class extends Be{constructor(e){super();f(this,T);f(this,se);f(this,ie);f(this,E);f(this,W);f(this,q);f(this,le);f(this,X);o(this,X,!1),o(this,le,e.defaultOptions),this.setOptions(e.options),this.observers=[],o(this,W,e.client),o(this,E,r(this,W).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,o(this,se,ct(this.options)),this.state=e.state??r(this,se),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=r(this,q))==null?void 0:e.promise}setOptions(e){this.options={...r(this,le),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&r(this,E).remove(this)}setData(e,t){const i=Ze(this.state.data,e,this.options);return P(this,T,L).call(this,{data:i,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),i}setState(e,t){P(this,T,L).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var i,n;const t=(i=r(this,q))==null?void 0:i.promise;return(n=r(this,q))==null||n.cancel(e),t?t.then(M).catch(M):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(r(this,se))}isActive(){return this.observers.some(e=>Xe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!We(this.state.dataUpdatedAt,e)}onFocus(){var t;const e=this.observers.find(i=>i.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}onOnline(){var t;const e=this.observers.find(i=>i.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),r(this,E).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(r(this,q)&&(r(this,X)?r(this,q).cancel({revert:!0}):r(this,q).cancelRetry()),this.scheduleGc()),r(this,E).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||P(this,T,L).call(this,{type:"invalidate"})}fetch(e,t){var l,y,p;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(t!=null&&t.cancelRefetch))this.cancel({silent:!0});else if(r(this,q))return r(this,q).continueRetry(),r(this,q).promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(m=>m.options.queryFn);c&&this.setOptions(c.options)}const i=new AbortController,n=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(o(this,X,!0),i.signal)})},u=()=>{const c=Ge(this.options,t),m={client:r(this,W),queryKey:this.queryKey,meta:this.meta};return n(m),o(this,X,!1),this.options.persister?this.options.persister(c,m,this):c(m)},h={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:r(this,W),state:this.state,fetchFn:u};n(h),(l=this.options.behavior)==null||l.onFetch(h,this),o(this,ie,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=h.fetchOptions)==null?void 0:y.meta))&&P(this,T,L).call(this,{type:"fetch",meta:(p=h.fetchOptions)==null?void 0:p.meta});const a=c=>{var m,S,C,d;Pe(c)&&c.silent||P(this,T,L).call(this,{type:"error",error:c}),Pe(c)||((S=(m=r(this,E).config).onError)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,this.state.data,c,this)),this.scheduleGc()};return o(this,q,Je({initialPromise:t==null?void 0:t.initialPromise,fn:h.fetchFn,abort:i.abort.bind(i),onSuccess:c=>{var m,S,C,d;if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(v){a(v);return}(S=(m=r(this,E).config).onSuccess)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,m)=>{P(this,T,L).call(this,{type:"failed",failureCount:c,error:m})},onPause:()=>{P(this,T,L).call(this,{type:"pause"})},onContinue:()=>{P(this,T,L).call(this,{type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay,networkMode:h.options.networkMode,canRun:()=>!0})),r(this,q).start()}},se=new WeakMap,ie=new WeakMap,E=new WeakMap,W=new WeakMap,q=new WeakMap,le=new WeakMap,X=new WeakMap,T=new WeakSet,L=function(e){const t=i=>{switch(e.type){case"failed":return{...i,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...ot(i.data,this.options),fetchMeta:e.meta??null};case"success":return{...i,data:e.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Pe(n)&&n.revert&&r(this,ie)?{...r(this,ie),fetchStatus:"idle"}:{...i,error:n,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...e.state}}};this.state=t(this.state),F.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),r(this,E).notify({query:this,type:"updated",action:e})})},ke);function ot(s,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(e.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}function ct(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=e!==void 0,i=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var k,Ue,lt=(Ue=class extends ge{constructor(e={}){super();f(this,k);this.config=e,o(this,k,new Map)}build(e,t,i){const n=t.queryKey,u=t.queryHash??Ce(n,t);let h=this.get(u);return h||(h=new ht({client:e,queryKey:n,queryHash:u,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(n)}),this.add(h)),h}add(e){r(this,k).has(e.queryHash)||(r(this,k).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=r(this,k).get(e.queryHash);t&&(e.destroy(),t===e&&r(this,k).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){F.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return r(this,k).get(e)}getAll(){return[...r(this,k).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(i=>De(t,i))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(i=>De(e,i)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},k=new WeakMap,Ue),U,O,Y,I,H,Ie,dt=(Ie=class extends Be{constructor(e){super();f(this,I);f(this,U);f(this,O);f(this,Y);this.mutationId=e.mutationId,o(this,O,e.mutationCache),o(this,U,[]),this.state=e.state||ft(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){r(this,U).includes(e)||(r(this,U).push(e),this.clearGcTimeout(),r(this,O).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){o(this,U,r(this,U).filter(t=>t!==e)),this.scheduleGc(),r(this,O).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){r(this,U).length||(this.state.status==="pending"?this.scheduleGc():r(this,O).remove(this))}continue(){var e;return((e=r(this,Y))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var u,h,a,l,y,p,c,m,S,C,d,v,D,Q,w,A,K,j,fe,he;const t=()=>{P(this,I,H).call(this,{type:"continue"})};o(this,Y,Je({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(b,ye)=>{P(this,I,H).call(this,{type:"failed",failureCount:b,error:ye})},onPause:()=>{P(this,I,H).call(this,{type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>r(this,O).canRun(this)}));const i=this.state.status==="pending",n=!r(this,Y).canStart();try{if(i)t();else{P(this,I,H).call(this,{type:"pending",variables:e,isPaused:n}),await((h=(u=r(this,O).config).onMutate)==null?void 0:h.call(u,e,this));const ye=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));ye!==this.state.context&&P(this,I,H).call(this,{type:"pending",context:ye,variables:e,isPaused:n})}const b=await r(this,Y).start();return await((p=(y=r(this,O).config).onSuccess)==null?void 0:p.call(y,b,e,this.state.context,this)),await((m=(c=this.options).onSuccess)==null?void 0:m.call(c,b,e,this.state.context)),await((C=(S=r(this,O).config).onSettled)==null?void 0:C.call(S,b,null,this.state.variables,this.state.context,this)),await((v=(d=this.options).onSettled)==null?void 0:v.call(d,b,null,e,this.state.context)),P(this,I,H).call(this,{type:"success",data:b}),b}catch(b){try{throw await((Q=(D=r(this,O).config).onError)==null?void 0:Q.call(D,b,e,this.state.context,this)),await((A=(w=this.options).onError)==null?void 0:A.call(w,b,e,this.state.context)),await((j=(K=r(this,O).config).onSettled)==null?void 0:j.call(K,void 0,b,this.state.variables,this.state.context,this)),await((he=(fe=this.options).onSettled)==null?void 0:he.call(fe,void 0,b,e,this.state.context)),b}finally{P(this,I,H).call(this,{type:"error",error:b})}}finally{r(this,O).runNext(this)}}},U=new WeakMap,O=new WeakMap,Y=new WeakMap,I=new WeakSet,H=function(e){const t=i=>{switch(e.type){case"failed":return{...i,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...i,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:e.error,failureCount:i.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),F.batch(()=>{r(this,U).forEach(i=>{i.onMutationUpdate(e)}),r(this,O).notify({mutation:this,type:"updated",action:e})})},Ie);function ft(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var x,R,de,Le,yt=(Le=class extends ge{constructor(e={}){super();f(this,x);f(this,R);f(this,de);this.config=e,o(this,x,new Set),o(this,R,new Map),o(this,de,0)}build(e,t,i){const n=new dt({mutationCache:this,mutationId:++pe(this,de)._,options:e.defaultMutationOptions(t),state:i});return this.add(n),n}add(e){r(this,x).add(e);const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);i?i.push(e):r(this,R).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(r(this,x).delete(e)){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);if(i)if(i.length>1){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}else i[0]===e&&r(this,R).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t),n=i==null?void 0:i.find(u=>u.state.status==="pending");return!n||n===e}else return!0}runNext(e){var i;const t=me(e);if(typeof t=="string"){const n=(i=r(this,R).get(t))==null?void 0:i.find(u=>u!==e&&u.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){F.batch(()=>{r(this,x).forEach(e=>{this.notify({type:"removed",mutation:e})}),r(this,x).clear(),r(this,R).clear()})}getAll(){return Array.from(r(this,x))}find(e){const t={exact:!0,...e};return this.getAll().find(i=>Ae(t,i))}findAll(e={}){return this.getAll().filter(t=>Ae(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return F.batch(()=>Promise.all(e.map(t=>t.continue().catch(M))))}},x=new WeakMap,R=new WeakMap,de=new WeakMap,Le);function me(s){var e;return(e=s.options.scope)==null?void 0:e.id}function Me(s){return{onFetch:(e,t)=>{var p,c,m,S,C;const i=e.options,n=(m=(c=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:c.fetchMore)==null?void 0:m.direction,u=((S=e.state.data)==null?void 0:S.pages)||[],h=((C=e.state.data)==null?void 0:C.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const y=async()=>{let d=!1;const v=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},D=Ge(e.options,e.fetchOptions),Q=async(w,A,K)=>{if(d)return Promise.reject();if(A==null&&w.pages.length)return Promise.resolve(w);const j={client:e.client,queryKey:e.queryKey,pageParam:A,direction:K?"backward":"forward",meta:e.options.meta};v(j);const fe=await D(j),{maxPages:he}=e.options,b=K?tt:et;return{pages:b(w.pages,fe,he),pageParams:b(w.pageParams,A,he)}};if(n&&u.length){const w=n==="backward",A=w?pt:Te,K={pages:u,pageParams:h},j=A(i,K);a=await Q(K,j,w)}else{const w=s??u.length;do{const A=l===0?h[0]??i.initialPageParam:Te(i,a);if(l>0&&A==null)break;a=await Q(a,A),l++}while(l<w)}return a};e.options.persister?e.fetchFn=()=>{var d,v;return(v=(d=e.options).persister)==null?void 0:v.call(d,y,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t)}:e.fetchFn=y}}}function Te(s,{pages:e,pageParams:t}){const i=e.length-1;return e.length>0?s.getNextPageParam(e[i],e,t[i],t):void 0}function pt(s,{pages:e,pageParams:t}){var i;return e.length>0?(i=s.getPreviousPageParam)==null?void 0:i.call(s,e[0],e,t[0],t):void 0}var g,V,$,re,ne,J,ae,ue,xe,mt=(xe=class{constructor(s={}){f(this,g);f(this,V);f(this,$);f(this,re);f(this,ne);f(this,J);f(this,ae);f(this,ue);o(this,g,s.queryCache||new lt),o(this,V,s.mutationCache||new yt),o(this,$,s.defaultOptions||{}),o(this,re,new Map),o(this,ne,new Map),o(this,J,0)}mount(){pe(this,J)._++,r(this,J)===1&&(o(this,ae,Ne.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onFocus())})),o(this,ue,ve.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onOnline())})))}unmount(){var s,e;pe(this,J)._--,r(this,J)===0&&((s=r(this,ae))==null||s.call(this),o(this,ae,void 0),(e=r(this,ue))==null||e.call(this),o(this,ue,void 0))}isFetching(s){return r(this,g).findAll({...s,fetchStatus:"fetching"}).length}isMutating(s){return r(this,V).findAll({...s,status:"pending"}).length}getQueryData(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state.data}ensureQueryData(s){const e=this.defaultQueryOptions(s),t=r(this,g).build(this,e),i=t.state.data;return i===void 0?this.fetchQuery(s):(s.revalidateIfStale&&t.isStaleByTime(Se(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(s){return r(this,g).findAll(s).map(({queryKey:e,state:t})=>{const i=t.data;return[e,i]})}setQueryData(s,e,t){const i=this.defaultQueryOptions({queryKey:s}),n=r(this,g).get(i.queryHash),u=n==null?void 0:n.state.data,h=_e(e,u);if(h!==void 0)return r(this,g).build(this,i).setData(h,{...t,manual:!0})}setQueriesData(s,e,t){return F.batch(()=>r(this,g).findAll(s).map(({queryKey:i})=>[i,this.setQueryData(i,e,t)]))}getQueryState(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state}removeQueries(s){const e=r(this,g);F.batch(()=>{e.findAll(s).forEach(t=>{e.remove(t)})})}resetQueries(s,e){const t=r(this,g);return F.batch(()=>(t.findAll(s).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...s},e)))}cancelQueries(s,e={}){const t={revert:!0,...e},i=F.batch(()=>r(this,g).findAll(s).map(n=>n.cancel(t)));return Promise.all(i).then(M).catch(M)}invalidateQueries(s,e={}){return F.batch(()=>(r(this,g).findAll(s).forEach(t=>{t.invalidate()}),(s==null?void 0:s.refetchType)==="none"?Promise.resolve():this.refetchQueries({...s,type:(s==null?void 0:s.refetchType)??(s==null?void 0:s.type)??"active"},e)))}refetchQueries(s,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},i=F.batch(()=>r(this,g).findAll(s).filter(n=>!n.isDisabled()).map(n=>{let u=n.fetch(void 0,t);return t.throwOnError||(u=u.catch(M)),n.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(i).then(M)}fetchQuery(s){const e=this.defaultQueryOptions(s);e.retry===void 0&&(e.retry=!1);const t=r(this,g).build(this,e);return t.isStaleByTime(Se(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(s){return this.fetchQuery(s).then(M).catch(M)}fetchInfiniteQuery(s){return s.behavior=Me(s.pages),this.fetchQuery(s)}prefetchInfiniteQuery(s){return this.fetchInfiniteQuery(s).then(M).catch(M)}ensureInfiniteQueryData(s){return s.behavior=Me(s.pages),this.ensureQueryData(s)}resumePausedMutations(){return ve.isOnline()?r(this,V).resumePausedMutations():Promise.resolve()}getQueryCache(){return r(this,g)}getMutationCache(){return r(this,V)}getDefaultOptions(){return r(this,$)}setDefaultOptions(s){o(this,$,s)}setQueryDefaults(s,e){r(this,re).set(oe(s),{queryKey:s,defaultOptions:e})}getQueryDefaults(s){const e=[...r(this,re).values()],t={};return e.forEach(i=>{ce(s,i.queryKey)&&Object.assign(t,i.defaultOptions)}),t}setMutationDefaults(s,e){r(this,ne).set(oe(s),{mutationKey:s,defaultOptions:e})}getMutationDefaults(s){const e=[...r(this,ne).values()],t={};return e.forEach(i=>{ce(s,i.mutationKey)&&Object.assign(t,i.defaultOptions)}),t}defaultQueryOptions(s){if(s._defaulted)return s;const e={...r(this,$).queries,...this.getQueryDefaults(s.queryKey),...s,_defaulted:!0};return e.queryHash||(e.queryHash=Ce(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Oe&&(e.enabled=!1),e}defaultMutationOptions(s){return s!=null&&s._defaulted?s:{...r(this,$).mutations,...(s==null?void 0:s.mutationKey)&&this.getMutationDefaults(s.mutationKey),...s,_defaulted:!0}}clear(){r(this,g).clear(),r(this,V).clear()}},g=new WeakMap,V=new WeakMap,$=new WeakMap,re=new WeakMap,ne=new WeakMap,J=new WeakMap,ae=new WeakMap,ue=new WeakMap,xe);class B{constructor(e={}){this.availableDatasets=[],this.apiUrl=e.apiUrl||"https://api.luzmo.com",this.apiVersion=e.apiVersion||"0.1.0",this.authKey=e.authKey||"",this.authToken=e.authToken||"",this.queryClient=new mt({defaultOptions:{queries:{staleTime:e.staleTime||5*60*1e3,gcTime:e.gcTime||10*60*1e3,retry:e.retry||3,retryDelay:e.retryDelay||(t=>Math.min(1e3*2**t,3e4))}}}),this.initNetworkListeners()}configure(e={}){if(e.apiVersion&&(this.apiVersion=e.apiVersion),e.apiUrl&&(this.apiUrl=e.apiUrl),e.authKey&&(this.authKey=e.authKey),e.authToken&&(this.authToken=e.authToken),e.staleTime||e.gcTime||e.retry){const t={};e.staleTime&&(t.staleTime=e.staleTime),e.gcTime&&(t.gcTime=e.gcTime),e.retry&&(t.retry=e.retry),this.queryClient.setDefaultOptions({queries:{...this.queryClient.getDefaultOptions().queries,...t}})}}initNetworkListeners(){typeof window<"u"&&window.addEventListener("online",()=>{console.warn("Network connection restored, refreshing data..."),this.refreshAll()})}getHeaders(e={}){return{"Content-Type":"application/json",...e}}async fetchApi(e,t,i={}){const n=`${this.apiUrl}/${this.apiVersion}${e}`,h={method:i.method||"POST",headers:this.getHeaders(i.headers),mode:"cors",...i};t!==void 0&&(t.key=this.authKey,t.token=this.authToken,h.body=JSON.stringify(t));try{const a=await fetch(n,h);if(!a.ok){const l=await a.json().catch(()=>null);throw a.status===401||a.status===403?new Error("Authentication failed. Please check your API token."):a.status===404?new Error(`Resource not found: ${e}`):a.status===429?new Error("Rate limit exceeded. Please try again later."):new Error((l==null?void 0:l.message)||`API request failed with status ${a.status}`)}return await a.json()}catch(a){throw console.error(`API request to ${e} failed:`,a),a instanceof Error&&(a.endpoint=e,a.timestamp=new Date().toISOString()),a}}async fetchAllDatasets(e={}){const t=e.offset||0,i=e.limit||50,n=["datasets",t,i];return await this.queryClient.fetchQuery({queryKey:n,queryFn:async()=>{const u={action:"get",version:this.apiVersion,find:{where:{type:"dataset"},limit:i,offset:t}},h=await this.fetchApi("/securable",u);return{data:(h==null?void 0:h.rows)||[],pagination:{offset:t,limit:i,total:(h==null?void 0:h.count)??0,pages:Math.ceil(((h==null?void 0:h.count)??0)/i)}}}})}async searchDatasets(e,t){if(!e)return[];const i=["datasets","search",e,t];return await this.queryClient.fetchQuery({queryKey:i,queryFn:async()=>{const n={action:"get",version:this.apiVersion,find:{where:{type:"dataset"}}};(e==null?void 0:e.length)>0&&(n.find.search={match_types:["name"],keyphrase:e}),t!=null&&t.offset&&(n.find.offset=t==null?void 0:t.offset),t!=null&&t.limit&&(n.find.limit=t==null?void 0:t.limit);const u=await this.fetchApi("/securable",n),h={data:(u==null?void 0:u.rows)||[]};return t!=null&&t.limit&&(h.pagination={offset:(t==null?void 0:t.offset)??0,limit:t==null?void 0:t.limit,total:(u==null?void 0:u.count)??0,pages:Math.ceil(((u==null?void 0:u.count)??0)/(t==null?void 0:t.limit))}),h}})}async fetchDatasetsWithColumnsAndFormulas(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=["datasets",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:{in:e}},attributes:["name","id"],include:[{model:"Column",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"],separate:!0,order:[["order","asc"]],include:[{model:"Column",attributes:["id","securable_id","hierarchy_enabled","currency_id"],as:"Joins"}]},{model:"Formula",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"]}]}},n=await this.fetchApi("/securable",i);return(n==null?void 0:n.rows)||[]}})}async fetchDataset(e){if(!e)throw new Error("Dataset ID is required");const t=["dataset",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{var u;const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:e},attributes:["name","id"],include:[{model:"Column"},{model:"Formula"}]}},n=await this.fetchApi("/securable",i);return((u=n==null?void 0:n.rows)==null?void 0:u[0])||null}})}async fetchData(e){if(!e)throw new Error("Query is required");const t=["data",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{queries:[e]}},n=await this.fetchApi("/data",i);return{data:(n==null?void 0:n.data)||[],performance:(n==null?void 0:n.performance)||{}}}})}refreshAll(){this.queryClient.refetchQueries()}invalidateDatasetData(e){e?(this.queryClient.invalidateQueries({queryKey:["dataset",e]}),this.queryClient.invalidateQueries({queryKey:["columns",e]})):this.queryClient.invalidateQueries({queryKey:["datasets"]})}invalidateAll(){this.queryClient.clear()}static getInstance(e={}){return B.instance?Object.keys(e).length>0&&B.instance.configure(e):B.instance=new B(e),B.instance}async fetchDatasetsRecursive(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=[...new Set(e)],i=new Set,n=new Map,u=h=>{h&&!i.has(h)&&!t.includes(h)&&t.push(h)};for(;t.length>0;){const h=[];for(;t.length>0&&h.length<50;){const a=t.shift();i.has(a)||h.push(a)}if(h.length!==0)try{(await this.fetchDatasetsWithColumnsAndFormulas(h)).forEach(l=>{const y=this.postProcessDatasetMetadata(l);i.add(y.id),this.queryClient.setQueryData(["dataset",y.id],y),(y.outgoingJoins??[]).map(c=>c.securable_id).filter(c=>c&&c!==y.id).forEach(c=>{u(c)}),n.set(y.id,y),this.availableDatasets.some(c=>c.id===y.id)||this.availableDatasets.push({id:y.id,name:y.name,columns:y.columns})})}catch(a){console.error("Error fetching datasets recursively:",a)}}return[...n.values()]}postProcessDatasetMetadata(e){var t;e.dateLoaded=new Date,e.outgoingJoins=[];for(const i of e.columns)if(((t=i.joins)==null?void 0:t.length)>0)for(const n of i.joins)e.outgoingJoins.push(n);return e}getAvailableDatasets(){return this.availableDatasets}getLinkedDatasetsIds(e){const t=this.queryClient.getQueryData(["dataset",e]);return t?(t.outgoingJoins??[]).map(i=>i.securable_id).filter(i=>i&&i!==e):[]}}const vt=B.getInstance();exports.dataBroker=vt;
|
@@ -17,45 +17,45 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-DtohCwyO.cjs");const
|
20
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-DtohCwyO.cjs");const n=require("../property-Cu4Q1hS4.cjs"),S=require("../index-DAoFunRy.cjs"),z=require("../luzmo-icons-DonyjSXg.cjs"),w=require("../index-DpHum3lw.cjs"),O=require("../localize-r7ALOUy_.cjs"),E=require("../state-fyl3IYMu.cjs"),M=require("../query-D5qWDopr.cjs"),T=require("../directive-BOOaQO_r.cjs"),U=require("../focusable-DAGGGYyz.cjs"),q=require("../sized-mixin-j_7aJM4b.cjs");require("../slot-menu-list/index.cjs");/**
|
21
21
|
* @license
|
22
22
|
* Copyright 2018 Google LLC
|
23
23
|
* SPDX-License-Identifier: BSD-3-Clause
|
24
|
-
*/const Y={},R=T.e(class extends T.i{constructor(){super(...arguments),this.ot=Y}render(u,t){return t()}update(u,[t,e]){if(Array.isArray(t)){if(Array.isArray(this.ot)&&this.ot.length===t.length&&t.every((r,l)=>r===this.ot[l]))return o.T}else if(this.ot===t)return o.T;return this.ot=Array.isArray(t)?Array.from(t):t,this.render(t,e)}});function N({element:u,handle:t,boundary:e=document.documentElement,onDragStart:r,onDragEnd:l}){if(!u||!t)throw new Error("makeDraggable: element and handle are required");const a=u.ownerDocument??document;let i=-1,b=0,y=0,m=0,p=0,z=0,L=0,C=0,_=0;const x=d=>{if(d.pointerId!==i)return;const h=d.clientX-b,f=d.clientY-y,c=(e??document.documentElement).getBoundingClientRect();let v=m+h,S=p+f;v=Math.min(Math.max(v,c.left),c.right-z),S=Math.min(Math.max(S,c.top),c.bottom-L);const A=v-m,O=S-p,P=C+A,B=_+O;u.style.transform=`translate3d(${P}px, ${B}px, 0)`},k=d=>{d.pointerId===i&&(a.removeEventListener("pointermove",x),a.removeEventListener("pointerup",k),i=-1,l==null||l())},$=d=>{var f;if(d.button!==0)return;i=d.pointerId;const h=u.getBoundingClientRect();m=h.left,p=h.top,z=h.width,L=h.height,b=d.clientX,y=d.clientY;try{const c=(f=a.defaultView)==null?void 0:f.getComputedStyle(u);if(c){const v=new DOMMatrixReadOnly(c.transform);C=v.m41,_=v.m42}}catch{C=0,_=0}t.setPointerCapture(i),a.addEventListener("pointermove",x),a.addEventListener("pointerup",k),r==null||r()};return t.addEventListener("pointerdown",$),()=>{t.removeEventListener("pointerdown",$),a.removeEventListener("pointermove",x),a.removeEventListener("pointerup",k)}}const X=":host{font-family:var(--luzmo-slot-menu-font-family, var(--luzmo-font-family));font-size:var(--luzmo-slot-menu-font-size, var(--slot-menu-font-size));color:var(--luzmo-slot-menu-font-color, var(--luzmo-font-color));display:block;width:fit-content}luzmo-slot-menu-list{min-width:var(--luzmo-slot-menu-list-min-width, var(--slot-menu-list-min-width));max-width:var(--luzmo-slot-menu-list-max-width, var(--slot-menu-list-max-width))}.slot-contents-container{position:relative;border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-border-color, var(--luzmo-border-color));border-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));background:var(--luzmo-slot-menu-background-color, var(--luzmo-background-color));box-shadow:var(--luzmo-slot-menu-popup-shadow-horizontal, var(--slot-menu-popup-shadow-horizontal)) var(--luzmo-slot-menu-popup-shadow-vertical, var(--slot-menu-popup-shadow-vertical)) var(--luzmo-slot-menu-popup-shadow-blur, var(--slot-menu-popup-shadow-blur)) var(--luzmo-slot-menu-popup-shadow-color, var(--slot-menu-popup-shadow-color));border-top-left-radius:0}.slot-contents-container .inner-container{display:flex}.slot-contents-container .inner-container luzmo-display-settings{min-width:var(--luzmo-slot-menu-display-settings-min-width, var(--slot-menu-display-settings-min-width));padding:var(--luzmo-slot-menu-display-settings-vertical-padding, var(--slot-menu-display-settings-vertical-padding)) var(--luzmo-slot-menu-display-settings-horizontal-padding, var(--slot-menu-display-settings-horizontal-padding))}:host([variant=popup]) .slot-contents-container{overflow:hidden;border-top-left-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));--slot-menu-popup-filter: drop-shadow( var( --luzmo-slot-menu-popup-shadow-horizontal, var(--slot-menu-popup-shadow-horizontal) ) var( --luzmo-slot-menu-popup-shadow-vertical, var(--slot-menu-popup-shadow-vertical) ) var( --luzmo-slot-menu-popup-shadow-blur, var(--slot-menu-popup-shadow-blur) ) var( --luzmo-slot-menu-popup-shadow-color, var(--slot-menu-popup-shadow-color) ) );filter:var(--luzmo-slot-menu-popup-filter, var(--slot-menu-popup-filter))}.slot-menu-top-menu{display:flex;align-items:center;border-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));border-bottom-left-radius:0;border-bottom-right-radius:0;overflow:hidden;width:fit-content}.drag-handle{background-color:var(--luzmo-slot-menu-drag-handle-background-color, var(--luzmo-background-color-highlight));cursor:grab;width:fit-content;border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-border-color, var(--luzmo-background-color-highlight));font-size:var(--luzmo-slot-menu-drag-handle-size, var(--slot-menu-drag-handle-size));padding:var(--luzmo-slot-menu-drag-handle-vertical-padding, var(--slot-menu-drag-handle-vertical-padding)) var(--luzmo-slot-menu-drag-handle-horizontal-padding, var(--slot-menu-drag-handle-horizontal-padding))}.drag-handle:hover{background-color:var(--luzmo-slot-menu-drag-handle-background-color-hover, var(--luzmo-background-color-highlight-hover))}.slot-content-action{display:flex;flex:0 1 auto;max-width:var(--luzmo-slot-menu-top-menu-label-max-width, var(--slot-menu-top-menu-label-max-width));gap:var(--luzmo-slot-menu-label-to-icon-gap, var(--slot-menu-label-to-icon-gap));background-color:var(--luzmo-slot-menu-content-label-background-color, var(--luzmo-primary));color:var(--luzmo-slot-menu-content-label-color, var(--luzmo-primary-inverse-color));border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-content-label-border-color, var(--luzmo-primary));padding:var(--luzmo-slot-menu-drag-handle-vertical-padding, var(--slot-menu-drag-handle-vertical-padding)) var(--luzmo-slot-menu-drag-handle-horizontal-padding, var(--slot-menu-drag-handle-horizontal-padding))}.slot-content-action:hover{background-color:var(--luzmo-slot-menu-content-label-background-color-hover, var(--luzmo-primary-hover))}.slot-content-action:focus{background-color:var(--luzmo-slot-menu-content-label-background-color-focus, var(--luzmo-primary-focus))}.slot-content-action .slot-content-label{flex:1 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.slot-content-action .slot-content-remove{flex:0 0 auto;cursor:pointer}.close{position:absolute;right:1rem;cursor:pointer;top:calc(-2 * var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)));background-color:var(--luzmo-slot-menu-close-button-background-color, var(--luzmo-background-color-highlight));font-size:var(--luzmo-slot-menu-close-button-size, var(--slot-menu-close-button-size));border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-border-color, var(--luzmo-border-color));border-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));border-top-left-radius:0;border-top-right-radius:0;padding:var(--luzmo-slot-menu-close-button-vertical-padding, var(--slot-menu-close-button-vertical-padding)) var(--luzmo-slot-menu-close-button-horizontal-padding, var(--slot-menu-close-button-horizontal-padding))}.close:hover{background-color:var(--luzmo-slot-menu-close-button-background-color-hover, var(--luzmo-background-color-highlight-hover))}:host{--slot-menu-display-settings-min-width: 19rem;--slot-menu-min-height: calc(var(--luzmo-component-height) * 2);--slot-menu-font-size: var(--luzmo-font-size);--slot-menu-display-settings-horizontal-padding: var(--luzmo-spacing-5);--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-4);--slot-menu-top-menu-label-max-width: 12rem;--slot-menu-list-min-width: 8rem;--slot-menu-list-max-width: 12rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-3);--slot-menu-drag-handle-size: var(--luzmo-font-size);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-2);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-3);--slot-menu-close-button-size: var(--luzmo-font-size-s);--slot-menu-close-button-vertical-padding: var(--luzmo-spacing-2);--slot-menu-close-button-horizontal-padding: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--slot-menu-popup-shadow-horizontal: 0;--slot-menu-popup-shadow-vertical: 1px;--slot-menu-popup-shadow-blur: 4px;--slot-menu-popup-shadow-color: var(--luzmo-border-color);--slot-menu-popup-box-shadow: var(--slot-menu-popup-shadow-horizontal) var(--slot-menu-popup-shadow-vertical) var(--slot-menu-popup-shadow-blur) var(--slot-menu-popup-shadow-color)}:host([size=s]){--slot-menu-display-settings-min-width: 16rem;--slot-menu-min-height: calc(var(--luzmo-component-height-s) * 2);--slot-menu-font-size: var(--luzmo-font-size-s);--slot-menu-display-settings-horizontal-padding: var(--luzmo-spacing-4);--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-3);--slot-menu-top-menu-label-max-width: 10rem;--slot-menu-list-min-width: 6rem;--slot-menu-list-max-width: 10rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-2);--slot-menu-drag-handle-size: var(--luzmo-font-size-s);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-2);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-3);--slot-menu-close-button-size: var(--luzmo-font-size-xs);--slot-menu-close-button-vertical-padding: var(--luzmo-spacing-2);--slot-menu-close-button-horizontal-padding: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) )}:host([size=l]){--slot-menu-display-settings-min-width: 23rem;--slot-menu-min-height: calc(var(--luzmo-component-height-l) * 2);--slot-menu-font-size: var(--luzmo-font-size-l);--slot-menu-display-settings-horizontal-padding: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-1) );--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-5);--slot-menu-top-menu-label-max-width: 14rem;--slot-menu-list-min-width: 9rem;--slot-menu-list-max-width: 14rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-4);--slot-menu-drag-handle-size: var(--luzmo-font-size-l);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-3);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-3);--slot-menu-close-button-size: var(--luzmo-font-size);--slot-menu-close-button-vertical-padding: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--slot-menu-close-button-horizontal-padding: var(--luzmo-spacing-3)}:host([size=xl]){--slot-menu-display-settings-min-width: 26rem;--slot-menu-min-height: calc(var(--luzmo-component-height-xl) * 2);--slot-menu-font-size: var(--luzmo-font-size-xl);--slot-menu-display-settings-horizontal-padding: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-2) );--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-5);--slot-menu-top-menu-label-max-width: 16rem;--slot-menu-list-min-width: 10rem;--slot-menu-list-max-width: 16rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-5);--slot-menu-drag-handle-size: var(--luzmo-font-size-xl);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-3);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-4);--slot-menu-close-button-size: var(--luzmo-font-size-l);--slot-menu-close-button-vertical-padding: var(--luzmo-spacing-3);--slot-menu-close-button-horizontal-padding: var(--luzmo-spacing-3)}";var G=Object.defineProperty,s=(u,t,e,r)=>{for(var l=void 0,a=u.length-1,i;a>=0;a--)(i=u[a])&&(l=i(t,e,l)||l);return l&&G(t,e,l),l};class n extends E.e(M.SizedMixin(U.LuzmoElement,{validSizes:Object.values(M.ElementSizes)})){constructor(){super(...arguments),this.language="en",this.contentLanguage="en",this.slotType="numeric",this.variant="draggable",this._periodOverPeriodEnabled=!1,this.measureColumns=[],this.apiUrl="https://api.luzmo.com",this.authKey="1a6069eb-9a30-424c-ad69-e0aa9e6bb8b6",this.authToken="AGAjEOVhJPyemwt5QNx1rI6nxuOH9pwdtyeg0aGSKuWenPR8GYmC3g2yKiCIjuD8POQOrEMGLYNnZdYRHZFAMi7QOfGd6gpSgZEbLXyhW9ucYG0U9Mc0uUksxIelkVH5yUESO3c6bVCV7FMVNIo7GW",this._slotContents=[],this._activeIndex=this.slotIndex??0,this._linkedDatasetIds=[]}static get styles(){return[o.r(X)]}get _currentSlotContent(){return this._slotContents[this.slotIndex??this._activeIndex]??{}}get _currentLabel(){return D.localize(this._currentSlotContent.label,this.contentLanguage)??"Untitled"}connectedCallback(){const t={};this.apiUrl&&(t.apiUrl=this.apiUrl),this.authKey&&this.authToken&&(t.authKey=this.authKey,t.authToken=this.authToken),w.dataBroker.configure(t),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupDrag&&(this._cleanupDrag(),this._cleanupDrag=void 0)}_sendChangeEvent(){this.dispatchEvent(new CustomEvent("slot-contents-changed",{bubbles:!0,composed:!0,cancelable:!0,detail:{slotContents:[...this._slotContents],linkedDatasetIds:[...this._linkedDatasetIds]}}))}_sendCloseEvent(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,cancelable:!0}))}isArrayColumnType(t){return new Set(["array[numeric]","array[spatial]","array[datetime]","array[hierarchy]"]).has(t)}async willUpdate(){var e,r,l,a;const t=this.slotContents??((e=this._store)==null?void 0:e.slotContents.get())??[];if(t!==this._slotContents){this._slotContents=structuredClone(t);const{set:i,column:b}=this._currentSlotContent;i&&i!==this._lastFetchedDatasetId&&(this._lastFetchedDatasetId=i,await w.dataBroker.fetchDatasetsRecursive([i]),this._linkedDatasetIds=w.dataBroker.getLinkedDatasetIds(i));const y=w.dataBroker.getAvailableDatasets();this.measureColumns=y.map(m=>{var p;return{datasetId:m.id,datasetName:m.name,columns:(p=m.columns)==null?void 0:p.filter(z=>z.type==="numeric"&&z.id!==b)}}),((r=this._store)==null?void 0:r.activeIndex.get())!==this._activeIndex&&((l=this._store)==null||l.updateActive(this._activeIndex)),this.slotName==="measure"&&(this._periodOverPeriodEnabled=((a=this._store)==null?void 0:a.periodOverPeriodEnabled.get())&&this._currentSlotContent.subtype!=="duration"&&!this.isArrayColumnType(this._currentSlotContent.type))}}updated(){var t;this.displaySettingsElement&&(this.displaySettingsElement.periodOverPeriod=this._periodOverPeriodEnabled,this.displaySettingsElement.measureColumns=this.measureColumns,this.displaySettingsElement.showRemoveButton=this.variant==="popup"&&(typeof this.slotIndex=="number"||((t=this._slotContents)==null?void 0:t.length)===1))}_handleSlotListChange(t){var r,l;this._slotContents=structuredClone(t.detail.slotContents);const e=t.detail.activeIndex;e!==this._activeIndex&&(this._activeIndex=e,(r=this._store)==null||r.updateActive(e)),this._slotContents.length<=1&&this.requestUpdate(),(l=this._store)==null||l.setContents(this._slotContents,this.slotName),this._sendChangeEvent()}_handleSlotContentChange(t){var e;this._slotContents[this.slotIndex??this._activeIndex]=structuredClone(t.detail.slotContent),this.slotMenuListElement&&(this.slotMenuListElement.slotContents=this._slotContents),(e=this._store)==null||e.updateContent(t.detail.slotContent,this.slotIndex??this._activeIndex),this._sendChangeEvent()}removeSlotContent(t){var e;this._slotContents=this._slotContents.filter((r,l)=>l!==t),(e=this._store)==null||e.setContents(this._slotContents,this.slotName),this._sendChangeEvent(),this._sendCloseEvent(),this.requestUpdate()}close(){this._sendCloseEvent()}_removeActiveSlotContent(){this.removeSlotContent(this.slotIndex??this._activeIndex)}render(){var t,e;return o.x`<div class="slot-menu-top-menu">
|
25
|
-
${this.variant==="draggable"?
|
26
|
-
${this._slotContents&&this._slotContents.length===1&&this.variant!=="popup"?
|
24
|
+
*/const R={},X=T.e(class extends T.i{constructor(){super(...arguments),this.ot=R}render(u,t){return t()}update(u,[t,o]){if(Array.isArray(t)){if(Array.isArray(this.ot)&&this.ot.length===t.length&&t.every((e,r)=>e===this.ot[r]))return n.T}else if(this.ot===t)return n.T;return this.ot=Array.isArray(t)?Array.from(t):t,this.render(t,o)}});function Y({element:u,handle:t,boundary:o=document.documentElement,onDragStart:e,onDragEnd:r}){if(!u||!t)throw new Error("makeDraggable: element and handle are required");const a=u.ownerDocument??document;let i=-1,m=0,y=0,c=0,h=0,b=0,L=0,_=0,C=0;const x=d=>{if(d.pointerId!==i)return;const v=d.clientX-m,f=d.clientY-y,p=(o??document.documentElement).getBoundingClientRect();let g=c+v,I=h+f;g=Math.min(Math.max(g,p.left),p.right-b),I=Math.min(Math.max(I,p.top),p.bottom-L);const A=g-c,B=I-h,P=_+A,D=C+B;u.style.transform=`translate3d(${P}px, ${D}px, 0)`},k=d=>{d.pointerId===i&&(a.removeEventListener("pointermove",x),a.removeEventListener("pointerup",k),i=-1,r==null||r())},$=d=>{var f;if(d.button!==0)return;i=d.pointerId;const v=u.getBoundingClientRect();c=v.left,h=v.top,b=v.width,L=v.height,m=d.clientX,y=d.clientY;try{const p=(f=a.defaultView)==null?void 0:f.getComputedStyle(u);if(p){const g=new DOMMatrixReadOnly(p.transform);_=g.m41,C=g.m42}}catch{_=0,C=0}t.setPointerCapture(i),a.addEventListener("pointermove",x),a.addEventListener("pointerup",k),e==null||e()};return t.addEventListener("pointerdown",$),()=>{t.removeEventListener("pointerdown",$),a.removeEventListener("pointermove",x),a.removeEventListener("pointerup",k)}}const N=":host{font-family:var(--luzmo-slot-menu-font-family, var(--luzmo-font-family));font-size:var(--luzmo-slot-menu-font-size, var(--slot-menu-font-size));color:var(--luzmo-slot-menu-font-color, var(--luzmo-font-color));display:block;width:fit-content}luzmo-slot-menu-list{min-width:var(--luzmo-slot-menu-list-min-width, var(--slot-menu-list-min-width));max-width:var(--luzmo-slot-menu-list-max-width, var(--slot-menu-list-max-width));background-color:var(--luzmo-slot-menu-list-background-color, var(--slot-menu-list-background-color))}.slot-contents-container{position:relative;border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-border-color, var(--luzmo-border-color));border-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));background:var(--luzmo-slot-menu-background-color, var(--luzmo-background-color));box-shadow:var(--luzmo-slot-menu-popup-shadow-horizontal, var(--slot-menu-popup-shadow-horizontal)) var(--luzmo-slot-menu-popup-shadow-vertical, var(--slot-menu-popup-shadow-vertical)) var(--luzmo-slot-menu-popup-shadow-blur, var(--slot-menu-popup-shadow-blur)) var(--luzmo-slot-menu-popup-shadow-color, var(--slot-menu-popup-shadow-color));border-top-left-radius:0}.slot-contents-container .inner-container{display:flex}.slot-contents-container .inner-container luzmo-display-settings{min-width:var(--luzmo-slot-menu-display-settings-min-width, var(--slot-menu-display-settings-min-width));padding:var(--luzmo-slot-menu-display-settings-vertical-padding, var(--slot-menu-display-settings-vertical-padding)) var(--luzmo-slot-menu-display-settings-horizontal-padding, var(--slot-menu-display-settings-horizontal-padding))}:host([variant=popup]) .slot-contents-container{overflow:hidden;border-top-left-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));--slot-menu-popup-filter: drop-shadow( var( --luzmo-slot-menu-popup-shadow-horizontal, var(--slot-menu-popup-shadow-horizontal) ) var( --luzmo-slot-menu-popup-shadow-vertical, var(--slot-menu-popup-shadow-vertical) ) var( --luzmo-slot-menu-popup-shadow-blur, var(--slot-menu-popup-shadow-blur) ) var( --luzmo-slot-menu-popup-shadow-color, var(--slot-menu-popup-shadow-color) ) );filter:var(--luzmo-slot-menu-popup-filter, var(--slot-menu-popup-filter))}.slot-menu-top-menu{display:flex;align-items:center;border-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));border-bottom-left-radius:0;border-bottom-right-radius:0;overflow:hidden;width:fit-content}.drag-handle{background-color:var(--luzmo-slot-menu-drag-handle-background-color, var(--luzmo-background-color-highlight));cursor:grab;width:fit-content;border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-border-color, var(--luzmo-background-color-highlight));font-size:var(--luzmo-slot-menu-drag-handle-size, var(--slot-menu-drag-handle-size));padding:var(--luzmo-slot-menu-drag-handle-vertical-padding, var(--slot-menu-drag-handle-vertical-padding)) var(--luzmo-slot-menu-drag-handle-horizontal-padding, var(--slot-menu-drag-handle-horizontal-padding))}.drag-handle:hover{background-color:var(--luzmo-slot-menu-drag-handle-background-color-hover, var(--luzmo-background-color-highlight-hover))}.slot-content-action{display:flex;flex:0 1 auto;max-width:var(--luzmo-slot-menu-top-menu-label-max-width, var(--slot-menu-top-menu-label-max-width));gap:var(--luzmo-slot-menu-label-to-icon-gap, var(--slot-menu-label-to-icon-gap));background-color:var(--luzmo-slot-menu-content-label-background-color, var(--luzmo-primary));color:var(--luzmo-slot-menu-content-label-color, var(--luzmo-primary-inverse-color));border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-content-label-border-color, var(--luzmo-primary));padding:var(--luzmo-slot-menu-drag-handle-vertical-padding, var(--slot-menu-drag-handle-vertical-padding)) var(--luzmo-slot-menu-drag-handle-horizontal-padding, var(--slot-menu-drag-handle-horizontal-padding))}.slot-content-action:hover{background-color:var(--luzmo-slot-menu-content-label-background-color-hover, var(--luzmo-primary-hover))}.slot-content-action:focus{background-color:var(--luzmo-slot-menu-content-label-background-color-focus, var(--luzmo-primary-focus))}.slot-content-action .slot-content-label{flex:1 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.slot-content-action .slot-content-remove{flex:0 0 auto;cursor:pointer}.close{position:absolute;right:1rem;cursor:pointer;top:calc(-2 * var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)));background-color:var(--luzmo-slot-menu-close-button-background-color, var(--luzmo-background-color-highlight));font-size:var(--luzmo-slot-menu-close-button-size, var(--slot-menu-close-button-size));border:var(--luzmo-slot-menu-border-width, var(--luzmo-border-width)) solid var(--luzmo-slot-menu-border-color, var(--luzmo-border-color));border-radius:var(--luzmo-slot-menu-border-radius, var(--luzmo-border-radius));border-top-left-radius:0;border-top-right-radius:0;padding:var(--luzmo-slot-menu-close-button-vertical-padding, var(--slot-menu-close-button-vertical-padding)) var(--luzmo-slot-menu-close-button-horizontal-padding, var(--slot-menu-close-button-horizontal-padding))}.close:hover{background-color:var(--luzmo-slot-menu-close-button-background-color-hover, var(--luzmo-background-color-highlight-hover))}:host{--slot-menu-display-settings-min-width: 19rem;--slot-menu-min-height: calc(var(--luzmo-component-height) * 2);--slot-menu-font-size: var(--luzmo-font-size);--slot-menu-display-settings-horizontal-padding: var(--luzmo-spacing-5);--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-4);--slot-menu-top-menu-label-max-width: 12rem;--slot-menu-list-min-width: 8rem;--slot-menu-list-max-width: 12rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-3);--slot-menu-drag-handle-size: var(--luzmo-font-size);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-2);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-3);--slot-menu-close-button-size: var(--luzmo-font-size-s);--slot-menu-close-button-vertical-padding: var(--luzmo-spacing-2);--slot-menu-close-button-horizontal-padding: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--slot-menu-popup-shadow-horizontal: 0;--slot-menu-popup-shadow-vertical: 1px;--slot-menu-popup-shadow-blur: 4px;--slot-menu-popup-shadow-color: var(--luzmo-border-color);--slot-menu-popup-box-shadow: var(--slot-menu-popup-shadow-horizontal) var(--slot-menu-popup-shadow-vertical) var(--slot-menu-popup-shadow-blur) var(--slot-menu-popup-shadow-color)}:host([size=s]){--slot-menu-display-settings-min-width: 16rem;--slot-menu-min-height: calc(var(--luzmo-component-height-s) * 2);--slot-menu-font-size: var(--luzmo-font-size-s);--slot-menu-display-settings-horizontal-padding: var(--luzmo-spacing-4);--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-3);--slot-menu-top-menu-label-max-width: 10rem;--slot-menu-list-min-width: 6rem;--slot-menu-list-max-width: 10rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-2);--slot-menu-drag-handle-size: var(--luzmo-font-size-s);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-2);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-3);--slot-menu-close-button-size: var(--luzmo-font-size-xs);--slot-menu-close-button-vertical-padding: var(--luzmo-spacing-2);--slot-menu-close-button-horizontal-padding: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) )}:host([size=l]){--slot-menu-display-settings-min-width: 23rem;--slot-menu-min-height: calc(var(--luzmo-component-height-l) * 2);--slot-menu-font-size: var(--luzmo-font-size-l);--slot-menu-display-settings-horizontal-padding: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-1) );--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-5);--slot-menu-top-menu-label-max-width: 14rem;--slot-menu-list-min-width: 9rem;--slot-menu-list-max-width: 14rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-4);--slot-menu-drag-handle-size: var(--luzmo-font-size-l);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-3);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-3);--slot-menu-close-button-size: var(--luzmo-font-size);--slot-menu-close-button-vertical-padding: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--slot-menu-close-button-horizontal-padding: var(--luzmo-spacing-3)}:host([size=xl]){--slot-menu-display-settings-min-width: 26rem;--slot-menu-min-height: calc(var(--luzmo-component-height-xl) * 2);--slot-menu-font-size: var(--luzmo-font-size-xl);--slot-menu-display-settings-horizontal-padding: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-2) );--slot-menu-display-settings-vertical-padding: var(--luzmo-spacing-5);--slot-menu-top-menu-label-max-width: 16rem;--slot-menu-list-min-width: 10rem;--slot-menu-list-max-width: 16rem;--slot-menu-label-to-icon-gap: var(--luzmo-spacing-5);--slot-menu-drag-handle-size: var(--luzmo-font-size-xl);--slot-menu-drag-handle-vertical-padding: var(--luzmo-spacing-3);--slot-menu-drag-handle-horizontal-padding: var(--luzmo-spacing-4);--slot-menu-close-button-size: var(--luzmo-font-size-l);--slot-menu-close-button-vertical-padding: var(--luzmo-spacing-3);--slot-menu-close-button-horizontal-padding: var(--luzmo-spacing-3)}";var K=Object.defineProperty,l=(u,t,o,e)=>{for(var r=void 0,a=u.length-1,i;a>=0;a--)(i=u[a])&&(r=i(t,o,r)||r);return r&&K(t,o,r),r};class s extends S.e(q.SizedMixin(U.LuzmoElement,{validSizes:Object.values(q.ElementSizes)})){constructor(){super(...arguments),this.language="en",this.contentLanguage="en",this.slotType="numeric",this.variant="draggable",this._periodOverPeriodEnabled=!1,this.measureColumns=[],this.apiUrl="https://api.luzmo.com",this.authKey="",this.authToken="",this._slotContents=[],this._activeIndex=this.slotIndex??0,this._linkedDatasetsIds=[]}static get styles(){return[n.r(N)]}get _currentSlotContent(){return this._slotContents[this.slotIndex??this._activeIndex]??{}}get _currentLabel(){return O.localize(this._currentSlotContent.label,this.contentLanguage)??"Untitled"}connectedCallback(){const t={};this.apiUrl&&(t.apiUrl=this.apiUrl),this.authKey&&this.authToken&&(t.authKey=this.authKey,t.authToken=this.authToken),w.dataBroker.configure(t),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupDrag&&(this._cleanupDrag(),this._cleanupDrag=void 0)}_sendChangeEvent(){this.dispatchEvent(new CustomEvent("slot-contents-changed",{bubbles:!0,composed:!0,cancelable:!0,detail:{slotContents:[...this._slotContents],linkedDatasetsIds:[...this._linkedDatasetsIds]}}))}_sendCloseEvent(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,cancelable:!0}))}isArrayColumnType(t){return new Set(["array[numeric]","array[spatial]","array[datetime]","array[hierarchy]"]).has(t)}async willUpdate(){var o,e,r,a;const t=this.slotContents??((o=this._store)==null?void 0:o.slotContents.get())??[];if(t!==this._slotContents){this._slotContents=structuredClone(t);const{set:i,column:m}=this._currentSlotContent;i&&i!==this._lastFetchedDatasetId&&(this._lastFetchedDatasetId=i,await w.dataBroker.fetchDatasetsRecursive([i]),this._linkedDatasetsIds=w.dataBroker.getLinkedDatasetsIds(i));const y=w.dataBroker.getAvailableDatasets();this.measureColumns=y.map(c=>{var h;return{datasetId:c.id,datasetName:c.name,columns:(h=c.columns)==null?void 0:h.filter(b=>b.type==="numeric"&&b.id!==m)}}),((e=this._store)==null?void 0:e.activeIndex.get())!==this._activeIndex&&((r=this._store)==null||r.updateActive(this._activeIndex)),this.slotName==="measure"&&(this._periodOverPeriodEnabled=((a=this._store)==null?void 0:a.periodOverPeriodEnabled.get())&&this._currentSlotContent.subtype!=="duration"&&!this.isArrayColumnType(this._currentSlotContent.type))}}updated(){var t;this.displaySettingsElement&&(this.displaySettingsElement.periodOverPeriod=this._periodOverPeriodEnabled,this.displaySettingsElement.measureColumns=this.measureColumns,this.displaySettingsElement.showRemoveButton=this.variant==="popup"&&(typeof this.slotIndex=="number"||((t=this._slotContents)==null?void 0:t.length)===1))}_handleSlotListChange(t){var i,m;this._slotContents=structuredClone(t.detail.slotContents);const o=t.detail.activeIndex;o!==this._activeIndex&&(this._activeIndex=o,(i=this._store)==null||i.updateActive(o));const e=this._slotContents[this._activeIndex],r=(e==null?void 0:e.column)??(e==null?void 0:e.columnId),a=(e==null?void 0:e.set)??(e==null?void 0:e.datasetId);!r||!a||(this.dispatchEvent(new CustomEvent("slot-menu-highlight",{bubbles:!0,composed:!0,detail:{columnId:r,securableId:a,level:(e==null?void 0:e.level)??0}})),this._slotContents.length<=1&&this.requestUpdate(),(m=this._store)==null||m.setContents(this._slotContents,this.slotName),this._sendChangeEvent())}_handleSlotContentChange(t){var o;this._slotContents[this.slotIndex??this._activeIndex]=structuredClone(t.detail.slotContent),this.slotMenuListElement&&(this.slotMenuListElement.slotContents=this._slotContents),(o=this._store)==null||o.updateContent(t.detail.slotContent,this.slotIndex??this._activeIndex),this._sendChangeEvent()}removeSlotContent(t){var o;this._slotContents=this._slotContents.filter((e,r)=>r!==t),(o=this._store)==null||o.setContents(this._slotContents,this.slotName),this._sendChangeEvent(),this._sendCloseEvent(),this.requestUpdate()}close(){this._sendCloseEvent()}_removeActiveSlotContent(){this.removeSlotContent(this.slotIndex??this._activeIndex)}render(){var t,o;return n.x`<div class="slot-menu-top-menu">
|
25
|
+
${this.variant==="draggable"?n.x`<div class="drag-handle">${z.y3(z.W)}</div>`:""}
|
26
|
+
${this._slotContents&&this._slotContents.length===1&&this.variant!=="popup"?n.x` <div class="slot-content-action">
|
27
27
|
<div class="slot-content-label">${this._currentLabel}</div>
|
28
28
|
<div
|
29
29
|
class="slot-content-remove"
|
30
30
|
@click=${this.removeSlotContent.bind(this,0)}
|
31
31
|
>
|
32
|
-
${
|
32
|
+
${z.y3(z.C1)}
|
33
33
|
</div>
|
34
34
|
</div>`:""}
|
35
35
|
</div>
|
36
36
|
<div
|
37
37
|
class="slot-contents-container ${((t=this._slotContents)==null?void 0:t.length)>1?"multiple":""}"
|
38
38
|
>
|
39
|
-
${this.variant==="popup"?"":
|
40
|
-
${
|
39
|
+
${this.variant==="popup"?"":n.x`<div class="close" @click=${this.close}>
|
40
|
+
${z.y3(z.F)}
|
41
41
|
</div>`}
|
42
42
|
<div class="inner-container">
|
43
|
-
${((
|
43
|
+
${((o=this._slotContents)==null?void 0:o.length)>1&&typeof this.slotIndex!="number"?n.x`<luzmo-slot-menu-list
|
44
44
|
.slotContents=${this._slotContents}
|
45
45
|
.contentLanguage=${this.contentLanguage}
|
46
46
|
.activeIndex=${this.slotIndex??this._activeIndex}
|
47
47
|
@slot-list-changed=${this._handleSlotListChange}
|
48
48
|
></luzmo-slot-menu-list>`:""}
|
49
|
-
${
|
49
|
+
${X([this.variant,this.slotType,this.language,this.contentLanguage],()=>{var e;return n.x`<luzmo-display-settings
|
50
50
|
.size=${this.size}
|
51
51
|
.language=${this.language}
|
52
52
|
.contentLanguage=${this.contentLanguage}
|
53
53
|
.slotContent=${this._currentSlotContent}
|
54
54
|
.slotType=${this.slotType}
|
55
55
|
.measureColumns=${this.measureColumns}
|
56
|
-
.showRemoveButton=${this.variant==="popup"&&(typeof this.slotIndex=="number"||((
|
56
|
+
.showRemoveButton=${this.variant==="popup"&&(typeof this.slotIndex=="number"||((e=this._slotContents)==null?void 0:e.length)===1)}
|
57
57
|
@slot-content-changed=${this._handleSlotContentChange}
|
58
58
|
@remove-slot-content=${this._removeActiveSlotContent}
|
59
59
|
></luzmo-display-settings>`})}
|
60
60
|
</div>
|
61
|
-
</div>`}firstUpdated(){if(this.variant==="draggable"&&!this.noDrag){const t=this.renderRoot.querySelector(".drag-handle");if(t){const
|
61
|
+
</div>`}firstUpdated(){if(this.variant==="draggable"&&!this.noDrag){const t=this.renderRoot.querySelector(".drag-handle");if(t){const o=this.dragBoundary?document.querySelector(this.dragBoundary):document.documentElement;this._cleanupDrag=Y({element:this,handle:t,boundary:o})}}}resetPosition(){this.style.transform=""}}l([n.n({type:String,reflect:!0})],s.prototype,"language");l([n.n({type:String,attribute:"content-language",reflect:!0})],s.prototype,"contentLanguage");l([n.n({type:String,attribute:"slot-type",reflect:!0})],s.prototype,"slotType");l([n.n({type:String,attribute:"slot-name",reflect:!0})],s.prototype,"slotName");l([n.n({type:String,attribute:"item-type",reflect:!0})],s.prototype,"itemType");l([n.n({type:Boolean,attribute:"no-drag",reflect:!0})],s.prototype,"noDrag");l([n.n({type:Boolean,attribute:"no-close",reflect:!0})],s.prototype,"noClose");l([n.n({type:String,reflect:!0})],s.prototype,"variant");l([n.n({type:Boolean,attribute:"no-top-menu-label",reflect:!0})],s.prototype,"noTopMenuLabel");l([S.c({context:S.slotContext,subscribe:!0})],s.prototype,"_store");l([n.n({type:String,attribute:"drag-boundary",reflect:!1})],s.prototype,"dragBoundary");l([n.n({type:Array,reflect:!1,attribute:"slot-contents"})],s.prototype,"slotContents");l([E.r()],s.prototype,"_periodOverPeriodEnabled");l([E.r()],s.prototype,"measureColumns");l([n.n({type:Number,reflect:!1,attribute:"slot-index"})],s.prototype,"slotIndex");l([M.e("luzmo-display-settings")],s.prototype,"displaySettingsElement");l([M.e("luzmo-slot-menu-list")],s.prototype,"slotMenuListElement");l([n.n({type:String,attribute:"api-url",reflect:!0})],s.prototype,"apiUrl");l([n.n({type:String,attribute:"auth-key",reflect:!0})],s.prototype,"authKey");l([n.n({type:String,attribute:"auth-token",reflect:!0})],s.prototype,"authToken");l([E.r()],s.prototype,"_slotContents");customElements.get("luzmo-slot-menu")||customElements.define("luzmo-slot-menu",s);exports.LuzmoSlotMenu=s;
|