@overmap-ai/forms 1.0.36-fields-renderer-size.0 → 1.0.36-fields-renderer-size.1

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/forms.js CHANGED
@@ -27015,7 +27015,7 @@ const o0 = H(
27015
27015
  onSubmit: I.handleSubmit,
27016
27016
  children: [
27017
27017
  F,
27018
- !t && (G || Q) ? /* @__PURE__ */ _(pe, { className: "flex items-center justify-end gap-2", size: "sm", children: [
27018
+ !t && (G || Q) ? /* @__PURE__ */ _(pe, { className: "flex items-center justify-end gap-2", size: m, children: [
27019
27019
  G ? /* @__PURE__ */ _(
27020
27020
  z,
27021
27021
  {
@@ -252,4 +252,4 @@
252
252
  `),e.append(`>>
253
253
  `),e.toString()},r.prototype.setMode=function(e){this.mode=e},r.prototype.setECLevel=function(e){this.ecLevel=e},r.prototype.setVersion=function(e){this.version=e},r.prototype.setMaskPattern=function(e){this.maskPattern=e},r.prototype.setMatrix=function(e){this.matrix=e},r.isValidMaskPattern=function(e){return e>=0&&e<r.NUM_MASK_PATTERNS},r.NUM_MASK_PATTERNS=8,r}(),hd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),le=function(r){hd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="WriterException",e}(ke),ro=function(){function r(){}return r.clearMatrix=function(e){e.clear(255)},r.buildMatrix=function(e,t,n,i,a){r.clearMatrix(a),r.embedBasicPatterns(n,a),r.embedTypeInfo(t,i,a),r.maybeEmbedVersionInfo(n,a),r.embedDataBits(e,i,a)},r.embedBasicPatterns=function(e,t){r.embedPositionDetectionPatternsAndSeparators(t),r.embedDarkDotAtLeftBottomCorner(t),r.maybeEmbedPositionAdjustmentPatterns(e,t),r.embedTimingPatterns(t)},r.embedTypeInfo=function(e,t,n){var i=new we;r.makeTypeInfoBits(e,t,i);for(var a=0,o=i.getSize();a<o;++a){var s=i.get(i.getSize()-1-a),l=r.TYPE_INFO_COORDINATES[a],u=l[0],c=l[1];if(n.setBoolean(u,c,s),a<8){var d=n.getWidth()-a-1,p=8;n.setBoolean(d,p,s)}else{var d=8,p=n.getHeight()-7+(a-8);n.setBoolean(d,p,s)}}},r.maybeEmbedVersionInfo=function(e,t){if(!(e.getVersionNumber()<7)){var n=new we;r.makeVersionInfoBits(e,n);for(var i=17,a=0;a<6;++a)for(var o=0;o<3;++o){var s=n.get(i);i--,t.setBoolean(a,t.getHeight()-11+o,s),t.setBoolean(t.getHeight()-11+o,a,s)}}},r.embedDataBits=function(e,t,n){for(var i=0,a=-1,o=n.getWidth()-1,s=n.getHeight()-1;o>0;){for(o===6&&(o-=1);s>=0&&s<n.getHeight();){for(var l=0;l<2;++l){var u=o-l;if(r.isEmpty(n.get(u,s))){var c=void 0;i<e.getSize()?(c=e.get(i),++i):c=!1,t!==255&&yr.getDataMaskBit(t,u,s)&&(c=!c),n.setBoolean(u,s,c)}}s+=a}a=-a,s+=a,o-=2}if(i!==e.getSize())throw new le("Not all bits consumed: "+i+"/"+e.getSize())},r.findMSBSet=function(e){return 32-X.numberOfLeadingZeros(e)},r.calculateBCHCode=function(e,t){if(t===0)throw new k("0 polynomial");var n=r.findMSBSet(t);for(e<<=n-1;r.findMSBSet(e)>=n;)e^=t<<r.findMSBSet(e)-n;return e},r.makeTypeInfoBits=function(e,t,n){if(!fi.isValidMaskPattern(t))throw new le("Invalid mask pattern");var i=e.getBits()<<3|t;n.appendBits(i,5);var a=r.calculateBCHCode(i,r.TYPE_INFO_POLY);n.appendBits(a,10);var o=new we;if(o.appendBits(r.TYPE_INFO_MASK_PATTERN,15),n.xor(o),n.getSize()!==15)throw new le("should not happen but we got: "+n.getSize())},r.makeVersionInfoBits=function(e,t){t.appendBits(e.getVersionNumber(),6);var n=r.calculateBCHCode(e.getVersionNumber(),r.VERSION_INFO_POLY);if(t.appendBits(n,12),t.getSize()!==18)throw new le("should not happen but we got: "+t.getSize())},r.isEmpty=function(e){return e===255},r.embedTimingPatterns=function(e){for(var t=8;t<e.getWidth()-8;++t){var n=(t+1)%2;r.isEmpty(e.get(t,6))&&e.setNumber(t,6,n),r.isEmpty(e.get(6,t))&&e.setNumber(6,t,n)}},r.embedDarkDotAtLeftBottomCorner=function(e){if(e.get(8,e.getHeight()-8)===0)throw new le;e.setNumber(8,e.getHeight()-8,1)},r.embedHorizontalSeparationPattern=function(e,t,n){for(var i=0;i<8;++i){if(!r.isEmpty(n.get(e+i,t)))throw new le;n.setNumber(e+i,t,0)}},r.embedVerticalSeparationPattern=function(e,t,n){for(var i=0;i<7;++i){if(!r.isEmpty(n.get(e,t+i)))throw new le;n.setNumber(e,t+i,0)}},r.embedPositionAdjustmentPattern=function(e,t,n){for(var i=0;i<5;++i)for(var a=r.POSITION_ADJUSTMENT_PATTERN[i],o=0;o<5;++o)n.setNumber(e+o,t+i,a[o])},r.embedPositionDetectionPattern=function(e,t,n){for(var i=0;i<7;++i)for(var a=r.POSITION_DETECTION_PATTERN[i],o=0;o<7;++o)n.setNumber(e+o,t+i,a[o])},r.embedPositionDetectionPatternsAndSeparators=function(e){var t=r.POSITION_DETECTION_PATTERN[0].length;r.embedPositionDetectionPattern(0,0,e),r.embedPositionDetectionPattern(e.getWidth()-t,0,e),r.embedPositionDetectionPattern(0,e.getWidth()-t,e);var n=8;r.embedHorizontalSeparationPattern(0,n-1,e),r.embedHorizontalSeparationPattern(e.getWidth()-n,n-1,e),r.embedHorizontalSeparationPattern(0,e.getWidth()-n,e);var i=7;r.embedVerticalSeparationPattern(i,0,e),r.embedVerticalSeparationPattern(e.getHeight()-i-1,0,e),r.embedVerticalSeparationPattern(i,e.getHeight()-i,e)},r.maybeEmbedPositionAdjustmentPatterns=function(e,t){if(!(e.getVersionNumber()<2))for(var n=e.getVersionNumber()-1,i=r.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[n],a=0,o=i.length;a!==o;a++){var s=i[a];if(s>=0)for(var l=0;l!==o;l++){var u=i[l];u>=0&&r.isEmpty(t.get(u,s))&&r.embedPositionAdjustmentPattern(u-2,s-2,t)}}},r.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),r.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),r.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),r.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),r.VERSION_INFO_POLY=7973,r.TYPE_INFO_POLY=1335,r.TYPE_INFO_MASK_PATTERN=21522,r}(),pd=function(){function r(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}return r.prototype.getDataBytes=function(){return this.dataBytes},r.prototype.getErrorCorrectionBytes=function(){return this.errorCorrectionBytes},r}(),no=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};(function(){function r(){}return r.calculateMaskPenalty=function(e){return yr.applyMaskPenaltyRule1(e)+yr.applyMaskPenaltyRule2(e)+yr.applyMaskPenaltyRule3(e)+yr.applyMaskPenaltyRule4(e)},r.encode=function(e,t,n){n===void 0&&(n=null);var i=r.DEFAULT_BYTE_MODE_ENCODING,a=n!==null&&n.get(tn.CHARACTER_SET)!==void 0;a&&(i=n.get(tn.CHARACTER_SET).toString());var o=this.chooseMode(e,i),s=new we;if(o===se.BYTE&&(a||r.DEFAULT_BYTE_MODE_ENCODING!==i)){var l=pe.getCharacterSetECIByName(i);l!==void 0&&this.appendECI(l,s)}this.appendModeInfo(o,s);var u=new we;this.appendBytes(e,o,u,i);var c;if(n!==null&&n.get(tn.QR_VERSION)!==void 0){var d=Number.parseInt(n.get(tn.QR_VERSION).toString(),10);c=Ct.getVersionForNumber(d);var p=this.calculateBitsNeeded(o,s,u,c);if(!this.willFit(p,c,t))throw new le("Data too big for requested version")}else c=this.recommendVersion(t,o,s,u);var h=new we;h.appendBitArray(s);var g=o===se.BYTE?u.getSizeInBytes():e.length;this.appendLengthInfo(g,c,o,h),h.appendBitArray(u);var x=c.getECBlocksForLevel(t),C=c.getTotalCodewords()-x.getTotalECCodewords();this.terminateBits(C,h);var _=this.interleaveWithECBytes(h,c.getTotalCodewords(),C,x.getNumBlocks()),w=new fi;w.setECLevel(t),w.setMode(o),w.setVersion(c);var A=c.getDimensionForVersion(),E=new fd(A,A),I=this.chooseMaskPattern(_,t,c,E);return w.setMaskPattern(I),ro.buildMatrix(_,t,c,I,E),w.setMatrix(E),w},r.recommendVersion=function(e,t,n,i){var a=this.calculateBitsNeeded(t,n,i,Ct.getVersionForNumber(1)),o=this.chooseVersion(a,e),s=this.calculateBitsNeeded(t,n,i,o);return this.chooseVersion(s,e)},r.calculateBitsNeeded=function(e,t,n,i){return t.getSize()+e.getCharacterCountBits(i)+n.getSize()},r.getAlphanumericCode=function(e){return e<r.ALPHANUMERIC_TABLE.length?r.ALPHANUMERIC_TABLE[e]:-1},r.chooseMode=function(e,t){if(t===void 0&&(t=null),pe.SJIS.getName()===t&&this.isOnlyDoubleByteKanji(e))return se.KANJI;for(var n=!1,i=!1,a=0,o=e.length;a<o;++a){var s=e.charAt(a);if(r.isDigit(s))n=!0;else if(this.getAlphanumericCode(s.charCodeAt(0))!==-1)i=!0;else return se.BYTE}return i?se.ALPHANUMERIC:n?se.NUMERIC:se.BYTE},r.isOnlyDoubleByteKanji=function(e){var t;try{t=Xe.encode(e,pe.SJIS)}catch{return!1}var n=t.length;if(n%2!==0)return!1;for(var i=0;i<n;i+=2){var a=t[i]&255;if((a<129||a>159)&&(a<224||a>235))return!1}return!0},r.chooseMaskPattern=function(e,t,n,i){for(var a=Number.MAX_SAFE_INTEGER,o=-1,s=0;s<fi.NUM_MASK_PATTERNS;s++){ro.buildMatrix(e,t,n,s,i);var l=this.calculateMaskPenalty(i);l<a&&(a=l,o=s)}return o},r.chooseVersion=function(e,t){for(var n=1;n<=40;n++){var i=Ct.getVersionForNumber(n);if(r.willFit(e,i,t))return i}throw new le("Data too big")},r.willFit=function(e,t,n){var i=t.getTotalCodewords(),a=t.getECBlocksForLevel(n),o=a.getTotalECCodewords(),s=i-o,l=(e+7)/8;return s>=l},r.terminateBits=function(e,t){var n=e*8;if(t.getSize()>n)throw new le("data bits cannot fit in the QR Code"+t.getSize()+" > "+n);for(var i=0;i<4&&t.getSize()<n;++i)t.appendBit(!1);var a=t.getSize()&7;if(a>0)for(var i=a;i<8;i++)t.appendBit(!1);for(var o=e-t.getSizeInBytes(),i=0;i<o;++i)t.appendBits((i&1)===0?236:17,8);if(t.getSize()!==n)throw new le("Bits size does not equal capacity")},r.getNumDataBytesAndNumECBytesForBlockID=function(e,t,n,i,a,o){if(i>=n)throw new le("Block ID too large");var s=e%n,l=n-s,u=Math.floor(e/n),c=u+1,d=Math.floor(t/n),p=d+1,h=u-d,g=c-p;if(h!==g)throw new le("EC bytes mismatch");if(n!==l+s)throw new le("RS blocks mismatch");if(e!==(d+h)*l+(p+g)*s)throw new le("Total bytes mismatch");i<l?(a[0]=d,o[0]=h):(a[0]=p,o[0]=g)},r.interleaveWithECBytes=function(e,t,n,i){var a,o,s,l;if(e.getSizeInBytes()!==n)throw new le("Number of bits and data bytes does not match");for(var u=0,c=0,d=0,p=new Array,h=0;h<i;++h){var g=new Int32Array(1),x=new Int32Array(1);r.getNumDataBytesAndNumECBytesForBlockID(t,n,i,h,g,x);var C=g[0],_=new Uint8Array(C);e.toBytes(8*u,_,0,C);var w=r.generateECBytes(_,x[0]);p.push(new pd(_,w)),c=Math.max(c,C),d=Math.max(d,w.length),u+=g[0]}if(n!==u)throw new le("Data bytes does not match offset");for(var A=new we,h=0;h<c;++h)try{for(var E=(a=void 0,no(p)),I=E.next();!I.done;I=E.next()){var N=I.value,_=N.getDataBytes();h<_.length&&A.appendBits(_[h],8)}}catch(V){a={error:V}}finally{try{I&&!I.done&&(o=E.return)&&o.call(E)}finally{if(a)throw a.error}}for(var h=0;h<d;++h)try{for(var D=(s=void 0,no(p)),M=D.next();!M.done;M=D.next()){var N=M.value,w=N.getErrorCorrectionBytes();h<w.length&&A.appendBits(w[h],8)}}catch(V){s={error:V}}finally{try{M&&!M.done&&(l=D.return)&&l.call(D)}finally{if(s)throw s.error}}if(t!==A.getSizeInBytes())throw new le("Interleaving error: "+t+" and "+A.getSizeInBytes()+" differ.");return A},r.generateECBytes=function(e,t){for(var n=e.length,i=new Int32Array(n+t),a=0;a<n;a++)i[a]=e[a]&255;new to(Re.QR_CODE_FIELD_256).encode(i,t);for(var o=new Uint8Array(t),a=0;a<t;a++)o[a]=i[n+a];return o},r.appendModeInfo=function(e,t){t.appendBits(e.getBits(),4)},r.appendLengthInfo=function(e,t,n,i){var a=n.getCharacterCountBits(t);if(e>=1<<a)throw new le(e+" is bigger than "+((1<<a)-1));i.appendBits(e,a)},r.appendBytes=function(e,t,n,i){switch(t){case se.NUMERIC:r.appendNumericBytes(e,n);break;case se.ALPHANUMERIC:r.appendAlphanumericBytes(e,n);break;case se.BYTE:r.append8BitBytes(e,n,i);break;case se.KANJI:r.appendKanjiBytes(e,n);break;default:throw new le("Invalid mode: "+t)}},r.getDigit=function(e){return e.charCodeAt(0)-48},r.isDigit=function(e){var t=r.getDigit(e);return t>=0&&t<=9},r.appendNumericBytes=function(e,t){for(var n=e.length,i=0;i<n;){var a=r.getDigit(e.charAt(i));if(i+2<n){var o=r.getDigit(e.charAt(i+1)),s=r.getDigit(e.charAt(i+2));t.appendBits(a*100+o*10+s,10),i+=3}else if(i+1<n){var o=r.getDigit(e.charAt(i+1));t.appendBits(a*10+o,7),i+=2}else t.appendBits(a,4),i++}},r.appendAlphanumericBytes=function(e,t){for(var n=e.length,i=0;i<n;){var a=r.getAlphanumericCode(e.charCodeAt(i));if(a===-1)throw new le;if(i+1<n){var o=r.getAlphanumericCode(e.charCodeAt(i+1));if(o===-1)throw new le;t.appendBits(a*45+o,11),i+=2}else t.appendBits(a,6),i++}},r.append8BitBytes=function(e,t,n){var i;try{i=Xe.encode(e,n)}catch(l){throw new le(l)}for(var a=0,o=i.length;a!==o;a++){var s=i[a];t.appendBits(s,8)}},r.appendKanjiBytes=function(e,t){var n;try{n=Xe.encode(e,pe.SJIS)}catch(d){throw new le(d)}for(var i=n.length,a=0;a<i;a+=2){var o=n[a]&255,s=n[a+1]&255,l=o<<8&4294967295|s,u=-1;if(l>=33088&&l<=40956?u=l-33088:l>=57408&&l<=60351&&(u=l-49472),u===-1)throw new le("Invalid byte sequence");var c=(u>>8)*192+(u&255);t.appendBits(c,13)}},r.appendECI=function(e,t){t.appendBits(se.ECI.getBits(),4),t.appendBits(e.getValue(),8)},r.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),r.DEFAULT_BYTE_MODE_ENCODING=pe.UTF8.getName(),r})();var vd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}();(function(r){vd(e,r);function e(t,n,i,a,o,s,l,u){var c=r.call(this,s,l)||this;if(c.yuvData=t,c.dataWidth=n,c.dataHeight=i,c.left=a,c.top=o,a+s>n||o+l>i)throw new k("Crop rectangle does not fit within image data.");return u&&c.reverseHorizontal(s,l),c}return e.prototype.getRow=function(t,n){if(t<0||t>=this.getHeight())throw new k("Requested row is outside the image: "+t);var i=this.getWidth();(n==null||n.length<i)&&(n=new Uint8ClampedArray(i));var a=(t+this.top)*this.dataWidth+this.left;return oe.arraycopy(this.yuvData,a,n,0,i),n},e.prototype.getMatrix=function(){var t=this.getWidth(),n=this.getHeight();if(t===this.dataWidth&&n===this.dataHeight)return this.yuvData;var i=t*n,a=new Uint8ClampedArray(i),o=this.top*this.dataWidth+this.left;if(t===this.dataWidth)return oe.arraycopy(this.yuvData,o,a,0,i),a;for(var s=0;s<n;s++){var l=s*t;oe.arraycopy(this.yuvData,o,a,l,t),o+=this.dataWidth}return a},e.prototype.isCropSupported=function(){return!0},e.prototype.crop=function(t,n,i,a){return new e(this.yuvData,this.dataWidth,this.dataHeight,this.left+t,this.top+n,i,a,!1)},e.prototype.renderThumbnail=function(){for(var t=this.getWidth()/e.THUMBNAIL_SCALE_FACTOR,n=this.getHeight()/e.THUMBNAIL_SCALE_FACTOR,i=new Int32Array(t*n),a=this.yuvData,o=this.top*this.dataWidth+this.left,s=0;s<n;s++){for(var l=s*t,u=0;u<t;u++){var c=a[o+u*e.THUMBNAIL_SCALE_FACTOR]&255;i[l+u]=4278190080|c*65793}o+=this.dataWidth*e.THUMBNAIL_SCALE_FACTOR}return i},e.prototype.getThumbnailWidth=function(){return this.getWidth()/e.THUMBNAIL_SCALE_FACTOR},e.prototype.getThumbnailHeight=function(){return this.getHeight()/e.THUMBNAIL_SCALE_FACTOR},e.prototype.reverseHorizontal=function(t,n){for(var i=this.yuvData,a=0,o=this.top*this.dataWidth+this.left;a<n;a++,o+=this.dataWidth)for(var s=o+t/2,l=o,u=o+t-1;l<s;l++,u--){var c=i[l];i[l]=i[u],i[u]=c}},e.prototype.invert=function(){return new Xn(this)},e.THUMBNAIL_SCALE_FACTOR=2,e})($r);var gd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}();(function(r){gd(e,r);function e(t,n,i,a,o,s,l){var u=r.call(this,n,i)||this;if(u.dataWidth=a,u.dataHeight=o,u.left=s,u.top=l,t.BYTES_PER_ELEMENT===4){for(var c=n*i,d=new Uint8ClampedArray(c),p=0;p<c;p++){var h=t[p],g=h>>16&255,x=h>>7&510,C=h&255;d[p]=(g+x+C)/4&255}u.luminances=d}else u.luminances=t;if(a===void 0&&(u.dataWidth=n),o===void 0&&(u.dataHeight=i),s===void 0&&(u.left=0),l===void 0&&(u.top=0),u.left+n>u.dataWidth||u.top+i>u.dataHeight)throw new k("Crop rectangle does not fit within image data.");return u}return e.prototype.getRow=function(t,n){if(t<0||t>=this.getHeight())throw new k("Requested row is outside the image: "+t);var i=this.getWidth();(n==null||n.length<i)&&(n=new Uint8ClampedArray(i));var a=(t+this.top)*this.dataWidth+this.left;return oe.arraycopy(this.luminances,a,n,0,i),n},e.prototype.getMatrix=function(){var t=this.getWidth(),n=this.getHeight();if(t===this.dataWidth&&n===this.dataHeight)return this.luminances;var i=t*n,a=new Uint8ClampedArray(i),o=this.top*this.dataWidth+this.left;if(t===this.dataWidth)return oe.arraycopy(this.luminances,o,a,0,i),a;for(var s=0;s<n;s++){var l=s*t;oe.arraycopy(this.luminances,o,a,l,t),o+=this.dataWidth}return a},e.prototype.isCropSupported=function(){return!0},e.prototype.crop=function(t,n,i,a){return new e(this.luminances,i,a,this.dataWidth,this.dataHeight,this.left+t,this.top+n)},e.prototype.invert=function(){return new Xn(this)},e})($r);var xd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),yd=function(r){xd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.forName=function(t){return this.getCharacterSetECIByName(t)},e}(pe),Cd=function(){function r(){}return r.ISO_8859_1=pe.ISO8859_1,r}(),hi,wd=301,md=function(r,e){for(var t=1,n=0;n<255;n++)e[n]=t,r[t]=n,t*=2,t>=256&&(t^=wd);return{LOG:r,ALOG:e}};hi=md([],[]),hi.LOG,hi.ALOG;var io;(function(r){r[r.FORCE_NONE=0]="FORCE_NONE",r[r.FORCE_SQUARE=1]="FORCE_SQUARE",r[r.FORCE_RECTANGLE=2]="FORCE_RECTANGLE"})(io||(io={}));var ao=129,oo=230,_d=231,Ad=235,Ed=236,Sd=237,Id=238,Od=239,bd=240,pi=254,Nd=254,so="[)>05",lo="[)>06",uo="",ne=0,Se=1,Le=2,ye=3,_e=4,De=5,Td=function(){function r(){}return r.prototype.getEncodingMode=function(){return ne},r.prototype.encode=function(e){var t=Qe.determineConsecutiveDigitCount(e.getMessage(),e.pos);if(t>=2)e.writeCodeword(this.encodeASCIIDigits(e.getMessage().charCodeAt(e.pos),e.getMessage().charCodeAt(e.pos+1))),e.pos+=2;else{var n=e.getCurrentChar(),i=Qe.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(i!==this.getEncodingMode())switch(i){case De:e.writeCodeword(_d),e.signalEncoderChange(De);return;case Se:e.writeCodeword(oo),e.signalEncoderChange(Se);return;case ye:e.writeCodeword(Id),e.signalEncoderChange(ye);break;case Le:e.writeCodeword(Od),e.signalEncoderChange(Le);break;case _e:e.writeCodeword(bd),e.signalEncoderChange(_e);break;default:throw new Error("Illegal mode: "+i)}else Qe.isExtendedASCII(n)?(e.writeCodeword(Ad),e.writeCodeword(n-128+1),e.pos++):(e.writeCodeword(n+1),e.pos++)}},r.prototype.encodeASCIIDigits=function(e,t){if(Qe.isDigit(e)&&Qe.isDigit(t)){var n=(e-48)*10+(t-48);return n+130}throw new Error("not digits: "+e+t)},r}(),Dd=function(){function r(){}return r.prototype.getEncodingMode=function(){return De},r.prototype.encode=function(e){var t=new q;for(t.append(0);e.hasMoreCharacters();){var n=e.getCurrentChar();t.append(n),e.pos++;var i=Qe.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(i!==this.getEncodingMode()){e.signalEncoderChange(ne);break}}var a=t.length()-1,o=1,s=e.getCodewordCount()+a+o;e.updateSymbolInfo(s);var l=e.getSymbolInfo().getDataCapacity()-s>0;if(e.hasMoreCharacters()||l)if(a<=249)t.setCharAt(0,W.getCharAt(a));else if(a<=1555)t.setCharAt(0,W.getCharAt(Math.floor(a/250)+249)),t.insert(1,W.getCharAt(a%250));else throw new Error("Message length not in valid ranges: "+a);for(var u=0,n=t.length();u<n;u++)e.writeCodeword(this.randomize255State(t.charAt(u).charCodeAt(0),e.getCodewordCount()+1))},r.prototype.randomize255State=function(e,t){var n=149*t%255+1,i=e+n;return i<=255?i:i-256},r}(),vi=function(){function r(){}return r.prototype.getEncodingMode=function(){return Se},r.prototype.encodeMaximal=function(e){for(var t=new q,n=0,i=e.pos,a=0;e.hasMoreCharacters();){var o=e.getCurrentChar();e.pos++,n=this.encodeChar(o,t),t.length()%3===0&&(i=e.pos,a=t.length())}if(a!==t.length()){var s=Math.floor(t.length()/3*2),l=Math.floor(e.getCodewordCount()+s+1);e.updateSymbolInfo(l);var u=e.getSymbolInfo().getDataCapacity()-l,c=Math.floor(t.length()%3);(c===2&&u!==2||c===1&&(n>3||u!==1))&&(e.pos=i)}t.length()>0&&e.writeCodeword(oo),this.handleEOD(e,t)},r.prototype.encode=function(e){for(var t=new q;e.hasMoreCharacters();){var n=e.getCurrentChar();e.pos++;var i=this.encodeChar(n,t),a=Math.floor(t.length()/3)*2,o=e.getCodewordCount()+a;e.updateSymbolInfo(o);var s=e.getSymbolInfo().getDataCapacity()-o;if(!e.hasMoreCharacters()){var l=new q;for(t.length()%3===2&&s!==2&&(i=this.backtrackOneCharacter(e,t,l,i));t.length()%3===1&&(i>3||s!==1);)i=this.backtrackOneCharacter(e,t,l,i);break}var u=t.length();if(u%3===0){var c=Qe.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(c!==this.getEncodingMode()){e.signalEncoderChange(ne);break}}}this.handleEOD(e,t)},r.prototype.backtrackOneCharacter=function(e,t,n,i){var a=t.length(),o=t.toString().substring(0,a-i);t.setLengthToZero(),t.append(o),e.pos--;var s=e.getCurrentChar();return i=this.encodeChar(s,n),e.resetSymbolInfo(),i},r.prototype.writeNextTriplet=function(e,t){e.writeCodewords(this.encodeToCodewords(t.toString()));var n=t.toString().substring(3);t.setLengthToZero(),t.append(n)},r.prototype.handleEOD=function(e,t){var n=Math.floor(t.length()/3*2),i=t.length()%3,a=e.getCodewordCount()+n;e.updateSymbolInfo(a);var o=e.getSymbolInfo().getDataCapacity()-a;if(i===2){for(t.append("\0");t.length()>=3;)this.writeNextTriplet(e,t);e.hasMoreCharacters()&&e.writeCodeword(pi)}else if(o===1&&i===1){for(;t.length()>=3;)this.writeNextTriplet(e,t);e.hasMoreCharacters()&&e.writeCodeword(pi),e.pos--}else if(i===0){for(;t.length()>=3;)this.writeNextTriplet(e,t);(o>0||e.hasMoreCharacters())&&e.writeCodeword(pi)}else throw new Error("Unexpected case. Please report!");e.signalEncoderChange(ne)},r.prototype.encodeChar=function(e,t){if(e===32)return t.append(3),1;if(e>=48&&e<=57)return t.append(e-48+4),1;if(e>=65&&e<=90)return t.append(e-65+14),1;if(e<32)return t.append(0),t.append(e),2;if(e<=47)return t.append(1),t.append(e-33),2;if(e<=64)return t.append(1),t.append(e-58+15),2;if(e<=95)return t.append(1),t.append(e-91+22),2;if(e<=127)return t.append(2),t.append(e-96),2;t.append("1");var n=2;return n+=this.encodeChar(e-128,t),n},r.prototype.encodeToCodewords=function(e){var t=1600*e.charCodeAt(0)+40*e.charCodeAt(1)+e.charCodeAt(2)+1,n=t/256,i=t%256,a=new q;return a.append(n),a.append(i),a.toString()},r}(),Md=function(){function r(){}return r.prototype.getEncodingMode=function(){return _e},r.prototype.encode=function(e){for(var t=new q;e.hasMoreCharacters();){var n=e.getCurrentChar();this.encodeChar(n,t),e.pos++;var i=t.length();if(i>=4){e.writeCodewords(this.encodeToCodewords(t.toString()));var a=t.toString().substring(4);t.setLengthToZero(),t.append(a);var o=Qe.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(o!==this.getEncodingMode()){e.signalEncoderChange(ne);break}}}t.append(W.getCharAt(31)),this.handleEOD(e,t)},r.prototype.handleEOD=function(e,t){try{var n=t.length();if(n===0)return;if(n===1){e.updateSymbolInfo();var i=e.getSymbolInfo().getDataCapacity()-e.getCodewordCount(),a=e.getRemainingCharacters();if(a>i&&(e.updateSymbolInfo(e.getCodewordCount()+1),i=e.getSymbolInfo().getDataCapacity()-e.getCodewordCount()),a<=i&&i<=2)return}if(n>4)throw new Error("Count must not exceed 4");var o=n-1,s=this.encodeToCodewords(t.toString()),l=!e.hasMoreCharacters(),u=l&&o<=2;if(o<=2){e.updateSymbolInfo(e.getCodewordCount()+o);var i=e.getSymbolInfo().getDataCapacity()-e.getCodewordCount();i>=3&&(u=!1,e.updateSymbolInfo(e.getCodewordCount()+s.length))}u?(e.resetSymbolInfo(),e.pos-=o):e.writeCodewords(s)}finally{e.signalEncoderChange(ne)}},r.prototype.encodeChar=function(e,t){e>=32&&e<=63?t.append(e):e>=64&&e<=94?t.append(W.getCharAt(e-64)):Qe.illegalCharacter(W.getCharAt(e))},r.prototype.encodeToCodewords=function(e){var t=e.length;if(t===0)throw new Error("StringBuilder must not be empty");var n=e.charAt(0).charCodeAt(0),i=t>=2?e.charAt(1).charCodeAt(0):0,a=t>=3?e.charAt(2).charCodeAt(0):0,o=t>=4?e.charAt(3).charCodeAt(0):0,s=(n<<18)+(i<<12)+(a<<6)+o,l=s>>16&255,u=s>>8&255,c=s&255,d=new q;return d.append(l),t>=2&&d.append(u),t>=3&&d.append(c),d.toString()},r}(),Fd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Pd=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ee=function(){function r(e,t,n,i,a,o,s,l){s===void 0&&(s=0),l===void 0&&(l=0),this.rectangular=e,this.dataCapacity=t,this.errorCodewords=n,this.matrixWidth=i,this.matrixHeight=a,this.dataRegions=o,this.rsBlockData=s,this.rsBlockError=l}return r.lookup=function(e,t,n,i,a){var o,s;t===void 0&&(t=0),n===void 0&&(n=null),i===void 0&&(i=null),a===void 0&&(a=!0);try{for(var l=Pd(Bd),u=l.next();!u.done;u=l.next()){var c=u.value;if(!(t===1&&c.rectangular)&&!(t===2&&!c.rectangular)&&!(n!=null&&(c.getSymbolWidth()<n.getWidth()||c.getSymbolHeight()<n.getHeight()))&&!(i!=null&&(c.getSymbolWidth()>i.getWidth()||c.getSymbolHeight()>i.getHeight()))&&e<=c.dataCapacity)return c}}catch(d){o={error:d}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(o)throw o.error}}if(a)throw new Error("Can't find a symbol arrangement that matches the message. Data codewords: "+e);return null},r.prototype.getHorizontalDataRegions=function(){switch(this.dataRegions){case 1:return 1;case 2:case 4:return 2;case 16:return 4;case 36:return 6;default:throw new Error("Cannot handle this number of data regions")}},r.prototype.getVerticalDataRegions=function(){switch(this.dataRegions){case 1:case 2:return 1;case 4:return 2;case 16:return 4;case 36:return 6;default:throw new Error("Cannot handle this number of data regions")}},r.prototype.getSymbolDataWidth=function(){return this.getHorizontalDataRegions()*this.matrixWidth},r.prototype.getSymbolDataHeight=function(){return this.getVerticalDataRegions()*this.matrixHeight},r.prototype.getSymbolWidth=function(){return this.getSymbolDataWidth()+this.getHorizontalDataRegions()*2},r.prototype.getSymbolHeight=function(){return this.getSymbolDataHeight()+this.getVerticalDataRegions()*2},r.prototype.getCodewordCount=function(){return this.dataCapacity+this.errorCodewords},r.prototype.getInterleavedBlockCount=function(){return this.rsBlockData?this.dataCapacity/this.rsBlockData:1},r.prototype.getDataCapacity=function(){return this.dataCapacity},r.prototype.getErrorCodewords=function(){return this.errorCodewords},r.prototype.getDataLengthForInterleavedBlock=function(e){return this.rsBlockData},r.prototype.getErrorLengthForInterleavedBlock=function(e){return this.rsBlockError},r}(),Vd=function(r){Fd(e,r);function e(){return r.call(this,!1,1558,620,22,22,36,-1,62)||this}return e.prototype.getInterleavedBlockCount=function(){return 10},e.prototype.getDataLengthForInterleavedBlock=function(t){return t<=8?156:155},e}(ee),Bd=[new ee(!1,3,5,8,8,1),new ee(!1,5,7,10,10,1),new ee(!0,5,7,16,6,1),new ee(!1,8,10,12,12,1),new ee(!0,10,11,14,6,2),new ee(!1,12,12,14,14,1),new ee(!0,16,14,24,10,1),new ee(!1,18,14,16,16,1),new ee(!1,22,18,18,18,1),new ee(!0,22,18,16,10,2),new ee(!1,30,20,20,20,1),new ee(!0,32,24,16,14,2),new ee(!1,36,24,22,22,1),new ee(!1,44,28,24,24,1),new ee(!0,49,28,22,14,2),new ee(!1,62,36,14,14,4),new ee(!1,86,42,16,16,4),new ee(!1,114,48,18,18,4),new ee(!1,144,56,20,20,4),new ee(!1,174,68,22,22,4),new ee(!1,204,84,24,24,4,102,42),new ee(!1,280,112,14,14,16,140,56),new ee(!1,368,144,16,16,16,92,36),new ee(!1,456,192,18,18,16,114,48),new ee(!1,576,224,20,20,16,144,56),new ee(!1,696,272,22,22,16,174,68),new ee(!1,816,336,24,24,16,136,56),new ee(!1,1050,408,18,18,36,175,68),new ee(!1,1304,496,20,20,36,163,62),new Vd],Ld=function(){function r(e){this.msg=e,this.pos=0,this.skipAtEnd=0;for(var t=e.split("").map(function(s){return s.charCodeAt(0)}),n=new q,i=0,a=t.length;i<a;i++){var o=String.fromCharCode(t[i]&255);if(o==="?"&&e.charAt(i)!=="?")throw new Error("Message contains characters outside ISO-8859-1 encoding.");n.append(o)}this.msg=n.toString(),this.shape=0,this.codewords=new q,this.newEncoding=-1}return r.prototype.setSymbolShape=function(e){this.shape=e},r.prototype.setSizeConstraints=function(e,t){this.minSize=e,this.maxSize=t},r.prototype.getMessage=function(){return this.msg},r.prototype.setSkipAtEnd=function(e){this.skipAtEnd=e},r.prototype.getCurrentChar=function(){return this.msg.charCodeAt(this.pos)},r.prototype.getCurrent=function(){return this.msg.charCodeAt(this.pos)},r.prototype.getCodewords=function(){return this.codewords},r.prototype.writeCodewords=function(e){this.codewords.append(e)},r.prototype.writeCodeword=function(e){this.codewords.append(e)},r.prototype.getCodewordCount=function(){return this.codewords.length()},r.prototype.getNewEncoding=function(){return this.newEncoding},r.prototype.signalEncoderChange=function(e){this.newEncoding=e},r.prototype.resetEncoderSignal=function(){this.newEncoding=-1},r.prototype.hasMoreCharacters=function(){return this.pos<this.getTotalMessageCharCount()},r.prototype.getTotalMessageCharCount=function(){return this.msg.length-this.skipAtEnd},r.prototype.getRemainingCharacters=function(){return this.getTotalMessageCharCount()-this.pos},r.prototype.getSymbolInfo=function(){return this.symbolInfo},r.prototype.updateSymbolInfo=function(e){e===void 0&&(e=this.getCodewordCount()),(this.symbolInfo==null||e>this.symbolInfo.getDataCapacity())&&(this.symbolInfo=ee.lookup(e,this.shape,this.minSize,this.maxSize,!0))},r.prototype.resetSymbolInfo=function(){this.symbolInfo=null},r}(),zd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),kd=function(r){zd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.getEncodingMode=function(){return ye},e.prototype.encode=function(t){for(var n=new q;t.hasMoreCharacters();){var i=t.getCurrentChar();t.pos++,this.encodeChar(i,n);var a=n.length();if(a%3===0){this.writeNextTriplet(t,n);var o=Qe.lookAheadTest(t.getMessage(),t.pos,this.getEncodingMode());if(o!==this.getEncodingMode()){t.signalEncoderChange(ne);break}}}this.handleEOD(t,n)},e.prototype.encodeChar=function(t,n){switch(t){case 13:n.append(0);break;case 42:n.append(1);break;case 62:n.append(2);break;case 32:n.append(3);break;default:t>=48&&t<=57?n.append(t-48+4):t>=65&&t<=90?n.append(t-65+14):Qe.illegalCharacter(W.getCharAt(t));break}return 1},e.prototype.handleEOD=function(t,n){t.updateSymbolInfo();var i=t.getSymbolInfo().getDataCapacity()-t.getCodewordCount(),a=n.length();t.pos-=a,(t.getRemainingCharacters()>1||i>1||t.getRemainingCharacters()!==i)&&t.writeCodeword(Nd),t.getNewEncoding()<0&&t.signalEncoderChange(ne)},e}(vi),Rd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ud=function(r){Rd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.getEncodingMode=function(){return Le},e.prototype.encodeChar=function(t,n){if(t===32)return n.append(3),1;if(t>=48&&t<=57)return n.append(t-48+4),1;if(t>=97&&t<=122)return n.append(t-97+14),1;if(t<32)return n.append(0),n.append(t),2;if(t<=47)return n.append(1),n.append(t-33),2;if(t<=64)return n.append(1),n.append(t-58+15),2;if(t>=91&&t<=95)return n.append(1),n.append(t-91+22),2;if(t===96)return n.append(2),n.append(0),2;if(t<=90)return n.append(2),n.append(t-65+1),2;if(t<=127)return n.append(2),n.append(t-123+27),2;n.append("1");var i=2;return i+=this.encodeChar(t-128,n),i},e}(vi),Qe=function(){function r(){}return r.randomize253State=function(e){var t=149*e%253+1,n=ao+t;return n<=254?n:n-254},r.encodeHighLevel=function(e,t,n,i,a){t===void 0&&(t=0),n===void 0&&(n=null),i===void 0&&(i=null),a===void 0&&(a=!1);var o=new vi,s=[new Td,o,new Ud,new kd,new Md,new Dd],l=new Ld(e);l.setSymbolShape(t),l.setSizeConstraints(n,i),e.startsWith(so)&&e.endsWith(uo)?(l.writeCodeword(Ed),l.setSkipAtEnd(2),l.pos+=so.length):e.startsWith(lo)&&e.endsWith(uo)&&(l.writeCodeword(Sd),l.setSkipAtEnd(2),l.pos+=lo.length);var u=ne;for(a&&(o.encodeMaximal(l),u=l.getNewEncoding(),l.resetEncoderSignal());l.hasMoreCharacters();)s[u].encode(l),l.getNewEncoding()>=0&&(u=l.getNewEncoding(),l.resetEncoderSignal());var c=l.getCodewordCount();l.updateSymbolInfo();var d=l.getSymbolInfo().getDataCapacity();c<d&&u!==ne&&u!==De&&u!==_e&&l.writeCodeword("þ");var p=l.getCodewords();for(p.length()<d&&p.append(ao);p.length()<d;)p.append(this.randomize253State(p.length()+1));return l.getCodewords().toString()},r.lookAheadTest=function(e,t,n){var i=this.lookAheadTestIntern(e,t,n);if(n===ye&&i===ye){for(var a=Math.min(t+3,e.length),o=t;o<a;o++)if(!this.isNativeX12(e.charCodeAt(o)))return ne}else if(n===_e&&i===_e){for(var a=Math.min(t+4,e.length),o=t;o<a;o++)if(!this.isNativeEDIFACT(e.charCodeAt(o)))return ne}return i},r.lookAheadTestIntern=function(e,t,n){if(t>=e.length)return n;var i;n===ne?i=[0,1,1,1,1,1.25]:(i=[1,2,2,2,2,2.25],i[n]=0);for(var a=0,o=new Uint8Array(6),s=[];;){if(t+a===e.length){he.fill(o,0),he.fill(s,0);var l=this.findMinimums(i,s,X.MAX_VALUE,o),u=this.getMinimumCount(o);if(s[ne]===l)return ne;if(u===1){if(o[De]>0)return De;if(o[_e]>0)return _e;if(o[Le]>0)return Le;if(o[ye]>0)return ye}return Se}var c=e.charCodeAt(t+a);if(a++,this.isDigit(c)?i[ne]+=.5:this.isExtendedASCII(c)?(i[ne]=Math.ceil(i[ne]),i[ne]+=2):(i[ne]=Math.ceil(i[ne]),i[ne]++),this.isNativeC40(c)?i[Se]+=2/3:this.isExtendedASCII(c)?i[Se]+=8/3:i[Se]+=4/3,this.isNativeText(c)?i[Le]+=2/3:this.isExtendedASCII(c)?i[Le]+=8/3:i[Le]+=4/3,this.isNativeX12(c)?i[ye]+=2/3:this.isExtendedASCII(c)?i[ye]+=13/3:i[ye]+=10/3,this.isNativeEDIFACT(c)?i[_e]+=3/4:this.isExtendedASCII(c)?i[_e]+=17/4:i[_e]+=13/4,this.isSpecialB256(c)?i[De]+=4:i[De]++,a>=4){if(he.fill(o,0),he.fill(s,0),this.findMinimums(i,s,X.MAX_VALUE,o),s[ne]<this.min(s[De],s[Se],s[Le],s[ye],s[_e]))return ne;if(s[De]<s[ne]||s[De]+1<this.min(s[Se],s[Le],s[ye],s[_e]))return De;if(s[_e]+1<this.min(s[De],s[Se],s[Le],s[ye],s[ne]))return _e;if(s[Le]+1<this.min(s[De],s[Se],s[_e],s[ye],s[ne]))return Le;if(s[ye]+1<this.min(s[De],s[Se],s[_e],s[Le],s[ne]))return ye;if(s[Se]+1<this.min(s[ne],s[De],s[_e],s[Le])){if(s[Se]<s[ye])return Se;if(s[Se]===s[ye]){for(var d=t+a+1;d<e.length;){var p=e.charCodeAt(d);if(this.isX12TermSep(p))return ye;if(!this.isNativeX12(p))break;d++}return Se}}}}},r.min=function(e,t,n,i,a){var o=Math.min(e,Math.min(t,Math.min(n,i)));return a===void 0?o:Math.min(o,a)},r.findMinimums=function(e,t,n,i){for(var a=0;a<6;a++){var o=t[a]=Math.ceil(e[a]);n>o&&(n=o,he.fill(i,0)),n===o&&(i[a]=i[a]+1)}return n},r.getMinimumCount=function(e){for(var t=0,n=0;n<6;n++)t+=e[n];return t||0},r.isDigit=function(e){return e>=48&&e<=57},r.isExtendedASCII=function(e){return e>=128&&e<=255},r.isNativeC40=function(e){return e===32||e>=48&&e<=57||e>=65&&e<=90},r.isNativeText=function(e){return e===32||e>=48&&e<=57||e>=97&&e<=122},r.isNativeX12=function(e){return this.isX12TermSep(e)||e===32||e>=48&&e<=57||e>=65&&e<=90},r.isX12TermSep=function(e){return e===13||e===42||e===62},r.isNativeEDIFACT=function(e){return e>=32&&e<=94},r.isSpecialB256=function(e){return!1},r.determineConsecutiveDigitCount=function(e,t){t===void 0&&(t=0);for(var n=e.length,i=t;i<n&&this.isDigit(e.charCodeAt(i));)i++;return i-t},r.illegalCharacter=function(e){var t=X.toHexString(e.charCodeAt(0));throw t="0000".substring(0,4-t.length)+t,new Error("Illegal character: "+e+" (0x"+t+")")},r}(),gi=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},co=function(){function r(e){this.charset=e,this.name=e.name}return r.prototype.canEncode=function(e){try{return Xe.encode(e,this.charset)!=null}catch{return!1}},r}(),Gd=function(){function r(e,t,n){var i,a,o,s,l,u;this.ENCODERS=["IBM437","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-11","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","windows-1250","windows-1251","windows-1252","windows-1256","Shift_JIS"].map(function(F){return new co(yd.forName(F))}),this.encoders=[];var c=[];c.push(new co(Cd.ISO_8859_1));for(var d=t!=null&&t.name.startsWith("UTF"),p=0;p<e.length;p++){var h=!1;try{for(var g=(i=void 0,gi(c)),x=g.next();!x.done;x=g.next()){var C=x.value,_=e.charAt(p),w=_.charCodeAt(0);if(w===n||C.canEncode(_)){h=!0;break}}}catch(F){i={error:F}}finally{try{x&&!x.done&&(a=g.return)&&a.call(g)}finally{if(i)throw i.error}}if(!h)try{for(var A=(o=void 0,gi(this.ENCODERS)),E=A.next();!E.done;E=A.next()){var C=E.value;if(C.canEncode(e.charAt(p))){c.push(C),h=!0;break}}}catch(F){o={error:F}}finally{try{E&&!E.done&&(s=A.return)&&s.call(A)}finally{if(o)throw o.error}}h||(d=!0)}if(c.length===1&&!d)this.encoders=[c[0]];else{this.encoders=[];var I=0;try{for(var N=gi(c),D=N.next();!D.done;D=N.next()){var C=D.value;this.encoders[I++]=C}}catch(F){l={error:F}}finally{try{D&&!D.done&&(u=N.return)&&u.call(N)}finally{if(l)throw l.error}}}var M=-1;if(t!=null){for(var p=0;p<this.encoders.length;p++)if(this.encoders[p]!=null&&t.name===this.encoders[p].name){M=p;break}}this.priorityEncoderIndex=M}return r.prototype.length=function(){return this.encoders.length},r.prototype.getCharsetName=function(e){if(!(e<this.length()))throw new Error("index must be less than length");return this.encoders[e].name},r.prototype.getCharset=function(e){if(!(e<this.length()))throw new Error("index must be less than length");return this.encoders[e].charset},r.prototype.getECIValue=function(e){return this.encoders[e].charset.getValueIdentifier()},r.prototype.getPriorityEncoderIndex=function(){return this.priorityEncoderIndex},r.prototype.canEncode=function(e,t){if(!(t<this.length()))throw new Error("index must be less than length");return!0},r.prototype.encode=function(e,t){if(!(t<this.length()))throw new Error("index must be less than length");return Xe.encode(W.getCharAt(e),this.encoders[t].name)},r}(),Hd=3,qd=function(){function r(e,t,n){this.fnc1=n;var i=new Gd(e,t,n);if(i.length()===1)for(var a=0;a<this.bytes.length;a++){var o=e.charAt(a).charCodeAt(0);this.bytes[a]=o===n?1e3:o}else this.bytes=this.encodeMinimally(e,i,n)}return r.prototype.getFNC1Character=function(){return this.fnc1},r.prototype.length=function(){return this.bytes.length},r.prototype.haveNCharacters=function(e,t){if(e+t-1>=this.bytes.length)return!1;for(var n=0;n<t;n++)if(this.isECI(e+n))return!1;return!0},r.prototype.charAt=function(e){if(e<0||e>=this.length())throw new Error(""+e);if(this.isECI(e))throw new Error("value at "+e+" is not a character but an ECI");return this.isFNC1(e)?this.fnc1:this.bytes[e]},r.prototype.subSequence=function(e,t){if(e<0||e>t||t>this.length())throw new Error(""+e);for(var n=new q,i=e;i<t;i++){if(this.isECI(i))throw new Error("value at "+i+" is not a character but an ECI");n.append(this.charAt(i))}return n.toString()},r.prototype.isECI=function(e){if(e<0||e>=this.length())throw new Error(""+e);return this.bytes[e]>255&&this.bytes[e]<=999},r.prototype.isFNC1=function(e){if(e<0||e>=this.length())throw new Error(""+e);return this.bytes[e]===1e3},r.prototype.getECIValue=function(e){if(e<0||e>=this.length())throw new Error(""+e);if(!this.isECI(e))throw new Error("value at "+e+" is not an ECI but a character");return this.bytes[e]-256},r.prototype.addEdge=function(e,t,n){(e[t][n.encoderIndex]==null||e[t][n.encoderIndex].cachedTotalSize>n.cachedTotalSize)&&(e[t][n.encoderIndex]=n)},r.prototype.addEdges=function(e,t,n,i,a,o){var s=e.charAt(i).charCodeAt(0),l=0,u=t.length();t.getPriorityEncoderIndex()>=0&&(s===o||t.canEncode(s,t.getPriorityEncoderIndex()))&&(l=t.getPriorityEncoderIndex(),u=l+1);for(var c=l;c<u;c++)(s===o||t.canEncode(s,c))&&this.addEdge(n,i+1,new fo(s,t,c,a,o))},r.prototype.encodeMinimally=function(e,t,n){var i=e.length,a=new fo[i+1][t.length()];this.addEdges(e,t,a,0,null,n);for(var o=1;o<=i;o++){for(var s=0;s<t.length();s++)a[o][s]!=null&&o<i&&this.addEdges(e,t,a,o,a[o][s],n);for(var s=0;s<t.length();s++)a[o-1][s]=null}for(var l=-1,u=X.MAX_VALUE,s=0;s<t.length();s++)if(a[i][s]!=null){var c=a[i][s];c.cachedTotalSize<u&&(u=c.cachedTotalSize,l=s)}if(l<0)throw new Error('Failed to encode "'+e+'"');for(var d=[],p=a[i][l];p!=null;){if(p.isFNC1())d.unshift(1e3);else for(var h=t.encode(p.c,p.encoderIndex),o=h.length-1;o>=0;o--)d.unshift(h[o]&255);var g=p.previous===null?0:p.previous.encoderIndex;g!==p.encoderIndex&&d.unshift(256+t.getECIValue(p.encoderIndex)),p=p.previous}for(var x=[],o=0;o<x.length;o++)x[o]=d[o];return x},r}(),fo=function(){function r(e,t,n,i,a){this.c=e,this.encoderSet=t,this.encoderIndex=n,this.previous=i,this.fnc1=a,this.c=e===a?1e3:e;var o=this.isFNC1()?1:t.encode(e,n).length,s=i===null?0:i.encoderIndex;s!==n&&(o+=Hd),i!=null&&(o+=i.cachedTotalSize),this.cachedTotalSize=o}return r.prototype.isFNC1=function(){return this.c===1e3},r}(),Xd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),$d=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(s){o={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},ho;(function(r){r[r.ASCII=0]="ASCII",r[r.C40=1]="C40",r[r.TEXT=2]="TEXT",r[r.X12=3]="X12",r[r.EDF=4]="EDF",r[r.B256=5]="B256"})(ho||(ho={})),function(r){Xd(e,r);function e(t,n,i,a,o){var s=r.call(this,t,n,i)||this;return s.shape=a,s.macroId=o,s}return e.prototype.getMacroId=function(){return this.macroId},e.prototype.getShapeHint=function(){return this.shape},e}(qd);var Wd=function(){function r(){}return r.prototype.isCompact=function(){return this.compact},r.prototype.setCompact=function(e){this.compact=e},r.prototype.getSize=function(){return this.size},r.prototype.setSize=function(e){this.size=e},r.prototype.getLayers=function(){return this.layers},r.prototype.setLayers=function(e){this.layers=e},r.prototype.getCodeWords=function(){return this.codeWords},r.prototype.setCodeWords=function(e){this.codeWords=e},r.prototype.getMatrix=function(){return this.matrix},r.prototype.setMatrix=function(e){this.matrix=e},r}(),po=function(){function r(){}return r.singletonList=function(e){return[e]},r.min=function(e,t){return e.sort(t)[0]},r}(),jd=function(){function r(e){this.previous=e}return r.prototype.getPrevious=function(){return this.previous},r}(),Yd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),xi=function(r){Yd(e,r);function e(t,n,i){var a=r.call(this,t)||this;return a.value=n,a.bitCount=i,a}return e.prototype.appendTo=function(t,n){t.appendBits(this.value,this.bitCount)},e.prototype.add=function(t,n){return new e(this,t,n)},e.prototype.addBinaryShift=function(t,n){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new e(this,t,n)},e.prototype.toString=function(){var t=this.value&(1<<this.bitCount)-1;return t|=1<<this.bitCount,"<"+X.toBinaryString(t|1<<this.bitCount).substring(1)+">"},e}(jd),Zd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Kd=function(r){Zd(e,r);function e(t,n,i){var a=r.call(this,t,0,0)||this;return a.binaryShiftStart=n,a.binaryShiftByteCount=i,a}return e.prototype.appendTo=function(t,n){for(var i=0;i<this.binaryShiftByteCount;i++)(i===0||i===31&&this.binaryShiftByteCount<=62)&&(t.appendBits(31,5),this.binaryShiftByteCount>62?t.appendBits(this.binaryShiftByteCount-31,16):i===0?t.appendBits(Math.min(this.binaryShiftByteCount,31),5):t.appendBits(this.binaryShiftByteCount-31,5)),t.appendBits(n[this.binaryShiftStart+i],8)},e.prototype.addBinaryShift=function(t,n){return new e(this,t,n)},e.prototype.toString=function(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"},e}(xi);function Qd(r,e,t){return new Kd(r,e,t)}function Cr(r,e,t){return new xi(r,e,t)}var Jd=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],ct=0,rn=1,We=2,vo=3,et=4,ef=new xi(null,0,0),yi=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])],tf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function rf(r){var e,t;try{for(var n=tf(r),i=n.next();!i.done;i=n.next()){var a=i.value;he.fill(a,-1)}}catch(o){e={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r[ct][et]=0,r[rn][et]=0,r[rn][ct]=28,r[vo][et]=0,r[We][et]=0,r[We][ct]=15,r}var go=rf(he.createInt32Array(6,6)),nf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},af=function(){function r(e,t,n,i){this.token=e,this.mode=t,this.binaryShiftByteCount=n,this.bitCount=i}return r.prototype.getMode=function(){return this.mode},r.prototype.getToken=function(){return this.token},r.prototype.getBinaryShiftByteCount=function(){return this.binaryShiftByteCount},r.prototype.getBitCount=function(){return this.bitCount},r.prototype.latchAndAppend=function(e,t){var n=this.bitCount,i=this.token;if(e!==this.mode){var a=yi[this.mode][e];i=Cr(i,a&65535,a>>16),n+=a>>16}var o=e===We?4:5;return i=Cr(i,t,o),new r(i,e,0,n+o)},r.prototype.shiftAndAppend=function(e,t){var n=this.token,i=this.mode===We?4:5;return n=Cr(n,go[this.mode][e],i),n=Cr(n,t,5),new r(n,this.mode,0,this.bitCount+i+5)},r.prototype.addBinaryShiftChar=function(e){var t=this.token,n=this.mode,i=this.bitCount;if(this.mode===et||this.mode===We){var a=yi[n][ct];t=Cr(t,a&65535,a>>16),i+=a>>16,n=ct}var o=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,s=new r(t,n,this.binaryShiftByteCount+1,i+o);return s.binaryShiftByteCount===2078&&(s=s.endBinaryShift(e+1)),s},r.prototype.endBinaryShift=function(e){if(this.binaryShiftByteCount===0)return this;var t=this.token;return t=Qd(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new r(t,this.mode,0,this.bitCount)},r.prototype.isBetterThanOrEqualTo=function(e){var t=this.bitCount+(yi[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?t+=r.calculateBinaryShiftCost(e)-r.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount},r.prototype.toBitArray=function(e){for(var t,n,i=[],a=this.endBinaryShift(e.length).token;a!==null;a=a.getPrevious())i.unshift(a);var o=new we;try{for(var s=nf(i),l=s.next();!l.done;l=s.next()){var u=l.value;u.appendTo(o,e)}}catch(c){t={error:c}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},r.prototype.toString=function(){return W.format("%s bits=%d bytes=%d",Jd[this.mode],this.bitCount,this.binaryShiftByteCount)},r.calculateBinaryShiftCost=function(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0},r.INITIAL_STATE=new r(ef,ct,0,0),r}();function of(r){var e=W.getCharCode(" "),t=W.getCharCode("."),n=W.getCharCode(",");r[ct][e]=1;for(var i=W.getCharCode("Z"),a=W.getCharCode("A"),o=a;o<=i;o++)r[ct][o]=o-a+2;r[rn][e]=1;for(var s=W.getCharCode("z"),l=W.getCharCode("a"),o=l;o<=s;o++)r[rn][o]=o-l+2;r[We][e]=1;for(var u=W.getCharCode("9"),c=W.getCharCode("0"),o=c;o<=u;o++)r[We][o]=o-c+2;r[We][n]=12,r[We][t]=13;for(var d=["\0"," ","","","","","","","\x07","\b"," ",`
254
254
  `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""],p=0;p<d.length;p++)r[vo][W.getCharCode(d[p])]=p;for(var h=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"],p=0;p<h.length;p++)W.getCharCode(h[p])>0&&(r[et][W.getCharCode(h[p])]=p);return r}var Ci=of(he.createInt32Array(5,256)),nn=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},sf=function(){function r(e){this.text=e}return r.prototype.encode=function(){for(var e=W.getCharCode(" "),t=W.getCharCode(`
255
- `),n=po.singletonList(af.INITIAL_STATE),i=0;i<this.text.length;i++){var a=void 0,o=i+1<this.text.length?this.text[i+1]:0;switch(this.text[i]){case W.getCharCode("\r"):a=o===t?2:0;break;case W.getCharCode("."):a=o===e?3:0;break;case W.getCharCode(","):a=o===e?4:0;break;case W.getCharCode(":"):a=o===e?5:0;break;default:a=0}a>0?(n=r.updateStateListForPair(n,i,a),i++):n=this.updateStateListForChar(n,i)}var s=po.min(n,function(l,u){return l.getBitCount()-u.getBitCount()});return s.toBitArray(this.text)},r.prototype.updateStateListForChar=function(e,t){var n,i,a=[];try{for(var o=nn(e),s=o.next();!s.done;s=o.next()){var l=s.value;this.updateStateForChar(l,t,a)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r.simplifyStates(a)},r.prototype.updateStateForChar=function(e,t,n){for(var i=this.text[t]&255,a=Ci[e.getMode()][i]>0,o=null,s=0;s<=et;s++){var l=Ci[s][i];if(l>0){if(o==null&&(o=e.endBinaryShift(t)),!a||s===e.getMode()||s===We){var u=o.latchAndAppend(s,l);n.push(u)}if(!a&&go[e.getMode()][s]>=0){var c=o.shiftAndAppend(s,l);n.push(c)}}}if(e.getBinaryShiftByteCount()>0||Ci[e.getMode()][i]===0){var d=e.addBinaryShiftChar(t);n.push(d)}},r.updateStateListForPair=function(e,t,n){var i,a,o=[];try{for(var s=nn(e),l=s.next();!l.done;l=s.next()){var u=l.value;this.updateStateForPair(u,t,n,o)}}catch(c){i={error:c}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return this.simplifyStates(o)},r.updateStateForPair=function(e,t,n,i){var a=e.endBinaryShift(t);if(i.push(a.latchAndAppend(et,n)),e.getMode()!==et&&i.push(a.shiftAndAppend(et,n)),n===3||n===4){var o=a.latchAndAppend(We,16-n).latchAndAppend(We,1);i.push(o)}if(e.getBinaryShiftByteCount()>0){var s=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);i.push(s)}},r.simplifyStates=function(e){var t,n,i,a,o=[];try{for(var s=nn(e),l=s.next();!l.done;l=s.next()){var u=l.value,c=!0,d=function(C){if(C.isBetterThanOrEqualTo(u))return c=!1,"break";u.isBetterThanOrEqualTo(C)&&(o=o.filter(function(_){return _!==C}))};try{for(var p=(i=void 0,nn(o)),h=p.next();!h.done;h=p.next()){var g=h.value,x=d(g);if(x==="break")break}}catch(C){i={error:C}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}c&&o.push(u)}}catch(C){t={error:C}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},r}(),lf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};(function(){function r(){}return r.encodeBytes=function(e){return r.encode(e,r.DEFAULT_EC_PERCENT,r.DEFAULT_AZTEC_LAYERS)},r.encode=function(e,t,n){var i=new sf(e).encode(),a=X.truncDivision(i.getSize()*t,100)+11,o=i.getSize()+a,s,l,u,c,d;if(n!==r.DEFAULT_AZTEC_LAYERS){if(s=n<0,l=Math.abs(n),l>(s?r.MAX_NB_BITS_COMPACT:r.MAX_NB_BITS))throw new k(W.format("Illegal value %s for layers",n));u=r.totalBitsInLayer(l,s),c=r.WORD_SIZE[l];var p=u-u%c;if(d=r.stuffBits(i,c),d.getSize()+a>p)throw new k("Data to large for user specified layer");if(s&&d.getSize()>c*64)throw new k("Data to large for user specified layer")}else{c=0,d=null;for(var h=0;;h++){if(h>r.MAX_NB_BITS)throw new k("Data too large for an Aztec code");if(s=h<=3,l=s?h+1:h,u=r.totalBitsInLayer(l,s),!(o>u)){(d==null||c!==r.WORD_SIZE[l])&&(c=r.WORD_SIZE[l],d=r.stuffBits(i,c));var p=u-u%c;if(!(s&&d.getSize()>c*64)&&d.getSize()+a<=p)break}}}var g=r.generateCheckWords(d,u,c),x=d.getSize()/c,C=r.generateModeMessage(s,l,x),_=(s?11:14)+l*4,w=new Int32Array(_),A;if(s){A=_;for(var h=0;h<w.length;h++)w[h]=h}else{A=_+1+2*X.truncDivision(X.truncDivision(_,2)-1,15);for(var E=X.truncDivision(_,2),I=X.truncDivision(A,2),h=0;h<E;h++){var N=h+X.truncDivision(h,15);w[E-h-1]=I-N-1,w[E+h]=I+N+1}}for(var D=new Je(A),h=0,M=0;h<l;h++){for(var F=(l-h)*4+(s?9:12),V=0;V<F;V++)for(var j=V*2,R=0;R<2;R++)g.get(M+j+R)&&D.set(w[h*2+R],w[h*2+V]),g.get(M+F*2+j+R)&&D.set(w[h*2+V],w[_-1-h*2-R]),g.get(M+F*4+j+R)&&D.set(w[_-1-h*2-R],w[_-1-h*2-V]),g.get(M+F*6+j+R)&&D.set(w[_-1-h*2-V],w[h*2+R]);M+=F*8}if(r.drawModeMessage(D,s,A,C),s)r.drawBullsEye(D,X.truncDivision(A,2),5);else{r.drawBullsEye(D,X.truncDivision(A,2),7);for(var h=0,V=0;h<X.truncDivision(_,2)-1;h+=15,V+=16)for(var R=X.truncDivision(A,2)&1;R<A;R+=2)D.set(X.truncDivision(A,2)-V,R),D.set(X.truncDivision(A,2)+V,R),D.set(R,X.truncDivision(A,2)-V),D.set(R,X.truncDivision(A,2)+V)}var Z=new Wd;return Z.setCompact(s),Z.setSize(A),Z.setLayers(l),Z.setCodeWords(x),Z.setMatrix(D),Z},r.drawBullsEye=function(e,t,n){for(var i=0;i<n;i+=2)for(var a=t-i;a<=t+i;a++)e.set(a,t-i),e.set(a,t+i),e.set(t-i,a),e.set(t+i,a);e.set(t-n,t-n),e.set(t-n+1,t-n),e.set(t-n,t-n+1),e.set(t+n,t-n),e.set(t+n,t-n+1),e.set(t+n,t+n-1)},r.generateModeMessage=function(e,t,n){var i=new we;return e?(i.appendBits(t-1,2),i.appendBits(n-1,6),i=r.generateCheckWords(i,28,4)):(i.appendBits(t-1,5),i.appendBits(n-1,11),i=r.generateCheckWords(i,40,4)),i},r.drawModeMessage=function(e,t,n,i){var a=X.truncDivision(n,2);if(t)for(var o=0;o<7;o++){var s=a-3+o;i.get(o)&&e.set(s,a-5),i.get(o+7)&&e.set(a+5,s),i.get(20-o)&&e.set(s,a+5),i.get(27-o)&&e.set(a-5,s)}else for(var o=0;o<10;o++){var s=a-5+o+X.truncDivision(o,5);i.get(o)&&e.set(s,a-7),i.get(o+10)&&e.set(a+7,s),i.get(29-o)&&e.set(s,a+7),i.get(39-o)&&e.set(a-7,s)}},r.generateCheckWords=function(e,t,n){var i,a,o=e.getSize()/n,s=new to(r.getGF(n)),l=X.truncDivision(t,n),u=r.bitsToWords(e,n,l);s.encode(u,l-o);var c=t%n,d=new we;d.appendBits(0,c);try{for(var p=lf(Array.from(u)),h=p.next();!h.done;h=p.next()){var g=h.value;d.appendBits(g,n)}}catch(x){i={error:x}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}return d},r.bitsToWords=function(e,t,n){var i=new Int32Array(n),a,o;for(a=0,o=e.getSize()/t;a<o;a++){for(var s=0,l=0;l<t;l++)s|=e.get(a*t+l)?1<<t-l-1:0;i[a]=s}return i},r.getGF=function(e){switch(e){case 4:return Re.AZTEC_PARAM;case 6:return Re.AZTEC_DATA_6;case 8:return Re.AZTEC_DATA_8;case 10:return Re.AZTEC_DATA_10;case 12:return Re.AZTEC_DATA_12;default:throw new k("Unsupported word size "+e)}},r.stuffBits=function(e,t){for(var n=new we,i=e.getSize(),a=(1<<t)-2,o=0;o<i;o+=t){for(var s=0,l=0;l<t;l++)(o+l>=i||e.get(o+l))&&(s|=1<<t-1-l);(s&a)===a?(n.appendBits(s&a,t),o--):(s&a)===0?(n.appendBits(s|1,t),o--):n.appendBits(s,t)}return n},r.totalBitsInLayer=function(e,t){return((t?88:112)+16*e)*e},r.DEFAULT_EC_PERCENT=33,r.DEFAULT_AZTEC_LAYERS=0,r.MAX_NB_BITS=32,r.MAX_NB_BITS_COMPACT=4,r.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]),r})();const uf=new Map([[Zi.DecodeHintType.POSSIBLE_FORMATS,[B.AZTEC,B.CODABAR,B.CODE_39,B.CODE_93,B.CODE_128,B.DATA_MATRIX,B.EAN_8,B.EAN_13,B.ITF,B.MAXICODE,B.PDF_417,B.QR_CODE,B.RSS_14,B.RSS_EXPANDED,B.UPC_A,B.UPC_E,B.UPC_EAN_EXTENSION]]]),an=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,...o}=r;return f.jsxs(v.Overlay.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[!!e&&f.jsx(v.Overlay.Trigger,{asChild:!0,children:e}),f.jsxs(v.Overlay.Content,{children:[f.jsx(v.Overlay.Title,{className:"sr-only",children:"Scanner"}),f.jsx(v.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),f.jsx(xo,{...o})]})]})});an.displayName="Scanner";const xo=m.memo(r=>{const{paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a}=r,{ref:o}=Zi.useZxing({paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a,hints:uf});return f.jsxs("div",{className:"flex size-full flex-col justify-center overflow-hidden bg-(--color-background)",children:[f.jsx("div",{className:"flex w-full justify-end p-4",children:f.jsx(v.Overlay.Close,{asChild:!0,children:f.jsx(v.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:f.jsx(v.LuIcon,{icon:nt})})})}),f.jsx("div",{className:"grow w-full max-h-full overflow-hidden p-4",children:f.jsx("video",{className:"size-full",ref:o})})]})});xo.displayName="ScannerInternal";const yo=m.memo(r=>{const{children:e}=r,[t,n]=m.useState(null),i=m.useCallback(()=>{n(null)},[]),a=m.useCallback(s=>{n(s(i))},[i]),o=m.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return f.jsxs(wa.Provider,{value:a,children:[e,t&&f.jsx(an,{open:!0,onOpenChange:o,...t})]})});yo.displayName="FileViewerProvider";const wi=m.memo(r=>{const[{inputId:e,labelId:t,label:n,helpText:i,size:a,severity:o,showInputOnly:s,field:l,fieldProps:u,helpers:c,touched:d},{disabled:p}]=Ne(r),{name:h,onBlur:g,onChange:x,value:C}=u,[_,w]=m.useState(!1),A=s?null:i,E=s?"":n,[I,N]=m.useState("");m.useEffect(()=>{N(C)},[C]);const D=m.useCallback(R=>{const Z=R.target.value;N(Z),(d||!l.onlyValidateAfterTouched)&&c.setError(l.getError(Z))},[l,c,d]),M=m.useCallback(()=>{x(I),g(I)},[I,g,x]),F=m.useCallback(R=>{x(R.getText()),w(!1)},[x]),V=m.useCallback(()=>{w(!0)},[]),j=m.useCallback(()=>{w(!1),g(C)},[g,C]);return f.jsx(Oe,{helpText:A,severity:o,size:a,children:f.jsxs(be,{size:a,severity:o,inputId:e,labelId:t,label:E,image:s?void 0:l.image,className:"flex-col items-start justify-start gap-2",children:[f.jsx(v.TextArea,{className:"w-full field-sizing-content",accentColor:"base",variant:"surface",size:a,id:e,name:h,value:I,placeholder:"Enter a qr or barcode",onChange:D,onBlur:M,disabled:p}),f.jsxs(v.Button,{onClick:V,className:"w-max",type:"button",variant:"soft",size:a,accentColor:"base",disabled:p,children:[f.jsx(v.LuIcon,{icon:pl}),"Scan"]}),f.jsx(an,{open:_,onDecodeResult:F,onOpenChange:j})]})})});wi.displayName="ScanFieldInput";const rr=class rr extends Pe{constructor(t){super(t);b(this,"type","qr");b(this,"onlyValidateAfterTouched",!1)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new rr({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new rr(t)}serializeValue(t){return t}deserializeValue(t){return t}render(t){return f.jsx(wi,{...t,field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}};b(rr,"fieldTypeName","Scan"),b(rr,"fieldTypeDescription","Used for scanning/reading QR and barcodes.");let wr=rr;const on=500,mi=m.memo(r=>{const[{inputId:e,labelId:t,size:n,severity:i,showInputOnly:a,field:o,helpText:s,label:l,fieldProps:u,touched:c,helpers:d},{disabled:p}]=Ne(r),{name:h,onBlur:g,onChange:x,value:C}=u,_=a?null:s,w=a?"":l,[A,E]=m.useState("");m.useEffect(()=>{E(C)},[C]);const I=m.useCallback(M=>{const F=M.target.value;E(F),(c||!o.onlyValidateAfterTouched)&&d.setError(o.getError(F))},[o,d,c]),N=m.useCallback(M=>{M.key==="Enter"&&M.preventDefault()},[]),D=m.useCallback(()=>{x(A),g(A)},[A,g,x]);return f.jsx(Oe,{helpText:_,severity:i,size:n,children:f.jsx(be,{size:n,severity:i,inputId:e,labelId:t,label:w,image:a?void 0:o.image,children:f.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:n,children:f.jsx(v.Input.Field,{id:e,className:"truncate",name:h,value:A,type:"text",placeholder:o.placeholder,onChange:I,onBlur:D,disabled:p,onKeyDown:N})})})})});mi.displayName="StringFieldInput";const nr=class nr extends Mn{constructor(t){const{...n}=t,i=t.maxLength?Math.min(on,t.maxLength):on,a=t.minLength?Math.min(t.minLength,i):void 0;super({...n,maxLength:i,minLength:a});b(this,"type","string")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new nr({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new nr({...a,maxLength:n,minLength:i,placeholder:"Enter a short description"})}render(t){return f.jsx(mi,{field:this,...t})}};b(nr,"fieldTypeName","Short Text"),b(nr,"fieldTypeDescription",`Short text fields can hold up to ${on} characters on a single line.`);let Gt=nr;const _i=m.memo(r=>{const[{inputId:e,labelId:t,size:n,severity:i,showInputOnly:a,field:o,helpText:s,label:l,fieldProps:u,touched:c,helpers:d},{disabled:p}]=Ne(r),{name:h,onBlur:g,onChange:x,value:C}=u,_=a?null:s,w=a?"":l,[A,E]=m.useState("");m.useEffect(()=>{E(C)},[C]);const I=m.useCallback(D=>{const M=D.target.value;E(M),(c||!o.onlyValidateAfterTouched)&&d.setError(o.getError(M))},[o,d,c]),N=m.useCallback(()=>{x(A),g(A)},[A,g,x]);return f.jsx(Oe,{helpText:_,severity:i,size:n,children:f.jsx(be,{size:n,severity:i,inputId:e,labelId:t,label:w,image:a?void 0:o.image,children:f.jsx(v.TextArea,{id:e,value:A,name:h,onChange:I,onBlur:N,className:"field-sizing-content min-h-12",placeholder:o.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:n,disabled:p})})})});_i.displayName="TextFieldInput";const ir=class ir extends Mn{constructor(t){const n=t.maxLength?Math.min(Nt,t.maxLength):Nt,i=t.minLength?Math.min(t.minLength,n):void 0;super({...t,maxLength:n,minLength:i});b(this,"type","text")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new ir({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new ir({...a,maxLength:n,minLength:i,placeholder:"Enter a description"})}render(t){return f.jsx(_i,{field:this,...t})}};b(ir,"fieldTypeName","Paragraph"),b(ir,"fieldTypeDescription",`Paragraph fields can hold up to ${Nt} characters and can have multiple lines.`);let Ht=ir;const Ai=m.memo(r=>{var M;const[{inputId:e,labelId:t,label:n,size:i,severity:a,helpText:o,showInputOnly:s,field:l,fieldProps:u},{disabled:c}]=Ne(r),{value:d,name:p,onChange:h,onBlur:g}=u,x=m.useRef(null),C=m.useMemo(()=>s?null:o||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,o,s]),_=m.useCallback(()=>{var F;(F=x.current)==null||F.click()},[]),w=m.useCallback(()=>{if(!x.current)return;const F=x.current.files;if(!F){g([]);return}const V=Array.from(F).map(R=>at.from(G.v4(),R)),j=[...d,...V];h(j),g(j)},[g,h,d]),A=m.useCallback(F=>{const V=[...d];V.splice(F,1),h(V)},[d,h]);m.useEffect(()=>{if(!x.current)return;const F=new AbortController;return x.current.addEventListener("cancel",()=>{g([...d])},{signal:F.signal}),()=>{F.abort()}},[g,d]);const E=s?"":n,D=l.maxFiles>1?"Select files":"Select a file";return f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(Oe,{helpText:C,severity:a,size:i,children:f.jsxs(be,{size:i,severity:a,inputId:e,labelId:t,label:E,image:s?void 0:l.image,children:[f.jsxs(v.Button,{className:"w-max",size:i,variant:"soft",accentColor:"base",onClick:_,type:"button",disabled:c,children:[f.jsx(v.LuIcon,{icon:Sn}),D]}),f.jsx("input",{id:e,name:p,type:"file",ref:x,accept:(M=l.extensions)==null?void 0:M.join(","),multiple:l.maxFiles>1,className:"hidden",onChange:w,value:""})]})}),Array.isArray(d)&&d.length>0&&f.jsx("div",{className:"flex h-max flex-col gap-2",children:d.map((F,V)=>f.jsx(zn,{file:F,onRemove:()=>{A(V)},disabled:c},V))})]})});Ai.displayName="UploadFieldInput";const ar=class ar extends Pe{constructor(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;super(o);b(this,"type","upload");b(this,"extensions");b(this,"maxFileSize");b(this,"maxFiles");b(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof i=="number"?i:1,1),this.extensions=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new qe({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${n}maximum_files`,integers:!0}),showDirectly:!1},{field:new qe({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${Xt}MB).`,required:!1,identifier:`${n}maximum_size`,minimum:1,maximum:Xt,integers:!0}),showDirectly:!1},{field:new it({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${n}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxFileSize??Xt,i=n*1e3*1e3,a=this.maxFiles||1;return t.push(o=>{if(o&&o.some(s=>s instanceof at&&s.size>i))return`Files must be at most ${n}MB.`}),t.push(o=>{if(o&&o.length>a)return`You can only upload ${a} files.`}),t}serialize(){return{...super.serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}duplicate(t){return new ar({...this.getOptions(),identifier:t})}setOptions(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;this.maxFileSize=typeof a=="number"?a:this.maxFileSize,this.maxFiles=typeof i=="number"?i:this.maxFiles,this.extensions=n,super.setOptions(o)}static deserialize(t){return new ar(t)}serializeValue(t){return[]}deserializeValue(t){return[]}render(t){return f.jsx(Ai,{field:this,...t})}isSerializedValue(t){return Array.isArray(t)&&t.length===0}isValue(t){return Array.isArray(t)?t.every(n=>n instanceof Ft||n instanceof at):!1}areValuesEqual(t,n){return qr(t,n)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){return t.length===n.length}};b(ar,"fieldTypeName","Upload"),b(ar,"fieldTypeDescription","Allows a file to be uploaded.");let qt=ar;const sn={date:dr,number:qe,boolean:bt,select:pt,string:Gt,text:Ht,upload:qt,qr:wr,"multi-string":Ot,"multi-select":it,radio:Vt,"checkbox-list":Tt,"pass-fail":Pt,otp:Dt,rating:Bt},fe={boolean:yl,date:Qs,"multi-string":hl,number:ll,qr:gl,"multi-select":dl,select:fl,string:wl,text:Ys,upload:Sn,section:cl,radio:el,"checkbox-list":il,"pass-fail":nl,otp:vl,rating:la},Xt=50,Co=Xt*1e3,wo=Co*1e3,Ie="Unlabelled",Ei="Unlabelled";class ${constructor(e){b(this,"id");b(this,"label");b(this,"getApplyFn");b(this,"serialize");b(this,"deserialize");const{id:t,getApplyFn:n,label:i,serialize:a,deserialize:o}=e;this.id=t,this.getApplyFn=n,this.label=i,this.serialize=a,this.deserialize=o}static create(e){return new $(e)}}const mo=$.create({id:"nullable-boolean-equals",label:"is",getApplyFn:r=>e=>e===r,serialize:r=>r,deserialize:r=>r}),_o=$.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:r=>e=>e!==r,serialize:r=>r,deserialize:r=>r}),Ao=$.create({id:"date-equals",getApplyFn:r=>e=>e.getTime()===r.getTime(),label:"is",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Eo=$.create({id:"date-not-equals",getApplyFn:r=>e=>e.getTime()!==r.getTime(),label:"is not",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),So=$.create({id:"date-before",getApplyFn:r=>e=>e.getTime()<r.getTime(),label:"before",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Io=$.create({id:"date-after",label:"after",getApplyFn:r=>e=>e.getTime()>r.getTime(),serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Oo=$.create({id:"date-range-in",label:"in between",getApplyFn:r=>e=>!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),bo=$.create({id:"date-range-not-in",label:"not in between",getApplyFn:r=>e=>!!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),No=$.create({id:"has-files",label:"is",getApplyFn:r=>e=>e.length>0,serialize:r=>r,deserialize:r=>r}),To=$.create({id:"does-not-have-files",label:"is not",getApplyFn:r=>e=>e.length===0,serialize:r=>r,deserialize:r=>r}),Si=$.create({id:"number-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Ii=$.create({id:"number-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Oi=$.create({id:"number-less-than",getApplyFn:r=>e=>e<r,label:"is less than",serialize:r=>r,deserialize:r=>r}),bi=$.create({id:"number-less-than-or-equals",getApplyFn:r=>e=>e<=r,label:"is less than or equal to",serialize:r=>r,deserialize:r=>r}),Ni=$.create({id:"number-greater-than",getApplyFn:r=>e=>e>r,label:"is greater than",serialize:r=>r,deserialize:r=>r}),Ti=$.create({id:"number-greater-than-or-equals",getApplyFn:r=>e=>e>=r,label:"is greater than or equal to",serialize:r=>r,deserialize:r=>r}),Di=$.create({id:"number-range-in",getApplyFn:r=>e=>!(r.to&&e>r.to||r.from&&e<r.from),label:"is between",serialize:r=>r,deserialize:r=>r}),Mi=$.create({id:"number-range-not-in",getApplyFn:r=>e=>!!(r.to&&e>r.to||r.from&&e<r.from),label:"is not between",serialize:r=>r,deserialize:r=>r}),Do=$.create({id:"pass-fail-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Mo=$.create({id:"pass-fail-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Fo=$.create({id:"pass-fail-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),Po=$.create({id:"pass-fail-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),mt=$.create({id:"nullable-string-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),_t=$.create({id:"nullable-string-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),mr=$.create({id:"string-includes",getApplyFn:r=>e=>e.includes(r),label:"includes",serialize:r=>r,deserialize:r=>r}),_r=$.create({id:"string-excludes",getApplyFn:r=>e=>!e.includes(r),label:"does not include",serialize:r=>r,deserialize:r=>r}),Fi=$.create({id:"string-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),Pi=$.create({id:"string-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),ln=$.create({id:"string-array-every",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isSubsetOf(n)}},label:"has all of",serialize:r=>r,deserialize:r=>r}),un=$.create({id:"string-array-some",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return!e.isDisjointFrom(n)}},label:"has any of",serialize:r=>r,deserialize:r=>r}),cn=$.create({id:"string-array-none",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isDisjointFrom(n)}},label:"has none of",serialize:r=>r,deserialize:r=>r}),dn=$.create({id:"string-array-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size===n.size&&n.isSubsetOf(e)}},label:"is",serialize:r=>r,deserialize:r=>r}),fn=$.create({id:"string-array-not-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size!==n.size||!n.isSubsetOf(e)}},label:"is not",serialize:r=>r,deserialize:r=>r}),L=r=>r;class Me extends lr{constructor(t){const{id:n,field:i,conditionValue:a,conditionModifier:o}=t;super();b(this,"id");b(this,"conditionValue");b(this,"conditionModifier");b(this,"field");b(this,"getConditionValue",()=>this.conditionValue);b(this,"setConditionValue",t=>{const n=this.modifiers[this.conditionModifier];t!==void 0&&!n.isConditionValueValid(t)||(this.conditionValue=t,this.notify(this))});b(this,"getConditionModifier",()=>this.conditionModifier);b(this,"setConditionModifier",t=>{const n=this.modifiers[t],i=this.getConditionValue();i&&!n.isConditionValueValid(i)&&(this.conditionValue=void 0),this.conditionModifier=t,this.notify(this)});b(this,"getConditionModifiers",()=>Object.entries(this.modifiers));b(this,"accessorFn",t=>t[this.field.identifier]);b(this,"getApplyFn",()=>{const t=this.modifiers[this.conditionModifier],n=this.getConditionValue(),i=n!==void 0&&t.isConditionValueValid(n),a=i?t.modifier.getApplyFn(n):null;return o=>{if(!i)return!0;const s=this.transformValue(o);return t.isValueValid(s)?a(s):!1}});this.id=n,this.field=i,this.conditionValue=a,this.conditionModifier=o}serialize(){return{id:this.id,type:this.field.type,fieldId:this.field.identifier,conditionValue:this.conditionValue!==void 0?this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue):void 0,conditionModifier:this.conditionModifier}}transformValue(t){return t}}const Vo=m.memo,At=Vo(function(r){const{ref:e,children:t,...n}=r,i=m.useCallback(a=>typeof t=="function"?f.jsxs(f.Fragment,{children:[t(a),f.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:f.jsx(v.LuIcon,{icon:Ge})})]}):f.jsxs(f.Fragment,{children:[t,f.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:f.jsx(v.LuIcon,{icon:Ge})})]}),[t]);return f.jsx(v.Menu.SelectItem,{ref:e,...n,children:i})}),Bo=Vo(function(r){const{ref:e,children:t,...n}=r,i=m.useCallback(a=>typeof t=="function"?f.jsxs(f.Fragment,{children:[t(a),f.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:f.jsx(v.LuIcon,{icon:Ge})})]}):f.jsxs(f.Fragment,{children:[t,f.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:f.jsx(v.LuIcon,{icon:Ge})})]}),[t]);return f.jsx(v.Menu.MultiSelectItem,{ref:e,...n,children:i})}),Vi=m.memo(r=>{const{ref:e,children:t,...n}=r,i=m.useCallback(a=>typeof t=="function"?f.jsxs(f.Fragment,{children:[t(a),f.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?f.jsx(v.LuIcon,{icon:Rr}):f.jsx(v.LuIcon,{icon:Ge})})]}):f.jsxs(f.Fragment,{children:[t,f.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?f.jsx(v.LuIcon,{icon:Rr}):f.jsx(v.LuIcon,{icon:Ge})})]}),[t]);return f.jsx(v.Menu.SelectAllItem,{ref:e,...n,children:i})});Vi.displayName="SelectAllItemTemplate";const ze=r=>{const{children:e,condition:t,size:n="sm",variant:i,accentColor:a,radius:o}=r,s=m.useCallback(l=>{t.setConditionModifier(l)},[t]);return f.jsxs(v.Menu.Root,{align:"start",children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{size:n,variant:i,radius:o,accentColor:a,children:f.jsx(v.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:s,children:t.getConditionModifiers().map(([l,u])=>f.jsx(At,{value:l,children:u.modifier.label},l))})})]})},hn=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,align:s,accentColor:l="base",...u}=r;return f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,align:s,children:f.jsx(v.DayPicker,{size:o,accentColor:l,...u})})]})});hn.displayName="DayPickerPopover";const Lo=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",values:l,onValuesChange:u,placeholder:c="Enter text",...d}=r,[p,h]=m.useState(""),g=m.useCallback(w=>{h(w.target.value)},[]),x=m.useCallback(w=>{w.key==="Enter"&&(w.preventDefault(),w.stopPropagation(),u([...l,p]),h(""))},[p,u,l]),C=m.useCallback(()=>{u([...l,p]),h("")},[p,u,l]),_=m.useCallback(w=>{const A=[...l];A.splice(w,1),u(A)},[u,l]);return f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,accentColor:s,...d,children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:f.jsx(v.Input.Field,{value:p,onChange:g,onKeyDown:x,placeholder:c,...d})}),f.jsx(v.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:C,children:f.jsx(v.LuIcon,{icon:je})})]}),l.length>0&&f.jsx("div",{className:"flex flex-col gap-1",children:l.map((w,A)=>f.jsxs(v.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[f.jsx("span",{className:"truncate",children:w}),f.jsx(v.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{_(A)},children:f.jsx(v.LuIcon,{icon:nt})})]},`${w}-${A}`))})]})})]})});Lo.displayName="NumberInputPopover";const Et=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter a number",...d}=r,[p,h]=m.useState(null);m.useEffect(()=>{l!==void 0&&h(l)},[l]);const g=m.useCallback(C=>{const _=C.target.valueAsNumber;h(isNaN(_)?null:_)},[]),x=m.useCallback(C=>{const _=C.target.valueAsNumber;u==null||u(isNaN(_)?null:_)},[u]);return f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...d,children:f.jsx(v.Input.Root,{size:o,accentColor:s,children:f.jsx(v.Input.Field,{placeholder:c,type:"number",value:p??"",onChange:g,onBlur:x})})})]})});Et.displayName="NumberInputPopover";const Fe=r=>{const{condition:e,onClick:t,...n}=r,i=m.useCallback(()=>{t(e)},[e,t]);return f.jsx(v.IconButton,{onClick:i,...n,children:f.jsx(v.LuIcon,{icon:nt})})};Fe.displayName="RemoveConditionButton";const Ar=m.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=m.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return f.jsxs(v.Menu.MultiSelectGroup,{ref:e,...n,children:[f.jsx(Vi,{children:"Select all"}),i.map(a=>f.jsx(Bo,{value:a.value,children:f.jsx("span",{className:"truncate",children:a.label})},a.value))]})});Ar.displayName="SelectFieldOptionMultiSelectGroup";const Bi=m.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=m.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return f.jsx(v.Menu.SelectGroup,{ref:e,...n,children:i.map(a=>f.jsx(At,{value:a.value,children:f.jsx("span",{className:"truncate",children:a.label})},a.value))})});Bi.displayName="SelectFieldOptionSelectGroup";const Er=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter text",...d}=r,[p,h]=m.useState(""),g=m.useCallback(C=>{h(C.target.value)},[]),x=m.useCallback(C=>{const _=C.target.value;u==null||u(_)},[u]);return m.useEffect(()=>{l&&h(l)},[l]),f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...d,children:f.jsx(v.Input.Root,{size:o,accentColor:s,children:f.jsx(v.Input.Field,{placeholder:c,type:"text",value:p,onChange:g,onBlur:x})})})]})});Er.displayName="TextInputPopover";const zo=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{switch(n){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[e.field.type]}),f.jsx("span",{className:"truncate",children:e.field.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:a()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsxs(v.Menu.SelectGroup,{required:!0,value:n,onValueChange:e.setConditionValue,children:[f.jsx(At,{value:!0,children:"true"}),f.jsx(At,{value:!1,children:"false"})]})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},ko={equals:L({modifier:mo,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_o,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Sr extends Me{constructor(t){super(t);b(this,"modifiers",ko)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ko[a];let l;return i!==void 0&&(l=s.modifier.deserialize(i)),new Sr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(zo,{condition:this,...t},this.id)}}const Ro=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"soft",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{values:i??[],selectFieldOptions:e.field.options,onValuesChange:o})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},Uo={equals:L({modifier:dn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:fn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:L({modifier:ln,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:L({modifier:un,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:L({modifier:cn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Ir extends Me{constructor(t){super(t);b(this,"modifiers",Uo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Uo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Ir({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(Ro,{condition:this,...t},this.id)}}class pn extends lr{constructor(t){super();b(this,"conditions");b(this,"conditionObserver",()=>{this.conditions=[...this.conditions],this.notify(this)});b(this,"initConditions",t=>{for(const n of t)n.observe(this.conditionObserver);return t});this.conditions=this.initConditions(t)}getConditions(){return this.conditions}addCondition(t){this.conditions=this.initConditions([...this.conditions,t]),this.notify(this)}addConditions(t){this.conditions=this.initConditions([...this.conditions,...t]),this.notify(this)}removeCondition(t){this.conditions=this.initConditions(this.conditions.filter(n=>n.id!==t.id)),this.notify(this)}removeConditions(t){const n=new Set(t.map(i=>i.id));this.conditions=this.initConditions(this.conditions.filter(i=>!n.has(i.id))),this.notify(this)}applyConditions(t){return this.conditions.length===0?!0:this.conditions.map(i=>[i.getApplyFn(),i.accessorFn]).every(([i,a])=>i(a(t)))}}const cf=(r,e)=>m.useMemo(()=>{const t=new pn(r);return t.observe(n=>e(n.getConditions())),t},[r,e]),Go=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{var o,s;switch(i){case"equals":case"notEquals":{const l=e.modifiers.equals,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return f.jsx(hn,{required:!1,size:"sm",mode:"single",selected:u??void 0,onSelect:c=>e.setConditionValue(c),children:f.jsx(v.Button,{type:"button",className:"truncate",children:u!==void 0?(u==null?void 0:u.toLocaleDateString())??"empty":"..."})})}case"before":case"after":{const l=e.modifiers.after,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return f.jsx(hn,{required:!0,size:"sm",mode:"single",selected:u,onSelect:e.setConditionValue,children:f.jsx(v.Button,{type:"button",className:"truncate",children:u?u.toLocaleDateString():"..."})})}case"in":case"notIn":{const l=e.modifiers.in,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return f.jsx(hn,{required:!0,mode:"range",size:"sm",selected:u,onSelect:e.setConditionValue,children:f.jsx(v.Button,{className:"truncate",children:u?`${(o=u.from)==null?void 0:o.toLocaleDateString()} - ${(s=u.to)==null?void 0:s.toLocaleDateString()}`:"..."})})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[e.field.type]}),f.jsx("span",{className:"truncate",children:e.field.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),a(),f.jsx(Fe,{condition:e,onClick:t})]})},Ho={equals:L({modifier:Ao,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),notEquals:L({modifier:Eo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),before:L({modifier:So,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),after:L({modifier:Io,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),in:L({modifier:Oo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r}),notIn:L({modifier:bo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r})};class Or extends Me{constructor(t){super(t);b(this,"modifiers",Ho)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ho[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Or({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(Go,{condition:this,...t},this.id)}}const qo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{values:i??[],selectFieldOptions:n.options,onValuesChange:o})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},Xo={equals:L({modifier:dn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:fn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:L({modifier:ln,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:L({modifier:un,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:L({modifier:cn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class br extends Me{constructor(t){super(t);b(this,"modifiers",Xo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Xo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new br({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(qo,{condition:this,...t},this.id)}}const Li=[],$o=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useCallback(l=>{e.setConditionValue(l.length>0?l:void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";case 1:return i[0].toString();default:return`${i.length} values`}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsx(Lo,{values:i??Li,onValuesChange:o,children:f.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),f.jsx(Fe,{condition:e,onClick:t})]})},Wo={equals:L({modifier:dn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:fn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:L({modifier:ln,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:L({modifier:un,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:L({modifier:cn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Nr extends Me{constructor(t){super(t);b(this,"modifiers",Wo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Wo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Nr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx($o,{condition:this,...t},this.id)}}const jo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const s=e.modifiers.greaterThan,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsx(Et,{value:l??null,onValueChange:u=>e.setConditionValue(u??void 0),size:"sm",children:f.jsx(v.Button,{type:"button",className:"truncate",children:l!==void 0?l??"empty":"..."})})}case"inRange":case"notInRange":{const s=e.modifiers.inRange,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(f.Fragment,{children:[f.jsx(Et,{value:(l==null?void 0:l.from)??null,onValueChange:u=>{e.setConditionValue({from:u,to:(l==null?void 0:l.to)??null})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.from)??"..."})}),f.jsx(Et,{value:(l==null?void 0:l.to)??null,onValueChange:u=>{e.setConditionValue({from:(l==null?void 0:l.from)??null,to:u})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.to)??"..."})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},Yo={equals:L({modifier:Si,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:L({modifier:Ii,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:L({modifier:Oi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:L({modifier:bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:L({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:L({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:L({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:L({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Tr extends Me{constructor(t){super(t);b(this,"modifiers",Yo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Yo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Tr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(jo,{condition:this,...t},this.id)}}const Zo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},Ko={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Dr extends Me{constructor(t){super(t);b(this,"modifiers",Ko)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ko[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Dr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(Zo,{condition:this,...t},this.id)}}const Qo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":{const s=e.modifiers.equals,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:l!==void 0?l?vt[l].label:"empty":"..."})})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(v.Menu.SelectGroup,{required:!1,value:l,onValueChange:e.setConditionValue,children:Mt.map(u=>{const{label:c}=vt[u];return f.jsx(At,{value:u,children:f.jsx("span",{className:"truncate",children:c})},u)})})})]})}case"includes":case"excludes":{const s=e.modifiers.includes,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",children:l?`${l.length} statuses`:"..."})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsxs(v.Menu.MultiSelectGroup,{values:l??Li,onValuesChange:e.setConditionValue,children:[f.jsx(Vi,{children:"Select all"}),Mt.map(u=>{const{label:c,icon:d}=vt[u];return f.jsxs(Bo,{value:u,children:[f.jsx(v.LuIcon,{icon:d}),f.jsx("span",{className:"truncate",children:c})]},u)})]})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},Jo={equals:L({modifier:Do,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),notEquals:L({modifier:Mo,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),includes:L({modifier:Fo,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:L({modifier:Po,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Mr extends Me{constructor(t){super(t);b(this,"modifiers",Jo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Jo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Mr({field:n,conditionModifier:a,conditionValue:l,...o})}transformValue(t){return t.status}render(t){return f.jsx(Qo,{condition:this,...t},this.id)}}const es=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useMemo(()=>n.options.map(u=>typeof u=="string"?{value:u,label:u}:u),[n.options]),s=m.useMemo(()=>{const u={};for(const c of o)u[c.value]=c.label;return u},[o]),l=()=>{switch(a){case"equals":case"notEquals":{const u=e.modifiers.equals,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:c!==void 0?c?s[c]:"empty":"..."})})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Bi,{required:!0,selectFieldOptions:n.options,value:c??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const u=e.modifiers.includes,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",children:c?`${c.length} options`:"..."})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{selectFieldOptions:n.options,values:c??Li,onValuesChange:e.setConditionValue})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),f.jsx(Fe,{condition:e,onClick:t})]})},ts={equals:L({modifier:mt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:L({modifier:_t,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:L({modifier:Fi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:L({modifier:Pi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Fr extends Me{constructor(t){super(t);b(this,"modifiers",ts)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ts[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Fr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(es,{condition:this,...t},this.id)}}const rs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const s=e.modifiers[a],l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsx(Et,{value:l??null,onValueChange:u=>e.setConditionValue(u??void 0),size:"sm",children:f.jsx(v.Button,{type:"button",className:"truncate",children:l!==void 0?l:"..."})})}case"inRange":case"notInRange":{const s=e.modifiers.inRange,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(f.Fragment,{children:[f.jsx(Et,{value:(l==null?void 0:l.from)??null,onValueChange:u=>{e.setConditionValue({from:u,to:(l==null?void 0:l.to)??null})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.from)??"..."})}),f.jsx(Et,{value:(l==null?void 0:l.to)??null,onValueChange:u=>{e.setConditionValue({from:(l==null?void 0:l.from)??null,to:u})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.to)??"..."})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},ns={equals:L({modifier:Si,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:L({modifier:Ii,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:L({modifier:Oi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:L({modifier:bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:L({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:L({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:L({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:L({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Pr extends Me{constructor(t){super(t);b(this,"modifiers",ns)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ns[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Pr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(rs,{condition:this,...t},this.id)}}const is=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},as={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Vr extends Me{constructor(t){super(t);b(this,"modifiers",as)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=as[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Vr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(is,{condition:this,...t},this.id)}}const os=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useMemo(()=>n.options.map(c=>typeof c=="string"?{value:c,label:c}:c),[n.options]),s=m.useMemo(()=>{const c={};for(const d of o)c[d.value]=d.label;return c},[o]),l=m.useCallback(c=>{c.length>0?e.setConditionValue(c):e.setConditionValue([])},[e]),u=()=>{switch(a){case"equals":case"notEquals":{const c=e.modifiers.equals,d=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:d!==void 0?d?s[d]:"empty":"..."})})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Bi,{required:!1,selectFieldOptions:n.options,value:d??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const c=e.modifiers.includes,d=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",children:d?`${d.length} options`:"..."})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{selectFieldOptions:n.options,values:d??[],onValuesChange:l})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),u(),f.jsx(Fe,{condition:e,onClick:t})]})},ss={equals:L({modifier:mt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:L({modifier:_t,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:L({modifier:Fi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:L({modifier:Pi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Br extends Me{constructor(t){super(t);b(this,"modifiers",ss)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ss[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Br({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(os,{condition:this,...t},this.id)}}const ls=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},us={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Lr extends Me{constructor(t){super(t);b(this,"modifiers",us)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=us[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Lr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(ls,{condition:this,...t},this.id)}}const cs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},ds={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class zr extends Me{constructor(t){super(t);b(this,"modifiers",ds)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ds[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new zr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(cs,{condition:this,...t},this.id)}}const fs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(i){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:o()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsxs(v.Menu.SelectGroup,{required:!0,value:i,onValueChange:e.setConditionValue,children:[f.jsx(At,{value:!0,children:"empty"}),f.jsx(At,{value:!1,children:"not empty"})]})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},hs={equals:L({modifier:No,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:To,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class kr extends Me{constructor(t){super(t);b(this,"modifiers",hs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=hs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new kr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(fs,{condition:this,...t},this.id)}}const df={date:Or,number:Tr,boolean:Sr,select:Br,string:Lr,text:zr,upload:kr,qr:Vr,"multi-string":Nr,"multi-select":br,radio:Fr,"checkbox-list":Ir,"pass-fail":Mr,otp:Dr,rating:Pr},ps=(r,e)=>{if(r.type!==e.type)throw new Error(`field and condition type mismatch ${r.type} !== ${e.type}`);return df[e.type].deserialize(e,r)},zi=(r,e)=>{const t={};for(const n of r)t[n.identifier]=n;return e.map(n=>ps(t[n.fieldId],n))},vn=r=>sn[r.type].deserialize(r);function ff(r){return r.map(vs)}const vs=r=>r.type==="section"?He.deserialize(r):vn(r);function hf(r){return r.map(vn)}function gs(r){const e=[];for(const t of r)if(t instanceof He)for(const n of t.getFields())e.push(n);else e.push(t);return e}function xs(r){const e={};for(const t of r)e[t.identifier]=t;return e}function ys(r,e,t=!0){const n=t?gn(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.serializeValue(o)}return i}function Cs(r,e,t=!0){const n=t?ki(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.deserializeValue(o)}return i}function gn(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isValue(i)&&(t[n.identifier]=n.cleanValue(i))}return t}function ki(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isSerializedValue(i)&&(t[n.identifier]=n.cleanSerializedValue(i))}return t}function ws(r,e){const t=gn(r,e),n={},i={};for(const a of r){if(!(a.identifier in t))continue;const o=t[a.identifier];switch(a.type){case"upload":if(!a.isValue(o))break;i[a.identifier]=o,n[a.identifier]=[];break;case"pass-fail":if(!a.isValue(o))break;i[a.identifier]=o.files,n[a.identifier]={...o,files:[]};break;default:n[a.identifier]=e[a.identifier]}}return[n,i]}function ms(r,e,t){const n={};for(const i of r){if(!(i.identifier in e))continue;const a=e[i.identifier];switch(i.type){case"upload":if(!i.isValue(a))break;n[i.identifier]=t[i.identifier]??[];break;case"pass-fail":if(!i.isValue(a))break;n[i.identifier]={...a,files:t[i.identifier]??[]};break;default:if(!i.isValue(a))break;n[i.identifier]=a}}return n}const _s=(r,e)=>{const t={};for(const n of r){const i=e[n.identifier];t[n.identifier]=i!==void 0?i:n.blankValue()}return t},As=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)||(n[i.identifier]=o)}return n},Es=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)&&(n[i.identifier]=o)}return n},Ri=(r,e,t)=>r.every(n=>{const i=e[n.identifier],a=t[n.identifier];return n.areValuesEqual(i,a)}),Ui=r=>{const e={};for(const t of r)e[t.identifier]=t.blankValue();return e},Ss=(r,e)=>Ri(r,e,Ui(r)),pf=(r,e,t={})=>{const{conditions:n=!1}=t,i=r.get(e.identifier);if(!i)throw new Error(`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`);const a=new Map,o=e.fields.map(l=>{const u=G.v4(),{image:c,...d}=l;return a.set(l.identifier,u),{...d,identifier:u}}),s={};if(n)for(const[l,u]of Object.entries(e.conditions??{})){const c=r.get(l);if(!c)continue;const d=u.map(p=>{const h=a.get(p.fieldId);if(!h)throw new Error(`Serialized condition referencing undefined field with identifier: ${p.fieldId}`);return{...p,fieldId:h}});s[c]=d}return{...e,identifier:i,conditions:s,fields:o}},vf=(r,e={})=>{const t=new Map(r.map(n=>[n.identifier,G.v4()]));return r.map(n=>pf(t,n,e))},Gi=(r,e)=>{const t={},n=r.filter(i=>i instanceof He);for(const i of r)if(i instanceof He){const a=n.filter(s=>i.identifier in s.conditions);if(a.length>0&&!a.some(s=>{const l=s.getConditions(i.identifier);return new pn(l).applyConditions(e)}))continue;const o=i.getErrors(e);Object.assign(t,o)}else{if(!(i instanceof Pe))throw new Error("Invalid field type");const a=i.identifier,o=i.getError(_n(e,a));o&&Hs(t,a,o)}if(Object.keys(t).length>0)return t},gf=async r=>{const e={},t=[];for(const n of r){const{fields:i}=n,a=[];for(const o of i){if(o.image){if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(s){console.error("Failed to get image from promise",s)}else e[o.identifier]=o.image;delete o.image}a.push(o)}t.push({...n,fields:a})}return{fields:t,images:e}};async function xf(r){const e={};for(const[t,n]of Object.entries(r))e[t]=await Promise.all(n);return e}class dt extends lr{constructor(t){super();b(this,"fieldSections");b(this,"fieldObserver",()=>{this.notify(this)});b(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});this.fieldSections=this.initFields(t)}serialize(){return this.fieldSections.map(t=>t.serialize())}static deserialize(t){return new dt(t.map(He.deserialize))}static reseedFieldSections(t,n){return vf(t,n)}getFields(){return this.fieldSections.flatMap(t=>t.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(t,n){const i=[...this.fieldSections];i.splice(n??this.fieldSections.length,0,t),this.fieldSections=this.initFields(i),this.notify(this)}removeFieldSection(t){const n=this.fieldSections.filter(i=>i.identifier!==t.identifier);for(const i of n)i.removeConditional(i.identifier);this.fieldSections=this.initFields(n),this.notify(this)}moveFieldSection(t,n){const i=[...this.fieldSections],[a]=i.splice(t,1);i.splice(n,0,a),this.fieldSections=this.initFields(i),this.notify(this)}getSectionDependencyGraph(){const t=new Us.DirectedGraph({type:"directed"});for(const n of this.fieldSections)for(const i of Object.keys(n.conditions))t.mergeEdge(n.identifier,i);return t}getDependenciesOfSection(t){const n=this.getSectionDependencyGraph(),i=new Map(this.fieldSections.map(o=>[o.identifier,o])),a=[];return Gs.bfsFromNode(n,t,(o,s,l)=>{a.push(i.get(o))},{mode:"in"}),a}cleanValues(t){return gn(this.getFields(),t)}cleanSerializedValues(t){return ki(this.getFields(),t)}deserializeValues(t,n){return Cs(this.getFields(),t,n)}serializeValues(t,n){return ys(this.getFields(),t,n)}initializeValues(t){return _s(this.getFields(),t)}validateValues(t){return Gi(this.getFieldSections(),t)}deserializeConditions(t){return zi(this.getFields(),t)}changedFieldValues(t,n){return As(this.getFields(),t,n)}unchangedFieldValues(t,n){return Es(this.getFields(),t,n)}areValuesEqual(t,n){return Ri(this.getFields(),t,n)}areValuesBlank(t){return Ss(this.getFields(),t)}blankValues(){return Ui(this.getFields())}extractFilesAndPromisesFromFieldValues(t){return ws(this.getFields(),t)}insertFilesAndPromisesToFieldValues(t,n){return ms(this.getFields(),t,n)}}const Is=m.createContext({}),Hi=m.memo(r=>{const{fieldSection:e,size:t,...n}=r,{label:i,description:a}=e,{values:o}=rt.useFormikContext(),{fieldSchema:s}=m.use(Is),l=m.useMemo(()=>s.getFieldSections(),[s]),u=m.useMemo(()=>l.filter(p=>e.identifier in p.conditions),[l,e.identifier]),c=m.useMemo(()=>u.length===0?!0:u.some(p=>{const h=p.getConditions(e.identifier);return new pn(h).applyConditions(o)}),[u,e,o]),d=ur(e.fields,{size:t,...n});return c?f.jsxs("div",{className:"flex flex-col gap-4",children:[(i||a)&&f.jsx(f.Fragment,{children:f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(v.Heading,{size:t,children:i}),a&&f.jsx(v.Text,{accentColor:"base",size:t,children:a})]})}),d]}):null});Hi.displayName="FieldSectionLayout";const It=class It extends On{constructor(t){const{label:n=null,description:i=null,fields:a,conditions:o={},...s}=t;super(s);b(this,"type","section");b(this,"label");b(this,"description");b(this,"conditions");b(this,"fields",[]);b(this,"fieldObserver",()=>{this.notify(this)});b(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});b(this,"conditionObserver",()=>{this.notify(this)});b(this,"initConditions",t=>{for(const n of Object.values(t).flat())n.observe(this.conditionObserver);return t});this.label=n,this.description=i,this.fields=this.initFields(a),this.conditions=this.initConditions(o)}serialize(){const t={};for(const[n,i]of Object.entries(this.conditions))t[n]=i.map(a=>a.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:t,fields:this.fields.map(n=>n.serialize())}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(t){return new It({...this.getOptions(),identifier:t,fields:this.fields.map(n=>n.duplicate(G.v4()))})}setOptions(t){const{label:n,description:i,fields:a,conditions:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.fields=a||this.fields,this.conditions=o||this.conditions,super.setOptions(s)}getErrors(t){const n={};for(const i of this.fields){const a=i.getError(t[i.identifier]);a&&(n[i.identifier]=a)}return n}getFields(){return this.fields}addField(t,n){const i=[...this.fields];i.splice(n??this.fields.length,0,t),this.fields=this.initFields(i),this.notify(this)}moveField(t,n){const i=[...this.fields],[a]=i.splice(t,1);i.splice(n,0,a),this.fields=i,this.notify(this)}removeField(t){this.fields=this.initFields(this.fields.filter(({identifier:i})=>i!==t.identifier));const n={};for(const[i,a]of Object.entries(this.conditions))n[i]=a.filter(o=>o.field.identifier!==t.identifier);this.conditions=n,this.notify(this)}getConditions(t){return this.conditions[t]}addCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],n]}),this.notify(this)}addConditions(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],...n]}),this.notify(this)}removeCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(i=>i.id!==n.id)}),this.notify(this)}removeConditions(t,n){const i=new Set(n.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(a=>!i.has(a.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(t){this.conditions=this.initConditions({...this.conditions,[t]:[]}),this.notify(this)}removeConditional(t){const n={...this.conditions};delete n[t],this.conditions=this.initConditions(n),this.notify(this)}render(t){return f.jsx(Hi,{fieldSection:this,...t})}};b(It,"fieldTypeName","Section"),b(It,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden."),b(It,"deserialize",t=>{const n=t.fields.map(vn),i={};for(const[a,o]of Object.entries(t.conditions))i[a]=zi(n,o);return new It({...t,fields:n,conditions:i})});let He=It;const St=m.createContext(new dt([])),xn="form-builder",yn=m.createContext({}),yf=(r=()=>null)=>m.useMemo(()=>Object.entries(sn).map(([t,n])=>({children:n.fieldTypeName,icon:f.jsx(v.LuIcon,{icon:fe[t]}),value:t,onSelect:()=>{r(t)}})),[r]),Cn=m.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,onSelectFieldType:a,...o}=r,s=yf(a);return f.jsxs(v.Menu.Root,{...o,children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:f.jsx(v.Menu.Scroll,{children:s.flat().map(l=>f.jsxs(v.Menu.Item,{onSelect:l.onSelect,children:[l.icon,l.children]},l.value))})})]})});Cn.displayName="CreateFieldDropdownMenu";const wn=r=>{switch(r){case"text":return new Ht({label:"",required:!1,identifier:G.v4()});case"boolean":return new bt({label:"",required:!1,identifier:G.v4()});case"number":return new qe({label:"",required:!1,identifier:G.v4()});case"date":return new dr({label:"",required:!1,identifier:G.v4()});case"string":return new Gt({label:"",required:!1,identifier:G.v4()});case"select":return new pt({label:"",options:[],required:!1,identifier:G.v4()});case"multi-string":return new Ot({label:"",required:!1,identifier:G.v4()});case"multi-select":return new it({label:"",options:[],required:!1,identifier:G.v4()});case"upload":return new qt({label:"",required:!1,identifier:G.v4(),maximum_files:6,maximum_size:Xt});case"qr":return new wr({label:"",required:!1,identifier:G.v4()});case"radio":return new Vt({label:"",options:[],required:!1,identifier:G.v4()});case"checkbox-list":return new Tt({label:"",options:[],required:!1,identifier:G.v4()});case"pass-fail":return new Pt({label:"",required:!1,identifier:G.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new Dt({label:"",validationType:"none",required:!1,identifier:G.v4(),length:6});case"rating":return new Bt({label:"",required:!1,identifier:G.v4(),maxRating:5})}},qi=r=>{switch(r.type){case"text":return new zr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"boolean":return new Sr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"number":return new Tr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"date":return new Or({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"string":return new Lr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"select":return new Br({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-string":return new Nr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-select":return new br({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"upload":return new kr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"qr":return new Vr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"radio":return new Fr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"checkbox-list":return new Ir({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"pass-fail":return new Mr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"otp":return new Dr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"rating":return new Pr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r})}},Os=(r,e)=>{switch(r){case"checkbox-list":return Tt.getFieldCreationSchema(e);case"multi-select":return it.getFieldCreationSchema(e);case"number":return qe.getFieldCreationSchema(e);case"radio":return Vt.getFieldCreationSchema(e);case"select":return pt.getFieldCreationSchema(e);case"string":return Gt.getFieldCreationSchema(e);case"text":return Ht.getFieldCreationSchema(e);case"upload":return qt.getFieldCreationSchema(e);case"pass-fail":return Pt.getFieldCreationSchema(e);case"otp":return Dt.getFieldCreationSchema(e);case"rating":return Bt.getFieldCreationSchema(e);default:return}},bs=m.memo(r=>{const{popoverInputs:e,hasError:t,...n}=r;return f.jsxs(v.Popover.Root,{children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:f.jsxs(v.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...t&&{color:Ur.danger},children:[f.jsx(v.LuIcon,{icon:xl}),"Settings"]},"settings")}),f.jsx(v.Popover.Content,{size:"sm",...n,children:f.jsx("div",{className:"flex w-full max-w-[350px] flex-col",children:e})})]})});bs.displayName="FieldSettingsPopover";const Ns=m.memo(r=>{const{parentPath:e,fieldIndex:t,field:n}=r,{errors:i}=rt.useFormikContext(),a=Gr(),{disableRequiredFields:o}=m.use(yn),[s,l]=m.useState(void 0);m.useEffect(()=>{n.image instanceof Promise?n.image.then(l).catch(console.error):l(n.image)},[n]);const u=s?URL.createObjectURL(s):void 0,c=m.useCallback(()=>{n.setOptions({image:void 0})},[n]),[d,p]=m.useMemo(()=>{const A=[],E=[],I=Os(n.type,`${e}.${t}`)??[];for(const N of I)N.showDirectly?A.push(N.field):E.push(N.field);return[A,E]},[n,e,t]),h=ur(d,{formId:xn,disabled:!1,size:"sm"}),g=ur(p,{formId:xn,disabled:!1,size:"sm"}),x=p.length>0,C=p.some(A=>{const E=_n(i,A.identifier);return E&&(typeof E!="object"||Object.values(E).length>0)}),_=m.useCallback(()=>{s&&a(()=>({file:s}))},[a,s]),{fieldTypeName:w}=sn[n.type];return f.jsxs("div",{className:"flex grow w-full flex-col gap-4",children:[f.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[f.jsxs("div",{className:"flex gap-2 items-center",children:[f.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),w]}),!o&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(v.Checkbox.Root,{checked:n.required,onCheckedChange:A=>n.setOptions({required:!!A}),size:"sm",children:f.jsx(v.Checkbox.Indicator,{children:f.jsx(v.LuIcon,{icon:Ge})})}),f.jsx(v.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),x&&f.jsx(bs,{popoverInputs:g,hasError:C,align:"end"})]}),s&&f.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[f.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:u,alt:s.name,onClick:_}),f.jsx(v.IconButton,{type:"button",className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:c,size:"sm",children:f.jsx(v.LuIcon,{icon:ht})})]}),f.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[f.jsx(v.Input.Root,{variant:"outline",size:"md",children:f.jsx(v.Input.Field,{placeholder:"Enter your question",value:n.label??"",onChange:A=>n.setOptions({label:A.target.value}),maxLength:200})}),f.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:n.description??"",onChange:A=>n.setOptions({description:A.target.value}),maxLength:1e3,resize:"vertical",size:"md"})]}),d.length>0&&f.jsx("div",{className:"w-full",children:h})]})});Ns.displayName="FieldBuilder";const Xi=m.memo(r=>{const{field:e,fieldSection:t,fieldIndex:n,sectionIndex:i}=r,a=m.useRef(null),o=`fields.${i}.fields`,s=m.useCallback(x=>{t.addField(wn(x),n+1)},[n,t]),l=m.useCallback(()=>{t.addField(e.duplicate(G.v4()))},[e,t]),u=m.useCallback(x=>{const C=x==="up"?i-1:i+1;t.moveField(n,C)},[t,n,i]),c=m.useCallback(x=>{const{files:C}=x.target;if(!C||C.length!==1)return;const _=C.item(0);if(_){if(_.size>wo){v.toast.error({title:"File upload error",description:`The file ${_.name} exceeded the maximum file size`});return}e.setOptions({image:_})}},[e]),d=m.useCallback(()=>{u("up")},[u]),p=m.useCallback(()=>{u("down")},[u]),h=m.useCallback(()=>{var x;(x=a.current)==null||x.click()},[]),g=m.useCallback(()=>{t.removeField(e)},[e,t]);return f.jsxs(v.Card,{className:"flex items-center justify-between gap-4 w-full",children:[f.jsx(Ns,{fieldIndex:n,field:e,parentPath:o}),f.jsxs(v.ButtonGroup,{className:"flex-col gap-0.5 flex",variant:"ghost",accentColor:"base",size:"sm",children:[f.jsx(Cn,{onSelectFieldType:s,size:"sm",children:f.jsx(v.IconButton,{type:"button",children:f.jsx(v.LuIcon,{icon:je})})}),f.jsx(v.IconButton,{type:"button",onClick:d,children:f.jsx(v.LuIcon,{icon:sa})}),f.jsx(v.IconButton,{type:"button",onClick:p,children:f.jsx(v.LuIcon,{icon:oa})}),f.jsx(v.IconButton,{type:"button",onClick:l,children:f.jsx(v.LuIcon,{icon:En})}),f.jsx(v.IconButton,{type:"button",onClick:h,children:f.jsx(v.LuIcon,{icon:ul})}),f.jsx(v.IconButton,{type:"button",onClick:g,children:f.jsx(v.LuIcon,{icon:ht})})]}),f.jsx("input",{className:"hidden",ref:a,type:"file",accept:"image/*",onChange:c})]})});Xi.displayName="FieldBuilderWithActions";const $i=m.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fields:a,onSelectField:o,...s}=r;return f.jsxs(v.Menu.Root,{...s,children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:f.jsx(v.Menu.Scroll,{children:a.map(l=>f.jsxs(v.Menu.Item,{onSelect:()=>o(l),children:[f.jsx(v.LuIcon,{icon:fe[l.type]}),l.label||Ie]},l.identifier))})})]})});$i.displayName="IssueDataFilterMenu";const Ts=m.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fieldSections:a,onSelectFieldCondition:o,...s}=r;return f.jsxs(v.Menu.Root,{...s,children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:a.map(l=>f.jsxs(v.Menu.Item,{onSelect:()=>o(l),children:[f.jsx(v.LuIcon,{icon:fe[l.type]}),l.label||Ei]},l.identifier))})]})});Ts.displayName="IssueDataFilterMenu";const Ds=m.memo(r=>{const{id:e,sourceX:t,sourceY:n,targetX:i,targetY:a,style:o,markerEnd:s,data:l}=r,{targetSection:u,sourceSection:c,layoutDirection:d}=l,p=m.useMemo(()=>c.getConditions(u.identifier),[c,u.identifier]),h=m.useCallback(()=>{c.removeConditional(u.identifier)},[c,u.identifier]),g=m.useCallback(A=>{c.addCondition(u.identifier,qi(A))},[c,u.identifier]),x=m.useCallback(A=>{c.removeCondition(u.identifier,A)},[c,u.identifier]),[C,_,w]=de.getBezierPath({sourceX:t,sourceY:n,sourcePosition:d==="LR"?de.Position.Right:de.Position.Bottom,targetX:i,targetY:a,targetPosition:d==="LR"?de.Position.Left:de.Position.Top});return f.jsxs(f.Fragment,{children:[f.jsx(de.BaseEdge,{id:e,path:C,style:o,markerEnd:s,labelX:_,labelY:w}),f.jsx(de.EdgeLabelRenderer,{children:f.jsxs(v.Card,{size:"xs",variant:"surface",className:"absolute nodrag nopan pointer-events-auto inline-flex flex-col gap-2 bg-(--base-2)",onMouseDown:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${_}px, ${w}px)`},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(v.Text,{size:"xs",className:"truncate max-w-[280px]",children:c.label||"Untitled section"}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsx($i,{fields:c.fields,onSelectField:g,children:f.jsx(v.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:f.jsx(v.LuIcon,{icon:je})})}),f.jsxs(v.Tooltip.Root,{children:[f.jsx(v.Tooltip.Trigger,{asChild:!0,children:f.jsx(v.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:h,children:f.jsx(v.LuIcon,{icon:ht})})}),f.jsx(v.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),p.length>0&&f.jsx("div",{className:"flex flex-col h-max w-full flex-wrap gap-1",children:p.map(A=>f.jsx(m.Fragment,{children:A.render({onRemove:x})},A.id))})]})})]})});Ds.displayName="FieldSectionConditionEdgeComponent";const Ms=m.memo(r=>{const{data:e,selected:t}=r,{fieldSection:n,index:i,layoutDirection:a}=e,o=m.use(St),s=m.useCallback(()=>{o.removeFieldSection(n)},[o,n]),l=m.useCallback(d=>{n.addField(wn(d))},[n]),u=m.useCallback(()=>{const d=new He({identifier:G.v4(),fields:[]});o.addFieldSection(d),n.addConditional(d.identifier)},[o,n]),c=m.useCallback(()=>{o.addFieldSection(n.duplicate(G.v4()))},[o,n]);return f.jsxs(v.Card,{variant:"surface",className:"cursor-pointer relative bg-(--base-2)","data-selected":t?"true":void 0,children:[f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[f.jsx(v.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:f.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:n.label??"",onChange:d=>n.setOptions({label:d.target.value}),maxLength:200})}),f.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:n.description??"",onChange:d=>n.setOptions({description:d.target.value}),maxLength:1e3,resize:"vertical",size:"md"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(v.Text,{weight:"bold",children:"Fields"}),f.jsx(Cn,{onSelectFieldType:l,size:"sm",children:f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:je})," Add field"]})})]}),f.jsx("div",{className:"flex flex-col gap-3",children:n.fields.map((d,p)=>f.jsx(Xi,{field:d,fieldSection:n,fieldIndex:p,sectionIndex:i},d.identifier))})]}),f.jsx(de.NodeToolbar,{isVisible:!0,position:de.Position.Right,align:"start",offset:8,onMouseDown:d=>d.stopPropagation(),children:f.jsx(v.Card,{variant:"surface",className:"flex flex-col items-center gap-1 p-1 bg-(--base-2)",size:"xs",onClick:d=>d.stopPropagation(),children:f.jsxs(v.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[f.jsx(v.IconButton,{type:"button",onClick:u,children:f.jsx(v.LuIcon,{icon:sl})}),f.jsx(v.IconButton,{type:"button",onClick:c,children:f.jsx(v.LuIcon,{icon:En})}),f.jsx(v.IconButton,{type:"button",onClick:s,children:f.jsx(v.LuIcon,{icon:ht})})]})})}),f.jsx(de.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?de.Position.Left:de.Position.Top}),f.jsx(de.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?de.Position.Right:de.Position.Bottom})]})});Ms.displayName="CustomNode";const Cf={fieldSection:Ms},wf={fieldSectionCondition:Ds},mf=(r,e,t)=>{const n=new Ki.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return n.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(i=>n.setEdge(i.source,i.target,{width:500,height:200,labelpos:"c"})),r.forEach(i=>{var a,o;return n.setNode(i.id,{...i,width:((a=i.measured)==null?void 0:a.width)??0,height:((o=i.measured)==null?void 0:o.height)??0})}),Ki.layout(n),[r.map(i=>{var l,u;const a=n.node(i.id),o=a.x-(((l=i.measured)==null?void 0:l.width)??0)/2,s=a.y-(((u=i.measured)==null?void 0:u.height)??0)/2;return{...i,position:{x:o,y:s}}}),e]},_f={hideAttribution:!0},Fs=m.memo(()=>{const{handleSubmit:r,errors:e}=rt.useFormikContext(),{onCancel:t}=m.use(yn),n=m.use(St),i=m.useRef(null),[a,o]=m.useState(),[s,l]=m.useState("TB");m.useLayoutEffect(()=>{i.current&&i.current.classList.remove("light")},[]);const u=m.useMemo(()=>n.fieldSections.map((N,D)=>({id:N.identifier,position:{x:0,y:0},data:{index:D,fieldSection:N,layoutDirection:s},draggable:!0,type:"fieldSection"})),[n.fieldSections,s]),c=m.useMemo(()=>{const N=[],D={};for(const M of n.fieldSections)D[M.identifier]=M;for(const M of n.fieldSections){const F=M.conditions;for(const[V,j]of Object.entries(F))N.push({id:`${M.identifier}-${V}`,source:M.identifier,target:V,data:{targetSection:D[V],sourceSection:M,layoutDirection:s},animated:j.length>0,markerEnd:de.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return N},[n.fieldSections,s]),[d,p,h]=de.useNodesState(u),[g,x,C]=de.useEdgesState(c);m.useEffect(()=>{p(u)},[u,p]),m.useEffect(()=>{x(c)},[c,x]);const[_,w]=m.useMemo(()=>mf(d,g,s),[g,s,d]),A=m.useCallback(()=>{n.addFieldSection(new He({identifier:G.v4(),fields:[]}))},[n]),E=m.useCallback(N=>{const{source:D,target:M}=N,F=n.fieldSections.find(({identifier:V})=>V===D);F.setOptions({conditions:{...F.conditions,[M]:[]}})},[n.fieldSections]),I=m.useCallback(N=>{const D=n.getSectionDependencyGraph();return!ji.willCreateCycle(D,N.source,N.target)},[n]);return f.jsxs("form",{className:"size-full flex flex-col gap-4",id:xn,onSubmit:r,children:[f.jsxs(v.Card,{className:"size-full relative",variant:"outline",children:[f.jsx(de.ReactFlow,{ref:i,onInit:o,nodes:_,onNodesChange:h,edges:w,onEdgesChange:C,nodeTypes:Cf,edgeTypes:wf,onConnect:E,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:I,proOptions:_f}),f.jsx(de.Panel,{position:"top-left",children:f.jsx(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:f.jsxs(v.Button,{type:"button",variant:"surface",onClick:A,children:[f.jsx(v.LuIcon,{icon:je})," Add section"]})})}),f.jsxs(de.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[f.jsxs(v.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:s,onValueChange:l,children:[f.jsx(v.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:f.jsx(v.LuIcon,{icon:Ks})}),f.jsx(v.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:f.jsx(v.LuIcon,{icon:Zs})})]}),f.jsx(v.Separator,{size:"sm"}),f.jsxs(v.ButtonGroup,{className:"flex flex-col ",size:"sm",accentColor:"base",variant:"soft",children:[f.jsx(v.IconButton,{className:"rounded-b-none",onClick:()=>a==null?void 0:a.zoomIn(),type:"button",children:f.jsx(v.LuIcon,{icon:je})}),f.jsx(v.IconButton,{onClick:()=>a==null?void 0:a.zoomOut(),radius:"none",type:"button",children:f.jsx(v.LuIcon,{icon:Rr})}),f.jsx(v.IconButton,{className:"rounded-t-none",onClick:()=>a==null?void 0:a.fitView(),type:"button",children:f.jsx(v.LuIcon,{icon:Cl})})]})]}),f.jsx(de.Panel,{position:"bottom-right",children:f.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[t&&f.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:t,children:"Cancel"}),f.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!e.fields&&f.jsx(v.Text,{size:"xs",accentColor:"danger",children:typeof e.fields=="string"&&e.fields})]})});Fs.displayName="FormBuilderFlowBuilder";const Ps=m.memo(r=>{const{sourceFieldSection:e,targetFieldSection:t}=r,n=m.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),i=m.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),a=m.useCallback(s=>{e.addCondition(t.identifier,qi(s))},[e,t.identifier]),o=m.useCallback(s=>{e.removeCondition(t.identifier,s)},[e,t.identifier]);return f.jsxs(v.Card,{className:"flex flex-col gap-2",children:[f.jsxs(v.ButtonGroup,{className:"justify-between gap-2 flex",size:"sm",accentColor:"base",variant:"soft",children:[f.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[f.jsx(v.LuIcon,{icon:fe.section}),e.label??Ei]}),f.jsx(v.IconButton,{type:"button",onClick:i,variant:"ghost",children:f.jsx(v.LuIcon,{icon:ht})})]}),f.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[n.map(s=>s.render({onRemove:o})),f.jsx($i,{fields:e.fields,onSelectField:a,align:"start",children:f.jsx(v.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:f.jsx(v.LuIcon,{icon:je})})})]})]})});Ps.displayName="FieldSectionConditionalItem";const Vs=m.memo(r=>{const{fieldSection:e}=r,t=m.use(St),n=m.useMemo(()=>t.fieldSections.filter(o=>e.identifier in o.conditions),[t.fieldSections,e.identifier]),i=m.useCallback(o=>{o.addConditional(e.identifier)},[e.identifier]),a=m.useMemo(()=>{const o=t.getSectionDependencyGraph();return t.fieldSections.filter(s=>!ji.willCreateCycle(o,s.identifier,e.identifier))},[e.identifier,t]);return f.jsxs("div",{className:"flex grow w-full flex-col gap-4",children:[f.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[f.jsx(v.Input.Root,{variant:"outline",size:"md",children:f.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:o=>e.setOptions({label:o.target.value}),maxLength:200})}),f.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:o=>e.setOptions({description:o.target.value}),maxLength:1e3,resize:"vertical",size:"md"})]}),f.jsx(v.Separator,{size:"full"}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex gap-2 justify-between",children:[f.jsx(v.Text,{accentColor:"base",children:"Conditions"}),f.jsx(Ts,{fieldSections:a,onSelectFieldCondition:i,children:f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[f.jsx(v.LuIcon,{icon:je}),"Add condition"]})})]}),n.map(o=>f.jsx(Ps,{sourceFieldSection:o,targetFieldSection:e},o.identifier))]}),f.jsx(v.Separator,{size:"full"})]})});Vs.displayName="FieldSectionBuilder";const Bs=m.memo(r=>{const{fieldSection:e,sectionIndex:t}=r,n=m.use(St),i=v.useAlertDialog(),a=m.useCallback(()=>{n.removeFieldSection(e)},[n,e]),o=m.useCallback(x=>{const C=x==="up"?t-1:t+1;n.moveFieldSection(t,C)},[n,t]),s=m.useCallback(()=>{n.addFieldSection(e.duplicate(G.v4()))},[n,e]),l=m.useCallback(x=>{e.addField(wn(x))},[e]),u=m.useCallback(()=>{o("up")},[o]),c=m.useCallback(()=>{o("down")},[o]),d=m.useCallback(async()=>{const x=[e.serialize()],C=dt.reseedFieldSections(x,{conditions:!1}),_=JSON.stringify(C);await navigator.clipboard.writeText(_),v.toast.success({title:"Section copied"})},[e]),p=m.useCallback(async()=>{const C=n.getDependenciesOfSection(e.identifier).map(A=>A.serialize()),_=dt.reseedFieldSections(C,{conditions:!0}),w=JSON.stringify(_);await navigator.clipboard.writeText(w),v.toast.success({title:"Section copied"})},[e,n]),h=m.useCallback(async()=>{const x=n.getDependenciesOfSection(e.identifier),C=x.length>1,_=x.length-1;C?i({title:"Copy section dependencies?",description:`This section has ${_} dependent section${_>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:p,cancel:"Dont include",onCancel:d}):d()},[e,n,i,p,d]),g=m.useCallback(async()=>{let x="";try{x=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const C=x.trim();if(!C){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let _;try{_=JSON.parse(C)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const w=Array.isArray(_)?_:[_],A=[];for(const E of w){if(!E||typeof E!="object")continue;const I=E;if(I.type!=="section"||!Array.isArray(I.fields))continue;const N={type:"section",identifier:typeof I.identifier=="string"?I.identifier:G.v4(),label:typeof I.label=="string"||I.label===null?I.label:null,description:typeof I.description=="string"||I.description===null?I.description:null,conditions:I.conditions&&typeof I.conditions=="object"?I.conditions:{},fields:I.fields};try{A.push(He.deserialize(N))}catch{}}if(A.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}A.forEach((E,I)=>{n.addFieldSection(E,t+1+I)}),v.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[n,t]);return f.jsxs(v.Card,{variant:"outline",className:"flex items-center justify-between gap-4 w-full",children:[f.jsxs("div",{className:"flex grow flex-col gap-4 w-full",children:[f.jsx(Vs,{fieldSection:e}),f.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[f.jsxs("div",{className:"flex gap-2 justify-between",children:[f.jsx(v.Text,{accentColor:"base",size:"md",children:"Fields"}),f.jsx(Cn,{onSelectFieldType:l,size:"sm",children:f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",children:[f.jsx(v.LuIcon,{icon:je})," Add field"]})})]}),e.fields.map((x,C)=>f.jsx(Xi,{field:x,fieldSection:e,fieldIndex:C,sectionIndex:t},x.identifier))]})]}),f.jsxs(v.ButtonGroup,{className:"flex-col gap-0.5 flex",variant:"ghost",accentColor:"base",size:"sm",children:[f.jsx(v.IconButton,{type:"button",onClick:u,children:f.jsx(v.LuIcon,{icon:sa})}),f.jsx(v.IconButton,{type:"button",onClick:c,children:f.jsx(v.LuIcon,{icon:oa})}),f.jsxs(v.Menu.Root,{align:"end",children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.IconButton,{type:"button",children:f.jsx(v.LuIcon,{icon:ia})})}),f.jsxs(v.Menu.Content,{size:"sm",children:[f.jsxs(v.Menu.Item,{onSelect:s,children:[f.jsx(v.LuIcon,{icon:En}),"Duplicate section"]}),f.jsxs(v.Menu.Item,{onSelect:h,children:[f.jsx(v.LuIcon,{icon:ta}),"Copy JSON"]}),f.jsxs(v.Menu.Item,{onSelect:g,children:[f.jsx(v.LuIcon,{icon:ra}),"Paste JSON"]}),f.jsxs(v.Menu.Item,{onSelect:a,children:[f.jsx(v.LuIcon,{icon:ht}),"Delete section"]})]})]})]})]})});Bs.displayName="FieldSectionWithActions";const Ls=m.memo(()=>{const{handleSubmit:r,errors:e}=rt.useFormikContext(),{onCancel:t}=m.use(yn),n=m.use(St),i=m.useCallback(()=>{n.addFieldSection(new He({identifier:G.v4(),fields:[]}))},[n]),a=m.useCallback(async()=>{try{const s=n.serialize(),l=dt.reseedFieldSections(s),u=JSON.stringify(l);await navigator.clipboard.writeText(u),v.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{v.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[n]),o=m.useCallback(async()=>{let s="";try{s=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const l=s.trim();if(!l){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let u;try{u=JSON.parse(l)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const c=Array.isArray(u)?u:[u],d=[];for(const h of c){if(!h||typeof h!="object")continue;const g=h;if(g.type!=="section"||!Array.isArray(g.fields))continue;const x={type:"section",identifier:typeof g.identifier=="string"?g.identifier:G.v4(),label:typeof g.label=="string"||g.label===null?g.label:null,description:typeof g.description=="string"||g.description===null?g.description:null,conditions:g.conditions&&typeof g.conditions=="object"?g.conditions:{},fields:g.fields};try{d.push(He.deserialize(x))}catch{}}if(d.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const p=n.fieldSections.length;d.forEach((h,g)=>{n.addFieldSection(h,p+g)}),v.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[n]);return f.jsxs("form",{className:"flex flex-col gap-4",id:xn,onSubmit:r,children:[f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:a,children:[f.jsx(v.LuIcon,{icon:ta})," Copy JSON"]}),f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:o,children:[f.jsx(v.LuIcon,{icon:ra})," Paste JSON"]})]}),n.fieldSections.map((s,l)=>f.jsx(Bs,{fieldSection:s,sectionIndex:l},s.identifier)),f.jsxs(v.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:i,children:[f.jsx(v.LuIcon,{icon:je})," Add section"]})]}),!!e.fields&&f.jsx(v.Text,{size:"xs",accentColor:"danger",children:typeof e.fields=="string"&&e.fields}),f.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[t&&f.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:t,children:"Cancel"}),f.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});Ls.displayName="FormBuilderListBuilder";const zs=m.memo(m.forwardRef((r,e)=>{const{readonly:t=!1,fieldSchema:n,values:i={},onValuesChange:a,onSubmit:o,submitText:s="Submit",hideSubmit:l=!1,cancelText:u,onCancel:c,hideCancel:d=!1,onDirty:p,onDirtyChange:h,className:g,buttonProps:x,enableReinitialize:C=!1,excludeUnchangedFields:_=!1,size:w="md"}=r,A=m.useId(),E=m.useMemo(()=>n.initializeValues(i),[n,i]),I=m.useCallback(U=>{o==null||o(_?n.changedFieldValues(E,U):U)},[_,E,o,n]),N=rt.useFormik({initialValues:E,onSubmit:I,validate:U=>n.validateValues(U),validateOnBlur:!1,validateOnChange:!1,enableReinitialize:!1});m.useLayoutEffect(()=>{C&&N.resetForm({values:E})},[C,E]);const{dirty:D}=N,M=m.useCallback((U,ae)=>{xs(gs(n.getFieldSections()))[U].areValuesEqual(E[U],ae)||a==null||a({...N.values,[U]:ae},{[U]:ae})},[N.values,E,a,n]),F=m.useMemo(()=>({formId:A,disabled:t,onValuesChange:M,size:w}),[A,M,t,w]),V=ur(n.getFieldSections(),F);m.useEffect(()=>{D&&p&&p(),h&&h(D)},[D,p,h]);const j=m.useMemo(()=>({fieldSchema:n,size:w}),[n,w]),R=!d&&!!c,Z=!l;return f.jsx(rt.FormikProvider,{value:N,children:f.jsx(Is,{value:j,children:f.jsxs("form",{id:A,ref:e,className:or.cx(g,"flex flex-col gap-4"),onSubmit:N.handleSubmit,children:[V,!t&&(R||Z)?f.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[R?f.jsxs(v.Button,{accentColor:"base",...x,type:"button",variant:"soft",onClick:c,children:[f.jsx(v.LuIcon,{icon:nt}),u]}):null,Z?f.jsxs(v.Button,{...x,type:"submit",accentColor:"primary",variant:"surface",children:[f.jsx(v.LuIcon,{icon:Ge}),s]}):null]}):null]})})})})),ks=m.memo(()=>{const r=m.use(St);return f.jsx(zs,{fieldSchema:r,readonly:!1})});ks.displayName="FormBuilderPreview";const Rs=m.memo(r=>{const{children:e,initialFields:t,onSave:n,onCancel:i,enableReinitialize:a=!1,disableRequiredFields:o=!1}=r,s=m.useCallback(h=>{var w;const g={};(!h.fields||h.fields.length===0)&&(g.fields="At least one field is required.");const x=[];for(const[A,E]of h.fields.entries())for(const[I,N]of E.fields.entries()){const D=((w=Os(N.type,`fields.${A}.fields.${I}`))==null?void 0:w.map(({field:M})=>M))??[];x.push(...D)}const C={};for(const A of x)C[A.identifier]=_n(h,A.identifier);const _=Gi(x,C);if(_&&(g.fields=_.fields),Object.keys(g).length>0)return v.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),g},[]),l=m.useMemo(()=>({fields:t??[]}),[t]),u=rt.useFormik({initialValues:l,validate:s,onSubmit:n,validateOnChange:!1,validateOnBlur:!1,enableReinitialize:a}),c=m.useCallback(h=>{u.setFieldValue("fields",h.serialize())},[u]),d=m.useMemo(()=>{const h=dt.deserialize(u.values.fields);return h.observe(c),h},[u.values.fields,c]),p=m.useMemo(()=>({disableRequiredFields:o,onCancel:i}),[o,i]);return f.jsx(yn,{value:p,children:f.jsx(St,{value:d,children:f.jsx(rt.FormikProvider,{value:u,children:e})})})});Rs.displayName="FormBuilderRoot";const Af={Root:Rs,FlowBuilder:Fs,ListBuilder:Ls,Preview:ks};S.BaseCondition=Me,S.BaseField=Pe,S.BaseFormElement=On,S.BaseOptionsField=cr,S.BaseStringField=Mn,S.BooleanEqualsConditionModifier=mo,S.BooleanField=bt,S.BooleanFieldCondition=Sr,S.BooleanFieldConditionCell=zo,S.BooleanFieldInput=Tn,S.BooleanNotEqualsConditionModifier=_o,S.CheckboxListField=Tt,S.CheckboxListFieldCondition=Ir,S.CheckboxListFieldConditionCell=Ro,S.CheckboxListFieldInput=Fn,S.ConditionManager=pn,S.DateAfterConditionModifier=Io,S.DateBeforeConditionModifier=So,S.DateEqualsConditionModifier=Ao,S.DateField=dr,S.DateFieldCondition=Or,S.DateFieldConditionCell=Go,S.DateFieldInput=Pn,S.DateNotEqualsConditionModifier=Eo,S.DateRangeInConditionModifier=Oo,S.DateRangeNotInConditionModifier=bo,S.DoesNotHaveFilesConditionModifier=To,S.FieldSchema=dt,S.FieldSection=He,S.FieldSectionLayout=Hi,S.FieldTypeToClsMapping=sn,S.FieldsRenderer=zs,S.FileCard=In,S.FormBuilder=Af,S.HasFilesConditionModifier=No,S.ImageCard=ha,S.ImageFile=Hr,S.ImageViewer=bn,S.ImageViewerProvider=da,S.InputWithHelpText=Oe,S.InputWithLabel=be,S.LONG_TEXT_FIELD_MAX_LENGTH=Nt,S.MultiSelectField=it,S.MultiSelectFieldCondition=br,S.MultiSelectFieldConditionCell=qo,S.MultiSelectFieldInput=Vn,S.MultiStringField=Ot,S.MultiStringFieldCondition=Nr,S.MultiStringFieldConditionCell=$o,S.MultiStringFieldInput=Nn,S.NumberEqualsConditionModifier=Si,S.NumberField=qe,S.NumberFieldCondition=Tr,S.NumberFieldConditionCell=jo,S.NumberFieldInput=Dn,S.NumberGreaterThanConditionModifier=Ni,S.NumberGreaterThanOrEqualsConditionModifier=Ti,S.NumberLessThanConditionModifier=Oi,S.NumberLessThanOrEqualsConditionModifier=bi,S.NumberNotEqualsConditionModifier=Ii,S.NumberRangeInConditionModifier=Di,S.NumberRangeNotInConditionModifier=Mi,S.OTPField=Dt,S.OTPFieldCondition=Dr,S.OTPFieldConditionCell=Zo,S.OTPFieldInput=Ln,S.Observable=lr,S.PassFailArrayExcludesConditionModifier=Po,S.PassFailArrayIncludesConditionModifier=Fo,S.PassFailEqualsConditionModifier=Do,S.PassFailField=Pt,S.PassFailFieldCondition=Mr,S.PassFailFieldConditionCell=Qo,S.PassFailFieldInput=kn,S.PassFailNotEqualsConditionModifier=Mo,S.RadioField=Vt,S.RadioFieldCondition=Fr,S.RadioFieldConditionCell=es,S.RadioFieldInput=Un,S.RatingField=Bt,S.RatingFieldCondition=Pr,S.RatingFieldConditionCell=rs,S.RatingFieldInput=Gn,S.SEVERITY_COLOR_MAPPING=Ur,S.SHORT_TEXT_FIELD_MAX_LENGTH=on,S.ScanField=wr,S.ScanFieldCondition=Vr,S.ScanFieldConditionCell=is,S.ScanFieldInput=wi,S.Scanner=an,S.ScannerProvider=yo,S.SelectField=pt,S.SelectFieldCondition=Br,S.SelectFieldConditionCell=os,S.SelectFieldInput=Bn,S.StringArrayEqualsConditionModifier=dn,S.StringArrayEveryConditionModifier=ln,S.StringArrayExcludesConditionModifier=Pi,S.StringArrayIncludesConditionModifier=Fi,S.StringArrayNoneConditionModifier=cn,S.StringArrayNotEqualsConditionModifier=fn,S.StringArraySomeConditionModifier=un,S.StringEqualsConditionModifier=mt,S.StringExcludesConditionModifier=_r,S.StringField=Gt,S.StringFieldCondition=Lr,S.StringFieldConditionCell=ls,S.StringFieldInput=mi,S.StringIncludesConditionModifier=mr,S.StringNotEqualsConditionModifier=_t,S.TextField=Ht,S.TextFieldCondition=zr,S.TextFieldConditionCell=cs,S.TextFieldInput=_i,S.UNLABELLED_FIELD_LABEL=Ie,S.UNLABELLED_SECTION_LABEL=Ei,S.UUIDFile=at,S.UUIDPromise=Ft,S.UploadField=qt,S.UploadFieldCondition=kr,S.UploadFieldConditionCell=fs,S.UploadFieldInput=Ai,S.areFieldValuesBlank=Ss,S.areFieldValuesEqual=Ri,S.areFileAndPromiseArraysEqual=qr,S.arePassFieldValuesEqual=ya,S.areSerializedPassFailFieldValuesEqual=Ca,S.awaitFilesAndPromises=xf,S.blankFieldValues=Ui,S.changedFieldValues=As,S.cleanFieldValues=gn,S.cleanSerializedFieldValues=ki,S.createCondition=qi,S.createConditionModifierConfig=L,S.createField=wn,S.deserialize=vs,S.deserializeCondition=ps,S.deserializeConditions=zi,S.deserializeField=vn,S.deserializeFieldValues=Cs,S.deserializeFields=ff,S.deserializeOnlyFields=hf,S.deserializePassFailFieldValue=xa,S.extractFilesAndPromisesFromFieldValues=ws,S.fieldIcons=fe,S.flattenFields=gs,S.getFieldsMapping=xs,S.initializeFieldValues=_s,S.insertFilesAndPromisesToFieldValues=ms,S.isFileAndPromiseArray=fa,S.isPassFailFieldStatus=Rn,S.isPassFailFieldValue=va,S.isSerializedPassFailFieldValue=pa,S.isStringArray=sr,S.maxFileSizeB=wo,S.maxFileSizeKB=Co,S.maxFileSizeMB=Xt,S.passFailFieldStatusMapping=vt,S.passFailFieldStatuses=Mt,S.separateImagesFromFields=gf,S.serializeFieldValues=ys,S.serializePassFailFieldValue=ga,S.unchangedFieldValues=Es,S.useConditionManager=cf,S.useFieldInput=ml,S.useFieldInputs=ur,S.useFormikInput=Ne,S.useImageViewer=Gr,S.useObjectUrl=ca,S.useScanner=_l,S.validateFields=Gi,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
255
+ `),n=po.singletonList(af.INITIAL_STATE),i=0;i<this.text.length;i++){var a=void 0,o=i+1<this.text.length?this.text[i+1]:0;switch(this.text[i]){case W.getCharCode("\r"):a=o===t?2:0;break;case W.getCharCode("."):a=o===e?3:0;break;case W.getCharCode(","):a=o===e?4:0;break;case W.getCharCode(":"):a=o===e?5:0;break;default:a=0}a>0?(n=r.updateStateListForPair(n,i,a),i++):n=this.updateStateListForChar(n,i)}var s=po.min(n,function(l,u){return l.getBitCount()-u.getBitCount()});return s.toBitArray(this.text)},r.prototype.updateStateListForChar=function(e,t){var n,i,a=[];try{for(var o=nn(e),s=o.next();!s.done;s=o.next()){var l=s.value;this.updateStateForChar(l,t,a)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r.simplifyStates(a)},r.prototype.updateStateForChar=function(e,t,n){for(var i=this.text[t]&255,a=Ci[e.getMode()][i]>0,o=null,s=0;s<=et;s++){var l=Ci[s][i];if(l>0){if(o==null&&(o=e.endBinaryShift(t)),!a||s===e.getMode()||s===We){var u=o.latchAndAppend(s,l);n.push(u)}if(!a&&go[e.getMode()][s]>=0){var c=o.shiftAndAppend(s,l);n.push(c)}}}if(e.getBinaryShiftByteCount()>0||Ci[e.getMode()][i]===0){var d=e.addBinaryShiftChar(t);n.push(d)}},r.updateStateListForPair=function(e,t,n){var i,a,o=[];try{for(var s=nn(e),l=s.next();!l.done;l=s.next()){var u=l.value;this.updateStateForPair(u,t,n,o)}}catch(c){i={error:c}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return this.simplifyStates(o)},r.updateStateForPair=function(e,t,n,i){var a=e.endBinaryShift(t);if(i.push(a.latchAndAppend(et,n)),e.getMode()!==et&&i.push(a.shiftAndAppend(et,n)),n===3||n===4){var o=a.latchAndAppend(We,16-n).latchAndAppend(We,1);i.push(o)}if(e.getBinaryShiftByteCount()>0){var s=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);i.push(s)}},r.simplifyStates=function(e){var t,n,i,a,o=[];try{for(var s=nn(e),l=s.next();!l.done;l=s.next()){var u=l.value,c=!0,d=function(C){if(C.isBetterThanOrEqualTo(u))return c=!1,"break";u.isBetterThanOrEqualTo(C)&&(o=o.filter(function(_){return _!==C}))};try{for(var p=(i=void 0,nn(o)),h=p.next();!h.done;h=p.next()){var g=h.value,x=d(g);if(x==="break")break}}catch(C){i={error:C}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}c&&o.push(u)}}catch(C){t={error:C}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},r}(),lf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};(function(){function r(){}return r.encodeBytes=function(e){return r.encode(e,r.DEFAULT_EC_PERCENT,r.DEFAULT_AZTEC_LAYERS)},r.encode=function(e,t,n){var i=new sf(e).encode(),a=X.truncDivision(i.getSize()*t,100)+11,o=i.getSize()+a,s,l,u,c,d;if(n!==r.DEFAULT_AZTEC_LAYERS){if(s=n<0,l=Math.abs(n),l>(s?r.MAX_NB_BITS_COMPACT:r.MAX_NB_BITS))throw new k(W.format("Illegal value %s for layers",n));u=r.totalBitsInLayer(l,s),c=r.WORD_SIZE[l];var p=u-u%c;if(d=r.stuffBits(i,c),d.getSize()+a>p)throw new k("Data to large for user specified layer");if(s&&d.getSize()>c*64)throw new k("Data to large for user specified layer")}else{c=0,d=null;for(var h=0;;h++){if(h>r.MAX_NB_BITS)throw new k("Data too large for an Aztec code");if(s=h<=3,l=s?h+1:h,u=r.totalBitsInLayer(l,s),!(o>u)){(d==null||c!==r.WORD_SIZE[l])&&(c=r.WORD_SIZE[l],d=r.stuffBits(i,c));var p=u-u%c;if(!(s&&d.getSize()>c*64)&&d.getSize()+a<=p)break}}}var g=r.generateCheckWords(d,u,c),x=d.getSize()/c,C=r.generateModeMessage(s,l,x),_=(s?11:14)+l*4,w=new Int32Array(_),A;if(s){A=_;for(var h=0;h<w.length;h++)w[h]=h}else{A=_+1+2*X.truncDivision(X.truncDivision(_,2)-1,15);for(var E=X.truncDivision(_,2),I=X.truncDivision(A,2),h=0;h<E;h++){var N=h+X.truncDivision(h,15);w[E-h-1]=I-N-1,w[E+h]=I+N+1}}for(var D=new Je(A),h=0,M=0;h<l;h++){for(var F=(l-h)*4+(s?9:12),V=0;V<F;V++)for(var j=V*2,R=0;R<2;R++)g.get(M+j+R)&&D.set(w[h*2+R],w[h*2+V]),g.get(M+F*2+j+R)&&D.set(w[h*2+V],w[_-1-h*2-R]),g.get(M+F*4+j+R)&&D.set(w[_-1-h*2-R],w[_-1-h*2-V]),g.get(M+F*6+j+R)&&D.set(w[_-1-h*2-V],w[h*2+R]);M+=F*8}if(r.drawModeMessage(D,s,A,C),s)r.drawBullsEye(D,X.truncDivision(A,2),5);else{r.drawBullsEye(D,X.truncDivision(A,2),7);for(var h=0,V=0;h<X.truncDivision(_,2)-1;h+=15,V+=16)for(var R=X.truncDivision(A,2)&1;R<A;R+=2)D.set(X.truncDivision(A,2)-V,R),D.set(X.truncDivision(A,2)+V,R),D.set(R,X.truncDivision(A,2)-V),D.set(R,X.truncDivision(A,2)+V)}var Z=new Wd;return Z.setCompact(s),Z.setSize(A),Z.setLayers(l),Z.setCodeWords(x),Z.setMatrix(D),Z},r.drawBullsEye=function(e,t,n){for(var i=0;i<n;i+=2)for(var a=t-i;a<=t+i;a++)e.set(a,t-i),e.set(a,t+i),e.set(t-i,a),e.set(t+i,a);e.set(t-n,t-n),e.set(t-n+1,t-n),e.set(t-n,t-n+1),e.set(t+n,t-n),e.set(t+n,t-n+1),e.set(t+n,t+n-1)},r.generateModeMessage=function(e,t,n){var i=new we;return e?(i.appendBits(t-1,2),i.appendBits(n-1,6),i=r.generateCheckWords(i,28,4)):(i.appendBits(t-1,5),i.appendBits(n-1,11),i=r.generateCheckWords(i,40,4)),i},r.drawModeMessage=function(e,t,n,i){var a=X.truncDivision(n,2);if(t)for(var o=0;o<7;o++){var s=a-3+o;i.get(o)&&e.set(s,a-5),i.get(o+7)&&e.set(a+5,s),i.get(20-o)&&e.set(s,a+5),i.get(27-o)&&e.set(a-5,s)}else for(var o=0;o<10;o++){var s=a-5+o+X.truncDivision(o,5);i.get(o)&&e.set(s,a-7),i.get(o+10)&&e.set(a+7,s),i.get(29-o)&&e.set(s,a+7),i.get(39-o)&&e.set(a-7,s)}},r.generateCheckWords=function(e,t,n){var i,a,o=e.getSize()/n,s=new to(r.getGF(n)),l=X.truncDivision(t,n),u=r.bitsToWords(e,n,l);s.encode(u,l-o);var c=t%n,d=new we;d.appendBits(0,c);try{for(var p=lf(Array.from(u)),h=p.next();!h.done;h=p.next()){var g=h.value;d.appendBits(g,n)}}catch(x){i={error:x}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}return d},r.bitsToWords=function(e,t,n){var i=new Int32Array(n),a,o;for(a=0,o=e.getSize()/t;a<o;a++){for(var s=0,l=0;l<t;l++)s|=e.get(a*t+l)?1<<t-l-1:0;i[a]=s}return i},r.getGF=function(e){switch(e){case 4:return Re.AZTEC_PARAM;case 6:return Re.AZTEC_DATA_6;case 8:return Re.AZTEC_DATA_8;case 10:return Re.AZTEC_DATA_10;case 12:return Re.AZTEC_DATA_12;default:throw new k("Unsupported word size "+e)}},r.stuffBits=function(e,t){for(var n=new we,i=e.getSize(),a=(1<<t)-2,o=0;o<i;o+=t){for(var s=0,l=0;l<t;l++)(o+l>=i||e.get(o+l))&&(s|=1<<t-1-l);(s&a)===a?(n.appendBits(s&a,t),o--):(s&a)===0?(n.appendBits(s|1,t),o--):n.appendBits(s,t)}return n},r.totalBitsInLayer=function(e,t){return((t?88:112)+16*e)*e},r.DEFAULT_EC_PERCENT=33,r.DEFAULT_AZTEC_LAYERS=0,r.MAX_NB_BITS=32,r.MAX_NB_BITS_COMPACT=4,r.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]),r})();const uf=new Map([[Zi.DecodeHintType.POSSIBLE_FORMATS,[B.AZTEC,B.CODABAR,B.CODE_39,B.CODE_93,B.CODE_128,B.DATA_MATRIX,B.EAN_8,B.EAN_13,B.ITF,B.MAXICODE,B.PDF_417,B.QR_CODE,B.RSS_14,B.RSS_EXPANDED,B.UPC_A,B.UPC_E,B.UPC_EAN_EXTENSION]]]),an=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,...o}=r;return f.jsxs(v.Overlay.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[!!e&&f.jsx(v.Overlay.Trigger,{asChild:!0,children:e}),f.jsxs(v.Overlay.Content,{children:[f.jsx(v.Overlay.Title,{className:"sr-only",children:"Scanner"}),f.jsx(v.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),f.jsx(xo,{...o})]})]})});an.displayName="Scanner";const xo=m.memo(r=>{const{paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a}=r,{ref:o}=Zi.useZxing({paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a,hints:uf});return f.jsxs("div",{className:"flex size-full flex-col justify-center overflow-hidden bg-(--color-background)",children:[f.jsx("div",{className:"flex w-full justify-end p-4",children:f.jsx(v.Overlay.Close,{asChild:!0,children:f.jsx(v.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:f.jsx(v.LuIcon,{icon:nt})})})}),f.jsx("div",{className:"grow w-full max-h-full overflow-hidden p-4",children:f.jsx("video",{className:"size-full",ref:o})})]})});xo.displayName="ScannerInternal";const yo=m.memo(r=>{const{children:e}=r,[t,n]=m.useState(null),i=m.useCallback(()=>{n(null)},[]),a=m.useCallback(s=>{n(s(i))},[i]),o=m.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return f.jsxs(wa.Provider,{value:a,children:[e,t&&f.jsx(an,{open:!0,onOpenChange:o,...t})]})});yo.displayName="FileViewerProvider";const wi=m.memo(r=>{const[{inputId:e,labelId:t,label:n,helpText:i,size:a,severity:o,showInputOnly:s,field:l,fieldProps:u,helpers:c,touched:d},{disabled:p}]=Ne(r),{name:h,onBlur:g,onChange:x,value:C}=u,[_,w]=m.useState(!1),A=s?null:i,E=s?"":n,[I,N]=m.useState("");m.useEffect(()=>{N(C)},[C]);const D=m.useCallback(R=>{const Z=R.target.value;N(Z),(d||!l.onlyValidateAfterTouched)&&c.setError(l.getError(Z))},[l,c,d]),M=m.useCallback(()=>{x(I),g(I)},[I,g,x]),F=m.useCallback(R=>{x(R.getText()),w(!1)},[x]),V=m.useCallback(()=>{w(!0)},[]),j=m.useCallback(()=>{w(!1),g(C)},[g,C]);return f.jsx(Oe,{helpText:A,severity:o,size:a,children:f.jsxs(be,{size:a,severity:o,inputId:e,labelId:t,label:E,image:s?void 0:l.image,className:"flex-col items-start justify-start gap-2",children:[f.jsx(v.TextArea,{className:"w-full field-sizing-content",accentColor:"base",variant:"surface",size:a,id:e,name:h,value:I,placeholder:"Enter a qr or barcode",onChange:D,onBlur:M,disabled:p}),f.jsxs(v.Button,{onClick:V,className:"w-max",type:"button",variant:"soft",size:a,accentColor:"base",disabled:p,children:[f.jsx(v.LuIcon,{icon:pl}),"Scan"]}),f.jsx(an,{open:_,onDecodeResult:F,onOpenChange:j})]})})});wi.displayName="ScanFieldInput";const rr=class rr extends Pe{constructor(t){super(t);b(this,"type","qr");b(this,"onlyValidateAfterTouched",!1)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new rr({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new rr(t)}serializeValue(t){return t}deserializeValue(t){return t}render(t){return f.jsx(wi,{...t,field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}};b(rr,"fieldTypeName","Scan"),b(rr,"fieldTypeDescription","Used for scanning/reading QR and barcodes.");let wr=rr;const on=500,mi=m.memo(r=>{const[{inputId:e,labelId:t,size:n,severity:i,showInputOnly:a,field:o,helpText:s,label:l,fieldProps:u,touched:c,helpers:d},{disabled:p}]=Ne(r),{name:h,onBlur:g,onChange:x,value:C}=u,_=a?null:s,w=a?"":l,[A,E]=m.useState("");m.useEffect(()=>{E(C)},[C]);const I=m.useCallback(M=>{const F=M.target.value;E(F),(c||!o.onlyValidateAfterTouched)&&d.setError(o.getError(F))},[o,d,c]),N=m.useCallback(M=>{M.key==="Enter"&&M.preventDefault()},[]),D=m.useCallback(()=>{x(A),g(A)},[A,g,x]);return f.jsx(Oe,{helpText:_,severity:i,size:n,children:f.jsx(be,{size:n,severity:i,inputId:e,labelId:t,label:w,image:a?void 0:o.image,children:f.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:n,children:f.jsx(v.Input.Field,{id:e,className:"truncate",name:h,value:A,type:"text",placeholder:o.placeholder,onChange:I,onBlur:D,disabled:p,onKeyDown:N})})})})});mi.displayName="StringFieldInput";const nr=class nr extends Mn{constructor(t){const{...n}=t,i=t.maxLength?Math.min(on,t.maxLength):on,a=t.minLength?Math.min(t.minLength,i):void 0;super({...n,maxLength:i,minLength:a});b(this,"type","string")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new nr({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new nr({...a,maxLength:n,minLength:i,placeholder:"Enter a short description"})}render(t){return f.jsx(mi,{field:this,...t})}};b(nr,"fieldTypeName","Short Text"),b(nr,"fieldTypeDescription",`Short text fields can hold up to ${on} characters on a single line.`);let Gt=nr;const _i=m.memo(r=>{const[{inputId:e,labelId:t,size:n,severity:i,showInputOnly:a,field:o,helpText:s,label:l,fieldProps:u,touched:c,helpers:d},{disabled:p}]=Ne(r),{name:h,onBlur:g,onChange:x,value:C}=u,_=a?null:s,w=a?"":l,[A,E]=m.useState("");m.useEffect(()=>{E(C)},[C]);const I=m.useCallback(D=>{const M=D.target.value;E(M),(c||!o.onlyValidateAfterTouched)&&d.setError(o.getError(M))},[o,d,c]),N=m.useCallback(()=>{x(A),g(A)},[A,g,x]);return f.jsx(Oe,{helpText:_,severity:i,size:n,children:f.jsx(be,{size:n,severity:i,inputId:e,labelId:t,label:w,image:a?void 0:o.image,children:f.jsx(v.TextArea,{id:e,value:A,name:h,onChange:I,onBlur:N,className:"field-sizing-content min-h-12",placeholder:o.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:n,disabled:p})})})});_i.displayName="TextFieldInput";const ir=class ir extends Mn{constructor(t){const n=t.maxLength?Math.min(Nt,t.maxLength):Nt,i=t.minLength?Math.min(t.minLength,n):void 0;super({...t,maxLength:n,minLength:i});b(this,"type","text")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new ir({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new ir({...a,maxLength:n,minLength:i,placeholder:"Enter a description"})}render(t){return f.jsx(_i,{field:this,...t})}};b(ir,"fieldTypeName","Paragraph"),b(ir,"fieldTypeDescription",`Paragraph fields can hold up to ${Nt} characters and can have multiple lines.`);let Ht=ir;const Ai=m.memo(r=>{var M;const[{inputId:e,labelId:t,label:n,size:i,severity:a,helpText:o,showInputOnly:s,field:l,fieldProps:u},{disabled:c}]=Ne(r),{value:d,name:p,onChange:h,onBlur:g}=u,x=m.useRef(null),C=m.useMemo(()=>s?null:o||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,o,s]),_=m.useCallback(()=>{var F;(F=x.current)==null||F.click()},[]),w=m.useCallback(()=>{if(!x.current)return;const F=x.current.files;if(!F){g([]);return}const V=Array.from(F).map(R=>at.from(G.v4(),R)),j=[...d,...V];h(j),g(j)},[g,h,d]),A=m.useCallback(F=>{const V=[...d];V.splice(F,1),h(V)},[d,h]);m.useEffect(()=>{if(!x.current)return;const F=new AbortController;return x.current.addEventListener("cancel",()=>{g([...d])},{signal:F.signal}),()=>{F.abort()}},[g,d]);const E=s?"":n,D=l.maxFiles>1?"Select files":"Select a file";return f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(Oe,{helpText:C,severity:a,size:i,children:f.jsxs(be,{size:i,severity:a,inputId:e,labelId:t,label:E,image:s?void 0:l.image,children:[f.jsxs(v.Button,{className:"w-max",size:i,variant:"soft",accentColor:"base",onClick:_,type:"button",disabled:c,children:[f.jsx(v.LuIcon,{icon:Sn}),D]}),f.jsx("input",{id:e,name:p,type:"file",ref:x,accept:(M=l.extensions)==null?void 0:M.join(","),multiple:l.maxFiles>1,className:"hidden",onChange:w,value:""})]})}),Array.isArray(d)&&d.length>0&&f.jsx("div",{className:"flex h-max flex-col gap-2",children:d.map((F,V)=>f.jsx(zn,{file:F,onRemove:()=>{A(V)},disabled:c},V))})]})});Ai.displayName="UploadFieldInput";const ar=class ar extends Pe{constructor(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;super(o);b(this,"type","upload");b(this,"extensions");b(this,"maxFileSize");b(this,"maxFiles");b(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof i=="number"?i:1,1),this.extensions=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new qe({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${n}maximum_files`,integers:!0}),showDirectly:!1},{field:new qe({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${Xt}MB).`,required:!1,identifier:`${n}maximum_size`,minimum:1,maximum:Xt,integers:!0}),showDirectly:!1},{field:new it({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${n}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxFileSize??Xt,i=n*1e3*1e3,a=this.maxFiles||1;return t.push(o=>{if(o&&o.some(s=>s instanceof at&&s.size>i))return`Files must be at most ${n}MB.`}),t.push(o=>{if(o&&o.length>a)return`You can only upload ${a} files.`}),t}serialize(){return{...super.serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}duplicate(t){return new ar({...this.getOptions(),identifier:t})}setOptions(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;this.maxFileSize=typeof a=="number"?a:this.maxFileSize,this.maxFiles=typeof i=="number"?i:this.maxFiles,this.extensions=n,super.setOptions(o)}static deserialize(t){return new ar(t)}serializeValue(t){return[]}deserializeValue(t){return[]}render(t){return f.jsx(Ai,{field:this,...t})}isSerializedValue(t){return Array.isArray(t)&&t.length===0}isValue(t){return Array.isArray(t)?t.every(n=>n instanceof Ft||n instanceof at):!1}areValuesEqual(t,n){return qr(t,n)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){return t.length===n.length}};b(ar,"fieldTypeName","Upload"),b(ar,"fieldTypeDescription","Allows a file to be uploaded.");let qt=ar;const sn={date:dr,number:qe,boolean:bt,select:pt,string:Gt,text:Ht,upload:qt,qr:wr,"multi-string":Ot,"multi-select":it,radio:Vt,"checkbox-list":Tt,"pass-fail":Pt,otp:Dt,rating:Bt},fe={boolean:yl,date:Qs,"multi-string":hl,number:ll,qr:gl,"multi-select":dl,select:fl,string:wl,text:Ys,upload:Sn,section:cl,radio:el,"checkbox-list":il,"pass-fail":nl,otp:vl,rating:la},Xt=50,Co=Xt*1e3,wo=Co*1e3,Ie="Unlabelled",Ei="Unlabelled";class ${constructor(e){b(this,"id");b(this,"label");b(this,"getApplyFn");b(this,"serialize");b(this,"deserialize");const{id:t,getApplyFn:n,label:i,serialize:a,deserialize:o}=e;this.id=t,this.getApplyFn=n,this.label=i,this.serialize=a,this.deserialize=o}static create(e){return new $(e)}}const mo=$.create({id:"nullable-boolean-equals",label:"is",getApplyFn:r=>e=>e===r,serialize:r=>r,deserialize:r=>r}),_o=$.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:r=>e=>e!==r,serialize:r=>r,deserialize:r=>r}),Ao=$.create({id:"date-equals",getApplyFn:r=>e=>e.getTime()===r.getTime(),label:"is",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Eo=$.create({id:"date-not-equals",getApplyFn:r=>e=>e.getTime()!==r.getTime(),label:"is not",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),So=$.create({id:"date-before",getApplyFn:r=>e=>e.getTime()<r.getTime(),label:"before",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Io=$.create({id:"date-after",label:"after",getApplyFn:r=>e=>e.getTime()>r.getTime(),serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Oo=$.create({id:"date-range-in",label:"in between",getApplyFn:r=>e=>!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),bo=$.create({id:"date-range-not-in",label:"not in between",getApplyFn:r=>e=>!!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),No=$.create({id:"has-files",label:"is",getApplyFn:r=>e=>e.length>0,serialize:r=>r,deserialize:r=>r}),To=$.create({id:"does-not-have-files",label:"is not",getApplyFn:r=>e=>e.length===0,serialize:r=>r,deserialize:r=>r}),Si=$.create({id:"number-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Ii=$.create({id:"number-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Oi=$.create({id:"number-less-than",getApplyFn:r=>e=>e<r,label:"is less than",serialize:r=>r,deserialize:r=>r}),bi=$.create({id:"number-less-than-or-equals",getApplyFn:r=>e=>e<=r,label:"is less than or equal to",serialize:r=>r,deserialize:r=>r}),Ni=$.create({id:"number-greater-than",getApplyFn:r=>e=>e>r,label:"is greater than",serialize:r=>r,deserialize:r=>r}),Ti=$.create({id:"number-greater-than-or-equals",getApplyFn:r=>e=>e>=r,label:"is greater than or equal to",serialize:r=>r,deserialize:r=>r}),Di=$.create({id:"number-range-in",getApplyFn:r=>e=>!(r.to&&e>r.to||r.from&&e<r.from),label:"is between",serialize:r=>r,deserialize:r=>r}),Mi=$.create({id:"number-range-not-in",getApplyFn:r=>e=>!!(r.to&&e>r.to||r.from&&e<r.from),label:"is not between",serialize:r=>r,deserialize:r=>r}),Do=$.create({id:"pass-fail-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Mo=$.create({id:"pass-fail-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Fo=$.create({id:"pass-fail-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),Po=$.create({id:"pass-fail-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),mt=$.create({id:"nullable-string-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),_t=$.create({id:"nullable-string-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),mr=$.create({id:"string-includes",getApplyFn:r=>e=>e.includes(r),label:"includes",serialize:r=>r,deserialize:r=>r}),_r=$.create({id:"string-excludes",getApplyFn:r=>e=>!e.includes(r),label:"does not include",serialize:r=>r,deserialize:r=>r}),Fi=$.create({id:"string-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),Pi=$.create({id:"string-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),ln=$.create({id:"string-array-every",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isSubsetOf(n)}},label:"has all of",serialize:r=>r,deserialize:r=>r}),un=$.create({id:"string-array-some",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return!e.isDisjointFrom(n)}},label:"has any of",serialize:r=>r,deserialize:r=>r}),cn=$.create({id:"string-array-none",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isDisjointFrom(n)}},label:"has none of",serialize:r=>r,deserialize:r=>r}),dn=$.create({id:"string-array-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size===n.size&&n.isSubsetOf(e)}},label:"is",serialize:r=>r,deserialize:r=>r}),fn=$.create({id:"string-array-not-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size!==n.size||!n.isSubsetOf(e)}},label:"is not",serialize:r=>r,deserialize:r=>r}),L=r=>r;class Me extends lr{constructor(t){const{id:n,field:i,conditionValue:a,conditionModifier:o}=t;super();b(this,"id");b(this,"conditionValue");b(this,"conditionModifier");b(this,"field");b(this,"getConditionValue",()=>this.conditionValue);b(this,"setConditionValue",t=>{const n=this.modifiers[this.conditionModifier];t!==void 0&&!n.isConditionValueValid(t)||(this.conditionValue=t,this.notify(this))});b(this,"getConditionModifier",()=>this.conditionModifier);b(this,"setConditionModifier",t=>{const n=this.modifiers[t],i=this.getConditionValue();i&&!n.isConditionValueValid(i)&&(this.conditionValue=void 0),this.conditionModifier=t,this.notify(this)});b(this,"getConditionModifiers",()=>Object.entries(this.modifiers));b(this,"accessorFn",t=>t[this.field.identifier]);b(this,"getApplyFn",()=>{const t=this.modifiers[this.conditionModifier],n=this.getConditionValue(),i=n!==void 0&&t.isConditionValueValid(n),a=i?t.modifier.getApplyFn(n):null;return o=>{if(!i)return!0;const s=this.transformValue(o);return t.isValueValid(s)?a(s):!1}});this.id=n,this.field=i,this.conditionValue=a,this.conditionModifier=o}serialize(){return{id:this.id,type:this.field.type,fieldId:this.field.identifier,conditionValue:this.conditionValue!==void 0?this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue):void 0,conditionModifier:this.conditionModifier}}transformValue(t){return t}}const Vo=m.memo,At=Vo(function(r){const{ref:e,children:t,...n}=r,i=m.useCallback(a=>typeof t=="function"?f.jsxs(f.Fragment,{children:[t(a),f.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:f.jsx(v.LuIcon,{icon:Ge})})]}):f.jsxs(f.Fragment,{children:[t,f.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:f.jsx(v.LuIcon,{icon:Ge})})]}),[t]);return f.jsx(v.Menu.SelectItem,{ref:e,...n,children:i})}),Bo=Vo(function(r){const{ref:e,children:t,...n}=r,i=m.useCallback(a=>typeof t=="function"?f.jsxs(f.Fragment,{children:[t(a),f.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:f.jsx(v.LuIcon,{icon:Ge})})]}):f.jsxs(f.Fragment,{children:[t,f.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:f.jsx(v.LuIcon,{icon:Ge})})]}),[t]);return f.jsx(v.Menu.MultiSelectItem,{ref:e,...n,children:i})}),Vi=m.memo(r=>{const{ref:e,children:t,...n}=r,i=m.useCallback(a=>typeof t=="function"?f.jsxs(f.Fragment,{children:[t(a),f.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?f.jsx(v.LuIcon,{icon:Rr}):f.jsx(v.LuIcon,{icon:Ge})})]}):f.jsxs(f.Fragment,{children:[t,f.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?f.jsx(v.LuIcon,{icon:Rr}):f.jsx(v.LuIcon,{icon:Ge})})]}),[t]);return f.jsx(v.Menu.SelectAllItem,{ref:e,...n,children:i})});Vi.displayName="SelectAllItemTemplate";const ze=r=>{const{children:e,condition:t,size:n="sm",variant:i,accentColor:a,radius:o}=r,s=m.useCallback(l=>{t.setConditionModifier(l)},[t]);return f.jsxs(v.Menu.Root,{align:"start",children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{size:n,variant:i,radius:o,accentColor:a,children:f.jsx(v.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:s,children:t.getConditionModifiers().map(([l,u])=>f.jsx(At,{value:l,children:u.modifier.label},l))})})]})},hn=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,align:s,accentColor:l="base",...u}=r;return f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,align:s,children:f.jsx(v.DayPicker,{size:o,accentColor:l,...u})})]})});hn.displayName="DayPickerPopover";const Lo=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",values:l,onValuesChange:u,placeholder:c="Enter text",...d}=r,[p,h]=m.useState(""),g=m.useCallback(w=>{h(w.target.value)},[]),x=m.useCallback(w=>{w.key==="Enter"&&(w.preventDefault(),w.stopPropagation(),u([...l,p]),h(""))},[p,u,l]),C=m.useCallback(()=>{u([...l,p]),h("")},[p,u,l]),_=m.useCallback(w=>{const A=[...l];A.splice(w,1),u(A)},[u,l]);return f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,accentColor:s,...d,children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:f.jsx(v.Input.Field,{value:p,onChange:g,onKeyDown:x,placeholder:c,...d})}),f.jsx(v.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:C,children:f.jsx(v.LuIcon,{icon:je})})]}),l.length>0&&f.jsx("div",{className:"flex flex-col gap-1",children:l.map((w,A)=>f.jsxs(v.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[f.jsx("span",{className:"truncate",children:w}),f.jsx(v.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{_(A)},children:f.jsx(v.LuIcon,{icon:nt})})]},`${w}-${A}`))})]})})]})});Lo.displayName="NumberInputPopover";const Et=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter a number",...d}=r,[p,h]=m.useState(null);m.useEffect(()=>{l!==void 0&&h(l)},[l]);const g=m.useCallback(C=>{const _=C.target.valueAsNumber;h(isNaN(_)?null:_)},[]),x=m.useCallback(C=>{const _=C.target.valueAsNumber;u==null||u(isNaN(_)?null:_)},[u]);return f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...d,children:f.jsx(v.Input.Root,{size:o,accentColor:s,children:f.jsx(v.Input.Field,{placeholder:c,type:"number",value:p??"",onChange:g,onBlur:x})})})]})});Et.displayName="NumberInputPopover";const Fe=r=>{const{condition:e,onClick:t,...n}=r,i=m.useCallback(()=>{t(e)},[e,t]);return f.jsx(v.IconButton,{onClick:i,...n,children:f.jsx(v.LuIcon,{icon:nt})})};Fe.displayName="RemoveConditionButton";const Ar=m.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=m.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return f.jsxs(v.Menu.MultiSelectGroup,{ref:e,...n,children:[f.jsx(Vi,{children:"Select all"}),i.map(a=>f.jsx(Bo,{value:a.value,children:f.jsx("span",{className:"truncate",children:a.label})},a.value))]})});Ar.displayName="SelectFieldOptionMultiSelectGroup";const Bi=m.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=m.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return f.jsx(v.Menu.SelectGroup,{ref:e,...n,children:i.map(a=>f.jsx(At,{value:a.value,children:f.jsx("span",{className:"truncate",children:a.label})},a.value))})});Bi.displayName="SelectFieldOptionSelectGroup";const Er=m.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter text",...d}=r,[p,h]=m.useState(""),g=m.useCallback(C=>{h(C.target.value)},[]),x=m.useCallback(C=>{const _=C.target.value;u==null||u(_)},[u]);return m.useEffect(()=>{l&&h(l)},[l]),f.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:e}),f.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...d,children:f.jsx(v.Input.Root,{size:o,accentColor:s,children:f.jsx(v.Input.Field,{placeholder:c,type:"text",value:p,onChange:g,onBlur:x})})})]})});Er.displayName="TextInputPopover";const zo=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{switch(n){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[e.field.type]}),f.jsx("span",{className:"truncate",children:e.field.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:a()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsxs(v.Menu.SelectGroup,{required:!0,value:n,onValueChange:e.setConditionValue,children:[f.jsx(At,{value:!0,children:"true"}),f.jsx(At,{value:!1,children:"false"})]})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},ko={equals:L({modifier:mo,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_o,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Sr extends Me{constructor(t){super(t);b(this,"modifiers",ko)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ko[a];let l;return i!==void 0&&(l=s.modifier.deserialize(i)),new Sr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(zo,{condition:this,...t},this.id)}}const Ro=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"soft",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{values:i??[],selectFieldOptions:e.field.options,onValuesChange:o})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},Uo={equals:L({modifier:dn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:fn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:L({modifier:ln,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:L({modifier:un,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:L({modifier:cn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Ir extends Me{constructor(t){super(t);b(this,"modifiers",Uo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Uo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Ir({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(Ro,{condition:this,...t},this.id)}}class pn extends lr{constructor(t){super();b(this,"conditions");b(this,"conditionObserver",()=>{this.conditions=[...this.conditions],this.notify(this)});b(this,"initConditions",t=>{for(const n of t)n.observe(this.conditionObserver);return t});this.conditions=this.initConditions(t)}getConditions(){return this.conditions}addCondition(t){this.conditions=this.initConditions([...this.conditions,t]),this.notify(this)}addConditions(t){this.conditions=this.initConditions([...this.conditions,...t]),this.notify(this)}removeCondition(t){this.conditions=this.initConditions(this.conditions.filter(n=>n.id!==t.id)),this.notify(this)}removeConditions(t){const n=new Set(t.map(i=>i.id));this.conditions=this.initConditions(this.conditions.filter(i=>!n.has(i.id))),this.notify(this)}applyConditions(t){return this.conditions.length===0?!0:this.conditions.map(i=>[i.getApplyFn(),i.accessorFn]).every(([i,a])=>i(a(t)))}}const cf=(r,e)=>m.useMemo(()=>{const t=new pn(r);return t.observe(n=>e(n.getConditions())),t},[r,e]),Go=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{var o,s;switch(i){case"equals":case"notEquals":{const l=e.modifiers.equals,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return f.jsx(hn,{required:!1,size:"sm",mode:"single",selected:u??void 0,onSelect:c=>e.setConditionValue(c),children:f.jsx(v.Button,{type:"button",className:"truncate",children:u!==void 0?(u==null?void 0:u.toLocaleDateString())??"empty":"..."})})}case"before":case"after":{const l=e.modifiers.after,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return f.jsx(hn,{required:!0,size:"sm",mode:"single",selected:u,onSelect:e.setConditionValue,children:f.jsx(v.Button,{type:"button",className:"truncate",children:u?u.toLocaleDateString():"..."})})}case"in":case"notIn":{const l=e.modifiers.in,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return f.jsx(hn,{required:!0,mode:"range",size:"sm",selected:u,onSelect:e.setConditionValue,children:f.jsx(v.Button,{className:"truncate",children:u?`${(o=u.from)==null?void 0:o.toLocaleDateString()} - ${(s=u.to)==null?void 0:s.toLocaleDateString()}`:"..."})})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[e.field.type]}),f.jsx("span",{className:"truncate",children:e.field.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),a(),f.jsx(Fe,{condition:e,onClick:t})]})},Ho={equals:L({modifier:Ao,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),notEquals:L({modifier:Eo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),before:L({modifier:So,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),after:L({modifier:Io,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),in:L({modifier:Oo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r}),notIn:L({modifier:bo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r})};class Or extends Me{constructor(t){super(t);b(this,"modifiers",Ho)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ho[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Or({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(Go,{condition:this,...t},this.id)}}const qo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{values:i??[],selectFieldOptions:n.options,onValuesChange:o})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},Xo={equals:L({modifier:dn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:fn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:L({modifier:ln,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:L({modifier:un,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:L({modifier:cn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class br extends Me{constructor(t){super(t);b(this,"modifiers",Xo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Xo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new br({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(qo,{condition:this,...t},this.id)}}const Li=[],$o=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useCallback(l=>{e.setConditionValue(l.length>0?l:void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";case 1:return i[0].toString();default:return`${i.length} values`}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsx(Lo,{values:i??Li,onValuesChange:o,children:f.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),f.jsx(Fe,{condition:e,onClick:t})]})},Wo={equals:L({modifier:dn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:fn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:L({modifier:ln,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:L({modifier:un,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:L({modifier:cn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Nr extends Me{constructor(t){super(t);b(this,"modifiers",Wo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Wo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Nr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx($o,{condition:this,...t},this.id)}}const jo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const s=e.modifiers.greaterThan,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsx(Et,{value:l??null,onValueChange:u=>e.setConditionValue(u??void 0),size:"sm",children:f.jsx(v.Button,{type:"button",className:"truncate",children:l!==void 0?l??"empty":"..."})})}case"inRange":case"notInRange":{const s=e.modifiers.inRange,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(f.Fragment,{children:[f.jsx(Et,{value:(l==null?void 0:l.from)??null,onValueChange:u=>{e.setConditionValue({from:u,to:(l==null?void 0:l.to)??null})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.from)??"..."})}),f.jsx(Et,{value:(l==null?void 0:l.to)??null,onValueChange:u=>{e.setConditionValue({from:(l==null?void 0:l.from)??null,to:u})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.to)??"..."})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},Yo={equals:L({modifier:Si,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:L({modifier:Ii,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:L({modifier:Oi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:L({modifier:bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:L({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:L({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:L({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:L({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Tr extends Me{constructor(t){super(t);b(this,"modifiers",Yo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Yo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Tr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(jo,{condition:this,...t},this.id)}}const Zo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},Ko={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Dr extends Me{constructor(t){super(t);b(this,"modifiers",Ko)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ko[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Dr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(Zo,{condition:this,...t},this.id)}}const Qo=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":{const s=e.modifiers.equals,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:l!==void 0?l?vt[l].label:"empty":"..."})})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(v.Menu.SelectGroup,{required:!1,value:l,onValueChange:e.setConditionValue,children:Mt.map(u=>{const{label:c}=vt[u];return f.jsx(At,{value:u,children:f.jsx("span",{className:"truncate",children:c})},u)})})})]})}case"includes":case"excludes":{const s=e.modifiers.includes,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",children:l?`${l.length} statuses`:"..."})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsxs(v.Menu.MultiSelectGroup,{values:l??Li,onValuesChange:e.setConditionValue,children:[f.jsx(Vi,{children:"Select all"}),Mt.map(u=>{const{label:c,icon:d}=vt[u];return f.jsxs(Bo,{value:u,children:[f.jsx(v.LuIcon,{icon:d}),f.jsx("span",{className:"truncate",children:c})]},u)})]})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},Jo={equals:L({modifier:Do,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),notEquals:L({modifier:Mo,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),includes:L({modifier:Fo,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:L({modifier:Po,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Mr extends Me{constructor(t){super(t);b(this,"modifiers",Jo)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Jo[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Mr({field:n,conditionModifier:a,conditionValue:l,...o})}transformValue(t){return t.status}render(t){return f.jsx(Qo,{condition:this,...t},this.id)}}const es=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useMemo(()=>n.options.map(u=>typeof u=="string"?{value:u,label:u}:u),[n.options]),s=m.useMemo(()=>{const u={};for(const c of o)u[c.value]=c.label;return u},[o]),l=()=>{switch(a){case"equals":case"notEquals":{const u=e.modifiers.equals,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:c!==void 0?c?s[c]:"empty":"..."})})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Bi,{required:!0,selectFieldOptions:n.options,value:c??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const u=e.modifiers.includes,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",children:c?`${c.length} options`:"..."})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{selectFieldOptions:n.options,values:c??Li,onValuesChange:e.setConditionValue})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),f.jsx(Fe,{condition:e,onClick:t})]})},ts={equals:L({modifier:mt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:L({modifier:_t,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:L({modifier:Fi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:L({modifier:Pi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Fr extends Me{constructor(t){super(t);b(this,"modifiers",ts)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ts[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Fr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(es,{condition:this,...t},this.id)}}const rs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const s=e.modifiers[a],l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsx(Et,{value:l??null,onValueChange:u=>e.setConditionValue(u??void 0),size:"sm",children:f.jsx(v.Button,{type:"button",className:"truncate",children:l!==void 0?l:"..."})})}case"inRange":case"notInRange":{const s=e.modifiers.inRange,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return f.jsxs(f.Fragment,{children:[f.jsx(Et,{value:(l==null?void 0:l.from)??null,onValueChange:u=>{e.setConditionValue({from:u,to:(l==null?void 0:l.to)??null})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.from)??"..."})}),f.jsx(Et,{value:(l==null?void 0:l.to)??null,onValueChange:u=>{e.setConditionValue({from:(l==null?void 0:l.from)??null,to:u})},size:"sm",children:f.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.to)??"..."})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},ns={equals:L({modifier:Si,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:L({modifier:Ii,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:L({modifier:Oi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:L({modifier:bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:L({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:L({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:L({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:L({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Pr extends Me{constructor(t){super(t);b(this,"modifiers",ns)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ns[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Pr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(rs,{condition:this,...t},this.id)}}const is=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},as={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Vr extends Me{constructor(t){super(t);b(this,"modifiers",as)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=as[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Vr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(is,{condition:this,...t},this.id)}}const os=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=m.useMemo(()=>n.options.map(c=>typeof c=="string"?{value:c,label:c}:c),[n.options]),s=m.useMemo(()=>{const c={};for(const d of o)c[d.value]=d.label;return c},[o]),l=m.useCallback(c=>{c.length>0?e.setConditionValue(c):e.setConditionValue([])},[e]),u=()=>{switch(a){case"equals":case"notEquals":{const c=e.modifiers.equals,d=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:d!==void 0?d?s[d]:"empty":"..."})})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Bi,{required:!1,selectFieldOptions:n.options,value:d??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const c=e.modifiers.includes,d=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",children:d?`${d.length} options`:"..."})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsx(Ar,{selectFieldOptions:n.options,values:d??[],onValuesChange:l})})]})}}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),u(),f.jsx(Fe,{condition:e,onClick:t})]})},ss={equals:L({modifier:mt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:L({modifier:_t,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:L({modifier:Fi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:L({modifier:Pi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Br extends Me{constructor(t){super(t);b(this,"modifiers",ss)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ss[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Br({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(os,{condition:this,...t},this.id)}}const ls=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},us={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Lr extends Me{constructor(t){super(t);b(this,"modifiers",us)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=us[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Lr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(ls,{condition:this,...t},this.id)}}const cs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return f.jsx(Er,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:f.jsx("span",{className:"truncate",children:i||"..."})})})}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),f.jsx(Fe,{condition:e,onClick:t})]})},ds={equals:L({modifier:mt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:_t,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:L({modifier:mr,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:L({modifier:_r,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class zr extends Me{constructor(t){super(t);b(this,"modifiers",ds)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ds[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new zr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(cs,{condition:this,...t},this.id)}}const fs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(i){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return f.jsxs(v.ButtonGroup,{className:"flex w-max max-w-full min-w-0 gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[f.jsxs(v.Badge,{className:"min-w-0 shrink-1",size:"sm",variant:"fill",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),f.jsx("span",{className:"truncate",children:n.label||Ie})]}),f.jsx(ze,{condition:e,children:f.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),f.jsxs(v.Menu.Root,{children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.Button,{type:"button",className:"min-w-0 shrink-1 grow",children:o()})}),f.jsx(v.Menu.Content,{size:"sm",children:f.jsxs(v.Menu.SelectGroup,{required:!0,value:i,onValueChange:e.setConditionValue,children:[f.jsx(At,{value:!0,children:"empty"}),f.jsx(At,{value:!1,children:"not empty"})]})})]}),f.jsx(Fe,{condition:e,onClick:t})]})},hs={equals:L({modifier:No,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:L({modifier:To,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class kr extends Me{constructor(t){super(t);b(this,"modifiers",hs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=hs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new kr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return f.jsx(fs,{condition:this,...t},this.id)}}const df={date:Or,number:Tr,boolean:Sr,select:Br,string:Lr,text:zr,upload:kr,qr:Vr,"multi-string":Nr,"multi-select":br,radio:Fr,"checkbox-list":Ir,"pass-fail":Mr,otp:Dr,rating:Pr},ps=(r,e)=>{if(r.type!==e.type)throw new Error(`field and condition type mismatch ${r.type} !== ${e.type}`);return df[e.type].deserialize(e,r)},zi=(r,e)=>{const t={};for(const n of r)t[n.identifier]=n;return e.map(n=>ps(t[n.fieldId],n))},vn=r=>sn[r.type].deserialize(r);function ff(r){return r.map(vs)}const vs=r=>r.type==="section"?He.deserialize(r):vn(r);function hf(r){return r.map(vn)}function gs(r){const e=[];for(const t of r)if(t instanceof He)for(const n of t.getFields())e.push(n);else e.push(t);return e}function xs(r){const e={};for(const t of r)e[t.identifier]=t;return e}function ys(r,e,t=!0){const n=t?gn(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.serializeValue(o)}return i}function Cs(r,e,t=!0){const n=t?ki(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.deserializeValue(o)}return i}function gn(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isValue(i)&&(t[n.identifier]=n.cleanValue(i))}return t}function ki(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isSerializedValue(i)&&(t[n.identifier]=n.cleanSerializedValue(i))}return t}function ws(r,e){const t=gn(r,e),n={},i={};for(const a of r){if(!(a.identifier in t))continue;const o=t[a.identifier];switch(a.type){case"upload":if(!a.isValue(o))break;i[a.identifier]=o,n[a.identifier]=[];break;case"pass-fail":if(!a.isValue(o))break;i[a.identifier]=o.files,n[a.identifier]={...o,files:[]};break;default:n[a.identifier]=e[a.identifier]}}return[n,i]}function ms(r,e,t){const n={};for(const i of r){if(!(i.identifier in e))continue;const a=e[i.identifier];switch(i.type){case"upload":if(!i.isValue(a))break;n[i.identifier]=t[i.identifier]??[];break;case"pass-fail":if(!i.isValue(a))break;n[i.identifier]={...a,files:t[i.identifier]??[]};break;default:if(!i.isValue(a))break;n[i.identifier]=a}}return n}const _s=(r,e)=>{const t={};for(const n of r){const i=e[n.identifier];t[n.identifier]=i!==void 0?i:n.blankValue()}return t},As=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)||(n[i.identifier]=o)}return n},Es=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)&&(n[i.identifier]=o)}return n},Ri=(r,e,t)=>r.every(n=>{const i=e[n.identifier],a=t[n.identifier];return n.areValuesEqual(i,a)}),Ui=r=>{const e={};for(const t of r)e[t.identifier]=t.blankValue();return e},Ss=(r,e)=>Ri(r,e,Ui(r)),pf=(r,e,t={})=>{const{conditions:n=!1}=t,i=r.get(e.identifier);if(!i)throw new Error(`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`);const a=new Map,o=e.fields.map(l=>{const u=G.v4(),{image:c,...d}=l;return a.set(l.identifier,u),{...d,identifier:u}}),s={};if(n)for(const[l,u]of Object.entries(e.conditions??{})){const c=r.get(l);if(!c)continue;const d=u.map(p=>{const h=a.get(p.fieldId);if(!h)throw new Error(`Serialized condition referencing undefined field with identifier: ${p.fieldId}`);return{...p,fieldId:h}});s[c]=d}return{...e,identifier:i,conditions:s,fields:o}},vf=(r,e={})=>{const t=new Map(r.map(n=>[n.identifier,G.v4()]));return r.map(n=>pf(t,n,e))},Gi=(r,e)=>{const t={},n=r.filter(i=>i instanceof He);for(const i of r)if(i instanceof He){const a=n.filter(s=>i.identifier in s.conditions);if(a.length>0&&!a.some(s=>{const l=s.getConditions(i.identifier);return new pn(l).applyConditions(e)}))continue;const o=i.getErrors(e);Object.assign(t,o)}else{if(!(i instanceof Pe))throw new Error("Invalid field type");const a=i.identifier,o=i.getError(_n(e,a));o&&Hs(t,a,o)}if(Object.keys(t).length>0)return t},gf=async r=>{const e={},t=[];for(const n of r){const{fields:i}=n,a=[];for(const o of i){if(o.image){if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(s){console.error("Failed to get image from promise",s)}else e[o.identifier]=o.image;delete o.image}a.push(o)}t.push({...n,fields:a})}return{fields:t,images:e}};async function xf(r){const e={};for(const[t,n]of Object.entries(r))e[t]=await Promise.all(n);return e}class dt extends lr{constructor(t){super();b(this,"fieldSections");b(this,"fieldObserver",()=>{this.notify(this)});b(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});this.fieldSections=this.initFields(t)}serialize(){return this.fieldSections.map(t=>t.serialize())}static deserialize(t){return new dt(t.map(He.deserialize))}static reseedFieldSections(t,n){return vf(t,n)}getFields(){return this.fieldSections.flatMap(t=>t.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(t,n){const i=[...this.fieldSections];i.splice(n??this.fieldSections.length,0,t),this.fieldSections=this.initFields(i),this.notify(this)}removeFieldSection(t){const n=this.fieldSections.filter(i=>i.identifier!==t.identifier);for(const i of n)i.removeConditional(i.identifier);this.fieldSections=this.initFields(n),this.notify(this)}moveFieldSection(t,n){const i=[...this.fieldSections],[a]=i.splice(t,1);i.splice(n,0,a),this.fieldSections=this.initFields(i),this.notify(this)}getSectionDependencyGraph(){const t=new Us.DirectedGraph({type:"directed"});for(const n of this.fieldSections)for(const i of Object.keys(n.conditions))t.mergeEdge(n.identifier,i);return t}getDependenciesOfSection(t){const n=this.getSectionDependencyGraph(),i=new Map(this.fieldSections.map(o=>[o.identifier,o])),a=[];return Gs.bfsFromNode(n,t,(o,s,l)=>{a.push(i.get(o))},{mode:"in"}),a}cleanValues(t){return gn(this.getFields(),t)}cleanSerializedValues(t){return ki(this.getFields(),t)}deserializeValues(t,n){return Cs(this.getFields(),t,n)}serializeValues(t,n){return ys(this.getFields(),t,n)}initializeValues(t){return _s(this.getFields(),t)}validateValues(t){return Gi(this.getFieldSections(),t)}deserializeConditions(t){return zi(this.getFields(),t)}changedFieldValues(t,n){return As(this.getFields(),t,n)}unchangedFieldValues(t,n){return Es(this.getFields(),t,n)}areValuesEqual(t,n){return Ri(this.getFields(),t,n)}areValuesBlank(t){return Ss(this.getFields(),t)}blankValues(){return Ui(this.getFields())}extractFilesAndPromisesFromFieldValues(t){return ws(this.getFields(),t)}insertFilesAndPromisesToFieldValues(t,n){return ms(this.getFields(),t,n)}}const Is=m.createContext({}),Hi=m.memo(r=>{const{fieldSection:e,size:t,...n}=r,{label:i,description:a}=e,{values:o}=rt.useFormikContext(),{fieldSchema:s}=m.use(Is),l=m.useMemo(()=>s.getFieldSections(),[s]),u=m.useMemo(()=>l.filter(p=>e.identifier in p.conditions),[l,e.identifier]),c=m.useMemo(()=>u.length===0?!0:u.some(p=>{const h=p.getConditions(e.identifier);return new pn(h).applyConditions(o)}),[u,e,o]),d=ur(e.fields,{size:t,...n});return c?f.jsxs("div",{className:"flex flex-col gap-4",children:[(i||a)&&f.jsx(f.Fragment,{children:f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(v.Heading,{size:t,children:i}),a&&f.jsx(v.Text,{accentColor:"base",size:t,children:a})]})}),d]}):null});Hi.displayName="FieldSectionLayout";const It=class It extends On{constructor(t){const{label:n=null,description:i=null,fields:a,conditions:o={},...s}=t;super(s);b(this,"type","section");b(this,"label");b(this,"description");b(this,"conditions");b(this,"fields",[]);b(this,"fieldObserver",()=>{this.notify(this)});b(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});b(this,"conditionObserver",()=>{this.notify(this)});b(this,"initConditions",t=>{for(const n of Object.values(t).flat())n.observe(this.conditionObserver);return t});this.label=n,this.description=i,this.fields=this.initFields(a),this.conditions=this.initConditions(o)}serialize(){const t={};for(const[n,i]of Object.entries(this.conditions))t[n]=i.map(a=>a.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:t,fields:this.fields.map(n=>n.serialize())}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(t){return new It({...this.getOptions(),identifier:t,fields:this.fields.map(n=>n.duplicate(G.v4()))})}setOptions(t){const{label:n,description:i,fields:a,conditions:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.fields=a||this.fields,this.conditions=o||this.conditions,super.setOptions(s)}getErrors(t){const n={};for(const i of this.fields){const a=i.getError(t[i.identifier]);a&&(n[i.identifier]=a)}return n}getFields(){return this.fields}addField(t,n){const i=[...this.fields];i.splice(n??this.fields.length,0,t),this.fields=this.initFields(i),this.notify(this)}moveField(t,n){const i=[...this.fields],[a]=i.splice(t,1);i.splice(n,0,a),this.fields=i,this.notify(this)}removeField(t){this.fields=this.initFields(this.fields.filter(({identifier:i})=>i!==t.identifier));const n={};for(const[i,a]of Object.entries(this.conditions))n[i]=a.filter(o=>o.field.identifier!==t.identifier);this.conditions=n,this.notify(this)}getConditions(t){return this.conditions[t]}addCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],n]}),this.notify(this)}addConditions(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],...n]}),this.notify(this)}removeCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(i=>i.id!==n.id)}),this.notify(this)}removeConditions(t,n){const i=new Set(n.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(a=>!i.has(a.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(t){this.conditions=this.initConditions({...this.conditions,[t]:[]}),this.notify(this)}removeConditional(t){const n={...this.conditions};delete n[t],this.conditions=this.initConditions(n),this.notify(this)}render(t){return f.jsx(Hi,{fieldSection:this,...t})}};b(It,"fieldTypeName","Section"),b(It,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden."),b(It,"deserialize",t=>{const n=t.fields.map(vn),i={};for(const[a,o]of Object.entries(t.conditions))i[a]=zi(n,o);return new It({...t,fields:n,conditions:i})});let He=It;const St=m.createContext(new dt([])),xn="form-builder",yn=m.createContext({}),yf=(r=()=>null)=>m.useMemo(()=>Object.entries(sn).map(([t,n])=>({children:n.fieldTypeName,icon:f.jsx(v.LuIcon,{icon:fe[t]}),value:t,onSelect:()=>{r(t)}})),[r]),Cn=m.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,onSelectFieldType:a,...o}=r,s=yf(a);return f.jsxs(v.Menu.Root,{...o,children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:f.jsx(v.Menu.Scroll,{children:s.flat().map(l=>f.jsxs(v.Menu.Item,{onSelect:l.onSelect,children:[l.icon,l.children]},l.value))})})]})});Cn.displayName="CreateFieldDropdownMenu";const wn=r=>{switch(r){case"text":return new Ht({label:"",required:!1,identifier:G.v4()});case"boolean":return new bt({label:"",required:!1,identifier:G.v4()});case"number":return new qe({label:"",required:!1,identifier:G.v4()});case"date":return new dr({label:"",required:!1,identifier:G.v4()});case"string":return new Gt({label:"",required:!1,identifier:G.v4()});case"select":return new pt({label:"",options:[],required:!1,identifier:G.v4()});case"multi-string":return new Ot({label:"",required:!1,identifier:G.v4()});case"multi-select":return new it({label:"",options:[],required:!1,identifier:G.v4()});case"upload":return new qt({label:"",required:!1,identifier:G.v4(),maximum_files:6,maximum_size:Xt});case"qr":return new wr({label:"",required:!1,identifier:G.v4()});case"radio":return new Vt({label:"",options:[],required:!1,identifier:G.v4()});case"checkbox-list":return new Tt({label:"",options:[],required:!1,identifier:G.v4()});case"pass-fail":return new Pt({label:"",required:!1,identifier:G.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new Dt({label:"",validationType:"none",required:!1,identifier:G.v4(),length:6});case"rating":return new Bt({label:"",required:!1,identifier:G.v4(),maxRating:5})}},qi=r=>{switch(r.type){case"text":return new zr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"boolean":return new Sr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"number":return new Tr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"date":return new Or({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"string":return new Lr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"select":return new Br({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-string":return new Nr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-select":return new br({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"upload":return new kr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"qr":return new Vr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"radio":return new Fr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"checkbox-list":return new Ir({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"pass-fail":return new Mr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"otp":return new Dr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"rating":return new Pr({id:G.v4(),conditionValue:void 0,conditionModifier:"equals",field:r})}},Os=(r,e)=>{switch(r){case"checkbox-list":return Tt.getFieldCreationSchema(e);case"multi-select":return it.getFieldCreationSchema(e);case"number":return qe.getFieldCreationSchema(e);case"radio":return Vt.getFieldCreationSchema(e);case"select":return pt.getFieldCreationSchema(e);case"string":return Gt.getFieldCreationSchema(e);case"text":return Ht.getFieldCreationSchema(e);case"upload":return qt.getFieldCreationSchema(e);case"pass-fail":return Pt.getFieldCreationSchema(e);case"otp":return Dt.getFieldCreationSchema(e);case"rating":return Bt.getFieldCreationSchema(e);default:return}},bs=m.memo(r=>{const{popoverInputs:e,hasError:t,...n}=r;return f.jsxs(v.Popover.Root,{children:[f.jsx(v.Popover.Trigger,{asChild:!0,children:f.jsxs(v.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...t&&{color:Ur.danger},children:[f.jsx(v.LuIcon,{icon:xl}),"Settings"]},"settings")}),f.jsx(v.Popover.Content,{size:"sm",...n,children:f.jsx("div",{className:"flex w-full max-w-[350px] flex-col",children:e})})]})});bs.displayName="FieldSettingsPopover";const Ns=m.memo(r=>{const{parentPath:e,fieldIndex:t,field:n}=r,{errors:i}=rt.useFormikContext(),a=Gr(),{disableRequiredFields:o}=m.use(yn),[s,l]=m.useState(void 0);m.useEffect(()=>{n.image instanceof Promise?n.image.then(l).catch(console.error):l(n.image)},[n]);const u=s?URL.createObjectURL(s):void 0,c=m.useCallback(()=>{n.setOptions({image:void 0})},[n]),[d,p]=m.useMemo(()=>{const A=[],E=[],I=Os(n.type,`${e}.${t}`)??[];for(const N of I)N.showDirectly?A.push(N.field):E.push(N.field);return[A,E]},[n,e,t]),h=ur(d,{formId:xn,disabled:!1,size:"sm"}),g=ur(p,{formId:xn,disabled:!1,size:"sm"}),x=p.length>0,C=p.some(A=>{const E=_n(i,A.identifier);return E&&(typeof E!="object"||Object.values(E).length>0)}),_=m.useCallback(()=>{s&&a(()=>({file:s}))},[a,s]),{fieldTypeName:w}=sn[n.type];return f.jsxs("div",{className:"flex grow w-full flex-col gap-4",children:[f.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[f.jsxs("div",{className:"flex gap-2 items-center",children:[f.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[f.jsx(v.LuIcon,{icon:fe[n.type]}),w]}),!o&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(v.Checkbox.Root,{checked:n.required,onCheckedChange:A=>n.setOptions({required:!!A}),size:"sm",children:f.jsx(v.Checkbox.Indicator,{children:f.jsx(v.LuIcon,{icon:Ge})})}),f.jsx(v.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),x&&f.jsx(bs,{popoverInputs:g,hasError:C,align:"end"})]}),s&&f.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[f.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:u,alt:s.name,onClick:_}),f.jsx(v.IconButton,{type:"button",className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:c,size:"sm",children:f.jsx(v.LuIcon,{icon:ht})})]}),f.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[f.jsx(v.Input.Root,{variant:"outline",size:"md",children:f.jsx(v.Input.Field,{placeholder:"Enter your question",value:n.label??"",onChange:A=>n.setOptions({label:A.target.value}),maxLength:200})}),f.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:n.description??"",onChange:A=>n.setOptions({description:A.target.value}),maxLength:1e3,resize:"vertical",size:"md"})]}),d.length>0&&f.jsx("div",{className:"w-full",children:h})]})});Ns.displayName="FieldBuilder";const Xi=m.memo(r=>{const{field:e,fieldSection:t,fieldIndex:n,sectionIndex:i}=r,a=m.useRef(null),o=`fields.${i}.fields`,s=m.useCallback(x=>{t.addField(wn(x),n+1)},[n,t]),l=m.useCallback(()=>{t.addField(e.duplicate(G.v4()))},[e,t]),u=m.useCallback(x=>{const C=x==="up"?i-1:i+1;t.moveField(n,C)},[t,n,i]),c=m.useCallback(x=>{const{files:C}=x.target;if(!C||C.length!==1)return;const _=C.item(0);if(_){if(_.size>wo){v.toast.error({title:"File upload error",description:`The file ${_.name} exceeded the maximum file size`});return}e.setOptions({image:_})}},[e]),d=m.useCallback(()=>{u("up")},[u]),p=m.useCallback(()=>{u("down")},[u]),h=m.useCallback(()=>{var x;(x=a.current)==null||x.click()},[]),g=m.useCallback(()=>{t.removeField(e)},[e,t]);return f.jsxs(v.Card,{className:"flex items-center justify-between gap-4 w-full",children:[f.jsx(Ns,{fieldIndex:n,field:e,parentPath:o}),f.jsxs(v.ButtonGroup,{className:"flex-col gap-0.5 flex",variant:"ghost",accentColor:"base",size:"sm",children:[f.jsx(Cn,{onSelectFieldType:s,size:"sm",children:f.jsx(v.IconButton,{type:"button",children:f.jsx(v.LuIcon,{icon:je})})}),f.jsx(v.IconButton,{type:"button",onClick:d,children:f.jsx(v.LuIcon,{icon:sa})}),f.jsx(v.IconButton,{type:"button",onClick:p,children:f.jsx(v.LuIcon,{icon:oa})}),f.jsx(v.IconButton,{type:"button",onClick:l,children:f.jsx(v.LuIcon,{icon:En})}),f.jsx(v.IconButton,{type:"button",onClick:h,children:f.jsx(v.LuIcon,{icon:ul})}),f.jsx(v.IconButton,{type:"button",onClick:g,children:f.jsx(v.LuIcon,{icon:ht})})]}),f.jsx("input",{className:"hidden",ref:a,type:"file",accept:"image/*",onChange:c})]})});Xi.displayName="FieldBuilderWithActions";const $i=m.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fields:a,onSelectField:o,...s}=r;return f.jsxs(v.Menu.Root,{...s,children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:f.jsx(v.Menu.Scroll,{children:a.map(l=>f.jsxs(v.Menu.Item,{onSelect:()=>o(l),children:[f.jsx(v.LuIcon,{icon:fe[l.type]}),l.label||Ie]},l.identifier))})})]})});$i.displayName="IssueDataFilterMenu";const Ts=m.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fieldSections:a,onSelectFieldCondition:o,...s}=r;return f.jsxs(v.Menu.Root,{...s,children:[f.jsx(v.Menu.ClickTrigger,{children:e}),f.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:a.map(l=>f.jsxs(v.Menu.Item,{onSelect:()=>o(l),children:[f.jsx(v.LuIcon,{icon:fe[l.type]}),l.label||Ei]},l.identifier))})]})});Ts.displayName="IssueDataFilterMenu";const Ds=m.memo(r=>{const{id:e,sourceX:t,sourceY:n,targetX:i,targetY:a,style:o,markerEnd:s,data:l}=r,{targetSection:u,sourceSection:c,layoutDirection:d}=l,p=m.useMemo(()=>c.getConditions(u.identifier),[c,u.identifier]),h=m.useCallback(()=>{c.removeConditional(u.identifier)},[c,u.identifier]),g=m.useCallback(A=>{c.addCondition(u.identifier,qi(A))},[c,u.identifier]),x=m.useCallback(A=>{c.removeCondition(u.identifier,A)},[c,u.identifier]),[C,_,w]=de.getBezierPath({sourceX:t,sourceY:n,sourcePosition:d==="LR"?de.Position.Right:de.Position.Bottom,targetX:i,targetY:a,targetPosition:d==="LR"?de.Position.Left:de.Position.Top});return f.jsxs(f.Fragment,{children:[f.jsx(de.BaseEdge,{id:e,path:C,style:o,markerEnd:s,labelX:_,labelY:w}),f.jsx(de.EdgeLabelRenderer,{children:f.jsxs(v.Card,{size:"xs",variant:"surface",className:"absolute nodrag nopan pointer-events-auto inline-flex flex-col gap-2 bg-(--base-2)",onMouseDown:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${_}px, ${w}px)`},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(v.Text,{size:"xs",className:"truncate max-w-[280px]",children:c.label||"Untitled section"}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsx($i,{fields:c.fields,onSelectField:g,children:f.jsx(v.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:f.jsx(v.LuIcon,{icon:je})})}),f.jsxs(v.Tooltip.Root,{children:[f.jsx(v.Tooltip.Trigger,{asChild:!0,children:f.jsx(v.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:h,children:f.jsx(v.LuIcon,{icon:ht})})}),f.jsx(v.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),p.length>0&&f.jsx("div",{className:"flex flex-col h-max w-full flex-wrap gap-1",children:p.map(A=>f.jsx(m.Fragment,{children:A.render({onRemove:x})},A.id))})]})})]})});Ds.displayName="FieldSectionConditionEdgeComponent";const Ms=m.memo(r=>{const{data:e,selected:t}=r,{fieldSection:n,index:i,layoutDirection:a}=e,o=m.use(St),s=m.useCallback(()=>{o.removeFieldSection(n)},[o,n]),l=m.useCallback(d=>{n.addField(wn(d))},[n]),u=m.useCallback(()=>{const d=new He({identifier:G.v4(),fields:[]});o.addFieldSection(d),n.addConditional(d.identifier)},[o,n]),c=m.useCallback(()=>{o.addFieldSection(n.duplicate(G.v4()))},[o,n]);return f.jsxs(v.Card,{variant:"surface",className:"cursor-pointer relative bg-(--base-2)","data-selected":t?"true":void 0,children:[f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[f.jsx(v.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:f.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:n.label??"",onChange:d=>n.setOptions({label:d.target.value}),maxLength:200})}),f.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:n.description??"",onChange:d=>n.setOptions({description:d.target.value}),maxLength:1e3,resize:"vertical",size:"md"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(v.Text,{weight:"bold",children:"Fields"}),f.jsx(Cn,{onSelectFieldType:l,size:"sm",children:f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[f.jsx(v.LuIcon,{icon:je})," Add field"]})})]}),f.jsx("div",{className:"flex flex-col gap-3",children:n.fields.map((d,p)=>f.jsx(Xi,{field:d,fieldSection:n,fieldIndex:p,sectionIndex:i},d.identifier))})]}),f.jsx(de.NodeToolbar,{isVisible:!0,position:de.Position.Right,align:"start",offset:8,onMouseDown:d=>d.stopPropagation(),children:f.jsx(v.Card,{variant:"surface",className:"flex flex-col items-center gap-1 p-1 bg-(--base-2)",size:"xs",onClick:d=>d.stopPropagation(),children:f.jsxs(v.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[f.jsx(v.IconButton,{type:"button",onClick:u,children:f.jsx(v.LuIcon,{icon:sl})}),f.jsx(v.IconButton,{type:"button",onClick:c,children:f.jsx(v.LuIcon,{icon:En})}),f.jsx(v.IconButton,{type:"button",onClick:s,children:f.jsx(v.LuIcon,{icon:ht})})]})})}),f.jsx(de.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?de.Position.Left:de.Position.Top}),f.jsx(de.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?de.Position.Right:de.Position.Bottom})]})});Ms.displayName="CustomNode";const Cf={fieldSection:Ms},wf={fieldSectionCondition:Ds},mf=(r,e,t)=>{const n=new Ki.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return n.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(i=>n.setEdge(i.source,i.target,{width:500,height:200,labelpos:"c"})),r.forEach(i=>{var a,o;return n.setNode(i.id,{...i,width:((a=i.measured)==null?void 0:a.width)??0,height:((o=i.measured)==null?void 0:o.height)??0})}),Ki.layout(n),[r.map(i=>{var l,u;const a=n.node(i.id),o=a.x-(((l=i.measured)==null?void 0:l.width)??0)/2,s=a.y-(((u=i.measured)==null?void 0:u.height)??0)/2;return{...i,position:{x:o,y:s}}}),e]},_f={hideAttribution:!0},Fs=m.memo(()=>{const{handleSubmit:r,errors:e}=rt.useFormikContext(),{onCancel:t}=m.use(yn),n=m.use(St),i=m.useRef(null),[a,o]=m.useState(),[s,l]=m.useState("TB");m.useLayoutEffect(()=>{i.current&&i.current.classList.remove("light")},[]);const u=m.useMemo(()=>n.fieldSections.map((N,D)=>({id:N.identifier,position:{x:0,y:0},data:{index:D,fieldSection:N,layoutDirection:s},draggable:!0,type:"fieldSection"})),[n.fieldSections,s]),c=m.useMemo(()=>{const N=[],D={};for(const M of n.fieldSections)D[M.identifier]=M;for(const M of n.fieldSections){const F=M.conditions;for(const[V,j]of Object.entries(F))N.push({id:`${M.identifier}-${V}`,source:M.identifier,target:V,data:{targetSection:D[V],sourceSection:M,layoutDirection:s},animated:j.length>0,markerEnd:de.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return N},[n.fieldSections,s]),[d,p,h]=de.useNodesState(u),[g,x,C]=de.useEdgesState(c);m.useEffect(()=>{p(u)},[u,p]),m.useEffect(()=>{x(c)},[c,x]);const[_,w]=m.useMemo(()=>mf(d,g,s),[g,s,d]),A=m.useCallback(()=>{n.addFieldSection(new He({identifier:G.v4(),fields:[]}))},[n]),E=m.useCallback(N=>{const{source:D,target:M}=N,F=n.fieldSections.find(({identifier:V})=>V===D);F.setOptions({conditions:{...F.conditions,[M]:[]}})},[n.fieldSections]),I=m.useCallback(N=>{const D=n.getSectionDependencyGraph();return!ji.willCreateCycle(D,N.source,N.target)},[n]);return f.jsxs("form",{className:"size-full flex flex-col gap-4",id:xn,onSubmit:r,children:[f.jsxs(v.Card,{className:"size-full relative",variant:"outline",children:[f.jsx(de.ReactFlow,{ref:i,onInit:o,nodes:_,onNodesChange:h,edges:w,onEdgesChange:C,nodeTypes:Cf,edgeTypes:wf,onConnect:E,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:I,proOptions:_f}),f.jsx(de.Panel,{position:"top-left",children:f.jsx(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:f.jsxs(v.Button,{type:"button",variant:"surface",onClick:A,children:[f.jsx(v.LuIcon,{icon:je})," Add section"]})})}),f.jsxs(de.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[f.jsxs(v.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:s,onValueChange:l,children:[f.jsx(v.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:f.jsx(v.LuIcon,{icon:Ks})}),f.jsx(v.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:f.jsx(v.LuIcon,{icon:Zs})})]}),f.jsx(v.Separator,{size:"sm"}),f.jsxs(v.ButtonGroup,{className:"flex flex-col ",size:"sm",accentColor:"base",variant:"soft",children:[f.jsx(v.IconButton,{className:"rounded-b-none",onClick:()=>a==null?void 0:a.zoomIn(),type:"button",children:f.jsx(v.LuIcon,{icon:je})}),f.jsx(v.IconButton,{onClick:()=>a==null?void 0:a.zoomOut(),radius:"none",type:"button",children:f.jsx(v.LuIcon,{icon:Rr})}),f.jsx(v.IconButton,{className:"rounded-t-none",onClick:()=>a==null?void 0:a.fitView(),type:"button",children:f.jsx(v.LuIcon,{icon:Cl})})]})]}),f.jsx(de.Panel,{position:"bottom-right",children:f.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[t&&f.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:t,children:"Cancel"}),f.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!e.fields&&f.jsx(v.Text,{size:"xs",accentColor:"danger",children:typeof e.fields=="string"&&e.fields})]})});Fs.displayName="FormBuilderFlowBuilder";const Ps=m.memo(r=>{const{sourceFieldSection:e,targetFieldSection:t}=r,n=m.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),i=m.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),a=m.useCallback(s=>{e.addCondition(t.identifier,qi(s))},[e,t.identifier]),o=m.useCallback(s=>{e.removeCondition(t.identifier,s)},[e,t.identifier]);return f.jsxs(v.Card,{className:"flex flex-col gap-2",children:[f.jsxs(v.ButtonGroup,{className:"justify-between gap-2 flex",size:"sm",accentColor:"base",variant:"soft",children:[f.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[f.jsx(v.LuIcon,{icon:fe.section}),e.label??Ei]}),f.jsx(v.IconButton,{type:"button",onClick:i,variant:"ghost",children:f.jsx(v.LuIcon,{icon:ht})})]}),f.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[n.map(s=>s.render({onRemove:o})),f.jsx($i,{fields:e.fields,onSelectField:a,align:"start",children:f.jsx(v.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:f.jsx(v.LuIcon,{icon:je})})})]})]})});Ps.displayName="FieldSectionConditionalItem";const Vs=m.memo(r=>{const{fieldSection:e}=r,t=m.use(St),n=m.useMemo(()=>t.fieldSections.filter(o=>e.identifier in o.conditions),[t.fieldSections,e.identifier]),i=m.useCallback(o=>{o.addConditional(e.identifier)},[e.identifier]),a=m.useMemo(()=>{const o=t.getSectionDependencyGraph();return t.fieldSections.filter(s=>!ji.willCreateCycle(o,s.identifier,e.identifier))},[e.identifier,t]);return f.jsxs("div",{className:"flex grow w-full flex-col gap-4",children:[f.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[f.jsx(v.Input.Root,{variant:"outline",size:"md",children:f.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:o=>e.setOptions({label:o.target.value}),maxLength:200})}),f.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:o=>e.setOptions({description:o.target.value}),maxLength:1e3,resize:"vertical",size:"md"})]}),f.jsx(v.Separator,{size:"full"}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex gap-2 justify-between",children:[f.jsx(v.Text,{accentColor:"base",children:"Conditions"}),f.jsx(Ts,{fieldSections:a,onSelectFieldCondition:i,children:f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[f.jsx(v.LuIcon,{icon:je}),"Add condition"]})})]}),n.map(o=>f.jsx(Ps,{sourceFieldSection:o,targetFieldSection:e},o.identifier))]}),f.jsx(v.Separator,{size:"full"})]})});Vs.displayName="FieldSectionBuilder";const Bs=m.memo(r=>{const{fieldSection:e,sectionIndex:t}=r,n=m.use(St),i=v.useAlertDialog(),a=m.useCallback(()=>{n.removeFieldSection(e)},[n,e]),o=m.useCallback(x=>{const C=x==="up"?t-1:t+1;n.moveFieldSection(t,C)},[n,t]),s=m.useCallback(()=>{n.addFieldSection(e.duplicate(G.v4()))},[n,e]),l=m.useCallback(x=>{e.addField(wn(x))},[e]),u=m.useCallback(()=>{o("up")},[o]),c=m.useCallback(()=>{o("down")},[o]),d=m.useCallback(async()=>{const x=[e.serialize()],C=dt.reseedFieldSections(x,{conditions:!1}),_=JSON.stringify(C);await navigator.clipboard.writeText(_),v.toast.success({title:"Section copied"})},[e]),p=m.useCallback(async()=>{const C=n.getDependenciesOfSection(e.identifier).map(A=>A.serialize()),_=dt.reseedFieldSections(C,{conditions:!0}),w=JSON.stringify(_);await navigator.clipboard.writeText(w),v.toast.success({title:"Section copied"})},[e,n]),h=m.useCallback(async()=>{const x=n.getDependenciesOfSection(e.identifier),C=x.length>1,_=x.length-1;C?i({title:"Copy section dependencies?",description:`This section has ${_} dependent section${_>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:p,cancel:"Dont include",onCancel:d}):d()},[e,n,i,p,d]),g=m.useCallback(async()=>{let x="";try{x=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const C=x.trim();if(!C){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let _;try{_=JSON.parse(C)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const w=Array.isArray(_)?_:[_],A=[];for(const E of w){if(!E||typeof E!="object")continue;const I=E;if(I.type!=="section"||!Array.isArray(I.fields))continue;const N={type:"section",identifier:typeof I.identifier=="string"?I.identifier:G.v4(),label:typeof I.label=="string"||I.label===null?I.label:null,description:typeof I.description=="string"||I.description===null?I.description:null,conditions:I.conditions&&typeof I.conditions=="object"?I.conditions:{},fields:I.fields};try{A.push(He.deserialize(N))}catch{}}if(A.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}A.forEach((E,I)=>{n.addFieldSection(E,t+1+I)}),v.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[n,t]);return f.jsxs(v.Card,{variant:"outline",className:"flex items-center justify-between gap-4 w-full",children:[f.jsxs("div",{className:"flex grow flex-col gap-4 w-full",children:[f.jsx(Vs,{fieldSection:e}),f.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[f.jsxs("div",{className:"flex gap-2 justify-between",children:[f.jsx(v.Text,{accentColor:"base",size:"md",children:"Fields"}),f.jsx(Cn,{onSelectFieldType:l,size:"sm",children:f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",children:[f.jsx(v.LuIcon,{icon:je})," Add field"]})})]}),e.fields.map((x,C)=>f.jsx(Xi,{field:x,fieldSection:e,fieldIndex:C,sectionIndex:t},x.identifier))]})]}),f.jsxs(v.ButtonGroup,{className:"flex-col gap-0.5 flex",variant:"ghost",accentColor:"base",size:"sm",children:[f.jsx(v.IconButton,{type:"button",onClick:u,children:f.jsx(v.LuIcon,{icon:sa})}),f.jsx(v.IconButton,{type:"button",onClick:c,children:f.jsx(v.LuIcon,{icon:oa})}),f.jsxs(v.Menu.Root,{align:"end",children:[f.jsx(v.Menu.ClickTrigger,{children:f.jsx(v.IconButton,{type:"button",children:f.jsx(v.LuIcon,{icon:ia})})}),f.jsxs(v.Menu.Content,{size:"sm",children:[f.jsxs(v.Menu.Item,{onSelect:s,children:[f.jsx(v.LuIcon,{icon:En}),"Duplicate section"]}),f.jsxs(v.Menu.Item,{onSelect:h,children:[f.jsx(v.LuIcon,{icon:ta}),"Copy JSON"]}),f.jsxs(v.Menu.Item,{onSelect:g,children:[f.jsx(v.LuIcon,{icon:ra}),"Paste JSON"]}),f.jsxs(v.Menu.Item,{onSelect:a,children:[f.jsx(v.LuIcon,{icon:ht}),"Delete section"]})]})]})]})]})});Bs.displayName="FieldSectionWithActions";const Ls=m.memo(()=>{const{handleSubmit:r,errors:e}=rt.useFormikContext(),{onCancel:t}=m.use(yn),n=m.use(St),i=m.useCallback(()=>{n.addFieldSection(new He({identifier:G.v4(),fields:[]}))},[n]),a=m.useCallback(async()=>{try{const s=n.serialize(),l=dt.reseedFieldSections(s),u=JSON.stringify(l);await navigator.clipboard.writeText(u),v.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{v.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[n]),o=m.useCallback(async()=>{let s="";try{s=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const l=s.trim();if(!l){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let u;try{u=JSON.parse(l)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const c=Array.isArray(u)?u:[u],d=[];for(const h of c){if(!h||typeof h!="object")continue;const g=h;if(g.type!=="section"||!Array.isArray(g.fields))continue;const x={type:"section",identifier:typeof g.identifier=="string"?g.identifier:G.v4(),label:typeof g.label=="string"||g.label===null?g.label:null,description:typeof g.description=="string"||g.description===null?g.description:null,conditions:g.conditions&&typeof g.conditions=="object"?g.conditions:{},fields:g.fields};try{d.push(He.deserialize(x))}catch{}}if(d.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const p=n.fieldSections.length;d.forEach((h,g)=>{n.addFieldSection(h,p+g)}),v.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[n]);return f.jsxs("form",{className:"flex flex-col gap-4",id:xn,onSubmit:r,children:[f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:a,children:[f.jsx(v.LuIcon,{icon:ta})," Copy JSON"]}),f.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:o,children:[f.jsx(v.LuIcon,{icon:ra})," Paste JSON"]})]}),n.fieldSections.map((s,l)=>f.jsx(Bs,{fieldSection:s,sectionIndex:l},s.identifier)),f.jsxs(v.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:i,children:[f.jsx(v.LuIcon,{icon:je})," Add section"]})]}),!!e.fields&&f.jsx(v.Text,{size:"xs",accentColor:"danger",children:typeof e.fields=="string"&&e.fields}),f.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[t&&f.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:t,children:"Cancel"}),f.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});Ls.displayName="FormBuilderListBuilder";const zs=m.memo(m.forwardRef((r,e)=>{const{readonly:t=!1,fieldSchema:n,values:i={},onValuesChange:a,onSubmit:o,submitText:s="Submit",hideSubmit:l=!1,cancelText:u,onCancel:c,hideCancel:d=!1,onDirty:p,onDirtyChange:h,className:g,buttonProps:x,enableReinitialize:C=!1,excludeUnchangedFields:_=!1,size:w="md"}=r,A=m.useId(),E=m.useMemo(()=>n.initializeValues(i),[n,i]),I=m.useCallback(U=>{o==null||o(_?n.changedFieldValues(E,U):U)},[_,E,o,n]),N=rt.useFormik({initialValues:E,onSubmit:I,validate:U=>n.validateValues(U),validateOnBlur:!1,validateOnChange:!1,enableReinitialize:!1});m.useLayoutEffect(()=>{C&&N.resetForm({values:E})},[C,E]);const{dirty:D}=N,M=m.useCallback((U,ae)=>{xs(gs(n.getFieldSections()))[U].areValuesEqual(E[U],ae)||a==null||a({...N.values,[U]:ae},{[U]:ae})},[N.values,E,a,n]),F=m.useMemo(()=>({formId:A,disabled:t,onValuesChange:M,size:w}),[A,M,t,w]),V=ur(n.getFieldSections(),F);m.useEffect(()=>{D&&p&&p(),h&&h(D)},[D,p,h]);const j=m.useMemo(()=>({fieldSchema:n,size:w}),[n,w]),R=!d&&!!c,Z=!l;return f.jsx(rt.FormikProvider,{value:N,children:f.jsx(Is,{value:j,children:f.jsxs("form",{id:A,ref:e,className:or.cx(g,"flex flex-col gap-4"),onSubmit:N.handleSubmit,children:[V,!t&&(R||Z)?f.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:w,children:[R?f.jsxs(v.Button,{accentColor:"base",...x,type:"button",variant:"soft",onClick:c,children:[f.jsx(v.LuIcon,{icon:nt}),u]}):null,Z?f.jsxs(v.Button,{...x,type:"submit",accentColor:"primary",variant:"surface",children:[f.jsx(v.LuIcon,{icon:Ge}),s]}):null]}):null]})})})})),ks=m.memo(()=>{const r=m.use(St);return f.jsx(zs,{fieldSchema:r,readonly:!1})});ks.displayName="FormBuilderPreview";const Rs=m.memo(r=>{const{children:e,initialFields:t,onSave:n,onCancel:i,enableReinitialize:a=!1,disableRequiredFields:o=!1}=r,s=m.useCallback(h=>{var w;const g={};(!h.fields||h.fields.length===0)&&(g.fields="At least one field is required.");const x=[];for(const[A,E]of h.fields.entries())for(const[I,N]of E.fields.entries()){const D=((w=Os(N.type,`fields.${A}.fields.${I}`))==null?void 0:w.map(({field:M})=>M))??[];x.push(...D)}const C={};for(const A of x)C[A.identifier]=_n(h,A.identifier);const _=Gi(x,C);if(_&&(g.fields=_.fields),Object.keys(g).length>0)return v.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),g},[]),l=m.useMemo(()=>({fields:t??[]}),[t]),u=rt.useFormik({initialValues:l,validate:s,onSubmit:n,validateOnChange:!1,validateOnBlur:!1,enableReinitialize:a}),c=m.useCallback(h=>{u.setFieldValue("fields",h.serialize())},[u]),d=m.useMemo(()=>{const h=dt.deserialize(u.values.fields);return h.observe(c),h},[u.values.fields,c]),p=m.useMemo(()=>({disableRequiredFields:o,onCancel:i}),[o,i]);return f.jsx(yn,{value:p,children:f.jsx(St,{value:d,children:f.jsx(rt.FormikProvider,{value:u,children:e})})})});Rs.displayName="FormBuilderRoot";const Af={Root:Rs,FlowBuilder:Fs,ListBuilder:Ls,Preview:ks};S.BaseCondition=Me,S.BaseField=Pe,S.BaseFormElement=On,S.BaseOptionsField=cr,S.BaseStringField=Mn,S.BooleanEqualsConditionModifier=mo,S.BooleanField=bt,S.BooleanFieldCondition=Sr,S.BooleanFieldConditionCell=zo,S.BooleanFieldInput=Tn,S.BooleanNotEqualsConditionModifier=_o,S.CheckboxListField=Tt,S.CheckboxListFieldCondition=Ir,S.CheckboxListFieldConditionCell=Ro,S.CheckboxListFieldInput=Fn,S.ConditionManager=pn,S.DateAfterConditionModifier=Io,S.DateBeforeConditionModifier=So,S.DateEqualsConditionModifier=Ao,S.DateField=dr,S.DateFieldCondition=Or,S.DateFieldConditionCell=Go,S.DateFieldInput=Pn,S.DateNotEqualsConditionModifier=Eo,S.DateRangeInConditionModifier=Oo,S.DateRangeNotInConditionModifier=bo,S.DoesNotHaveFilesConditionModifier=To,S.FieldSchema=dt,S.FieldSection=He,S.FieldSectionLayout=Hi,S.FieldTypeToClsMapping=sn,S.FieldsRenderer=zs,S.FileCard=In,S.FormBuilder=Af,S.HasFilesConditionModifier=No,S.ImageCard=ha,S.ImageFile=Hr,S.ImageViewer=bn,S.ImageViewerProvider=da,S.InputWithHelpText=Oe,S.InputWithLabel=be,S.LONG_TEXT_FIELD_MAX_LENGTH=Nt,S.MultiSelectField=it,S.MultiSelectFieldCondition=br,S.MultiSelectFieldConditionCell=qo,S.MultiSelectFieldInput=Vn,S.MultiStringField=Ot,S.MultiStringFieldCondition=Nr,S.MultiStringFieldConditionCell=$o,S.MultiStringFieldInput=Nn,S.NumberEqualsConditionModifier=Si,S.NumberField=qe,S.NumberFieldCondition=Tr,S.NumberFieldConditionCell=jo,S.NumberFieldInput=Dn,S.NumberGreaterThanConditionModifier=Ni,S.NumberGreaterThanOrEqualsConditionModifier=Ti,S.NumberLessThanConditionModifier=Oi,S.NumberLessThanOrEqualsConditionModifier=bi,S.NumberNotEqualsConditionModifier=Ii,S.NumberRangeInConditionModifier=Di,S.NumberRangeNotInConditionModifier=Mi,S.OTPField=Dt,S.OTPFieldCondition=Dr,S.OTPFieldConditionCell=Zo,S.OTPFieldInput=Ln,S.Observable=lr,S.PassFailArrayExcludesConditionModifier=Po,S.PassFailArrayIncludesConditionModifier=Fo,S.PassFailEqualsConditionModifier=Do,S.PassFailField=Pt,S.PassFailFieldCondition=Mr,S.PassFailFieldConditionCell=Qo,S.PassFailFieldInput=kn,S.PassFailNotEqualsConditionModifier=Mo,S.RadioField=Vt,S.RadioFieldCondition=Fr,S.RadioFieldConditionCell=es,S.RadioFieldInput=Un,S.RatingField=Bt,S.RatingFieldCondition=Pr,S.RatingFieldConditionCell=rs,S.RatingFieldInput=Gn,S.SEVERITY_COLOR_MAPPING=Ur,S.SHORT_TEXT_FIELD_MAX_LENGTH=on,S.ScanField=wr,S.ScanFieldCondition=Vr,S.ScanFieldConditionCell=is,S.ScanFieldInput=wi,S.Scanner=an,S.ScannerProvider=yo,S.SelectField=pt,S.SelectFieldCondition=Br,S.SelectFieldConditionCell=os,S.SelectFieldInput=Bn,S.StringArrayEqualsConditionModifier=dn,S.StringArrayEveryConditionModifier=ln,S.StringArrayExcludesConditionModifier=Pi,S.StringArrayIncludesConditionModifier=Fi,S.StringArrayNoneConditionModifier=cn,S.StringArrayNotEqualsConditionModifier=fn,S.StringArraySomeConditionModifier=un,S.StringEqualsConditionModifier=mt,S.StringExcludesConditionModifier=_r,S.StringField=Gt,S.StringFieldCondition=Lr,S.StringFieldConditionCell=ls,S.StringFieldInput=mi,S.StringIncludesConditionModifier=mr,S.StringNotEqualsConditionModifier=_t,S.TextField=Ht,S.TextFieldCondition=zr,S.TextFieldConditionCell=cs,S.TextFieldInput=_i,S.UNLABELLED_FIELD_LABEL=Ie,S.UNLABELLED_SECTION_LABEL=Ei,S.UUIDFile=at,S.UUIDPromise=Ft,S.UploadField=qt,S.UploadFieldCondition=kr,S.UploadFieldConditionCell=fs,S.UploadFieldInput=Ai,S.areFieldValuesBlank=Ss,S.areFieldValuesEqual=Ri,S.areFileAndPromiseArraysEqual=qr,S.arePassFieldValuesEqual=ya,S.areSerializedPassFailFieldValuesEqual=Ca,S.awaitFilesAndPromises=xf,S.blankFieldValues=Ui,S.changedFieldValues=As,S.cleanFieldValues=gn,S.cleanSerializedFieldValues=ki,S.createCondition=qi,S.createConditionModifierConfig=L,S.createField=wn,S.deserialize=vs,S.deserializeCondition=ps,S.deserializeConditions=zi,S.deserializeField=vn,S.deserializeFieldValues=Cs,S.deserializeFields=ff,S.deserializeOnlyFields=hf,S.deserializePassFailFieldValue=xa,S.extractFilesAndPromisesFromFieldValues=ws,S.fieldIcons=fe,S.flattenFields=gs,S.getFieldsMapping=xs,S.initializeFieldValues=_s,S.insertFilesAndPromisesToFieldValues=ms,S.isFileAndPromiseArray=fa,S.isPassFailFieldStatus=Rn,S.isPassFailFieldValue=va,S.isSerializedPassFailFieldValue=pa,S.isStringArray=sr,S.maxFileSizeB=wo,S.maxFileSizeKB=Co,S.maxFileSizeMB=Xt,S.passFailFieldStatusMapping=vt,S.passFailFieldStatuses=Mt,S.separateImagesFromFields=gf,S.serializeFieldValues=ys,S.serializePassFailFieldValue=ga,S.unchangedFieldValues=Es,S.useConditionManager=cf,S.useFieldInput=ml,S.useFieldInputs=ur,S.useFormikInput=Ne,S.useImageViewer=Gr,S.useObjectUrl=ca,S.useScanner=_l,S.validateFields=Gi,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overmap-ai/forms",
3
- "version": "1.0.36-fields-renderer-size.0",
3
+ "version": "1.0.36-fields-renderer-size.1",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"