@cube-nl/dmp-sdk 1.1.0-rc.2 → 1.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -10
- package/dist/app.d.ts +2 -2
- package/dist/app.js +1 -1
- package/dist/cube-sdk.js +23 -20
- package/dist/cube-ui.manifest.json +10 -3
- package/dist/size.json +2 -2
- package/dist/ui/attributes.js +1 -1
- package/dist/ui/blocks/board.d.ts +1 -1
- package/dist/ui/blocks/board.js +75 -3
- package/dist/ui/manifest.js +9 -0
- package/dist/ui/trial-banner.d.ts +2 -0
- package/dist/ui/trial-banner.js +23 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cube-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @cube-nl/dmp-sdk 1.1.0-rc.
|
|
2
|
-
"use strict";(()=>{var Zr=Object.defineProperty;var eo=(e,n,t)=>n in e?Zr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var b=(e,n,t)=>eo(e,typeof n!="symbol"?n+"":n,t);var $=class extends Error{constructor(t,o,a){let i=a!==null&&typeof a=="object"?a:{},r=re(i.detail)??re(i.error_description);super(r??`HTTP ${t}`);b(this,"status");b(this,"code");b(this,"reason");b(this,"type");b(this,"title");b(this,"detail");b(this,"errors");b(this,"retryAfter");b(this,"recordVersion");b(this,"allow");b(this,"headers");b(this,"body");this.name="DmpError",this.status=t,this.code=re(i.code)??re(i.error),this.reason=re(i.reason),this.type=re(i.type),this.title=re(i.title),this.detail=r,this.errors=to(i.errors)?i.errors:null,this.retryAfter=no(o.get("Retry-After")),this.recordVersion=o.get("X-Dmp-Record-Version"),this.allow=o.has("Allow")?(o.get("Allow")??"").split(",").map(s=>s.trim()).filter(s=>s!==""):null,this.headers=o,this.body=a}get isProblem(){return this.code!==null}};function P(e){return e instanceof $}function re(e){return typeof e=="string"?e:null}function to(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function no(e){if(e===null||e.trim()==="")return null;let n=Number(e);if(Number.isFinite(n))return n;let t=Date.parse(e);return Number.isNaN(t)?null:Math.max(0,Math.ceil((t-Date.now())/1e3))}function on(e){return{async getAccessToken(){let n=typeof e=="function"?await e():e;return n===void 0||n===""?null:n}}}var Ne="cube-dmp-sdk.pending-login";function sn(e){let n=e.fetch??globalThis.fetch.bind(globalThis),t=e.tokenStore??je(),o=e.pendingStore??so(),a=(e.refreshLeewaySeconds??30)*1e3,i=typeof e.scopes=="string"?e.scopes:e.scopes.join(" "),r=e.metadata??{},s=ro(r)?Promise.resolve({...r,issuer:r.issuer??e.issuer}):null,l=null,u=()=>(s??(s=oo(e.issuer,n).then(f=>({...f,...r}),f=>{throw s=null,f})),s),c=async(f,m)=>{let{token_endpoint:g}=await u(),w=new URLSearchParams(f);e.clientSecret!==void 0&&w.set("client_secret",e.clientSecret);let v=await n(g,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:w.toString()}),k=await an(v);if(!v.ok||k===null||typeof k!="object"||typeof k.access_token!="string")throw new $(v.status,v.headers,k);let S={accessToken:k.access_token,refreshToken:typeof k.refresh_token=="string"?k.refresh_token:null,expiresAt:typeof k.expires_in=="number"?Date.now()+k.expires_in*1e3:null,scope:typeof k.scope=="string"?k.scope:m};return await t.set(S),S},d=()=>(l??(l=(async()=>{let f=await t.get();if(f?.refreshToken==null)throw new TypeError("No refresh token: sign in again.");try{return await c({grant_type:"refresh_token",refresh_token:f.refreshToken,client_id:e.clientId},f.scope)}catch(m){throw m instanceof $&&m.status>=400&&m.status<500&&await t.set(null),m}})().finally(()=>{l=null})),l),p=async(f={})=>{let m=await u();if(!(m.code_challenge_methods_supported??[]).includes("S256"))throw new TypeError("The authorization server does not offer PKCE S256; this SDK will not sign in without it.");let g=rn(64),w=f.state??rn(32),v=ln(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(g))),k={verifier:g,state:w,redirectUri:e.redirectUri,clientId:e.clientId};o.setItem(Ne,JSON.stringify(k));let S=new URL(m.authorization_endpoint);return S.search=new URLSearchParams({...f.extraParams,response_type:"code",client_id:e.clientId,redirect_uri:e.redirectUri,scope:i,state:w,code_challenge:v,code_challenge_method:"S256"}).toString(),S.toString()};return{discover:u,authorizationUrl:p,async signIn(f={}){let m=nn();if(m===null)throw new TypeError("signIn() needs a browser; use authorizationUrl() and redirect yourself.");m.assign(await p(f))},async handleCallback(f){let m=f??nn()?.href;if(m===void 0)throw new TypeError("handleCallback() needs the callback URL outside a browser.");let g=new URL(m),w=new URLSearchParams(g.search);if(!ao(g,e.redirectUri)||!w.has("code")&&!w.has("error"))return null;if(f===void 0){for(let k of["code","state","error","error_description","iss"])g.searchParams.delete(k);globalThis.history?.replaceState(null,"",g.pathname+g.search+g.hash)}let v=lo(o.getItem(Ne));if(v===null||w.get("state")!==v.state)throw new TypeError("The state does not match: this callback does not belong to a sign-in started here.");if(o.removeItem(Ne),w.has("error"))throw new $(400,new Headers,{error:w.get("error")??"access_denied",error_description:w.get("error_description")??void 0});return c({grant_type:"authorization_code",code:w.get("code")??"",redirect_uri:v.redirectUri,client_id:v.clientId,code_verifier:v.verifier},i)},refresh:d,async getTokens(){return t.get()},async setTokens(f){await t.set(f)},async signOut(){await t.set(null),o.removeItem(Ne)},async getAccessToken(){let f=await t.get();if(f===null)return null;if(f.expiresAt!==null&&f.expiresAt-a<=Date.now()&&f.refreshToken!==null)try{return(await d()).accessToken}catch{return(await t.get())?.accessToken??null}return f.accessToken},async onUnauthorized(){if((await t.get())?.refreshToken==null)return!1;try{return await d(),!0}catch{return!1}}}}function ro(e){return typeof e.authorization_endpoint=="string"&&typeof e.token_endpoint=="string"}async function oo(e,n=globalThis.fetch.bind(globalThis)){let t=`${e.replace(/\/+$/,"")}/.well-known/oauth-authorization-server`,o=await n(t,{headers:{Accept:"application/json"}}),a=await an(o);if(!o.ok||a===null||typeof a!="object")throw new $(o.status,o.headers,a);return a}function je(e=null){let n=e;return{get:()=>n,set:t=>{n=t}}}function io(){let e=new Map;return{getItem:n=>e.get(n)??null,setItem:(n,t)=>{e.set(n,t)},removeItem:n=>{e.delete(n)}}}function so(){try{let e=globalThis.sessionStorage;if(e!==void 0)return e}catch{}return io()}function nn(){let e=globalThis.location;return e!==void 0&&typeof e.assign=="function"?e:null}function ao(e,n){let t=new URL(n),o=a=>a.replace(/\/+$/,"")||"/";return e.origin===t.origin&&o(e.pathname)===o(t.pathname)}function lo(e){if(e===null)return null;try{let n=JSON.parse(e);return typeof n.verifier=="string"&&typeof n.state=="string"&&typeof n.redirectUri=="string"&&typeof n.clientId=="string"?n:null}catch{return null}}async function an(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function rn(e){return ln(crypto.getRandomValues(new Uint8Array(e)))}function ln(e){let n=e instanceof Uint8Array?e:new Uint8Array(e),t="";for(let o of n)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var uo=new Set(["in","between"]);function oe(e,n={}){let t=new URLSearchParams;co(t,e,n.fields),po(t,n.filter),xe(t,"sort",n.sort),xe(t,"include",n.include),xe(t,"with_count",n.withCount),fo(t,n.has),xe(t,"fn",n.fn),xe(t,"group",n.group),n.page?.size!==void 0&&t.append("page[size]",String(n.page.size)),n.page?.number!==void 0&&t.append("page[number]",String(n.page.number));for(let[o,a]of Object.entries(n.params??{}))t.append(o,a);return t.toString().replace(/%5B/gi,"[").replace(/%5D/gi,"]").replace(/%2C/gi,",").replace(/%28/gi,"(").replace(/%29/gi,")")}function co(e,n,t){if(t===void 0)return;let o=go(t)?{[n]:t}:t;for(let[a,i]of Object.entries(o))i.length>0&&e.append(`fields[${a}]`,i.join(","))}function po(e,n){for(let[t,o]of Object.entries(n??{})){if(Array.isArray(o))throw new TypeError(`filter.${t}: a bare list names no operator and cube/api refuses it. Write { in: [...] } (or { between: [from, to] }).`);if(o==null)throw new TypeError(`filter.${t}: write { is: 'null' } or { is: 'not_null' } to filter on null.`);if(typeof o!="object"){e.append(`filter[${t}]`,vt(o));continue}for(let[a,i]of Object.entries(o))i!==void 0&&e.append(`filter[${t}][${a}]`,mo(t,a,i))}}function mo(e,n,t){if(t===null){if(n!=="is")throw new TypeError(`filter.${e}.${n}: null is only meaningful under 'is'.`);return"null"}if(Array.isArray(t)){if(!uo.has(n))throw new TypeError(`filter.${e}.${n}: takes one value; only 'in' and 'between' take a list.`);return t.map(vt).join(",")}return vt(t)}function fo(e,n){for(let[t,o]of Object.entries(n??{}))o===!0?e.append(`has[${t}]`,"1"):typeof o=="number"?e.append(`has[${t}][min]`,String(o)):(o.min!==void 0&&e.append(`has[${t}][min]`,String(o.min)),o.max!==void 0&&e.append(`has[${t}][max]`,String(o.max)))}function xe(e,n,t){if(t===void 0)return;let o=typeof t=="string"?t:t.filter(a=>a!=="").join(",");o!==""&&e.append(n,o)}function vt(e){return typeof e=="boolean"?e?"1":"0":String(e)}function go(e){return Array.isArray(e)}var ho=/^[a-z][a-z0-9_]*$/;function St(e){let n=e.baseUrl.replace(/\/+$/,""),t=e.fetch??globalThis.fetch.bind(globalThis),o=e.auth===void 0?null:typeof e.auth=="string"||typeof e.auth=="function"?on(e.auth):e.auth,a=e.cache??(typeof document<"u"?"no-cache":void 0),i=async(s,l,{query:u,body:c,headers:d={},signal:p}={})=>{let f=`${n}${l.startsWith("/")?l:`/${l}`}${u?`?${u}`:""}`,m=async()=>{let k=o===null?null:await o.getAccessToken(),S={method:s,headers:{Accept:"application/json",...e.headers,...k!==null?{Authorization:`Bearer ${k}`}:{},...c!==void 0?{"Content-Type":"application/json"}:{},...d}};c!==void 0&&(S.body=JSON.stringify(c)),a!==void 0&&(S.cache=a),p!==void 0&&(S.signal=p);let D=Date.now(),L=await t(f,S);return e.onResponse?.({method:s,url:f,status:L.status,ms:Date.now()-D}),L},g=await m();g.status===401&&o?.onUnauthorized!==void 0&&await o.onUnauthorized()&&(await g.body?.cancel().catch(()=>{}),g=await m());let w=await yo(g);if(!g.ok)throw new $(g.status,g.headers,w);let v=wo(w)?w:null;return{status:g.status,data:v!==null?v.data:w,meta:v?.meta??null,headers:g.headers,etag:g.headers.get("ETag"),recordVersion:g.headers.get("X-Dmp-Record-Version"),location:g.headers.get("Location"),replayed:g.headers.get("Idempotency-Replayed")==="true",rateLimit:vo(g.headers)}};return{async capabilities(s={}){let l=(await i("GET","/_capabilities",Be({},s))).data;return{...l,resources:l.resources.map(bo)}},resources:s=>{if(!ho.test(s))throw new TypeError(`'${s}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let l=`/${s}`,u=m=>{let g=String(m);if(g==="")throw new TypeError(`${s}: an empty id would address the collection, not a record.`);if(dn(g))throw new TypeError(`${s}: '${g}' is not an id: it would address another path, not a record.`);return`${l}/${encodeURIComponent(g)}`},c=m=>m===void 0?"":oe(s,{fields:m}),d=async(m={},g={})=>await i("GET",l,Be({query:oe(s,m)},g)),p=async function*(m={},g={}){let w=m.page?.number??1;for(;;){let v=await d({...m,page:{...m.page,number:w}},g);yield v;let k=v.meta.page;if(k==null||k.number>=k.pages||v.data.length===0)return;w=k.number+1}},f=async(m,g,w)=>{let v=await i("POST",m,{query:c(w.fields),body:g??{},headers:Ie(w)});return{...v,data:v.status===204?null:v.data,accepted:v.status===202}};return{name:s,list:d,pages:p,async*all(m={},g={}){for await(let w of p(m,g))yield*w.data},get:(m,g={},w={})=>i("GET",u(m),Be({query:oe(s,g)},w)),aggregate:(m,g={})=>i("GET",`${l}/_aggregate`,Be({query:oe(s,m)},g)),create:(m,g={})=>i("POST",l,{query:c(g.fields),body:m,headers:Ie(g)}),update:(m,g,w={})=>i("PATCH",u(m),{query:c(w.fields),body:g,headers:Ie(w)}),delete:async(m,g={})=>({...await i("DELETE",u(m),{headers:Ie(g)}),data:null}),operation:(m,g,w,v={})=>f(`${u(m)}/${encodeURIComponent(un(g))}`,w,v),collectionOperation:(m,g,w={})=>f(`${l}/_operations/${encodeURIComponent(un(m))}`,g,w)}},request:i}}function bo(e){return{...e,operations:(e.operations??[]).map(n=>({...n,input:kt(n.input)})),aggregatable:kt(e.aggregatable),relations:kt(e.relations)}}function kt(e){return Array.isArray(e)||e===void 0||e===null?{}:e}function cn(){return crypto.randomUUID()}function un(e){if(e===""||e.startsWith("_"))throw new TypeError(`'${e}' is not an operation name: the '_' namespace is reserved by the API.`);if(dn(e))throw new TypeError(`'${e}' is not an operation name: it would address another path.`);return e}function dn(e){return e==="."||e===".."}function Ie(e){let n={};if(e.idempotencyKey!==void 0&&(n["Idempotency-Key"]=e.idempotencyKey),e.ifMatch!==void 0){if(e.ifMatch.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");n["If-Match"]=e.ifMatch}return n}function Be(e,n){return n.signal===void 0?e:{...e,signal:n.signal}}async function yo(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function wo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"data"in e}function vo(e){let n=t=>{let o=e.get(t);return o===null||o===""||!Number.isFinite(Number(o))?null:Number(o)};return{limit:n("X-RateLimit-Limit"),remaining:n("X-RateLimit-Remaining"),reset:n("X-RateLimit-Reset")}}var pn=/^[a-z][a-z0-9_]*$/,mn=["eq","neq","gt","gte","lt","lte","in","like","ilike","is","between"],ko=[[">=","gte"],["<=","lte"],["<>","neq"],[">","gt"],["<","lt"],["=","eq"]],Et=["count","sum","avg","min","max"],fn=["day","week","month","quarter","year"],xt=20,Tt=5,gn=1e3,Ct=200,So=50,At=200,xo="1.0",Z=class{constructor(n,t=null,o=()=>{}){b(this,"manifest",t);b(this,"guard",o);b(this,"tables",new Map);for(let[a,i]of Object.entries(To(n))){if(typeof i!="object"||i===null||Array.isArray(i))continue;let r=typeof i.schema?.name=="string"&&i.schema.name!==""?i.schema.name:a;pn.test(r)&&this.tables.set(r,Co(r,i))}}rows(n){return this.tables.get(n)?.rows??[]}resourceNames(){return[...this.tables.keys()]}describe(n){let t=this.tables.get(n);return t===void 0?null:{name:n,actions:[...t.actions],fields:[...t.fields.values()].map(o=>{let a=t.choices.get(o.name);return{name:o.name,type:o.types.join("|"),format:o.format,nullable:o.nullable,readonly:!t.writable.has(o.name),enum:a===void 0?null:a.map(String),description:o.description}}),summary:[...t.summary],filterable:[...t.filterable],sortable:[...t.fields.keys()],groupable:[...t.groupable],aggregatable:Object.fromEntries([...t.aggregatable].map(([o,a])=>[o,a.filter(i=>i!=="count")]))}}resource(n){if(!pn.test(n))throw new TypeError(`'${n}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let t=(i,r)=>Promise.resolve().then(()=>r(this.authorize(n,i))),o=(i={})=>t("list",r=>Ro(r,i)),a=async function*(i={}){let r=i.page?.number??1;for(;;){let s=await o({...i,page:{...i.page,number:r}});if(yield s,s.meta.page.number>=s.meta.page.pages||s.data.length===0)return;r=s.meta.page.number+1}};return{name:n,list:o,pages:a,async*all(i={}){for await(let r of a(i))yield*r.data},get:(i,r={})=>t("get",s=>Eo(s,i,r)),aggregate:i=>t("aggregate",r=>_o(r,i)),create:(i,r={})=>t("create",s=>jo(s,i,r)),update:(i,r,s={})=>t("update",l=>Io(l,i,r,s)),delete:(i,r={})=>t("delete",s=>Bo(s,i,r)),operation:(i,r,s,l)=>t("get",u=>{throw He(u,i),yn(r)}),collectionOperation:i=>t("list",()=>{throw yn(i)})}}authorize(n,t){this.guard();let o=this.tables.get(n);if(o===void 0)throw M(404,"not_found",`Unknown API resource [${n}].`);let a=this.manifest?.uses;if(a!==void 0&&!(a[n]??[]).includes(t))throw M(403,"client_scope_exceeded",`This app may not ${t} '${n}': add it to "uses" in cube-app.json.`);return o}};function To(e){let n=e.resources;return Object.keys(e).length===1&&Te(n)&&!("rows"in n)&&!("schema"in n)?n:e}function Co(e,n){let t=n.schema??{},o=(n.rows??[]).map(d=>Mt(d)),a=new Map,i=Array.isArray(t.fields)?t.fields.map(d=>[d.name,d]):Object.entries(t.fields??{});for(let[d,p]of i)a.set(d,Ao(d,p));for(let d of a.size===0?o:[])for(let p of Object.keys(d))a.has(p)||a.set(p,{name:p,types:[],nullable:!0,format:null,description:null});let r=[...a.keys()],s=(Te(t.choices)?Object.entries(t.choices):[]).filter(d=>Te(d[1])&&Array.isArray(d[1].values)),l=new Set(["id",...t.readonly??[],...i.filter(([,d])=>d.readonly===!0).map(([d])=>d),...s.filter(([,d])=>d.writable===!1).map(([d])=>d)]),u=new Map;for(let[d,p]of i)Array.isArray(p.enum)&&u.set(d,p.enum);for(let[d,p]of s)u.set(d,p.values);let c=d=>Array.isArray(d)?d.filter(p=>typeof p=="string"&&a.has(p)):null;return{name:e,actions:Array.isArray(t.actions)?t.actions.filter(d=>typeof d=="string"):["list","get","create","update","delete"],fields:a,filterable:c(t.filters)??r,groupable:c(t.groupable)??r,aggregatable:new Map(Te(t.aggregatable)?Object.entries(t.aggregatable).filter(([d,p])=>a.has(d)&&Array.isArray(p)).map(([d,p])=>[d,[...p]]):r.map(d=>[d,[...Et]])),choices:u,writable:new Set(r.filter(d=>!l.has(d))),summary:(c(t.summary_fields)??[]).length>0?c(t.summary_fields):r,rows:o,versions:new Map(o.map(d=>[W(d.id),1])),replays:new Map}}function Ao(e,n){let t=n.type,o=typeof t=="string"?t.split("|"):Array.isArray(t)?[...t]:[];return{name:e,types:o.filter(a=>a!=="null"&&a!==""),nullable:n.nullable===!0||o.includes("null"),format:typeof n.format=="string"?n.format:null,description:typeof n.description=="string"?n.description:null}}function Ce(e,n){return new URLSearchParams(oe(e.name,n))}function Ro(e,n){let t=Ce(e,n),o=Ue(e,t),a=vn(e,t),i=Fo(e,t),{size:r,number:s}=Oo(t),l=wn(e,t),u=e.rows.filter(f=>a.every(m=>kn(e,f,m)));i.length>0&&(u=[...u].sort((f,m)=>{for(let{field:g,descending:w}of i){let v=H(f[g],m[g]);if(v!==0)return w?-v:v}return 0}));let c=u.length,d=u.slice((s-1)*r,s*r).map(f=>ze(f,o)),p={size:r,number:s,total:c,pages:Math.max(1,Math.ceil(c/r))};return{...de(200,d,ce(e,p,l)),meta:{...ce(e,p,l),page:p}}}function Eo(e,n,t){let o=Ce(e,t),a=Ue(e,o),i=wn(e,o),r=He(e,n);return de(200,ze(r,a),ce(e,null,i),Ve(e,r))}function Ue(e,n){let t=`fields[${e.name}]`,o=n.get(t);if(o===null||o==="")return e.summary;let a=o.split(",").map(r=>r.trim()),i=a.filter(r=>!e.fields.has(r));if(i.length>0)throw M(422,"query_invalid",`Unknown ${t}: ${i.join(", ")}.`,{[t]:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]});return a}function wn(e,n){let t=o=>(n.get(o)??"").split(",").filter(a=>a!=="");return[...new Set([...t("include"),...t("with_count")])]}function vn(e,n){let t=[],o=[];n.forEach((a,i)=>o.push([i,a]));for(let[a,i]of o){let r=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/.exec(a);if(r===null)continue;let s=r[1];if(!e.filterable.includes(s))throw M(422,"query_invalid",`Unknown filter: ${s}.`,{filter:[`Allowed values: ${e.filterable.join(", ")}.`]},"not_filterable");t.push(r[2]===void 0?Do(s,i):Mo(s,r[2],i))}if(t.length>xt)throw M(422,"query_invalid",`A query takes at most ${xt} filters.`,{filter:[`Sent ${t.length}; the limit is ${xt}.`]});return t}function Do(e,n){for(let[t,o]of ko)if(n.startsWith(t))return{field:e,operator:o,value:n.slice(t.length)};return{field:e,operator:"eq",value:n}}function Mo(e,n,t){if(!mn.includes(n))throw M(422,"query_invalid",`Unknown filter operator: ${n}.`,{filter:[`Allowed operators: ${mn.join(", ")}.`]});if(n==="between"&&t.split(",").length!==2)throw M(422,"query_invalid",`filter[${e}][between] takes exactly 2 values.`,{filter:[`Write filter[${e}][between]=low,high. Received ${t.split(",").length} value(s).`]});if(n==="in"&&t.split(",").length>Ct)throw M(422,"query_invalid",`filter[${e}][in] takes at most ${Ct} values.`,{filter:[`Sent ${t.split(",").length}; the limit is ${Ct}.`]});if(n==="is"&&t!=="null"&&t!=="not_null")throw M(422,"query_invalid",`filter[${e}][is] takes null or not_null.`,{filter:[`Received: ${t}.`]});return{field:e,operator:n,value:t}}function kn(e,n,t){let o=n[t.field],a=i=>Vo(e.fields.get(t.field),i.trim());switch(t.operator){case"eq":return Rt(o,a(t.value));case"neq":return o!=null&&!Rt(o,a(t.value));case"gt":return o!=null&&H(o,a(t.value))>0;case"gte":return o!=null&&H(o,a(t.value))>=0;case"lt":return o!=null&&H(o,a(t.value))<0;case"lte":return o!=null&&H(o,a(t.value))<=0;case"in":return t.value.split(",").some(i=>Rt(o,a(i)));case"between":{let[i,r]=t.value.split(",").map(a);return o!=null&&H(o,i)>=0&&H(o,r)<=0}case"like":case"ilike":return typeof o=="string"&&Lo(o,t.value);case"is":return t.value==="null"?o==null:o!=null;default:return!1}}function Lo(e,n){let t=n.split("%").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(t,"iu").test(e)}function Fo(e,n){let t=n.get("sort");if(t===null||t==="")return[];let o=t.split(",").map(i=>i.trim()).filter(i=>i!=="").map(i=>({field:i.replace(/^[-+]/,""),descending:i.startsWith("-")})),a=o.map(i=>i.field).filter(i=>!e.fields.has(i));if(a.length>0)throw M(422,"query_invalid",`Unknown sort: ${a.join(", ")}.`,{sort:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]},"not_sortable");return o}function Oo(e){let n=o=>{let a=e.get(o);if(a===null||a==="")return null;if(!/^\d+$/.test(a))throw M(422,"query_invalid",`${o} must be a positive integer.`,{[o]:["Expected a positive integer."]});return Number(a)},t=n("page[size]")??So;if(t>At)throw M(422,"cardinality_exceeded",`page[size] may not exceed ${At}.`,{"page.size":[`The maximum page size is ${At}.`]});return{size:Math.max(1,t),number:Math.max(1,n("page[number]")??1)}}function _o(e,n){let t=Ce(e,n),o=(t.get("fn")??"").trim();if(o==="")throw M(422,"query_invalid","fn is required: name at least one aggregation function.",{fn:[`Expected e.g. fn=count or fn=sum(field). ${Dt(e)}`]});let a=o.split(",").map(f=>f.trim()),i=a.map(f=>$o(e,f));hn(a,"fn");let r=(t.get("group")??"").trim(),s=r===""?[]:r.split(",").map(f=>f.trim());if(s.length>Tt)throw M(422,"cardinality_exceeded",`group may not exceed ${Tt} dimensions, ${s.length} given.`,{group:[`Use at most ${Tt} dimensions.`]});let l=s.map(f=>Po(e,f));hn(s,"group");let u=vn(e,t),c=new Map;for(let f of e.rows.filter(m=>u.every(g=>kn(e,m,g)))){let m={};for(let[v,k]of s.entries())m[k]=l[v](f);let g=JSON.stringify(Object.values(m)),w=c.get(g)??{key:m,rows:[]};w.rows.push(f),c.set(g,w)}if(s.length===0&&c.size===0&&c.set("[]",{key:{},rows:[]}),c.size>gn)throw M(422,"cardinality_exceeded","The grouping produces more groups than the configured maximum.",{groepen:["The grouping produces more groups than the configured maximum.",`Allowed values: groepeer grover, of filter eerst; maximaal ${gn} groepen.`]},"too_many_groups");let p=[...c.values()].sort((f,m)=>{for(let g of s){let w=H(f.key[g],m.key[g]);if(w!==0)return w}return 0}).map(({key:f,rows:m})=>{let g={...f};for(let[w,v]of a.entries())g[v]=i[w](m);return g});return de(200,p,{...ce(e,null,[]),groups:p.length})}function hn(e,n){let t=[...new Set(e.filter((o,a)=>e.indexOf(o)!==a))];if(t.length>0)throw M(422,"query_invalid",`Duplicate ${n} entry: ${t.join(", ")}.`,{[n]:[`List each ${n} entry once.`]})}function Dt(e){return e.aggregatable.size===0?"This resource has no aggregatable fields; only bare count is available.":`Aggregatable fields: ${[...e.aggregatable.keys()].join(", ")}.`}function $o(e,n){let t=/^([a-z]+)\(([a-z0-9_]+)\)$/.exec(n);if(t===null&&!/^[a-z]+$/.test(n))throw M(422,"query_invalid",`Unparseable fn entry: ${n}.`,{fn:["Expected `count` or `function(field)`, e.g. sum(field)."]});let o=t===null?n:t[1],a=t===null?null:t[2];if(!Et.includes(o))throw M(422,"query_invalid",`Unknown aggregation function: ${o}.`,{fn:[`Allowed values: ${Et.join(", ")}.`]});if(a===null){if(o!=="count")throw M(422,"query_invalid",`${o} must be applied to a field, e.g. ${o}(field).`,{fn:[Dt(e)]});return r=>r.length}let i=e.aggregatable.get(a);if(i===void 0)throw M(422,"query_invalid",`Unknown aggregatable field: ${a}.`,{fn:[Dt(e)]});if(!i.includes(o))throw M(422,"query_invalid",`${o} is not allowed on ${a}.`,{fn:[`Allowed functions for ${a}: ${i.join(", ")}.`]});return r=>{let s=r.map(u=>u[a]).filter(u=>u!=null),l=s.map(Number).filter(u=>Number.isFinite(u));switch(o){case"count":return r.length;case"sum":return l.length===0?null:l.reduce((u,c)=>u+c,0);case"avg":return l.length===0?null:l.reduce((u,c)=>u+c,0)/l.length;case"min":return s.length===0?null:s.reduce((u,c)=>H(c,u)<0?c:u);default:return s.length===0?null:s.reduce((u,c)=>H(c,u)>0?c:u)}}}function Po(e,n){let t=n.split(".");if(t.length>2)throw M(422,"query_invalid",`Unparseable group entry: ${n}.`,{group:["Expected `field` or `field.unit`, e.g. published_at.month."]});let[o,a]=t;if(!e.groupable.includes(o))throw M(422,"query_invalid",`Unknown group: ${o}.`,{group:[`Allowed values: ${e.groupable.join(", ")}.`]},"not_groupable");if(a===void 0)return i=>i[o]??null;if(!fn.includes(a))throw M(422,"query_invalid",`Unknown truncation unit: ${a}.`,{group:[`Allowed values: ${fn.join(", ")}.`]});return i=>No(i[o],a)}function No(e,n){let t=typeof e=="string"?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null;if(t===null)return null;let[o,a,i]=[Number(t[1]),Number(t[2]),Number(t[3])],r=new Date(Date.UTC(o,a-1,i));if(r.getUTCFullYear()!==o||r.getUTCMonth()!==a-1||r.getUTCDate()!==i)return null;switch(n){case"day":return t[0];case"week":{let s=new Date(r.getTime()+(3-(r.getUTCDay()+6)%7)*864e5),l=s.getUTCFullYear(),u=1+Math.floor((s.getTime()-Date.UTC(l,0,1))/(7*864e5));return`${l}-W${String(u).padStart(2,"0")}`}case"month":return t[0].slice(0,7);case"quarter":return`${t[1]}-Q${Math.ceil(a/3)}`;case"year":return t[1];default:return null}}function jo(e,n,t){let o=t.fields===void 0?e.summary:Ue(e,Ce(e,{fields:t.fields})),a=JSON.stringify([n,t.fields??null]);if(t.idempotencyKey!==void 0){let l=e.replays.get(t.idempotencyKey);if(l!==void 0){if(l.body!==a)throw M(422,"validation_failed","This Idempotency-Key was already used with a different request body. Use a new key, or resend the original body.");return{...l.response,replayed:!0}}}let i=Sn(e,n),r={id:zo(e),...i};for(let l of e.fields.keys())l in r||(r[l]=null);e.rows.push(r),e.versions.set(W(r.id),1);let s=de(201,ze(r,o),ce(e,null,[]),Ve(e,r));return t.idempotencyKey!==void 0&&e.replays.set(t.idempotencyKey,{body:a,response:s}),s}function Io(e,n,t,o){let a=o.fields===void 0?e.summary:Ue(e,Ce(e,{fields:o.fields})),i=He(e,n);return xn(e,i,o.ifMatch),Object.assign(i,Sn(e,t)),e.versions.set(W(i.id),(e.versions.get(W(i.id))??1)+1),de(200,ze(i,a),ce(e,null,[]),Ve(e,i))}function Bo(e,n,t){let o=He(e,n);return xn(e,o,t.ifMatch),e.rows.splice(e.rows.indexOf(o),1),e.versions.delete(W(o.id)),de(204,null,null)}function Sn(e,n){let t=[...e.writable],o=t.length===0?"This resource declares no writable fields.":`Writable fields: ${t.join(", ")}.`;if(!Te(n)||Object.keys(n).length===0)throw M(422,"validation_failed","The request body must be a JSON object naming at least one writable field.",{body:[o]});let a=Object.keys(n).filter(r=>!e.writable.has(r));if(a.length>0)throw M(422,"query_invalid",`Unknown or read-only fields: ${a.join(", ")}.`,Object.fromEntries(a.map(r=>[r,[o]])));let i={};for(let[r,s]of Object.entries(n)){let l=e.fields.get(r),u=Ho(l,s)??Uo(e,l,r,s);u!==null&&(i[r]=[u])}if(Object.keys(i).length>0)throw M(422,"validation_failed","The request body failed validation.",i);return Mt(n)}function Uo(e,n,t,o){let a=e.choices.get(t);return a===void 0||o===null&&n?.nullable===!0||a.includes(o)?null:`The selected ${t.replace(/_/g," ")} is invalid.`}function Ho(e,n){return e===void 0||e.types.length!==1?null:n===null?e.nullable?null:bn(e):(()=>{switch(e.types[0]){case"string":return typeof n=="string";case"integer":return typeof n=="number"&&Number.isInteger(n)||typeof n=="string"&&/^[+-]?\d+$/.test(n.trim());case"number":return typeof n=="number"&&Number.isFinite(n)||typeof n=="string"&&n.trim()!==""&&Number.isFinite(Number(n));case"boolean":return[!0,!1,0,1,"0","1"].includes(n);case"array":case"object":return typeof n=="object";default:return!0}})()?null:bn(e)}function bn(e){return`The ${e.name.replace(/_/g," ")} field must be ${{string:"a string",integer:"an integer",number:"a number",boolean:"true or false",array:"an array",object:"an array"}[e.types[0]]??"valid"}.`}function xn(e,n,t){if(t===void 0)return;if(t.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");let o=Ve(e,n);if(t!==o)throw M(409,"conflict","The record changed since the version you sent.",void 0,void 0,{"X-Dmp-Record-Version":o})}function zo(e){let n=e.rows.map(t=>t.id);return n.length>0&&n.every(t=>typeof t=="string")&&n.some(t=>!/^\d+$/.test(t))?crypto.randomUUID():n.reduce((t,o)=>Math.max(t,Number(o)||0),0)+1}function He(e,n){let t=W(n);if(t===""||t==="."||t==="..")throw new TypeError(`${e.name}: '${t}' is not an id.`);let o=e.rows.find(a=>W(a.id)===t);if(o===void 0)throw M(404,"not_found",`No such ${e.name} record.`);return o}function yn(e){return M(404,"not_found",`No such operation [${e}]. The preview runs no custom operations.`)}function ze(e,n){let t={};for(let o of n)t[o]=o in e?Mt(e[o]):null;return t}function Ve(e,n){return`"preview-${W(n.id)}-${e.versions.get(W(n.id))??1}"`}function ce(e,n,t){return{resource:e.name,contract:xo,page:n,groups:null,omitted:t,pruned:[],forbidden_fields:[]}}function de(e,n,t,o=null){let a=new Headers({"X-Dmp-Preview":"true"});return o!==null&&a.set("X-Dmp-Record-Version",o),{status:e,data:n,meta:t,headers:a,etag:null,recordVersion:o,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}}function M(e,n,t,o,a,i={}){return new $(e,new Headers({"Content-Type":"application/problem+json",...i}),{type:`https://docs.cube.nl/dmp-api/problems/${n}`,title:n.replace(/_/g," "),status:e,code:n,...a!==void 0?{reason:a}:{},detail:t,...o!==void 0?{errors:o}:{}})}function Vo(e,n){let t=e?.types[0];if((t==="integer"||t==="number")&&n!==""&&Number.isFinite(Number(n)))return Number(n);if(t==="boolean"){if(n==="1"||n==="true")return!0;if(n==="0"||n==="false")return!1}return n}function Rt(e,n){return e==null?!1:typeof e=="boolean"&&typeof n!="boolean"?(e?"1":"0")===String(n)||String(e)===String(n):typeof e=="number"&&typeof n=="string"?String(e)===n:e===n||typeof e!="object"&&String(e)===String(n)}function H(e,n){if(e==null||n==null)return e==null?n==null?0:-1:1;if(typeof e=="number"&&typeof n=="number")return e-n;if(typeof e=="boolean"||typeof n=="boolean")return+(e===!0||e===1||e==="1")-+(n===!0||n===1||n==="1");let t=String(e),o=String(n);return t<o?-1:t>o?1:0}function W(e){return e==null?"":String(e)}function Te(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mt(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function Tn(e){return{name:e.name,actions:[...e.actions],fields:e.fields.map(n=>({name:n.name,type:n.type,format:null,nullable:n.nullable,readonly:n.readonly,enum:null,description:n.description??null})),summary:[...e.summary],filterable:[...e.filterable],sortable:[...e.sortable],groupable:[...e.groupable],aggregatable:Object.fromEntries(Object.entries(e.aggregatable).map(([n,t])=>[n,[...t]]))}}var Lt="Voorbeeldgebruiker",pe={invalidPrimary:"De hoofdkleur is geen geldige hexkleur; de neutrale standaardkleur wordt gebruikt.",invalidAccent:"De accentkleur is geen geldige hexkleur; er wordt een accentkleur afgeleid.",primaryLight:"De hoofdkleur is erg licht; witte tekst erop heeft weinig contrast.",primaryDarkened:"De hoofdkleur is voor tekst donkerder gemaakt om voldoende contrast te houden."},y={loading:"Laden\u2026",empty:"Er is hier nog niets te tonen.",error:"Er ging iets mis bij het laden.",retry:"Opnieuw proberen",forbidden:"Je hebt geen toegang tot deze gegevens.",signedOut:"Je bent niet ingelogd.",signIn:"Inloggen",signOut:"Uitloggen",signedIn:"Ingelogd",previewUser:Lt,pages:"Pagina's",yes:"Ja",no:"Nee",emptyValue:"\u2014",quarter:(e,n)=>`K${e} ${n}`,week:(e,n)=>`week ${e}, ${n}`,monthYear:(e,n)=>`${e} '${n.slice(-2)}`,period:{label:"Periode","this-month":"Deze maand","12m":"Laatste 12 maanden","this-year":"Dit jaar",custom:"Zelf kiezen",from:"Van",to:"Tot en met",invalidRange:"De einddatum ligt v\xF3\xF3r de begindatum.",incompleteDate:"Vul bij Van en Tot en met een volledige datum in."},noData:"geen gegevens",comparedTo:"t.o.v. vorige periode",newValue:"nieuw",higher:"hoger",lower:"lager",incomplete:"Mogelijk niet compleet: er zijn meer groepen dan de DMP in \xE9\xE9n keer teruggeeft.",asTable:"Gegevens van de grafiek",tooManyGroups:"Te veel groepen om te tonen (meer dan 1000). Kies een kortere periode of een filter.",points:e=>`${e} ${e===1?"punt":"punten"}`,change:(e,n)=>`${e} procent ${n} dan de vorige periode`,search:"Zoeken",all:"Alle",min:"Vanaf",max:"Tot en met",previous:"Vorige",next:"Volgende",pageOf:(e,n,t)=>`Pagina ${e} van ${n} \xB7 ${t} rijen`,exportCsv:"Exporteren (CSV)",exporting:e=>`${e} rijen opgehaald\u2026`,chooseRow:"Kies een rij om de details te zien.",edit:"Bewerken",save:"Opslaan",cancel:"Annuleren",saved:"Opgeslagen.",formSaved:"Opgeslagen. Dank je wel!",another:"Nog een invullen",required:"Vul dit veld in.",requiredMark:" (verplicht)",notANumber:"Vul een getal in.",notAnInteger:"Vul een geheel getal in.",conflict:"Iemand anders heeft deze rij intussen gewijzigd. Laad de nieuwste versie en probeer het opnieuw.",reload:"Opnieuw laden",saveFailed:"Opslaan is niet gelukt. Probeer het opnieuw.",exportFailed:"Exporteren is niet gelukt. Probeer het opnieuw.",formInvalid:"Niet alles is goed ingevuld.",noWritableFields:"Dit formulier heeft geen invulbare velden.",calcFailed:"De berekening lukt niet met deze invoer.",moveTo:e=>`Verplaats naar ${e}`,moveFailed:"Verplaatsen lukte niet.",tryAgain:"Probeer het opnieuw.",changedMeanwhile:"Iemand anders heeft dit intussen gewijzigd; de nieuwste stand is geladen.",more:e=>`en nog ${e}`,noColumns:'Geef de kolommen op met <cube-column value="\u2026">.',emptyColumn:"Leeg",range:(e,n)=>`Kies een waarde van ${e} tot en met ${n}.`,atLeast:e=>`Kies een waarde van ${e} of meer.`,atMost:e=>`Kies een waarde van ten hoogste ${e}.`,step:e=>`Kies een waarde in stappen van ${e}.`,example:"Voorbeeld",exampleMissing:"Voorbeeld \u2014 bestaat nog niet",exampleNotSaved:"Voorbeeld \u2014 wordt niet opgeslagen",gaps:{screen:"Scherm",what:"Wat ontbreekt",type:"Soort gegeven",why:"Waarom",none:"Er ontbreekt niets: alles in dit voorstel bestaat al in de DMP.",types:{tekst:"Tekst",getal:"Getal",bedrag:"Bedrag",datum:"Datum",keuze:"Keuze","ja/nee":"Ja/nee"}},trial:{banner:(e,n)=>["Proefversie","alleen jij","alleen lezen"].concat(e===null?[]:[`verloopt om ${e}`]).concat(n.length===0?[]:[`leest: ${n.join(", ")}`]).concat("Plak geen gegevens uit deze proefversie in je AI-gesprek.").join(" \xB7 "),expired:"Deze proefversie is verlopen. Vraag in je gesprek om een nieuwe.",closed:"Deze proefversie is gesloten.",refreshing:"Nieuwe versie wordt geladen\u2026",wider:"Er is een nieuwe versie die meer gegevens leest.",load:"Laden",elsewhere:"Laad de pagina opnieuw.",reload:"Opnieuw laden"},invalid:{json:(e,n)=>`${e}: ${n} is geen geldige JSON`,number:(e,n)=>`${e}: ${n} is geen geldig getal`,attribute:e=>`${e} mag geen attribuut zijn: geen inline stijl of script`,measure:e=>`"${e}" is geen geldige meting: gebruik count of count/sum/avg/min/max(veld)`,missing:(e,n)=>`${e}: ${n} ontbreekt`,value:(e,n,t)=>`${e}: ${n} "${t}" is geen geldige waarde`,formula:"cube-calc: formula moet een functie zijn",calcSingle:"cube-calc: formula gaf \xE9\xE9n waarde, maar er zijn meer cube-results; geef een object met hun namen",duplicate:(e,n)=>`${e}: name "${n}" komt twee keer voor`,calcAsync:"cube-calc: formula gaf een Promise; geef de uitkomst direct terug, niet async",dateField:e=>`${e}: date-field ontbreekt bij period`,compare:e=>`${e}: compare werkt alleen samen met period`,periodSource:e=>`Geen periodekiezer gevonden voor "${e}"`,periodEnd:e=>`"${e}" is geen geldige einddatum van de periode`,notFilterable:(e,n,t)=>`${e}: ${n} noemt "${t}", maar daarop kan niet gefilterd worden`,selector:(e,n,t)=>`${e}: ${n} "${t}" is geen geldige selector`,lookup:e=>`"${e}" is geen geldige opzoeking: gebruik resource.veld`,dimension:e=>`"${e}" is geen geldige indeling: gebruik veld of veld.day/week/month/quarter/year`},theme:pe};var Ln=["color-primary","color-primary-hover","color-primary-subtle","color-primary-text","color-on-primary","color-accent","color-on-accent","color-text","color-text-muted","color-bg","color-surface","color-border","color-focus","color-danger","color-success","color-warning","color-example-bg","color-example-text","color-series-1","color-series-2","color-series-3","color-series-4","color-series-5","color-series-6","radius","radius-small","font-family"],Fn={primary_colour:"#475467",corners:"normaal",font:"system"},Ae={inter:{family:"Inter",files:[{file:"inter.woff2",weight:"100 900",style:"normal"}]},"albert-sans":{family:"Albert Sans",files:[{file:"albert-sans.woff2",weight:"100 900",style:"normal"}]},"source-sans-3":{family:"Source Sans 3",files:[{file:"source-sans-3.woff2",weight:"200 900",style:"normal"}]},"nunito-sans":{family:"Nunito Sans",files:[{file:"nunito-sans.woff2",weight:"200 1000",style:"normal"}]},"ibm-plex-sans":{family:"IBM Plex Sans",files:[{file:"ibm-plex-sans.woff2",weight:"100 700",style:"normal"}]}},Cn='system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',An="#f6f8fa";function me(e){if(typeof e!="string")return null;let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);if(!n||n[1]===void 0)return null;let t=n[1].toLowerCase();return t.length===3&&(t=[...t].map(o=>o+o).join("")),[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function $t(e){return"#"+e.map(n=>Math.max(0,Math.min(255,n)).toString(16).padStart(2,"0")).join("")}function Rn(e){let[n,t,o]=e.map(a=>{let i=a/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4});return .2126*n+.7152*t+.0722*o}function Re(e,n){let t=me(e),o=me(n);if(!t||!o)return 1;let a=Rn(t),i=Rn(o);return(Math.max(a,i)+.05)/(Math.min(a,i)+.05)}function Ft(e,n,t){let o=me(e),a=me(n);return $t(o.map((i,r)=>Math.round(i*(1-t)+a[r]*t)))}function En(e){return Re(e,"#ffffff")>=Re(e,"#000000")?"#ffffff":"#000000"}function Ko(e,n){let[t,o,a]=me(e).map(k=>k/255),i=Math.max(t,o,a),r=Math.min(t,o,a),s=(i+r)/2,l=i-r,u=0,c=0;l!==0&&(c=l/(1-Math.abs(2*s-1)),i===t?u=(o-a)/l%6:i===o?u=(a-t)/l+2:u=(t-o)/l+4,u*=60),u=((u+n)%360+360)%360;let d=(1-Math.abs(2*s-1))*c,p=d*(1-Math.abs(u/60%2-1)),f=s-d/2,m=Math.floor(u/60)%6,[g,w,v]=[[d,p,0],[p,d,0],[0,d,p],[0,p,d],[p,0,d],[d,0,p]][m];return $t([g,w,v].map(k=>Math.round((k+f)*255)))}function Ot(e){let n=me(e);return n?$t(n):null}function qo(e){let n=[],t=Ot(e.primary_colour);t===null&&(t=Ot(Fn.primary_colour),n.push({code:"invalid-primary",message:pe.invalidPrimary}));let o=null;e.accent_colour!==void 0&&e.accent_colour!==null&&(o=Ot(e.accent_colour),o===null&&n.push({code:"invalid-accent",message:pe.invalidAccent})),o??(o=Ko(t,330)),Re(t,"#ffffff")<3&&n.push({code:"primary-light",message:pe.primaryLight});let a=Ft(t,"#ffffff",.9),i=t;for(let m=0;m<=20&&(i=Ft(t,"#000000",m/20),!(Re(i,An)>=4.5&&Re(i,a)>=4.5));m++);i!==t&&n.push({code:"primary-darkened-for-text",message:pe.primaryDarkened});let r=En(t),s={scherp:["0px","0px"],normaal:["6px","4px"],rond:["12px","8px"]},l=typeof e.corners=="string"&&Object.hasOwn(s,e.corners)?e.corners:"normaal",[u,c]=s[l],d=typeof e.font=="string"&&Object.hasOwn(Ae,e.font)?e.font:"system",p=d==="system"?Cn:`"${Ae[d].family}", ${Cn}`;return{tokens:{"color-primary":t,"color-primary-hover":Ft(t,r==="#ffffff"?"#000000":"#ffffff",.15),"color-primary-subtle":a,"color-primary-text":i,"color-on-primary":r,"color-accent":o,"color-on-accent":En(o),"color-text":"#1f2328","color-text-muted":"#59636e","color-bg":"#ffffff","color-surface":An,"color-border":"#d1d9e0","color-focus":i,"color-danger":"#b42318","color-success":"#067647","color-warning":"#b54708","color-example-bg":"#fef0c7","color-example-text":"#7a2e0e","color-series-1":t,"color-series-2":o,"color-series-3":"#0e9384","color-series-4":"#dc6803","color-series-5":"#7a5af8","color-series-6":"#475467",radius:u,"radius-small":c,"font-family":p},warnings:n}}var Go=/^#[0-9a-f]{6}$/i,Wo=/^\d+(\.\d+)?(px|rem)$/,Qo=/^data:image\/(svg\+xml|png);/,Jo=/[;{}<>\\\u0000-\u001f]|\/\*/,Dn=/["'()\\\s]/,Mn=String.raw`(?:\s*"[^"]*"\s*|\s*'[^']*'\s*|[^"',]+)`,Yo=new RegExp(`^${Mn}(?:,${Mn})*$`);function Ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xo(e,n){return typeof n!="string"?!1:e.startsWith("color-")?Go.test(n):e.startsWith("radius")?Wo.test(n):n.length>0&&n.length<=200&&!Jo.test(n)&&Yo.test(n)}function qe(e,n,t){if(typeof e!="string"||e==="")return null;if(t&&Qo.test(e))return Dn.test(e)?null:e;try{let o=new URL(n),a=new URL(e,o);if((a.protocol==="https:"||a.protocol==="http:")&&a.origin===o.origin&&!Dn.test(a.href))return a.href}catch{}return null}function Zo(e,n){let t=[];for(let o of Array.isArray(e)?e:[]){if(!Ke(o))continue;let a=qe(o.src,n,!1);if(a===null)continue;let i=typeof o.weight=="string"&&/^\d{1,4}( \d{1,4})?$/.test(o.weight)?o.weight:"400";t.push({src:a,weight:i,style:o.style==="italic"?"italic":"normal"})}return t}function ie(e,n){let t=e,o=Fn,a=null,i=null;Ke(t)&&(Object.hasOwn(t,"source")&&Ke(t.source)?(o=t.source,a=Object.hasOwn(t,"tokens")?t.tokens:null,i=Object.hasOwn(t,"font_files")?t.font_files:null):Object.hasOwn(t,"primary_colour")&&(o=t));let{tokens:r,warnings:s}=qo(o);if(Ke(a))for(let c of Ln)Object.hasOwn(a,c)&&Xo(c,a[c])&&(r[c]=a[c]);let l=typeof o.font=="string"&&Object.hasOwn(Ae,o.font)?o.font:null,u=Zo(i,n);return l!==null&&u.length===0&&!Array.isArray(i)&&(u=Ae[l].files.flatMap(c=>{let d=qe("cube-theme/"+c.file,n,!1);return d===null?[]:[{src:d,weight:c.weight,style:c.style}]})),{tokens:r,logo:qe(o.logo,n,!0),logoDark:qe(o.logo_dark,n,!0),fontFamily:l===null?null:Ae[l].family,fontFiles:u,warnings:s}}function On(e){return":where(:root){"+Ln.map(n=>`--cube-${n}:${e.tokens[n]}`).join(";")+"}"}var Ge=null,_t=new Set;function We(){return Ge??(Ge=ie(null,"http://localhost/")),Ge}function Pt(e){Ge=e;for(let n of[..._t])n(e)}function Qe(e){return _t.add(e),()=>{_t.delete(e)}}var _n="cube-trial-config",ei=["dmpUrl","apiUrl","token","expiresAt","statusUrl"],Je=null;function ti(e){let n=e?.getElementById(_n)??null;if(n===null)return null;Je=null,n.remove();let t=null;try{let i=JSON.parse(n.textContent??"");t=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{}if(t?.mode!=="trial"||ei.some(i=>typeof t[i]!="string"||t[i]===""))return console.warn(`#${_n} is not a complete trial config; the app starts without it.`),null;let o=i=>typeof t[i]=="string"?t[i]:null,a=t.leest;return Je={mode:"trial",dmpUrl:t.dmpUrl,apiUrl:t.apiUrl,token:t.token,expiresAt:t.expiresAt,statusUrl:t.statusUrl,version:o("version"),soort:o("soort"),userId:o("userId"),leest:Array.isArray(a)?a.filter(i=>typeof i=="string"):[]},Je}function Ye(){return Je}typeof document<"u"&&ti(document);var $n="1.1.0-rc.2";var R=class extends TypeError{};var ee=["number","integer","currency","percent"],In="nl-NL",ni=["day","week","month","quarter","year"],Xe=/^(\d{4})-(\d{2})-(\d{2})$/,ri=/^\s*-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?\s*$/i,oi=/^(count|sum|avg|min|max)(?:\(([A-Za-z_][A-Za-z0-9_]*)\))?$/,ii=/^([A-Za-z_][A-Za-z0-9_]*)(?:\.([a-z]+))?$/,Pn=new Map,Nn=new Map;function Nt(e){let n=JSON.stringify(e),t=Pn.get(n);return t===void 0&&(t=new Intl.NumberFormat(In,e),Pn.set(n,t)),t}function jt(e){let n=JSON.stringify(e),t=Nn.get(n);return t===void 0&&(t=new Intl.DateTimeFormat(In,e),Nn.set(n,t)),t}function se(e){return typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="bigint"||typeof e=="string"&&ri.test(e)?Number(e):null}function si(e){return e instanceof Date?Number.isNaN(e.getTime())?null:e:typeof e=="number"?Number.isFinite(e)?new Date(e):null:typeof e=="string"?j(e):null}function N(e,n,t={}){if(e==null||e==="")return y.emptyValue;switch(n){case"number":case"integer":case"currency":case"percent":{let o=se(e);if(o===null)return String(e);let a=t.compact===!0?{notation:"compact"}:{};if(n==="currency")return Nt({style:"currency",currency:t.currency??"EUR",...a}).format(o);if(n==="percent")return Nt({style:"percent",maximumFractionDigits:1}).format(o);let i=n==="integer"?0:t.compact===!0?1:2;return Nt({maximumFractionDigits:i,...a}).format(o)}case"date":case"datetime":{let o=si(e);if(o===null)return String(e);let a={day:"numeric",month:"short",year:"numeric"};n==="datetime"&&Object.assign(a,{hour:"2-digit",minute:"2-digit"});let i=typeof e=="string"&&Xe.test(e);return t.timeZone!==void 0&&!i&&(a.timeZone=t.timeZone),jt(a).format(o)}case"boolean":return e===!0||e==="true"||e===1?y.yes:e===!1||e==="false"||e===0?y.no:String(e);default:return Array.isArray(e)?e.map(o=>N(o,"text")).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}}function It(e,n,t={}){switch(n){case"year":return e;case"quarter":{let o=/^(\d{4})-Q([1-4])$/.exec(e);return o?.[1]!==void 0&&o[2]!==void 0?y.quarter(o[2],o[1]):e}case"week":{let o=/^(\d{4})-W(\d{2})$/.exec(e);return o?.[1]!==void 0&&o[2]!==void 0?y.week(Number(o[2]),o[1]):e}case"month":{let o=/^(\d{4})-(\d{2})$/.exec(e);if(o?.[1]===void 0||o[2]===void 0)return e;let a=Hn(Number(o[1]),Number(o[2])-1,1);return jt(t.short===!0?{month:"short"}:{month:"short",year:"numeric"}).format(a)}case"day":{let o=Xe.test(e)?j(e):null;return o===null?e:jt({day:"numeric",month:"short"}).format(o)}default:return e}}function Bn(e){let n=oi.exec(e.trim()),t=n?.[1];if(t===void 0||t!=="count"&&n?.[2]===void 0)throw new R(y.invalid.measure(e));return{fn:t,field:n?.[2]??null}}function Ze(e){let n=ii.exec(e.trim()),t=n?.[1],o=n?.[2];if(t===void 0||o!==void 0&&!ni.includes(o))throw new R(y.invalid.dimension(e));return{field:t,truncation:o??null}}function Un(e,n){if(e?.format==="date")return"date";if(e?.format==="date-time")return"datetime";if(e?.format==="currency")return"currency";switch(e?.type){case"integer":return"integer";case"number":return"number";case"boolean":return"boolean";case"string":return jn(n)??"text"}return typeof n=="boolean"?"boolean":typeof n=="number"?Number.isInteger(n)?"integer":"number":jn(n)??"text"}function jn(e){return typeof e!="string"?null:Xe.test(e)?j(e)===null?null:"date":/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(e)&&!Number.isNaN(Date.parse(e))?"datetime":null}function z(e){let n=e.replace(/_id$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return n===""?e:n.charAt(0).toUpperCase()+n.slice(1)}function j(e){let n=Xe.exec(e);if(n?.[1]!==void 0&&n[2]!==void 0&&n[3]!==void 0){let o=Hn(Number(n[1]),Number(n[2])-1,Number(n[3]));return o.getMonth()===Number(n[2])-1?o:null}let t=Date.parse(e);return Number.isNaN(t)?null:new Date(t)}function Hn(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function I(e){let n=t=>String(t).padStart(2,"0");return`${String(e.getFullYear()).padStart(4,"0")}-${n(e.getMonth()+1)}-${n(e.getDate())}`}var Vn={tekst:"text",getal:"number",bedrag:"currency",datum:"date",keuze:"text","ja/nee":"boolean"},Bt=e=>typeof e=="string"&&e!=="",tt=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),et=(e=[])=>[e].flat().join(",").split(",").map(n=>n.trim());function ai(e){if(typeof e!="object"||e===null)return!1;let n=e,t=n.waarden;return typeof n.resource=="string"&&/^[a-z][a-z0-9_]*$/.test(n.resource)&&(n.veld===void 0||Bt(n.veld))&&typeof n.type=="string"&&tt(Vn,n.type)&&(t===void 0||Array.isArray(t)&&t.every(o=>typeof o=="string"))&&(n.type!=="keuze"||Array.isArray(t)&&t.length>0)&&Bt(n.scherm)&&Bt(n.reden)}function Kn(e){let n=[],t=[];for(let o of Array.isArray(e)?e:e==null?[]:[e])(ai(o)?n:t).push(o);return t.length>0&&console.warn(`cube-app.json ontbreekt: ${t.length} malformed entries ignored`,t),n}function zn(e){return Vn[e]}function nt(e,n){if(e===null)return null;let t=i=>{let r=zn(i);return r==="date"||r==="currency"?r:null},o=n.flatMap(({resource:i,veld:r,type:s,waarden:l,reden:u})=>{if(i!==e.name||r===void 0||e.fields.some(d=>d.name===r))return[];let c=zn(s);return[{name:r,type:c==="boolean"?c:c==="number"||c==="currency"?"number":"string",format:t(s),nullable:!0,readonly:!1,enum:l??null,description:u}]}),a=o.map(i=>i.name);return{...e,fields:[...e.fields.map(i=>n.find(({resource:s,veld:l})=>s===e.name&&l===i.name)?.type==="bedrag"&&i.format==null?{...i,format:"currency"}:i),...o],summary:e.summary.length>0?[...e.summary,...a]:e.summary,filterable:[...e.filterable,...a],sortable:[...e.sortable,...a]}}function li(e){let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619)>>>0;return n}function ui(e,n,t){let{veld:o,type:a,waarden:i}=e,r=li(`${e.resource}.${o}.${String(n)}`);if(o!==void 0){let s=t.filter(l=>tt(l,o)&&l[o]!==void 0);if(s.length>0)return s[r%s.length]?.[o]}switch(a){case"tekst":return`Voorbeeld ${r%100+1}`;case"getal":return r%1e3;case"bedrag":return r%1e5/100;case"datum":return I(new Date(2026,0,1+r%365));case"keuze":return i!==void 0&&i.length>0?i[r%i.length]:null;case"ja/nee":return r%2===0}}function qn(e,n){let t=e?.fields;return Array.isArray(t)?t:t?.[n]}async function Ut(e,n,{filter:t={},sort:o=[]}){let a=[o].flat().join(",").split(",").map(u=>u.replace(/^[-+]/,"")),i=Object.fromEntries([...n.flatMap(Object.keys),...Object.keys(t),...a].filter(u=>u!=="").map(u=>[u,{type:typeof n.find(c=>c[u]!=null)?.[u]}])),r=new Map(n.map(u=>[String(u.id),u])),s=new Z({[e]:{schema:{fields:i},rows:n}}),{data:l}=await s.resource(e).list({filter:t,sort:o,page:{size:200}});return l.map(u=>r.get(String(u.id)))}function Ht(e,n,t,o){let{name:a}=e,i=new Map(n.filter(p=>p.resource===a&&p.veld!==void 0).map(p=>[p.veld,p])),r=p=>i.has(/^[-+]?(?:\w+\()?([^.()]*)/.exec(p)?.[1]??""),s=(p={})=>{let f=qn(p,a),m=f?.filter(k=>!i.has(k)),g=Object.entries(p.filter??{}),w=et(p.sort).filter(k=>k!==""),v=k=>({filter:Object.fromEntries(g.filter(([S])=>i.has(S)===k)),sort:w.filter(S=>r(S)===k)});return{live:{...p,...m&&{fields:m.includes("id")?m:[...m,"id"]},...v(!1)},local:v(!0),shown:k=>f===void 0||f.includes(k)}},l=(p,f,m=!1)=>{for(let[g,w]of i)(m||f(g))&&(!tt(p,g)||p[g]==null)&&(p[g]=ui(w,p.id,o))},u=async(p,{local:f,shown:m})=>{let g=p.data;g.forEach(v=>l(v,m,!0)),g.length>0&&(f.sort.length>0||Object.keys(f.filter).length>0)&&(g=await Ut(a,g,f));for(let v of g)for(let k of i.keys())m(k)||delete v[k];let{meta:w}=p;return{...p,data:g,meta:Object.keys(f.filter).length>0?{...w,page:{...w.page,total:g.length,pages:w.page.number}}:w}},c=async(p,f)=>{let m=s(p);return u(await e.list(m.live,f),m)},d=async function*(p,f){let m=s(p);for await(let g of e.pages(m.live,f))yield await u(g,m)};return{...e,list:c,pages:d,async*all(p,f){for await(let m of d(p,f))yield*m.data},async get(p,f,m){let g=s(f),w=await e.get(p,g.live,m);return l(w.data,g.shown),g.shown("id")||delete w.data.id,w},aggregate:(p,f)=>[et(p.fn).map(m=>m.replace(/^\w+$/,"")),et(p.group),Object.keys(p.filter??{})].flat().some(r)?t.resource(a).aggregate(p):e.aggregate(p,f)}}function Gn(e,n){let t=m=>String(m.id),o=new Map,a=new Map,i=new Set,r=0,s=(m,g)=>({status:m,data:g,meta:null,headers:new Headers,etag:null,recordVersion:null,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}),l=(m,g)=>{let w=qn(g,n);return Object.fromEntries(Object.entries(m).filter(([v])=>w?.includes(v)??!0))},u=async(m,g={})=>{let{page:w}=m.meta,v=o.size>0?await Ut(n,[...o.values()].reverse(),g):[],k=new Set(v.map(t)),S=new Set(a.size>0?(await Ut(n,[...a.values()],g)).map(t):[]),D=new Set(m.data.map(t)),L=m.data.filter(A=>!i.has(t(A))&&(!o.has(t(A))||k.has(t(A)))).map(A=>o.get(t(A))??A),B=v.filter(A=>!S.has(t(A))&&!D.has(t(A))),T=w.total-[...S].filter(A=>!k.has(A)).length+B.length,x=w.number===1?[...B,...L]:L,E=et(g.sort).map(A=>[A.replace(/^[-+]/,""),A.startsWith("-")?-1:1]),O=A=>o.has(t(A))&&(!D.has(t(A))||E.some(([ue])=>a.get(t(A))?.[ue]!==A[ue])),G=x.filter(A=>!O(A));if(E.every(([A])=>G.every(ue=>tt(ue,A)))){for(let A of x.filter(O)){let ue=G.findIndex(Jr=>E.reduce((Yr,[tn,Xr])=>Yr||Xr*H(A[tn],Jr[tn]),0)<0);G.splice(ue>>>0,0,A)}x=G}return{...m,data:x.map(A=>l(A,g)),meta:{...m.meta,page:{...w,total:T}}}},c=async(m,g,w)=>{let v=o.get(String(m));if(i.has(String(m))){let k=`No such ${n} record.`;throw new $(404,new Headers,{status:404,code:"not_found",detail:k})}return v===void 0?e.get(m,g,w):s(200,l(v,g))},d=async m=>{let{data:g}=await c(m);return o.has(String(m))||a.set(String(m),g),g},p=async()=>({...s(202,null),accepted:!0}),f=async function*(m,g){for await(let w of e.pages(m,g))yield await u(w,m)};return{...e,get:c,pages:f,operation:p,collectionOperation:p,list:async(m,g)=>u(await e.list(m,g),m),async*all(m,g){for await(let w of f(m,g))yield*w.data},async create(m){let g={...m,id:`voorbeeld-${++r}`};return o.set(g.id,g),s(201,{...g})},async update(m,g){let w=await d(m),v={...w,...g,id:w.id};return o.set(String(m),v),s(200,{...v})},async delete(m){return await d(m),o.delete(String(m)),i.add(String(m)),s(204,null)}}}var di="./cube-app.config.json",pi="./cube-mock.json",mi="./cube-app.json",fi="./cube-theme.json",gi={id:"preview",name:Lt,scopes:[]},Qn=null,Jn=null,V=null,zt=null,rt=null,Wn=0;function Yn(e={}){let n=V!==null&&V===zt,t=++Wn,o=wi(e,()=>t===Wn);return V=o,zt=null,o.then(()=>{n&&V===o&&yi()},()=>{V===o&&(V=null)}),o}function hi(){return V!==null?V:(rt??(rt=bi().then(()=>{if(rt=null,V!==null)return V;let e=Yn();return zt=e,e})),rt)}function bi(){let e=globalThis;return new Promise(n=>{let t=()=>{setTimeout(n,0)};e.document===void 0||e.document.readyState==="complete"||e.addEventListener===void 0?t():e.addEventListener("load",t,{once:!0})})}function yi(){let e=globalThis.document;if(e===void 0)return;let n=e.defaultView?.CustomEvent??CustomEvent;e.dispatchEvent(new n("cube-session-change"))}async function wi(e,n){let t=e.fetch??globalThis.fetch.bind(globalThis),o=e.pageUrl??rr(),a=Ye(),[i,r]=await Promise.all([a===null?ot(t,Ee(di,o)):null,vi(e,t,o)]);return n()&&Pt(r),a!==null?Ti(a,e,t,o):i===null?ki(e,t,o):Si(Ri(i),e,t,o)}async function vi(e,n,t){try{if(e.theme===!1)return ie(null,t);let o=e.theme??Jn;if(o!==null)return ie(o,t);let a=await ot(n,Ee(fi,t));if(a!==null&&(a.theme!==1||typeof a.source!="object"||a.source===null))throw new TypeError("cube-theme.json is not a theme file.");return ie(a,t)}catch(o){return console.warn(`cube-theme.json could not be used, the neutral theme applies: ${String(o)}`),ie(null,t)}}async function Xn(e,n,t){let o=e.mock??Qn??await ot(n,Ee(pi,t))??{},a=e.manifest===!1?null:e.manifest??await ot(n,Ee(mi,t));return[o,a]}function Zn(e,n){let t=e==="wireframe",o=t?Kn(n?.ontbreekt):[];return{soort:e??null,gaps:o,simulatesWrites:t,isExample:(a,i)=>o.some(r=>r.resource===a&&(r.veld===void 0||r.veld===i))}}function er(e,n){let t=new Map;return e?a=>{let i=t.get(a)??Gn(n(a),a);return t.set(a,i),i}:n}async function ki(e,n,t){let[o,a]=await Xn(e,n,t),i=!0,r=()=>{if(!i)throw new $(401,new Headers({"Content-Type":"application/problem+json"}),{type:"https://docs.cube.nl/dmp-api/problems/token_invalid",title:"token invalid",status:401,code:"token_invalid",detail:"Unauthenticated."})},s=Zn(a?.soort,a),l=new Z(o,a,r),u=new Z(o,null,r),c=d=>s.isExample(d)?u:l;return{...s,mode:"preview",signInError:null,user:()=>i?{...gi}:null,async signIn(){i=!0},async signOut(){i=!1},resource:er(s.simulatesWrites,d=>{let p=c(d),f=p.resource(d),m=p.describe(d)?.fields??[],g=s.gaps.filter(({resource:w,veld:v})=>w===d&&v!==void 0&&!m.some(k=>k.name===v));return g.length>0?Ht(f,g,u,u.rows(d)):f}),schema:async d=>nt(c(d).describe(d),s.gaps)}}async function tr(e,n,t,o){let[a,i]=e==="wireframe"?await Xn(n,t,o):[{},null];return{marked:Zn(e,i),examples:new Z(a)}}function nr(e,{marked:n,examples:t}){let{client:o}=e,a=null;return{...n,mode:e.mode,get signInError(){return e.signInError()},user:e.user,signIn:e.signIn,signOut:e.signOut,resource:er(n.simulatesWrites,i=>n.isExample(i)?t.resource(i):n.gaps.some(r=>r.resource===i)?Ht(o.resources(i),n.gaps,t,t.rows(i)):o.resources(i)),async schema(i){if(n.isExample(i))return nt(t.describe(i),n.gaps);a??(a=o.capabilities());try{let r=(await a).resources.find(s=>s.name===i);return r===void 0?null:nt(Tn(r),n.gaps)}catch(r){throw a=null,r}}}}async function Si(e,n,t,o){let a=e.dmpUrl.replace(/\/+$/,""),i=null,r=Ei(n.tokenStorage==="memory"?je():Di(`cube-app.tokens.${e.clientId}`),d=>{i=d}),s=sn({issuer:e.issuer??a,clientId:e.clientId,redirectUri:Ee(e.redirectUri,o),scopes:e.scopes,fetch:t,tokenStore:r,...e.metadata!==void 0?{metadata:e.metadata}:{}}),l=St({baseUrl:e.apiUrl??`${a}/apps/api/v1`,auth:s,fetch:t}),u=null,c=await tr(e.soort,n,t,o);i=await r.get();try{await s.handleCallback()}catch(d){u=d instanceof Error?d:new Error(String(d))}return i===null&&u===null&&n.autoSignIn===!0&&await s.signIn(),nr({mode:"live",client:l,signInError:()=>u,user:()=>i===null?null:Ci(i),async signIn(){u=null,await s.signIn()},async signOut(){await s.signOut()}},c)}function xi(e){return async(n,t)=>{let o=(t?.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?e(n,t):new Response(JSON.stringify({status:403,code:"insufficient_scope"}),{status:403,headers:{"Content-Type":"application/problem+json"}})}}async function Ti(e,n,t,o){let a=e.token,i=St({baseUrl:e.apiUrl,auth:()=>a,fetch:xi(t)}),r=await tr(e.soort??void 0,n,t,o);return nr({mode:"trial",client:i,signInError:()=>null,user:()=>a===null?null:{id:e.userId,name:null,scopes:["api:read"]},async signIn(){globalThis.location?.reload()},async signOut(){a=null}},r)}function Ci(e){let n=Ai(e.accessToken),t=n?.sub,o=Array.isArray(n?.scopes)?n.scopes.map(String):null;return{id:typeof t=="string"||typeof t=="number"?String(t):null,name:null,scopes:o??(e.scope??"").split(" ").filter(a=>a!=="")}}function Ai(e){let n=e.split(".")[1];if(n===void 0)return null;try{let t=n.replace(/-/g,"+").replace(/_/g,"/"),o=atob(t.padEnd(t.length+(4-t.length%4)%4,"=")),a=new TextDecoder().decode(Uint8Array.from(o,r=>r.charCodeAt(0))),i=JSON.parse(a);return i!==null&&typeof i=="object"?i:null}catch{return null}}function Ri(e){let n=["dmpUrl","clientId","redirectUri"].filter(o=>typeof e[o]!="string"||e[o]===""),t=e.scopes;if(typeof t=="string"||Array.isArray(t)&&t.every(o=>typeof o=="string")||n.push("scopes"),n.length>0)throw new TypeError(`cube-app.config.json is incomplete: ${n.join(", ")} missing or not a string.`);return e}async function ot(e,n){let t;try{t=await e(n,{headers:{Accept:"application/json"},...typeof document<"u"?{cache:"no-store"}:{}})}catch{return null}if(t.status===404||t.status===410)return null;if(!t.ok)throw new Error(`${n} answered ${t.status}.`);try{let o=JSON.parse(await t.text());return o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{return null}}function Ei(e,n){return{async get(){let t=await e.get();return n(t),t},async set(t){await e.set(t),n(t)}}}function Di(e){let n=(()=>{try{return globalThis.sessionStorage??null}catch{return null}})();return n===null?je():{get(){try{let t=n.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}},set(t){try{t===null?n.removeItem(e):n.setItem(e,JSON.stringify(t))}catch{}}}}function rr(){let e=globalThis;return e.document?.baseURI??e.location?.href??"http://localhost/"}function Ee(e,n){return new URL(e,n).href}function Mi(e){Qn=e}function Li(e){Jn=e,Pt(ie(e,rr()))}var it=Object.freeze({connect:Yn,ready:hi,mock:Mi,theme:Li,version:$n,sdk:"1"});var or={"cube-state":["kind","message","retry"],"cube-app-shell":["name","logo","logo-alt"],"cube-page":["name","label"],"cube-field":["name","label","format","multiline","options","hidden"],"cube-period-picker":["default","label","today"],"cube-kpi":["resource","measure","label","format","currency","filter","period","date-field","compare"],"cube-chart":["resource","measure","by","kind","label","format","currency","filter","period","date-field","lookup","height","limit"],"cube-top":["resource","measure","by","limit","order","label","format","currency","filter","period","date-field","lookup"],"cube-table":["resource","fields","search","filters","sort","page-size","export","detail","filter","period","date-field"],"cube-detail":["resource","record-id","fields","editable"],"cube-form":["resource","fields","submit-label","success-text"],"cube-calc":["label"],"cube-input":["name","label","type","value","min","max","step","options"],"cube-result":["name","label","format","currency","emphasis"],"cube-board":["resource","status-field","title-field","fields","sort","filter","page-size"],"cube-column":["value","label"],"cube-gap-list":["scherm"]};var Fi="http://www.w3.org/2000/svg";function h(e,n,t={},...o){let a=e.createElement(n);for(let[i,r]of Object.entries(t))ir(i,r===!0||typeof r=="string"),typeof r=="function"?a.addEventListener(i.replace(/^on/,""),r):r===!0?a.setAttribute(i,""):typeof r=="string"&&a.setAttribute(i,r);return sr(e,a,o),a}function U(e,n,t={},...o){let a=e.createElementNS(Fi,n);for(let[i,r]of Object.entries(t))ir(i,!0),a.setAttribute(i,String(r));return sr(e,a,o),a}function ir(e,n){let t=e.toLowerCase();if(t==="style"||n&&t.startsWith("on"))throw new R(y.invalid.attribute(e))}function C(e){for(;e.firstChild!==null;)e.removeChild(e.firstChild)}function sr(e,n,t){for(let o of t)typeof o=="string"?n.appendChild(e.createTextNode(o)):o!=null&&o!==!1&&n.appendChild(o)}var De=`
|
|
1
|
+
/*! @cube-nl/dmp-sdk 1.1.0-rc.3 cube-sdk.js (window.CubeApp) | MIT */
|
|
2
|
+
"use strict";(()=>{var to=Object.defineProperty;var no=(e,n,t)=>n in e?to(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var b=(e,n,t)=>no(e,typeof n!="symbol"?n+"":n,t);var P=class extends Error{constructor(t,o,a){let i=a!==null&&typeof a=="object"?a:{},r=oe(i.detail)??oe(i.error_description);super(r??`HTTP ${t}`);b(this,"status");b(this,"code");b(this,"reason");b(this,"type");b(this,"title");b(this,"detail");b(this,"errors");b(this,"retryAfter");b(this,"recordVersion");b(this,"allow");b(this,"headers");b(this,"body");this.name="DmpError",this.status=t,this.code=oe(i.code)??oe(i.error),this.reason=oe(i.reason),this.type=oe(i.type),this.title=oe(i.title),this.detail=r,this.errors=ro(i.errors)?i.errors:null,this.retryAfter=oo(o.get("Retry-After")),this.recordVersion=o.get("X-Dmp-Record-Version"),this.allow=o.has("Allow")?(o.get("Allow")??"").split(",").map(s=>s.trim()).filter(s=>s!==""):null,this.headers=o,this.body=a}get isProblem(){return this.code!==null}};function N(e){return e instanceof P}function oe(e){return typeof e=="string"?e:null}function ro(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function oo(e){if(e===null||e.trim()==="")return null;let n=Number(e);if(Number.isFinite(n))return n;let t=Date.parse(e);return Number.isNaN(t)?null:Math.max(0,Math.ceil((t-Date.now())/1e3))}function on(e){return{async getAccessToken(){let n=typeof e=="function"?await e():e;return n===void 0||n===""?null:n}}}var Ne="cube-dmp-sdk.pending-login";function sn(e){let n=e.fetch??globalThis.fetch.bind(globalThis),t=e.tokenStore??je(),o=e.pendingStore??lo(),a=(e.refreshLeewaySeconds??30)*1e3,i=typeof e.scopes=="string"?e.scopes:e.scopes.join(" "),r=e.metadata??{},s=io(r)?Promise.resolve({...r,issuer:r.issuer??e.issuer}):null,l=null,u=()=>(s??(s=so(e.issuer,n).then(f=>({...f,...r}),f=>{throw s=null,f})),s),c=async(f,d)=>{let{token_endpoint:g}=await u(),w=new URLSearchParams(f);e.clientSecret!==void 0&&w.set("client_secret",e.clientSecret);let v=await n(g,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:w.toString()}),k=await an(v);if(!v.ok||k===null||typeof k!="object"||typeof k.access_token!="string")throw new P(v.status,v.headers,k);let S={accessToken:k.access_token,refreshToken:typeof k.refresh_token=="string"?k.refresh_token:null,expiresAt:typeof k.expires_in=="number"?Date.now()+k.expires_in*1e3:null,scope:typeof k.scope=="string"?k.scope:d};return await t.set(S),S},p=()=>(l??(l=(async()=>{let f=await t.get();if(f?.refreshToken==null)throw new TypeError("No refresh token: sign in again.");try{return await c({grant_type:"refresh_token",refresh_token:f.refreshToken,client_id:e.clientId},f.scope)}catch(d){throw d instanceof P&&d.status>=400&&d.status<500&&await t.set(null),d}})().finally(()=>{l=null})),l),m=async(f={})=>{let d=await u();if(!(d.code_challenge_methods_supported??[]).includes("S256"))throw new TypeError("The authorization server does not offer PKCE S256; this SDK will not sign in without it.");let g=rn(64),w=f.state??rn(32),v=ln(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(g))),k={verifier:g,state:w,redirectUri:e.redirectUri,clientId:e.clientId};o.setItem(Ne,JSON.stringify(k));let S=new URL(d.authorization_endpoint);return S.search=new URLSearchParams({...f.extraParams,response_type:"code",client_id:e.clientId,redirect_uri:e.redirectUri,scope:i,state:w,code_challenge:v,code_challenge_method:"S256"}).toString(),S.toString()};return{discover:u,authorizationUrl:m,async signIn(f={}){let d=nn();if(d===null)throw new TypeError("signIn() needs a browser; use authorizationUrl() and redirect yourself.");d.assign(await m(f))},async handleCallback(f){let d=f??nn()?.href;if(d===void 0)throw new TypeError("handleCallback() needs the callback URL outside a browser.");let g=new URL(d),w=new URLSearchParams(g.search);if(!uo(g,e.redirectUri)||!w.has("code")&&!w.has("error"))return null;if(f===void 0){for(let k of["code","state","error","error_description","iss"])g.searchParams.delete(k);globalThis.history?.replaceState(null,"",g.pathname+g.search+g.hash)}let v=co(o.getItem(Ne));if(v===null||w.get("state")!==v.state)throw new TypeError("The state does not match: this callback does not belong to a sign-in started here.");if(o.removeItem(Ne),w.has("error"))throw new P(400,new Headers,{error:w.get("error")??"access_denied",error_description:w.get("error_description")??void 0});return c({grant_type:"authorization_code",code:w.get("code")??"",redirect_uri:v.redirectUri,client_id:v.clientId,code_verifier:v.verifier},i)},refresh:p,async getTokens(){return t.get()},async setTokens(f){await t.set(f)},async signOut(){await t.set(null),o.removeItem(Ne)},async getAccessToken(){let f=await t.get();if(f===null)return null;if(f.expiresAt!==null&&f.expiresAt-a<=Date.now()&&f.refreshToken!==null)try{return(await p()).accessToken}catch{return(await t.get())?.accessToken??null}return f.accessToken},async onUnauthorized(){if((await t.get())?.refreshToken==null)return!1;try{return await p(),!0}catch{return!1}}}}function io(e){return typeof e.authorization_endpoint=="string"&&typeof e.token_endpoint=="string"}async function so(e,n=globalThis.fetch.bind(globalThis)){let t=`${e.replace(/\/+$/,"")}/.well-known/oauth-authorization-server`,o=await n(t,{headers:{Accept:"application/json"}}),a=await an(o);if(!o.ok||a===null||typeof a!="object")throw new P(o.status,o.headers,a);return a}function je(e=null){let n=e;return{get:()=>n,set:t=>{n=t}}}function ao(){let e=new Map;return{getItem:n=>e.get(n)??null,setItem:(n,t)=>{e.set(n,t)},removeItem:n=>{e.delete(n)}}}function lo(){try{let e=globalThis.sessionStorage;if(e!==void 0)return e}catch{}return ao()}function nn(){let e=globalThis.location;return e!==void 0&&typeof e.assign=="function"?e:null}function uo(e,n){let t=new URL(n),o=a=>a.replace(/\/+$/,"")||"/";return e.origin===t.origin&&o(e.pathname)===o(t.pathname)}function co(e){if(e===null)return null;try{let n=JSON.parse(e);return typeof n.verifier=="string"&&typeof n.state=="string"&&typeof n.redirectUri=="string"&&typeof n.clientId=="string"?n:null}catch{return null}}async function an(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function rn(e){return ln(crypto.getRandomValues(new Uint8Array(e)))}function ln(e){let n=e instanceof Uint8Array?e:new Uint8Array(e),t="";for(let o of n)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var po=new Set(["in","between"]);function ie(e,n={}){let t=new URLSearchParams;mo(t,e,n.fields),fo(t,n.filter),xe(t,"sort",n.sort),xe(t,"include",n.include),xe(t,"with_count",n.withCount),ho(t,n.has),xe(t,"fn",n.fn),xe(t,"group",n.group),n.page?.size!==void 0&&t.append("page[size]",String(n.page.size)),n.page?.number!==void 0&&t.append("page[number]",String(n.page.number));for(let[o,a]of Object.entries(n.params??{}))t.append(o,a);return t.toString().replace(/%5B/gi,"[").replace(/%5D/gi,"]").replace(/%2C/gi,",").replace(/%28/gi,"(").replace(/%29/gi,")")}function mo(e,n,t){if(t===void 0)return;let o=bo(t)?{[n]:t}:t;for(let[a,i]of Object.entries(o))i.length>0&&e.append(`fields[${a}]`,i.join(","))}function fo(e,n){for(let[t,o]of Object.entries(n??{})){if(Array.isArray(o))throw new TypeError(`filter.${t}: a bare list names no operator and cube/api refuses it. Write { in: [...] } (or { between: [from, to] }).`);if(o==null)throw new TypeError(`filter.${t}: write { is: 'null' } or { is: 'not_null' } to filter on null.`);if(typeof o!="object"){e.append(`filter[${t}]`,vt(o));continue}for(let[a,i]of Object.entries(o))i!==void 0&&e.append(`filter[${t}][${a}]`,go(t,a,i))}}function go(e,n,t){if(t===null){if(n!=="is")throw new TypeError(`filter.${e}.${n}: null is only meaningful under 'is'.`);return"null"}if(Array.isArray(t)){if(!po.has(n))throw new TypeError(`filter.${e}.${n}: takes one value; only 'in' and 'between' take a list.`);return t.map(vt).join(",")}return vt(t)}function ho(e,n){for(let[t,o]of Object.entries(n??{}))o===!0?e.append(`has[${t}]`,"1"):typeof o=="number"?e.append(`has[${t}][min]`,String(o)):(o.min!==void 0&&e.append(`has[${t}][min]`,String(o.min)),o.max!==void 0&&e.append(`has[${t}][max]`,String(o.max)))}function xe(e,n,t){if(t===void 0)return;let o=typeof t=="string"?t:t.filter(a=>a!=="").join(",");o!==""&&e.append(n,o)}function vt(e){return typeof e=="boolean"?e?"1":"0":String(e)}function bo(e){return Array.isArray(e)}var yo=/^[a-z][a-z0-9_]*$/;function St(e){let n=e.baseUrl.replace(/\/+$/,""),t=e.fetch??globalThis.fetch.bind(globalThis),o=e.auth===void 0?null:typeof e.auth=="string"||typeof e.auth=="function"?on(e.auth):e.auth,a=e.cache??(typeof document<"u"?"no-cache":void 0),i=async(s,l,{query:u,body:c,headers:p={},signal:m}={})=>{let f=`${n}${l.startsWith("/")?l:`/${l}`}${u?`?${u}`:""}`,d=async()=>{let k=o===null?null:await o.getAccessToken(),S={method:s,headers:{Accept:"application/json",...e.headers,...k!==null?{Authorization:`Bearer ${k}`}:{},...c!==void 0?{"Content-Type":"application/json"}:{},...p}};c!==void 0&&(S.body=JSON.stringify(c)),a!==void 0&&(S.cache=a),m!==void 0&&(S.signal=m);let R=Date.now(),L=await t(f,S);return e.onResponse?.({method:s,url:f,status:L.status,ms:Date.now()-R}),L},g=await d();g.status===401&&o?.onUnauthorized!==void 0&&await o.onUnauthorized()&&(await g.body?.cancel().catch(()=>{}),g=await d());let w=await vo(g);if(!g.ok)throw new P(g.status,g.headers,w);let v=ko(w)?w:null;return{status:g.status,data:v!==null?v.data:w,meta:v?.meta??null,headers:g.headers,etag:g.headers.get("ETag"),recordVersion:g.headers.get("X-Dmp-Record-Version"),location:g.headers.get("Location"),replayed:g.headers.get("Idempotency-Replayed")==="true",rateLimit:So(g.headers)}};return{async capabilities(s={}){let l=(await i("GET","/_capabilities",Be({},s))).data;return{...l,resources:l.resources.map(wo)}},resources:s=>{if(!yo.test(s))throw new TypeError(`'${s}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let l=`/${s}`,u=d=>{let g=String(d);if(g==="")throw new TypeError(`${s}: an empty id would address the collection, not a record.`);if(dn(g))throw new TypeError(`${s}: '${g}' is not an id: it would address another path, not a record.`);return`${l}/${encodeURIComponent(g)}`},c=d=>d===void 0?"":ie(s,{fields:d}),p=async(d={},g={})=>await i("GET",l,Be({query:ie(s,d)},g)),m=async function*(d={},g={}){let w=d.page?.number??1;for(;;){let v=await p({...d,page:{...d.page,number:w}},g);yield v;let k=v.meta.page;if(k==null||k.number>=k.pages||v.data.length===0)return;w=k.number+1}},f=async(d,g,w)=>{let v=await i("POST",d,{query:c(w.fields),body:g??{},headers:Ie(w)});return{...v,data:v.status===204?null:v.data,accepted:v.status===202}};return{name:s,list:p,pages:m,async*all(d={},g={}){for await(let w of m(d,g))yield*w.data},get:(d,g={},w={})=>i("GET",u(d),Be({query:ie(s,g)},w)),aggregate:(d,g={})=>i("GET",`${l}/_aggregate`,Be({query:ie(s,d)},g)),create:(d,g={})=>i("POST",l,{query:c(g.fields),body:d,headers:Ie(g)}),update:(d,g,w={})=>i("PATCH",u(d),{query:c(w.fields),body:g,headers:Ie(w)}),delete:async(d,g={})=>({...await i("DELETE",u(d),{headers:Ie(g)}),data:null}),operation:(d,g,w,v={})=>f(`${u(d)}/${encodeURIComponent(un(g))}`,w,v),collectionOperation:(d,g,w={})=>f(`${l}/_operations/${encodeURIComponent(un(d))}`,g,w)}},request:i}}function wo(e){return{...e,operations:(e.operations??[]).map(n=>({...n,input:kt(n.input)})),aggregatable:kt(e.aggregatable),relations:kt(e.relations)}}function kt(e){return Array.isArray(e)||e===void 0||e===null?{}:e}function cn(){return crypto.randomUUID()}function un(e){if(e===""||e.startsWith("_"))throw new TypeError(`'${e}' is not an operation name: the '_' namespace is reserved by the API.`);if(dn(e))throw new TypeError(`'${e}' is not an operation name: it would address another path.`);return e}function dn(e){return e==="."||e===".."}function Ie(e){let n={};if(e.idempotencyKey!==void 0&&(n["Idempotency-Key"]=e.idempotencyKey),e.ifMatch!==void 0){if(e.ifMatch.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");n["If-Match"]=e.ifMatch}return n}function Be(e,n){return n.signal===void 0?e:{...e,signal:n.signal}}async function vo(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function ko(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"data"in e}function So(e){let n=t=>{let o=e.get(t);return o===null||o===""||!Number.isFinite(Number(o))?null:Number(o)};return{limit:n("X-RateLimit-Limit"),remaining:n("X-RateLimit-Remaining"),reset:n("X-RateLimit-Reset")}}var pn=/^[a-z][a-z0-9_]*$/,mn=["eq","neq","gt","gte","lt","lte","in","like","ilike","is","between"],xo=[[">=","gte"],["<=","lte"],["<>","neq"],[">","gt"],["<","lt"],["=","eq"]],Et=["count","sum","avg","min","max"],fn=["day","week","month","quarter","year"],xt=20,Tt=5,gn=1e3,Ct=200,To=50,At=200,Co="1.0",te=class{constructor(n,t=null,o=()=>{}){b(this,"manifest",t);b(this,"guard",o);b(this,"tables",new Map);for(let[a,i]of Object.entries(Ao(n))){if(typeof i!="object"||i===null||Array.isArray(i))continue;let r=typeof i.schema?.name=="string"&&i.schema.name!==""?i.schema.name:a;pn.test(r)&&this.tables.set(r,Ro(r,i))}}rows(n){return this.tables.get(n)?.rows??[]}resourceNames(){return[...this.tables.keys()]}describe(n){let t=this.tables.get(n);return t===void 0?null:{name:n,actions:[...t.actions],fields:[...t.fields.values()].map(o=>{let a=t.choices.get(o.name);return{name:o.name,type:o.types.join("|"),format:o.format,nullable:o.nullable,readonly:!t.writable.has(o.name),enum:a===void 0?null:a.map(String),description:o.description}}),summary:[...t.summary],filterable:[...t.filterable],sortable:[...t.fields.keys()],groupable:[...t.groupable],aggregatable:Object.fromEntries([...t.aggregatable].map(([o,a])=>[o,a.filter(i=>i!=="count")]))}}resource(n){if(!pn.test(n))throw new TypeError(`'${n}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let t=(i,r)=>Promise.resolve().then(()=>r(this.authorize(n,i))),o=(i={})=>t("list",r=>Do(r,i)),a=async function*(i={}){let r=i.page?.number??1;for(;;){let s=await o({...i,page:{...i.page,number:r}});if(yield s,s.meta.page.number>=s.meta.page.pages||s.data.length===0)return;r=s.meta.page.number+1}};return{name:n,list:o,pages:a,async*all(i={}){for await(let r of a(i))yield*r.data},get:(i,r={})=>t("get",s=>Mo(s,i,r)),aggregate:i=>t("aggregate",r=>Po(r,i)),create:(i,r={})=>t("create",s=>Bo(s,i,r)),update:(i,r,s={})=>t("update",l=>Uo(l,i,r,s)),delete:(i,r={})=>t("delete",s=>Ho(s,i,r)),operation:(i,r,s,l)=>t("get",u=>{throw He(u,i),yn(r)}),collectionOperation:i=>t("list",()=>{throw yn(i)})}}authorize(n,t){this.guard();let o=this.tables.get(n);if(o===void 0)throw M(404,"not_found",`Unknown API resource [${n}].`);let a=this.manifest?.uses;if(a!==void 0&&!(a[n]??[]).includes(t))throw M(403,"client_scope_exceeded",`This app may not ${t} '${n}': add it to "uses" in cube-app.json.`);return o}};function Ao(e){let n=e.resources;return Object.keys(e).length===1&&Te(n)&&!("rows"in n)&&!("schema"in n)?n:e}function Ro(e,n){let t=n.schema??{},o=(n.rows??[]).map(p=>Mt(p)),a=new Map,i=Array.isArray(t.fields)?t.fields.map(p=>[p.name,p]):Object.entries(t.fields??{});for(let[p,m]of i)a.set(p,Eo(p,m));for(let p of a.size===0?o:[])for(let m of Object.keys(p))a.has(m)||a.set(m,{name:m,types:[],nullable:!0,format:null,description:null});let r=[...a.keys()],s=(Te(t.choices)?Object.entries(t.choices):[]).filter(p=>Te(p[1])&&Array.isArray(p[1].values)),l=new Set(["id",...t.readonly??[],...i.filter(([,p])=>p.readonly===!0).map(([p])=>p),...s.filter(([,p])=>p.writable===!1).map(([p])=>p)]),u=new Map;for(let[p,m]of i)Array.isArray(m.enum)&&u.set(p,m.enum);for(let[p,m]of s)u.set(p,m.values);let c=p=>Array.isArray(p)?p.filter(m=>typeof m=="string"&&a.has(m)):null;return{name:e,actions:Array.isArray(t.actions)?t.actions.filter(p=>typeof p=="string"):["list","get","create","update","delete"],fields:a,filterable:c(t.filters)??r,groupable:c(t.groupable)??r,aggregatable:new Map(Te(t.aggregatable)?Object.entries(t.aggregatable).filter(([p,m])=>a.has(p)&&Array.isArray(m)).map(([p,m])=>[p,[...m]]):r.map(p=>[p,[...Et]])),choices:u,writable:new Set(r.filter(p=>!l.has(p))),summary:(c(t.summary_fields)??[]).length>0?c(t.summary_fields):r,rows:o,versions:new Map(o.map(p=>[Q(p.id),1])),replays:new Map}}function Eo(e,n){let t=n.type,o=typeof t=="string"?t.split("|"):Array.isArray(t)?[...t]:[];return{name:e,types:o.filter(a=>a!=="null"&&a!==""),nullable:n.nullable===!0||o.includes("null"),format:typeof n.format=="string"?n.format:null,description:typeof n.description=="string"?n.description:null}}function Ce(e,n){return new URLSearchParams(ie(e.name,n))}function Do(e,n){let t=Ce(e,n),o=Ue(e,t),a=vn(e,t),i=Oo(e,t),{size:r,number:s}=$o(t),l=wn(e,t),u=e.rows.filter(f=>a.every(d=>kn(e,f,d)));i.length>0&&(u=[...u].sort((f,d)=>{for(let{field:g,descending:w}of i){let v=V(f[g],d[g]);if(v!==0)return w?-v:v}return 0}));let c=u.length,p=u.slice((s-1)*r,s*r).map(f=>ze(f,o)),m={size:r,number:s,total:c,pages:Math.max(1,Math.ceil(c/r))};return{...de(200,p,ce(e,m,l)),meta:{...ce(e,m,l),page:m}}}function Mo(e,n,t){let o=Ce(e,t),a=Ue(e,o),i=wn(e,o),r=He(e,n);return de(200,ze(r,a),ce(e,null,i),Ve(e,r))}function Ue(e,n){let t=`fields[${e.name}]`,o=n.get(t);if(o===null||o==="")return e.summary;let a=o.split(",").map(r=>r.trim()),i=a.filter(r=>!e.fields.has(r));if(i.length>0)throw M(422,"query_invalid",`Unknown ${t}: ${i.join(", ")}.`,{[t]:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]});return a}function wn(e,n){let t=o=>(n.get(o)??"").split(",").filter(a=>a!=="");return[...new Set([...t("include"),...t("with_count")])]}function vn(e,n){let t=[],o=[];n.forEach((a,i)=>o.push([i,a]));for(let[a,i]of o){let r=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/.exec(a);if(r===null)continue;let s=r[1];if(!e.filterable.includes(s))throw M(422,"query_invalid",`Unknown filter: ${s}.`,{filter:[`Allowed values: ${e.filterable.join(", ")}.`]},"not_filterable");t.push(r[2]===void 0?Lo(s,i):Fo(s,r[2],i))}if(t.length>xt)throw M(422,"query_invalid",`A query takes at most ${xt} filters.`,{filter:[`Sent ${t.length}; the limit is ${xt}.`]});return t}function Lo(e,n){for(let[t,o]of xo)if(n.startsWith(t))return{field:e,operator:o,value:n.slice(t.length)};return{field:e,operator:"eq",value:n}}function Fo(e,n,t){if(!mn.includes(n))throw M(422,"query_invalid",`Unknown filter operator: ${n}.`,{filter:[`Allowed operators: ${mn.join(", ")}.`]});if(n==="between"&&t.split(",").length!==2)throw M(422,"query_invalid",`filter[${e}][between] takes exactly 2 values.`,{filter:[`Write filter[${e}][between]=low,high. Received ${t.split(",").length} value(s).`]});if(n==="in"&&t.split(",").length>Ct)throw M(422,"query_invalid",`filter[${e}][in] takes at most ${Ct} values.`,{filter:[`Sent ${t.split(",").length}; the limit is ${Ct}.`]});if(n==="is"&&t!=="null"&&t!=="not_null")throw M(422,"query_invalid",`filter[${e}][is] takes null or not_null.`,{filter:[`Received: ${t}.`]});return{field:e,operator:n,value:t}}function kn(e,n,t){let o=n[t.field],a=i=>qo(e.fields.get(t.field),i.trim());switch(t.operator){case"eq":return Rt(o,a(t.value));case"neq":return o!=null&&!Rt(o,a(t.value));case"gt":return o!=null&&V(o,a(t.value))>0;case"gte":return o!=null&&V(o,a(t.value))>=0;case"lt":return o!=null&&V(o,a(t.value))<0;case"lte":return o!=null&&V(o,a(t.value))<=0;case"in":return t.value.split(",").some(i=>Rt(o,a(i)));case"between":{let[i,r]=t.value.split(",").map(a);return o!=null&&V(o,i)>=0&&V(o,r)<=0}case"like":case"ilike":return typeof o=="string"&&_o(o,t.value);case"is":return t.value==="null"?o==null:o!=null;default:return!1}}function _o(e,n){let t=n.split("%").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(t,"iu").test(e)}function Oo(e,n){let t=n.get("sort");if(t===null||t==="")return[];let o=t.split(",").map(i=>i.trim()).filter(i=>i!=="").map(i=>({field:i.replace(/^[-+]/,""),descending:i.startsWith("-")})),a=o.map(i=>i.field).filter(i=>!e.fields.has(i));if(a.length>0)throw M(422,"query_invalid",`Unknown sort: ${a.join(", ")}.`,{sort:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]},"not_sortable");return o}function $o(e){let n=o=>{let a=e.get(o);if(a===null||a==="")return null;if(!/^\d+$/.test(a))throw M(422,"query_invalid",`${o} must be a positive integer.`,{[o]:["Expected a positive integer."]});return Number(a)},t=n("page[size]")??To;if(t>At)throw M(422,"cardinality_exceeded",`page[size] may not exceed ${At}.`,{"page.size":[`The maximum page size is ${At}.`]});return{size:Math.max(1,t),number:Math.max(1,n("page[number]")??1)}}function Po(e,n){let t=Ce(e,n),o=(t.get("fn")??"").trim();if(o==="")throw M(422,"query_invalid","fn is required: name at least one aggregation function.",{fn:[`Expected e.g. fn=count or fn=sum(field). ${Dt(e)}`]});let a=o.split(",").map(f=>f.trim()),i=a.map(f=>No(e,f));hn(a,"fn");let r=(t.get("group")??"").trim(),s=r===""?[]:r.split(",").map(f=>f.trim());if(s.length>Tt)throw M(422,"cardinality_exceeded",`group may not exceed ${Tt} dimensions, ${s.length} given.`,{group:[`Use at most ${Tt} dimensions.`]});let l=s.map(f=>jo(e,f));hn(s,"group");let u=vn(e,t),c=new Map;for(let f of e.rows.filter(d=>u.every(g=>kn(e,d,g)))){let d={};for(let[v,k]of s.entries())d[k]=l[v](f);let g=JSON.stringify(Object.values(d)),w=c.get(g)??{key:d,rows:[]};w.rows.push(f),c.set(g,w)}if(s.length===0&&c.size===0&&c.set("[]",{key:{},rows:[]}),c.size>gn)throw M(422,"cardinality_exceeded","The grouping produces more groups than the configured maximum.",{groepen:["The grouping produces more groups than the configured maximum.",`Allowed values: groepeer grover, of filter eerst; maximaal ${gn} groepen.`]},"too_many_groups");let m=[...c.values()].sort((f,d)=>{for(let g of s){let w=V(f.key[g],d.key[g]);if(w!==0)return w}return 0}).map(({key:f,rows:d})=>{let g={...f};for(let[w,v]of a.entries())g[v]=i[w](d);return g});return de(200,m,{...ce(e,null,[]),groups:m.length})}function hn(e,n){let t=[...new Set(e.filter((o,a)=>e.indexOf(o)!==a))];if(t.length>0)throw M(422,"query_invalid",`Duplicate ${n} entry: ${t.join(", ")}.`,{[n]:[`List each ${n} entry once.`]})}function Dt(e){return e.aggregatable.size===0?"This resource has no aggregatable fields; only bare count is available.":`Aggregatable fields: ${[...e.aggregatable.keys()].join(", ")}.`}function No(e,n){let t=/^([a-z]+)\(([a-z0-9_]+)\)$/.exec(n);if(t===null&&!/^[a-z]+$/.test(n))throw M(422,"query_invalid",`Unparseable fn entry: ${n}.`,{fn:["Expected `count` or `function(field)`, e.g. sum(field)."]});let o=t===null?n:t[1],a=t===null?null:t[2];if(!Et.includes(o))throw M(422,"query_invalid",`Unknown aggregation function: ${o}.`,{fn:[`Allowed values: ${Et.join(", ")}.`]});if(a===null){if(o!=="count")throw M(422,"query_invalid",`${o} must be applied to a field, e.g. ${o}(field).`,{fn:[Dt(e)]});return r=>r.length}let i=e.aggregatable.get(a);if(i===void 0)throw M(422,"query_invalid",`Unknown aggregatable field: ${a}.`,{fn:[Dt(e)]});if(!i.includes(o))throw M(422,"query_invalid",`${o} is not allowed on ${a}.`,{fn:[`Allowed functions for ${a}: ${i.join(", ")}.`]});return r=>{let s=r.map(u=>u[a]).filter(u=>u!=null),l=s.map(Number).filter(u=>Number.isFinite(u));switch(o){case"count":return r.length;case"sum":return l.length===0?null:l.reduce((u,c)=>u+c,0);case"avg":return l.length===0?null:l.reduce((u,c)=>u+c,0)/l.length;case"min":return s.length===0?null:s.reduce((u,c)=>V(c,u)<0?c:u);default:return s.length===0?null:s.reduce((u,c)=>V(c,u)>0?c:u)}}}function jo(e,n){let t=n.split(".");if(t.length>2)throw M(422,"query_invalid",`Unparseable group entry: ${n}.`,{group:["Expected `field` or `field.unit`, e.g. published_at.month."]});let[o,a]=t;if(!e.groupable.includes(o))throw M(422,"query_invalid",`Unknown group: ${o}.`,{group:[`Allowed values: ${e.groupable.join(", ")}.`]},"not_groupable");if(a===void 0)return i=>i[o]??null;if(!fn.includes(a))throw M(422,"query_invalid",`Unknown truncation unit: ${a}.`,{group:[`Allowed values: ${fn.join(", ")}.`]});return i=>Io(i[o],a)}function Io(e,n){let t=typeof e=="string"?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null;if(t===null)return null;let[o,a,i]=[Number(t[1]),Number(t[2]),Number(t[3])],r=new Date(Date.UTC(o,a-1,i));if(r.getUTCFullYear()!==o||r.getUTCMonth()!==a-1||r.getUTCDate()!==i)return null;switch(n){case"day":return t[0];case"week":{let s=new Date(r.getTime()+(3-(r.getUTCDay()+6)%7)*864e5),l=s.getUTCFullYear(),u=1+Math.floor((s.getTime()-Date.UTC(l,0,1))/(7*864e5));return`${l}-W${String(u).padStart(2,"0")}`}case"month":return t[0].slice(0,7);case"quarter":return`${t[1]}-Q${Math.ceil(a/3)}`;case"year":return t[1];default:return null}}function Bo(e,n,t){let o=t.fields===void 0?e.summary:Ue(e,Ce(e,{fields:t.fields})),a=JSON.stringify([n,t.fields??null]);if(t.idempotencyKey!==void 0){let l=e.replays.get(t.idempotencyKey);if(l!==void 0){if(l.body!==a)throw M(422,"validation_failed","This Idempotency-Key was already used with a different request body. Use a new key, or resend the original body.");return{...l.response,replayed:!0}}}let i=Sn(e,n),r={id:Ko(e),...i};for(let l of e.fields.keys())l in r||(r[l]=null);e.rows.push(r),e.versions.set(Q(r.id),1);let s=de(201,ze(r,o),ce(e,null,[]),Ve(e,r));return t.idempotencyKey!==void 0&&e.replays.set(t.idempotencyKey,{body:a,response:s}),s}function Uo(e,n,t,o){let a=o.fields===void 0?e.summary:Ue(e,Ce(e,{fields:o.fields})),i=He(e,n);return xn(e,i,o.ifMatch),Object.assign(i,Sn(e,t)),e.versions.set(Q(i.id),(e.versions.get(Q(i.id))??1)+1),de(200,ze(i,a),ce(e,null,[]),Ve(e,i))}function Ho(e,n,t){let o=He(e,n);return xn(e,o,t.ifMatch),e.rows.splice(e.rows.indexOf(o),1),e.versions.delete(Q(o.id)),de(204,null,null)}function Sn(e,n){let t=[...e.writable],o=t.length===0?"This resource declares no writable fields.":`Writable fields: ${t.join(", ")}.`;if(!Te(n)||Object.keys(n).length===0)throw M(422,"validation_failed","The request body must be a JSON object naming at least one writable field.",{body:[o]});let a=Object.keys(n).filter(r=>!e.writable.has(r));if(a.length>0)throw M(422,"query_invalid",`Unknown or read-only fields: ${a.join(", ")}.`,Object.fromEntries(a.map(r=>[r,[o]])));let i={};for(let[r,s]of Object.entries(n)){let l=e.fields.get(r),u=Vo(l,s)??zo(e,l,r,s);u!==null&&(i[r]=[u])}if(Object.keys(i).length>0)throw M(422,"validation_failed","The request body failed validation.",i);return Mt(n)}function zo(e,n,t,o){let a=e.choices.get(t);return a===void 0||o===null&&n?.nullable===!0||a.includes(o)?null:`The selected ${t.replace(/_/g," ")} is invalid.`}function Vo(e,n){return e===void 0||e.types.length!==1?null:n===null?e.nullable?null:bn(e):(()=>{switch(e.types[0]){case"string":return typeof n=="string";case"integer":return typeof n=="number"&&Number.isInteger(n)||typeof n=="string"&&/^[+-]?\d+$/.test(n.trim());case"number":return typeof n=="number"&&Number.isFinite(n)||typeof n=="string"&&n.trim()!==""&&Number.isFinite(Number(n));case"boolean":return[!0,!1,0,1,"0","1"].includes(n);case"array":case"object":return typeof n=="object";default:return!0}})()?null:bn(e)}function bn(e){return`The ${e.name.replace(/_/g," ")} field must be ${{string:"a string",integer:"an integer",number:"a number",boolean:"true or false",array:"an array",object:"an array"}[e.types[0]]??"valid"}.`}function xn(e,n,t){if(t===void 0)return;if(t.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");let o=Ve(e,n);if(t!==o)throw M(409,"conflict","The record changed since the version you sent.",void 0,void 0,{"X-Dmp-Record-Version":o})}function Ko(e){let n=e.rows.map(t=>t.id);return n.length>0&&n.every(t=>typeof t=="string")&&n.some(t=>!/^\d+$/.test(t))?crypto.randomUUID():n.reduce((t,o)=>Math.max(t,Number(o)||0),0)+1}function He(e,n){let t=Q(n);if(t===""||t==="."||t==="..")throw new TypeError(`${e.name}: '${t}' is not an id.`);let o=e.rows.find(a=>Q(a.id)===t);if(o===void 0)throw M(404,"not_found",`No such ${e.name} record.`);return o}function yn(e){return M(404,"not_found",`No such operation [${e}]. The preview runs no custom operations.`)}function ze(e,n){let t={};for(let o of n)t[o]=o in e?Mt(e[o]):null;return t}function Ve(e,n){return`"preview-${Q(n.id)}-${e.versions.get(Q(n.id))??1}"`}function ce(e,n,t){return{resource:e.name,contract:Co,page:n,groups:null,omitted:t,pruned:[],forbidden_fields:[]}}function de(e,n,t,o=null){let a=new Headers({"X-Dmp-Preview":"true"});return o!==null&&a.set("X-Dmp-Record-Version",o),{status:e,data:n,meta:t,headers:a,etag:null,recordVersion:o,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}}function M(e,n,t,o,a,i={}){return new P(e,new Headers({"Content-Type":"application/problem+json",...i}),{type:`https://docs.cube.nl/dmp-api/problems/${n}`,title:n.replace(/_/g," "),status:e,code:n,...a!==void 0?{reason:a}:{},detail:t,...o!==void 0?{errors:o}:{}})}function qo(e,n){let t=e?.types[0];if((t==="integer"||t==="number")&&n!==""&&Number.isFinite(Number(n)))return Number(n);if(t==="boolean"){if(n==="1"||n==="true")return!0;if(n==="0"||n==="false")return!1}return n}function Rt(e,n){return e==null?!1:typeof e=="boolean"&&typeof n!="boolean"?(e?"1":"0")===String(n)||String(e)===String(n):typeof e=="number"&&typeof n=="string"?String(e)===n:e===n||typeof e!="object"&&String(e)===String(n)}function V(e,n){if(e==null||n==null)return e==null?n==null?0:-1:1;if(typeof e=="number"&&typeof n=="number")return e-n;if(typeof e=="boolean"||typeof n=="boolean")return+(e===!0||e===1||e==="1")-+(n===!0||n===1||n==="1");let t=String(e),o=String(n);return t<o?-1:t>o?1:0}function Q(e){return e==null?"":String(e)}function Te(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mt(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function Tn(e){return{name:e.name,actions:[...e.actions],fields:e.fields.map(n=>({name:n.name,type:n.type,format:null,nullable:n.nullable,readonly:n.readonly,enum:null,description:n.description??null})),summary:[...e.summary],filterable:[...e.filterable],sortable:[...e.sortable],groupable:[...e.groupable],aggregatable:Object.fromEntries(Object.entries(e.aggregatable).map(([n,t])=>[n,[...t]]))}}var Lt="Voorbeeldgebruiker",pe={invalidPrimary:"De hoofdkleur is geen geldige hexkleur; de neutrale standaardkleur wordt gebruikt.",invalidAccent:"De accentkleur is geen geldige hexkleur; er wordt een accentkleur afgeleid.",primaryLight:"De hoofdkleur is erg licht; witte tekst erop heeft weinig contrast.",primaryDarkened:"De hoofdkleur is voor tekst donkerder gemaakt om voldoende contrast te houden."},y={loading:"Laden\u2026",empty:"Er is hier nog niets te tonen.",error:"Er ging iets mis bij het laden.",retry:"Opnieuw proberen",forbidden:"Je hebt geen toegang tot deze gegevens.",signedOut:"Je bent niet ingelogd.",signIn:"Inloggen",signOut:"Uitloggen",signedIn:"Ingelogd",previewUser:Lt,pages:"Pagina's",yes:"Ja",no:"Nee",emptyValue:"\u2014",quarter:(e,n)=>`K${e} ${n}`,week:(e,n)=>`week ${e}, ${n}`,monthYear:(e,n)=>`${e} '${n.slice(-2)}`,period:{label:"Periode","this-month":"Deze maand","12m":"Laatste 12 maanden","this-year":"Dit jaar",custom:"Zelf kiezen",from:"Van",to:"Tot en met",invalidRange:"De einddatum ligt v\xF3\xF3r de begindatum.",incompleteDate:"Vul bij Van en Tot en met een volledige datum in."},noData:"geen gegevens",comparedTo:"t.o.v. vorige periode",newValue:"nieuw",higher:"hoger",lower:"lager",incomplete:"Mogelijk niet compleet: er zijn meer groepen dan de DMP in \xE9\xE9n keer teruggeeft.",asTable:"Gegevens van de grafiek",tooManyGroups:"Te veel groepen om te tonen (meer dan 1000). Kies een kortere periode of een filter.",points:e=>`${e} ${e===1?"punt":"punten"}`,change:(e,n)=>`${e} procent ${n} dan de vorige periode`,search:"Zoeken",all:"Alle",min:"Vanaf",max:"Tot en met",previous:"Vorige",next:"Volgende",pageOf:(e,n,t)=>`Pagina ${e} van ${n} \xB7 ${t} rijen`,exportCsv:"Exporteren (CSV)",exporting:e=>`${e} rijen opgehaald\u2026`,chooseRow:"Kies een rij om de details te zien.",edit:"Bewerken",save:"Opslaan",cancel:"Annuleren",saved:"Opgeslagen.",formSaved:"Opgeslagen. Dank je wel!",another:"Nog een invullen",required:"Vul dit veld in.",requiredMark:" (verplicht)",notANumber:"Vul een getal in.",notAnInteger:"Vul een geheel getal in.",conflict:"Iemand anders heeft deze rij intussen gewijzigd. Laad de nieuwste versie en probeer het opnieuw.",reload:"Opnieuw laden",saveFailed:"Opslaan is niet gelukt. Probeer het opnieuw.",exportFailed:"Exporteren is niet gelukt. Probeer het opnieuw.",formInvalid:"Niet alles is goed ingevuld.",noWritableFields:"Dit formulier heeft geen invulbare velden.",calcFailed:"De berekening lukt niet met deze invoer.",moveTo:e=>`Verplaats naar ${e}`,moveFailed:"Verplaatsen lukte niet.",tryAgain:"Probeer het opnieuw.",changedMeanwhile:"Iemand anders heeft dit intussen gewijzigd; de nieuwste stand is geladen.",more:e=>`en nog ${e}`,noColumns:'Geef de kolommen op met <cube-column value="\u2026">.',emptyColumn:"Leeg",range:(e,n)=>`Kies een waarde van ${e} tot en met ${n}.`,atLeast:e=>`Kies een waarde van ${e} of meer.`,atMost:e=>`Kies een waarde van ten hoogste ${e}.`,step:e=>`Kies een waarde in stappen van ${e}.`,example:"Voorbeeld",exampleMissing:"Voorbeeld \u2014 bestaat nog niet",exampleNotSaved:"Voorbeeld \u2014 wordt niet opgeslagen",gaps:{screen:"Scherm",what:"Wat ontbreekt",type:"Soort gegeven",why:"Waarom",none:"Er ontbreekt niets: alles in dit voorstel bestaat al in de DMP.",types:{tekst:"Tekst",getal:"Getal",bedrag:"Bedrag",datum:"Datum",keuze:"Keuze","ja/nee":"Ja/nee"}},trial:{banner:(e,n)=>["Proefversie","alleen jij","alleen lezen"].concat(e===null?[]:[`verloopt om ${e}`]).concat(n.length===0?[]:[`leest: ${n.join(", ")}`]).concat("Plak geen gegevens uit deze proefversie in je AI-gesprek.").join(" \xB7 "),expired:"Deze proefversie is verlopen. Vraag in je gesprek om een nieuwe.",closed:"Deze proefversie is gesloten.",refreshing:"Nieuwe versie wordt geladen\u2026",wider:"Er is een nieuwe versie die meer gegevens leest.",load:"Laden",elsewhere:"Laad de pagina opnieuw.",reload:"Opnieuw laden"},invalid:{json:(e,n)=>`${e}: ${n} is geen geldige JSON`,number:(e,n)=>`${e}: ${n} is geen geldig getal`,attribute:e=>`${e} mag geen attribuut zijn: geen inline stijl of script`,measure:e=>`"${e}" is geen geldige meting: gebruik count of count/sum/avg/min/max(veld)`,missing:(e,n)=>`${e}: ${n} ontbreekt`,value:(e,n,t)=>`${e}: ${n} "${t}" is geen geldige waarde`,formula:"cube-calc: formula moet een functie zijn",calcSingle:"cube-calc: formula gaf \xE9\xE9n waarde, maar er zijn meer cube-results; geef een object met hun namen",duplicate:(e,n)=>`${e}: name "${n}" komt twee keer voor`,calcAsync:"cube-calc: formula gaf een Promise; geef de uitkomst direct terug, niet async",dateField:e=>`${e}: date-field ontbreekt bij period`,compare:e=>`${e}: compare werkt alleen samen met period`,periodSource:e=>`Geen periodekiezer gevonden voor "${e}"`,periodEnd:e=>`"${e}" is geen geldige einddatum van de periode`,notFilterable:(e,n,t)=>`${e}: ${n} noemt "${t}", maar daarop kan niet gefilterd worden`,selector:(e,n,t)=>`${e}: ${n} "${t}" is geen geldige selector`,lookup:e=>`"${e}" is geen geldige opzoeking: gebruik resource.veld`,dimension:e=>`"${e}" is geen geldige indeling: gebruik veld of veld.day/week/month/quarter/year`},theme:pe};var Ln=["color-primary","color-primary-hover","color-primary-subtle","color-primary-text","color-on-primary","color-accent","color-on-accent","color-text","color-text-muted","color-bg","color-surface","color-border","color-focus","color-danger","color-success","color-warning","color-example-bg","color-example-text","color-series-1","color-series-2","color-series-3","color-series-4","color-series-5","color-series-6","radius","radius-small","font-family"],Fn={primary_colour:"#475467",corners:"normaal",font:"system"},Ae={inter:{family:"Inter",files:[{file:"inter.woff2",weight:"100 900",style:"normal"}]},"albert-sans":{family:"Albert Sans",files:[{file:"albert-sans.woff2",weight:"100 900",style:"normal"}]},"source-sans-3":{family:"Source Sans 3",files:[{file:"source-sans-3.woff2",weight:"200 900",style:"normal"}]},"nunito-sans":{family:"Nunito Sans",files:[{file:"nunito-sans.woff2",weight:"200 1000",style:"normal"}]},"ibm-plex-sans":{family:"IBM Plex Sans",files:[{file:"ibm-plex-sans.woff2",weight:"100 700",style:"normal"}]}},Cn='system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',An="#f6f8fa";function me(e){if(typeof e!="string")return null;let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);if(!n||n[1]===void 0)return null;let t=n[1].toLowerCase();return t.length===3&&(t=[...t].map(o=>o+o).join("")),[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function $t(e){return"#"+e.map(n=>Math.max(0,Math.min(255,n)).toString(16).padStart(2,"0")).join("")}function Rn(e){let[n,t,o]=e.map(a=>{let i=a/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4});return .2126*n+.7152*t+.0722*o}function Re(e,n){let t=me(e),o=me(n);if(!t||!o)return 1;let a=Rn(t),i=Rn(o);return(Math.max(a,i)+.05)/(Math.min(a,i)+.05)}function Ft(e,n,t){let o=me(e),a=me(n);return $t(o.map((i,r)=>Math.round(i*(1-t)+a[r]*t)))}function En(e){return Re(e,"#ffffff")>=Re(e,"#000000")?"#ffffff":"#000000"}function Go(e,n){let[t,o,a]=me(e).map(k=>k/255),i=Math.max(t,o,a),r=Math.min(t,o,a),s=(i+r)/2,l=i-r,u=0,c=0;l!==0&&(c=l/(1-Math.abs(2*s-1)),i===t?u=(o-a)/l%6:i===o?u=(a-t)/l+2:u=(t-o)/l+4,u*=60),u=((u+n)%360+360)%360;let p=(1-Math.abs(2*s-1))*c,m=p*(1-Math.abs(u/60%2-1)),f=s-p/2,d=Math.floor(u/60)%6,[g,w,v]=[[p,m,0],[m,p,0],[0,p,m],[0,m,p],[m,0,p],[p,0,m]][d];return $t([g,w,v].map(k=>Math.round((k+f)*255)))}function _t(e){let n=me(e);return n?$t(n):null}function Wo(e){let n=[],t=_t(e.primary_colour);t===null&&(t=_t(Fn.primary_colour),n.push({code:"invalid-primary",message:pe.invalidPrimary}));let o=null;e.accent_colour!==void 0&&e.accent_colour!==null&&(o=_t(e.accent_colour),o===null&&n.push({code:"invalid-accent",message:pe.invalidAccent})),o??(o=Go(t,330)),Re(t,"#ffffff")<3&&n.push({code:"primary-light",message:pe.primaryLight});let a=Ft(t,"#ffffff",.9),i=t;for(let d=0;d<=20&&(i=Ft(t,"#000000",d/20),!(Re(i,An)>=4.5&&Re(i,a)>=4.5));d++);i!==t&&n.push({code:"primary-darkened-for-text",message:pe.primaryDarkened});let r=En(t),s={scherp:["0px","0px"],normaal:["6px","4px"],rond:["12px","8px"]},l=typeof e.corners=="string"&&Object.hasOwn(s,e.corners)?e.corners:"normaal",[u,c]=s[l],p=typeof e.font=="string"&&Object.hasOwn(Ae,e.font)?e.font:"system",m=p==="system"?Cn:`"${Ae[p].family}", ${Cn}`;return{tokens:{"color-primary":t,"color-primary-hover":Ft(t,r==="#ffffff"?"#000000":"#ffffff",.15),"color-primary-subtle":a,"color-primary-text":i,"color-on-primary":r,"color-accent":o,"color-on-accent":En(o),"color-text":"#1f2328","color-text-muted":"#59636e","color-bg":"#ffffff","color-surface":An,"color-border":"#d1d9e0","color-focus":i,"color-danger":"#b42318","color-success":"#067647","color-warning":"#b54708","color-example-bg":"#fef0c7","color-example-text":"#7a2e0e","color-series-1":t,"color-series-2":o,"color-series-3":"#0e9384","color-series-4":"#dc6803","color-series-5":"#7a5af8","color-series-6":"#475467",radius:u,"radius-small":c,"font-family":m},warnings:n}}var Qo=/^#[0-9a-f]{6}$/i,Jo=/^\d+(\.\d+)?(px|rem)$/,Yo=/^data:image\/(svg\+xml|png);/,Xo=/[;{}<>\\\u0000-\u001f]|\/\*/,Dn=/["'()\\\s]/,Mn=String.raw`(?:\s*"[^"]*"\s*|\s*'[^']*'\s*|[^"',]+)`,Zo=new RegExp(`^${Mn}(?:,${Mn})*$`);function Ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ei(e,n){return typeof n!="string"?!1:e.startsWith("color-")?Qo.test(n):e.startsWith("radius")?Jo.test(n):n.length>0&&n.length<=200&&!Xo.test(n)&&Zo.test(n)}function qe(e,n,t){if(typeof e!="string"||e==="")return null;if(t&&Yo.test(e))return Dn.test(e)?null:e;try{let o=new URL(n),a=new URL(e,o);if((a.protocol==="https:"||a.protocol==="http:")&&a.origin===o.origin&&!Dn.test(a.href))return a.href}catch{}return null}function ti(e,n){let t=[];for(let o of Array.isArray(e)?e:[]){if(!Ke(o))continue;let a=qe(o.src,n,!1);if(a===null)continue;let i=typeof o.weight=="string"&&/^\d{1,4}( \d{1,4})?$/.test(o.weight)?o.weight:"400";t.push({src:a,weight:i,style:o.style==="italic"?"italic":"normal"})}return t}function se(e,n){let t=e,o=Fn,a=null,i=null;Ke(t)&&(Object.hasOwn(t,"source")&&Ke(t.source)?(o=t.source,a=Object.hasOwn(t,"tokens")?t.tokens:null,i=Object.hasOwn(t,"font_files")?t.font_files:null):Object.hasOwn(t,"primary_colour")&&(o=t));let{tokens:r,warnings:s}=Wo(o);if(Ke(a))for(let c of Ln)Object.hasOwn(a,c)&&ei(c,a[c])&&(r[c]=a[c]);let l=typeof o.font=="string"&&Object.hasOwn(Ae,o.font)?o.font:null,u=ti(i,n);return l!==null&&u.length===0&&!Array.isArray(i)&&(u=Ae[l].files.flatMap(c=>{let p=qe("cube-theme/"+c.file,n,!1);return p===null?[]:[{src:p,weight:c.weight,style:c.style}]})),{tokens:r,logo:qe(o.logo,n,!0),logoDark:qe(o.logo_dark,n,!0),fontFamily:l===null?null:Ae[l].family,fontFiles:u,warnings:s}}function _n(e){return":where(:root){"+Ln.map(n=>`--cube-${n}:${e.tokens[n]}`).join(";")+"}"}var Ge=null,Ot=new Set;function We(){return Ge??(Ge=se(null,"http://localhost/")),Ge}function Pt(e){Ge=e;for(let n of[...Ot])n(e)}function Qe(e){return Ot.add(e),()=>{Ot.delete(e)}}var On="cube-trial-config",ni=["dmpUrl","apiUrl","token","expiresAt","statusUrl"],Je=null;function ri(e){let n=e?.getElementById(On)??null;if(n===null)return null;Je=null,n.remove();let t=null;try{let i=JSON.parse(n.textContent??"");t=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{}if(t?.mode!=="trial"||ni.some(i=>typeof t[i]!="string"||t[i]===""))return console.warn(`#${On} is not a complete trial config; the app starts without it.`),null;let o=i=>typeof t[i]=="string"?t[i]:null,a=t.leest;return Je={mode:"trial",dmpUrl:t.dmpUrl,apiUrl:t.apiUrl,token:t.token,expiresAt:t.expiresAt,statusUrl:t.statusUrl,version:o("version"),soort:o("soort"),userId:o("userId"),leest:Array.isArray(a)?a.filter(i=>typeof i=="string"):[]},Je}function Ye(){return Je}typeof document<"u"&&ri(document);var $n="1.1.0-rc.3";var A=class extends TypeError{};var ne=["number","integer","currency","percent"],In="nl-NL",oi=["day","week","month","quarter","year"],Xe=/^(\d{4})-(\d{2})-(\d{2})$/,ii=/^\s*-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?\s*$/i,si=/^(count|sum|avg|min|max)(?:\(([A-Za-z_][A-Za-z0-9_]*)\))?$/,ai=/^([A-Za-z_][A-Za-z0-9_]*)(?:\.([a-z]+))?$/,Pn=new Map,Nn=new Map;function Nt(e){let n=JSON.stringify(e),t=Pn.get(n);return t===void 0&&(t=new Intl.NumberFormat(In,e),Pn.set(n,t)),t}function jt(e){let n=JSON.stringify(e),t=Nn.get(n);return t===void 0&&(t=new Intl.DateTimeFormat(In,e),Nn.set(n,t)),t}function ae(e){return typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="bigint"||typeof e=="string"&&ii.test(e)?Number(e):null}function li(e){return e instanceof Date?Number.isNaN(e.getTime())?null:e:typeof e=="number"?Number.isFinite(e)?new Date(e):null:typeof e=="string"?B(e):null}function I(e,n,t={}){if(e==null||e==="")return y.emptyValue;switch(n){case"number":case"integer":case"currency":case"percent":{let o=ae(e);if(o===null)return String(e);let a=t.compact===!0?{notation:"compact"}:{};if(n==="currency")return Nt({style:"currency",currency:t.currency??"EUR",...a}).format(o);if(n==="percent")return Nt({style:"percent",maximumFractionDigits:1}).format(o);let i=n==="integer"?0:t.compact===!0?1:2;return Nt({maximumFractionDigits:i,...a}).format(o)}case"date":case"datetime":{let o=li(e);if(o===null)return String(e);let a={day:"numeric",month:"short",year:"numeric"};n==="datetime"&&Object.assign(a,{hour:"2-digit",minute:"2-digit"});let i=typeof e=="string"&&Xe.test(e);return t.timeZone!==void 0&&!i&&(a.timeZone=t.timeZone),jt(a).format(o)}case"boolean":return e===!0||e==="true"||e===1?y.yes:e===!1||e==="false"||e===0?y.no:String(e);default:return Array.isArray(e)?e.map(o=>I(o,"text")).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}}function It(e,n,t={}){switch(n){case"year":return e;case"quarter":{let o=/^(\d{4})-Q([1-4])$/.exec(e);return o?.[1]!==void 0&&o[2]!==void 0?y.quarter(o[2],o[1]):e}case"week":{let o=/^(\d{4})-W(\d{2})$/.exec(e);return o?.[1]!==void 0&&o[2]!==void 0?y.week(Number(o[2]),o[1]):e}case"month":{let o=/^(\d{4})-(\d{2})$/.exec(e);if(o?.[1]===void 0||o[2]===void 0)return e;let a=Hn(Number(o[1]),Number(o[2])-1,1);return jt(t.short===!0?{month:"short"}:{month:"short",year:"numeric"}).format(a)}case"day":{let o=Xe.test(e)?B(e):null;return o===null?e:jt({day:"numeric",month:"short"}).format(o)}default:return e}}function Bn(e){let n=si.exec(e.trim()),t=n?.[1];if(t===void 0||t!=="count"&&n?.[2]===void 0)throw new A(y.invalid.measure(e));return{fn:t,field:n?.[2]??null}}function Ze(e){let n=ai.exec(e.trim()),t=n?.[1],o=n?.[2];if(t===void 0||o!==void 0&&!oi.includes(o))throw new A(y.invalid.dimension(e));return{field:t,truncation:o??null}}function Un(e,n){if(e?.format==="date")return"date";if(e?.format==="date-time")return"datetime";if(e?.format==="currency")return"currency";switch(e?.type){case"integer":return"integer";case"number":return"number";case"boolean":return"boolean";case"string":return jn(n)??"text"}return typeof n=="boolean"?"boolean":typeof n=="number"?Number.isInteger(n)?"integer":"number":jn(n)??"text"}function jn(e){return typeof e!="string"?null:Xe.test(e)?B(e)===null?null:"date":/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(e)&&!Number.isNaN(Date.parse(e))?"datetime":null}function K(e){let n=e.replace(/_id$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return n===""?e:n.charAt(0).toUpperCase()+n.slice(1)}function B(e){let n=Xe.exec(e);if(n?.[1]!==void 0&&n[2]!==void 0&&n[3]!==void 0){let o=Hn(Number(n[1]),Number(n[2])-1,Number(n[3]));return o.getMonth()===Number(n[2])-1?o:null}let t=Date.parse(e);return Number.isNaN(t)?null:new Date(t)}function Hn(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function U(e){let n=t=>String(t).padStart(2,"0");return`${String(e.getFullYear()).padStart(4,"0")}-${n(e.getMonth()+1)}-${n(e.getDate())}`}var Vn={tekst:"text",getal:"number",bedrag:"currency",datum:"date",keuze:"text","ja/nee":"boolean"},Bt=e=>typeof e=="string"&&e!=="",tt=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),et=(e=[])=>[e].flat().join(",").split(",").map(n=>n.trim());function ui(e){if(typeof e!="object"||e===null)return!1;let n=e,t=n.waarden;return typeof n.resource=="string"&&/^[a-z][a-z0-9_]*$/.test(n.resource)&&(n.veld===void 0||Bt(n.veld))&&typeof n.type=="string"&&tt(Vn,n.type)&&(t===void 0||Array.isArray(t)&&t.every(o=>typeof o=="string"))&&(n.type!=="keuze"||Array.isArray(t)&&t.length>0)&&Bt(n.scherm)&&Bt(n.reden)}function Kn(e){let n=[],t=[];for(let o of Array.isArray(e)?e:e==null?[]:[e])(ui(o)?n:t).push(o);return t.length>0&&console.warn(`cube-app.json ontbreekt: ${t.length} malformed entries ignored`,t),n}function zn(e){return Vn[e]}function nt(e,n){if(e===null)return null;let t=i=>{let r=zn(i);return r==="date"||r==="currency"?r:null},o=n.flatMap(({resource:i,veld:r,type:s,waarden:l,reden:u})=>{if(i!==e.name||r===void 0||e.fields.some(p=>p.name===r))return[];let c=zn(s);return[{name:r,type:c==="boolean"?c:c==="number"||c==="currency"?"number":"string",format:t(s),nullable:!0,readonly:!1,enum:l??null,description:u}]}),a=o.map(i=>i.name);return{...e,fields:[...e.fields.map(i=>n.find(({resource:s,veld:l})=>s===e.name&&l===i.name)?.type==="bedrag"&&i.format==null?{...i,format:"currency"}:i),...o],summary:e.summary.length>0?[...e.summary,...a]:e.summary,filterable:[...e.filterable,...a],sortable:[...e.sortable,...a]}}function ci(e){let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619)>>>0;return n}function di(e,n,t){let{veld:o,type:a,waarden:i}=e,r=ci(`${e.resource}.${o}.${String(n)}`);if(o!==void 0){let s=t.filter(l=>tt(l,o)&&l[o]!==void 0);if(s.length>0)return s[r%s.length]?.[o]}switch(a){case"tekst":return`Voorbeeld ${r%100+1}`;case"getal":return r%1e3;case"bedrag":return r%1e5/100;case"datum":return U(new Date(2026,0,1+r%365));case"keuze":return i!==void 0&&i.length>0?i[r%i.length]:null;case"ja/nee":return r%2===0}}function qn(e,n){let t=e?.fields;return Array.isArray(t)?t:t?.[n]}async function Ut(e,n,{filter:t={},sort:o=[]}){let a=[o].flat().join(",").split(",").map(u=>u.replace(/^[-+]/,"")),i=Object.fromEntries([...n.flatMap(Object.keys),...Object.keys(t),...a].filter(u=>u!=="").map(u=>[u,{type:typeof n.find(c=>c[u]!=null)?.[u]}])),r=new Map(n.map(u=>[String(u.id),u])),s=new te({[e]:{schema:{fields:i},rows:n}}),{data:l}=await s.resource(e).list({filter:t,sort:o,page:{size:200}});return l.map(u=>r.get(String(u.id)))}function Ht(e,n,t,o){let{name:a}=e,i=new Map(n.filter(m=>m.resource===a&&m.veld!==void 0).map(m=>[m.veld,m])),r=m=>i.has(/^[-+]?(?:\w+\()?([^.()]*)/.exec(m)?.[1]??""),s=(m={})=>{let f=qn(m,a),d=f?.filter(k=>!i.has(k)),g=Object.entries(m.filter??{}),w=et(m.sort).filter(k=>k!==""),v=k=>({filter:Object.fromEntries(g.filter(([S])=>i.has(S)===k)),sort:w.filter(S=>r(S)===k)});return{live:{...m,...d&&{fields:d.includes("id")?d:[...d,"id"]},...v(!1)},local:v(!0),shown:k=>f===void 0||f.includes(k)}},l=(m,f,d=!1)=>{for(let[g,w]of i)(d||f(g))&&(!tt(m,g)||m[g]==null)&&(m[g]=di(w,m.id,o))},u=async(m,{local:f,shown:d})=>{let g=m.data;g.forEach(v=>l(v,d,!0)),g.length>0&&(f.sort.length>0||Object.keys(f.filter).length>0)&&(g=await Ut(a,g,f));for(let v of g)for(let k of i.keys())d(k)||delete v[k];let{meta:w}=m;return{...m,data:g,meta:Object.keys(f.filter).length>0?{...w,page:{...w.page,total:g.length,pages:w.page.number}}:w}},c=async(m,f)=>{let d=s(m);return u(await e.list(d.live,f),d)},p=async function*(m,f){let d=s(m);for await(let g of e.pages(d.live,f))yield await u(g,d)};return{...e,list:c,pages:p,async*all(m,f){for await(let d of p(m,f))yield*d.data},async get(m,f,d){let g=s(f),w=await e.get(m,g.live,d);return l(w.data,g.shown),g.shown("id")||delete w.data.id,w},aggregate:(m,f)=>[et(m.fn).map(d=>d.replace(/^\w+$/,"")),et(m.group),Object.keys(m.filter??{})].flat().some(r)?t.resource(a).aggregate(m):e.aggregate(m,f)}}function Gn(e,n){let t=d=>String(d.id),o=new Map,a=new Map,i=new Set,r=0,s=(d,g)=>({status:d,data:g,meta:null,headers:new Headers,etag:null,recordVersion:null,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}),l=(d,g)=>{let w=qn(g,n);return Object.fromEntries(Object.entries(d).filter(([v])=>w?.includes(v)??!0))},u=async(d,g={})=>{let{page:w}=d.meta,v=o.size>0?await Ut(n,[...o.values()].reverse(),g):[],k=new Set(v.map(t)),S=new Set(a.size>0?(await Ut(n,[...a.values()],g)).map(t):[]),R=new Set(d.data.map(t)),L=d.data.filter(D=>!i.has(t(D))&&(!o.has(t(D))||k.has(t(D)))).map(D=>o.get(t(D))??D),j=v.filter(D=>!S.has(t(D))&&!R.has(t(D))),x=w.total-[...S].filter(D=>!k.has(D)).length+j.length,F=w.number===1?[...j,...L]:L,T=et(g.sort).map(D=>[D.replace(/^[-+]/,""),D.startsWith("-")?-1:1]),E=D=>o.has(t(D))&&(!R.has(t(D))||T.some(([$])=>a.get(t(D))?.[$]!==D[$])),z=F.filter(D=>!E(D));if(T.every(([D])=>z.every($=>tt($,D)))){for(let D of F.filter(E)){let $=z.findIndex(Xr=>T.reduce((Zr,[tn,eo])=>Zr||eo*V(D[tn],Xr[tn]),0)<0);z.splice($>>>0,0,D)}F=z}return{...d,data:F.map(D=>l(D,g)),meta:{...d.meta,page:{...w,total:x}}}},c=async(d,g,w)=>{let v=o.get(String(d));if(i.has(String(d))){let k=`No such ${n} record.`;throw new P(404,new Headers,{status:404,code:"not_found",detail:k})}return v===void 0?e.get(d,g,w):s(200,l(v,g))},p=async d=>{let{data:g}=await c(d);return o.has(String(d))||a.set(String(d),g),g},m=async()=>({...s(202,null),accepted:!0}),f=async function*(d,g){for await(let w of e.pages(d,g))yield await u(w,d)};return{...e,get:c,pages:f,operation:m,collectionOperation:m,list:async(d,g)=>u(await e.list(d,g),d),async*all(d,g){for await(let w of f(d,g))yield*w.data},async create(d){let g={...d,id:`voorbeeld-${++r}`};return o.set(g.id,g),s(201,{...g})},async update(d,g){let w=await p(d),v={...w,...g,id:w.id};return o.set(String(d),v),s(200,{...v})},async delete(d){return await p(d),o.delete(String(d)),i.add(String(d)),s(204,null)}}}var mi="./cube-app.config.json",fi="./cube-mock.json",gi="./cube-app.json",hi="./cube-theme.json",bi={id:"preview",name:Lt,scopes:[]},Qn=null,Jn=null,q=null,zt=null,rt=null,Wn=0;function Yn(e={}){let n=q!==null&&q===zt,t=++Wn,o=ki(e,()=>t===Wn);return q=o,zt=null,o.then(()=>{n&&q===o&&vi()},()=>{q===o&&(q=null)}),o}function yi(){return q!==null?q:(rt??(rt=wi().then(()=>{if(rt=null,q!==null)return q;let e=Yn();return zt=e,e})),rt)}function wi(){let e=globalThis;return new Promise(n=>{let t=()=>{setTimeout(n,0)};e.document===void 0||e.document.readyState==="complete"||e.addEventListener===void 0?t():e.addEventListener("load",t,{once:!0})})}function vi(){let e=globalThis.document;if(e===void 0)return;let n=e.defaultView?.CustomEvent??CustomEvent;e.dispatchEvent(new n("cube-session-change"))}async function ki(e,n){let t=e.fetch??globalThis.fetch.bind(globalThis),o=e.pageUrl??rr(),a=Ye(),[i,r]=await Promise.all([a===null?ot(t,Ee(mi,o)):null,Si(e,t,o)]);return n()&&Pt(r),a!==null?Ai(a,e,t,o):i===null?xi(e,t,o):Ti(Di(i),e,t,o)}async function Si(e,n,t){try{if(e.theme===!1)return se(null,t);let o=e.theme??Jn;if(o!==null)return se(o,t);let a=await ot(n,Ee(hi,t));if(a!==null&&(a.theme!==1||typeof a.source!="object"||a.source===null))throw new TypeError("cube-theme.json is not a theme file.");return se(a,t)}catch(o){return console.warn(`cube-theme.json could not be used, the neutral theme applies: ${String(o)}`),se(null,t)}}async function Xn(e,n,t){let o=e.mock??Qn??await ot(n,Ee(fi,t))??{},a=e.manifest===!1?null:e.manifest??await ot(n,Ee(gi,t));return[o,a]}function Zn(e,n){let t=e==="wireframe",o=t?Kn(n?.ontbreekt):[];return{soort:e??null,gaps:o,simulatesWrites:t,isExample:(a,i)=>o.some(r=>r.resource===a&&(r.veld===void 0||r.veld===i))}}function er(e,n){let t=new Map;return e?a=>{let i=t.get(a)??Gn(n(a),a);return t.set(a,i),i}:n}async function xi(e,n,t){let[o,a]=await Xn(e,n,t),i=!0,r=()=>{if(!i)throw new P(401,new Headers({"Content-Type":"application/problem+json"}),{type:"https://docs.cube.nl/dmp-api/problems/token_invalid",title:"token invalid",status:401,code:"token_invalid",detail:"Unauthenticated."})},s=Zn(a?.soort,a),l=new te(o,a,r),u=new te(o,null,r),c=p=>s.isExample(p)?u:l;return{...s,mode:"preview",signInError:null,user:()=>i?{...bi}:null,async signIn(){i=!0},async signOut(){i=!1},resource:er(s.simulatesWrites,p=>{let m=c(p),f=m.resource(p),d=m.describe(p)?.fields??[],g=s.gaps.filter(({resource:w,veld:v})=>w===p&&v!==void 0&&!d.some(k=>k.name===v));return g.length>0?Ht(f,g,u,u.rows(p)):f}),schema:async p=>nt(c(p).describe(p),s.gaps)}}async function tr(e,n,t,o){let[a,i]=e==="wireframe"?await Xn(n,t,o):[{},null];return{marked:Zn(e,i),examples:new te(a)}}function nr(e,{marked:n,examples:t}){let{client:o}=e,a=null;return{...n,mode:e.mode,get signInError(){return e.signInError()},user:e.user,signIn:e.signIn,signOut:e.signOut,resource:er(n.simulatesWrites,i=>n.isExample(i)?t.resource(i):n.gaps.some(r=>r.resource===i)?Ht(o.resources(i),n.gaps,t,t.rows(i)):o.resources(i)),async schema(i){if(n.isExample(i))return nt(t.describe(i),n.gaps);a??(a=o.capabilities());try{let r=(await a).resources.find(s=>s.name===i);return r===void 0?null:nt(Tn(r),n.gaps)}catch(r){throw a=null,r}}}}async function Ti(e,n,t,o){let a=e.dmpUrl.replace(/\/+$/,""),i=null,r=Mi(n.tokenStorage==="memory"?je():Li(`cube-app.tokens.${e.clientId}`),p=>{i=p}),s=sn({issuer:e.issuer??a,clientId:e.clientId,redirectUri:Ee(e.redirectUri,o),scopes:e.scopes,fetch:t,tokenStore:r,...e.metadata!==void 0?{metadata:e.metadata}:{}}),l=St({baseUrl:e.apiUrl??`${a}/apps/api/v1`,auth:s,fetch:t}),u=null,c=await tr(e.soort,n,t,o);i=await r.get();try{await s.handleCallback()}catch(p){u=p instanceof Error?p:new Error(String(p))}return i===null&&u===null&&n.autoSignIn===!0&&await s.signIn(),nr({mode:"live",client:l,signInError:()=>u,user:()=>i===null?null:Ri(i),async signIn(){u=null,await s.signIn()},async signOut(){await s.signOut()}},c)}function Ci(e){return async(n,t)=>{let o=(t?.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?e(n,t):new Response(JSON.stringify({status:403,code:"insufficient_scope"}),{status:403,headers:{"Content-Type":"application/problem+json"}})}}async function Ai(e,n,t,o){let a=e.token,i=St({baseUrl:e.apiUrl,auth:()=>a,fetch:Ci(t)}),r=await tr(e.soort??void 0,n,t,o);return nr({mode:"trial",client:i,signInError:()=>null,user:()=>a===null?null:{id:e.userId,name:null,scopes:["api:read"]},async signIn(){globalThis.location?.reload()},async signOut(){a=null}},r)}function Ri(e){let n=Ei(e.accessToken),t=n?.sub,o=Array.isArray(n?.scopes)?n.scopes.map(String):null;return{id:typeof t=="string"||typeof t=="number"?String(t):null,name:null,scopes:o??(e.scope??"").split(" ").filter(a=>a!=="")}}function Ei(e){let n=e.split(".")[1];if(n===void 0)return null;try{let t=n.replace(/-/g,"+").replace(/_/g,"/"),o=atob(t.padEnd(t.length+(4-t.length%4)%4,"=")),a=new TextDecoder().decode(Uint8Array.from(o,r=>r.charCodeAt(0))),i=JSON.parse(a);return i!==null&&typeof i=="object"?i:null}catch{return null}}function Di(e){let n=["dmpUrl","clientId","redirectUri"].filter(o=>typeof e[o]!="string"||e[o]===""),t=e.scopes;if(typeof t=="string"||Array.isArray(t)&&t.every(o=>typeof o=="string")||n.push("scopes"),n.length>0)throw new TypeError(`cube-app.config.json is incomplete: ${n.join(", ")} missing or not a string.`);return e}async function ot(e,n){let t;try{t=await e(n,{headers:{Accept:"application/json"},...typeof document<"u"?{cache:"no-store"}:{}})}catch{return null}if(t.status===404||t.status===410)return null;if(!t.ok)throw new Error(`${n} answered ${t.status}.`);try{let o=JSON.parse(await t.text());return o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{return null}}function Mi(e,n){return{async get(){let t=await e.get();return n(t),t},async set(t){await e.set(t),n(t)}}}function Li(e){let n=(()=>{try{return globalThis.sessionStorage??null}catch{return null}})();return n===null?je():{get(){try{let t=n.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}},set(t){try{t===null?n.removeItem(e):n.setItem(e,JSON.stringify(t))}catch{}}}}function rr(){let e=globalThis;return e.document?.baseURI??e.location?.href??"http://localhost/"}function Ee(e,n){return new URL(e,n).href}function Fi(e){Qn=e}function _i(e){Jn=e,Pt(se(e,rr()))}var it=Object.freeze({connect:Yn,ready:yi,mock:Fi,theme:_i,version:$n,sdk:"1"});var or={"cube-state":["kind","message","retry"],"cube-app-shell":["name","logo","logo-alt"],"cube-page":["name","label"],"cube-field":["name","label","format","multiline","options","hidden"],"cube-period-picker":["default","label","today"],"cube-kpi":["resource","measure","label","format","currency","filter","period","date-field","compare"],"cube-chart":["resource","measure","by","kind","label","format","currency","filter","period","date-field","lookup","height","limit"],"cube-top":["resource","measure","by","limit","order","label","format","currency","filter","period","date-field","lookup"],"cube-table":["resource","fields","search","filters","sort","page-size","export","detail","filter","period","date-field"],"cube-detail":["resource","record-id","fields","editable"],"cube-form":["resource","fields","submit-label","success-text"],"cube-calc":["label"],"cube-input":["name","label","type","value","min","max","step","options"],"cube-result":["name","label","format","currency","emphasis"],"cube-board":["resource","status-field","title-field","fields","sort","filter","page-size","detail"],"cube-column":["value","label"],"cube-gap-list":["scherm"]};var Oi="http://www.w3.org/2000/svg";function h(e,n,t={},...o){let a=e.createElement(n);for(let[i,r]of Object.entries(t))ir(i,r===!0||typeof r=="string"),typeof r=="function"?a.addEventListener(i.replace(/^on/,""),r):r===!0?a.setAttribute(i,""):typeof r=="string"&&a.setAttribute(i,r);return sr(e,a,o),a}function H(e,n,t={},...o){let a=e.createElementNS(Oi,n);for(let[i,r]of Object.entries(t))ir(i,!0),a.setAttribute(i,String(r));return sr(e,a,o),a}function ir(e,n){let t=e.toLowerCase();if(t==="style"||n&&t.startsWith("on"))throw new A(y.invalid.attribute(e))}function C(e){for(;e.firstChild!==null;)e.removeChild(e.firstChild)}function sr(e,n,t){for(let o of t)typeof o=="string"?n.appendChild(e.createTextNode(o)):o!=null&&o!==!1&&n.appendChild(o)}var De=`
|
|
3
3
|
:host{display:block;box-sizing:border-box;min-width:0;font-family:var(--cube-font-family,system-ui,sans-serif);
|
|
4
4
|
color:var(--cube-color-text,#1f2328);font-size:1rem;line-height:1.5}
|
|
5
5
|
:host([hidden]){display:none}
|
|
@@ -29,7 +29,7 @@ td.example,dd.example{text-decoration:underline dashed;text-underline-offset:.25
|
|
|
29
29
|
font-weight:600}
|
|
30
30
|
.row{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}
|
|
31
31
|
@media (max-width:640px){.row{flex-direction:column;align-items:stretch}.row>button{width:100%}}
|
|
32
|
-
`,ar=new WeakMap;function st(e,n){let t=ar.get(e);t===void 0&&(t=new Map,ar.set(e,t));let o=t.get(n);return o===void 0&&(o=new e.CSSStyleSheet,o.replaceSync(n),t.set(n,o)),o}var
|
|
32
|
+
`,ar=new WeakMap;function st(e,n){let t=ar.get(e);t===void 0&&(t=new Map,ar.set(e,t));let o=t.get(n);return o===void 0&&(o=new e.CSSStyleSheet,o.replaceSync(n),t.set(n,o)),o}var J=class extends Error{constructor(t){super(t.detail??t.kind);b(this,"state");this.state=t}};function Y(e){if(e instanceof J)return e.state;if(N(e)){if(e.status===401)return{kind:"signed-out",detail:null};if(e.status===403)return{kind:"forbidden",detail:null}}return e instanceof A?{kind:"error",detail:e.message}:{kind:"error",detail:null}}function $i(e){return new Promise(n=>{e.readyState==="loading"?e.addEventListener("DOMContentLoaded",()=>n(),{once:!0}):(e.defaultView?.setTimeout??setTimeout)(n,0)})}function at(e){return h(e,"span",{class:"badge example"},y.example,h(e,"span",{class:"sr-only"},y.exampleMissing.slice(y.example.length)))}function Pi(e){return e!==null&&typeof e=="object"&&e.name==="AbortError"}function lr(e,n={}){let t=n.session??(()=>it.ready());class o extends e.HTMLElement{constructor(){super();b(this,"body");b(this,"current",Promise.resolve());b(this,"scheduled",!1);b(this,"controller",null);b(this,"badge",null);b(this,"onSessionChange",()=>this.schedule());b(this,"onDataChange",r=>{if(r.composedPath()[0]===this&&!this.constructor.reloadsOnOwnChange)return;let s=r.detail?.resource,l=this.getAttribute("resource")?.trim()??"";typeof s=="string"&&l!==""&&s.trim()===l&&this.schedule()});let r=this.constructor,s=this.attachShadow({mode:"open"});s.adoptedStyleSheets=r.css===""?[st(e,De)]:[st(e,De),st(e,r.css)],this.body=h(e.document,"div",{class:"cube-body",part:"body"}),s.appendChild(this.body),s.addEventListener("cube-retry",l=>{l.stopPropagation(),this.schedule()})}static get observedAttributes(){return[...or[this.tag]??[]]}get updateComplete(){return(async()=>{let r;do r=this.current,await r;while(r!==this.current)})()}connectedCallback(){this.ownerDocument.addEventListener("cube-session-change",this.onSessionChange),this.ownerDocument.addEventListener("cube-data-change",this.onDataChange),this.schedule()}disconnectedCallback(){this.ownerDocument.removeEventListener("cube-session-change",this.onSessionChange),this.ownerDocument.removeEventListener("cube-data-change",this.onDataChange),this.controller?.abort(),this.controller=null,this.removeAttribute("aria-busy")}attributeChangedCallback(r,s,l){s!==l&&this.schedule()}refresh(){if(!this.isConnected)return this.current;this.controller?.abort();let r=new AbortController;this.controller=r;let s=this.run(r.signal);return this.current=s,s}schedule(){this.scheduled||!this.isConnected||(this.scheduled=!0,this.current=new Promise(r=>{queueMicrotask(()=>{this.scheduled=!1,r(this.isConnected?this.refresh():void 0)})}))}async run(r){let s=this.constructor;this.showState("loading");try{if(await $i(this.ownerDocument),r.aborted)return;let l=s.needsSession?await this.session():null;if(r.aborted)return;await this.load(r,l),r.aborted||this.mark(l)}catch(l){if(r.aborted||Pi(l))return;this.badge?.remove(),this.showState(Y(l)),l instanceof TypeError&&!(l instanceof A)&&console.warn(`${this.localName}:`,l)}finally{r.aborted||this.removeAttribute("aria-busy")}}session(){return t()}shownFields(){return[]}exampleField(r,s,l){return r.isExample?.(s,l)===!0&&!r.isExample(s)}notSaved(r){return r.simulatesWrites===!0?h(this.ownerDocument,"p",{class:"note not-saved"},y.exampleNotSaved):null}mark(r){let s=this.getAttribute("resource")?.trim()??"";if(!(r?.isExample!==void 0&&s!==""&&(r.isExample(s)||this.shownFields().some(u=>r.isExample(s,u))))){this.badge?.remove();return}this.badge??(this.badge=h(this.ownerDocument,"p",{class:"badge example",role:"note"},y.exampleMissing)),this.shadowRoot?.insertBefore(this.badge,this.body)}showState(r,s=null){let{kind:l,detail:u,retry:c}=typeof r=="string"?{kind:r,detail:s}:r;l==="loading"&&this.setAttribute("aria-busy","true"),C(this.body),this.body.appendChild(h(this.ownerDocument,"cube-state",{kind:l,message:u,retry:c===!1?"false":null}))}attr(r){return this.getAttribute(r)}flag(r){return this.hasAttribute(r)&&this.getAttribute(r)!=="false"}num(r,s){let l=this.getAttribute(r);if(l===null||l.trim()==="")return s;let u=Number(l);if(!Number.isFinite(u))throw new A(y.invalid.number(this.localName,r));return u}json(r){let s=this.getAttribute(r);if(s===null||s.trim()==="")return null;try{return JSON.parse(s)}catch{throw new A(y.invalid.json(this.localName,r))}}emit(r,s=null){let l=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;return this.dispatchEvent(new l(r,{detail:s,bubbles:!0,composed:!0}))}}return b(o,"tag",""),b(o,"css",""),b(o,"needsSession",!0),b(o,"reloadsOnOwnChange",!0),o}var Ni=`
|
|
33
33
|
:host{background:var(--cube-color-bg)}
|
|
34
34
|
header{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1rem;padding:.75rem 1.5rem;
|
|
35
35
|
border-bottom:1px solid var(--cube-color-border);background:var(--cube-color-surface)}
|
|
@@ -46,12 +46,12 @@ border-bottom-color:var(--cube-color-primary)}
|
|
|
46
46
|
main{padding:1.5rem}
|
|
47
47
|
::slotted(cube-page:not([hidden])){display:flex;flex-direction:column;gap:1.5rem}
|
|
48
48
|
@media (max-width:640px){header{padding:.75rem 1rem}nav{padding:0}main{padding:1rem}}
|
|
49
|
-
`,Vt="#/";function ur(e,n){class t extends e{constructor(){super();b(this,"header");b(this,"heading");b(this,"user");b(this,"nav");b(this,"list");b(this,"main");b(this,"built","");b(this,"stopTheme",null);b(this,"onHash",()=>this.updatePages());let i=n.document;this.heading=h(i,"h1"),this.user=h(i,"div",{class:"user"}),this.header=h(i,"header",{},this.heading,this.user),this.list=h(i,"ul"),this.nav=h(i,"nav",{"aria-label":y.pages},this.list);let r=h(i,"slot",{onslotchange:()=>this.updatePages()});this.main=h(i,"main",{},r),this.body.append(this.header,this.main),this.renderHeader()}connectedCallback(){super.connectedCallback(),this.ownerDocument.defaultView?.addEventListener("hashchange",this.onHash),this.stopTheme?.(),this.stopTheme=Qe(()=>this.renderHeader()),this.renderHeader(),this.updatePages()}disconnectedCallback(){super.disconnectedCallback(),this.ownerDocument.defaultView?.removeEventListener("hashchange",this.onHash),this.stopTheme?.(),this.stopTheme=null}async load(i,r){this.renderHeader(),this.updatePages(),r!==null&&this.renderUser(r)}showState(i){let r=typeof i=="string"?i:i.kind;C(this.user),r==="signed-out"&&this.user.appendChild(this.signInButton())}renderHeader(){let i=this.attr("name")??"",r=this.attr("logo")??We().logo,s=this.header.querySelector(".logo");if(this.heading.textContent=i,r===null||r===""){s?.remove();return}let l=h(n.document,"img",{class:"logo",src:r,alt:this.attr("logo-alt")??i});s===null?this.header.prepend(l):s.replaceWith(l)}renderUser(i){let r=n.document,s=i.user();if(C(this.user),s===null){this.user.appendChild(this.signInButton());return}this.user.append(h(r,"span",{},s.name!==null&&s.name!==""?s.name:y.signedIn),h(r,"button",{type:"button",class:"secondary",onclick:()=>{this.change(l=>l.signOut())}},y.signOut))}signInButton(){return h(n.document,"button",{type:"button",onclick:()=>{this.change(i=>i.signIn())}},y.signIn)}async change(i){try{await i(await this.session())}catch{this.refresh();return}let r=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;this.ownerDocument.dispatchEvent(new r("cube-session-change"))}pages(){return Array.from(this.children).filter(i=>i.localName==="cube-page")}updatePages(){let i=this.pages(),s=(n.location??this.ownerDocument.defaultView?.location)?.hash??"",l="";if(s.startsWith(Vt))try{l=decodeURIComponent(s.slice(Vt.length).split("?")[0]??"")}catch{l=""}let u=i.find(
|
|
49
|
+
`,Vt="#/";function ur(e,n){class t extends e{constructor(){super();b(this,"header");b(this,"heading");b(this,"user");b(this,"nav");b(this,"list");b(this,"main");b(this,"built","");b(this,"stopTheme",null);b(this,"onHash",()=>this.updatePages());let i=n.document;this.heading=h(i,"h1"),this.user=h(i,"div",{class:"user"}),this.header=h(i,"header",{},this.heading,this.user),this.list=h(i,"ul"),this.nav=h(i,"nav",{"aria-label":y.pages},this.list);let r=h(i,"slot",{onslotchange:()=>this.updatePages()});this.main=h(i,"main",{},r),this.body.append(this.header,this.main),this.renderHeader()}connectedCallback(){super.connectedCallback(),this.ownerDocument.defaultView?.addEventListener("hashchange",this.onHash),this.stopTheme?.(),this.stopTheme=Qe(()=>this.renderHeader()),this.renderHeader(),this.updatePages()}disconnectedCallback(){super.disconnectedCallback(),this.ownerDocument.defaultView?.removeEventListener("hashchange",this.onHash),this.stopTheme?.(),this.stopTheme=null}async load(i,r){this.renderHeader(),this.updatePages(),r!==null&&this.renderUser(r)}showState(i){let r=typeof i=="string"?i:i.kind;C(this.user),r==="signed-out"&&this.user.appendChild(this.signInButton())}renderHeader(){let i=this.attr("name")??"",r=this.attr("logo")??We().logo,s=this.header.querySelector(".logo");if(this.heading.textContent=i,r===null||r===""){s?.remove();return}let l=h(n.document,"img",{class:"logo",src:r,alt:this.attr("logo-alt")??i});s===null?this.header.prepend(l):s.replaceWith(l)}renderUser(i){let r=n.document,s=i.user();if(C(this.user),s===null){this.user.appendChild(this.signInButton());return}this.user.append(h(r,"span",{},s.name!==null&&s.name!==""?s.name:y.signedIn),h(r,"button",{type:"button",class:"secondary",onclick:()=>{this.change(l=>l.signOut())}},y.signOut))}signInButton(){return h(n.document,"button",{type:"button",onclick:()=>{this.change(i=>i.signIn())}},y.signIn)}async change(i){try{await i(await this.session())}catch{this.refresh();return}let r=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;this.ownerDocument.dispatchEvent(new r("cube-session-change"))}pages(){return Array.from(this.children).filter(i=>i.localName==="cube-page")}updatePages(){let i=this.pages(),s=(n.location??this.ownerDocument.defaultView?.location)?.hash??"",l="";if(s.startsWith(Vt))try{l=decodeURIComponent(s.slice(Vt.length).split("?")[0]??"")}catch{l=""}let u=i.find(p=>p.getAttribute("name")===l)??i[0];for(let p of i)p.hidden=p!==u;if(i.length<2){this.nav.remove(),C(this.list),this.built="";return}this.nav.parentNode!==this.body&&this.body.insertBefore(this.nav,this.main);let c=JSON.stringify(i.map(p=>[p.getAttribute("name"),p.getAttribute("label")]));if(c!==this.built){C(this.list);for(let p of i){let m=p.getAttribute("name")??"",f=Vt+encodeURIComponent(m),d=h(n.document,"a",{href:f},p.getAttribute("label")??m);this.list.appendChild(h(n.document,"li",{},d))}this.built=c}Array.from(this.list.querySelectorAll("a")).forEach((p,m)=>{i[m]===u?p.setAttribute("aria-current","page"):p.removeAttribute("aria-current")})}}return b(t,"tag","cube-app-shell"),b(t,"css",Ni),t}var ji=/^([a-z][a-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)$/,Kt=200;function fe(e){let n=e.getAttribute("filter");if(n===null||n.trim()==="")return{};let t;try{t=JSON.parse(n)}catch{t=null}if(t===null||typeof t!="object"||Array.isArray(t))throw new A(y.invalid.json(e.localName,"filter"));return t}function Ii(e){let n=e;return typeof n?.from=="string"&&typeof n.to=="string"&&typeof n.previous?.from=="string"&&typeof n.previous.to=="string"}function lt(e,n){let t=B(n.to);if(t===null)throw new A(y.invalid.periodEnd(n.to));return t.setDate(t.getDate()+1),{[e]:{gte:n.from,lt:U(t)}}}async function ut(e,n){if(n===null||n==="")return null;let t=e.ownerDocument.querySelector(n),o=(e.ownerDocument.defaultView??window).customElements;if(t===null||o.get(t.localName)===void 0)throw new A(y.invalid.periodSource(n));let a=t;if(await a.updateComplete,!Ii(a.value))throw new A(y.invalid.periodSource(n));return a}function ct(e,n,t){if(e!==null&&e!=="")return e;if(n!==null&&n!==""){let o=Ze(n);if(o.truncation!==null)return o.field}throw new A(y.invalid.dateField(t))}async function cr(e,n,t,o){let a=ji.exec(n),i=a?.[1],r=a?.[2];if(i===void 0||r===void 0)throw new A(y.invalid.lookup(n));let s=[...new Set(t.filter(u=>u!=null).map(u=>u))],l=new Map;for(let u=0;u<s.length;u+=Kt){o.throwIfAborted();let c=s.slice(u,u+Kt),p;try{let m={filter:{id:{in:c}},fields:["id",r],page:{size:Kt}};({data:p}=await e.resource(i).list(m,{signal:o}))}catch(m){if(o.aborted||m?.name==="AbortError")throw m;continue}for(let m of p){let f=m[r];f!=null&&l.set(String(m.id),String(f))}}return l}var Bi=["number","integer","currency","percent"],O=`
|
|
50
50
|
.card{padding:1rem 1.25rem;border:1px solid var(--cube-color-border);border-radius:var(--cube-radius);
|
|
51
51
|
background:var(--cube-color-surface)}
|
|
52
52
|
`,ge=`
|
|
53
53
|
.label{margin:0 0 .5rem;font-weight:600}
|
|
54
|
-
`;function
|
|
54
|
+
`;function _(e,n){let t=e.getAttribute(n)?.trim()??"";if(t==="")throw new A(y.invalid.missing(e.localName,n));return t}function he(e){let n=/\(([^)]+)\)/.exec(e.getAttribute("measure")??"")?.[1]?.trim(),t=e.getAttribute("by")?.split(".")[0];return[n,t,e.getAttribute("date-field")].filter(o=>!!o)}function Me(e){if(typeof e=="string"&&e.trim()==="")return null;let n=typeof e=="number"||typeof e=="string"?Number(e):NaN;return Number.isFinite(n)?n:null}var G=class{constructor(n){b(this,"block",n);b(this,"source",null);b(this,"onChange",()=>{this.block.isConnected?this.block.refresh():this.follow(null)})}follow(n){n!==this.source&&(this.source?.removeEventListener("cube-change",this.onChange),this.source=n,n?.addEventListener("cube-change",this.onChange))}};async function be(e,n,t,o=null){let a=Bn(_(e,"measure")),i=fe(e),r=e.getAttribute("period"),s=r===null||r===""?null:ct(e.getAttribute("date-field"),o,e.localName),l=await ut(e,r);return t.aborted?null:(n.follow(l),{fn:a.field===null?a.fn:`${a.fn}(${a.field})`,field:a.field,count:a.fn==="count",period:l?.value??null,filterFor:u=>u===null||s===null?i:{...i,...lt(s,u)}})}async function dt(e,n,t,o,a){try{return await e.resource(n).aggregate({fn:o.fn,group:t,filter:o.filterFor(o.period)},{signal:a})}catch(i){throw N(i)&&i.status===422&&(i.reason==="too_many_groups"||i.code==="cardinality_exceeded")?new J({kind:"error",detail:y.tooManyGroups,retry:!1}):i}}function X(e,n,t,o){let a=e.getAttribute(n),i=a===null||a.trim()===""?NaN:Number(a);return Number.isFinite(i)&&i>=t?Math.floor(i):o}async function pt(e,n,t,o,a,i){let r=a.descending?-1:1,s=t.filter(c=>c[o.by]!==null&&c[o.by]!==void 0).map(c=>({key:String(c[o.by]),value:Me(c[o.fn])})).filter(c=>c.value!==null).sort((c,p)=>r*(c.value-p.value)).slice(0,a.limit),l=e.getAttribute("lookup"),u=l===null||l===""||s.length===0?null:await cr(n,l,s.map(c=>c.key),i);return i.aborted?null:s.map(c=>({...c,label:u===null?c.key:u.get(c.key)??`#${c.key}`}))}function ye(e,n){let t=e.getAttribute("format"),o=t!==null&&Bi.includes(t)?t:n?"integer":"number",a=e.getAttribute("currency")||"EUR";return(i,r)=>I(i,o,{currency:a,compact:r===!0})}var Le=Symbol("cube-field hidden");function dr(e){var n,t;return class extends(t=e.HTMLElement,n=Le,t){constructor(){super(...arguments);b(this,n)}connectedCallback(){this[Le]===void 0&&(this[Le]=this.hasAttribute("hidden")),this.hidden=!0}}}function mt(e){let n=e.field?.enum??null;return e.config?.options??(n===null?null:n.map(t=>({value:t,label:t})))}var Ui=["text","number","integer","currency","percent","date","datetime","boolean"];function Z(e){let n=(e??"").split(",").map(t=>t.trim()).filter(t=>t!=="");return n.length>0?n:null}function qt(e){if(e===null)return null;let n=e.split(",").map(t=>{let o=t.indexOf("="),a=(o<0?t:t.slice(0,o)).trim(),i=o<0?a:t.slice(o+1).trim();return{value:a,label:i===""?a:i}}).filter(t=>t.value!=="");return n.length>0?n:null}function W(e){let n=new Map;for(let t of Array.from(e.children)){let o=t.getAttribute("name")?.trim()??"";if(t.localName!=="cube-field"||o==="")continue;let a=t.getAttribute("format"),i=t[Le];n.set(o,{name:o,label:t.getAttribute("label"),format:a!==null&&Ui.includes(a)?a:null,multiline:t.hasAttribute("multiline"),options:qt(t.getAttribute("options")),hidden:i??t.hasAttribute("hidden")})}return n}function Fe(e,n){return e.get(n)?.label??K(n)}function ee(e,n,t,o){let a=e!==null&&e.summary.length>0?e.summary:null;return(n??a??(o===void 0?[]:Object.keys(o))).filter(r=>t.get(r)?.hidden!==!0).map(r=>{let s=e?.fields.find(u=>u.name===r),l=t.get(r);return{name:r,label:Fe(t,r),format:l?.format??Un(s,o?.[r]),field:s,config:l}})}var we=`
|
|
55
55
|
.field{display:flex;flex-direction:column;gap:.25rem;min-width:0}
|
|
56
56
|
.field label{font-weight:600}
|
|
57
57
|
.field .required{font-weight:400;color:var(--cube-color-text-muted)}
|
|
@@ -59,7 +59,7 @@ background:var(--cube-color-surface)}
|
|
|
59
59
|
.field.check input{min-height:auto;width:1.25rem;height:1.25rem}
|
|
60
60
|
.field [aria-invalid=true]{border-color:var(--cube-color-danger,#b42318)}
|
|
61
61
|
.field-error{margin:0;color:var(--cube-color-danger,#b42318);font-size:.875rem}
|
|
62
|
-
`,
|
|
62
|
+
`,Hi=/^-?(\d{1,3}(\.\d{3})+|\d*)(,\d+)?$/,zi=/^-?[1-9]\d{0,2}(\.\d{3})+$/,Vi=/^-?(\d+\.?\d*|\.\d+)$/,Ki=0;function qi(e){return e.includes(",")?Hi.test(e)&&/\d/.test(e)?Number(e.replace(/\./g,"").replace(",",".")):null:zi.test(e)?Number(e.replace(/\./g,"")):Vi.test(e)?Number(e):null}var pr=e=>Number(e.toPrecision(12));function _e(e,n){if(e.trim()==="")return{value:null};if(ne.includes(n)){let t=qi(e.replace(/[\s €%]/g,""));return t===null||!Number.isFinite(t)?{error:y.notANumber}:n==="integer"&&!Number.isInteger(t)?{error:y.notAnInteger}:{value:n==="percent"?pr(t/100):t}}if(n==="boolean")return{value:e==="true"||e==="1"};if(n==="datetime"){let t=Date.parse(e);return{value:Number.isNaN(t)?e:new Date(t).toISOString()}}return{value:e}}function mr(e){if(!N(e)||e.status!==422||e.errors===null)return null;let n={};for(let[t,o]of Object.entries(e.errors)){let a=Array.isArray(o)?o.find(i=>typeof i=="string"):void 0;a!==void 0&&(n[t]=a)}return Object.keys(n).length>0?n:null}function Gi(e,n){if(e==null)return"";if(ne.includes(n)){let t=typeof e=="number"?e:Number(e);return typeof e=="boolean"||!Number.isFinite(t)?String(e):String(n==="percent"?pr(t*100):t).replace(".",",")}if(n==="date"&&typeof e=="string")return e.slice(0,10);if(n==="datetime"&&typeof e=="string"){let t=Date.parse(e);if(Number.isNaN(t))return e;let o=new Date(t),a=i=>String(i).padStart(2,"0");return`${U(o)}T${a(o.getHours())}:${a(o.getMinutes())}`}return typeof e=="object"?JSON.stringify(e):String(e)}function Wi(e,n,t,o){let a=mt(n),i=Gi(t,n.format);if(a!==null){let u=a.some(m=>m.value===i),c=i===""||u?a:[...a,{value:i,label:i}],p=h(e,"select",{id:o,name:n.name},h(e,"option",{value:""},y.emptyValue),...c.map(m=>h(e,"option",{value:m.value},m.label)));return p.value=i,p}if(n.format==="text"&&n.config?.multiline===!0){let u=h(e,"textarea",{id:o,name:n.name,rows:"4"});return u.value=i,u}let r=ne.includes(n.format),s=n.format==="date"?"date":n.format==="datetime"?"datetime-local":"text",l=h(e,"input",{id:o,name:n.name,type:n.format==="boolean"?"checkbox":s,inputmode:r?"decimal":null});return n.format==="boolean"?l.checked=t===!0||t==="true"||t===1:l.value=i,l}function ve(e,n,t,o){let a=`cube-input-${++Ki}`,i=Wi(e,n,t,a),r=i.getAttribute("type")==="checkbox";o&&!r&&i.setAttribute("aria-required","true");let s=o&&!r?h(e,"span",{class:"required","aria-hidden":"true"},y.requiredMark):null,l=h(e,"label",{for:a},n.label,s),u=h(e,"p",{id:`${a}-error`,class:"field-error",hidden:!0});return{element:h(e,"div",{class:r?"field check":"field"},...r?[i,l]:[l,i],u),name:n.name,read(){return r?{value:i.checked}:o&&i.value.trim()===""?{error:y.required}:_e(i.value,n.format)},setError(p){u.textContent=p??"",u.hidden=p===null,p===null?(i.removeAttribute("aria-invalid"),i.removeAttribute("aria-describedby")):(i.setAttribute("aria-invalid","true"),i.setAttribute("aria-describedby",u.id))}}}var ke=`
|
|
63
63
|
form{display:flex;flex-direction:column;gap:1rem}
|
|
64
64
|
.actions{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:1rem}
|
|
65
65
|
.alert{margin:0 0 1rem;padding:.75rem 1rem;border:1px solid var(--cube-color-danger,#b42318);
|
|
@@ -69,15 +69,18 @@ border-radius:var(--cube-radius-small)}
|
|
|
69
69
|
.alert button{margin-top:.5rem}
|
|
70
70
|
.status{margin:.5rem 0 0}
|
|
71
71
|
.status:empty{margin:0}
|
|
72
|
-
`;function Se(e,n){return e?.body===n?e:{key:cn(),body:n}}function
|
|
72
|
+
`;function Se(e,n){return e?.body===n?e:{key:cn(),body:n}}function Oe(e,n,t,o){C(n),n.append(h(e,"p",{},t),...o==null?[]:[o]),n.hidden=!1,n.focus()}function ft(e,n,t,o,a){let i=mr(t);if(i!==null){for(let u of o)u.setError(i[u.name]??null);let s=Object.entries(i).filter(([u])=>!o.some(c=>c.name===u)),l=s.length===0?null:h(e,"ul",{},...s.map(([u,c])=>h(e,"li",{},`${a(u)}: ${c}`)));Oe(e,n,y.formInvalid,l);return}let r=Y(t).kind;Oe(e,n,r==="forbidden"?y.forbidden:r==="signed-out"?y.signedOut:y.saveFailed)}function le(e){let n=e?.user()??null;return n===null?null:String(n.id)}var Qi=`${O}${ke}
|
|
73
73
|
.board{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(14rem,1fr);gap:1rem;
|
|
74
74
|
position:relative;overflow-x:auto}
|
|
75
75
|
@media (max-width:640px){.board{grid-auto-flow:row;grid-auto-columns:auto}}
|
|
76
76
|
section{min-width:0}
|
|
77
77
|
h3{margin:0 0 .5rem;font-size:1rem}
|
|
78
78
|
article{margin-top:.5rem;padding:.75rem;border:1px solid var(--cube-color-border);
|
|
79
|
-
border-radius:var(--cube-radius-small);background:var(--cube-color-bg);overflow-wrap:anywhere
|
|
79
|
+
border-radius:var(--cube-radius-small);background:var(--cube-color-bg);overflow-wrap:anywhere;
|
|
80
|
+
cursor:pointer}
|
|
80
81
|
article[draggable=true]{cursor:grab}
|
|
82
|
+
article.chosen{border-color:var(--cube-color-primary);background:var(--cube-color-primary-subtle);
|
|
83
|
+
box-shadow:inset 4px 0 0 var(--cube-color-primary)}
|
|
81
84
|
.title{margin:0;font-weight:600}
|
|
82
85
|
dl{display:grid;grid-template-columns:auto 1fr;gap:0 .5rem;margin:.25rem 0 0;font-size:.875rem}
|
|
83
86
|
dd{margin:0;min-width:0}
|
|
@@ -86,7 +89,7 @@ dd{margin:0;min-width:0}
|
|
|
86
89
|
.moves button::before{content:"\\2192 "}
|
|
87
90
|
.muted{margin:.5rem 0 0}
|
|
88
91
|
.not-saved{display:inline-block;margin-bottom:.75rem}
|
|
89
|
-
`,gt=e=>String(e.id);function
|
|
92
|
+
`,gt=e=>String(e.id);function Ji(e){return e.split(",").map(n=>n.trim()).filter(n=>n!=="").map(n=>({field:n.replace(/^[-+]/,""),descending:n.startsWith("-")}))}function Yi(e,n){if(e==null||n==null)return e==null?n==null?0:-1:1;if(typeof e=="number"&&typeof n=="number")return e-n;if(typeof e=="boolean"||typeof n=="boolean")return+(e===!0||e===1||e==="1")-+(n===!0||n===1||n==="1");let t=String(e),o=String(n);return t<o?-1:t>o?1:0}function Xi(e,n,t){for(let{field:o,descending:a}of e){let i=Yi(n[o],t[o]);if(i!==0)return a?-i:i}return 0}function fr(e,n){return e.numeric&&Number.isFinite(Number(n))?Number(n):n}function Zi(e){if(N(e)&&(e.status===409||e.status===412))return y.changedMeanwhile;let n=Y(e).kind;return n==="forbidden"?y.forbidden:n==="signed-out"?y.signedOut:y.tryAgain}function gr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"alert",h(t,"div",{class:"alert",role:"alert",hidden:!0}));b(this,"loaded",null);b(this,"tracks",new Map);b(this,"pending",0);b(this,"stale",!1);b(this,"dragged",null);b(this,"focusKey",null);b(this,"attempt",null);b(this,"ids",0);b(this,"shownResource",null);b(this,"chosen",null);this.shadowRoot?.insertBefore(this.alert,this.body)}shownFields(){let r=this.loaded;return r===null?[]:[r.status,r.title,...r.fields.map(s=>s.name)]}refresh(){if(this.pending>0)return this.stale=!0,Promise.resolve();this.stale=!1;let r=this.shadowRoot?.activeElement?.closest("article")?.getAttribute("data-id");return r!=null&&(this.focusKey=r),super.refresh()}async load(r,s){if(s===null)return;this.loaded=null;let l=_(this,"resource"),u=_(this,"status-field"),c=_(this,"title-field");l!==this.shownResource&&(this.chosen=null,this.shownResource=l),this.detailTarget();let p=fe(this),m=Math.min(X(this,"page-size",1,50),200),f=this.attr("sort")?.trim()??"",d=Ji(f),g=await s.schema(l);if(r.aborted)return;let w=g?.fields.find(F=>F.name===u),v=g===null||g.fields.some(F=>F.name==="id"),k=Z(this.attr("fields")),S=k===null?[]:ee(g,k,W(this)),R={fields:[...new Set([...v?["id"]:[],c,u,...S.map(F=>F.name),...d.map(F=>F.field)])],page:{size:m}};f!==""&&(R.sort=f);let L=s.resource(l),j=await Promise.all(this.columnValues(w?.enum??null).map(async F=>{let{data:T,meta:E}=await L.list({...R,filter:{...p,[u]:F.value}},{signal:r});return{...F,rows:[...T],total:E.page?.total??T.length}}));if(r.aborted)return;let x={session:s,user:le(s),resource:l,status:u,title:c,fields:S,columns:j,canMove:v&&g!==null&&g.actions.includes("update")&&w?.readonly===!1,order:d,numeric:w?.type==="integer"||w?.type==="number"};this.loaded=x,this.tracks.clear(),this.render(x)}columnValues(r){let s=Array.from(this.children).filter(u=>u.localName==="cube-column"),l=s.length>0?s.map(u=>{let c=_(u,"value");return{value:c,label:u.getAttribute("label")?.trim()||K(c)}}):(r??[]).map(u=>({value:u,label:K(u)}));if(l.length===0)throw new J({kind:"error",detail:y.noColumns,retry:!1});return l}render(r){let s=new Map;C(this.body),this.body.append(...[r.canMove&&this.notSaved(r.session),h(t,"div",{class:"board"},...r.columns.map(u=>this.column(r,u,s)))].filter(u=>!!u));let l=this.focusKey;this.focusKey=null,l!==null&&s.get(l)?.focus()}column(r,s,l){let u=`b${++this.ids}`,c=s.total-s.rows.length;return h(t,"section",{class:"card",role:"group","aria-labelledby":u,ondragover:p=>{r.canMove&&this.dragged!==null&&p.preventDefault()},ondrop:p=>{p.preventDefault();let m=this.dragged;this.dragged=null,m!==null&&this.move(r,m,s.value)}},h(t,"h3",{id:u},s.label," ",h(t,"span",{class:"badge"},`${s.total}`)),...s.rows.length===0?[h(t,"p",{class:"muted"},y.emptyColumn)]:s.rows.map(p=>this.card(r,s,p,l)),c>0?h(t,"p",{class:"muted"},y.more(c)):null)}card(r,s,l,u){let c=gt(l),p=`b${++this.ids}`,m=l.id!=null&&c===this.chosen,f=h(t,"article",{tabindex:"0",draggable:r.canMove?"true":"false","data-id":c,"aria-labelledby":p,class:m?"chosen":null,"aria-current":m?"true":null,onclick:d=>{d.target.closest("button")===null&&this.select(r,l)},onkeydown:(d=>{d.target!==f||d.altKey||d.ctrlKey||d.metaKey||d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),this.select(r,l))}),ondragstart:d=>{this.dragged=c,d.dataTransfer?.setData("text/plain",c)},ondragend:()=>{this.dragged=null}},h(t,"p",{class:"title",id:p},I(l[r.title],"text")),r.fields.length===0?null:h(t,"dl",{},...r.fields.flatMap(d=>[h(t,"dt",{},d.label),h(t,"dd",{},I(l[d.name],d.format))])),r.canMove?h(t,"div",{class:"moves"},...r.columns.filter(d=>d!==s).map(d=>h(t,"button",{type:"button",class:"secondary","aria-label":y.moveTo(d.label),"aria-describedby":p,onclick:()=>this.move(r,c,d.value)},d.label))):null);return u.set(c,f),f}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new A(y.invalid.selector(this.localName,"detail",r))}}select(r,s){let l=s.id??null;this.chosen=l===null?null:String(l);for(let c of Array.from(this.body.querySelectorAll("article"))){let p=c.getAttribute("data-id")===this.chosen;c.classList.toggle("chosen",p),p?c.setAttribute("aria-current","true"):c.removeAttribute("aria-current")}if(this.emit("cube-select",{resource:r.resource,id:l,row:s}),l===null)return;let u=null;try{u=this.detailTarget()}catch(c){this.showState(Y(c));return}u?.setAttribute("record-id",String(l))}place(r,s,l){let u=r.columns.find(c=>c.value===l);for(let c of r.columns){let p=c.rows.findIndex(f=>gt(f)===s),m=c.rows[p];if(!(m===void 0||u===void 0)){if(c.rows.splice(p,1),c.total--,m[r.status]=fr(r,l),r.order.length===0)u.rows.unshift(m);else{let f=u.rows.findIndex(d=>Xi(r.order,d,m)>0);u.rows.splice(f===-1?u.rows.length:f,0,m)}return u.total++,{row:m,from:c.value}}}return null}move(r,s,l){let u=r.columns.find(w=>w.rows.some(v=>gt(v)===s));if(!r.canMove||this.loaded!==r||u===void 0||u.value===l)return;let c=this.place(r,s,l);if(c===null)return;let{row:p,from:m}=c;this.alert.hidden=!0,this.focusKey=s,this.render(r);let f=this.tracks.get(s);f===void 0&&(f={confirmed:m,tail:Promise.resolve(),generation:0},this.tracks.set(s,f));let d=f,g=d.generation;this.pending++,d.tail=d.tail.then(()=>g===d.generation?this.send(r,d,p,m,l):void 0).finally(()=>{--this.pending===0&&this.stale&&this.refresh()})}async send(r,s,l,u,c){let p=gt(l),m={[r.status]:fr(r,c)},f=Se(this.attempt,JSON.stringify([r.resource,p,m]));this.attempt=f;try{let d=await this.session();if(le(d)!==r.user){s.generation++,this.stale=!0;return}await d.resource(r.resource).update(l.id,m,{idempotencyKey:f.key}),this.attempt===f&&(this.attempt=null),s.confirmed=c,this.emit("cube-move",{resource:r.resource,id:l.id,from:u,to:c}),this.emit("cube-data-change",{resource:r.resource})}catch(d){if(N(d)&&this.attempt===f&&(this.attempt=null),s.generation++,N(d)&&(d.status===409||d.status===412)&&(this.stale=!0),this.loaded!==r)return;this.place(r,p,s.confirmed),this.focusKey=p,this.render(r),C(this.alert),this.alert.append(`${y.moveFailed} ${Zi(d)}`),this.alert.hidden=!1}}}return b(o,"tag","cube-board"),b(o,"css",Qi),b(o,"reloadsOnOwnChange",!1),o}var es=`${O}${ge}${we}
|
|
90
93
|
.inputs{display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))}
|
|
91
94
|
.inputs:empty{display:none}
|
|
92
95
|
.results{display:flex;flex-wrap:wrap;gap:1rem 2rem;margin-top:1.25rem;padding-top:1rem;
|
|
@@ -98,7 +101,7 @@ border-top:1px solid var(--cube-color-border)}
|
|
|
98
101
|
.result.emphasis output{font-size:2rem;font-weight:700;line-height:1.2}
|
|
99
102
|
.alert{margin:1rem 0 0;color:var(--cube-color-danger,#b42318)}
|
|
100
103
|
.alert:empty{margin:0}
|
|
101
|
-
`,
|
|
104
|
+
`,ts=["number","integer","currency","percent","text","select","checkbox"],ns=["number","integer","currency","percent","text"],hr=0;function br(e,n,t){let o=e.getAttribute(n)?.trim()??"",a=o===""?t[0]:o;if(!t.includes(a))throw new A(y.invalid.value(e.localName,n,a));return a}function Gt(e,n){let t=e.getAttribute(n)?.trim()??"";if(t==="")return null;let o=Number(t);if(!Number.isFinite(o)||n==="step"&&o<=0)throw new A(y.invalid.number(e.localName,n));return o}var $e=e=>I(e,"number");function yr(e){let n=e.editor.read();if("error"in n||typeof n.value!="number")return n;let t=e.format==="percent"?Number((n.value*100).toPrecision(12)):n.value,{min:o,max:a,step:i}=e;if(o!==null&&t<o||a!==null&&t>a)return{error:o===null?y.atMost($e(a)):a===null?y.atLeast($e(o)):y.range($e(o),$e(a))};if(i!==null){let r=(t-(o??0))/i;if(Math.abs(r-Math.round(r))>1e-9)return{error:y.step($e(i))}}return n}function wr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"fn",null);b(this,"drawn",null);b(this,"shownValues",{});b(this,"shownResults",{});let u=Object.getOwnPropertyDescriptor(this,"formula");u!==void 0&&(delete this.formula,this.fn=u.value)}get formula(){return typeof this.fn=="function"?this.fn:null}set formula(u){this.fn=u,this.drawn!==null&&(u===null||typeof u=="function")?this.calculate(!0):(this.drawn=null,this.refresh())}get values(){return{...this.shownValues}}get results(){return{...this.shownResults}}refresh(){return this.drawn!==null&&this.drawn.label===this.attr("label")?Promise.resolve():(this.drawn=null,super.refresh())}async load(){if(this.drawn=null,this.fn!==null&&typeof this.fn!="function")throw new J({kind:"error",detail:y.invalid.formula,retry:!1});let u=Array.from(this.children),c=u.filter(w=>w.localName==="cube-input").map(i),p=u.filter(w=>w.localName==="cube-result").map(r);if(p.length===0)throw new A(y.invalid.missing(this.localName,"cube-result"));a("cube-input",c.map(w=>w.editor.name)),a("cube-result",p.map(w=>w.name));let m=this.attr("label"),f=m===null||m.trim()===""?null:h(t,"p",{class:"label",id:`cube-calc-${++hr}`},m),d=h(t,"p",{class:"alert",role:"alert"}),g=h(t,"form",{novalidate:!0,"aria-labelledby":f?.id??null},h(t,"div",{class:"inputs"},...c.map(w=>w.editor.element)),h(t,"div",{class:"results","aria-live":"polite"},...p.map(w=>w.element)),d);g.addEventListener("submit",w=>w.preventDefault()),g.addEventListener("input",()=>this.calculate(!0,!0)),g.addEventListener("change",()=>this.showErrors()),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},f,g)),this.drawn={label:m,inputs:c,results:p,alert:d},this.showErrors(),this.calculate(!1)}showErrors(){for(let u of this.drawn?.inputs??[]){let c=yr(u);u.shown="error"in c,u.editor.setError("error"in c?c.error:null)}}calculate(u,c=!1){let p=this.drawn;if(p===null)return;let m={};for(let g of p.inputs){let w=yr(g);m[g.editor.name]="error"in w?null:w.value,g.shown&&(g.shown="error"in w,g.editor.setError("error"in w?w.error:null))}let f={},d=!1;try{let g=this.formula,w=g===null?null:g({...m});if((typeof w=="object"||typeof w=="function")&&w!==null&&typeof w.then=="function"){this.drawn=null,this.showState({kind:"error",detail:y.invalid.calcAsync,retry:!1});return}let v=w===null||typeof w!="object";if(v&&w!==null&&w!==void 0&&p.results.length>1){if(c)throw new A(y.invalid.calcSingle);this.drawn=null,this.showState({kind:"error",detail:y.invalid.calcSingle,retry:!1});return}for(let k of p.results){let S=v?w:w[k.name],R=typeof S=="number"&&!Number.isFinite(S)||k.format!=="text"&&typeof S=="object"&&S!==null;d||(d=R),f[k.name]=R||S===void 0?null:S}}catch(g){p.alert.textContent===""&&console.warn(g),d=!0;for(let w of p.results)f[w.name]=null}for(let g of p.results)g.output.textContent=I(f[g.name],g.format,{currency:g.currency});d&&p.alert.textContent===""&&(p.alert.textContent=y.calcFailed),d||(p.alert.textContent=""),this.shownValues=m,this.shownResults=f,u&&this.emit("cube-change",{values:{...m},results:{...f}})}}b(o,"tag","cube-calc"),b(o,"css",es),b(o,"needsSession",!1);function a(s,l){let u=l.find((c,p)=>l.indexOf(c)!==p);if(u!==void 0)throw new A(y.invalid.duplicate(s,u))}function i(s){let l=_(s,"name"),u=_(s,"label"),c=br(s,"type",ts),p=c==="select"?"text":c==="checkbox"?"boolean":c,m=c==="checkbox"?null:qt(s.getAttribute("options"));if(c==="select"&&m===null)throw new A(y.invalid.missing(s.localName,"options"));let f=s.getAttribute("value"),d=f===null?{value:null}:_e(f,p);return{editor:ve(t,{name:l,label:u,format:p,field:void 0,config:{name:l,label:u,format:p,multiline:!1,options:m,hidden:!1}},"error"in d?f:d.value,!1),format:p,min:Gt(s,"min"),max:Gt(s,"max"),step:Gt(s,"step"),shown:!1}}function r(s){let l=_(s,"name"),u=_(s,"label"),c=br(s,"format",ns),p=s.getAttribute("currency")?.trim().toUpperCase()||"EUR";try{I(0,"currency",{currency:p})}catch{throw new A(y.invalid.value(s.localName,"currency",p))}let m=`cube-result-${++hr}`,f=h(t,"output",{id:m,name:l}),d=s.hasAttribute("emphasis")&&s.getAttribute("emphasis")!=="false",g=h(t,"div",{class:d?"result emphasis":"result"},h(t,"label",{for:m},u),f);return{name:l,format:c,currency:p,element:g,output:f}}return o}var Pe=56,Wt=8,vr=8,rs=24,Qt=7,kr=8;function os(e,n,t=4){let o=Math.min(e,0),a=Math.max(n,0);if(a<=o)return[0,1];let i=(a-o)/t,r=10**Math.floor(Math.log10(i)),s=i/r,l=(s<=1?1:s<=2?2:s<=5?5:10)*r,u=[];for(let c=Math.floor(o/l);c<=Math.ceil(a/l);c++)u.push(Number((c*l).toPrecision(12)));return u}function is(e,n,t,o){let a=Math.max(1,Math.floor(t/Qt)),i=n.length<=a?n:`${n.slice(0,a-1)}\u2026`,r=i.length*Qt/2,s=Math.min(Math.max(o.x,o.left+r),o.right-r),l=H(e,"text",{class:"x",x:s,y:o.y},i);return i!==n&&l.append(H(e,"title",{},n)),l}function Sr(e,n,t,o){let{width:a,height:i}=t,r=n.points.map(x=>x.value??0),s=os(Math.min(...r),Math.max(...r)),l=s[0]??0,u=(s.at(-1)??1)-l||1,c=i-vr-rs,p=Math.max(a-Pe-Wt,1),m=n.points.length,f=p/Math.max(m,1),d=x=>vr+c*(1-(x-l)/u),g=x=>Pe+f*(x+.5),w=H(e,"svg",{viewBox:`0 0 ${a} ${i}`,width:"100%",height:i,role:"img","aria-label":`${n.label}, ${y.points(m)}`});for(let x of s)w.append(H(e,"line",{class:"grid",x1:Pe,x2:a-Wt,y1:d(x),y2:d(x)}),H(e,"text",{class:"tick",x:Pe-6,y:d(x)+4},o(x,!0)));let v=n.points.map(x=>x.tick??x.label),k=Math.max(1,...v.map(x=>x.length)),S=n.categories===!0?1:Math.ceil(m/Math.max(1,Math.floor(p/(k*Qt+kr)))),R=n.points.map((x,F)=>F).filter(x=>x%S===0),L=f*S-kr/2;for(let x of R){let F={x:g(x),y:i-6,left:Pe,right:a-Wt};w.append(is(e,v[x]??"",L,F))}return{root:w,band:f,x:g,y:d,title:x=>H(e,"title",{},`${x.label}: ${x.value===null?y.emptyValue:o(x.value)}`)}}function xr(e,n,t,o){let{root:a,x:i,y:r,title:s}=Sr(e,n,t,o),l="",u="M";return n.points.forEach((c,p)=>{if(c.value===null){u="M";return}l+=`${u}${i(p).toFixed(1)} ${r(c.value).toFixed(1)}`,u="L"}),a.append(H(e,"path",{class:"s1",d:l})),n.points.forEach((c,p)=>{c.value!==null&&a.append(H(e,"circle",{class:"s1",cx:i(p),cy:r(c.value),r:3},s(c)))}),a}function Tr(e,n,t,o){let{root:a,band:i,x:r,y:s,title:l}=Sr(e,n,t,o),u=i*.7;return n.points.forEach((c,p)=>{let m=s(Math.max(c.value??0,0)),f=s(Math.min(c.value??0,0));a.append(H(e,"rect",{class:"s1",x:r(p)-u/2,y:m,width:u,height:f-m},l(c)))}),a}var Jt=864e5,ss=600,as=["line","bar"],ls=`${O}${ge}
|
|
102
105
|
svg{display:block;overflow:visible}
|
|
103
106
|
.grid{stroke:var(--cube-color-border)}
|
|
104
107
|
.tick,.x{font-size:12px;fill:var(--cube-color-text-muted)}
|
|
@@ -106,11 +109,11 @@ svg{display:block;overflow:visible}
|
|
|
106
109
|
.x{text-anchor:middle}
|
|
107
110
|
rect.s1,circle.s1{fill:var(--cube-color-series-1)}
|
|
108
111
|
path.s1{fill:none;stroke:var(--cube-color-series-1);stroke-width:2}
|
|
109
|
-
`;function
|
|
112
|
+
`;function us(e,n){let t=e.toISOString().slice(0,10);switch(n){case"day":return t;case"week":{let o=new Date(e.getTime()+(3-(e.getUTCDay()+6)%7)*Jt),a=o.getUTCFullYear(),i=1+Math.floor((o.getTime()-Date.UTC(a,0,1))/(7*Jt));return`${a}-W${String(i).padStart(2,"0")}`}case"month":return t.slice(0,7);case"quarter":return`${t.slice(0,4)}-Q${Math.ceil((e.getUTCMonth()+1)/3)}`;case"year":return t.slice(0,4)}}function cs(e,n){let t=It(e,"month",{short:!0});return n||e.endsWith("-01")?y.monthYear(t,e.slice(0,4)):t}function Cr(e,n,t){let o=new Set,a=Date.parse(`${n}T00:00:00Z`);for(let i=Date.parse(`${e}T00:00:00Z`);i<=a;i+=Jt)o.add(us(new Date(i),t));return[...o]}function Ar(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(this));b(this,"plot",h(n.document,"div",{class:"plot"}));b(this,"observer",null);b(this,"observed",0);b(this,"drawn",0);b(this,"drawing",null)}shownFields(){return he(this)}connectedCallback(){super.connectedCallback(),!(this.observer!==null||n.ResizeObserver===void 0)&&(this.observer=new n.ResizeObserver(i=>{let r=Math.round(i.at(-1)?.contentRect.width??0);r<=0||(this.observed=r,r!==this.drawn&&this.draw())}),this.observer.observe(this.plot))}disconnectedCallback(){super.disconnectedCallback(),this.observer?.disconnect(),this.observer=null}async load(i,r){if(r===null)return;let s=_(this,"resource"),l=_(this,"by"),{field:u,truncation:c}=Ze(l),p=X(this,"height",80,240),m=X(this,"limit",1,12),f=await be(this,this.period,i,l);if(f===null)return;let{fn:d,period:g}=f,{data:w}=await dt(r,s,l,f,i);if(i.aborted)return;let v=w.filter(L=>L[l]!==null&&L[l]!==void 0);if(v.length===0){this.showState("empty");return}let k;if(c!==null){let L=new Map(v.map(T=>[String(T[l]),Me(T[d])])),j=g===null?[...L.keys()].sort():Cr(g.from,g.to,c),x=g?.today??g?.to??"",F=g===null||x<g.from?new Set:new Set(Cr(g.from,x<g.to?x:g.to,c));k=j.map((T,E)=>({key:T,label:It(T,c),...c==="month"?{tick:cs(T,E===0)}:{},value:g===null||!F.has(T)?L.get(T)??null:L.get(T)??0}))}else{let L=await pt(this,r,v,{by:l,fn:d},{descending:!0,limit:m},i);if(L===null)return;if(L.length===0){this.showState("empty");return}k=L}let S=this.attr("label")??K(f.field??d),R=this.attr("kind");this.render({label:S,points:k,categories:c===null},p,{line:as.includes(R??"")?R==="line":c!==null,format:ye(this,f.count),byLabel:K(u)})}render(i,r,s){let l=n.document;this.drawing={series:i,height:r,line:s.line,format:s.format};let u=c=>c===null?y.emptyValue:s.format(c);C(this.body),this.body.appendChild(h(l,"div",{class:"card"},this.attr("label")===null?"":h(l,"p",{class:"label","aria-hidden":"true"},i.label),this.plot,h(l,"div",{class:"sr-only"},h(l,"table",{},h(l,"caption",{},y.asTable),h(l,"thead",{},h(l,"tr",{},h(l,"th",{scope:"col"},s.byLabel),h(l,"th",{scope:"col"},i.label))),h(l,"tbody",{},...i.points.map(c=>h(l,"tr",{},h(l,"th",{scope:"row"},c.label),h(l,"td",{},u(c.value))))))))),this.draw()}draw(){if(this.drawing===null)return;let{series:i,height:r,line:s,format:l}=this.drawing,u=this.observed||Math.round(this.plot.clientWidth)||ss;this.drawn=u,C(this.plot),this.plot.appendChild((s?xr:Tr)(n.document,i,{width:u,height:r},l))}}return b(t,"tag","cube-chart"),b(t,"css",ls),t}var ds=`${O}${we}${ke}
|
|
110
113
|
dl{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.5rem 1rem;margin:0}
|
|
111
114
|
dt{font-weight:600}
|
|
112
115
|
dd{margin:0;min-width:0;overflow-wrap:anywhere}
|
|
113
|
-
`,
|
|
116
|
+
`,Rr=e=>e.field!==void 0&&!e.field.readonly;function ps(e,n,t){let o=n===void 0||n===""?null:n;if(o===t||o===null&&t===!1&&e.format==="boolean")return!0;if(o===null||t===null)return!1;if(e.format==="date"&&typeof o=="string"&&typeof t=="string")return o.slice(0,10)===t;if(typeof t=="number"&&typeof o=="string")return Number(o)===t;if(typeof t=="string"&&typeof o=="number")return String(o)===t;if(e.format==="datetime"&&typeof o=="string"&&typeof t=="string"){let a=i=>Math.floor(Date.parse(i)/6e4);return a(o)===a(t)}return typeof o=="object"&&JSON.stringify(o)===JSON.stringify(t)}function Er(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"status",h(t,"p",{class:"status",role:"status"}));b(this,"loaded",null);b(this,"editing",null);b(this,"attempt",null);b(this,"saved",null);b(this,"edit",null);this.shadowRoot?.appendChild(this.status)}disconnectedCallback(){super.disconnectedCallback(),this.editing=null}refresh(){let r=this.editing;return r!==null&&r.resource===this.attr("resource")?.trim()&&r.id===this.recordId()&&r.user===le(this.loaded?.session)?Promise.resolve():(this.editing=null,super.refresh())}shownFields(){return this.loaded?.columns.map(r=>r.name)??[]}recordId(){let r=this.attr("record-id")?.trim()??"";return r===""?null:r}async load(r,s){if(s===null)return;this.loaded=null;let l=_(this,"resource"),u=this.recordId(),c=this.saved!==null&&this.saved.resource===l&&this.saved.id===u;if(this.saved=null,c||(this.status.textContent=""),u===null){this.showState("empty",y.chooseRow);return}let p=await s.schema(l);if(r.aborted)return;let m=Z(this.attr("fields")),f=await s.resource(l).get(u,m===null?{}:{fields:m},{signal:r});if(r.aborted)return;let d=f.data,g={session:s,resource:l,id:u,columns:ee(p,m,W(this),d),row:d,version:f.recordVersion,canEdit:this.flag("editable")&&this.allowsUpdate(p)};this.loaded=g,this.renderView(g),c&&this.edit?.focus()}allowsUpdate(r){return r!==null&&r.actions.includes("update")}renderView(r){this.edit=r.canEdit&&r.columns.some(Rr)?h(t,"button",{type:"button",onclick:()=>this.startEditing(r)},y.edit):null,C(this.body),this.body.appendChild(h(t,"div",{class:"card"},h(t,"dl",{},...r.columns.flatMap(s=>this.pair(r,s))),this.edit===null?null:h(t,"div",{class:"actions"},this.edit,this.notSaved(r.session))))}pair(r,s){let l=this.exampleField(r.session,r.resource,s.name);return[h(t,"dt",{},s.label,...l?[" ",at(t)]:[]),h(t,"dd",{class:l?"example":null},I(r.row[s.name],s.format))]}startEditing(r){this.editing={resource:r.resource,id:r.id,user:le(r.session)},this.status.textContent="";let s=[],l=r.columns.map(f=>{if(!Rr(f))return h(t,"dl",{},...this.pair(r,f));let d=ve(t,f,r.row[f.name],f.field?.nullable===!1);return s.push(d),d.element}),u=h(t,"div",{class:"alert",role:"alert",tabindex:"-1",hidden:!0}),c=h(t,"button",{type:"submit"},y.save),p=h(t,"button",{type:"button",class:"secondary",onclick:()=>{this.editing=null,this.attempt=null,this.renderView(r),this.edit?.focus()}},y.cancel),m=h(t,"form",{novalidate:!0},u,...l,h(t,"div",{class:"actions"},c,p,this.notSaved(r.session)));m.addEventListener("submit",f=>{f.preventDefault(),this.save(r,s,{alert:u,save:c,cancel:p})}),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},m)),s[0]?.element.querySelector("input,select,textarea")?.focus()}async save(r,s,l){if(l.save.disabled)return;let u={},c=!1;for(let f of s){let d=f.read(),g=r.columns.find(w=>w.name===f.name);if("error"in d){f.setError(d.error),c=!0;continue}f.setError(null),ps(g,r.row[f.name],d.value)||(u[f.name]=d.value)}if(c){Oe(t,l.alert,y.formInvalid);return}if(Object.keys(u).length===0){this.editing=null,this.renderView(r),this.edit?.focus();return}let p=JSON.stringify([r.resource,r.id,u]);this.attempt=Se(this.attempt,p);let m={idempotencyKey:this.attempt.key};r.version!==null&&(m.ifMatch=r.version),l.save.disabled=!0,l.cancel.disabled=!0,l.alert.hidden=!0;try{let f=await this.session();if(this.editing!==null&&this.editing.user!==le(f)){this.editing=null,this.refresh();return}let d=await f.resource(r.resource).update(r.id,u,m);this.attempt=null;let g=d.data;if(this.loaded===r&&this.editing!==null){this.editing=null;let w={...r.row,...u,...g},v={...r,row:w,version:d.recordVersion};this.loaded=v,this.saved={resource:r.resource,id:r.id},this.renderView(v),this.status.textContent=y.saved,this.edit?.focus()}this.emit("cube-saved",{resource:r.resource,id:g.id??r.id,row:g}),this.emit("cube-data-change",{resource:r.resource})}catch(f){if(this.loaded!==r||this.editing===null)return;l.cancel.disabled=!1,this.failed(f,s,l)}}failed(r,s,l){if(N(r)&&(this.attempt=null),N(r)&&(r.status===409||r.status===412)){let u=h(t,"button",{type:"button",class:"secondary",onclick:()=>{this.editing=null,this.refresh()}},y.reload);Oe(t,l.alert,y.conflict,u);return}l.save.disabled=!1,ft(t,l.alert,r,s,u=>Fe(W(this),u))}}return b(o,"tag","cube-detail"),b(o,"css",ds),o}var ms=`${O}${we}${ke}`,fs=["resource","fields","submit-label","success-text"];function Mr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"status",h(t,"p",{class:"status",role:"status"}));b(this,"drawn",null);b(this,"shown",null);b(this,"attempt",null);this.shadowRoot?.appendChild(this.status)}shownFields(){return this.drawn?.columns.map(r=>r.name)??[]}key(){let r=this.drawn?.session.user()?.id??null;return JSON.stringify([...fs.map(s=>this.attr(s)),r])}text(r,s){let l=this.attr(r)?.trim()??"";return l===""?s:l}refresh(){return this.shown===this.key()?Promise.resolve():(this.shown=null,super.refresh())}async load(r,s){if(s===null)return;this.drawn=null,this.attempt=null;let l=_(this,"resource"),u=await s.schema(l);if(r.aborted)return;if(u===null||!u.actions.includes("create")){this.showState({kind:"forbidden",detail:null,retry:!1});return}let c=u.fields.filter(d=>!d.readonly&&d.name!=="id"),m=(Z(this.attr("fields"))??c.map(d=>d.name)).filter(d=>c.some(g=>g.name===d)),f=ee(u,m,W(this));if(f.length===0){this.showState({kind:"error",detail:y.noWritableFields,retry:!1});return}this.drawn={session:s,resource:l,columns:f},this.shown=this.key(),this.renderForm(!1)}renderForm(r){let s=this.drawn;this.status.textContent="";let l=s.columns.map(m=>ve(t,m,null,m.field?.nullable===!1&&m.format!=="boolean")),u=h(t,"div",{class:"alert",role:"alert",tabindex:"-1",hidden:!0}),c=h(t,"button",{type:"submit"},this.text("submit-label",y.save)),p=h(t,"form",{novalidate:!0},u,...l.map(m=>m.element),h(t,"div",{class:"actions"},c,this.notSaved(s.session)));p.addEventListener("submit",m=>{m.preventDefault(),this.submit(s,l,u,c)}),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},p)),r&&Dr(l[0])?.focus()}async submit(r,s,l,u){if(u.disabled)return;let c={},p=null;for(let f of s){let d=f.read();f.setError("error"in d?d.error:null),"error"in d?p??(p=f):d.value!==null&&(c[f.name]=d.value)}if(p!==null){l.hidden=!0,Dr(p)?.focus();return}this.attempt=Se(this.attempt,JSON.stringify([r.resource,c]));let m=this.attempt.key;u.disabled=!0,l.hidden=!0;try{let d=await(await this.session()).resource(r.resource).create(c,{idempotencyKey:m});this.attempt=null;let g=d.data;this.drawn===r&&this.done(),this.emit("cube-created",{resource:r.resource,row:g}),this.emit("cube-data-change",{resource:r.resource})}catch(f){if(N(f)&&(this.attempt=null),this.drawn!==r)return;u.disabled=!1,ft(t,l,f,s,d=>Fe(W(this),d))}}done(){let r=h(t,"button",{type:"button",onclick:()=>this.renderForm(!0)},y.another);C(this.body);let s=this.drawn===null?null:this.notSaved(this.drawn.session);this.body.appendChild(h(t,"div",{class:"card"},h(t,"div",{class:"actions"},r,s))),this.status.textContent=this.text("success-text",y.formSaved),n.setTimeout(()=>{r.isConnected&&r.focus()},0)}}return b(o,"tag","cube-form"),b(o,"css",ms),o}function Dr(e){return e?.element.querySelector("input,select,textarea")??null}var gs=`${O}
|
|
114
117
|
ul{list-style:none;margin:0;padding:0;display:grid;gap:.75rem}
|
|
115
118
|
h3{margin:0 0 .5rem;font-size:1rem;overflow-wrap:anywhere}
|
|
116
119
|
dl{margin:0;display:grid;gap:.375rem}
|
|
@@ -118,14 +121,14 @@ dl div{display:flex;flex-wrap:wrap;gap:0 .75rem}
|
|
|
118
121
|
dt{flex:0 0 8rem;font-weight:600}
|
|
119
122
|
dd{flex:1 1 12rem;margin:0;min-width:0;overflow-wrap:break-word}
|
|
120
123
|
p{margin:0}
|
|
121
|
-
`;function
|
|
124
|
+
`;function Lr(e,n){let t=n.document;class o extends e{async load(i,r){if(r===null||i.aborted)return;let s=this.attr("scherm")?.trim()??"",l=(r.gaps??[]).filter(c=>s===""||c.scherm===s),u=(c,p)=>h(t,"div",{},h(t,"dt",{},c),h(t,"dd",{},p));C(this.body),this.body.appendChild(l.length===0?h(t,"div",{class:"card"},h(t,"p",{},y.gaps.none)):h(t,"ul",{role:"list","aria-label":y.gaps.what},...l.map(c=>h(t,"li",{class:"card"},h(t,"h3",{},c.veld===void 0?c.resource:`${c.resource}.${c.veld}`),h(t,"dl",{},u(y.gaps.screen,c.scherm),u(y.gaps.type,c.type==="keuze"?`${y.gaps.types.keuze}: ${(c.waarden??[]).join(", ")}`:y.gaps.types[c.type]),u(y.gaps.why,c.reden))))))}}return b(o,"tag","cube-gap-list"),b(o,"css",gs),o}var Fr=new Intl.NumberFormat("nl-NL",{minimumFractionDigits:1,maximumFractionDigits:1}),hs=`${O}
|
|
122
125
|
.kpi{display:flex;flex-direction:column;gap:.25rem}
|
|
123
126
|
.label{margin:0;font-size:.875rem;font-weight:600;color:var(--cube-color-text-muted)}
|
|
124
127
|
.value{margin:0;font-size:2rem;font-weight:700;line-height:1.2;overflow-wrap:anywhere}
|
|
125
128
|
.compare{margin:0;font-size:.875rem;color:var(--cube-color-text-muted)}
|
|
126
129
|
.compare.up{color:var(--cube-color-success)}
|
|
127
130
|
.compare.down{color:var(--cube-color-danger)}
|
|
128
|
-
`;function
|
|
131
|
+
`;function _r(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(this))}shownFields(){return he(this)}async load(i,r){if(r===null)return;let s=_(this,"resource");if(this.flag("compare")&&!this.attr("period"))throw new A(y.invalid.compare(this.localName));let l=await be(this,this.period,i);if(l===null)return;let{fn:u,period:c}=l,p=r.resource(s),m=async w=>{let{data:v}=await p.aggregate({fn:u,filter:l.filterFor(w)},{signal:i});return Me(v[0]?.[u])},f=this.flag("compare")?c?.previous??null:null,[d,g]=await Promise.all([m(c),f===null?null:m(f)]);i.aborted||this.render(d,f===null?void 0:g,l.count)}render(i,r,s){let l=n.document,u=ye(this,s),c=this.attr("label"),p=i===null?h(l,"p",{class:"value"},h(l,"span",{"aria-hidden":"true"},y.emptyValue),h(l,"span",{class:"sr-only"},y.noData)):h(l,"p",{class:"value"},h(l,"data",{value:String(i)},u(i)));C(this.body),this.body.appendChild(h(l,"div",{class:"card kpi"},c===null||c===""?null:h(l,"p",{class:"label"},c),p,r===void 0||i===null?null:this.compareLine(i,r)))}compareLine(i,r){let s=n.document;if(r===null||r===0)return h(s,"p",{class:"compare new"},y.newValue);let l=(i-r)/Math.abs(r),u=Fr.format(Math.abs(l)*100);if(u===Fr.format(0))return h(s,"p",{class:"compare same"},`${u}% ${y.comparedTo}`);let c=l>0;return h(s,"p",{class:c?"compare up":"compare down",role:"img","aria-label":y.change(u,c?y.higher:y.lower)},`${c?"\u25B2":"\u25BC"} ${u}% ${y.comparedTo}`)}}return b(t,"tag","cube-kpi"),b(t,"css",hs),t}var bs=864e5;function re(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function bt(e,n){return{from:U(e),to:U(n)}}function ht(e,n,t){let o=e.getFullYear(),a=e.getMonth()+n;return bt(re(o,a,1),re(o,a+t,0))}function ys(e,n){return Math.round((Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))/bs)+1}function Yt(e,n,t){switch(e){case"this-month":return{key:e,...ht(n,0,1),previous:ht(n,-1,1)};case"12m":return{key:e,...ht(n,-11,12),previous:ht(n,-23,12)};case"this-year":{let o=n.getFullYear();return{key:e,...bt(re(o,0,1),re(o,11,31)),previous:bt(re(o-1,0,1),re(o-1,11,31))}}case"custom":{let o=t===void 0?null:B(t.from),a=t===void 0?null:B(t.to);if(t===void 0||o===null||a===null||a<o)throw new TypeError("A custom period needs a valid from and to, from not after to.");let i=ys(o,a);return{key:e,from:t.from,to:t.to,previous:bt(re(o.getFullYear(),o.getMonth(),o.getDate()-i),re(o.getFullYear(),o.getMonth(),o.getDate()-1))}}}}var Xt=["this-month","12m","this-year","custom"],Or="12m",ws=`
|
|
129
132
|
.picker{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem}
|
|
130
133
|
.field{display:flex;flex-direction:column;gap:.25rem;min-width:0}
|
|
131
134
|
label{font-weight:600;font-size:.875rem}
|
|
@@ -135,15 +138,15 @@ label{font-weight:600;font-size:.875rem}
|
|
|
135
138
|
.custom .error:empty{flex-basis:0}
|
|
136
139
|
input[aria-invalid=true]{border:2px solid var(--cube-color-danger)}
|
|
137
140
|
@media (max-width:640px){.picker,.custom{flex-direction:column;align-items:stretch}}
|
|
138
|
-
`;function
|
|
141
|
+
`;function $r(e,n,t,o){return h(e,"div",{class:"field"},h(e,"label",{for:n},t),o)}function Pr(e,n){class t extends e{constructor(){super();b(this,"select");b(this,"label");b(this,"custom");b(this,"from");b(this,"to");b(this,"error");b(this,"chosen",null);b(this,"range",null);b(this,"announced",null);let i=n.document;this.select=h(i,"select",{id:"period",onchange:()=>this.onSelect()},...Xt.map(l=>h(i,"option",{value:l},y.period[l]))),this.label=h(i,"label",{for:"period"});let r=l=>h(i,"input",{type:"date",id:l,onchange:()=>this.onDates()});this.from=r("from"),this.to=r("to"),this.error=h(i,"p",{id:"range-error",class:"error","aria-live":"polite"}),this.custom=h(i,"div",{class:"custom",hidden:!0},$r(i,"from",y.period.from,this.from),$r(i,"to",y.period.to,this.to),this.error);let s=h(i,"div",{class:"field"},this.label,this.select);this.body.appendChild(h(i,"div",{class:"picker"},s,this.custom))}get value(){let i=this.key(),r=this.today();return{...i==="custom"&&this.range!==null?Yt("custom",r,this.range):Yt(i==="custom"?Or:i,r),today:U(r)}}refresh(){return this.render(),this.changed(),Promise.resolve()}async load(){this.render()}showState(){this.render()}key(){if(this.chosen!==null)return this.chosen;let i=this.attr("default");return Xt.includes(i)?i:Or}today(){let i=this.attr("today");return(i===null?null:B(i))??new Date}render(){let i=this.key();this.label.textContent=this.attr("label")??y.period.label,this.select.value=i,this.custom.hidden=i!=="custom",i==="custom"&&this.range===null&&this.fillDates()}fillDates(){let{from:i,to:r}=this.value;this.range={from:i,to:r},this.from.value=i,this.to.value=r,this.explain(null)}onSelect(){let i=this.select.value;Xt.includes(i)&&(i==="custom"&&this.key()!=="custom"&&(this.range=null,this.fillDates()),this.chosen=i,this.render(),this.changed())}onDates(){let i={from:this.from.value,to:this.to.value},r=B(i.from),s=B(i.to);if(r===null||s===null){this.explain(y.period.incompleteDate);return}if(s<r){this.explain(y.period.invalidRange);return}this.explain(null),this.range=i,this.changed()}changed(){let i=this.value,r=JSON.stringify(i),s=this.announced;this.announced=r,s!==null&&s!==r&&this.emit("cube-change",i)}explain(i){this.error.textContent=i??"";for(let r of[this.from,this.to])i===null?(r.removeAttribute("aria-invalid"),r.removeAttribute("aria-describedby")):(r.setAttribute("aria-invalid","true"),r.setAttribute("aria-describedby",this.error.id))}}return b(t,"tag","cube-period-picker"),b(t,"css",ws),b(t,"needsSession",!1),t}var vs=["loading","empty","error","forbidden","signed-out"],ks={loading:y.loading,empty:y.empty,error:y.error,forbidden:y.forbidden,"signed-out":y.signedOut},Ss=`
|
|
139
142
|
.state{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:1rem;border:1px solid var(--cube-color-border);
|
|
140
143
|
border-radius:var(--cube-radius);background:var(--cube-color-surface)}
|
|
141
144
|
.state[data-kind=error]{border-left:4px solid var(--cube-color-danger)}
|
|
142
145
|
.state[data-kind=forbidden],.state[data-kind=signed-out]{border-left:4px solid var(--cube-color-warning)}
|
|
143
146
|
.state p{margin:0;flex:1 1 12rem}
|
|
144
147
|
.state[data-kind=loading] p,.state[data-kind=empty] p{color:var(--cube-color-text-muted)}
|
|
145
|
-
`,
|
|
146
|
-
`).join("")}`}function
|
|
148
|
+
`,Nr=["error","forbidden","signed-out"],yt=new WeakMap;function jr(e,n){class t extends e{constructor(){super();b(this,"failed",!1);b(this,"kind","loading");b(this,"region");b(this,"message");b(this,"action",null);b(this,"announce",null);this.message=h(n.document,"p"),this.region=h(n.document,"div",{class:"state"},this.message)}disconnectedCallback(){super.disconnectedCallback(),yt.get(this.ownerDocument)===this&&yt.delete(this.ownerDocument),this.announce!==null&&n.clearTimeout(this.announce),this.announce=null}refresh(){return this.failed=!1,this.render(),Promise.resolve()}async load(){this.render()}showState(){this.render()}render(){let i=this.attr("kind"),r=this.failed?"error":vs.includes(i)?i:"loading",s=this.ownerDocument;this.kind=r;let l=Nr.includes(r)&&this.claimAlert();this.action?.remove(),this.action=null,r==="signed-out"?this.action=h(s,"button",{type:"button",onclick:()=>{this.signIn()}},y.signIn):r==="error"&&(this.failed||this.attr("retry")!=="false")&&(this.action=h(s,"button",{type:"button",class:"secondary",onclick:()=>{this.emit("cube-retry")}},y.retry)),this.region.setAttribute("data-kind",r),r==="loading"?this.region.removeAttribute("role"):this.region.setAttribute("role",l?"alert":"status"),l?this.region.removeAttribute("aria-live"):this.region.setAttribute("aria-live",r==="loading"?"off":"polite"),this.action!==null&&this.region.appendChild(this.action),this.region.parentNode!==this.body&&(C(this.body),this.body.appendChild(this.region));let u=this.failed?y.error:this.attr("message")??ks[r];if(this.announce!==null&&n.clearTimeout(this.announce),this.announce=null,this.message.textContent!==u){if(r==="loading"){this.message.textContent=u;return}this.message.textContent="",this.announce=n.setTimeout(()=>{this.announce=null,this.message.textContent=u},0)}}claimAlert(){let i=this.ownerDocument,r=yt.get(i);return r!==void 0&&r!==this&&r.isConnected&&Nr.includes(r.kind)?!1:(yt.set(i,this),!0)}async signIn(){try{await(await this.session()).signIn()}catch{this.failed=!0,this.render();return}let i=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;this.ownerDocument.dispatchEvent(new i("cube-session-change"))}}return b(t,"tag","cube-state"),b(t,"css",Ss),b(t,"needsSession",!1),t}var xs=/^[=+\-@\t\r]/,Ts=/[;"\r\n]/;function Ir(e,n){if(e==null)return"";let t=ne.includes(n)?ae(e):null,o;return t!==null?o=(String(t).includes("e")?t.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20}):String(t)).replace(".",","):(typeof e=="boolean"?o=e?y.yes.toLowerCase():y.no.toLowerCase():typeof e=="object"?o=JSON.stringify(e):o=String(e),xs.test(o)&&(o=`'${o}`)),Ts.test(o)?`"${o.replace(/"/g,'""')}"`:o}function Br(e,n){return`\uFEFF${[e.map(o=>Ir(o.label,"text")),...n.map(o=>e.map(a=>Ir(o[a.name],a.format)))].map(o=>`${o.join(";")}\r
|
|
149
|
+
`).join("")}`}function Ur(e,n,t){let o=e.defaultView,a=new(o?.Blob??Blob)([t],{type:"text/csv;charset=utf-8"}),i=(o?.URL??URL).createObjectURL(a),r=h(e,"a",{href:i,download:n,hidden:!0});e.body.appendChild(r),r.click(),r.remove(),(o?.setTimeout??setTimeout)(()=>(o?.URL??URL).revokeObjectURL(i),0)}var Cs=`${O}
|
|
147
150
|
.tools{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem;margin-bottom:.75rem}
|
|
148
151
|
.control{display:flex;flex-direction:column;gap:.25rem;min-width:0;max-width:100%}
|
|
149
152
|
.control>label,legend{font-weight:600}
|
|
@@ -166,7 +169,7 @@ tbody tr.chosen{background:var(--cube-color-primary-subtle);box-shadow:inset 4px
|
|
|
166
169
|
.pager{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.75rem}
|
|
167
170
|
.pager p,.export-status{margin:0;color:var(--cube-color-text-muted)}
|
|
168
171
|
.pager p{margin-inline-end:auto}
|
|
169
|
-
`,wt=ee,Ur=200,Ts=50,Cs=300,Hr=" search";function As(e){let n=j(e.slice(0,10));return n===null?null:(n.setDate(n.getDate()+1),I(n))}var le=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function zr(e,n,t){let o=e[n];e[n]=le(o)&&le(t)?{...o,...t}:t}function Rs(e,n){let t=se(e),o=se(n);if(t!==null&&o!==null)return Math.sign(t-o);let a=String(e),i=String(n);return a<i?-1:a>i?1:0}function Vr(e){return e!==void 0&&(!le(e)||"ilike"in e)}function Es(e,n){if(!le(e)||!le(n))return e;let t={...n,...e};for(let[o,a]of[["gte",1],["gt",1],["lte",-1],["lt",-1]]){let i=e[o],r=n[o];i!=null&&r!==void 0&&r!==null&&(t[o]=Rs(r,i)===a?r:i)}return t}function Kr(e,n){let t=n.document;class o extends e{constructor(){super(...arguments);b(this,"period",new K(this));b(this,"context",null);b(this,"parts",new Map);b(this,"values",new Map);b(this,"sortBy",null);b(this,"page",1);b(this,"requests",0);b(this,"rowsController",null);b(this,"debounce",null);b(this,"exporting",null);b(this,"headers",new Map);b(this,"frame",null);b(this,"table",null);b(this,"pagerText",null);b(this,"previous",null);b(this,"next",null);b(this,"pager",null);b(this,"exportButton",null);b(this,"exportStatus",null);b(this,"shownResource",null);b(this,"chosen",null);b(this,"shownIds",null);b(this,"updates",0);b(this,"warned",new Set)}shownFields(){return this.context?.columns.map(r=>r.name)??[]}disconnectedCallback(){super.disconnectedCallback(),this.stopDebounce(),this.rowsController?.abort(),this.exporting?.abort(),this.exporting=null}async load(r,s){if(s===null)return;this.stopDebounce(),this.context=null,this.rowsController?.abort();let l=F(this,"resource");++this.updates,l!==this.shownResource&&(this.values.clear(),this.sortBy=null,this.page=1,this.chosen=null,this.shownIds=null,this.shownResource=l),this.detailTarget();let u=this.attr("period"),c=u===null||u===""?null:ct(this.attr("date-field"),null,this.localName),d=fe(this),p=await ut(this,u);if(r.aborted)return;this.period.follow(p);let f=p===null||c===null?d:{...d,...lt(c,p.value)},m=await s.schema(l);if(r.aborted)return;let g=Y(this.attr("fields")),w=m===null||m.fields.some(O=>O.name==="id"),v={session:s,resource:l,columns:[],base:f,fields:g===null?void 0:[...new Set([...w?["id"]:[],...g])],size:Math.min(J(this,"page-size",1,25),Ur)};this.exporting?.abort(),this.exporting=null,r.addEventListener("abort",()=>this.rowsController?.abort(),{once:!0});let k=Y(this.attr("filters"))??[];this.checkFilterable(m,k);let S=k.filter(O=>!(O in d)||le(d[O]));for(let O of[...this.parts.keys()])S.includes(O)||this.parts.delete(O);let D=q(this);this.context=v;let L=await this.fetchRows(v,this.query(v,v.size,this.page)),B=L===null?null:await this.lastPageIfPast(v,L);if(B===null||r.aborted)return;let T=B.data[0];v.columns=X(m,g,D,T);let x=new Map([...D].map(([O,G])=>[O,{...G,hidden:!1}])),E=X(m,S,x,T);this.build(v,m,E),this.renderRows(v,B)}checkFilterable(r,s){if(r===null)return;let l=this.attr("search")?.trim()??"",u=s.map(c=>["filters",c]);l!==""&&u.push(["search",l]);for(let[c,d]of u)if(!r.filterable.includes(d))throw new R(y.invalid.notFilterable(this.localName,c,d))}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new R(y.invalid.selector(this.localName,"detail",r))}}query(r,s,l){let u={},c=this.attr("search")?.trim()??"",d=this.values.get(Hr)?.trim()??"";c!==""&&d!==""&&zr(u,c,{ilike:`%${d}%`});for(let[g,w]of this.parts){let v=w();v!==null&&zr(u,g,v)}let p={...r.base};for(let[g,w]of Object.entries(u)){let v=p[g];p[g]=v===void 0?w:Es(v,w)}let f=this.sortBy??(this.attr("sort")?.trim()||null),m={filter:p,page:{size:s,number:l}};return f!==null&&(m.sort=f),r.fields!==void 0&&(m.fields=r.fields),m}async fetchRows(r,s){let l=++this.requests;this.rowsController?.abort();let u=new AbortController;this.rowsController=u,this.setAttribute("aria-busy","true");try{let c=await r.session.resource(r.resource).list(s,{signal:u.signal});return l===this.requests&&!u.signal.aborted?c:null}finally{l===this.requests&&this.removeAttribute("aria-busy")}}async lastPageIfPast(r,s){let l=s.meta.page;return s.data.length>0||this.page<=1||l===void 0||l===null||l.total===0?s:(this.page=Math.max(1,l.pages),this.fetchRows(r,this.query(r,r.size,this.page)))}async update(r){let s=this.context;if(s===null||!this.isConnected)return;r&&(this.page=1);let l=++this.updates;try{let u=await this.fetchRows(s,this.query(s,s.size,this.page)),c=u===null?null:await this.lastPageIfPast(s,u);c!==null&&this.renderRows(s,c)}catch(u){if(l!==this.updates||u?.name==="AbortError")return;this.showRowsState(te(u))}}later(r){this.stopDebounce(),this.debounce=n.setTimeout(()=>{this.debounce=null,this.update(r)},Cs)}stopDebounce(){this.debounce!==null&&n.clearTimeout(this.debounce),this.debounce=null}build(r,s,l){this.parts=new Map;let u=[],c=this.attr("search")?.trim()??"";if(c!==""){Vr(r.base[c])&&this.warnFixed("search",c);let p=h(t,"input",{type:"search"});u.push(this.control(p,Hr,y.search,!0))}for(let p of l)u.push(this.filterControl(p,r.base[p.name]));this.flag("export")?(this.exportButton=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.toggleExport()},y.exportCsv),this.exportStatus=h(t,"p",{class:"export-status",role:"status"}),u.push(this.exportButton,this.exportStatus)):(this.exportButton=null,this.exportStatus=null),this.headers=new Map,this.frame=h(t,"div",{class:"scroll"}),this.pagerText=h(t,"p",{"aria-live":"polite"}),this.previous=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.go(-1)},y.previous),this.next=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.go(1)},y.next),this.pager=h(t,"div",{class:"pager"},this.pagerText,this.previous,this.next);let d=h(t,"thead",{},h(t,"tr",{},...r.columns.map(p=>{let f=s?.sortable.includes(p.name)===!0,m=h(t,"th",{scope:"col",class:wt.includes(p.format)?"num":null},f?h(t,"button",{type:"button",onclick:()=>this.sortOn(p.name)},p.label,h(t,"span",{class:"arrow","aria-hidden":"true"})):p.label,...this.exampleField(r.session,r.resource,p.name)?[" ",at(t)]:[]);return f&&this.headers.set(p.name,m),m})));this.table=h(t,"table",{},h(t,"caption",{class:"sr-only"},z(r.resource)),d,h(t,"tbody")),this.markSort(),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},u.length>0?h(t,"div",{class:"tools"},...u):null,this.frame,this.pager))}control(r,s,l,u,c){let d=`cube-table-${++Ds}`;return r.id=d,r.value=this.values.get(s)??"",c?.(r),r.addEventListener(u?"input":"change",()=>{this.values.set(s,r.value),c?.(r),u?this.later(!0):this.update(!0)}),h(t,"div",{class:"control"},h(t,"label",{for:d},l),r)}warnFixed(r,s){let u=`${this.localName}: filter already fixes "${s}", so ${r} on it changes nothing.`;this.warned.has(u)||(this.warned.add(u),console.warn(u))}filterControl(r,s){let l=r.name,u=v=>this.values.get(v)?.trim()??"",c=mt(r),d=c===null&&r.format==="boolean";if(c!==null||d){le(s)&&this.warnFixed("filters",l);let v=c??[{value:"true",label:y.yes},{value:"false",label:y.no}],k=h(t,"select",{},h(t,"option",{value:""},y.all),...v.map(D=>h(t,"option",{value:D.value},D.label))),S=wt.includes(r.format);return this.parts.set(l,()=>{let D=u(l);return D===""?null:d?D==="true":S?se(D)??D:D}),this.control(k,l,r.label,!1)}let p=r.format==="date"||r.format==="datetime";if(!p&&!wt.includes(r.format))return Vr(s)&&this.warnFixed("filters",l),this.parts.set(l,()=>u(l)===""?null:{ilike:`%${u(l)}%`}),this.control(h(t,"input",{type:"text"}),l,r.label,!0);let f=v=>{let k=Oe(u(v),r.format);return"value"in k&&typeof k.value=="number"?k.value:null},m=v=>k=>{u(v)!==""&&f(v)===null?k.setAttribute("aria-invalid","true"):k.removeAttribute("aria-invalid")},g=v=>{let k=`${l}:${v}`,S=h(t,"input",{type:p?"date":"text",inputmode:p?null:"decimal","aria-label":`${y[v]} (${r.label})`});return this.control(S,k,y[v],!p,p?void 0:m(k))};this.parts.set(l,()=>{let v={},k=p?u(`${l}:min`)||null:f(`${l}:min`),S=p?As(u(`${l}:max`)):f(`${l}:max`);return k!==null&&(v.gte=k),S!==null&&(v[p?"lt":"lte"]=S),Object.keys(v).length>0?v:null});let w=h(t,"legend",{},r.label);return h(t,"fieldset",{class:"control"},w,g("min"),g("max"))}sortOn(r){let s=this.sortBy??(this.attr("sort")?.trim()||null);this.sortBy=s===r?`-${r}`:r,this.markSort(),this.update(!0)}markSort(){let r=this.sortBy??(this.attr("sort")?.trim()||""),s=r.replace(/^-/,"");for(let[l,u]of this.headers)l===s?u.setAttribute("aria-sort",r.startsWith("-")?"descending":"ascending"):u.removeAttribute("aria-sort")}go(r){this.page=Math.max(1,this.page+r),this.update(!1)}renderRows(r,s){let l=this.frame,u=this.table;if(l===null||u===null)return;let c=s.meta.page,d=c?.total??s.data.length,p=Math.max(1,c?.pages??1);this.page=c?.number??this.page,C(l);let f=JSON.stringify(s.data.map(g=>g.id??null));if(f!==this.shownIds&&(this.chosen=null),this.shownIds=f,s.data.length===0){this.showRowsState({kind:"empty",detail:null});return}let m=h(t,"tbody",{},...s.data.map(g=>this.row(r,g)));m.querySelector('tr[tabindex="0"]')===null&&m.firstElementChild?.setAttribute("tabindex","0"),u.replaceChild(m,u.querySelector("tbody")),l.appendChild(u),this.pager!==null&&(this.pager.hidden=!1),this.pagerText!==null&&(this.pagerText.textContent=y.pageOf(this.page,p,d)),this.previous!==null&&(this.previous.disabled=this.page<=1),this.next!==null&&(this.next.disabled=this.page>=p)}showRowsState(r){this.frame!==null&&(C(this.frame),this.frame.appendChild(h(t,"cube-state",{kind:r.kind,message:r.detail,retry:r.retry===!1?"false":null})),this.pager!==null&&(this.pager.hidden=!0))}row(r,s){let l=()=>this.select(r,s,d),u=p=>this.exampleField(r.session,r.resource,p.name),c=this.chosen!==null&&String(s.id??"")===this.chosen,d=h(t,"tr",{tabindex:c?"0":"-1",class:c?"chosen":null,"aria-current":c?"true":null,onclick:l,onkeydown:(p=>{if(p.altKey||p.ctrlKey||p.metaKey)return;if(p.key==="Enter"||p.key===" "){p.preventDefault(),l();return}let f=this.rowFor(d,p.key);f!==void 0&&(p.preventDefault(),f!==null&&(d.setAttribute("tabindex","-1"),f.setAttribute("tabindex","0"),f.focus()))})},...r.columns.map(p=>{let f=[wt.includes(p.format)&&"num",u(p)&&"example"];return h(t,"td",{class:f.filter(Boolean).join(" ")||null},N(s[p.name],p.format))}));return d}rowFor(r,s){let l=r.parentElement;switch(s){case"ArrowDown":return r.nextElementSibling;case"ArrowUp":return r.previousElementSibling;case"Home":return l?.firstElementChild;case"End":return l?.lastElementChild;default:return}}select(r,s,l){let u=s.id??null;this.chosen=u===null?null:String(u);for(let d of Array.from(l.parentElement?.children??[]))d.classList.toggle("chosen",d===l),d.setAttribute("tabindex",d===l?"0":"-1"),d===l?d.setAttribute("aria-current","true"):d.removeAttribute("aria-current");if(this.emit("cube-select",{resource:r.resource,id:u,row:s}),u===null)return;let c=null;try{c=this.detailTarget()}catch(d){this.showState(te(d));return}c?.setAttribute("record-id",String(u))}toggleExport(){if(this.exporting!==null){this.exporting.abort(),this.exporting=null,this.exportButton!==null&&(this.exportButton.textContent=y.exportCsv),this.exportStatus!==null&&(this.exportStatus.textContent="");return}this.runExport()}async runExport(){let r=this.context,s=this.exportButton,l=this.exportStatus;if(r===null||s===null||l===null)return;let u=new AbortController;this.exporting=u;let{signal:c}=u;s.textContent=y.cancel,l.textContent=y.exporting(0);let d=[],p="";try{let f=0,m=this.query(r,Ur,1);for await(let g of r.session.resource(r.resource).pages(m,{signal:c}))if(c.aborted||(d.push(...g.data),l.textContent=y.exporting(d.length),++f>=Ts))break;c.aborted||Br(t,`${r.resource}-${I(new Date)}.csv`,Ir(r.columns,d))}catch(f){!c.aborted&&f?.name!=="AbortError"&&(p=y.exportFailed)}finally{this.exporting===u&&(this.exporting=null,s.textContent=y.exportCsv,l.textContent=p)}}}return b(o,"tag","cube-table"),b(o,"css",xs),o}var Ds=0;var Ms=`${_}${ge}
|
|
172
|
+
`,wt=ne,Hr=200,As=50,Rs=300,zr=" search";function Es(e){let n=B(e.slice(0,10));return n===null?null:(n.setDate(n.getDate()+1),U(n))}var ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function Vr(e,n,t){let o=e[n];e[n]=ue(o)&&ue(t)?{...o,...t}:t}function Ds(e,n){let t=ae(e),o=ae(n);if(t!==null&&o!==null)return Math.sign(t-o);let a=String(e),i=String(n);return a<i?-1:a>i?1:0}function Kr(e){return e!==void 0&&(!ue(e)||"ilike"in e)}function Ms(e,n){if(!ue(e)||!ue(n))return e;let t={...n,...e};for(let[o,a]of[["gte",1],["gt",1],["lte",-1],["lt",-1]]){let i=e[o],r=n[o];i!=null&&r!==void 0&&r!==null&&(t[o]=Ds(r,i)===a?r:i)}return t}function qr(e,n){let t=n.document;class o extends e{constructor(){super(...arguments);b(this,"period",new G(this));b(this,"context",null);b(this,"parts",new Map);b(this,"values",new Map);b(this,"sortBy",null);b(this,"page",1);b(this,"requests",0);b(this,"rowsController",null);b(this,"debounce",null);b(this,"exporting",null);b(this,"headers",new Map);b(this,"frame",null);b(this,"table",null);b(this,"pagerText",null);b(this,"previous",null);b(this,"next",null);b(this,"pager",null);b(this,"exportButton",null);b(this,"exportStatus",null);b(this,"shownResource",null);b(this,"chosen",null);b(this,"shownIds",null);b(this,"updates",0);b(this,"warned",new Set)}shownFields(){return this.context?.columns.map(r=>r.name)??[]}disconnectedCallback(){super.disconnectedCallback(),this.stopDebounce(),this.rowsController?.abort(),this.exporting?.abort(),this.exporting=null}async load(r,s){if(s===null)return;this.stopDebounce(),this.context=null,this.rowsController?.abort();let l=_(this,"resource");++this.updates,l!==this.shownResource&&(this.values.clear(),this.sortBy=null,this.page=1,this.chosen=null,this.shownIds=null,this.shownResource=l),this.detailTarget();let u=this.attr("period"),c=u===null||u===""?null:ct(this.attr("date-field"),null,this.localName),p=fe(this),m=await ut(this,u);if(r.aborted)return;this.period.follow(m);let f=m===null||c===null?p:{...p,...lt(c,m.value)},d=await s.schema(l);if(r.aborted)return;let g=Z(this.attr("fields")),w=d===null||d.fields.some(E=>E.name==="id"),v={session:s,resource:l,columns:[],base:f,fields:g===null?void 0:[...new Set([...w?["id"]:[],...g])],size:Math.min(X(this,"page-size",1,25),Hr)};this.exporting?.abort(),this.exporting=null,r.addEventListener("abort",()=>this.rowsController?.abort(),{once:!0});let k=Z(this.attr("filters"))??[];this.checkFilterable(d,k);let S=k.filter(E=>!(E in p)||ue(p[E]));for(let E of[...this.parts.keys()])S.includes(E)||this.parts.delete(E);let R=W(this);this.context=v;let L=await this.fetchRows(v,this.query(v,v.size,this.page)),j=L===null?null:await this.lastPageIfPast(v,L);if(j===null||r.aborted)return;let x=j.data[0];v.columns=ee(d,g,R,x);let F=new Map([...R].map(([E,z])=>[E,{...z,hidden:!1}])),T=ee(d,S,F,x);this.build(v,d,T),this.renderRows(v,j)}checkFilterable(r,s){if(r===null)return;let l=this.attr("search")?.trim()??"",u=s.map(c=>["filters",c]);l!==""&&u.push(["search",l]);for(let[c,p]of u)if(!r.filterable.includes(p))throw new A(y.invalid.notFilterable(this.localName,c,p))}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new A(y.invalid.selector(this.localName,"detail",r))}}query(r,s,l){let u={},c=this.attr("search")?.trim()??"",p=this.values.get(zr)?.trim()??"";c!==""&&p!==""&&Vr(u,c,{ilike:`%${p}%`});for(let[g,w]of this.parts){let v=w();v!==null&&Vr(u,g,v)}let m={...r.base};for(let[g,w]of Object.entries(u)){let v=m[g];m[g]=v===void 0?w:Ms(v,w)}let f=this.sortBy??(this.attr("sort")?.trim()||null),d={filter:m,page:{size:s,number:l}};return f!==null&&(d.sort=f),r.fields!==void 0&&(d.fields=r.fields),d}async fetchRows(r,s){let l=++this.requests;this.rowsController?.abort();let u=new AbortController;this.rowsController=u,this.setAttribute("aria-busy","true");try{let c=await r.session.resource(r.resource).list(s,{signal:u.signal});return l===this.requests&&!u.signal.aborted?c:null}finally{l===this.requests&&this.removeAttribute("aria-busy")}}async lastPageIfPast(r,s){let l=s.meta.page;return s.data.length>0||this.page<=1||l===void 0||l===null||l.total===0?s:(this.page=Math.max(1,l.pages),this.fetchRows(r,this.query(r,r.size,this.page)))}async update(r){let s=this.context;if(s===null||!this.isConnected)return;r&&(this.page=1);let l=++this.updates;try{let u=await this.fetchRows(s,this.query(s,s.size,this.page)),c=u===null?null:await this.lastPageIfPast(s,u);c!==null&&this.renderRows(s,c)}catch(u){if(l!==this.updates||u?.name==="AbortError")return;this.showRowsState(Y(u))}}later(r){this.stopDebounce(),this.debounce=n.setTimeout(()=>{this.debounce=null,this.update(r)},Rs)}stopDebounce(){this.debounce!==null&&n.clearTimeout(this.debounce),this.debounce=null}build(r,s,l){this.parts=new Map;let u=[],c=this.attr("search")?.trim()??"";if(c!==""){Kr(r.base[c])&&this.warnFixed("search",c);let m=h(t,"input",{type:"search"});u.push(this.control(m,zr,y.search,!0))}for(let m of l)u.push(this.filterControl(m,r.base[m.name]));this.flag("export")?(this.exportButton=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.toggleExport()},y.exportCsv),this.exportStatus=h(t,"p",{class:"export-status",role:"status"}),u.push(this.exportButton,this.exportStatus)):(this.exportButton=null,this.exportStatus=null),this.headers=new Map,this.frame=h(t,"div",{class:"scroll"}),this.pagerText=h(t,"p",{"aria-live":"polite"}),this.previous=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.go(-1)},y.previous),this.next=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.go(1)},y.next),this.pager=h(t,"div",{class:"pager"},this.pagerText,this.previous,this.next);let p=h(t,"thead",{},h(t,"tr",{},...r.columns.map(m=>{let f=s?.sortable.includes(m.name)===!0,d=h(t,"th",{scope:"col",class:wt.includes(m.format)?"num":null},f?h(t,"button",{type:"button",onclick:()=>this.sortOn(m.name)},m.label,h(t,"span",{class:"arrow","aria-hidden":"true"})):m.label,...this.exampleField(r.session,r.resource,m.name)?[" ",at(t)]:[]);return f&&this.headers.set(m.name,d),d})));this.table=h(t,"table",{},h(t,"caption",{class:"sr-only"},K(r.resource)),p,h(t,"tbody")),this.markSort(),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},u.length>0?h(t,"div",{class:"tools"},...u):null,this.frame,this.pager))}control(r,s,l,u,c){let p=`cube-table-${++Ls}`;return r.id=p,r.value=this.values.get(s)??"",c?.(r),r.addEventListener(u?"input":"change",()=>{this.values.set(s,r.value),c?.(r),u?this.later(!0):this.update(!0)}),h(t,"div",{class:"control"},h(t,"label",{for:p},l),r)}warnFixed(r,s){let u=`${this.localName}: filter already fixes "${s}", so ${r} on it changes nothing.`;this.warned.has(u)||(this.warned.add(u),console.warn(u))}filterControl(r,s){let l=r.name,u=v=>this.values.get(v)?.trim()??"",c=mt(r),p=c===null&&r.format==="boolean";if(c!==null||p){ue(s)&&this.warnFixed("filters",l);let v=c??[{value:"true",label:y.yes},{value:"false",label:y.no}],k=h(t,"select",{},h(t,"option",{value:""},y.all),...v.map(R=>h(t,"option",{value:R.value},R.label))),S=wt.includes(r.format);return this.parts.set(l,()=>{let R=u(l);return R===""?null:p?R==="true":S?ae(R)??R:R}),this.control(k,l,r.label,!1)}let m=r.format==="date"||r.format==="datetime";if(!m&&!wt.includes(r.format))return Kr(s)&&this.warnFixed("filters",l),this.parts.set(l,()=>u(l)===""?null:{ilike:`%${u(l)}%`}),this.control(h(t,"input",{type:"text"}),l,r.label,!0);let f=v=>{let k=_e(u(v),r.format);return"value"in k&&typeof k.value=="number"?k.value:null},d=v=>k=>{u(v)!==""&&f(v)===null?k.setAttribute("aria-invalid","true"):k.removeAttribute("aria-invalid")},g=v=>{let k=`${l}:${v}`,S=h(t,"input",{type:m?"date":"text",inputmode:m?null:"decimal","aria-label":`${y[v]} (${r.label})`});return this.control(S,k,y[v],!m,m?void 0:d(k))};this.parts.set(l,()=>{let v={},k=m?u(`${l}:min`)||null:f(`${l}:min`),S=m?Es(u(`${l}:max`)):f(`${l}:max`);return k!==null&&(v.gte=k),S!==null&&(v[m?"lt":"lte"]=S),Object.keys(v).length>0?v:null});let w=h(t,"legend",{},r.label);return h(t,"fieldset",{class:"control"},w,g("min"),g("max"))}sortOn(r){let s=this.sortBy??(this.attr("sort")?.trim()||null);this.sortBy=s===r?`-${r}`:r,this.markSort(),this.update(!0)}markSort(){let r=this.sortBy??(this.attr("sort")?.trim()||""),s=r.replace(/^-/,"");for(let[l,u]of this.headers)l===s?u.setAttribute("aria-sort",r.startsWith("-")?"descending":"ascending"):u.removeAttribute("aria-sort")}go(r){this.page=Math.max(1,this.page+r),this.update(!1)}renderRows(r,s){let l=this.frame,u=this.table;if(l===null||u===null)return;let c=s.meta.page,p=c?.total??s.data.length,m=Math.max(1,c?.pages??1);this.page=c?.number??this.page,C(l);let f=JSON.stringify(s.data.map(g=>g.id??null));if(f!==this.shownIds&&(this.chosen=null),this.shownIds=f,s.data.length===0){this.showRowsState({kind:"empty",detail:null});return}let d=h(t,"tbody",{},...s.data.map(g=>this.row(r,g)));d.querySelector('tr[tabindex="0"]')===null&&d.firstElementChild?.setAttribute("tabindex","0"),u.replaceChild(d,u.querySelector("tbody")),l.appendChild(u),this.pager!==null&&(this.pager.hidden=!1),this.pagerText!==null&&(this.pagerText.textContent=y.pageOf(this.page,m,p)),this.previous!==null&&(this.previous.disabled=this.page<=1),this.next!==null&&(this.next.disabled=this.page>=m)}showRowsState(r){this.frame!==null&&(C(this.frame),this.frame.appendChild(h(t,"cube-state",{kind:r.kind,message:r.detail,retry:r.retry===!1?"false":null})),this.pager!==null&&(this.pager.hidden=!0))}row(r,s){let l=()=>this.select(r,s,p),u=m=>this.exampleField(r.session,r.resource,m.name),c=this.chosen!==null&&String(s.id??"")===this.chosen,p=h(t,"tr",{tabindex:c?"0":"-1",class:c?"chosen":null,"aria-current":c?"true":null,onclick:l,onkeydown:(m=>{if(m.altKey||m.ctrlKey||m.metaKey)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),l();return}let f=this.rowFor(p,m.key);f!==void 0&&(m.preventDefault(),f!==null&&(p.setAttribute("tabindex","-1"),f.setAttribute("tabindex","0"),f.focus()))})},...r.columns.map(m=>{let f=[wt.includes(m.format)&&"num",u(m)&&"example"];return h(t,"td",{class:f.filter(Boolean).join(" ")||null},I(s[m.name],m.format))}));return p}rowFor(r,s){let l=r.parentElement;switch(s){case"ArrowDown":return r.nextElementSibling;case"ArrowUp":return r.previousElementSibling;case"Home":return l?.firstElementChild;case"End":return l?.lastElementChild;default:return}}select(r,s,l){let u=s.id??null;this.chosen=u===null?null:String(u);for(let p of Array.from(l.parentElement?.children??[]))p.classList.toggle("chosen",p===l),p.setAttribute("tabindex",p===l?"0":"-1"),p===l?p.setAttribute("aria-current","true"):p.removeAttribute("aria-current");if(this.emit("cube-select",{resource:r.resource,id:u,row:s}),u===null)return;let c=null;try{c=this.detailTarget()}catch(p){this.showState(Y(p));return}c?.setAttribute("record-id",String(u))}toggleExport(){if(this.exporting!==null){this.exporting.abort(),this.exporting=null,this.exportButton!==null&&(this.exportButton.textContent=y.exportCsv),this.exportStatus!==null&&(this.exportStatus.textContent="");return}this.runExport()}async runExport(){let r=this.context,s=this.exportButton,l=this.exportStatus;if(r===null||s===null||l===null)return;let u=new AbortController;this.exporting=u;let{signal:c}=u;s.textContent=y.cancel,l.textContent=y.exporting(0);let p=[],m="";try{let f=0,d=this.query(r,Hr,1);for await(let g of r.session.resource(r.resource).pages(d,{signal:c}))if(c.aborted||(p.push(...g.data),l.textContent=y.exporting(p.length),++f>=As))break;c.aborted||Ur(t,`${r.resource}-${U(new Date)}.csv`,Br(r.columns,p))}catch(f){!c.aborted&&f?.name!=="AbortError"&&(m=y.exportFailed)}finally{this.exporting===u&&(this.exporting=null,s.textContent=y.exportCsv,l.textContent=m)}}}return b(o,"tag","cube-table"),b(o,"css",Cs),o}var Ls=0;var Fs=`${O}${ge}
|
|
170
173
|
ol{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:.25rem}
|
|
171
174
|
button{display:grid;grid-template-columns:1fr auto;gap:.125rem .75rem;width:100%;padding:.5rem .75rem;
|
|
172
175
|
border:0;border-radius:var(--cube-radius);background:none;color:inherit;font:inherit;text-align:start;cursor:pointer}
|
|
@@ -177,10 +180,10 @@ button:focus-visible{outline:2px solid var(--cube-color-focus);outline-offset:2p
|
|
|
177
180
|
svg{grid-column:1/-1;display:block;width:100%;height:.5rem}
|
|
178
181
|
rect.bar{fill:var(--cube-color-series-1)}
|
|
179
182
|
.note{margin:.5rem 0 0;font-size:.875rem;color:var(--cube-color-text-muted)}
|
|
180
|
-
`;function
|
|
183
|
+
`;function Gr(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(this))}shownFields(){return he(this)}async load(i,r){if(r===null)return;let s=_(this,"resource"),l=_(this,"by"),u=X(this,"limit",1,5),c=await be(this,this.period,i,l);if(c===null)return;let{data:p,meta:m}=await dt(r,s,l,c,i);if(i.aborted)return;let f={descending:this.attr("order")!=="asc",limit:u},d=await pt(this,r,p,{by:l,fn:c.fn},f,i);if(d===null)return;if(d.length===0){this.showState("empty");return}let g=(m?.groups??0)>p.length;this.render(d,l,ye(this,c.count),g)}render(i,r,s,l){let u=n.document,c=Math.max(...i.map(f=>f.value)),p=this.attr("label"),m={};p!==null&&p!==""&&(m["aria-label"]=p),l&&(m["aria-describedby"]="incomplete"),C(this.body),this.body.appendChild(h(u,"div",{class:"card"},...p===null||p===""?[]:[h(u,"p",{class:"label"},p)],h(u,"ol",m,...i.map(f=>h(u,"li",{},h(u,"button",{type:"button",onclick:()=>{this.emit("cube-select",{by:r,key:f.key})}},h(u,"span",{class:"name"},f.label)," ",h(u,"span",{class:"value"},s(f.value)),this.bar(f.value,c))))),...l?[h(u,"p",{class:"note",id:"incomplete",role:"note"},y.incomplete)]:[]))}bar(i,r){let s=r>0&&i>0?i/r*100:0;return H(n.document,"svg",{viewBox:"0 0 100 4",preserveAspectRatio:"none","aria-hidden":"true",focusable:"false"},H(n.document,"rect",{class:"bar",x:0,y:0,width:s,height:4}))}}return b(t,"tag","cube-top"),b(t,"css",Fs),t}var _s=[["cube-state",jr],["cube-app-shell",ur],["cube-period-picker",Pr],["cube-kpi",_r],["cube-chart",Ar],["cube-top",Gr],["cube-table",qr],["cube-detail",Er],["cube-form",Mr],["cube-calc",wr],["cube-board",gr],["cube-gap-list",Lr]],Wr=new WeakMap;function Os(e){return class extends e.HTMLElement{}}function $s(e,n,t){let o=e.document.fonts;if(!(n.fontFamily===null||e.FontFace===void 0||o===void 0))for(let a of n.fontFiles){let i=`${n.fontFamily}|${a.src}|${a.weight??""}|${a.style??""}`;if(!t.has(i)){t.add(i);try{let r={style:a.style??"normal"};a.weight!==void 0&&(r.weight=a.weight);let s=new e.FontFace(n.fontFamily,`url("${a.src}")`,r);o.add(s),s.load().catch(()=>{})}catch{}}}}function Ps(e){let n=e.document,t=Wr.get(n);t?.stop();let o=new e.CSSStyleSheet,a=t?.fonts??new Set,i=r=>{try{o.replaceSync(_n(r)),$s(e,r,a)}catch{}};i(We()),n.adoptedStyleSheets=[...n.adoptedStyleSheets.filter(r=>r!==t?.sheet),o],Wr.set(n,{sheet:o,stop:Qe(i),fonts:a})}function Zt(e,n={}){let t=e??globalThis;if(t.customElements===void 0||t.HTMLElement===void 0||t.document===void 0)return;let o=t,a=o.customElements;Ps(o);let i=lr(o,n);for(let[r,s]of _s)a.get(r)===void 0&&a.define(r,s(i,o));a.get("cube-page")===void 0&&a.define("cube-page",Os(o));for(let r of["cube-field","cube-input","cube-result","cube-column"])a.get(r)===void 0&&a.define(r,dr(o))}var Ns=5e3,js=6e4,Qr=6e4,Is=1e4,Bs=`
|
|
181
184
|
.banner{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:.5rem 1rem;
|
|
182
185
|
border-bottom:1px solid var(--cube-color-border);border-left:4px solid var(--cube-color-warning);
|
|
183
186
|
background:var(--cube-color-surface);font-size:.875rem}
|
|
184
187
|
.banner p{margin:0;flex:1 1 16rem}
|
|
185
188
|
.banner[data-state=expired],.banner[data-state=closed]{border-left-color:var(--cube-color-danger)}
|
|
186
|
-
`;function
|
|
189
|
+
`;function Jr(e,n){let t=e.document,o=e.now??Date.now,a=Date.parse(n.expiresAt),i=Number.isFinite(a),r=i?new Intl.DateTimeFormat("nl-NL",{hour:"2-digit",minute:"2-digit",timeZoneName:"short"}).format(new Date(a)):null,s=t.createElement("cube-trial-banner"),l=s.attachShadow({mode:"open"}),u=[De,Bs].map(T=>{let E=new e.CSSStyleSheet;return E.replaceSync(T),E}),c=h(t,"p",{},y.trial.banner(r,n.leest)),p=h(t,"div",{class:"banner",role:"status","aria-live":"polite"},c),m=null,f=!1,d=!1,g=null,w=0;l.adoptedStyleSheets=u,l.appendChild(p);let v=()=>{t.body.insertBefore(s,t.body.firstChild)},k=()=>t.visibilityState!=="hidden",S=()=>{f=!0,g?.abort(),m!==null&&e.clearTimeout(m),m=null,t.removeEventListener("visibilitychange",F)},R=(T,E)=>{S(),!s.isConnected&&t.body!==null&&v(),p.setAttribute("data-state",T),C(c),c.appendChild(t.createTextNode(y.trial[T])),E!==void 0&&p.appendChild(h(t,"button",{type:"button",onclick:E[1]},E[0]))},L=(T=k()?Ns:js)=>{if(f)return;m!==null&&e.clearTimeout(m);let E=Math.max(T,Math.min(Qr,w-o()));m=e.setTimeout(j,i?Math.max(0,Math.min(E,a-o())):E)},j=async()=>{if(m=null,f)return;if(i&&o()>=a){R("expired");return}w=0,d=!0;let T=e.AbortController===void 0?null:new e.AbortController;g=T;let E=T===null?null:e.setTimeout(()=>T.abort(),Is);try{let z=await e.fetch(n.statusUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${n.token}`},cache:"no-store",...T===null?{}:{signal:T.signal}});await x(z)}catch{L()}finally{d=!1,g=null,E!==null&&e.clearTimeout(E)}},x=async T=>{if(f)return;if(T.ok&&(w=0),T.status===429){let $=(T.headers.get("Retry-After")??"").trim();/^\d+$/.test($)&&(w=o()+Math.min(Qr,Number($)*1e3))}if(T.ok||T.status===429||T.status>=500){L();return}let E={};try{let $=await T.json();$!==null&&typeof $=="object"&&(E=$)}catch{}let z=E.code,D=null;if(z==="trial_expired")R("expired");else if(z==="trial_elsewhere")R("elsewhere",[y.trial.reload,()=>e.location.reload()]);else if(z==="trial_replaced"&&(D=Us(E.newer,n.dmpUrl))!==null){let $=D.href;E.wider===!1?(R("refreshing"),e.location.assign($)):R("wider",[y.trial.load,()=>e.location.assign($)])}else R("closed")};function F(){if(!(f||d)){if(!k()){L();return}if(w>o()){L(0);return}m!==null&&e.clearTimeout(m),j()}}return t.addEventListener("visibilitychange",F),t.body===null?t.addEventListener("DOMContentLoaded",v,{once:!0}):v(),L(),S}function Us(e,n){if(typeof e!="string")return null;try{let t=new URL(e);return t.origin===new URL(n).origin&&t.pathname.startsWith("/apps/proef/")?t:null}catch{return null}}var Hs=Object.freeze({...it,defineBlocks:Zt});globalThis.CubeApp=Hs;typeof customElements<"u"&&Zt();var Yr=Ye(),en=globalThis;Yr!==null&&en.document!==void 0&&en.CSSStyleSheet!==void 0&&Jr(en,Yr);})();
|