@uniformdev/canvas 16.2.1-nuxt.252 → 16.2.1-nuxt.274

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.
@@ -0,0 +1,5 @@
1
+ var Y=Object.create;var E=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ne=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ye=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+n+'" is not supported')});var Ce=(n,e)=>()=>(n&&(e=n(n=0)),e);var _=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},S=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of X(e))!te.call(n,o)&&o!==t&&E(n,o,{get:()=>e[o],enumerable:!(r=Q(e,o))||r.enumerable});return n};var re=(n,e,t)=>(t=n!=null?Y(ee(n)):{},S(e||!n||!n.__esModule?E(t,"default",{value:n,enumerable:!0}):t,n)),Te=n=>S(E({},"__esModule",{value:!0}),n);var ge=(n,e,t)=>(ne(n,typeof e!="symbol"?e+"":e,t),t),O=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var oe=(n,e,t)=>(O(n,e,"read from private field"),t?t.call(n):e.get(n)),Pe=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},ie=(n,e,t,r)=>(O(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Ae=(n,e,t,r)=>({set _(o){ie(n,e,o,t)},get _(){return oe(n,e,r)}});var M=_((Se,k)=>{function u(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}k.exports=u;u.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};u.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};u.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};u.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};u.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};u.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};u.prototype.start=u.prototype.try;u.prototype.errors=function(){return this._errors};u.prototype.attempts=function(){return this._attempts};u.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(n[i]||0)+1;n[i]=s,s>=t&&(e=o,t=s)}return e}});var V=_(f=>{var se=M();f.operation=function(n){var e=f.timeouts(n);return new se(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};f.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};f.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};f.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var o=0;o<t.length;o++){var i=t[o],s=n[i];n[i]=function(c){var m=f.operation(e),p=Array.prototype.slice.call(arguments,1),l=p.pop();p.push(function(h){m.retry(h)||(h&&(arguments[0]=m.mainError()),l.apply(this,arguments))}),m.attempt(function(){c.apply(n,p)})}.bind(n,s),n[i].options=e}}});var B=_((Ne,$)=>{$.exports=V()});function P(n,e){let t=[{ancestorsAndSelf:[{component:n,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=t.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:a=>{Object.assign(o.component,a),["parameters","variant","slots","data","_pattern","_patternError"].forEach(m=>{a[m]||delete o.component[m]})},removeComponent:()=>{let{parentSlot:a,parentSlotIndex:c}=r.ancestorsAndSelf[0],m=r.ancestorsAndSelf[1];if(a&&typeof c!="undefined")m.component.slots[a].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:a=>{let c=Array.isArray(a)?a:[a],{parentSlot:m,parentSlotIndex:p}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(m&&typeof p!="undefined")l.component.slots[m].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let a=Object.keys(s);for(let c=a.length-1;c>=0;c--){let m=a[c],p=s[m];for(let l=p.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:p[l],parentSlot:m,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(t.length>0)}function v(n){let e=[];for(let t=n.length-1;t>=0;t--){let{parentSlot:r,parentSlotIndex:o}=n[t];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var N=class{constructor(e,t){this.groups=e.reduce((r,o)=>{var s;let i=t(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,t){this.groups[e].forEach(r=>r.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var A=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},L=class{constructor(){this._componentIndex={};this._rootBuilder=new A}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>{this._componentIndex[o]=this._componentIndex[o]||new A,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,r)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){t=new Map(t);for(let[o,i]of r.resolveComponentEnhancers())t.set(o,i)}return t}};var w=class{constructor(e,t,r){this._resolve=e;this._reject=t;this.args=r;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function be({handleBatch:n,shouldQueue:e,limitPolicy:t}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((a,c)=>{r.push(new w(a,c,s))})},completeAll:async()=>{if(r.length>0){try{await n(r)}catch(a){r.forEach(c=>c.reject(a))}if(r.some(a=>!a.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:t}}var x=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function b({limit:n,interval:e,strict:t}){if(!Number.isFinite(n))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let p=Date.now();return p-o>e?(i=1,o=p,0):(i<n?i++:(o+=e,i=1),o-p)}let a=[];function c(){let p=Date.now();if(a.length<n)return a.push(p),0;let l=a.shift()+e;return p>=l?(a.push(p),0):(a.push(l),l-p)}let m=t?c:s;return p=>{let l=function(...h){if(!l.isEnabled)return(async()=>p.apply(this,h))();let y;return new Promise((C,W)=>{y=setTimeout(()=>{C(p.apply(this,h)),r.delete(y)},m()),r.set(y,W)})};return l.abort=()=>{for(let h of r.keys())clearTimeout(h),r.get(h)(new x);r.clear(),a.splice(0,a.length)},l.isEnabled=!0,l}}var U=re(B(),1),ae=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),R=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},ce=(n,e,t)=>{let r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},pe=n=>ae.has(n),D=n=>globalThis.DOMException===void 0?new Error(n):new DOMException(n);async function I(n,e){return new Promise((t,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=U.default.operation(e);o.attempt(async i=>{try{t(await n(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof R)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!pe(s.message))o.stop(),r(s);else{ce(s,i,e);try{await e.onFailedAttempt(s)}catch(a){r(a);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?D("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:D(i))},{once:!0})})}function j({throttle:n={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=n?b(n):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>I(s,e)}return i()}}var d=async n=>await n();async function Fe({composition:n,enhancers:e,context:t,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
2
+ ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
+
4
+ `))}}){let o=[],i=new Set,s=new Set;P(n,(c,m)=>{var l;Object.entries((l=c.parameters)!=null?l:{}).forEach(([h,y])=>{let C=e.resolveParameterEnhancer(c,h,y);C&&(s.add(C),o.push(le(c,m,h,y,C,t)))});let p=e.resolveComponentEnhancers(c);o.push(me(c,m,p,t)),i.add(p)}),o.push(...Array.from(i).flatMap(c=>Array.from(c).map(async([,m])=>{var p;try{m.completeAll&&await((p=m.limitPolicy)!=null?p:d)(()=>m.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async c=>{var m;try{c.completeAll&&await((m=c.limitPolicy)!=null?m:d)(()=>c.completeAll())}catch(p){return{error:p,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(o)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&r(a)}async function me(n,e,t,r){return t.size&&(n.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let c=await(i.completeAll?d:(s=i.limitPolicy)!=null?s:d)(async()=>i.enhanceOne({component:n,context:r}));c!=null&&(n.data[o]=c)}catch(a){let c=`Component ${v(e)} (type: ${n.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete n.data[o],{message:c,error:a}}}))}async function le(n,e,t,r,o,i){var s;try{let c=await(o.completeAll?d:(s=o.limitPolicy)!=null?s:d)(async()=>o.enhanceOne({parameter:r,parameterName:t,component:n,context:i}));c===null?delete n.parameters[t]:typeof c=="undefined"?n.parameters[t]={...r,value:r.value}:n.parameters[t]={...r,value:c}}catch(a){let c=`Component ${v(e)} (type: ${n.type}): enhancing parameter ${t} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete n.parameters[t],{message:c,error:a}}}var ze=(n,...e)=>({enhanceOne:r=>{let o="enhanceOne"in n?n.enhanceOne(r):n(r);for(let i of e){let s=ue(o)?o:Promise.resolve(o),a="enhanceOne"in i?i.enhanceOne:i;o=s.then(c=>a({...r,parameter:{type:r.parameter.type,value:c}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in n?(r=n.completeAll)==null?void 0:r.call(n):0)!=null?o:0}});function ue(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var T=class extends Error{constructor(t,r,o,i,s,a){super(`${t}
5
+ ${i}${s?" "+s:""} (${r} ${o}${a?` Request ID: ${a}`:""})`);this.errorMessage=t;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=a;Object.setPrototypeOf(this,T.prototype)}},g=class{constructor(e){var r,o,i,s,a,c;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(a=e.limitPolicy)!=null?a:j({}),bypassCache:(c=e.bypassCache)!=null?c:!1}}async getCompositionList(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionById(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(r)}async updateComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...t,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...t==null?void 0:t.headers,...r}});if(!o.ok){let s="";try{let a=await o.text();try{let c=JSON.parse(a);c.errorMessage?s=Array.isArray(c.errorMessage)?c.errorMessage.join(", "):c.errorMessage:s=a}catch(c){s=a}}catch(a){s="General error"}throw new T(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,g.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},F=class extends g{constructor(e){super({...e,bypassCache:!0})}};var Je="$personalization",We="$test",G="$localization",Ye="intentTag",z="locale",Qe="pz",Xe="test",H="localized",et=0,tt=64,K="$pzCrit",Z="$tstVrnt",nt="$enr";var ot=n=>n.startsWith("$");function at(n){return n?n.map((e,t)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[K])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:r}}):[]}function mt(n){return n?n.map((e,t)=>{var i,s,a;let r=(s=(i=e.parameters)==null?void 0:i[Z])==null?void 0:s.value,o=(a=r==null?void 0:r.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var q="https://js.pusher.com/7.0.3/pusher.min.js";async function he(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((n,e)=>{let t=setTimeout(()=>{window.Pusher&&n(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${q}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=q,r.addEventListener("load",()=>{clearTimeout(t),n(window.Pusher)}),document.head.appendChild(r)})}async function ut(){let n=await he();if(!n)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new n("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=t.subscribe(r);return{unsubscribe:()=>t.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function J(n,e,t){return`${n}.${e}@${t}`}function yt({projectId:n,compositionId:e,compositionState:t=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=J(n,e,t),a=r(s),c=a.addEventHandler(i,o);return()=>{c(),a.unsubscribe()}}function fe({component:n}){var r;let e={},t=(r=n.slots)==null?void 0:r[H];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[z];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function gt({composition:n,locale:e}){P(n,(t,r,o)=>{if(t.type===G){let i=fe({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),a;if(s&&(a=i[s]),a!=null&&a.length){let[c,...m]=a;o.replaceComponent(c),m.length&&o.insertAfter(m)}else o.removeComponent()}})}export{ye as a,Ce as b,_ as c,Ee as d,re as e,Te as f,ge as g,oe as h,Pe as i,ie as j,Ae as k,P as l,v as m,N as n,A as o,L as p,w as q,be as r,j as s,d as t,Fe as u,ze as v,T as w,g as x,F as y,Je as z,We as A,G as B,Ye as C,z as D,Qe as E,Xe as F,H as G,et as H,tt as I,K as J,Z as K,nt as L,ot as M,at as N,mt as O,ut as P,J as Q,yt as R,fe as S,gt as T};
package/dist/cli/cli.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { UniformCLIPlugin } from '@uniformdev/cli';
2
- import { A as CanvasDefinitions } from '../createEventBus-cca4f579.js';
2
+ import { A as CanvasDefinitions } from '../createEventBus-97db7eb7.js';
3
3
  import { UniformPackage } from '@uniformdev/cli/sync';
4
4
  import 'pusher-js';
5
5
 
package/dist/cli/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{H as r4,I as vd,a as Z,b as ud,c as z,d as fd,e as $p,f as hd,g as ei,h as ma,i as kp,j as P1,k as ai,y as ne}from"../chunk-6OEWBKP7.mjs";var or=z((mm,nr)=>{var Ka=1e3,Ja=Ka*60,Qa=Ja*60,Ea=Qa*24,Ul=Ea*7,$l=Ea*365.25;nr.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return kl(e);if(p==="number"&&isFinite(e))return a.long?Hl(e):ql(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function kl(e){if(e=String(e),!(e.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!a){var p=parseFloat(a[1]),t=(a[2]||"ms").toLowerCase();switch(t){case"years":case"year":case"yrs":case"yr":case"y":return p*$l;case"weeks":case"week":case"w":return p*Ul;case"days":case"day":case"d":return p*Ea;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Qa;case"minutes":case"minute":case"mins":case"min":case"m":return p*Ja;case"seconds":case"second":case"secs":case"sec":case"s":return p*Ka;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function ql(e){var a=Math.abs(e);return a>=Ea?Math.round(e/Ea)+"d":a>=Qa?Math.round(e/Qa)+"h":a>=Ja?Math.round(e/Ja)+"m":a>=Ka?Math.round(e/Ka)+"s":e+"ms"}function Hl(e){var a=Math.abs(e);return a>=Ea?ct(e,a,Ea,"day"):a>=Qa?ct(e,a,Qa,"hour"):a>=Ja?ct(e,a,Ja,"minute"):a>=Ka?ct(e,a,Ka,"second"):e+" ms"}function ct(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var Ri=z((cm,sr)=>{function zl(e){p.debug=p,p.default=p,p.coerce=o,p.disable=r,p.enable=i,p.enabled=d,p.humanize=or(),p.destroy=s,Object.keys(e).forEach(l=>{p[l]=e[l]}),p.names=[],p.skips=[],p.formatters={};function a(l){let m=0;for(let c=0;c<l.length;c++)m=(m<<5)-m+l.charCodeAt(c),m|=0;return p.colors[Math.abs(m)%p.colors.length]}p.selectColor=a;function p(l){let m,c=null,u,v;function g(...h){if(!g.enabled)return;let C=g,x=Number(new Date),T=x-(m||x);C.diff=T,C.prev=m,C.curr=x,m=x,h[0]=p.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let B=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(L,O)=>{if(L==="%%")return"%";B++;let G=p.formatters[O];if(typeof G=="function"){let X=h[B];L=G.call(C,X),h.splice(B,1),B--}return L}),p.formatArgs.call(C,h),(C.log||p.log).apply(C,h)}return g.namespace=l,g.useColors=p.useColors(),g.color=p.selectColor(l),g.extend=t,g.destroy=p.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==p.namespaces&&(u=p.namespaces,v=p.enabled(l)),v),set:h=>{c=h}}),typeof p.init=="function"&&p.init(g),g}function t(l,m){let c=p(this.namespace+(typeof m=="undefined"?":":m)+l);return c.log=this.log,c}function i(l){p.save(l),p.namespaces=l,p.names=[],p.skips=[];let m,c=(typeof l=="string"?l:"").split(/[\s,]+/),u=c.length;for(m=0;m<u;m++)!c[m]||(l=c[m].replace(/\*/g,".*?"),l[0]==="-"?p.skips.push(new RegExp("^"+l.slice(1)+"$")):p.names.push(new RegExp("^"+l+"$")))}function r(){let l=[...p.names.map(n),...p.skips.map(n).map(m=>"-"+m)].join(",");return p.enable(""),l}function d(l){if(l[l.length-1]==="*")return!0;let m,c;for(m=0,c=p.skips.length;m<c;m++)if(p.skips[m].test(l))return!1;for(m=0,c=p.names.length;m<c;m++)if(p.names[m].test(l))return!0;return!1}function n(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function o(l){return l instanceof Error?l.stack||l.message:l}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return p.enable(p.load()),p}sr.exports=zl});var lr=z((Ye,ut)=>{Ye.formatArgs=Yl;Ye.save=Gl;Ye.load=Kl;Ye.useColors=Wl;Ye.storage=Jl();Ye.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ye.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Wl(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Yl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ut.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let p=0,t=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(p++,i==="%c"&&(t=p))}),e.splice(t,0,a)}Ye.log=console.debug||console.log||(()=>{});function Gl(e){try{e?Ye.storage.setItem("debug",e):Ye.storage.removeItem("debug")}catch(a){}}function Kl(){let e;try{e=Ye.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function Jl(){try{return localStorage}catch(e){}}ut.exports=Ri()(Ye);var{formatters:Ql}=ut.exports;Ql.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var cr=z((um,mr)=>{"use strict";mr.exports=(e,a=process.argv)=>{let p=e.startsWith("-")?"":e.length===1?"-":"--",t=a.indexOf(p+e),i=a.indexOf("--");return t!==-1&&(i===-1||t<i)}});var hr=z((fm,fr)=>{"use strict";var Zl=Z("os"),ur=Z("tty"),a1=cr(),{env:Ee}=process,$1;a1("no-color")||a1("no-colors")||a1("color=false")||a1("color=never")?$1=0:(a1("color")||a1("colors")||a1("color=true")||a1("color=always"))&&($1=1);"FORCE_COLOR"in Ee&&(Ee.FORCE_COLOR==="true"?$1=1:Ee.FORCE_COLOR==="false"?$1=0:$1=Ee.FORCE_COLOR.length===0?1:Math.min(parseInt(Ee.FORCE_COLOR,10),3));function Ui(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function $i(e,a){if($1===0)return 0;if(a1("color=16m")||a1("color=full")||a1("color=truecolor"))return 3;if(a1("color=256"))return 2;if(e&&!a&&$1===void 0)return 0;let p=$1||0;if(Ee.TERM==="dumb")return p;if(process.platform==="win32"){let t=Zl.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Ee)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in Ee)||Ee.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in Ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ee.TEAMCITY_VERSION)?1:0;if(Ee.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Ee){let t=parseInt((Ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ee.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ee.TERM)||"COLORTERM"in Ee?1:p}function Xl(e){let a=$i(e,e&&e.isTTY);return Ui(a)}fr.exports={supportsColor:Xl,stdout:Ui($i(!0,ur.isatty(1))),stderr:Ui($i(!0,ur.isatty(2)))}});var gr=z((Fe,ht)=>{var e8=Z("tty"),ft=Z("util");Fe.init=n8;Fe.log=i8;Fe.formatArgs=p8;Fe.save=d8;Fe.load=r8;Fe.useColors=a8;Fe.destroy=ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Fe.colors=[6,2,3,4,5,1];try{let e=hr();e&&(e.stderr||e).level>=2&&(Fe.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}Fe.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{let p=a.substring(6).toLowerCase().replace(/_([a-z])/g,(i,r)=>r.toUpperCase()),t=process.env[a];return/^(yes|on|true|enabled)$/i.test(t)?t=!0:/^(no|off|false|disabled)$/i.test(t)?t=!1:t==="null"?t=null:t=Number(t),e[p]=t,e},{});function a8(){return"colors"in Fe.inspectOpts?Boolean(Fe.inspectOpts.colors):e8.isatty(process.stderr.fd)}function p8(e){let{namespace:a,useColors:p}=this;if(p){let t=this.color,i="\x1B[3"+(t<8?t:"8;5;"+t),r=` ${i};1m${a} \x1B[0m`;e[0]=r+e[0].split(`
1
+ import{H as r4,I as vd,a as Z,b as ud,c as z,d as fd,e as $p,f as hd,g as ei,h as ma,i as kp,j as P1,k as ai,y as ne}from"../chunk-2C4YYM6A.mjs";var or=z((mm,nr)=>{var Ka=1e3,Ja=Ka*60,Qa=Ja*60,Ea=Qa*24,Ul=Ea*7,$l=Ea*365.25;nr.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return kl(e);if(p==="number"&&isFinite(e))return a.long?Hl(e):ql(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function kl(e){if(e=String(e),!(e.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!a){var p=parseFloat(a[1]),t=(a[2]||"ms").toLowerCase();switch(t){case"years":case"year":case"yrs":case"yr":case"y":return p*$l;case"weeks":case"week":case"w":return p*Ul;case"days":case"day":case"d":return p*Ea;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Qa;case"minutes":case"minute":case"mins":case"min":case"m":return p*Ja;case"seconds":case"second":case"secs":case"sec":case"s":return p*Ka;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function ql(e){var a=Math.abs(e);return a>=Ea?Math.round(e/Ea)+"d":a>=Qa?Math.round(e/Qa)+"h":a>=Ja?Math.round(e/Ja)+"m":a>=Ka?Math.round(e/Ka)+"s":e+"ms"}function Hl(e){var a=Math.abs(e);return a>=Ea?ct(e,a,Ea,"day"):a>=Qa?ct(e,a,Qa,"hour"):a>=Ja?ct(e,a,Ja,"minute"):a>=Ka?ct(e,a,Ka,"second"):e+" ms"}function ct(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var Ri=z((cm,sr)=>{function zl(e){p.debug=p,p.default=p,p.coerce=o,p.disable=r,p.enable=i,p.enabled=d,p.humanize=or(),p.destroy=s,Object.keys(e).forEach(l=>{p[l]=e[l]}),p.names=[],p.skips=[],p.formatters={};function a(l){let m=0;for(let c=0;c<l.length;c++)m=(m<<5)-m+l.charCodeAt(c),m|=0;return p.colors[Math.abs(m)%p.colors.length]}p.selectColor=a;function p(l){let m,c=null,u,v;function g(...h){if(!g.enabled)return;let C=g,x=Number(new Date),T=x-(m||x);C.diff=T,C.prev=m,C.curr=x,m=x,h[0]=p.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let B=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(L,O)=>{if(L==="%%")return"%";B++;let G=p.formatters[O];if(typeof G=="function"){let X=h[B];L=G.call(C,X),h.splice(B,1),B--}return L}),p.formatArgs.call(C,h),(C.log||p.log).apply(C,h)}return g.namespace=l,g.useColors=p.useColors(),g.color=p.selectColor(l),g.extend=t,g.destroy=p.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==p.namespaces&&(u=p.namespaces,v=p.enabled(l)),v),set:h=>{c=h}}),typeof p.init=="function"&&p.init(g),g}function t(l,m){let c=p(this.namespace+(typeof m=="undefined"?":":m)+l);return c.log=this.log,c}function i(l){p.save(l),p.namespaces=l,p.names=[],p.skips=[];let m,c=(typeof l=="string"?l:"").split(/[\s,]+/),u=c.length;for(m=0;m<u;m++)!c[m]||(l=c[m].replace(/\*/g,".*?"),l[0]==="-"?p.skips.push(new RegExp("^"+l.slice(1)+"$")):p.names.push(new RegExp("^"+l+"$")))}function r(){let l=[...p.names.map(n),...p.skips.map(n).map(m=>"-"+m)].join(",");return p.enable(""),l}function d(l){if(l[l.length-1]==="*")return!0;let m,c;for(m=0,c=p.skips.length;m<c;m++)if(p.skips[m].test(l))return!1;for(m=0,c=p.names.length;m<c;m++)if(p.names[m].test(l))return!0;return!1}function n(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function o(l){return l instanceof Error?l.stack||l.message:l}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return p.enable(p.load()),p}sr.exports=zl});var lr=z((Ye,ut)=>{Ye.formatArgs=Yl;Ye.save=Gl;Ye.load=Kl;Ye.useColors=Wl;Ye.storage=Jl();Ye.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ye.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Wl(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Yl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ut.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let p=0,t=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(p++,i==="%c"&&(t=p))}),e.splice(t,0,a)}Ye.log=console.debug||console.log||(()=>{});function Gl(e){try{e?Ye.storage.setItem("debug",e):Ye.storage.removeItem("debug")}catch(a){}}function Kl(){let e;try{e=Ye.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function Jl(){try{return localStorage}catch(e){}}ut.exports=Ri()(Ye);var{formatters:Ql}=ut.exports;Ql.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var cr=z((um,mr)=>{"use strict";mr.exports=(e,a=process.argv)=>{let p=e.startsWith("-")?"":e.length===1?"-":"--",t=a.indexOf(p+e),i=a.indexOf("--");return t!==-1&&(i===-1||t<i)}});var hr=z((fm,fr)=>{"use strict";var Zl=Z("os"),ur=Z("tty"),a1=cr(),{env:Ee}=process,$1;a1("no-color")||a1("no-colors")||a1("color=false")||a1("color=never")?$1=0:(a1("color")||a1("colors")||a1("color=true")||a1("color=always"))&&($1=1);"FORCE_COLOR"in Ee&&(Ee.FORCE_COLOR==="true"?$1=1:Ee.FORCE_COLOR==="false"?$1=0:$1=Ee.FORCE_COLOR.length===0?1:Math.min(parseInt(Ee.FORCE_COLOR,10),3));function Ui(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function $i(e,a){if($1===0)return 0;if(a1("color=16m")||a1("color=full")||a1("color=truecolor"))return 3;if(a1("color=256"))return 2;if(e&&!a&&$1===void 0)return 0;let p=$1||0;if(Ee.TERM==="dumb")return p;if(process.platform==="win32"){let t=Zl.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Ee)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in Ee)||Ee.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in Ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ee.TEAMCITY_VERSION)?1:0;if(Ee.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Ee){let t=parseInt((Ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ee.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ee.TERM)||"COLORTERM"in Ee?1:p}function Xl(e){let a=$i(e,e&&e.isTTY);return Ui(a)}fr.exports={supportsColor:Xl,stdout:Ui($i(!0,ur.isatty(1))),stderr:Ui($i(!0,ur.isatty(2)))}});var gr=z((Fe,ht)=>{var e8=Z("tty"),ft=Z("util");Fe.init=n8;Fe.log=i8;Fe.formatArgs=p8;Fe.save=d8;Fe.load=r8;Fe.useColors=a8;Fe.destroy=ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Fe.colors=[6,2,3,4,5,1];try{let e=hr();e&&(e.stderr||e).level>=2&&(Fe.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}Fe.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{let p=a.substring(6).toLowerCase().replace(/_([a-z])/g,(i,r)=>r.toUpperCase()),t=process.env[a];return/^(yes|on|true|enabled)$/i.test(t)?t=!0:/^(no|off|false|disabled)$/i.test(t)?t=!1:t==="null"?t=null:t=Number(t),e[p]=t,e},{});function a8(){return"colors"in Fe.inspectOpts?Boolean(Fe.inspectOpts.colors):e8.isatty(process.stderr.fd)}function p8(e){let{namespace:a,useColors:p}=this;if(p){let t=this.color,i="\x1B[3"+(t<8?t:"8;5;"+t),r=` ${i};1m${a} \x1B[0m`;e[0]=r+e[0].split(`
2
2
  `).join(`
3
3
  `+r),e.push(i+"m+"+ht.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=t8()+a+" "+e[0]}function t8(){return Fe.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i8(...e){return process.stderr.write(ft.format(...e)+`
4
4
  `)}function d8(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function r8(){return process.env.DEBUG}function n8(e){e.inspectOpts={};let a=Object.keys(Fe.inspectOpts);for(let p=0;p<a.length;p++)e.inspectOpts[a[p]]=Fe.inspectOpts[a[p]]}ht.exports=Ri()(Fe);var{formatters:vr}=ht.exports;vr.o=function(e){return this.inspectOpts.colors=this.useColors,ft.inspect(e,this.inspectOpts).split(`
@@ -215,7 +215,7 @@ interface external$1 {
215
215
  /** @description Friendly name of the component definition */
216
216
  name: string;
217
217
  /**
218
- * @description Icon name for the component definition (e.g. 'screen')
218
+ * @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
219
219
  * @default screen
220
220
  */
221
221
  icon?: string;
@@ -422,7 +422,7 @@ interface components$1 {
422
422
  /** @description Friendly name of the component definition */
423
423
  name: string;
424
424
  /**
425
- * @description Icon name for the component definition (e.g. 'screen')
425
+ * @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
426
426
  * @default screen
427
427
  */
428
428
  icon?: string;
@@ -853,7 +853,7 @@ interface external {
853
853
  /** @description Friendly name of the component definition */
854
854
  name: string;
855
855
  /**
856
- * @description Icon name for the component definition (e.g. 'screen')
856
+ * @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
857
857
  * @default screen
858
858
  */
859
859
  icon?: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionPutParameters, d as CompositionDeleteParameters, e as ComponentDefinitionGetParameters, f as ComponentDefinitionPutParameters, g as ComponentDefinitionDeleteParameters, P as PreviewEventBus } from './createEventBus-cca4f579.js';
2
- export { A as CanvasDefinitions, B as ChannelSubscription, r as ComponentDefinition, k as ComponentDefinitionAPIDeleteRequest, j as ComponentDefinitionAPIPutRequest, i as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, h as ComponentDefinitionGetResponse, l as ComponentDefinitionListAPIOptions, m as ComponentDefinitionParameter, q as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, p as ComponentDefinitionSlot, o as ComponentDefinitionSlugSettings, n as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, z as ComponentParameterBinding, w as CompositionAPIDeleteRequest, y as CompositionAPIOptions, v as CompositionAPIResponse, d as CompositionDeleteParameters, u as CompositionGetListResponse, b as CompositionGetParameters, t as CompositionGetResponse, x as CompositionListAPIResponse, c as CompositionPutParameters, s as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, D as createEventBus } from './createEventBus-cca4f579.js';
1
+ import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionPutParameters, d as CompositionDeleteParameters, e as ComponentDefinitionGetParameters, f as ComponentDefinitionPutParameters, g as ComponentDefinitionDeleteParameters, P as PreviewEventBus } from './createEventBus-97db7eb7.js';
2
+ export { A as CanvasDefinitions, B as ChannelSubscription, r as ComponentDefinition, k as ComponentDefinitionAPIDeleteRequest, j as ComponentDefinitionAPIPutRequest, i as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, h as ComponentDefinitionGetResponse, l as ComponentDefinitionListAPIOptions, m as ComponentDefinitionParameter, q as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, p as ComponentDefinitionSlot, o as ComponentDefinitionSlugSettings, n as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, z as ComponentParameterBinding, w as CompositionAPIDeleteRequest, y as CompositionAPIOptions, v as CompositionAPIResponse, d as CompositionDeleteParameters, u as CompositionGetListResponse, b as CompositionGetParameters, t as CompositionGetResponse, x as CompositionListAPIResponse, c as CompositionPutParameters, s as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, D as createEventBus } from './createEventBus-97db7eb7.js';
3
3
  import { Options } from 'p-throttle';
4
4
  import { Options as Options$1 } from 'p-retry';
5
5
  import { PersonalizedVariant, TestVariant } from '@uniformdev/context';
@@ -470,7 +470,7 @@ declare class CanvasClient {
470
470
  }[] | undefined;
471
471
  slugSettings?: {
472
472
  required?: "no" | "yes" | "disabled" | undefined;
473
- unique?: "global" | "no" | "local" | undefined;
473
+ unique?: "no" | "local" | "global" | undefined;
474
474
  regularExpression?: string | undefined;
475
475
  regularExpressionMessage?: string | undefined;
476
476
  } | undefined;
@@ -541,14 +541,6 @@ declare const CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
541
541
  declare const CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
542
542
  /** Public ID of the Uniform Context enrichment tag parameter on Canvas components */
543
543
  declare const CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
544
- /** Component type of 'loop' system component */
545
- declare const CANVAS_LOOP_TYPE = "$loop";
546
- /** Name of parameter on loop component that defines the name of the resource to expose for the iterator */
547
- declare const CANVAS_LOOP_RESOURCE_PARAMETER = "$loopResource";
548
- /** Name of the parameter that stores the binding for the loop */
549
- declare const CANVAS_LOOP_PARAMETER = "$loopBinding";
550
- /** Name of the slot that the loop component exposes for the iterator body */
551
- declare const CANVAS_LOOP_SLOT = "body";
552
544
 
553
545
  /** Determines if a given Canvas component type is a system-defined type */
554
546
  declare const isSystemComponentDefinition: (componentType: string) => boolean;
@@ -592,47 +584,4 @@ declare function localize({ composition, locale, }: {
592
584
  }) => string | undefined);
593
585
  }): void;
594
586
 
595
- /**
596
- * Resource objects that can be bound to on a composition
597
- * @deprecated Do not use
598
- */
599
- declare type CompositionResources = Record<string, unknown>;
600
-
601
- /** @deprecated Do not use */
602
- declare type BindParameterResult = {
603
- bound: boolean;
604
- value?: unknown;
605
- };
606
- /** @deprecated Do not use */
607
- declare function bindParameter(parameter: ComponentParameter, resources: CompositionResources): BindParameterResult;
608
-
609
- /** @deprecated Do not use */
610
- declare type BindParametersResult = {
611
- hasBindings: boolean;
612
- errors: Error[];
613
- result: ComponentInstance;
614
- };
615
- /** @deprecated Do not use */
616
- declare type BindParametersOptions = {
617
- /**
618
- * If true, any binding errors are thrown. Otherwise, they are returned in the result.
619
- * @default true
620
- */
621
- throwErrors?: boolean;
622
- /**
623
- * If true, loop components are bound and replaced by their enumerated values.
624
- * If false, loop components are untouched and remain in the composition data with bindings still in the loop body.
625
- * @default true
626
- */
627
- expandLoops?: boolean;
628
- /**
629
- * If true, leaves binding expressions behind in the resulting composition.
630
- * If false, binding expressions are removed from the resulting composition.
631
- * @default false
632
- */
633
- preserveBindings?: boolean;
634
- };
635
- /** @deprecated Do not use */
636
- declare function bindParameters(composition: ComponentInstance, resources: CompositionResources, options?: BindParametersOptions): BindParametersResult;
637
-
638
- export { BatchEnhancer, BatchEntry, BindParameterResult, BindParametersOptions, BindParametersResult, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_LOOP_PARAMETER, CANVAS_LOOP_RESOURCE_PARAMETER, CANVAS_LOOP_SLOT, CANVAS_LOOP_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, CanvasClientOptions, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionResources, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, WalkComponentTreeActions, bindParameter, bindParameters, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
587
+ export { BatchEnhancer, BatchEntry, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, CanvasClientOptions, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, WalkComponentTreeActions, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-6OEWBKP7.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,D as CANVAS_LOOP_PARAMETER,C as CANVAS_LOOP_RESOURCE_PARAMETER,E as CANVAS_LOOP_SLOT,B as CANVAS_LOOP_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,N as bindParameter,O as bindParameters,k as compose,g as createBatchEnhancer,I as createEventBus,h as createLimitPolicy,j as enhance,L as extractLocales,J as getChannelName,b as getComponentPath,F as isSystemComponentDefinition,M as localize,G as mapSlotToPersonalizedVariations,H as mapSlotToTestVariations,i as nullLimitPolicy,K as subscribeToComposition,a as walkComponentTree};
1
+ import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-2C4YYM6A.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,E as createEventBus,h as createLimitPolicy,j as enhance,H as extractLocales,F as getChannelName,b as getComponentPath,B as isSystemComponentDefinition,I as localize,C as mapSlotToPersonalizedVariations,D as mapSlotToTestVariations,i as nullLimitPolicy,G as subscribeToComposition,a as walkComponentTree};
package/dist/index.js CHANGED
@@ -1,11 +1,5 @@
1
- "use strict";var he=Object.create;var b=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})},Z=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of de(e))!Ce.call(n,o)&&o!==t&&b(n,o,{get:()=>e[o],enumerable:!(r=fe(e,o))||r.enumerable});return n};var I=(n,e,t)=>(t=n!=null?he(ye(n)):{},Z(e||!n||!n.__esModule?b(t,"default",{value:n,enumerable:!0}):t,n)),Pe=n=>Z(b({},"__esModule",{value:!0}),n);var W=R((Xe,q)=>{function h(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}q.exports=h;h.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};h.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};h.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};h.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};h.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};h.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};h.prototype.start=h.prototype.try;h.prototype.errors=function(){return this._errors};h.prototype.attempts=function(){return this._attempts};h.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(n[i]||0)+1;n[i]=s,s>=t&&(e=o,t=s)}return e}});var Q=R(A=>{var Ae=W();A.operation=function(n){var e=A.timeouts(n);return new Ae(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};A.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};A.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};A.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var o=0;o<t.length;o++){var i=t[o],s=n[i];n[i]=function(a){var p=A.operation(e),m=Array.prototype.slice.call(arguments,1),l=m.pop();m.push(function(u){p.retry(u)||(u&&(arguments[0]=p.mainError()),l.apply(this,arguments))}),p.attempt(function(){a.apply(n,m)})}.bind(n,s),n[i].options=e}}});var ee=R((tt,X)=>{X.exports=Q()});var Je={};Ee(Je,{BatchEntry:()=>w,CANVAS_DRAFT_STATE:()=>yt,CANVAS_ENRICHMENT_TAG_PARAM:()=>Be,CANVAS_INTENT_TAG_PARAM:()=>Le,CANVAS_LOCALE_TAG_PARAM:()=>j,CANVAS_LOCALIZATION_SLOT:()=>U,CANVAS_LOCALIZATION_TYPE:()=>k,CANVAS_LOOP_PARAMETER:()=>H,CANVAS_LOOP_RESOURCE_PARAMETER:()=>z,CANVAS_LOOP_SLOT:()=>J,CANVAS_LOOP_TYPE:()=>G,CANVAS_PERSONALIZATION_PARAM:()=>D,CANVAS_PERSONALIZE_SLOT:()=>Ne,CANVAS_PERSONALIZE_TYPE:()=>Oe,CANVAS_PUBLISHED_STATE:()=>Ct,CANVAS_TEST_SLOT:()=>$e,CANVAS_TEST_TYPE:()=>Se,CANVAS_TEST_VARIANT_PARAM:()=>F,CanvasClient:()=>_,CanvasClientError:()=>T,ChildEnhancerBuilder:()=>v,EnhancerBuilder:()=>S,UncachedCanvasClient:()=>V,UniqueBatchEntries:()=>O,bindParameter:()=>Y,bindParameters:()=>pe,compose:()=>Re,createBatchEnhancer:()=>ge,createEventBus:()=>Ue,createLimitPolicy:()=>M,enhance:()=>be,extractLocales:()=>oe,getChannelName:()=>K,getComponentPath:()=>g,isSystemComponentDefinition:()=>Me,localize:()=>Fe,mapSlotToPersonalizedVariations:()=>Ve,mapSlotToTestVariations:()=>ke,nullLimitPolicy:()=>C,subscribeToComposition:()=>De,walkComponentTree:()=>P});module.exports=Pe(Je);function P(n,e){let t=[{ancestorsAndSelf:[{component:n,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=t.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(o.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(p=>{c[p]||delete o.component[p]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:a}=r.ancestorsAndSelf[0],p=r.ancestorsAndSelf[1];if(c&&typeof a!="undefined")p.component.slots[c].splice(a,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let a=Array.isArray(c)?c:[c],{parentSlot:p,parentSlotIndex:m}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(p&&typeof m!="undefined")l.component.slots[p].splice(m+1,0,...a);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let c=Object.keys(s);for(let a=c.length-1;a>=0;a--){let p=c[a],m=s[p];for(let l=m.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:m[l],parentSlot:p,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(t.length>0)}function g(n){let e=[];for(let t=n.length-1;t>=0;t--){let{parentSlot:r,parentSlotIndex:o}=n[t];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var O=class{constructor(e,t){this.groups=e.reduce((r,o)=>{var s;let i=t(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,t){this.groups[e].forEach(r=>r.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var v=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},S=class{constructor(){this._componentIndex={};this._rootBuilder=new v}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>{this._componentIndex[o]=this._componentIndex[o]||new v,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,r)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){t=new Map(t);for(let[o,i]of r.resolveComponentEnhancers())t.set(o,i)}return t}};var w=class{constructor(e,t,r){this._resolve=e;this._reject=t;this.args=r;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function ge({handleBatch:n,shouldQueue:e,limitPolicy:t}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{r.push(new w(c,a,s))})},completeAll:async()=>{if(r.length>0){try{await n(r)}catch(c){r.forEach(a=>a.reject(c))}if(r.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:t}}var L=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function N({limit:n,interval:e,strict:t}){if(!Number.isFinite(n))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let m=Date.now();return m-o>e?(i=1,o=m,0):(i<n?i++:(o+=e,i=1),o-m)}let c=[];function a(){let m=Date.now();if(c.length<n)return c.push(m),0;let l=c.shift()+e;return m>=l?(c.push(m),0):(c.push(l),l-m)}let p=t?a:s;return m=>{let l=function(...u){if(!l.isEnabled)return(async()=>m.apply(this,u))();let d;return new Promise((f,y)=>{d=setTimeout(()=>{f(m.apply(this,u)),r.delete(d)},p()),r.set(d,y)})};return l.abort=()=>{for(let u of r.keys())clearTimeout(u),r.get(u)(new L);r.clear(),c.splice(0,c.length)},l.isEnabled=!0,l}}var ne=I(ee(),1),Te=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),$=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},_e=(n,e,t)=>{let r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},ve=n=>Te.has(n),te=n=>globalThis.DOMException===void 0?new Error(n):new DOMException(n);async function B(n,e){return new Promise((t,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=ne.default.operation(e);o.attempt(async i=>{try{t(await n(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof $)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!ve(s.message))o.stop(),r(s);else{_e(s,i,e);try{await e.onFailedAttempt(s)}catch(c){r(c);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?te("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:te(i))},{once:!0})})}function M({throttle:n={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=n?N(n):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>B(s,e)}return i()}}var C=async n=>await n();async function be({composition:n,enhancers:e,context:t,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
1
+ "use strict";var Y=Object.create;var A=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var w=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ne=(r,e)=>{for(var t in e)A(r,t,{get:e[t],enumerable:!0})},U=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of X(e))!te.call(r,o)&&o!==t&&A(r,o,{get:()=>e[o],enumerable:!(n=Q(e,o))||n.enumerable});return r};var re=(r,e,t)=>(t=r!=null?Y(ee(r)):{},U(e||!r||!r.__esModule?A(t,"default",{value:r,enumerable:!0}):t,r)),oe=r=>U(A({},"__esModule",{value:!0}),r);var F=w((Ve,j)=>{function u(r,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(r)),this._timeouts=r,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}j.exports=u;u.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};u.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};u.prototype.retry=function(r){if(this._timeout&&clearTimeout(this._timeout),!r)return!1;var e=new Date().getTime();if(r&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(r),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(r);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},t),this._options.unref&&this._timer.unref(),!0};u.prototype.attempt=function(r,e){this._fn=r,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};u.prototype.try=function(r){console.log("Using RetryOperation.try() is deprecated"),this.attempt(r)};u.prototype.start=function(r){console.log("Using RetryOperation.start() is deprecated"),this.attempt(r)};u.prototype.start=u.prototype.try;u.prototype.errors=function(){return this._errors};u.prototype.attempts=function(){return this._attempts};u.prototype.mainError=function(){if(this._errors.length===0)return null;for(var r={},e=null,t=0,n=0;n<this._errors.length;n++){var o=this._errors[n],i=o.message,s=(r[i]||0)+1;r[i]=s,s>=t&&(e=o,t=s)}return e}});var G=w(d=>{var se=F();d.operation=function(r){var e=d.timeouts(r);return new se(e,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})};d.timeouts=function(r){if(r instanceof Array)return[].concat(r);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in r)e[t]=r[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],o=0;o<e.retries;o++)n.push(this.createTimeout(o,e));return r&&r.forever&&!n.length&&n.push(this.createTimeout(o,e)),n.sort(function(i,s){return i-s}),n};d.createTimeout=function(r,e){var t=e.randomize?Math.random()+1:1,n=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,r));return n=Math.min(n,e.maxTimeout),n};d.wrap=function(r,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var n in r)typeof r[n]=="function"&&t.push(n)}for(var o=0;o<t.length;o++){var i=t[o],s=r[i];r[i]=function(c){var m=d.operation(e),p=Array.prototype.slice.call(arguments,1),l=p.pop();p.push(function(h){m.retry(h)||(h&&(arguments[0]=m.mainError()),l.apply(this,arguments))}),m.attempt(function(){c.apply(r,p)})}.bind(r,s),r[i].options=e}}});var H=w((Be,z)=>{z.exports=G()});var Re={};ne(Re,{BatchEntry:()=>v,CANVAS_DRAFT_STATE:()=>Xe,CANVAS_ENRICHMENT_TAG_PARAM:()=>ge,CANVAS_INTENT_TAG_PARAM:()=>Ce,CANVAS_LOCALE_TAG_PARAM:()=>M,CANVAS_LOCALIZATION_SLOT:()=>V,CANVAS_LOCALIZATION_TYPE:()=>k,CANVAS_PERSONALIZATION_PARAM:()=>$,CANVAS_PERSONALIZE_SLOT:()=>Ee,CANVAS_PERSONALIZE_TYPE:()=>de,CANVAS_PUBLISHED_STATE:()=>et,CANVAS_TEST_SLOT:()=>Te,CANVAS_TEST_TYPE:()=>ye,CANVAS_TEST_VARIANT_PARAM:()=>B,CanvasClient:()=>E,CanvasClientError:()=>C,ChildEnhancerBuilder:()=>P,EnhancerBuilder:()=>b,UncachedCanvasClient:()=>L,UniqueBatchEntries:()=>x,compose:()=>he,createBatchEnhancer:()=>ie,createEventBus:()=>we,createLimitPolicy:()=>N,enhance:()=>me,extractLocales:()=>J,getChannelName:()=>D,getComponentPath:()=>_,isSystemComponentDefinition:()=>Pe,localize:()=>be,mapSlotToPersonalizedVariations:()=>Ae,mapSlotToTestVariations:()=>_e,nullLimitPolicy:()=>f,subscribeToComposition:()=>xe,walkComponentTree:()=>g});module.exports=oe(Re);function g(r,e){let t=[{ancestorsAndSelf:[{component:r,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let n=t.pop();if(!n)continue;let o=n.ancestorsAndSelf[0],i=!0;e(o.component,n.ancestorsAndSelf,{replaceComponent:a=>{Object.assign(o.component,a),["parameters","variant","slots","data","_pattern","_patternError"].forEach(m=>{a[m]||delete o.component[m]})},removeComponent:()=>{let{parentSlot:a,parentSlotIndex:c}=n.ancestorsAndSelf[0],m=n.ancestorsAndSelf[1];if(a&&typeof c!="undefined")m.component.slots[a].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:a=>{let c=Array.isArray(a)?a:[a],{parentSlot:m,parentSlotIndex:p}=n.ancestorsAndSelf[0],l=n.ancestorsAndSelf[1];if(m&&typeof p!="undefined")l.component.slots[m].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let a=Object.keys(s);for(let c=a.length-1;c>=0;c--){let m=a[c],p=s[m];for(let l=p.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:p[l],parentSlot:m,parentSlotIndex:l},...n.ancestorsAndSelf]})}}}while(t.length>0)}function _(r){let e=[];for(let t=r.length-1;t>=0;t--){let{parentSlot:n,parentSlotIndex:o}=r[t];n&&o!==void 0&&e.push(`${n}[${o}]`)}return`.${e.join(".")}`}var x=class{constructor(e,t){this.groups=e.reduce((n,o)=>{var s;let i=t(o.args);return n[i]=(s=n[i])!=null?s:[],n[i].push(o),n},{})}resolveKey(e,t){this.groups[e].forEach(n=>n.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(n=>{n.isCompleted||n.resolve(e)})})}};var P=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var n;return(n=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:n.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},b=class{constructor(){this._componentIndex={};this._rootBuilder=new P}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>{this._componentIndex[o]=this._componentIndex[o]||new P,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,n){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,n);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,n)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),n=this._componentIndex[e.type];if(n){t=new Map(t);for(let[o,i]of n.resolveComponentEnhancers())t.set(o,i)}return t}};var v=class{constructor(e,t,n){this._resolve=e;this._reject=t;this.args=n;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function ie({handleBatch:r,shouldQueue:e,limitPolicy:t}){let n=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((a,c)=>{n.push(new v(a,c,s))})},completeAll:async()=>{if(n.length>0){try{await r(n)}catch(a){n.forEach(c=>c.reject(a))}if(n.some(a=>!a.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=n.length;return n=[],s},limitPolicy:t}}var R=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function I({limit:r,interval:e,strict:t}){if(!Number.isFinite(r))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let n=new Map,o=0,i=0;function s(){let p=Date.now();return p-o>e?(i=1,o=p,0):(i<r?i++:(o+=e,i=1),o-p)}let a=[];function c(){let p=Date.now();if(a.length<r)return a.push(p),0;let l=a.shift()+e;return p>=l?(a.push(p),0):(a.push(l),l-p)}let m=t?c:s;return p=>{let l=function(...h){if(!l.isEnabled)return(async()=>p.apply(this,h))();let y;return new Promise((T,W)=>{y=setTimeout(()=>{T(p.apply(this,h)),n.delete(y)},m()),n.set(y,W)})};return l.abort=()=>{for(let h of n.keys())clearTimeout(h),n.get(h)(new R);n.clear(),a.splice(0,a.length)},l.isEnabled=!0,l}}var Z=re(H(),1),ae=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),S=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},ce=(r,e,t)=>{let n=t.retries-(e-1);return r.attemptNumber=e,r.retriesLeft=n,r},pe=r=>ae.has(r),K=r=>globalThis.DOMException===void 0?new Error(r):new DOMException(r);async function O(r,e){return new Promise((t,n)=>{e={onFailedAttempt(){},retries:10,...e};let o=Z.default.operation(e);o.attempt(async i=>{try{t(await r(i))}catch(s){if(!(s instanceof Error)){n(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof S)o.stop(),n(s.originalError);else if(s instanceof TypeError&&!pe(s.message))o.stop(),n(s);else{ce(s,i,e);try{await e.onFailedAttempt(s)}catch(a){n(a);return}o.retry(s)||n(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?K("The operation was aborted."):e.signal.reason;n(i instanceof Error?i:K(i))},{once:!0})})}function N({throttle:r={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=r?I(r):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>O(s,e)}return i()}}var f=async r=>await r();async function me({composition:r,enhancers:e,context:t,onErrors:n=o=>{throw new Error(o.map(i=>`${i.message}
2
2
  ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
3
 
4
- `))}}){let o=[],i=new Set,s=new Set;P(n,(a,p)=>{var l;Object.entries((l=a.parameters)!=null?l:{}).forEach(([u,d])=>{let f=e.resolveParameterEnhancer(a,u,d);f&&(s.add(f),o.push(xe(a,p,u,d,f,t)))});let m=e.resolveComponentEnhancers(a);o.push(we(a,p,m,t)),i.add(m)}),o.push(...Array.from(i).flatMap(a=>Array.from(a).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:C)(()=>p.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async a=>{var p;try{a.completeAll&&await((p=a.limitPolicy)!=null?p:C)(()=>a.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(o)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);c.length&&r(c)}async function we(n,e,t,r){return t.size&&(n.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let a=await(i.completeAll?C:(s=i.limitPolicy)!=null?s:C)(async()=>i.enhanceOne({component:n,context:r}));a!=null&&(n.data[o]=a)}catch(c){let a=`Component ${g(e)} (type: ${n.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete n.data[o],{message:a,error:c}}}))}async function xe(n,e,t,r,o,i){var s;try{let a=await(o.completeAll?C:(s=o.limitPolicy)!=null?s:C)(async()=>o.enhanceOne({parameter:r,parameterName:t,component:n,context:i}));a===null?delete n.parameters[t]:typeof a=="undefined"?n.parameters[t]={...r,value:r.value}:n.parameters[t]={...r,value:a}}catch(c){let a=`Component ${g(e)} (type: ${n.type}): enhancing parameter ${t} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete n.parameters[t],{message:a,error:c}}}var Re=(n,...e)=>({enhanceOne:r=>{let o="enhanceOne"in n?n.enhanceOne(r):n(r);for(let i of e){let s=Ie(o)?o:Promise.resolve(o),c="enhanceOne"in i?i.enhanceOne:i;o=s.then(a=>c({...r,parameter:{type:r.parameter.type,value:a}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in n?(r=n.completeAll)==null?void 0:r.call(n):0)!=null?o:0}});function Ie(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var T=class extends Error{constructor(t,r,o,i,s,c){super(`${t}
5
- ${i}${s?" "+s:""} (${r} ${o}${c?` Request ID: ${c}`:""})`);this.errorMessage=t;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=c;Object.setPrototypeOf(this,T.prototype)}},_=class{constructor(e){var r,o,i,s,c,a;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(c=e.limitPolicy)!=null?c:M({}),bypassCache:(a=e.bypassCache)!=null?a:!1}}async getCompositionList(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionById(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(r)}async updateComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...t,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...t==null?void 0:t.headers,...r}});if(!o.ok){let s="";try{let c=await o.text();try{let a=JSON.parse(c);a.errorMessage?s=Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage:s=c}catch(a){s=c}}catch(c){s="General error"}throw new T(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,_.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},V=class extends _{constructor(e){super({...e,bypassCache:!0})}};var Oe="$personalization",Se="$test",k="$localization",Le="intentTag",j="locale",Ne="pz",$e="test",U="localized",yt=0,Ct=64,D="$pzCrit",F="$tstVrnt",Be="$enr",G="$loop",z="$loopResource",H="$loopBinding",J="body";var Me=n=>n.startsWith("$");function Ve(n){return n?n.map((e,t)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[D])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:r}}):[]}function ke(n){return n?n.map((e,t)=>{var i,s,c;let r=(s=(i=e.parameters)==null?void 0:i[F])==null?void 0:s.value,o=(c=r==null?void 0:r.id)!=null?c:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var re="https://js.pusher.com/7.0.3/pusher.min.js";async function je(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((n,e)=>{let t=setTimeout(()=>{window.Pusher&&n(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${re}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=re,r.addEventListener("load",()=>{clearTimeout(t),n(window.Pusher)}),document.head.appendChild(r)})}async function Ue(){let n=await je();if(!n)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new n("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=t.subscribe(r);return{unsubscribe:()=>t.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function K(n,e,t){return`${n}.${e}@${t}`}function De({projectId:n,compositionId:e,compositionState:t=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=K(n,e,t),c=r(s),a=c.addEventHandler(i,o);return()=>{a(),c.unsubscribe()}}function oe({component:n}){var r;let e={},t=(r=n.slots)==null?void 0:r[U];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[j];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function Fe({composition:n,locale:e}){P(n,(t,r,o)=>{if(t.type===k){let i=oe({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),c;if(s&&(c=i[s]),c!=null&&c.length){let[a,...p]=c;o.replaceComponent(a),p.length&&o.insertAfter(p)}else o.removeComponent()}})}var se=I(require("json-pointer")),{get:Ge,set:ze}=se.default;function ae(n,e){if(typeof n.pointer=="string")return ie(e,n.pointer);let t={};return Object.entries(n.pointer).forEach(([r,o])=>{ze(t,r,ie(e,o))}),t}function ie(n,e){try{return Ge(n,e)}catch(t){throw new Error(`Unable to resolve resource pointer '${e}': ${t.message}
6
-
7
- Resources:
8
- ${JSON.stringify(n,null,2)}`)}}function Y(n,e){if(!(n!=null&&n.binding))return{bound:!1};switch(n.binding.syntax){case"jptr":return{bound:!0,value:ae(n.binding,e)};default:throw new Error(`Unsupported binding syntax '${n.binding.syntax}'`)}}var ce=I(require("rfdc"));var He=(0,ce.default)();function pe(n,e,t){let{throwErrors:r=!0,expandLoops:o=!0,preserveBindings:i=!1}=t||{},s=He(n),c=!1,a=[];if(P(s,(p,m,l)=>{var u,d;if(!!p.parameters&&(Object.entries(p.parameters).forEach(([f,y])=>{try{let E=Y(y,e);E.bound&&(c=!0,y.value=E.value,i||delete y.binding)}catch(E){a.push(new Error(`Failed to bind parameter ${f} in component ${g(m)}: ${E.message}`)),delete p.parameters[f]}}),p.type===G&&(l.stopProcessingDescendants(),o))){let f=(d=(u=p.slots)==null?void 0:u[J])!=null?d:[],y=p.parameters[H].value;if(!Array.isArray(y)){a.push(new Error(`Failed to bind loop component ${g(m)}: loop is not bound to an array of data`));return}let E={...t,throwErrors:!1};y.reverse().forEach(me=>{let le={...e,[p.parameters[z].value]:me};f.forEach(ue=>{let x=pe(ue,le,E);x.errors.length>0?a.push(...x.errors):l.insertAfter(x.result)})}),l.removeComponent()}}),r&&a.length>0)throw new Error(`${a.length} error${a.length!==1?"s":""} occurred while binding parameters to resources.
9
-
10
- ${a.map(p=>p.message).join(`
11
- `)}`);return{hasBindings:c,errors:a,result:s}}0&&(module.exports={BatchEntry,CANVAS_DRAFT_STATE,CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_INTENT_TAG_PARAM,CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE,CANVAS_LOOP_PARAMETER,CANVAS_LOOP_RESOURCE_PARAMETER,CANVAS_LOOP_SLOT,CANVAS_LOOP_TYPE,CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE,CANVAS_TEST_SLOT,CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM,CanvasClient,CanvasClientError,ChildEnhancerBuilder,EnhancerBuilder,UncachedCanvasClient,UniqueBatchEntries,bindParameter,bindParameters,compose,createBatchEnhancer,createEventBus,createLimitPolicy,enhance,extractLocales,getChannelName,getComponentPath,isSystemComponentDefinition,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
4
+ `))}}){let o=[],i=new Set,s=new Set;g(r,(c,m)=>{var l;Object.entries((l=c.parameters)!=null?l:{}).forEach(([h,y])=>{let T=e.resolveParameterEnhancer(c,h,y);T&&(s.add(T),o.push(ue(c,m,h,y,T,t)))});let p=e.resolveComponentEnhancers(c);o.push(le(c,m,p,t)),i.add(p)}),o.push(...Array.from(i).flatMap(c=>Array.from(c).map(async([,m])=>{var p;try{m.completeAll&&await((p=m.limitPolicy)!=null?p:f)(()=>m.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async c=>{var m;try{c.completeAll&&await((m=c.limitPolicy)!=null?m:f)(()=>c.completeAll())}catch(p){return{error:p,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(o)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&n(a)}async function le(r,e,t,n){return t.size&&(r.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let c=await(i.completeAll?f:(s=i.limitPolicy)!=null?s:f)(async()=>i.enhanceOne({component:r,context:n}));c!=null&&(r.data[o]=c)}catch(a){let c=`Component ${_(e)} (type: ${r.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete r.data[o],{message:c,error:a}}}))}async function ue(r,e,t,n,o,i){var s;try{let c=await(o.completeAll?f:(s=o.limitPolicy)!=null?s:f)(async()=>o.enhanceOne({parameter:n,parameterName:t,component:r,context:i}));c===null?delete r.parameters[t]:typeof c=="undefined"?r.parameters[t]={...n,value:n.value}:r.parameters[t]={...n,value:c}}catch(a){let c=`Component ${_(e)} (type: ${r.type}): enhancing parameter ${t} (type: ${n.type}) threw exception. Parameter will be removed.`;return delete r.parameters[t],{message:c,error:a}}}var he=(r,...e)=>({enhanceOne:n=>{let o="enhanceOne"in r?r.enhanceOne(n):r(n);for(let i of e){let s=fe(o)?o:Promise.resolve(o),a="enhanceOne"in i?i.enhanceOne:i;o=s.then(c=>a({...n,parameter:{type:n.parameter.type,value:c}}))}return o},completeAll:async()=>{var n,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in r?(n=r.completeAll)==null?void 0:n.call(r):0)!=null?o:0}});function fe(r){return!!r&&(typeof r=="object"||typeof r=="function")&&typeof r.then=="function"}var C=class extends Error{constructor(t,n,o,i,s,a){super(`${t}
5
+ ${i}${s?" "+s:""} (${n} ${o}${a?` Request ID: ${a}`:""})`);this.errorMessage=t;this.fetchMethod=n;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=a;Object.setPrototypeOf(this,C.prototype)}},E=class{constructor(e){var n,o,i,s,a,c;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(n=e.apiHost)!=null?n:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(a=e.limitPolicy)!=null?a:N({}),bypassCache:(c=e.bypassCache)!=null?c:!1}}async getCompositionList(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async getCompositionBySlug(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async getCompositionById(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:n}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:n}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(n)}async updateComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let n=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...t,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...t==null?void 0:t.headers,...n}});if(!o.ok){let s="";try{let a=await o.text();try{let c=JSON.parse(a);c.errorMessage?s=Array.isArray(c.errorMessage)?c.errorMessage.join(", "):c.errorMessage:s=a}catch(c){s=a}}catch(a){s="General error"}throw new C(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,E.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let n=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&n.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),n}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},L=class extends E{constructor(e){super({...e,bypassCache:!0})}};var de="$personalization",ye="$test",k="$localization",Ce="intentTag",M="locale",Ee="pz",Te="test",V="localized",Xe=0,et=64,$="$pzCrit",B="$tstVrnt",ge="$enr";var Pe=r=>r.startsWith("$");function Ae(r){return r?r.map((e,t)=>{var i,s;let n=(s=(i=e.parameters)==null?void 0:i[$])==null?void 0:s.value,o=(n==null?void 0:n.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:n}}):[]}function _e(r){return r?r.map((e,t)=>{var i,s,a;let n=(s=(i=e.parameters)==null?void 0:i[B])==null?void 0:s.value,o=(a=n==null?void 0:n.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var q="https://js.pusher.com/7.0.3/pusher.min.js";async function ve(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((r,e)=>{let t=setTimeout(()=>{window.Pusher&&r(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${q}"><\/script> manually.`)},5e3),n=document.createElement("script");n.src=q,n.addEventListener("load",()=>{clearTimeout(t),r(window.Pusher)}),document.head.appendChild(n)})}async function we(){let r=await ve();if(!r)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new r("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:n=>{let o=t.subscribe(n);return{unsubscribe:()=>t.unsubscribe(n),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function D(r,e,t){return`${r}.${e}@${t}`}function xe({projectId:r,compositionId:e,compositionState:t=0,eventBus:{subscribe:n},callback:o,event:i="updated"}){let s=D(r,e,t),a=n(s),c=a.addEventHandler(i,o);return()=>{c(),a.unsubscribe()}}function J({component:r}){var n;let e={},t=(n=r.slots)==null?void 0:n[V];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[M];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function be({composition:r,locale:e}){g(r,(t,n,o)=>{if(t.type===k){let i=J({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),a;if(s&&(a=i[s]),a!=null&&a.length){let[c,...m]=a;o.replaceComponent(c),m.length&&o.insertAfter(m)}else o.removeComponent()}})}0&&(module.exports={BatchEntry,CANVAS_DRAFT_STATE,CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_INTENT_TAG_PARAM,CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE,CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE,CANVAS_TEST_SLOT,CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM,CanvasClient,CanvasClientError,ChildEnhancerBuilder,EnhancerBuilder,UncachedCanvasClient,UniqueBatchEntries,compose,createBatchEnhancer,createEventBus,createLimitPolicy,enhance,extractLocales,getChannelName,getComponentPath,isSystemComponentDefinition,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-6OEWBKP7.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,D as CANVAS_LOOP_PARAMETER,C as CANVAS_LOOP_RESOURCE_PARAMETER,E as CANVAS_LOOP_SLOT,B as CANVAS_LOOP_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,N as bindParameter,O as bindParameters,k as compose,g as createBatchEnhancer,I as createEventBus,h as createLimitPolicy,j as enhance,L as extractLocales,J as getChannelName,b as getComponentPath,F as isSystemComponentDefinition,M as localize,G as mapSlotToPersonalizedVariations,H as mapSlotToTestVariations,i as nullLimitPolicy,K as subscribeToComposition,a as walkComponentTree};
1
+ import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-2C4YYM6A.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,E as createEventBus,h as createLimitPolicy,j as enhance,H as extractLocales,F as getChannelName,b as getComponentPath,B as isSystemComponentDefinition,I as localize,C as mapSlotToPersonalizedVariations,D as mapSlotToTestVariations,i as nullLimitPolicy,G as subscribeToComposition,a as walkComponentTree};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "16.2.1-nuxt.252+5c8ef696a",
3
+ "version": "16.2.1-nuxt.274+0a8a48855",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -47,10 +47,9 @@
47
47
  "update-openapi": "tsx ./scripts/update-openapi.cts"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/json-pointer": "^1.0.31",
51
50
  "@types/retry": "0.12.1",
52
51
  "@types/yargs": "17.0.10",
53
- "@uniformdev/cli": "^16.2.1-nuxt.252+5c8ef696a",
52
+ "@uniformdev/cli": "^16.2.1-nuxt.274+0a8a48855",
54
53
  "p-limit": "4.0.0",
55
54
  "p-retry": "5.1.1",
56
55
  "p-throttle": "5.0.0",
@@ -58,9 +57,7 @@
58
57
  "yargs": "17.5.1"
59
58
  },
60
59
  "dependencies": {
61
- "@uniformdev/context": "^16.2.1-nuxt.252+5c8ef696a",
62
- "json-pointer": "^0.6.2",
63
- "rfdc": "^1.3.0"
60
+ "@uniformdev/context": "^16.2.1-nuxt.274+0a8a48855"
64
61
  },
65
62
  "files": [
66
63
  "/dist"
@@ -68,5 +65,5 @@
68
65
  "publishConfig": {
69
66
  "access": "public"
70
67
  },
71
- "gitHead": "5c8ef696a903f69c8f4c369bd117611b9073d55d"
68
+ "gitHead": "0a8a48855ef532336761a3872c3d515ab6b9113e"
72
69
  }
@@ -1,11 +0,0 @@
1
- var pe=Object.create;var T=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var fe=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ne=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var $e=(t,e)=>()=>(t&&(e=t(t=0)),e);var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Be=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of le(e))!he.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=me(e,o))||r.enumerable});return t};var de=(t,e,n)=>(n=t!=null?pe(ue(t)):{},N(e||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t)),Me=t=>N(T({},"__esModule",{value:!0}),t);var Ve=(t,e,n)=>(fe(t,typeof e!="symbol"?e+"":e,n),n),$=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var ye=(t,e,n)=>($(t,e,"read from private field"),n?n.call(t):e.get(t)),ke=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},Ce=(t,e,n,r)=>($(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),je=(t,e,n,r)=>({set _(o){Ce(t,e,o,n)},get _(){return ye(t,e,r)}});var k=x((Ke,V)=>{function h(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}V.exports=h;h.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};h.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};h.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0};h.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};h.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};h.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};h.prototype.start=h.prototype.try;h.prototype.errors=function(){return this._errors};h.prototype.attempts=function(){return this._attempts};h.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(t[i]||0)+1;t[i]=s,s>=n&&(e=o,n=s)}return e}});var j=x(E=>{var Ee=k();E.operation=function(t){var e=E.timeouts(t);return new Ee(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};E.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return t&&t.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};E.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,r=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return r=Math.min(r,e.maxTimeout),r};E.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var r in t)typeof t[r]=="function"&&n.push(r)}for(var o=0;o<n.length;o++){var i=n[o],s=t[i];t[i]=function(a){var p=E.operation(e),m=Array.prototype.slice.call(arguments,1),l=m.pop();m.push(function(u){p.retry(u)||(u&&(arguments[0]=p.mainError()),l.apply(this,arguments))}),p.attempt(function(){a.apply(t,m)})}.bind(t,s),t[i].options=e}}});var D=x((Ze,U)=>{U.exports=j()});function g(t,e){let n=[{ancestorsAndSelf:[{component:t,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=n.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(o.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(p=>{c[p]||delete o.component[p]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:a}=r.ancestorsAndSelf[0],p=r.ancestorsAndSelf[1];if(c&&typeof a!="undefined")p.component.slots[c].splice(a,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let a=Array.isArray(c)?c:[c],{parentSlot:p,parentSlotIndex:m}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(p&&typeof m!="undefined")l.component.slots[p].splice(m+1,0,...a);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let c=Object.keys(s);for(let a=c.length-1;a>=0;a--){let p=c[a],m=s[p];for(let l=m.length-1;l>=0;l--)n.push({ancestorsAndSelf:[{component:m[l],parentSlot:p,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(n.length>0)}function A(t){let e=[];for(let n=t.length-1;n>=0;n--){let{parentSlot:r,parentSlotIndex:o}=t[n];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var B=class{constructor(e,n){this.groups=e.reduce((r,o)=>{var s;let i=n(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,n){this.groups[e].forEach(r=>r.resolve(n))}resolveRemaining(e){Object.keys(this.groups).forEach(n=>{this.groups[n].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var b=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(n)})),this}parameterType(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,enhancer:this._resolveParameterEnhancer(n)})),this}data(e,n){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof n=="function"?{enhanceOne:n}:n),this}resolveParameterEnhancer(e,n){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===n.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},M=class{constructor(){this._componentIndex={};this._rootBuilder=new b}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,n){return this._rootBuilder.parameterName(e,n),this}parameterType(e,n){return this._rootBuilder.parameterType(e,n),this}data(e,n){return this._rootBuilder.data(e,n),this}component(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>{this._componentIndex[o]=this._componentIndex[o]||new b,n(this._componentIndex[o])}),this}resolveParameterEnhancer(e,n,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(n,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(n,r)}resolveComponentEnhancers(e){let n=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){n=new Map(n);for(let[o,i]of r.resolveComponentEnhancers())n.set(o,i)}return n}};var R=class{constructor(e,n,r){this._resolve=e;this._reject=n;this.args=r;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function ze({handleBatch:t,shouldQueue:e,limitPolicy:n}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{r.push(new R(c,a,s))})},completeAll:async()=>{if(r.length>0){try{await t(r)}catch(c){r.forEach(a=>a.reject(c))}if(r.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:n}}var I=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function O({limit:t,interval:e,strict:n}){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let m=Date.now();return m-o>e?(i=1,o=m,0):(i<t?i++:(o+=e,i=1),o-m)}let c=[];function a(){let m=Date.now();if(c.length<t)return c.push(m),0;let l=c.shift()+e;return m>=l?(c.push(m),0):(c.push(l),l-m)}let p=n?a:s;return m=>{let l=function(...u){if(!l.isEnabled)return(async()=>m.apply(this,u))();let d;return new Promise((f,y)=>{d=setTimeout(()=>{f(m.apply(this,u)),r.delete(d)},p()),r.set(d,y)})};return l.abort=()=>{for(let u of r.keys())clearTimeout(u),r.get(u)(new I);r.clear(),c.splice(0,c.length)},l.isEnabled=!0,l}}var G=de(D(),1),Pe=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),S=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},ge=(t,e,n)=>{let r=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=r,t},Ae=t=>Pe.has(t),F=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function L(t,e){return new Promise((n,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=G.default.operation(e);o.attempt(async i=>{try{n(await t(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof S)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!Ae(s.message))o.stop(),r(s);else{ge(s,i,e);try{await e.onFailedAttempt(s)}catch(c){r(c);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?F("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:F(i))},{once:!0})})}function z({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?O(t):null;return function(o){let i=async()=>await o();if(n&&(i=n(i)),e){let s=i;i=()=>L(s,e)}return i()}}var P=async t=>await t();async function it({composition:t,enhancers:e,context:n,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
2
- ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
-
4
- `))}}){let o=[],i=new Set,s=new Set;g(t,(a,p)=>{var l;Object.entries((l=a.parameters)!=null?l:{}).forEach(([u,d])=>{let f=e.resolveParameterEnhancer(a,u,d);f&&(s.add(f),o.push(_e(a,p,u,d,f,n)))});let m=e.resolveComponentEnhancers(a);o.push(Te(a,p,m,n)),i.add(m)}),o.push(...Array.from(i).flatMap(a=>Array.from(a).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:P)(()=>p.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async a=>{var p;try{a.completeAll&&await((p=a.limitPolicy)!=null?p:P)(()=>a.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(o)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);c.length&&r(c)}async function Te(t,e,n,r){return n.size&&(t.data={}),await Promise.all(Array.from(n).map(async([o,i])=>{var s;try{let a=await(i.completeAll?P:(s=i.limitPolicy)!=null?s:P)(async()=>i.enhanceOne({component:t,context:r}));a!=null&&(t.data[o]=a)}catch(c){let a=`Component ${A(e)} (type: ${t.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete t.data[o],{message:a,error:c}}}))}async function _e(t,e,n,r,o,i){var s;try{let a=await(o.completeAll?P:(s=o.limitPolicy)!=null?s:P)(async()=>o.enhanceOne({parameter:r,parameterName:n,component:t,context:i}));a===null?delete t.parameters[n]:typeof a=="undefined"?t.parameters[n]={...r,value:r.value}:t.parameters[n]={...r,value:a}}catch(c){let a=`Component ${A(e)} (type: ${t.type}): enhancing parameter ${n} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete t.parameters[n],{message:a,error:c}}}var at=(t,...e)=>({enhanceOne:r=>{let o="enhanceOne"in t?t.enhanceOne(r):t(r);for(let i of e){let s=ve(o)?o:Promise.resolve(o),c="enhanceOne"in i?i.enhanceOne:i;o=s.then(a=>c({...r,parameter:{type:r.parameter.type,value:a}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in t?(r=t.completeAll)==null?void 0:r.call(t):0)!=null?o:0}});function ve(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var _=class extends Error{constructor(n,r,o,i,s,c){super(`${n}
5
- ${i}${s?" "+s:""} (${r} ${o}${c?` Request ID: ${c}`:""})`);this.errorMessage=n;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=c;Object.setPrototypeOf(this,_.prototype)}},v=class{constructor(e){var r,o,i,s,c,a;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let n=e.fetch;if(!n)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")n=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")n=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:n,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(c=e.limitPolicy)!=null?c:z({}),bypassCache:(a=e.bypassCache)!=null?a:!1}}async getCompositionList(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async getCompositionById(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async updateComposition(e){let n=this.createUrl("/api/v1/canvas");await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let n=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:n});return await this.apiClient(r)}async updateComponentDefinition(e){let n=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let n=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,n){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...n,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...n==null?void 0:n.headers,...r}});if(!o.ok){let s="";try{let c=await o.text();try{let a=JSON.parse(c);a.errorMessage?s=Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage:s=c}catch(a){s=c}}catch(c){s="General error"}throw new _(s,(i=n==null?void 0:n.method)!=null?i:"GET",e.toString(),o.status,o.statusText,v.getRequestId(o))}return n!=null&&n.expectNoContent?null:await o.json()})}createUrl(e,n){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(n!=null?n:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let n=e.headers.get("apigw-requestid");if(n)return n}},H=class extends v{constructor(e){super({...e,bypassCache:!0})}};var ut="$personalization",ht="$test",J="$localization",ft="intentTag",K="locale",dt="pz",yt="test",Y="localized",Ct=0,Et=64,Z="$pzCrit",q="$tstVrnt",Pt="$enr",W="$loop",Q="$loopResource",X="$loopBinding",ee="body";var At=t=>t.startsWith("$");function vt(t){return t?t.map((e,n)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[Z])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${n}-${e.type}`;return{...e,id:o,pz:r}}):[]}function xt(t){return t?t.map((e,n)=>{var i,s,c;let r=(s=(i=e.parameters)==null?void 0:i[q])==null?void 0:s.value,o=(c=r==null?void 0:r.id)!=null?c:"testId"in e?e.testId:`ab-${n}-${e.type}`;return{...e,id:o}}):[]}var te="https://js.pusher.com/7.0.3/pusher.min.js";async function be(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((t,e)=>{let n=setTimeout(()=>{window.Pusher&&t(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${te}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=te,r.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(r)})}async function It(){let t=await be();if(!t)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let n=new t("7b5f5abd160fea549ffe",{cluster:"mt1"});n.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=n.subscribe(r);return{unsubscribe:()=>n.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function ne(t,e,n){return`${t}.${e}@${n}`}function Nt({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=ne(t,e,n),c=r(s),a=c.addEventHandler(i,o);return()=>{a(),c.unsubscribe()}}function we({component:t}){var r;let e={},n=(r=t.slots)==null?void 0:r[Y];return n==null||n.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[K];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function Vt({composition:t,locale:e}){g(t,(n,r,o)=>{if(n.type===J){let i=we({component:n}),s=typeof e=="string"?e:e({component:n,locales:i}),c;if(s&&(c=i[s]),c!=null&&c.length){let[a,...p]=c;o.replaceComponent(a),p.length&&o.insertAfter(p)}else o.removeComponent()}})}import xe from"json-pointer";var{get:Re,set:Ie}=xe;function oe(t,e){if(typeof t.pointer=="string")return re(e,t.pointer);let n={};return Object.entries(t.pointer).forEach(([r,o])=>{Ie(n,r,re(e,o))}),n}function re(t,e){try{return Re(t,e)}catch(n){throw new Error(`Unable to resolve resource pointer '${e}': ${n.message}
6
-
7
- Resources:
8
- ${JSON.stringify(t,null,2)}`)}}function ie(t,e){if(!(t!=null&&t.binding))return{bound:!1};switch(t.binding.syntax){case"jptr":return{bound:!0,value:oe(t.binding,e)};default:throw new Error(`Unsupported binding syntax '${t.binding.syntax}'`)}}import Oe from"rfdc";var Se=Oe();function Le(t,e,n){let{throwErrors:r=!0,expandLoops:o=!0,preserveBindings:i=!1}=n||{},s=Se(t),c=!1,a=[];if(g(s,(p,m,l)=>{var u,d;if(!!p.parameters&&(Object.entries(p.parameters).forEach(([f,y])=>{try{let C=ie(y,e);C.bound&&(c=!0,y.value=C.value,i||delete y.binding)}catch(C){a.push(new Error(`Failed to bind parameter ${f} in component ${A(m)}: ${C.message}`)),delete p.parameters[f]}}),p.type===W&&(l.stopProcessingDescendants(),o))){let f=(d=(u=p.slots)==null?void 0:u[ee])!=null?d:[],y=p.parameters[X].value;if(!Array.isArray(y)){a.push(new Error(`Failed to bind loop component ${A(m)}: loop is not bound to an array of data`));return}let C={...n,throwErrors:!1};y.reverse().forEach(se=>{let ae={...e,[p.parameters[Q].value]:se};f.forEach(ce=>{let w=Le(ce,ae,C);w.errors.length>0?a.push(...w.errors):l.insertAfter(w.result)})}),l.removeComponent()}}),r&&a.length>0)throw new Error(`${a.length} error${a.length!==1?"s":""} occurred while binding parameters to resources.
9
-
10
- ${a.map(p=>p.message).join(`
11
- `)}`);return{hasBindings:c,errors:a,result:s}}export{Ne as a,$e as b,x as c,Be as d,de as e,Me as f,Ve as g,ye as h,ke as i,Ce as j,je as k,g as l,A as m,B as n,b as o,M as p,R as q,ze as r,z as s,P as t,it as u,at as v,_ as w,v as x,H as y,ut as z,ht as A,J as B,ft as C,K as D,dt as E,yt as F,Y as G,Ct as H,Et as I,Z as J,q as K,Pt as L,W as M,Q as N,X as O,ee as P,At as Q,vt as R,xt as S,It as T,ne as U,Nt as V,we as W,Vt as X,ie as Y,Le as Z};
@@ -1,11 +0,0 @@
1
- var pe=Object.create;var T=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var fe=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Le=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Ne=(t,e)=>()=>(t&&(e=t(t=0)),e);var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$e=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of le(e))!he.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=me(e,o))||r.enumerable});return t};var de=(t,e,n)=>(n=t!=null?pe(ue(t)):{},N(e||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t)),Be=t=>N(T({},"__esModule",{value:!0}),t);var Me=(t,e,n)=>(fe(t,typeof e!="symbol"?e+"":e,n),n),$=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var ye=(t,e,n)=>($(t,e,"read from private field"),n?n.call(t):e.get(t)),Ve=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},Ce=(t,e,n,r)=>($(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),ke=(t,e,n,r)=>({set _(o){Ce(t,e,o,n)},get _(){return ye(t,e,r)}});var k=x((Je,V)=>{function h(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}V.exports=h;h.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};h.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};h.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0};h.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};h.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};h.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};h.prototype.start=h.prototype.try;h.prototype.errors=function(){return this._errors};h.prototype.attempts=function(){return this._attempts};h.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(t[i]||0)+1;t[i]=s,s>=n&&(e=o,n=s)}return e}});var j=x(E=>{var Ee=k();E.operation=function(t){var e=E.timeouts(t);return new Ee(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};E.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return t&&t.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};E.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,r=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return r=Math.min(r,e.maxTimeout),r};E.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var r in t)typeof t[r]=="function"&&n.push(r)}for(var o=0;o<n.length;o++){var i=n[o],s=t[i];t[i]=function(a){var p=E.operation(e),m=Array.prototype.slice.call(arguments,1),l=m.pop();m.push(function(u){p.retry(u)||(u&&(arguments[0]=p.mainError()),l.apply(this,arguments))}),p.attempt(function(){a.apply(t,m)})}.bind(t,s),t[i].options=e}}});var D=x((Ye,U)=>{U.exports=j()});function g(t,e){let n=[{ancestorsAndSelf:[{component:t,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=n.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(o.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(p=>{c[p]||delete o.component[p]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:a}=r.ancestorsAndSelf[0],p=r.ancestorsAndSelf[1];if(c&&typeof a!="undefined")p.component.slots[c].splice(a,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let a=Array.isArray(c)?c:[c],{parentSlot:p,parentSlotIndex:m}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(p&&typeof m!="undefined")l.component.slots[p].splice(m+1,0,...a);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let c=Object.keys(s);for(let a=c.length-1;a>=0;a--){let p=c[a],m=s[p];for(let l=m.length-1;l>=0;l--)n.push({ancestorsAndSelf:[{component:m[l],parentSlot:p,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(n.length>0)}function A(t){let e=[];for(let n=t.length-1;n>=0;n--){let{parentSlot:r,parentSlotIndex:o}=t[n];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var B=class{constructor(e,n){this.groups=e.reduce((r,o)=>{var s;let i=n(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,n){this.groups[e].forEach(r=>r.resolve(n))}resolveRemaining(e){Object.keys(this.groups).forEach(n=>{this.groups[n].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var b=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(n)})),this}parameterType(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,enhancer:this._resolveParameterEnhancer(n)})),this}data(e,n){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof n=="function"?{enhanceOne:n}:n),this}resolveParameterEnhancer(e,n){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===n.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},M=class{constructor(){this._componentIndex={};this._rootBuilder=new b}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,n){return this._rootBuilder.parameterName(e,n),this}parameterType(e,n){return this._rootBuilder.parameterType(e,n),this}data(e,n){return this._rootBuilder.data(e,n),this}component(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>{this._componentIndex[o]=this._componentIndex[o]||new b,n(this._componentIndex[o])}),this}resolveParameterEnhancer(e,n,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(n,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(n,r)}resolveComponentEnhancers(e){let n=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){n=new Map(n);for(let[o,i]of r.resolveComponentEnhancers())n.set(o,i)}return n}};var R=class{constructor(e,n,r){this._resolve=e;this._reject=n;this.args=r;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function Ge({handleBatch:t,shouldQueue:e,limitPolicy:n}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{r.push(new R(c,a,s))})},completeAll:async()=>{if(r.length>0){try{await t(r)}catch(c){r.forEach(a=>a.reject(c))}if(r.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:n}}var I=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function O({limit:t,interval:e,strict:n}){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let m=Date.now();return m-o>e?(i=1,o=m,0):(i<t?i++:(o+=e,i=1),o-m)}let c=[];function a(){let m=Date.now();if(c.length<t)return c.push(m),0;let l=c.shift()+e;return m>=l?(c.push(m),0):(c.push(l),l-m)}let p=n?a:s;return m=>{let l=function(...u){if(!l.isEnabled)return(async()=>m.apply(this,u))();let d;return new Promise((f,y)=>{d=setTimeout(()=>{f(m.apply(this,u)),r.delete(d)},p()),r.set(d,y)})};return l.abort=()=>{for(let u of r.keys())clearTimeout(u),r.get(u)(new I);r.clear(),c.splice(0,c.length)},l.isEnabled=!0,l}}var G=de(D(),1),Pe=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),S=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},ge=(t,e,n)=>{let r=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=r,t},Ae=t=>Pe.has(t),F=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function L(t,e){return new Promise((n,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=G.default.operation(e);o.attempt(async i=>{try{n(await t(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof S)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!Ae(s.message))o.stop(),r(s);else{ge(s,i,e);try{await e.onFailedAttempt(s)}catch(c){r(c);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?F("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:F(i))},{once:!0})})}function z({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?O(t):null;return function(o){let i=async()=>await o();if(n&&(i=n(i)),e){let s=i;i=()=>L(s,e)}return i()}}var P=async t=>await t();async function ot({composition:t,enhancers:e,context:n,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
2
- ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
-
4
- `))}}){let o=[],i=new Set,s=new Set;g(t,(a,p)=>{var l;Object.entries((l=a.parameters)!=null?l:{}).forEach(([u,d])=>{let f=e.resolveParameterEnhancer(a,u,d);f&&(s.add(f),o.push(_e(a,p,u,d,f,n)))});let m=e.resolveComponentEnhancers(a);o.push(Te(a,p,m,n)),i.add(m)}),o.push(...Array.from(i).flatMap(a=>Array.from(a).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:P)(()=>p.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async a=>{var p;try{a.completeAll&&await((p=a.limitPolicy)!=null?p:P)(()=>a.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(o)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);c.length&&r(c)}async function Te(t,e,n,r){return n.size&&(t.data={}),await Promise.all(Array.from(n).map(async([o,i])=>{var s;try{let a=await(i.completeAll?P:(s=i.limitPolicy)!=null?s:P)(async()=>i.enhanceOne({component:t,context:r}));a!=null&&(t.data[o]=a)}catch(c){let a=`Component ${A(e)} (type: ${t.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete t.data[o],{message:a,error:c}}}))}async function _e(t,e,n,r,o,i){var s;try{let a=await(o.completeAll?P:(s=o.limitPolicy)!=null?s:P)(async()=>o.enhanceOne({parameter:r,parameterName:n,component:t,context:i}));a===null?delete t.parameters[n]:typeof a=="undefined"?t.parameters[n]={...r,value:r.value}:t.parameters[n]={...r,value:a}}catch(c){let a=`Component ${A(e)} (type: ${t.type}): enhancing parameter ${n} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete t.parameters[n],{message:a,error:c}}}var st=(t,...e)=>({enhanceOne:r=>{let o="enhanceOne"in t?t.enhanceOne(r):t(r);for(let i of e){let s=ve(o)?o:Promise.resolve(o),c="enhanceOne"in i?i.enhanceOne:i;o=s.then(a=>c({...r,parameter:{type:r.parameter.type,value:a}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in t?(r=t.completeAll)==null?void 0:r.call(t):0)!=null?o:0}});function ve(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var _=class extends Error{constructor(n,r,o,i,s,c){super(`${n}
5
- ${i}${s?" "+s:""} (${r} ${o}${c?` Request ID: ${c}`:""})`);this.errorMessage=n;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=c;Object.setPrototypeOf(this,_.prototype)}},v=class{constructor(e){var r,o,i,s,c,a;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let n=e.fetch;if(!n)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")n=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")n=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:n,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(c=e.limitPolicy)!=null?c:z({}),bypassCache:(a=e.bypassCache)!=null?a:!1}}async getCompositionList(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async getCompositionById(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async updateComposition(e){let n=this.createUrl("/api/v1/canvas");await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let n=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:n});return await this.apiClient(r)}async updateComponentDefinition(e){let n=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let n=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,n){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...n,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...n==null?void 0:n.headers,...r}});if(!o.ok){let s="";try{let c=await o.text();try{let a=JSON.parse(c);a.errorMessage?s=Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage:s=c}catch(a){s=c}}catch(c){s="General error"}throw new _(s,(i=n==null?void 0:n.method)!=null?i:"GET",e.toString(),o.status,o.statusText,v.getRequestId(o))}return n!=null&&n.expectNoContent?null:await o.json()})}createUrl(e,n){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(n!=null?n:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let n=e.headers.get("apigw-requestid");if(n)return n}},H=class extends v{constructor(e){super({...e,bypassCache:!0})}};var lt="$personalization",ut="$test",J="$localization",ht="intentTag",K="locale",ft="pz",dt="test",Y="localized",yt=0,Ct=64,Z="$pzCrit",q="$tstVrnt",Et="$enr",W="$loop",Q="$loopResource",X="$loopBinding",ee="body";var gt=t=>t.startsWith("$");function _t(t){return t?t.map((e,n)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[Z])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${n}-${e.type}`;return{...e,id:o,pz:r}}):[]}function wt(t){return t?t.map((e,n)=>{var i,s,c;let r=(s=(i=e.parameters)==null?void 0:i[q])==null?void 0:s.value,o=(c=r==null?void 0:r.id)!=null?c:"testId"in e?e.testId:`ab-${n}-${e.type}`;return{...e,id:o}}):[]}var te="https://js.pusher.com/7.0.3/pusher.min.js";async function be(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((t,e)=>{let n=setTimeout(()=>{window.Pusher&&t(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${te}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=te,r.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(r)})}async function Rt(){let t=await be();if(!t)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let n=new t("7b5f5abd160fea549ffe",{cluster:"mt1"});n.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=n.subscribe(r);return{unsubscribe:()=>n.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function ne(t,e,n){return`${t}.${e}@${n}`}function Lt({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=ne(t,e,n),c=r(s),a=c.addEventHandler(i,o);return()=>{a(),c.unsubscribe()}}function we({component:t}){var r;let e={},n=(r=t.slots)==null?void 0:r[Y];return n==null||n.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[K];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function Mt({composition:t,locale:e}){g(t,(n,r,o)=>{if(n.type===J){let i=we({component:n}),s=typeof e=="string"?e:e({component:n,locales:i}),c;if(s&&(c=i[s]),c!=null&&c.length){let[a,...p]=c;o.replaceComponent(a),p.length&&o.insertAfter(p)}else o.removeComponent()}})}import{get as xe,set as Re}from"json-pointer";function oe(t,e){if(typeof t.pointer=="string")return re(e,t.pointer);let n={};return Object.entries(t.pointer).forEach(([r,o])=>{Re(n,r,re(e,o))}),n}function re(t,e){try{return xe(t,e)}catch(n){throw new Error(`Unable to resolve resource pointer '${e}': ${n.message}
6
-
7
- Resources:
8
- ${JSON.stringify(t,null,2)}`)}}function ie(t,e){if(!(t!=null&&t.binding))return{bound:!1};switch(t.binding.syntax){case"jptr":return{bound:!0,value:oe(t.binding,e)};default:throw new Error(`Unsupported binding syntax '${t.binding.syntax}'`)}}import Ie from"rfdc";var Oe=Ie();function Se(t,e,n){let{throwErrors:r=!0,expandLoops:o=!0,preserveBindings:i=!1}=n||{},s=Oe(t),c=!1,a=[];if(g(s,(p,m,l)=>{var u,d;if(!!p.parameters&&(Object.entries(p.parameters).forEach(([f,y])=>{try{let C=ie(y,e);C.bound&&(c=!0,y.value=C.value,i||delete y.binding)}catch(C){a.push(new Error(`Failed to bind parameter ${f} in component ${A(m)}: ${C.message}`)),delete p.parameters[f]}}),p.type===W&&(l.stopProcessingDescendants(),o))){let f=(d=(u=p.slots)==null?void 0:u[ee])!=null?d:[],y=p.parameters[X].value;if(!Array.isArray(y)){a.push(new Error(`Failed to bind loop component ${A(m)}: loop is not bound to an array of data`));return}let C={...n,throwErrors:!1};y.reverse().forEach(se=>{let ae={...e,[p.parameters[Q].value]:se};f.forEach(ce=>{let w=Se(ce,ae,C);w.errors.length>0?a.push(...w.errors):l.insertAfter(w.result)})}),l.removeComponent()}}),r&&a.length>0)throw new Error(`${a.length} error${a.length!==1?"s":""} occurred while binding parameters to resources.
9
-
10
- ${a.map(p=>p.message).join(`
11
- `)}`);return{hasBindings:c,errors:a,result:s}}export{Le as a,Ne as b,x as c,$e as d,de as e,Be as f,Me as g,ye as h,Ve as i,Ce as j,ke as k,g as l,A as m,B as n,b as o,M as p,R as q,Ge as r,z as s,P as t,ot as u,st as v,_ as w,v as x,H as y,lt as z,ut as A,J as B,ht as C,K as D,ft as E,dt as F,Y as G,yt as H,Ct as I,Z as J,q as K,Et as L,W as M,Q as N,X as O,ee as P,gt as Q,_t as R,wt as S,Rt as T,ne as U,Lt as V,we as W,Mt as X,ie as Y,Se as Z};