@roqua/quby-frontend 0.10.11 → 0.10.12
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.
|
@@ -324,6 +324,7 @@ export type IBooleanCalculation = ICalcComparer | ICalcBooleanReducer;
|
|
|
324
324
|
export type ICalculation = INumberCalculation | IBooleanCalculation | ICalcStringValue;
|
|
325
325
|
export type ISexpVariables = {
|
|
326
326
|
[key: string]: {
|
|
327
|
+
type: "number" | "boolean" | "string";
|
|
327
328
|
calculation: ICalculation;
|
|
328
329
|
};
|
|
329
330
|
};
|
package/dist/quby-frontend.es.js
CHANGED
|
@@ -9179,7 +9179,7 @@ class ig {
|
|
|
9179
9179
|
}
|
|
9180
9180
|
setValue(e, n) {
|
|
9181
9181
|
const a = this.questionnaire.getField(e);
|
|
9182
|
-
this.values[e] = n, (n === null || typeof n == "string") && "setsTextvar" in a && a.setsTextvar && this.setTextvar(a.setsTextvar, n), this.validate(), this.
|
|
9182
|
+
this.values[e] = n, (n === null || typeof n == "string") && "setsTextvar" in a && a.setsTextvar && this.setTextvar(a.setsTextvar, n), this.validate(), this.calculations.handleValueChanged(e), this.calculateVisibility(), this.changeHandlers.forEach((o) => o(this, "valueChanged"));
|
|
9183
9183
|
}
|
|
9184
9184
|
setActiveQuestion(e) {
|
|
9185
9185
|
this.activeQuestionKey !== e && (this.activeQuestionKey && this.touchField(this.activeQuestionKey), this.activeQuestionKey = e, this.changeHandlers.forEach((n) => n(this)));
|
|
@@ -36,7 +36,7 @@ __p += '`),Wt&&(be+=`' +
|
|
|
36
36
|
function print() { __p += __j.call(arguments, '') }
|
|
37
37
|
`:`;
|
|
38
38
|
`)+be+`return __p
|
|
39
|
-
}`;var Mt=Vg(function(){return Dt(O,Xe+"return "+be).apply(n,z)});if(Mt.source=be,Qf(Mt))throw Mt;return Mt}function p1(t){return an(t).toLowerCase()}function h1(t){return an(t).toUpperCase()}function g1(t,i,u){if(t=an(t),t&&(u||i===n))return _e(t);if(!t||!(i=yr(i)))return t;var m=Ar(t),C=Ar(i),O=Qt(m,C),z=Xn(m,C)+1;return pi(m,O,z).join("")}function m1(t,i,u){if(t=an(t),t&&(u||i===n))return t.slice(0,Nl(t)+1);if(!t||!(i=yr(i)))return t;var m=Ar(t),C=Xn(m,Ar(i))+1;return pi(m,0,C).join("")}function v1(t,i,u){if(t=an(t),t&&(u||i===n))return t.replace(rn,"");if(!t||!(i=yr(i)))return t;var m=Ar(t),C=Qt(m,Ar(i));return pi(m,C).join("")}function b1(t,i){var u=Ft,m=ye;if(An(i)){var C="separator"in i?i.separator:C;u="length"in i?Rt(i.length):u,m="omission"in i?yr(i.omission):m}t=an(t);var O=t.length;if(Eo(t)){var z=Ar(t);O=z.length}if(u>=O)return t;var $=u-To(m);if($<1)return m;var J=z?pi(z,0,$).join(""):t.slice(0,$);if(C===n)return J+m;if(z&&($+=J.length-$),Xf(C)){if(t.slice($).search(C)){var ce,fe=J;for(C.global||(C=ba(C.source,an(kt.exec(C))+"g")),C.lastIndex=0;ce=C.exec(fe);)var be=ce.index;J=J.slice(0,be===n?$:be)}}else if(t.indexOf(yr(C),$)!=$){var Le=J.lastIndexOf(C);Le>-1&&(J=J.slice(0,Le))}return J+m}function y1(t){return t=an(t),t&&hr.test(t)?t.replace(Pn,Ou):t}var w1=N(function(t,i,u){return t+(u?" ":"")+i.toUpperCase()}),tp=M("toUpperCase");function Ug(t,i,u){return t=an(t),i=u?n:i,i===n?Ec(t)?Ic(t):So(t):t.match(i)||[]}var Vg=bt(function(t,i){try{return Cn(t,n,i)}catch(u){return Qf(u)?u:new st(u)}}),x1=Rs(function(t,i){return Hn(i,function(u){u=$o(u),Gn(t,u,Kf(t[u],t))}),t});function S1(t){var i=t==null?0:t.length,u=lt();return t=i?qt(t,function(m){if(typeof m[1]!="function")throw new vr(v);return[u(m[0]),m[1]]}):[],bt(function(m){for(var C=-1;++C<i;){var O=t[C];if(Cn(O[0],this,m))return Cn(O[1],this,m)}})}function _1(t){return Xl(lr(t,F))}function np(t){return function(){return t}}function k1(t,i){return t==null||t!==t?i:t}var E1=d(),C1=d(!0);function Mi(t){return t}function rp(t){return zo(typeof t=="function"?t:lr(t,F))}function T1(t){return na(lr(t,F))}function R1(t,i){return fi(t,lr(i,F))}var I1=bt(function(t,i){return function(u){return Hr(u,t,i)}}),A1=bt(function(t,i){return function(u){return Hr(t,u,i)}});function ip(t,i,u){var m=xr(i),C=pl(i,m);u==null&&!(An(i)&&(C.length||!m.length))&&(u=i,i=t,t=this,C=pl(i,xr(i)));var O=!(An(u)&&"chain"in u)||!!u.chain,z=As(t);return Hn(C,function($){var J=i[$];t[$]=J,z&&(t.prototype[$]=function(){var ce=this.__chain__;if(O||ce){var fe=t(this.__wrapped__),be=fe.__actions__=Yn(this.__actions__);return be.push({func:J,args:arguments,thisArg:t}),fe.__chain__=ce,fe}return J.apply(t,Tr([this.value()],arguments))})}),t}function O1(){return En._===this&&(En._=dn),this}function ap(){}function M1(t){return t=Rt(t),bt(function(i){return io(i,t)})}var F1=L(qt),P1=L(xo),D1=L(ma);function Wg(t){return Wf(t)?h($o(t)):lu(t)}function L1(t){return function(i){return t==null?n:to(t,i)}}var B1=pe(),N1=pe(!0);function op(){return[]}function sp(){return!1}function j1(){return{}}function z1(){return""}function U1(){return!0}function V1(t,i){if(t=Rt(t),t<1||t>ze)return[];var u=ue,m=vn(t,ue);i=lt(i),t-=ue;for(var C=Q(m,i);++u<t;)i(u);return C}function W1(t){return Et(t)?qt(t,$o):aa(t)?[t]:Yn(ug(an(t)))}function H1(t){var i=++Fu;return an(t)+i}var $1=T(function(t,i){return t+i},0),G1=at("ceil"),Z1=T(function(t,i){return t/i},1),Y1=at("floor");function K1(t){return t&&t.length?fl(t,Mi,fs):n}function J1(t,i){return t&&t.length?fl(t,lt(i,2),fs):n}function Q1(t){return es(t,Mi)}function X1(t,i){return es(t,lt(i,2))}function q1(t){return t&&t.length?fl(t,Mi,di):n}function e_(t,i){return t&&t.length?fl(t,lt(i,2),di):n}var t_=T(function(t,i){return t*i},1),n_=at("round"),r_=T(function(t,i){return t-i},0);function i_(t){return t&&t.length?q(t,Mi):0}function a_(t,i){return t&&t.length?q(t,lt(i,2)):0}return I.after=Tx,I.ary=wg,I.assign=hS,I.assignIn=Pg,I.assignInWith=zd,I.assignWith=gS,I.at=mS,I.before=xg,I.bind=Kf,I.bindAll=x1,I.bindKey=Sg,I.castArray=jx,I.chain=vg,I.chunk=Y0,I.compact=K0,I.concat=J0,I.cond=S1,I.conforms=_1,I.constant=np,I.countBy=ix,I.create=vS,I.curry=_g,I.curryRight=kg,I.debounce=Eg,I.defaults=bS,I.defaultsDeep=yS,I.defer=Rx,I.delay=Ix,I.difference=Q0,I.differenceBy=X0,I.differenceWith=q0,I.drop=ew,I.dropRight=tw,I.dropRightWhile=nw,I.dropWhile=rw,I.fill=iw,I.filter=ox,I.flatMap=ux,I.flatMapDeep=cx,I.flatMapDepth=dx,I.flatten=pg,I.flattenDeep=aw,I.flattenDepth=ow,I.flip=Ax,I.flow=E1,I.flowRight=C1,I.fromPairs=sw,I.functions=CS,I.functionsIn=TS,I.groupBy=fx,I.initial=uw,I.intersection=cw,I.intersectionBy=dw,I.intersectionWith=fw,I.invert=IS,I.invertBy=AS,I.invokeMap=hx,I.iteratee=rp,I.keyBy=gx,I.keys=xr,I.keysIn=Oi,I.map=Pd,I.mapKeys=MS,I.mapValues=FS,I.matches=T1,I.matchesProperty=R1,I.memoize=Ld,I.merge=PS,I.mergeWith=Dg,I.method=I1,I.methodOf=A1,I.mixin=ip,I.negate=Bd,I.nthArg=M1,I.omit=DS,I.omitBy=LS,I.once=Ox,I.orderBy=mx,I.over=F1,I.overArgs=Mx,I.overEvery=P1,I.overSome=D1,I.partial=Jf,I.partialRight=Cg,I.partition=vx,I.pick=BS,I.pickBy=Lg,I.property=Wg,I.propertyOf=L1,I.pull=mw,I.pullAll=gg,I.pullAllBy=vw,I.pullAllWith=bw,I.pullAt=yw,I.range=B1,I.rangeRight=N1,I.rearg=Fx,I.reject=wx,I.remove=ww,I.rest=Px,I.reverse=Zf,I.sampleSize=Sx,I.set=jS,I.setWith=zS,I.shuffle=_x,I.slice=xw,I.sortBy=Cx,I.sortedUniq=Rw,I.sortedUniqBy=Iw,I.split=u1,I.spread=Dx,I.tail=Aw,I.take=Ow,I.takeRight=Mw,I.takeRightWhile=Fw,I.takeWhile=Pw,I.tap=Kw,I.throttle=Lx,I.thru=Fd,I.toArray=Og,I.toPairs=Bg,I.toPairsIn=Ng,I.toPath=W1,I.toPlainObject=Fg,I.transform=US,I.unary=Bx,I.union=Dw,I.unionBy=Lw,I.unionWith=Bw,I.uniq=Nw,I.uniqBy=jw,I.uniqWith=zw,I.unset=VS,I.unzip=Yf,I.unzipWith=mg,I.update=WS,I.updateWith=HS,I.values=ec,I.valuesIn=$S,I.without=Uw,I.words=Ug,I.wrap=Nx,I.xor=Vw,I.xorBy=Ww,I.xorWith=Hw,I.zip=$w,I.zipObject=Gw,I.zipObjectDeep=Zw,I.zipWith=Yw,I.entries=Bg,I.entriesIn=Ng,I.extend=Pg,I.extendWith=zd,ip(I,I),I.add=$1,I.attempt=Vg,I.camelCase=KS,I.capitalize=jg,I.ceil=G1,I.clamp=GS,I.clone=zx,I.cloneDeep=Vx,I.cloneDeepWith=Wx,I.cloneWith=Ux,I.conformsTo=Hx,I.deburr=zg,I.defaultTo=k1,I.divide=Z1,I.endsWith=JS,I.eq=so,I.escape=QS,I.escapeRegExp=XS,I.every=ax,I.find=sx,I.findIndex=dg,I.findKey=wS,I.findLast=lx,I.findLastIndex=fg,I.findLastKey=xS,I.floor=Y1,I.forEach=bg,I.forEachRight=yg,I.forIn=SS,I.forInRight=_S,I.forOwn=kS,I.forOwnRight=ES,I.get=qf,I.gt=$x,I.gte=Gx,I.has=RS,I.hasIn=ep,I.head=hg,I.identity=Mi,I.includes=px,I.indexOf=lw,I.inRange=ZS,I.invoke=OS,I.isArguments=wu,I.isArray=Et,I.isArrayBuffer=Zx,I.isArrayLike=Ai,I.isArrayLikeObject=Kn,I.isBoolean=Yx,I.isBuffer=El,I.isDate=Kx,I.isElement=Jx,I.isEmpty=Qx,I.isEqual=Xx,I.isEqualWith=qx,I.isError=Qf,I.isFinite=eS,I.isFunction=As,I.isInteger=Tg,I.isLength=Nd,I.isMap=Rg,I.isMatch=tS,I.isMatchWith=nS,I.isNaN=rS,I.isNative=iS,I.isNil=oS,I.isNull=aS,I.isNumber=Ig,I.isObject=An,I.isObjectLike=jn,I.isPlainObject=Vc,I.isRegExp=Xf,I.isSafeInteger=sS,I.isSet=Ag,I.isString=jd,I.isSymbol=aa,I.isTypedArray=qu,I.isUndefined=lS,I.isWeakMap=uS,I.isWeakSet=cS,I.join=pw,I.kebabCase=qS,I.last=Ia,I.lastIndexOf=hw,I.lowerCase=e1,I.lowerFirst=t1,I.lt=dS,I.lte=fS,I.max=K1,I.maxBy=J1,I.mean=Q1,I.meanBy=X1,I.min=q1,I.minBy=e_,I.stubArray=op,I.stubFalse=sp,I.stubObject=j1,I.stubString=z1,I.stubTrue=U1,I.multiply=t_,I.nth=gw,I.noConflict=O1,I.noop=ap,I.now=Dd,I.pad=n1,I.padEnd=r1,I.padStart=i1,I.parseInt=a1,I.random=YS,I.reduce=bx,I.reduceRight=yx,I.repeat=o1,I.replace=s1,I.result=NS,I.round=n_,I.runInContext=Z,I.sample=xx,I.size=kx,I.snakeCase=l1,I.some=Ex,I.sortedIndex=Sw,I.sortedIndexBy=_w,I.sortedIndexOf=kw,I.sortedLastIndex=Ew,I.sortedLastIndexBy=Cw,I.sortedLastIndexOf=Tw,I.startCase=c1,I.startsWith=d1,I.subtract=r_,I.sum=i_,I.sumBy=a_,I.template=f1,I.times=V1,I.toFinite=Os,I.toInteger=Rt,I.toLength=Mg,I.toLower=p1,I.toNumber=Aa,I.toSafeInteger=pS,I.toString=an,I.toUpper=h1,I.trim=g1,I.trimEnd=m1,I.trimStart=v1,I.truncate=b1,I.unescape=y1,I.uniqueId=H1,I.upperCase=w1,I.upperFirst=tp,I.each=bg,I.eachRight=yg,I.first=hg,ip(I,function(){var t={};return Ti(I,function(i,u){$t.call(I.prototype,u)||(t[u]=i)}),t}(),{chain:!1}),I.VERSION=a,Hn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){I[t].placeholder=I}),Hn(["drop","take"],function(t,i){St.prototype[t]=function(u){u=u===n?1:mn(Rt(u),0);var m=this.__filtered__&&!i?new St(this):this.clone();return m.__filtered__?m.__takeCount__=vn(u,m.__takeCount__):m.__views__.push({size:vn(u,ue),type:t+(m.__dir__<0?"Right":"")}),m},St.prototype[t+"Right"]=function(u){return this.reverse()[t](u).reverse()}}),Hn(["filter","map","takeWhile"],function(t,i){var u=i+1,m=u==Be||u==He;St.prototype[t]=function(C){var O=this.clone();return O.__iteratees__.push({iteratee:lt(C,3),type:u}),O.__filtered__=O.__filtered__||m,O}}),Hn(["head","last"],function(t,i){var u="take"+(i?"Right":"");St.prototype[t]=function(){return this[u](1).value()[0]}}),Hn(["initial","tail"],function(t,i){var u="drop"+(i?"":"Right");St.prototype[t]=function(){return this.__filtered__?new St(this):this[u](1)}}),St.prototype.compact=function(){return this.filter(Mi)},St.prototype.find=function(t){return this.filter(t).head()},St.prototype.findLast=function(t){return this.reverse().find(t)},St.prototype.invokeMap=bt(function(t,i){return typeof t=="function"?new St(this):this.map(function(u){return Hr(u,t,i)})}),St.prototype.reject=function(t){return this.filter(Bd(lt(t)))},St.prototype.slice=function(t,i){t=Rt(t);var u=this;return u.__filtered__&&(t>0||i<0)?new St(u):(t<0?u=u.takeRight(-t):t&&(u=u.drop(t)),i!==n&&(i=Rt(i),u=i<0?u.dropRight(-i):u.take(i-t)),u)},St.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},St.prototype.toArray=function(){return this.take(ue)},Ti(St.prototype,function(t,i){var u=/^(?:filter|find|map|reject)|While$/.test(i),m=/^(?:head|last)$/.test(i),C=I[m?"take"+(i=="last"?"Right":""):i],O=m||/^find/.test(i);C&&(I.prototype[i]=function(){var z=this.__wrapped__,$=m?[1]:arguments,J=z instanceof St,ce=$[0],fe=J||Et(z),be=function(jt){var Wt=C.apply(I,Tr([jt],$));return m&&Le?Wt[0]:Wt};fe&&u&&typeof ce=="function"&&ce.length!=1&&(J=fe=!1);var Le=this.__chain__,Xe=!!this.__actions__.length,ut=O&&!Le,Mt=J&&!Xe;if(!O&&fe){z=Mt?z:new St(this);var ct=t.apply(z,$);return ct.__actions__.push({func:Fd,args:[be],thisArg:n}),new sr(ct,Le)}return ut&&Mt?t.apply(this,$):(ct=this.thru(be),ut?m?ct.value()[0]:ct.value():ct)})}),Hn(["pop","push","shift","sort","splice","unshift"],function(t){var i=$a[t],u=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",m=/^(?:pop|shift)$/.test(t);I.prototype[t]=function(){var C=arguments;if(m&&!this.__chain__){var O=this.value();return i.apply(Et(O)?O:[],C)}return this[u](function(z){return i.apply(Et(z)?z:[],C)})}}),Ti(St.prototype,function(t,i){var u=I[i];if(u){var m=u.name+"";$t.call(_a,m)||(_a[m]=[]),_a[m].push({name:i,func:u})}}),_a[g(n,G).name]=[{name:"wrapper",func:n}],St.prototype.clone=rl,St.prototype.reverse=Do,St.prototype.value=cs,I.prototype.at=Jw,I.prototype.chain=Qw,I.prototype.commit=Xw,I.prototype.next=qw,I.prototype.plant=tx,I.prototype.reverse=nx,I.prototype.toJSON=I.prototype.valueOf=I.prototype.value=rx,I.prototype.first=I.prototype.head,Ki&&(I.prototype[Ki]=ex),I},Bn=Mu();Gi?((Gi.exports=Bn)._=Bn,bo._=Bn):En._=Bn}).call(er)}(sd,sd.exports);var Da=sd.exports;const vi=Symbol.for("@ts-pattern/matcher"),Bp=Symbol.for("@ts-pattern/isVariadic"),ld="@ts-pattern/anonymous-select-key",qd=r=>!!(r&&typeof r=="object"),ud=r=>r&&!!r[vi],Sr=(r,e,n)=>{if(ud(r)){const a=r[vi](),{matched:o,selections:c}=a.match(e);return o&&c&&Object.keys(c).forEach(v=>n(v,c[v])),o}if(qd(r)){if(!qd(e))return!1;if(Array.isArray(r)){if(!Array.isArray(e))return!1;let a=[],o=[],c=[];for(const v of r.keys()){const x=r[v];ud(x)&&x[Bp]?c.push(x):c.length?o.push(x):a.push(x)}if(c.length){if(c.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(e.length<a.length+o.length)return!1;const v=e.slice(0,a.length),x=o.length===0?[]:e.slice(-o.length),y=e.slice(a.length,o.length===0?1/0:-o.length);return a.every((E,B)=>Sr(E,v[B],n))&&o.every((E,B)=>Sr(E,x[B],n))&&(c.length===0||Sr(c[0],y,n))}return r.length===e.length&&r.every((v,x)=>Sr(v,e[x],n))}return Reflect.ownKeys(r).every(a=>{const o=r[a];return(a in e||ud(c=o)&&c[vi]().matcherType==="optional")&&Sr(o,e[a],n);var c})}return Object.is(e,r)},Fi=r=>{var e,n,a;return qd(r)?ud(r)?(e=(n=(a=r[vi]()).getSelectionKeys)==null?void 0:n.call(a))!=null?e:[]:Array.isArray(r)?vc(r,Fi):vc(Object.values(r),Fi):[]},vc=(r,e)=>r.reduce((n,a)=>n.concat(e(a)),[]);function Dv(...r){if(r.length===1){const[e]=r;return n=>Sr(e,n,()=>{})}if(r.length===2){const[e,n]=r;return Sr(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${r.length}.`)}function _r(r){return Object.assign(r,{optional:()=>tf(r),and:e=>bn(r,e),or:e=>Np(r,e),select:e=>e===void 0?bc(r):bc(e,r)})}function ef(r){return Object.assign((e=>Object.assign(e,{[Symbol.iterator](){let n=0;const a=[{value:Object.assign(e,{[Bp]:!0}),done:!1},{done:!0,value:void 0}];return{next:()=>{var o;return(o=a[n++])!=null?o:a.at(-1)}}}}))(r),{optional:()=>ef(tf(r)),select:e=>ef(e===void 0?bc(r):bc(e,r))})}function tf(r){return _r({[vi]:()=>({match:e=>{let n={};const a=(o,c)=>{n[o]=c};return e===void 0?(Fi(r).forEach(o=>a(o,void 0)),{matched:!0,selections:n}):{matched:Sr(r,e,a),selections:n}},getSelectionKeys:()=>Fi(r),matcherType:"optional"})})}const Lv=(r,e)=>{for(const n of r)if(!e(n))return!1;return!0},Bv=(r,e)=>{for(const[n,a]of r.entries())if(!e(a,n))return!1;return!0};function bn(...r){return _r({[vi]:()=>({match:e=>{let n={};const a=(o,c)=>{n[o]=c};return{matched:r.every(o=>Sr(o,e,a)),selections:n}},getSelectionKeys:()=>vc(r,Fi),matcherType:"and"})})}function Np(...r){return _r({[vi]:()=>({match:e=>{let n={};const a=(o,c)=>{n[o]=c};return vc(r,Fi).forEach(o=>a(o,void 0)),{matched:r.some(o=>Sr(o,e,a)),selections:n}},getSelectionKeys:()=>vc(r,Fi),matcherType:"or"})})}function Ht(r){return{[vi]:()=>({match:e=>({matched:!!r(e)})})}}function bc(...r){const e=typeof r[0]=="string"?r[0]:void 0,n=r.length===2?r[1]:typeof r[0]=="string"?void 0:r[0];return _r({[vi]:()=>({match:a=>{let o={[e??ld]:a};return{matched:n===void 0||Sr(n,a,(c,v)=>{o[c]=v}),selections:o}},getSelectionKeys:()=>[e??ld].concat(n===void 0?[]:Fi(n))})})}function po(r){return typeof r=="number"}function Ns(r){return typeof r=="string"}function js(r){return typeof r=="bigint"}const jp=_r(Ht(function(r){return!0})),Nv=jp,zs=r=>Object.assign(_r(r),{startsWith:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&a.startsWith(n)))));var n},endsWith:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&a.endsWith(n)))));var n},minLength:e=>zs(bn(r,(n=>Ht(a=>Ns(a)&&a.length>=n))(e))),length:e=>zs(bn(r,(n=>Ht(a=>Ns(a)&&a.length===n))(e))),maxLength:e=>zs(bn(r,(n=>Ht(a=>Ns(a)&&a.length<=n))(e))),includes:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&a.includes(n)))));var n},regex:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&!!a.match(n)))));var n}}),jv=zs(Ht(Ns)),ho=r=>Object.assign(_r(r),{between:(e,n)=>ho(bn(r,((a,o)=>Ht(c=>po(c)&&a<=c&&o>=c))(e,n))),lt:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a<n))(e))),gt:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a>n))(e))),lte:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a<=n))(e))),gte:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a>=n))(e))),int:()=>ho(bn(r,Ht(e=>po(e)&&Number.isInteger(e)))),finite:()=>ho(bn(r,Ht(e=>po(e)&&Number.isFinite(e)))),positive:()=>ho(bn(r,Ht(e=>po(e)&&e>0))),negative:()=>ho(bn(r,Ht(e=>po(e)&&e<0)))}),zv=ho(Ht(po)),Us=r=>Object.assign(_r(r),{between:(e,n)=>Us(bn(r,((a,o)=>Ht(c=>js(c)&&a<=c&&o>=c))(e,n))),lt:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a<n))(e))),gt:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a>n))(e))),lte:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a<=n))(e))),gte:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a>=n))(e))),positive:()=>Us(bn(r,Ht(e=>js(e)&&e>0))),negative:()=>Us(bn(r,Ht(e=>js(e)&&e<0)))}),Uv=Us(Ht(js)),Vv=_r(Ht(function(r){return typeof r=="boolean"})),Wv=_r(Ht(function(r){return typeof r=="symbol"})),Hv=_r(Ht(function(r){return r==null})),$v=_r(Ht(function(r){return r!=null}));var cd={__proto__:null,matcher:vi,optional:tf,array:function(...r){return ef({[vi]:()=>({match:e=>{if(!Array.isArray(e))return{matched:!1};if(r.length===0)return{matched:!0};const n=r[0];let a={};if(e.length===0)return Fi(n).forEach(c=>{a[c]=[]}),{matched:!0,selections:a};const o=(c,v)=>{a[c]=(a[c]||[]).concat([v])};return{matched:e.every(c=>Sr(n,c,o)),selections:a}},getSelectionKeys:()=>r.length===0?[]:Fi(r[0])})})},set:function(...r){return _r({[vi]:()=>({match:e=>{if(!(e instanceof Set))return{matched:!1};let n={};if(e.size===0)return{matched:!0,selections:n};if(r.length===0)return{matched:!0};const a=(c,v)=>{n[c]=(n[c]||[]).concat([v])},o=r[0];return{matched:Lv(e,c=>Sr(o,c,a)),selections:n}},getSelectionKeys:()=>r.length===0?[]:Fi(r[0])})})},map:function(...r){return _r({[vi]:()=>({match:e=>{if(!(e instanceof Map))return{matched:!1};let n={};if(e.size===0)return{matched:!0,selections:n};const a=(x,y)=>{n[x]=(n[x]||[]).concat([y])};if(r.length===0)return{matched:!0};var o;if(r.length===1)throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${(o=r[0])==null?void 0:o.toString()}`);const[c,v]=r;return{matched:Bv(e,(x,y)=>{const E=Sr(c,y,a),B=Sr(v,x,a);return E&&B}),selections:n}},getSelectionKeys:()=>r.length===0?[]:[...Fi(r[0]),...Fi(r[1])]})})},intersection:bn,union:Np,not:function(r){return _r({[vi]:()=>({match:e=>({matched:!Sr(r,e,()=>{})}),getSelectionKeys:()=>[],matcherType:"not"})})},when:Ht,select:bc,any:jp,_:Nv,string:jv,number:zv,bigint:Uv,boolean:Vv,symbol:Wv,nullish:Hv,nonNullable:$v,instanceOf:function(r){return _r(Ht(function(e){return n=>n instanceof e}(r)))},shape:function(r){return _r(Ht(Dv(r)))}};class Gv extends Error{constructor(e){let n;try{n=JSON.stringify(e)}catch{n=e}super(`Pattern matching error: no pattern matches value ${n}`),this.input=void 0,this.input=e}}const nf={matched:!1,value:void 0};function yc(r){return new dd(r,nf)}class dd{constructor(e,n){this.input=void 0,this.state=void 0,this.input=e,this.state=n}with(...e){if(this.state.matched)return this;const n=e[e.length-1],a=[e[0]];let o;e.length===3&&typeof e[1]=="function"?o=e[1]:e.length>2&&a.push(...e.slice(1,e.length-1));let c=!1,v={};const x=(E,B)=>{c=!0,v[E]=B},y=!a.some(E=>Sr(E,this.input,x))||o&&!o(this.input)?nf:{matched:!0,value:n(c?ld in v?v[ld]:v:this.input,this.input)};return new dd(this.input,y)}when(e,n){if(this.state.matched)return this;const a=!!e(this.input);return new dd(this.input,a?{matched:!0,value:n(this.input,this.input)}:nf)}otherwise(e){return this.state.matched?this.state.value:e(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new Gv(this.input)}run(){return this.exhaustive()}returnType(){return this}}const Df=class{constructor(e,n){Tt(this,"sexpVariables");Tt(this,"questionKeyToCalculationKeys");Tt(this,"response");Tt(this,"results",{});Tt(this,"calculateNumber",e=>yc(e).with({op:"number"},({value:n})=>n).with({op:"number_value"},({key:n})=>this.response.numberValue(n)).with({op:"sum"},({values:n})=>this.reduce(n,"sum")).with({op:"subtract"},({values:n})=>this.reduce(n,"subtract")).with({op:"multiply"},({values:n})=>this.reduce(n,"multiply")).with({op:"divide"},({values:n})=>this.reduce(n,"divide")).with({op:"round"},({value:n,digits:a})=>this.round(n,a)).exhaustive());Tt(this,"calculateBoolean",e=>{if(!Qd.options.includes(e.op))throw new Error(`Unknown boolean operation: ${e.op}`);return yc(e).with({op:cd.union(...Jd.options)},this.compare).with({op:cd.union(...Kd.options)},this.booleanReduce).exhaustive()});Tt(this,"compare",e=>{const n=this.calculateNumber(e.left),a=this.calculateNumber(e.right);return n===null||a===null?null:yc(e.op).with("eq",()=>n===a).with("not_eq",()=>n!==a).with("gt",()=>n>a).with("gteq",()=>n>=a).with("lt",()=>n<a).with("lteq",()=>n<=a).exhaustive()});Tt(this,"booleanReduce",e=>{const n=e.values.map(this.calculateBoolean);return n.some(a=>a===null)?null:yc(e.op).with("all",()=>n.every(a=>a===!0)).with("some",()=>n.some(a=>a===!0)).with("none",()=>n.every(a=>a===!1)).exhaustive()});this.sexpVariables=e,this.questionKeyToCalculationKeys=Zv(e),this.response=n}getResult(e){return this.results[e]===void 0&&(this.results[e]=this.calculate(this.sexpVariables[e].calculation)),this.results[e]??null}handleValueChanged(e){var n;(n=this.questionKeyToCalculationKeys[e])==null||n.forEach(a=>{delete this.results[a]})}calculate(e){return yc(e).with({op:"string_value"},({key:n})=>this.stringValue(n)).with({op:cd.union("number","number_value","sum","subtract","multiply","divide","round")},this.calculateNumber).with({op:cd.union(...Qd.options)},this.calculateBoolean).exhaustive()}stringValue(e){const n=this.response.cleanValue(e);return(n==null?void 0:n.toString())??null}reduce(e,n){const a=e.map(o=>this.calculateNumber(o));return a.some(o=>o===null)?null:a.reduce(Df.numberReducers[n])}round(e,n){const a=this.calculateNumber(e);return a===null?null:Number(a.toFixed(n))}};let fd=Df;Tt(fd,"numberReducers",{sum:(e,n)=>e+n,multiply:(e,n)=>e*n,subtract:(e,n)=>e-n,divide:(e,n)=>e/n});function Zv(r){const e={};for(const[n,a]of Object.entries(r))Tu(a.calculation).forEach(c=>{e[c]??(e[c]=new Set),e[c].add(n)});return e}function Tu(r){switch(r.op){case"number_value":case"string_value":return[r.key];case"sum":case"multiply":case"divide":case"subtract":return r.values.flatMap(e=>Tu(e));case"round":return Tu(r.value);case"eq":case"not_eq":case"gt":case"gteq":case"lt":case"lteq":return[...Tu(r.left),...Tu(r.right)];case"all":case"some":case"none":return r.values.flatMap(e=>Tu(e));case"number":return[]}}function Yv(r,e,n){if(arguments.length<3)throw new TypeError("3 argument required, but only "+arguments.length+" present");var a=new Date(r,e,n);return a.getFullYear()===r&&a.getMonth()===e&&a.getDate()===n}const zp=["requires_answer","minimum_checked_required","answer_group_minimum"];function Up(r){switch(r.type){case"requires_answer":return new Vp(r);case"valid_integer":return new $p(r);case"valid_float":return new Gp(r);case"valid_date":return new Hp(r);case"minimum":return new Zp(r);case"maximum":return new Yp(r);case"minimum_date":return new Kp(r);case"maximum_date":return new Jp(r);case"minimum_checked_required":return new Qp(r);case"maximum_checked_allowed":return new Xp(r);case"answer_group_minimum":return new qp(r);case"answer_group_maximum":return new eh(r);case"regexp":return new th(r)}}class bi{constructor(e){Tt(this,"config");this.config=e}}class Vp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Ru(n.value)||this.ignoreDueToDependsOn(e)||n.addError({type:this.config.type,message:{t:"requires_answer"}})}ignoreDueToDependsOn(e){return!this.config.dependsOnQuestions&&!this.config.dependsOnOptions?!1:!this.dependsOnQuestionAnswered(e)&&!this.dependsOnOptionSelected(e)}dependsOnQuestionAnswered(e){return this.config.dependsOnQuestions===void 0?!1:this.config.dependsOnQuestions.some(n=>Ru(e.getValidationFieldState(n).value))}dependsOnOptionSelected(e){return this.config.dependsOnOptions===void 0?!1:Object.entries(this.config.dependsOnOptions).some(([n,a])=>{const o=e.getValidationFieldState(n).value;if(Ru(o)){if(typeof o=="string")return a.some(c=>c===o);if(o instanceof Set)return a.some(c=>o.has(c));throw new Error("unknown question type for dependsOnOptions: this.config.fieldKey")}else return!1})}}function Ru(r){if(r==null)return!1;if(typeof r=="string")return!!r;if(typeof r=="number")return!0;if(r instanceof Map)return hd(r);if("size"in r)return r.size>0;if("length"in r)return r.length>0;throw`Unexpected value type in validation ${r}`}function pd(r){return r===void 0||r===null||r===""?!1:typeof r=="string"}function Wp(r){return r===void 0||r===null?!1:typeof r=="number"}function hd(r){if(r===void 0||r===null)return!1;for(const[e,n]of r){if(typeof e!="string"||typeof n!="string")return!1;if(pd(n))return!0}return!1}const Kv=/(\s*-?[1-9][0-9]+\s*|\s*-?[0-9]\s*)/;class Hp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!hd(n.value))return;if(this.config.requiredParts.some(o=>!n.value.get(o))){n.addError({type:this.config.type,message:{t:`valid_date.${this.config.subtype}`}});return}const a=rf(n.value);(!a||!Yv(a.year,a.month,a.day)||a.year<1900||a.year>2100||a.hour>23||a.minute>59)&&n.addError({type:this.config.type,message:{t:`valid_date.${this.config.subtype}`}})}}function rf(r){var e=function(n,a){const o=r.get(n);return o===void 0||o==""?a:parseInt(o,10)};return[...r.values()].some(n=>n&&!/^\d*$/.test(n))?null:{year:e("year",2e3),month:e("month",1)-1,day:e("day",1),hour:e("hour",0),minute:e("minute",0)}}class $p extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!pd(n.value))return;const a=Kv.exec(n.value);(a===null||a[0]!==n.value)&&n.addError({type:this.config.type,message:{t:"valid_integer"}})}}class Gp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!pd(n.value))return;const a=parseFloat(n.value);!isNaN(a)&&isFinite(a)||n.addError({type:this.config.type,message:{t:"valid_float"}})}}class Zp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Wp(n.value)&&parseFloat(n.value)<this.config.value&&n.addError({type:this.config.type,message:{t:"minimum",value:this.config.value.toString()}})}}class Yp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Wp(n.value)&&parseFloat(n.value)>this.config.value&&n.addError({type:this.config.type,message:{t:"maximum",value:this.config.value.toString()}})}}class Kp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!hd(n.value))return;const a=rf(n.value);a&&new Date(a.year,a.month,a.hour)<new Date(this.config.value)&&n.addError({type:this.config.type,message:{t:"minimum_date",friendly_date:this.config.value}})}}class Jp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!hd(n.value))return;const a=rf(n.value);a&&new Date(a.year,a.month,a.hour)>new Date(this.config.value)&&n.addError({type:this.config.type,message:{t:"maximum_date",friendly_date:this.config.value}})}}class Qp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);(!n.value||n.value.size<this.config.minimumCheckedValue)&&n.addError({type:this.config.type,message:{t:"minimum_checked_required",count:this.config.minimumCheckedValue}})}}class Xp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Ru(n.value)&&n.value.size>this.config.maximumCheckedValue&&n.addError({type:this.config.type,message:{t:"maximum_checked_allowed",count:this.config.maximumCheckedValue}})}}class qp extends bi{validate(e){const n=this.config.fieldKeys.map(a=>e.getValidationFieldState(a));n.filter(a=>Ru(a.value)).length>=this.config.value||n.forEach(a=>{a.addError({type:this.config.type,message:{t:"answer_group_minimum",value:this.config.value}})})}}class eh extends bi{validate(e){const n=this.config.fieldKeys.map(a=>e.getValidationFieldState(a));n.filter(a=>Ru(a.value)).length<=this.config.value||n.forEach(a=>{a.addError({type:this.config.type,message:{t:"answer_group_maximum",value:this.config.value}})})}}class th extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!pd(n.value))return;const a=this.config.matcher.replace("\\A","^").replace("\\Z","$"),c=new RegExp(a).exec(n.value);(c===null||c[0]!==n.value)&&n.addError({type:this.config.type,message:this.config.explanation||{t:"regexp",matcher:this.config.matcher}})}}const nh=On.coerce.number(),rh=On.coerce.string(),ih=On.preprocess(r=>r instanceof Array?new Set(r):r,On.set(On.string())),ah=On.preprocess(r=>!(r instanceof Map)&&r instanceof Object?new Map(Object.entries(r)):r,On.map(Dp,On.string())),oh=On.record(On.boolean()),sh=On.preprocess(r=>!(r instanceof Map)&&r instanceof Object?new Map(Object.entries(r)):r,On.map(On.string(),On.string()));class af{constructor(e,n){Tt(this,"questionnaire");Tt(this,"values");Tt(this,"originalValues");Tt(this,"beenActives");Tt(this,"errors");Tt(this,"visibility");Tt(this,"changeHandlers");Tt(this,"flags");Tt(this,"textvars");Tt(this,"activeQuestionKey");Tt(this,"calculations");this.questionnaire=e,this.values=n.value,this.originalValues={...n.value},this.beenActives=new Set,this.errors=new Map,this.visibility=new Map,this.changeHandlers=[],this.flags=n.flags,this.textvars=this.initTextvars(n.textvars),this.activeQuestionKey=null,this.calculations=new fd(e.sexpVariables,this),this.validate(),this.calculateVisibility()}cleanValue(e){if(!(this.values[e]===void 0||!this.isVisible(e)&&!this.isDisabled(e)))return this.values[e]}cleanValues(){const e=Object.keys(this.values).filter(n=>this.values[n]&&this.isVisible(n)&&!this.isDisabled(n));return Da.pick(this.values,e)}onChange(e){this.changeHandlers.push(e)}offChange(e){Da.pull(this.changeHandlers,e)}getFieldState(e){const n=this.errors.get(e)||[];return{key:e,value:this.values[e],showErrors:this.beenActives.has(e)&&!this.isDisabled(e)&&n.length>0,valid:n.length===0,errors:n,hidden:!this.isVisible(e),disabled:this.isDisabled(e),isActiveQuestion:this.activeQuestionKey===e,setAsActiveQuestion:()=>this.setActiveQuestion(e),setValue:a=>this.setValue(e,a)}}getValidationFieldState(e){return{value:this.values[e],addError:n=>this.addError(e,n)}}setTextvar(e,n){n?this.textvars.set(e,n):this.textvars.set(e,this.questionnaire.textvars.find(a=>a.key===e).default)}initTextvars(e){const n=new Map;for(const a of this.questionnaire.textvars)n.set(a.key,e.get(a.key)??a.default);for(const a of Object.values(this.questionnaire.questions)){const o=this.cleanValue(a.key);typeof o=="string"&&"setsTextvar"in a&&a.setsTextvar&&n.set(a.setsTextvar,o)}return n}setValue(e,n){const a=this.questionnaire.getField(e);this.values[e]=n,(n===null||typeof n=="string")&&"setsTextvar"in a&&a.setsTextvar&&this.setTextvar(a.setsTextvar,n),this.validate(),this.calculateVisibility(),this.calculations.handleValueChanged(e),this.changeHandlers.forEach(o=>o(this,"valueChanged"))}setActiveQuestion(e){this.activeQuestionKey!==e&&(this.activeQuestionKey&&this.touchField(this.activeQuestionKey),this.activeQuestionKey=e,this.changeHandlers.forEach(n=>n(this)))}addError(e,n){const a=this.errors.get(e)||[];a.push(n),this.errors.set(e,a)}valueHasChanged(){for(const e in this.questionnaire.questions){const n=lh(this.values[e]),a=lh(this.originalValues[e]);if(!Da.isEqual(n,a))return!0}return!1}touchAllFields(){Object.values(this.questionnaire.questions).forEach(e=>{this.touchField(e.key)})}touchPanelFields(e){e.questionKeys.forEach(n=>{this.touchField(n)})}touchField(e){if(this.beenActives.has(e))return;this.questionnaire.getQuestionsInSameGroup(e).forEach(a=>{this.beenActives.add(a.key),this.values[a.key]===void 0&&this.setValue(a.key,null)})}firstNotValidQuestionInPanel(e){return e.questionKeys.find(n=>{if(!this.isVisible(n)||this.isDisabled(n))return!1;if((this.errors.get(n)||[]).length>0)return!0})||null}firstNotValidQuestion(){const e=this.questionnaire.panels.find(n=>this.firstNotValidQuestionInPanel(n));return e==null?null:this.firstNotValidQuestionInPanel(e)}validate(){this.errors=new Map,this.questionnaire.validations.forEach(e=>{const n=Up(e);n&&n.validate(this)})}validEnoughForForcedSave(){for(const e of this.errors.values())if(!e.every(n=>zp.includes(n.type)))return!1;return!0}calculateVisibility(){const e=Object.keys(this.calculations.questionKeyToCalculationKeys).reduce((a,o)=>(a[o]=this.isVisible(o),a),{});this.visibility=new Map;let n=null;this.questionnaire.visibilityRules.forEach(a=>{n??(n=a.questionKey),a.questionKey!==n&&(e[n]&&e[n]!==this.isVisible(n)&&this.calculations.handleValueChanged(n),n=a.questionKey),a.runAgainst(this)})}markShown(e){const n=this.visibility.get(e)||{shown:!1,hidden:!1};n.shown=!0,this.visibility.set(e,n)}markHidden(e){const n=this.visibility.get(e)||{shown:!1,hidden:!1};n.hidden=!0,this.visibility.set(e,n)}isDisabled(e){const n=this.questionnaire.getField(e);if(!n.parentKey||!n.parentOptionKey)return!1;const a=this.questionnaire.getField(n.parentKey),o=this.values[a.key];return a.type==="radio"?o!==n.parentOptionKey:a.type==="check_box"?!o||!o.has(n.parentOptionKey):!1}isVisible(e){const n=this.visibility.get(e)||{shown:!1,hidden:!1},a=n.shown||!n.hidden,o=this.questionnaire.getField(e);return o.parentKey?a&&this.isVisible(o.parentKey):a}numberValue(e){const n=this.cleanValue(e);switch(this.questionnaire.getField(e).type){case"integer":case"float":return n;case"select":case"radio":case"scale":return n?this.questionnaire.getOptionNumberValue(e,n):null}return null}}function lh(r){return r===""||r==null||r instanceof Set&&r.size===0||r instanceof Map&&r.size===0?null:r}const uh=new Xd({key:"test",title:"test",language:"nl",panels:[],questions:{},visibilityRules:[],textvars:{},validations:[]}),Jv=new af(uh,{value:{},flags:{},textvars:new Map}),Qv={displayMode:"paged",darkMode:!1,newLayout:!0},Xv=(r,e)=>null,gd=Ee.createContext({questionnaire:uh,response:Jv,setQuestionRef:Xv,displayOptions:Qv});class of extends Error{}const ch=(r,e)=>{let n=r.value;return Da.isEmpty(n)&&!Da.isEmpty(e.defaultAnswerValue)&&(n=e.defaultAnswerValue),{flags:oh.parse(r.flags),textvars:sh.parse(r.textvars),value:qv(n,e)}},qv=(r,e)=>{const n=On.record(On.string(),On.any()).parse(r);return Object.values(e.questions).reduce((a,o)=>{const c=n[o.key];if(c==null)return a;switch(o.type){case"integer":case"float":a[o.key]=nh.parse(c);break;case"string":case"textarea":a[o.key]=rh.parse(c);break;case"select":case"scale":case"radio":a[o.key]=eb(c,o,e);break;case"check_box":a[o.key]=tb(c,o);break;case"date_parts":a[o.key]=ah.parse(c);break}return a},{})},eb=(r,e,n)=>{const a=On.string().parse(r);if(!n.getFlatOptions(e.key).some(c=>c.key===a))throw new of(`wrong option key ${a} present for ${e.key}`);return a},tb=(r,e)=>{const n=ih.parse(r);return n.forEach(a=>{if(!e.children.some(o=>o.key===a))throw new of(`wrong option key ${a} present for ${e.key}`)}),n},dh=/\{\{((?<type>[a-z_]+)\.(?<textvar>[a-z0-9]+)|(?<textvaronly>[a-z0-9_]+))\}\}/g;class fh{constructor(e,n){Tt(this,"response");Tt(this,"questionnaire");Tt(this,"stringToVariables");this.response=e,this.questionnaire=n,this.stringToVariables=new Map,this.interpolateCurlies=this.interpolateCurlies.bind(this)}interpolateCurlies(e){return this.stringToVariables.has(e)||this.stringToVariables.set(e,Array.from(e.matchAll(dh)).map(n=>n.groups.textvar)),this.stringToVariables.get(e).length==0?e:e.replace(dh,(...n)=>{var x;const{type:a,textvar:o,textvaronly:c}=n[n.length-1],v=a==="calculation"?(x=this.response.calculations.getResult(o))==null?void 0:x.toString():this.response.textvars.get(`${this.questionnaire.key}_${o||c}`);return Da.escape(v||"")})}}var sf={exports:{}},wc={};/**
|
|
39
|
+
}`;var Mt=Vg(function(){return Dt(O,Xe+"return "+be).apply(n,z)});if(Mt.source=be,Qf(Mt))throw Mt;return Mt}function p1(t){return an(t).toLowerCase()}function h1(t){return an(t).toUpperCase()}function g1(t,i,u){if(t=an(t),t&&(u||i===n))return _e(t);if(!t||!(i=yr(i)))return t;var m=Ar(t),C=Ar(i),O=Qt(m,C),z=Xn(m,C)+1;return pi(m,O,z).join("")}function m1(t,i,u){if(t=an(t),t&&(u||i===n))return t.slice(0,Nl(t)+1);if(!t||!(i=yr(i)))return t;var m=Ar(t),C=Xn(m,Ar(i))+1;return pi(m,0,C).join("")}function v1(t,i,u){if(t=an(t),t&&(u||i===n))return t.replace(rn,"");if(!t||!(i=yr(i)))return t;var m=Ar(t),C=Qt(m,Ar(i));return pi(m,C).join("")}function b1(t,i){var u=Ft,m=ye;if(An(i)){var C="separator"in i?i.separator:C;u="length"in i?Rt(i.length):u,m="omission"in i?yr(i.omission):m}t=an(t);var O=t.length;if(Eo(t)){var z=Ar(t);O=z.length}if(u>=O)return t;var $=u-To(m);if($<1)return m;var J=z?pi(z,0,$).join(""):t.slice(0,$);if(C===n)return J+m;if(z&&($+=J.length-$),Xf(C)){if(t.slice($).search(C)){var ce,fe=J;for(C.global||(C=ba(C.source,an(kt.exec(C))+"g")),C.lastIndex=0;ce=C.exec(fe);)var be=ce.index;J=J.slice(0,be===n?$:be)}}else if(t.indexOf(yr(C),$)!=$){var Le=J.lastIndexOf(C);Le>-1&&(J=J.slice(0,Le))}return J+m}function y1(t){return t=an(t),t&&hr.test(t)?t.replace(Pn,Ou):t}var w1=N(function(t,i,u){return t+(u?" ":"")+i.toUpperCase()}),tp=M("toUpperCase");function Ug(t,i,u){return t=an(t),i=u?n:i,i===n?Ec(t)?Ic(t):So(t):t.match(i)||[]}var Vg=bt(function(t,i){try{return Cn(t,n,i)}catch(u){return Qf(u)?u:new st(u)}}),x1=Rs(function(t,i){return Hn(i,function(u){u=$o(u),Gn(t,u,Kf(t[u],t))}),t});function S1(t){var i=t==null?0:t.length,u=lt();return t=i?qt(t,function(m){if(typeof m[1]!="function")throw new vr(v);return[u(m[0]),m[1]]}):[],bt(function(m){for(var C=-1;++C<i;){var O=t[C];if(Cn(O[0],this,m))return Cn(O[1],this,m)}})}function _1(t){return Xl(lr(t,F))}function np(t){return function(){return t}}function k1(t,i){return t==null||t!==t?i:t}var E1=d(),C1=d(!0);function Mi(t){return t}function rp(t){return zo(typeof t=="function"?t:lr(t,F))}function T1(t){return na(lr(t,F))}function R1(t,i){return fi(t,lr(i,F))}var I1=bt(function(t,i){return function(u){return Hr(u,t,i)}}),A1=bt(function(t,i){return function(u){return Hr(t,u,i)}});function ip(t,i,u){var m=xr(i),C=pl(i,m);u==null&&!(An(i)&&(C.length||!m.length))&&(u=i,i=t,t=this,C=pl(i,xr(i)));var O=!(An(u)&&"chain"in u)||!!u.chain,z=As(t);return Hn(C,function($){var J=i[$];t[$]=J,z&&(t.prototype[$]=function(){var ce=this.__chain__;if(O||ce){var fe=t(this.__wrapped__),be=fe.__actions__=Yn(this.__actions__);return be.push({func:J,args:arguments,thisArg:t}),fe.__chain__=ce,fe}return J.apply(t,Tr([this.value()],arguments))})}),t}function O1(){return En._===this&&(En._=dn),this}function ap(){}function M1(t){return t=Rt(t),bt(function(i){return io(i,t)})}var F1=L(qt),P1=L(xo),D1=L(ma);function Wg(t){return Wf(t)?h($o(t)):lu(t)}function L1(t){return function(i){return t==null?n:to(t,i)}}var B1=pe(),N1=pe(!0);function op(){return[]}function sp(){return!1}function j1(){return{}}function z1(){return""}function U1(){return!0}function V1(t,i){if(t=Rt(t),t<1||t>ze)return[];var u=ue,m=vn(t,ue);i=lt(i),t-=ue;for(var C=Q(m,i);++u<t;)i(u);return C}function W1(t){return Et(t)?qt(t,$o):aa(t)?[t]:Yn(ug(an(t)))}function H1(t){var i=++Fu;return an(t)+i}var $1=T(function(t,i){return t+i},0),G1=at("ceil"),Z1=T(function(t,i){return t/i},1),Y1=at("floor");function K1(t){return t&&t.length?fl(t,Mi,fs):n}function J1(t,i){return t&&t.length?fl(t,lt(i,2),fs):n}function Q1(t){return es(t,Mi)}function X1(t,i){return es(t,lt(i,2))}function q1(t){return t&&t.length?fl(t,Mi,di):n}function e_(t,i){return t&&t.length?fl(t,lt(i,2),di):n}var t_=T(function(t,i){return t*i},1),n_=at("round"),r_=T(function(t,i){return t-i},0);function i_(t){return t&&t.length?q(t,Mi):0}function a_(t,i){return t&&t.length?q(t,lt(i,2)):0}return I.after=Tx,I.ary=wg,I.assign=hS,I.assignIn=Pg,I.assignInWith=zd,I.assignWith=gS,I.at=mS,I.before=xg,I.bind=Kf,I.bindAll=x1,I.bindKey=Sg,I.castArray=jx,I.chain=vg,I.chunk=Y0,I.compact=K0,I.concat=J0,I.cond=S1,I.conforms=_1,I.constant=np,I.countBy=ix,I.create=vS,I.curry=_g,I.curryRight=kg,I.debounce=Eg,I.defaults=bS,I.defaultsDeep=yS,I.defer=Rx,I.delay=Ix,I.difference=Q0,I.differenceBy=X0,I.differenceWith=q0,I.drop=ew,I.dropRight=tw,I.dropRightWhile=nw,I.dropWhile=rw,I.fill=iw,I.filter=ox,I.flatMap=ux,I.flatMapDeep=cx,I.flatMapDepth=dx,I.flatten=pg,I.flattenDeep=aw,I.flattenDepth=ow,I.flip=Ax,I.flow=E1,I.flowRight=C1,I.fromPairs=sw,I.functions=CS,I.functionsIn=TS,I.groupBy=fx,I.initial=uw,I.intersection=cw,I.intersectionBy=dw,I.intersectionWith=fw,I.invert=IS,I.invertBy=AS,I.invokeMap=hx,I.iteratee=rp,I.keyBy=gx,I.keys=xr,I.keysIn=Oi,I.map=Pd,I.mapKeys=MS,I.mapValues=FS,I.matches=T1,I.matchesProperty=R1,I.memoize=Ld,I.merge=PS,I.mergeWith=Dg,I.method=I1,I.methodOf=A1,I.mixin=ip,I.negate=Bd,I.nthArg=M1,I.omit=DS,I.omitBy=LS,I.once=Ox,I.orderBy=mx,I.over=F1,I.overArgs=Mx,I.overEvery=P1,I.overSome=D1,I.partial=Jf,I.partialRight=Cg,I.partition=vx,I.pick=BS,I.pickBy=Lg,I.property=Wg,I.propertyOf=L1,I.pull=mw,I.pullAll=gg,I.pullAllBy=vw,I.pullAllWith=bw,I.pullAt=yw,I.range=B1,I.rangeRight=N1,I.rearg=Fx,I.reject=wx,I.remove=ww,I.rest=Px,I.reverse=Zf,I.sampleSize=Sx,I.set=jS,I.setWith=zS,I.shuffle=_x,I.slice=xw,I.sortBy=Cx,I.sortedUniq=Rw,I.sortedUniqBy=Iw,I.split=u1,I.spread=Dx,I.tail=Aw,I.take=Ow,I.takeRight=Mw,I.takeRightWhile=Fw,I.takeWhile=Pw,I.tap=Kw,I.throttle=Lx,I.thru=Fd,I.toArray=Og,I.toPairs=Bg,I.toPairsIn=Ng,I.toPath=W1,I.toPlainObject=Fg,I.transform=US,I.unary=Bx,I.union=Dw,I.unionBy=Lw,I.unionWith=Bw,I.uniq=Nw,I.uniqBy=jw,I.uniqWith=zw,I.unset=VS,I.unzip=Yf,I.unzipWith=mg,I.update=WS,I.updateWith=HS,I.values=ec,I.valuesIn=$S,I.without=Uw,I.words=Ug,I.wrap=Nx,I.xor=Vw,I.xorBy=Ww,I.xorWith=Hw,I.zip=$w,I.zipObject=Gw,I.zipObjectDeep=Zw,I.zipWith=Yw,I.entries=Bg,I.entriesIn=Ng,I.extend=Pg,I.extendWith=zd,ip(I,I),I.add=$1,I.attempt=Vg,I.camelCase=KS,I.capitalize=jg,I.ceil=G1,I.clamp=GS,I.clone=zx,I.cloneDeep=Vx,I.cloneDeepWith=Wx,I.cloneWith=Ux,I.conformsTo=Hx,I.deburr=zg,I.defaultTo=k1,I.divide=Z1,I.endsWith=JS,I.eq=so,I.escape=QS,I.escapeRegExp=XS,I.every=ax,I.find=sx,I.findIndex=dg,I.findKey=wS,I.findLast=lx,I.findLastIndex=fg,I.findLastKey=xS,I.floor=Y1,I.forEach=bg,I.forEachRight=yg,I.forIn=SS,I.forInRight=_S,I.forOwn=kS,I.forOwnRight=ES,I.get=qf,I.gt=$x,I.gte=Gx,I.has=RS,I.hasIn=ep,I.head=hg,I.identity=Mi,I.includes=px,I.indexOf=lw,I.inRange=ZS,I.invoke=OS,I.isArguments=wu,I.isArray=Et,I.isArrayBuffer=Zx,I.isArrayLike=Ai,I.isArrayLikeObject=Kn,I.isBoolean=Yx,I.isBuffer=El,I.isDate=Kx,I.isElement=Jx,I.isEmpty=Qx,I.isEqual=Xx,I.isEqualWith=qx,I.isError=Qf,I.isFinite=eS,I.isFunction=As,I.isInteger=Tg,I.isLength=Nd,I.isMap=Rg,I.isMatch=tS,I.isMatchWith=nS,I.isNaN=rS,I.isNative=iS,I.isNil=oS,I.isNull=aS,I.isNumber=Ig,I.isObject=An,I.isObjectLike=jn,I.isPlainObject=Vc,I.isRegExp=Xf,I.isSafeInteger=sS,I.isSet=Ag,I.isString=jd,I.isSymbol=aa,I.isTypedArray=qu,I.isUndefined=lS,I.isWeakMap=uS,I.isWeakSet=cS,I.join=pw,I.kebabCase=qS,I.last=Ia,I.lastIndexOf=hw,I.lowerCase=e1,I.lowerFirst=t1,I.lt=dS,I.lte=fS,I.max=K1,I.maxBy=J1,I.mean=Q1,I.meanBy=X1,I.min=q1,I.minBy=e_,I.stubArray=op,I.stubFalse=sp,I.stubObject=j1,I.stubString=z1,I.stubTrue=U1,I.multiply=t_,I.nth=gw,I.noConflict=O1,I.noop=ap,I.now=Dd,I.pad=n1,I.padEnd=r1,I.padStart=i1,I.parseInt=a1,I.random=YS,I.reduce=bx,I.reduceRight=yx,I.repeat=o1,I.replace=s1,I.result=NS,I.round=n_,I.runInContext=Z,I.sample=xx,I.size=kx,I.snakeCase=l1,I.some=Ex,I.sortedIndex=Sw,I.sortedIndexBy=_w,I.sortedIndexOf=kw,I.sortedLastIndex=Ew,I.sortedLastIndexBy=Cw,I.sortedLastIndexOf=Tw,I.startCase=c1,I.startsWith=d1,I.subtract=r_,I.sum=i_,I.sumBy=a_,I.template=f1,I.times=V1,I.toFinite=Os,I.toInteger=Rt,I.toLength=Mg,I.toLower=p1,I.toNumber=Aa,I.toSafeInteger=pS,I.toString=an,I.toUpper=h1,I.trim=g1,I.trimEnd=m1,I.trimStart=v1,I.truncate=b1,I.unescape=y1,I.uniqueId=H1,I.upperCase=w1,I.upperFirst=tp,I.each=bg,I.eachRight=yg,I.first=hg,ip(I,function(){var t={};return Ti(I,function(i,u){$t.call(I.prototype,u)||(t[u]=i)}),t}(),{chain:!1}),I.VERSION=a,Hn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){I[t].placeholder=I}),Hn(["drop","take"],function(t,i){St.prototype[t]=function(u){u=u===n?1:mn(Rt(u),0);var m=this.__filtered__&&!i?new St(this):this.clone();return m.__filtered__?m.__takeCount__=vn(u,m.__takeCount__):m.__views__.push({size:vn(u,ue),type:t+(m.__dir__<0?"Right":"")}),m},St.prototype[t+"Right"]=function(u){return this.reverse()[t](u).reverse()}}),Hn(["filter","map","takeWhile"],function(t,i){var u=i+1,m=u==Be||u==He;St.prototype[t]=function(C){var O=this.clone();return O.__iteratees__.push({iteratee:lt(C,3),type:u}),O.__filtered__=O.__filtered__||m,O}}),Hn(["head","last"],function(t,i){var u="take"+(i?"Right":"");St.prototype[t]=function(){return this[u](1).value()[0]}}),Hn(["initial","tail"],function(t,i){var u="drop"+(i?"":"Right");St.prototype[t]=function(){return this.__filtered__?new St(this):this[u](1)}}),St.prototype.compact=function(){return this.filter(Mi)},St.prototype.find=function(t){return this.filter(t).head()},St.prototype.findLast=function(t){return this.reverse().find(t)},St.prototype.invokeMap=bt(function(t,i){return typeof t=="function"?new St(this):this.map(function(u){return Hr(u,t,i)})}),St.prototype.reject=function(t){return this.filter(Bd(lt(t)))},St.prototype.slice=function(t,i){t=Rt(t);var u=this;return u.__filtered__&&(t>0||i<0)?new St(u):(t<0?u=u.takeRight(-t):t&&(u=u.drop(t)),i!==n&&(i=Rt(i),u=i<0?u.dropRight(-i):u.take(i-t)),u)},St.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},St.prototype.toArray=function(){return this.take(ue)},Ti(St.prototype,function(t,i){var u=/^(?:filter|find|map|reject)|While$/.test(i),m=/^(?:head|last)$/.test(i),C=I[m?"take"+(i=="last"?"Right":""):i],O=m||/^find/.test(i);C&&(I.prototype[i]=function(){var z=this.__wrapped__,$=m?[1]:arguments,J=z instanceof St,ce=$[0],fe=J||Et(z),be=function(jt){var Wt=C.apply(I,Tr([jt],$));return m&&Le?Wt[0]:Wt};fe&&u&&typeof ce=="function"&&ce.length!=1&&(J=fe=!1);var Le=this.__chain__,Xe=!!this.__actions__.length,ut=O&&!Le,Mt=J&&!Xe;if(!O&&fe){z=Mt?z:new St(this);var ct=t.apply(z,$);return ct.__actions__.push({func:Fd,args:[be],thisArg:n}),new sr(ct,Le)}return ut&&Mt?t.apply(this,$):(ct=this.thru(be),ut?m?ct.value()[0]:ct.value():ct)})}),Hn(["pop","push","shift","sort","splice","unshift"],function(t){var i=$a[t],u=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",m=/^(?:pop|shift)$/.test(t);I.prototype[t]=function(){var C=arguments;if(m&&!this.__chain__){var O=this.value();return i.apply(Et(O)?O:[],C)}return this[u](function(z){return i.apply(Et(z)?z:[],C)})}}),Ti(St.prototype,function(t,i){var u=I[i];if(u){var m=u.name+"";$t.call(_a,m)||(_a[m]=[]),_a[m].push({name:i,func:u})}}),_a[g(n,G).name]=[{name:"wrapper",func:n}],St.prototype.clone=rl,St.prototype.reverse=Do,St.prototype.value=cs,I.prototype.at=Jw,I.prototype.chain=Qw,I.prototype.commit=Xw,I.prototype.next=qw,I.prototype.plant=tx,I.prototype.reverse=nx,I.prototype.toJSON=I.prototype.valueOf=I.prototype.value=rx,I.prototype.first=I.prototype.head,Ki&&(I.prototype[Ki]=ex),I},Bn=Mu();Gi?((Gi.exports=Bn)._=Bn,bo._=Bn):En._=Bn}).call(er)}(sd,sd.exports);var Da=sd.exports;const vi=Symbol.for("@ts-pattern/matcher"),Bp=Symbol.for("@ts-pattern/isVariadic"),ld="@ts-pattern/anonymous-select-key",qd=r=>!!(r&&typeof r=="object"),ud=r=>r&&!!r[vi],Sr=(r,e,n)=>{if(ud(r)){const a=r[vi](),{matched:o,selections:c}=a.match(e);return o&&c&&Object.keys(c).forEach(v=>n(v,c[v])),o}if(qd(r)){if(!qd(e))return!1;if(Array.isArray(r)){if(!Array.isArray(e))return!1;let a=[],o=[],c=[];for(const v of r.keys()){const x=r[v];ud(x)&&x[Bp]?c.push(x):c.length?o.push(x):a.push(x)}if(c.length){if(c.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(e.length<a.length+o.length)return!1;const v=e.slice(0,a.length),x=o.length===0?[]:e.slice(-o.length),y=e.slice(a.length,o.length===0?1/0:-o.length);return a.every((E,B)=>Sr(E,v[B],n))&&o.every((E,B)=>Sr(E,x[B],n))&&(c.length===0||Sr(c[0],y,n))}return r.length===e.length&&r.every((v,x)=>Sr(v,e[x],n))}return Reflect.ownKeys(r).every(a=>{const o=r[a];return(a in e||ud(c=o)&&c[vi]().matcherType==="optional")&&Sr(o,e[a],n);var c})}return Object.is(e,r)},Fi=r=>{var e,n,a;return qd(r)?ud(r)?(e=(n=(a=r[vi]()).getSelectionKeys)==null?void 0:n.call(a))!=null?e:[]:Array.isArray(r)?vc(r,Fi):vc(Object.values(r),Fi):[]},vc=(r,e)=>r.reduce((n,a)=>n.concat(e(a)),[]);function Dv(...r){if(r.length===1){const[e]=r;return n=>Sr(e,n,()=>{})}if(r.length===2){const[e,n]=r;return Sr(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${r.length}.`)}function _r(r){return Object.assign(r,{optional:()=>tf(r),and:e=>bn(r,e),or:e=>Np(r,e),select:e=>e===void 0?bc(r):bc(e,r)})}function ef(r){return Object.assign((e=>Object.assign(e,{[Symbol.iterator](){let n=0;const a=[{value:Object.assign(e,{[Bp]:!0}),done:!1},{done:!0,value:void 0}];return{next:()=>{var o;return(o=a[n++])!=null?o:a.at(-1)}}}}))(r),{optional:()=>ef(tf(r)),select:e=>ef(e===void 0?bc(r):bc(e,r))})}function tf(r){return _r({[vi]:()=>({match:e=>{let n={};const a=(o,c)=>{n[o]=c};return e===void 0?(Fi(r).forEach(o=>a(o,void 0)),{matched:!0,selections:n}):{matched:Sr(r,e,a),selections:n}},getSelectionKeys:()=>Fi(r),matcherType:"optional"})})}const Lv=(r,e)=>{for(const n of r)if(!e(n))return!1;return!0},Bv=(r,e)=>{for(const[n,a]of r.entries())if(!e(a,n))return!1;return!0};function bn(...r){return _r({[vi]:()=>({match:e=>{let n={};const a=(o,c)=>{n[o]=c};return{matched:r.every(o=>Sr(o,e,a)),selections:n}},getSelectionKeys:()=>vc(r,Fi),matcherType:"and"})})}function Np(...r){return _r({[vi]:()=>({match:e=>{let n={};const a=(o,c)=>{n[o]=c};return vc(r,Fi).forEach(o=>a(o,void 0)),{matched:r.some(o=>Sr(o,e,a)),selections:n}},getSelectionKeys:()=>vc(r,Fi),matcherType:"or"})})}function Ht(r){return{[vi]:()=>({match:e=>({matched:!!r(e)})})}}function bc(...r){const e=typeof r[0]=="string"?r[0]:void 0,n=r.length===2?r[1]:typeof r[0]=="string"?void 0:r[0];return _r({[vi]:()=>({match:a=>{let o={[e??ld]:a};return{matched:n===void 0||Sr(n,a,(c,v)=>{o[c]=v}),selections:o}},getSelectionKeys:()=>[e??ld].concat(n===void 0?[]:Fi(n))})})}function po(r){return typeof r=="number"}function Ns(r){return typeof r=="string"}function js(r){return typeof r=="bigint"}const jp=_r(Ht(function(r){return!0})),Nv=jp,zs=r=>Object.assign(_r(r),{startsWith:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&a.startsWith(n)))));var n},endsWith:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&a.endsWith(n)))));var n},minLength:e=>zs(bn(r,(n=>Ht(a=>Ns(a)&&a.length>=n))(e))),length:e=>zs(bn(r,(n=>Ht(a=>Ns(a)&&a.length===n))(e))),maxLength:e=>zs(bn(r,(n=>Ht(a=>Ns(a)&&a.length<=n))(e))),includes:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&a.includes(n)))));var n},regex:e=>{return zs(bn(r,(n=e,Ht(a=>Ns(a)&&!!a.match(n)))));var n}}),jv=zs(Ht(Ns)),ho=r=>Object.assign(_r(r),{between:(e,n)=>ho(bn(r,((a,o)=>Ht(c=>po(c)&&a<=c&&o>=c))(e,n))),lt:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a<n))(e))),gt:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a>n))(e))),lte:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a<=n))(e))),gte:e=>ho(bn(r,(n=>Ht(a=>po(a)&&a>=n))(e))),int:()=>ho(bn(r,Ht(e=>po(e)&&Number.isInteger(e)))),finite:()=>ho(bn(r,Ht(e=>po(e)&&Number.isFinite(e)))),positive:()=>ho(bn(r,Ht(e=>po(e)&&e>0))),negative:()=>ho(bn(r,Ht(e=>po(e)&&e<0)))}),zv=ho(Ht(po)),Us=r=>Object.assign(_r(r),{between:(e,n)=>Us(bn(r,((a,o)=>Ht(c=>js(c)&&a<=c&&o>=c))(e,n))),lt:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a<n))(e))),gt:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a>n))(e))),lte:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a<=n))(e))),gte:e=>Us(bn(r,(n=>Ht(a=>js(a)&&a>=n))(e))),positive:()=>Us(bn(r,Ht(e=>js(e)&&e>0))),negative:()=>Us(bn(r,Ht(e=>js(e)&&e<0)))}),Uv=Us(Ht(js)),Vv=_r(Ht(function(r){return typeof r=="boolean"})),Wv=_r(Ht(function(r){return typeof r=="symbol"})),Hv=_r(Ht(function(r){return r==null})),$v=_r(Ht(function(r){return r!=null}));var cd={__proto__:null,matcher:vi,optional:tf,array:function(...r){return ef({[vi]:()=>({match:e=>{if(!Array.isArray(e))return{matched:!1};if(r.length===0)return{matched:!0};const n=r[0];let a={};if(e.length===0)return Fi(n).forEach(c=>{a[c]=[]}),{matched:!0,selections:a};const o=(c,v)=>{a[c]=(a[c]||[]).concat([v])};return{matched:e.every(c=>Sr(n,c,o)),selections:a}},getSelectionKeys:()=>r.length===0?[]:Fi(r[0])})})},set:function(...r){return _r({[vi]:()=>({match:e=>{if(!(e instanceof Set))return{matched:!1};let n={};if(e.size===0)return{matched:!0,selections:n};if(r.length===0)return{matched:!0};const a=(c,v)=>{n[c]=(n[c]||[]).concat([v])},o=r[0];return{matched:Lv(e,c=>Sr(o,c,a)),selections:n}},getSelectionKeys:()=>r.length===0?[]:Fi(r[0])})})},map:function(...r){return _r({[vi]:()=>({match:e=>{if(!(e instanceof Map))return{matched:!1};let n={};if(e.size===0)return{matched:!0,selections:n};const a=(x,y)=>{n[x]=(n[x]||[]).concat([y])};if(r.length===0)return{matched:!0};var o;if(r.length===1)throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${(o=r[0])==null?void 0:o.toString()}`);const[c,v]=r;return{matched:Bv(e,(x,y)=>{const E=Sr(c,y,a),B=Sr(v,x,a);return E&&B}),selections:n}},getSelectionKeys:()=>r.length===0?[]:[...Fi(r[0]),...Fi(r[1])]})})},intersection:bn,union:Np,not:function(r){return _r({[vi]:()=>({match:e=>({matched:!Sr(r,e,()=>{})}),getSelectionKeys:()=>[],matcherType:"not"})})},when:Ht,select:bc,any:jp,_:Nv,string:jv,number:zv,bigint:Uv,boolean:Vv,symbol:Wv,nullish:Hv,nonNullable:$v,instanceOf:function(r){return _r(Ht(function(e){return n=>n instanceof e}(r)))},shape:function(r){return _r(Ht(Dv(r)))}};class Gv extends Error{constructor(e){let n;try{n=JSON.stringify(e)}catch{n=e}super(`Pattern matching error: no pattern matches value ${n}`),this.input=void 0,this.input=e}}const nf={matched:!1,value:void 0};function yc(r){return new dd(r,nf)}class dd{constructor(e,n){this.input=void 0,this.state=void 0,this.input=e,this.state=n}with(...e){if(this.state.matched)return this;const n=e[e.length-1],a=[e[0]];let o;e.length===3&&typeof e[1]=="function"?o=e[1]:e.length>2&&a.push(...e.slice(1,e.length-1));let c=!1,v={};const x=(E,B)=>{c=!0,v[E]=B},y=!a.some(E=>Sr(E,this.input,x))||o&&!o(this.input)?nf:{matched:!0,value:n(c?ld in v?v[ld]:v:this.input,this.input)};return new dd(this.input,y)}when(e,n){if(this.state.matched)return this;const a=!!e(this.input);return new dd(this.input,a?{matched:!0,value:n(this.input,this.input)}:nf)}otherwise(e){return this.state.matched?this.state.value:e(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new Gv(this.input)}run(){return this.exhaustive()}returnType(){return this}}const Df=class{constructor(e,n){Tt(this,"sexpVariables");Tt(this,"questionKeyToCalculationKeys");Tt(this,"response");Tt(this,"results",{});Tt(this,"calculateNumber",e=>yc(e).with({op:"number"},({value:n})=>n).with({op:"number_value"},({key:n})=>this.response.numberValue(n)).with({op:"sum"},({values:n})=>this.reduce(n,"sum")).with({op:"subtract"},({values:n})=>this.reduce(n,"subtract")).with({op:"multiply"},({values:n})=>this.reduce(n,"multiply")).with({op:"divide"},({values:n})=>this.reduce(n,"divide")).with({op:"round"},({value:n,digits:a})=>this.round(n,a)).exhaustive());Tt(this,"calculateBoolean",e=>{if(!Qd.options.includes(e.op))throw new Error(`Unknown boolean operation: ${e.op}`);return yc(e).with({op:cd.union(...Jd.options)},this.compare).with({op:cd.union(...Kd.options)},this.booleanReduce).exhaustive()});Tt(this,"compare",e=>{const n=this.calculateNumber(e.left),a=this.calculateNumber(e.right);return n===null||a===null?null:yc(e.op).with("eq",()=>n===a).with("not_eq",()=>n!==a).with("gt",()=>n>a).with("gteq",()=>n>=a).with("lt",()=>n<a).with("lteq",()=>n<=a).exhaustive()});Tt(this,"booleanReduce",e=>{const n=e.values.map(this.calculateBoolean);return n.some(a=>a===null)?null:yc(e.op).with("all",()=>n.every(a=>a===!0)).with("some",()=>n.some(a=>a===!0)).with("none",()=>n.every(a=>a===!1)).exhaustive()});this.sexpVariables=e,this.questionKeyToCalculationKeys=Zv(e),this.response=n}getResult(e){return this.results[e]===void 0&&(this.results[e]=this.calculate(this.sexpVariables[e].calculation)),this.results[e]??null}handleValueChanged(e){var n;(n=this.questionKeyToCalculationKeys[e])==null||n.forEach(a=>{delete this.results[a]})}calculate(e){return yc(e).with({op:"string_value"},({key:n})=>this.stringValue(n)).with({op:cd.union("number","number_value","sum","subtract","multiply","divide","round")},this.calculateNumber).with({op:cd.union(...Qd.options)},this.calculateBoolean).exhaustive()}stringValue(e){const n=this.response.cleanValue(e);return(n==null?void 0:n.toString())??null}reduce(e,n){const a=e.map(o=>this.calculateNumber(o));return a.some(o=>o===null)?null:a.reduce(Df.numberReducers[n])}round(e,n){const a=this.calculateNumber(e);return a===null?null:Number(a.toFixed(n))}};let fd=Df;Tt(fd,"numberReducers",{sum:(e,n)=>e+n,multiply:(e,n)=>e*n,subtract:(e,n)=>e-n,divide:(e,n)=>e/n});function Zv(r){const e={};for(const[n,a]of Object.entries(r))Tu(a.calculation).forEach(c=>{e[c]??(e[c]=new Set),e[c].add(n)});return e}function Tu(r){switch(r.op){case"number_value":case"string_value":return[r.key];case"sum":case"multiply":case"divide":case"subtract":return r.values.flatMap(e=>Tu(e));case"round":return Tu(r.value);case"eq":case"not_eq":case"gt":case"gteq":case"lt":case"lteq":return[...Tu(r.left),...Tu(r.right)];case"all":case"some":case"none":return r.values.flatMap(e=>Tu(e));case"number":return[]}}function Yv(r,e,n){if(arguments.length<3)throw new TypeError("3 argument required, but only "+arguments.length+" present");var a=new Date(r,e,n);return a.getFullYear()===r&&a.getMonth()===e&&a.getDate()===n}const zp=["requires_answer","minimum_checked_required","answer_group_minimum"];function Up(r){switch(r.type){case"requires_answer":return new Vp(r);case"valid_integer":return new $p(r);case"valid_float":return new Gp(r);case"valid_date":return new Hp(r);case"minimum":return new Zp(r);case"maximum":return new Yp(r);case"minimum_date":return new Kp(r);case"maximum_date":return new Jp(r);case"minimum_checked_required":return new Qp(r);case"maximum_checked_allowed":return new Xp(r);case"answer_group_minimum":return new qp(r);case"answer_group_maximum":return new eh(r);case"regexp":return new th(r)}}class bi{constructor(e){Tt(this,"config");this.config=e}}class Vp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Ru(n.value)||this.ignoreDueToDependsOn(e)||n.addError({type:this.config.type,message:{t:"requires_answer"}})}ignoreDueToDependsOn(e){return!this.config.dependsOnQuestions&&!this.config.dependsOnOptions?!1:!this.dependsOnQuestionAnswered(e)&&!this.dependsOnOptionSelected(e)}dependsOnQuestionAnswered(e){return this.config.dependsOnQuestions===void 0?!1:this.config.dependsOnQuestions.some(n=>Ru(e.getValidationFieldState(n).value))}dependsOnOptionSelected(e){return this.config.dependsOnOptions===void 0?!1:Object.entries(this.config.dependsOnOptions).some(([n,a])=>{const o=e.getValidationFieldState(n).value;if(Ru(o)){if(typeof o=="string")return a.some(c=>c===o);if(o instanceof Set)return a.some(c=>o.has(c));throw new Error("unknown question type for dependsOnOptions: this.config.fieldKey")}else return!1})}}function Ru(r){if(r==null)return!1;if(typeof r=="string")return!!r;if(typeof r=="number")return!0;if(r instanceof Map)return hd(r);if("size"in r)return r.size>0;if("length"in r)return r.length>0;throw`Unexpected value type in validation ${r}`}function pd(r){return r===void 0||r===null||r===""?!1:typeof r=="string"}function Wp(r){return r===void 0||r===null?!1:typeof r=="number"}function hd(r){if(r===void 0||r===null)return!1;for(const[e,n]of r){if(typeof e!="string"||typeof n!="string")return!1;if(pd(n))return!0}return!1}const Kv=/(\s*-?[1-9][0-9]+\s*|\s*-?[0-9]\s*)/;class Hp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!hd(n.value))return;if(this.config.requiredParts.some(o=>!n.value.get(o))){n.addError({type:this.config.type,message:{t:`valid_date.${this.config.subtype}`}});return}const a=rf(n.value);(!a||!Yv(a.year,a.month,a.day)||a.year<1900||a.year>2100||a.hour>23||a.minute>59)&&n.addError({type:this.config.type,message:{t:`valid_date.${this.config.subtype}`}})}}function rf(r){var e=function(n,a){const o=r.get(n);return o===void 0||o==""?a:parseInt(o,10)};return[...r.values()].some(n=>n&&!/^\d*$/.test(n))?null:{year:e("year",2e3),month:e("month",1)-1,day:e("day",1),hour:e("hour",0),minute:e("minute",0)}}class $p extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!pd(n.value))return;const a=Kv.exec(n.value);(a===null||a[0]!==n.value)&&n.addError({type:this.config.type,message:{t:"valid_integer"}})}}class Gp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!pd(n.value))return;const a=parseFloat(n.value);!isNaN(a)&&isFinite(a)||n.addError({type:this.config.type,message:{t:"valid_float"}})}}class Zp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Wp(n.value)&&parseFloat(n.value)<this.config.value&&n.addError({type:this.config.type,message:{t:"minimum",value:this.config.value.toString()}})}}class Yp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Wp(n.value)&&parseFloat(n.value)>this.config.value&&n.addError({type:this.config.type,message:{t:"maximum",value:this.config.value.toString()}})}}class Kp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!hd(n.value))return;const a=rf(n.value);a&&new Date(a.year,a.month,a.hour)<new Date(this.config.value)&&n.addError({type:this.config.type,message:{t:"minimum_date",friendly_date:this.config.value}})}}class Jp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!hd(n.value))return;const a=rf(n.value);a&&new Date(a.year,a.month,a.hour)>new Date(this.config.value)&&n.addError({type:this.config.type,message:{t:"maximum_date",friendly_date:this.config.value}})}}class Qp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);(!n.value||n.value.size<this.config.minimumCheckedValue)&&n.addError({type:this.config.type,message:{t:"minimum_checked_required",count:this.config.minimumCheckedValue}})}}class Xp extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);Ru(n.value)&&n.value.size>this.config.maximumCheckedValue&&n.addError({type:this.config.type,message:{t:"maximum_checked_allowed",count:this.config.maximumCheckedValue}})}}class qp extends bi{validate(e){const n=this.config.fieldKeys.map(a=>e.getValidationFieldState(a));n.filter(a=>Ru(a.value)).length>=this.config.value||n.forEach(a=>{a.addError({type:this.config.type,message:{t:"answer_group_minimum",value:this.config.value}})})}}class eh extends bi{validate(e){const n=this.config.fieldKeys.map(a=>e.getValidationFieldState(a));n.filter(a=>Ru(a.value)).length<=this.config.value||n.forEach(a=>{a.addError({type:this.config.type,message:{t:"answer_group_maximum",value:this.config.value}})})}}class th extends bi{validate(e){const n=e.getValidationFieldState(this.config.fieldKey);if(!pd(n.value))return;const a=this.config.matcher.replace("\\A","^").replace("\\Z","$"),c=new RegExp(a).exec(n.value);(c===null||c[0]!==n.value)&&n.addError({type:this.config.type,message:this.config.explanation||{t:"regexp",matcher:this.config.matcher}})}}const nh=On.coerce.number(),rh=On.coerce.string(),ih=On.preprocess(r=>r instanceof Array?new Set(r):r,On.set(On.string())),ah=On.preprocess(r=>!(r instanceof Map)&&r instanceof Object?new Map(Object.entries(r)):r,On.map(Dp,On.string())),oh=On.record(On.boolean()),sh=On.preprocess(r=>!(r instanceof Map)&&r instanceof Object?new Map(Object.entries(r)):r,On.map(On.string(),On.string()));class af{constructor(e,n){Tt(this,"questionnaire");Tt(this,"values");Tt(this,"originalValues");Tt(this,"beenActives");Tt(this,"errors");Tt(this,"visibility");Tt(this,"changeHandlers");Tt(this,"flags");Tt(this,"textvars");Tt(this,"activeQuestionKey");Tt(this,"calculations");this.questionnaire=e,this.values=n.value,this.originalValues={...n.value},this.beenActives=new Set,this.errors=new Map,this.visibility=new Map,this.changeHandlers=[],this.flags=n.flags,this.textvars=this.initTextvars(n.textvars),this.activeQuestionKey=null,this.calculations=new fd(e.sexpVariables,this),this.validate(),this.calculateVisibility()}cleanValue(e){if(!(this.values[e]===void 0||!this.isVisible(e)&&!this.isDisabled(e)))return this.values[e]}cleanValues(){const e=Object.keys(this.values).filter(n=>this.values[n]&&this.isVisible(n)&&!this.isDisabled(n));return Da.pick(this.values,e)}onChange(e){this.changeHandlers.push(e)}offChange(e){Da.pull(this.changeHandlers,e)}getFieldState(e){const n=this.errors.get(e)||[];return{key:e,value:this.values[e],showErrors:this.beenActives.has(e)&&!this.isDisabled(e)&&n.length>0,valid:n.length===0,errors:n,hidden:!this.isVisible(e),disabled:this.isDisabled(e),isActiveQuestion:this.activeQuestionKey===e,setAsActiveQuestion:()=>this.setActiveQuestion(e),setValue:a=>this.setValue(e,a)}}getValidationFieldState(e){return{value:this.values[e],addError:n=>this.addError(e,n)}}setTextvar(e,n){n?this.textvars.set(e,n):this.textvars.set(e,this.questionnaire.textvars.find(a=>a.key===e).default)}initTextvars(e){const n=new Map;for(const a of this.questionnaire.textvars)n.set(a.key,e.get(a.key)??a.default);for(const a of Object.values(this.questionnaire.questions)){const o=this.cleanValue(a.key);typeof o=="string"&&"setsTextvar"in a&&a.setsTextvar&&n.set(a.setsTextvar,o)}return n}setValue(e,n){const a=this.questionnaire.getField(e);this.values[e]=n,(n===null||typeof n=="string")&&"setsTextvar"in a&&a.setsTextvar&&this.setTextvar(a.setsTextvar,n),this.validate(),this.calculations.handleValueChanged(e),this.calculateVisibility(),this.changeHandlers.forEach(o=>o(this,"valueChanged"))}setActiveQuestion(e){this.activeQuestionKey!==e&&(this.activeQuestionKey&&this.touchField(this.activeQuestionKey),this.activeQuestionKey=e,this.changeHandlers.forEach(n=>n(this)))}addError(e,n){const a=this.errors.get(e)||[];a.push(n),this.errors.set(e,a)}valueHasChanged(){for(const e in this.questionnaire.questions){const n=lh(this.values[e]),a=lh(this.originalValues[e]);if(!Da.isEqual(n,a))return!0}return!1}touchAllFields(){Object.values(this.questionnaire.questions).forEach(e=>{this.touchField(e.key)})}touchPanelFields(e){e.questionKeys.forEach(n=>{this.touchField(n)})}touchField(e){if(this.beenActives.has(e))return;this.questionnaire.getQuestionsInSameGroup(e).forEach(a=>{this.beenActives.add(a.key),this.values[a.key]===void 0&&this.setValue(a.key,null)})}firstNotValidQuestionInPanel(e){return e.questionKeys.find(n=>{if(!this.isVisible(n)||this.isDisabled(n))return!1;if((this.errors.get(n)||[]).length>0)return!0})||null}firstNotValidQuestion(){const e=this.questionnaire.panels.find(n=>this.firstNotValidQuestionInPanel(n));return e==null?null:this.firstNotValidQuestionInPanel(e)}validate(){this.errors=new Map,this.questionnaire.validations.forEach(e=>{const n=Up(e);n&&n.validate(this)})}validEnoughForForcedSave(){for(const e of this.errors.values())if(!e.every(n=>zp.includes(n.type)))return!1;return!0}calculateVisibility(){const e=Object.keys(this.calculations.questionKeyToCalculationKeys).reduce((a,o)=>(a[o]=this.isVisible(o),a),{});this.visibility=new Map;let n=null;this.questionnaire.visibilityRules.forEach(a=>{n??(n=a.questionKey),a.questionKey!==n&&(e[n]&&e[n]!==this.isVisible(n)&&this.calculations.handleValueChanged(n),n=a.questionKey),a.runAgainst(this)})}markShown(e){const n=this.visibility.get(e)||{shown:!1,hidden:!1};n.shown=!0,this.visibility.set(e,n)}markHidden(e){const n=this.visibility.get(e)||{shown:!1,hidden:!1};n.hidden=!0,this.visibility.set(e,n)}isDisabled(e){const n=this.questionnaire.getField(e);if(!n.parentKey||!n.parentOptionKey)return!1;const a=this.questionnaire.getField(n.parentKey),o=this.values[a.key];return a.type==="radio"?o!==n.parentOptionKey:a.type==="check_box"?!o||!o.has(n.parentOptionKey):!1}isVisible(e){const n=this.visibility.get(e)||{shown:!1,hidden:!1},a=n.shown||!n.hidden,o=this.questionnaire.getField(e);return o.parentKey?a&&this.isVisible(o.parentKey):a}numberValue(e){const n=this.cleanValue(e);switch(this.questionnaire.getField(e).type){case"integer":case"float":return n;case"select":case"radio":case"scale":return n?this.questionnaire.getOptionNumberValue(e,n):null}return null}}function lh(r){return r===""||r==null||r instanceof Set&&r.size===0||r instanceof Map&&r.size===0?null:r}const uh=new Xd({key:"test",title:"test",language:"nl",panels:[],questions:{},visibilityRules:[],textvars:{},validations:[]}),Jv=new af(uh,{value:{},flags:{},textvars:new Map}),Qv={displayMode:"paged",darkMode:!1,newLayout:!0},Xv=(r,e)=>null,gd=Ee.createContext({questionnaire:uh,response:Jv,setQuestionRef:Xv,displayOptions:Qv});class of extends Error{}const ch=(r,e)=>{let n=r.value;return Da.isEmpty(n)&&!Da.isEmpty(e.defaultAnswerValue)&&(n=e.defaultAnswerValue),{flags:oh.parse(r.flags),textvars:sh.parse(r.textvars),value:qv(n,e)}},qv=(r,e)=>{const n=On.record(On.string(),On.any()).parse(r);return Object.values(e.questions).reduce((a,o)=>{const c=n[o.key];if(c==null)return a;switch(o.type){case"integer":case"float":a[o.key]=nh.parse(c);break;case"string":case"textarea":a[o.key]=rh.parse(c);break;case"select":case"scale":case"radio":a[o.key]=eb(c,o,e);break;case"check_box":a[o.key]=tb(c,o);break;case"date_parts":a[o.key]=ah.parse(c);break}return a},{})},eb=(r,e,n)=>{const a=On.string().parse(r);if(!n.getFlatOptions(e.key).some(c=>c.key===a))throw new of(`wrong option key ${a} present for ${e.key}`);return a},tb=(r,e)=>{const n=ih.parse(r);return n.forEach(a=>{if(!e.children.some(o=>o.key===a))throw new of(`wrong option key ${a} present for ${e.key}`)}),n},dh=/\{\{((?<type>[a-z_]+)\.(?<textvar>[a-z0-9]+)|(?<textvaronly>[a-z0-9_]+))\}\}/g;class fh{constructor(e,n){Tt(this,"response");Tt(this,"questionnaire");Tt(this,"stringToVariables");this.response=e,this.questionnaire=n,this.stringToVariables=new Map,this.interpolateCurlies=this.interpolateCurlies.bind(this)}interpolateCurlies(e){return this.stringToVariables.has(e)||this.stringToVariables.set(e,Array.from(e.matchAll(dh)).map(n=>n.groups.textvar)),this.stringToVariables.get(e).length==0?e:e.replace(dh,(...n)=>{var x;const{type:a,textvar:o,textvaronly:c}=n[n.length-1],v=a==="calculation"?(x=this.response.calculations.getResult(o))==null?void 0:x.toString():this.response.textvars.get(`${this.questionnaire.key}_${o||c}`);return Da.escape(v||"")})}}var sf={exports:{}},wc={};/**
|
|
40
40
|
* @license React
|
|
41
41
|
* react-jsx-runtime.production.min.js
|
|
42
42
|
*
|