@blotout/qinto-cli 0.1.14 → 0.1.16
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 +56 -5
- package/dist/index.js +4733 -3778
- package/dist/index.js.map +1 -1
- package/dist/worker-artifact/app-runtime/index.js +7322 -1876
- package/dist/worker-artifact/main/b6b625dbf1615da405354d9b8813ffcc4e753b93-q.js.txt +1 -0
- package/dist/worker-artifact/main/index.js +6990 -2378
- package/dist/worker-artifact/version.json +8 -25
- package/dist/worker-artifact/wfp/index.js +385 -337
- package/package.json +11 -11
- package/templates/app/full/qinto.app.jsonc +5 -3
- package/dist/worker-artifact/apps-ui/index.js +0 -59
- package/dist/worker-artifact/main/70bb879cfb530cd1d478f5eed2979cf1344f3be0-q.js.txt +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotout/qinto-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Qinto CLI: authenticate against the Qinto platform and operate it from the terminal or from an agent.",
|
|
6
6
|
"repository": {
|
|
@@ -23,27 +23,27 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@inquirer/prompts": "8.
|
|
26
|
+
"@inquirer/prompts": "8.7.1",
|
|
27
27
|
"commander": "15.0.0",
|
|
28
28
|
"esbuild": "0.28.2",
|
|
29
29
|
"jsonc-parser": "3.3.1",
|
|
30
|
-
"miniflare": "5.
|
|
31
|
-
"open": "11.0.
|
|
30
|
+
"miniflare": "5.20260831.0-alpha",
|
|
31
|
+
"open": "11.0.2",
|
|
32
32
|
"proper-lockfile": "4.1.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "25.
|
|
35
|
+
"@types/node": "25.9.5",
|
|
36
36
|
"@types/proper-lockfile": "4.1.4",
|
|
37
|
-
"@vitest/coverage-v8": "4.1.
|
|
37
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
38
38
|
"openapi-typescript": "7.13.0",
|
|
39
|
-
"tsx": "4.23.
|
|
39
|
+
"tsx": "4.23.13",
|
|
40
40
|
"typescript": "6.0.3",
|
|
41
|
-
"vite": "
|
|
42
|
-
"vitest": "4.1.
|
|
41
|
+
"vite": "8.2.2",
|
|
42
|
+
"vitest": "4.1.11",
|
|
43
43
|
"@qinto/app-build": "0.0.0",
|
|
44
44
|
"@qinto/app-dev": "0.0.0",
|
|
45
|
-
"@qinto/
|
|
46
|
-
"@qinto/
|
|
45
|
+
"@qinto/app-manifest": "0.0.0",
|
|
46
|
+
"@qinto/oauth-grammar": "0.0.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "vite build",
|
|
@@ -37,9 +37,11 @@
|
|
|
37
37
|
// this app, which only this app reads back. Each name belongs to one list. Uncomment to use it —
|
|
38
38
|
// a site manager sees the list and must accept any name a later version adds.
|
|
39
39
|
//
|
|
40
|
-
// "
|
|
41
|
-
//
|
|
42
|
-
//
|
|
40
|
+
// "type" says what a value is: "attribution" for a click or campaign id, "identity" (the default)
|
|
41
|
+
// for a vendor id that names the visitor across visits. "expiresInSeconds" is optional and runs
|
|
42
|
+
// from the first sighting of that value; seeing the same value again never extends it. Omit it to
|
|
43
|
+
// keep the value for the life of the visitor profile.
|
|
44
|
+
// "capture": { "queryParams": [{ "name": "fbclid", "type": "attribution", "expiresInSeconds": 604800 }], "cookies": [{ "name": "_fbp" }] },
|
|
43
45
|
// eventResults lets the matching server install receive this browser handler's return value on
|
|
44
46
|
// the same action as action.browser. It is untrusted page input and delivery stays fail-open.
|
|
45
47
|
"browser": { "entry": "src/browser.ts", "eventResults": ["track"] },
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/index.ts
|
|
5
|
-
var CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
6
|
-
var DEFAULT_CONTENT_TYPE = "application/octet-stream";
|
|
7
|
-
var withSecurityHeaders = /* @__PURE__ */ __name((response, portalOrigin) => {
|
|
8
|
-
response.headers.set("content-security-policy", `frame-ancestors ${portalOrigin}`);
|
|
9
|
-
response.headers.set("x-content-type-options", "nosniff");
|
|
10
|
-
response.headers.set("referrer-policy", "no-referrer");
|
|
11
|
-
response.headers.set("vary", "sec-fetch-dest");
|
|
12
|
-
return response;
|
|
13
|
-
}, "withSecurityHeaders");
|
|
14
|
-
var NAVIGATION_DESTINATIONS = /* @__PURE__ */ new Set(["document", "object", "embed"]);
|
|
15
|
-
var assetKeys = /* @__PURE__ */ __name((hostname, pathname) => {
|
|
16
|
-
const dot = hostname.indexOf(".");
|
|
17
|
-
const slug = dot === -1 ? hostname : hostname.slice(0, dot);
|
|
18
|
-
const segments = pathname.split("/").filter((segment) => segment !== "");
|
|
19
|
-
const [appId, appVersionId] = segments;
|
|
20
|
-
if (appId === void 0 || appVersionId === void 0) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
exact: `ui/${slug}/${segments.join("/")}`,
|
|
25
|
-
fallback: `ui/${slug}/${appId}/${appVersionId}/index.html`
|
|
26
|
-
};
|
|
27
|
-
}, "assetKeys");
|
|
28
|
-
var serve = /* @__PURE__ */ __name(async (request, env) => {
|
|
29
|
-
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
30
|
-
return new Response("method not allowed", { status: 405 });
|
|
31
|
-
}
|
|
32
|
-
const destination = request.headers.get("sec-fetch-dest");
|
|
33
|
-
if (destination !== null && NAVIGATION_DESTINATIONS.has(destination)) {
|
|
34
|
-
return new Response("unauthorized", { status: 401 });
|
|
35
|
-
}
|
|
36
|
-
const url = new URL(request.url);
|
|
37
|
-
const keys = assetKeys(url.hostname, url.pathname);
|
|
38
|
-
if (keys === null) {
|
|
39
|
-
return new Response("not found", { status: 404 });
|
|
40
|
-
}
|
|
41
|
-
const object = await env.APPS_BUCKET.get(keys.exact) ?? await env.APPS_BUCKET.get(keys.fallback);
|
|
42
|
-
if (object === null) {
|
|
43
|
-
return new Response("not found", { status: 404 });
|
|
44
|
-
}
|
|
45
|
-
return new Response(object.body, {
|
|
46
|
-
headers: {
|
|
47
|
-
"content-type": object.httpMetadata?.contentType ?? DEFAULT_CONTENT_TYPE,
|
|
48
|
-
"cache-control": CACHE_CONTROL
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}, "serve");
|
|
52
|
-
var index_default = {
|
|
53
|
-
async fetch(request, env) {
|
|
54
|
-
return withSecurityHeaders(await serve(request, env), env.PORTAL_ORIGIN);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
export {
|
|
58
|
-
index_default as default
|
|
59
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){var e=class extends Error{constructor(e){super(e),this.name=`QintoError`}},t=class extends e{constructor(e){super(e),this.name=`QintoTimeoutError`}},n=(e=Date.now())=>`evt_${globalThis.crypto.randomUUID()}_${e}`,r=(e,t)=>{if(e!==void 0)return e;let r=t?.orderId;return typeof r==`string`&&r!==``?r:n()},i=[`necessary`,`functional`,`analytics`,`marketing`,`salesOfData`],a=(e,t,n)=>n===void 0||!i.some(e=>e===n)?!1:n===`necessary`||e!==null&&e.categories[n]===!0&&e.apps[t]!==!1,o=()=>{},s=100,c=1024,l=32*1024,u=(e,t,n)=>e.target.config?.consentConfiguration?.enabled!==!0||a(n,t,e.target.config?.apps?.[t]?.category),d=e=>Object.values(e.config?.apps??{}).some(e=>e.category!==`necessary`||e.capture!==void 0),f=(e,t)=>{let{app:n,install:r,topic:i,to:a}=e;return typeof n!=`string`||typeof i!=`string`||r!==void 0&&typeof r!=`string`||t&&!(Array.isArray(a)&&a.every(e=>typeof e==`string`))},p=(e,t,n,r)=>r===null?e.slug===t&&(n===void 0||n===e.installId):r.has(e.slug),m=(e,t)=>{console.error(`[Qinto] A handler of app "${e.slug}" (install "${e.installId}") failed.`,t)},h=(e,t,n)=>{for(let r of t)try{let t=r(n);t instanceof Promise&&t.catch(t=>{m(e,t)})}catch(t){m(e,t)}},g=(e,t,n,r)=>{e.activated.add(r.id);let i={slug:t,installId:r.id,eventHandlers:[],consentHandlers:[],pushHandlers:[],sharedContextHandlers:[]};e.instances.push(i);let a={variables:r.variables,install:{id:r.id,label:r.label},getSession:async()=>{let n=await e.client.getSession();return e.target.config?.apps?.[t]?.geo===!0?n:{...n,ip:null,geo:null}},track:(t,n)=>{e.client.track(t,n).catch(o)},onEvent:e=>{i.eventHandlers.push(e)},onConsent:e=>{i.consentHandlers.push(e)},onPush:e=>{i.pushHandlers.push(e)},onSharedContext:n=>{if(e.target.config?.apps?.[t]?.sharedContext!==!0){console.error(`[Qinto] App "${t}" reads shared context without declaring the sharedContext capability.`);return}i.sharedContextHandlers.push(n),e.sharedContext!==null&&ee(e,t)&&h(i,[n],e.sharedContext)}};try{n(a)}catch(e){console.error(`[Qinto] App "${t}" failed to activate install "${r.id}".`,e)}},_=(e,t,n)=>{if(!u(e,t,e.consent))return;let r=((`_appInstalls`in e.target?e.target._appInstalls:void 0)?.[t]??[]).filter(t=>!e.activated.has(t.id));if(r.length===0)return;let i=n.factory;if(i===void 0){try{i=n.loader()}catch(e){i=null,console.error(`[Qinto] App "${t}" failed to load.`,e)}e.apps.set(t,{...n,factory:i})}if(i!==null)for(let n of r)g(e,t,i,n)},ee=(e,t)=>u(e,t,e.consent)?e.sharedContextConsent===void 0||u(e,t,e.sharedContextConsent):!1,te=e=>{let{categories:t,apps:n}=e;if(!(typeof t!=`object`||!t||typeof n!=`object`||!n))return{categories:t,apps:n}},ne=(e,t)=>{let n=e;n.consent=t,n.sharedContextConsent=void 0;for(let n of e.instances)h(n,n.consentHandlers,t);e.onConsentSettled?.(t);for(let[t,n]of e.apps)_(e,t,n)},v=async e=>{try{ne(e,await e.client.getConsent())}catch(e){console.error(`[Qinto] The apps consent read failed.`,e)}},y=e=>{let t;try{t=JSON.stringify(e)}catch{return}if(!(t===void 0||new TextEncoder().encode(t).length>c))return JSON.parse(t)},b=e=>{let t={};for(let n of e){if(n.settled!==n.total||n.values.length!==1)continue;let e=y(n.values[0]);if(e===void 0)continue;let r={...t[n.instance.slug]??{},[n.instance.installId]:e},i={...t,[n.instance.slug]:r};new TextEncoder().encode(JSON.stringify(i)).length<=l&&(t[n.instance.slug]=r)}return Object.keys(t).length===0?void 0:t},x=async(e,t)=>{e.onPageEvent?.(e.consent);let n=[],r=[];for(let i of e.instances){if(!u(e,i.slug,e.consent))continue;if(e.target.config?.apps?.[i.slug]?.eventResults?.includes(t.type)!==!0){h(i,i.eventHandlers,t);continue}let a={instance:i,total:i.eventHandlers.length,settled:0,values:[]};n.push(a);for(let e of i.eventHandlers){let n;try{n=e(t)}catch(e){a.settled+=1,m(i,e);continue}r.push(Promise.resolve(n).then(e=>{a.settled+=1,e!==void 0&&a.values.push(e)},e=>{a.settled+=1,m(i,e)}))}}if(r.length>0){let e=o,t=new Promise(t=>{e=t}),n=setTimeout(e,s);await Promise.race([Promise.all(r),t]),clearTimeout(n)}return b(n)},re=e=>{let{client:t}=e;return{track:async(n,i,a)=>{let o=r(a?.eventId,i),s=t.actionContext(),c=await x(e,{type:`track`,event:n,eventId:o,properties:i??{}});return await t.submitTrack({event:n,eventId:o,properties:i,context:s,appResults:c}),{eventId:o}},identify:async(n,r)=>{let i=t.actionContext(),a=await x(e,{type:`identify`,event:`identify`,properties:n??{}});return t.submitIdentify({traits:n,id:r,context:i,appResults:a})},alias:t.alias,consent:async n=>{if(await t.submitConsent(n,t.actionContext()),e.onConsentMutation?.(),d(e.target)){let t=e;t.consent=null,await v(e)}},getAnonId:t.getAnonId,getConsent:t.getConsent,getSession:t.getSession,close:t.close}},ie=(e,t)=>{let n=new Map,r=null,i=null,a=e=>{let[t,i]=e;if(n.has(t))return;let a={loader:i};n.set(t,a),r?.(t,a)},o=e,s=`_apps`in o?o._apps:void 0,c=Array.isArray(s)?s:[];c.push=(...e)=>{for(let t of e)a(t);return 0},o._apps=c;for(let e of c.splice(0))a(e);return{sharedContext:e=>{let{context:t}=e;if(typeof t!=`object`||!t||Array.isArray(t)){console.error(`[Qinto] The server sent a malformed shared context.`,e);return}let n=i;if(n===null)return;n.sharedContext=t;let r=te(e),a=r??n.consent;n.sharedContextConsent=r;for(let e of n.instances)u(n,e.slug,a)&&h(e,e.sharedContextHandlers,n.sharedContext)},push:e=>{let{app:t,install:n,topic:r,scope:a,to:o}=e,s=a===`site`;if(f(e,s)){console.error(`[Qinto] The server sent a malformed app push.`,e);return}let c=i;if(c===null)return;let l=s?new Set(o):null,d={topic:r,data:e.data,from:t};for(let e of c.instances)p(e,t,n,l)&&u(c,e.slug,c.consent)&&h(e,e.pushHandlers,d)},connect:async a=>{let o={target:e,client:a,apps:n,instances:[],activated:new Set,consent:null,sharedContext:i?.sharedContext??null,sharedContextConsent:i?.sharedContextConsent,onConsentSettled:t?.onConsentSettled,onConsentMutation:t?.onConsentMutation,onPageEvent:t?.onPageEvent};i=o,r=(e,t)=>{_(o,e,t),o.consent===null&&o.target.config?.consentConfiguration?.enabled===!0&&o.target.config?.apps?.[e]?.category!==`necessary`&&v(o)};for(let[e,t]of n)_(o,e,t);return e.config?.consentConfiguration?.enabled===!0&&d(e)?await v(o):o.onConsentSettled?.(o.consent),re(o)}}},ae=`PageView`,S=()=>{},oe=e=>{e.config?.autoCapture?.pageLoad===!0&&e.q.push([`track`,[ae],S,S])},C=512,w=1440*60*1e3,T=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>[e,t.value]))])),E=(e,t)=>`qinto:cap:${encodeURIComponent(e)}:${encodeURIComponent(t)}`,D=e=>{try{let t=window.sessionStorage.getItem(e);if(t===null)return null;let n=JSON.parse(t);return typeof n.at!=`number`||typeof n.anonId!=`string`||typeof n.apps!=`object`||n.apps===null||Date.now()-n.at>w?null:{at:n.at,anonId:n.anonId,apps:n.apps}}catch{return null}},O=(e,t)=>{try{window.sessionStorage.setItem(e,JSON.stringify(t))}catch{}},k=e=>{try{window.sessionStorage.removeItem(e)}catch{}},A=e=>{try{return decodeURIComponent(e)}catch{return e}},j=()=>{let e={};for(let t of document.cookie.split(`;`)){let n=t.indexOf(`=`);n>0&&(e[t.slice(0,n).trim()]=A(t.slice(n+1)))}return e},M=(e,t)=>{let n={};for(let r of e.queryParams){let e=t.params.get(r);e!==null&&e.length<=C&&(n[r]={value:e,source:`query`})}for(let r of e.cookies){let e=t.cookies[r];e!==void 0&&e.length<=C&&(n[r]={value:e,source:`cookie`})}return n},N=(e,t)=>{let n={params:new URLSearchParams(window.location.search),cookies:j()},r={};for(let[i,o]of Object.entries(e.config?.apps??{})){if(o.capture===void 0||!a(t,i,o.category))continue;let e=M(o.capture,n);Object.keys(e).length>0&&(r[i]=e)}return r},P=(e,t)=>{let n={};for(let[r,i]of Object.entries(e)){let e=t[r]??{},a={};for(let[t,n]of Object.entries(i))(e[t]?.value!==n.value||e[t]?.source!==n.source)&&(a[t]=n);Object.keys(a).length>0&&(n[r]=a)}return n},F=(e,t,n,r)=>{let i=E(r,n),a=D(i),o=a?.apps??{},s=a?.anonId??null,c=a===null,l={},u=0,d=(e,t)=>{s!==null&&s!==e.anonId&&(o={}),s=e.anonId;let n=new Set(Object.entries(e.accepted).flatMap(([e,t])=>t.map(t=>`${e}\u0000${t}`)));for(let[e,r]of Object.entries(t))for(let[t,i]of Object.entries(r))n.has(`${e}\u0000${t}`)&&(o[e]={...o[e],[t]:i});O(i,{at:Date.now(),anonId:s,apps:o})},f=null,p=()=>{u+=1,o={},l={},k(i)},m=n=>{if(f=n,!c)return;let r=P(N(e,n),{...o,...l});if(Object.keys(r).length===0)return;let i=u;l={...l,...r},t(T(r)).then(e=>{i===u&&d(e,r)}).catch(()=>{}).finally(()=>{l={}})};return{settled:e=>{m(e)},needsAnon:()=>!c,observedAnon:e=>{(e===null||s!==null&&s!==e)&&p(),s=e,c=!0,m(f)},clear:p}},I=Symbol.for(`qinto.connectGate`),L=()=>{},R=e=>{let t=globalThis,n=(t[I]??Promise.resolve()).then(e);return t[I]=n.then(L,L),n},z=class extends e{constructor(e){super(e),this.name=`QintoProtocolError`}},B=e=>{if(typeof e!=`string`)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n=t;return n.t===`ack`||n.t===`error`||n.t===`consentState`||n.t===`session`||n.t===`captureAck`||n.t===`appPush`||n.t===`sharedContext`?t:null},V=e=>{if(e.t===`consentState`)return{categories:e.categories,apps:e.apps};if(e.t===`session`)return{anonId:e.anonId,globalId:e.globalId,ip:e.ip,geo:e.geo};if(e.t===`captureAck`)return{anonId:e.anonId,accepted:e.accepted}},H=e=>{let n=new Map,r=e=>{let t=n.get(e);if(t!==void 0)return clearTimeout(t.timer),n.delete(e),t};return{submit:r=>new Promise((i,a)=>{let o={frame:r,sent:e.send(r),resolve:i,reject:a,timer:setTimeout(()=>{n.delete(r.ref),a(new t(`The Qinto request timed out.`))},e.requestTimeoutMs)};n.set(r.ref,o)}),flush:()=>{for(let t of n.values())t.sent||=e.send(t.frame)},deliver:e=>{let t=e.ref===void 0?void 0:r(e.ref);if(t!==void 0){if(e.t===`error`){t.reject(new z(e.message));return}t.resolve(V(e))}},rejectAll:e=>{let t=[...n.values()];n.clear();for(let n of t)clearTimeout(n.timer),n.reject(e)}}},U=e=>new WebSocket(e),se=500,W=3e4,G=`session not initialized`,K=(e,t)=>{let n=Math.min(se*2**e,W);return Math.round(n/2+n/2*t)},ce=(e,t)=>e.t===`appPush`?(t.onAppPush?.(e),!0):e.t===`sharedContext`?(t.onSharedContext?.(e),!0):!1,le=e=>{let t=`${e.destination.replace(/\/+$/,``)}/open`,n=null,r=null,i=0,a=null,o=H({send:e=>n===null||n.readyState!==1?!1:(n.send(JSON.stringify(e)),!0),requestTimeoutMs:e.requestTimeoutMs}),s=t=>{e.onError?.(t)},c=()=>{if(r!==null&&(clearTimeout(r),r=null),n!==null){let e=n;n=null,e.close()}o.rejectAll(new z(`connection closed`))},l=()=>{let u=U(t);n=u,u.onopen=()=>{i=0;let e=a;a=null,o.flush(),e?.resolve()},u.onmessage=t=>{let n=B(t.data);if(n===null){s(new z(`invalid message`));return}ce(n,e)||(`anonId`in n&&typeof n.anonId==`string`&&e.onAnonId?.(n.anonId),o.deliver(n),n.t===`error`&&n.message===G&&u.close())},u.onerror=()=>{s(new z(`connection closed`))},u.onclose=()=>{if(n!==u)return;n=null;let e=a;if(e!==null){a=null,c(),e.reject(new z(`connection closed`));return}o.rejectAll(new z(`connection closed`)),r=setTimeout(()=>{r=null,l()},K(i,Math.random())),i+=1}};return{connect:()=>new Promise((e,t)=>{a={resolve:e,reject:t},l()}),submit:e=>o.submit(e),close:()=>{c()}}},ue=1e4,de=()=>{let e=0;return()=>(e+=1,`q${e}`)},fe=(e,t)=>{let n=`qinto:visit:${e.replace(/\/+$/,``)}:${t}`,r,i=!1;try{let e=sessionStorage.getItem(n),t=e===null?null:JSON.parse(e);t===null||typeof t.id!=`string`||!/^vis_[0-9a-f-]{36}$/.test(t.id)||!Number.isSafeInteger(t.startedAt)||t.startedAt<0?(r={id:`vis_${crypto.randomUUID()}`,startedAt:Date.now()},sessionStorage.setItem(n,JSON.stringify(r)),i=!0):r={id:t.id,startedAt:t.startedAt}}catch{r={id:`vis_${crypto.randomUUID()}`,startedAt:Date.now()},i=!0}return()=>{let e={...r,isNew:i};return i=!1,e}},pe=(e,t,n,i)=>{let a=null,o=fe(n,i),s=()=>{let e=document.referrer;return{occurredAt:Date.now(),page:{url:window.location.href,...e===``?{}:{referrer:e}},session:o()}},c=async()=>{let n=await e.submit({t:`getSession`,ref:t()});return a=n.anonId,n};return{actionContext:s,submitIdentify:async({traits:n,id:r,context:i,appResults:a})=>{await e.submit({t:`identify`,ref:t(),traits:n,id:r,context:i,appResults:a})},submitTrack:async({event:n,eventId:r,properties:i,context:a,appResults:o})=>{await e.submit({t:`track`,ref:t(),event:n,eventId:r,properties:i,context:a,appResults:o})},submitConsent:async(n,r)=>{await e.submit({t:`consent`,ref:t(),categories:n.categories,apps:n.apps,context:r})},track:async(n,i,a)=>{let o=r(a?.eventId,i);return await e.submit({t:`track`,ref:t(),event:n,eventId:o,properties:i,context:s()}),{eventId:o}},alias:async n=>{await e.submit({t:`alias`,ref:t(),alias:n})},getConsent:async()=>await e.submit({t:`getConsent`,ref:t()}),getSession:c,getAnonId:async()=>(a===null&&await c(),a),close:()=>{e.close()}}},me=async e=>{let t=le({destination:e.destination,requestTimeoutMs:e.requestTimeoutMs??ue,onError:e.onError,onAppPush:e.onAppPush,onSharedContext:e.onSharedContext,onAnonId:e.onAnonId});await R(()=>t.connect());let n=de();return{client:pe(t,n,e.destination,e.globalName??`qinto`),submitCapture:async e=>await t.submit({t:`capture`,ref:n(),apps:e})}},he=[`then`,`ready`,`config`],q=()=>{},ge=(e,t)=>(...n)=>{let r=new Promise((r,i)=>{e.q.push([t,n,r,i])});return r.catch(q),r},J=e=>{let t=e;return t._q=1,t.q=[],new Proxy(t,{get:(e,n)=>typeof n!=`string`||he.includes(n)||n in t?Reflect.get(t,n):(t[n]=ge(t,n),t[n])})},_e=()=>{let e=document.currentScript?.dataset.qintoGlobal;return typeof e==`string`&&e!==``?e:`qinto`},ve=e=>typeof e==`object`&&!!e&&e._q===1,ye=(e=`qinto`)=>{let t=globalThis;if(e in t){let n=t[e];if(!ve(n))return null;let r=Array.isArray(n.q)?n:J(n);return r!==n&&Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0}),r}let n=J({});return Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0}),n},be=(t,n)=>async(r,i)=>{let a=Reflect.get(t,r);if(typeof a!=`function`)throw new e(`[Qinto] ${n}.${r} is not a method of this tag.`);return a.apply(t,Array.from(i))},Y=e=>()=>Promise.reject(e),X=(e,t)=>{let[n,r,i,a]=t;e(n,r).then(i,a)},xe=e=>{let t=[];return t.push=(...t)=>{for(let n of t)X(e,n);return 0},t},Se=(e,t,n=`window.qinto`)=>{let r=e.ready;if(r!==void 0)return r;let i=e,a=e=>{let t=i.q;i.q=xe(e);for(let n of t)X(e,n)},o=t().then(e=>{a(be(e,n))},e=>{throw a(Y(e)),e});return o.catch(q),i.ready=o,o},Z=_e(),Q=ye(Z),$=`window.${Z}`;if(Q!==null&&Q.ready===void 0){let e=null,t=ie(Q,{onConsentSettled:t=>{e?.settled(t)},onConsentMutation:()=>{e?.clear()},onPageEvent:t=>{e?.settled(t)}});oe(Q),Se(Q,async()=>{let n=Q.config?.destination;if(typeof n!=`string`||n===``)throw Error(`[Qinto] ${$}.config.destination is missing.`);let r=await me({destination:n,globalName:Z,onAppPush:t.push,onSharedContext:t.sharedContext,onAnonId:t=>{e?.observedAnon(t)}});e=F(Q,r.submitCapture,n,Z);let i=await t.connect(r.client);return e.needsAnon()&&e.observedAnon((await r.client.getSession()).anonId),i},$)}})();
|