@viamedici-spc/configurator-framer-bundle 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +67 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10426 -0
- package/package.json +58 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react"),Be=require("react/jsx-runtime"),po=require("framer");function Eu(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const xu=Eu(X);var Au=globalThis&&globalThis.__spreadArray||function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))},Du=function(t){return function(){return{concat:function(e,n){return function(r){return t.concat(e(r),n(r))}}}}},Ou=function(t){var e=Du(t);return function(){return{concat:e().concat,empty:function(){return t.empty}}}};function $e(t){return t}function Dr(t){return function(){return t}}var Nu=Dr(null),na=Dr(void 0),Ee=na;function ne(t,e,n,r,i,o,a,u,s){switch(arguments.length){case 1:return t;case 2:return function(){return e(t.apply(this,arguments))};case 3:return function(){return n(e(t.apply(this,arguments)))};case 4:return function(){return r(n(e(t.apply(this,arguments))))};case 5:return function(){return i(r(n(e(t.apply(this,arguments)))))};case 6:return function(){return o(i(r(n(e(t.apply(this,arguments))))))};case 7:return function(){return a(o(i(r(n(e(t.apply(this,arguments)))))))};case 8:return function(){return u(a(o(i(r(n(e(t.apply(this,arguments))))))))};case 9:return function(){return s(u(a(o(i(r(n(e(t.apply(this,arguments)))))))))}}}function c(t,e,n,r,i,o,a,u,s){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return i(r(n(e(t))));case 6:return o(i(r(n(e(t)))));case 7:return a(o(i(r(n(e(t))))));case 8:return u(a(o(i(r(n(e(t)))))));case 9:return s(u(a(o(i(r(n(e(t))))))));default:{for(var l=arguments[0],f=1;f<arguments.length;f++)l=arguments[f](l);return l}}}var we=function(t,e){var n=typeof t=="number"?function(r){return r.length>=t}:t;return function(){var r=Array.from(arguments);return n(arguments)?e.apply(this,r):function(i){return e.apply(void 0,Au([i],r,!1))}}},_u=globalThis&&globalThis.__spreadArray||function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))},Mu=function(t){return t._tag==="None"},$i=function(t){return t._tag==="Some"},Or={_tag:"None"},Nr=function(t){return{_tag:"Some",value:t}},$u=function(t){return t._tag==="Left"},_r=function(t){return{_tag:"Left",left:t}},Mr=function(t){return{_tag:"Right",right:t}},qu=function(t){return[t]},Pu=function(t){return t.length>0},Ru=function(t){return t[0]},ju=function(t){return t.slice(1)},Uu=[],ku={},Bu=Object.prototype.hasOwnProperty,Vu=function(t){return _u([t[0]],t.slice(1),!0)};function Fu(t,e){return function(n){return function(r){return t.ap(t.map(r,function(i){return function(o){return e.ap(i,o)}}),n)}}}function Gu(t){return function(e){return{concat:function(n,r){return t.ap(t.map(n,function(i){return function(o){return e.concat(i,o)}}),r)}}}}function ra(t,e,n){return function(r){for(var i=Array(n.length+1),o=0;o<n.length;o++)i[o]=n[o];return i[n.length]=r,e===0?t.apply(null,i):ra(t,e-1,i)}}function Lu(t){var e=t.length;switch(e){case 1:return function(n){var r;return r={},r[t[0]]=n,r};case 2:return function(n){return function(r){var i;return i={},i[t[0]]=n,i[t[1]]=r,i}};case 3:return function(n){return function(r){return function(i){var o;return o={},o[t[0]]=n,o[t[1]]=r,o[t[2]]=i,o}}};case 4:return function(n){return function(r){return function(i){return function(o){var a;return a={},a[t[0]]=n,a[t[1]]=r,a[t[2]]=i,a[t[3]]=o,a}}}};case 5:return function(n){return function(r){return function(i){return function(o){return function(a){var u;return u={},u[t[0]]=n,u[t[1]]=r,u[t[2]]=i,u[t[3]]=o,u[t[4]]=a,u}}}}};default:return ra(function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];for(var i={},o=0;o<e;o++)i[t[o]]=n[o];return i},e-1,[])}}function zu(t){return function(e){for(var n=Object.keys(e),r=n.length,i=Lu(n),o=t.map(e[n[0]],i),a=1;a<r;a++)o=t.ap(o,e[n[a]]);return o}}function Hu(t,e){return function(n){return function(r){return t.map(r,function(i){return e.map(i,n)})}}}function Wu(t){var e=Gu(t);return function(n){return{concat:e(n).concat,empty:t.of(n.empty)}}}function Ku(t){return function(e,n){return t.chain(e,function(r){return t.map(n(r),function(){return r})})}}function ia(t){return function(e){return function(n){return t.fromEither(Mu(n)?_r(e()):Mr(n.value))}}}function Ju(t,e){return function(n,r){return function(i){return e.chain(i,function(o){return t.fromEither(n(o)?Mr(o):_r(r(o)))})}}}var dn=function(t){return{equals:function(e,n){return e===n||t(e,n)}}},fe=function(t){return dn(function(e,n){for(var r in t)if(!t[r].equals(e[r],n[r]))return!1;return!0})},Xu={equals:function(t,e){return t===e}},Yu=function(t){return function(e,n){return e===n||t.compare(e,n)>-1?e:n}};function Qu(t,e){return t<e?-1:t>e?1:0}var Zu={equals:Xu.equals,compare:Qu},tc=Zu,ec=function(t){return{concat:Yu(t)}},nc=ec,R=Or,J=Nr;function rc(t){return function(e){return t(e)?J(e):R}}var ic=function(t,e){return c(t,x(e))},oc=function(t,e){return c(t,sc(e))},ac="Option",Ln=function(t){return{equals:function(e,n){return e===n||(re(e)?re(n):re(n)?!1:t.equals(e.value,n.value))}}},x=function(t){return function(e){return re(e)?R:J(t(e.value))}},Oe=J,sc=function(t){return function(e){return re(e)||re(t)?R:J(e.value(t.value))}},uc={URI:ac,map:ic,ap:oc,of:Oe},oa=we(2,function(t,e){return re(t)?R:e(t.value)}),cc=we(2,function(t,e){return re(t)?e():t}),vo=cc,lc=oa($e),At=function(t){return function(e){return re(e)?R:t(e.value)?e:R}},Dn=$i,re=function(t){return t._tag==="None"},fc=function(t,e){return function(n){return re(n)?t():e(n.value)}},me=fc,aa=me,dc=function(t){return function(e){return re(e)?t():e.value}},st=dc,li=lc,V=function(t){return t==null?R:J(t)},De=me(Nu,$e),yt=me(na,$e),Xt=oa,hc=Wu(uc),$r={equals:function(t,e){return t===e}},pc={equals:$r.equals,compare:function(t,e){return t<e?-1:t>e?1:0}};$r.equals,pc.compare;globalThis&&globalThis.__spreadArray;var vc=Uu,yc=Pu,mc=function(t,e){return t<0||t>=e.length},gc=function(t,e,n){if(n[t]===e)return n;var r=Vu(n);return r[t]=e,r},bc=function(t){return function(e){if(e.length===1)return e;for(var n=[wc(e)],r=Tc(e),i=function(s){n.every(function(l){return!t.equals(l,s)})&&n.push(s)},o=0,a=r;o<a.length;o++){var u=a[o];i(u)}return n}},Sc=qu,Cc=Ru,wc=Cc,Tc=ju;globalThis&&globalThis.__spreadArray;var mr=function(t){return t.length===0},qr=yc,Ic=function(t){return function(e){if(mr(e))return fa;for(var n=[],r=0;r<e.length;r++)n.push.apply(n,t(r,e[r]));return n}},Ec=mc,xc=function(t){return function(e){for(var n=0;n<e.length;n++)if(t(e[n]))return Nr(n);return Or}};function _t(t){return function(e){for(var n=0;n<e.length;n++)if(t(e[n]))return Nr(e[n]);return Or}}var Ac=function(t,e){return function(n){return Ec(t,n)?Or:Nr(qc(t,e(n[t]),n))}},Dc=function(t,e,n){for(var r=[],i=Math.min(t.length,e.length),o=0;o<i;o++)r[o]=n(t[o],e[o]);return r};function sa(t,e){return e===void 0?function(n){return sa(n,t)}:Dc(t,e,function(n,r){return[n,r]})}function ua(t){return function(e,n){if(n===void 0){var r=ua(t);return function(a){return r(e,a)}}for(var i=function(a){return t.equals(a,e)},o=0;o<n.length;o++)if(i(n[o]))return!0;return!1}}var an=function(t){var e=bc(t);return function(n){return qr(n)?e(n):n}},Oc=function(t){return function(e){return mr(e)?t:mr(t)?e:e.concat(t)}},L=Oc;function ca(t){var e=ua(t);return function(n,r){if(r===void 0){var i=ca(t);return function(o){return i(o,n)}}return n.filter(function(o){return!e(o,r)})}}var Nc=Sc,_c=we(2,function(t,e){return c(t,Ic(function(n,r){return e(r,n)}))}),la=_c($e),b=function(t){return function(e){return e.map(function(n){return t(n)})}},Gt=function(t){return function(e){return e.filter(t)}},Mc=function(t){return function(e){for(var n=[],r=0;r<e.length;r++){var i=t(r,e[r]);$i(i)&&n.push(i.value)}return n}},hn=function(t){return Mc(function(e,n){return t(n)})},se=hn($e),fi=function(t,e){return $c(t,function(n,r,i){return e(r,i)})},$c=function(t,e){return function(n){for(var r=n.length,i=t,o=0;o<r;o++)i=e(o,i,n[o]);return i}},qi=function(t){return dn(function(e,n){return e.length===n.length&&e.every(function(r,i){return t.equals(r,n[i])})})},qc=function(t,e,n){return qr(n)?gc(t,e,n):n},yo=function(t){return t.slice()},mo=function(t){return mr(t)?fa:t.slice()},fa=vc;function Pc(t){return function(e){return e.every(t)}}var ie=Symbol("@ts-pattern/matcher"),gr="@ts-pattern/anonymous-select-key",di=function(t){return!!(t&&typeof t=="object")},fr=function(t){return t&&!!t[ie]},Je=function t(e,n,r){if(di(e)){if(fr(e)){var i=e[ie]().match(n),o=i.matched,a=i.selections;return o&&a&&Object.keys(a).forEach(function(s){return r(s,a[s])}),o}if(!di(n))return!1;if(Array.isArray(e))return!!Array.isArray(n)&&e.length===n.length&&e.every(function(s,l){return t(s,n[l],r)});if(e instanceof Map)return n instanceof Map&&Array.from(e.keys()).every(function(s){return t(e.get(s),n.get(s),r)});if(e instanceof Set){if(!(n instanceof Set))return!1;if(e.size===0)return n.size===0;if(e.size===1){var u=Array.from(e.values())[0];return fr(u)?Array.from(n.values()).every(function(s){return t(u,s,r)}):n.has(u)}return Array.from(e.values()).every(function(s){return n.has(s)})}return Object.keys(e).every(function(s){var l,f=e[s];return(s in n||fr(l=f)&&l[ie]().matcherType==="optional")&&t(f,n[s],r)})}return Object.is(n,e)},Ne=function t(e){var n,r,i;return di(e)?fr(e)?(n=(r=(i=e[ie]()).getSelectionKeys)==null?void 0:r.call(i))!=null?n:[]:Array.isArray(e)?jn(e,t):jn(Object.values(e),t):[]},jn=function(t,e){return t.reduce(function(n,r){return n.concat(e(r))},[])};function go(t){var e;return(e={})[ie]=function(){return{match:function(n){var r={},i=function(o,a){r[o]=a};return n===void 0?(Ne(t).forEach(function(o){return i(o,void 0)}),{matched:!0,selections:r}):{matched:Je(t,n,i),selections:r}},getSelectionKeys:function(){return Ne(t)},matcherType:"optional"}},e}function bo(t){var e;return(e={})[ie]=function(){return{match:function(n){if(!Array.isArray(n))return{matched:!1};var r={};if(n.length===0)return Ne(t).forEach(function(o){r[o]=[]}),{matched:!0,selections:r};var i=function(o,a){r[o]=(r[o]||[]).concat([a])};return{matched:n.every(function(o){return Je(t,o,i)}),selections:r}},getSelectionKeys:function(){return Ne(t)}}},e}function So(){var t,e=[].slice.call(arguments);return(t={})[ie]=function(){return{match:function(n){var r={},i=function(o,a){r[o]=a};return{matched:e.every(function(o){return Je(o,n,i)}),selections:r}},getSelectionKeys:function(){return jn(e,Ne)},matcherType:"and"}},t}function Co(){var t,e=[].slice.call(arguments);return(t={})[ie]=function(){return{match:function(n){var r={},i=function(o,a){r[o]=a};return jn(e,Ne).forEach(function(o){return i(o,void 0)}),{matched:e.some(function(o){return Je(o,n,i)}),selections:r}},getSelectionKeys:function(){return jn(e,Ne)},matcherType:"or"}},t}function wo(t){var e;return(e={})[ie]=function(){return{match:function(n){return{matched:!Je(t,n,function(){})}},getSelectionKeys:function(){return[]},matcherType:"not"}},e}function ue(t){var e;return(e={})[ie]=function(){return{match:function(n){return{matched:!!t(n)}}}},e}function To(){var t,e=[].slice.call(arguments),n=typeof e[0]=="string"?e[0]:void 0,r=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return(t={})[ie]=function(){return{match:function(i){var o,a=((o={})[n??gr]=i,o);return{matched:r===void 0||Je(r,i,function(u,s){a[u]=s}),selections:a}},getSelectionKeys:function(){return[n??gr].concat(r===void 0?[]:Ne(r))}}},t}var da=ue(function(t){return!0}),Rc=da,jc=ue(function(t){return typeof t=="string"}),Uc=ue(function(t){return typeof t=="number"}),kc=ue(function(t){return typeof t=="boolean"}),Bc=ue(function(t){return typeof t=="bigint"}),Vc=ue(function(t){return typeof t=="symbol"}),Fc=ue(function(t){return t==null}),ft={__proto__:null,optional:go,array:bo,intersection:So,union:Co,not:wo,when:ue,select:To,any:da,_:Rc,string:jc,number:Uc,boolean:kc,bigint:Bc,symbol:Vc,nullish:Fc,instanceOf:function(t){return ue(function(e){return function(n){return n instanceof e}}(t))},typed:function(){return{array:bo,optional:go,intersection:So,union:Co,not:wo,select:To,when:ue}}};function O(t){return new Gc(t,[])}var Gc=function(){function t(n,r){this.value=void 0,this.cases=void 0,this.value=n,this.cases=r}var e=t.prototype;return e.with=function(){var n=[].slice.call(arguments),r=n[n.length-1],i=[n[0]],o=[];return n.length===3&&typeof n[1]=="function"?(i.push(n[0]),o.push(n[1])):n.length>2&&i.push.apply(i,n.slice(1,n.length-1)),new t(this.value,this.cases.concat([{match:function(a){var u={},s=!!(i.some(function(l){return Je(l,a,function(f,h){u[f]=h})})&&o.every(function(l){return l(a)}));return{matched:s,value:s&&Object.keys(u).length?gr in u?u[gr]:u:a}},handler:r}]))},e.when=function(n,r){return new t(this.value,this.cases.concat([{match:function(i){return{matched:!!n(i),value:i}},handler:r}]))},e.otherwise=function(n){return new t(this.value,this.cases.concat([{match:function(r){return{matched:!0,value:r}},handler:n}])).run()},e.exhaustive=function(){return this.run()},e.run=function(){for(var n=this.value,r=void 0,i=0;i<this.cases.length;i++){var o=this.cases[i],a=o.match(this.value);if(a.matched){n=a.value,r=o.handler;break}}if(!r){var u;try{u=JSON.stringify(this.value)}catch{u=this.value}throw new Error("Pattern matching error: no pattern matches value "+u)}return r(n,this.value)},t}(),ht={equals:function(t,e){return t===e}};ht.equals;var Pi={equals:function(t,e){return t===e}};Pi.equals;var Lc=function(t){return function(e){for(var n=[],r=0;r<e.length;r++)n.push.apply(n,t(r,e[r]));return n}};function Ue(t){return _t(t)}var dr=function(t){return function(e){return e.map(function(n){return t(n)})}},zc=we(2,function(t,e){return c(t,Lc(function(n,r){return e(r,n)}))}),Hc=zc($e),Wc=function(t){return function(e){for(var n=[],r=0;r<e.length;r++){var i=t(r,e[r]);$i(i)&&n.push(i.value)}return n}},Ie=function(t){return Wc(function(e,n){return t(n)})},Kc=function(t){return function(e){return e.filter(t)}},Ri=_r,Pr=Mr,ha=function(t,e){return c(t,Xc(e))},Jc=function(t,e){return c(t,Zc(e))},ji="Either",Xc=function(t){return function(e){return _e(e)?e:Pr(t(e.right))}},Yc={URI:ji,map:ha},Qc=function(t){return function(e){return _e(e)?e:_e(t)?t:Pr(e.right(t.right))}},Zc=Qc,tl={URI:ji,map:ha,ap:Jc},el=function(t){return function(e){return _e(e)?Ri(t(e.left)):e}},pa={URI:ji,fromEither:$e},nl=ia(pa),_e=$u,rl=function(t,e){return function(n){return _e(n)?t(n.left):e(n.right)}},ke=rl;pa.fromEither;var il=function(t){return _e(t)?Pr(t.left):Ri(t.right)};function ol(t){return ne(Pr,t.of)}function al(t){return ne(Ri,t.of)}function sl(t){return Hu(t,Yc)}function ul(t){return Fu(t,tl)}function cl(t){return function(e,n){return t.chain(e,function(r){return _e(r)?t.of(r):n(r.right)})}}function ll(t){return function(e,n){return t.map(e,el(n))}}function fl(t){return function(e,n){return function(r){return t.map(r,ke(e,n))}}}function dl(t){return function(e){return function(n){return t.chain(n,function(r){return _e(r)?e(r.left):t.of(r)})}}}function hl(t){return function(e){return t.map(e,il)}}var pl=function(t){return function(){return Promise.resolve().then(t)}};function vl(t){return function(e){return function(){return new Promise(function(n){setTimeout(function(){Promise.resolve().then(e).then(n)},t)})}}}var Rr=function(t,e){return c(t,va(e))},Ui=function(t,e){return c(t,yl(e))},va=function(t){return function(e){return function(){return Promise.resolve().then(e).then(t)}}},yl=function(t){return function(e){return function(){return Promise.all([Promise.resolve().then(e),Promise.resolve().then(t)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},zn=function(t){return function(){return Promise.resolve(t)}},ki=we(2,function(t,e){return function(){return Promise.resolve().then(t).then(function(n){return e(n)()})}}),Hn="Task",jr={URI:Hn,map:Rr},Bi={URI:Hn,of:zn},ml={URI:Hn,map:Rr,ap:Ui},Vi={URI:Hn,map:Rr,of:zn,ap:Ui,chain:ki},gl=$e,Io=ki,br={URI:Hn,map:Rr,of:zn,ap:Ui,chain:ki,fromIO:pl,fromTask:gl},bl=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(f){try{l(r.next(f))}catch(h){a(h)}}function s(f){try{l(r.throw(f))}catch(h){a(h)}}function l(f){f.done?o(f.value):i(f.value).then(u,s)}l((r=r.apply(t,e||[])).next())})},Sl=globalThis&&globalThis.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(l){return function(f){return s([l,f])}}function s(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(n=0)),n;)try{if(r=1,i&&(o=l[0]&2?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,i=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){n.label=l[1];break}if(l[0]===6&&n.label<o[1]){n.label=o[1],o=l;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(l);break}o[2]&&n.ops.pop(),n.trys.pop();continue}l=e.call(t,n)}catch(f){l=[6,f],i=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},pe=al(Bi),pn=ol(Bi),Cl=zn,wl=function(t){return va(nl(t))},Sr=fl(jr),Eo=function(t,e){return function(){return bl(void 0,void 0,void 0,function(){var n;return Sl(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t().then(Mr)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,_r(e(n))];case 3:return[2]}})})}},ya=dl(Vi),xo=hl(jr),ma=function(t,e){return c(t,Tt(e))},ga=function(t,e){return c(t,Il(e))},Tt=sl(jr),Tl=we(2,ll(jr)),ee=Tl,Il=ul(ml),ba=we(2,cl(Vi)),sn=pn,Fi="TaskEither",El={URI:Fi,map:ma,ap:ga,of:sn},Sa={URI:Fi,map:ma,ap:ga,chain:ba},Gi={URI:Fi,fromEither:Cl},xl=we(2,Ku(Sa)),Li=ia(Gi);Gi.fromEither;var Al=Ju(Gi,Sa),Dl=sn(ku),te=ba,Ol=xl,Nl=Object.getOwnPropertyNames,_l=Object.getOwnPropertySymbols,Ml=Object.prototype.hasOwnProperty;function Ao(t,e){return function(r,i,o){return t(r,i,o)&&e(r,i,o)}}function rr(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);var o=i.cache,a=o.get(n),u=o.get(r);if(a&&u)return a===r&&u===n;o.set(n,r),o.set(r,n);var s=t(n,r,i);return o.delete(n),o.delete(r),s}}function Do(t){return Nl(t).concat(_l(t))}var Ca=Object.hasOwn||function(t,e){return Ml.call(t,e)};function vn(t,e){return t||e?t===e:t===e||t!==t&&e!==e}var wa="_owner",Oo=Object.getOwnPropertyDescriptor,No=Object.keys;function $l(t,e,n){var r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function ql(t,e){return vn(t.getTime(),e.getTime())}function _o(t,e,n){if(t.size!==e.size)return!1;for(var r={},i=t.entries(),o=0,a,u;(a=i.next())&&!a.done;){for(var s=e.entries(),l=!1,f=0;(u=s.next())&&!u.done;){var h=a.value,d=h[0],y=h[1],m=u.value,v=m[0],w=m[1];!l&&!r[f]&&(l=n.equals(d,v,o,f,t,e,n)&&n.equals(y,w,d,v,t,e,n))&&(r[f]=!0),f++}if(!l)return!1;o++}return!0}function Pl(t,e,n){var r=No(t),i=r.length;if(No(e).length!==i)return!1;for(var o;i-- >0;)if(o=r[i],o===wa&&(t.$$typeof||e.$$typeof)&&t.$$typeof!==e.$$typeof||!Ca(e,o)||!n.equals(t[o],e[o],o,o,t,e,n))return!1;return!0}function In(t,e,n){var r=Do(t),i=r.length;if(Do(e).length!==i)return!1;for(var o,a,u;i-- >0;)if(o=r[i],o===wa&&(t.$$typeof||e.$$typeof)&&t.$$typeof!==e.$$typeof||!Ca(e,o)||!n.equals(t[o],e[o],o,o,t,e,n)||(a=Oo(t,o),u=Oo(e,o),(a||u)&&(!a||!u||a.configurable!==u.configurable||a.enumerable!==u.enumerable||a.writable!==u.writable)))return!1;return!0}function Rl(t,e){return vn(t.valueOf(),e.valueOf())}function jl(t,e){return t.source===e.source&&t.flags===e.flags}function Mo(t,e,n){if(t.size!==e.size)return!1;for(var r={},i=t.values(),o,a;(o=i.next())&&!o.done;){for(var u=e.values(),s=!1,l=0;(a=u.next())&&!a.done;)!s&&!r[l]&&(s=n.equals(o.value,a.value,o.value,a.value,t,e,n))&&(r[l]=!0),l++;if(!s)return!1}return!0}function Ul(t,e){var n=t.length;if(e.length!==n)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}var kl="[object Arguments]",Bl="[object Boolean]",Vl="[object Date]",Fl="[object Map]",Gl="[object Number]",Ll="[object Object]",zl="[object RegExp]",Hl="[object Set]",Wl="[object String]",Kl=Array.isArray,$o=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,qo=Object.assign,Jl=Object.prototype.toString.call.bind(Object.prototype.toString);function Xl(t){var e=t.areArraysEqual,n=t.areDatesEqual,r=t.areMapsEqual,i=t.areObjectsEqual,o=t.arePrimitiveWrappersEqual,a=t.areRegExpsEqual,u=t.areSetsEqual,s=t.areTypedArraysEqual;return function(f,h,d){if(f===h)return!0;if(f==null||h==null||typeof f!="object"||typeof h!="object")return f!==f&&h!==h;var y=f.constructor;if(y!==h.constructor)return!1;if(y===Object)return i(f,h,d);if(Kl(f))return e(f,h,d);if($o!=null&&$o(f))return s(f,h,d);if(y===Date)return n(f,h,d);if(y===RegExp)return a(f,h,d);if(y===Map)return r(f,h,d);if(y===Set)return u(f,h,d);var m=Jl(f);return m===Vl?n(f,h,d):m===zl?a(f,h,d):m===Fl?r(f,h,d):m===Hl?u(f,h,d):m===Ll?typeof f.then!="function"&&typeof h.then!="function"&&i(f,h,d):m===kl?i(f,h,d):m===Bl||m===Gl||m===Wl?o(f,h,d):!1}}function Yl(t){var e=t.circular,n=t.createCustomConfig,r=t.strict,i={areArraysEqual:r?In:$l,areDatesEqual:ql,areMapsEqual:r?Ao(_o,In):_o,areObjectsEqual:r?In:Pl,arePrimitiveWrappersEqual:Rl,areRegExpsEqual:jl,areSetsEqual:r?Ao(Mo,In):Mo,areTypedArraysEqual:r?In:Ul};if(n&&(i=qo({},i,n(i))),e){var o=rr(i.areArraysEqual),a=rr(i.areMapsEqual),u=rr(i.areObjectsEqual),s=rr(i.areSetsEqual);i=qo({},i,{areArraysEqual:o,areMapsEqual:a,areObjectsEqual:u,areSetsEqual:s})}return i}function Ql(t){return function(e,n,r,i,o,a,u){return t(e,n,u)}}function Zl(t){var e=t.circular,n=t.comparator,r=t.createState,i=t.equals,o=t.strict;if(r)return function(s,l){var f=r(),h=f.cache,d=h===void 0?e?new WeakMap:void 0:h,y=f.meta;return n(s,l,{cache:d,equals:i,meta:y,strict:o})};if(e)return function(s,l){return n(s,l,{cache:new WeakMap,equals:i,meta:void 0,strict:o})};var a={cache:void 0,equals:i,meta:void 0,strict:o};return function(s,l){return n(s,l,a)}}var tf=qe();qe({strict:!0});qe({circular:!0});qe({circular:!0,strict:!0});qe({createInternalComparator:function(){return vn}});qe({strict:!0,createInternalComparator:function(){return vn}});qe({circular:!0,createInternalComparator:function(){return vn}});qe({circular:!0,createInternalComparator:function(){return vn},strict:!0});function qe(t){t===void 0&&(t={});var e=t.circular,n=e===void 0?!1:e,r=t.createInternalComparator,i=t.createState,o=t.strict,a=o===void 0?!1:o,u=Yl(t),s=Xl(u),l=r?r(s):Ql(s);return Zl({circular:n,comparator:s,createState:i,equals:l,strict:a})}function Ta(t){return function(e,n){if(n===void 0){var r=Ta(t);return function(o){return r(o,e)}}for(var i in e)if(!Bu.call(n,i)||!t.equals(e[i],n[i]))return!1;return!0}}function ef(t){var e=Ta(t);return dn(function(n,r){return e(n)(r)&&e(r)(n)})}function nf(t){return ne(J,t.of)}function rf(t){return Dr(t.of(R))}function of(t){var e=rf(t);return function(n,r){return t.chain(n,me(function(){return e()},r))}}globalThis&&globalThis.__awaiter;globalThis&&globalThis.__generator;var af=nf(Bi),sf=zn,uf=we(2,of(Vi)),cf=uf,lf=Ou,qn=c,ff=lf(hc({concat:nc(tc).concat,empty:0}))();function df(t){return function(e){return e.iterNumber>=t?R:J(0)}}function hf(t,e){return function(n){return qn(n,e,x(function(r){return Math.min(t,r)}))}}function pf(t){return function(e){return J(t*Math.pow(2,e.iterNumber))}}var vf={iterNumber:0,cumulativeDelay:0,previousDelay:R};function yf(t,e){var n=t(e);return{iterNumber:e.iterNumber+1,cumulativeDelay:e.cumulativeDelay+st(function(){return 0})(n),previousDelay:n}}function mf(t,e){var n=yf(t,e);return qn(n.previousDelay,aa(function(){return br.of(n)},function(r){return vl(r)(br.of(n))}))}function Qe(t,e,n){var r=function(i){return qn(i,e,Io(function(o){return n(o)?qn(mf(t,i),Io(function(a){return qn(a.previousDelay,aa(function(){return br.of(o)},function(){return r(a)}))})):br.of(o)}))};return r(vf)}function gf(t){return e=>c(e,Tt(n=>(t(n)(),n)))}const Un=gf;function Cr(t){return e=>c(e,xo,Un(t),xo)}function bf(t){return e=>c(e,Un(n=>()=>t(n)()),Cr(n=>()=>t(n)()))}function Sf(t){return e=>c(e,x(n=>(t(n)(),n)))}const Cf=Sf;function zi(t){return{equals(e,n){return e==null&&n==null?!0:e==null||n===null||n===void 0?!1:t.equals(e,n)}}}function Wn(t){return{equals(e,n){const r=c(V(e),st(()=>[])),i=c(V(n),st(()=>[]));return qi(t).equals(r,i)}}}const Xe=fe({localId:ht,componentPath:Wn(ht),sharedConfigurationModelId:zi(ht)}),Ia=fe({localId:ht,configurationModelId:ht}),Ea=dn((t,e)=>O({x:t,y:e}).with({x:{type:"Choice"},y:{type:"Choice"}},n=>wf.equals(n.x,n.y)).with({x:{type:"Component"},y:{type:"Component"}},n=>Tf.equals(n.x,n.y)).with({x:{type:"Numeric"},y:{type:"Numeric"}},n=>If.equals(n.x,n.y)).with({x:{type:"Boolean"},y:{type:"Boolean"}},n=>Ef.equals(n.x,n.y)).otherwise(()=>!1)),wf=fe({type:ht,attributeId:Xe,state:ht,choiceValueId:ht}),Tf=fe({type:ht,attributeId:Xe,state:ht}),If=fe({type:ht,attributeId:Xe,state:$r}),Ef=fe({type:ht,attributeId:Xe,state:Pi});var Rt=(t=>(t.whyIsNotSatisfied="why-is-not-satisfied",t.whyIsStateNotPossible="why-is-state-not-possible",t))(Rt||{}),jt=(t=>(t.choiceValue="choice-value",t.component="component",t.boolean="boolean",t.numeric="numeric",t.configuration="configuration",t.attribute="attribute",t))(jt||{}),un=(t=>(t.Rule="Rule",t.Cardinality="Cardinality",t.Component="Component",t))(un||{}),kn=(t=>(t.all="all",t.none="none",t.specific="specific",t))(kn||{}),ge=(t=>(t.Channel="Channel",t.Package="Package",t))(ge||{}),it=(t=>(t.Boolean="Boolean",t.Numeric="Numeric",t.Choice="Choice",t.Component="Component",t))(it||{}),be=(t=>(t.Included="Included",t.Excluded="Excluded",t))(be||{}),Me=(t=>(t.Included="Included",t.Excluded="Excluded",t))(Me||{}),Se=(t=>(t.Implicit="Implicit",t.Explicit="Explicit",t))(Se||{}),Fe=(t=>(t.Mandatory="Mandatory",t.Optional="Optional",t))(Fe||{}),Ge=(t=>(t.Always="Always",t.Optional="Optional",t))(Ge||{});const xf=Object.freeze(Object.defineProperty({__proto__:null,AllowedRulesInExplainType:kn,AttributeType:it,ChoiceValueDecisionState:be,ComponentDecisionState:Me,ConfigurationModelSourceType:ge,ConstraintType:un,DecisionKind:Se,ExplainQuestionSubject:jt,ExplainQuestionType:Rt,Inclusion:Ge,Selection:Fe,eqCausedByDecision:Ea,eqGlobalAttributeId:Xe,eqGlobalConstraintId:Ia},Symbol.toStringTag,{value:"Module"}));var wt=(t=>(t.Unknown="Unknown",t.CommunicationError="Local.LowLevelCommunicationError",t.ServiceError="ServiceError",t.ConfigurationConflict="ConfigurationConflict",t.ConfigurationUnauthenticated="ConfigurationUnauthenticated",t.ConfigurationUnauthorized="ConfigurationUnauthorized",t.ConfigurationApplicationError="ConfigurationApplicationError",t.ConfigurationTimeout="ConfigurationTimeout",t.ConfigurationModelNotFound="ConfigurationModelNotFound",t.ConfigurationAttributeNotFound="ConfigurationAttributeNotFound",t.ConfigurationSolutionNotAvailable="ConfigurationSolutionNotAvailable",t.ConfigurationRejectedDecisionsConflict="ConfigurationRejectedDecisionsConflict",t.ConfigurationChoiceValueNotFound="ConfigurationChoiceValueNotFound",t.DecisionsToRespectInvalid="DecisionsToRespectInvalid",t.ConfigurationModelInvalid="ConfigurationModelInvalid",t.ConfigurationInitializationFailure="ConfigurationInitializationFailure",t.ConfigurationModelNotFeasible="ConfigurationModelNotFeasible",t.ConfigurationSetManyConflict="ConfigurationSetManyConflict",t))(wt||{}),Ur=(t=>(t[t.NumericDecisionOutOfRange=0]="NumericDecisionOutOfRange",t))(Ur||{});const xa={createConfigurationRejectedDecisionsConflict(t){return{type:"ConfigurationRejectedDecisionsConflict",rejectedDecisions:t}}},Af=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationConflictReason:Ur,FailureResultFactory:xa,FailureType:wt},Symbol.toStringTag,{value:"Module"}));class Aa{mapToCreateSessionRequest(e){return{configurationModelSource:this.mapToConfigurationModelSource(e.configurationModelSource),attributeRelations:this.mapToAttributeRelations(e.attributeRelations),usageRuleParameters:this.mapToUsageRuleParameters(e.usageRuleParameters),allowedInExplain:this.mapToAllowedInExplain(e.allowedInExplain)}}mapToConfigurationModelSource(e){return O(e).with({type:ge.Channel},n=>({type:"Channel",deploymentName:n.deploymentName,channel:n.channel})).with({type:ge.Package},n=>({type:"Package",configurationModelPackage:n.configurationModelPackage})).exhaustive()}mapToAttributeRelations(e){return c(e,V,x(ne(b(n=>this.mapToDecisionsToRespect(n)),n=>[...n])),yt)}mapToDecisionsToRespect(e){return{attributeId:e.attributeId,decisions:c([...e.decisions],dr(n=>this.mapToGlobalAttributeId(n)))}}mapToUsageRuleParameters(e){return c(V(e),yt)}mapToGlobalAttributeId(e){return{localId:e.localId,componentPath:e.componentPath,sharedConfigurationModelId:e.sharedConfigurationModelId}}mapToAllowedInExplain(e){return O(e).with({rules:{type:kn.none}},n=>({rules:{type:"AllowedRulesNone"}})).with({rules:{type:kn.specific,rules:ft.array(ft.any)}},n=>({rules:{type:"AllowedRulesSpecific",rules:c(n.rules.rules,b(r=>this.mapToGlobalConstraintId(r)),r=>[...r])}})).otherwise(()=>({rules:{type:"AllowedRulesAll"}}))}mapToGlobalConstraintId(e){return{localId:e.localId,configurationModelId:e.configurationModelId}}}function Df(t){return e=>Al(n=>n!=null,t)(e)}function Of(){return pn(Ee())}var Kt=(t=>(t.whyIsNotSatisfied="why-is-not-satisfied",t.whyIsStateNotPossible="why-is-state-not-possible",t))(Kt||{}),Ve=(t=>(t.decisions="decisions",t.constraints="constraints",t.all="all",t))(Ve||{}),Mt=(t=>(t.choiceValue="choice-value",t.component="component",t.boolean="boolean",t.numeric="numeric",t.configuration="configuration",t.attribute="attribute",t))(Mt||{});const Pt=fe({localId:ht,componentPath:Wn(ht),sharedConfigurationModel:zi(ht)}),Nf=Ln(qi(fe({attributeId:Pt,decisions:Wn(Pt)}))),_f=fe({configurationModelSource:dn((t,e)=>tf(t,e)),decisionsToRespect:Nf,usageRuleParameters:ef(ht)});var Bn=(t=>(t.Channel="Channel",t.Package="Package",t))(Bn||{}),ot=(t=>(t.Boolean="Boolean",t.Numeric="Numeric",t.Choice="Choice",t.Component="Component",t))(ot||{}),B=(t=>(t.Boolean="Boolean",t.Numeric="Numeric",t.ChoiceValue="ChoiceValue",t.Component="Component",t))(B||{}),It=(t=>(t.Included="Included",t.Excluded="Excluded",t))(It||{}),St=(t=>(t.Implicit="Implicit",t.Explicit="Explicit",t))(St||{}),Le=(t=>(t.Mandatory="Mandatory",t.Optional="Optional",t))(Le||{}),ze=(t=>(t.Always="Always",t.Optional="Optional",t))(ze||{});const Mf={equals:(t,e)=>t.choiceValueId!==e.choiceValueId?!1:Ln(ht).equals(t.state,e.state)},$f={equals(t,e){return Ln($r).equals(t.value,e.value)}},qf={equals(t,e){return Ln(Pi).equals(t.value,e.value)}},Pf={equals(t,e){return Ln(ht).equals(t.state,e.state)}},Rf={equals(t,e){return Pt.equals(t.attributeId,e.attributeId)?O({x:t,y:e}).with({x:{type:"Boolean"},y:{type:"Boolean"}},(n,r)=>qf.equals(r.x,r.y)).with({x:{type:"Numeric"},y:{type:"Numeric"}},(n,r)=>$f.equals(r.x,r.y)).with({x:{type:"Component"},y:{type:"Component"}},(n,r)=>Pf.equals(r.x,r.y)).with({x:{type:"ChoiceValue"},y:{type:"ChoiceValue"}},(n,r)=>Mf.equals(r.x,r.y)).otherwise(()=>!1):!1}},jf=qi(Rf),Uf={equals:(t,e)=>jf.equals(t.decisions,e.decisions)&&kf.equals(t.mode,e.mode)},kf={equals:(t,e)=>O({x:t,y:e}).with({x:{type:"Default"},y:{type:"Default"}},n=>!0).with({x:{type:"DropExistingDecisions"},y:{type:"DropExistingDecisions"}},n=>!0).otherwise(()=>!1)};var hi=(t=>(t.NotAvailable="NotAvailable",t.StateNotPossible="StateNotPossible",t))(hi||{}),cn=(t=>(t.Rule="Rule",t.Cardinality="Cardinality",t.Component="Component",t))(cn||{}),j=(t=>(t.ServiceError="ServiceError",t.Unknown="Unknown",t.CommunicationError="CommunicationError",t.ConfigurationConflict="ConfigurationConflict",t.ConfigurationSolutionNotAvailable="ConfigurationSolutionNotAvailable",t.ConfigurationAttributeNotFound="ConfigurationAttributeNotFound",t.ConfigurationChoiceValueNotFound="ConfigurationChoiceValueNotFound",t.ConfigurationUnauthenticated="ConfigurationUnauthenticated",t.ConfigurationApplicationError="ConfigurationApplicationError",t.ConfigurationTimeout="ConfigurationTimeout",t.ConfigurationModelNotFound="ConfigurationModelNotFound",t.ConfigurationRejectedDecisionsConflict="ConfigurationRejectedDecisionsConflict",t.ConfigurationSetManyConflict="ConfigurationSetManyConflict",t.DecisionsToRespectInvalid="DecisionsToRespectInvalid",t.ConfigurationModelInvalid="ConfigurationModelInvalid",t.ConfigurationInitializationFailure="ConfigurationInitializationFailure",t.ConfigurationModelNotFeasible="ConfigurationModelNotFeasible",t))(j||{}),Hi=(t=>(t[t.NumericDecisionOutOfRange=0]="NumericDecisionOutOfRange",t))(Hi||{});const Bf={createConfigurationRejectedDecisionsConflict(t){return{type:"ConfigurationRejectedDecisionsConflict",rejectedDecisions:t}}};function Vf(t,e){console.log(`--------------------------------------------------------------------------------
|
|
2
|
+
-- ${e??""}
|
|
3
|
+
--------------------------------------------------------------------------------
|
|
4
|
+
${JSON.stringify(t,null,2)}`)}var Pn=(t=>(t.ConfigurationEngineRestApiUnauthorized="Generic::Unauthorized",t.ClientError="Generic::LocalClientError",t.ServerError="Generic::ServerError",t.UnhandledResponseStatus="LocalUnhandledResponseStatus",t.LowLevelCommunicationError="LocalLowLevelCommunicationError",t))(Pn||{}),Da=(t=>(t.BooleanAttributeNotFound="BooleanAttributeNotFound",t.ChoiceAttributeNotFound="ChoiceAttributeNotFound",t.ChoiceValueNotFound="ChoiceValueNotFound",t.ConfigurationInitializationFailure="InitializationFailure",t.ConfigurationModelInvalid="ConfigurationModelInvalid",t.LegacyConfigurationModelInvalid="DeploymentStore.Core.Store.SnapshotInvalid",t.LegacySnapshotInvalid="SnapshotInvalid",t.ConfigurationModelNotFeasible="ConfigurationModelNotFeasible",t.ConfigurationModelNotFound="ConfigurationModelNotFound",t.ConflictWithConsequence="ConflictWithConsequence",t.DecisionInvalid="DecisionInvalid",t.DecisionsToRespectInvalid="DecisionsToRespectInvalid",t.NumericAttributeNotFound="NumericAttributeNotFound",t.NumericDecisionOutOfRange="NumericDecisionOutOfRange",t.SessionNotFound="SessionNotFound",t.SetDecisionConflict="SetDecisionConflict",t.Unauthorized="Unauthorized",t))(Da||{});const Ff=t=>Object.values(Da).includes(t),Gf=t=>Ff(t)?J(t):R;function Lf(t){return c(t,Gf,x(e=>O(e).with("ConfigurationModelNotFound",()=>({type:j.ConfigurationModelNotFound})).with("DecisionsToRespectInvalid",()=>({type:j.DecisionsToRespectInvalid})).with(ft.union("ChoiceAttributeNotFound","NumericAttributeNotFound","BooleanAttributeNotFound"),()=>({type:j.ConfigurationAttributeNotFound})).with("ChoiceValueNotFound",()=>({type:j.ConfigurationChoiceValueNotFound})).with("DecisionInvalid",()=>({type:j.ConfigurationConflict})).with("NumericDecisionOutOfRange",()=>({type:j.ConfigurationConflict,reason:Hi.NumericDecisionOutOfRange})).with("ConflictWithConsequence",()=>({type:j.ConfigurationConflict})).with(ft.union("SessionNotFound","Unauthorized"),()=>({type:j.ConfigurationUnauthenticated})).with("ConfigurationModelInvalid",()=>({type:j.ConfigurationModelInvalid})).with("DeploymentStore.Core.Store.SnapshotInvalid",()=>({type:j.ConfigurationModelInvalid})).with("SnapshotInvalid",()=>({type:j.ConfigurationModelInvalid})).with("InitializationFailure",()=>({type:j.ConfigurationInitializationFailure})).with("ConfigurationModelNotFeasible",n=>({type:j.ConfigurationModelNotFeasible,constraintExplanations:[]})).with("SetDecisionConflict",()=>({type:j.ConfigurationConflict})).exhaustive()))}const zf=t=>Object.values(Pn).includes(t),Hf=t=>zf(t)?J(t):R;function Wf(t){return c(t,Hf,x(e=>O(e).with("Generic::LocalClientError",()=>({type:j.ConfigurationApplicationError})).with("Generic::ServerError",()=>({type:j.ServiceError})).with("LocalLowLevelCommunicationError",()=>({type:j.CommunicationError})).with("Generic::Unauthorized",()=>({type:j.ConfigurationUnauthenticated})).with("LocalUnhandledResponseStatus",()=>({type:j.Unknown})).exhaustive()))}function he(t,e){Vf(t,e);const n=t.type;return c(R,vo(()=>Lf(n)),vo(()=>Wf(n)),st(()=>(console.error("InterpretEngineError encountered unexpected error type","ProblemDetails",t,"Context",e),{type:j.Unknown})))}class Oa{constructor(e,n,r,i){this.engineApiClient=e,this.contractToRestMapper=n,this.restToDomainMapper=r,this.options=i}create(e){const n=this.contractToRestMapper.mapToCreateSessionRequest(e);return c(this.engineApiClient.createSessionUsingJwtBearer(n,this.options.accessToken),ee(r=>he(r,"ClientSideSessionLifetimeHandler - create")),te(r=>this.restToDomainMapper.mapToSessionId(r)),Df(()=>({type:j.ConfigurationUnauthenticated})))}close(e){return c(this.engineApiClient.deleteSessionUsingJwtBearer(e,this.options.accessToken),ee(n=>he(n,"ClientSideSessionLifetimeHandler - close")),Tt(()=>Ee()))}}function Kf(t){var e=[];if(t.length===0)return"";if(typeof t[0]!="string")throw new TypeError("Url must be a string. Received "+t[0]);if(t[0].match(/^[^/:]+:\/*$/)&&t.length>1){var n=t.shift();t[0]=n+t[0]}t[0].match(/^file:\/\/\//)?t[0]=t[0].replace(/^([^/:]+):\/*/,"$1:///"):t[0]=t[0].replace(/^([^/:]+):\/*/,"$1://");for(var r=0;r<t.length;r++){var i=t[r];if(typeof i!="string")throw new TypeError("Url must be a string. Received "+i);i!==""&&(r>0&&(i=i.replace(/^[\/]+/,"")),r<t.length-1?i=i.replace(/[\/]+$/,""):i=i.replace(/[\/]+$/,"/"),e.push(i))}var o=e.join("/");o=o.replace(/\/(\?|&|#[^!])/g,"$1");var a=o.split("?");return o=a.shift()+(a.length>0?"?":"")+a.join("&"),o}function Jf(){var t;return typeof arguments[0]=="object"?t=arguments[0]:t=[].slice.call(arguments),Kf(t)}var Na=(t=>(t[t.Ok=200]="Ok",t[t.NoContent=204]="NoContent",t[t.BadRequest=400]="BadRequest",t[t.Unauthorized=401]="Unauthorized",t[t.NotFound=404]="NotFound",t[t.Conflict=409]="Conflict",t))(Na||{});function de(t,e,n){const r=c(Array.isArray(t)?t:[t],Jf);return c(Eo(()=>fetch(r,e),i=>({type:"error"})),te(i=>c(Eo(async()=>{const o=await i.json();return{response:i,data:o}},()=>i))),ya(i=>i.status===401?pe({type:Pn.ConfigurationEngineRestApiUnauthorized,status:401}):i.status===204?pn({response:i,data:{}}):i.type==="error"?pe({type:Pn.LowLevelCommunicationError}):pe({type:Pn.UnhandledResponseStatus})),te(i=>c(n(i),Li(()=>i.data))))}function pi(t,e){return de(t,e,n=>{if(n.response.status===200)return Oe(n.data);if(n.response.status===409){const r=n.data;return O(r).with({type:"ConfigurationModelInvalid"},i=>Oe(r)).with({type:"ConfigurationModelNotFeasible"},i=>Oe(r)).otherwise(()=>R)}return R})}class Xf{constructor(e){this.baseUrl=e}createSessionUsingApiKey(e,n){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-API-KEY":n},body:JSON.stringify(e)};return pi([this.baseUrl,"v2/session"],r)}createSessionUsingJwtBearer(e,n){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8",Authorization:`Bearer ${n}`},body:JSON.stringify(e)};return pi([this.baseUrl,"v2/session"],r)}setMany(e,n){const r={method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e},body:JSON.stringify(n)};return de([this.baseUrl,"v2/session/configuration/decision/many"],r,i=>i.response.status===200||i.response.status===409?J(i.data):R)}makeDecision(e,n){const r={method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e},body:JSON.stringify(n)};return de([this.baseUrl,"v2/session/configuration/decision"],r,i=>i.response.status===200?J(i.data):R)}getDecisions(e){const n={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e}};return de([this.baseUrl,"v2/session/configuration/decision"],n,r=>r.response.status===200?J(r.data):R)}getWhyStateNotPossible(e,n){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e},body:JSON.stringify(n)};return de([this.baseUrl,"v2/session/configuration/consequence/explain/why-state-not-possible"],r,i=>i.response.status===200?J(i.data):R)}getWhyNotSatisfied(e,n){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e},body:JSON.stringify(n)};return de([this.baseUrl,"v2/session/configuration/consequence/explain/why-not-satisfied"],r,i=>i.response.status===200?J(i.data):R)}getConsequence(e){const n={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e}};return de([this.baseUrl,"v2/session/configuration/consequence"],n,r=>r.response.status===200?J(r.data):R)}deleteSessionUsingJwtBearer(e,n){const r={method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8",Authorization:`Bearer ${n}`}};return de([this.baseUrl,`v2/session/${e}`],r,i=>i.response.status===204?J({}):R)}}var He=(t=>(t.Included="Included",t.Excluded="Excluded",t))(He||{}),vi=(t=>(t.Mandatory="Mandatory",t.Optional="Optional",t))(vi||{}),yi=(t=>(t.Always="Always",t.Optional="Optional",t))(yi||{}),Vn=(t=>(t.Implicit="Implicit",t.Explicit="Explicit",t))(Vn||{}),ve=(t=>(t.Included="Included",t.Excluded="Excluded",t.Undefined="Undefined",t))(ve||{}),Ht=(t=>(t.Choice="Choice",t.Numeric="Numeric",t.Boolean="Boolean",t.Component="Component",t))(Ht||{}),mi=(t=>(t.NotAvailable="NotAvailable",t.StateNotPossible="StateNotPossible",t))(mi||{}),gi=(t=>(t.Attribute="Attribute",t.Configuration="Configuration",t))(gi||{}),On=(t=>(t.Boolean="Boolean",t.Numeric="Numeric",t.ChoiceValue="ChoiceValue",t.Component="Component",t))(On||{});const zt=fe({localId:ht,componentPath:Wn(ht),sharedConfigurationModelId:zi(ht)});let _a=class{mapToDecisions(e){return{}}mapToSessionId(e){return O(e).with({sessionId:ft.string},n=>pn(n.sessionId)).with({type:"ConfigurationModelNotFeasible"},n=>{const r=c(n.constraintExplanations,b(i=>this.mapToConstraintExplanation(i)));return pe({type:j.ConfigurationModelNotFeasible,constraintExplanations:r})}).with({type:"ConfigurationModelInvalid"},()=>pe({type:j.ConfigurationModelInvalid})).otherwise(()=>pe({type:j.Unknown}))}mapToExplainAnswer(e,n){const r=O(n).with({question:Kt.whyIsStateNotPossible,subject:Mt.boolean},a=>[{type:B.Boolean,attributeId:a.attributeId,value:J(a.state)}]).with({question:Kt.whyIsStateNotPossible,subject:Mt.numeric},a=>[{type:B.Numeric,attributeId:a.attributeId,value:J(a.state)}]).with({question:Kt.whyIsStateNotPossible,subject:Mt.component},a=>[{type:B.Component,attributeId:a.attributeId,state:J(a.state)}]).with({question:Kt.whyIsStateNotPossible,subject:Mt.choiceValue},a=>[{type:B.ChoiceValue,attributeId:a.attributeId,choiceValueId:a.choiceValueId,state:J(a.state)}]).otherwise(()=>[]),i=c(e.decisionExplanations,b(a=>this.mapToDecisionExplanation(a,r,{type:"Default"}))),o=c(e.constraintExplanations,b(a=>this.mapToConstraintExplanation(a)));return O(n).with({answerType:Ve.decisions},()=>({decisionExplanations:i})).with({answerType:Ve.constraints},()=>({constraintExplanations:o})).with({answerType:Ve.all},()=>({constraintExplanations:o,decisionExplanations:i})).exhaustive()}mapToConfigurationSetManyConflictFailure(e,n,r){const i=this.mapToExplicitDecisions(n);return{type:j.ConfigurationSetManyConflict,decisionExplanations:c(e.decisionExplanations,b(o=>this.mapToDecisionExplanation(o,i,r))),constraintExplanations:c(e.constraintExplanations,b(o=>this.mapToConstraintExplanation(o)))}}mapToGlobalConstraintId(e){return{localId:e.localId,configurationModelId:e.configurationModelId}}mapToConfigurationModel(e,n){const r=this.mapToAttributes(e,n);return{isSatisfied:n.isConfigurationSatisfied??!1,attributes:r}}mapToBooleanDecision(e){return{type:B.Boolean,attributeId:this.mapToGlobalAttributeId(e.attributeId),value:V(e.state)}}mapToNumericDecision(e){return{type:B.Numeric,attributeId:this.mapToGlobalAttributeId(e.attributeId),value:V(e.state)}}mapToComponentDecision(e){return{type:B.Component,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:this.mapToDecisionState(e.state)}}mapToExplicitChoiceValueDecision(e){return{type:B.ChoiceValue,attributeId:this.mapToGlobalAttributeId(e.attributeId),choiceValueId:e.choiceValueId,state:this.mapToDecisionState(e.state)}}mapToGlobalAttributeId(e){return{localId:e.localId,sharedConfigurationModel:e.sharedConfigurationModelId,componentPath:e.componentPath??[]}}mapToChoiceValueDecision(e){return c(this.mapToDecisionState(e.state),x(n=>({kind:this.mapToDecisionKind(e.kind),state:n})))}mapToConstraintExplanation(e){return{causedByRules:c(e.causedByRules,b(n=>this.mapToRuleConstraint(n))),causedByCardinalities:c(e.causedByCardinalities,b(n=>this.mapToCardinalityConstraint(n)))}}mapToRuleConstraint(e){return{type:cn.Rule,ruleId:this.mapToGlobalConstraintId(e.constraintId)}}mapToCardinalityConstraint(e){return{type:cn.Cardinality,attributeId:this.mapToGlobalAttributeId(e.attributeId)}}mapToExplicitDecisions(e){const n=c(e.booleanDecisions??[],b(a=>({type:B.Boolean,attributeId:this.mapToGlobalAttributeId(a.attributeId),value:V(a.state)}))),r=c(e.numericDecisions??[],b(a=>({type:B.Numeric,attributeId:this.mapToGlobalAttributeId(a.attributeId),value:V(a.state)}))),i=c(e.componentDecisions??[],b(a=>({type:B.Component,attributeId:this.mapToGlobalAttributeId(a.attributeId),state:c(V(a.state),x(u=>this.mapToDecisionState(u)),li)}))),o=c(e.choiceDecisions??[],b(a=>({type:B.ChoiceValue,attributeId:this.mapToGlobalAttributeId(a.attributeId),choiceValueId:a.choiceValueId,state:c(V(a.state),x(u=>this.mapToDecisionState(u)),li)})));return c([],L(n),L(r),L(i),L(o))}mapToDecisionExplanation(e,n,r){const i=c(e.causedByBooleanDecisions,b(m=>this.mapToCausedByBooleanDecision(m))),o=c(e.causedByNumericDecisions,b(m=>this.mapToCausedByNumericDecision(m))),a=c(e.causedByComponentDecisions,b(m=>this.mapToCausedByComponentDecision(m))),u=c(e.causedByChoiceDecisions,b(m=>this.mapToCausedByChoiceValueDecision(m))),s=c(i,b(m=>({type:B.Boolean,attributeId:m.attributeId,value:R}))),l=c(o,b(m=>({type:B.Numeric,attributeId:m.attributeId,value:R}))),f=c(a,b(m=>({type:B.Component,attributeId:m.attributeId,state:R}))),h=c(u,b(m=>({type:B.ChoiceValue,attributeId:m.attributeId,choiceValueId:m.choiceValueId,state:R}))),d=c([],L(s),L(l),L(f),L(h)),y=ca(dn((m,v)=>{const w=Pt.equals(m.attributeId,v.attributeId);return O({a:m,b:v}).with({a:{type:B.ChoiceValue},b:{type:B.ChoiceValue}},E=>w&&E.a.choiceValueId===E.b.choiceValueId).otherwise(()=>w)}))(d)(n);return{causedByBooleanDecisions:i,causedByNumericDecisions:o,causedByComponentDecisions:a,causedByChoiceDecisions:u,solution:{decisions:c([],L(d),L(y)),mode:r}}}mapToCausedByBooleanDecision(e){return{type:B.Boolean,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:e.state,reason:this.mapToReason(e.reason)}}mapToReason(e){return O(e).with(mi.NotAvailable,()=>hi.NotAvailable).with(mi.StateNotPossible,()=>hi.StateNotPossible).exhaustive()}mapToCausedByNumericDecision(e){return{type:B.Numeric,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:e.state,reason:this.mapToReason(e.reason)}}mapToCausedByComponentDecision(e){return{type:B.Component,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:this.mapToPossibleDecisionState(e.state),reason:this.mapToReason(e.reason)}}mapToCausedByChoiceValueDecision(e){return{type:B.ChoiceValue,attributeId:this.mapToGlobalAttributeId(e.attributeId),choiceValueId:e.choiceValueId,state:this.mapToPossibleDecisionState(e.state),reason:this.mapToReason(e.reason)}}mapToAttributes(e,n){function r(d){return c(n.canAttributeContributeToConfigurationSatisfaction,_t(y=>zt.equals(y,d)),Dn)}const i=c([],L(c(e.choiceValueDecisions,b(d=>d.attributeId))),L(c(n.choiceConsequences,b(d=>d.attributeId))),an(zt)),o=c(i,b(d=>{const y=c(e.choiceValueDecisions??[],Kc(v=>zt.equals(v.attributeId,d))),m=c(n.choiceConsequences??[],Ue(v=>zt.equals(v.attributeId,d)));return c(m,x(v=>this.mapToChoiceAttributes(v,y,r(d))))}),se),a=c([],L(c(e.numericDecisions,b(d=>d.attributeId))),L(c(n.numericConsequences,b(d=>d.attributeId))),an(zt)),u=c(a,b(d=>{const y=c(e.numericDecisions??[],Ue(v=>zt.equals(v.attributeId,d))),m=c(n.numericConsequences??[],Ue(v=>zt.equals(v.attributeId,d)));return c(m,x(v=>this.mapToNumericAttribute(v,y,r(d))))}),se),s=c([],L(c(e.booleanDecisions,b(d=>d.attributeId))),L(c(n.booleanConsequences,b(d=>d.attributeId))),an(zt)),l=c(s,b(d=>{const y=c(e.booleanDecisions??[],Ue(v=>zt.equals(v.attributeId,d))),m=c(n.booleanConsequences??[],Ue(v=>zt.equals(v.attributeId,d)));return c(m,x(v=>this.mapToBooleanAttribute(v,y,r(d))))}),se),f=c([],L(c(e.componentDecisions,b(d=>d.attributeId))),L(c(n.componentConsequences,b(d=>d.attributeId))),an(zt)),h=c(f,b(d=>{const y=c(e.componentDecisions??[],Ue(v=>zt.equals(v.attributeId,d))),m=c(n.componentConsequences??[],Ue(v=>zt.equals(v.attributeId,d)));return c(m,x(v=>this.mapToComponentAttribute(v,y,r(d))))}),se);return c([],L(o),L(h),L(u),L(l))}mapToComponentAttribute(e,n,r){return{type:ot.Component,attributeId:this.mapToGlobalAttributeId(e.attributeId),isSatisfied:e.isSatisfied,possibleDecisionStates:c(e.possibleDecisionStates,dr(i=>this.mapToPossibleDecisionState(i))),decision:c(n,Xt(i=>c(this.mapToDecisionState(i.state),x(o=>({state:o,kind:i.kind}))))),inclusion:this.mapToInclusion(e.inclusion),selection:c(e.selection,V,x(i=>this.mapToSelection(i)),yt),canContributeToConfigurationSatisfaction:r}}mapToChoiceAttributes(e,n,r){const i=c(e.values,dr(o=>{const a=c(n,_t(u=>u.choiceValueId==o.choiceValueId));return this.mapToChoiceValue(o,a)}));return{type:ot.Choice,attributeId:this.mapToGlobalAttributeId(e.attributeId),isSatisfied:e.isSatisfied,cardinality:this.mapToCardinality(e.cardinality),values:i,canContributeToConfigurationSatisfaction:r}}mapToBooleanAttribute(e,n,r){return{type:ot.Boolean,attributeId:this.mapToGlobalAttributeId(e.attributeId),isSatisfied:e.isSatisfied,selection:this.mapToSelection(e.selection),possibleDecisionStates:e.possibleDecisionStates,decision:c(n,Xt(i=>c(i.state,V,x(o=>({kind:this.mapToDecisionKind(i.kind),state:o}))))),canContributeToConfigurationSatisfaction:r}}mapToNumericAttribute(e,n,r){return{type:ot.Numeric,attributeId:this.mapToGlobalAttributeId(e.attributeId),isSatisfied:e.isSatisfied,range:{min:e.range.min,max:e.range.max},selection:this.mapToSelection(e.selection),decimalPlaces:e.decimalPlaces,decision:c(n,Xt(i=>c(i.state,V,x(o=>({kind:this.mapToDecisionKind(i.kind),state:o}))))),canContributeToConfigurationSatisfaction:r}}mapToChoiceValue(e,n){const r=c(e.possibleDecisionStates,dr(i=>this.mapToPossibleDecisionState(i)));return{choiceValueId:e.choiceValueId,decision:c(n,Xt(i=>this.mapToChoiceValueDecision(i))),possibleDecisionStates:r}}mapToDecisionKind(e){return O(e).with(Vn.Implicit,()=>St.Implicit).with(Vn.Explicit,()=>St.Explicit).exhaustive()}mapToDecisionState(e){return O(e).with(ve.Included,()=>J(It.Included)).with(ve.Excluded,()=>J(It.Excluded)).with(ve.Undefined,()=>R).exhaustive()}mapToPossibleDecisionState(e){return O(e).with(He.Included,()=>It.Included).with(He.Excluded,()=>It.Excluded).exhaustive()}mapToSelection(e){return O(e).with(vi.Mandatory,()=>Le.Mandatory).with(vi.Optional,()=>Le.Optional).exhaustive()}mapToInclusion(e){return O(e).with(yi.Always,()=>ze.Always).with(yi.Optional,()=>ze.Optional).exhaustive()}mapToCardinality(e){return{lowerBound:e.lowerBound,upperBound:e.upperBound}}},Ma=class{constructor(e,n){this.restToDomainMapper=new _a,this.contractToRestMapper=e,this.options=n}create(e){const n=this.contractToRestMapper.mapToCreateSessionRequest(e),r=pi(this.options.sessionCreateUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},body:JSON.stringify(n)});return c(r,ee(i=>he(i,"ServerSideSessionLifetimeHandler - create")),te(i=>this.restToDomainMapper.mapToSessionId(i)))}close(e){return c(de(this.options.sessionDeleteUrl,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8","X-SESSION-ID":e}},n=>n.response.status===Na.NoContent?J({}):R),ee(n=>he(n,"ServerSideSessionLifetimeHandler - close")),Tt(Ee))}},Yf=class{constructor(e,n,r){this.inner=e,this.contractToDomainMapper=n,this.domainToContractMapper=r,this.onConfigurationChangedHandler=R}setOnConfigurationChangedHandler(e){const n=c(e,V,x(r=>i=>{const o=this.domainToContractMapper.mapToConfiguration(i);r(o)}));this.inner.setOnConfigurationChangedHandler(n)}getConfiguration(){const e=this.inner.getConfiguration();return this.domainToContractMapper.mapToConfiguration(e)}getSessionContext(){const e=this.inner.getSessionContext();return this.domainToContractMapper.mapToSessionContext(e)}async setSessionContext(e){const n=this.contractToDomainMapper.mapToSessionContext(e);return await c(this.inner.setSessionContext(n),Tt(Ee),this.adaptToContractPromise())()}async restoreConfiguration(e){const n=this.contractToDomainMapper.mapToConfiguration(e);return await c(this.inner.restoreConfiguration(n),Tt(Ee),this.adaptToContractPromise())()}async makeDecision(e){const n=this.contractToDomainMapper.mapToAttributeDecision(e);return await c(this.inner.makeDecision(n),Tt(Ee),this.adaptToContractPromise())()}async setMany(e,n){const r=this.contractToDomainMapper.mapToAttributeDecisions(e),i=this.contractToDomainMapper.mapToMode(n);return await c(this.inner.setMany(r,i),Tt(Ee),this.adaptToContractPromise())()}async applySolution(e){const n=this.contractToDomainMapper.mapToSolution(e);return await c(this.inner.applySolution(n),Tt(Ee),this.adaptToContractPromise())()}async explain(e,n){const r=this.contractToDomainMapper.mapToExplainQuestion(e,n);return await c(this.inner.explain(r),Tt(i=>this.domainToContractMapper.mapToExplainAnswer(i)),this.adaptToContractPromise())()}async close(){return await c(this.inner.close(),ee(e=>this.domainToContractMapper.mapToFailureResult(e)),Sr(Promise.reject,e=>Promise.resolve()))()}adaptToContractPromise(){return ne(ee(e=>this.domainToContractMapper.mapToFailureResult(e)),Sr(e=>Promise.reject(e),e=>Promise.resolve(e)))}},Qf=class{mapToExplainQuestion(e,n){const r={answerType:O(n).with("decisions",()=>Ve.decisions).with("constraints",()=>Ve.constraints).with("full",()=>Ve.all).exhaustive()};return O(e).with({question:Rt.whyIsNotSatisfied,subject:jt.configuration},i=>({...r,question:Kt.whyIsNotSatisfied,subject:Mt.configuration})).with({question:Rt.whyIsNotSatisfied,subject:jt.attribute},i=>({...r,question:Kt.whyIsNotSatisfied,subject:Mt.attribute,attributeId:this.mapToGlobalAttributeId(i.attributeId)})).with({question:Rt.whyIsStateNotPossible,subject:jt.choiceValue},i=>({...r,question:Kt.whyIsStateNotPossible,subject:Mt.choiceValue,attributeId:this.mapToGlobalAttributeId(i.attributeId),choiceValueId:i.choiceValueId,state:this.mapToDecisionState(i.state)})).with({question:Rt.whyIsStateNotPossible,subject:jt.component},i=>({...r,question:Kt.whyIsStateNotPossible,subject:Mt.component,attributeId:this.mapToGlobalAttributeId(i.attributeId),state:this.mapToDecisionState(i.state)})).with({question:Rt.whyIsStateNotPossible,subject:jt.numeric},i=>({...r,question:Kt.whyIsStateNotPossible,subject:Mt.numeric,attributeId:this.mapToGlobalAttributeId(i.attributeId),state:i.state})).with({question:Rt.whyIsStateNotPossible,subject:jt.boolean},i=>({...r,question:Kt.whyIsStateNotPossible,subject:Mt.boolean,attributeId:this.mapToGlobalAttributeId(i.attributeId),state:i.state})).exhaustive()}mapToConfiguration(e){return{isSatisfied:e.isSatisfied,attributes:c(e.attributes,b(n=>this.mapToAttribute(n)))}}mapToAttributeDecisions(e){return c(e,b(n=>this.mapToAttributeDecision(n)))}mapToSessionContext(e){return{configurationModelSource:this.mapToConfigurationModelSource(e.configurationModelSource),decisionsToRespect:this.mapToDecisionsToRespect(e.attributeRelations),usageRuleParameters:this.mapToUsageRuleParameters(e.usageRuleParameters)}}mapToAttributeDecision(e){return O(e).with({type:it.Choice,choiceValueId:ft.string},n=>({type:B.ChoiceValue,attributeId:this.mapToGlobalAttributeId(n.attributeId),choiceValueId:n.choiceValueId,state:this.mapToDecisionStateOption(n.state)})).with({type:it.Numeric},n=>({type:B.Numeric,attributeId:this.mapToGlobalAttributeId(n.attributeId),value:V(n.state)})).with({type:it.Boolean},n=>({type:B.Boolean,attributeId:this.mapToGlobalAttributeId(n.attributeId),value:V(n.state)})).with({type:it.Component},n=>({type:B.Component,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(V(n.state),Xt(r=>this.mapToDecisionStateOption(r)))})).exhaustive()}mapToDecisionsToRespect(e){return c(V(e),x(n=>c(n,b(r=>({attributeId:this.mapToGlobalAttributeId(r.attributeId),decisions:c(r.decisions,b(i=>this.mapToGlobalAttributeId(i)))})))))}mapToMode(e){return O(e).with({type:"DropExistingDecisions"},n=>({type:"DropExistingDecisions",conflictHandling:this.mapToConflictHandling(n.conflictHandling)})).otherwise(()=>({type:"Default"}))}mapToConflictHandling(e){return O(e).with({type:"Manual"},n=>({type:"Manual",includeConstraintsInConflictExplanation:n.includeConstraintsInConflictExplanation})).with({type:"Automatic"},n=>({type:"Automatic"})).exhaustive()}mapToGlobalAttributeId(e){return{localId:e.localId,componentPath:e.componentPath??[],sharedConfigurationModel:e.sharedConfigurationModelId}}mapToConfigurationModelSource(e){return O(e).with({type:ge.Package},n=>({type:Bn.Package,configurationModelPackage:n.configurationModelPackage})).with({type:ge.Channel},n=>({type:Bn.Channel,deploymentName:n.deploymentName,channel:n.channel})).exhaustive()}mapToSolution(e){return{decisions:c(e.decisions,b(n=>this.mapToAttributeDecision(n))),mode:this.mapToMode(e.mode)}}mapToAttribute(e){return O(e).with({type:it.Boolean},n=>({type:ot.Boolean,attributeId:this.mapToGlobalAttributeId(n.id),isSatisfied:n.isSatisfied,possibleDecisionStates:n.possibleDecisionStates,selection:this.mapToSelection(n.selection),decision:c(n.decision,V,x(r=>({kind:this.mapToDecisionKind(r.kind),state:r.state}))),canContributeToConfigurationSatisfaction:n.canContributeToConfigurationSatisfaction})).with({type:it.Numeric},n=>({type:ot.Numeric,attributeId:this.mapToGlobalAttributeId(n.id),isSatisfied:n.isSatisfied,range:{min:n.range.min,max:n.range.max},decimalPlaces:n.decimalPlaces,selection:this.mapToSelection(n.selection),decision:c(n.decision,V,x(r=>({kind:this.mapToDecisionKind(r.kind),state:r.state}))),canContributeToConfigurationSatisfaction:n.canContributeToConfigurationSatisfaction})).with({type:it.Choice},n=>({type:ot.Choice,attributeId:this.mapToGlobalAttributeId(n.id),isSatisfied:n.isSatisfied,cardinality:{lowerBound:n.cardinality.lowerBound,upperBound:n.cardinality.upperBound},values:c(n.values,b(r=>this.mapToChoiceValue(r))),canContributeToConfigurationSatisfaction:n.canContributeToConfigurationSatisfaction})).with({type:it.Component},n=>({type:ot.Component,attributeId:this.mapToGlobalAttributeId(n.id),isSatisfied:n.isSatisfied,decision:c(n.decision,V,Xt(r=>c(this.mapToDecisionStateOption(r.state),x(i=>({kind:this.mapToDecisionKind(r.kind),state:i}))))),possibleDecisionStates:c(n.possibleDecisionStates,b(r=>this.mapToDecisionStateOption(r)),se),selection:c(n.selection,V,x(r=>this.mapToSelection(r)),yt),inclusion:this.mapToInclusion(n.inclusion),canContributeToConfigurationSatisfaction:n.canContributeToConfigurationSatisfaction})).exhaustive()}mapToChoiceValue(e){return{choiceValueId:e.id,decision:this.mapToChoiceValueDecision(e),possibleDecisionStates:c(e.possibleDecisionStates,b(n=>this.mapToDecisionStateOption(n)),se)}}mapToChoiceValueDecision(e){return c(e.decision,V,Xt(n=>c(this.mapToDecisionStateOption(n.state),x(r=>({state:r,kind:this.mapToDecisionKind(n.kind)})))))}mapToDecisionKind(e){return O(e).with(Se.Implicit,()=>St.Implicit).with(Se.Explicit,()=>St.Explicit).exhaustive()}mapToSelection(e){return O(e).with(Fe.Mandatory,()=>Le.Mandatory).with(Fe.Optional,()=>Le.Optional).exhaustive()}mapToInclusion(e){return O(e).with(Ge.Always,()=>ze.Always).with(Ge.Optional,()=>ze.Optional).exhaustive()}mapToDecisionState(e){return O(e).with(ft.union(be.Included,Me.Included),()=>It.Included).with(ft.union(be.Excluded,Me.Excluded),()=>It.Excluded).exhaustive()}mapToDecisionStateOption(e){return c(V(e),x(n=>this.mapToDecisionState(n)))}mapToUsageRuleParameters(e){return e??{}}},$a=class{mapToExplainAnswer(e){const n=O(e).with({decisionExplanations:ft.array(ft.any)},i=>c(i.decisionExplanations,b(o=>this.mapToDecisionExplanation(o)))).otherwise(()=>[]),r=O(e).with({constraintExplanations:ft.array(ft.any)},i=>c(i.constraintExplanations,b(o=>this.mapToConstraintExplanation(o)))).otherwise(()=>[]);return{decisionExplanations:n,constraintExplanations:r}}mapToConstraintExplanation(e){return{causedByCardinalities:c(e.causedByCardinalities,b(n=>this.mapToGlobalAttributeId(n.attributeId))),causedByRules:c(e.causedByRules,b(n=>this.mapToGlobalConstraintId(n.ruleId)))}}mapToDecisionExplanation(e){const n=c(e.causedByChoiceDecisions,b(a=>this.mapToCausedByChoiceAttributeDecision(a))),r=c(e.causedByComponentDecisions,b(a=>this.mapToCausedByComponentAttributeDecision(a))),i=c(e.causedByNumericDecisions,b(a=>this.mapToCausedByNumericAttributeDecision(a))),o=c(e.causedByBooleanDecisions,b(a=>this.mapToCausedByBooleanAttributeDecision(a)));return{causedByDecisions:c([],L(n),L(r),L(i),L(o)),solution:this.mapToSolution(e.solution)}}mapToSolution(e){return{decisions:c(e.decisions,b(n=>this.mapToExplicitDecision(n))),mode:this.mapToMode(e.mode)}}mapToMode(e){return O(e).with({type:"DropExistingDecisions"},n=>({type:"DropExistingDecisions",conflictHandling:this.mapToConflictHandling(n.conflictHandling)})).otherwise(()=>({type:"Default"}))}mapToConflictHandling(e){return O(e).with({type:"Manual"},n=>({type:"Manual",includeConstraintsInConflictExplanation:n.includeConstraintsInConflictExplanation})).with({type:"Automatic"},n=>({type:"Automatic"})).exhaustive()}mapToSessionContext(e){return{configurationModelSource:this.mapToConfigurationModelSource(e.configurationModelSource),attributeRelations:this.mapToDecisionsToRespect(e.decisionsToRespect),usageRuleParameters:this.mapToUsageRuleParameters(e.usageRuleParameters)}}mapToFailureResult(e){return O(e).with({type:j.ConfigurationConflict},n=>({type:wt.ConfigurationConflict,reason:O(n.reason).with(Hi.NumericDecisionOutOfRange,()=>Ur.NumericDecisionOutOfRange).otherwise(()=>{})})).with({type:j.ConfigurationApplicationError},()=>({type:wt.ConfigurationApplicationError})).with({type:j.ConfigurationUnauthenticated},()=>({type:wt.ConfigurationUnauthenticated})).with({type:j.ConfigurationModelNotFound},()=>({type:wt.ConfigurationModelNotFound})).with({type:j.ConfigurationTimeout},()=>({type:wt.ConfigurationTimeout})).with({type:j.ConfigurationAttributeNotFound},()=>({type:wt.ConfigurationAttributeNotFound})).with({type:j.ConfigurationChoiceValueNotFound},()=>({type:wt.ConfigurationChoiceValueNotFound})).with({type:j.ConfigurationSolutionNotAvailable},()=>({type:wt.ConfigurationSolutionNotAvailable})).with({type:j.ConfigurationRejectedDecisionsConflict},n=>{const r=c(n.rejectedDecisions,b(i=>this.mapToExplicitDecision(i)));return xa.createConfigurationRejectedDecisionsConflict(r)}).with({type:j.DecisionsToRespectInvalid},()=>({type:wt.DecisionsToRespectInvalid})).with({type:j.ServiceError},()=>({type:wt.ServiceError})).with({type:j.CommunicationError},()=>({type:wt.CommunicationError})).with({type:j.Unknown},()=>({type:wt.Unknown})).with({type:j.ConfigurationModelInvalid},()=>({type:wt.ConfigurationModelInvalid})).with({type:j.ConfigurationInitializationFailure},()=>({type:wt.ConfigurationInitializationFailure})).with({type:j.ConfigurationModelNotFeasible},n=>({type:wt.ConfigurationModelNotFeasible,constraintExplanations:c(n.constraintExplanations,b(r=>this.mapToConstraintExplanation(r)))})).with({type:j.ConfigurationSetManyConflict},n=>({type:wt.ConfigurationSetManyConflict,decisionExplanations:c(n.decisionExplanations,b(r=>this.mapToDecisionExplanation(r))),constraintExplanations:c(n.constraintExplanations,b(r=>this.mapToConstraintExplanation(r)))})).exhaustive()}mapToConfiguration(e){return{isSatisfied:e.isSatisfied,attributes:c(e.attributes,b(n=>this.mapToAttribute(n)))}}mapToDecisionsToRespect(e){return c(e,x(ne(b(n=>({attributeId:this.mapToGlobalAttributeId(n.attributeId),decisions:c(n.decisions,b(r=>this.mapToGlobalAttributeId(r)))})))),yt)}mapToGlobalAttributeId(e){return{localId:e.localId,sharedConfigurationModelId:e.sharedConfigurationModel,componentPath:[...e.componentPath??[]]}}mapToGlobalConstraintId(e){return{localId:e.localId,configurationModelId:e.configurationModelId}}mapToConfigurationModelSource(e){return O(e).with({type:Bn.Package},n=>({type:ge.Package,configurationModelPackage:n.configurationModelPackage})).with({type:Bn.Channel},n=>({type:ge.Channel,deploymentName:n.deploymentName,channel:n.channel})).exhaustive()}mapToExplicitDecision(e){return O(e).with({type:B.ChoiceValue},n=>({type:it.Choice,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(n.state,x(r=>this.mapToChoiceValueDecisionState(r)),yt),choiceValueId:n.choiceValueId})).with({type:B.Component},n=>({type:it.Component,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(n.state,x(r=>this.mapToComponentDecisionState(r)),yt)})).with({type:B.Numeric},n=>({type:it.Numeric,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(n.value,yt)})).with({type:B.Boolean},n=>({type:it.Boolean,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(n.value,yt)})).exhaustive()}mapToCardinality(e){return O(e).with(cn.Cardinality,()=>un.Cardinality).with(cn.Component,()=>un.Component).with(cn.Rule,()=>un.Rule).exhaustive()}mapToCausedByAttributeDecision(e){return O(e).with({type:B.ChoiceValue},n=>this.mapToCausedByChoiceAttributeDecision(n)).with({type:B.Numeric},n=>this.mapToCausedByNumericAttributeDecision(n)).with({type:B.Boolean},n=>this.mapToCausedByBooleanAttributeDecision(n)).with({type:B.Component},n=>this.mapToCausedByComponentAttributeDecision(n)).exhaustive()}mapToCausedByChoiceAttributeDecision(e){return{type:it.Choice,attributeId:this.mapToGlobalAttributeId(e.attributeId),choiceValueId:e.choiceValueId,state:this.mapToChoiceValueDecisionState(e.state)}}mapToCausedByNumericAttributeDecision(e){return{type:it.Numeric,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:e.state}}mapToCausedByBooleanAttributeDecision(e){return{type:it.Boolean,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:e.state}}mapToCausedByComponentAttributeDecision(e){return{type:it.Component,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:this.mapToComponentDecisionState(e.state)}}mapToSelection(e){return O(e).with(Le.Mandatory,()=>Fe.Mandatory).with(Le.Optional,()=>Fe.Optional).exhaustive()}mapToAttribute(e){const n={id:this.mapToGlobalAttributeId(e.attributeId),isSatisfied:e.isSatisfied,canContributeToConfigurationSatisfaction:e.canContributeToConfigurationSatisfaction};return O(e).with({type:ot.Boolean},r=>({...n,type:it.Boolean,decision:c(r.decision,x(i=>({state:i.state,kind:this.mapToDecisionKind(i.kind)})),De),selection:this.mapToSelection(r.selection),possibleDecisionStates:r.possibleDecisionStates})).with({type:ot.Numeric},r=>({...n,type:it.Numeric,decision:c(r.decision,x(i=>({state:i.state,kind:this.mapToDecisionKind(i.kind)})),De),range:r.range,decimalPlaces:r.decimalPlaces,selection:this.mapToSelection(r.selection)})).with({type:ot.Choice},r=>({...n,type:it.Choice,cardinality:r.cardinality,values:c(r.values,b(i=>{const o=c(i.decision,x(a=>({state:this.mapToChoiceValueDecisionState(a.state),kind:this.mapToDecisionKind(a.kind)})),De);return{id:i.choiceValueId,possibleDecisionStates:c(i.possibleDecisionStates,b(a=>this.mapToChoiceValueDecisionState(a))),decision:o}}))})).with({type:ot.Component},r=>({...n,type:it.Component,decision:c(r.decision,x(i=>({state:this.mapToComponentDecisionState(i.state),kind:this.mapToDecisionKind(i.kind)})),De),possibleDecisionStates:c(r.possibleDecisionStates,b(i=>this.mapToComponentDecisionState(i))),selection:c(r.selection,V,x(i=>this.mapToSelection(i)),yt),inclusion:this.mapToInclusion(r.inclusion)})).exhaustive()}mapToInclusion(e){return O(e).with(ze.Always,()=>Ge.Always).with(ze.Optional,()=>Ge.Optional).exhaustive()}mapToComponentDecisionState(e){return O(e).with(It.Included,()=>Me.Included).with(It.Excluded,()=>Me.Excluded).exhaustive()}mapToChoiceValueDecisionState(e){return O(e).with(It.Included,()=>be.Included).with(It.Excluded,()=>be.Excluded).exhaustive()}mapToDecisionKind(e){return O(e).with(St.Explicit,()=>Se.Explicit).with(St.Implicit,()=>Se.Implicit).exhaustive()}mapToUsageRuleParameters(e){return e}},qa=class{constructor(e,n){this.contractToDomainMapper=new Qf,this.domainToContractMapper=new $a,this.sessionHandler=e,this.internalConfigurationSessionCreator=n}async createSession(e){const n=this.configurationSessionFrom(e);return await c(this.sessionHandler.recreate(n),Tt(r=>{const i=this.internalConfigurationSessionCreator(this.sessionHandler,r);return new Yf(i,this.contractToDomainMapper,this.domainToContractMapper)}),Sr(r=>{const i=this.domainToContractMapper.mapToFailureResult(r);return Promise.reject(i)},r=>Promise.resolve(r)))()}configurationSessionFrom(e){return{context:this.contractToDomainMapper.mapToSessionContext(e),sessionId:R,configuration:{isSatisfied:!1,attributes:[]},solutions:[]}}};function Wi(t){return t.possibleDecisionStates.some(e=>e===be.Included)}function Pa(t){return!Wi(t)}const Zf=Object.freeze(Object.defineProperty({__proto__:null,isAllowed:Wi,isBlocked:Pa},Symbol.toStringTag,{value:"Module"}));function td(t){return O(t).with({type:it.Choice},e=>e.cardinality.lowerBound>0).otherwise(()=>!0)}function ed(t){return O(t).with({type:it.Choice},e=>e.cardinality.upperBound>1).otherwise(()=>!1)}function nd(t){return c(t.values,Gt(Wi))}function rd(t){return c(t.values,Gt(Pa))}function Ra(t,e){return c(t.values,hn(n=>c(n.decision,V,At(r=>r.kind===e))))}function ja(t){return c(t.values,Gt(e=>c(e.decision,V,x(n=>n.state===be.Included),st(()=>!1))))}const id=ja;function Ua(t){return c(t.decision,V,At(e=>e.kind===Se.Explicit),De)}function ka(t){return c(t.decision,V,At(e=>e.kind===Se.Explicit),De)}function od(t,e){return t.possibleDecisionStates.some(n=>n===e)}function Ba(t){return c(t.decision,V,De)}function Va(t){return Fa(t,Me.Included)}function ad(t){return!Va(t)}function Fa(t,e){return t.possibleDecisionStates.some(n=>n===e)}const sd=Object.freeze(Object.defineProperty({__proto__:null,getAllowedChoiceValues:nd,getBlockedChoiceValues:rd,getBooleanDecision:ka,getChoiceDecisions:Ra,getComponentDecision:Ba,getIncludedChoiceValues:ja,getNumericDecision:Ua,getSelectedChoiceValues:id,isBooleanValuePossible:od,isComponentAllowed:Va,isComponentBlocked:ad,isComponentStatePossible:Fa,isMandatory:td,isMultiSelect:ed},Symbol.toStringTag,{value:"Module"})),Ga=t=>t.type===it.Boolean,La=t=>t.type===it.Choice,za=t=>t.type===it.Numeric,Ha=t=>t.type===it.Component,ud=Wn(ht);function cd(t,e,n){var r;const i=((r=e.componentPath)==null?void 0:r.length)??0;return c(t,Gt(o=>{var a;const u=((a=o.id.componentPath)==null?void 0:a.length)??0;return n?i>u?!1:c(o.id.componentPath??[],sa(e.componentPath??[]),Pc(([s,l])=>s===l)):ud.equals(o.id.componentPath,e.componentPath)}))}function ld(t,e,n){return[]}function fd(t){return c(t,Gt(e=>{const n=c(e.id.componentPath,V,x(i=>i.length===0),st(()=>!0)),r=c(e.id.sharedConfigurationModelId,V,me(()=>!0,()=>!1));return n&&r}))}function dd(t,e){return c(Wa(t),b(n=>Ra(n,e)),la,hn(n=>V(n)))}function hd(t,e){return c(Ja(t),Gt(n=>{var r;return((r=n.decision)==null?void 0:r.kind)===e}),b(n=>Ua(n)),hn(n=>V(n)))}function pd(t,e){return c(Xa(t),Gt(n=>{var r;return((r=n.decision)==null?void 0:r.kind)===e}),b(n=>ka(n)),hn(n=>V(n)))}function vd(t,e){return c(Ka(t),Gt(n=>{var r;return((r=n.decision)==null?void 0:r.kind)===e}),b(n=>Ba(n)),hn(n=>V(n)))}function Wa(t){return c(t.attributes,Gt(La))}function Ka(t){return c(t.attributes,Gt(Ha))}function Ja(t){return c(t.attributes,Gt(za))}function Xa(t){return c(t.attributes,Gt(Ga))}function yd(t,e){return c(Kn(t,e),yt)}function md(t,e){return c(Ya(t,e),yt)}function gd(t,e,n){return c(Ya(t,e),x(r=>r.values),Xt(ne(_t(r=>r.id===n))),yt)}function bd(t,e){return c(Kn(t,e),At(za),yt)}function Sd(t,e){return c(Kn(t,e),At(Ga),yt)}function Cd(t,e){return c(Kn(t,e),At(Ha),yt)}function Kn(t,e){return c(t.attributes,_t(n=>Xe.equals(n.id,e)))}function Ya(t,e){return c(Kn(t,e),At(La))}const wd=Object.freeze(Object.defineProperty({__proto__:null,filterAttributesOfComponent:cd,filterAttributesOfRoot:fd,filterAttributesOfShared:ld,getAttribute:yd,getBooleanAttribute:Sd,getBooleanAttributes:Xa,getBooleanDecisions:pd,getChoiceAttribute:md,getChoiceAttributes:Wa,getChoiceDecisions:dd,getChoiceValue:gd,getComponentAttribute:Cd,getComponentAttributes:Ka,getComponentDecisions:vd,getNumericAttribute:bd,getNumericAttributes:Ja,getNumericDecisions:hd},Symbol.toStringTag,{value:"Module"})),Qa={whyIsNotSatisfied:{configuration:{question:Rt.whyIsNotSatisfied,subject:jt.configuration},attribute:t=>({question:Rt.whyIsNotSatisfied,subject:jt.attribute,attributeId:t})},whyIsStateNotPossible:{choice:t=>({choiceValue:e=>({state:n=>({question:Rt.whyIsStateNotPossible,subject:jt.choiceValue,attributeId:t,choiceValueId:e,state:n})})}),boolean:t=>({state:e=>({question:Rt.whyIsStateNotPossible,subject:jt.boolean,attributeId:t,state:e})}),numeric:t=>({state:e=>({question:Rt.whyIsStateNotPossible,subject:jt.numeric,attributeId:t,state:e})}),component:t=>({state:e=>({question:Rt.whyIsStateNotPossible,subject:jt.component,attributeId:t,state:e})})}},Td=Object.freeze(Object.defineProperty({__proto__:null,explainQuestionBuilder:Qa},Symbol.toStringTag,{value:"Module"})),Id="https://spc.cloud.ceventis.de/api/engine",Ed={hcaEngineBaseUrl:Id};function xd(t){return{hcaEngineBaseUrl:t.hcaEngineBaseUrl??Ed.hcaEngineBaseUrl,sessionHandler:t.sessionHandler}}function En(t){if(t==null)throw new Error("Implementation Error: Unexpected null value encountered");return t}const Za=t=>e=>n=>c(n,xc(r=>t.equals(r,e)),x(r=>c(n,Ac(r,i=>e))),li,st(()=>c(n,L(Nc(e))))),ir=Za({equals:(t,e)=>Pt.equals(t.attributeId,e.attributeId)}),Ad=Za({equals:(t,e)=>t.choiceValueId===e.choiceValueId});let Dd=class{constructor(e){this.restToDomainMapper=e}updateConfigurationSession(e,n){const r=this.updateConfigurationModel(e.configuration,n);return{...e,configuration:r}}updateConfigurationModel(e,n){var r,i,o,a,u,s,l,f,h;const d=c(((r=n.affectedDecisions)==null?void 0:r.choiceValueDecisions)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),y=c(((i=n.consequences)==null?void 0:i.choiceConsequences)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),m=c(((o=n.affectedDecisions)==null?void 0:o.componentDecisions)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),v=c(((a=n.consequences)==null?void 0:a.componentConsequences)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),w=c(((u=n.affectedDecisions)==null?void 0:u.numericDecisions)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),E=c(((s=n.consequences)==null?void 0:s.numericConsequences)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),C=c(((l=n.affectedDecisions)==null?void 0:l.booleanDecisions)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),S=c(((f=n.consequences)==null?void 0:f.booleanConsequences)??[],b(g=>({attributeId:this.restToDomainMapper.mapToGlobalAttributeId(g.attributeId),payload:g}))),I=c([],L(c(C,b(g=>g.attributeId))),L(c(S,b(g=>g.attributeId))),L(c(w,b(g=>g.attributeId))),L(c(E,b(g=>g.attributeId))),L(c(d,b(g=>g.attributeId))),L(c(y,b(g=>g.attributeId))),L(c(m,b(g=>g.attributeId))),L(c(v,b(g=>g.attributeId))),an(Pt)),P=c(I,fi(e.attributes,(g,N)=>{const F=e.attributes.find($=>Pt.equals($.attributeId,N));return O(F).with({type:ot.Choice},($,z)=>{const q=this.mergeChoice(z,c(y,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)),c(d,Gt(D=>Pt.equals(D.attributeId,N)),b(D=>D.payload)));return ir(q)(g)}).with({type:ot.Numeric},($,z)=>{const q=this.mergeNumeric(z,c(E,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)),c(w,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)));return ir(q)(g)}).with({type:ot.Boolean},($,z)=>{const q=this.mergeBoolean(z,c(S,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)),c(C,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)));return ir(q)(g)}).with({type:ot.Component},($,z)=>{const q=this.mergeComponent(z,c(v,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)),c(m,_t(D=>Pt.equals(D.attributeId,N)),x(D=>D.payload)));return ir(q)(g)}).exhaustive()}));return{...e,isSatisfied:c((h=n.consequences)==null?void 0:h.isConfigurationSatisfied,V,st(()=>e.isSatisfied)),attributes:P}}mergeChoice(e,n,r){const i=c(n,x(s=>s.values??[]),st(()=>[])),o=c(r),a=c([],L(c(i,b(s=>s.choiceValueId))),L(c(o,b(s=>s.choiceValueId))),b(En),an(ht)),u=c(a,fi(e.values,(s,l)=>{const f=c(i,_t(m=>m.choiceValueId===l)),h=c(o,_t(m=>m.choiceValueId===l)),d=c(e.values.find(m=>m.choiceValueId===l),V),y=this.mergeChoiceValue(l,d,f,h);return Ad(y)(s)}));return{...e,isSatisfied:c(n,x(s=>En(s.isSatisfied)),st(()=>e.isSatisfied)),values:u}}mergeChoiceValue(e,n,r,i){const o=c(i,x(u=>({state:this.toDecisionState(En(u.state)),kind:this.toDecisionKind(En(u.kind))})),st(()=>({state:c(n,Xt(u=>c(u.decision,x(s=>s.state)))),kind:c(n,Xt(u=>c(u.decision,x(s=>s.kind))),st(()=>St.Explicit))}))),a=c(r,x(u=>c(mo(u.possibleDecisionStates??[]),b(s=>this.toPossibleDecisionState(s)),se)),st(()=>c(n,x(u=>u.possibleDecisionStates??[]),st(()=>[]))));return{choiceValueId:e,decision:c(o.state,x(u=>({state:u,kind:o.kind}))),possibleDecisionStates:a}}mergeComponent(e,n,r){const i=c(r,x(a=>{const u=this.toDecisionState(En(a.state));return c(u,x(s=>({state:s,kind:this.toDecisionKind(a.kind)})))}),st(()=>c(e.decision,x(a=>({state:a.state,kind:a.kind}))))),o=c(n,x(a=>c(mo(a.possibleDecisionStates??[]),b(u=>this.toPossibleDecisionState(u)),se)),st(()=>e.possibleDecisionStates));return{...e,isSatisfied:c(n,x(a=>a.isSatisfied),st(()=>e.isSatisfied)),possibleDecisionStates:o,decision:i}}mergeNumeric(e,n,r){return{...e,isSatisfied:c(n,Xt(i=>V(i.isSatisfied)),st(()=>e.isSatisfied)),decision:c(r,me(()=>e.decision,i=>c(i.state,V,x(o=>({kind:this.toDecisionKind(i.kind),state:o})))))}}mergeBoolean(e,n,r){return{...e,isSatisfied:c(n,Xt(i=>V(i.isSatisfied)),st(()=>e.isSatisfied)),decision:c(r,me(()=>e.decision,i=>c(i.state,V,x(o=>({kind:this.toDecisionKind(i.kind),state:o}))))),possibleDecisionStates:c(n,x(i=>i.possibleDecisionStates),st(()=>e.possibleDecisionStates))}}toPossibleDecisionState(e){return O(e).with(He.Included,()=>J(It.Included)).with(He.Excluded,()=>J(It.Excluded)).otherwise(()=>R)}toDecisionState(e){return O(e).with(ve.Included,()=>J(It.Included)).with(ve.Excluded,()=>J(It.Excluded)).otherwise(()=>R)}toDecisionKind(e){return O(e).with(Vn.Implicit,()=>St.Implicit).with(Vn.Explicit,()=>St.Explicit).exhaustive()}},Od=class{mapSessionToExplicitDecisions(e){return this.mapToExplicitDecisionsInner(e.configuration.attributes)}mapToExplicitDecision(e){return O(e).with({type:B.ChoiceValue},n=>({type:Ht.Choice,attributeId:this.mapToGlobalAttributeId(n.attributeId),choiceValueId:n.choiceValueId,state:this.mapToDecisionState(n.state)})).with({type:B.Component},n=>({type:Ht.Component,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:this.mapToDecisionState(n.state)})).with({type:B.Numeric},n=>({type:Ht.Numeric,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(n.value,yt)})).with({type:B.Boolean},n=>({type:Ht.Boolean,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:c(n.value,yt)})).exhaustive()}mapToExplicitDecisions(e,n){const r=this.mapToMode(n),i=c([...e],Ie(s=>s.type!==B.Boolean?R:J({type:Ht.Boolean,attributeId:this.mapToGlobalAttributeId(s.attributeId),state:c(s.value,yt)}))),o=c([...e],Ie(s=>s.type!==B.Numeric?R:J({type:Ht.Numeric,attributeId:this.mapToGlobalAttributeId(s.attributeId),state:c(s.value,yt)}))),a=c([...e],Ie(s=>s.type!==B.ChoiceValue?R:J({type:Ht.Choice,attributeId:this.mapToGlobalAttributeId(s.attributeId),choiceValueId:s.choiceValueId,state:this.mapToDecisionState(s.state)}))),u=c([...e],Ie(s=>s.type!==B.Component?R:J({type:Ht.Component,attributeId:this.mapToGlobalAttributeId(s.attributeId),state:this.mapToDecisionState(s.state)})));return{mode:r,choiceDecisions:a,numericDecisions:o,booleanDecisions:i,componentDecisions:u}}mapToExplicitDecisionsInner(e){const n=c([...e],Ie(a=>a.type!==ot.Boolean?R:c(a.decision,At(u=>u.kind===St.Explicit),x(()=>this.mapToExplicitBooleanDecision(a))))),r=c([...e],Ie(a=>a.type!==ot.Numeric?R:c(a.decision,At(u=>u.kind===St.Explicit),x(()=>this.mapToExplicitNumericDecision(a))))),i=c([...e],Ie(a=>a.type!==ot.Component?R:c(a.decision,At(u=>u.kind===St.Explicit),x(()=>this.mapToExplicitComponentDecision(a))))),o=c([...e],Ie(a=>a.type!==ot.Choice?R:c(this.mapToExplicitChoiceDecisions(a),rc(u=>c(u,qr)))),Hc);return{booleanDecisions:n,numericDecisions:r,choiceDecisions:o,componentDecisions:i}}mapToMode(e){return O(e).with({type:"Default"},n=>({type:"Default"})).with({type:"DropExistingDecisions"},n=>this.mapToDropExistingDecisionsMode(n)).exhaustive()}mapToGlobalAttributeId(e){return{localId:e.localId,componentPath:c(e.componentPath,V,x(yo),De),sharedConfigurationModelId:e.sharedConfigurationModel}}mapToDropExistingDecisionsMode(e){return{type:"DropExistingDecisions",conflictResolution:O(e.conflictHandling).with({type:"Manual",includeConstraintsInConflictExplanation:ft.boolean},n=>({type:"Manual",includeConstraintsInConflictExplanation:n.includeConstraintsInConflictExplanation})).otherwise(()=>({type:"Automatic"}))}}mapToExplicitBooleanDecision(e){return{type:Ht.Boolean,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:c(e.decision,x(n=>n.state),yt)}}mapToExplicitNumericDecision(e){return{type:Ht.Numeric,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:c(e.decision,x(n=>n.state),yt)}}mapToExplicitComponentDecision(e){return{type:Ht.Component,attributeId:this.mapToGlobalAttributeId(e.attributeId),state:this.mapToDecisionState(c(e.decision,x(n=>n.state)))}}mapToExplicitChoiceDecisions(e){function n(r){return c(r.decision,x(i=>i.kind===St.Explicit),st(()=>!1))}return c(e.values,Gt(n),b(r=>({type:Ht.Choice,attributeId:this.mapToGlobalAttributeId(e.attributeId),choiceValueId:r.choiceValueId,state:this.mapToDecisionState(c(r.decision,x(i=>i.state)))})),yo)}mapToDecisionState(e){return c(e,x(n=>O(n).with(It.Included,()=>ve.Included).with(It.Excluded,()=>ve.Excluded).exhaustive()),st(()=>ve.Undefined))}mapToPossibleDecisionState(e){return O(e).with(It.Included,()=>He.Included).with(It.Excluded,()=>He.Excluded).exhaustive()}mapToWhyNotSatisfiedRequest(e){return O(e).with({subject:Mt.attribute},n=>({type:gi.Attribute,attributeId:this.mapToGlobalAttributeId(n.attributeId)})).with({subject:Mt.configuration},()=>({type:gi.Configuration})).exhaustive()}mapToWhyStateNotPossibleRequest(e){return O(e).with({subject:Mt.boolean},n=>({type:On.Boolean,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:n.state})).with({subject:Mt.numeric},n=>({type:On.Numeric,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:n.state})).with({subject:Mt.component},n=>({type:On.Component,attributeId:this.mapToGlobalAttributeId(n.attributeId),state:this.mapToPossibleDecisionState(n.state)})).with({subject:Mt.choiceValue},n=>({type:On.ChoiceValue,attributeId:this.mapToGlobalAttributeId(n.attributeId),choiceValueId:n.choiceValueId,state:this.mapToPossibleDecisionState(n.state)})).exhaustive()}},Nd=class{constructor(){this.configurationSession={hasExplicitDecisions(e){return c(e.configuration.attributes,_t(n=>O(n).with({type:ot.Boolean},r=>c(r.decision,At(i=>i.kind===St.Explicit),Dn)).with({type:ot.Numeric},r=>c(r.decision,At(i=>i.kind===St.Explicit),Dn)).with({type:ot.Choice},r=>c(r.values,_t(i=>c(i.decision,x(o=>o.kind===St.Explicit),st(()=>!1))),Dn)).with({type:ot.Component},r=>c(r.decision,At(i=>i.kind===St.Explicit),Dn)).exhaustive()),me(()=>!1,()=>!0))},getExplicitDecisions(e){return c(e.configuration.attributes,b(n=>O(n).with({type:ot.Boolean},r=>c(r.decision,At(i=>i.kind===St.Explicit),x(i=>({type:B.Boolean,attributeId:r.attributeId,value:V(i.state)})),x(i=>[i]))).with({type:ot.Numeric},r=>c(r.decision,At(i=>i.kind===St.Explicit),x(i=>({type:B.Numeric,attributeId:r.attributeId,value:V(i.state)})),x(i=>[i]))).with({type:ot.Choice},r=>c(r.values,b(i=>c(i.decision,At(o=>o.kind===St.Explicit),x(o=>({type:B.ChoiceValue,attributeId:r.attributeId,choiceValueId:i.choiceValueId,state:V(o.state)})))),se,Oe)).with({type:ot.Component},r=>c(r.decision,At(i=>i.kind===St.Explicit),x(i=>({type:B.Component,attributeId:r.attributeId,state:V(i.state)})),x(i=>[i]))).exhaustive()),se,la)}}}},_d=class{constructor(e,n,r,i,o,a){this.engineApiClient=n,this.domainToRestMapper=i,this.restToDomainMapper=r,this.domainToContractMapper=o,this.domainUpdater=a,this.sessionHandler=e,this.interpreter=new Nd}close(e){return this.sessionHandler.close(e)}recreate(e){return this.initializeInner(e,!1)}reinitialize(e){return this.initializeInner(e,!0)}makeDecision(e,n){const r=this.domainToRestMapper.mapToExplicitDecision(e);return this.withSession(n,(i,o)=>c(this.engineApiClient.makeDecision(i,r),ee(he),Tt(a=>this.domainUpdater.updateConfigurationSession(o,a))))}explain(e,n){return this.withSession(n,r=>{const i=O(e).with({question:Kt.whyIsNotSatisfied},o=>this.explainWhyNotSatisfied(o,r)).with({question:Kt.whyIsStateNotPossible},o=>this.explainWhyStateNotPossible(o,r)).exhaustive();return c(i,ee(he),Tt(o=>this.restToDomainMapper.mapToExplainAnswer(o,e)))})}setMany(e,n,r){return this.withSession(r,(i,o)=>{const a=this.setManyInner(e,n,i);return c(a,te(u=>{var s,l,f,h;const d=c([],L(c(((s=u.rejectedDecisions)==null?void 0:s.booleanDecisions)??[],b(y=>this.restToDomainMapper.mapToBooleanDecision(y)))),L(c(((l=u.rejectedDecisions)==null?void 0:l.numericDecisions)??[],b(y=>this.restToDomainMapper.mapToNumericDecision(y)))),L(c(((f=u.rejectedDecisions)==null?void 0:f.componentDecisions)??[],b(y=>this.restToDomainMapper.mapToComponentDecision(y)))),L(c(((h=u.rejectedDecisions)==null?void 0:h.choiceValueDecisions)??[],b(y=>this.restToDomainMapper.mapToExplicitChoiceValueDecision(y)))));return c(d,qr)?pe(Bf.createConfigurationRejectedDecisionsConflict(d)):sn(this.domainUpdater.updateConfigurationSession(o,u))}))})}replaceDecisions(e,n){const r=this.interpreter.configurationSession.getExplicitDecisions(n),i=this.setManyInner(r,{type:"DropExistingDecisions",conflictHandling:{type:"Automatic"}},e);return c(i,Tt(o=>({})))}setManyInner(e,n,r){const i=this.domainToRestMapper.mapToExplicitDecisions(e,n),o=this.engineApiClient.setMany(r,i);return c(o,ee(he),te(a=>{const u={rejectedDecisions:{booleanDecisions:ft.array(ft.any)}},s={decisionExplanations:ft.array(ft.any)};return O(a).with(u,l=>pn(l)).with(s,l=>pe(this.restToDomainMapper.mapToConfigurationSetManyConflictFailure(l,i,n))).otherwise(()=>pe({type:j.Unknown}))}))}explainWhyStateNotPossible(e,n){const r=this.domainToRestMapper.mapToWhyStateNotPossibleRequest(e);return this.engineApiClient.getWhyStateNotPossible(n,r)}explainWhyNotSatisfied(e,n){const r=this.domainToRestMapper.mapToWhyNotSatisfiedRequest(e);return this.engineApiClient.getWhyNotSatisfied(n,r)}withSession(e,n){return c(sn(e),te(r=>c(r.sessionId,me(()=>this.initializeInner(r,!1),()=>sn(r)))),te(r=>c(r.sessionId,Li(()=>({type:j.ConfigurationUnauthenticated})),te(i=>n(i,r)))))}initializeInner(e,n){return c(Dl,()=>c(e.sessionId,sf,cf(r=>n?af(r):c(this.sessionHandler.close(r),Sr(()=>R,()=>R)))),r=>{const i=this.domainToContractMapper.mapToSessionContext(e.context);return c(r,wl(()=>({type:j.ConfigurationUnauthenticated})),ya(()=>this.sessionHandler.create(i)))},r=>c(r,Ol(i=>c(Oe(e),At(this.interpreter.configurationSession.hasExplicitDecisions),x(o=>this.replaceDecisions(i,o)),st(()=>sn({}))))),r=>c(r,te(i=>{const o=this.determineConsequences(i),a=this.determineDecisions(i),u=zu(El)({consequences:o,decisions:a});return c(u,Tt(({decisions:s,consequences:l})=>this.restToDomainMapper.mapToConfigurationModel(s,l)),Tt(s=>({sessionId:Oe(i),configuration:s,context:e.context,solutions:[]})))})))}determineDecisions(e){return c(this.engineApiClient.getDecisions(e),ee(he))}determineConsequences(e){return c(this.engineApiClient.getConsequence(e),ee(he))}},Md=class{constructor(e,n){this.onConfigurationChangedHandler=R,this.sessionHandler=e,this.configurationSession=n}setOnConfigurationChangedHandler(e){this.onConfigurationChangedHandler=e}getSessionContext(){return this.configurationSession.context}getConfiguration(){return this.configurationSession.configuration}explain(e){return c(this.sessionHandler.explain(e,this.configurationSession),this.updateAvailableSolutionsIfRight(n=>this.deriveSolutionsFromExplainAnswer(n)),this.invalidateAvailableSolutionsIfLeft())}setSessionContext(e){return c(this.sessionHandler.recreate({...this.configurationSession,context:e}),this.updateSession())}invalidateSessionId(){this.configurationSession={...this.configurationSession,sessionId:R}}restoreConfiguration(e){return c(this.sessionHandler.reinitialize({...this.configurationSession,configuration:e}),this.updateSession())}makeDecision(e){return c(this.sessionHandler.makeDecision(e,this.configurationSession),this.updateSession())}close(){return c(this.configurationSession.sessionId,x(e=>this.sessionHandler.close(e)),x(ne(Tt(e=>{this.configurationSession={...this.configurationSession,sessionId:R}}))),st(Dr(Of())))}applySolution(e){return c(this.configurationSession.solutions,_t(n=>Uf.equals(n,e)),Li(()=>({type:j.ConfigurationSolutionNotAvailable})),Tt(n=>n.decisions),te(n=>this.setMany(n,e.mode)))}setMany(e,n){return c(this.sessionHandler.setMany(e,n,this.configurationSession),this.updateSession(),Cr(r=>()=>{const i=O(r).with({decisionExplanations:ft.array(ft.any)},o=>J(o.decisionExplanations)).otherwise(()=>R);this.configurationSession={...this.configurationSession,solutions:c(i,x(ne(b(o=>o.solution))),st(()=>[]))}}))}deriveSolutionsFromExplainAnswer(e){const n=O(e).with({decisionExplanations:ft.array(ft.any)},r=>r.decisionExplanations).otherwise(()=>[]);return c(n,b(r=>r.solution))}invalidateAvailableSolutions(){return bf(()=>()=>{this.configurationSession={...this.configurationSession,solutions:[]}})}invalidateAvailableSolutionsIfLeft(){return Cr(()=>()=>{this.configurationSession={...this.configurationSession,solutions:[]}})}updateAvailableSolutionsIfRight(e){return Un(n=>()=>{this.configurationSession={...this.configurationSession,solutions:e(n)}})}updateSession(){return ne(Un(e=>()=>{this.configurationSession=e,c(this.onConfigurationChangedHandler,Cf(n=>()=>n(this.configurationSession.configuration)))}),Tt(e=>e.configuration),this.invalidateAvailableSolutions())}},$d=class{constructor(e){this.inner=e;const n=3,r=2e3,i=200;this.policy=hf(r,ff.concat(pf(i),df(n)))}getSessionContext(){return this.inner.getSessionContext()}close(){return this.inner.close()}setSessionContext(e){const n=()=>this.inner.setSessionContext(e);return Qe(this.policy,n,r=>c(r,ke(i=>this.determineAndPrepareRetry(i),()=>!1)))}makeDecision(e){const n=()=>this.inner.makeDecision(e);return Qe(this.policy,n,r=>c(r,ke(i=>this.determineAndPrepareRetry(i),()=>!1)))}restoreConfiguration(e){const n=()=>this.inner.restoreConfiguration(e);return Qe(this.policy,n,r=>c(r,ke(i=>this.determineAndPrepareRetry(i),()=>!1)))}explain(e){const n=()=>this.inner.explain(e);return Qe(this.policy,n,r=>c(r,ke(i=>this.determineAndPrepareRetry(i),()=>!1)))}applySolution(e){const n=()=>this.inner.applySolution(e);return Qe(this.policy,n,r=>c(r,ke(i=>this.determineAndPrepareRetry(i),()=>!1)))}setMany(e,n){const r=()=>this.inner.setMany(e,n);return Qe(this.policy,r,i=>c(i,ke(o=>this.determineAndPrepareRetry(o),()=>!1)))}setOnConfigurationChangedHandler(e){this.inner.setOnConfigurationChangedHandler(e)}invalidateSessionId(){this.inner.invalidateSessionId()}getConfiguration(){return this.inner.getConfiguration()}determineAndPrepareRetry(e){return O(e).with({type:j.ConfigurationUnauthenticated},()=>(this.invalidateSessionId(),!0)).with({type:j.ConfigurationTimeout},()=>!0).otherwise(()=>!1)}},qd=class{constructor(){this.queue=[],this.operating=R}push(e){const n=new Pd(e);return this.queue.push(n),this.operating=c(this.operating,st(()=>this.start()),Oe),n.promise}async start(){for(;this.queue.length;){const e=[...this.queue];this.queue=[];const n=c(e,b(r=>r.argument),fi(R,(r,i)=>this.reduce(r,i)),x(ne(r=>this.execute(r),r=>r.then(i=>{c(e,b(o=>{o.resolve(i)}))}).catch(i=>{c(e,b(o=>{o.reject(i)}))}))),yt);n&&await n}this.operating=R}async flush(){return this.operating||Promise.resolve()}size(){return this.queue.length}},Pd=class{constructor(e){this.resolve=()=>{},this.reject=()=>{},this.argument=e,this.promise=new Promise((n,r)=>{this.resolve=n,this.reject=r})}},Rd=class extends qd{constructor(e){super(),this.inner=e}reduce(e,n){return J(n)}async execute(e){return await this.inner.setSessionContext(e)()}},jd=class{constructor(e){this.inner=e,this.setContextReducingTaskExecutor=new Rd(e)}getSessionContext(){return this.inner.getSessionContext()}setSessionContext(e){const n=this.inner.getSessionContext();if(_f.equals(n,e))return pn(this.getConfiguration());const r=this.setContextReducingTaskExecutor.push(e);return()=>r}applySolution(e){return this.inner.applySolution(e)}close(){return this.inner.close()}makeDecision(e){return this.inner.makeDecision(e)}restoreConfiguration(e){return this.inner.restoreConfiguration(e)}setMany(e,n){return this.inner.setMany(e,n)}explain(e){return this.inner.explain(e)}invalidateSessionId(){return this.inner.invalidateSessionId()}getConfiguration(){return this.inner.getConfiguration()}setOnConfigurationChangedHandler(e){return this.inner.setOnConfigurationChangedHandler(e)}},Ud=class{constructor(e,n=!1){this.stringify=n,this.inner=e,this.durationNumberFormat=new Intl.NumberFormat("en-EN",{maximumFractionDigits:3})}withLogging(e,n,r){const i=performance.now(),o=()=>{const a=performance.now()-i;return this.durationNumberFormat.format(a)};return console.debug(`Operation ${e} started with`,this.renderAsRequired(n)),c(r(),Cr(a=>()=>{console.debug(`Operation ${e} completed after ${o()}ms with failure`,this.renderAsRequired(a))}),Un(a=>()=>{console.debug(`Operation ${e} completed after ${o()}ms with success`,this.renderAsRequired(a))}))}renderAsRequired(e){return this.stringify?JSON.stringify(e,null,2):e}explain(e){return this.withLogging("explain",[e],()=>this.inner.explain(e))}getSessionContext(){return this.inner.getSessionContext()}setSessionContext(e){return this.withLogging("setSessionContext",[e],()=>this.inner.setSessionContext(e))}applySolution(e){return this.withLogging("applySolution",[e],()=>this.inner.applySolution(e))}close(){return this.inner.close()}makeDecision(e){return this.withLogging("makeDecision",[e],()=>this.inner.makeDecision(e))}restoreConfiguration(e){return this.withLogging("restoreConfiguration",[e],()=>this.inner.restoreConfiguration(e))}setMany(e,n){return this.withLogging("setMany",[e,n],()=>this.inner.setMany(e,n))}invalidateSessionId(){return this.inner.invalidateSessionId()}getConfiguration(){return this.inner.getConfiguration()}setOnConfigurationChangedHandler(e){return this.inner.setOnConfigurationChangedHandler(e)}};function kd(t){t=xd(t);const e=new Xf(t.hcaEngineBaseUrl),n=new _a,r=new Od,i=new $a,o=new Aa,a=new Dd(n),u=O(t.sessionHandler).with({create:ft.any,close:ft.any},f=>f).with({accessToken:ft.string},f=>new Oa(e,o,n,f)).with({sessionCreateUrl:ft.string,sessionDeleteUrl:ft.string},f=>new Ma(o,f)).exhaustive(),s=new _d(u,e,n,r,i,a),l=(f,h)=>c(new Md(f,h),d=>new $d(d),d=>new jd(d),d=>new Ud(d,!1));return new qa(s,l)}const Bd=Xe.equals,Vd=Ia.equals,Fd=Ea.equals,Gd=Object.freeze(Object.defineProperty({__proto__:null,AllowedRulesInExplainType:kn,AttributeInterpreter:sd,AttributeType:it,ChoiceValueDecisionState:be,ChoiceValueInterpreter:Zf,ClientSideSessionLifetimeHandler:Oa,ComponentDecisionState:Me,ConfigurationConflictReason:Ur,ConfigurationInterpreter:wd,ConfigurationModelSourceType:ge,ConfiguratorClient:qa,ConstraintType:un,ContractToRestMapper:Aa,DecisionKind:Se,ExplainQuestionSubject:jt,ExplainQuestionType:Rt,FailureType:wt,Inclusion:Ge,QuestionBuilder:Td,Results:Af,Selection:Fe,ServerSideSessionLifetimeHandler:Ma,Types:xf,causedByDecisionEquals:Fd,createClient:kd,explainQuestionBuilder:Qa,globalAttributeIdEquals:Bd,globalConstraintIdEquals:Vd},Symbol.toStringTag,{value:"Module"}));function ts(t){return function(n,r,i,o,a,u,s){return t(n,r,s)}}function kr(t){return function(n,r,i,o){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i,o);var a=o.get(n),u=o.get(r);if(a&&u)return a===r&&u===n;o.set(n,r),o.set(r,n);var s=t(n,r,i,o);return o.delete(n),o.delete(r),s}}function es(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n}function Po(t){return t.constructor===Object||t.constructor==null}function Ro(t){return typeof t.then=="function"}function Br(t,e){return t===e||t!==t&&e!==e}var Ld="[object Arguments]",zd="[object Boolean]",Hd="[object Date]",Wd="[object RegExp]",Kd="[object Map]",Jd="[object Number]",Xd="[object Object]",Yd="[object Set]",Qd="[object String]",jo=Object.prototype.toString;function Vr(t){var e=t.areArraysEqual,n=t.areDatesEqual,r=t.areMapsEqual,i=t.areObjectsEqual,o=t.areRegExpsEqual,a=t.areSetsEqual,u=t.createIsNestedEqual,s=u(l);function l(f,h,d){if(f===h)return!0;if(!f||!h||typeof f!="object"||typeof h!="object")return f!==f&&h!==h;if(Po(f)&&Po(h))return i(f,h,s,d);var y=Array.isArray(f),m=Array.isArray(h);if(y||m)return y===m&&e(f,h,s,d);var v=jo.call(f);return v!==jo.call(h)?!1:v===Hd?n(f,h,s,d):v===Wd?o(f,h,s,d):v===Kd?r(f,h,s,d):v===Yd?a(f,h,s,d):v===Xd||v===Ld?Ro(f)||Ro(h)?!1:i(f,h,s,d):v===zd||v===Jd||v===Qd?Br(f.valueOf(),h.valueOf()):!1}return l}function ns(t,e,n,r){var i=t.length;if(e.length!==i)return!1;for(;i-- >0;)if(!n(t[i],e[i],i,i,t,e,r))return!1;return!0}var Zd=kr(ns);function rs(t,e){return Br(t.valueOf(),e.valueOf())}function is(t,e,n,r){var i=t.size===e.size;if(!i)return!1;if(!t.size)return!0;var o={},a=0;return t.forEach(function(u,s){if(i){var l=!1,f=0;e.forEach(function(h,d){!l&&!o[f]&&(l=n(s,d,a,f,t,e,r)&&n(u,h,s,d,t,e,r))&&(o[f]=!0),f++}),a++,i=l}}),i}var th=kr(is),eh="_owner",nh=Object.prototype.hasOwnProperty;function os(t,e,n,r){var i=Object.keys(t),o=i.length;if(Object.keys(e).length!==o)return!1;for(var a;o-- >0;){if(a=i[o],a===eh){var u=!!t.$$typeof,s=!!e.$$typeof;if((u||s)&&u!==s)return!1}if(!nh.call(e,a)||!n(t[a],e[a],a,a,t,e,r))return!1}return!0}var rh=kr(os);function as(t,e){return t.source===e.source&&t.flags===e.flags}function ss(t,e,n,r){var i=t.size===e.size;if(!i)return!1;if(!t.size)return!0;var o={};return t.forEach(function(a,u){if(i){var s=!1,l=0;e.forEach(function(f,h){!s&&!o[l]&&(s=n(a,f,u,h,t,e,r))&&(o[l]=!0),l++}),i=s}}),i}var ih=kr(ss),us=Object.freeze({areArraysEqual:ns,areDatesEqual:rs,areMapsEqual:is,areObjectsEqual:os,areRegExpsEqual:as,areSetsEqual:ss,createIsNestedEqual:ts}),cs=Object.freeze({areArraysEqual:Zd,areDatesEqual:rs,areMapsEqual:th,areObjectsEqual:rh,areRegExpsEqual:as,areSetsEqual:ih,createIsNestedEqual:ts}),oh=Vr(us);function ah(t,e){return oh(t,e,void 0)}Vr(es(us,{createIsNestedEqual:function(){return Br}}));Vr(cs);Vr(es(cs,{createIsNestedEqual:function(){return Br}}));/*! *****************************************************************************
|
|
5
|
+
Copyright (c) Microsoft Corporation.
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
+
purpose with or without fee is hereby granted.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
13
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
+
***************************************************************************** */var T=function(){return T=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},T.apply(this,arguments)};function Ki(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function K(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(u){a={error:u}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return o}function lt(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}var at;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(at||(at={}));var We;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(We||(We={}));var bi=at.Start,Ji=at.Stop,Jn=at.Raise,Fr=at.Send,ls=at.Cancel,sh=at.NullEvent,Xi=at.Assign;at.After;at.DoneState;var fs=at.Log,uh=at.Init,Si=at.Invoke;at.ErrorExecution;var Uo=at.ErrorPlatform,ch=at.ErrorCustom,ds=at.Update,lh=at.Choose,fh=at.Pure,hs=".",ko={},Ci="xstate.guard",dh="",vt=process.env.NODE_ENV==="production",or;function Yi(t,e,n){n===void 0&&(n=hs);var r=Rn(t,n),i=Rn(e,n);return Z(i)?Z(r)?i===r:!1:Z(r)?r in i:Object.keys(r).every(function(o){return o in i?Yi(r[o],i[o]):!1})}function ps(t){try{return Z(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function wi(t,e){try{return yn(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function hh(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function Rn(t,e){if(hh(t))return t.value;if(yn(t))return wr(t);if(typeof t!="string")return t;var n=wi(t,e);return wr(n)}function wr(t){if(t.length===1)return t[0];for(var e={},n=e,r=0;r<t.length-1;r++)r===t.length-2?n[t[r]]=t[r+1]:(n[t[r]]={},n=n[t[r]]);return e}function Nn(t,e){for(var n={},r=Object.keys(t),i=0;i<r.length;i++){var o=r[i];n[o]=e(t[o],o,t,i)}return n}function Bo(t,e,n){var r,i,o={};try{for(var a=K(Object.keys(t)),u=a.next();!u.done;u=a.next()){var s=u.value,l=t[s];n(l)&&(o[s]=e(l,s,t))}}catch(f){r={error:f}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}var ph=function(t){return function(e){var n,r,i=e;try{for(var o=K(t),a=o.next();!a.done;a=o.next()){var u=a.value;i=i[u]}}catch(s){n={error:s}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}};function vh(t,e){return function(n){var r,i,o=n;try{for(var a=K(t),u=a.next();!u.done;u=a.next()){var s=u.value;o=o[e][s]}}catch(l){r={error:l}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}}function hr(t){if(!t)return[[]];if(Z(t))return[[t]];var e=pt(Object.keys(t).map(function(n){var r=t[n];return typeof r!="string"&&(!r||!Object.keys(r).length)?[[n]]:hr(t[n]).map(function(i){return[n].concat(i)})}));return e}function pt(t){var e;return(e=[]).concat.apply(e,lt([],Q(t),!1))}function vs(t){return yn(t)?t:[t]}function Zt(t){return t===void 0?[]:vs(t)}function Tr(t,e,n){var r,i;if(nt(t))return t(e,n.data);var o={};try{for(var a=K(Object.keys(t)),u=a.next();!u.done;u=a.next()){var s=u.value,l=t[s];nt(l)?o[s]=l(e,n.data):o[s]=l}}catch(f){r={error:f}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}function yh(t){return/^(done|error)\./.test(t)}function Vo(t){return!!(t instanceof Promise||t!==null&&(nt(t)||typeof t=="object")&&nt(t.then))}function mh(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function gh(t,e){var n,r,i=Q([[],[]],2),o=i[0],a=i[1];try{for(var u=K(t),s=u.next();!s.done;s=u.next()){var l=s.value;e(l)?o.push(l):a.push(l)}}catch(f){n={error:f}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return[o,a]}function ys(t,e){return Nn(t.states,function(n,r){if(n){var i=(Z(e)?void 0:e[r])||(n?n.current:void 0);if(i)return{current:i,states:ys(n,i)}}})}function bh(t,e){return{current:e,states:ys(t,e)}}function Fo(t,e,n,r){vt||xt(!!t,"Attempting to update undefined context");var i=t&&n.reduce(function(o,a){var u,s,l=a.assignment,f={state:r,action:a,_event:e},h={};if(nt(l))h=l(o,e.data,f);else try{for(var d=K(Object.keys(l)),y=d.next();!y.done;y=d.next()){var m=y.value,v=l[m];h[m]=nt(v)?v(o,e.data,f):v}}catch(w){u={error:w}}finally{try{y&&!y.done&&(s=d.return)&&s.call(d)}finally{if(u)throw u.error}}return Object.assign({},o,h)},t);return i}var xt=function(){};vt||(xt=function(t,e){var n=t instanceof Error?t:void 0;if(!(!n&&t)&&console!==void 0){var r=["Warning: ".concat(e)];n&&r.push(n),console.warn.apply(console,r)}});function yn(t){return Array.isArray(t)}function nt(t){return typeof t=="function"}function Z(t){return typeof t=="string"}function ms(t,e){if(t)return Z(t)?{type:Ci,name:t,predicate:e?e[t]:void 0}:nt(t)?{type:Ci,name:t.name,predicate:t}:t}function Sh(t){try{return"subscribe"in t&&nt(t.subscribe)}catch{return!1}}var xe=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();or={},or[xe]=function(){return this},or[Symbol.observable]=function(){return this};function Ce(t){return!!t&&"__xstatenode"in t}function Ch(t){return!!t&&typeof t.send=="function"}var wh=function(){var t=0;return function(){return t++,t.toString(16)}}();function Gr(t,e){return Z(t)||typeof t=="number"?T({type:t},e):t}function Nt(t,e){if(!Z(t)&&"$$type"in t&&t.$$type==="scxml")return t;var n=Gr(t);return T({name:n.type,data:n,$$type:"scxml",type:"external"},e)}function Ze(t,e){var n=vs(e).map(function(r){return typeof r>"u"||typeof r=="string"||Ce(r)?{target:r,event:t}:T(T({},r),{event:t})});return n}function Th(t){if(!(t===void 0||t===dh))return Zt(t)}function Ih(t,e,n){if(!vt){var r=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";if(t===e)console.error("Missing onError handler for invocation '".concat(n,"', error was '").concat(t,"'.").concat(r));else{var i=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(n,"'. ")+"Original error: '".concat(t,"'. ").concat(r," Current error is '").concat(e,"'.").concat(i))}}}function gs(t,e,n,r,i){var o=t.options.guards,a={state:i,cond:e,_event:r};if(e.type===Ci)return((o==null?void 0:o[e.name])||e.predicate)(n,r.data,a);var u=o==null?void 0:o[e.type];if(!u)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return u(n,r.data,a)}function bs(t){return typeof t=="string"?{type:t}:t}function pr(t,e,n){var r=function(){},i=typeof t=="object",o=i?t:null;return{next:((i?t.next:t)||r).bind(o),error:((i?t.error:e)||r).bind(o),complete:((i?t.complete:n)||r).bind(o)}}function ar(t,e){return"".concat(t,":invocation[").concat(e,"]")}function Ti(t){return(t.type===Jn||t.type===Fr&&t.to===We.Internal)&&typeof t.delay!="number"}var ln=Nt({type:uh});function Ii(t,e){return e&&e[t]||void 0}function Fn(t,e){var n;if(Z(t)||typeof t=="number"){var r=Ii(t,e);nt(r)?n={type:t,exec:r}:r?n=r:n={type:t,exec:void 0}}else if(nt(t))n={type:t.name||t.toString(),exec:t};else{var r=Ii(t.type,e);if(nt(r))n=T(T({},t),{exec:r});else if(r){var i=r.type||t.type;n=T(T(T({},r),t),{type:i})}else n=t}return n}var Ae=function(t,e){if(!t)return[];var n=yn(t)?t:[t];return n.map(function(r){return Fn(r,e)})};function Qi(t){var e=Fn(t);return T(T({id:Z(t)?t:e.id},e),{type:e.type})}function Eh(t,e){return{type:Jn,event:typeof t=="function"?t:Gr(t),delay:e?e.delay:void 0,id:e==null?void 0:e.id}}function xh(t,e,n,r){var i={_event:n},o=Nt(nt(t.event)?t.event(e,n.data,i):t.event),a;if(Z(t.delay)){var u=r&&r[t.delay];a=nt(u)?u(e,n.data,i):u}else a=nt(t.delay)?t.delay(e,n.data,i):t.delay;return T(T({},t),{type:Jn,_event:o,delay:a})}function Lr(t,e){return{to:e?e.to:void 0,type:Fr,event:nt(t)?t:Gr(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:nt(t)?t.name:ps(t)}}function Ah(t,e,n,r){var i={_event:n},o=Nt(nt(t.event)?t.event(e,n.data,i):t.event),a;if(Z(t.delay)){var u=r&&r[t.delay];a=nt(u)?u(e,n.data,i):u}else a=nt(t.delay)?t.delay(e,n.data,i):t.delay;var s=nt(t.to)?t.to(e,n.data,i):t.to;return T(T({},t),{to:s,_event:o,event:o.data,delay:a})}function Dh(t,e){return Lr(t,T(T({},e),{to:We.Parent}))}var Oh=function(t,e,n){return T(T({},t),{value:Z(t.expr)?t.expr:t.expr(e,n.data,{_event:n})})},Nh=function(t){return{type:ls,sendId:t}};function _h(t){var e=Qi(t);return{type:at.Start,activity:e,exec:void 0}}function Mh(t){var e=nt(t)?t:Qi(t);return{type:at.Stop,activity:e,exec:void 0}}function $h(t,e,n){var r=nt(t.activity)?t.activity(e,n.data):t.activity,i=typeof r=="string"?{id:r}:r,o={type:at.Stop,activity:i};return o}var qh=function(t){return{type:Xi,assignment:t}};function Ph(t,e){var n=e?"#".concat(e):"";return"".concat(at.After,"(").concat(t,")").concat(n)}function sr(t,e){var n="".concat(at.DoneState,".").concat(t),r={type:n,data:e};return r.toString=function(){return n},r}function vr(t,e){var n="".concat(at.DoneInvoke,".").concat(t),r={type:n,data:e};return r.toString=function(){return n},r}function _n(t,e){var n="".concat(at.ErrorPlatform,".").concat(t),r={type:n,data:e};return r.toString=function(){return n},r}function Rh(t,e){if(!vt&&(!t||typeof t=="function")){var n=t;t=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=typeof n=="function"?n.apply(void 0,lt([],Q(r),!1)):n;if(!o)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return o}}return Lr(function(r,i){return i},T(T({},e),{to:t}))}var jh=function(t){var e,n,r=[];try{for(var i=K(t),o=i.next();!o.done;o=i.next())for(var a=o.value,u=0;u<a.actions.length;){if(a.actions[u].type===Xi){r.push(a.actions[u]),a.actions.splice(u,1);continue}u++}}catch(s){e={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r};function Ir(t,e,n,r,i,o,a){a===void 0&&(a=!1);var u=a?[]:jh(i),s=u.length?Fo(n,r,u,e):n,l=a?[n]:void 0,f=[];function h(m,v){var w;switch(v.type){case Jn:{var E=xh(v,s,r,t.options.delays);return o&&typeof E.delay=="number"&&o(E,s,r),E}case Fr:var C=Ah(v,s,r,t.options.delays);if(!vt){var S=v.delay;xt(!Z(S)||typeof C.delay=="number","No delay reference for delay expression '".concat(S,"' was found on machine '").concat(t.id,"'"))}return o&&C.to!==We.Internal&&(m==="entry"?f.push(C):o(C,s,r)),C;case fs:{var I=Oh(v,s,r);return o==null||o(I,s,r),I}case lh:{var P=v,g=(w=P.conds.find(function(dt){var ut=ms(dt.cond,t.options.guards);return!ut||gs(t,ut,s,r,o?void 0:e)}))===null||w===void 0?void 0:w.actions;if(!g)return[];var N=Q(Ir(t,e,s,r,[{type:m,actions:Ae(Zt(g),t.options.actions)}],o,a),2),F=N[0],$=N[1];return s=$,l==null||l.push(s),F}case fh:{var g=v.get(s,r.data);if(!g)return[];var z=Q(Ir(t,e,s,r,[{type:m,actions:Ae(Zt(g),t.options.actions)}],o,a),2),q=z[0],D=z[1];return s=D,l==null||l.push(s),q}case Ji:{var I=$h(v,s,r);return o==null||o(I,n,r),I}case Xi:{s=Fo(s,r,[v],o?void 0:e),l==null||l.push(s);break}default:var et=Fn(v,t.options.actions),mt=et.exec;if(o)o(et,s,r);else if(mt&&l){var Qt=l.length-1,kt=T(T({},et),{exec:function(dt){for(var ut=[],Et=1;Et<arguments.length;Et++)ut[Et-1]=arguments[Et];mt.apply(void 0,lt([l[Qt]],Q(ut),!1))}});et=kt}return et}}function d(m){var v,w,E=[];try{for(var C=K(m.actions),S=C.next();!S.done;S=C.next()){var I=S.value,P=h(m.type,I);P&&(E=E.concat(P))}}catch(g){v={error:g}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(v)throw v.error}}return f.forEach(function(g){o(g,s,r)}),f.length=0,E}var y=pt(i.map(d));return[y,s]}var Er=[],rn=function(t,e){Er.push(t);var n=e(t);return Er.pop(),n},Uh=function(t){return t(Er[Er.length-1])};function Ss(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[xe]=function(){return this},e}function kh(t,e,n,r){var i,o=bs(t.src),a=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[o.type],u=t.data?Tr(t.data,n,r):void 0,s=a?Zi(a,t.id,u):Ss(t.id);return s.meta=t,s}function Zi(t,e,n){var r=Ss(e);if(r.deferred=!0,Ce(t)){var i=r.state=rn(void 0,function(){return(n?t.withContext(n):t).initialState});r.getSnapshot=function(){return i}}return r}function Bh(t){try{return typeof t.send=="function"}catch{return!1}}function Vh(t){return Bh(t)&&"id"in t}function Fh(t){var e;return T((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[xe]=function(){return this},e),t)}var xr=function(t){return t.type==="atomic"||t.type==="final"};function Cs(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function Gn(t){return Cs(t).filter(function(e){return e.type!=="history"})}function ws(t){var e=[t];return xr(t)?e:e.concat(pt(Gn(t).map(ws)))}function Mn(t,e){var n,r,i,o,a,u,s,l,f=new Set(t),h=Ei(f),d=new Set(e);try{for(var y=K(d),m=y.next();!m.done;m=y.next())for(var v=m.value,w=v.parent;w&&!d.has(w);)d.add(w),w=w.parent}catch($){n={error:$}}finally{try{m&&!m.done&&(r=y.return)&&r.call(y)}finally{if(n)throw n.error}}var E=Ei(d);try{for(var C=K(d),S=C.next();!S.done;S=C.next()){var v=S.value;if(v.type==="compound"&&(!E.get(v)||!E.get(v).length))h.get(v)?h.get(v).forEach(function(z){return d.add(z)}):v.initialStateNodes.forEach(function(z){return d.add(z)});else if(v.type==="parallel")try{for(var I=(a=void 0,K(Gn(v))),P=I.next();!P.done;P=I.next()){var g=P.value;d.has(g)||(d.add(g),h.get(g)?h.get(g).forEach(function(z){return d.add(z)}):g.initialStateNodes.forEach(function(z){return d.add(z)}))}}catch(z){a={error:z}}finally{try{P&&!P.done&&(u=I.return)&&u.call(I)}finally{if(a)throw a.error}}}}catch($){i={error:$}}finally{try{S&&!S.done&&(o=C.return)&&o.call(C)}finally{if(i)throw i.error}}try{for(var N=K(d),F=N.next();!F.done;F=N.next())for(var v=F.value,w=v.parent;w&&!d.has(w);)d.add(w),w=w.parent}catch($){s={error:$}}finally{try{F&&!F.done&&(l=N.return)&&l.call(N)}finally{if(s)throw s.error}}return d}function Ts(t,e){var n=e.get(t);if(!n)return{};if(t.type==="compound"){var r=n[0];if(r){if(xr(r))return r.key}else return{}}var i={};return n.forEach(function(o){i[o.key]=Ts(o,e)}),i}function Ei(t){var e,n,r=new Map;try{for(var i=K(t),o=i.next();!o.done;o=i.next()){var a=o.value;r.has(a)||r.set(a,[]),a.parent&&(r.has(a.parent)||r.set(a.parent,[]),r.get(a.parent).push(a))}}catch(u){e={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}function Gh(t,e){var n=Mn([t],e);return Ts(t,Ei(n))}function $n(t,e){return Array.isArray(t)?t.some(function(n){return n===e}):t instanceof Set?t.has(e):!1}function Lh(t){return lt([],Q(new Set(pt(lt([],Q(t.map(function(e){return e.ownEvents})),!1)))),!1)}function yr(t,e){return e.type==="compound"?Gn(e).some(function(n){return n.type==="final"&&$n(t,n)}):e.type==="parallel"?Gn(e).every(function(n){return yr(t,n)}):!1}function zh(t){return t===void 0&&(t=[]),t.reduce(function(e,n){return n.meta!==void 0&&(e[n.id]=n.meta),e},{})}function Go(t){return new Set(pt(t.map(function(e){return e.tags})))}function Is(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(Z(t)||Z(e))return t===e;var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(function(i){return Is(t[i],e[i])})}function Hh(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Wh(t,e){var n=t.exec,r=T(T({},t),{exec:n!==void 0?function(){return n(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return r}var Jt=function(){function t(e){var n=this,r;this.actions=[],this.activities=ko,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||ko,this.meta=zh(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(r=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&r!==void 0?r:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return Lh(n.configuration)}})}return t.from=function(e,n){if(e instanceof t)return e.context!==n?new t({value:e.value,context:n,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var r=ln;return new t({value:e,context:n,_event:r,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,n){if(e instanceof t){if(!e.actions.length)return e;var r=ln;return new t({value:e.value,context:n,_event:r,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,n)},t.prototype.toStrings=function(e,n){var r=this;if(e===void 0&&(e=this.value),n===void 0&&(n="."),Z(e))return[e];var i=Object.keys(e);return i.concat.apply(i,lt([],Q(i.map(function(o){return r.toStrings(e[o],n).map(function(a){return o+n+a})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var n=e.tags;e.machine;var r=Ki(e,["configuration","transitions","tags","machine"]);return T(T({},r),{tags:Array.from(n)})},t.prototype.matches=function(e){return Yi(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var n;vt&&xt(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var r=(n=this.machine)===null||n===void 0?void 0:n.getTransitionData(this,e);return!!(r!=null&&r.transitions.length)&&r.transitions.some(function(i){return i.target!==void 0||i.actions.length})},t}(),Kh={deferEvents:!1},Lo=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=T(T({},Kh),e)}return t.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents){this.schedule(e);return}this.process(e)}this.flushEvents()},t.prototype.schedule=function(e){if(!this.initialized||this.processingEvent){this.queue.push(e);return}if(this.queue.length!==0)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()},t.prototype.clear=function(){this.queue=[]},t.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},t.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(n){throw this.clear(),n}finally{this.processingEvent=!1}},t}(),ni=new Map,Jh=0,xn={bookId:function(){return"x:".concat(Jh++)},register:function(t,e){return ni.set(t,e),t},get:function(t){return ni.get(t)},free:function(t){ni.delete(t)}};function to(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;vt||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues")}function Xh(){var t=to();if(t&&"__xstate__"in t)return t.__xstate__}function Yh(t){if(to()){var e=Xh();e&&e.register(t)}}function Qh(t,e){e===void 0&&(e={});var n=t.initialState,r=new Set,i=[],o=!1,a=function(){if(!o){for(o=!0;i.length>0;){var l=i.shift();n=t.transition(n,l,s),r.forEach(function(f){return f.next(n)})}o=!1}},u=Fh({id:e.id,send:function(l){i.push(l),a()},getSnapshot:function(){return n},subscribe:function(l,f,h){var d=pr(l,f,h);return r.add(d),d.next(n),{unsubscribe:function(){r.delete(d)}}}}),s={parent:e.parent,self:u,id:e.id||"anonymous",observers:r};return n=t.start?t.start(s):n,u}var xi={sync:!1,autoForward:!1},bt;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(bt||(bt={}));var Zh=function(){function t(e,n){n===void 0&&(n=t.defaultOptions);var r=this;this.machine=e,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=bt.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(f,h){if(yn(f))return r.batch(f),r.state;var d=Nt(Gr(f,h));if(r.status===bt.Stopped)return vt||xt(!1,'Event "'.concat(d.name,'" was sent to stopped service "').concat(r.machine.id,`". This service has already reached its final state, and will not transition.
|
|
18
|
+
Event: `).concat(JSON.stringify(d.data))),r.state;if(r.status!==bt.Running&&!r.options.deferEvents)throw new Error('Event "'.concat(d.name,'" was sent to uninitialized service "').concat(r.machine.id,`". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.
|
|
19
|
+
Event: `).concat(JSON.stringify(d.data)));return r.scheduler.schedule(function(){r.forward(d);var y=r._nextState(d);r.update(y,d)}),r._state},this.sendTo=function(f,h,d){var y=r.parent&&(h===We.Parent||r.parent.id===h),m=y?r.parent:Z(h)?h===We.Internal?r:r.children.get(h)||xn.get(h):Ch(h)?h:void 0;if(!m){if(!y)throw new Error("Unable to send event to child '".concat(h,"' from service '").concat(r.id,"'."));vt||xt(!1,"Service '".concat(r.id,"' has no parent: unable to send event ").concat(f.type));return}if("machine"in m){if(r.status!==bt.Stopped||r.parent!==m||r.state.done){var v=T(T({},f),{name:f.name===ch?"".concat(_n(r.id)):f.name,origin:r.sessionId});!d&&r.machine.config.predictableActionArguments?r._outgoingQueue.push([m,v]):m.send(v)}}else!d&&r.machine.config.predictableActionArguments?r._outgoingQueue.push([m,f.data]):m.send(f.data)},this._exec=function(f,h,d,y){y===void 0&&(y=r.machine.options.actions);var m=f.exec||Ii(f.type,y),v=nt(m)?m:m?m.exec:f.exec;if(v)try{return v(h,d.data,r.machine.config.predictableActionArguments?{action:f,_event:d}:{action:f,state:r.state,_event:d})}catch(mt){throw r.parent&&r.parent.send({type:"xstate.error",data:mt}),mt}switch(f.type){case Jn:{var w=f;r.defer(w);break}case Fr:var E=f;if(typeof E.delay=="number"){r.defer(E);return}else E.to?r.sendTo(E._event,E.to,d===ln):r.send(E._event);break;case ls:r.cancel(f.sendId);break;case bi:{if(r.status!==bt.Running)return;var C=f.activity;if(!r.machine.config.predictableActionArguments&&!r.state.activities[C.id||C.type])break;if(C.type===at.Invoke){var S=bs(C.src),I=r.machine.options.services?r.machine.options.services[S.type]:void 0,P=C.id,g=C.data;vt||xt(!("forward"in C),"`forward` property is deprecated (found in invocation of '".concat(C.src,"' in in machine '").concat(r.machine.id,"'). ")+"Please use `autoForward` instead.");var N="autoForward"in C?C.autoForward:!!C.forward;if(!I){vt||xt(!1,"No service found for invocation '".concat(C.src,"' in machine '").concat(r.machine.id,"'."));return}var F=g?Tr(g,h,d):void 0;if(typeof I=="string")return;var $=nt(I)?I(h,d.data,{data:F,src:S,meta:C.meta}):I;if(!$)return;var z=void 0;Ce($)&&($=F?$.withContext(F):$,z={autoForward:N}),r.spawn($,P,z)}else r.spawnActivity(C);break}case Ji:{r.stopChild(f.activity.id);break}case fs:var q=f,D=q.label,et=q.value;D?r.logger(D,et):r.logger(et);break;default:vt||xt(!1,"No implementation found for action type '".concat(f.type,"'"));break}};var i=T(T({},t.defaultOptions),n),o=i.clock,a=i.logger,u=i.parent,s=i.id,l=s!==void 0?s:e.id;this.id=l,this.logger=a,this.clock=o,this.parent=u,this.options=i,this.scheduler=new Lo({deferEvents:this.options.deferEvents}),this.sessionId=xn.bookId()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:rn(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return vt||xt(this.status!==bt.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),t.prototype.execute=function(e,n){var r,i;try{for(var o=K(e.actions),a=o.next();!a.done;a=o.next()){var u=a.value;this.exec(u,e,n)}}catch(s){r={error:s}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},t.prototype.update=function(e,n){var r,i,o,a,u,s,l,f,h=this;if(e._sessionid=this.sessionId,this._state=e,(!this.machine.config.predictableActionArguments||n===ln)&&this.options.execute)this.execute(this.state);else for(var d=void 0;d=this._outgoingQueue.shift();)d[0].send(d[1]);if(this.children.forEach(function($){h.state.children[$.id]=$}),this.devTools&&this.devTools.send(n.data,e),e.event)try{for(var y=K(this.eventListeners),m=y.next();!m.done;m=y.next()){var v=m.value;v(e.event)}}catch($){r={error:$}}finally{try{m&&!m.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}try{for(var w=K(this.listeners),E=w.next();!E.done;E=w.next()){var v=E.value;v(e,e.event)}}catch($){o={error:$}}finally{try{E&&!E.done&&(a=w.return)&&a.call(w)}finally{if(o)throw o.error}}try{for(var C=K(this.contextListeners),S=C.next();!S.done;S=C.next()){var I=S.value;I(this.state.context,this.state.history?this.state.history.context:void 0)}}catch($){u={error:$}}finally{try{S&&!S.done&&(s=C.return)&&s.call(C)}finally{if(u)throw u.error}}if(this.state.done){var P=e.configuration.find(function($){return $.type==="final"&&$.parent===h.machine}),g=P&&P.doneData?Tr(P.doneData,e.context,n):void 0;this._doneEvent=vr(this.id,g);try{for(var N=K(this.doneListeners),F=N.next();!F.done;F=N.next()){var v=F.value;v(this._doneEvent)}}catch($){l={error:$}}finally{try{F&&!F.done&&(f=N.return)&&f.call(N)}finally{if(l)throw l.error}}this._stop(),this._stopChildren(),xn.free(this.sessionId)}},t.prototype.onTransition=function(e){return this.listeners.add(e),this.status===bt.Running&&e(this.state,this.state.event),this},t.prototype.subscribe=function(e,n,r){var i=this,o=pr(e,n,r);this.listeners.add(o.next),this.status!==bt.NotStarted&&o.next(this.state);var a=function(){i.doneListeners.delete(a),i.stopListeners.delete(a),o.complete()};return this.status===bt.Stopped?o.complete():(this.onDone(a),this.onStop(a)),{unsubscribe:function(){i.listeners.delete(o.next),i.doneListeners.delete(a),i.stopListeners.delete(a)}}},t.prototype.onEvent=function(e){return this.eventListeners.add(e),this},t.prototype.onSend=function(e){return this.sendListeners.add(e),this},t.prototype.onChange=function(e){return this.contextListeners.add(e),this},t.prototype.onStop=function(e){return this.stopListeners.add(e),this},t.prototype.onDone=function(e){return this.status===bt.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},t.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},t.prototype.start=function(e){var n=this;if(this.status===bt.Running)return this;this.machine._init(),xn.register(this.sessionId,this),this.initialized=!0,this.status=bt.Running;var r=e===void 0?this.initialState:rn(this,function(){return Hh(e)?n.machine.resolveState(e):n.machine.resolveState(Jt.from(e,n.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){n.update(r,ln)}),this},t.prototype._stopChildren=function(){this.children.forEach(function(e){nt(e.stop)&&e.stop()}),this.children.clear()},t.prototype._stop=function(){var e,n,r,i,o,a,u,s,l,f;try{for(var h=K(this.listeners),d=h.next();!d.done;d=h.next()){var y=d.value;this.listeners.delete(y)}}catch(N){e={error:N}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(e)throw e.error}}try{for(var m=K(this.stopListeners),v=m.next();!v.done;v=m.next()){var y=v.value;y(),this.stopListeners.delete(y)}}catch(N){r={error:N}}finally{try{v&&!v.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var w=K(this.contextListeners),E=w.next();!E.done;E=w.next()){var y=E.value;this.contextListeners.delete(y)}}catch(N){o={error:N}}finally{try{E&&!E.done&&(a=w.return)&&a.call(w)}finally{if(o)throw o.error}}try{for(var C=K(this.doneListeners),S=C.next();!S.done;S=C.next()){var y=S.value;this.doneListeners.delete(y)}}catch(N){u={error:N}}finally{try{S&&!S.done&&(s=C.return)&&s.call(C)}finally{if(u)throw u.error}}if(!this.initialized)return this;this.initialized=!1,this.status=bt.Stopped,this._initialState=void 0;try{for(var I=K(Object.keys(this.delayedEventsMap)),P=I.next();!P.done;P=I.next()){var g=P.value;this.clock.clearTimeout(this.delayedEventsMap[g])}}catch(N){l={error:N}}finally{try{P&&!P.done&&(f=I.return)&&f.call(I)}finally{if(l)throw l.error}}this.scheduler.clear(),this.scheduler=new Lo({deferEvents:this.options.deferEvents})},t.prototype.stop=function(){var e=this,n=this.scheduler;return this._stop(),n.schedule(function(){var r;if(!(!((r=e._state)===null||r===void 0)&&r.done)){var i=Nt({type:"xstate.stop"}),o=rn(e,function(){var a=pt(lt([],Q(e.state.configuration),!1).sort(function(h,d){return d.order-h.order}).map(function(h){return Ae(h.onExit,e.machine.options.actions)})),u=Q(Ir(e.machine,e.state,e.state.context,i,[{type:"exit",actions:a}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),s=u[0],l=u[1],f=new Jt({value:e.state.value,context:l,_event:i,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:s.filter(function(h){return!Ti(h)}),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return f.changed=!0,f});e.update(o,i),e._stopChildren(),xn.free(e.sessionId)}}),this},t.prototype.batch=function(e){var n=this;if(this.status===bt.NotStarted&&this.options.deferEvents)vt||xt(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,`" and are deferred. Make sure .start() is called for this service.
|
|
20
|
+
Event: `).concat(JSON.stringify(event)));else if(this.status!==bt.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(e.length){var r=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule(function(){var i,o,a=n.state,u=!1,s=[],l=function(y){var m=Nt(y);n.forward(m),a=rn(n,function(){return n.machine.transition(a,m,void 0,r||void 0)}),s.push.apply(s,lt([],Q(n.machine.config.predictableActionArguments?a.actions:a.actions.map(function(v){return Wh(v,a)})),!1)),u=u||!!a.changed};try{for(var f=K(e),h=f.next();!h.done;h=f.next()){var d=h.value;l(d)}}catch(y){i={error:y}}finally{try{h&&!h.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}a.changed=u,a.actions=s,n.update(a,Nt(e[e.length-1]))})}},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype._nextState=function(e,n){var r=this;n===void 0&&(n=!!this.machine.config.predictableActionArguments&&this._exec);var i=Nt(e);if(i.name.indexOf(Uo)===0&&!this.state.nextEvents.some(function(a){return a.indexOf(Uo)===0}))throw i.data.data;var o=rn(this,function(){return r.machine.transition(r.state,i,void 0,n||void 0)});return o},t.prototype.nextState=function(e){return this._nextState(e,!1)},t.prototype.forward=function(e){var n,r;try{for(var i=K(this.forwardTo),o=i.next();!o.done;o=i.next()){var a=o.value,u=this.children.get(a);if(!u)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(a,"'."));u.send(e)}}catch(s){n={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.defer=function(e){var n=this,r=this.clock.setTimeout(function(){"to"in e&&e.to?n.sendTo(e._event,e.to,!0):n.send(e._event)},e.delay);e.id&&(this.delayedEventsMap[e.id]=r)},t.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},t.prototype.exec=function(e,n,r){r===void 0&&(r=this.machine.options.actions),this._exec(e,n.context,n._event,r)},t.prototype.removeChild=function(e){var n;this.children.delete(e),this.forwardTo.delete(e),(n=this.state)===null||n===void 0||delete n.children[e]},t.prototype.stopChild=function(e){var n=this.children.get(e);n&&(this.removeChild(e),nt(n.stop)&&n.stop())},t.prototype.spawn=function(e,n,r){if(this.status!==bt.Running)return Zi(e,n);if(Vo(e))return this.spawnPromise(Promise.resolve(e),n);if(nt(e))return this.spawnCallback(e,n);if(Vh(e))return this.spawnActor(e,n);if(Sh(e))return this.spawnObservable(e,n);if(Ce(e))return this.spawnMachine(e,T(T({},r),{id:n}));if(mh(e))return this.spawnBehavior(e,n);throw new Error('Unable to spawn entity "'.concat(n,'" of type "').concat(typeof e,'".'))},t.prototype.spawnMachine=function(e,n){var r=this;n===void 0&&(n={});var i=new t(e,T(T({},this.options),{parent:this,id:n.id||e.id})),o=T(T({},xi),n);o.sync&&i.onTransition(function(u){r.send(ds,{state:u,id:i.id})});var a=i;return this.children.set(i.id,a),o.autoForward&&this.forwardTo.add(i.id),i.onDone(function(u){r.removeChild(i.id),r.send(Nt(u,{origin:i.id}))}).start(),a},t.prototype.spawnBehavior=function(e,n){var r=Qh(e,{id:n,parent:this});return this.children.set(n,r),r},t.prototype.spawnPromise=function(e,n){var r,i=this,o=!1,a;e.then(function(s){o||(a=s,i.removeChild(n),i.send(Nt(vr(n,s),{origin:n})))},function(s){if(!o){i.removeChild(n);var l=_n(n,s);try{i.send(Nt(l,{origin:n}))}catch(f){Ih(s,f,n),i.devTools&&i.devTools.send(l,i.state),i.machine.strict&&i.stop()}}});var u=(r={id:n,send:function(){},subscribe:function(s,l,f){var h=pr(s,l,f),d=!1;return e.then(function(y){d||(h.next(y),!d&&h.complete())},function(y){d||h.error(y)}),{unsubscribe:function(){return d=!0}}},stop:function(){o=!0},toJSON:function(){return{id:n}},getSnapshot:function(){return a}},r[xe]=function(){return this},r);return this.children.set(n,u),u},t.prototype.spawnCallback=function(e,n){var r,i=this,o=!1,a=new Set,u=new Set,s,l=function(d){s=d,u.forEach(function(y){return y(d)}),!o&&i.send(Nt(d,{origin:n}))},f;try{f=e(l,function(d){a.add(d)})}catch(d){this.send(_n(n,d))}if(Vo(f))return this.spawnPromise(f,n);var h=(r={id:n,send:function(d){return a.forEach(function(y){return y(d)})},subscribe:function(d){var y=pr(d);return u.add(y.next),{unsubscribe:function(){u.delete(y.next)}}},stop:function(){o=!0,nt(f)&&f()},toJSON:function(){return{id:n}},getSnapshot:function(){return s}},r[xe]=function(){return this},r);return this.children.set(n,h),h},t.prototype.spawnObservable=function(e,n){var r,i=this,o,a=e.subscribe(function(s){o=s,i.send(Nt(s,{origin:n}))},function(s){i.removeChild(n),i.send(Nt(_n(n,s),{origin:n}))},function(){i.removeChild(n),i.send(Nt(vr(n),{origin:n}))}),u=(r={id:n,send:function(){},subscribe:function(s,l,f){return e.subscribe(s,l,f)},stop:function(){return a.unsubscribe()},getSnapshot:function(){return o},toJSON:function(){return{id:n}}},r[xe]=function(){return this},r);return this.children.set(n,u),u},t.prototype.spawnActor=function(e,n){return this.children.set(n,e),e},t.prototype.spawnActivity=function(e){var n=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(!n){vt||xt(!1,"No implementation found for activity '".concat(e.type,"'"));return}var r=n(this.state.context,e);this.spawnEffect(e.id,r)},t.prototype.spawnEffect=function(e,n){var r;this.children.set(e,(r={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:n||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}},r[xe]=function(){return this},r))},t.prototype.attachDev=function(){var e=to();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var n=typeof this.options.devTools=="object"?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(T(T({name:this.id,autoPause:!0,stateSanitizer:function(r){return{value:r.value,context:r.context,actions:r.actions}}},n),{features:T({jump:!1,skip:!1},n?n.features:void 0)}),this.machine),this.devTools.init(this.state)}Yh(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[xe]=function(){return this},t.prototype.getSnapshot=function(){return this.status===bt.NotStarted?this.initialState:this._state},t.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,n){return setTimeout(e,n)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},t.interpret=Es,t}(),tp=function(t){return Z(t)?T(T({},xi),{name:t}):T(T(T({},xi),{name:wh()}),t)};function zo(t,e){var n=tp(e);return Uh(function(r){if(!vt){var i=Ce(t)||nt(t);xt(!!r||i,'Attempted to spawn an Actor (ID: "'.concat(Ce(t)?t.id:"undefined",'") outside of a service. This will have no effect.'))}return r?r.spawn(t,n.name,n):Zi(t,n.name)})}function Es(t,e){var n=new Zh(t,e);return n}function ep(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function ur(t){return T(T({type:Si},t),{toJSON:function(){t.onDone,t.onError;var e=Ki(t,["onDone","onError"]);return T(T({},e),{type:Si,src:ep(t.src)})}})}var on="",Ai="#",An="*",tn={},en=function(t){return t[0]===Ai},np=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},rp=function(t,e,n){var r=n.slice(0,-1).some(function(o){return!("cond"in o)&&!("in"in o)&&(Z(o.target)||Ce(o.target))}),i=e===on?"the transient event":"event '".concat(e,"'");xt(!r,"One or more transitions for ".concat(i," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},ip=function(){function t(e,n,r,i){r===void 0&&(r="context"in e?e.context:void 0);var o=this,a;this.config=e,this._context=r,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(np(),n),this.parent=i==null?void 0:i.parent,this.key=this.config.key||(i==null?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:hs),this.id=this.config.id||lt([this.machine.key],Q(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(a=this.config.schema)!==null&&a!==void 0?a:{},this.description=this.config.description,vt||xt(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?Nn(this.config.states,function(l,f){var h,d=new t(l,{},void 0,{parent:o,key:f});return Object.assign(o.idMap,T((h={},h[d.id]=d,h),d.idMap)),d}):tn;var u=0;function s(l){var f,h;l.order=u++;try{for(var d=K(Cs(l)),y=d.next();!y.done;y=d.next()){var m=y.value;s(m)}}catch(v){f={error:v}}finally{try{y&&!y.done&&(h=d.return)&&h.call(d)}finally{if(f)throw f.error}}}s(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(l){var f=l.event;return f===on}):on in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=Zt(this.config.entry||this.config.onEntry).map(function(l){return Fn(l)}),this.onExit=Zt(this.config.exit||this.config.onExit).map(function(l){return Fn(l)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=Zt(this.config.invoke).map(function(l,f){var h,d;if(Ce(l)){var y=ar(o.id,f);return o.machine.options.services=T((h={},h[y]=l,h),o.machine.options.services),ur({src:y,id:y})}else if(Z(l.src)){var y=l.id||ar(o.id,f);return ur(T(T({},l),{id:y,src:l.src}))}else if(Ce(l.src)||nt(l.src)){var y=l.id||ar(o.id,f);return o.machine.options.services=T((d={},d[y]=l.src,d),o.machine.options.services),ur(T(T({id:y},l),{src:y}))}else{var m=l.src;return ur(T(T({id:ar(o.id,f)},l),{src:m}))}}),this.activities=Zt(this.config.activities).concat(this.invoke).map(function(l){return Qi(l)}),this.transition=this.transition.bind(this),this.tags=Zt(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||ws(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,n){var r=this.options,i=r.actions,o=r.activities,a=r.guards,u=r.services,s=r.delays;return new t(this.config,{actions:T(T({},i),e.actions),activities:T(T({},o),e.activities),guards:T(T({},a),e.guards),services:T(T({},u),e.services),delays:T(T({},s),e.delays)},n??this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return nt(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:Nn(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(n,r){return n[r.eventType]=n[r.eventType]||[],n[r.eventType].push(r),n},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var n=e===on,r=this.transitions.filter(function(i){var o=i.eventType===e;return n?o:o||i.eventType===An});return this.__cache.candidates[e]=r,r},t.prototype.getDelayedTransitions=function(){var e=this,n=this.config.after;if(!n)return[];var r=function(o,a){var u=nt(o)?"".concat(e.id,":delay[").concat(a,"]"):o,s=Ph(u,e.id);return e.onEntry.push(Lr(s,{delay:o})),e.onExit.push(Nh(s)),s},i=yn(n)?n.map(function(o,a){var u=r(o.delay,a);return T(T({},o),{event:u})}):pt(Object.keys(n).map(function(o,a){var u=n[o],s=Z(u)?{target:u}:u,l=isNaN(+o)?o:+o,f=r(l,a);return Zt(s).map(function(h){return T(T({},h),{event:f,delay:l})})}));return i.map(function(o){var a=o.delay;return T(T({},e.formatTransition(o)),{delay:a})})},t.prototype.getStateNodes=function(e){var n,r=this;if(!e)return[];var i=e instanceof Jt?e.value:Rn(e,this.delimiter);if(Z(i)){var o=this.getStateNode(i).initial;return o!==void 0?this.getStateNodes((n={},n[i]=o,n)):[this,this.states[i]]}var a=Object.keys(i),u=[this];return u.push.apply(u,lt([],Q(pt(a.map(function(s){return r.getStateNode(s).getStateNodes(i[s])}))),!1)),u},t.prototype.handles=function(e){var n=ps(e);return this.events.includes(n)},t.prototype.resolveState=function(e){var n=e instanceof Jt?e:Jt.create(e),r=Array.from(Mn([],this.getStateNodes(n.value)));return new Jt(T(T({},n),{value:this.resolve(n.value),configuration:r,done:yr(r,this),tags:Go(r),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,n,r){var i=this.getStateNode(e),o=i.next(n,r);return!o||!o.transitions.length?this.next(n,r):o},t.prototype.transitionCompoundNode=function(e,n,r){var i=Object.keys(e),o=this.getStateNode(i[0]),a=o._transition(e[i[0]],n,r);return!a||!a.transitions.length?this.next(n,r):a},t.prototype.transitionParallelNode=function(e,n,r){var i,o,a={};try{for(var u=K(Object.keys(e)),s=u.next();!s.done;s=u.next()){var l=s.value,f=e[l];if(f){var h=this.getStateNode(l),d=h._transition(f,n,r);d&&(a[l]=d)}}}catch(E){i={error:E}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}var y=Object.keys(a).map(function(E){return a[E]}),m=pt(y.map(function(E){return E.transitions})),v=y.some(function(E){return E.transitions.length>0});if(!v)return this.next(n,r);var w=pt(Object.keys(a).map(function(E){return a[E].configuration}));return{transitions:m,exitSet:pt(y.map(function(E){return E.exitSet})),configuration:w,source:n,actions:pt(Object.keys(a).map(function(E){return a[E].actions}))}},t.prototype._transition=function(e,n,r){return Z(e)?this.transitionLeafNode(e,n,r):Object.keys(e).length===1?this.transitionCompoundNode(e,n,r):this.transitionParallelNode(e,n,r)},t.prototype.getTransitionData=function(e,n){return this._transition(e.value,e,Nt(n))},t.prototype.next=function(e,n){var r,i,o=this,a=n.name,u=[],s=[],l;try{for(var f=K(this.getCandidates(a)),h=f.next();!h.done;h=f.next()){var d=h.value,y=d.cond,m=d.in,v=e.context,w=m?Z(m)&&en(m)?e.matches(Rn(this.getStateNodeById(m).path,this.delimiter)):Yi(Rn(m,this.delimiter),ph(this.path.slice(0,-2))(e.value)):!0,E=!1;try{E=!y||gs(this.machine,y,v,n,e)}catch(I){throw new Error("Unable to evaluate guard '".concat(y.name||y.type,"' in transition for event '").concat(a,"' in state node '").concat(this.id,`':
|
|
21
|
+
`).concat(I.message))}if(E&&w){d.target!==void 0&&(s=d.target),u.push.apply(u,lt([],Q(d.actions),!1)),l=d;break}}}catch(I){r={error:I}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}if(l){if(!s.length)return{transitions:[l],exitSet:[],configuration:e.value?[this]:[],source:e,actions:u};var C=pt(s.map(function(I){return o.getRelativeStateNodes(I,e.historyValue)})),S=!!l.internal;return{transitions:[l],exitSet:S?[]:pt(s.map(function(I){return o.getPotentiallyReenteringNodes(I)})),configuration:C,source:e,actions:u}}},t.prototype.getPotentiallyReenteringNodes=function(e){if(this.order<e.order)return[this];for(var n=[],r=this,i=e;r&&r!==i;)n.push(r),r=r.parent;return r!==i?[]:(n.push(i),n)},t.prototype.getActions=function(e,n,r,i,o,a,u){var s,l,f,h,d=this,y=a?Mn([],this.getStateNodes(a.value)):[],m=new Set;try{for(var v=K(Array.from(e).sort(function(q,D){return q.order-D.order})),w=v.next();!w.done;w=v.next()){var E=w.value;(!$n(y,E)||$n(r.exitSet,E)||E.parent&&m.has(E.parent))&&m.add(E)}}catch(q){s={error:q}}finally{try{w&&!w.done&&(l=v.return)&&l.call(v)}finally{if(s)throw s.error}}try{for(var C=K(y),S=C.next();!S.done;S=C.next()){var E=S.value;(!$n(e,E)||$n(r.exitSet,E.parent))&&r.exitSet.push(E)}}catch(q){f={error:q}}finally{try{S&&!S.done&&(h=C.return)&&h.call(C)}finally{if(f)throw f.error}}r.exitSet.sort(function(q,D){return D.order-q.order});var I=Array.from(m).sort(function(q,D){return q.order-D.order}),P=new Set(r.exitSet),g=pt(I.map(function(q){var D=[];if(q.type!=="final")return D;var et=q.parent;if(!et.parent)return D;D.push(sr(q.id,q.doneData),sr(et.id,q.doneData?Tr(q.doneData,i,o):void 0));var mt=et.parent;return mt.type==="parallel"&&Gn(mt).every(function(Qt){return yr(r.configuration,Qt)})&&D.push(sr(mt.id)),D})),N=I.map(function(q){var D=q.onEntry,et=q.activities.map(function(mt){return _h(mt)});return{type:"entry",actions:Ae(u?lt(lt([],Q(D),!1),Q(et),!1):lt(lt([],Q(et),!1),Q(D),!1),d.machine.options.actions)}}).concat({type:"state_done",actions:g.map(function(q){return Eh(q)})}),F=Array.from(P).map(function(q){return{type:"exit",actions:Ae(lt(lt([],Q(q.onExit),!1),Q(q.activities.map(function(D){return Mh(D)})),!1),d.machine.options.actions)}}),$=F.concat({type:"transition",actions:Ae(r.actions,this.machine.options.actions)}).concat(N);if(n){var z=Ae(pt(lt([],Q(e),!1).sort(function(q,D){return D.order-q.order}).map(function(q){return q.onExit})),this.machine.options.actions).filter(function(q){return!Ti(q)});return $.concat({type:"stop",actions:z})}return $},t.prototype.transition=function(e,n,r,i){e===void 0&&(e=this.initialState);var o=Nt(n),a;if(e instanceof Jt)a=r===void 0?e:this.resolveState(Jt.from(e,r));else{var u=Z(e)?this.resolve(wr(this.getResolvedPath(e))):this.resolve(e),s=r??this.machine.context;a=this.resolveState(Jt.from(u,s))}if(!vt&&o.name===An)throw new Error("An event cannot have the wildcard type ('".concat(An,"')"));if(this.strict&&!this.events.includes(o.name)&&!yh(o.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(o.name,"'"));var l=this._transition(a.value,a,o)||{transitions:[],configuration:[],exitSet:[],source:a,actions:[]},f=Mn([],this.getStateNodes(a.value)),h=l.configuration.length?Mn(f,l.configuration):f;return l.configuration=lt([],Q(h),!1),this.resolveTransition(l,a,a.context,i,o)},t.prototype.resolveRaisedTransition=function(e,n,r,i){var o,a=e.actions;return e=this.transition(e,n,void 0,i),e._event=r,e.event=r.data,(o=e.actions).unshift.apply(o,lt([],Q(a),!1)),e},t.prototype.resolveTransition=function(e,n,r,i,o){var a,u,s,l,f=this;o===void 0&&(o=ln);var h=e.configuration,d=!n||e.transitions.length>0,y=d?e.configuration:n?n.configuration:[],m=yr(y,this),v=d?Gh(this.machine,h):void 0,w=n?n.historyValue?n.historyValue:e.source?this.machine.historyValue(n.value):void 0:void 0,E=this.getActions(new Set(y),m,e,r,o,n,i),C=n?T({},n.activities):{};try{for(var S=K(E),I=S.next();!I.done;I=S.next()){var P=I.value;try{for(var g=(s=void 0,K(P.actions)),N=g.next();!N.done;N=g.next()){var F=N.value;F.type===bi?C[F.activity.id||F.activity.type]=F:F.type===Ji&&(C[F.activity.id||F.activity.type]=!1)}}catch(Lt){s={error:Lt}}finally{try{N&&!N.done&&(l=g.return)&&l.call(g)}finally{if(s)throw s.error}}}}catch(Lt){a={error:Lt}}finally{try{I&&!I.done&&(u=S.return)&&u.call(S)}finally{if(a)throw a.error}}var $=Q(Ir(this,n,r,o,E,i,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),z=$[0],q=$[1],D=Q(gh(z,Ti),2),et=D[0],mt=D[1],Qt=z.filter(function(Lt){var Te;return Lt.type===bi&&((Te=Lt.activity)===null||Te===void 0?void 0:Te.type)===Si}),kt=Qt.reduce(function(Lt,Te){return Lt[Te.activity.id]=kh(Te.activity,f.machine,q,o),Lt},n?T({},n.children):{}),dt=new Jt({value:v||n.value,context:q,_event:o,_sessionid:n?n._sessionid:null,historyValue:v?w?bh(w,v):void 0:n?n.historyValue:void 0,history:!v||e.source?n:void 0,actions:v?mt:[],activities:v?C:n?n.activities:{},events:[],configuration:y,transitions:e.transitions,children:kt,done:m,tags:Go(y),machine:this}),ut=r!==q;dt.changed=o.name===ds||ut;var Et=dt.history;Et&&delete Et.history;var tr=!m&&(this._transient||h.some(function(Lt){return Lt._transient}));if(!d&&(!tr||o.name===on))return dt;var Bt=dt;if(!m)for(tr&&(Bt=this.resolveRaisedTransition(Bt,{type:sh},o,i));et.length;){var Zr=et.shift();Bt=this.resolveRaisedTransition(Bt,Zr._event,o,i)}var er=Bt.changed||(Et?!!Bt.actions.length||ut||typeof Et.value!=typeof Bt.value||!Is(Bt.value,Et.value):void 0);return Bt.changed=er,Bt.history=Et,Bt},t.prototype.getStateNode=function(e){if(en(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var n=this.states[e];if(!n)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return n},t.prototype.getStateNodeById=function(e){var n=en(e)?e.slice(Ai.length):e;if(n===this.id)return this;var r=this.machine.idMap[n];if(!r)throw new Error("Child state node '#".concat(n,"' does not exist on machine '").concat(this.id,"'"));return r},t.prototype.getStateNodeByPath=function(e){if(typeof e=="string"&&en(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var n=wi(e,this.delimiter).slice(),r=this;n.length;){var i=n.shift();if(!i.length)break;r=r.getStateNode(i)}return r},t.prototype.resolve=function(e){var n,r=this;if(!e)return this.initialStateValue||tn;switch(this.type){case"parallel":return Nn(this.initialStateValue,function(o,a){return o?r.getStateNode(a).resolve(e[a]||o):tn});case"compound":if(Z(e)){var i=this.getStateNode(e);return i.type==="parallel"||i.type==="compound"?(n={},n[e]=i.initialStateValue,n):e}return Object.keys(e).length?Nn(e,function(o,a){return o?r.getStateNode(a).resolve(o):tn}):this.initialStateValue||{};default:return e||tn}},t.prototype.getResolvedPath=function(e){if(en(e)){var n=this.machine.idMap[e.slice(Ai.length)];if(!n)throw new Error("Unable to find state node '".concat(e,"'"));return n.path}return wi(e,this.delimiter)},Object.defineProperty(t.prototype,"initialStateValue",{get:function(){var e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var n;if(this.type==="parallel")n=Bo(this.states,function(r){return r.initialStateValue||tn},function(r){return r.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));n=xr(this.states[this.initial])?this.initial:(e={},e[this.initial]=this.states[this.initial].initialStateValue,e)}else n={};return this.__cache.initialStateValue=n,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),t.prototype.getInitialState=function(e,n){this._init();var r=this.getStateNodes(e);return this.resolveTransition({configuration:r,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,n??this.machine.context,void 0)},Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e;if(this.type==="history"){var n=this.config;Z(n.target)?e=en(n.target)?wr(this.machine.getStateNodeById(n.target).path.slice(this.path.length-1)):n.target:e=n.target}return e},enumerable:!1,configurable:!0}),t.prototype.getRelativeStateNodes=function(e,n,r){return r===void 0&&(r=!0),r?e.type==="history"?e.resolveHistory(n):e.initialStateNodes:[e]},Object.defineProperty(t.prototype,"initialStateNodes",{get:function(){var e=this;if(xr(this))return[this];if(this.type==="compound"&&!this.initial)return vt||xt(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var n=hr(this.initialStateValue);return pt(n.map(function(r){return e.getFromRelativePath(r)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var n=Q(e),r=n[0],i=n.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(r,"' from node with no states"));var o=this.getStateNode(r);if(o.type==="history")return o.resolveHistory();if(!this.states[r])throw new Error("Child state '".concat(r,"' does not exist on '").concat(this.id,"'"));return this.states[r].getFromRelativePath(i)},t.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:Bo(this.states,function(n,r){if(!e)return n.historyValue();var i=Z(e)?void 0:e[r];return n.historyValue(i||n.initialStateValue)},function(n){return!n.history})}},t.prototype.resolveHistory=function(e){var n=this;if(this.type!=="history")return[this];var r=this.parent;if(!e){var i=this.target;return i?pt(hr(i).map(function(a){return r.getFromRelativePath(a)})):r.initialStateNodes}var o=vh(r.path,"states")(e).current;return Z(o)?[r.getStateNode(o)]:pt(hr(o).map(function(a){return n.history==="deep"?r.getFromRelativePath(a):[r.states[a[0]]]}))},Object.defineProperty(t.prototype,"stateIds",{get:function(){var e=this,n=pt(Object.keys(this.states).map(function(r){return e.states[r].stateIds}));return[this.id].concat(n)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){var e,n,r,i;if(this.__cache.events)return this.__cache.events;var o=this.states,a=new Set(this.ownEvents);if(o)try{for(var u=K(Object.keys(o)),s=u.next();!s.done;s=u.next()){var l=s.value,f=o[l];if(f.states)try{for(var h=(r=void 0,K(f.events)),d=h.next();!d.done;d=h.next()){var y=d.value;a.add("".concat(y))}}catch(m){r={error:m}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}}}catch(m){e={error:m}}finally{try{s&&!s.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(a)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter(function(n){return!(!n.target&&!n.actions.length&&n.internal)}).map(function(n){return n.eventType}));return Array.from(e)},enumerable:!1,configurable:!0}),t.prototype.resolveTarget=function(e){var n=this;if(e!==void 0)return e.map(function(r){if(!Z(r))return r;var i=r[0]===n.delimiter;if(i&&!n.parent)return n.getStateNodeByPath(r.slice(1));var o=i?n.key+r:r;if(n.parent)try{var a=n.parent.getStateNodeByPath(o);return a}catch(u){throw new Error("Invalid transition definition for state node '".concat(n.id,`':
|
|
22
|
+
`).concat(u.message))}else return n.getStateNodeByPath(o)})},t.prototype.formatTransition=function(e){var n=this,r=Th(e.target),i="internal"in e?e.internal:r?r.some(function(s){return Z(s)&&s[0]===n.delimiter}):!0,o=this.machine.options.guards,a=this.resolveTarget(r),u=T(T({},e),{actions:Ae(Zt(e.actions)),cond:ms(e.cond,o),target:a,source:this,internal:i,eventType:e.event,toJSON:function(){return T(T({},u),{target:u.target?u.target.map(function(s){return"#".concat(s.id)}):void 0,source:"#".concat(n.id)})}});return u},t.prototype.formatTransitions=function(){var e,n,r=this,i;if(!this.config.on)i=[];else if(Array.isArray(this.config.on))i=this.config.on;else{var o=this.config.on,a=An,u=o[a],s=u===void 0?[]:u,l=Ki(o,[typeof a=="symbol"?a:a+""]);i=pt(Object.keys(l).map(function(C){!vt&&C===on&&xt(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(r.id,'".'));var S=Ze(C,l[C]);return vt||rp(r,C,S),S}).concat(Ze(An,s)))}var f=this.config.always?Ze("",this.config.always):[],h=this.config.onDone?Ze(String(sr(this.id)),this.config.onDone):[];vt||xt(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var d=pt(this.invoke.map(function(C){var S=[];return C.onDone&&S.push.apply(S,lt([],Q(Ze(String(vr(C.id)),C.onDone)),!1)),C.onError&&S.push.apply(S,lt([],Q(Ze(String(_n(C.id)),C.onError)),!1)),S})),y=this.after,m=pt(lt(lt(lt(lt([],Q(h),!1),Q(d),!1),Q(i),!1),Q(f),!1).map(function(C){return Zt(C).map(function(S){return r.formatTransition(S)})}));try{for(var v=K(y),w=v.next();!w.done;w=v.next()){var E=w.value;m.push(E)}}catch(C){e={error:C}}finally{try{w&&!w.done&&(n=v.return)&&n.call(v)}finally{if(e)throw e.error}}return m},t}(),Ho=!1;function eo(t,e){return!vt&&!("predictableActionArguments"in t)&&!Ho&&(Ho=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new ip(t,e)}var Vt=qh,op=Lr,xs=Dh,cr=Rh,rt={},no={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});/*! *****************************************************************************
|
|
23
|
+
Copyright (c) Microsoft Corporation.
|
|
24
|
+
|
|
25
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
26
|
+
purpose with or without fee is hereby granted.
|
|
27
|
+
|
|
28
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
29
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
30
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
31
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
32
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
33
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
+
***************************************************************************** */t.__assign=function(){return t.__assign=Object.assign||function(a){for(var u,s=1,l=arguments.length;s<l;s++){u=arguments[s];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(a[f]=u[f])}return a},t.__assign.apply(this,arguments)};function e(o,a){var u={};for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&a.indexOf(s)<0&&(u[s]=o[s]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,s=Object.getOwnPropertySymbols(o);l<s.length;l++)a.indexOf(s[l])<0&&Object.prototype.propertyIsEnumerable.call(o,s[l])&&(u[s[l]]=o[s[l]]);return u}function n(o){var a=typeof Symbol=="function"&&Symbol.iterator,u=a&&o[a],s=0;if(u)return u.call(o);if(o&&typeof o.length=="number")return{next:function(){return o&&s>=o.length&&(o=void 0),{value:o&&o[s++],done:!o}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(o,a){var u=typeof Symbol=="function"&&o[Symbol.iterator];if(!u)return o;var s=u.call(o),l,f=[],h;try{for(;(a===void 0||a-- >0)&&!(l=s.next()).done;)f.push(l.value)}catch(d){h={error:d}}finally{try{l&&!l.done&&(u=s.return)&&u.call(s)}finally{if(h)throw h.error}}return f}function i(o,a,u){if(u||arguments.length===2)for(var s=0,l=a.length,f;s<l;s++)(f||!(s in a))&&(f||(f=Array.prototype.slice.call(a,0,s)),f[s]=a[s]);return o.concat(f||Array.prototype.slice.call(a))}t.__read=r,t.__rest=e,t.__spreadArray=i,t.__values=n})(no);var zr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ActionTypes=void 0,function(e){e.Start="xstate.start",e.Stop="xstate.stop",e.Raise="xstate.raise",e.Send="xstate.send",e.Cancel="xstate.cancel",e.NullEvent="",e.Assign="xstate.assign",e.After="xstate.after",e.DoneState="done.state",e.DoneInvoke="done.invoke",e.Log="xstate.log",e.Init="xstate.init",e.Invoke="xstate.invoke",e.ErrorExecution="error.execution",e.ErrorCommunication="error.communication",e.ErrorPlatform="error.platform",e.ErrorCustom="xstate.error",e.Update="xstate.update",e.Pure="xstate.pure",e.Choose="xstate.choose"}(t.ActionTypes||(t.ActionTypes={})),t.SpecialTargets=void 0,function(e){e.Parent="#_parent",e.Internal="#_internal"}(t.SpecialTargets||(t.SpecialTargets={}))})(zr);var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});var Ot=zr,ap=Ot.ActionTypes.Start,sp=Ot.ActionTypes.Stop,up=Ot.ActionTypes.Raise,cp=Ot.ActionTypes.Send,lp=Ot.ActionTypes.Cancel,fp=Ot.ActionTypes.NullEvent,dp=Ot.ActionTypes.Assign,hp=Ot.ActionTypes.After,pp=Ot.ActionTypes.DoneState,vp=Ot.ActionTypes.Log,yp=Ot.ActionTypes.Init,mp=Ot.ActionTypes.Invoke,gp=Ot.ActionTypes.ErrorExecution,bp=Ot.ActionTypes.ErrorPlatform,Sp=Ot.ActionTypes.ErrorCustom,Cp=Ot.ActionTypes.Update,wp=Ot.ActionTypes.Choose,Tp=Ot.ActionTypes.Pure;Ct.after=hp;Ct.assign=dp;Ct.cancel=lp;Ct.choose=wp;Ct.doneState=pp;Ct.error=Sp;Ct.errorExecution=gp;Ct.errorPlatform=bp;Ct.init=yp;Ct.invoke=mp;Ct.log=vp;Ct.nullEvent=fp;Ct.pure=Tp;Ct.raise=up;Ct.send=cp;Ct.start=ap;Ct.stop=sp;Ct.update=Cp;var As={},mn={};Object.defineProperty(mn,"__esModule",{value:!0});var Ip=".",Ep={},xp="xstate.guard",Ap="";mn.DEFAULT_GUARD_TYPE=xp;mn.EMPTY_ACTIVITY_MAP=Ep;mn.STATE_DELIMITER=Ip;mn.TARGETLESS_KEY=Ap;var Hr={};Object.defineProperty(Hr,"__esModule",{value:!0});var Dp=process.env.NODE_ENV==="production";Hr.IS_PRODUCTION=Dp;(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=no,n=zr,r=Ct,i=mn,o=Hr,a;function u(p){return Object.keys(p)}function s(p,A,M){M===void 0&&(M=i.STATE_DELIMITER);var _=y(p,M),U=y(A,M);return ut(U)?ut(_)?U===_:!1:ut(_)?_ in U:Object.keys(_).every(function(k){return k in U?s(_[k],U[k]):!1})}function l(p){try{return ut(p)||typeof p=="number"?"".concat(p):p.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function f(p){try{return ut(p)||typeof p=="number"?"".concat(p):dt(p)?p.name:p.type}catch{throw new Error("Actions must be strings or objects with a string action.type property.")}}function h(p,A){try{return kt(p)?p:p.toString().split(A)}catch{throw new Error("'".concat(p,"' is not a valid state path."))}}function d(p){return typeof p=="object"&&"value"in p&&"context"in p&&"event"in p&&"_event"in p}function y(p,A){if(d(p))return p.value;if(kt(p))return m(p);if(typeof p!="string")return p;var M=h(p,A);return m(M)}function m(p){if(p.length===1)return p[0];for(var A={},M=A,_=0;_<p.length-1;_++)_===p.length-2?M[p[_]]=p[_+1]:(M[p[_]]={},M=M[p[_]]);return A}function v(p,A){for(var M={},_=Object.keys(p),U=0;U<_.length;U++){var k=_[U];M[k]=A(p[k],k,p,U)}return M}function w(p,A,M){var _,U,k={};try{for(var Y=e.__values(Object.keys(p)),H=Y.next();!H.done;H=Y.next()){var ct=H.value,gt=p[ct];M(gt)&&(k[ct]=A(gt,ct,p))}}catch(ae){_={error:ae}}finally{try{H&&!H.done&&(U=Y.return)&&U.call(Y)}finally{if(_)throw _.error}}return k}var E=function(p){return function(A){var M,_,U=A;try{for(var k=e.__values(p),Y=k.next();!Y.done;Y=k.next()){var H=Y.value;U=U[H]}}catch(ct){M={error:ct}}finally{try{Y&&!Y.done&&(_=k.return)&&_.call(k)}finally{if(M)throw M.error}}return U}};function C(p,A){return function(M){var _,U,k=M;try{for(var Y=e.__values(p),H=Y.next();!H.done;H=Y.next()){var ct=H.value;k=k[A][ct]}}catch(gt){_={error:gt}}finally{try{H&&!H.done&&(U=Y.return)&&U.call(Y)}finally{if(_)throw _.error}}return k}}function S(p){if(!p)return[[]];if(ut(p))return[[p]];var A=P(Object.keys(p).map(function(M){var _=p[M];return typeof _!="string"&&(!_||!Object.keys(_).length)?[[M]]:S(p[M]).map(function(U){return[M].concat(U)})}));return A}function I(p){var A,M,_={};if(p&&p.length===1&&p[0].length===1)return p[0][0];try{for(var U=e.__values(p),k=U.next();!k.done;k=U.next())for(var Y=k.value,H=_,ct=0;ct<Y.length;ct++){var gt=Y[ct];if(ct===Y.length-2){H[gt]=Y[ct+1];break}H[gt]=H[gt]||{},H=H[gt]}}catch(ae){A={error:ae}}finally{try{k&&!k.done&&(M=U.return)&&M.call(U)}finally{if(A)throw A.error}}return _}function P(p){var A;return(A=[]).concat.apply(A,e.__spreadArray([],e.__read(p),!1))}function g(p){return kt(p)?p:[p]}function N(p){return p===void 0?[]:g(p)}function F(p,A,M){var _,U;if(dt(p))return p(A,M.data);var k={};try{for(var Y=e.__values(Object.keys(p)),H=Y.next();!H.done;H=Y.next()){var ct=H.value,gt=p[ct];dt(gt)?k[ct]=gt(A,M.data):k[ct]=gt}}catch(ae){_={error:ae}}finally{try{H&&!H.done&&(U=Y.return)&&U.call(Y)}finally{if(_)throw _.error}}return k}function $(p){return/^(done|error)\./.test(p)}function z(p){return!!(p instanceof Promise||p!==null&&(dt(p)||typeof p=="object")&&dt(p.then))}function q(p){return p!==null&&typeof p=="object"&&"transition"in p&&typeof p.transition=="function"}function D(p,A){var M,_,U=e.__read([[],[]],2),k=U[0],Y=U[1];try{for(var H=e.__values(p),ct=H.next();!ct.done;ct=H.next()){var gt=ct.value;A(gt)?k.push(gt):Y.push(gt)}}catch(ae){M={error:ae}}finally{try{ct&&!ct.done&&(_=H.return)&&_.call(H)}finally{if(M)throw M.error}}return[k,Y]}function et(p,A){return v(p.states,function(M,_){if(M){var U=(ut(A)?void 0:A[_])||(M?M.current:void 0);if(U)return{current:U,states:et(M,U)}}})}function mt(p,A){return{current:A,states:et(p,A)}}function Qt(p,A,M,_){o.IS_PRODUCTION||t.warn(!!p,"Attempting to update undefined context");var U=p&&M.reduce(function(k,Y){var H,ct,gt=Y.assignment,ae={state:_,action:Y,_event:A},ti={};if(dt(gt))ti=gt(k,A.data,ae);else try{for(var nr=e.__values(Object.keys(gt)),Tn=nr.next();!Tn.done;Tn=nr.next()){var ho=Tn.value,ei=gt[ho];ti[ho]=dt(ei)?ei(k,A.data,ae):ei}}catch(Iu){H={error:Iu}}finally{try{Tn&&!Tn.done&&(ct=nr.return)&&ct.call(nr)}finally{if(H)throw H.error}}return Object.assign({},k,ti)},p);return U}t.warn=function(){},o.IS_PRODUCTION||(t.warn=function(p,A){var M=p instanceof Error?p:void 0;if(!(!M&&p)&&console!==void 0){var _=["Warning: ".concat(A)];M&&_.push(M),console.warn.apply(console,_)}});function kt(p){return Array.isArray(p)}function dt(p){return typeof p=="function"}function ut(p){return typeof p=="string"}function Et(p,A){if(p)return ut(p)?{type:i.DEFAULT_GUARD_TYPE,name:p,predicate:A?A[p]:void 0}:dt(p)?{type:i.DEFAULT_GUARD_TYPE,name:p.name,predicate:p}:p}function tr(p){try{return"subscribe"in p&&dt(p.subscribe)}catch{return!1}}var Bt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),Zr=(a={},a[Bt]=function(){return this},a[Symbol.observable]=function(){return this},a);function er(p){return!!p&&"__xstatenode"in p}function Lt(p){return!!p&&typeof p.send=="function"}var Te=function(){var p=0;return function(){return p++,p.toString(16)}}();function fo(p,A){return ut(p)||typeof p=="number"?e.__assign({type:p},A):p}function vu(p,A){if(!ut(p)&&"$$type"in p&&p.$$type==="scxml")return p;var M=fo(p);return e.__assign({name:M.type,data:M,$$type:"scxml",type:"external"},A)}function yu(p,A){var M=g(A).map(function(_){return typeof _>"u"||typeof _=="string"||er(_)?{target:_,event:p}:e.__assign(e.__assign({},_),{event:p})});return M}function mu(p){if(!(p===void 0||p===i.TARGETLESS_KEY))return N(p)}function gu(p,A,M){if(!o.IS_PRODUCTION){var _=p.stack?" Stacktrace was '".concat(p.stack,"'"):"";if(p===A)console.error("Missing onError handler for invocation '".concat(M,"', error was '").concat(p,"'.").concat(_));else{var U=A.stack?" Stacktrace was '".concat(A.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(M,"'. ")+"Original error: '".concat(p,"'. ").concat(_," Current error is '").concat(A,"'.").concat(U))}}}function bu(p,A,M,_,U){var k=p.options.guards,Y={state:U,cond:A,_event:_};if(A.type===i.DEFAULT_GUARD_TYPE)return((k==null?void 0:k[A.name])||A.predicate)(M,_.data,Y);var H=k==null?void 0:k[A.type];if(!H)throw new Error("Guard '".concat(A.type,"' is not implemented on machine '").concat(p.id,"'."));return H(M,_.data,Y)}function Su(p){return typeof p=="string"?{type:p}:p}function Cu(p,A,M){var _=function(){},U=typeof p=="object",k=U?p:null;return{next:((U?p.next:p)||_).bind(k),error:((U?p.error:A)||_).bind(k),complete:((U?p.complete:M)||_).bind(k)}}function wu(p,A){return"".concat(p,":invocation[").concat(A,"]")}function Tu(p){return(p.type===r.raise||p.type===r.send&&p.to===n.SpecialTargets.Internal)&&typeof p.delay!="number"}t.createInvokeId=wu,t.evaluateGuard=bu,t.flatten=P,t.getActionType=f,t.getEventType=l,t.interopSymbols=Zr,t.isActor=Lt,t.isArray=kt,t.isBehavior=q,t.isBuiltInEvent=$,t.isFunction=dt,t.isMachine=er,t.isObservable=tr,t.isPromiseLike=z,t.isRaisableAction=Tu,t.isStateLike=d,t.isString=ut,t.keys=u,t.mapContext=F,t.mapFilterValues=w,t.mapValues=v,t.matchesState=s,t.nestedPath=C,t.normalizeTarget=mu,t.partition=D,t.path=E,t.pathToStateValue=m,t.pathsToStateValue=I,t.reportUnhandledExceptionOnInvocation=gu,t.symbolObservable=Bt,t.toArray=N,t.toArrayStrict=g,t.toEventObject=fo,t.toGuard=Et,t.toInvokeSource=Su,t.toObserver=Cu,t.toSCXMLEvent=vu,t.toStatePath=h,t.toStatePaths=S,t.toStateValue=y,t.toTransitionConfigArray=yu,t.uniqueId=Te,t.updateContext=Qt,t.updateHistoryStates=et,t.updateHistoryValue=mt})(As);Object.defineProperty(rt,"__esModule",{value:!0});var tt=no,Yt=zr,Dt=Ct,W=As,Ds=Hr,Op=W.toSCXMLEvent({type:Dt.init});function Di(t,e){return e&&e[t]||void 0}function Wr(t,e){var n;if(W.isString(t)||typeof t=="number"){var r=Di(t,e);W.isFunction(r)?n={type:t,exec:r}:r?n=r:n={type:t,exec:void 0}}else if(W.isFunction(t))n={type:t.name||t.toString(),exec:t};else{var r=Di(t.type,e);if(W.isFunction(r))n=tt.__assign(tt.__assign({},t),{exec:r});else if(r){var i=r.type||t.type;n=tt.__assign(tt.__assign(tt.__assign({},r),t),{type:i})}else n=t}return n}var Oi=function(t,e){if(!t)return[];var n=W.isArray(t)?t:[t];return n.map(function(r){return Wr(r,e)})};function ro(t){var e=Wr(t);return tt.__assign(tt.__assign({id:W.isString(t)?t:e.id},e),{type:e.type})}function Np(t,e){return{type:Dt.raise,event:typeof t=="function"?t:W.toEventObject(t),delay:e?e.delay:void 0,id:e==null?void 0:e.id}}function Os(t,e,n,r){var i={_event:n},o=W.toSCXMLEvent(W.isFunction(t.event)?t.event(e,n.data,i):t.event),a;if(W.isString(t.delay)){var u=r&&r[t.delay];a=W.isFunction(u)?u(e,n.data,i):u}else a=W.isFunction(t.delay)?t.delay(e,n.data,i):t.delay;return tt.__assign(tt.__assign({},t),{type:Dt.raise,_event:o,delay:a})}function Xn(t,e){return{to:e?e.to:void 0,type:Dt.send,event:W.isFunction(t)?t:W.toEventObject(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:W.isFunction(t)?t.name:W.getEventType(t)}}function Ns(t,e,n,r){var i={_event:n},o=W.toSCXMLEvent(W.isFunction(t.event)?t.event(e,n.data,i):t.event),a;if(W.isString(t.delay)){var u=r&&r[t.delay];a=W.isFunction(u)?u(e,n.data,i):u}else a=W.isFunction(t.delay)?t.delay(e,n.data,i):t.delay;var s=W.isFunction(t.to)?t.to(e,n.data,i):t.to;return tt.__assign(tt.__assign({},t),{to:s,_event:o,event:o.data,delay:a})}function io(t,e){return Xn(t,tt.__assign(tt.__assign({},e),{to:Yt.SpecialTargets.Parent}))}function _p(t,e,n){return Xn(e,tt.__assign(tt.__assign({},n),{to:t}))}function Mp(){return io(Dt.update)}function $p(t,e){return Xn(t,tt.__assign(tt.__assign({},e),{to:function(n,r,i){var o=i._event;return o.origin}}))}var qp=function(t,e){return{context:t,event:e}};function Pp(t,e){return t===void 0&&(t=qp),{type:Dt.log,label:e,expr:t}}var _s=function(t,e,n){return tt.__assign(tt.__assign({},t),{value:W.isString(t.expr)?t.expr:t.expr(e,n.data,{_event:n})})},Rp=function(t){return{type:Dt.cancel,sendId:t}};function jp(t){var e=ro(t);return{type:Yt.ActionTypes.Start,activity:e,exec:void 0}}function Up(t){var e=W.isFunction(t)?t:ro(t);return{type:Yt.ActionTypes.Stop,activity:e,exec:void 0}}function Ms(t,e,n){var r=W.isFunction(t.activity)?t.activity(e,n.data):t.activity,i=typeof r=="string"?{id:r}:r,o={type:Yt.ActionTypes.Stop,activity:i};return o}var kp=function(t){return{type:Dt.assign,assignment:t}};function Bp(t){return typeof t=="object"&&"type"in t}function Vp(t,e){var n=e?"#".concat(e):"";return"".concat(Yt.ActionTypes.After,"(").concat(t,")").concat(n)}function Fp(t,e){var n="".concat(Yt.ActionTypes.DoneState,".").concat(t),r={type:n,data:e};return r.toString=function(){return n},r}function Gp(t,e){var n="".concat(Yt.ActionTypes.DoneInvoke,".").concat(t),r={type:n,data:e};return r.toString=function(){return n},r}function Lp(t,e){var n="".concat(Yt.ActionTypes.ErrorPlatform,".").concat(t),r={type:n,data:e};return r.toString=function(){return n},r}function zp(t){return{type:Yt.ActionTypes.Pure,get:t}}function Hp(t,e){if(!Ds.IS_PRODUCTION&&(!t||typeof t=="function")){var n=t;t=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=typeof n=="function"?n.apply(void 0,tt.__spreadArray([],tt.__read(r),!1)):n;if(!o)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return o}}return Xn(function(r,i){return i},tt.__assign(tt.__assign({},e),{to:t}))}function Wp(t,e){return io(function(n,r,i){return{type:Dt.error,data:W.isFunction(t)?t(n,r,i):t}},tt.__assign(tt.__assign({},e),{to:Yt.SpecialTargets.Parent}))}function Kp(t){return{type:Yt.ActionTypes.Choose,conds:t}}var Jp=function(t){var e,n,r=[];try{for(var i=tt.__values(t),o=i.next();!o.done;o=i.next())for(var a=o.value,u=0;u<a.actions.length;){if(a.actions[u].type===Dt.assign){r.push(a.actions[u]),a.actions.splice(u,1);continue}u++}}catch(s){e={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r};function Ni(t,e,n,r,i,o,a){a===void 0&&(a=!1);var u=a?[]:Jp(i),s=u.length?W.updateContext(n,r,u,e):n,l=a?[n]:void 0,f=[];function h(m,v){var w;switch(v.type){case Dt.raise:{var E=Os(v,s,r,t.options.delays);return o&&typeof E.delay=="number"&&o(E,s,r),E}case Dt.send:var C=Ns(v,s,r,t.options.delays);if(!Ds.IS_PRODUCTION){var S=v.delay;W.warn(!W.isString(S)||typeof C.delay=="number","No delay reference for delay expression '".concat(S,"' was found on machine '").concat(t.id,"'"))}return o&&C.to!==Yt.SpecialTargets.Internal&&(m==="entry"?f.push(C):o(C,s,r)),C;case Dt.log:{var I=_s(v,s,r);return o==null||o(I,s,r),I}case Dt.choose:{var P=v,g=(w=P.conds.find(function(dt){var ut=W.toGuard(dt.cond,t.options.guards);return!ut||W.evaluateGuard(t,ut,s,r,o?void 0:e)}))===null||w===void 0?void 0:w.actions;if(!g)return[];var N=tt.__read(Ni(t,e,s,r,[{type:m,actions:Oi(W.toArray(g),t.options.actions)}],o,a),2),F=N[0],$=N[1];return s=$,l==null||l.push(s),F}case Dt.pure:{var g=v.get(s,r.data);if(!g)return[];var z=tt.__read(Ni(t,e,s,r,[{type:m,actions:Oi(W.toArray(g),t.options.actions)}],o,a),2),q=z[0],D=z[1];return s=D,l==null||l.push(s),q}case Dt.stop:{var I=Ms(v,s,r);return o==null||o(I,n,r),I}case Dt.assign:{s=W.updateContext(s,r,[v],o?void 0:e),l==null||l.push(s);break}default:var et=Wr(v,t.options.actions),mt=et.exec;if(o)o(et,s,r);else if(mt&&l){var Qt=l.length-1,kt=tt.__assign(tt.__assign({},et),{exec:function(dt){for(var ut=[],Et=1;Et<arguments.length;Et++)ut[Et-1]=arguments[Et];mt.apply(void 0,tt.__spreadArray([l[Qt]],tt.__read(ut),!1))}});et=kt}return et}}function d(m){var v,w,E=[];try{for(var C=tt.__values(m.actions),S=C.next();!S.done;S=C.next()){var I=S.value,P=h(m.type,I);P&&(E=E.concat(P))}}catch(g){v={error:g}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(v)throw v.error}}return f.forEach(function(g){o(g,s,r)}),f.length=0,E}var y=W.flatten(i.map(d));return[y,s]}rt.actionTypes=Dt;rt.after=Vp;rt.assign=kp;rt.cancel=Rp;rt.choose=Kp;rt.done=Fp;rt.doneInvoke=Gp;rt.error=Lp;rt.escalate=Wp;rt.forwardTo=Hp;rt.getActionFunction=Di;rt.initEvent=Op;rt.isActionObject=Bp;var Wt=rt.log=Pp,Xp=rt.pure=zp;rt.raise=Np;rt.resolveActions=Ni;rt.resolveLog=_s;rt.resolveRaise=Os;rt.resolveSend=Ns;rt.resolveStop=Ms;rt.respond=$p;rt.send=Xn;rt.sendParent=io;rt.sendTo=_p;rt.sendUpdate=Mp;rt.start=jp;var Wo=rt.stop=Up;rt.toActionObject=Wr;rt.toActionObjects=Oi;rt.toActivityDefinition=ro;var _i={exports:{}},ri={},lr={exports:{}},ii={};/**
|
|
36
|
+
* @license React
|
|
37
|
+
* use-sync-external-store-shim.production.min.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/var Ko;function Yp(){if(Ko)return ii;Ko=1;var t=X;function e(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,o=t.useLayoutEffect,a=t.useDebugValue;function u(h,d){var y=d(),m=r({inst:{value:y,getSnapshot:d}}),v=m[0].inst,w=m[1];return o(function(){v.value=y,v.getSnapshot=d,s(v)&&w({inst:v})},[h,y,d]),i(function(){return s(v)&&w({inst:v}),h(function(){s(v)&&w({inst:v})})},[h]),a(y),y}function s(h){var d=h.getSnapshot;h=h.value;try{var y=d();return!n(h,y)}catch{return!0}}function l(h,d){return d()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:u;return ii.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,ii}var oi={};/**
|
|
44
|
+
* @license React
|
|
45
|
+
* use-sync-external-store-shim.development.js
|
|
46
|
+
*
|
|
47
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the MIT license found in the
|
|
50
|
+
* LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/var Jo;function Qp(){return Jo||(Jo=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=X,e=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(S){{for(var I=arguments.length,P=new Array(I>1?I-1:0),g=1;g<I;g++)P[g-1]=arguments[g];r("error",S,P)}}function r(S,I,P){{var g=e.ReactDebugCurrentFrame,N=g.getStackAddendum();N!==""&&(I+="%s",P=P.concat([N]));var F=P.map(function($){return String($)});F.unshift("Warning: "+I),Function.prototype.apply.call(console[S],console,F)}}function i(S,I){return S===I&&(S!==0||1/S===1/I)||S!==S&&I!==I}var o=typeof Object.is=="function"?Object.is:i,a=t.useState,u=t.useEffect,s=t.useLayoutEffect,l=t.useDebugValue,f=!1,h=!1;function d(S,I,P){f||t.startTransition!==void 0&&(f=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=I();if(!h){var N=I();o(g,N)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),h=!0)}var F=a({inst:{value:g,getSnapshot:I}}),$=F[0].inst,z=F[1];return s(function(){$.value=g,$.getSnapshot=I,y($)&&z({inst:$})},[S,g,I]),u(function(){y($)&&z({inst:$});var q=function(){y($)&&z({inst:$})};return S(q)},[S]),l(g),g}function y(S){var I=S.getSnapshot,P=S.value;try{var g=I();return!o(P,g)}catch{return!0}}function m(S,I,P){return I()}var v=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",w=!v,E=w?m:d,C=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:E;oi.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),oi}var Xo;function $s(){return Xo||(Xo=1,process.env.NODE_ENV==="production"?lr.exports=Yp():lr.exports=Qp()),lr.exports}/**
|
|
52
|
+
* @license React
|
|
53
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
54
|
+
*
|
|
55
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the MIT license found in the
|
|
58
|
+
* LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/var Yo;function Zp(){if(Yo)return ri;Yo=1;var t=X,e=$s();function n(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,o=t.useRef,a=t.useEffect,u=t.useMemo,s=t.useDebugValue;return ri.useSyncExternalStoreWithSelector=function(l,f,h,d,y){var m=o(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=u(function(){function E(g){if(!C){if(C=!0,S=g,g=d(g),y!==void 0&&v.hasValue){var N=v.value;if(y(N,g))return I=N}return I=g}if(N=I,r(S,g))return N;var F=d(g);return y!==void 0&&y(N,F)?N:(S=g,I=F)}var C=!1,S,I,P=h===void 0?null:h;return[function(){return E(f())},P===null?void 0:function(){return E(P())}]},[f,h,d,y]);var w=i(l,m[0],m[1]);return a(function(){v.hasValue=!0,v.value=w},[w]),s(w),w},ri}var ai={};/**
|
|
60
|
+
* @license React
|
|
61
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
62
|
+
*
|
|
63
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the MIT license found in the
|
|
66
|
+
* LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/var Qo;function tv(){return Qo||(Qo=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=X,e=$s();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,o=t.useRef,a=t.useEffect,u=t.useMemo,s=t.useDebugValue;function l(f,h,d,y,m){var v=o(null),w;v.current===null?(w={hasValue:!1,value:null},v.current=w):w=v.current;var E=u(function(){var P=!1,g,N,F=function(D){if(!P){P=!0,g=D;var et=y(D);if(m!==void 0&&w.hasValue){var mt=w.value;if(m(mt,et))return N=mt,mt}return N=et,et}var Qt=g,kt=N;if(r(Qt,D))return kt;var dt=y(D);return m!==void 0&&m(kt,dt)?kt:(g=D,N=dt,dt)},$=d===void 0?null:d,z=function(){return F(h())},q=$===null?void 0:function(){return F($())};return[z,q]},[h,d,y,m]),C=E[0],S=E[1],I=i(f,C,S);return a(function(){w.hasValue=!0,w.value=I},[I]),s(I),I}ai.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ai}process.env.NODE_ENV==="production"?_i.exports=Zp():_i.exports=tv();var ev=_i.exports,nv=X.useLayoutEffect;function Zo(t){var e=xu.useRef();return e.current||(e.current={v:t()}),e.current.v}var Ar=globalThis&&globalThis.__assign||function(){return Ar=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},Ar.apply(this,arguments)},rv=globalThis&&globalThis.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},iv=globalThis&&globalThis.__read||function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(u){a={error:u}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return o};function ov(t,e){var n=Zo(function(){return typeof t=="function"?t():t});if(process.env.NODE_ENV!=="production"&&typeof t!="function"){var r=iv(X.useState(n),1),i=r[0];t!==i&&console.warn("Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\nPlease make sure that you pass the same Machine as argument each time.")}var o=e.context,a=e.guards,u=e.actions,s=e.activities,l=e.services,f=e.delays;e.state;var h=rv(e,["context","guards","actions","activities","services","delays","state"]),d=Zo(function(){var y={context:o,guards:a,actions:u,activities:s,services:l,delays:f},m=n.withConfig(y,function(){return Ar(Ar({},n.context),o)});return Es(m,h)});return nv(function(){Object.assign(d.machine.options.actions,u),Object.assign(d.machine.options.guards,a),Object.assign(d.machine.options.activities,s),Object.assign(d.machine.options.services,l),Object.assign(d.machine.options.delays,f)},[u,a,s,l,f]),d}globalThis&&globalThis.__read;globalThis&&globalThis.__values;function av(t,e,n){if(t.status===bt.NotStarted)return!0;var r=n.changed===void 0&&(Object.keys(n.children).length>0||typeof e.changed=="boolean");return!(n.changed||r)}var sv=globalThis&&globalThis.__read||function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(u){a={error:u}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return o};function uv(t){return t}function cv(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=sv(e,1),i=r[0],o=i===void 0?{}:i,a=ov(t,o),u=X.useCallback(function(){return a.status===bt.NotStarted?o.state?Jt.create(o.state):a.machine.initialState:a.getSnapshot()},[a]),s=X.useCallback(function(h,d){return av(a,h,d)},[a]),l=X.useCallback(function(h){var d=a.subscribe(h).unsubscribe;return d},[a]),f=ev.useSyncExternalStoreWithSelector(l,u,u,uv,s);return X.useEffect(function(){var h=o.state;return a.start(h?Jt.create(h):void 0),function(){a.stop(),a.status=bt.NotStarted}},[]),[f,a.send,a]}var lv=globalThis&&globalThis.__spreadArray||function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))};function Yn(t){return t}function qs(t){return function(){return t}}var fv=qs(null),Ps=qs(void 0),dv=Ps;function Rs(t,e,n,r,i,o,a,u,s){switch(arguments.length){case 1:return t;case 2:return function(){return e(t.apply(this,arguments))};case 3:return function(){return n(e(t.apply(this,arguments)))};case 4:return function(){return r(n(e(t.apply(this,arguments))))};case 5:return function(){return i(r(n(e(t.apply(this,arguments)))))};case 6:return function(){return o(i(r(n(e(t.apply(this,arguments))))))};case 7:return function(){return a(o(i(r(n(e(t.apply(this,arguments)))))))};case 8:return function(){return u(a(o(i(r(n(e(t.apply(this,arguments))))))))};case 9:return function(){return s(u(a(o(i(r(n(e(t.apply(this,arguments)))))))))}}}function G(t,e,n,r,i,o,a,u,s){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return i(r(n(e(t))));case 6:return o(i(r(n(e(t)))));case 7:return a(o(i(r(n(e(t))))));case 8:return u(a(o(i(r(n(e(t)))))));case 9:return s(u(a(o(i(r(n(e(t))))))));default:{for(var l=arguments[0],f=1;f<arguments.length;f++)l=arguments[f](l);return l}}}var oo=function(t,e){var n=typeof t=="number"?function(r){return r.length>=t}:t;return function(){var r=Array.from(arguments);return n(arguments)?e.apply(this,r):function(i){return e.apply(void 0,lv([i],r,!1))}}},js=function(t){return t._tag==="Some"},Us={_tag:"None"},ks=function(t){return{_tag:"Some",value:t}},hv=function(t){return t.length>0},pv=[],vv=Object.prototype.hasOwnProperty;function yv(t){return function(e,n){return t.chain(e,function(r){return t.map(n(r),function(){return r})})}}var ce=function(t){return{equals:function(e,n){return e===n||t(e,n)}}},Pe=function(t){return ce(function(e,n){for(var r in t)if(!t[r].equals(e[r],n[r]))return!1;return!0})},Bs={equals:function(t,e){return t===e}};Bs.equals;var oe=Us,Re=ks;function Kr(t){return function(e){return t(e)?Re(e):oe}}var mv=function(t,e){return G(t,le(e))},gv=function(t,e){return G(t,Sv(e))},bv="Option",le=function(t){return function(e){return Ke(e)?oe:Re(t(e.value))}},Sv=function(t){return function(e){return Ke(e)||Ke(t)?oe:Re(e.value(t.value))}},Vs=oo(2,function(t,e){return Ke(t)?oe:e(t.value)}),Cv={URI:bv,map:mv,ap:gv,chain:Vs},je=function(t){return function(e){return Ke(e)?oe:t(e.value)?e:oe}},Ke=function(t){return t._tag==="None"},wv=function(t,e){return function(n){return Ke(n)?t():e(n.value)}},ao=wv,Tv=function(t){return function(e){return Ke(e)?t():e.value}},fn=Tv,Iv=oo(2,yv(Cv)),$t=function(t){return t==null?oe:Re(t)},Jr=ao(fv,Yn),gn=ao(Ps,Yn),Ev=Vs,xv=Iv,so={equals:function(t,e){return t===e}};so.equals;so.equals;var Av=pv,Dv=hv,Ov=function(t){return t.length===0},Fs=Dv,Nv=function(t){return function(e){if(Ov(e))return $v;for(var n=[],r=0;r<e.length;r++)n.push.apply(n,t(r,e[r]));return n}};function Gs(t){return function(e){for(var n=0;n<e.length;n++)if(t(e[n]))return ks(e[n]);return Us}}var _v=function(t,e,n){for(var r=[],i=Math.min(t.length,e.length),o=0;o<i;o++)r[o]=n(t[o],e[o]);return r};function Ls(t,e){return e===void 0?function(n){return Ls(n,t)}:_v(t,e,function(n,r){return[n,r]})}var zs=oo(2,function(t,e){return G(t,Nv(function(n,r){return e(r,n)}))}),Hs=zs(Yn),ye=function(t){return function(e){return e.map(function(n){return t(n)})}},Ft=function(t){return function(e){return e.filter(t)}},Mv=function(t){return function(e){for(var n=[],r=0;r<e.length;r++){var i=t(r,e[r]);js(i)&&n.push(i.value)}return n}},Ye=function(t){return Mv(function(e,n){return t(n)})},si=Ye(Yn),uo=function(t){return ce(function(e,n){return e.length===n.length&&e.every(function(r,i){return t.equals(r,n[i])})})},$v=Av;function qv(t){return function(e){return e.every(t)}}var Pv=zs,Ut={equals:function(t,e){return t===e}};Ut.equals;var Ws={equals:function(t,e){return t===e}};Ws.equals;function Ks(t){return function(e,n){if(n===void 0){var r=Ks(t);return function(o){return r(o,e)}}for(var i in e)if(!vv.call(n,i)||!t.equals(e[i],n[i]))return!1;return!0}}function Rv(t){var e=Ks(t);return ce(function(n,r){return e(n)(r)&&e(r)(n)})}function jv(t){return{equals(e,n){return e==null&&n==null?!0:e==null||n===null||n===void 0?!1:t.equals(e,n)}}}function Js(t){return{equals(e,n){const r=G($t(e),fn(()=>[])),i=G($t(n),fn(()=>[]));return uo(t).equals(r,i)}}}const bn=Pe({localId:Ut,componentPath:Js(Ut),sharedConfigurationModelId:jv(Ut)}),Uv=Pe({localId:Ut,configurationModelId:Ut}),kv=ce((t,e)=>O({x:t,y:e}).with({x:{type:"Choice"},y:{type:"Choice"}},n=>Bv.equals(n.x,n.y)).with({x:{type:"Component"},y:{type:"Component"}},n=>Vv.equals(n.x,n.y)).with({x:{type:"Numeric"},y:{type:"Numeric"}},n=>Fv.equals(n.x,n.y)).with({x:{type:"Boolean"},y:{type:"Boolean"}},n=>Gv.equals(n.x,n.y)).otherwise(()=>!1)),Bv=Pe({type:Ut,attributeId:bn,state:Ut,choiceValueId:Ut}),Vv=Pe({type:Ut,attributeId:bn,state:Ut}),Fv=Pe({type:Ut,attributeId:bn,state:so}),Gv=Pe({type:Ut,attributeId:bn,state:Ws});var Xs=(t=>(t.whyIsNotSatisfied="why-is-not-satisfied",t.whyIsStateNotPossible="why-is-state-not-possible",t))(Xs||{}),Ys=(t=>(t.choiceValue="choice-value",t.component="component",t.boolean="boolean",t.numeric="numeric",t.configuration="configuration",t.attribute="attribute",t))(Ys||{}),qt=(t=>(t.Boolean="Boolean",t.Numeric="Numeric",t.Choice="Choice",t.Component="Component",t))(qt||{}),Xr=(t=>(t.Implicit="Implicit",t.Explicit="Explicit",t))(Xr||{});function Lv(t,e){return G(t.values,Ye(n=>G(n.decision,$t,je(r=>r.kind===e))))}function zv(t){return G(t.decision,$t,je(e=>e.kind===Xr.Explicit),Jr)}function Hv(t){return G(t.decision,$t,je(e=>e.kind===Xr.Explicit),Jr)}function Wv(t){return G(t.decision,$t,Jr)}const Qs=t=>t.type===qt.Boolean,Zs=t=>t.type===qt.Choice,tu=t=>t.type===qt.Numeric,eu=t=>t.type===qt.Component,Kv=Js(Ut);function Jv(t,e,n){var r;const i=((r=e.componentPath)==null?void 0:r.length)??0;return G(t,Ft(o=>{var a;const u=((a=o.id.componentPath)==null?void 0:a.length)??0;return n?i>u?!1:G(o.id.componentPath??[],Ls(e.componentPath??[]),qv(([s,l])=>s===l)):Kv.equals(o.id.componentPath,e.componentPath)}))}function Xv(t,e,n){return[]}function Yv(t){return G(t,Ft(e=>{const n=G(e.id.componentPath,$t,le(i=>i.length===0),fn(()=>!0)),r=G(e.id.sharedConfigurationModelId,$t,ao(()=>!0,()=>!1));return n&&r}))}function Qv(t,e){return G(nu(t),ye(n=>Lv(n,e)),Hs,Ye(n=>$t(n)))}function Zv(t,e){return G(iu(t),Ft(n=>{var r;return((r=n.decision)==null?void 0:r.kind)===e}),ye(n=>zv(n)),Ye(n=>$t(n)))}function ty(t,e){return G(ou(t),Ft(n=>{var r;return((r=n.decision)==null?void 0:r.kind)===e}),ye(n=>Hv(n)),Ye(n=>$t(n)))}function ey(t,e){return G(ru(t),Ft(n=>{var r;return((r=n.decision)==null?void 0:r.kind)===e}),ye(n=>Wv(n)),Ye(n=>$t(n)))}function nu(t){return G(t.attributes,Ft(Zs))}function ru(t){return G(t.attributes,Ft(eu))}function iu(t){return G(t.attributes,Ft(tu))}function ou(t){return G(t.attributes,Ft(Qs))}function ny(t,e){return G(Qn(t,e),gn)}function ry(t,e){return G(au(t,e),gn)}function iy(t,e,n){return G(au(t,e),le(r=>r.values),Ev(Rs(Gs(r=>r.id===n))),gn)}function oy(t,e){return G(Qn(t,e),je(tu),gn)}function ay(t,e){return G(Qn(t,e),je(Qs),gn)}function sy(t,e){return G(Qn(t,e),je(eu),gn)}function Qn(t,e){return G(t.attributes,Gs(n=>bn.equals(n.id,e)))}function au(t,e){return G(Qn(t,e),je(Zs))}const Sn=Object.freeze(Object.defineProperty({__proto__:null,filterAttributesOfComponent:Jv,filterAttributesOfRoot:Yv,filterAttributesOfShared:Xv,getAttribute:ny,getBooleanAttribute:ay,getBooleanAttributes:ou,getBooleanDecisions:ty,getChoiceAttribute:ry,getChoiceAttributes:nu,getChoiceDecisions:Qv,getChoiceValue:iy,getComponentAttribute:sy,getComponentAttributes:ru,getComponentDecisions:ey,getNumericAttribute:oy,getNumericAttributes:iu,getNumericDecisions:Zv},Symbol.toStringTag,{value:"Module"}));Xs.whyIsNotSatisfied,Ys.configuration;const ta=bn.equals;Uv.equals;kv.equals;function Mi(t){return ce((e,n)=>{const r=e==null,i=n==null;return r&&i||!r&&!i&&t.equals(e,n)})}const su=X.createContext(null),uu=X.createContext(null),cu=X.createContext(null),lu=X.createContext(null),co=()=>X.useContext(su),Cn=()=>X.useContext(lu),fu="The configuration is not initialized. Consider using the ConfigurationSuspender or unload components manually that make use of any unsafe hook while the configuration is initializing. Check the hooks documentation to see if it is safe to use while the configuration is initializing.";function lo(t){if(!t)throw new Error(fu)}function wn(t){if(!t)throw new Error(fu)}function Zn(){const t=co();return lo(t),X.useMemo(()=>({makeDecision:e=>t.makeDecision(e),setManyDecision:(e,n)=>t.setMany(e,n)}),[t])}var Yr=function(t){return function(e){return js(t(e))}};const uy=Yr(t=>t.type===qt.Choice?Re(t):oe),cy=Yr(t=>t.type===qt.Numeric?Re(t):oe),ly=Yr(t=>t.type===qt.Boolean?Re(t):oe),fy=Yr(t=>t.type===qt.Component?Re(t):oe);function Qr(t){return t.decision!=null&&t.decision.kind===Xr.Explicit}function du(t){return G(t.values,Ft(Qr),ye(e=>({type:qt.Choice,attributeId:t.id,choiceValueId:e.id,state:null})))}function dy(t){return G(t,Kr(Qr),le(()=>({type:qt.Numeric,attributeId:t.id,state:null})))}function hy(t){return G(t,Kr(Qr),le(()=>({type:qt.Boolean,attributeId:t.id,state:null})))}function py(t){return G(t,Kr(Qr),le(()=>({type:qt.Component,attributeId:t.id,state:null})))}function vy(t,e){return G(Sn.filterAttributesOfComponent(e,t,!0),n=>[G(n,Ft(uy),Pv(du)),G(n,Ft(cy),ye(dy),si),G(n,Ft(ly),ye(hy),si),G(n,Ft(fy),ye(py),si)],Hs)}function yy(t,e){const n=Cn();return wn(n),X.useMemo(()=>G($t(t),le(Rs(ye(r=>Sn.getAttribute(n,r)),e??!1?Yn:Ye($t))),fn(()=>n.attributes)),[t,n,e])}function my(t){const e=Cn(),{makeDecision:n,setManyDecision:r}=Zn();wn(e);const i=Sn.getChoiceAttribute(e,t),o=X.useMemo(()=>({makeDecision:(u,s)=>n({type:qt.Choice,attributeId:t,choiceValueId:u,state:s}),clearDecisions:G(i,$t,le(du),je(Fs),le(u=>()=>r(u,{type:"Default"})),fn(()=>()=>Promise.resolve()))}),[t,i,n,r]),a=X.useMemo(()=>({...o,attribute:i}),[i,o]);if(i)return a}function gy(t){const e=Cn(),{makeDecision:n}=Zn();wn(e);const r=Sn.getNumericAttribute(e,t),i=X.useMemo(()=>({makeDecision:a=>n({type:qt.Numeric,attributeId:t,state:a})}),[t,n]),o=X.useMemo(()=>({...i,attribute:r}),[r,i]);if(r)return o}function by(t){const e=Cn(),{makeDecision:n}=Zn();wn(e);const r=Sn.getBooleanAttribute(e,t),i=X.useMemo(()=>({makeDecision:a=>n({type:qt.Boolean,attributeId:t,state:a})}),[t,n]),o=X.useMemo(()=>({...i,attribute:r}),[r,i]);if(r)return o}function Sy(t){const e=Cn(),{makeDecision:n,setManyDecision:r}=Zn();wn(e);const i=e.attributes,o=Sn.getComponentAttribute(e,t),a=X.useMemo(()=>({makeDecision:s=>n({type:qt.Component,attributeId:t,state:s}),clearSubtree:G(vy(t,i),Kr(Fs),le(s=>()=>r(s,{type:"Default"})),fn(()=>()=>Promise.resolve()))}),[t,n,i,r]),u=X.useMemo(()=>({...a,attribute:o}),[o,a]);if(o)return u}const Cy=ce((t,e)=>Rv(Ut).equals(t??{},e??{})),wy=Pe({attributeId:ce(ta),decisions:uo(ce(ta))}),Ty=ce((t,e)=>uo(wy).equals(t??[],e??[])),ui=Pe({configurationModelSource:ce((t,e)=>ah(t,e)),attributeRelations:Ty,usageRuleParameters:Cy}),Iy=Bs,ci=Mi(Iy),Ey=()=>eo({predictableActionArguments:!0,preserveActionOrder:!0,schema:{context:{},events:{}},context:{desiredClient:null,desiredSessionContext:null,actualClient:null,session:null,sessionCreationError:null,sessionUpdateError:null,hasEverSuccessfullyCreatedSession:!1},initial:"ProcessChanges",on:{ChangeConfigurationClient:{actions:["saveDesiredClient"]},ChangeSessionContext:{actions:["saveDesiredSessionContext"]}},exit:[Wt("Shutting down","SessionManagement:"),"disposeOldSession"],states:{ProcessChanges:{entry:[Wt("Entering ProcessChanges","SessionManagement:"),nn(2)],always:[{target:"DisposeSession",cond:"shallDisposeSession"},{target:"CreateSession",cond:"shallCreateSession"},{target:"UpdateSession",cond:"shallUpdateSession"}]},DisposeSession:{entry:[Wt("Entering DisposeSession","SessionManagement:"),nn(2)],always:{actions:["disposeOldSession"],target:"ProcessChanges"}},CreateSession:{entry:[Wt("Entering CreateSession","SessionManagement:"),nn(0)],invoke:{id:"getNewSession",src:"createSession",onDone:{actions:["setSessionCreationResult","setHasEverSuccessfullyCreatedSession"],target:"ProcessChanges"},onError:{actions:"setSessionCreationError",target:"SessionCreationFailed"}}},SessionCreationFailed:{entry:[Wt("Entering SessionCreationFailed","SessionManagement:"),nn(2)],always:{target:"ProcessChanges",cond:"shallImmediatelyProcessChangesAfterSessionCreationError"},exit:[Wt("Exiting SessionCreationFailed","SessionManagement:"),"clearSessionCreationError"],on:{RetrySessionCreation:{target:"ProcessChanges",actions:Wt("Retrying session creation","SessionManagement:")}}},UpdateSession:{entry:[Wt("Entering UpdateSession","SessionManagement:"),nn(1)],invoke:{id:"updateExistingSession",src:"updateSession",onDone:{target:"ProcessChanges"},onError:{actions:"setSessionUpdateError",target:"SessionUpdateFailed"}}},SessionUpdateFailed:{entry:[Wt("Entering SessionUpdateFailed","SessionManagement:"),nn(2)],always:{target:"ProcessChanges",cond:"shallImmediatelyProcessChangesAfterSessionUpdateError"},exit:[Wt("Exiting SessionUpdateFailed","SessionManagement:"),"clearSessionUpdateError"],on:{RetrySessionUpdate:{target:"ProcessChanges",actions:Wt("Retrying session update","SessionManagement:")}}}}},{actions:{saveDesiredClient:Vt({desiredClient:(t,e)=>e.client}),saveDesiredSessionContext:Vt({desiredSessionContext:(t,e)=>e.sessionContext}),disposeOldSession:Vt((t,e)=>(t.session&&t.session.close().then(dv).catch(n=>{}),{session:null,actualClient:null})),setSessionCreationResult:Vt((t,e)=>({session:e.data.session,actualClient:e.data.client})),setSessionCreationError:Vt((t,e)=>({sessionCreationError:e.data})),clearSessionCreationError:Vt({sessionCreationError:()=>null}),setSessionUpdateError:Vt((t,e)=>({sessionUpdateError:e.data})),clearSessionUpdateError:Vt({sessionUpdateError:()=>null}),setHasEverSuccessfullyCreatedSession:Vt({hasEverSuccessfullyCreatedSession:()=>!0})},services:{createSession:t=>t.desiredClient.createSession(t.desiredSessionContext).then(e=>({session:e,client:t.desiredClient})).catch(e=>Promise.reject({type:e.type,client:t.desiredClient,sessionContext:t.desiredSessionContext})),updateSession:t=>t.session.setSessionContext(t.desiredSessionContext).catch(e=>Promise.reject({type:e.type,sessionContext:t.desiredSessionContext}))},guards:{shallDisposeSession:t=>t.session!=null&&(t.desiredSessionContext==null||t.desiredClient==null||!ci.equals(t.actualClient,t.desiredClient)),shallCreateSession:t=>t.session==null&&t.desiredClient!=null&&t.desiredSessionContext!=null,shallUpdateSession:t=>t.session!=null&&!ui.equals(t.session.getSessionContext(),t.desiredSessionContext),shallImmediatelyProcessChangesAfterSessionCreationError:t=>!ci.equals(t.desiredClient,t.sessionCreationError.client)||!Mi(ui).equals(t.desiredSessionContext,t.sessionCreationError.sessionContext),shallImmediatelyProcessChangesAfterSessionUpdateError:t=>!ci.equals(t.desiredClient,t.actualClient)||!Mi(ui).equals(t.desiredSessionContext,t.sessionUpdateError.sessionContext)}});function nn(t){const e=t===0,n=t===1;return Xp((r,i)=>{const o={isInitializing:(!r.hasEverSuccessfullyCreatedSession||e)&&r.sessionCreationError==null,errorType:r.sessionCreationError&&r.sessionCreationError.type},a={isUpdating:n&&r.sessionUpdateError==null,errorType:r.sessionUpdateError&&r.sessionUpdateError.type};return xs({type:"SessionManagementStateChanged",sessionInitialization:o,sessionUpdating:a,session:r.session})})}const xy=t=>e=>(e({type:"ConfigurationChanged",session:t,configuration:t.getConfiguration()}),t.setOnConfigurationChangedHandler(n=>{e({type:"ConfigurationChanged",session:t,configuration:n})}),()=>{t.setOnConfigurationChangedHandler(null)}),Ay=()=>eo({predictableActionArguments:!0,preserveActionOrder:!0,schema:{context:{},events:{}},context:{session:null},on:{ConfigurationChanged:{actions:[xs((t,e)=>e)]}},initial:"ProcessChanges",states:{ProcessChanges:{entry:[Wt("Entering ProcessChanges","ConfigurationSubscriptionManagement:")],on:{ChangeSession:{actions:["saveSession"]}},always:[{target:"Subscribe",cond:(t,e)=>t.session!=null}]},Subscribe:{entry:[Wt("Entering Subscribe","ConfigurationSubscriptionManagement:")],on:{ChangeSession:{target:"ProcessChanges",cond:(t,e)=>e.session==null||t.session!==e.session,actions:["saveSession"]}},invoke:{id:"configurationSubscriptionActor",src:(t,e)=>xy(t.session)}}}},{actions:{saveSession:Vt((t,e)=>({session:e.session}))}}),Dy=()=>{let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}},ea=()=>{const t=Dy();return{capsule:{promise:t.promise},resolve:t.resolve,reject:t.reject}},Oy=()=>eo({predictableActionArguments:!0,preserveActionOrder:!0,schema:{context:{},events:{}},context:{sessionManagementActor:null,configurationSubscriptionManagementActor:null,sessionInitialization:null,sessionUpdating:null,session:null,configuration:null,isReadyPromise:ea()},entry:[Vt({sessionManagementActor:()=>zo(Ey()),configurationSubscriptionManagementActor:()=>zo(Ay())})],exit:[Wo(t=>t.sessionManagementActor),Wo(t=>t.configurationSubscriptionManagementActor)],on:{ChangeConfigurationClient:{actions:[cr(t=>t.sessionManagementActor)]},ChangeSessionContext:{actions:[cr(t=>t.sessionManagementActor)]},RetrySessionCreation:{actions:[cr(t=>t.sessionManagementActor)]},RetrySessionUpdate:{actions:[cr(t=>t.sessionManagementActor)]},SessionManagementStateChanged:{actions:[Vt((t,e)=>({session:e.session,sessionInitialization:e.sessionInitialization,sessionUpdating:e.sessionUpdating})),op(t=>({type:"ChangeSession",session:t.session}),{to:t=>t.configurationSubscriptionManagementActor}),"calculateReadyState"]},ConfigurationChanged:{actions:[Vt((t,e)=>({configuration:{session:e.session,configuration:e.configuration}})),"calculateReadyState"]}},initial:"Idle",states:{Idle:{}}},{actions:{calculateReadyState:Vt((t,e)=>{var n;const r=!((n=t.sessionInitialization)!=null&&n.isInitializing)&&t.session!=null&&t.configuration!=null&&t.configuration.session===t.session;return t.isReadyPromise&&r&&(t.isReadyPromise.resolve(),t.isReadyPromise.capsule.promise=null),{isReadyPromise:(()=>r?null:t.isReadyPromise!=null?t.isReadyPromise:ea())()}})}});function Ny(t){var e,n;const[r,i]=cv(Oy,{logger:(...s)=>console.log("ConfigurationManagement:",...s)});X.useEffect(()=>{i({type:"ChangeConfigurationClient",client:t.configuratorClient}),t.configuratorClient||console.warn("The configurator client is null or undefined. This will dispose the session that may exist. If this was not intended, make sure you pass a valid client.")},[t.configuratorClient]),X.useEffect(()=>{const s=G($t(t.sessionContext),xv(l=>$t(l.configurationModelSource)),Jr);i({type:"ChangeSessionContext",sessionContext:s}),s||console.warn("The session context is null or undefined. This will dispose the session that may exist. If this was not intended, make sure you pass valid session context data.")},[t.sessionContext]);const o=X.useMemo(()=>{var s,l,f,h;return{isInitializing:((l=(s=r.context.isReadyPromise)==null?void 0:s.capsule)==null?void 0:l.promise)!=null,isInitializingPromise:(f=r.context.isReadyPromise)==null?void 0:f.capsule,error:((h=r.context.sessionInitialization)==null?void 0:h.errorType)&&{type:r.context.sessionInitialization.errorType,retry:()=>i({type:"RetrySessionCreation"})}}},[r.context.sessionInitialization,r.context.isReadyPromise]),a=X.useMemo(()=>{var s,l;return{isUpdating:(s=r.context.sessionUpdating)==null?void 0:s.isUpdating,error:((l=r.context.sessionUpdating)==null?void 0:l.errorType)&&{type:r.context.sessionUpdating.errorType,retry:()=>i({type:"RetrySessionUpdate"})}}},[r.context.sessionUpdating]),u=((e=r.context.configuration)==null?void 0:e.session)===r.context.session?(n=r.context.configuration)==null?void 0:n.configuration:null;return{configurationInitialization:o,configurationUpdating:a,session:r.context.session,configuration:u}}function _y(t){const{configurationInitialization:e,configurationUpdating:n,session:r,configuration:i}=Ny({configuratorClient:t.configuratorClient,sessionContext:t});return Be.jsx(uu.Provider,{value:e,children:Be.jsx(cu.Provider,{value:n,children:Be.jsx(su.Provider,{value:r,children:Be.jsx(lu.Provider,{value:i,children:t.children})})})})}function hu(){return X.useContext(uu)}function My(){return X.useContext(cu)}function $y(t){const{children:e}=t,{isInitializingPromise:n}=hu();if(n!=null&&n.promise)throw n.promise;return Be.jsx(Be.Fragment,{children:e})}function qy(){const t=co();return lo(t),X.useMemo(()=>({}),[t])}function Py(){const t=co(),e=Cn();return lo(t),wn(e),X.useMemo(()=>({configuration:e,restoreConfiguration:n=>t.restoreConfiguration(n)}),[e,t])}const Ry=Object.freeze(Object.defineProperty({__proto__:null,Configuration:_y,ConfigurationSuspender:$y,useAttributes:yy,useBooleanAttribute:by,useChoiceAttribute:my,useComponentAttribute:Sy,useConfiguration:Py,useConfigurationInitialization:hu,useConfigurationUpdating:My,useDecision:Zn,useExplain:qy,useNumericAttribute:gy},Symbol.toStringTag,{value:"Module"}));function pu(t){return Be.jsxs("div",{children:["Hello World from ",t.name.toUpperCase()]})}po.addPropertyControls(pu,{name:{title:"Name",type:po.ControlType.String}});const jy=Object.freeze(Object.defineProperty({__proto__:null,HelloWorld:pu},Symbol.toStringTag,{value:"Module"}));exports.Configurator=Gd;exports.ConfiguratorFramer=jy;exports.ConfiguratorReact=Ry;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Configurator from '@viamedici-spc/configurator-ts';
|
|
2
|
+
import * as ConfiguratorFramer from '@viamedici-spc/configurator-framer';
|
|
3
|
+
import * as ConfiguratorReact from '@viamedici-spc/configurator-react';
|
|
4
|
+
|
|
5
|
+
export { Configurator }
|
|
6
|
+
|
|
7
|
+
export { ConfiguratorFramer }
|
|
8
|
+
|
|
9
|
+
export { ConfiguratorReact }
|
|
10
|
+
|
|
11
|
+
export { }
|