@fungi.computer/prints 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -88,4 +88,4 @@ Error generating stack: `+e.message+`
88
88
  @#[line:`+e.lineNumber+`,col:`+e.columnNumber+`]`}function y(e,t,n){return typeof e==`string`?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+``:e}`endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl`.replace(/\w+/g,function(e){g.prototype[e]=function(){return null}});function b(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}function x(e){if(e===`error`)throw`onErrorStopParsing`}function S(){throw`onWarningStopParsing`}e.__DOMHandler=g,e.DOMParser=h,e.normalizeLineEndings=m,e.onErrorStopParsing=x,e.onWarningStopParsing=S})),LR=o((e=>{var t=AR();e.assign=t.assign,e.hasDefaultHTMLNamespace=t.hasDefaultHTMLNamespace,e.isHTMLMimeType=t.isHTMLMimeType,e.isValidMimeType=t.isValidMimeType,e.MIME_TYPE=t.MIME_TYPE,e.NAMESPACE=t.NAMESPACE;var n=jR();e.DOMException=n.DOMException,e.DOMExceptionName=n.DOMExceptionName,e.ExceptionCode=n.ExceptionCode,e.ParseError=n.ParseError;var r=NR();e.Attr=r.Attr,e.CDATASection=r.CDATASection,e.CharacterData=r.CharacterData,e.Comment=r.Comment,e.Document=r.Document,e.DocumentFragment=r.DocumentFragment,e.DocumentType=r.DocumentType,e.DOMImplementation=r.DOMImplementation,e.Element=r.Element,e.Entity=r.Entity,e.EntityReference=r.EntityReference,e.LiveNodeList=r.LiveNodeList,e.NamedNodeMap=r.NamedNodeMap,e.Node=r.Node,e.NodeList=r.NodeList,e.Notation=r.Notation,e.ProcessingInstruction=r.ProcessingInstruction,e.Text=r.Text,e.XMLSerializer=r.XMLSerializer;var i=IR();e.DOMParser=i.DOMParser,e.normalizeLineEndings=i.normalizeLineEndings,e.onErrorStopParsing=i.onErrorStopParsing,e.onWarningStopParsing=i.onWarningStopParsing}))(),RR=class{constructor(e){if(zR(e))throw Error(`DataView: Passed buffer type is unsupported.`);this.buffer=e,this.byteLength=this.buffer.length}getUint8(e){return this.buffer.readUInt8(e)}getUint16(e,t){return t?this.buffer.readUInt16LE(e):this.buffer.readUInt16BE(e)}getUint32(e,t){return t?this.buffer.readUInt32LE(e):this.buffer.readUInt32BE(e)}getInt32(e,t){return t?this.buffer.readInt32LE(e):this.buffer.readInt32BE(e)}};function zR(e){return typeof e!=`object`||e.length===void 0||e.readUInt8===void 0||e.readUInt16LE===void 0||e.readUInt16BE===void 0||e.readUInt32LE===void 0||e.readUInt32BE===void 0||e.readInt32LE===void 0||e.readInt32BE===void 0}function BR(e,t,n){try{return new DataView(e,t,n)}catch{return new RR(e,t,n)}}function VR(e,t,n){let r=[];for(let i=0;i<n&&t+i<e.byteLength;i++)r.push(e.getUint8(t+i));return GR(r)}function HR(e,t){let n=[],r=0;for(;t+r<e.byteLength;){let i=e.getUint8(t+r);if(i===0)break;n.push(i),r++}return GR(n)}function UR(e,t,n){let r=[];for(let i=0;i+2<=n&&t+i+2<=e.byteLength;i+=2)r.push(e.getUint16(t+i));return r[r.length-1]===0&&r.pop(),GR(r)}function WR(e,t){let n=e.getUint8(t);return[n,VR(e,t+1,n)]}function GR(e){return e.map(e=>String.fromCharCode(e)).join(``)}function KR(e){let t=qR(e);return t===void 0?e:t}function qR(e){try{return decodeURIComponent(escape(e))}catch{return}}function JR(e,t,n,r){e&&t&&e.push({type:t,start:n,end:r})}function YR(){if(typeof Promise>`u`)throw Error(`Promise is required when async mode is enabled.`)}function XR(){for(let e=1;e<arguments.length;e++)for(let t in arguments[e])ZR(arguments[0],t,arguments[e][t]);return arguments[0]}function ZR(e,t,n){if(t===`__proto__`){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0});return}e[t]=n}function QR(e,t,n){let r=!1;Object.defineProperty(e,t,{get(){return r||(r=!0,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n.apply(e),writable:!0})),e[t]},configurable:!0,enumerable:!0})}function $R(e){if(typeof btoa<`u`)return btoa(typeof e==`string`?e:Array.prototype.reduce.call(new Uint8Array(e),(e,t)=>e+String.fromCharCode(t),``));if(!(typeof Buffer>`u`))return Buffer.from===void 0?new Buffer(e).toString(`base64`):Buffer.from(e).toString(`base64`)}function ez(e){let t=e.substring(e.indexOf(`,`)+1);if(e.indexOf(`;base64`)!==-1)return typeof atob<`u`?Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer:typeof Buffer>`u`?void 0:Buffer.from===void 0?new Buffer(t,`base64`):Buffer.from(t,`base64`);let n=decodeURIComponent(t);return typeof Buffer<`u`?Buffer.from===void 0?new Buffer(n):Buffer.from(n):Uint8Array.from(n,e=>e.charCodeAt(0)).buffer}function tz(e,t,n){return rz(n,Math.max(0,t-e.length))+e}function nz(e,t){return parseInt(e.replace(`.`,``),t)/t**+(e.split(`.`)[1]||``).length}function rz(e,t){return Array(t+1).join(e)}var iz=`brotli`,az=134217728;function oz(e,t,n,r=`string`,i){let a=sz(i);if(i&&t!==void 0){let o=i[t===0?`deflate`:`brotli`];if(typeof o==`function`){let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return Promise.resolve(o(t)).then(e=>dz(e)>a?fz(a):r===`dataview`?e instanceof ArrayBuffer?new DataView(e):e.byteOffset===0&&e.byteLength===e.buffer.byteLength?new DataView(e.buffer):new DataView(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)):new TextDecoder(n).decode(e))}}if(t===0&&typeof DecompressionStream==`function`)return cz(e,`deflate`,a).then(e=>uz(e,r,n));if(t===`brotli`){if(typeof DecompressionStream==`function`)try{return cz(e,`brotli`,a).then(e=>uz(e,r,n))}catch{}return Promise.reject(`Brotli decompression is not supported in this environment. Pass in a brotli decompression function via the decompress option.`)}if(t!==void 0)return Promise.reject(`Unknown compression method ${t}.`);if(r===`string`)try{return new TextDecoder(n).decode(e)}catch{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return Array.from(t,e=>String.fromCharCode(e)).join(``)}return e}function sz(e){return e&&typeof e.maxDecompressedSize==`number`?e.maxDecompressedSize:az}function cz(e,t,n){let r=new DecompressionStream(t),i=new Blob([e]).stream().pipeThrough(r).getReader(),a=[],o=0;return s();function s(){return i.read().then(({done:e,value:t})=>e?lz(a,o):(o+=t.byteLength,o>n?i.cancel().then(()=>fz(n)):(a.push(t),s())))}}function lz(e,t){let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].byteLength;return n.buffer}function uz(e,t,n){return t===`dataview`?new DataView(e):new TextDecoder(n).decode(e)}function dz(e){return e&&typeof e.byteLength==`number`?e.byteLength:0}function fz(e){return typeof console<`u`&&typeof console.warn==`function`&&console.warn(`ExifReader: skipped a compressed metadata block that would exceed the maximum decompressed size of ${e} bytes.`),Promise.reject(`Decompressed metadata exceeded the maximum allowed size of ${e} bytes.`)}function pz(e){return typeof e==`string`}function mz(e){return typeof File<`u`&&e instanceof File}function hz(e){return/^data:[^;,]*(;base64)?,/.test(e)}function gz(e,t){return/^\w+:\/\//.test(e)?typeof fetch<`u`?yz(e,vz(t)).then(e=>e.buffer):Cz(e,vz(t)).then(e=>e.buffer):hz(e)?Promise.resolve(ez(e)):Dz(e,vz(t)).then(e=>e.buffer)}function _z(e,t){return jz(e,vz(t)).then(e=>e.buffer)}function vz(e){return e&&Number.isInteger(e.length)&&e.length>=0?{start:0,end:e.length}:{start:0}}function yz(e,{start:t=0,end:n}={}){let r={method:`GET`};return(t>0||n!==void 0&&n!==1/0)&&(r.headers={range:bz(t,n)}),fetch(e,r).then(e=>{let t=e&&typeof e.status==`number`?e.status:void 0;if(t!==void 0&&!Sz(t)){let n=e.statusText||``;return Promise.reject(Error(`Could not fetch file: ${t} ${n}`.trim()))}let n=xz(e);return Promise.resolve(e.arrayBuffer()).then(e=>({buffer:e,totalSize:n,status:t}))})}function bz(e,t){return t===void 0||t===1/0?`bytes=${e}-`:`bytes=${e}-${t-1}`}function xz(e){if(!(!e||!e.headers||typeof e.headers.get!=`function`))return Tz(e.headers.get(`Content-Range`),e.headers.get(`Content-Length`))}function Sz(e){return e>=200&&e<=299||e===416}function Cz(e,{start:t=0,end:n}={}){return new Promise((r,i)=>{let a={};(t>0||n!==void 0&&n!==1/0)&&(a.headers={range:bz(t,n)}),Ez(e)(e,a,e=>{if(e.statusCode>=200&&e.statusCode<=299){let t=wz(e),n=[];e.on(`data`,e=>n.push(Buffer.from(e))),e.on(`error`,e=>i(e)),e.on(`end`,()=>r({buffer:Buffer.concat(n),totalSize:t,status:e.statusCode}))}else e.statusCode===416?(e.resume(),r({buffer:Buffer.alloc(0),totalSize:wz(e),status:e.statusCode})):(i(Error(`Could not fetch file: ${e.statusCode} ${e.statusMessage}`)),e.resume())}).on(`error`,e=>i(e))})}function wz(e){if(!(!e||!e.headers))return Tz(e.headers[`content-range`],e.headers[`content-length`])}function Tz(e,t){if(e){let t=/\/(\d+|\*)$/.exec(e);if(t&&t[1]!==`*`)return parseInt(t[1],10)}if(t){let e=parseInt(t,10);if(Number.isFinite(e))return e}}function Ez(e){return/^https:\/\//.test(e)?__non_webpack_require__(`https`).get:__non_webpack_require__(`http`).get}function Dz(e,{start:t=0,end:n,totalSize:r}={}){return new Promise((i,a)=>{let o=Az();o.open(e,(s,c)=>{if(s)return a(s);Oz(o,e,r,(r,s)=>{if(r)return o.close(c,()=>a(r));let l=n===void 0||n===1/0||n>s?s:n,u=Math.min(Math.max(0,t),l),d=l-u,f=Buffer.alloc(d);if(d===0)return o.close(c,t=>kz(e,t,f,s,i));o.read(c,{buffer:f,length:d,position:u},t=>{if(t)return o.close(c,()=>a(t));o.close(c,t=>kz(e,t,f,s,i))})})})})}function Oz(e,t,n,r){if(n!==void 0)return r(null,n);e.stat(t,(e,t)=>r(e,e?void 0:t.size))}function kz(e,t,n,r,i){t&&console.warn(`Could not close file ${e}:`,t),i({buffer:n,totalSize:r})}function Az(){try{return __non_webpack_require__(`fs`)}catch{return}}function jz(e,{start:t=0,end:n}={}){return new Promise((r,i)=>{let a=new FileReader,o=typeof e.size==`number`?e.size:void 0;if(a.onload=e=>r({buffer:e.target.result,totalSize:o}),a.onerror=()=>i(a.error),e&&typeof e.slice==`function`&&(t>0||n!==void 0&&n!==1/0)){let r=n===void 0||n===1/0?o:n;a.readAsArrayBuffer(e.slice(t,r))}else a.readAsArrayBuffer(e)})}function Mz(e,t){if(!e)return t;if(!t)return e;if(typeof Buffer<`u`&&Buffer.isBuffer(e)&&Buffer.isBuffer(t))return Buffer.concat([e,t]);let n=Nz(e),r=Nz(t),i=new Uint8Array(n.byteLength+r.byteLength);return i.set(n,0),i.set(r,n.byteLength),i.buffer}function Nz(e){return e instanceof ArrayBuffer?new Uint8Array(e):typeof Buffer<`u`&&Buffer.isBuffer(e)||ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Pz=131072,Fz=4,Iz=`length: "auto" could not locate metadata in this file (no metadata blocks found after reading the file — e.g. plain TIFF, bare JPEG XL codestream, or a file with no recognizable metadata).`,Lz=`length: "auto" is not supported for this file type (no leading metadata container — e.g. plain TIFF or bare JPEG XL codestream).`;function Rz(e){if(e.expanded!==!0||e.includeOffsets!==!0)throw Error(`length: "auto" requires both expanded: true and includeOffsets: true.`)}function zz(e){return function(e,i){YR();let a=XR({},i,{async:!0});return pz(e)?t(e,a):mz(e)?n(e,a):r(e,a)};function t(e,t){return/^\w+:\/\//.test(e)?i(typeof fetch<`u`?{readRange:(t,n)=>yz(e,{start:t,end:n}),options:t}:{readRange:(t,n)=>Cz(e,{start:t,end:n}),options:t}):hz(e)?r(ez(e),t):i({readRange:(t,n,r)=>Dz(e,{start:t,end:n,totalSize:r?r.totalSize:void 0}),options:t})}function n(e,t){return i({readRange:(t,n)=>jz(e,{start:t,end:n}),options:t})}function r(t,n){return Promise.resolve().then(()=>e(t,n)).then(e=>{if(!e||!e.metadataRange)throw Error(Lz);let n=e.metadataRange.end;return e.metadataRange.buffer=Wz(t,n),e.metadataRange.fetched=Gz(e.metadataRange.buffer),e.metadataRange.requests=0,e})}function i({readRange:e,options:t}){return a({readRange:e,options:t,buffer:null,fetched:0,requests:0,totalSize:void 0,need:Pz,iter:0})}function a(t){return t.iter>=Fz||(t.totalSize!==void 0&&(t.need=Math.min(t.need,t.totalSize)),t.need<=t.fetched)?c(t):t.readRange(t.fetched,t.need,{totalSize:t.totalSize}).then(n=>(t.requests++,n.status===416?s(t):(Bz(t,n),Promise.resolve(e(t.buffer,t.options)).then(e=>o(t,e)))))}function o(e,t){let n=t&&t.metadataRange;if(n&&n.complete)return Vz(t,e.buffer,e.fetched,e.requests);let r=e.totalSize!==void 0&&e.fetched>=e.totalSize;if(!n&&r)throw Error(Iz);let i=Hz({range:n,totalSize:e.totalSize,fetched:e.fetched});if(i<=e.fetched){if(n)return Vz(t,e.buffer,e.fetched,e.requests);throw Error(Iz)}return e.need=i,e.iter++,a(e)}function s(t){return t.readRange(0,1/0,{totalSize:void 0}).then(n=>(t.requests++,t.buffer=n.buffer,t.fetched=Gz(t.buffer),n.totalSize!==void 0&&(t.totalSize=n.totalSize),Promise.resolve(e(t.buffer,t.options)))).then(e=>{if(!e||!e.metadataRange)throw Error(Iz);return Vz(e,t.buffer,t.fetched,t.requests)})}function c(t){console.warn(`ExifReader: length:"auto" did not converge in ${Fz} iterations; falling back to full read.`);let n;return n=t.totalSize!==void 0&&t.fetched<t.totalSize?t.readRange(t.fetched,t.totalSize,{totalSize:t.totalSize}).then(e=>{t.requests++,Bz(t,e)}):t.totalSize===void 0?t.readRange(t.fetched,1/0,{totalSize:t.totalSize}).then(e=>{t.requests++,Bz(t,e)}):Promise.resolve(),n.then(()=>Promise.resolve(e(t.buffer,t.options))).then(e=>{if(!e||!e.metadataRange)throw Error(Iz);return Vz(e,t.buffer,t.fetched,t.requests)})}}function Bz(e,t){if(t.status===200&&e.fetched>0){e.buffer=t.buffer,e.fetched=Gz(e.buffer),t.totalSize!==void 0&&(e.totalSize=t.totalSize);return}t.totalSize!==void 0&&e.totalSize===void 0&&(e.totalSize=t.totalSize),e.buffer=Mz(e.buffer,t.buffer),e.fetched=Gz(e.buffer)}function Vz(e,t,n,r){let i=e.metadataRange.end;return e.metadataRange.buffer=Uz(t,i),e.metadataRange.fetched=n,e.metadataRange.requests=r,e}function Hz({range:e,totalSize:t,fetched:n}){return e?Math.min(Math.max(e.end,n*2),t===void 0?1/0:t):t===void 0?n*2:t}function Uz(e,t){return!e||typeof t!=`number`||t<0?e:typeof Buffer<`u`&&Buffer.isBuffer(e)?Buffer.from(e.subarray(0,Math.min(t,e.length))):e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer?e.slice(0,Math.min(t,e.byteLength)):e}function Wz(e,t){if(typeof Buffer<`u`&&Buffer.isBuffer(e))return Buffer.from(e.subarray(0,t));if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return e.slice(0,t);if(ArrayBuffer.isView(e)){let n=Math.max(0,Math.min(t,e.byteLength));return e.buffer.slice(e.byteOffset,e.byteOffset+n)}return e}function Gz(e){return e?typeof e.byteLength==`number`?e.byteLength:typeof e.length==`number`?e.length:0:0}var Q={USE_FILE:!0,USE_JFIF:!0,USE_PNG_FILE:!0,USE_EXIF:!0,USE_IPTC:!0,USE_XMP:!0,USE_ICC:!0,USE_MPF:!0,USE_PHOTOSHOP:!0,USE_THUMBNAIL:!0,USE_TIFF:!0,USE_JPEG:!0,USE_PNG:!0,USE_HEIC:!0,USE_AVIF:!0,USE_JXL:!0,USE_WEBP:!0,USE_GIF:!0,USE_MAKER_NOTES:!0};function Kz(e){if(e.length>=8){let t=GR(e.slice(0,8));if(t===`ASCII\0\0\0`)return GR(e.slice(8));if(t===`JIS\0\0\0\0\0`)return`[JIS encoded text]`;if(t===`UNICODE\0`)return`[Unicode encoded text]`;if(t===`\0\0\0\0\0\0\0\0`){let t=GR(e.slice(8));return/[\x20-\x7e]/.test(t)?t:`[Undefined encoding]`}}return`Undefined`}function qz(e){return e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600}var Jz=18761,Yz=19789,Xz={BIG_ENDIAN:Yz,LITTLE_ENDIAN:Jz,getByteOrder:Zz};function Zz(e,t){if(e.getUint16(t)===Jz)return Jz;if(e.getUint16(t)===Yz)return Yz;throw Error(`Illegal byte order value. Faulty image.`)}function Qz(e,t){return e.getUint32(t+4)}function $z(e,t,n){return t+n<=e.byteLength}var eB=1048576;function tB(e,t,n,r,i,a){let{offsets:o,sizes:s}=nB(n,r+3),c=e.getUint8(o.offsetSize)>>4;s.item.extent.extentOffset=c;let l=e.getUint8(o.lengthSize)&15;s.item.extent.extentLength=l;let u=e.getUint8(o.baseOffsetSize)>>4;s.item.baseOffset=u;let d=rB(e,o.indexSize,n);s.item.extent.extentIndex=d===void 0?0:d;let f=iB(e,o.itemCount,n);return{type:`iloc`,items:aB(e,Math.min(t+i,a),n,o,s,c,l,d,f),length:i}}function nB(e,t){let n={item:{dataReferenceIndex:2,extentCount:2,extent:{}}};e<2?(n.itemCount=2,n.item.itemId=2):e===2&&(n.itemCount=4,n.item.itemId=4),e===1||e===2?n.item.constructionMethod=2:n.item.constructionMethod=0;let r={offsetSize:t,lengthSize:t,baseOffsetSize:t+1,indexSize:t+1};return r.itemCount=t+2,r.items=r.itemCount+n.itemCount,r.item={itemId:0},r.item.constructionMethod=r.item.itemId+n.item.itemId,r.item.dataReferenceIndex=r.item.constructionMethod+n.item.constructionMethod,{offsets:r,sizes:n}}function rB(e,t,n){if(n===1||n===2)return e.getUint8(t)&15}function iB(e,t,n){if(n<2)return e.getUint16(t);if(n===2)return e.getUint32(t)}function aB(e,t,n,r,i,a,o,s,c){if(c===void 0)return[];let l=[],u=r.items,d=i.item.extent.extentIndex+i.item.extent.extentOffset+i.item.extent.extentLength,f=i.item.itemId+i.item.constructionMethod+i.item.dataReferenceIndex+i.item.baseOffset+i.item.extentCount,p=0;for(let r=0;r<c&&!(u+f>t);r++){let r={extents:[]};r.itemId=sB(e,u,n),u+=i.item.itemId,r.constructionMethod=n===1||n===2?e.getUint16(u)&15:void 0,u+=i.item.constructionMethod,r.dataReferenceIndex=e.getUint16(u),u+=i.item.dataReferenceIndex,r.baseOffset=lB(e,u,i.item.baseOffset),u+=i.item.baseOffset,r.extentCount=e.getUint16(u),u+=i.item.extentCount;let c=oB(r.extentCount,d,u,t,eB-p);for(let t=0;t<c;t++){let t={};t.extentIndex=cB(e,n,u,s),u+=i.item.extent.extentIndex,t.extentOffset=lB(e,u,a),u+=i.item.extent.extentOffset,t.extentLength=lB(e,u,o),u+=i.item.extent.extentLength,r.extents.push(t)}if(p+=c,l.push(r),(r.extentCount-c)*d>0)break}return l}function oB(e,t,n,r,i){if(t===0)return 0;let a=Math.floor((r-n)/t);return Math.max(0,Math.min(e,a,i))}function sB(e,t,n){if(n<2)return e.getUint16(t);if(n===2)return e.getUint32(t)}function cB(e,t,n,r){if((t===1||t===2)&&r>0)return lB(e,n,r)}function lB(e,t,n){return n===4?e.getUint32(t):n===8?(console.warn(`This file uses an 8-bit offset which is currently not supported by ExifReader. Contact the maintainer to get it fixed.`),Qz(e,t)):0}var uB=1718909296,dB=1768977008,fB=1835365473,pB=1768714083,mB=1768186228,hB=1768517222,gB=1768842853,_B=1768973167,vB=1668246642,yB=1165519206,bB=1835625829,xB=1970432288;function SB(e,t,n=e.byteLength){if($z(e,t,8))try{let{length:r,contentOffset:i}=wB(e,t);if(r<8)return;let a=e.getUint32(t+4);if(a===uB)return HB(e,i,r);if(a===dB)return UB(e,t,i,r,n);if(a===_B)return WB(e,t,i,r,n);if(a===vB)return GB(e,i,r);if(a===mB)return JB(i,r);if(!$z(e,i,1))return;let o=e.getUint8(i);return a===fB?qB(e,t,i+1,r,n):a===pB?tB(e,t,o,i+1,r,n):a===hB?XB(e,t,o,i+1,r,n):a===gB?ZB(e,t,o,i+1,r):{type:void 0,length:r}}catch{return}}function CB(e,t){if(!e)return!1;try{let n=SB(e,0);return n!==void 0&&t.indexOf(n.majorBrand)!==-1}catch{return!1}}function wB(e,t){let n=e.getUint32(t);if(TB(n))return{length:e.byteLength-t,contentOffset:t+4+4};if(EB(n)){if(!$z(e,t,16))return{length:0,contentOffset:t+4+4};if(DB(e,t))return{length:e.getUint32(t+12),contentOffset:t+4+4+8}}return{length:n,contentOffset:t+4+4}}function TB(e){return e===0}function EB(e){return e===1}function DB(e,t){return e.getUint32(t+8)===0}function OB(e,t){if(Q.USE_EXIF||Q.USE_XMP||Q.USE_ICC){let n={},r=kB(e);if(!r)return{hasAppMarkers:!1};if(Q.USE_EXIF){let i=AB(e,r,t);i!==void 0&&(n.tiffHeaderOffset=i.tiffHeaderOffset,i.dataView!==void 0&&(n.exifDataView=i.dataView))}if(Q.USE_XMP){let i=zB(e,r,t);i!==void 0&&(n.xmpChunks=i.chunks,i.dataView!==void 0&&(n.xmpDataView=i.dataView))}return Q.USE_ICC&&(n.iccChunks=VB(r,t)),n.hasAppMarkers=n.tiffHeaderOffset!==void 0||n.xmpChunks!==void 0||n.iccChunks!==void 0,n}return{}}function kB(e){let t=0;for(;t+4+4<=e.byteLength;){let n=SB(e,t);if(n===void 0)break;if(n.type===`meta`)return n;t+=n.length}}function AB(e,t,n){try{let r=IB(t).itemId,i=LB(t,r);PB(i);let a=NB(t);if(jB(n,i,`exif`,a),i.extents.length>1){let t=FB(e,i,a);return t===void 0?void 0:{tiffHeaderOffset:RB(t,0),dataView:t}}let o=MB(i,i.extents[0],a);return o===void 0?void 0:{tiffHeaderOffset:RB(e,o)}}catch{return}}function jB(e,t,n,r){if(e)for(let i=0;i<t.extents.length;i++){let a=t.extents[i],o=MB(t,a,r);o!==void 0&&JR(e,n,o,o+a.extentLength)}}function MB(e,t,n){let r=e.constructionMethod;if(r===void 0||r===0)return e.baseOffset+t.extentOffset;if(r===1&&n!==void 0)return n+e.baseOffset+t.extentOffset}function NB(e){let t=e.subBoxes.find(e=>e.type===`idat`);return t?t.contentOffset:void 0}function PB(e){e.constructionMethod===2&&console.warn(`This file uses iloc constructionMethod 2 (item_offset) which is currently not supported by ExifReader. Contact the maintainer to get it fixed.`)}function FB(e,t,n){let r=[],i=0;for(let a=0;a<t.extents.length;a++){let o=t.extents[a],s=MB(t,o,n);if(s===void 0||s+o.extentLength>e.byteLength||(r.push({start:s,length:o.extentLength}),i+=o.extentLength,i>e.byteLength))return}let a=new Uint8Array(i),o=0;for(let t=0;t<r.length;t++){let{start:n,length:i}=r[t];for(let t=0;t<i;t++)a[o+t]=e.getUint8(n+t);o+=i}return new DataView(a.buffer)}function IB(e){return e.subBoxes.find(e=>e.type===`iinf`).itemInfos.find(e=>e.itemType===yB)}function LB(e,t){return e.subBoxes.find(e=>e.type===`iloc`).items.find(e=>e.itemId===t)}function RB(e,t){return t+4+e.getUint32(t)}function zB(e,t,n){try{let r=BB(t).itemId,i=LB(t,r);PB(i);let a=NB(t);if(jB(n,i,`xmp`,a),i.extents.length>1){let t=FB(e,i,a);return t===void 0?void 0:{chunks:[{dataOffset:0,length:t.byteLength}],dataView:t}}let o=i.extents[0],s=MB(i,o,a);return s===void 0?void 0:{chunks:[{dataOffset:s,length:o.extentLength}]}}catch{return}}function BB(e){return e.subBoxes.find(e=>e.type===`iinf`).itemInfos.find(e=>e.itemType===1835625829&&e.contentType===`application/rdf+xml`)}function VB(e,t){try{let n=e.subBoxes.find(e=>e.type===`iprp`).subBoxes.find(e=>e.type===`ipco`).properties.find(e=>e.type===`colr`).icc;if(n)return JR(t,`icc`,n.offset,n.offset+n.length),[n]}catch{}}function HB(e,t,n){return{type:`ftyp`,majorBrand:VR(e,t,4),length:n}}function UB(e,t,n,r,i){return{type:`iprp`,subBoxes:YB(e,n,r-(n-t),i),length:r}}function WB(e,t,n,r,i){return{type:`ipco`,properties:YB(e,n,r-(n-t),i),length:r}}function GB(e,t,n){return{type:`colr`,icc:KB(e,t),length:n}}function KB(e,t){let n=VR(e,t,4);if(n===`prof`||n===`rICC`)return{offset:t+4,length:e.getUint32(t+4),chunkNumber:1,chunksTotal:1}}function qB(e,t,n,r,i){return{type:`meta`,subBoxes:YB(e,n+3,r-(n+3-t),i),length:r}}function JB(e,t){return{type:`idat`,contentOffset:e,length:t}}function YB(e,t,n,r){let i=[yB,bB],a=Math.min(t+n,r),o=[],s=t;for(;s+8<=a;){let t=SB(e,s,a);if(t===void 0)break;t.type!==void 0&&(t.itemType===void 0||i.indexOf(t.itemType)!==-1)&&o.push(t),s+=t.length}return o}function XB(e,t,n,r,i,a){let o=n===0?2:4,s=r+3+o;return{type:`iinf`,itemInfos:YB(e,s,i-(s-t),a),length:i}}function ZB(e,t,n,r,i){r+=3;let a={type:`infe`,length:i};return(n===0||n===1)&&(a.itemId=e.getUint16(r),r+=2,a.itemProtectionIndex=e.getUint16(r),r+=2,a.itemName=HR(e,r),r+=a.itemName.length+1),n>=2&&(n===2?(a.itemId=e.getUint16(r),r+=2):n===3&&(a.itemId=e.getUint32(r),r+=4),a.itemProtectionIndex=e.getUint16(r),r+=2,a.itemType=e.getUint32(r),r+=4,a.itemName=HR(e,r),r+=a.itemName.length+1,a.itemType===1835625829?(a.contentType=HR(e,r),r+=a.contentType.length+1,t+i>r&&(a.contentEncoding=HR(e,r),r+=a.contentEncoding.length+1)):a.itemType===xB&&(a.itemUri=HR(e,r),r+=a.itemUri.length+1)),a}var QB={isTiffFile:$B,findTiffOffsets:tV};function $B(e){return!!e&&e.byteLength>=4&&eV(e)}function eV(e){let t=e.getUint16(0)===Xz.LITTLE_ENDIAN;return e.getUint16(2,t)===42}function tV(){return Q.USE_EXIF?{hasAppMarkers:!0,tiffHeaderOffset:0}:{}}var nV={isJpegFile:zV,findJpegOffsets:BV},rV=2,iV=65496,aV=2,oV=4,sV=2,cV=2,lV=10,uV=18,dV=33,fV=79,pV=18,mV=8,hV=`ICC_PROFILE\0`,gV=16,_V=17,vV=255,yV=`MPF\0`,bV=65472,xV=65474,SV=65476,CV=65499,wV=65501,TV=65498,EV=65504,DV=65505,OV=65506,kV=65517,AV=65519,jV=65534,MV=65535,NV=`JFIF`,PV=`Exif`,FV=`http://ns.adobe.com/xap/1.0/\0`,IV=`http://ns.adobe.com/xmp/extension/\0`,LV=`Photoshop 3.0`,RV=`8BIM`;function zV(e){return!!e&&e.byteLength>=rV&&e.getUint16(0)===iV}function BV(e,t){let n=aV,r,i,a,o,s,c,l,u,d,f=0,p,m=!1;for(;n+oV+5<=e.byteLength;){let h;if(e.getUint16(n)===TV&&(m=!0),Q.USE_FILE&&VV(e,n))r=e.getUint16(n+sV),i=n+sV,h=`file`;else if(Q.USE_FILE&&HV(e,n))r=e.getUint16(n+sV),a=n+sV,h=`file`;else if(Q.USE_JFIF&&GV(e,n))r=e.getUint16(n+sV),o=n+cV,h=`jfif`;else if(Q.USE_EXIF&&KV(e,n)){r=e.getUint16(n+sV),f++;let t=n+lV;if(f===1)p={appMarkerPosition:n,fieldLength:r,tiffHeaderOffset:t,score:void 0};else{p.score===void 0&&(p.score=nH(e,p.appMarkerPosition,p.fieldLength,p.tiffHeaderOffset));let i=nH(e,n,r,t);i>p.score&&(p={appMarkerPosition:n,fieldLength:r,tiffHeaderOffset:t,score:i})}s=p.tiffHeaderOffset,h=`exif`}else if(Q.USE_XMP&&qV(e,n))l||=[],r=e.getUint16(n+sV),l.push(ZV(n,r)),h=`xmp`;else if(Q.USE_XMP&&YV(e,n))l||=[],r=e.getUint16(n+sV),l.push(QV(n,r)),h=`xmp`;else if(Q.USE_IPTC&&$V(e,n))r=e.getUint16(n+sV),c=n+uV,h=`iptc`;else if(Q.USE_ICC&&UV(e,n)){if(r=e.getUint16(n+sV),u||=[],u.length<vV){let t=n+pV,i=r-16,a=e.getUint8(n+gV),o=e.getUint8(n+_V);u.push({offset:t,length:i,chunkNumber:a,chunksTotal:o})}h=`icc`}else if(Q.USE_MPF&&WV(e,n))r=e.getUint16(n+sV),d=n+mV,h=`mpf`;else if(eH(e,n))r=e.getUint16(n+sV);else if(tH(e,n)){n++;continue}else break;JR(t,h,n,n+sV+r),n+=sV+r}return f>1&&iH(f),t&&(!m&&n+sV<=e.byteLength&&e.getUint16(n)===TV&&(m=!0),t.truncated=!m),{hasAppMarkers:n>aV,fileDataOffset:i||a,jfifDataOffset:o,tiffHeaderOffset:s,iptcDataOffset:c,xmpChunks:l,iccChunks:u,mpfDataOffset:d}}function VV(e,t){return e.getUint16(t)===bV}function HV(e,t){return e.getUint16(t)===xV}function UV(e,t){return e.getUint16(t)===OV&&t+_V<e.byteLength&&VR(e,t+oV,12)===hV}function WV(e,t){return e.getUint16(t)===OV&&VR(e,t+oV,4)===yV}function GV(e,t){return e.getUint16(t)===EV&&VR(e,t+oV,4)===NV&&e.getUint8(t+oV+4)===0}function KV(e,t){return e.getUint16(t)===DV&&VR(e,t+oV,4)===PV&&e.getUint8(t+oV+4)===0}function qV(e,t){return e.getUint16(t)===DV&&JV(e,t)}function JV(e,t){return VR(e,t+oV,29)===FV}function YV(e,t){return e.getUint16(t)===DV&&XV(e,t)}function XV(e,t){return VR(e,t+oV,35)===IV}function ZV(e,t){return{dataOffset:e+dV,length:t-31}}function QV(e,t){return{dataOffset:e+fV,length:t-77}}function $V(e,t){let n=t+oV+13+1;return n+4<=e.byteLength&&e.getUint16(t)===kV&&VR(e,t+oV,13)===LV&&e.getUint8(t+oV+13)===0&&VR(e,n,4)===RV}function eH(e,t){let n=e.getUint16(t);return n>=EV&&n<=AV||n===jV||n===bV||n===xV||n===SV||n===CV||n===wV||n===TV}function tH(e,t){return e.getUint16(t)===MV}function nH(e,t,n,r){let i=rH(e,r,t+sV+n);if(!i)return 0;let a=Number.isInteger(i.ifdEntries)?i.ifdEntries:0;return(i.isValid?1e9:0)+a*1e6+n}function rH(e,t,n){try{if(t+8>n)return;let r=e.getUint16(t+0),i=r===Xz.LITTLE_ENDIAN;if(!i&&r!==Xz.BIG_ENDIAN||e.getUint16(t+2,i)!==42)return;let a=t+e.getUint32(t+4,i);if(a+2>n)return;let o=e.getUint16(a,i);return{ifdEntries:o,isValid:a+(2+o*12+4)<=n&&o>0}}catch{return}}function iH(e){typeof console>`u`||typeof console.warn!=`function`||console.warn(`ExifReader: Found ${e} Exif segments (APP1). Will pick the best candidate segment.`)}var aH={isPngFile:pH,findPngOffsets:mH},oH=`‰PNG\r
89
89
  
90
90
  `,sH=4,cH=`XML:com.adobe.xmp\0`,lH=`pHYs`,uH=`tIME`,dH=`eXIf`,fH=`iCCP`;function pH(e){return!!e&&VR(e,0,8)===oH}function mH(e,t,n){let r={hasAppMarkers:!1},i=8,a=!1;for(;i+sH+4<=e.byteLength;){let o,s=e.getUint32(i+0);if(n&&VR(e,i+4,4)===`IEND`&&(a=!0),Q.USE_PNG_FILE&&hH(e,i))r.hasAppMarkers=!0,r.pngHeaderOffset=i+8,o=`file`;else if(Q.USE_XMP&&gH(e,i)){let t=xH(e,i);t!==void 0&&(r.hasAppMarkers=!0,r.xmpChunks=[{dataOffset:t,length:s-(t-(i+8))}],o=`xmp`)}else if(_H(e,i,t)){r.hasAppMarkers=!0;let t=VR(e,i+4,4);r.pngTextChunks||=[],r.pngTextChunks.push({length:s,type:t,offset:i+8}),o=`png`}else if(vH(e,i))r.hasAppMarkers=!0,r.tiffHeaderOffset=i+8,o=`exif`;else if(Q.USE_ICC&&t&&yH(e,i)){let t=i+8,n=SH(e,t);n!==void 0&&(r.hasAppMarkers=!0,r.iccChunks||=[],r.iccChunks.push({offset:n.compressedProfileOffset,length:s-(n.compressedProfileOffset-t),chunkNumber:1,chunksTotal:1,profileName:n.profileName,compressionMethod:n.compressionMethod}),o=`icc`)}else bH(e,i)&&(r.hasAppMarkers=!0,r.pngChunkOffsets||=[],r.pngChunkOffsets.push(i+0),o=`png`);let c=s+sH+4+4;JR(n,o,i,i+c),i+=c}return n&&(n.truncated=!a),r}function hH(e,t){return VR(e,t+4,4)===`IHDR`}function gH(e,t){return VR(e,t+4,4)===`iTXt`&&VR(e,t+8,18)===cH}function _H(e,t,n){let r=VR(e,t+4,4);return r===`tEXt`||r===`iTXt`||r===`zTXt`&&n}function vH(e,t){return VR(e,t+4,4)===dH}function yH(e,t){return VR(e,t+4,4)===fH}function bH(e,t){let n=[lH,uH],r=VR(e,t+4,4);return n.includes(r)}function xH(e,t){t+=28;let n=0;for(;n<2&&t<e.byteLength;)e.getUint8(t)===0&&n++,t++;if(!(n<2))return t}function SH(e,t){let n=HR(e,t);if(t+=n.length+1,t+1>e.byteLength)return;let r=e.getUint8(t);return t+=1,{profileName:n,compressionMethod:r,compressedProfileOffset:t}}var CH={isHeicFile:TH,findHeicOffsets:EH},wH=[`heic`,`heix`,`hevc`,`hevx`,`heim`,`heis`,`hevm`,`hevs`,`mif1`];function TH(e){return CB(e,wH)}function EH(e,t){return OB(e,t)}var DH={isAvifFile:kH,findAvifOffsets:AH},OH=[`avif`];function kH(e){return CB(e,OH)}function AH(e,t){return OB(e,t)}var jH={isJxlFile:VH,findJxlOffsets:WH},MH=[0,0,0,12,74,88,76,32,13,10,135,10],NH=[255,10],PH=1165519206,FH=2020437024,IH=1651666786,LH=1786276963,RH=1786276976,zH=4,BH=4;function VH(e){try{return HH(e)||UH(e)}catch{return!1}}function HH(e){if(!e||e.byteLength<MH.length)return!1;for(let t=0;t<MH.length;t++)if(e.getUint8(t)!==MH[t])return!1;return!0}function UH(e){return!e||e.byteLength<NH.length?!1:e.getUint8(0)===NH[0]&&e.getUint8(1)===NH[1]}function WH(e,t){let n=0,r,i,a,o,s;if(UH(e))return{hasAppMarkers:!0,tiffHeaderOffset:void 0,xmpChunks:void 0,brobExifChunk:void 0,brobXmpChunk:void 0,jxlCodestreamOffset:0};for(;n+8<=e.byteLength;){let{length:c,contentOffset:l}=wB(e,n);if(c<8)break;let u=e.getUint32(n+4),d;if(Q.USE_EXIF&&u===PH){try{r=RB(e,l)}catch{}d=`exif`}if(Q.USE_XMP&&u===FH&&(i=[{dataOffset:l,length:c-(l-n)}],d=`xmp`),u===LH&&s===void 0&&(s=l),u===RH&&s===void 0&&l+zH<=e.byteLength&&(e.getUint32(l)&2147483647||(s=l+zH)),u===IH&&l+BH<=e.byteLength){let t=e.getUint32(l),s=l+BH,u=c-(s-n);Q.USE_EXIF&&t===PH&&(d=`exif`,r===void 0&&!a&&(a={dataOffset:s,length:u})),Q.USE_XMP&&t===FH&&(d=`xmp`,!i&&!o&&(o={dataOffset:s,length:u}))}JR(t,d,n,n+c),n+=c}return{hasAppMarkers:r!==void 0||i!==void 0||a!==void 0||o!==void 0||s!==void 0,tiffHeaderOffset:r,xmpChunks:i,brobExifChunk:a,brobXmpChunk:o,jxlCodestreamOffset:s}}var GH={isWebpFile:KH,findOffsets:qH};function KH(e){return!!e&&VR(e,0,4)===`RIFF`&&VR(e,8,4)===`WEBP`}function qH(e,t){let n=12,r=!1,i,a,o,s;for(;n+8<e.byteLength;){let c=VR(e,n,4),l=e.getUint32(n+4,!0),u;Q.USE_EXIF&&c===`EXIF`?(r=!0,i=VR(e,n+8,6)===`Exif\0\0`?n+8+6:n+8,u=`exif`):Q.USE_XMP&&c===`XMP `?(r=!0,a=[{dataOffset:n+8,length:l}],u=`xmp`):Q.USE_ICC&&c===`ICCP`?(r=!0,o=[{offset:n+8,length:l,chunkNumber:1,chunksTotal:1}],u=`icc`):c===`VP8X`&&(r=!0,s=n+8,u=`riff`);let d=8+(l%2==0?l:l+1);JR(t,u,n,n+d),n+=d}return{hasAppMarkers:r,tiffHeaderOffset:i,xmpChunks:a,iccChunks:o,vp8xChunkOffset:s}}var JH={isGifFile:QH,findOffsets:$H},YH=6,XH=[`GIF87a`,`GIF89a`],ZH=13;function QH(e){return!!e&&XH.includes(VR(e,0,YH))}function $H(e,t){return JR(t,`gif`,0,ZH),{gifHeaderOffset:0}}var eU={isXMLFile:iU,findOffsets:aU},tU=0,nU=`<?xpacket begin`,rU=[`<?xpacket end=`,`</x:xmpmeta>`];function iU(e){return!!e&&VR(e,tU,15)===nU}function aU(e,t){let n=[];return n.push({dataOffset:tU,length:e.byteLength}),JR(t,`xmp`,0,e.byteLength),t&&(t.truncated=!oU(e)),{xmpChunks:n}}function oU(e){let t=VR(e,0,e.byteLength);for(let e=0;e<rU.length;e++)if(t.indexOf(rU[e])!==-1)return!0;return!1}var sU={parseAppMarkers:cU};function cU(e,t,n){let r=n?[]:void 0;if(Q.USE_TIFF&&QB.isTiffFile(e))return lU(QB.findTiffOffsets(),`tiff`,`TIFF`,r);if(Q.USE_JPEG&&nV.isJpegFile(e))return lU(nV.findJpegOffsets(e,r),`jpeg`,`JPEG`,r);if(Q.USE_PNG&&aH.isPngFile(e))return lU(aH.findPngOffsets(e,t,r),`png`,`PNG`,r);if(Q.USE_HEIC&&CH.isHeicFile(e))return lU(CH.findHeicOffsets(e,r),`heic`,`HEIC`,r);if(Q.USE_AVIF&&DH.isAvifFile(e))return lU(DH.findAvifOffsets(e,r),`avif`,`AVIF`,r);if(Q.USE_JXL&&jH.isJxlFile(e))return lU(jH.findJxlOffsets(e,r),`jxl`,`JPEG XL`,r);if(Q.USE_WEBP&&GH.isWebpFile(e))return lU(GH.findOffsets(e,r),`webp`,`WebP`,r);if(Q.USE_GIF&&JH.isGifFile(e))return lU(JH.findOffsets(e,r),`gif`,`GIF`,r);if(Q.USE_XMP&&eU.isXMLFile(e))return lU(eU.findOffsets(e,r),`xml`,`XML`,r);throw Error(`Invalid image format`)}function lU(e,t,n,r){let i=XR({},e,{fileType:{value:t,description:n}});return r!==void 0&&(i.metadataBlocks=r,i.metadataTruncated=!!r.truncated),i}var uU={ApertureValue:e=>(Math.sqrt(2)**+(e[0]/e[1])).toFixed(2),ColorSpace(e){return e===1?`sRGB`:e===65535?`Uncalibrated`:`Unknown`},ComponentsConfiguration(e){return e.map(e=>{if(e===49)return`Y`;if(e===50)return`Cb`;if(e===51)return`Cr`;if(e===52)return`R`;if(e===53)return`G`;if(e===54)return`B`}).join(``)},Contrast(e){return e===0?`Normal`:e===1?`Soft`:e===2?`Hard`:`Unknown`},CustomRendered(e){return e===0?`Normal process`:e===1?`Custom process`:`Unknown`},ExposureMode(e){return e===0?`Auto exposure`:e===1?`Manual exposure`:e===2?`Auto bracket`:`Unknown`},ExposureProgram(e){return e===0?`Undefined`:e===1?`Manual`:e===2?`Normal program`:e===3?`Aperture priority`:e===4?`Shutter priority`:e===5?`Creative program`:e===6?`Action program`:e===7?`Portrait mode`:e===8?`Landscape mode`:e===9?`Bulb`:`Unknown`},ExposureTime(e){if(e[0]/e[1]>.25){let t=e[0]/e[1];return Number.isInteger(t)?``+t:t.toFixed(1)}return e[0]===0?`0/${e[1]}`:`1/${Math.round(e[1]/e[0])}`},FNumber:e=>`f/${Number(e[0]/e[1]).toFixed(1)}`,FocalLength:e=>e[0]/e[1]+` mm`,FocalPlaneResolutionUnit(e){return e===2?`inches`:e===3?`centimeters`:e===4?`millimeters`:`Unknown`},LightSource:e=>e===1?`Daylight`:e===2?`Fluorescent`:e===3?`Tungsten (incandescent light)`:e===4?`Flash`:e===9?`Fine weather`:e===10?`Cloudy weather`:e===11?`Shade`:e===12?`Daylight fluorescent (D 5700 – 7100K)`:e===13?`Day white fluorescent (N 4600 – 5400K)`:e===14?`Cool white fluorescent (W 3900 – 4500K)`:e===15?`White fluorescent (WW 3200 – 3700K)`:e===17?`Standard light A`:e===18?`Standard light B`:e===19?`Standard light C`:e===20?`D55`:e===21?`D65`:e===22?`D75`:e===23?`D50`:e===24?`ISO studio tungsten`:e===255?`Other light source`:`Unknown`,MeteringMode(e){return e===1?`Average`:e===2?`CenterWeightedAverage`:e===3?`Spot`:e===4?`MultiSpot`:e===5?`Pattern`:e===6?`Partial`:e===255?`Other`:`Unknown`},ResolutionUnit(e){return e===2?`inches`:e===3?`centimeters`:`Unknown`},Saturation(e){return e===0?`Normal`:e===1?`Low saturation`:e===2?`High saturation`:`Unknown`},FocalLengthIn35mmFilm(e){return e===0?`Unknown`:e+` mm`},SceneCaptureType(e){return e===0?`Standard`:e===1?`Landscape`:e===2?`Portrait`:e===3?`Night scene`:`Unknown`},Sharpness(e){return e===0?`Normal`:e===1?`Soft`:e===2?`Hard`:`Unknown`},ShutterSpeedValue(e){let t=2**(e[0]/e[1]);return t<=1?`${Math.round(1/t)}`:`1/${Math.round(t)}`},WhiteBalance(e){return e===0?`Auto white balance`:e===1?`Manual white balance`:`Unknown`},XResolution:e=>``+Math.round(e[0]/e[1]),YResolution:e=>``+Math.round(e[0]/e[1])},dU={11:`ProcessingSoftware`,254:{name:`SubfileType`,description:e=>({0:`Full-resolution image`,1:`Reduced-resolution image`,2:`Single page of multi-page image`,3:`Single page of multi-page reduced-resolution image`,4:`Transparency mask`,5:`Transparency mask of reduced-resolution image`,6:`Transparency mask of multi-page image`,7:`Transparency mask of reduced-resolution multi-page image`,65537:`Alternate reduced-resolution image`,4294967295:`Invalid`})[e]||`Unknown`},255:{name:`OldSubfileType`,description:e=>({0:`Full-resolution image`,1:`Reduced-resolution image`,2:`Single page of multi-page image`})[e]||`Unknown`},256:`ImageWidth`,257:`ImageLength`,258:`BitsPerSample`,259:`Compression`,262:`PhotometricInterpretation`,263:{name:`Thresholding`,description:e=>({1:`No dithering or halftoning`,2:`Ordered dither or halfton`,3:`Randomized dither`})[e]||`Unknown`},264:`CellWidth`,265:`CellLength`,266:{name:`FillOrder`,description:e=>({1:`Normal`,2:`Reversed`})[e]||`Unknown`},269:`DocumentName`,270:`ImageDescription`,271:`Make`,272:`Model`,273:`StripOffsets`,274:{name:`Orientation`,description:e=>e===1?`top-left`:e===2?`top-right`:e===3?`bottom-right`:e===4?`bottom-left`:e===5?`left-top`:e===6?`right-top`:e===7?`right-bottom`:e===8?`left-bottom`:`Undefined`},277:`SamplesPerPixel`,278:`RowsPerStrip`,279:`StripByteCounts`,280:`MinSampleValue`,281:`MaxSampleValue`,282:{name:`XResolution`,description:uU.XResolution},283:{name:`YResolution`,description:uU.YResolution},284:`PlanarConfiguration`,285:`PageName`,286:{name:`XPosition`,description:e=>``+Math.round(e[0]/e[1])},287:{name:`YPosition`,description:e=>``+Math.round(e[0]/e[1])},290:{name:`GrayResponseUnit`,description:e=>({1:`0.1`,2:`0.001`,3:`0.0001`,4:`1e-05`,5:`1e-06`})[e]||`Unknown`},296:{name:`ResolutionUnit`,description:uU.ResolutionUnit},297:`PageNumber`,301:`TransferFunction`,305:`Software`,306:`DateTime`,315:`Artist`,316:`HostComputer`,317:`Predictor`,318:{name:`WhitePoint`,description:e=>e.map(e=>`${e[0]}/${e[1]}`).join(`, `)},319:{name:`PrimaryChromaticities`,description:e=>e.map(e=>`${e[0]}/${e[1]}`).join(`, `)},321:`HalftoneHints`,322:`TileWidth`,323:`TileLength`,330:`A100DataOffset`,332:{name:`InkSet`,description:e=>({1:`CMYK`,2:`Not CMYK`})[e]||`Unknown`},337:`TargetPrinter`,338:{name:`ExtraSamples`,description:e=>({0:`Unspecified`,1:`Associated Alpha`,2:`Unassociated Alpha`})[e]||`Unknown`},339:{name:`SampleFormat`,description:e=>{let t={1:`Unsigned`,2:`Signed`,3:`Float`,4:`Undefined`,5:`Complex int`,6:`Complex float`};return Array.isArray(e)?e.map(e=>t[e]||`Unknown`).join(`, `):`Unknown`}},513:`JPEGInterchangeFormat`,514:`JPEGInterchangeFormatLength`,529:{name:`YCbCrCoefficients`,description:e=>e.map(e=>``+e[0]/e[1]).join(`/`)},530:`YCbCrSubSampling`,531:{name:`YCbCrPositioning`,description:e=>e===1?`centered`:e===2?`co-sited`:`undefined `+e},532:{name:`ReferenceBlackWhite`,description:e=>e.map(e=>``+e[0]/e[1]).join(`, `)},700:`ApplicationNotes`,18246:`Rating`,18249:`RatingPercent`,33432:{name:`Copyright`,description:e=>e.join(`; `)},33550:`PixelScale`,33723:`IPTC-NAA`,33920:`IntergraphMatrix`,33922:`ModelTiePoint`,34118:`SEMInfo`,34264:`ModelTransform`,34377:`PhotoshopSettings`,34665:`Exif IFD Pointer`,34675:`ICC_Profile`,34735:`GeoTiffDirectory`,34736:`GeoTiffDoubleParams`,34737:`GeoTiffAsciiParams`,34853:`GPS Info IFD Pointer`,40091:{name:`XPTitle`,description:fU},40092:{name:`XPComment`,description:fU},40093:{name:`XPAuthor`,description:fU},40094:{name:`XPKeywords`,description:fU},40095:{name:`XPSubject`,description:fU},42112:`GDALMetadata`,42113:`GDALNoData`,50341:`PrintIM`,50707:`DNGBackwardVersion`,50708:`UniqueCameraModel`,50709:`LocalizedCameraModel`,50721:`ColorMatrix1`,50722:`ColorMatrix2`,50723:`CameraCalibration1`,50724:`CameraCalibration2`,50725:`ReductionMatrix1`,50726:`ReductionMatrix2`,50727:`AnalogBalance`,50728:`AsShotNeutral`,50729:`AsShotWhiteXY`,50730:`BaselineExposure`,50731:`BaselineNoise`,50732:`BaselineSharpness`,50734:`LinearResponseLimit`,50735:`CameraSerialNumber`,50736:`DNGLensInfo`,50739:`ShadowScale`,50741:{name:`MakerNoteSafety`,description:e=>({0:`Unsafe`,1:`Safe`})[e]||`Unknown`},50778:{name:`CalibrationIlluminant1`,description:uU.LightSource},50779:{name:`CalibrationIlluminant2`,description:uU.LightSource},50781:`RawDataUniqueID`,50827:`OriginalRawFileName`,50828:`OriginalRawFileData`,50831:`AsShotICCProfile`,50832:`AsShotPreProfileMatrix`,50833:`CurrentICCProfile`,50834:`CurrentPreProfileMatrix`,50879:`ColorimetricReference`,50885:`SRawType`,50898:`PanasonicTitle`,50899:`PanasonicTitle2`,50931:`CameraCalibrationSig`,50932:`ProfileCalibrationSig`,50933:`ProfileIFD`,50934:`AsShotProfileName`,50936:`ProfileName`,50937:`ProfileHueSatMapDims`,50938:`ProfileHueSatMapData1`,50939:`ProfileHueSatMapData2`,50940:`ProfileToneCurve`,50941:{name:`ProfileEmbedPolicy`,description:e=>({0:`Allow Copying`,1:`Embed if Used`,2:`Never Embed`,3:`No Restrictions`})[e]||`Unknown`},50942:`ProfileCopyright`,50964:`ForwardMatrix1`,50965:`ForwardMatrix2`,50966:`PreviewApplicationName`,50967:`PreviewApplicationVersion`,50968:`PreviewSettingsName`,50969:`PreviewSettingsDigest`,50970:{name:`PreviewColorSpace`,description:e=>({1:`Gray Gamma 2.2`,2:`sRGB`,3:`Adobe RGB`,4:`ProPhoto RGB`})[e]||`Unknown`},50971:`PreviewDateTime`,50972:`RawImageDigest`,50973:`OriginalRawFileDigest`,50981:`ProfileLookTableDims`,50982:`ProfileLookTableData`,51043:`TimeCodes`,51044:`FrameRate`,51058:`TStop`,51081:`ReelName`,51089:`OriginalDefaultFinalSize`,51090:`OriginalBestQualitySize`,51091:`OriginalDefaultCropSize`,51105:`CameraLabel`,51107:{name:`ProfileHueSatMapEncoding`,description:e=>({0:`Linear`,1:`sRGB`})[e]||`Unknown`},51108:{name:`ProfileLookTableEncoding`,description:e=>({0:`Linear`,1:`sRGB`})[e]||`Unknown`},51109:`BaselineExposureOffset`,51110:{name:`DefaultBlackRender`,description:e=>({0:`Auto`,1:`None`})[e]||`Unknown`},51111:`NewRawImageDigest`,51112:`RawToPreviewGain`};function fU(e){return new TextDecoder(`utf-16`).decode(new Uint8Array(e)).replace(/\u0000+$/,``)}var pU={33434:{name:`ExposureTime`,description:uU.ExposureTime},33437:{name:`FNumber`,description:uU.FNumber},34850:{name:`ExposureProgram`,description:uU.ExposureProgram},34852:`SpectralSensitivity`,34855:`ISOSpeedRatings`,34856:{name:`OECF`,description:()=>`[Raw OECF table data]`},34858:`TimeZoneOffset`,34859:`SelfTimerMode`,34864:{name:`SensitivityType`,description:e=>({1:`Standard Output Sensitivity`,2:`Recommended Exposure Index`,3:`ISO Speed`,4:`Standard Output Sensitivity and Recommended Exposure Index`,5:`Standard Output Sensitivity and ISO Speed`,6:`Recommended Exposure Index and ISO Speed`,7:`Standard Output Sensitivity, Recommended Exposure Index and ISO Speed`})[e]||`Unknown`},34865:`StandardOutputSensitivity`,34866:`RecommendedExposureIndex`,34867:`ISOSpeed`,34868:`ISOSpeedLatitudeyyy`,34869:`ISOSpeedLatitudezzz`,36864:{name:`ExifVersion`,description:e=>GR(e)},36867:`DateTimeOriginal`,36868:`DateTimeDigitized`,36873:`GooglePlusUploadCode`,36880:`OffsetTime`,36881:`OffsetTimeOriginal`,36882:`OffsetTimeDigitized`,37121:{name:`ComponentsConfiguration`,description:uU.ComponentsConfiguration},37122:`CompressedBitsPerPixel`,37377:{name:`ShutterSpeedValue`,description:uU.ShutterSpeedValue},37378:{name:`ApertureValue`,description:uU.ApertureValue},37379:`BrightnessValue`,37380:`ExposureBiasValue`,37381:{name:`MaxApertureValue`,description:e=>(Math.sqrt(2)**+(e[0]/e[1])).toFixed(2)},37382:{name:`SubjectDistance`,description:e=>e[0]/e[1]+` m`},37383:{name:`MeteringMode`,description:uU.MeteringMode},37384:{name:`LightSource`,description:uU.LightSource},37385:{name:`Flash`,description:e=>e===0?`Flash did not fire`:e===1?`Flash fired`:e===5?`Strobe return light not detected`:e===7?`Strobe return light detected`:e===9?`Flash fired, compulsory flash mode`:e===13?`Flash fired, compulsory flash mode, return light not detected`:e===15?`Flash fired, compulsory flash mode, return light detected`:e===16?`Flash did not fire, compulsory flash mode`:e===24?`Flash did not fire, auto mode`:e===25?`Flash fired, auto mode`:e===29?`Flash fired, auto mode, return light not detected`:e===31?`Flash fired, auto mode, return light detected`:e===32?`No flash function`:e===65?`Flash fired, red-eye reduction mode`:e===69?`Flash fired, red-eye reduction mode, return light not detected`:e===71?`Flash fired, red-eye reduction mode, return light detected`:e===73?`Flash fired, compulsory flash mode, red-eye reduction mode`:e===77?`Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected`:e===79?`Flash fired, compulsory flash mode, red-eye reduction mode, return light detected`:e===89?`Flash fired, auto mode, red-eye reduction mode`:e===93?`Flash fired, auto mode, return light not detected, red-eye reduction mode`:e===95?`Flash fired, auto mode, return light detected, red-eye reduction mode`:`Unknown`},37386:{name:`FocalLength`,description:uU.FocalLength},37393:`ImageNumber`,37394:{name:`SecurityClassification`,description:e=>({C:`Confidential`,R:`Restricted`,S:`Secret`,T:`Top Secret`,U:`Unclassified`})[e]||`Unknown`},37395:`ImageHistory`,37396:{name:`SubjectArea`,description:e=>e.length===2?`Location; X: ${e[0]}, Y: ${e[1]}`:e.length===3?`Circle; X: ${e[0]}, Y: ${e[1]}, diameter: ${e[2]}`:e.length===4?`Rectangle; X: ${e[0]}, Y: ${e[1]}, width: ${e[2]}, height: ${e[3]}`:`Unknown`},37500:{name:`MakerNote`,description:()=>`[Raw maker note data]`},37510:{name:`UserComment`,description:Kz},37520:`SubSecTime`,37521:`SubSecTimeOriginal`,37522:`SubSecTimeDigitized`,37724:`ImageSourceData`,37888:{name:`AmbientTemperature`,description:e=>e[0]/e[1]+` °C`},37889:{name:`Humidity`,description:e=>e[0]/e[1]+` %`},37890:{name:`Pressure`,description:e=>e[0]/e[1]+` hPa`},37891:{name:`WaterDepth`,description:e=>e[0]/e[1]+` m`},37892:{name:`Acceleration`,description:e=>e[0]/e[1]+` mGal`},37893:{name:`CameraElevationAngle`,description:e=>e[0]/e[1]+` °`},40960:{name:`FlashpixVersion`,description:e=>e.map(e=>String.fromCharCode(e)).join(``)},40961:{name:`ColorSpace`,description:uU.ColorSpace},40962:`PixelXDimension`,40963:`PixelYDimension`,40964:`RelatedSoundFile`,40965:`Interoperability IFD Pointer`,41483:`FlashEnergy`,41484:{name:`SpatialFrequencyResponse`,description:()=>`[Raw SFR table data]`},41486:`FocalPlaneXResolution`,41487:`FocalPlaneYResolution`,41488:{name:`FocalPlaneResolutionUnit`,description:uU.FocalPlaneResolutionUnit},41492:{name:`SubjectLocation`,description:([e,t])=>`X: ${e}, Y: ${t}`},41493:`ExposureIndex`,41495:{name:`SensingMethod`,description:e=>e===1?`Undefined`:e===2?`One-chip color area sensor`:e===3?`Two-chip color area sensor`:e===4?`Three-chip color area sensor`:e===5?`Color sequential area sensor`:e===7?`Trilinear sensor`:e===8?`Color sequential linear sensor`:`Unknown`},41728:{name:`FileSource`,description:e=>e===3?`DSC`:`Unknown`},41729:{name:`SceneType`,description:e=>e===1?`A directly photographed image`:`Unknown`},41730:{name:`CFAPattern`,description:()=>`[Raw CFA pattern table data]`},41985:{name:`CustomRendered`,description:uU.CustomRendered},41986:{name:`ExposureMode`,description:uU.ExposureMode},41987:{name:`WhiteBalance`,description:uU.WhiteBalance},41988:{name:`DigitalZoomRatio`,description:e=>e[0]===0?`Digital zoom was not used`:``+e[0]/e[1]},41989:{name:`FocalLengthIn35mmFilm`,description:uU.FocalLengthIn35mmFilm},41990:{name:`SceneCaptureType`,description:uU.SceneCaptureType},41991:{name:`GainControl`,description:e=>e===0?`None`:e===1?`Low gain up`:e===2?`High gain up`:e===3?`Low gain down`:e===4?`High gain down`:`Unknown`},41992:{name:`Contrast`,description:uU.Contrast},41993:{name:`Saturation`,description:uU.Saturation},41994:{name:`Sharpness`,description:uU.Sharpness},41995:{name:`DeviceSettingDescription`,description:()=>`[Raw device settings table data]`},41996:{name:`SubjectDistanceRange`,description:e=>e===1?`Macro`:e===2?`Close view`:e===3?`Distant view`:`Unknown`},42016:`ImageUniqueID`,42032:`CameraOwnerName`,42033:`BodySerialNumber`,42034:{name:`LensSpecification`,description:e=>{let t=`${parseFloat((e[0][0]/e[0][1]).toFixed(5))}-${parseFloat((e[1][0]/e[1][1]).toFixed(5))} mm`;if(e[3][1]===0)return`${t} f/?`;let n=1/(e[2][1]/e[2][1]/(e[3][0]/e[3][1]));return`${t} f/${parseFloat(n.toFixed(5))}`}},42035:`LensMake`,42036:`LensModel`,42037:`LensSerialNumber`,42080:{name:`CompositeImage`,description:e=>({1:`Not a Composite Image`,2:`General Composite Image`,3:`Composite Image Captured While Shooting`})[e]||`Unknown`},42081:`SourceImageNumberOfCompositeImage`,42082:`SourceExposureTimesOfCompositeImage`,42240:`Gamma`,59932:`Padding`,59933:`OffsetSchema`,65e3:`OwnerName`,65001:`SerialNumber`,65002:`Lens`,65100:`RawFile`,65101:`Converter`,65102:`WhiteBalance`,65105:`Exposure`,65106:`Shadows`,65107:`Brightness`,65108:`Contrast`,65109:`Saturation`,65110:`Sharpness`,65111:`Smoothness`,65112:`MoireFilter`},mU={0:{name:`GPSVersionID`,description:e=>e[0]===2&&e[1]===2&&e[2]===0&&e[3]===0?`Version 2.2`:`Unknown`},1:{name:`GPSLatitudeRef`,description:e=>{let t=e.join(``);return t===`N`?`North latitude`:t===`S`?`South latitude`:`Unknown`}},2:{name:`GPSLatitude`,description:qz},3:{name:`GPSLongitudeRef`,description:e=>{let t=e.join(``);return t===`E`?`East longitude`:t===`W`?`West longitude`:`Unknown`}},4:{name:`GPSLongitude`,description:qz},5:{name:`GPSAltitudeRef`,description:e=>e===0?`Sea level`:e===1?`Sea level reference (negative value)`:`Unknown`},6:{name:`GPSAltitude`,description:e=>e[0]/e[1]+` m`},7:{name:`GPSTimeStamp`,description:e=>e.map(([e,t])=>{let n=e/t;return/^\d(\.|$)/.test(`${n}`)?`0${n}`:n}).join(`:`)},8:`GPSSatellites`,9:{name:`GPSStatus`,description:e=>{let t=e.join(``);return t===`A`?`Measurement in progress`:t===`V`?`Measurement Interoperability`:`Unknown`}},10:{name:`GPSMeasureMode`,description:e=>{let t=e.join(``);return t===`2`?`2-dimensional measurement`:t===`3`?`3-dimensional measurement`:`Unknown`}},11:`GPSDOP`,12:{name:`GPSSpeedRef`,description:e=>{let t=e.join(``);return t===`K`?`Kilometers per hour`:t===`M`?`Miles per hour`:t===`N`?`Knots`:`Unknown`}},13:`GPSSpeed`,14:{name:`GPSTrackRef`,description:e=>{let t=e.join(``);return t===`T`?`True direction`:t===`M`?`Magnetic direction`:`Unknown`}},15:`GPSTrack`,16:{name:`GPSImgDirectionRef`,description:e=>{let t=e.join(``);return t===`T`?`True direction`:t===`M`?`Magnetic direction`:`Unknown`}},17:`GPSImgDirection`,18:`GPSMapDatum`,19:{name:`GPSDestLatitudeRef`,description:e=>{let t=e.join(``);return t===`N`?`North latitude`:t===`S`?`South latitude`:`Unknown`}},20:{name:`GPSDestLatitude`,description:e=>e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600},21:{name:`GPSDestLongitudeRef`,description:e=>{let t=e.join(``);return t===`E`?`East longitude`:t===`W`?`West longitude`:`Unknown`}},22:{name:`GPSDestLongitude`,description:e=>e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600},23:{name:`GPSDestBearingRef`,description:e=>{let t=e.join(``);return t===`T`?`True direction`:t===`M`?`Magnetic direction`:`Unknown`}},24:`GPSDestBearing`,25:{name:`GPSDestDistanceRef`,description:e=>{let t=e.join(``);return t===`K`?`Kilometers`:t===`M`?`Miles`:t===`N`?`Knots`:`Unknown`}},26:`GPSDestDistance`,27:{name:`GPSProcessingMethod`,description:Kz},28:{name:`GPSAreaInformation`,description:Kz},29:`GPSDateStamp`,30:{name:`GPSDifferential`,description:e=>e===0?`Measurement without differential correction`:e===1?`Differential correction applied`:`Unknown`},31:`GPSHPositioningError`},hU={1:`InteroperabilityIndex`,2:{name:`InteroperabilityVersion`,description:e=>GR(e)},4096:`RelatedImageFileFormat`,4097:`RelatedImageWidth`,4098:`RelatedImageHeight`},gU={45056:{name:`MPFVersion`,description:e=>GR(e)},45057:`NumberOfImages`,45058:`MPEntry`,45059:`ImageUIDList`,45060:`TotalFrames`},_U={1:{name:`CameraSettings`,description:e=>e},4:{name:`ShotInfo`,description:e=>e},149:`LensModel`},vU={0:{name:`PentaxVersion`,description:e=>e.join(`.`)},5:`PentaxModelID`,555:`LevelInfo`},yU=Q.USE_EXIF?XR({},dU,pU):{},bU=`exif`,xU=`interoperability`,SU=`canon`,CU=`pentax`,wU={"0th":yU,"1st":Q.USE_EXIF?dU:{},[bU]:yU,gps:Q.USE_EXIF?mU:{},[xU]:Q.USE_EXIF?hU:{},mpf:Q.USE_MPF?gU:{},[SU]:Q.USE_MAKER_NOTES?_U:{},[CU]:Q.USE_MAKER_NOTES?vU:{}},TU={1:1,2:1,3:2,4:4,5:8,7:1,9:4,10:8,13:4},EU={BYTE:1,ASCII:2,SHORT:3,LONG:4,RATIONAL:5,UNDEFINED:7,SLONG:9,SRATIONAL:10,IFD:13},$={getAsciiValue:DU,getByteAt:OU,getAsciiAt:kU,getShortAt:AU,getLongAt:jU,getRationalAt:MU,getUndefinedAt:NU,getSlongAt:PU,getSrationalAt:FU,getIfdPointerAt:IU,typeSizes:TU,tagTypes:EU,getTypeSize:LU};function DU(e){return e.map(e=>String.fromCharCode(e))}function OU(e,t){return e.getUint8(t)}function kU(e,t){return e.getUint8(t)}function AU(e,t,n){return e.getUint16(t,n===Xz.LITTLE_ENDIAN)}function jU(e,t,n){return e.getUint32(t,n===Xz.LITTLE_ENDIAN)}function MU(e,t,n){return[jU(e,t,n),jU(e,t+4,n)]}function NU(e,t){return OU(e,t)}function PU(e,t,n){return e.getInt32(t,n===Xz.LITTLE_ENDIAN)}function FU(e,t,n){return[PU(e,t,n),PU(e,t+4,n)]}function IU(e,t,n){return jU(e,t,n)}function LU(e){if(EU[e]===void 0)throw Error(`No such type found.`);return TU[EU[e]]}var RU={exif:!0,iptc:!0,photoshop:!0,mpf:!0,makerNotes:!0},zU={exif:!0,iptc:!0,xmp:!0,icc:!0,photoshop:!0,makerNotes:!0,mpf:!0,file:!0,jfif:!0,png:!0,riff:!0,gif:!0,gps:!0,composite:!0,thumbnail:!0},BU={exifIfdPointer:`Exif IFD Pointer`,gpsInfoIfdPointer:`GPS Info IFD Pointer`,interoperabilityIfdPointer:`Interoperability IFD Pointer`},VU={thumbnail:[`JPEGInterchangeFormat`,`JPEGInterchangeFormatLength`],iptc:[`IPTC-NAA`],xmp:[`ApplicationNotes`],icc:[`ICC_Profile`],photoshop:[`ImageSourceData`,`PhotoshopSettings`],makerNotes:[`MakerNote`,`Make`],gps:[`GPSLatitude`,`GPSLatitudeRef`,`GPSLongitude`,`GPSLongitudeRef`,`GPSAltitude`,`GPSAltitudeRef`]},HU={file:[`Image Width`,`Image Height`],exif:[`FocalLength`,`FocalPlaneXResolution`,`FocalPlaneYResolution`,`FocalPlaneResolutionUnit`,`FocalLengthIn35mmFilm`]};function UU(e){let t=Object.create(null);if(!e)return t;Array.isArray(e.exif)&&e.exif.length>0&&(t[BU.exifIfdPointer]=!0,n(t,e.exif));for(let n in VU)if(WU(e[n])){let e=VU[n];for(let n=0;n<e.length;n++)t[e[n]]=!0;t[BU.exifIfdPointer]=!0}return WU(e.gps)&&(t[BU.gpsInfoIfdPointer]=!0,t[BU.exifIfdPointer]=!0),t;function n(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(typeof r!=`string`)continue;let i=r.toLowerCase();i.indexOf(`gps`)===0&&(e[BU.gpsInfoIfdPointer]=!0),(i.indexOf(`interoperability`)===0||i.indexOf(`relatedimage`)===0)&&(e[BU.interoperabilityIfdPointer]=!0)}}}function WU(e){return e===!0||Array.isArray(e)&&e.length>0}function GU({includeTags:e,excludeTags:t}={}){let n=!!e,r=!!t,i=n||r,a=Object.create(null),o=Object.create(null),s=Object.create(null);if(!i)return KU();let c=n&&(ZU(e,`iptc`)||ZU(e,`xmp`)||ZU(e,`icc`)||ZU(e,`photoshop`)||ZU(e,`makerNotes`)||ZU(e,`thumbnail`)||ZU(e,`gps`)||ZU(e,`composite`)),l=n&&ZU(e,`composite`),u=Object.create(null);n&&(u=JU(e));let d=Object.create(null);n&&l&&(d=rW(HU.file));for(let i in zU){let f=n&&Object.prototype.hasOwnProperty.call(e,i),p=r&&Object.prototype.hasOwnProperty.call(t,i),m;p&&!f&&(m=t[i]);let h=$U({groupKey:i,includeValue:f?e[i]:void 0,excludeValue:m,extraIncludeNames:Object.create(null)});a[i]=!n||f,f&&QU(e[i])&&(a[i]=!1),h.excludeAll&&(a[i]=!1),o[i]=h,s[i]=$U({groupKey:i,includeValue:YU({groupKey:i,hasIncludeTags:n,hasIncludeEntry:f,includeTags:e,shouldParseExif:c,shouldParseFile:l}),excludeValue:m,extraIncludeNames:XU({groupKey:i,hasIncludeTags:n,hasIncludeEntry:f,shouldParseExif:c,shouldParseFile:l,exifIncludeDependencies:u,fileIncludeDependencies:d})})}return{isActive:i,shouldReturnGroup:f,shouldParseGroup:p,shouldReturnTag:m,shouldParseTag:h};function f(e){return!zU[e]||!!a[e]}function p(e){return!zU[e]||f(e)?!0:e===`exif`?c:e===`file`&&l}function m(e,t,n){return zU[e]?f(e)?eW(o[e],t,n):!1:!0}function h(e,t,n){return zU[e]?p(e)?eW(s[e],t,n):!1:!0}}function KU(){return{isActive:!1,shouldReturnGroup:e,shouldParseGroup:e,shouldReturnTag:e,shouldParseTag:e};function e(){return!0}}var qU=KU();function JU(e){let t=UU(e);return ZU(e,`composite`)&&iW(t,HU.exif),t}function YU({groupKey:e,hasIncludeTags:t,hasIncludeEntry:n,includeTags:r,shouldParseExif:i,shouldParseFile:a}){if(!t)return!0;if(n)return e===`thumbnail`&&Array.isArray(r[e])?!0:r[e];if(e===`exif`&&i||e===`file`&&a)return[]}function XU({groupKey:e,hasIncludeTags:t,hasIncludeEntry:n,shouldParseExif:r,shouldParseFile:i,exifIncludeDependencies:a,fileIncludeDependencies:o}){return t?e===`exif`&&(r||n&&Object.keys(a).length>0)?a:e===`file`&&i?o:Object.create(null):Object.create(null)}function ZU(e,t){if(!e||!Object.prototype.hasOwnProperty.call(e,t))return!1;let n=e[t];return n===!0||Array.isArray(n)&&n.length>0}function QU(e){return Array.isArray(e)&&e.length===0}function $U({groupKey:e,includeValue:t,excludeValue:n,extraIncludeNames:r}){let i=!!RU[e],a={includeAll:!1,includeNames:void 0,includeIds:void 0,excludeAll:!1,excludeNames:void 0,excludeIds:void 0};if(t===!0)a.includeAll=!0;else if(Array.isArray(t)){a.includeNames=Object.create(null),i&&(a.includeIds=Object.create(null));for(let e=0;e<t.length;e++)o(a,t[e]);for(let e in r)a.includeNames[e.toLowerCase()]=!0}else if(r&&Object.keys(r).length>0){a.includeNames=Object.create(null);for(let e in r)a.includeNames[e.toLowerCase()]=!0}if(n===!0)return a.excludeAll=!0,a;if(Array.isArray(n)){a.excludeNames=Object.create(null),i&&(a.excludeIds=Object.create(null));for(let e=0;e<n.length;e++)s(a,n[e])}return a;function o(e,t){if(typeof t==`number`&&e.includeIds){e.includeIds[String(t)]=!0;return}typeof t==`string`&&(e.includeNames[t.toLowerCase()]=!0)}function s(e,t){if(typeof t==`number`&&e.excludeIds){e.excludeIds[String(t)]=!0;return}typeof t==`string`&&(e.excludeNames[t.toLowerCase()]=!0)}}function eW(e,t,n){return e.excludeAll?!1:e.includeAll||!e.includeNames&&!e.includeIds||tW(e,t,n)?!nW(e,t,n):!1}function tW(e,t,n){return!!(n!==void 0&&e.includeIds&&e.includeIds[String(n)]||t&&e.includeNames&&e.includeNames[String(t).toLowerCase()])}function nW(e,t,n){return!!(n!==void 0&&e.excludeIds&&e.excludeIds[String(n)]||t&&e.excludeNames&&e.excludeNames[String(t).toLowerCase()])}function rW(e){let t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n].toLowerCase()]=!0;return t}function iW(e,t){for(let n=0;n<t.length;n++)e[t[n]]=!0}var aW=4,oW={1:$.getByteAt,2:$.getAsciiAt,3:$.getShortAt,4:$.getLongAt,5:$.getRationalAt,7:$.getUndefinedAt,9:$.getSlongAt,10:$.getSrationalAt,13:$.getIfdPointerAt};function sW(e,t,n){let r=t+4;if(!(r+$.getTypeSize(`LONG`)>e.byteLength))return t+$.getLongAt(e,r,n)}function cW(e,t,n,r,i,a,o=!1,s=qU,c=`exif`,l=lW(e)){let u=$.getTypeSize(`SHORT`),d={},f=uW(e,r,i);r+=u;for(let u=0;u<f&&!(r+12>e.byteLength);u++){let u=dW(e,t,n,r,i,a,s,c,l);u!==void 0&&(d[u.name]={id:u.id,value:u.value,description:u.description},o&&(d[u.name].computed=bW(u.tagType,u.value)),(u.name===`MakerNote`||t===`pentax`&&u.name===`LevelInfo`)&&(d[u.name].__offset=u.__offset)),r+=12}if(Q.USE_THUMBNAIL&&r<e.byteLength-$.getTypeSize(`LONG`)){let c=$.getLongAt(e,r,i);c!==0&&t===`0th`&&s.shouldParseGroup(`thumbnail`)&&(d.Thumbnail=cW(e,`1st`,n,n+c,i,a,o,s,`thumbnail`,l))}return d}function lW(e){return{remaining:e.byteLength*aW}}function uW(e,t,n){return t+$.getTypeSize(`SHORT`)<=e.byteLength?$.getShortAt(e,t,n):0}function dW(e,t,n,r,i,a=!1,o=qU,s=`exif`,c){let l=$.getTypeSize(`SHORT`),u=l+$.getTypeSize(`SHORT`),d=u+$.getTypeSize(`LONG`),f=$.getShortAt(e,r,i),p=$.getShortAt(e,r+l,i),m=$.getLongAt(e,r+u,i),h,g;if($.typeSizes[p]===void 0||!a&&wU[t][f]===void 0)return;let _=fW(t,f);if(!o.shouldParseTag(s,_,f))return;if(pW(p,m))g=r+d,h=mW(e,g,p,m,i);else if(g=$.getLongAt(e,r+d,i),hW(e,n,g,p,m)){let t=f===33723,r=gW(c.remaining,p,m);c.remaining-=r*$.typeSizes[p],h=mW(e,n+g,p,r,i,t)}else h=`<faulty value>`;p===$.tagTypes.ASCII&&(h=_W(h),h=vW(h));let v=h;if(wU[t][f]!==void 0){if(wU[t][f].name!==void 0&&wU[t][f].description!==void 0)try{v=wU[t][f].description(h)}catch{v=yW(h)}else v=p===$.tagTypes.RATIONAL||p===$.tagTypes.SRATIONAL?``+h[0]/h[1]:yW(h)}return{id:f,name:_,value:h,description:v,tagType:p,__offset:g}}function fW(e,t){if(wU[e][t]!==void 0){if(typeof wU[e][t]==`string`)return wU[e][t];if(wU[e][t].name)return wU[e][t].name}return`undefined-${t}`}function pW(e,t){return $.typeSizes[e]*t<=$.getTypeSize(`LONG`)}function mW(e,t,n,r,i,a=!1){let o=[];a&&(r*=$.typeSizes[n],n=$.tagTypes.BYTE);for(let a=0;a<r;a++)o.push(oW[n](e,t,i)),t+=$.typeSizes[n];return n===$.tagTypes.ASCII?o=$.getAsciiValue(o):o.length===1&&(o=o[0]),o}function hW(e,t,n,r,i){return t+n+$.typeSizes[r]*i<=e.byteLength}function gW(e,t,n){let r=Math.min(n,Math.floor(e/$.typeSizes[t]));return r===1&&n>1?0:r}function _W(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(e[r]===`\0`){n++;continue}t[n]===void 0&&(t[n]=``),t[n]+=e[r]}return t}function vW(e){return e.map(e=>KR(e))}function yW(e){return e instanceof Array?e.join(`, `):e}function bW(e,t){return e===$.tagTypes.ASCII?Array.isArray(t)&&t.length===1?t[0]:t:e===$.tagTypes.RATIONAL||e===$.tagTypes.SRATIONAL?xW(t)?SW(t):Array.isArray(t)?t.map(e=>SW(e)):t:t}function xW(e){return!Array.isArray(e)||e.length!==2?!1:typeof e[0]==`number`&&typeof e[1]==`number`}function SW(e){if(!Array.isArray(e)||e.length!==2)return e;let t=e[0],n=e[1];return!Number.isFinite(t)||!Number.isFinite(n)?e:n===0?null:t/n}var CW=[{pointerKey:`Exif IFD Pointer`,ifdType:bU},{pointerKey:`GPS Info IFD Pointer`,ifdType:`gps`},{pointerKey:`Interoperability IFD Pointer`,ifdType:xU}],wW={read:TW};function TW(e,t,n,r=!1,i=void 0){let a=Xz.getByteOrder(e,t),o=lW(e),s=EW(e,t,a,n,r,i,o);for(let c=0;c<CW.length;c++)s=DW(CW[c],s,e,t,a,n,r,i,o);return{tags:s,byteOrder:a}}function EW(e,t,n,r,i,a,o){let s=sW(e,t,n);return s===void 0?{}:cW(e,`0th`,t,s,n,r,i,a,`exif`,o)}function DW(e,t,n,r,i,a,o,s,c){let l=t[e.pointerKey];return l===void 0?t:XR(t,cW(n,e.ifdType,r,r+l.value,i,a,o,s,`exif`,c))}var OW={read:jW},kW=16,AW=8;function jW(e,t,n,r=!1,i=void 0){try{let a=Xz.getByteOrder(e,t),o=sW(e,t,a);return o===void 0?{}:MW(e,t,cW(e,`mpf`,t,o,a,n,r,i,`mpf`),a)}catch{return{}}}function MW(e,t,n,r){if(!n.MPEntry)return n;let i=e.byteLength,a=e.byteOffset||0,o=i*AW,s=[];for(let c=0;c<Math.ceil(n.MPEntry.value.length/kW);c++){s[c]={};let l=NW(n.MPEntry.value,c*kW,$.getTypeSize(`LONG`),r);s[c].ImageFlags=PW(l),s[c].ImageFormat=FW(l),s[c].ImageType=IW(l);let u=NW(n.MPEntry.value,c*kW+4,$.getTypeSize(`LONG`),r);s[c].ImageSize={value:u,description:``+u};let d=LW(c,n.MPEntry,r,t);s[c].ImageOffset={value:d,description:``+d};let f=NW(n.MPEntry.value,c*kW+12,$.getTypeSize(`SHORT`),r);s[c].DependentImage1EntryNumber={value:f,description:``+f};let p=NW(n.MPEntry.value,c*kW+14,$.getTypeSize(`SHORT`),r);s[c].DependentImage2EntryNumber={value:p,description:``+p};let m=Math.min(Math.max(d,0),i),h=Math.min(m+Math.max(u,0),i,m+o);s[c].image=e.buffer.slice(a+m,a+h),o-=h-m,QR(s[c],`base64`,function(){return $R(this.image)})}return n.Images=s,n}function NW(e,t,n,r){if(r===Xz.LITTLE_ENDIAN){let r=0;for(let i=0;i<n;i++)r+=e[t+i]<<8*i;return r}let i=0;for(let r=0;r<n;r++)i+=e[t+r]<<8*(n-1-r);return i}function PW(e){let t=[e>>31&1,e>>30&1,e>>29&1],n=[];return t[0]&&n.push(`Dependent Parent Image`),t[1]&&n.push(`Dependent Child Image`),t[2]&&n.push(`Representative Image`),{value:t,description:n.join(`, `)||`None`}}function FW(e){let t=e>>24&7;return{value:t,description:t===0?`JPEG`:`Unknown`}}function IW(e){let t=e&16777215;return{value:t,description:{196608:`Baseline MP Primary Image`,65537:`Large Thumbnail (VGA equivalent)`,65538:`Large Thumbnail (Full HD equivalent)`,131073:`Multi-Frame Image (Panorama)`,131074:`Multi-Frame Image (Disparity)`,131075:`Multi-Frame Image (Multi-Angle)`,0:`Undefined`}[t]||`Unknown`}}function LW(e,t,n,r){return RW(e)?0:NW(t.value,e*kW+8,$.getTypeSize(`LONG`),n)+r}function RW(e){return e===0}var zW={read:BW};function BW(e,t){let n=VW(e,t),r=GW(e,t,n);return{"Bits Per Sample":HW(e,t,n),"Image Height":UW(e,t,n),"Image Width":WW(e,t,n),"Color Components":r,Subsampling:r&&KW(e,t,r.value,n)}}function VW(e,t){return Math.min($.getShortAt(e,t),e.byteLength-t)}function HW(e,t,n){if(3>n)return;let r=$.getByteAt(e,t+2);return{value:r,description:``+r}}function UW(e,t,n){if(5>n)return;let r=$.getShortAt(e,t+3);return{value:r,description:`${r}px`}}function WW(e,t,n){if(7>n)return;let r=$.getShortAt(e,t+5);return{value:r,description:`${r}px`}}function GW(e,t,n){if(8>n)return;let r=$.getByteAt(e,t+7);return{value:r,description:``+r}}function KW(e,t,n,r){if(8+3*n>r)return;let i=[];for(let r=0;r<n;r++){let n=t+8+r*3;i.push([$.getByteAt(e,n),$.getByteAt(e,n+1),$.getByteAt(e,n+2)])}return{value:i,description:i.length>1?qW(i)+JW(i):``}}function qW(e){let t={1:`Y`,2:`Cb`,3:`Cr`,4:`I`,5:`Q`};return e.map(e=>t[e[0]]).join(``)}function JW(e){let t={17:`4:4:4 (1 1)`,18:`4:4:0 (1 2)`,20:`4:4:1 (1 4)`,33:`4:2:2 (2 1)`,34:`4:2:0 (2 2)`,36:`4:2:1 (2 4)`,65:`4:1:1 (4 1)`,66:`4:1:0 (4 2)`};return e.length===0||e[0][1]===void 0||t[e[0][1]]===void 0?``:t[e[0][1]]}var YW={read:$W},XW=2,ZW=[9,13,18,30],QW=[0,1,12/10,4/3,3/2,16/9,5/4,2];function $W(e,t){let n={};try{let{height:r,width:i}=eG(nG(e,t+XW));n[`Image Height`]={value:r,description:`${r}px`},n[`Image Width`]={value:i,description:`${i}px`}}catch{}return n}function eG(e){let t=e.readBits(1),n,r;if(t){n=(e.readBits(5)+1)*8;let t=e.readBits(3);r=t===0?(e.readBits(5)+1)*8:Math.ceil(n*QW[t])}else{n=tG(e);let t=e.readBits(3);r=t===0?tG(e):Math.ceil(n*QW[t])}return{height:n,width:r}}function tG(e){let t=e.readBits(2);return 1+e.readBits(ZW[t])}function nG(e,t){let n=t,r=0;return{readBits(t){let i=0;for(let a=0;a<t;a++){if(n>=e.byteLength)throw Error(`Unexpected end of data`);let t=e.getUint8(n)>>r&1;i|=t<<a,r++,r>=8&&(r=0,n++)}return i}}}var rG={read:iG};function iG(e,t){let n=aG(e,t),r=dG(e,t,n),i=fG(e,t,n),a={"JFIF Version":oG(e,t,n),"Resolution Unit":sG(e,t,n),XResolution:lG(e,t,n),YResolution:uG(e,t,n),"JFIF Thumbnail Width":r,"JFIF Thumbnail Height":i};if(r!==void 0&&i!==void 0){let o=pG(e,t,3*r.value*i.value,n);o&&(a[`JFIF Thumbnail`]=o)}for(let e in a)a[e]===void 0&&delete a[e];return a}function aG(e,t){return Math.min($.getShortAt(e,t),e.byteLength-t)}function oG(e,t,n){if(9>n)return;let r=$.getByteAt(e,t+7),i=$.getByteAt(e,t+7+1);return{value:r*256+i,description:r+`.`+i}}function sG(e,t,n){if(10>n)return;let r=$.getByteAt(e,t+9);return{value:r,description:cG(r)}}function cG(e){return e===0?`None`:e===1?`inches`:e===2?`cm`:`Unknown`}function lG(e,t,n){if(12>n)return;let r=$.getShortAt(e,t+10);return{value:r,description:``+r}}function uG(e,t,n){if(14>n)return;let r=$.getShortAt(e,t+12);return{value:r,description:``+r}}function dG(e,t,n){if(15>n)return;let r=$.getByteAt(e,t+14);return{value:r,description:`${r}px`}}function fG(e,t,n){if(16>n)return;let r=$.getByteAt(e,t+15);return{value:r,description:`${r}px`}}function pG(e,t,n,r){if(n===0||16+n>r)return;let i=e.byteOffset||0;return{value:e.buffer.slice(i+t+16,i+t+16+n),description:`<24-bit RGB pixel data>`}}var mG={iptc:{256:{name:`Model Version`,description:e=>((e[0]<<8)+e[1]).toString()},261:{name:`Destination`,repeatable:!0},276:{name:`File Format`,description:e=>((e[0]<<8)+e[1]).toString()},278:{name:`File Format Version`,description:e=>((e[0]<<8)+e[1]).toString()},286:`Service Identifier`,296:`Envelope Number`,306:`Product ID`,316:`Envelope Priority`,326:{name:`Date Sent`,description:hG},336:{name:`Time Sent`,description:gG},346:{name:`Coded Character Set`,description:_G,encoding_name:_G},356:`UNO`,376:{name:`ARM Identifier`,description:e=>((e[0]<<8)+e[1]).toString()},378:{name:`ARM Version`,description:e=>((e[0]<<8)+e[1]).toString()},512:{name:`Record Version`,description:e=>((e[0]<<8)+e[1]).toString()},515:`Object Type Reference`,516:`Object Attribute Reference`,517:`Object Name`,519:`Edit Status`,520:{name:`Editorial Update`,description:e=>GR(e)===`01`?`Additional Language`:`Unknown`},522:`Urgency`,524:{name:`Subject Reference`,repeatable:!0,description:e=>{let t=GR(e).split(`:`);return t[2]+(t[3]?`/`+t[3]:``)+(t[4]?`/`+t[4]:``)}},527:`Category`,532:{name:`Supplemental Category`,repeatable:!0},534:`Fixture Identifier`,537:{name:`Keywords`,repeatable:!0},538:{name:`Content Location Code`,repeatable:!0},539:{name:`Content Location Name`,repeatable:!0},542:`Release Date`,547:`Release Time`,549:`Expiration Date`,550:`Expiration Time`,552:`Special Instructions`,554:{name:`Action Advised`,description:e=>{let t=GR(e);return t===`01`?`Object Kill`:t===`02`?`Object Replace`:t===`03`?`Object Append`:t===`04`?`Object Reference`:`Unknown`}},557:{name:`Reference Service`,repeatable:!0},559:{name:`Reference Date`,repeatable:!0},562:{name:`Reference Number`,repeatable:!0},567:{name:`Date Created`,description:hG},572:{name:`Time Created`,description:gG},574:{name:`Digital Creation Date`,description:hG},575:{name:`Digital Creation Time`,description:gG},577:`Originating Program`,582:`Program Version`,587:{name:`Object Cycle`,description:e=>{let t=GR(e);return t===`a`?`morning`:t===`p`?`evening`:t===`b`?`both`:`Unknown`}},592:{name:`By-line`,repeatable:!0},597:{name:`By-line Title`,repeatable:!0},602:`City`,604:`Sub-location`,607:`Province/State`,612:`Country/Primary Location Code`,613:`Country/Primary Location Name`,615:`Original Transmission Reference`,617:`Headline`,622:`Credit`,627:`Source`,628:`Copyright Notice`,630:{name:`Contact`,repeatable:!0},632:`Caption/Abstract`,634:{name:`Writer/Editor`,repeatable:!0},637:{name:`Rasterized Caption`,description:e=>e},642:`Image Type`,643:{name:`Image Orientation`,description:e=>{let t=GR(e);return t===`P`?`Portrait`:t===`L`?`Landscape`:t===`S`?`Square`:`Unknown`}},647:`Language Identifier`,662:{name:`Audio Type`,description:e=>{let t=GR(e),n=t.charAt(0),r=t.charAt(1),i=``;return n===`1`?i+=`Mono`:n===`2`&&(i+=`Stereo`),r===`A`?i+=`, actuality`:r===`C`?i+=`, question and answer session`:r===`M`?i+=`, music, transmitted by itself`:r===`Q`?i+=`, response to a question`:r===`R`?i+=`, raw sound`:r===`S`?i+=`, scener`:r===`V`?i+=`, voicer`:r===`W`&&(i+=`, wrap`),i===``?t:i}},663:{name:`Audio Sampling Rate`,description:e=>parseInt(GR(e),10)+` Hz`},664:{name:`Audio Sampling Resolution`,description:e=>{let t=parseInt(GR(e),10);return t+(t===1?` bit`:` bits`)}},665:{name:`Audio Duration`,description:e=>{let t=GR(e);return t.length>=6?t.substr(0,2)+`:`+t.substr(2,2)+`:`+t.substr(4,2):t}},666:`Audio Outcue`,698:`Short Document ID`,699:`Unique Document ID`,700:`Owner ID`,712:{name:e=>e.length===2?`ObjectData Preview File Format`:`Record 2 destination`,description:e=>{if(e.length===2){let t=(e[0]<<8)+e[1];return t===0?`No ObjectData`:t===1?`IPTC-NAA Digital Newsphoto Parameter Record`:t===2?`IPTC7901 Recommended Message Format`:t===3?`Tagged Image File Format (Adobe/Aldus Image data)`:t===4?`Illustrator (Adobe Graphics data)`:t===5?`AppleSingle (Apple Computer Inc)`:t===6?`NAA 89-3 (ANPA 1312)`:t===7?`MacBinary II`:t===8?`IPTC Unstructured Character Oriented File Format (UCOFF)`:t===9?`United Press International ANPA 1312 variant`:t===10?`United Press International Down-Load Message`:t===11?`JPEG File Interchange (JFIF)`:t===12?`Photo-CD Image-Pac (Eastman Kodak)`:t===13?`Microsoft Bit Mapped Graphics File [*.BMP]`:t===14?`Digital Audio File [*.WAV] (Microsoft & Creative Labs)`:t===15?`Audio plus Moving Video [*.AVI] (Microsoft)`:t===16?`PC DOS/Windows Executable Files [*.COM][*.EXE]`:t===17?`Compressed Binary File [*.ZIP] (PKWare Inc)`:t===18?`Audio Interchange File Format AIFF (Apple Computer Inc)`:t===19?`RIFF Wave (Microsoft Corporation)`:t===20?`Freehand (Macromedia/Aldus)`:t===21?`Hypertext Markup Language "HTML" (The Internet Society)`:t===22?`MPEG 2 Audio Layer 2 (Musicom), ISO/IEC`:t===23?`MPEG 2 Audio Layer 3, ISO/IEC`:t===24?`Portable Document File (*.PDF) Adobe`:t===25?`News Industry Text Format (NITF)`:t===26?`Tape Archive (*.TAR)`:t===27?`Tidningarnas Telegrambyrå NITF version (TTNITF DTD)`:t===28?`Ritzaus Bureau NITF version (RBNITF DTD)`:t===29?`Corel Draw [*.CDR]`:`Unknown format ${t}`}return GR(e)}},713:{name:`ObjectData Preview File Format Version`,description:(e,t)=>{let n={"00":{"00":`1`},"01":{"01":`1`,"02":`2`,"03":`3`,"04":`4`},"02":{"04":`4`},"03":{"01":`5.0`,"02":`6.0`},"04":{"01":`1.40`},"05":{"01":`2`},"06":{"01":`1`},11:{"01":`1.02`},20:{"01":`3.1`,"02":`4.0`,"03":`5.0`,"04":`5.5`},21:{"02":`2.0`}},r=GR(e);if(t[`ObjectData Preview File Format`]){let e=GR(t[`ObjectData Preview File Format`].value);if(n[e]&&n[e][r])return n[e][r]}return r}},714:`ObjectData Preview Data`,1802:{name:`Size Mode`,description:e=>e[0].toString()},1812:{name:`Max Subfile Size`,description:e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<8)+e[n];return t.toString()}},1882:{name:`ObjectData Size Announced`,description:e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<8)+e[n];return t.toString()}},1887:{name:`Maximum ObjectData Size`,description:e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<8)+e[n];return t.toString()}}}};function hG(e){let t=GR(e);return t.length>=8?t.substr(0,4)+`-`+t.substr(4,2)+`-`+t.substr(6,2):t}function gG(e){let t=GR(e),n=t;return t.length>=6&&(n=t.substr(0,2)+`:`+t.substr(2,2)+`:`+t.substr(4,2),t.length===11&&(n+=t.substr(6,1)+t.substr(7,2)+`:`+t.substr(9,2))),n}function _G(e){let t=GR(e);return t===`\x1B%G`?`UTF-8`:t===`\x1B%5`?`Windows-1252`:t===`\x1B%/G`?`UTF-8 Level 1`:t===`\x1B%/H`?`UTF-8 Level 2`:t===`\x1B%/I`?`UTF-8 Level 3`:t===`\x1B/A`?`ISO-8859-1`:t===`\x1B/B`?`ISO-8859-2`:t===`\x1B/C`?`ISO-8859-3`:t===`\x1B/D`?`ISO-8859-4`:t===`\x1B/@`?`ISO-8859-5`:t===`\x1B/G`?`ISO-8859-6`:t===`\x1B/F`?`ISO-8859-7`:t===`\x1B/H`?`ISO-8859-8`:`Unknown`}var vG={get:yG};function yG(){if(typeof TextDecoder<`u`)return TextDecoder}var bG=5,xG={128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376},SG={decode:CG,TAG_HEADER_SIZE:bG};function CG(e,t){if(typeof t==`string`)return KR(t);let n=vG.get();if(n!==void 0&&e!==void 0)try{return new n(e).decode(t instanceof DataView?t.buffer:Uint8Array.from(t))}catch{}let r=t.map(e=>String.fromCharCode(e)).join(``);try{return decodeURIComponent(escape(r))}catch{return wG(t)}}function wG(e){let t=e instanceof DataView,n=t?e.byteLength:e.length,r=t?t=>e.getUint8(t):t=>e[t],i=Array(n);for(let e=0;e<n;e++){let t=r(e),n=xG[t];i[e]=n===void 0?t:n}return String.fromCharCode.apply(null,i)}var TG=943868237,EG=4,DG=2,OG=1,kG=4,AG=12,jG=1028,MG=5,NG={read:PG};function PG(e,t,n,r=qU){try{if(Array.isArray(e))return zG(new DataView(Uint8Array.from(e).buffer),{size:e.length},0,n,r);let{naaBlock:i,dataOffset:a}=FG(e,t);return zG(e,i,a,n,r)}catch{return{}}}function FG(e,t){for(;t+AG<=e.byteLength;){let n=IG(e,t);if(LG(n))return{naaBlock:n,dataOffset:t+n.headerSize};t+=n.headerSize+n.size+RG(n)}throw Error(`No IPTC NAA resource block.`)}function IG(e,t){if(e.getUint32(t,!1)!==TG)throw Error(`Not an IPTC resource block.`);let n=e.getUint8(t+EG+DG),r=(n%2==0?n+1:n)+OG;return{headerSize:6+r+kG,type:e.getUint16(t+EG),size:e.getUint32(t+EG+DG+r)}}function LG(e){return e.type===jG}function RG(e){return e.size%2==0?0:1}function zG(e,t,n,r,i){let a={},o,s=n+t.size;for(;n<s&&n<e.byteLength;){let{tag:t,tagSize:s}=BG(e,n,a,o,r,i);if(t===null)break;t&&(`encoding`in t&&(o=t.encoding),a[t.name]===void 0||t.repeatable===void 0?a[t.name]={id:t.id,value:t.value,description:t.description}:(a[t.name]instanceof Array||(a[t.name]=[{id:a[t.name].id,value:a[t.name].value,description:a[t.name].description}]),a[t.name].push({id:t.id,value:t.value,description:t.description}))),n+=MG+s}return a}function BG(e,t,n={},r=void 0,i=!1,a=qU){if(HG(e,t))return{tag:null,tagSize:0};let o=e.getUint16(t+1),s=e.getUint16(t+3);if(!i&&!mG.iptc[o]||!a.shouldParseTag(`iptc`,VG(o,i),o))return{tag:void 0,tagSize:s};let c=UG(e,t+MG,s),l={id:o,name:WG(mG.iptc[o],o,c),value:c,description:qG(mG.iptc[o],c,n,r)};return XG(o)&&(l.repeatable=!0),ZG(o)&&(l.encoding=mG.iptc[o].encoding_name(c)),{tag:l,tagSize:s}}function VG(e,t){let n=mG.iptc[e];if(!n)return t?`undefined-${e}`:void 0;if(typeof n==`string`)return n;if(n&&typeof n.name==`string`)return n.name}function HG(e,t){return e.getUint8(t)!==28}function UG(e,t,n){let r=[];for(let i=0;i<n;i++)r.push(e.getUint8(t+i));return r}function WG(e,t,n){return e?GG(e)?e:KG(e)?e.name(n):e.name:`undefined-${t}`}function GG(e){return typeof e==`string`}function KG(e){return typeof e.name==`function`}function qG(e,t,n,r){if(YG(e))try{return e.description(t,n)}catch{}return JG(e,t)?SG.decode(r,t):t}function JG(e,t){return e&&t instanceof Array}function YG(e){return e&&e.description!==void 0}function XG(e){return mG.iptc[e]&&mG.iptc[e].repeatable}function ZG(e){return mG.iptc[e]&&mG.iptc[e].encoding_name!==void 0}var QG={"tiff:Orientation"(e){return e===`1`?`Horizontal (normal)`:e===`2`?`Mirror horizontal`:e===`3`?`Rotate 180`:e===`4`?`Mirror vertical`:e===`5`?`Mirror horizontal and rotate 270 CW`:e===`6`?`Rotate 90 CW`:e===`7`?`Mirror horizontal and rotate 90 CW`:e===`8`?`Rotate 270 CW`:e},"tiff:ResolutionUnit":e=>uU.ResolutionUnit(parseInt(e,10)),"tiff:XResolution":e=>$G(uU.XResolution,e),"tiff:YResolution":e=>$G(uU.YResolution,e),"exif:ApertureValue":e=>$G(uU.ApertureValue,e),"exif:GPSLatitude":nK,"exif:GPSLongitude":nK,"exif:FNumber":e=>$G(uU.FNumber,e),"exif:FocalLength":e=>$G(uU.FocalLength,e),"exif:FocalPlaneResolutionUnit":e=>uU.FocalPlaneResolutionUnit(parseInt(e,10)),"exif:ColorSpace":e=>uU.ColorSpace(eK(e)),"exif:ComponentsConfiguration"(e,t){if(/^\d, \d, \d, \d$/.test(t)){let e=t.split(`, `).map(e=>e.charCodeAt(0));return uU.ComponentsConfiguration(e)}return t},"exif:Contrast":e=>uU.Contrast(parseInt(e,10)),"exif:CustomRendered":e=>uU.CustomRendered(parseInt(e,10)),"exif:ExposureMode":e=>uU.ExposureMode(parseInt(e,10)),"exif:ExposureProgram":e=>uU.ExposureProgram(parseInt(e,10)),"exif:ExposureTime"(e){return tK(e)?uU.ExposureTime(e.split(`/`).map(e=>parseInt(e,10))):e},"exif:MeteringMode":e=>uU.MeteringMode(parseInt(e,10)),"exif:Saturation":e=>uU.Saturation(parseInt(e,10)),"exif:SceneCaptureType":e=>uU.SceneCaptureType(parseInt(e,10)),"exif:Sharpness":e=>uU.Sharpness(parseInt(e,10)),"exif:ShutterSpeedValue":e=>$G(uU.ShutterSpeedValue,e),"exif:WhiteBalance":e=>uU.WhiteBalance(parseInt(e,10))};function $G(e,t){return tK(t)?e(t.split(`/`)):t}function eK(e){return e.substring(0,2)===`0x`?parseInt(e.substring(2),16):parseInt(e,10)}function tK(e){return/^-?\d+\/-?\d+$/.test(e)}function nK(e){let[t,n]=e.split(`,`);if(t!==void 0&&n!==void 0){let e=parseFloat(t),r=parseFloat(n),i=n.charAt(n.length-1);if(!Number.isNaN(e)&&!Number.isNaN(r))return``+(e+r/60)+i}return e}var rK={get:iK};function iK(e){if(e)return e;if(typeof DOMParser<`u`)return new DOMParser;try{let{DOMParser:e,onErrorStopParsing:t}=__non_webpack_require__(`@xmldom/xmldom`);return new e({onError:t})}catch{return}}function aK(e){let t=[`prefix is non-null and namespace is null`,`prefix not bound to a namespace`,`prefix inte bundet till en namnrymd`,/Namespace prefix .+ is not defined/];for(let n=0;n<t.length;n++)if(new RegExp(t[n]).test(e.message))return!0;return!1}function oK(e){let t=sK(e);if(t===-1)return e;let{insertionIndex:n,attributeValueSpans:r}=cK(e,t+1);if(n===-1)return e;let i=dK(e,t,n,r),a=pK(e).filter(e=>i[e]===void 0);if(a.length===0)return e;let o=hK(a);return e.slice(0,n)+o+e.slice(n)}function sK(e){let t=0;for(;t<e.length;){if(t=e.indexOf(`<`,t),t===-1)return-1;if(/[A-Za-z_]/.test(e.charAt(t+1)))return t;lK(e,`<!--`,t)?t=uK(e,t+4,`-->`):lK(e,`<![CDATA[`,t)?t=uK(e,t+9,`]]>`):e.charAt(t+1)===`?`?t=uK(e,t+2,`?>`):t++}return-1}function cK(e,t){let n=[],r,i;for(let a=t;a<e.length;a++){let t=e.charAt(a);if(r!==void 0)t===r&&(n.push({start:i,end:a}),r=void 0);else if(t===`"`||t===`'`)r=t,i=a+1;else if(t===`>`)return e.charAt(a-1)===`/`?{insertionIndex:a-1,attributeValueSpans:n}:{insertionIndex:a,attributeValueSpans:n}}return{insertionIndex:-1,attributeValueSpans:n}}function lK(e,t,n){return e.slice(n,n+t.length)===t}function uK(e,t,n){let r=e.indexOf(n,t);return r===-1?e.length:r+n.length}function dK(e,t,n,r){let i=Object.create(null),a=/xmlns:([A-Za-z_][A-Za-z0-9._-]*)\s*=\s*["']([^"']*)["']/g,o,s=0;for(;(o=a.exec(e))!==null;){for(;s<r.length&&r[s].end<=o.index;)s++;if(s<r.length&&r[s].start<=o.index){a.lastIndex=r[s].end;continue}(o[2]!==``||fK(o.index,t,n))&&(i[o[1]]=!0)}return i}function fK(e,t,n){return e>t&&e<n}function pK(e){let t=[],n=Object.create(null),r=/(?:^|[^A-Za-z0-9._-])([A-Za-z_][A-Za-z0-9._-]*):[A-Za-z_][A-Za-z0-9._-]*/g,i;for(;(i=r.exec(e))!==null;){let e=i[1];e!==`xmlns`&&e!==`xml`&&n[e]===void 0&&(n[e]=!0,t.push(e))}return t}var mK={xmp:`http://ns.adobe.com/xap/1.0/`,tiff:`http://ns.adobe.com/tiff/1.0/`,exif:`http://ns.adobe.com/exif/1.0/`,dc:`http://purl.org/dc/elements/1.1/`,xmpMM:`http://ns.adobe.com/xap/1.0/mm/`,stEvt:`http://ns.adobe.com/xap/1.0/sType/ResourceEvent#`,stRef:`http://ns.adobe.com/xap/1.0/sType/ResourceRef#`,photoshop:`http://ns.adobe.com/photoshop/1.0/`};function hK(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(` xmlns:`+r+`="`+gK(r)+`"`)}return t.join(``)}function gK(e){return Object.prototype.hasOwnProperty.call(mK,e)?mK[e]:`http://fallback.namespace/`+e}var _K={read:yK},vK=class extends Error{constructor(e){super(e),this.name=`ParseError`}};function yK(e,t,n){let r={};if(typeof e==`string`)return CK(r,e,n),r;let[i,a]=bK(e,t),o=CK(r,i,n);if(a){let i=CK(r,a,n);!o&&!i&&(delete r._raw,CK(r,xK(e,t),n))}return r}function bK(e,t){if(t.length===0)return[];let n=[xK(e,t.slice(0,1))];return t.length>1&&n.push(xK(e,t.slice(1))),n}function xK(e,t){let n=t.map(t=>SK(e,t)),r=n.reduce((e,t)=>e+t.length,0),i=new Uint8Array(r),a=0;for(let e=0;e<n.length;e++)i.set(n[e],a),a+=n[e].length;return new DataView(i.buffer)}function SK(e,t){let n=e.byteLength,r=e.byteOffset||0,i=Math.min(Math.max(t.dataOffset,0),n),a=Math.min(i+Math.max(t.length,0),n);return new Uint8Array(e.buffer.slice(r+i,r+a))}function CK(e,t,n){try{let{doc:r,raw:i,decodeValue:a}=wK(t,n);return e._raw=(e._raw||``)+i,XR(e,zK(jK(AK(r),!0,a))),!0}catch{return!1}}function wK(e,t){let n=rK.get(t);if(!n)throw console.warn(`Warning: DOMParser is not available. It is needed to be able to parse XMP tags.`),Error();let{xmlString:r,decodeValue:i}=TK(e);return{doc:kK(n,OK(r)),raw:r,decodeValue:i}}function TK(e){if(typeof e==`string`)return EK(e);let t=vG.get();if(t!==void 0)try{return{xmlString:new t(`utf-8`,{fatal:!0}).decode(e),decodeValue:DK}}catch{}return EK(VR(e,0,e.byteLength))}function EK(e){let t=qR(e);return t===void 0?{xmlString:e,decodeValue:KR}:{xmlString:t,decodeValue:DK}}function DK(e){return e}function OK(e){return e.replace(/^.+(<\?xpacket begin)/,`$1`).replace(/(<\?xpacket end=".*"\?>).+$/,`$1`)}function kK(e,t,n=!1){try{let n=e.parseFromString(t,`application/xml`),r=n.getElementsByTagName(`parsererror`);if(r.length>0)throw new vK(r[0].textContent);return n}catch(r){if(r.name===`ParseError`&&aK(r)&&!n)return kK(e,oK(t),!0);throw r}}function AK(e){for(let t=0;t<e.childNodes.length;t++){if(e.childNodes[t].tagName===`x:xmpmeta`)return AK(e.childNodes[t]);if(e.childNodes[t].tagName===`rdf:RDF`)return e.childNodes[t]}throw Error()}function jK(e,t,n){let r=MK(e);return NK(r)?t?{}:n(PK(r[0])):FK(r,n)}function MK(e){let t=[];for(let n=0;n<e.childNodes.length;n++)t.push(e.childNodes[n]);return t}function NK(e){return e.length===1&&e[0].nodeName===`#text`}function PK(e){return e.nodeValue}function FK(e,t){let n=Object.create(null);return e.forEach(e=>{if(IK(e)){let r=LK(e,t);n[e.nodeName]===void 0?n[e.nodeName]=r:(Array.isArray(n[e.nodeName])||(n[e.nodeName]=[n[e.nodeName]]),n[e.nodeName].push(r))}}),n}function IK(e){return e.nodeName&&e.nodeName!==`#text`}function LK(e,t){return{attributes:RK(e,t),value:jK(e,!1,t)}}function RK(e,t){let n={};for(let r=0;r<e.attributes.length;r++)ZR(n,e.attributes[r].nodeName,t(e.attributes[r].value));return n}function zK(e){let t={};if(typeof e==`string`)return e;for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]),r.forEach(e=>{XR(t,BK(e.attributes)),typeof e.value==`object`&&XR(t,YK(e.value))})}return t}function BK(e){let t={};for(let n in e)try{VK(n)&&ZR(t,UK(n),{value:e[n],attributes:{},description:WK(e[n],n)})}catch{}return t}function VK(e){return e!==`rdf:parseType`&&!HK(e)}function HK(e){return e.split(`:`)[0]===`xmlns`}function UK(e){return/^MicrosoftPhoto(_\d+_)?:Rating$/i.test(e)?`RatingPercent`:e.split(`:`)[1]}function WK(e,t=void 0){if(Array.isArray(e)){let n=GK(e);if(KK(t))try{let r=QG[t](e,n);if(typeof r==`string`)return r}catch{}return n}if(typeof e==`object`)return qK(e);if(KK(t))try{return QG[t](e)}catch{return e}return e}function GK(e){return e.map(e=>e.value===void 0?WK(e):WK(e.value)).join(`, `)}function KK(e){return Object.prototype.hasOwnProperty.call(QG,e)&&typeof QG[e]==`function`}function qK(e){let t=[];for(let n in e)t.push(`${JK(n)}: ${WK(e[n].value)}`);return t.join(`; `)}function JK(e){return e===`CiAdrCity`?`CreatorCity`:e===`CiAdrCtry`?`CreatorCountry`:e===`CiAdrExtadr`?`CreatorAddress`:e===`CiAdrPcode`?`CreatorPostalCode`:e===`CiAdrRegion`?`CreatorRegion`:e===`CiEmailWork`?`CreatorWorkEmail`:e===`CiTelWork`?`CreatorWorkPhone`:e===`CiUrlWork`?`CreatorWorkUrl`:e}function YK(e,t={}){for(let n in e)try{HK(n)||ZR(t,UK(n),XK(e[n],n))}catch{}return t}function XK(e,t){return QK(e)?$K(e,t):ZK(e)?{value:``,attributes:{},description:``}:eq(e)?tq(e,t):sq(e)?cq(e,t):lq(e)?uq(e,t):dq(e)?pq(e,t):hq(e,t)}function ZK(e){return e.attributes[`rdf:parseType`]===`Resource`&&typeof e.value==`string`&&e.value.trim()===``}function QK(e){return Array.isArray(e)}function $K(e,t){return hq(e[e.length-1],t)}function eq(e){return e.attributes[`rdf:parseType`]===`Resource`&&e.value[`rdf:value`]!==void 0||e.value[`rdf:Description`]!==void 0&&e.value[`rdf:Description`].value[`rdf:value`]!==void 0}function tq(e,t){let n=nq(e);e.value[`rdf:Description`]!==void 0&&(e=e.value[`rdf:Description`]),XR(n,nq(e),rq(e));let r=iq(e);return{value:r,attributes:n,description:WK(r,t)}}function nq(e){let t={};for(let n in e.attributes)n!==`rdf:parseType`&&n!==`rdf:resource`&&!HK(n)&&ZR(t,UK(n),e.attributes[n]);return t}function rq(e){let t={};for(let n in e.value)n!==`rdf:value`&&!HK(n)&&ZR(t,UK(n),e.value[n].value);return t}function iq(e){let t=aq(e.value[`rdf:value`]);return gq(t)||oq(t)}function aq(e){return QK(e)?e[e.length-1]:e}function oq(e){return dq(e)?pq(e).value:typeof e.value==`object`?YK(e.value,Object.create(null)):e.value}function sq(e){return e.attributes[`rdf:parseType`]===`Resource`||e.value[`rdf:Description`]!==void 0&&e.value[`rdf:Description`].value[`rdf:value`]===void 0}function cq(e,t){let n={value:{},attributes:{}};return e.value[`rdf:Description`]!==void 0&&(XR(n.value,BK(e.value[`rdf:Description`].attributes)),XR(n.attributes,nq(e)),e=e.value[`rdf:Description`]),XR(n.value,YK(e.value)),n.description=WK(n.value,t),n}function lq(e){return Object.keys(e.value).length===0&&e.attributes[`xml:lang`]===void 0&&e.attributes[`rdf:resource`]===void 0}function uq(e,t){let n=BK(e.attributes);return{value:n,attributes:{},description:WK(n,t)}}function dq(e){return fq(e.value)!==void 0}function fq(e){return aq(e[`rdf:Bag`]||e[`rdf:Seq`]||e[`rdf:Alt`])}function pq(e,t){let n=fq(e.value).value[`rdf:li`],r=nq(e),i=[];return n===void 0?n=[]:Array.isArray(n)||(n=[n]),n.forEach(e=>{i.push(mq(e))}),{value:i,attributes:r,description:WK(i,t)}}function mq(e){return eq(e)?tq(e):sq(e)?cq(e).value:lq(e)?uq(e).value:hq(e)}function hq(e,t){let n=gq(e)||zK(e.value);return{value:n,attributes:nq(e),description:WK(n,t)}}function gq(e){return e.attributes&&e.attributes[`rdf:resource`]}var _q={CLOSED_SUBPATH_LENGTH:0,CLOSED_SUBPATH_BEZIER_LINKED:1,CLOSED_SUBPATH_BEZIER_UNLINKED:2,OPEN_SUBPATH_LENGTH:3,OPEN_SUBPATH_BEZIER_LINKED:4,OPEN_SUBPATH_BEZIER_UNLINKED:5,FILL_RULE:6,CLIPBOARD:7,INITIAL_FILL_RULE:8},vq=24,yq={2e3:{name:`PathInformation`,description:bq},2999:{name:`ClippingPathName`,description(e){let[,t]=WR(e,0);return t}}};function bq(e){let t={},n=[];for(let r=0;r<e.byteLength;r+=26){let i=$.getShortAt(e,r);xq[i]&&(t[i]||(t[i]=xq[i].description),n.push({type:i,path:xq[i].path(e,r+2)}))}return JSON.stringify({types:t,paths:n})}var xq={[_q.CLOSED_SUBPATH_LENGTH]:{description:`Closed subpath length`,path:(e,t)=>[$.getShortAt(e,t)]},[_q.CLOSED_SUBPATH_BEZIER_LINKED]:{description:`Closed subpath Bezier knot, linked`,path:Sq},[_q.CLOSED_SUBPATH_BEZIER_UNLINKED]:{description:`Closed subpath Bezier knot, unlinked`,path:Sq},[_q.OPEN_SUBPATH_LENGTH]:{description:`Open subpath length`,path:(e,t)=>[$.getShortAt(e,t)]},[_q.OPEN_SUBPATH_BEZIER_LINKED]:{description:`Open subpath Bezier knot, linked`,path:Sq},[_q.OPEN_SUBPATH_BEZIER_UNLINKED]:{description:`Open subpath Bezier knot, unlinked`,path:Sq},[_q.FILL_RULE]:{description:`Path fill rule`,path:()=>[]},[_q.INITIAL_FILL_RULE]:{description:`Initial fill rule`,path:(e,t)=>[$.getShortAt(e,t)]},[_q.CLIPBOARD]:{description:`Clipboard`,path:wq}};function Sq(e,t){let n=[];for(let r=0;r<vq;r+=8)n.push(Cq(e,t+r));return n}function Cq(e,t){let n=Tq(e,t,8);return[Tq(e,t+4,8),n]}function wq(e,t){return[[Tq(e,t,8),Tq(e,t+4,8),Tq(e,t+8,8),Tq(e,t+12,8)],Tq(e,t+16,8)]}function Tq(e,t,n){let r=$.getLongAt(e,t),i=r>>>31?-1:1,a=(r&2130706432)>>>32-n,o=r&parseInt(rz(`1`,32-n),2);return i*nz(a.toString(2)+`.`+tz(o.toString(2),32-n,`0`),2)}var Eq={read:Mq},Dq=`8BIM`,Oq=2,kq=4,Aq=4,jq=12;function Mq(e,t,n=qU){if(!Array.isArray(e))return{};let r=BR(new Uint8Array(e).buffer),i={},a=0;for(;a+jq<=r.byteLength;){let e=VR(r,a,Aq);a+=Aq;let o=$.getShortAt(r,a);a+=Oq;let{tagName:s,tagNameSize:c}=Pq(r,a);if(a+=c,a+kq>r.byteLength)break;let l=$.getLongAt(r,a);a+=kq;let u=Math.min(l,r.byteLength-a);if(e===Dq){let e=Nq(o,s,t);if(!n.shouldParseTag(`photoshop`,e,o)){a+=u+u%2;continue}let c=BR(r.buffer,a,u),l={id:o,value:VR(c,0,u)};if(yq[o]){try{l.description=yq[o].description(c)}catch{l.description=`<no description formatter>`}i[s||yq[o].name]=l}else t&&(i[`undefined-${o}`]=l)}a+=u+u%2}return i}function Nq(e,t,n){if(t)return t;if(yq[e]&&yq[e].name)return yq[e].name;if(n)return`undefined-${e}`}function Pq(e,t){let[n,r]=WR(e,t);return{tagName:r,tagNameSize:1+n+ +(n%2==0)}}var Fq={desc:{name:`ICC Description`},cprt:{name:`ICC Copyright`},dmdd:{name:`ICC Device Model Description`},vued:{name:`ICC Viewing Conditions Description`},dmnd:{name:`ICC Device Manufacturer for Display`},tech:{name:`Technology`}},Iq={4:{name:`Preferred CMM type`,value:(e,t)=>VR(e,t,4),description:e=>e===null?``:Bq(e)},8:{name:`Profile Version`,value:(e,t)=>e.getUint8(t).toString(10)+`.`+(e.getUint8(t+1)>>4).toString(10)+`.`+(e.getUint8(t+1)%16).toString(10)},12:{name:`Profile/Device class`,value:(e,t)=>VR(e,t,4),description:e=>{switch(e.toLowerCase()){case`scnr`:return`Input Device profile`;case`mntr`:return`Display Device profile`;case`prtr`:return`Output Device profile`;case`link`:return`DeviceLink profile`;case`abst`:return`Abstract profile`;case`spac`:return`ColorSpace profile`;case`nmcl`:return`NamedColor profile`;case`cenc`:return`ColorEncodingSpace profile`;case`mid `:return`MultiplexIdentification profile`;case`mlnk`:return`MultiplexLink profile`;case`mvis`:return`MultiplexVisualization profile`;default:return e}}},16:{name:`Color Space`,value:(e,t)=>VR(e,t,4)},20:{name:`Connection Space`,value:(e,t)=>VR(e,t,4)},24:{name:`ICC Profile Date`,value:(e,t)=>Lq(e,t).toISOString()},36:{name:`ICC Signature`,value:(e,t)=>zq(e.buffer.slice(t,t+4))},40:{name:`Primary Platform`,value:(e,t)=>VR(e,t,4),description:e=>Bq(e)},48:{name:`Device Manufacturer`,value:(e,t)=>VR(e,t,4),description:e=>Bq(e)},52:{name:`Device Model Number`,value:(e,t)=>VR(e,t,4)},64:{name:`Rendering Intent`,value:(e,t)=>e.getUint32(t),description:e=>{switch(e){case 0:return`Perceptual`;case 1:return`Relative Colorimetric`;case 2:return`Saturation`;case 3:return`Absolute Colorimetric`;default:return e}}},80:{name:`Profile Creator`,value:(e,t)=>VR(e,t,4)}};function Lq(e,t){let n=e.getUint16(t),r=e.getUint16(t+2)-1,i=e.getUint16(t+4),a=e.getUint16(t+6),o=e.getUint16(t+8),s=e.getUint16(t+10);return new Date(Date.UTC(n,r,i,a,o,s))}var Rq=8192;function zq(e){let t=new Uint8Array(e),n=[];for(let e=0;e<t.length;e+=Rq)n.push(String.fromCharCode.apply(null,t.subarray(e,e+Rq)));return n.join(``)}function Bq(e){switch(e.toLowerCase()){case`appl`:return`Apple`;case`adbe`:return`Adobe`;case`msft`:return`Microsoft`;case`sunw`:return`Sun Microsystems`;case`sgi`:return`Silicon Graphics`;case`tgnt`:return`Taligent`;default:return e}}var Vq={read:nJ},Hq=84,Uq=128,Wq=`acsp`,Gq=`desc`,Kq=`mluc`,qq=`text`,Jq=`sig `,Yq=12,Xq=12,Zq=12,Qq=16,$q=1e3,eJ=1e3,tJ=1048576;function nJ(e,t,n,r){return n&&t[0].compressionMethod!==void 0?rJ(e,t,r):aJ(e,t)}function rJ(e,t,n){if(!iJ(t[0].compressionMethod))return{};let r=e.byteOffset||0,i=e.buffer.slice(r+t[0].offset,r+t[0].offset+t[0].length);return oz(new DataView(new Uint8Array(i).buffer),t[0].compressionMethod,`utf-8`,`dataview`,n).then(uJ).catch(()=>({}))}function iJ(e){return e===0}function aJ(e,t){try{let n=oJ(e),r=e.byteOffset||0,i=t.reduce((e,t)=>e+t.length,0),a=Math.min(i,n.byteLength),o=new Uint8Array(a),s=0,c=sJ(t);for(let e=1;e<=t.length;e++){let t=c[e];if(!t)throw Error(`ICC chunk ${e} not found`);let i=n.slice(r+t.offset,r+t.offset+t.length),a=new Uint8Array(i);o.set(a,s),s+=a.length}return uJ(new DataView(o.buffer))}catch{return{}}}function oJ(e){return Array.isArray(e)?new DataView(Uint8Array.from(e).buffer).buffer:e.buffer}function sJ(e){let t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n].chunkNumber]===void 0&&(t[e[n].chunkNumber]=e[n]);return t}function cJ(e){return e.byteLength<132}function lJ(e,t){return e.byteLength<t+Yq}function uJ(e){let t=e.buffer,n=e.getUint32();if(e.byteLength!==n)throw Error(`ICC profile length not matching`);if(e.byteLength<Hq)throw Error(`ICC profile too short`);let r={},i=Object.keys(Iq);for(let t=0;t<i.length;t++){let n=i[t],a=Iq[n],o=a.value(e,parseInt(n,10)),s=o;a.description&&(s=a.description(o)),r[a.name]={value:o,description:s}}if(zq(t.slice(36,40))!==Wq)throw Error(`ICC profile: missing signature`);if(cJ(e))return r;let a=Math.min(e.getUint32(Uq),eJ),o=132,s={remaining:Math.min(e.byteLength,tJ)};for(let n=0;n<a;n++){if(lJ(e,o))return r;let n=VR(e,o,4),i=e.getUint32(o+4),a=e.getUint32(o+8);if(i>e.byteLength)return r;let c=VR(e,i,4);if(c===Gq){if(i+Xq>e.byteLength)return r;let t=e.getUint32(i+8);if(t>a)return r;fJ(r,n,dJ(e,i+12,t-1,s))}else if(c===Kq){if(i+Qq>e.byteLength)return r;let t=e.getUint32(i+8),o=e.getUint32(i+12);if(o<Zq||t>$q)return r;let c=t*o;if(c>e.byteLength-i-Qq||c>s.remaining)return r;s.remaining-=c;let l=Math.min(a,e.byteLength-i),u=i+Qq,d=[];for(let n=0;n<t;n++){let t=VR(e,u+0,2),n=VR(e,u+2,2),r=e.getUint32(u+4),a=e.getUint32(u+8),c=Math.max(0,l-a),f=Math.min(r,c,s.remaining);s.remaining-=f;let p=UR(e,i+a,f);d.push({languageCode:t,countryCode:n,text:p}),u+=o}if(t===1)fJ(r,n,d[0].text);else{let e={};for(let t=0;t<d.length;t++)e[`${d[t].languageCode}-${d[t].countryCode}`]=d[t].text;fJ(r,n,e)}}else if(c===qq){let t=dJ(e,i+8,a-8,s),o=t.indexOf(`\0`);fJ(r,n,o===-1?t:t.slice(0,o))}else c===Jq&&fJ(r,n,zq(t.slice(i+8,i+12)));o+=12}return r}function dJ(e,t,n,r){let i=Math.max(0,Math.min(n,e.byteLength-t,r.remaining));return r.remaining-=i,zq(e.buffer.slice(t,t+i))}function fJ(e,t,n){Fq[t]?e[Fq[t].name]={value:n,description:n}:e[t]={value:n,description:n}}var pJ=27,mJ=22,hJ={read:gJ,SHOT_INFO_AUTO_ROTATE:pJ,CAMERA_SETTINGS_LENS_TYPE:mJ};function gJ(e,t,n,r,i,a=!1,o=void 0){let s=cW(e,SU,t,t+n,r,i,a,o,`makerNotes`);return s.ShotInfo&&(s=XR({},s,_J(s.ShotInfo.value)),delete s.ShotInfo),s.CameraSettings&&(s=XR({},s,vJ(s.CameraSettings.value)),delete s.CameraSettings),s}function _J(e){let t={};return e[pJ]!==void 0&&(t.AutoRotate={value:e[pJ],description:yJ(e[pJ])}),t}function vJ(e){let t={};if(!Array.isArray(e))return t;let n=e[mJ];return Number.isFinite(n)&&(t.LensType={value:n,description:`${n}`}),t}function yJ(e){return e===0?`None`:e===1?`Rotate 90 CW`:e===2?`Rotate 180`:e===3?`Rotate 270 CW`:`Unknown`}var bJ=8,xJ=10,SJ={K3_III:78420},CJ={CAMERA_ORIENTATION:1,ROLL_ANGLE:3,PITCH_ANGLE:5},wJ={read:TJ,PENTAX_IFD_OFFSET:xJ,MODEL_ID:SJ,LIK3III:CJ};function TJ(e,t,n,r,i=!1,a=void 0){try{let o=Xz.getByteOrder(e,t+n+bJ),s=t+n,c=cW(e,CU,s,s+xJ,o,r,i,a,`makerNotes`);return EJ(c)&&(c=XR({},c,DJ(e,s+c.LevelInfo.__offset,o)),delete c.LevelInfo),c}catch{return{}}}function EJ(e){return e.PentaxModelID&&e.PentaxModelID.value===SJ.K3_III&&e.LevelInfo}function DJ(e,t,n){let r={};if(t+7>e.byteLength)return r;let i=e.getInt8(t+CJ.CAMERA_ORIENTATION);r.CameraOrientation={value:i,description:OJ(i)};let a=e.getInt16(t+CJ.ROLL_ANGLE,n===Xz.LITTLE_ENDIAN);r.RollAngle={value:a,description:kJ(a)};let o=e.getInt16(t+CJ.PITCH_ANGLE,n===Xz.LITTLE_ENDIAN);return r.PitchAngle={value:o,description:AJ(o)},r}function OJ(e){return e===0?`Horizontal (normal)`:e===1?`Rotate 270 CW`:e===2?`Rotate 180`:e===3?`Rotate 90 CW`:e===4?`Upwards`:e===5?`Downwards`:`Unknown`}function kJ(e){return``+e*-.5}function AJ(e){return``+e*-.5}var jJ={read:FJ},MJ={0:`Grayscale`,2:`RGB`,3:`Palette`,4:`Grayscale with Alpha`,6:`RGB with Alpha`},NJ={0:`Noninterlaced`,1:`Adam7 Interlace`},PJ=[{name:`Image Width`,offset:0,size:4,read:$.getLongAt,description:e=>`${e}px`},{name:`Image Height`,offset:4,size:4,read:$.getLongAt,description:e=>`${e}px`},{name:`Bit Depth`,offset:8,size:1,read:$.getByteAt,description:e=>`${e}`},{name:`Color Type`,offset:9,size:1,read:$.getByteAt,description:e=>MJ[e]||`Unknown`},{name:`Compression`,offset:10,size:1,read:$.getByteAt,description:e=>e===0?`Deflate/Inflate`:`Unknown`},{name:`Filter`,offset:11,size:1,read:$.getByteAt,description:e=>e===0?`Adaptive`:`Unknown`},{name:`Interlace`,offset:12,size:1,read:$.getByteAt,description:e=>NJ[e]||`Unknown`}];function FJ(e,t){let n={};for(let r=0;r<PJ.length;r++)n[PJ[r].name]=IJ(e,t,PJ[r]);return n}function IJ(e,t,n){if(t+n.offset+n.size>e.byteLength)return;let r=n.read(e,t+n.offset);return{value:r,description:n.description(r)}}var LJ={read:KJ},RJ=`STATE_KEYWORD`,zJ=`STATE_COMPRESSION`,BJ=`STATE_LANG`,VJ=`STATE_TRANSLATED_KEYWORD`,HJ=`STATE_TEXT`,UJ=1,WJ=1,GJ=6;function KJ(e,t,n,r,i=!1,a=qU,o){let s={},c=[];for(let l=0;l<t.length;l++){let{offset:u,length:d,type:f}=t[l],p=qJ(e,u,d,f,n,o);if(p instanceof Promise)c.push(p.then(({name:e,value:t,description:n})=>{try{if(Q.USE_EXIF&&tY(e,t))return a.shouldParseGroup(`exif`)?{__exif:wW.read(rY(t),GJ,r,i,a).tags}:{};if(Q.USE_IPTC&&nY(e,t))return a.shouldParseGroup(`iptc`)?{__iptc:NG.read(rY(t),0,r,a)}:{};if(e&&!tY(e,t)&&!nY(e,t))return a.shouldParseGroup(`png`)?{[e]:{value:t,description:n}}:{}}catch{}return{}}));else{let{name:e,value:t,description:n}=p;e&&a.shouldParseGroup(`png`)&&(s[e]={value:t,description:n})}}return{readTags:s,readTagsPromise:c.length>0?Promise.all(c):void 0}}function qJ(e,t,n,r,i,a){let o=[],s=[],c=[],l,u=RJ,d,f=e.byteOffset||0;for(let i=0;i<n&&t+i<e.byteLength;i++){if(u===zJ){d=JJ({type:r,dataView:e,offset:t+i}),r===`iTXt`&&(i+=UJ),u=YJ(r,u);continue}if(u===HJ){let r=e.buffer.slice(f+t+i,f+t+n);l=new DataView(new Uint8Array(r).buffer);break}let a=e.getUint8(t+i);a===0?u=YJ(r,u):u===RJ?o.push(a):u===BJ?s.push(a):u===VJ&&c.push(a)}if(d!==void 0&&!i)return{};let p=oz(l,d,XJ(r),`string`,a);return p instanceof Promise?p.then(e=>ZJ(e,r,s,o)).catch(()=>ZJ(`<text using unknown compression>`.split(``),r,s,o)):ZJ(p,r,s,o)}function JJ({type:e,dataView:t,offset:n}){if(e===`iTXt`){if(n+1<t.byteLength&&t.getUint8(n)===WJ)return t.getUint8(n+1)}else if(e===`zTXt`)return t.getUint8(n)}function YJ(e,t){return t===RJ&&[`iTXt`,`zTXt`].includes(e)?zJ:t===zJ?e===`iTXt`?BJ:HJ:t===BJ?VJ:HJ}function XJ(e){return e===`tEXt`||e===`zTXt`?`latin1`:`utf-8`}function ZJ(e,t,n,r){let i=$J(e);return{name:QJ(t,n,r),value:i,description:t===`iTXt`?eY(e):i}}function QJ(e,t,n){let r=GR(n);return e===`tEXt`||t.length===0?r:`${r} (${GR(t)})`}function $J(e){return e instanceof DataView?VR(e,0,e.byteLength):e}function eY(e){return SG.decode(`UTF-8`,e)}function tY(e,t){return e.toLowerCase()===`raw profile type exif`&&t.substring(1,5)===`exif`}function nY(e,t){return e.toLowerCase()===`raw profile type iptc`&&t.substring(1,5)===`iptc`}function rY(e){return iY(e.match(/\n(exif|iptc)\n\s*\d+\n([\s\S]*)$/)[2].replace(/\n/g,``))}function iY(e){let t=new DataView(new ArrayBuffer(e.length/2));for(let n=0;n<e.length;n+=2)t.setUint8(n/2,parseInt(e.substring(n,n+2),16));return t}var aY={read:oY};function oY(e,t){let n={};for(let r=0;r<t.length;r++){let i=$.getLongAt(e,t[r]+0),a=VR(e,t[r]+4,4);a===`pHYs`?(n[`Pixels Per Unit X`]=sY(e,t[r],i),n[`Pixels Per Unit Y`]=cY(e,t[r],i),n[`Pixel Units`]=lY(e,t[r],i)):a===`tIME`&&(n[`Modify Date`]=uY(e,t[r],i))}return n}function sY(e,t,n){if(!dY(e,t,n,0,4))return;let r=$.getLongAt(e,t+8+0);return{value:r,description:``+r}}function cY(e,t,n){if(!dY(e,t,n,4,4))return;let r=$.getLongAt(e,t+8+4);return{value:r,description:``+r}}function lY(e,t,n){if(!dY(e,t,n,8,1))return;let r=$.getByteAt(e,t+8+8);return{value:r,description:r===1?`meters`:`Unknown`}}function uY(e,t,n){if(!dY(e,t,n,0,7))return;let r=$.getShortAt(e,t+8),i=$.getByteAt(e,t+8+2),a=$.getByteAt(e,t+8+3),o=$.getByteAt(e,t+8+4),s=$.getByteAt(e,t+8+5),c=$.getByteAt(e,t+8+6);return{value:[r,i,a,o,s,c],description:`${fY(r,4)}-${fY(i,2)}-${fY(a,2)} ${fY(o,2)}:${fY(s,2)}:${fY(c,2)}`}}function dY(e,t,n,r,i){return r+i<=n&&t+8+r+i<=e.byteLength}function fY(e,t){return tz(``+e,t,`0`)}var pY={read:_Y},mY=4,hY=7,gY=10;function _Y(e,t){let n={};if(t+gY>e.byteLength)return n;let r=$.getByteAt(e,t);return n.Alpha=vY(r),n.Animation=yY(r),n.ImageWidth=bY(e,t+mY),n.ImageHeight=bY(e,t+hY),n}function vY(e){let t=e&16;return{value:+!!t,description:t?`Yes`:`No`}}function yY(e){let t=e&2;return{value:+!!t,description:t?`Yes`:`No`}}function bY(e,t){let n=$.getByteAt(e,t)+256*$.getByteAt(e,t+1)+65536*$.getByteAt(e,t+2)+1;return{value:n,description:n+`px`}}var xY={read:wY},SY=e=>`${e} ${e===1?`bit`:`bits`}`,CY=[{name:`GIF Version`,offset:3,size:3,getValue:(e,t)=>VR(e,t,3),description:e=>e},{name:`Image Width`,offset:6,size:2,getValue:(e,t)=>e.getUint16(t,!0),description:e=>`${e}px`},{name:`Image Height`,offset:8,size:2,getValue:(e,t)=>e.getUint16(t,!0),description:e=>`${e}px`},{name:`Global Color Map`,offset:10,size:1,getValue:(e,t)=>(e.getUint8(t)&128)>>>7,description:e=>e===1?`Yes`:`No`},{name:`Bits Per Pixel`,offset:10,size:1,getValue:(e,t)=>(e.getUint8(t)&7)+1,description:SY},{name:`Color Resolution Depth`,offset:10,size:1,getValue:(e,t)=>((e.getUint8(t)&112)>>>4)+1,description:SY}];function wY(e){let t={};for(let n=0;n<CY.length;n++)t[CY[n].name]=TY(e,CY[n]);return t}function TY(e,t){if(t.offset+t.size>e.byteLength)return;let n=t.getValue(e,t.offset);return{value:n,description:t.description(n)}}var EY=[6,7,99],DY={get:OY};function OY(e,t,n){if(kY(t)){let r=n+t.JPEGInterchangeFormat.value,i=t.JPEGInterchangeFormatLength.value;if(AY(e,r,i)){t.type=`image/jpeg`;let n=e.byteOffset||0;t.image=e.buffer.slice(n+r,n+r+i),QR(t,`base64`,function(){return $R(this.image)})}}return t}function kY(e){return e&&(e.Compression===void 0||EY.includes(e.Compression.value))&&e.JPEGInterchangeFormat&&e.JPEGInterchangeFormat.value&&e.JPEGInterchangeFormatLength&&e.JPEGInterchangeFormatLength.value}function AY(e,t,n){return jY(t)&&jY(n)&&t+n<=e.byteLength}function jY(e){return typeof e==`number`&&e>=0&&e%1==0}var MY={INCHES:2,CENTIMETERS:3,MILLIMETERS:4},NY={INCHES_TO_MM:25.4,CM_TO_MM:10,MM_TO_MM:1},PY={get:FY};function FY(e,t){let n={},r=!1,i=IY(e,`exif`,`FocalLength`,t),a=IY(e,`exif`,`FocalPlaneXResolution`,t),o=IY(e,`exif`,`FocalPlaneYResolution`,t),s=IY(e,`exif`,`FocalPlaneResolutionUnit`,t),c=IY(e,`file`,`Image Width`,t),l=IY(e,`file`,`Image Height`,t),u=IY(e,`exif`,`FocalLengthIn35mmFilm`,t)||LY(a,o,s,c,l,i);u&&(n.FocalLength35efl={value:u,description:uU.FocalLengthIn35mmFilm(u)},r=!0);let d=RY(i,u);d&&(n.ScaleFactorTo35mmEquivalent=d,r=!0);let f=zY(u);if(f&&(n.FieldOfView=f,r=!0),r)return n}function IY(e,t,n,r){if(r&&e[t]&&e[t][n])return e[t][n].value;if(!r&&e[n])return e[n].value}function LY(e,t,n,r,i,a){if(e&&t&&n&&r&&i&&a)try{let o;switch(n){case MY.INCHES:o=NY.INCHES_TO_MM;break;case MY.CENTIMETERS:o=NY.CM_TO_MM;break;case MY.MILLIMETERS:o=NY.MM_TO_MM;break;default:return}let s=e[0]/e[1]*o,c=t[0]/t[1]*o,l=r/s,u=i/c,d=Math.sqrt(l**2+u**2);return a[0]/a[1]*(43.27/d)}catch{}}function RY(e,t){if(e&&t)try{let n=t/(e[0]/e[1]);return{value:n,description:n.toFixed(1)}}catch{}}function zY(e){if(e)try{let t=2*Math.atan(36/(2*e))*(180/Math.PI);return{value:t,description:t.toFixed(1)+` deg`}}catch{}}function BY({mergeSteps:e,deferredResults:t,parsedGroups:n,expanded:r,tagFilter:i,dataView:a,tiffHeaderOffset:o,exifDataView:s,fileType:c,pngTextChunks:l,pngTextIsAsync:u,thumbnailIfdTags:d,deps:f}){let p={};for(let l=0;l<e.length;l++)p=VY({step:e[l],deferredResults:t,parsedGroups:n,expanded:r,tagFilter:i,dataView:a,tiffHeaderOffset:o,exifDataView:s,fileType:c,thumbnailIfdTags:d,tags:p,deps:f});return Q.USE_PNG&&r&&u&&i.shouldReturnGroup(`png`)&&p.png&&(p.pngText=f.objectAssign({},p.png)),Q.USE_PNG&&r&&i.shouldReturnGroup(`png`)&&f.hasPngTextData(l)&&p.png&&!p.pngText&&(p.pngText=f.objectAssign({},p.png)),p}function VY({step:e,deferredResults:t,parsedGroups:n,expanded:r,tagFilter:i,dataView:a,tiffHeaderOffset:o,exifDataView:s,fileType:c,thumbnailIfdTags:l,tags:u,deps:d}){if(e.type===`mergeGroupAssign`){let t=d.filterTagsForReturn(e.groupKey,e.parsedTags,i);return HY(u,e.groupKey,t,r,d)}if(e.type===`mergeGroupMerge`){let t=d.filterTagsForReturn(e.groupKey,e.parsedTags,i);return WY(u,e.groupKey,t,r,d)}if(Q.USE_XMP&&e.type===`mergeXmpGroupAssign`){let t=d.filterTagsForReturn(`xmp`,e.parsedTags,i);return UY(u,t,r,d)}if(Q.USE_ICC&&e.type===`mergeIccDeferred`){let a=t[e.deferredKey],o=d.filterTagsForParse(`icc`,a,i);if(n.icc=o,!i.shouldReturnGroup(`icc`))return u;let s=d.filterTagsForReturn(`icc`,o,i);return HY(u,`icc`,s,r,d)}if(Q.USE_JXL&&e.type===`mergeBrobExifDeferred`){let a=t[e.deferredKey];if(!a||Object.keys(a).length===0)return u;let o=d.filterTagsForParse(`exif`,a,i);if(n.exif=n.exif?d.objectAssign({},n.exif,o):o,!i.shouldReturnGroup(`exif`))return u;let s=d.filterTagsForReturn(`exif`,o,i);return HY(u,`exif`,s,r,d)}if(Q.USE_JXL&&e.type===`mergeBrobXmpDeferred`){let a=t[e.deferredKey];if(!a||Object.keys(a).length===0)return u;let o=d.filterTagsForParse(`xmp`,a,i);if(n.xmp=o,!i.shouldReturnGroup(`xmp`))return u;let s=d.filterTagsForReturn(`xmp`,o,i);return UY(u,s,r,d)}if(Q.USE_PNG&&e.type===`mergePngFile`){let t=d.filterTagsForReturn(`png`,e.parsedTags,i);return i.shouldReturnGroup(`png`)?r?(u.png=u.png?d.objectAssign({},u.png,t):t,u.pngFile=t,u):d.objectAssign({},u,t):u}if(Q.USE_PNG&&e.type===`mergePngChunk`){let t=d.filterTagsForReturn(`png`,e.parsedTags,i);return i.shouldReturnGroup(`png`)?r?(u.png=u.png?d.objectAssign({},u.png,t):t,u):d.objectAssign({},u,t):u}if(Q.USE_PNG&&e.type===`processPngTextReadTags`)return GY({readTags:e.readTags,parsedGroups:n,expanded:r,tagFilter:i,tags:u,deps:d});if(Q.USE_PNG&&e.type===`processPngTextReadTagsDeferredList`){let a=t[e.deferredKey]||[];for(let e=0;e<a.length;e++)u=GY({readTags:a[e],parsedGroups:n,expanded:r,tagFilter:i,tags:u,deps:d});return u}if(Q.USE_EXIF&&e.type===`gps`){if(r&&i.shouldReturnGroup(`gps`)&&n.exif){let e=d.getGpsGroupFromExifTags(n.exif);if(e){let t=d.filterTagsForReturn(`gps`,e,i);u.gps=t}}return u}if((Q.USE_EXIF||Q.USE_XMP)&&e.type===`composite`){if(!i.shouldReturnGroup(`composite`))return u;let e=u,t=r;i.isActive&&(e={exif:n.exif,file:n.file},t=!0);let a=d.Composite.get(e,t);if(!a)return u;let o=d.filterTagsForReturn(`composite`,a,i);return HY(u,`composite`,o,r,d)}if(e.type===`thumbnail`){if(!i.shouldReturnGroup(`thumbnail`)||!i.shouldReturnTag(`thumbnail`,`Thumbnail`))return delete u.Thumbnail,u;if(!l)return u;let e=d.filterTagsForParse(`thumbnail`,l,i),t=Q.USE_EXIF&&Q.USE_THUMBNAIL&&d.Thumbnail.get(s||a,e,o);return t?u.Thumbnail=t:delete u.Thumbnail,u}if(e.type===`metadataRange`){if(!r)return u;let t=qY(e.metadataBlocks,e.metadataTruncated,a,n);return t&&(u.metadataRange=t),u}return e.type===`fileType`&&c&&i.shouldReturnGroup(`file`)&&i.shouldReturnTag(`file`,`FileType`)&&(r?(u.file||(u.file={}),u.file.FileType=c):u.FileType=c),u}function HY(e,t,n,r,i){return r?(e[t]=n,e):i.objectAssign({},e,n)}function UY(e,t,n,r){if(n)return e.xmp=t,e;let i=r.objectAssign({},t);return delete i._raw,r.objectAssign({},e,i)}function WY(e,t,n,r,i){return r?(e[t]=e[t]?i.objectAssign({},e[t],n):n,e):i.objectAssign({},e,n)}function GY({readTags:e,parsedGroups:t,expanded:n,tagFilter:r,tags:i,deps:a}){let o=e.__exif,s=e.__iptc;if(delete e.__exif,delete e.__iptc,o){let e=a.filterTagsForParse(`exif`,o,r);if(t.exif=t.exif?a.objectAssign({},t.exif,e):e,r.shouldReturnGroup(`exif`)){let t=a.filterTagsForReturn(`exif`,e,r);if(n)i.exif=i.exif?a.objectAssign({},i.exif,t):t;else{let e=a.objectAssign({},t);delete e.Thumbnail,i=a.objectAssign({},i,e)}}}if(s){let e=a.filterTagsForParse(`iptc`,s,r);if(t.iptc=t.iptc?a.objectAssign({},t.iptc,e):e,r.shouldReturnGroup(`iptc`)){let t=a.filterTagsForReturn(`iptc`,e,r);n?i.iptc=i.iptc?a.objectAssign({},i.iptc,t):t:i=a.objectAssign({},i,t)}}if(r.shouldReturnGroup(`png`)){let o=a.filterTagsForParse(`png`,e,r),s=a.filterTagsForReturn(`png`,o,r);t.pngText=o,n?(i.png=i.png?a.objectAssign({},i.png,s):s,s&&Object.keys(s).length>0&&(i.pngText=i.pngText?a.objectAssign({},i.pngText,s):s)):i=a.objectAssign({},i,s)}return i}function KY(e){return!!e&&typeof e.then==`function`}function qY(e,t,n,r){let i=(e||[]).slice(),a=!!t;if(r&&r.mpf&&Array.isArray(r.mpf.Images))for(let e=0;e<r.mpf.Images.length;e++){let t=r.mpf.Images[e];if(!t||!t.ImageOffset||!t.ImageSize)continue;let n=t.ImageOffset.value,a=t.ImageSize.value;typeof n!=`number`||n<=0||typeof a!=`number`||a<=0||i.push({type:`mpfImage`,start:n,end:n+a})}if(i.length===0)return;i.sort((e,t)=>e.start-t.start);let o=i[0].start,s=i[0].end;for(let e=1;e<i.length;e++)i[e].end>s&&(s=i[e].end);let c=n&&typeof n.byteLength==`number`?n.byteLength:0;return{start:o,end:s,complete:!a&&s<=c,blocks:i}}function JY(e){this.name=`MetadataMissingError`,this.message=e||`No Exif data`,this.stack=Error().stack}JY.prototype=Error();var YY={MetadataMissingError:JY},XY={load:ZY,loadView:eX,errors:YY};function ZY(e,t={}){if(t.length===`auto`)return Rz(t),zz(QY)(e,t);if(pz(e)||mz(e)){YR();let n=pz(e)?gz:_z,r=XR({},t,{async:!0});return n(e,r).then(e=>QY(e,r))}return QY(e,t)}function QY(e,t){return $Y(e)&&(e=new Uint8Array(e).buffer),eX(BR(e),t)}function $Y(e){try{return Buffer.isBuffer(e)}catch{return!1}}function eX(e,{expanded:t=!1,async:n=!1,computed:r=!1,includeUnknown:i=!1,includeOffsets:a=!1,domParser:o=void 0,includeTags:s=void 0,excludeTags:c=void 0,decompress:l=void 0}={}){e=tX(e);let u=GU({includeTags:s,excludeTags:c}),d=Object.create(null),f=[],p=Object.create(null),m=[],h=!1,g,_,{fileType:v,fileDataOffset:y,jfifDataOffset:b,tiffHeaderOffset:x,iptcDataOffset:S,xmpChunks:C,iccChunks:w,mpfDataOffset:T,pngHeaderOffset:E,pngTextChunks:D,pngChunkOffsets:O,vp8xChunkOffset:k,gifHeaderOffset:A,brobExifChunk:j,brobXmpChunk:M,jxlCodestreamOffset:N,metadataBlocks:P,metadataTruncated:F,exifDataView:I,xmpDataView:L}=sU.parseAppMarkers(e,n,t&&a),R=lX({fileType:v,fileDataOffset:y,jfifDataOffset:b,tiffHeaderOffset:x,iptcDataOffset:S,xmpChunks:C,iccChunks:w,mpfDataOffset:T,pngHeaderOffset:E,pngTextChunks:D,pngChunkOffsets:O,vp8xChunkOffset:k,gifHeaderOffset:A,jxlCodestreamOffset:N});if(Q.USE_JPEG&&Q.USE_FILE&&y!==void 0&&u.shouldParseGroup(`file`)&&B(s)){let t=oX(`file`,zW.read(e,y),u);d.file=t,u.shouldReturnGroup(`file`)&&f.push({type:`mergeGroupAssign`,groupKey:`file`,parsedTags:t})}if(Q.USE_JPEG&&Q.USE_JFIF&&b!==void 0&&u.shouldParseGroup(`jfif`)){let t=oX(`jfif`,rG.read(e,b),u);d.jfif=t,u.shouldReturnGroup(`jfif`)&&f.push({type:`mergeGroupAssign`,groupKey:`jfif`,parsedTags:t})}if(Q.USE_EXIF&&x!==void 0&&u.shouldParseGroup(`exif`)){let{tags:n,byteOrder:a}=aX(I||e,x,i,r,u);n.Thumbnail&&(g=n.Thumbnail,delete n.Thumbnail);let s=oX(`exif`,n,u);if(d.exif=s,Q.USE_IPTC&&s[`IPTC-NAA`]&&S===void 0&&u.shouldParseGroup(`iptc`)){let e=oX(`iptc`,NG.read(s[`IPTC-NAA`].value,0,i,u),u);d.iptc=e,u.shouldReturnGroup(`iptc`)&&f.push({type:`mergeGroupAssign`,groupKey:`iptc`,parsedTags:e})}if(Q.USE_XMP&&s.ApplicationNotes&&Array.isArray(s.ApplicationNotes.value)&&!dX(C)&&u.shouldParseGroup(`xmp`)){let e=oX(`xmp`,_K.read(GR(s.ApplicationNotes.value),void 0,o),u);if(d.xmp=e,u.shouldReturnGroup(`xmp`)){let n={type:`mergeXmpGroupAssign`,parsedTags:e};t?f.push(n):_=n}}if(Q.USE_PHOTOSHOP&&s.ImageSourceData&&s.PhotoshopSettings&&Array.isArray(s.PhotoshopSettings.value)&&u.shouldParseGroup(`photoshop`)){let e=oX(`photoshop`,Eq.read(s.PhotoshopSettings.value,i,u),u);d.photoshop=e,u.shouldReturnGroup(`photoshop`)&&f.push({type:`mergeGroupAssign`,groupKey:`photoshop`,parsedTags:e})}if(Q.USE_ICC&&s.ICC_Profile&&!fX(w)&&u.shouldParseGroup(`icc`)){let e=oX(`icc`,Vq.read(s.ICC_Profile.value,[{offset:0,length:s.ICC_Profile.value.length,chunkNumber:1,chunksTotal:1}]),u);d.icc=e,u.shouldReturnGroup(`icc`)&&f.push({type:`mergeGroupAssign`,groupKey:`icc`,parsedTags:e})}if(Q.USE_MAKER_NOTES&&s.MakerNote&&u.shouldParseGroup(`makerNotes`)){if(pX(s)){let t=hJ.read(I||e,x,s.MakerNote.__offset,a,i,r,u);d.makerNotes=t,u.shouldReturnGroup(`makerNotes`)&&f.push({type:`mergeGroupAssign`,groupKey:`makerNotes`,parsedTags:t})}else if(mX(s)){let t=wJ.read(I||e,x,s.MakerNote.__offset,i,r,u);d.makerNotes=t,u.shouldReturnGroup(`makerNotes`)&&f.push({type:`mergeGroupAssign`,groupKey:`makerNotes`,parsedTags:t})}}s.MakerNote&&delete s.MakerNote.__offset,u.shouldReturnGroup(`exif`)&&f.push({type:`mergeGroupAssign`,groupKey:`exif`,parsedTags:s}),!t&&_&&(f.push(_),_=void 0)}if(Q.USE_JPEG&&Q.USE_IPTC&&S!==void 0&&u.shouldParseGroup(`iptc`)){let t=oX(`iptc`,NG.read(e,S,i,u),u);d.iptc=t,u.shouldReturnGroup(`iptc`)&&f.push({type:`mergeGroupAssign`,groupKey:`iptc`,parsedTags:t})}if(Q.USE_XMP&&dX(C)&&u.shouldParseGroup(`xmp`)){let t=oX(`xmp`,_K.read(L||e,C,o),u);d.xmp=t,u.shouldReturnGroup(`xmp`)&&f.push({type:`mergeXmpGroupAssign`,parsedTags:t})}if(Q.USE_JXL&&Q.USE_EXIF&&j&&x===void 0&&u.shouldParseGroup(`exif`)&&n){let t=iX(e,j);m.push(oz(t,iz,void 0,`dataview`,l).then(e=>{let t=RB(e,0),{tags:n}=wW.read(e,t,i,r,u);n.Thumbnail&&delete n.Thumbnail,p.brobExif=n}).catch(()=>{p.brobExif={}})),f.push({type:`mergeBrobExifDeferred`,deferredKey:`brobExif`})}if(Q.USE_JXL&&Q.USE_XMP&&M&&!dX(C)&&u.shouldParseGroup(`xmp`)&&n){let t=iX(e,M);m.push(oz(t,iz,void 0,`dataview`,l).then(e=>{p.brobXmp=_K.read(e,[{dataOffset:0,length:e.byteLength}],o)}).catch(()=>{p.brobXmp={}})),f.push({type:`mergeBrobXmpDeferred`,deferredKey:`brobXmp`})}if(Q.USE_ICC&&fX(w)&&u.shouldParseGroup(`icc`)){let t=Vq.read(e,w,n,l);if(KY(t)){if(!n)throw Error(`Promise is required when async mode is enabled.`);m.push(t.then(e=>{p.iccApp=e})),f.push({type:`mergeIccDeferred`,deferredKey:`iccApp`})}else{let e=oX(`icc`,t,u);d.icc=e,u.shouldReturnGroup(`icc`)&&f.push({type:`mergeGroupAssign`,groupKey:`icc`,parsedTags:e})}}if(Q.USE_MPF&&T!==void 0&&u.shouldParseGroup(`mpf`)){let t=oX(`mpf`,OW.read(e,T,i,r,u),u);d.mpf=t,u.shouldReturnGroup(`mpf`)&&f.push({type:`mergeGroupAssign`,groupKey:`mpf`,parsedTags:t})}if(Q.USE_PNG&&Q.USE_PNG_FILE&&E!==void 0&&u.shouldParseGroup(`png`)){let t=oX(`png`,jJ.read(e,E),u);d.pngFile=t,u.shouldReturnGroup(`png`)&&f.push({type:`mergePngFile`,parsedTags:t})}if(Q.USE_PNG&&hX(D)&&(u.shouldParseGroup(`png`)||u.shouldParseGroup(`exif`)||u.shouldParseGroup(`iptc`))){let{readTags:t,readTagsPromise:a}=LJ.read(e,D,n,i,r,u,l);h=!!a,f.push({type:`processPngTextReadTags`,readTags:t}),a&&(m.push(a.then(e=>{p.pngTextTagList=e})),f.push({type:`processPngTextReadTagsDeferredList`,deferredKey:`pngTextTagList`}))}if(Q.USE_PNG&&O!==void 0&&u.shouldParseGroup(`png`)){let t=oX(`png`,aY.read(e,O),u);d.pngChunk=t,u.shouldReturnGroup(`png`)&&f.push({type:`mergePngChunk`,parsedTags:t})}if(Q.USE_WEBP&&k!==void 0&&u.shouldParseGroup(`riff`)){let t=oX(`riff`,pY.read(e,k),u);d.riff=t,u.shouldReturnGroup(`riff`)&&f.push({type:`mergeGroupMerge`,groupKey:`riff`,parsedTags:t})}if(Q.USE_GIF&&A!==void 0&&u.shouldParseGroup(`gif`)){let t=oX(`gif`,xY.read(e,A),u);d.gif=t,u.shouldReturnGroup(`gif`)&&f.push({type:`mergeGroupMerge`,groupKey:`gif`,parsedTags:t})}if(Q.USE_JXL&&N!==void 0&&u.shouldParseGroup(`file`)){let t=oX(`file`,YW.read(e,N),u);d.file=t,u.shouldReturnGroup(`file`)&&f.push({type:`mergeGroupAssign`,groupKey:`file`,parsedTags:t})}if(Q.USE_EXIF&&f.push({type:`gps`}),(Q.USE_EXIF||Q.USE_XMP)&&f.push({type:`composite`}),f.push({type:`thumbnail`}),f.push({type:`fileType`}),t&&a&&f.push({type:`metadataRange`,metadataBlocks:P,metadataTruncated:!!F}),!R)throw new YY.MetadataMissingError;let z={objectAssign:XR,hasPngTextData:hX,filterTagsForParse:oX,filterTagsForReturn:sX,getGpsGroupFromExifTags:Q.USE_EXIF?uX:void 0,Composite:Q.USE_EXIF||Q.USE_XMP?PY:void 0,Thumbnail:DY};if(n)return YR(),Promise.all(m).then(()=>BY({mergeSteps:f,deferredResults:p,parsedGroups:d,expanded:t,tagFilter:u,dataView:e,tiffHeaderOffset:x,exifDataView:I,fileType:v,pngTextChunks:D,pngTextIsAsync:h,thumbnailIfdTags:g,deps:z}));return BY({mergeSteps:f,deferredResults:p,parsedGroups:d,expanded:t,tagFilter:u,dataView:e,tiffHeaderOffset:x,exifDataView:I,fileType:v,pngTextChunks:D,pngTextIsAsync:h,thumbnailIfdTags:g,deps:z});function B(e){if(!e)return!0;let{composite:t,file:n}=e;return t===!0||Array.isArray(t)&&t.length>0?!0:!(Array.isArray(n)&&n.length===1&&n[0]===`FileType`)}}function tX(e){return nX(e)?BR(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)):e}function nX(e){return rX(e)&&(e.byteOffset>0||e.byteLength<e.buffer.byteLength)}function rX(e){return!!e&&typeof e.getUint8==`function`&&typeof e.byteOffset==`number`&&typeof e.byteLength==`number`&&!!e.buffer&&typeof e.buffer.slice==`function`}function iX(e,t){let n=Math.max(0,Math.min(t.length,e.byteLength-t.dataOffset));return new DataView(e.buffer,e.byteOffset+t.dataOffset,n)}function aX(e,t,n,r,i){try{return wW.read(e,t,n,r,i)}catch{return{tags:{},byteOrder:Xz.BIG_ENDIAN}}}function oX(e,t,n){return n.isActive?cX(e,t,n.shouldParseTag):t}function sX(e,t,n){return n.isActive?cX(e,t,n.shouldReturnTag):t}function cX(e,t,n){if(!t)return t;let r={};for(let a in t){let o=t[a];n(e,a,i(o))&&(r[a]=o)}return r;function i(e){if(e)return Array.isArray(e)?e.length===0?void 0:e[0].id:e.id}}function lX({fileType:e,fileDataOffset:t,jfifDataOffset:n,tiffHeaderOffset:r,iptcDataOffset:i,xmpChunks:a,iccChunks:o,mpfDataOffset:s,pngHeaderOffset:c,pngTextChunks:l,pngChunkOffsets:u,vp8xChunkOffset:d,gifHeaderOffset:f,jxlCodestreamOffset:p}){return!!e||Q.USE_JPEG&&Q.USE_FILE&&t!==void 0||Q.USE_JPEG&&Q.USE_JFIF&&n!==void 0||Q.USE_EXIF&&r!==void 0||Q.USE_JPEG&&Q.USE_IPTC&&i!==void 0||Q.USE_XMP&&dX(a)||Q.USE_ICC&&fX(o)||Q.USE_MPF&&s!==void 0||Q.USE_PNG&&Q.USE_PNG_FILE&&c!==void 0||Q.USE_PNG&&hX(l)||Q.USE_PNG&&u!==void 0||Q.USE_WEBP&&d!==void 0||Q.USE_GIF&&f!==void 0||Q.USE_JXL&&p!==void 0}function uX(e){let t;if(e.GPSLatitude&&e.GPSLatitudeRef){t||={};try{t.Latitude=qz(e.GPSLatitude.value),e.GPSLatitudeRef.value.join(``)===`S`&&(t.Latitude=-t.Latitude)}catch{}}if(e.GPSLongitude&&e.GPSLongitudeRef){t||={};try{t.Longitude=qz(e.GPSLongitude.value),e.GPSLongitudeRef.value.join(``)===`W`&&(t.Longitude=-t.Longitude)}catch{}}if(e.GPSAltitude&&e.GPSAltitudeRef){t||={};try{t.Altitude=e.GPSAltitude.value[0]/e.GPSAltitude.value[1],e.GPSAltitudeRef.value===1&&(t.Altitude=-t.Altitude)}catch{}}if(t)return t}function dX(e){return Array.isArray(e)&&e.length>0}function fX(e){return Array.isArray(e)&&e.length>0}function pX(e){return e.Make&&e.Make.value&&Array.isArray(e.Make.value)&&e.Make.value[0]===`Canon`&&e.MakerNote&&e.MakerNote.__offset}function mX(e){return Array.isArray(e.MakerNote.value)&&e.MakerNote.value.length>7&&GR(e.MakerNote.value.slice(0,7))===`PENTAX `&&e.MakerNote.__offset}function hX(e){return Array.isArray(e)&&e.length>0}var gX=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18]);new Uint32Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,32769,49153,65537,98305,131073,196609,262145,393217,524289,786433])[39]+(1<<gX[39])-1;var _X=new Uint8Array([24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112]);(()=>{let e=new Map;for(let t=0;t<120;t++)e.set(_X[t],t+1);return e})(),new Int32Array([17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15]);var vX=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10]);new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073])[23]+(1<<vX[23])-1;function yX(e){if(e.length<12)throw Error(`Invalid RIFF file: shorter than 12-byte container header`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e[0]!==82||e[1]!==73||e[2]!==70||e[3]!==70)throw Error(`Invalid RIFF file: missing RIFF signature`);if(e[8]!==87||e[9]!==69||e[10]!==66||e[11]!==80)throw Error(`Invalid WebP file: missing WEBP signature`);let n=[],r=12;for(;r+8<=e.length;){let i=String.fromCharCode(e[r],e[r+1],e[r+2],e[r+3]),a=t.getUint32(r+4,!0),o=r+8,s=Math.min(o+a,e.length);n.push({fourCC:i,size:a,data:e.subarray(o,s),offset:o});let c=a+(a&1),l=r+8+c;if(l<=r)break;r=l}return n}function bX(e){let t=4;for(let n of e){let e=n.data.length+(n.data.length&1);t+=8+e}let n=new Uint8Array(8+t),r=new DataView(n.buffer);n[0]=82,n[1]=73,n[2]=70,n[3]=70,r.setUint32(4,t,!0),n[8]=87,n[9]=69,n[10]=66,n[11]=80;let i=12;for(let t of e){n[i]=t.fourCC.charCodeAt(0),n[i+1]=t.fourCC.charCodeAt(1),n[i+2]=t.fourCC.charCodeAt(2),n[i+3]=t.fourCC.charCodeAt(3),r.setUint32(i+4,t.data.length,!0),n.set(t.data,i+8);let e=t.data.length+(t.data.length&1);i+=8+e}return n}new Uint8Array([0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0]),new Uint8Array([0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15]),new Uint8Array([173,148,140,0]),new Uint8Array([176,155,140,135,0]),new Uint8Array([180,157,141,134,130,0]),new Uint8Array([254,254,243,230,196,177,153,140,133,130,129,0]),(()=>{let e=new Uint8Array(1056),t=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],n=0;for(let r=0;r<4;r++)for(let i=0;i<8;i++)for(let a=0;a<3;a++)for(let o=0;o<11;o++)e[n++]=t[r][i][a][o];return e})(),(()=>{let e=new Uint8Array(1056),t=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],n=0;for(let r=0;r<4;r++)for(let i=0;i<8;i++)for(let a=0;a<3;a++)for(let o=0;o<11;o++)e[n++]=t[r][i][a][o];return e})(),new Uint16Array([4,5,6,7,8,9,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,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284]),new Uint16Array([4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157]),new Int8Array([-10,2,4,6,-0,-2,-3,-1]),new Uint8Array([145,156,163,128]),new Int8Array([-0,2,-2,4,-3,-1]),new Uint8Array([142,114,183]),new Int8Array([-0,2,-1,4,-2,6,8,12,-3,10,-4,-5,-6,14,-7,16,-8,-9]),(()=>{let e=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],t=new Uint8Array(900),n=0;for(let r=0;r<10;r++)for(let i=0;i<10;i++)for(let a=0;a<9;a++)t[n++]=e[r][i][a];return t})(),new Uint16Array([0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396]),new Uint8Array([7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,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,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,0]),new Uint8Array([127,127,191,127,159,191,223,127,143,159,175,191,207,223,239,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,247,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,211,215,219,223,227,231,235,239,243,247,251,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,127]);var xX;(function(e){e[e.Literal=0]=`Literal`,e[e.Backref=1]=`Backref`,e[e.Cache=2]=`Cache`})(xX||={});var SX=o((e=>{(function(t){typeof DO_NOT_EXPORT_CRC>`u`?typeof e==`object`?t(e):typeof define==`function`&&define.amd?define(function(){var e={};return t(e),e}):t({}):t({})})(function(e){e.version=`0.3.0`;function t(){for(var e=0,t=Array(256),n=0;n!=256;++n)e=n,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,t[n]=e;return typeof Int32Array<`u`?new Int32Array(t):t}var n=t(),r=typeof Buffer<`u`;function i(e){if(e.length>32768&&r)return o(new Buffer(e));for(var t=-1,i=e.length-1,a=0;a<i;)t=n[(t^e.charCodeAt(a++))&255]^t>>>8,t=n[(t^e.charCodeAt(a++))&255]^t>>>8;return a===i&&(t=t>>>8^n[(t^e.charCodeAt(a))&255]),t^-1}function a(e){if(e.length>1e4)return o(e);for(var t=-1,r=0,i=e.length-3;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+3;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function o(e){for(var t=-1,r=0,i=e.length-7;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+7;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function s(e){for(var t=-1,r=0,i=e.length,a,o;r<i;)a=e.charCodeAt(r++),a<128?t=t>>>8^n[(t^a)&255]:a<2048?(t=t>>>8^n[(t^(192|a>>6&31))&255],t=t>>>8^n[(t^(128|a&63))&255]):a>=55296&&a<57344?(a=(a&1023)+64,o=e.charCodeAt(r++)&1023,t=t>>>8^n[(t^(240|a>>8&7))&255],t=t>>>8^n[(t^(128|a>>2&63))&255],t=t>>>8^n[(t^(128|o>>6&15|a&3))&255],t=t>>>8^n[(t^(128|o&63))&255]):(t=t>>>8^n[(t^(224|a>>12&15))&255],t=t>>>8^n[(t^(128|a>>6&63))&255],t=t>>>8^n[(t^(128|a&63))&255]);return t^-1}e.table=n,e.bstr=i,e.buf=a,e.str=s})})),CX=o(((e,t)=>{var n=SX();t.exports=o;var r=new Uint8Array(4),i=new Int32Array(r.buffer),a=new Uint32Array(r.buffer);function o(e){if(e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)throw Error(`Invalid .png file header`);if(e[4]!==13||e[5]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);if(e[6]!==26)throw Error(`Invalid .png file header`);if(e[7]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);for(var t=!1,o=[],s=8;s<e.length;){r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var c=a[0]+4,l=new Uint8Array(c);l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++];var u=String.fromCharCode(l[0])+String.fromCharCode(l[1])+String.fromCharCode(l[2])+String.fromCharCode(l[3]);if(!o.length&&u!==`IHDR`)throw Error(`IHDR header missing`);if(u===`IEND`){t=!0,o.push({name:u,data:new Uint8Array});break}for(var d=4;d<c;d++)l[d]=e[s++];r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var f=i[0];if(n.buf(l)!==f)throw Error(`CRC values for `+u+` header do not match, PNG file is likely corrupted`);var p=new Uint8Array(l.buffer.slice(4));o.push({name:u,data:p})}if(!t)throw Error(`.png file ended prematurely: no IEND header was found`);return o}})),wX=o(((e,t)=>{t.exports=function(e,t,n){var r=[],i=e.length;if(i===0)return r;var a=t<0?Math.max(0,t+i):t||0;for(n!==void 0&&(i=n<0?n+i:n);i-->a;)r[i-a]=e[i];return r}})),TX=o(((e,t)=>{var n=wX(),r=SX();t.exports=s;var i=new Uint8Array(4),a=new Int32Array(i.buffer),o=new Uint32Array(i.buffer);function s(e){var t=8,s=t,c;for(c=0;c<e.length;c++)t+=e[c].data.length,t+=12;var l=new Uint8Array(t);for(l[0]=137,l[1]=80,l[2]=78,l[3]=71,l[4]=13,l[5]=10,l[6]=26,l[7]=10,c=0;c<e.length;c++){var u=e[c],d=u.name,f=u.data,p=f.length,m=[d.charCodeAt(0),d.charCodeAt(1),d.charCodeAt(2),d.charCodeAt(3)];o[0]=p,l[s++]=i[3],l[s++]=i[2],l[s++]=i[1],l[s++]=i[0],l[s++]=m[0],l[s++]=m[1],l[s++]=m[2],l[s++]=m[3];for(var h=0;h<p;)l[s++]=f[h++];var g=m.concat(n(f));a[0]=r.buf(g),l[s++]=i[3],l[s++]=i[2],l[s++]=i[1],l[s++]=i[0]}return l}})),EX=l(CX(),1),DX=l(TX(),1);function OX(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function kX(e,t){let n=new TextEncoder().encode(t);return e.length>=n.length&&n.every((t,n)=>e[n]===t)}function AX(e,t){let n=(0,EX.default)(e),r=`XML:com.adobe.xmp\0`,i=n.filter(e=>!([`iTXt`,`tEXt`,`zTXt`].includes(e.name)&&kX(e.data,r))),a=i.findIndex(e=>e.name===`IDAT`);if(a<0)throw Error(`PNG has no image data`);return i.splice(a,0,{name:`iTXt`,data:OX([new TextEncoder().encode(r),new Uint8Array(4),new TextEncoder().encode(t)])}),(0,DX.default)(i)}var jX=`http://ns.adobe.com/xap/1.0/\0`,MX=`http://ns.adobe.com/xmp/extension/\0`;function NX(e,t){let n=e,r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.length<4||r.getUint16(0)!==65496||r.getUint16(n.length-2)!==65497)throw Error(`Invalid JPEG envelope`);let i=new TextEncoder().encode(`${jX}${t}`);if(i.length>65533)throw Error(`XMP exceeds one JPEG APP1 segment`);let a=new Uint8Array(4),o=new DataView(a.buffer);o.setUint16(0,65505),o.setUint16(2,i.length+2);let s=OX([a,i]),c=[n.subarray(0,2)],l=1,u=!0,d=!1,f=2;for(;f+4<=n.length;){let e=f;if(n[f]!==255)throw Error(`Invalid JPEG marker`);for(;n[f]===255;)f++;let t=n[f];if(t===void 0||t===0||t===216||t===217)throw Error(`JPEG ended before its scan`);if(t===1||t>=208&&t<=215){c.push(n.subarray(e,f+1)),f++,u=!1;continue}if(f+3>n.length)throw Error(`Truncated JPEG length`);let i=r.getUint16(f+1),a=f+1+i;if(i<2||a>n.length)throw Error(`Truncated JPEG segment`);if(t>=192&&t<=207&&![196,200,204].includes(t)&&(d=!0),t===218){if(!d)throw Error(`JPEG has no frame`);return c.splice(l,0,s),c.push(n.subarray(e)),OX(c)}let o=n.subarray(f+3,a);t===225&&[jX,MX].some(e=>kX(o,e))||(c.push(n.subarray(e,a)),u&&(t===224||t===225&&kX(o,`Exif\0\0`))?l=c.length:u=!1),f=a}throw Error(`JPEG has no scan`)}var PX=`https://fungi.computer/ns/provenance/1.0/`,FX=`http://iptc.org/std/Iptc4xmpExt/2008-02-29/`,IX=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`;function LX(e){let t=new LR.DOMParser({onError:()=>{throw Error(`Invalid provenance XML`)}}),n=e?t.parseFromString(e,`application/xml`):void 0,r=(e,t)=>{let r=n?.getElementsByTagNameNS(e,t).item(0);if(r?.textContent)return r.textContent;let i=n?.getElementsByTagNameNS(IX,`Description`);if(i)for(let n=0;n<i.length;n++){let r=i.item(n)?.getAttributeNS(e,t);if(r)return r}},i=t.parseFromString(`<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about=""/></rdf:RDF></x:xmpmeta>`,`application/xml`),a=i.getElementsByTagNameNS(IX,`Description`).item(0);if(!a)throw Error(`Missing provenance description`);let o=[{namespace:PX,name:`printId`,qualified:`fungi:printId`},{namespace:FX,name:`DigitalSourceType`,qualified:`Iptc4xmpExt:DigitalSourceType`}];for(let{namespace:e,name:t,qualified:n}of o){let o=r(e,t);if(o===void 0)continue;let s=i.createElementNS(e,n);s.textContent=o,a.appendChild(s)}return new LR.XMLSerializer().serializeToString(i)}var RX=33554432,zX=class extends Error{reason;name=`ProvenanceExportError`;constructor(e,t){super(`Print export refused: ${e}`,t),this.reason=e}};function BX(e,t){let n=yX(e);if(n.some(e=>e.size!==e.data.length)||n.reduce((e,t)=>e+8+t.size+t.size%2,12)!==e.length)throw Error(`Incomplete extended WebP`);if(!n.some(e=>e.fourCC===`XMP `))return e;if(!n.some(e=>e.fourCC===`VP8X`))throw Error(`XMP without extended WebP header`);let r=!1;return bX(n.flatMap(e=>e.fourCC===`XMP `?r?[]:(r=!0,[{fourCC:`XMP `,data:new TextEncoder().encode(t)}]):[{fourCC:e.fourCC,data:e.data}]))}async function VX(e){if(e.length>33554432)throw new zX(`too-large`);let t=new TextDecoder(`latin1`).decode(e);if(t.includes(`c2pa`)||t.includes(`caBX`))throw new zX(`signed-image`);try{let t=await XY.loadView(new DataView(e.buffer,e.byteOffset,e.byteLength),{expanded:!0,async:!0,domParser:new LR.DOMParser,includeTags:{xmp:!0,png:!0,file:!0},decompress:{maxDecompressedSize:RX}}),n=t.file?.FileType?.value;if(n!==`png`&&n!==`jpeg`&&n!==`webp`&&n!==`gif`)throw new zX(`unsupported-format`);let r={type:`image/${n}`,extension:n===`jpeg`?`jpg`:n};if(n===`gif`&&!t.xmp)return{bytes:e,...r};let i=LX(t.xmp?._raw??t.pngText?.[`XML:com.adobe.xmp`]?.value),a=n===`png`?AX(e,i):n===`jpeg`?NX(e,i):n===`webp`?BX(e,i):void 0;if(!a)throw new zX(`unsupported-format`);if(a.length>33554432)throw new zX(`too-large`);return{bytes:a,...r}}catch(e){throw e instanceof zX?e:new zX(`invalid-image`,{cause:e})}}function HX(e){return/\.mp4$/iu.test(e)}async function UX(e,t){if(HX(e.name)){let n=document.createElement(`video`);return n.preload=`metadata`,n.muted=!0,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP4 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,width:n.videoWidth,height:n.videoHeight}}let n=new Image;return n.src=t,await n.decode(),{file:e,url:t,width:n.naturalWidth,height:n.naturalHeight}}var WX={title:`Image too large`,message:`Download supports images up to 32 MiB. Choose a smaller image.`};async function GX(e,t){let n=()=>{if(t.throwIfAborted(),e.kind===`computer`&&e.connection.app.context.get().computerId!==e.computerId)throw new Y(`Print Computer changed`,{code:`SELECTION_CHANGED`,retryable:!1})};if(n(),e.file.size>33554432)throw new zX(`too-large`);let r=e.kind===`computer`?await wR(e.connection.app.capabilities,{path:e.path},{signal:t}):e.file;if(n(),r.size>33554432)throw new zX(`too-large`);let i=e.kind===`computer`?e.path:r.name,a=(i.split(`/`).at(-1)??`print`).replace(/\.[^.]*$/,``)||`print`;if(HX(i))return n(),new File([r],`${a}.mp4`,{type:`video/mp4`});let o=await VX(new Uint8Array(await r.arrayBuffer()));return n(),new File([Uint8Array.from(o.bytes)],`${a}.${o.extension}`,{type:o.type})}function KX(e){return e instanceof zX?{...{"too-large":WX,"signed-image":{title:`Download unavailable`,message:`This image has signed metadata that Prints cannot safely remove.`},"invalid-image":{title:`Couldn't prepare the image`,message:`Prints couldn't remove this image's private details. Choose another image.`},"unsupported-format":{title:`Download unavailable`,message:`Prints cannot safely export this file format yet.`}}[e.reason],retryable:!1}:lx(e,{FILE_TOO_LARGE:WX})}function qX(e){return{...{"no-user-gesture":{title:`Click to download`,message:`Click Download in Prints to save this image.`},"too-large":WX,"invalid-request":{title:`Download unavailable`,message:`The prepared image could not be saved. Reopen its information and try again.`},unavailable:{title:`Download unavailable`,message:`The host cannot save files right now. Reopen Prints and try again.`},denied:{title:`Download denied`,message:`Your browser did not allow this download. Check its download settings and try again.`},busy:{title:`Download busy`,message:`Wait for the current browser action to finish, then try again.`}}[e.reason],retryable:!1}}function JX(e,t){console.error(`Prints operation failed`,JSON.stringify({operation:e,errorKind:t instanceof Error?`error`:`non-error`,stage:t instanceof $A?t.stage:null,provider:t instanceof $A?t.provider:void 0}),Zm(t))}function YX({source:e,app:t}){let n=(0,K.useRef)(null),r=FS({gcTime:0,mutationFn:async t=>{let n=await GX(e,t.signal),r=new Uint8Array(await n.arrayBuffer());return t.signal.throwIfAborted(),{kind:`saveFile`,name:n.name,mime:n.type,bytes:r}},onError:(e,t)=>{t.signal.aborted||JX(`prepare-print-download`,e)}}),{mutate:i,reset:a}=r;(0,K.useEffect)(()=>{let r=new AbortController;n.current=r;let o=()=>{r.abort(),a()},s=t?.context.subscribe(t=>{e.kind===`computer`&&t.computerId!==e.computerId&&o()}),c=t?.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&o()});return i(r),()=>{s?.(),c?.(),r.abort(),n.current===r&&(n.current=null)}},[e,t,i,a]);let o=FS({gcTime:0,mutationFn:e=>e,onError:e=>{JX(`download-print`,e)}}),s=r.error??o.error,c=s?KX(s):o.data?.kind===`refused`?qX(o.data):null,l=r.isIdle||r.isPending;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fP,{type:`button`,label:`Download`,title:l?`Preparing download…`:o.isPending?`Downloading…`:`Download`,disabled:!r.data||o.isPending,"aria-busy":l||o.isPending,icon:(0,X.jsx)(Fie,{size:16,"aria-hidden":`true`}),onClick:()=>{if(r.data&&!o.isPending&&!n.current?.signal.aborted){let e=t?t.ui.requestBrowserAction(r.data):Promise.resolve({kind:`refused`,reason:`unavailable`});o.mutate(e)}}}),c?(0,X.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[c.title,`. `,c.message]}):null]})}var XX=Xa({print:Xa({kind:lo([`image`,`video`]),model:da(),width:Pa().nullable(),height:Pa().nullable(),steps:Pa().nullable(),createdAt:Pa()}),typed:Xa({prompt:da(),references:Pa()}),references:Ja(Xa({path:da(),computerId:da().optional()})),characters:Ja(da())}),ZX=(e,t)=>({style:t,kind:e.print.kind,model:e.print.model,typed:e.typed,references:e.references,steps:e.print.steps,width:e.print.width,height:e.print.height}),QX=(e,t)=>t===0?e:QX(t,e%t),$X=(e,t)=>{let n=QX(e,t);return`${String(e/n)}:${String(t/n)}`},eZ=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function tZ(e,t){let n=e.source,r=n.kind===`computer`?n.path:null,i=n.kind===`computer`?n.computerId:null;return NS({...CA(t,EA,bA.of(t,`prints`,`output-details`,i,r),async(e,t)=>{let n=await e.call(`getOutput`,JSON.stringify({path:r}));t.throwIfAborted();let i=XX.safeParse(n);return i.success?i.data:null}),enabled:!!(t&&r&&i&&t.capabilities.has(EA)),retry:!1})}function nZ({sigil:e,label:t,children:n}){return(0,X.jsxs)(pie,{children:[(0,X.jsxs)(`span`,{className:`prints-info-label`,children:[(0,X.jsx)(Die,{name:e,size:16}),t]}),(0,X.jsx)(`span`,{className:`prints-info-value`,children:n})]})}function rZ({name:e}){let t=e.length>iZ?e.slice(-iZ):``;return(0,X.jsxs)(`span`,{className:`prints-info-file`,title:e,"data-print-file":!0,children:[(0,X.jsx)(`span`,{className:`prints-info-file-head`,children:e.slice(0,e.length-t.length)}),t?(0,X.jsx)(`span`,{className:`prints-info-file-tail`,children:t}):null]})}var iZ=10;function aZ({image:e,app:t,download:n=(0,X.jsx)(YX,{source:e.source,app:t}),referenceImages:r,models:i,canAnimate:a,onIterate:o,onClose:s}){let[c,l]=(0,K.useState)(null),u=(0,K.useRef)(null),d=NS(AM(t,e.source.kind===`computer`?e.source.path:null)),f=tZ(e,t).data,p=f?ZX(f,d.data?.style??null):null,m=f?ZL(i,f.print.model):null;return(0,K.useEffect)(()=>{let e=document.activeElement;return u.current?.focus(),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,X.jsxs)($I,{ref:u,className:`prints-info-drawer`,role:`region`,"aria-label":`Image information`,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),s())},children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Image info`}),(0,X.jsx)(QI,{"aria-label":`Close image information`,icon:(0,X.jsx)(AL,{}),onClick:s})]}),(0,X.jsxs)(fie,{density:`compact`,className:`prints-info-facts`,children:[(0,X.jsx)(nZ,{sigil:`list`,label:`File`,children:(0,X.jsx)(rZ,{name:e.file.name})}),(0,X.jsxs)(nZ,{sigil:`prints`,label:`Size`,children:[e.width,` × `,e.height,` · `,$X(e.width,e.height)]}),d.data?.style?(0,X.jsx)(nZ,{sigil:`write`,label:`Style`,children:d.data.style}):null,f?(0,X.jsx)(nZ,{sigil:`sendPrompts`,label:`Prompt`,children:(0,X.jsx)(`span`,{className:`whitespace-pre-wrap`,"data-print-prompt":!0,children:f.typed.prompt})}):null,f?(0,X.jsx)(nZ,{sigil:`generateMedia`,label:`Model`,children:(0,X.jsx)(`span`,{"data-print-model":!0,children:m?XL(m):`${f.print.model} (no longer available)`})}):null,f&&f.characters.length>0?(0,X.jsx)(nZ,{sigil:`members`,label:`Characters`,children:(0,X.jsx)(`span`,{"data-print-characters":!0,children:f.characters.map(e=>`@${e}`).join(`, `)})}):null,f&&f.references.length>0?(0,X.jsx)(nZ,{sigil:`read`,label:`References`,children:(0,X.jsx)(`ul`,{className:`prints-info-references`,"data-print-references":!0,"aria-label":`${String(f.references.length)} references`,children:f.references.map((t,n)=>{let i=t.path.split(`/`).at(-1),a=e.source.kind===`computer`&&jL(t,e.source.computerId)?r.find(e=>e.path===t.path):void 0;return(0,X.jsx)(`li`,{title:t.path,children:a?(0,X.jsx)(`img`,{src:a.url,alt:i}):i},`${String(n)}:${t.path}`)})})}):null,f?(0,X.jsx)(nZ,{sigil:`schedule`,label:`Made`,children:eZ.format(f.print.createdAt)}):null]}),(0,X.jsxs)(`div`,{className:`prints-info-actions`,role:`group`,"aria-label":`Image actions`,children:[p&&e.source.kind===`computer`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fP,{label:`Reuse`,icon:(0,X.jsx)(TL,{}),disabled:d.isPending,onClick:()=>{l(o(`reuse`,p))}}),(0,X.jsx)(fP,{label:`Remix`,icon:(0,X.jsx)(EL,{}),disabled:d.isPending,onClick:()=>{l(o(`remix`,p))}}),a&&p.kind===`image`?(0,X.jsx)(fP,{label:`Animate`,icon:(0,X.jsx)(Pie,{}),disabled:d.isPending,onClick:()=>{l(o(`animate`,p))}}):null]}):null,n]}),c?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm`,children:c}):null]})}function oZ(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var sZ=oZ(`https://base-ui.com/production-error`,`Base UI`),cZ=K.createContext(void 0);function lZ(e){let t=K.useContext(cZ);if(!e&&t===void 0)throw Error(sZ(27));return t}var uZ={};function dZ(e,t){let n=K.useRef(uZ);return n.current===uZ&&(n.current=e(t)),n}function fZ(e,t,n,r){let i=dZ(mZ).current;return hZ(i,e,t,n,r)&&_Z(i,[e,t,n,r]),i.callback}function pZ(e){let t=dZ(mZ).current;return gZ(t,e)&&_Z(t,e),t.callback}function mZ(){return{callback:null,cleanup:null,refs:[]}}function hZ(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function gZ(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function _Z(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var vZ=18;function yZ(e){return vZ>=e}function bZ(e){if(!K.isValidElement(e))return null;let t=e,n=t.props;return(yZ(19)?n?.ref:t.ref)??null}function xZ(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function SZ(){}var CZ=Object.freeze([]),wZ=Object.freeze({});function TZ(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function EZ(e,t){return typeof e==`function`?e(t):e}function DZ(e,t){return typeof e==`function`?e(t):e}var OZ={};function kZ(e,t,n,r,i){if(!n&&!r&&!i&&!e)return jZ(t);let a=jZ(e);return t&&(a=MZ(a,t)),n&&(a=MZ(a,n)),r&&(a=MZ(a,r)),i&&(a=MZ(a,i)),a}function AZ(e){if(e.length===0)return OZ;if(e.length===1)return jZ(e[0]);let t=jZ(e[0]);for(let n=1;n<e.length;n+=1)t=MZ(t,e[n]);return t}function jZ(e){return IZ(e)?{...e(OZ)}:NZ(e)}function MZ(e,t){return IZ(t)?t(e):PZ(e,t)}function NZ(e){let t={...e};for(let e in t){let n=t[e];FZ(e,n)&&(t[e]=RZ(n))}return t}function PZ(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=xZ(e.style,r);break;case`className`:e[n]=BZ(e.className,r);break;default:e[n]=FZ(n,r)?LZ(e[n],r):r}}return e}function FZ(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function IZ(e){return typeof e==`function`}function LZ(e,t){return t?e?(...n)=>{let r=n[0];if(VZ(r)){let i=r;zZ(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:RZ(t):e}function RZ(e){return e&&((...t)=>{let n=t[0];return VZ(n)&&zZ(n),e(...t)})}function zZ(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function BZ(e,t){return t?e?t+` `+e:t:e}function VZ(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function HZ(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=KZ(r));let i=UZ(t,n,r);if(n.enabled===!1)return null;let a=n.state??wZ;return qZ(e,r,i,a)}function UZ(e,t,n){let{className:r,style:i}=e,{state:a=wZ,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?EZ(r,a):void 0,d=l?DZ(i,a):void 0,f=l?TZ(a,c):wZ,p=l&&s?WZ(s):void 0,m=l?xZ(f,p)??{}:wZ;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?pZ([m.ref,bZ(n),...o]):fZ(m.ref,bZ(n),o):fZ(null,null)),l?(u!==void 0&&(m.className=BZ(m.className,u)),d!==void 0&&(m.style=xZ(m.style,d)),m):wZ}function WZ(e){return Array.isArray(e)?AZ(e):kZ(void 0,e)}var GZ=Symbol.for(`react.lazy`);function KZ(e){if(e?.$$typeof!==GZ)return e;let t=K.Children.toArray(e)[0];return K.isValidElement(t)?t:e}function qZ(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=kZ(n,t.props);return e.ref=n.ref,K.cloneElement(t,e)}return JZ(e,n)}function JZ(e,t){return e===`button`?(0,K.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,K.createElement)(`img`,{alt:``,...t,key:t.key}):K.createElement(e,t)}var YZ=`data-starting-style`,XZ=`data-ending-style`,ZZ={[YZ]:``},QZ={[XZ]:``},$Z={transitionStatus(e){return e===`starting`?ZZ:e===`ending`?QZ:null}},eQ=`data-open`,tQ=`data-closed`,nQ=`data-anchor-hidden`,rQ=`data-popup-open`,iQ=`data-pressed`,aQ={[rQ]:``},oQ={[rQ]:``,[iQ]:``},sQ={[eQ]:``},cQ={[tQ]:``},lQ={[nQ]:``},uQ={open(e){return e?aQ:null}},dQ={open(e){return e?oQ:null}},fQ={open(e){return e?sQ:cQ},anchorHidden(e){return e?lQ:null}},pQ={...fQ,...$Z},mQ=K.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=lZ(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return HZ(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:pQ,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})});function hQ(){return typeof window<`u`}function gQ(e){return yQ(e)?(e.nodeName||``).toLowerCase():`#document`}function _Q(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vQ(e){return((yQ(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function yQ(e){return hQ()?e instanceof Node||e instanceof _Q(e).Node:!1}function bQ(e){return hQ()?e instanceof Element||e instanceof _Q(e).Element:!1}function xQ(e){return hQ()?e instanceof HTMLElement||e instanceof _Q(e).HTMLElement:!1}function SQ(e){return!hQ()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof _Q(e).ShadowRoot}function CQ(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=PQ(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function wQ(e){return/^(table|td|th)$/.test(gQ(e))}function TQ(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var EQ=/transform|translate|scale|rotate|perspective|filter/,DQ=/paint|layout|strict|content/,OQ=e=>!!e&&e!==`none`,kQ;function AQ(e){let t=bQ(e)?PQ(e):e;return OQ(t.transform)||OQ(t.translate)||OQ(t.scale)||OQ(t.rotate)||OQ(t.perspective)||!MQ()&&(OQ(t.backdropFilter)||OQ(t.filter))||EQ.test(t.willChange||``)||DQ.test(t.contain||``)}function jQ(e){let t=IQ(e);for(;xQ(t)&&!NQ(t);){if(AQ(t))return t;if(TQ(t))return null;t=IQ(t)}return null}function MQ(){return kQ??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),kQ}function NQ(e){return/^(html|body|#document)$/.test(gQ(e))}function PQ(e){return _Q(e).getComputedStyle(e)}function FQ(e){return bQ(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function IQ(e){if(gQ(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||SQ(e)&&e.host||vQ(e);return SQ(t)?t.host:t}function LQ(e){let t=IQ(e);return NQ(t)?(e.ownerDocument||e).body:xQ(t)&&CQ(t)?t:LQ(t)}function RQ(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=LQ(e),i=r===e.ownerDocument?.body,a=_Q(r);if(i){let e=zQ(a);return t.concat(a,a.visualViewport||[],CQ(r)?r:[],e&&n?RQ(e):[])}return t.concat(r,RQ(r,[],n))}function zQ(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var BQ={...K},VQ=BQ.useInsertionEffect,HQ=VQ&&VQ!==BQ.useLayoutEffect?VQ:e=>e();function UQ(e){let t=dZ(WQ).current;return t.next=e,HQ(t.effect),t.trampoline}function WQ(){let e={next:void 0,callback:GQ,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function GQ(){}var KQ=typeof document<`u`?K.useLayoutEffect:()=>{},qQ=K.createContext(void 0);function JQ(e=!1){let t=K.useContext(qQ);if(t===void 0&&!e)throw Error(sZ(16));return t}function YQ(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:K.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function XQ(e){return e?.ownerDocument||document}function ZQ(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(_Q(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function QQ(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=K.useRef(null),s=JQ(!0),c=a??s!==void 0,{props:l}=YQ({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=K.useCallback(()=>{let e=o.current;$Q(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return KQ(u,[u]),{getButtonProps:K.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return kZ({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(zZ(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=$Q(r),s=!i&&e$(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),ZQ(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),ZQ(r,e)))},onKeyUp(e){if(!t){if(zZ(e),a?.(e),e.target===e.currentTarget&&i&&c&&$Q(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),ZQ(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:UQ(e=>{o.current=e,u()})}}function $Q(e){return xQ(e)&&e.tagName===`BUTTON`}function e$(e){return xQ(e)&&e.tagName===`A`&&!!e.href}function t$(e,t,n,r){let i=!1,a=!1,o=r??wZ;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function n$(e,t,n){let r=n??wZ;return{reason:e,event:t??new Event(`base-ui`),...r}}var r$=`none`,i$=`trigger-press`,a$=`trigger-hover`,o$=`trigger-focus`,s$=`outside-press`,c$=`item-press`,l$=`close-press`,u$=`focus-out`,d$=`escape-key`,f$=`list-navigation`,p$=`keyboard`,m$=`pointer`,h$=`cancel-open`,g$=`sibling-open`,_$=`imperative-action`,v$=K.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=lZ(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=QQ({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,t$(l$,e.nativeEvent))}return HZ(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});function y$(){let[,e]=K.useState({});return K.useCallback(()=>{e({})},[])}var b$=0;function x$(e,t=`mui`){let n=K.useRef(void 0),r=y$(),i=e??n.current;return K.useEffect(()=>{n.current??(b$+=1,n.current=`${t}-${b$}`,e??r())},[e,t,r]),i}var S$=BQ.useId;function C$(e,t){if(S$!==void 0){let n=S$();return e??(t?`${t}-${n}`:n)}return x$(e,t)}function w$(e){return C$(e,`base-ui`)}var T$=K.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=lZ(),c=w$(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),HZ(`p`,e,{ref:t,props:[{id:c},o]})});function E$(e){K.useEffect(e,CZ)}var D$=0,O$=class e{static create(){return new e}currentId=D$;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=D$,t()},e)}isStarted(){return this.currentId!==D$}clear=()=>{this.currentId!==D$&&(clearTimeout(this.currentId),this.currentId=D$)};disposeEffect=()=>this.clear};function k$(){let e=dZ(O$.create).current;return E$(e.disposeEffect),e}function A$(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:j$,platform:M$,maxTouchPoints:N$}=A$(),P$=j$.toLowerCase(),F$=M$.toLowerCase(),I$=/^i(os$|p)/.test(F$)||F$===`macintel`&&N$>1,L$=`android`,R$=F$===L$||P$.includes(L$),z$=!I$&&F$.startsWith(`mac`);F$.startsWith(`win`),!R$&&/^(linux|chrome os)/.test(F$);var B$=z$||I$,V$=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!V$&&P$.includes(`firefox`),!V$&&P$.includes(`chrom`);var H$=B$,U$=/jsdom|happydom/.test(P$);function W$(e){e.preventDefault(),e.stopPropagation()}function G$(e){return`nativeEvent`in e}function K$(e){return e.pointerType===``&&e.isTrusted?!0:R$&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function q$(e){return U$?!1:!R$&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(R$||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function J$(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Y$(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function X$(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Z$(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&SQ(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Q$(e,t){let n=e;for(;n;){if(bQ(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(SQ(n)?n.host:null)}return null}function $$(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var e1=`data-base-ui-focusable`,t1=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,n1=`ArrowLeft`,r1=`ArrowRight`,i1=`ArrowUp`,a1=`ArrowDown`,o1=`data-trigger-disabled`;function s1(e,t){if(!bQ(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(o1);for(let[,e]of t.entries())if(Z$(e,n))return!e.hasAttribute(o1);return!1}function c1(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function l1(e){return e.matches(`html,body`)}function u1(e){return xQ(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function d1(e){return Q$(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${t1}`)!=null}function f1(e){return e?e.getAttribute(`role`)===`combobox`&&u1(e):!1}function p1(e){if(!e||U$)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function m1(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function h1(e,t){return t!=null&&!J$(t)?0:typeof e==`function`?e():e}function g1(e,t,n){let r=h1(e,n);return typeof r==`number`?r:r?.[t]}function _1(e){return typeof e==`function`?e():e}function v1(e,t){return t||e===`click`||e===`mousedown`}function y1(e){return e?.includes(`mouse`)&&e!==`mousedown`}function b1(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function x1(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function S1(e){let t=dZ(C1,e).current;return t.next=e,KQ(t.effect),t}function C1(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var w1=null;globalThis.requestAnimationFrame;var T1=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},E1=class e{static create(){return new e}static request(e){return T1.request(e)}static cancel(e){return T1.cancel(e)}currentId=w1;request(e){this.cancel(),this.currentId=T1.request(()=>{this.currentId=w1,e()})}cancel=()=>{this.currentId!==w1&&(T1.cancel(this.currentId),this.currentId=w1)};disposeEffect=()=>this.cancel};function D1(){let e=dZ(E1.create).current;return E$(e.disposeEffect),e}var O1={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},k1={...O1,position:`fixed`,margin:0,top:0,left:0};({...O1});var A1=K.forwardRef(function(e,t){let[n,r]=K.useState();KQ(()=>{H$&&V$&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,X.jsx)(`span`,{...e,ref:t,style:k1,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),j1=Math.min,M1=Math.max,N1=Math.round,P1=Math.floor,F1=e=>({x:e,y:e}),I1={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function L1(e,t,n){return M1(e,j1(t,n))}function R1(e,t){return typeof e==`function`?e(t):e}function z1(e){return e.split(`-`)[0]}function B1(e){return e.split(`-`)[1]}function V1(e){return e===`x`?`y`:`x`}function H1(e){return e===`y`?`height`:`width`}function U1(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function W1(e){return V1(U1(e))}function G1(e,t,n){n===void 0&&(n=!1);let r=B1(e),i=W1(e),a=H1(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=e0(o)),[o,e0(o)]}function K1(e){let t=e0(e);return[q1(e),t,q1(t)]}function q1(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var J1=[`left`,`right`],Y1=[`right`,`left`],X1=[`top`,`bottom`],Z1=[`bottom`,`top`];function Q1(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Y1:J1:t?J1:Y1;case`left`:case`right`:return t?X1:Z1;default:return[]}}function $1(e,t,n,r){let i=B1(e),a=Q1(z1(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(q1)))),a}function e0(e){let t=z1(e);return I1[t]+e.slice(t.length)}function t0(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function n0(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:t0(e)}function r0(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function i0(e,t){return t<0||t>=e.length}function a0(e,t){return c0(e.current,{disabledIndices:t})}function o0(e,t){return c0(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function s0(e,t,n){let{decrement:r,loopFocus:i,allowEscape:a,disabledIndices:o,minIndex:s,maxIndex:c}=n,l=()=>c0(e,{startingIndex:t,decrement:r,disabledIndices:o}),u,d=!1;if(!i)u=r?Math.max(s,l()):Math.min(c,l());else if(r?t<=s:t>=c){let n=r?-1:e.length;a&&t!==n?u=-1:(u=r?c:s,d=!0)}else u=l();return{index:i0(e,u)?-1:u,wrapped:d}}function c0(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&l0(e,a,r));return a}function l0(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!d0(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function u0(e){return e.visibility===`hidden`||e.visibility===`collapse`}function d0(e,t=e?PQ(e):null){return!e||!e.isConnected||!t||u0(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var f0=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function p0(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return SQ(n)?n.host:null}function m0(e){for(let t of Array.from(e.children))if(gQ(t)===`summary`)return t;return null}function h0(e,t){let n=m0(t);return!!n&&(e===n||Z$(n,e))}function g0(e){let t=e?gQ(e):``;return e!=null&&e.matches(f0)&&(t!==`summary`||e.parentElement!=null&&gQ(e.parentElement)===`details`&&m0(e.parentElement)===e)&&(t!==`details`||m0(e)==null)&&(t!==`input`||e.type!==`hidden`)}function _0(e){if(!g0(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=p0(t)){let n=t!==e,r=gQ(t)===`slot`;if(t.hasAttribute(`inert`)||n&&gQ(t)===`details`&&!t.open&&!h0(e,t)||t.hasAttribute(`hidden`)||!r&&!v0(t,n))return!1}return!0}function v0(e,t){let n=PQ(e);return t?n.display!==`none`:d0(e,n)}function y0(e){let t=e.tabIndex;if(t<0){let t=gQ(e);if(t===`details`||t===`audio`||t===`video`||xQ(e)&&e.isContentEditable)return 0}return t}function b0(e){if(gQ(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function x0(e,t){let n=b0(e);if(!n)return!0;let r=t.find(e=>{let t=b0(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=b0(e);return t?.name===n.name&&t.form===n.form})===n}function S0(e){if(xQ(e)&&gQ(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return xQ(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function C0(e,t){S0(e).forEach(e=>{g0(e)&&t.push(e),C0(e,t)})}function w0(e,t,n){S0(e).forEach(e=>{xQ(e)&&e.matches(t)&&n.push(e),w0(e,t,n)})}function T0(e){return _0(e)&&y0(e)>=0}function E0(e){let t=[];return C0(e,t),t.filter(_0)}function D0(e){let t=E0(e);return t.filter(e=>y0(e)>=0&&x0(e,t))}function O0(e,t){let n=D0(e),r=n.length;if(r===0)return;let i=X$(XQ(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function k0(e){return O0(XQ(e).body,1)||e}function A0(e){return O0(XQ(e).body,-1)||e}function j0(e,t,n){if(!e)return null;let r=[];C0(XQ(e).body,r);let i=r.indexOf(e);if(i===-1)return null;let a=r.filter(_0);for(let e=1;e<r.length;e+=1){let o=r[(i+t*e+r.length)%r.length];if(!Z$(n,o)&&T0(o)&&x0(o,a))return o}return r[i]}function M0(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Z$(n,r)}function N0(e){D0(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function P0(e){let t=[];w0(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function F0(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...F0(e,t.id,n)])}function I0(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function L0(e){return`data-base-ui-${e}`}var R0=0;function z0(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(R0);function a(){i&&!i()||e?.focus({preventScroll:n})}if(r)return a(),SZ;let o=requestAnimationFrame(a);return R0=o,()=>{R0===o&&(cancelAnimationFrame(o),R0=0)}}var B0=`data-base-ui-inert`,V0=new WeakMap,H0=new WeakSet,U0=new WeakMap,W0=0;function G0(e){return e?SQ(e)?e.host:G0(e.parentNode):null}var K0=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=G0(t);return e.contains(n)?n:null}).filter(e=>e!=null),q0=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},J0=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{gQ(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Y0(e,t,n,{mark:r=!0}){let i=K0(t,e),a=r?J0(t,q0(i),new Set(i)):[],o=[],s=[];if(n){let e=K0(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);J0(t,q0(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(V0.get(e)||0)+1;V0.set(e,r),o.push(e),r===1&&n&&H0.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(U0.get(e)||0)+1;U0.set(e,t),s.push(e),t===1&&e.setAttribute(B0,``)}),W0+=1,()=>{o.forEach(e=>{let t=(V0.get(e)||0)-1;V0.set(e,t),t||(H0.has(e)||e.removeAttribute(`aria-hidden`),H0.delete(e))}),r&&s.forEach(e=>{let t=(U0.get(e)||0)-1;U0.set(e,t),t||e.removeAttribute(B0)}),--W0,W0||(V0=new WeakMap,H0=new WeakSet,U0=new WeakMap)}}function X0(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=XQ(e[0]).body;return Y0(e,i,n,{mark:r})}var Z0={style:{transition:`none`}},Q0=`data-base-ui-click-trigger`,$0={fallbackAxisSide:`none`},e2={fallbackAxisSide:`end`},t2={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},n2=l(LS(),1),r2=K.createContext(null),i2=()=>K.useContext(r2),a2=L0(`portal`);function o2(e={}){let{ref:t,container:n,componentProps:r=wZ,elementProps:i}=e,a=C$(),o=i2()?.portalNode,[s,c]=K.useState(null),[l,u]=K.useState(null),d=UQ(e=>{e!==null&&u(e)}),f=K.useRef(null);KQ(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(yQ(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=HZ(`div`,r,{ref:[t,d],props:[{id:a,[a2]:``},i]}),m=s&&p?n2.createPortal(p,s):null;return{node:l,nodeId:K.isValidElement(p)?p.props.id:void 0,subtree:m}}var s2=K.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=o2({container:o,ref:t,componentProps:e,elementProps:c}),f=K.useRef(null),p=K.useRef(null),m=K.useRef(null),h=K.useRef(null),[g,_]=K.useState(null),v=K.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;K.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&M0(e)&&(e.type===`focusin`?v.current&&=(P0(l),!1):(N0(l),v.current=!0))}return x1(b1(l,`focusin`,e,!0),b1(l,`focusout`,e,!0))},[l,y]),KQ(()=>{!l||b!==!0||!v.current||(P0(l),v.current=!1)},[b,l]);let S=K.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,X.jsxs)(K.Fragment,{children:[d,(0,X.jsxs)(r2.Provider,{value:S,children:[x&&l&&(0,X.jsx)(A1,{"data-type":`outside`,ref:f,onFocus:e=>{M0(e,l)?m.current?.focus():A0(g?g.domReference:null)?.focus()}}),x&&l&&(0,X.jsx)(`span`,{role:s,"aria-owns":u,style:t2}),l&&n2.createPortal(a,l),x&&l&&(0,X.jsx)(A1,{"data-type":`outside`,ref:p,onFocus:e=>{M0(e,l)?h.current?.focus():(k0(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,t$(`focus-out`,e.nativeEvent)))}})]})]})});function c2(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var l2=class{nodesRef={current:[]};events=c2();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},u2=K.createContext(null),d2=K.createContext(null),f2=()=>K.useContext(u2)?.id||null,p2=e=>{let t=K.useContext(d2);return e??t};function m2(e){let t=C$(),n=p2(e),r=f2();return KQ(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function h2(e){let{children:t,id:n}=e,r=f2();return(0,X.jsx)(u2.Provider,{value:K.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function g2(e){let{children:t,externalTree:n}=e,r=dZ(()=>n??new l2).current;return(0,X.jsx)(d2.Provider,{value:r,children:t})}function _2(e){return e==null?e:`current`in e?e.current:e}function v2(e,t){let n=_Q($$(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(K$(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var y2=20,b2=[];function x2(){b2=b2.filter(e=>e.deref()?.isConnected)}function S2(e){x2(),e&&gQ(e)!==`body`&&(b2.push(new WeakRef(e)),b2.length>y2&&(b2=b2.slice(-20)))}function C2(){return x2(),b2[b2.length-1]?.deref()}function w2(e){return e?T0(e)?e:D0(e)[0]||e:null}function T2(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=E0(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return T0(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function E2(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=UQ(()=>b.current.floatingContext?.nodeId),S=i===!1,C=f1(_)&&S,w=S1(i),T=S1(a),E=S1(o),D=S1(u),O=S1(g),k=p2(m),A=i2(),j=K.useRef(!1),M=K.useRef(!1),N=K.useRef(!1),P=K.useRef(null),F=K.useRef(``),I=K.useRef(``),L=K.useRef(null),R=K.useRef(null),z=fZ(L,p,A?.beforeInsideRef),B=fZ(R,A?.afterInsideRef),V=k$(),H=k$(),ee=D1(),te=A!=null,U=m1(v),W=UQ((e=U)=>e?D0(e):[]),ne=UQ(()=>h?.().filter(e=>e!=null)??[]);K.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&Z$(U,X$(XQ(U)))&&W().length===0&&!C&&W$(e)}return b1(XQ(U),`keydown`,e)},[r,U,c,C,W]),K.useEffect(()=>{if(r||!g)return;let e=XQ(U);function t(){N.current=!1}function n(e){let t=$$(e),n=ne(),r=Z$(v,t)||Z$(_,t)||Z$(A?.portalNode,t)||n.some(e=>e===t||Z$(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,Q$(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,H.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return x1(b1(e,`pointerdown`,n,!0),b1(e,`pointerup`,t,!0),b1(e,`pointercancel`,t,!0),b1(e,`keydown`,i,!0),t)},[r,v,_,U,g,A,H,ne]),K.useEffect(()=>{if(r||!l)return;let e=XQ(U);function n(){M.current=!0,H.start(0,()=>{M.current=!1})}function i(e){let t=$$(e);T0(t)&&(P.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=$$(n);c&&r==null&&a!=null&&Z$(v,a)&&S2(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=ne(),p=r?.hasAttribute(L0(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,_2(f),_2(d)].includes(r),m=!(Z$(_,r)||Z$(v,r)||Z$(r,v)||Z$(A?.portalNode,r)||u.some(e=>e===r||Z$(e,r))||l.hasMatchingElement(e=>Z$(e,r))||p||k&&(F0(k.nodesRef.current,o).find(e=>Z$(e.context?.elements.floating,r)||Z$(e.context?.elements.domReference,r))||I0(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,m1(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&U&&T2(U),s&&i!==_&&!d0(a)&&X$(e)===e.body){if(xQ(U)&&(U.focus(),s===`popup`)){ee.request(()=>{U.focus()});return}let e=W(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||U;xQ(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!c)&&r&&m&&!M.current&&(C||r!==C2())&&(j.current=!0,t.setOpen(!1,t$(u$,n)))})}function o(){N.current||(b.current.insideReactTree=!0,V.start(0,()=>{b.current.insideReactTree=!1}))}let u=xQ(_)?_:null;if(!(!v&&!u))return x1(u&&b1(u,`focusout`,a),u&&b1(u,`pointerdown`,n),v&&b1(v,`focusin`,i),v&&b1(v,`focusout`,a),v&&A&&b1(v,`focusout`,o,!0))},[r,_,v,U,c,k,A,t,l,s,W,C,x,b,V,H,ee,d,f,ne]),K.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${L0(`portal`)}]`)||[]),t=(k?I0(k.nodesRef.current,x()):[]).find(e=>f1(e.context?.elements.domReference||null))?.context?.elements.domReference,n=X0([v,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ne(),t,_2(f),_2(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=X0([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,ne]),KQ(()=>{if(!g||r||!xQ(U))return;F.current=``,I.current=``;let e=XQ(U),t=X$(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||Z$(U,t))return;let i=null,a=()=>(i??=W(U),i[0]||U),o;o=r===!0||r===null?a():_2(r),o||=a();let s=Z$(U,X$(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&K$(c);z0(o,{sync:l,preventScroll:o===U,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=X$(e);return!(t!==o&&Z$(U,t))}})})},[r,g,U,W,w,D,O,b]);let re=K.useRef(null);KQ(()=>{if(r||!U){re.current=null;return}re.current&&=(re.current.cancelled=!0,null);let e=XQ(U),t=X$(e),n=D.current==null;S2(t);function i(e){if(e.open||(F.current=v2(e.nativeEvent,I.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(L0(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(K$(e.nativeEvent)||q$(e.nativeEvent))j.current=!1;else{let e=!1;XQ(U).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&gQ(t)!==`body`?t:null,s=n?o||a:a||o;return s||=C2()||null,typeof i==`boolean`?s:_2(i)||s||null}return()=>{y.off(`openchange`,i);let t=X$(e),n=ne(),r=Z$(v,t)||n.some(e=>e===t||Z$(e,t))||k&&F0(k.nodesRef.current,x(),!1).some(e=>Z$(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s),l={cancelled:!1};re.current=l,queueMicrotask(()=>{re.current===l&&(re.current=null);let n=w2(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&xQ(n)&&(!(!i&&n!==t&&t!==e.body)||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,U,T,E,D,y,k,_,x,ne]),KQ(()=>{if(!V$||g||!v)return;let e=X$(XQ(v));!xQ(e)||!u1(e)||Z$(v,e)&&e.blur()},[g,v]),KQ(()=>{if(!(r||!A))return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),KQ(()=>{if(!(r||!U))return T2(U),()=>{queueMicrotask(x2)}},[r,U]);let ie=!r&&(!c||!C)&&(te||c);return(0,X.jsxs)(K.Fragment,{children:[ie&&(0,X.jsx)(A1,{"data-type":`inside`,ref:z,onFocus:e=>{if(c){let e=W();z0(e[e.length-1])}else A?.portalNode&&(j.current=!1,M0(e,A.portalNode)?k0(_)?.focus():_2(f??A.beforeOutsideRef)?.focus())}}),n,ie&&(0,X.jsx)(A1,{"data-type":`inside`,ref:B,onFocus:e=>{c?z0(W()[0]):A?.portalNode&&(l&&(j.current=!0),M0(e,A.portalNode)?A0(_)?.focus():_2(d??A.afterOutsideRef)?.focus())}})]})}function D2(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=i$}=t,l=e.context.dataRef,u=K.useRef(void 0),d=D1(),f=k$(),p=K.useMemo(()=>{function t(t,n,r,i){let a=t$(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=J$(e.pointerType,!0)&&q$(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||J$(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=$$(s),p=u1(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;if(r===`mousedown`&&o){u.current=void 0;return}J$(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return K.useMemo(()=>n?{reference:p}:wZ,[n,p])}function Vie(){return!1}function O2(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function k2(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Vie,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=p2(c),m=UQ(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=UQ(()=>a),{escapeKey:v,outsidePress:y}=O2(s),b=K.useRef(!1),x=K.useRef(!1),S=K.useRef(!1),C=K.useRef(!1),w=K.useRef(!1),T=K.useRef(``),E=K.useRef(null),D=k$(),O=k$(),k=k$(),A=UQ(()=>{O.clear(),d.current.insideReactTree=!1}),j=UQ(e=>{let t=d.current.floatingContext?.nodeId;return(p?F0(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=UQ(t=>c1(t,e.select(`floatingElement`))||c1(t,e.select(`domReferenceElement`))),N=UQ(t=>{o()&&e.setOpen(!1,t$(i$,t.nativeEvent))}),P=UQ(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=G$(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=t$(d$,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),F=UQ(()=>{d.current.insideReactTree=!0,O.start(0,A)}),I=UQ(t=>{if(!l||!n||t.button!==0)return;let r=$$(t.nativeEvent);Z$(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),L=UQ(e=>{!l||!n||(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});K.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),K.useEffect(()=>A,[A]),K.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new O$,i=XQ(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(V$?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&F0(p.nodesRef.current,t).some(t=>c1(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=$$(n),i=`[${L0(`inert`)}]`,a=bQ(r)?r.getRootNode():null,o=Array.from((SQ(a)?a:XQ(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>Z$(e,r))))return;let c=bQ(r)?r:null;for(;c&&!NQ(c);){let e=IQ(c);if(NQ(e)||!bQ(e))break;c=e}if(!(o.length&&bQ(r)&&!l1(r)&&!Z$(r,e.select(`floatingElement`))&&o.every(e=>!Z$(c,e)))){if(xQ(r)&&!(`touches`in n)){let e=NQ(r),t=PQ(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!K$(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,t$(s$,n)),A())}}}function F(t){f()!==`sloppy`||t.pointerType===`touch`||!e.select(`open`)||!n||M(t)||N(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=$$(e);if(!n)return;let r=b1(n,e.type,()=>{t(e),r()})}function R(e){T.current=`touch`,L(e,I)}function z(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),!(e.type===`mousedown`&&E.current&&!E.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function B(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;if(c(),f()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!O(e)){if(n){s();return}typeof h==`function`&&!h(e)||(t.clear(),S.current=!0,A())}}}function V(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function H(e){L(e,V)}function ee(e){f()!==`sloppy`||!E.current||M(e)||(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function te(e){L(e,ee)}let U=x1(r&&x1(b1(i,`keydown`,P),b1(i,`compositionstart`,a),b1(i,`compositionend`,o)),g&&x1(b1(i,`click`,z,!0),b1(i,`pointerdown`,z,!0),b1(i,`pointerup`,B,!0),b1(i,`pointercancel`,B,!0),b1(i,`mousedown`,z,!0),b1(i,`mouseup`,B,!0),b1(i,`touchstart`,R,{capture:!0,passive:!0}),b1(i,`touchmove`,H,{capture:!0,passive:!0}),b1(i,`touchend`,te,{capture:!0,passive:!0})));return()=>{U(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,P,A,_,j,M,p,e,D,k]);let R=K.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),z=K.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return K.useMemo(()=>n?{reference:R,floating:z,trigger:R}:{},[n,R,z])}function A2(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),KQ(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};bQ(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function j2(e,t=!1,n=!1,r=!1){let[i,a]=K.useState(e&&t?`idle`:void 0),[o,s]=K.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),KQ(()=>{if(!e&&o&&i!==`ending`&&n){let e=E1.request(()=>{a(`ending`)});return()=>{E1.cancel(e)}}},[e,o,i,n]),KQ(()=>{if(!e||t||i===void 0)return;let n=E1.request(()=>{a(void 0)});return()=>{E1.cancel(n)}},[t,e,i]),KQ(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=E1.request(()=>{a(`idle`)});return()=>{E1.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function M2(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var N2=null;function P2(e){if(!N2){let e=[];N2=e,queueMicrotask(()=>{N2=null,n2.flushSync(()=>{for(let t of e)t()})})}N2.push(e)}function F2(e,t=!1,n=!1){let r=D1();return UQ((i,a=null)=>{r.cancel();let o=_2(e);if(o==null)return;let s=o,c=()=>{if(!n){n2.flushSync(i);return}P2(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(M2(s).map(e=>e.finished.then(SZ))).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(M2(s).some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=YZ;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function I2(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=UQ(a),s=F2(r,n,i);K.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}function L2(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=UQ(i),{mounted:c,setMounted:l,transitionStatus:u}=j2(t,!1,!1,o),d=!t&&r;KQ(()=>{t&&s(!1)},[t,s]);let f=K.useRef(c),p=K.useRef(!1),m=y$(),h=()=>{f.current=!1,l(!1),a()};KQ(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=UQ(()=>{if(f.current){if(t){p.current=!0,m();return}h()}});return I2({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var R2={tabIndex:-1,[e1]:``};function z2(e){return t=>t!==`touch`||e.current}function B2(e,t=!1){let n=C$(),r=f2()!=null,i=dZ(()=>e(n,r)).current;return A2({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function V2({handle:e,store:t}){return KQ(()=>e.attachStore(t),[e,t]),null}function H2(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function U2(e,t){let n=K.useRef(null);return UQ(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),H2(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),H2(t))})}function W2(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function G2(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function K2(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=U2(e,n),o=UQ(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=UQ(e=>{a(e),e&&o(e)});return KQ(()=>(s(t.current),()=>s(null)),[s,t,n,e]),KQ(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function q2(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=K.useRef(null),i=e.useState(`open`);KQ(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=t$(r$);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function J2(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=L2({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return dZ(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Y2(e,t){e.useSyncedValues(t),KQ(()=>()=>{e.update({activeTriggerProps:wZ,inactiveTriggerProps:wZ,popupProps:wZ})},[e])}function X2(e,t){KQ(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),KQ(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Z2=class{idMap=new Map;add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},Q2=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),$2=o(((e,t)=>{t.exports=Q2()})),e4=o((e=>{var t=d(),n=$2();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),t4=o(((e,t)=>{t.exports=e4()})),n4=[],r4=void 0;function i4(){return r4}function a4(e){n4.push(e)}function o4(e){let t=(t,n)=>{let r=dZ(c4).current,i;try{r4=r;for(let e of n4)e.before(r);i=e(t,n);for(let e of n4)e.after(r);r.didInitialize=!0}finally{r4=void 0}return i};return t.displayName=e.displayName||e.name,t}function s4(e){return K.forwardRef(o4(e))}function c4(){return{didInitialize:!1}}var l4=$2(),u4=t4(),d4=yZ(19)?m4:h4;function f4(e,t,n,r,i){return d4(e,t,n,r,i)}function p4(e,t,n,r,i){let a=K.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,l4.useSyncExternalStore)(e.subscribe,a,a)}a4({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,l4.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function m4(e,t,n,r,i){let a=i4();if(!a)return p4(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function h4(e,t,n,r,i){return(0,u4.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var g4=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return f4(this,e,t,n,r)}},_4=class extends g4{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){K.useDebugValue(e);let n=this;KQ(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;KQ(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;KQ(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){K.useDebugValue(e);let n=this,r=t!==void 0;KQ(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return K.useDebugValue(e),f4(this,this.selectors[e],t,n,r)}useContextCallback(e,t){K.useDebugValue(e);let n=UQ(t??SZ);this.context[e]=n}useStateSetter(e){let t=K.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},v4={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},y4=class extends _4{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:c2(),nested:n,triggerElements:i},v4),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Y$(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function b4(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new y4({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:wZ,inactiveTriggerProps:wZ,popupProps:wZ}}var x4=e=>e.triggerIdProp??e.activeTriggerId,S4=e=>e.openProp??e.open,C4=e=>(e.popupElement?.id??e.floatingId)||void 0;function w4(e,t){return t!==void 0&&S4(e)&&x4(e)===t}function T4(e,t){return w4(e,t)?!0:t!==void 0&&S4(e)&&x4(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var E4={open:S4,mounted:e=>e.mounted,transitionStatus:e=>S4(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:x4,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:C4,isTriggerActive:(e,t)=>t!==void 0&&x4(e)===t,isOpenedByTrigger:(e,t)=>w4(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&x4(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>T4(e,t)?C4(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function D4(e){let t=K.useCallback(t=>e===void 0?SZ:e.subscribeStore(t),[e]),n=K.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,l4.useSyncExternalStore)(t,n,()=>e?.serverStore)}var O4=z$&&V$;function k4(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=K.useRef(!1),s=K.useRef(null),c=K.useRef(!0),l=k$();K.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=_Q(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&xQ(t)&&t===X$(XQ(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return x1(b1(r,`blur`,i),O4&&b1(r,`keydown`,a,!0),O4&&b1(r,`pointerdown`,l,!0))},[e,n]),K.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);bQ(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=K.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=$$(n.nativeEvent);if(bQ(a)){if(O4&&!n.relatedTarget){if(!c.current&&!u1(a))return}else if(!p1(a))return}let u=s1(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,t$(o$,d,f));return}l.start(r,()=>{o.current||e.setOpen(!0,t$(o$,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=bQ(r)&&r.hasAttribute(L0(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=X$(XQ(t));!r&&n===t||Z$(a.current.floatingContext?.refs.floating.current,n)||Z$(t,n)||o||s1(r??n,e.context.triggerElements)||e.setOpen(!1,t$(o$,i))})}}},[a,r,e,l]);return K.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var A4=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new O$;restTimeout=new O$;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},j4=new WeakMap;function M4(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&j4.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),j4.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function N4(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=j4.get(n);a&&a!==e&&M4(a),M4(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,j4.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function P4(e){let t=e.context.dataRef.current,n=dZ(()=>t.hoverInteractionState??A4.create()).current;return t.hoverInteractionState||=n,E$(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function F4(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=p2(),u=f2(),d=P4(e),f=k$(),p=UQ(()=>v1(c.current.openEvent?.type,d.interactedInside)),m=UQ(()=>y1(c.current.openEvent?.type)),h=UQ(()=>{M4(d)});KQ(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),K.useEffect(()=>h,[h]),KQ(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&bQ(s)&&o){let e=s,t=o,n=XQ(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??Q$(e,`[data-rootownerid]`)??n.body;return N4(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),K.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&F0(l.nodesRef.current,u).length>0)}function a(t){let n=g1(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,t$(a$,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=$$(e);if(!d1(t)){d.interactedInside=!1;return}d.interactedInside=Q$(t,`[aria-haspopup]`)!=null}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(s1(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(l&&r&&bQ(o)&&F0(l.nodesRef.current,r,!1).some(e=>Z$(e.context?.elements.floating,o)))){if(d.handler){d.handler(n);return}h(),m()&&!p()&&a(n)}}function v(n){!l||!u||t()||f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,t$(a$,n)),l.events.emit(`floating.closed`,n)})}let y=o;return x1(y&&b1(y,`mouseenter`,g),y&&b1(y,`mouseleave`,_),y&&b1(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var I4={current:null};function L4(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=I4,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=p2(l),v=P4(e),y=K.useRef(!1),b=S1(i),x=S1(r),S=S1(o),C=S1(n),w=S1(p),T=S1(f),E=UQ(()=>v1(h.current.openEvent?.type,v.interactedInside)),D=UQ(()=>w.current?.()!==!1),O=UQ((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Z$(t,n);if(!bQ(r))return!1;let a=r;return i.hasMatchingElement(e=>Z$(e,a))&&(!t||!Z$(t,a))}),k=UQ(()=>{v.handler&&=(XQ(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=UQ(()=>{M4(v)});return u&&(v.handleCloseOptions=i?.__options),K.useEffect(()=>k,[k]),K.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===a$,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),K.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=g1(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,t$(a$,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,t$(a$,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!bQ(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!J$(v.pointerType))return;let n=_1(S.current),r=g1(x.current,`open`,v.pointerType),i=$$(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(bQ(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Z$(t,i)){c=t;break}}bQ(o)&&bQ(s)&&!e.context.triggerElements.hasElement(o)&&Z$(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&bQ(c)&&bQ(s)&&Z$(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;if(h){D()&&e.setOpen(!0,t$(a$,t,c));return}m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,t$(a$,t,c))}):g&&D()&&e.setOpen(!0,t$(a$,t,c)))}function o(n){if(E()){A();return}k();let r=XQ(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!s1(n.relatedTarget,e.context.triggerElements)){if(b.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=b.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n);return}(v.pointerType!==`touch`||!Z$(e.select(`floatingElement`),n.relatedTarget))&&t(n)}}function l(e){Z$(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?b1(r,`mouseout`,l):void 0;return s?x1(b1(r,`mousemove`,i,{once:!0}),b1(r,`mouseenter`,i),b1(r,`mouseleave`,o),f):x1(b1(r,`mouseenter`,i),b1(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),K.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!J$(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;N4(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=_1(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,t$(a$,n,r))}v.pointerType===`touch`?n2.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function R4(e){return V$&&e.movementX===0&&e.movementY===0}function z4(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function B4(e,t){return z4(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function V4(e,t,n){return z4(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function H4(e,t,n){return z4(t,n?e===n1:e===r1,e===a1)}function U4(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:z4(t,n?e===r1:e===n1,e===i1)}function W4(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=m1(E),A=f1(D),j=S1(k),M=f2(),N=p2(x),P=K.useRef(f),F=K.useRef(o??-1),I=K.useRef(null),L=K.useRef(!0),R=UQ(e=>{i(F.current===-1?null:F.current,e)}),z=K.useRef(!!E),B=K.useRef(T),V=K.useRef(!1),H=K.useRef(!1),ee=K.useRef(null),te=S1(h),U=S1(T),W=S1(o),ne=S1(b),re=D1(),ie=D1(),ae=UQ(()=>{re.cancel();function e(e){d||(ee.current=z0(e,{sync:V.current,preventScroll:!0}))}let t=n.current[F.current],r=H.current;t&&e(t),(V.current?e=>e():e=>re.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),ue&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});KQ(()=>{O.current.orientation=g},[O,g]),KQ(()=>{T||(I.current=null),(!T||f!==`auto`)&&(P.current=f)},[T,f]),KQ(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(H.current=!0,R())):z.current&&(F.current=-1,R()))},[a,T,E,o,R]),KQ(()=>{if(a){if(!T){V.current=!1;return}if(E){if(r==null){if(V.current=!1,W.current!=null)return;if(z.current&&(F.current=-1,ae()),(!B.current||!z.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ie.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||V4(I.current,_,u)||l?a0(n):o0(n),I.current=null,R())};t()}}else i0(n.current,r)||(F.current=r,ae(),H.current=!1)}}},[a,T,E,r,W,l,n,_,u,R,ae,ie]),KQ(()=>{if(!a||E||!N||d||!z.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=X$(XQ(D??t??null)),r=e.some(e=>e.context&&Z$(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),KQ(()=>{B.current=T,z.current=!!E});let oe=r!=null,se=UQ(e=>{if(!U.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),G=UQ(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),ce=UQ(()=>a0(n,te.current)),le=UQ(t=>{if(L.current=!1,V.current=!0,t.which===229||!U.current&&t.currentTarget===j.current)return;if(l&&U4(t.key,g,u,w)){B4(t.key,G())||W$(t),e.setOpen(!1,t$(f$,t.nativeEvent));let n=S?.current??D;xQ(n)&&n.focus();return}r!=null&&r!==F.current&&!i0(n.current,r)&&(F.current=r);let i=F.current,a=a0(n,h),o=o0(n,h);if(A||(t.key===`Home`&&(W$(t),F.current=a,R(t)),t.key===`End`&&(W$(t),F.current=o,R(t))),C!=null){let e=C(t,F.current,n,g,c,u,h,a,o);if(e!=null&&e!==F.current&&(F.current=e,R(t)),g===`both`)return}if(B4(t.key,g)){W$(t);let e=X$(t.currentTarget.ownerDocument);if(T&&!d&&Z$(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Z$(t,e))){F.current=V4(t.key,g,u)?a:o,R(t),r===F.current&&ae();return}let{index:l,wrapped:f}=s0(n.current,i,{decrement:!V4(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(V.current=!1),F.current=l,R(t)}}),ue=K.useMemo(()=>({onFocus(e){V.current=!0,se(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){R4(e)||(V.current=!0,H.current=!1,p&&se(e))},onPointerLeave(e){if(!U.current||!L.current||e.pointerType===`touch`)return;V.current=!0;let t=e.relatedTarget;if(!(!p||n.current.includes(t))&&ne.current&&(ee.current?.(),ee.current=null,F.current=-1,R(e),!d)){let e=j.current,t=X$(XQ(e));e&&Z$(e,t)&&e.focus({preventScroll:!0})}}}),[se,U,j,p,n,R,ne,d]),de=K.useMemo(()=>d&&T&&oe&&{"aria-activedescendant":`${y}-${r}`},[d,T,oe,y,r]),fe=K.useMemo(()=>({...A?{}:de,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=$$(t.nativeEvent);if(n&&!Z$(j.current,n))return;W$(t);let r=t$(u$,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&xQ(i)&&i.focus();return}le(t)},onPointerMove(e){R4(e)||(L.current=!0)}}),[de,le,j,A,e,T,d,D,S]),pe=K.useMemo(()=>{function t(t){e.setOpen(!0,t$(f$,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&K$(e.nativeEvent)&&(P.current=!d)}function r(e){P.current=f,f===`auto`&&q$(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(n){let r=e.select(`open`);L.current=!1;let i=n.key.startsWith(`Arrow`),a=H4(n.key,G(),u),o=B4(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||u1(n.currentTarget)))return le(n);if(!(!r&&!m&&i)){if(s){let e=B4(n.key,G());I.current=l&&e?null:n.key}if(l){a&&(W$(n),r?(F.current=ce(),R(n),d&&j.current?.focus()):t(n));return}o&&(W.current!=null&&(F.current=W.current),W$(n),!r&&m?t(n):le(n),r&&R(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(F.current=-1,R(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[le,f,ce,l,R,e,m,g,_,G,u,W,d,j]),me=K.useMemo(()=>({...de,...pe}),[de,pe]);return K.useMemo(()=>a?{reference:me,floating:fe,item:ue,trigger:pe}:{},[a,me,fe,pe,ue])}function G4(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=UQ(s),f=e.useState(`open`),p=k$(),m=K.useRef(``),h=K.useRef(u??i??-1),g=K.useRef(null),_=UQ(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!d0(n)||n?.matches(`:disabled`)?!1:o==null||!l0(CZ,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(i)||!s(n)))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(W$(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(W$(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=UQ(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Z$(r,n)||Z$(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});KQ(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=K.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return K.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var K4=.1,q4=K4*K4,J4=.5;function Y4(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function X4(e,t,n,r,i,a,o,s,c,l){let u=!1;return Y4(e,t,n,r,i,a)&&(u=!u),Y4(e,t,i,a,o,s)&&(u=!u),Y4(e,t,o,s,c,l)&&(u=!u),Y4(e,t,c,l,n,r)&&(u=!u),u}function Z4(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Q4(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function $4(e={}){let{blockPointerEvents:t=!1}=e,n=new O$,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*q4;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=$$(r),g=r.type===`mouseleave`,_=Z$(u,h),v=Z$(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&bQ(r.relatedTarget)&&Z$(u,r.relatedTarget))return;function y(){return!!(s&&F0(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Q4(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Q4(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Q4(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Q4(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Z4(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?J4/2:J4*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+J4+1,o=C||T?S.bottom-J4:S.top,s=C?T?S.bottom-J4:S.top:S.bottom-J4;M=X4(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?J4/2:J4*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-J4,o=C||T?S.top+J4:S.bottom,s=C?T?S.top+J4:S.bottom:S.top+J4;M=X4(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?J4/2:J4*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+J4+1,o=w||E?S.right-J4:S.left,s=w?E?S.right-J4:S.left:S.right-J4;M=X4(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?J4/2:J4*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-J4,o=w||E?S.left+J4:S.right,s=w?E?S.left+J4:S.right:S.left+J4;M=X4(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function e3(e,t,n){let{reference:r,floating:i}=e,a=U1(t),o=W1(t),s=H1(o),c=z1(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=B1(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function t3(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=R1(t,e),p=n0(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=r0(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=r0(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var n3=50,r3=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:t3},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=e3(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<n3&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=e3(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},i3=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=R1(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=z1(r),_=U1(o),v=z1(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[e0(o)]:K1(o)),x=p!==`none`;!d&&x&&b.push(...$1(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=G1(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===U1(t)||T.every(e=>U1(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=U1(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},a3=new Set([`left`,`top`]);async function o3(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=z1(n),s=B1(n),c=U1(n)===`y`,l=a3.has(o)?-1:1,u=a&&c?-1:1,d=R1(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var s3=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await o3(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},c3=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=R1(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=U1(i),p=V1(f),m=u[p],h=u[f],g=(e,t)=>L1(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},l3=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=R1(e,t),u={x:n,y:r},d=U1(i),f=V1(d),p=u[f],m=u[d],h=R1(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=a3.has(z1(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},u3=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=R1(e,t),c=await i.detectOverflow(t,s),l=z1(n),u=B1(n),d=U1(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=j1(p-c[m],g),y=j1(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*M1(c.left,c.right):S=p-2*M1(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function d3(e){let t=PQ(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=xQ(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=N1(n)!==a||N1(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function f3(e){return bQ(e)?e:e.contextElement}function p3(e){let t=f3(e);if(!xQ(t))return F1(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=d3(t),o=(a?N1(n.width):n.width)/r,s=(a?N1(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var m3=F1(0);function h3(e){let t=_Q(e);return!MQ()||!t.visualViewport?m3:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function g3(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===_Q(e)}function _3(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=f3(e),o=F1(1);t&&(r?bQ(r)&&(o=p3(r)):o=p3(e));let s=g3(a,n,r)?h3(a):F1(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=_Q(a),t=bQ(r)?_Q(r):r,n=e,i=zQ(n);for(;i&&t!==n;){let e=p3(i),t=i.getBoundingClientRect(),r=PQ(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=_Q(i),i=zQ(n)}}return r0({width:u,height:d,x:c,y:l})}function v3(e,t){let n=FQ(e).scrollLeft;return t?t.left+n:_3(vQ(e)).left+n}function y3(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-v3(e,n),y:n.top+t.scrollTop}}function b3(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=vQ(r),s=t?TQ(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=F1(1),u=F1(0),d=xQ(r);if((d||!a)&&((gQ(r)!==`body`||CQ(o))&&(c=FQ(r)),d)){let e=_3(r);l=p3(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?y3(o,c):F1(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function x3(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function S3(e){let t=FQ(e),n=e.ownerDocument.body,r=M1(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=M1(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+v3(e),o=-t.scrollTop;return PQ(n).direction===`rtl`&&(a+=M1(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var C3=25;function w3(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=_Q(e),a=vQ(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!MQ()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(v3(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=C3&&(s-=o)}return{width:s,height:c,x:l,y:u}}function T3(e,t){let n=_3(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=p3(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function E3(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=w3(e,n,t);else if(t===`document`)r=S3(vQ(e));else if(bQ(t))r=T3(t,n);else{let n=h3(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return r0(r)}function D3(e,t){let n=t.get(e);if(n)return n;let r=RQ(e,[],!1).filter(e=>bQ(e)&&gQ(e)!==`body`),i=null,a=PQ(e).position===`fixed`,o=a?IQ(e):e;for(;bQ(o)&&!NQ(o);){let e=PQ(o),t=AQ(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=IQ(o)}return t.set(e,r),r}function O3(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?TQ(t)?[]:D3(t,this._c):[].concat(n),r],o=E3(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=E3(t,a[e],i);s=M1(n.top,s),c=j1(n.right,c),l=j1(n.bottom,l),u=M1(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function k3(e){let{width:t,height:n}=d3(e);return{width:t,height:n}}function A3(e,t,n){let r=xQ(t),i=vQ(t),a=n===`fixed`,o=_3(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=F1(0);if((r||!a)&&((gQ(t)!==`body`||CQ(i))&&(s=FQ(t)),r)){let e=_3(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=v3(i));let l=i&&!r&&!a?y3(i,s):F1(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function j3(e){return PQ(e).position===`static`}function M3(e,t){if(!xQ(e)||PQ(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return vQ(e)===n&&(n=n.ownerDocument.body),n}function N3(e,t){let n=_Q(e);if(TQ(e))return n;if(!xQ(e)){let t=IQ(e);for(;t&&!NQ(t);){if(bQ(t)&&!j3(t))return t;t=IQ(t)}return n}let r=M3(e,t);for(;r&&wQ(r)&&j3(r);)r=M3(r,t);return r&&NQ(r)&&j3(r)&&!AQ(r)?n:r||jQ(e)||n}var P3=async function(e){let t=this.getOffsetParent||N3,n=this.getDimensions,r=await n(e.floating);return{reference:A3(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function F3(e){return PQ(e).direction===`rtl`}var I3={convertOffsetParentRelativeRectToViewportRelativeRect:b3,getDocumentElement:vQ,getClippingRect:O3,getOffsetParent:N3,getElementRects:P3,getClientRects:x3,getDimensions:k3,getScale:p3,isElement:bQ,isRTL:F3};function L3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function R3(e,t,n){let r=null,i,a=vQ(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=P1(d),h=P1(a.clientWidth-(u+f)),g=P1(a.clientHeight-(d+p)),_=P1(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:M1(0,j1(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!L3(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=_Q(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function z3(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=f3(e),u=i||a?[...l?RQ(l):[],...t?RQ(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?R3(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?_3(e):null;c&&g();function g(){let t=_3(e);h&&!L3(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var B3=s3,V3=c3,H3=i3,U3=u3,W3=l3,G3=(e,t,n)=>{let r=new Map,i=n??{},a={...I3,...i.platform,_c:r};return r3(e,t,{...i,platform:a})},K3=typeof document<`u`?K.useLayoutEffect:function(){};function q3(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!q3(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!q3(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function J3(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Y3(e,t){let n=J3(e);return Math.round(t*n)/n}function X3(e){let t=K.useRef(e);return K3(()=>{t.current=e}),t}function Z3(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=K.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=K.useState(r);q3(f,r)||p(r);let[m,h]=K.useState(null),[g,_]=K.useState(null),v=K.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=K.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=K.useRef(null),C=K.useRef(null),w=K.useRef(u),T=c!=null,E=X3(c),D=X3(i),O=X3(l),k=K.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),G3(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!q3(w.current,t)&&(w.current=t,n2.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);K3(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=K.useRef(!1);K3(()=>(A.current=!0,()=>{A.current=!1}),[]),K3(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=K.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=K.useMemo(()=>({reference:b,floating:x}),[b,x]),N=K.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Y3(M.floating,u.x),r=Y3(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...J3(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return K.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Q3=(e,t)=>{let n=B3(e);return{name:n.name,fn:n.fn,options:[e,t]}},$3=(e,t)=>{let n=V3(e);return{name:n.name,fn:n.fn,options:[e,t]}},e6=(e,t)=>({fn:W3(e).fn,options:[e,t]}),t6=(e,t)=>{let n=H3(e);return{name:n.name,fn:n.fn,options:[e,t]}},n6=(e,t)=>{let n=U3(e);return{name:n.name,fn:n.fn,options:[e,t]}},r6=K.createContext(void 0);function i6(){let e=K.useContext(r6);if(e===void 0)throw Error(sZ(26));return e}var a6=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),o6=`--nested-dialogs`,s6=`data-nested-dialog-open`,c6={...fQ,...$Z,nestedDialogOpen(e){return e?{[s6]:``}:null}},l6=K.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=lZ(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);i6(),I2({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?z2(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=HZ(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...R2,hidden:!m,onKeyDown(e){a6.has(e.key)&&e.stopPropagation()},style:{[o6]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:c6});return(0,X.jsx)(E2,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function u6(e){return yZ(19)?e:e?`true`:void 0}var d6=K.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,X.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),f6=K.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=lZ(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,X.jsx)(r6.Provider,{value:n,children:(0,X.jsxs)(s2,{ref:t,...r,children:[a&&o===!0&&(0,X.jsx)(d6,{ref:i.context.internalBackdropRef,inert:u6(!s)}),e.children]})}):null}),p6={},m6={},h6=``;function g6(e,t){return CQ(e)?e:t}function _6(e,t,n){return/hidden|clip/.test(e.getComputedStyle(g6(t,n)).overflowY)}function Hie(e){if(typeof document>`u`)return!1;let t=XQ(e);return _Q(t).innerWidth-t.documentElement.clientWidth>0}function Uie(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=XQ(e),n=t.documentElement,r=t.body,i=g6(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function Wie(e){let t=XQ(e),n=t.documentElement,r=t.body,i=g6(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function Gie(e){let t=XQ(e),n=t.documentElement,r=t.body,i=_Q(n),a=0,o=0,s=!1,c=E1.create();if(V$&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,p6={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},h6=n.style.scrollBehavior,m6={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=g6(n,r);if(s=Uie(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,p6),Object.assign(r.style,m6),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=h6)}function d(){u(),c.request(l)}l();let f=b1(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var Kie=new class{lockCount=0;restore=null;timeoutLock=O$.create();timeoutUnlock=O$.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=XQ(e),n=t.documentElement,r=t.body,i=_Q(n);if(_6(i,n,r)){let t=new i.MutationObserver(()=>{_6(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=I$||!Hie(e);this.restore=a?Wie(e):Gie(e)}};function v6(e=!0,t=null){KQ(()=>{if(e)return Kie.acquire(t)},[e,t])}function qie({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=K.useState(0),[d,f]=K.useState(0),p=l===0,m=k2(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=$$(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Z$(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return v6(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{!e.select(`open`)&&!e.select(`mounted`)||(u(t),f(n))}),KQ(()=>{!r&&!i&&(u(0),f(0))},[r,i]),KQ(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),Y2(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var Jie={...E4,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Yie=class extends _4{constructor(e,t,n){let r=new Z2,i=Xie(e,r,t,n);super(i,Zie(r),Jie)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(W2(this.state,e,t.trigger)))}};function Xie(e,t,n,r=!1){return{...b4(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function Zie(e){return{popupRef:K.createRef(),backdropRef:K.createRef(),internalBackdropRef:K.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Qie(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=lZ(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=B2((e,t)=>new Yie({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);X2(b,x),q2(b);let{forceUnmount:w}=J2(x,b);K.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,t$(_$))}),[w,b]);let T=x||S||u!=null;return(0,X.jsxs)(cZ.Provider,{value:b,children:[u&&(0,X.jsx)(V2,{handle:u,store:b}),T&&(0,X.jsx)(qie,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var $ie=o4(function(e){return Qie(`dialog`,e)}),eae=K.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=lZ(),c=w$(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),HZ(`h2`,e,{ref:t,props:[{id:c},o]})});function tae(e){let t=K.useRef(``),n=K.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:K.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function nae(e,t){let n=K.useRef(e),r=UQ(t);KQ(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function y6(e,t){let{onClick:n,onPointerDown:r}=tae(UQ((n,r)=>{(typeof e==`function`?e():e)||t(r||(I$?`touch`:``))}));return K.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function rae(e){let[t,n]=K.useState(null),r=y6(e,n);return nae(e,t=>{t&&!e&&n(null)}),K.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var iae=s4(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=lZ(!0),f=D4(l)??d;if(!f)throw Error(sZ(79));let p=w$(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=K.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=K2(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=QQ({disabled:a,native:o}),S=D2(m),C=y6(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return HZ(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[Q0]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:uQ})}),aae=(0,K.createContext)(void 0),oae=(0,K.createContext)(null);function b6(e){let t=(0,K.useContext)(oae);return t===null?Object.hasOwn(globalThis,`document`)?document.body:null:t[e]}function x6(e){let t=(0,K.useContext)(aae),n=(0,K.useRef)(e);n.current=e,(0,K.useEffect)(()=>t?.(()=>{n.current()}),[t])}var S6=(0,K.createContext)(null);function C6({children:e,interactionOwner:t=`local`,modal:n=!0,onOpenChange:r,...i}){return(0,X.jsx)(S6.Provider,{value:{interactionOwner:t,modal:n},children:(0,X.jsx)($ie,{...i,modal:n,onOpenChange:(e,n)=>{if(t===`host`&&!e&&n.reason===`escape-key`){n.cancel(),n.allowPropagation();return}r?.(e,n)},children:e})})}function w6(){let e=(0,K.useContext)(S6);if(!e)throw Error(`Dialog parts must be used inside <Dialog>`);return e}(0,K.forwardRef)(function({className:e,type:t=`button`,...n},r){return(0,X.jsx)(iae,{...n,className:t=>Z(`btn`,uP(e,t)),ref:r,type:t})});var T6=(0,K.forwardRef)(function({container:e,...t},n){let r=b6(`dialog`);return e==null&&r===null?null:(0,X.jsx)(f6,{...t,container:e??r,ref:n})}),E6=(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(mQ,{...t,ref:n,className:t=>Z(`caps-dialog-backdrop fixed inset-0 bg-black/40`,uP(e,t))})}),D6=(0,K.forwardRef)(function({className:e,finalFocus:t,size:n=`default`,...r},i){let a=w6();return(0,X.jsx)(l6,{...r,"data-size":n,className:t=>Z(`caps-dialog-popup overflow-y-auto overscroll-contain rounded-box bg-base-100 p-lg text-base-content shadow-xl`,n===`fill`?`fixed inset-0 h-full w-full max-w-none`:`max-h-screen w-11/12 max-w-(--container-lg)`,uP(e,t)),finalFocus:a.interactionOwner===`host`?!1:t??!0,ref:i})}),O6=(0,K.forwardRef)(function({container:e,keepMounted:t=!0,className:n,size:r=`default`,...i},a){let{modal:o}=w6();return(0,X.jsxs)(T6,{container:e,keepMounted:t,children:[o===!0?(0,X.jsx)(E6,{}):null,(0,X.jsx)(D6,{...i,size:r,className:e=>Z(r==="default"&&`fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,uP(n,e)),ref:a})]})});function k6({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Z(`flex justify-end gap-sm`,e)})}function A6({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Z(`flex flex-col gap-sm`,e)})}var j6=(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(eae,{...t,className:t=>Z(`text-lg font-semibold`,uP(e,t)),ref:n})});(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(T$,{...t,className:t=>Z(`text-sm text-base-content`,uP(e,t)),ref:n})});var M6=(0,K.forwardRef)(function({className:e,type:t=`button`,...n},r){return(0,X.jsx)(v$,{...n,className:t=>Z(`btn btn-ghost`,uP(e,t)),ref:r,type:t})}),sae={queued:`Waiting to start`,generating:`Generating`,refining:`Refining`,done:void 0,failed:void 0},N6=(0,K.forwardRef)(function({status:e,children:t,aspectRatio:n,label:r,indicator:i,failure:a,className:o,style:s,...c},l){let u=(0,K.useRef)(null);(0,K.useImperativeHandle)(l,()=>u.current);let d=(0,K.useRef)(e),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(e);m!==e&&(h(e),p(e===`done`)),(0,K.useLayoutEffect)(()=>{let t=u.current,n=d.current;if(d.current=e,!t||n===e)return;if(!kP(t)){p(!1);return}let r=TP(t),i=OP(r,r.ease),a=[],o=t.querySelector(`:scope > [data-layer="media"]`),s=t.querySelector(`:scope > [data-layer="placeholder"]`),c=t.querySelector(`:scope > [data-layer="failure"]`);if(e===`done`&&o){let e=o.animate(r.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,filter:`blur(10px)`,transform:`scale(1.03)`},{opacity:1,filter:`blur(0px)`,transform:`none`}],{duration:r.reduced?r.fast:r.slow*2,easing:i,fill:`backwards`});e.addEventListener(`finish`,()=>{p(!1)}),a.push(e),s&&a.push(s.animate([{opacity:1},{opacity:0}],{duration:r.reduced?r.fast:r.slow,easing:i,fill:`forwards`}))}return e===`failed`&&c&&a.push(c.animate([{opacity:0,transform:`translateY(${String(r.distance)}px)`},{opacity:1,transform:`none`}],{duration:r.normal,easing:i})),n===`failed`&&s&&a.push(s.animate([{opacity:.4},{opacity:1}],{duration:r.normal,easing:i})),()=>{for(let e of a)e.cancel()}},[e]);let g=e===`queued`||e===`generating`||e===`refining`,_=r??sae[e],v=e===`done`||e===`refining`;return(0,X.jsxs)(`div`,{...c,ref:u,className:Z(`caps-generation-frame`,o),"data-status":e,"data-aspect":n===void 0?void 0:``,"aria-busy":g,style:n===void 0?s:{aspectRatio:n,...s},children:[e===`done`&&!f?null:(0,X.jsxs)(`div`,{className:Z(`caps-generation-placeholder`,e===`queued`&&`skeleton`),"data-layer":`placeholder`,role:e===`done`?void 0:`status`,"aria-hidden":e===`done`||void 0,children:[e===`generating`||e===`refining`||e===`done`?i??(0,X.jsx)(JI,{decorative:!0,size:`lg`,variant:`bloom`}):null,_===void 0?null:(0,X.jsx)(MP,{children:_})]}),v?(0,X.jsx)(`div`,{className:`caps-generation-media`,"data-layer":`media`,children:t}):null,e===`failed`&&a!==void 0?(0,X.jsx)(`div`,{className:`caps-generation-failure`,"data-layer":`failure`,role:`alert`,children:a}):null]})}),P6=K.createContext(void 0);function F6(){let e=K.useContext(P6);if(e===void 0)throw Error(sZ(53));return e}function I6(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var L6=`base-ui-disable-scrollbar`,R6={className:L6,getElement(e){return(0,X.jsx)(`style`,{nonce:e,href:L6,precedence:`base-ui:low`,children:`.${L6}{scrollbar-width:none}.${L6}::-webkit-scrollbar{display:none}`})}},cae=`data-has-overflow-x`,lae=`data-has-overflow-y`,uae=`data-overflow-x-start`,dae=`data-overflow-x-end`,fae=`data-overflow-y-start`,pae=`data-overflow-y-end`,z6=e=>t=>t?{[e]:``}:null,B6={hasOverflowX:z6(cae),hasOverflowY:z6(lae),overflowXStart:z6(uae),overflowXEnd:z6(dae),overflowYStart:z6(fae),overflowYEnd:z6(pae),cornerHidden:()=>null},mae=K.createContext(void 0),hae={disableStyleElements:!1};function gae(){return K.useContext(mae)??hae}var V6=`--scroll-area-corner-height`,H6=`--scroll-area-corner-width`,_ae=`data-orientation`,vae={x:0,y:0},U6={width:0,height:0},yae={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},bae={x:!0,y:!0,corner:!0},xae=K.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=Sae(i),d=w$(),f=k$(),p=k$(),{nonce:m,disableStyleElements:h}=gae(),[g,_]=K.useState(!1),[v,y]=K.useState(!1),[b,x]=K.useState(!1),[S,C]=K.useState(!1),[w,T]=K.useState(!1),[E,D]=K.useState(U6),[O,k]=K.useState(U6),[A,j]=K.useState(yae),[M,N]=K.useState(bae),P=K.useRef(null),F=K.useRef(null),I=K.useRef(null),L=K.useRef(null),R=K.useRef(null),z=K.useRef(null),B=K.useRef(null),V=K.useRef(null),H=K.useRef(0),ee=K.useRef(0),te=K.useRef(0),U=K.useRef(0),W=K.useRef(`vertical`),ne=K.useRef(vae),re=K.useRef(null);function ie(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let ae=UQ(e=>{let t=e.x-ne.current.x,n=e.y-ne.current.y;ne.current=e,n!==0&&ie(!0),t!==0&&ie(!1)}),oe=UQ(()=>{let e=F.current;e&&re.current===null&&(re.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),se=UQ(e=>{if(e.button!==0||V.current!==null&&(W.current===`vertical`?R.current:z.current)?.hasPointerCapture(V.current))return;V.current=e.pointerId,H.current=e.clientY,ee.current=e.clientX,W.current=e.currentTarget.getAttribute(_ae);let t=F.current;t&&(te.current=t.scrollTop,U.current=t.scrollLeft,oe()),(W.current===`vertical`?R.current:z.current)?.setPointerCapture(e.pointerId)}),G=UQ(e=>{if(e.pointerId!==V.current)return;V.current=null,(W.current===`vertical`?x:y)(!1),re.current!==null&&(F.current&&(F.current.style.scrollSnapType=re.current),re.current=null);let t=W.current===`vertical`?R.current:z.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),ce=UQ(e=>{if(e.pointerId!==V.current)return;if(e.buttons%2==0){G(e);return}let t=F.current;if(!t)return;let n=W.current===`vertical`,r=n?R.current:z.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=I6(i,`padding`,a),s=I6(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-H.current:e.clientX-ee.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?te.current:U.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ie(n)});function le(e){C(e.pointerType===`touch`)}function ue(e){if(le(e),e.pointerType!==`touch`){let t=Z$(P.current,e.target);_(t)}}let de=K.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),fe={role:`presentation`,onPointerEnter:ue,onPointerMove:ue,onPointerDown:le,onPointerLeave(){_(!1)},style:{position:`relative`,[V6]:`${E.height}px`,[H6]:`${E.width}px`}},pe=HZ(`div`,e,{state:de,ref:[t,P],props:[fe,o],stateAttributesMapping:B6}),me=K.useMemo(()=>({handlePointerDown:se,handlePointerMove:ce,handlePointerUp:G,handleScroll:ae,disableViewportSnap:oe,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:B,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:z,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:de,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[se,ce,G,ae,oe,E,O,w,S,v,b,g,d,M,A,de,s,c,l,u]);return(0,X.jsxs)(P6.Provider,{value:me,children:[!h&&R6.getElement(m),pe]})});function Sae(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}function W6(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var G6=K.createContext(void 0);function Cae(){let e=K.useContext(G6);if(e===void 0)throw Error(sZ(55));return e}var wae=K.createContext(void 0);function K6(){return K.useContext(wae)?.direction??`ltr`}function q6(e,t){if(t<=0)return 0;let n=W6(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var Tae=`--scroll-area-overflow-x-start`,Eae=`--scroll-area-overflow-x-end`,Dae=`--scroll-area-overflow-y-start`,Oae=`--scroll-area-overflow-y-end`,J6=`--scroll-area-thumb-height`,Y6=`--scroll-area-thumb-width`,X6=[Tae,Eae,Dae,Oae],Z6=!1;function kae(){Z6||V$||(typeof CSS<`u`&&`registerProperty`in CSS&&X6.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),Z6=!0)}var Aae=K.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=F6(),T=K6(),E=K.useRef(!0),D=K.useRef([NaN,NaN,NaN,NaN]),O=k$(),k=k$(),A=UQ(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=jae(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=q6(T===`rtl`?-w:w,P),L=P-I);let R=A?0:q6(x,F),z=A?0:F-R,B=j?0:b,V=A?0:y,H=0,ee=0;!j&&!A&&(H=t?.offsetWidth||0,ee=n?.offsetHeight||0);let te=f.width===0&&f.height===0,U=te?H:0,W=te?ee:0,ne=I6(n,`padding`,`x`),re=I6(t,`padding`,`y`),ie=I6(i,`margin`,`x`),ae=I6(r,`margin`,`y`),oe=B-ne-ie,se=V-re-ae,G=n?Math.min(n.offsetWidth-U,oe):oe,ce=t?Math.min(t.offsetHeight-W,se):se,le=Math.max(16,G*M),ue=Math.max(16,ce*N);if(m(e=>Q6(e,{width:le,height:ue})),t&&r){let e=$6(r,J6,x,F,h,ue,t.offsetHeight-ue-re-ae);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-le-ne-ie,t=$6(i,Y6,T===`rtl`?-w:w,P,_,le,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let de=[I,L,R,z];X6.forEach((t,n)=>{e.style.setProperty(t,`${de[n]}px`)}),a&&p(e=>Q6(e,{width:H,height:ee})),g(e=>Q6(e,k));let fe={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&z>C.yEnd};S(e=>Q6(e,fe))});KQ(()=>{kae()},[]),KQ(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),KQ(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),KQ(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=M2(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(SZ))).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:R6.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=HZ(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:B6}),P=K.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,X.jsx)(G6.Provider,{value:P,children:N})});function jae(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function Q6(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function $6(e,t,n,r,i,a,o){let s=W6(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var e8=K.createContext(void 0);function Mae(){let e=K.useContext(e8);if(e===void 0)throw Error(sZ(54));return e}var Nae=K.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=F6(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=K6(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;K.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return b1(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=$$(e.nativeEvent),n=T?h.current:g.current;if(n&&Z$(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=I6(n,`margin`,a),s=I6(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${V6})`,insetInlineEnd:0,[J6]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${H6})`,bottom:0,[Y6]:`${S.width}px`}}},M=HZ(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:B6});return A?(0,X.jsx)(e8.Provider,{value:i,children:M}):null}),Pae=K.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{computeThumbPosition:o}=Cae(),{hasMeasuredScrollbar:s,viewportState:c}=F6(),l=K.useRef(null),u=K.useRef(s);return KQ(()=>{if(typeof ResizeObserver>`u`)return;let e=!1,t=new ResizeObserver(()=>{!e&&(e=!0,!u.current)||o()});return l.current&&t.observe(l.current),()=>{t.disconnect()}},[o]),HZ(`div`,e,{ref:[t,l],state:c,stateAttributesMapping:B6,props:[{role:`presentation`,style:{minWidth:`fit-content`}},a]})}),Fae=K.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=F6(),m=Mae(),h=m===`vertical`;return HZ(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),t8=Object.freeze({ease:`linear`,duration:0});function n8(e,t){let n=ore(e,t.duration);return n<=0?t8:e.steps>0?{ease:RI(e.steps),duration:n}:{ease:LI({bounce:are(e,t.bounce),duration:n}),duration:n}}function r8(e,t){let n=DP(e,t.duration);return{ease:e.steps>0?RI(e.steps):t.ease,duration:n}}function Iae(e,t,n){let r=(Math.abs(t)-Math.abs(e))/Math.max(16,n);if(Math.abs(r)<.035)return null;let i=Math.min(.04,Math.abs(r)*.3),a=r>0,o=Math.sign(t||e);return{scaleY:1+(a?i:-i),scaleX:1+(a?-i/2:i/2),origin:(a?o>0:o<0)?`center top`:`center bottom`}}function Lae(e,t,n){if(t<=0||Math.abs(n)<4)return null;let r=e<=0&&n<0,i=e>=t-1&&n>0;if(!r&&!i)return null;let a=Math.min(.06,Math.abs(n)/120*.06);return{scaleY:1-a,scaleX:1+a/2,origin:r?`center top`:`center bottom`}}var i8=(0,K.forwardRef)(function({children:e,className:t,surface:n=!1,surfaceSize:r,surfaceDepth:i,screen:a=!1,...o},s){let c=(0,K.useRef)(null),l=(0,K.useRef)(null),u=jP();(0,K.useEffect)(()=>{let e=c.current,t=e?.querySelector(`.caps-scroll-viewport`);if(!t||!e)return;let n=null,r,i=t.scrollTop,a=performance.now(),o=0,s=e=>{let t=l.current;if(!e||u||!t)return;n?.cancel(),t.style.transformOrigin=e.origin;let r=TP(t),i=r8(r,{ease:`outQuad`,duration:45}),a=n8(r,{bounce:.18,duration:180});n=FI(t,{scaleY:[{to:e.scaleY,...i},{to:1,...a}],scaleX:[{to:e.scaleX,...i},{to:1,...a}]})},d=(e,t)=>{let n=Iae(o,e,t);o=e,s(n)},f=e=>{if(e.ctrlKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;let n=e.deltaMode===1?16:e.deltaMode===2?t.clientHeight:1,i=Lae(t.scrollTop,t.scrollHeight-t.clientHeight,e.deltaY*n);i&&(clearTimeout(r),o=0,s(i))},p=()=>{let e=performance.now(),n=e-a,s=n>100?16:Math.max(16,n),c=t.scrollTop-i;n>100&&(o=0),d(c/s,s),i=t.scrollTop,a=e,clearTimeout(r),r=setTimeout(()=>{d(0,32)},64)};return t.addEventListener(`scroll`,p,{passive:!0}),e.addEventListener(`wheel`,f,{passive:!0}),()=>{clearTimeout(r),n?.cancel(),l.current&&(l.current.style.transform=`none`),t.removeEventListener(`scroll`,p),e.removeEventListener(`wheel`,f)}},[a,n,u]);let d=(0,X.jsx)(Aae,{render:a?(0,X.jsx)(eL,{}):(0,X.jsx)(`div`,{}),...o,ref:s,className:`caps-scroll-viewport`,children:(0,X.jsx)(Pae,{style:{minWidth:0},children:e})});return(0,X.jsxs)(xae,{render:n?(0,X.jsx)($I,{size:r??`md`,depth:i??`shallow`}):(0,X.jsx)(`div`,{}),ref:c,className:Z(`caps-scroll-area`,t),children:[a?(0,X.jsx)(`div`,{className:`caps-display-gasket caps-scroll-display`,children:d}):d,(0,X.jsx)($I,{size:`sm`,depth:`deep`,placement:`embedded`,className:`caps-scroll-track-surface`,children:(0,X.jsx)(Nae,{className:`caps-scroll-track`,children:(0,X.jsx)(Fae,{className:`caps-scroll-thumb`,children:(0,X.jsx)(`span`,{className:`caps-scroll-thumb-surface`,ref:l})})})})]})}),a8={dot:{y:-4,height:8,cy:0},pill:{y:-16,height:32,cy:0},bang:{y:-16,height:20,cy:12}};function Rae({className:e,glyph:t,motion:n}){let r=`caps-status-${(0,K.useId)().replaceAll(`:`,``)}`,i=(0,K.useRef)(null),a=(0,K.useRef)(null),o=(0,K.useRef)(null),s=(0,K.useRef)(null),c=(0,K.useRef)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(a8[t]).current,d=(0,K.useRef)(t===`dot`?1:4).current,f=(0,K.useRef)(+(t===`bang`)).current,p=(0,K.useRef)(t),m=EP(s),{reduced:h}=m;return(0,K.useLayoutEffect)(()=>{if(!i.current||!a.current||!c.current||!l.current)return;let e=a8[t],n=h||p.current===t;p.current=t;let r=TP(i.current),o=n?{duration:0}:n8(r,{bounce:.3,duration:360}),s=FI(i.current,{y:e.y,height:e.height,...o}),u=FI(a.current,{cy:e.cy,...n?{duration:0}:{delay:DP(r,35),...n8(r,{bounce:.3,duration:420})}}),d=FI(c.current,{gradientTransform:`matrix(1 0 0 ${t===`dot`?`1`:`4`} 0 0)`,...o}),f=FI(l.current,{opacity:+(t===`bang`),...n?t8:r8(r,{ease:`inOutSine`,duration:220})});return()=>{s.cancel(),u.cancel(),d.cancel(),f.cancel()}},[t,h]),(0,K.useLayoutEffect)(()=>{if(!o.current||!s.current||h||n===`none`)return;let e=n===`pulse`?FI(o.current,{opacity:[1,.45],...r8(m,{ease:`inOutSine`,duration:750}),alternate:!0,loop:!0}):FI(o.current,{keyframes:{"0%":{translateY:0,scaleX:1,scaleY:1},"18%":{translateY:.25,scaleX:1.1,scaleY:.91},"42%":{translateY:-1.3,scaleX:.94,scaleY:1.06},"62%":{translateY:-1.65,scaleX:1,scaleY:1},"82%":{translateY:.15,scaleX:1.06,scaleY:.95},"100%":{translateY:0,scaleX:1,scaleY:1}},...r8(m,{ease:`inOutSine`,duration:1e3}),loop:!0}),t=WI(s.current,t=>{t?e.resume():e.pause()});return()=>{t(),e.revert()}},[n,h,m]),(0,X.jsxs)(`svg`,{ref:s,"aria-hidden":`true`,className:`caps-status-bead ${e??``}`,width:`8`,height:`8`,viewBox:`-4 -4 8 8`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(UI,{id:r,values:HI}),(0,X.jsx)(zI,{ref:c,id:`${r}-surface`,transform:`matrix(1 0 0 ${String(d)} 0 0)`}),(0,X.jsxs)(`radialGradient`,{id:`${r}-drop-light`,gradientUnits:`userSpaceOnUse`,cx:`-1.2`,cy:`10.4`,r:`5.6`,children:[(0,X.jsx)(`stop`,{offset:`0`,stopColor:`var(--color-white)`,style:{stopOpacity:`calc(var(--depth) * 0.5)`}}),(0,X.jsx)(`stop`,{offset:`1`,stopColor:`var(--color-white)`,stopOpacity:`0`})]}),(0,X.jsx)(BI,{id:`${r}-shadow`}),(0,X.jsx)(`mask`,{id:`${r}-silhouette`,maskUnits:`userSpaceOnUse`,x:`-12`,y:`-24`,width:`24`,height:`48`,style:{maskType:`alpha`},children:(0,X.jsxs)(`g`,{fill:`var(--color-white)`,filter:`url(#${r})`,children:[(0,X.jsx)(`rect`,{ref:i,x:`-4`,y:u.y,width:`8`,height:u.height,rx:`4`}),(0,X.jsx)(`circle`,{ref:a,cx:`0`,cy:u.cy,r:`4`})]})})]}),(0,X.jsx)(`g`,{ref:o,filter:`url(#${r}-shadow)`,children:(0,X.jsxs)(`g`,{mask:`url(#${r}-silhouette)`,children:[(0,X.jsx)(`rect`,{x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-surface)`}),(0,X.jsx)(`rect`,{ref:l,x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-drop-light)`,opacity:f})]})})]})}var zae=.28;function o8(e,t){switch(e){case`ring`:return{dashes:1,track:0,arc:0,sweep:0,disc:0,tick:0,cross:0};case`arc`:return{dashes:0,track:1,arc:1,sweep:t===void 0?zae:Math.min(1,Math.max(0,t)),disc:0,tick:0,cross:0};case`check`:return{dashes:0,track:0,arc:1,sweep:1,disc:1,tick:1,cross:0};case`cross`:return{dashes:0,track:0,arc:1,sweep:1,disc:1,tick:0,cross:1}}}var s8=7.25;function Bae({className:e,glyph:t,progress:n}){let r=`caps-status-mark-${(0,K.useId)().replaceAll(`:`,``)}`,i=(0,K.useRef)(null),a=(0,K.useRef)(null),o=(0,K.useRef)(null),s=(0,K.useRef)(null),c=(0,K.useRef)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=(0,K.useRef)(o8(t,n)).current,p=(0,K.useRef)(t),m=jP();(0,K.useLayoutEffect)(()=>{let e=i.current,r=a.current,c=o.current,f=s.current,h=l.current,g=u.current,_=d.current;if(!e||!r||!c||!f||!h||!g||!_)return;let v=o8(t,n),y=p.current;p.current=t;let b=TP(e),x=m||y===t&&t!==`arc`,S=x?m?{ease:b.ease,duration:b.fast}:t8:r8(b,{ease:`outQuad`,duration:160}),C=(t===`check`||t===`cross`)&&!x,w=r8(b,{ease:`inOutSine`,duration:220}),T=[FI(r,{opacity:v.dashes,...S}),FI(c,{opacity:v.track*.28,...S}),FI(f,{opacity:v.arc,"stroke-dasharray":`${String(v.sweep)} 1`,...x?m?t8:S:w}),FI(h,{r:v.disc*s8,...C?{delay:w.duration*.7,...n8(b,{bounce:.35,duration:360})}:m?t8:r8(b,{ease:`inCubic`,duration:140})}),FI(g,{"stroke-dashoffset":1-v.tick,...C&&v.tick>0?{delay:w.duration*.7+b.fast,...r8(b,{ease:`outCubic`,duration:240})}:t8}),FI(_,{"stroke-dashoffset":1-v.cross,...C&&v.cross>0?{delay:w.duration*.7+b.fast,...r8(b,{ease:`outCubic`,duration:240})}:t8})];return t===`cross`&&C&&b.shake>0&&T.push(FI(e,{translateX:[0,-b.shake,b.shake,-b.shake/2,0],delay:w.duration+b.fast,...r8(b,{ease:`linear`,duration:300})})),()=>{for(let e of T)e.cancel()}},[t,n,m]);let h=t===`arc`&&n===void 0&&!m;return(0,K.useLayoutEffect)(()=>{if(!h||!c.current||!i.current)return;let e=TP(i.current),t=FI(c.current,{rotate:[0,360],...r8(e,{ease:`linear`,duration:900}),loop:!0}),n=WI(i.current,e=>{e?t.resume():t.pause()});return()=>{n(),t.revert()}},[h]),(0,X.jsxs)(`svg`,{ref:i,"aria-hidden":`true`,className:`caps-status-mark ${e??``}`,viewBox:`0 0 16 16`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(zI,{id:`${r}-surface`,transform:`matrix(1.6 0 0 1.6 8 8)`}),(0,X.jsxs)(`mask`,{id:`${r}-knock`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`16`,height:`16`,children:[(0,X.jsx)(`rect`,{width:`16`,height:`16`,fill:`var(--color-white)`}),(0,X.jsx)(`path`,{ref:u,d:`M4.9 8.3 7.1 10.5 11.2 5.9`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-f.tick}),(0,X.jsx)(`path`,{ref:d,d:`M5.4 5.4 10.6 10.6 M10.6 5.4 5.4 10.6`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-f.cross})]})]}),(0,X.jsx)(`circle`,{ref:a,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`1.7 2.2`,opacity:f.dashes}),(0,X.jsx)(`circle`,{ref:o,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:f.track*.28}),(0,X.jsx)(`g`,{ref:c,className:`caps-status-mark-spin`,children:(0,X.jsx)(`circle`,{ref:s,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`${String(f.sweep)} 1`,transform:`rotate(-90 8 8)`,opacity:f.arc})}),(0,X.jsx)(`circle`,{ref:l,cx:`8`,cy:`8`,r:f.disc*s8,fill:`url(#${r}-surface)`,mask:`url(#${r}-knock)`})]})}var Vae=new Set([`ring`,`arc`,`check`,`cross`]);function Hae(e){return Vae.has(e)}var c8={neutral:`text-base-content`,primary:`text-primary`,secondary:`text-secondary`,accent:`text-accent`,success:`text-success`,info:`text-info`,warning:`text-warning`,error:`text-error`},l8=(0,K.forwardRef)(function({className:e,label:t,glyph:n=`dot`,motion:r=`none`,tone:i=`neutral`,size:a=`default`,appearance:o=`plain`,progress:s,...c},l){return(0,X.jsxs)(`span`,{...c,className:Z(`caps-status`,a===`compact`&&`caps-status-compact`,o===`chip`&&`caps-status-chip`,e),"data-tone":o===`chip`?i:void 0,"data-glyph":n,"data-motion":r,ref:l,children:[Hae(n)?(0,X.jsx)(Bae,{className:c8[i],glyph:n,progress:s}):(0,X.jsx)(Rae,{className:c8[i],glyph:n,motion:r}),t===void 0?null:(0,X.jsx)(`span`,{children:t})]})}),u8=24,d8={all:e=>bA.of(e,`prints`,`gallery`),listings:e=>[...d8.all(e),`listing`],listing:(e,t)=>[...d8.listings(e),t],file:(e,t)=>[...d8.all(e),`file`,t]};function f8(e,t){let n=e?.context.get().computerId;return nne({queryKey:d8.listing(e,t),initialPageParam:0,enabled:!!(n&&t&&e.capabilities.has(fR)&&e.capabilities.has(CR)),queryFn:async({pageParam:r,signal:i})=>{if(!e||!n||!t)throw new Y(`No Computer folder selected`,{code:`SELECTION_CHANGED`,retryable:!1});let a=[],o=r;do{if(i.throwIfAborted(),e.context.get().computerId!==n)throw new Y(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});let r=await TR(e.capabilities,{path:t,limit:u8-a.length,offset:o});if(i.throwIfAborted(),r.nextOffset!==null&&r.nextOffset<=o)throw new Y(`Directory pagination did not advance`,{code:`PROTOCOL`,retryable:!1});a.push(...r.entries.filter(e=>e.type===`file`&&/\.(avif|gif|jpe?g|png|svg|webp|mp4)$/i.test(e.name)).map(e=>({...e,path:`${r.path.replace(/\/$/,``)}/${e.name}`}))),o=r.nextOffset}while(a.length<u8&&o!==null);return{entries:a,nextOffset:o}},getNextPageParam:e=>e.nextOffset})}function Uae(e,t,n){return{...CA(e,CR,[...d8.file(e,t.path),t.modifiedAt,t.size],async(n,r)=>{if(!e)throw new Y(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});let i=await wR(e.capabilities,{path:t.path},{signal:r});return new File([i],i.name,{type:i.type,lastModified:t.modifiedAt})}),enabled:!!(n&&e?.context.get().computerId&&e.capabilities.has(CR)),structuralSharing:!1}}function Wae(e,t){let n=e?.app??null,r=Yk(n),i=_x(),[a,o]=(0,K.useState)(()=>new Set),s=(0,K.useCallback)(e=>{if(!r)return;let t=`${r}:${e}`;o(e=>e.has(t)?e:new Set([...e,t]))},[r]),c=(0,K.useCallback)(e=>{s(e),i.resetQueries({queryKey:d8.file(n,e)})},[n,i,s]),l=f8(n,t),u=IS(l),d=(0,K.useMemo)(()=>l.enabled?u.data?.pages.flatMap(e=>e.entries)??[]:[],[u.data,l.enabled]),f=(0,K.useCallback)(e=>({files:e.flatMap((e,t)=>e.data?[{path:d[t].path,file:e.data}]:[]),failures:e.flatMap((e,t)=>e.isError?[d[t].name]:[]),loading:e.some(e=>e.isLoading)}),[d]),p=ene({queries:d.map(e=>Uae(n,e,!!(r&&a.has(`${r}:${e.path}`)))),combine:f});return(0,K.useEffect)(()=>{if(!n)return;let e=d8.all(n),t=d8.listings(n),a=!0;i.invalidateQueries({queryKey:e});let o=()=>{i.cancelQueries({queryKey:e})},s=n.context.subscribe(e=>{e.computerId!==r&&o()}),c=n.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&o()}),l=n.capabilities.subscribe(()=>{queueMicrotask(()=>{!a||n.context.get().computerId!==r||i.resetQueries({queryKey:t})})});return()=>{a=!1,s(),c(),l(),o()}},[n,r,e,i]),{entries:d,loadFile:s,retryFile:c,files:p.files,failures:p.failures,error:u.error,loading:u.isFetching||p.loading,hasNextPage:u.hasNextPage,nextPageReady:u.hasNextPage&&!u.isFetching&&!u.error,refresh:()=>{u.refetch({cancelRefetch:!1})},loadMore:()=>{u.isFetching||u.fetchNextPage({cancelRefetch:!1})}}}function p8(e){return e.replace(/\s/gu,` `).replace(/ +/g,` `).trim()}function Gae(e,t){let[n,r]=(0,K.useState)([]),i=(0,K.useRef)(new Map),a=(0,K.useRef)(Promise.resolve()),[o,s]=(0,K.useState)(null),c=(0,K.useRef)(new Map),l=(0,K.useRef)(e);l.current=e;let u=(0,K.useRef)(t);u.current=t;let d=(e,t,n)=>{let a=i.current.get(e);a&&i.current.set(e,{...a,status:t,message:n}),r([...i.current.values()])},f=(0,K.useCallback)(async(e,t)=>{let n=()=>t.signal.aborted;if(n()){d(e.id,`cancelled`,`Cancelled before sending`),c.current.delete(e.id);return}let r=e.dimensions;if(!r)try{let t=await UX(e.file,e.previewUrl);r={width:t.width,height:t.height},e.dimensions=r;let n=i.current.get(e.id);n&&i.current.set(e.id,{...n,dimensions:r})}catch(t){JX(`decode-upload-image`,t),d(e.id,`error`,`Could not decode this image. No upload was sent.`),c.current.delete(e.id);return}try{if(n()){d(e.id,`cancelled`,`Cancelled before sending`);return}if(e.app.context.get().computerId!==e.computerId){d(e.id,`error`,`Computer changed. Select the original Computer and retry. No upload was sent.`);return}u.current({id:e.id,path:e.path,computerId:e.computerId,app:e.app,width:r.width,height:r.height}),d(e.id,`sending`,`Sending; awaiting Computer completion`),await kR(e.app.capabilities,{path:e.path,content:e.file.slice()},{signal:t.signal}),d(e.id,`complete`,`Written to Computer`);try{await l.current(e.path,e.app,e.computerId)}catch(t){JX(`refresh-upload-preview`,t),d(e.id,`complete`,`Written; fresh preview unavailable`)}}catch(t){n()||JX(`write-computer-upload`,t),d(e.id,n()?`cancelled`:`error`,n()?`Cancelled request; check Computer before retrying`:`Completion not confirmed; check Computer or retry`)}finally{c.current.delete(e.id)}},[]),p=e=>{let t=new AbortController;c.current.set(e.id,t),d(e.id,`queued`,`Queued`),a.current=a.current.then(()=>f(e,t))},m=(0,K.useCallback)(()=>{for(let e of c.current.values())e.abort()},[]);return(0,K.useEffect)(()=>()=>{m();for(let e of i.current.values())URL.revokeObjectURL(e.previewUrl)},[m]),{items:n,error:o,cancelAll:m,add(e,t,n){s(null);let r=[...i.current.values()].reduce((e,t)=>e+t.file.size,0);for(let a of e){if(!a.type.startsWith(`image/`)){s(`Only image files can be uploaded here`);continue}if(i.current.size>=8||r+a.size>67108864){s(`Upload queue limit: eight files and 64 MiB. Remove finished rows before adding more.`);break}let e=n.context.get().computerId;if(!e){s(`Select a Computer before uploading images.`);continue}let o=`${t.replace(/\/$/,``)}/upload-${cA(8)}-${p8(a.name)}`;if(i.current.has(o)){s(`This path is already in the queue. Retry or remove its existing row.`);continue}let c={computerId:e,id:o,file:a,previewUrl:URL.createObjectURL(a),app:n,path:o,status:`queued`,message:`Queued`};i.current.set(c.id,c),r+=a.size,p(c)}},cancel(e){c.current.get(e)?.abort()},retry(e){let t=n.find(t=>t.id===e);t&&!c.current.has(e)&&p(t)},remove(e){if(!c.current.has(e)){let t=i.current.get(e);t&&URL.revokeObjectURL(t.previewUrl),i.current.delete(e),r([...i.current.values()])}}}}function m8(e){return e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name}function Kae(e){return e.connection.app.ui.openNavigation({computerId:e.computerId,path:e.path})}function qae(e,t){let n=t.path,r=Yk(e?.app),i=(0,K.useRef)(new Set),a=(0,K.useRef)(0),o=(0,K.useRef)(e);o.current=e;let s=e?.app.capabilities.has(fR)===!0,c=e?.app.capabilities.has(CR)===!0,l=e?.app.capabilities.has(ER)===!0,u=Wae(e,t.galleryPath),[d,f]=(0,K.useState)([]),[p,m]=(0,K.useState)([]),[h,g]=(0,K.useState)([]),[_,v]=(0,K.useState)([]);(0,K.useEffect)(()=>{v([])},[e]);let y=e=>{v(t=>t.some(t=>t.key===e.key)?t.map(t=>t.key===e.key?e:t):[...t,e])},[b,x]=(0,K.useState)(!1),S=(0,K.useMemo)(()=>[...u.error?[`Could not refresh the Media gallery`]:[],...u.failures],[u.error,u.failures]),C=(0,K.useRef)(new WeakMap),w=(0,K.useMemo)(()=>{if(!c||!s)return d.filter(e=>e.kind===`local`);let t=r?u.files.map(({file:t,path:n})=>({kind:`computer`,computerId:r,connection:e,file:t,path:n})):[],i=d.filter(t=>t.kind===`local`||t.computerId===r&&t.connection===e&&t.path.slice(0,t.path.lastIndexOf(`/`))===n?.replace(/\/$/,``));return[...t.filter(e=>!i.some(t=>t.kind===`computer`&&e.kind===`computer`&&t.path===e.path)),...i]},[e,r,n,u.files,d,c,s]),T=(0,K.useCallback)(()=>{a.current+=1;for(let e of i.current)e.abort();i.current.clear()},[]);(0,K.useEffect)(()=>{if(!e)return()=>{T()};let t=e.app.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&T()});return()=>{t(),T()}},[e,T]),(0,K.useEffect)(()=>{if(e)return e.app.context.subscribe(e=>{e.computerId!==r&&T()})},[e,r,T]),(0,K.useEffect)(()=>{v([]),f(e=>e.filter(e=>e.kind===`local`))},[r]);let E=(0,K.useCallback)(async(e,t,n)=>{let r=n??t.app.context.get().computerId;if(!r){g([`The selected Computer is unavailable`]);return}if(o.current!==t){g([`Computer selection changed`]);return}if(t.app.context.get().computerId!==r){g([`Computer selection changed before the preview was loaded`]);return}let s=a.current,c=new AbortController;i.current.add(c);try{let n=await wR(t.app.capabilities,{path:e},{signal:c.signal});if(c.signal.aborted||s!==a.current)return;v(t=>t.map(t=>t.key===`${r}:${e}`?{...t,previewFile:n}:t)),f(i=>[...i.filter(t=>t.kind!==`computer`||t.path!==e||t.computerId!==r),{kind:`computer`,computerId:r,file:n,path:e,connection:t}])}catch(t){c.signal.aborted||(JX(`read-computer-file`,t),g([`Could not read ${e}`]),v(t=>t.map(t=>t.key===`${r}:${e}`?{...t,error:`Saved; preview unavailable. Retry loading it.`}:t)))}finally{i.current.delete(c)}},[]),D=(0,K.useCallback)(t=>{let n=d.find(n=>n.kind===`computer`&&n.connection===e&&n.computerId===r&&n.path===t);n?.kind===`computer`?E(t,n.connection,n.computerId):u.retryFile(t)},[d,e,r,E,u.retryFile]),O=(0,K.useRef)(new Set),k=(0,K.useRef)(new Set),A=(0,K.useCallback)(e=>{URL.revokeObjectURL(e),O.current.delete(e)},[]);(0,K.useEffect)(()=>{let e=!0,t=new Set,n=new Map,r=new Set,i=[...w].sort((e,t)=>t.file.lastModified-e.file.lastModified||e.file.name.localeCompare(t.file.name)).map(e=>{let t=URL.createObjectURL(e.file);return O.current.add(t),{source:e,file:e.file,url:t}}),a=i.length;return g(S),x(a>0),a===0&&m([]),i.forEach(({file:o,url:s,source:c},l)=>{let u=C.current.get(o);u||(u=(async()=>{let e=URL.createObjectURL(o);try{let{width:t,height:n}=await UX(o,e);return{width:t,height:n}}finally{URL.revokeObjectURL(e)}})(),C.current.set(o,u)),u.then(r=>{e&&(n.set(l,{...r,file:o,url:s,source:c}),t.add(s),m(i.flatMap((e,t)=>{let r=n.get(t);return r?[r]:[]})),v(e=>e.map(e=>e.previewFile===o?{...e,resolved:!0,previewFile:void 0,error:void 0}:e)))}).catch(t=>{e&&(JX(`decode-gallery-image`,t),A(s),r.add(o.name),g([...S,...r]),c.kind===`computer`&&v(e=>e.map(e=>e.key===`${c.computerId}:${c.path}`?{...e,error:`Could not decode the saved image.`}:e)))}).finally(()=>{--a,e&&a===0&&(x(!1),m(i.flatMap((e,t)=>{let r=n.get(t);return r?[r]:[]})))})}),()=>{e=!1;for(let{url:e}of i)t.has(e)||A(e)}},[w,S,A]),(0,K.useEffect)(()=>{let e=new Set(p.map(e=>e.url));for(let t of k.current)e.has(t)||A(t);k.current=e},[p,A]),(0,K.useEffect)(()=>{let e=O.current;return()=>{for(let t of e)URL.revokeObjectURL(t);e.clear()}},[]);let j=Gae(async(e,t,n)=>{let r=o.current,i=r?.app===t&&t.context.get().computerId===n?r:null;i&&await E(e,i,n)},e=>{o.current?.app===e.app&&e.app.context.get().computerId===e.computerId&&y({key:`${e.computerId}:${e.path}`,path:e.path,computerId:e.computerId,width:e.width,height:e.height,uploadId:e.id})});return(0,K.useEffect)(()=>{let t=j.cancelAll,n=e?.app.lifecycle.subscribe(e=>{(e===`disposing`||e===`disconnected`||e===`disposed`)&&t()});return()=>{n?.(),t()}},[e,j.cancelAll]),{images:p,failed:h,loading:b,gallery:u,gallerySlots:_,canBrowse:s,canRead:c,canWrite:l,reserveSlot:y,addComputerFile:E,retryFile:D,uploads:j,uploadFiles:async i=>{if(!e||!l||n===null)return;let a=e,s=r,c=await t.ensureCreated();if(c){g([c]);return}o.current===a&&a.app.context.get().computerId===s&&j.add(i,n,a.app)},failSlot:(e,t)=>{v(n=>n.map(n=>n.key===e?{...n,error:t}:n))},clearSlotError:e=>{v(t=>t.map(t=>t.key===e?{...t,error:void 0}:t))},removeSlot:e=>{v(t=>t.filter(t=>t.key!==e))}}}function Jae(e){return e.map(e=>e.key)}function h8(e,t,n){let r=e.indexOf(t);return r<0?null:e[r+n]??null}function Yae(e,t,n){if(e.includes(t))return t;let r=n.indexOf(t);if(r>=0){let t=new Set(e);for(let e=1;e<n.length;e+=1)for(let i of[e,-e]){let e=r+i;if(e<0||e>=n.length)continue;let a=n[e];if(t.has(a))return a}}return e[0]??null}function Xae({url:e,path:t,onError:n,autoPlay:r}){let i=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let t=i.current;if(!t)return;let a=!1;return r&&t.play().catch(t=>{a||t instanceof DOMException&&(t.name===`NotAllowedError`||t.name===`AbortError`)||(JX(`play-print-video`,t),n(e))}),()=>{a=!0,t.pause()}},[e,n,r]),(0,X.jsx)(`video`,{ref:i,src:e,"aria-label":t,controls:!0,playsInline:!0,preload:`auto`,className:`block max-h-full max-w-full object-contain`,onError:()=>{n(e)}})}function Zae({item:e,actualSize:t}){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(null),o=e.pending===!0&&!e.onVisible,[s,c]=(0,K.useState)(o);o&&!s&&c(!0);let l=e.pendingLabel??`Loading print…`,u=(0,X.jsx)(`img`,{src:e.url,alt:e.path,decoding:`async`,width:t?e.width:void 0,height:t?e.height:void 0,className:t?`block max-w-none`:`block max-h-full max-w-full object-contain`,onLoad:()=>{r(e.url)},onError:()=>{a(e.url)}},e.url);return(0,X.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 items-center justify-center overflow-hidden`,"data-print-viewer-stage":!0,children:e.error||i===e.url?(0,X.jsx)(N6,{status:`failed`,className:`h-full w-full`,failure:(0,X.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-sm px-md text-center`,children:[(0,X.jsx)(l8,{tone:`error`,appearance:`chip`,glyph:`bang`,label:o?`Not saved`:`Prints can't show this file`}),(0,X.jsx)(`p`,{className:`max-w-full break-words text-sm`,children:e.path}),e.error?(0,X.jsx)(`p`,{className:`text-sm`,children:e.error}):null,e.onRetry?(0,X.jsx)(QI,{"aria-label":`Retry print`,title:`Retry print`,icon:(0,X.jsx)(TL,{}),onClick:e.onRetry}):null,e.onDismiss?(0,X.jsx)(QI,{"aria-label":`Dismiss print`,title:`Dismiss print`,icon:(0,X.jsx)(AL,{}),onClick:e.onDismiss}):null]})}):HX(e.path)&&e.url?(0,X.jsx)(Xae,{url:e.url,path:e.path,onError:a,autoPlay:!s}):e.url?(0,X.jsxs)(X.Fragment,{children:[t?(0,X.jsx)(i8,{className:`h-full w-full`,role:`region`,"aria-label":`Actual-size print`,tabIndex:0,"data-print-viewer-scroll":!0,children:u}):u,n===e.url?null:(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(JI,{label:`Loading print`,variant:`bloom`})})]}):(0,X.jsx)(N6,{status:`generating`,label:l,className:`h-full w-full`,indicator:(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`flex max-w-full flex-col items-center gap-sm px-md text-center`,children:[(0,X.jsx)(JI,{decorative:!0,variant:`bloom`}),(0,X.jsx)(`p`,{className:`text-sm`,children:l})]})})})}function Qae({source:e}){let[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fP,{label:`Open in Inkcap`,icon:(0,X.jsx)(Iie,{}),disabled:t,onClick:()=>{n(!0),i(!1),Kae(e).catch(e=>{JX(`open-print-in-inkcap`,e),i(!0)}).finally(()=>{n(!1)})}}),r?(0,X.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Could not open `,e.path,` in Inkcap.`]}):null]})}function $ae({items:e,images:t,viewerKey:n,app:r,onNavigate:i,onClose:a,renderInfo:o}){let s=(0,K.useRef)(null),c=Jae(e),l=(0,K.useRef)(c),u=n===null?null:Yae(c,n,l.current);(0,K.useEffect)(()=>{l.current=c,n!==null&&u!==n&&(u===null?a(n):i(u))},[c,u,n,a,i]),(0,K.useEffect)(()=>{if(u===null)return;let t=e.findIndex(e=>e.key===u);for(let n of e.slice(Math.max(0,t-1),t+2))n.onVisible?.()},[e,u]);let[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null);(0,K.useEffect)(()=>{m(null)},[u]),(0,K.useEffect)(()=>{f(null)},[n]);let h=e.find(e=>e.key===u),g=t.find(e=>m8(e)===u);if(!h||u===null)return null;let _=h8(c,u,-1),v=h8(c,u,1),y=h.path.split(`/`).at(-1)??h.path,b=()=>{a(u)},x=e=>{e!==null&&i(e)};return(0,X.jsx)(C6,{open:!0,onOpenChange:e=>{e||b()},children:(0,X.jsxs)(T6,{children:[(0,X.jsx)(E6,{}),(0,X.jsxs)(D6,{ref:s,size:`fill`,initialFocus:s,finalFocus:!1,className:`flex min-h-0 flex-col gap-sm`,onKeyDown:e=>{e.altKey||e.ctrlKey||e.metaKey||e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select, video, [data-print-viewer-scroll], [contenteditable=true]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),x(e.key===`ArrowLeft`?_:v)):e.key.toLowerCase()===`i`&&g&&(e.preventDefault(),f(d===u?null:u)))},children:[(0,X.jsx)(uie,{fit:`fill`,children:(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(die,{title:(0,X.jsx)(j6,{className:`truncate`,children:y}),status:(0,X.jsxs)(`span`,{"aria-live":`polite`,"aria-atomic":`true`,children:[(0,X.jsxs)(`span`,{className:`sr-only`,children:[y,`, `]}),c.indexOf(u)+1,` of `,c.length]})}),(0,X.jsxs)(`div`,{className:`@container relative flex min-h-0 min-w-0 flex-1`,children:[(0,X.jsx)(Zae,{item:h,actualSize:p===u},u),d===u&&g?o(g,()=>{f(null)}):null]})]})}),(0,X.jsxs)(`div`,{className:`prints-viewer-actions`,children:[(0,X.jsx)(QI,{size:`default`,iconSize:`md`,"aria-label":`Previous print`,title:`Previous print (Left arrow)`,"aria-keyshortcuts":`ArrowLeft`,icon:(0,X.jsx)(jie,{}),disabled:_===null,onClick:()=>{x(_)}}),(0,X.jsx)(QI,{size:`default`,iconSize:`md`,"aria-label":`Next print`,title:`Next print (Right arrow)`,"aria-keyshortcuts":`ArrowRight`,icon:(0,X.jsx)(Mie,{}),disabled:v===null,onClick:()=>{x(v)}}),(0,X.jsx)(QI,{size:`default`,iconSize:`md`,"aria-label":`Image info`,title:`Image info (I)`,"aria-keyshortcuts":`i`,"aria-expanded":d===u,icon:(0,X.jsx)(xL,{}),disabled:!g,onClick:()=>{f(d===u?null:u)}}),HX(h.path)?null:(0,X.jsx)(QI,{size:`default`,iconSize:`md`,"aria-label":`Actual size`,title:`Actual size`,"aria-pressed":p===u,active:p===u,icon:(0,X.jsx)(SL,{}),disabled:!h.url||!!h.error,onClick:()=>{m(p===u?null:u)}}),g?(0,X.jsx)(YX,{source:g.source,app:r},g.url):null,g?.source.kind===`computer`?(0,X.jsx)(Qae,{source:g.source},u):null,(0,X.jsx)(QI,{size:`default`,iconSize:`md`,"aria-label":`Close viewer`,title:`Close viewer (Escape)`,icon:(0,X.jsx)(AL,{}),onClick:b})]})]})]})})}var g8=e=>fb.pipe(J(Ub(1)),J(Kb(e))),_8=pb.pipe(J(Vb()),J(Db(Number.isSafeInteger,{message:`Expected a safe integer`}))),v8=_8.pipe(J(Lb(0))),eoe=q({bytes:v8,costMilliunits:_8.pipe(J(Rb(0))),destination:q({computerId:g8(256),path:g8(4096)}),format:bb([`png`,`jpeg`,`gif`,`webp`,`mp4`]),height:v8,model:g8(256),width:v8}),toe=q({operation:cb(`complete-generation`),reference:tj,result:eoe,derivedFrom:sb(g8(256)),references:sb(_b(xb(g8(256))))}),y8=q({reference:tj,input:_j,typed:q({prompt:Jb,references:Hb.pipe(J(Rb(0)))}),style:sb(Bj),characters:sb(_b(rM))});yb([q({operation:cb(`remember-generation`),record:y8}),q({operation:cb(`forget-generation`),reference:tj}),q({operation:cb(`list-generations`),after:xb(fb)})]);function b8(e){return{reference:e.reference,input:Ej(e.input),typed:e.typed,style:e.style,characters:e.characters}}async function noe(e,t){let n=b8(ib(y8,{onExcessProperty:`error`})(t)),r=b8(ib(y8,{onExcessProperty:`error`})(await e.require(TA).request(JSON.stringify({operation:`remember-generation`,record:n}))));if(JSON.stringify(r)!==JSON.stringify(n))throw new Y(`Prints did not confirm the original generation command`,{code:`PROTOCOL`,retryable:!1});return r}async function roe(e,t){ib(q({removed:mb}))(await e.require(TA).request(JSON.stringify({operation:`forget-generation`,reference:t})))}async function ioe(e,t=null){let n=ib(q({records:_b(y8),next:xb(fb)}),{onExcessProperty:`error`})(await e.require(TA).request(JSON.stringify({operation:`list-generations`,after:t})));return{records:n.records.map(b8),next:n.next}}async function aoe(e,t,n){let r=ib(toe,{onExcessProperty:`error`})({operation:`complete-generation`,reference:t,result:n}),i=ib(q({printId:fb,computerId:fb}))(await e.require(TA).request(JSON.stringify(r)));if(i.printId!==t.requestId||i.computerId!==t.computerId)throw new Y(`Prints did not confirm the saved generation`,{code:`PROTOCOL`,retryable:!1})}var ooe=nb(q({reference:tj}));function soe({connection:e,folder:t,effects:n,styles:r,characters:i}){let a=e?.app??null,o=Yk(a),s=(0,K.useRef)(e);s.current=e;let c=(0,K.useRef)(n);c.current=n;let l=_x(),u=bA.of(a,`prints`,`generation`),d=[...u,`recovery`],f=NS(EM(a)),p=f.isError?void 0:f.data,m=p?.models??[],h=a?.capabilities.has(Sj)===!0,g=p?.canGenerate??!1,_=f.error?lx(f.error).message:p?.models.length===0?`The granted Media model registry is empty.`:null,v=IS({queryKey:d,enabled:a!==null&&o!==null,initialPageParam:null,queryFn:async({pageParam:e,signal:t})=>{if(!a)throw new Y(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});if(a.context.get().computerId!==o)throw new Y(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});let n=await ioe(a.capabilities,e);return t.throwIfAborted(),n},getNextPageParam:e=>e.next}),y=(0,K.useMemo)(()=>Array.from(new Map(v.data?.pages.flatMap(e=>e.records).map(e=>[e.reference.requestId,e])??[]).values()),[v.data]),b=(0,K.useRef)(new Map),x=(0,K.useRef)(new Set),S=(0,K.useRef)(0),C=(0,K.useRef)(null),[w,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(null),O=e=>{T(e),c.current.notifyFailure(e.message)},k=e=>{D(e),c.current.notifyFailure(e)},A=(0,K.useRef)(null);(0,K.useEffect)(()=>{A.current!==v.error&&(A.current=v.error,v.error&&c.current.notifyFailure(lx(v.error).message))},[v.error]);let j=e=>s.current===e.connection&&e.connection.app.context.get().computerId===e.reference.computerId,M=(e,t)=>{l.setQueryData(e,e=>e&&{...e,pages:e.pages.map(e=>({...e,records:e.records.filter(e=>e.reference.requestId!==t)}))})},N=FS({mutationKey:[...u,`run`],mutationFn:async e=>{e.controller.signal.throwIfAborted();let t=b8({reference:e.reference,input:e.input,typed:e.typed,style:e.style,characters:e.characters});await noe(e.connection.app.capabilities,t),e.controller.signal.throwIfAborted();let n=await e.session.restoreAttempt(e.reference),r;try{r=await n.generate(t.input,{signal:e.controller.signal})}finally{n[Symbol.dispose]()}return await aoe(e.connection.app.capabilities,t.reference,r),{input:e.input,result:r}},onMutate:e=>{if(!j(e)||e.controller.signal.aborted)return;let t=ZL(e.session.models,e.input.settings.model),n={key:`${e.reference.computerId}:${e.input.destination.path}`,computerId:e.reference.computerId,path:e.input.destination.path,width:e.draft.width,height:e.draft.height,pendingLabel:VL(t)};t?.kind===`video`&&(n.startedAt=Date.now(),n.resumed=e.resumed===!0),c.current.reserve(n)},onSuccess:(e,t)=>{M(t.recoveryKey,t.reference.requestId),C.current?.reference.requestId===t.reference.requestId&&(C.current=null),!(!j(t)||t.controller.signal.aborted)&&c.current.saved(e,t.connection)},onError:(e,n)=>{if(JX(`generate-media`,e),!j(n)||n.controller.signal.aborted)return;t.recheck();let r=IL(e).message;c.current.failed(`${n.reference.computerId}:${n.input.destination.path}`,r),c.current.notifyFailure(r)},onSettled:(e,t,n)=>{b.current.get(n.reference.requestId)===n.controller&&b.current.delete(n.reference.requestId)}}),P=FS({mutationKey:[...u,`discard`],mutationFn:async e=>{await roe(e.connection.app.capabilities,e.reference)},onSuccess:(e,t)=>{M(t.recoveryKey,t.reference.requestId),C.current?.reference.requestId===t.reference.requestId&&(C.current=null)},onError:(e,t)=>{j(t)&&k(lx(e).message)},onSettled:(e,t,n)=>{b.current.get(n.reference.requestId)===n.controller&&b.current.delete(n.reference.requestId)}}),F=rne({filters:{mutationKey:u,status:`pending`},select:e=>yd(ooe(e.state.variables))?.reference.requestId}),I=new Set(F.filter(e=>e!==void 0));(0,K.useEffect)(()=>{x.current.clear(),T(null),D(null),C.current=null;let e=bA.of(a,`prints`,`generation`,`recovery`),t=a?.capabilities.subscribe(()=>{queueMicrotask(()=>{l.resetQueries({queryKey:e,exact:!0})})}),n=()=>{S.current+=1;for(let e of b.current.values())e.abort();b.current.clear(),l.cancelQueries({queryKey:e})},r=a?.context.subscribe(e=>{e.computerId!==o&&n()}),i=a?.lifecycle.subscribe(e=>{(e===`disposing`||e===`disposed`||e===`disconnected`)&&n()});return()=>{r?.(),i?.(),t?.(),n()}},[a,o,e,l]);let L=e=>{let t=e.reference.requestId;if(b.current.has(t))return!1;if(!j(e))return k(`Select the original Computer to retry this generation.`),!1;if(p?.computerId!==e.reference.computerId)return k(`Media access is unavailable for the original Computer.`),!1;let n=new AbortController;return b.current.set(t,n),C.current=e,T(null),D(null),S.current+=1,N.mutate({...e,session:p,controller:n,ticket:S.current,recoveryKey:d}),!0};(0,K.useEffect)(()=>{if(!(!e||!p||!v.isSuccess))for(let t of y){let n=t.reference.requestId;x.current.has(n)||t.reference.computerId!==o||ZL(p.models,t.input.settings.model)?.kind!==`video`||L({connection:e,...t,resumed:!0,draft:{...t.input.settings,references:t.input.settings.references??[],destination:t.input.destination.path}})&&x.current.add(n)}},[e,o,p,v.isSuccess,y]);let R=async n=>{if(!e?.app.capabilities.has(ER)||!g)return!1;if(t.path===null)return t.setEditing(!0),!1;C.current=null;let a=ZL(m,n.model);if(a===void 0)return O({kind:`error`,mediaKind:null,message:`Choose a model from the granted registry.`}),!1;let c=gM({prompt:n.prompt,saved:i,references:n.references,computerId:o,model:{label:a.label,maxReferences:a.input.maxReferences}});if(c.kind===`refused`)return O({kind:`error`,mediaKind:a.kind,message:c.message}),!1;let l=sR({...n,references:c.references},a);if(l)return O({kind:`error`,mediaKind:a.kind,message:l}),!1;let u=n.style===void 0?void 0:r.find(e=>e.name===n.style);if(n.style!==void 0&&u===void 0)return O({kind:`error`,mediaKind:a.kind,message:`The "${n.style}" style no longer exists. Pick another or none.`}),!1;let d=c.characters.map(e=>e.name),f=Kj(u?.text,c.prompt),_=Jj(f,qj(a),u?.name,d);if(_!==void 0)return O({kind:`error`,mediaKind:a.kind,message:_}),!1;if(!h||!p)return T(null),!1;let v=e,y=v.app.context.get().computerId,b=S.current,x={...n,prompt:f,references:c.references,destination:zL(n,t.path,a)},w=iR(x,a),E;try{let e=await t.ensureCreated();if(e)return O({kind:`error`,mediaKind:a.kind,message:e}),!1;if(S.current!==b||s.current!==v||v.app.context.get().computerId!==y)return!1;let n=await p.createAttempt();E=n.reference,n[Symbol.dispose]()}catch(e){return S.current===b&&s.current===v&&v.app.context.get().computerId===y&&O({kind:`error`,mediaKind:a.kind,...IL(e)}),!1}return S.current!==b||s.current!==v||v.app.context.get().computerId!==y?!1:L({connection:v,reference:E,input:w,draft:x,typed:{prompt:n.prompt.trim(),references:n.references.length},style:u?.name,characters:d})},z=N.variables;return{state:w??(z&&j(z)&&z.ticket===S.current?N.isPending?{kind:`pending`,draft:z.draft}:N.isError?{kind:`error`,mediaKind:ZL(z.session.models,z.input.settings.model)?.kind??null,...IL(N.error)}:{kind:`completed`,record:N.data}:null)??(!e||!h||o===null?{kind:`unavailable`,reason:`Image creation is unavailable for this Computer right now.`}:_?{kind:`unavailable`,reason:_}:p?{kind:`ready`}:{kind:`loading`}),models:m,modelsLoading:f.isFetching,modelsError:_,canGenerate:g,mediaCapability:h,retryModels:()=>{f.refetch()},submit:R,isRunning:()=>b.current.size>0,activeGenerations:I,pendingGenerations:y,recoveryError:E??(v.error?lx(v.error).message:null),reportRecoveryError:e=>{k(lx(e).message)},hasMore:v.hasNextPage,loadMore:()=>{v.isFetching||v.fetchNextPage()},resume:t=>{if(!e||p?.computerId!==t.reference.computerId){k(`Select the original Computer to retry this generation.`);return}L({connection:e,...t,draft:{...t.input.settings,references:t.input.settings.references??[],destination:t.input.destination.path}})},discard:t=>{if(!e||b.current.has(t.reference.requestId))return;let n=new AbortController;b.current.set(t.reference.requestId,n),P.mutate({...t,connection:e,controller:n,draft:{...t.input.settings,references:t.input.settings.references??[]},recoveryKey:d})},retryPath:e=>{let t=C.current;return t?.input.destination.path!==e||!j(t)?!1:(L(t),!0)},retry:C.current&&j(C.current)?()=>{C.current&&L(C.current)}:void 0,errorKey:`generation:${C.current?.reference.requestId??`draft`}:${String(S.current)}`}}function coe({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function x8(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var S8=[],C8=0,{link:w8,unlink:loe,propagate:uoe,checkDirty:T8,shallowPropagate:E8}=coe({update(e){return e._update()},notify(e){S8[O8++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,M8(e))}}),D8=0,O8=0,k8,A8=0;function j8(e){try{++A8,e()}finally{--A8||N8()}}function M8(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=loe(n,e)}function N8(){if(!(A8>0)){for(;D8<O8;){let e=S8[D8];S8[D8++]=void 0,e.notify()}D8=0,O8=0}}function P8(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return k8!==void 0&&w8(i,k8,C8),i._snapshot},subscribe(e){let t=x8(e),n={current:!1},r=doe(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=k8,o=t?.compare??Object.is;if(n)k8=i,++C8,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{k8=a,n&&(i.flags&=-5),M8(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&T8(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&E8(e)}}else e&32&&(i.flags=e&-33);return k8!==void 0&&w8(i,k8,C8),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(uoe(e),E8(e),N8())}},i}function doe(e){let t=()=>{let t=k8;k8=n,++C8,n.depsTail=void 0,n.flags=6;try{return e()}finally{k8=t,n.flags&=-5,M8(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&T8(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,M8(this)}};return t(),n}var F8=class{constructor(e,t){this.atom=P8(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(x8(e))}},foe=class{constructor(e){this.atom=P8(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(x8(e))}};function I8(e,t){return typeof e==`function`?new foe(e):t?new F8(e,t):new F8(e)}var poe=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function moe(e,t){return new poe(e,t).maybeExecute}var hoe=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},L8=new class extends hoe{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function R8(e,t){return typeof e==`function`?e(t):e}function z8(e,t){return G8(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function B8(e,t,n){let r=G8(t);function i(e){if(!r.length)return R8(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function goe(e,t){let n=G8(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var V8=46,H8=91,U8=93,W8=48,_oe=57;function G8(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===H8),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===V8||s===H8||s===U8){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==W8),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==U8&&(a!==-1||s!==U8)&&(a!==s||s!==V8&&s!==H8)&&n.push(``);r=o+1,i=!0}else(s<W8||s>_oe)&&(i=!1);a=s}return n.length||n.push(``),n}function voe(e){return!(Array.isArray(e)&&e.length===0)}function K8(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function q8(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var J8=e=>!!e&&typeof e==`object`&&`fields`in e;function Y8(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!Y8(e[i],t[i]))return!1;return!0}var X8=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},Z8=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function Q8(e,t){return e==null?t:{...e,...t}}for(var $8=256,e5=[],t5;$8--;)e5[$8]=($8+256).toString(16).substring(1);function n5(){let e=0,t,n=``;if(!t5||$8+16>256){for(t5=Array(256),e=256;e--;)t5[e]=256*Math.random()|0;e=0,$8=0}for(;e<16;e++)t=t5[$8+e],n+=e===6?e5[t&15|64]:e===8?e5[t&63|128]:e5[t],e&1&&e>1&&e<11&&(n+=`-`);return $8++,n}var yoe=moe(e=>L8.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function r5(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=r5(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,r5(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(r5(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=r5(e[n]));return t}function i5(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var a5=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function boe(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var o5=(e,t)=>{let n=boe(e,t);return{form:n,fields:n}},s5={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:o5(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:o5(r.issues,e)}},c5=e=>!!e&&`~standard`in e,l5={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function u5(e){function t(t){let n=e.getFieldMeta(t)??l5;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>l5;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function d5(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var f5=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{yoe(this)}),t=L8.on(`request-form-state`,e=>{e.payload.id===this._formId&&L8.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=L8.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=L8.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),L8.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return L8.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!Y8(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!Y8(e.defaultState,t.defaultState)&&!this.state.isTouched;if(!(!n&&!r)){if(j8(()=>{this.baseStore.setState(()=>d5(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=u5(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}L8.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=B8(t,e.instance.name,e.instance.options.defaultValue))}),d5({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return j8(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return j8(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=K8(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||a5}),r=!1,i={};return j8(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=p5(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=m5(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??l5,r=a?.[e],{newErrorValue:s,newSource:c}=X8({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=l5)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=m5(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=m5(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=q8(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||a5});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=m5(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=p5(r);s&&(i=i?{...i,...s}:s);let c=m5(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??l5,r=i?.[e],{newErrorValue:a,newSource:o}=X8({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=l5)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),j8(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),L8.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),L8.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}j8(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),j8(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),L8.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),L8.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>z8(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:R8(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=l5,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;j8(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:B8(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t!==n&&t.startsWith(n)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=goe(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),u5(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],Q8(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),u5(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),Q8(r,{dontValidate:!0})),u5(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),Q8(n,{dontValidate:!0})),u5(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return B8(B8(e,`${t}`,i),`${n}`,r)},Q8(r,{dontValidate:!0})),u5(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},Q8(r,{dontValidate:!0})),u5(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],Q8(t,{dontValidate:!0})),u5(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=z8(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:l5},values:i===void 0?t.values:B8(t.values,e,i)}})},this.setErrorMap=e=>{j8(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(J8(t)){let{formError:e,fieldErrors:r}=p5(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>s5.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>s5.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??n5(),this._devtoolsSubmissionOverride=!1;let t=d5({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(!(n===void 0||!J8(n)))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=I8(t);let n;this.fieldMetaDerived=I8(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=z8(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!voe(u),f=!o.isDirty,p=Y8(l,this.getFieldInfo(a)?.instance?.options.defaultValue??z8(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=I8(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!i5(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&i5(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let T={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(T,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=T}return r});let r;this.store=I8(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&J8(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&Y8(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return c5(e.validate)?s5[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function p5(e){return e?J8(e)?{formError:p5(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function m5(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var h5=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...l5,isTouched:e.fieldMetaBase[this.name]?.isTouched??l5.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??l5.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??l5.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(Y8(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,Q8(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,Q8(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,Q8(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,Q8(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,Q8(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,Q8(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,Q8(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,Q8(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=K8(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||a5}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=K8(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||a5});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;j8(()=>{let e=(e,n)=>{let r=_5(n.cause),a=n.validate?g5(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=Z8({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=_5(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=q8(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||a5}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=q8(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||a5});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));j8(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=_5(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=g5(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=Z8({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),j8(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>i5(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[_5(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[_5(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)a.get(t)&&!t.options.asyncAlways||c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>s5.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>s5.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)i5(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=I8(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...l5,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!Y8(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return c5(e.validate)?s5[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function g5(e){if(e)return e}function _5(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function v5(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function xoe(e){return{...l5,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var y5=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??v5({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(Y8(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...l5,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??v5({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;x5(t)&&(n=t.group,r=t.fields);let i=b5(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:v5({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,Q8(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof h5&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&i5(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=X8({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=l5)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=K8(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||a5}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=K8(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||a5});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;j8(()=>{let t=(t,r)=>{let i=C5(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&x5(s)&&(c=s.group,l=s.fields);let u=b5(c),d=n[i],{newErrorValue:f,newSource:p}=Z8({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=C5(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=q8(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||a5}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=q8(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||a5});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=C5(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&x5(o)&&(l=o.group,u=o.fields);let d=b5(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=Z8({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return j8(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>i5(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[C5(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>i5(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),j8(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}j8(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),j8(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=I8(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??xoe(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!Y8(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(c5(e.validate)){let t=s5[e.type](e.value,e.validate);return e.type===`validate`?S5(t):t.then(S5)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function b5(e){if(e)return e}function x5(e){return!!e&&typeof e==`object`&&`fields`in e}function S5(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function C5(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Soe(e,t){if(!t)return;let n=Object.assign({},e,{state:r5(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return j8(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}function Coe(e,t){return e===t}function w5(e,t=e=>e,n){let r=n?.compare??Coe,i=(0,K.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,K.useCallback)(()=>e.get(),[e]);return(0,u4.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var T5=typeof window<`u`?K.useLayoutEffect:K.useEffect;function E5(e){let[t,n]=(0,K.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,K.useState)(()=>new h5({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new h5({...e}),i(a),n({form:e.form,name:e.name}));let o=w5(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=w5(a.store,e=>e.meta.isTouched),c=w5(a.store,e=>e.meta.isBlurred),l=w5(a.store,e=>e.meta.isDirty),u=w5(a.store,e=>e.meta.errorMap),d=w5(a.store,e=>e.meta.errorSourceMap),f=w5(a.store,e=>e.meta.isValidating),p=(0,K.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return T5(a.mount,[a]),T5(()=>{a.update(e)}),p}var woe=(({children:e,...t})=>{let n=E5(t),r=(0,K.useMemo)(()=>R8(e,n),[e,n]);return(0,X.jsx)(X.Fragment,{children:r})});function Toe(){return(0,K.useState)(()=>n5())[0]}var Eoe=K,Doe=`18.3.1`.split(`.`)[0]===`17`?Toe:Eoe.useId;function Ooe(e){let[t,n]=(0,K.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,K.useState)(()=>new y5({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new y5({...e})),n({form:e.form,name:e.name}));let a=w5(r.store,e=>e.value),o=w5(r.store,e=>e.meta.isTouched),s=w5(r.store,e=>e.meta.isBlurred),c=w5(r.store,e=>e.meta.isDirty),l=w5(r.store,e=>e.meta.errorMap),u=w5(r.store,e=>e.meta.errorSourceMap),d=w5(r.store,e=>e.meta.isValidating),f=w5(r.store,e=>e.meta.isSubmitting),p=w5(r.store,e=>e.meta.isSubmitted),m=w5(r.store,e=>e.meta.submissionAttempts),h=w5(r.store,e=>e.meta.isSubmitSuccessful),g=w5(r.store,e=>e.meta.canSubmit),_=w5(r.store,e=>e.meta.isValid),v=w5(r.store,e=>e.meta.isFieldsValid),y=w5(r.store,e=>e.meta.isFieldsValidating),b=w5(r.store,e=>e.meta.isGroupValid),x=(0,K.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return T5(r.mount,[r]),T5(()=>{r.update(e)}),x}var koe=(({children:e,...t})=>{let n=Ooe(t),r=(0,K.useMemo)(()=>R8(e,n),[e,n]);return(0,X.jsx)(X.Fragment,{children:r})});function Aoe({form:e,selector:t=e=>e,children:n}){let r=w5(e.store,t);return(0,X.jsx)(X.Fragment,{children:R8(n,r)})}function D5(e){let t=Doe(),[n,r]=(0,K.useState)(e?.formId),[i,a]=(0,K.useState)(()=>new f5({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new f5({...e,formId:n})),r(n)}let o=(0,K.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,X.jsx)(woe,{...e,form:i})},e.FormGroup=function(e){return(0,X.jsx)(koe,{...e,form:i})},e.Subscribe=function(e){return(0,X.jsx)(Aoe,{form:i,selector:e.selector,children:e.children})},e},[i]);T5(i.mount,[]),T5(()=>{i.update(e)});let s=(0,K.useRef)(!1);return T5(()=>{s.current&&e?.transform&&Soe(i,e.transform)},[i,e?.transform]),T5(()=>{s.current=!0}),o}var O5=(0,K.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsx)(`input`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:Z(`input caps-input w-full`,e),ref:r})});(0,K.forwardRef)(function({leading:e,className:t,...n},r){return(0,X.jsxs)(`span`,{className:`caps-search-input`,"data-leading":e?`true`:void 0,children:[e?(0,X.jsx)(`span`,{className:`caps-search-leading`,"aria-hidden":`true`,children:e}):null,(0,X.jsx)(O5,{...n,type:`search`,className:t,ref:r})]})});function joe(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Moe=e=>{switch(e){case`success`:return Foe;case`info`:return Loe;case`warning`:return Ioe;case`error`:return Roe;default:return null}},Noe=Array(12).fill(0),Poe=({visible:e,className:t})=>K.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},K.createElement(`div`,{className:`sonner-spinner`},Noe.map((e,t)=>K.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Foe=K.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},K.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),Ioe=K.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},K.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),Loe=K.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},K.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),Roe=K.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},K.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),zoe=K.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},K.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),K.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),Boe=()=>{let[e,t]=K.useState(document.hidden);return K.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},Voe=1,Hoe=100,k5=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:Voe++,A5=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-Hoe;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=k5(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],K.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(Woe(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!K.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!K.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!K.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!K.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=k5(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},Uoe=(e,t)=>A5.message(e,t),Woe=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,Goe=Object.assign(Uoe,{success:A5.success,info:A5.info,warning:A5.warning,error:A5.error,custom:A5.custom,message:A5.message,promise:A5.promise,dismiss:A5.dismiss,loading:A5.loading},{getHistory:()=>A5.toasts,getToasts:()=>A5.getActiveToasts()});joe(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function j5(e){return e.label!==void 0}var Koe=3,qoe=`24px`,Joe=`16px`,M5=4e3,Yoe=356,Xoe=14,Zoe=45,Qoe=200;function N5(...e){return e.filter(Boolean).join(` `)}function $oe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var ese=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=K.useState(null),[O,k]=K.useState(null),[A,j]=K.useState(!1),[M,N]=K.useState(!1),[P,F]=K.useState(!1),[I,L]=K.useState(!1),[R,z]=K.useState(!1),[B,V]=K.useState(0),[H,ee]=K.useState(0),te=K.useRef(n.duration||y||M5),U=K.useRef(null),W=K.useRef(null),ne=c===0,re=c+1<=o,ie=n.type,ae=ie??`default`,oe=n.dismissible!==!1,se=n.className||``,G=n.descriptionClassName||``,ce=K.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),le=K.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ue=K.useMemo(()=>n.duration||y||M5,[n.duration,y]),de=K.useRef(0),fe=K.useRef(0),pe=K.useRef(0),me=K.useRef(null),[he,ge]=b.split(`-`),_e=K.useMemo(()=>s.reduce((e,t,n)=>n>=ce?e:e+t.height,0),[s,ce]),ve=Boe(),ye=K.useMemo(()=>e.swipeDirections??$oe(b),[e.swipeDirections,b]),be=n.invert||t,xe=ie===`loading`;fe.current=K.useMemo(()=>ce*x+_e,[ce,_e]),K.useEffect(()=>{te.current=ue},[ue]),K.useEffect(()=>{j(!0)},[]),K.useEffect(()=>{let e=W.current;if(e){let t=e.getBoundingClientRect().height;return ee(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),K.useLayoutEffect(()=>{if(!A)return;let e=W.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ee(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let Se=K.useCallback(()=>{N(!0),V(fe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},Qoe)},[n,d,a,fe]);K.useEffect(()=>{if(n.promise&&ie===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||ve?(()=>{if(pe.current<de.current){let e=new Date().getTime()-de.current;te.current-=e}pe.current=new Date().getTime()})():te.current!==1/0&&(de.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Se()},te.current)),()=>clearTimeout(e)},[u,i,n,ie,ve,Se]),K.useEffect(()=>{n.delete&&(Se(),n.onDismiss==null||n.onDismiss.call(n,n))},[Se,n.delete]);function Ce(){return w?.loading?K.createElement(`div`,{className:N5(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ie===`loading`},w.loading):K.createElement(Poe,{className:N5(C?.loader,n?.classNames?.loader),visible:ie===`loading`})}let we=n.icon||w?.[ie]||Moe(ie);return K.createElement(`li`,{tabIndex:0,ref:W,className:N5(_,se,C?.toast,n?.classNames?.toast,C?.[ae],n?.classNames?.[ae]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":re,"data-y-position":he,"data-x-position":ge,"data-index":c,"data-front":ne,"data-swiping":P,"data-dismissible":oe,"data-type":ie,"data-invert":be,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?B:fe.current}px`,"--initial-height":S?`auto`:`${H}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),me.current=null},onPointerDown:e=>{e.button!==2&&(xe||!oe||(U.current=new Date,V(fe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),me.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!oe)return;me.current=null;let e=Number(W.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(W.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-U.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if((E===`x`?ye.includes(e>0?`right`:`left`):ye.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=Zoe||a>.11)){V(fe.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Se(),L(!0);return}var o,s;(o=W.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=W.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),z(!1),F(!1),D(null)},onPointerMove:e=>{var t,n;if(!me.current||!oe||window.getSelection()?.toString().length>0)return;let r=e.clientY-me.current.y,i=e.clientX-me.current.x;!E&&(Math.abs(i)>1||Math.abs(r)>1)&&D(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(ye.includes(`top`)||ye.includes(`bottom`)){if(ye.includes(`top`)&&r<0||ye.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(E===`x`&&(ye.includes(`left`)||ye.includes(`right`))){if(ye.includes(`left`)&&i<0||ye.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&z(!0),(t=W.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=W.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},le&&!n.jsx&&ie!==`loading`?K.createElement(`button`,{"aria-label":T,"data-disabled":xe,"data-close-button":!0,onClick:xe||!oe?()=>{}:()=>{Se(),n.onDismiss==null||n.onDismiss.call(n,n)},className:N5(C?.closeButton,n?.classNames?.closeButton)},w?.close??zoe):null,(ie||n.icon||n.promise)&&n.icon!==null&&(w?.[ie]!==null||n.icon)?K.createElement(`div`,{"data-icon":``,className:N5(C?.icon,n?.classNames?.icon)},ie===`loading`?n.icon||Ce():n.promise?Ce():null,ie===`loading`?null:we):null,K.createElement(`div`,{"data-content":``,className:N5(C?.content,n?.classNames?.content)},K.createElement(`div`,{"data-title":``,className:N5(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?K.createElement(`div`,{"data-description":``,className:N5(v,G,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),K.isValidElement(n.cancel)?n.cancel:n.cancel&&j5(n.cancel)?K.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{j5(n.cancel)&&oe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Se())},className:N5(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,K.isValidElement(n.action)?n.action:n.action&&j5(n.action)?K.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{j5(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Se())},className:N5(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function P5(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function tse(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?Joe:qoe;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var nse=K.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=Koe,toastOptions:g,dir:_=P5(),gap:v=Xoe,icons:y,customAriaLabel:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=K.useState([]),w=K.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=K.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=K.useState([]),[O,k]=K.useState(!1),[A,j]=K.useState(!1),[M,N]=K.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=K.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=K.useRef(null),L=K.useRef(!1),R=K.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||A5.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return K.useEffect(()=>A5.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{n2.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),K.useEffect(()=>{if(d!==`system`){N(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?N(`dark`):N(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{N(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{N(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),K.useEffect(()=>{S.length<=1&&k(!1)},[S]),K.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=P.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===P.current||P.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),K.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),K.createElement(`section`,{ref:t,"aria-label":b??`${x} ${F}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?K.createElement(`ol`,{key:t,dir:_===`auto`?P5():_,tabIndex:-1,ref:P,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${Yoe}px`,"--gap":`${v}px`,...m,...tse(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>K.createElement(ese,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:R,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:v,expanded:O,swipeDirections:e.swipeDirections}))):null}))});function rse({className:e,...t}){let n=b6(`toast`);return n?(0,n2.createPortal)((0,X.jsx)(nse,{position:`top-right`,swipeDirections:[`right`,`top`],offset:16,gap:8,className:Z(`caps-toaster`,e),...t}),n):null}var ise=(0,K.forwardRef)(function({children:e,className:t,optional:n,required:r,...i},a){return(0,X.jsxs)(`label`,{...i,className:Z(`label caps-label cursor-pointer justify-start gap-sm text-sm font-semibold text-base-content`,t),ref:a,children:[e,r?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-error`,children:`*`}):null,n&&!r?(0,X.jsx)(`span`,{className:`caps-label-optional`,children:`Optional`}):null]})}),F5=(0,K.forwardRef)(function({children:e,className:t,...n},r){return(0,X.jsx)(`div`,{...n,className:Z(`caps-input-group join flex w-full items-stretch [&>*]:join-item [&>*:first-child]:rounded-e-none [&>*:last-child]:rounded-s-none [&>*:not(:first-child):not(:last-child)]:rounded-none [&>.btn]:shrink-0 [&>.input]:min-w-0 [&>.input]:flex-1 [&>.select]:min-w-0 [&>.select]:flex-1`,t),ref:r,children:K.Children.map(e,e=>(0,K.isValidElement)(e)?(0,K.cloneElement)(e,{className:Z(`join-item caps-input-group-control`,e.props.className)}):e)})}),I5=(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,className:Z(`join-item flex items-center border border-base-300 bg-base-200 px-md text-sm text-base-content`,e),ref:n})});function ase(e){let t=e.parentElement;if(!t||e.previousElementSibling===null)return 0;let n=getComputedStyle(t);if(!(n.display.includes(`grid`)||n.display.includes(`flex`)&&n.flexDirection.startsWith(`column`)))return 0;let r=Number.parseFloat(n.rowGap);return Number.isFinite(r)?r:0}(0,K.forwardRef)(function({show:e,appear:t=!1,children:n,className:r,...i},a){let o=(0,K.useRef)(null);(0,K.useImperativeHandle)(a,()=>o.current);let s=jP(),[c,l]=(0,K.useState)(e),u=(0,K.useRef)(!0);return e&&!c&&l(!0),(0,K.useLayoutEffect)(()=>{let n=o.current,r=u.current;if(u.current=!1,!n||r&&!t)return;if(!kP(n)){e||l(!1);return}let i=TP(n),a=`translateY(${String(i.distance)}px)`,c=OP(i,i.ease),d=n.getBoundingClientRect().height,f=ase(n),p=(e,t)=>{n.style.overflow=`clip`;let r=e=>({height:`${String(e)}px`,marginBlockStart:`${String(e===0?-f:0)}px`}),a=n.animate([r(e),r(t)],{duration:i.normal,easing:c}),o=()=>{n.style.removeProperty(`overflow`)};return a.addEventListener(`finish`,o),a.addEventListener(`cancel`,o),a};if(e){let e=[n.animate([{opacity:0,transform:a},{opacity:1,transform:`none`}],{duration:i.normal,easing:c})];return!s&&d>0&&e.push(p(0,d)),()=>{for(let t of e)t.cancel()}}let m=n.animate([{opacity:1,transform:`none`},{opacity:0,transform:a}],{duration:i.fast,easing:OP(i,i.easeExit),fill:`forwards`}),h=!s&&d>0?p(d,0):m;return h!==m&&h.effect?.updateTiming({fill:`forwards`}),h.addEventListener(`finish`,()=>{l(!1)}),()=>{m.cancel(),h.cancel()}},[e,t,s]),c?(0,X.jsx)(`div`,{...i,ref:o,className:Z(`caps-presence`,r),"data-present":e,"aria-hidden":!e||void 0,children:n}):null});var ose=(0,K.forwardRef)(function({open:e,children:t,className:n,...r},i){return(0,X.jsx)(`div`,{...r,ref:i,className:Z(`caps-collapse`,n),"data-open":e,"aria-hidden":!e||void 0,children:(0,X.jsx)(`div`,{className:`caps-collapse-clip`,children:t})})});(0,K.forwardRef)(function({swapKey:e,anchor:t=`start`,children:n,className:r,...i},a){let o=(0,K.useRef)(null);(0,K.useImperativeHandle)(a,()=>o.current);let s=jP(),[c,l]=(0,K.useState)({key:e,content:n}),[u,d]=(0,K.useState)([]);c.key===e?c.content!==n&&l({key:e,content:n}):(d([...u.filter(t=>t.key!==e&&t.key!==c.key),c]),l({key:e,content:n}));let f=(0,K.useRef)(null);return(0,K.useLayoutEffect)(()=>{let e=o.current;if(!e||!(`ResizeObserver`in globalThis))return;f.current=e.getBoundingClientRect();let t=new ResizeObserver(()=>{e.getAnimations().length===0&&(f.current=e.getBoundingClientRect())});return t.observe(e),()=>{t.disconnect()}},[]),(0,K.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=[...e.querySelectorAll(`:scope > [data-swap-leaving]`)],n=e.querySelector(`:scope > [data-swap-current]`);if(n===null||t.length===0)return;if(!kP(e)){d([]);return}let r=f.current,i=e.getBoundingClientRect(),a=TP(e),c=[n.animate([{opacity:0,filter:`blur(${String(a.blur)}px)`,transform:`translateY(${String(a.distance/2)}px)`},{opacity:1,filter:`blur(0px)`,transform:`none`}],{duration:a.normal,easing:OP(a,a.ease)})];for(let e of t){let t=e.animate([{opacity:1,filter:`blur(0px)`,transform:`none`},{opacity:0,filter:`blur(${String(a.blur)}px)`,transform:`translateY(${String(-a.distance/2)}px)`}],{duration:a.fast,easing:OP(a,a.easeExit),fill:`forwards`}),n=e.dataset.swapLeaving;t.onfinish=()=>{d(e=>e.filter(e=>e.key!==n))},c.push(t)}let l=r!==null&&(Math.abs(r.height-i.height)>.5||Math.abs(r.width-i.width)>.5);return!s&&l&&c.push(e.animate([{width:`${String(r.width)}px`,height:`${String(r.height)}px`},{width:`${String(i.width)}px`,height:`${String(i.height)}px`}],{duration:a.normal,easing:OP(a,a.ease)})),()=>{for(let e of c)e.cancel()}},[e,s]),(0,X.jsx)(`div`,{...i,ref:o,className:Z(`caps-swap`,r),"data-anchor":t,children:[...u.map(e=>(0,X.jsx)(`div`,{className:`caps-swap-layer`,"data-swap-leaving":e.key,"aria-hidden":`true`,children:e.content},e.key)),(0,X.jsx)(`div`,{className:`caps-swap-layer`,"data-swap-current":``,children:n},e)]})});function L5({children:e,...t}){let[n,r]=(0,K.useState)(e);return e&&e!==n&&r(e),(0,X.jsx)(ose,{...t,className:Z(`caps-field-error-reveal`,t.className),open:!!e,children:(0,X.jsx)(`div`,{className:`caps-field-error`,role:`alert`,"aria-hidden":!e,children:n})})}function R5({children:e,divider:t=!0,error:n,layout:r=`end`,status:i,...a}){return(0,X.jsxs)(`footer`,{...a,className:Z(`caps-form-footer`,a.className),"data-divider":t,"data-layout":r,children:[(0,X.jsx)(L5,{children:n}),(0,X.jsxs)(`div`,{className:`caps-form-footer-row`,children:[i?(0,X.jsx)(`div`,{className:`caps-form-footer-status`,role:`status`,children:i}):null,(0,X.jsx)(`div`,{className:`caps-form-footer-actions`,children:e})]})]})}var sse=(0,K.forwardRef)(function({busy:e=!1,children:t,className:n,layout:r,...i},a){return(0,X.jsx)(`form`,{...i,"aria-busy":e||void 0,className:Z(`caps-form`,n),"data-layout":r,ref:a,children:(0,X.jsx)(`fieldset`,{className:`caps-form-body`,disabled:e,children:t})})}),cse={2:`h2`,3:`h3`,4:`h4`},lse=(0,K.forwardRef)(function({children:e,className:t,description:n,layout:r,level:i=3,title:a,...o},s){let c=(0,K.useId)(),l=cse[i];return(0,X.jsxs)(`section`,{...o,"aria-labelledby":`${c}-title`,className:Z(`caps-form-section`,t),"data-layout":r,ref:s,children:[(0,X.jsxs)(`header`,{className:`caps-form-section-copy`,children:[(0,X.jsx)(l,{className:`caps-form-section-title`,id:`${c}-title`,children:a}),n?(0,X.jsx)(`p`,{className:`caps-form-section-description`,children:n}):null]}),(0,X.jsx)(`div`,{className:`caps-form-section-fields`,children:e})]})}),z5=(0,K.forwardRef)(function({children:e,className:t,description:n,error:r,layout:i,legend:a,legendTitle:o,...s},c){let l=(0,K.useId)(),u=[n?`${l}-description`:s[`aria-describedby`],r?`${l}-error`:null].filter(Boolean).join(` `)||void 0;return(0,X.jsxs)(`fieldset`,{...s,"aria-describedby":u,"aria-invalid":r?!0:s[`aria-invalid`],className:Z(`caps-fieldset`,t),"data-layout":i,ref:c,children:[(0,X.jsx)(`legend`,{className:`caps-fieldset-legend`,title:o,children:a}),n?(0,X.jsx)(`p`,{className:`caps-fieldset-description`,id:`${l}-description`,children:n}):null,(0,X.jsx)(`div`,{className:`caps-fieldset-fields`,children:e}),r===void 0?null:(0,X.jsx)(L5,{id:`${l}-error`,children:r})]})});function use(e){let t=[];return K.Children.forEach(e.props.children,e=>{(0,K.isValidElement)(e)&&e.type!==I5&&t.push(e)}),t[0]??null}var B5=(0,K.forwardRef)(function({children:e,className:t,description:n,error:r,icon:i,label:a,labelTitle:o,optional:s,orientation:c=`vertical`,readout:l=!1,required:u,...d},f){let p=(0,K.useId)(),m=(0,K.isValidElement)(e)?e:null,h=m?.type===F5,g=h?use(m):m,_=g?.props.id??p,v=`${_}-description`,y=`${_}-error`,b=[g?.props[`aria-describedby`],n?v:null,r?y:null].filter(Boolean).join(` `)||void 0,x=u===!0||g?.props.required,S=r?!0:g?.props[`aria-invalid`],C=u===!0||g?.props[`aria-required`],w={id:_};x!==void 0&&(w.required=x),b!==void 0&&(w[`aria-describedby`]=b),S!==void 0&&(w[`aria-invalid`]=S),C!==void 0&&(w[`aria-required`]=C);let T=m&&g&&!l?h?(0,K.cloneElement)(m,void 0,K.Children.map(m.props.children,e=>e===g?(0,K.cloneElement)(g,w):e)):(0,K.cloneElement)(m,w):e,E=a?(0,X.jsx)(ise,{htmlFor:l?void 0:_,title:o,className:c===`inline`?`font-normal`:void 0,...u===void 0?{}:{required:u},...s===void 0?{}:{optional:s},children:a}):null,D=a||n?(0,X.jsxs)(`div`,{className:`caps-field-copy`,children:[E,n?(0,X.jsx)(`p`,{className:`caps-field-description`,id:v,children:n}):null]}):null,O=i?(0,X.jsxs)(`div`,{className:`caps-field-lead`,children:[(0,X.jsx)(`span`,{className:`caps-field-icon`,"aria-hidden":`true`,children:i}),D]}):D;return(0,X.jsxs)(`div`,{...d,className:Z(`caps-field`,t),"data-orientation":c,ref:f,children:[c===`horizontal`?(0,X.jsxs)(`div`,{className:`caps-field-row`,children:[O,T]}):c===`inline`?(0,X.jsxs)(`div`,{className:`caps-field-row`,children:[T,O]}):(0,X.jsxs)(X.Fragment,{children:[O,T]}),(0,X.jsx)(L5,{id:y,children:r})]})});function dse(e){let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1}var V5=`M 9.86 38.14 A 20 20 0 1 1 38.14 38.14`,fse=6,pse=new Map([[`ArrowUp`,1],[`ArrowDown`,-1],[`PageUp`,10],[`PageDown`,-10]]),mse=(0,K.forwardRef)(function({className:e,decrementLabel:t=`Decrease`,defaultValue:n=null,disabled:r,incrementLabel:i=`Increase`,invalid:a,max:o,min:s,onBlur:c,onKeyDown:l,onValueChange:u,step:d=1,unit:f,value:p,wrap:m=!1,...h},g){let[_,v]=(0,K.useState)(n),[y,b]=(0,K.useState)(null),x=p===void 0?_:p,S=dse(d),C=e=>{let t=Number(e.toFixed(S));return s!==void 0&&t<s?s:o!==void 0&&t>o?o:t},w=e=>{let t=e===null?null:C(e);v(t),b(null),t!==x&&u?.(t)},T=()=>{if(y===null)return;let e=Number(y);w(y.trim()===``||!Number.isFinite(e)?null:e)},E=e=>{let t=(x??s??0)+e*d;if(m&&s!==void 0&&o!==void 0){if(t>o){w(s);return}if(t<s){w(o);return}}w(t)},D=s!==void 0&&x!==null&&x<=s,O=o!==void 0&&x!==null&&x>=o,k=r===!0,A=(0,K.useRef)(null),j=s!==void 0&&o!==void 0&&o>s?((x??s)-s)/(o-s):null,M=e=>{k||(e.currentTarget.setPointerCapture(e.pointerId),A.current={y:e.clientY,value:x??s??0})},N=e=>{if(!A.current)return;let t=Math.trunc((A.current.y-e.clientY)/fse),n=C(A.current.value+t*d);n!==x&&w(n)},P=()=>{A.current=null};return(0,X.jsxs)(`span`,{className:Z(`caps-number-field`,e),"data-at-max":O||void 0,"data-at-min":D||void 0,"data-disabled":k||void 0,"data-wrap":m||void 0,children:[j===null?null:(0,X.jsxs)(`svg`,{className:`caps-number-field-dial`,viewBox:`0 0 48 48`,"aria-hidden":`true`,focusable:`false`,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:P,children:[(0,X.jsx)(`path`,{className:`caps-number-field-dial-track`,d:V5,pathLength:100}),(0,X.jsx)(`path`,{className:`caps-number-field-dial-level`,d:V5,pathLength:100,strokeDasharray:`${String(Math.max(.5,j*100))} 100`})]}),(0,X.jsx)(XI,{type:`button`,variant:`outline`,size:`icon`,className:`caps-number-field-decrement`,"aria-label":t,"aria-controls":h.id,tabIndex:-1,disabled:k||D&&!m,onClick:()=>{E(-1)},children:(0,X.jsx)(CL,{"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`caps-number-field-readout`,children:[(0,X.jsx)(`input`,{...h,"aria-invalid":a?!0:h[`aria-invalid`]===!1?void 0:h[`aria-invalid`],className:`input caps-input caps-number-field-input`,disabled:r,inputMode:h.inputMode??(S>0?`decimal`:`numeric`),max:o,min:s,onBlur:e=>{T(),c?.(e)},onChange:e=>{b(e.target.value)},onKeyDown:e=>{if(l?.(e),e.defaultPrevented)return;let t=pse.get(e.key);t===void 0?e.key===`Home`&&s!==void 0?(e.preventDefault(),w(s)):e.key===`End`&&o!==void 0?(e.preventDefault(),w(o)):e.key===`Enter`&&T():(e.preventDefault(),E(t))},ref:g,step:d,type:`number`,value:y??(x===null?``:String(x))}),f?(0,X.jsx)(`span`,{className:`caps-number-field-unit`,"aria-hidden":`true`,children:f}):null]}),(0,X.jsx)(XI,{type:`button`,variant:`outline`,size:`icon`,className:`caps-number-field-increment`,"aria-label":i,"aria-controls":h.id,tabIndex:-1,disabled:k||O&&!m,onClick:()=>{E(1)},children:(0,X.jsx)(wL,{"aria-hidden":`true`})})]})}),H5=(0,K.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,X.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:Z(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,X.jsx)(yL,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function hse({checked:e}){let t=`caps-switch-${(0,K.useId)().replaceAll(`:`,``)}`,n=(0,K.useRef)(null),r=(0,K.useRef)(null),i=(0,K.useRef)(e).current,a=(0,K.useRef)(e),o=jP();return(0,K.useLayoutEffect)(()=>{if(!n.current||!r.current)return;let t=o||a.current===e;a.current=e;let i=e?16:8,s=TP(n.current),c=n8(s,{bounce:.25,duration:440}),l=r8(s,{ease:`inOutSine`,duration:100}),u=FI(n.current,t?{x:2,y:2,width:i,height:8,duration:0}:{x:[{to:e?2.5:1.5,...l},{to:2,...c}],y:[{to:1.5,...l},{to:2,...c}],height:[{to:9,...l},{to:8,...c}],width:[{to:e?7:16.5,...l},{to:i,...c}]}),d=FI(r.current,{gradientTransform:e?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`,...t?{duration:0}:{delay:l.duration,...c}});return()=>{u.cancel(),d.cancel()}},[e,o]),(0,X.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(zI,{ref:r,id:`${t}-surface`,transform:i?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(BI,{id:`${t}-shadow`}),(0,X.jsx)(VI,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-track`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,X.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,X.jsx)(`rect`,{ref:n,x:`2`,y:`2`,width:i?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var U5=(0,K.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,K.useRef)(null),[c,l]=(0,K.useState)(n),u=t??c;return(0,K.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,K.useEffect)(()=>{let e=s.current?.form;if(!e||t!==void 0)return;let r=e=>{queueMicrotask(()=>{!e.defaultPrevented&&s.current&&l(n)})};return e.addEventListener(`reset`,r),()=>{e.removeEventListener(`reset`,r)}},[t,n,a.form]),(0,X.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,X.jsx)(`input`,{...a,checked:u,className:Z(`caps-switch-input`,e),onChange:e=>{t===void 0&&l(e.target.checked),r?.(e),i?.(e.target.checked)},ref:s,role:`switch`,type:`checkbox`}),(0,X.jsx)(hse,{checked:u})]})}),gse={2:`h2`,3:`h3`,4:`h4`};function _se(e,t){let{reduced:n}=t,r=e&&!n,i=DP(t,600),[a,o]=(0,K.useState)(r);return(0,K.useEffect)(()=>{if(o(r),!r)return;let e=globalThis.setTimeout(()=>{o(!1)},i);return()=>{globalThis.clearTimeout(e)}},[r,i]),a}var W5=(0,K.forwardRef)(function({actions:e,className:t,description:n,headingLevel:r=2,suggestions:i,thinking:a=!1,title:o,visual:s,renderVisual:c,variant:l=`plain`,...u},d){let f=(0,K.useId)(),p=(0,K.useRef)(null),m=EP(p),h=_se(l===`speech`,m)&&!a,g=gse[r],_=c?c({speaking:h,thinking:a}):s,v=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(g,{ref:p,className:`empty-state-title`,id:u[`aria-labelledby`]?void 0:f,children:o}),(0,X.jsx)(`p`,{children:n}),i&&i.length>0?(0,X.jsx)(`ul`,{"aria-label":`Try one of these`,className:`empty-state-suggestions`,children:i.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(XI,{size:`sm`,variant:`outline`,onClick:e.onSelect,children:e.label})},e.label))}):null,e?(0,X.jsx)(`div`,{className:`empty-state-actions`,children:e}):null]});return(0,X.jsxs)(`section`,{...u,"aria-labelledby":u[`aria-labelledby`]??f,className:Z(`empty-state`,l!==`plain`&&`empty-state-${l}`,t),ref:d,children:[_?(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`empty-state-visual`,children:_}):null,l===`speech`?(0,X.jsx)(`div`,{className:`empty-state-bubble`,children:v}):v]})});function vse(e,t){return{kind:`button`,id:`folder`,text:t.checking?`Checking…`:`prints`,icon:`folder`,title:e===null?`Choose where Prints saves images`:NC(`Save prints to ${e}`,1024),opens:`dialog`,expanded:t.editing}}var yse=`modulepreload`,bse=function(e,t){return new URL(e,t).href},G5={},xse=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=bse(t,n),t=s(t),t in G5)return;G5[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:yse,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Sse(e,t=/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)){return e.startsWith(`<leader>`)?`Ctrl K ${e.slice(8)}`:e.split(` `).map(e=>e.split(`+`).map(e=>e===`mod`?t?`⌘`:`Ctrl`:e===`escape`?`Esc`:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join(e===`ctrl+k`||e===`mod+k`?` `:`+`)).join(` `)}function Cse(e){let t=new Map;for(let n of e.bindings)t.set(n.commandId,[...t.get(n.commandId)??[],Sse(n.binding)]);return e.slash.map(e=>({alias:e.alias,commandId:e.commandId,command:e.command,title:e.title,description:e.description,category:e.category,order:e.order,grammar:e.arguments,consumesDraft:e.consumesDraft,keys:t.get(e.commandId)??[],availability:e.availability}))}function wse(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();if(r.length===0)return{tier:0,spread:0,indices:[]};let i=e=>Array.from({length:r.length},(t,n)=>e+n);if(n.startsWith(r))return{tier:0,spread:n.length-r.length,indices:i(0)};let a=n.search(RegExp(`[-_\\s]${r.replaceAll(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}`,`u`));if(a>=0)return{tier:1,spread:a,indices:i(a+1)};let o=n.indexOf(r);if(o>=0)return{tier:2,spread:o,indices:i(o)};let s=[],c=0;for(let e of r){let t=n.indexOf(e,c);if(t<0)return;s.push(t),c=t+1}let l=s[0]??0;return{tier:3,spread:(s.at(-1)??0)-l-r.length+1,indices:s}}function Tse(e,t,n,r){return e.map(e=>({entry:e,match:wse(t(e),n)})).filter(e=>e.match!==void 0).sort((e,n)=>e.match.tier-n.match.tier||e.match.spread-n.match.spread||r(e.entry)-r(n.entry)||t(e.entry).localeCompare(t(n.entry))).map(({entry:e,match:t})=>({entry:e,indices:t.indices}))}var K5=[`help`,`login`,`model`];function Ese(e,t,n={}){if(!t.startsWith(`/`)||t.includes(`
91
- `))return{kind:`none`};let r=t.search(/\s/u);if(r<0){let r=t.slice(1);return{kind:`commands`,query:r,items:Tse(e.filter(e=>e.availability.status===`available`&&(r.length===0?e.category===(n.idleCategory??`Conversation`)||K5.includes(e.alias):e.category!==`Advanced`||e.alias.toLocaleLowerCase().startsWith(r.toLocaleLowerCase()))),e=>e.alias,r,e=>{let t=K5.indexOf(e.alias);return r.length===0&&t>=0?t-K5.length:e.order}).map(({entry:e,indices:t})=>({command:e,label:`/${e.alias}`,matches:t.map(e=>e+1),insert:e.grammar===void 0?`/${e.alias}`:`/${e.alias} `}))}}let i=t.slice(1,r),a=e.find(e=>e.alias===i);if(a?.grammar===void 0||a.availability.status!==`available`)return{kind:`none`};let o=t.slice(r).trimStart(),s=(o.includes(` `)?[]:a.grammar.words??[]).filter(e=>e.word.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())).map(e=>({word:e,label:e.word,matches:Array.from({length:o.length},(e,t)=>t),insert:`/${i} ${e.word}`}));return{kind:`arguments`,command:a,query:o,hint:`/${i} ${a.grammar.hint}`,items:s}}var Dse=hA({keyCode:_A(229)});function q5(e){return e.nativeEvent.isComposing||ye(Dse,e.nativeEvent).success}function Ose(e,t){return e.animate(t.reduced?[{opacity:1},{opacity:0}]:[{opacity:1,transform:`none`},{opacity:0,transform:`translateY(-120%)`}],{duration:t.reduced?t.fast:t.normal,easing:OP(t,t.easeExit),fill:`backwards`})}function kse(e,t){let n=-12*Math.min(1.5,t.bounce/.3);return e.animate(t.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translateY(70%)`},{opacity:1,transform:`translateY(${String(n)}%)`,offset:.6},{opacity:1,transform:`none`}],{duration:t.reduced?t.fast:t.springDuration,easing:OP(t,t.ease),fill:`backwards`})}function J5(e,t,n){return e.animate([{opacity:1-n},{opacity:n}],{duration:t.reduced?t.fast:t.normal,delay:n===1&&!t.reduced?t.fast/2:0,easing:OP(t,t.ease),fill:`backwards`})}function Ase(e,t){let n=1+.05*Math.min(1.5,.4+t.bounce/.3);return e.animate([{transform:`scale(1)`},{transform:`scale(${String(n)})`,offset:.4},{transform:`scale(1)`}],{duration:t.springDuration,easing:OP(t,`ease-out`)})}var jse=(0,K.forwardRef)(function({state:e,onStop:t,stopLabel:n=`Stop`,iconSize:r=20,onClick:i,disabled:a,className:o,tone:s=`primary`,"aria-label":c,...l},u){let d=(0,K.useRef)(null);(0,K.useImperativeHandle)(u,()=>d.current);let f=(0,K.useRef)(e);(0,K.useLayoutEffect)(()=>{let t=d.current,n=f.current;if(f.current=e,!t||n===e||!kP(t))return;let r=t.querySelector(`[data-glyph="arrow"]`),i=t.querySelector(`[data-glyph="busy"]`);if(!r||!i)return;let a=TP(t),o=[];return e===`busy`?o.push(Ose(r,a),J5(i,a,1)):n===`busy`&&o.push(J5(i,a,0),kse(r,a)),n===`empty`&&e===`ready`&&!a.reduced&&o.push(Ase(t,a)),()=>{for(let e of o)e.cancel()}},[e]);let p=e===`busy`,m=p&&t!==void 0;return(0,X.jsx)(fP,{...l,ref:d,className:Z(`caps-send-action`,o),tone:s,"aria-busy":p?!0:void 0,"aria-label":m?n:c,"data-send-state":e,disabled:a===!0||e===`empty`||p&&!m,onClick:m?t:i,label:null,icon:(0,X.jsxs)(`span`,{className:`caps-send-glyph`,"data-state":e,children:[(0,X.jsx)(`span`,{"data-glyph":`arrow`,children:(0,X.jsx)(Nie,{"aria-hidden":`true`,size:r})}),(0,X.jsx)(`span`,{"data-glyph":`busy`,children:t===void 0?(0,X.jsx)(JI,{decorative:!0,size:`sm`}):(0,X.jsx)(OL,{"aria-hidden":`true`,fill:`currentColor`,size:Math.round(r*.7)})})]})})}),Mse=(0,K.forwardRef)(function({className:e,label:t,...n},r){return(0,X.jsx)(fP,{...n,ref:r,className:Z(`parakeet-composer-model-key`,e),label:t,readout:(0,X.jsx)(yL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),Y5=(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,ref:n,className:Z(`caps-popover-anchor`,e)})}),X5=(0,K.forwardRef)(function({className:e,open:t,side:n=`top`,...r},i){return t?(0,X.jsx)(`div`,{...r,ref:i,className:Z(`caps-popover`,e),"data-side":n}):null}),Nse=(0,K.forwardRef)(function({active:e,className:t,onMouseDown:n,...r},i){return(0,X.jsx)(`div`,{role:`option`,"aria-selected":e,...r,ref:i,className:Z(`caps-popover-option`,t),"data-active":e,onMouseDown:e=>{e.preventDefault(),n?.(e)}})});function Z5({items:e,openId:t,onOpenChange:n,leading:r,trailing:i,renderTrigger:a,placement:o=`housing`,align:s=`end`,hostInset:c,className:l,...u}){let d=(0,K.useId)(),f=(0,K.useRef)(null),p=(0,K.useRef)(null),m=(0,K.useRef)(new Map),h=e.find(e=>e.id===t&&!e.disabled),g=h?.id,_=()=>{g&&m.current.get(g)?.focus(),n(null)};return(0,K.useEffect)(()=>{g&&p.current?.focus()},[g]),(0,K.useEffect)(()=>{c===void 0?f.current?.style.removeProperty(`--caps-status-tray-host-inset`):f.current?.style.setProperty(`--caps-status-tray-host-inset`,`${String(Math.max(0,c))}px`)},[c]),(0,K.useEffect)(()=>{if(!g)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),m.current.get(g)?.focus(),n(null))},t=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&n(null)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[g,n]),(0,X.jsxs)(Y5,{...u,ref:f,className:Z(`caps-status-tray`,l),"data-placement":o,"data-align":s,children:[h?(0,X.jsxs)(X5,{open:!0,ref:p,tabIndex:-1,side:`top`,id:`${d}-${h.id}`,role:`dialog`,"aria-labelledby":`${d}-title`,className:`caps-status-tray-panel`,"data-status-tray-panel":h.id,children:[(0,X.jsxs)(`div`,{className:`caps-status-tray-head`,children:[h.tone?(0,X.jsx)(l8,{size:`compact`,tone:h.tone,glyph:h.glyph??`dot`}):null,(0,X.jsx)(`span`,{id:`${d}-title`,className:`caps-status-tray-title`,children:h.title??h.label}),h.actions,(0,X.jsx)(QI,{"aria-label":`Close tray`,icon:(0,X.jsx)(AL,{"aria-hidden":`true`}),onClick:_})]}),(0,X.jsx)(`div`,{className:`caps-status-tray-body`,children:h.content})]}):null,o===`host`?null:(0,X.jsxs)(`div`,{className:`caps-status-tray-row`,children:[r,(0,X.jsx)(`div`,{className:`caps-status-tray-chips`,children:e.map(e=>{let r={ref:t=>{t?m.current.set(e.id,t):m.current.delete(e.id)},type:`button`,className:a?void 0:`caps-status-tray-chip`,"aria-expanded":g===e.id,"aria-controls":g===e.id?`${d}-${e.id}`:void 0,"aria-label":e.accessibleLabel,disabled:e.disabled,title:e.disabled?e.accessibleLabel:void 0,"aria-haspopup":`dialog`,"data-status-tray-chip":e.id,onClick:()=>{n(t===e.id?null:e.id)},children:(0,X.jsxs)(X.Fragment,{children:[e.tone?(0,X.jsx)(l8,{size:`compact`,glyph:e.glyph??`dot`,motion:e.motion??`none`,tone:e.tone}):null,(0,X.jsx)(`span`,{className:`caps-status-tray-label`,children:e.label}),e.count!==void 0&&e.count>0?(0,X.jsx)(`span`,{className:`caps-status-tray-count`,children:e.count}):null]})};return(0,X.jsxs)(K.Fragment,{children:[a?a(r):(0,X.jsx)(`button`,{...r}),e.after]},e.id)})}),i]})]})}function Pse({children:e,className:t,...n}){return(0,X.jsx)(`div`,{...n,className:Z(`caps-status-tray-list`,t),children:e})}function Q5({icon:e,primary:t,secondary:n,actions:r,className:i,...a}){return(0,X.jsxs)(`div`,{...a,className:Z(`caps-status-tray-item`,i),children:[e?(0,X.jsx)(`span`,{className:`caps-status-tray-icon`,children:e}):null,(0,X.jsxs)(`span`,{className:`caps-status-tray-text`,children:[(0,X.jsx)(`span`,{className:`caps-status-tray-primary`,children:t}),n?(0,X.jsx)(`span`,{className:`caps-status-tray-secondary`,children:n}):null]}),r?(0,X.jsx)(`span`,{className:`caps-status-tray-actions`,children:r}):null]})}function $5({children:e=`All caught up.`,title:t}){return(0,X.jsxs)(`div`,{className:`caps-status-tray-note`,children:[t?(0,X.jsx)(`strong`,{className:`caps-status-tray-note-title`,children:t}):null,(0,X.jsx)(`p`,{children:e})]})}var e7=(0,K.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:Z(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})});function t7(e,t){return`${e}-${String(t)}`}function Fse(e){switch(e.key){case`ArrowDown`:return`next`;case`ArrowUp`:return`previous`;case`Enter`:return e.shiftKey?null:`accept`;case`Tab`:return`accept`;case`Escape`:return`dismiss`;default:return null}}function Ise(e){return{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":e.open,"aria-controls":e.open?e.listId:void 0,"aria-activedescendant":e.open?t7(e.listId,e.selected):void 0}}function n7({open:e,rows:t,selected:n,listId:r,label:i,kind:a,hint:o,empty:s,onHighlight:c,onChoose:l}){return(0,X.jsx)(X5,{open:e,side:`top`,"data-parakeet-slash":``,children:(0,X.jsxs)(`div`,{className:`parakeet-slash-menu`,"data-kind":a,children:[o===void 0?null:(0,X.jsx)(`p`,{className:`parakeet-slash-hint`,children:o}),t.length===0?s===void 0?null:(0,X.jsx)(`p`,{className:`parakeet-slash-hint`,children:s}):(0,X.jsx)(`div`,{id:r,role:`listbox`,"aria-label":i,children:t.map((e,t)=>(0,X.jsxs)(Nse,{id:t7(r,t),active:t===n,"aria-disabled":e.disabled===!0||void 0,"data-disabled":e.disabled===!0,onMouseEnter:()=>{c(t)},onClick:()=>{l(t)},children:[e.media===void 0?null:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`parakeet-slash-media`,children:e.media}),(0,X.jsx)(`span`,{className:`parakeet-slash-label`,children:e.label}),(0,X.jsx)(`span`,{className:`parakeet-slash-detail`,children:e.detail}),e.keys===void 0||e.keys.length===0?null:(0,X.jsx)(`kbd`,{className:`parakeet-slash-keys`,children:e.keys})]},e.key))})]})})}var r7={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},Lse={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function Rse({state:e}){let t=`caps-checkbox-${(0,K.useId)().replaceAll(`:`,``)}`,n=(0,K.useRef)(null),r=(0,K.useRef)(e).current,i=(0,K.useRef)(e),a=jP();return(0,K.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=TP(n.current),c=r8(s,{ease:`inCubic`,duration:160}),l=FI(n.current,{d:{to:r7[e],...o?t8:r8(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?t8:t?r8(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...r8(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:DP(s,120),...n8(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,X.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(zI,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(BI,{id:`${t}-shadow`}),(0,X.jsx)(VI,{id:`${t}-inset`}),(0,X.jsx)(UI,{id:`${t}-goo`,values:Lse}),(0,X.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,X.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,X.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,X.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,X.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,X.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,X.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,X.jsx)(`path`,{ref:n,d:r7[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,X.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,X.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,X.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var i7=(0,K.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,K.useRef)(null),[d,f]=(0,K.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,K.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,K.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,K.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,X.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,X.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:Z(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,X.jsx)(Rse,{state:m}):n]})}),a7=`data-glide-stand-in`;function o7(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left+e.scrollLeft-e.clientLeft,y:r.top-n.top+e.scrollTop-e.clientTop,width:r.width,height:r.height}}function s7(e){return{transform:`translate(${String(e.x)}px, ${String(e.y)}px)`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}}function c7(e){let t=(0,K.useRef)(null);return(0,K.useCallback)(n=>{t.current?.(),t.current=n?zse(n,e):null},[e])}function zse(e,t){if(!kP(e))return()=>void 0;let n=e.ownerDocument,r=e.querySelector(t),i=r?o7(e,r):null,a=null,o=null,s=new Set,c=()=>{for(let e of s)e.removeAttribute(a7);s.clear(),a&&(a.hidden=!0),o=null},l=()=>{if(a)return a;let t=n.createElement(`span`);return t.className=`caps-glide`,t.setAttribute(`aria-hidden`,`true`),e.prepend(t),e.classList.add(`caps-glide-host`),getComputedStyle(e).position===`static`&&e.classList.add(`caps-glide-anchor`),a=t,t},u=(t,n)=>{let r=TP(e),u=o7(e,t),d=o&&a?o7(e,a):i;if(i=u,o?.cancel(),c(),r.reduced||d===null||Math.abs(d.y-u.y)<1&&Math.abs(d.x-u.x)<1)return;t.setAttribute(a7,`measure`);let f=getComputedStyle(t),p=f.backgroundColor,m=f.borderRadius;for(let e of[t,n])e&&(e.setAttribute(a7,``),s.add(e));let h=l();h.hidden=!1,h.style.backgroundColor=p,h.style.borderRadius=m;let g=h.animate([s7(d),s7(u)],{duration:r.normal,easing:OP(r,r.ease),fill:`forwards`});o=g,g.addEventListener(`finish`,()=>{o===g&&c()})},d=()=>{let n=e.querySelector(t);if(n===r)return;let i=r;r=n,n&&u(n,i)},f=new MutationObserver(d);return f.observe(e,{subtree:!0,attributes:!0,attributeFilter:[`data-highlighted`,`data-active`,`data-navigation`,`aria-selected`]}),e.addEventListener(`pointerover`,d),e.addEventListener(`pointerout`,d),()=>{f.disconnect(),e.removeEventListener(`pointerover`,d),e.removeEventListener(`pointerout`,d),o?.cancel(),c(),a?.remove()}}function Bse({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,K.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,K.useState)(null);(0,K.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}function Vse({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=K.useRef(e!==void 0),[a,o]=K.useState(()=>t);return[i&&e!==void 0?e:a,K.useCallback(e=>{i||o(e)},[])]}var Hse=RM(`card caps-card`,{variants:{variant:{surface:`caps-card-surface`,outline:`caps-card-outline`,interactive:`caps-card-interactive`,game:`caps-card-game caps-card-interactive`,fit:`caps-card-fit`},density:{regular:``,compact:`caps-card-compact`}},defaultVariants:{variant:`surface`,density:`regular`}}),l7=(0,K.forwardRef)(function({className:e,density:t,featured:n=!1,state:r,variant:i,...a},o){return(0,X.jsx)(`div`,{...a,className:Z(Hse({density:t,variant:i}),n&&`caps-card-featured`,e),"data-state":r,ref:o})});(0,K.forwardRef)(function({className:e,density:t,variant:n,width:r=`default`,...i},a){return(0,X.jsx)(`main`,{className:`caps-centered-card-stage`,children:(0,X.jsx)(l7,{...i,className:Z(`caps-centered-card`,r===`wide`&&`caps-centered-card-wide`,e),ref:a,variant:n??`surface`,...t?{density:t}:{}})})}),(0,K.forwardRef)(function({alignment:e=`start`,className:t,...n},r){return(0,X.jsx)(`div`,{...n,className:Z(`caps-card-header`,e===`center`&&`caps-card-header-centered`,t),ref:r})}),(0,K.forwardRef)(function({className:e,level:t=3,...n},r){return(0,X.jsx)(t===2?`h2`:`h3`,{...n,className:Z(`caps-card-title`,e),ref:r})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`p`,{...t,className:Z(`caps-card-description`,e),ref:n})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,className:Z(`caps-card-content`,e),ref:n})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,className:Z(`caps-card-footer`,e),ref:n})});var Use=(0,K.forwardRef)(function({action:e,attachments:t,className:n,input:r,toolbar:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:Z(`caps-composer`,n),children:[t===void 0?null:(0,X.jsx)(`div`,{className:`caps-composer-attachments`,children:t}),(0,X.jsx)(`div`,{className:`caps-composer-input`,children:r}),i===void 0&&e===void 0?null:(0,X.jsxs)(`div`,{className:`caps-composer-bar`,children:[(0,X.jsx)(`div`,{className:`caps-composer-toolbar`,children:i}),e]})]})});function Wse({draft:e,hasAttachments:t=!1,busy:n,queueWhileBusy:r=!1,blocked:i=!1}){let a=!i&&(e.trim().length>0||t);return n&&(!r||!a)?`busy`:a?`ready`:`empty`}function Gse({attachments:e,action:t,children:n,className:r,input:i,menu:a,row:o,...s}){return(0,X.jsxs)(Y5,{className:`parakeet-composer-anchor`,children:[a,(0,X.jsxs)(l7,{...s,className:Z(`parakeet-composer-shell`,r),children:[(0,X.jsx)(Use,{action:t,attachments:e,input:i,toolbar:o===void 0?void 0:(0,X.jsx)(Z5,{className:`parakeet-composer-row`,align:`start`,items:o.items,openId:o.openId,onOpenChange:o.onOpenChange,renderTrigger:({children:e,...t})=>(0,X.jsx)(fP,{...t,label:e,expanded:t[`aria-expanded`]===!0}),leading:o.controls,trailing:(0,X.jsxs)(`span`,{className:`parakeet-composer-trailing`,children:[o.status,o.readout==null?null:(0,X.jsx)(`span`,{className:`parakeet-composer-readout`,children:o.readout}),(0,X.jsx)(`span`,{className:`parakeet-composer-action`,children:o.action})]})})}),n]})]})}function Kse(e,t){(0,K.useLayoutEffect)(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${String(t.scrollHeight)}px`)},[e,t])}var u7=K.createContext(void 0);function qse(e){let t=K.useContext(u7);if(t===void 0&&!e)throw Error(sZ(33));return t}var d7=K.createContext(void 0);function f7(e){let t=K.useContext(d7);if(t===void 0&&!e)throw Error(sZ(36));return t}var Jse=K.createContext(void 0);function p7(e=!0){let t=K.useContext(Jse);if(t===void 0&&!e)throw Error(sZ(25));return t}var m7=K.createContext(null);function h7(e=`root`){let t=K.useContext(m7),n=K.useContext(d7);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var Yse={visible:!0,ref:null};function Xse(){return Yse}function g7(e,t,n=`root`){let r=h7(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Xse)({label:e.label,children:e.children,render:e.render}),a=fZ(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var _7=K.createContext(void 0);function Zse(){let e=K.useContext(_7);if(e===void 0)throw Error(sZ(30));return e}function Qse(e){e.preventDefault()}function $se(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=f7(),u=p7(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return K.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?Qse:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:c$})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!z$&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&ZQ(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var v7={type:`regular-item`};function y7(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=K.useRef(null),{getButtonProps:d,buttonRef:f}=QQ({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=$se({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=K.useCallback(e=>kZ(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=fZ(u,f);return K.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var b7=K.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function ece(){return K.useContext(b7)}function x7(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=ece(),u=K.useRef(-1),[d,f]=K.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=K.useRef(null),h=K.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return KQ(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var tce=`data-checked`,nce=`data-unchecked`,S7={checked(e){return e?{[tce]:``}:{[nce]:``}},...$Z},rce=K.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=f7(),m=x7({guess:!0,label:a}),h=w$(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=y7({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:v7}),C=K.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=t$(c$,e.nativeEvent,void 0,{preventUnmountOnClose:SZ});u?.(!l,t)}let T=HZ(`div`,e,{state:C,stateAttributesMapping:S7,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,X.jsx)(_7.Provider,{value:C,children:T})}),ice=K.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=Vse({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=g7(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,X.jsx)(rce,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),ace=K.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Zse(),c=K.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=j2(s.checked);return I2({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),HZ(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:S7,props:{"aria-hidden":!0,...o},enabled:a||u})}),oce=K.createContext(void 0);function sce(){let e=K.useContext(oce);if(e===void 0)throw Error(sZ(31));return e}var cce=K.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=w$(a),c=sce();return KQ(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),HZ(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),lce=K.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=f7(),f=x7({guess:!0,label:a}),p=w$(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=y7({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:v7});return HZ(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),uce=K.forwardRef(function(e,t){let n=g7(e,t);return n.visible?(0,X.jsx)(lce,{...e,ref:n.ref}):null}),dce=K.createContext(void 0);function C7(e){let t=K.useContext(dce);if(t===void 0&&!e)throw Error(sZ(69));return t}function w7(e){return e===`starting`?Z0:wZ}var fce=K.createContext(void 0);function pce(){return K.useContext(fce)}function mce(e,t){let n=KZ(e.render);if(K.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function hce(e,t,n){let r=mce(e,t),i=r===t?void 0:r;return[r,K.useCallback(e=>n?.(e?i:void 0),[i,n])]}function gce(e,t,n){let r=KZ(e.render),i=K.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var _ce=K.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=f7(),m=pce(),{side:h,align:g}=qse(),_=C7(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=hce(e,u,d),L=gce(e,C,N),R=w.type===`menu`?m:void 0,z=w.type===`context-menu`,B=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(B=()=>l.state.activeIndex===null&&P),I2({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),K.useEffect(()=>{function e(e){l.setOpen(!1,t$(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),F4(D,{enabled:A&&!j&&!z&&w.type!==`menubar`,closeDelay:k});let V=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:H,handleFocus:ee}=(K.useContext(m7)?.useParentHandoff??yce)(l,w,v,f),te=HZ(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,V,I],stateAttributesMapping:pQ,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&a6.has(e.key)&&e.stopPropagation()},onFocus:ee},w7(y),c,{"data-rootownerid":E}]}),U=w.type===void 0||z;(C||w.type===`menubar`&&T!==`outside-press`)&&(U=!0);let W=R?.getReturnElement??H;return(0,X.jsx)(E2,{context:D,openInteractionType:M,modal:z,disabled:!x,returnFocus:a??W??U,explicitReturnFocus:a===void 0&&W?!1:void 0,initialFocus:B,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:te})}),vce={parentVirtualFocusRef:void 0,handleFocus:void 0};function yce(){return vce}var bce=K.forwardRef(function(e,t){let n=h7()?.Popup??_ce;return(0,X.jsx)(n,{...e,ref:t})}),T7=K.createContext(void 0);function xce(){let e=K.useContext(T7);if(e===void 0)throw Error(sZ(32));return e}var Sce=K.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=f7();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,X.jsx)(T7.Provider,{value:n,children:(0,X.jsx)(s2,{ref:t,...r,portalOwnerRole:o})})});function Cce(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=K.useState(null),d=K.useRef(null),f=p2(n),p=K.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Z3({...e,elements:{...p,...l&&{reference:l}}}),h=K.useCallback(e=>{let t=bQ(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=K.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=K.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=K.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return KQ(()=>{o&&(d.current=o)},[o]),KQ(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),K.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var wce=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=R1(e,t)||{};if(l==null)return{};let d=n0(u),f={x:n,y:r},p=W1(i),m=H1(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=L1(D,k,O),j=!c.arrow&&B1(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Tce=(e,t)=>{let{name:n,fn:r}=wce(e);return{name:n,fn:r,options:[e,t]}},Ece={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Dce={sideX:`left`,sideY:`top`},Oce=`--available-width`,kce=`--available-height`,Ace=`--anchor-width`,jce=`--anchor-height`,Mce=`--transform-origin`,E7=Oce,D7=kce;function O7(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function k7(e,t,n){let{rects:r,placement:i}=e;return{side:O7(t,z1(i),n),align:B1(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function A7(e){return Nce(e,Cce)}function Nce(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=UQ(O),A=O?k:n,j=S1(n),M=S1(g),N=K6()===`rtl`,[P,F]=K.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?z1(P):null,R=P&&I?B1(P)||`center`:null,z=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],B=R||o,V=B===`center`?z:`${z}-${B}`,H=l;typeof H==`number`?H={top:H,right:H,bottom:H,left:H}:H&&={top:H.top||0,right:H.right||0,bottom:H.bottom||0,left:H.left||0};let ee=+(i===`bottom`),te=+(i===`top`),U=+(i===`right`),W=+(i===`left`),ne={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:H},re=K.useRef(null),ie=S1(a),ae=S1(s),oe=typeof a==`function`?0:a,se=typeof s==`function`?0:s,G=[];p&&G.push(p),G.push(Q3(e=>{let t=k7(e,i,N),n=typeof ie.current==`function`?ie.current(t):ie.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[oe,se,N,i]));let ce=w===`none`&&C!==`shift`,le=!ce&&(u||E||C===`shift`),ue=C===`none`?null:t6({...ne,padding:{top:H.top+1+ee,right:H.right+1+W,bottom:H.bottom+1+te,left:H.left+1+U},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),de=ce?null:$3({...ne,rootBoundary:D,mainAxis:w!==`none`,crossAxis:le,limiter:u||E?void 0:e6(e=>{if(!re.current)return{};let{width:t,height:n}=re.current.getBoundingClientRect(),r=U1(z1(e.placement)),i=r===`y`?t:n,a=r===`y`?H.left+H.right:H.top+H.bottom;return{offset:i/2+a/2}})},[ne,u,E,D,H,w]);C===`shift`||w===`shift`||B===`center`?G.push(de,ue):G.push(ue,de),G.push(n6({...ne,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(E7,`${t}px`),i.setProperty(D7,`${n}px`);let a=_Q(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Ace,`${u}px`),i.setProperty(jce,`${d}px`)}}),Tce(e=>({element:re.current||XQ(e.elements.floating).createElement(`div`),padding:re.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=z1(r),u=B1(r),d=U1(l)===`y`,f=re.current,p=typeof a==`function`?a(k7(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return le&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Mce,d?`${m} ${h}`:`${h} ${m}`),{}}},Ece,b),KQ(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let fe=K.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:pe,elements:me,x:he,y:ge,middlewareData:_e,update:ve,placement:ye,context:be,isPositioned:xe,floatingStyles:Se}=t({rootContext:h,open:m?g:void 0,placement:V,middleware:G,strategy:r,whileElementsMounted:m?void 0:(...e)=>z3(...e,fe),nodeId:y,externalTree:S}),{sideX:Ce,sideY:we}=_e.adaptiveOrigin||Dce,Te=xe?r:`fixed`,Ee=K.useMemo(()=>{let e;return e=xe?b?{position:Te,[Ce]:he,[we]:ge}:{...Se,position:Te}:{position:Te,top:0,left:0},e[E7]=`100vw`,e[D7]=`100vh`,xe||(e.opacity=0),e},[b,Te,Ce,he,we,ge,Se,xe]),De=K.useRef(null);KQ(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(j7(t)?t.current:t)||null;n!==De.current&&(pe.setPositionReference(n),De.current=n)},[g,pe,A,j]),K.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&j7(e)&&e.current!==De.current&&(pe.setPositionReference(e.current),De.current=e.current)},[g,pe,A,j]),K.useEffect(()=>{if(m&&g&&me.reference&&me.floating)return z3(me.reference,me.floating,ve,fe)},[m,g,me,ve,fe]);let Oe=z1(ye),ke=O7(i,Oe,N),Ae=B1(ye)||`center`,je=!!_e.hide?.referenceHidden;KQ(()=>{x&&g&&xe&&(Oe!==z||I&&Ae!==B)&&F(ye)},[x,I,g,xe,ye,Oe,Ae,z,B]);let Me=K.useMemo(()=>({position:`absolute`,top:_e.arrow?.y,left:_e.arrow?.x}),[_e.arrow]),Ne=_e.arrow?.centerOffset!==0;return K.useMemo(()=>({positionerStyles:Ee,arrowStyles:Me,arrowRef:re,arrowUncentered:Ne,side:ke,align:Ae,physicalSide:Oe,anchorHidden:je,refs:pe,context:be,isPositioned:xe,update:ve}),[Ee,Me,re,Ne,ke,Ae,Oe,je,pe,be,xe,ve])}function j7(e){return e!=null&&`current`in e}function Pce(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=UQ(i),[,o]=K.useState(0),s=dZ(Ice).current,c=dZ(Fce).current,l=K.useRef(0),u=K.useRef(!0),d=K.useRef(null),f=K.useRef(null),p=UQ(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=UQ((e,t)=>{c.set(e,t),p()}),h=UQ(e=>{c.delete(e),p()}),g=UQ(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!zce(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&M7(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Rce(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=UQ(()=>{let[e,t]=Lce(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});KQ(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),KQ(()=>{u.current&&v()}),KQ(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=UQ(e=>(s.add(e),()=>{s.delete(e)})),b=K.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,X.jsx)(b7.Provider,{value:b,children:t})}function Fce(){return new Map}function Ice(){return new Set}function Lce(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>M7(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Rce(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function zce(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function M7(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function N7(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=K.useRef(null),o=K.useRef(null),s=F2(r);KQ(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),KQ(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function P7(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),HZ(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},w7(r),i],stateAttributesMapping:fQ})}var Bce=20;function F7(e,t,n,r){let[i,a]=K.useState(!1);KQ(()=>{if(!e||!t||n==null){a(!1);return}let r=XQ(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-Bce)},[e,t,n]),v6(e&&(!t||i),r)}var Vce=K.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=$0,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=f7(),x=xce(),S=p7(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),z=n,B=c,V=l,H=s,ee=h;C.type===`context-menu`&&(z=n??C.context?.anchor,H??=`start`,!o&&H!==`center`&&(V=e.alignOffset??2,B=e.sideOffset??-5));let te=o,U=H;C.type===`menu`?(te??=`inline-end`,U??=`start`,ee=e.collisionAvoidance??e2):C.type===`menubar`&&(te??=C.context.orientation===`vertical`?`inline-end`:`bottom`,U??=`start`);let W=C.type===`context-menu`,ne=A7({anchor:z,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:te,sideOffset:B,align:U,alignOffset:V,arrowPadding:W?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ee,shift:W?{crossAxis:!(`side`in ee&&ee.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});K.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,t$(g$)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),K.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,t$(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let re=k$();K.useEffect(()=>{D||re.clear()},[D,re]),K.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?re.isStarted()||re.start(e,()=>{v.setOpen(!1,t$(g$))}):v.setOpen(!1,t$(g$))}else re.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,re]),K.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),N7({store:v,domReference:R,positionerElement:M,open:D});let ie={open:D,side:ne.side,align:ne.align,anchorHidden:ne.anchorHidden,nested:C.type===`menu`,instant:N},ae=C.type===`menubar`&&C.context.modal;F7(D&&(ae||O&&F!==`trigger-hover`),k===`touch`,M,A);let oe=P7(e,ie,{styles:ne.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),se=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),G=null;return C.type===`menubar`?G=C.context.contentElement:C.type===void 0&&(G=A),(0,X.jsxs)(u7.Provider,{value:ne,children:[se&&(0,X.jsx)(d6,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:u6(!D),cutout:G}),(0,X.jsx)(h2,{id:I,children:(0,X.jsx)(Pce,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:oe})})]})}),Hce=K.createContext(null);function I7(e){let t=K.useContext(Hce);if(t===null&&!e)throw Error(sZ(5));return t}function Uce(e){return e==null?r$:e.type.startsWith(`key`)?p$:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?m$:r$}var Wce={...E4,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=E4.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>V$&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!E4.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Gce=class extends _4{constructor(e,t,n=!1){let r=new Z2,i=qce(r,t,n,e);super(i,Kce(r),Wce),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function Kce(e){return{positionerRef:K.createRef(),popupRef:K.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:K.createRef(),beforeTriggerFocusGuardRef:K.createRef(),beforeContentFocusGuardRef:K.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function qce(e,t,n=!1,r){return{...b4(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:wZ,inputProps:wZ,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new l2,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:wZ,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var L7=K.createContext(null);function R7(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Jce(e,t){return e===`list-navigation`||R7(e,t)}var Yce=o4(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=p7(!0),C=f7(!0),w=I7(!0),T=C?.store,E=C?.virtualFocus??!1,D=K.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=w$(),k=w$(),[A,j]=K.useState(void 0),M=(A??k)||void 0,N=f2(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=dZ(()=>F?P?.state.instantType:void 0).current,L=dZ(()=>{let e=new Gce({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),z=m2(R),B=L.useState(`open`),V=L.useState(`activeTriggerElement`),H=L.useState(`positionerElement`),ee=L.useState(`hoverEnabled`),te=L.useState(`disabled`),U=L.useState(`lastOpenChangeReason`),W=L.useState(`parent`),ne=L.useState(`activeIndex`),re=L.useState(`keyboardOpen`),ie=L.useState(`payload`),ae=L.useState(`floatingParentNodeId`),oe=K.useRef(null),se=K.useRef(W.type!==`context-menu`),G=k$(),ce=K.useRef(!0),le=k$(),ue=ae!=null,{openMethod:de,triggerProps:fe}=rae(B);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:W.type===void 0?c:void 0,openMethod:de,rootId:O}),q2(L);let{forceUnmount:pe,transitionStatus:me}=J2(B,L,()=>{L.set(`allowMouseEnter`,!1)},F),he=F2(L.context.popupRef);K.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!B){e();return}if(me!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return he(e,t.signal),()=>{t.abort()}},[I,B,me,he,L]),KQ(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:z,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:z,floatingParentNodeId:N})},[S,C,z,N,V,L]),K.useEffect(()=>{if(B||(oe.current=null),W.type===`context-menu`){if(!B){G.clear(),se.current=!1;return}G.start(500,()=>{se.current=!0})}},[G,B,W.type]),KQ(()=>{!B&&!ee&&L.set(`hoverEnabled`,!0)},[B,ee,L]);let ge=UQ((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||B===e&&t.trigger===V&&U===n)return;let i=G2(t);if(!e&&t.trigger==null&&(t.trigger=V??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ce.current)return;e&&n===`trigger-focus`?(ce.current=!1,le.start(300,()=>{ce.current=!0})):(ce.current=!0,le.clear());let o=!e&&(n===`escape-key`||n==null);oe.current=t.event;let s=W2(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Jce(n,a),s.instantType=W.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:R7(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),_e=A2({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:ge}),ve=_e.context.events;KQ(()=>{let e=({open:e,eventDetails:t})=>ge(e,t);return ve.on(`setOpen`,e),()=>{ve?.off(`setOpen`,e)}},[ve,ge]),KQ(()=>L.subscribeToParentMenu(),[L]);let ye=K.useCallback(()=>{L.setOpen(!1,t$(_$))},[L]);K.useImperativeHandle(d,()=>({unmount:pe,close:ye}),[pe,ye]);let be;W.type===`context-menu`&&(be=W.context),K.useImperativeHandle(be?.positionerRef,()=>H,[H]),K.useImperativeHandle(be?.actionsRef,()=>({setOpen:ge}),[ge]);let xe=k2(_e,{enabled:!te,bubbles:{escapeKey:f&&W.type===`menu`},outsidePress(){return W.type!==`context-menu`||oe.current?.type===`contextmenu`||se.current},externalTree:ue?R:void 0}),Se=K6(),Ce=W4(_e,{enabled:!te,listRef:L.context.itemDomElements,activeIndex:ne,virtual:v,nested:W.type===`menubar`||!v&&W.type!==void 0,parentOrientation:W.type===`menubar`?W.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?re:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Se===`rtl`,disabledIndices:CZ,onNavigate(e,t){L.setActiveIndex(e,Uce(t),t?.nativeEvent)},openOnArrowKeyDown:W.type!==`context-menu`&&!(v&&_),externalTree:!v&&ue?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),we=K.useCallback(e=>{L.context.typingRef.current=e},[L]),Te=G4(_e,{enabled:!te&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:ne,resetMs:500,onMatch:(e,t)=>{B&&e!==ne&&L.setActiveIndex(e,p$,t.nativeEvent)},onTyping:we}),Ee=UQ(a),De=K.useRef(-1),Oe=UQ(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(De.current===n&&L.context.reportedItem===t)return;De.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=r$,L.context.highlightEvent=void 0,a&&Ee(t,n$(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});KQ(()=>{Oe()},[ne,Oe]);let ke=K.useMemo(()=>{if(!v)return Ce.reference;if(!Ce.trigger)return wZ;let{onFocus:e,...t}=Ce.trigger;return t},[v,Ce.reference,Ce.trigger]);L.useSyncedValue(`inputProps`,v?Ce.reference??wZ:wZ);let Ae=K.useMemo(()=>{let e=kZ(Te.reference,ke,xe.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},fe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=B,e},[L,Te.reference,ke,xe.reference,fe,B]),je=K.useMemo(()=>{let e=kZ(Ce.trigger,xe.trigger,fe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ce.trigger,xe.trigger,fe]);dZ(()=>(L.update({inactiveTriggerProps:je}),null)),Y2(L,{floatingRootContext:_e,activeTriggerProps:Ae,inactiveTriggerProps:je,popupProps:K.useMemo(()=>kZ(R2,{onMouseMove(){L.set(`allowMouseEnter`,!0),W.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Te.floating,Ce.floating,xe.floating),[W.type,L,Te.floating,Ce.floating,xe.floating]),itemProps:Ce.item??wZ});let Me=K.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Oe}),[L,D,u,l,b,k,v,E,Oe]),Ne=typeof t==`function`?t({payload:ie}):t,Pe=(0,X.jsxs)(d7.Provider,{value:Me,children:[p&&(0,X.jsx)(V2,{handle:p,store:L}),Ne]});return(W.type===void 0||W.type===`context-menu`)&&(Pe=(0,X.jsx)(g2,{externalTree:R,children:Pe})),Pe});function Xce(e){let t=K.useContext(L7);if(t===null)return(0,X.jsx)(Yce,{...e});let n=t.Root;return(0,X.jsx)(L7.Provider,{value:null,children:(0,X.jsx)(n,{...t.options,...e})})}var z7=5;function Zce(e,t){let n=Qce(t);return e.clientX>=n.left-z7&&e.clientX<=n.right+z7&&e.clientY>=n.top-z7&&e.clientY<=n.bottom+z7}function Qce(e){let t=e.getBoundingClientRect(),n=_Q(e);if(U$)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function $ce(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=JQ(),{ref:i,index:a}=x7(e),o=n===a,s=K.useRef(null),c=fZ(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function ele(e){let{render:t,className:n,style:r,state:i=wZ,props:a=CZ,refs:o=CZ,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=$ce({metadata:s});return HZ(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function B7(e){if(xQ(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!NQ(e))return B7(IQ(e))}function V7(e,t){function n(n,r,i){let a=n.currentTarget;n2.flushSync(()=>{e.setOpen(!1,t$(u$,n.nativeEvent,a))}),j0(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&M0(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function tle(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=K.useRef(!1);return K.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,XQ(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:wZ,[t,n,r])}var nle=s4(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=f7(!0),h=D4(d)??m?.store;if(!h)throw Error(sZ(85));let g=w$(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=K.useRef(null),S=ile(),C=JQ(!0),w=p2(),T=K.useMemo(()=>w??new l2,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=K2(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:m2(T),floatingParentNodeId:f2(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=QQ({disabled:A,native:o});K.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=K.useRef(null),P=k$(),F=UQ(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Z$(N.current,t)||Z$(h.select(`positionerElement`),t)||t===N.current||(t==null||B7(t)!==h.select(`rootId`))&&(Zce(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:h$}))});K.useEffect(()=>{let e=XQ(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=L4(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:$4({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=rle(y,h.select(`lastOpenChangeReason`)),z=D2(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),B=k4(v,{enabled:!A&&I}),V=tle({open:y,enabled:O,mouseDownAction:`open`}),H=K.useMemo(()=>kZ(B.reference,z.reference),[B.reference,z.reference]),ee=h.useState(`triggerProps`,D),te=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:U,handleFocusTargetFocus:W}=V7(h,x),ne={disabled:A,open:y},re=[N,t,M,E,x],ie=[H,L??wZ,ee,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),XQ(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},te,O?{role:`menuitem`}:{},V,p,j],ae=HZ(`button`,e,{enabled:!O,stateAttributesMapping:dQ,state:ne,ref:re,props:ie});return O?(0,X.jsx)(ele,{tag:`button`,render:n,className:r,style:i,state:ne,refs:re,props:ie,stateAttributesMapping:dQ}):y?(0,X.jsxs)(K.Fragment,{children:[(0,X.jsx)(A1,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:U},`${g}-pre-focus-guard`),(0,X.jsx)(K.Fragment,{children:ae},g),(0,X.jsx)(A1,{ref:h.context.triggerFocusTargetRef,onFocus:W},`${g}-post-focus-guard`)]}):(0,X.jsx)(K.Fragment,{children:ae},g)});function rle(e,t){let n=k$(),[r,i]=K.useState(!1);return KQ(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function ile(){let e=I7(!0);return K.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var ale=K.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return HZ(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),H7=(0,K.createContext)(null);function ole({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,K.useRef)(null),o=e??a;return x6(()=>o.current?.close()),(0,X.jsx)(H7.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,X.jsx)(Xce,{...i,actionsRef:o,onOpenChange:(e,t)=>{if(n===`host`&&!e&&t.reason===`escape-key`){t.cancel(),t.allowPropagation();return}r?.(e,t)},children:t})})}function sle(){let e=(0,K.useContext)(H7);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var cle=(0,K.forwardRef)(function({className:e,render:t,type:n=`button`,...r},i){return(0,X.jsx)(nle,{...r,className:t=>Z(`btn caps-dropdown-trigger`,uP(e,t)),ref:i,render:t,type:n})}),lle=(0,K.forwardRef)(function({container:e,...t},n){let r=b6(`popover`);return e==null&&r===null?null:(0,X.jsx)(Sce,{...t,container:e??r,ref:n})}),ule=(0,K.forwardRef)(function({collisionBoundary:e,...t},n){let r=b6(`popover`);return(0,X.jsx)(Vce,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),dle=(0,K.forwardRef)(function({className:e,finalFocus:t,...n},r){let{interactionOwner:i}=sle(),a=(0,K.useRef)(null);(0,K.useImperativeHandle)(r,()=>a.current);let o=c7(`.caps-dropdown-item[data-highlighted]`),s=(0,K.useCallback)(e=>{a.current=e,o(e)},[o]);return(0,X.jsx)(bce,{...n,className:t=>Z(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,uP(e,t)),finalFocus:i===`host`?!1:t??!0,ref:s})}),fle=(0,K.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,X.jsx)(lle,{container:r,keepMounted:i,children:(0,X.jsx)(ule,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,X.jsx)(dle,{...s,ref:c,children:n})})})}),U7=`caps-dropdown-item flex w-full items-center gap-sm rounded-field px-md py-sm text-left text-sm outline-none transition-colors hover:bg-base-200 focus-visible:bg-base-200 aria-[current=page]:bg-base-200 aria-[current=page]:font-semibold disabled:cursor-not-allowed disabled:text-base-content/40 data-disabled:cursor-not-allowed data-disabled:text-base-content/40`;(0,K.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:r=`default`,...i},a){return(0,X.jsx)(uce,{...i,className:t=>Z(U7,r===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,uP(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:a})});var ple=(0,K.forwardRef)(function({children:e,className:t,onClick:n,onSelect:r,...i},a){return(0,X.jsxs)(ice,{...i,className:e=>Z(U7,uP(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||r?.(e)},ref:a,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,X.jsx)(ace,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})});(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(ale,{...t,className:t=>Z(`my-xs h-px bg-base-300`,uP(e,t)),ref:n})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(cce,{...t,className:t=>Z(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,uP(e,t)),ref:n})});function mle({disabled:e,emptyLabel:t,models:n,onChange:r,value:i}){let a=n.find(e=>e.id===i),[o,s]=(0,K.useState)(null);return(0,X.jsx)(`span`,{className:`contents`,ref:s,children:(0,X.jsxs)(ole,{children:[(0,X.jsx)(cle,{"aria-label":`Generation model`,"data-generation-model":i,disabled:e||n.length===0,render:(e,n)=>(0,X.jsx)(Mse,{...e,expanded:n.open,label:a===void 0?t:XL(a)})}),(0,X.jsx)(fle,{"data-generation-model-menu":!0,container:o,side:`top`,align:`start`,"aria-label":`Generation models`,children:n.map(e=>(0,X.jsx)(ple,{"data-generation-model-option":e.id,checked:e.id===i,closeOnClick:!0,onSelect:()=>{r(e.id)},children:XL(e)},e.id))})]})})}function hle(e){let t=Yk(e),n=(0,K.useRef)(e);n.current=e;let r=_x(),i=NS(DM(e)),a=IS(f8(e,i.data?.configured?i.data.path:null)),[o,s]=(0,K.useState)(null),c=n=>n?.app===e&&n.computerId===t,l=FS({mutationKey:TM.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new Y(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(ER).mkdir({path:r}),a(),await TR(e.capabilities,{path:r,limit:1,offset:0}),a(),Ij(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&s(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:d8.listing(n.owner,n.path),exact:!0})])}),u=l.variables?.owner===e&&l.variables.id===t,d=i.isFetching||u&&l.isPending,f=async(n,r)=>{if(!e||!t||d)return`Computer selection changed. Try again.`;let i=n.trim();if(!eb(XA)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await l.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:TM.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},p=i.isError||a.isError;return{path:p?null:i.data?.path??null,galleryPath:p||!i.data?.configured?null:i.data.path,computerId:t,available:e?.capabilities.has(TA)===!0,writable:e?.capabilities.has(ER)===!0,busy:d,error:p?`Your media folder is unavailable. Choose or create a folder.`:null,editing:c(o),setEditing:n=>{s(n?{app:e,computerId:t}:null)},choose:f,ensureCreated:async()=>i.data?i.data.configured?null:f(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:d8.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:TM.folder(e),exact:!0})}}}var gle=nb(fb),_le=nb(q({message:fb}));function vle(e){for(let t of e.errors){let e=bd(vd(xd(_le(t),e=>e.message),()=>gle(t)));if(e!==void 0&&e.length>0)return e}}var yle={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},W7=(0,K.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,X.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:Z(`progress caps-gooey-motion caps-gooey-progress w-full`,yle[t],e),ref:r})});(0,K.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:Z(`caps-game-meter`,i),children:[(0,X.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,X.jsx)(W7,{"aria-label":e,value:t,max:n,tone:r})]})});function G7({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,X.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,X.jsx)(xle,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function K7({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,X.jsx)(QI,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,X.jsx)(TL,{}):(0,X.jsx)(AL,{}),onClick:()=>void n(t),type:`button`}):null}function ble({item:e}){return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,X.jsx)(`div`,{className:`caps-upload-details`,children:(0,X.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function xle({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,X.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,X.jsx)(zie,{className:`size-4`})}),(0,X.jsx)(ble,{item:e}),(0,X.jsx)(Sle,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,X.jsx)(W7,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function Sle({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,X.jsx)(K7,{action:e.retry,id:t,onAction:i,retry:!0}),(0,X.jsx)(K7,{action:e.cancel,id:t,onAction:n}),(0,X.jsx)(K7,{action:e.remove,id:t,onAction:r})]})}var q7=K.createContext(void 0);function J7(e){let t=K.useContext(q7);if(t===void 0&&!e)throw Error(sZ(47));return t}var Cle={...E4,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!E4.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&E4.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>E4.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},wle=class extends _4{constructor(e,t,n){let r=new Z2;super(Tle(e,r,t,n),Ele(r),Cle)}setOpen=(e,t)=>{let n=t.reason===a$,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=G2(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=W2(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),n2.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Tle(e,t,n,r=!1){let i={...b4(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Ele(e){return{popupRef:K.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:K.createRef(),beforeTriggerFocusGuardRef:K.createRef(),beforeContentFocusGuardRef:K.createRef(),stickIfOpenTimeout:new O$,stickIfOpen:!0,triggerElements:e}}var Y7=o4(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=Ole(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),X2(u,d),q2(u);let{forceUnmount:m}=J2(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),K.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),K.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,t$(_$))}),[m,u]);let h=d||f||s!=null;return(0,X.jsxs)(q7.Provider,{value:u,children:[s&&(0,X.jsx)(V2,{handle:s,store:u}),h&&(0,X.jsx)(kle,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function Dle(e){return J7(!0)?(0,X.jsx)(Y7,{props:e}):(0,X.jsx)(g2,{children:(0,X.jsx)(Y7,{props:e})})}function Ole(e,t){let n=B2((e,n)=>new wle(t,e,n));return K.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function kle({store:e,modal:t}){let n=k2(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Y2(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var Ale=s4(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=J7(!0),h=D4(s)??m;if(!h)throw Error(sZ(74));let g=w$(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=K.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=K2(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=L4(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:$4(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=D2(v,{stickIfOpen:UQ(()=>h.context.stickIfOpen)}),k=y6(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=QQ({disabled:a,native:o}),N={open(e){return w?dQ.open(e):uQ.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=V7(h,x),I=HZ(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[Q0]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,X.jsx)(K.Fragment,{children:I},g);return E?(0,X.jsxs)(K.Fragment,{children:[(0,X.jsx)(A1,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,X.jsx)(A1,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),X7=K.createContext(void 0);function jle(){let e=K.useContext(X7);if(e===void 0)throw Error(sZ(45));return e}var Mle=K.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return J7().useState(`mounted`)||n?(0,X.jsx)(X7.Provider,{value:n,children:(0,X.jsx)(s2,{ref:t,...r})}):null}),Z7=K.createContext(void 0);function Nle(){let e=K.useContext(Z7);if(!e)throw Error(sZ(46));return e}var Ple=K.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=e2,..._}=e,v=J7(),y=jle(),b=m2(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=A7({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});N7({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;F7(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=P7(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,X.jsxs)(Z7.Provider,{value:j,children:[S&&M&&(0,X.jsx)(d6,{inert:u6(!C),cutout:T}),(0,X.jsx)(h2,{id:b,children:P})]})}),Fle=K.createContext(void 0);function Ile(){let[e,t]=K.useState(0),n=UQ(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:K.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Lle=K.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=J7(),l=Nle(),u=C7(!0)!=null,{context:d,hasClosePart:f}=Ile(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);I2({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),F4(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?z2(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=HZ(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...R2,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&a6.has(e.key)&&e.stopPropagation()}},w7(g),s],stateAttributesMapping:pQ});return(0,X.jsx)(E2,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:xQ(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,X.jsx)(Fle.Provider,{value:d,children:M})})}),Rle=(0,K.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,X.jsxs)(`button`,{...r,ref:i,type:n,className:Z(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(yL,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function zle({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(t),[x,S]=(0,K.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,K.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=Bse({getKey:n,isDisabled:o,items:T});(0,K.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(q5(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,K.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function Ble(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,K.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:R,onPointerMove:z,activeItem:B,activeKey:V,commit:H,groups:ee,inputValue:te,listboxId:U,onInputChange:W,onInputKeyDown:ne,open:re,optionId:ie,selectedKeys:ae,setOpen:oe}=zle({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});x6(()=>{O&&oe(!1)});let se=b6(`popover`),G=s===void 0?se:s,ce=c7(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),le=(0,X.jsx)(O5,{..._,...O?{}:L,"aria-activedescendant":B?ie(f(B)):void 0,"aria-autocomplete":`list`,"aria-controls":U,"aria-expanded":!0,className:Z(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),W(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||ne(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:te}),ue=(0,X.jsx)(`div`,{id:U,ref:ce,className:`caps-combobox-list`,"data-navigation":R?`keyboard`:`pointer`,onPointerMove:z,role:`listbox`,"aria-multiselectable":C??void 0,children:ee.every(e=>e.items.length===0)?(0,X.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ee.map(e=>(0,X.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,X.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=V===t,i={active:r,disabled:n,selected:ae.includes(t)};return(0,X.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&R,disabled:n,id:ie(t),onClick:()=>{H(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,X.jsx)(vL,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,X.jsx)(`div`,{...j,className:Z(j.className),ref:D,children:(0,X.jsxs)(Dle,{modal:!0,onOpenChange:oe,open:re,children:[(0,X.jsx)(Ale,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),G===null?null:(0,X.jsx)(Mle,{container:G,children:(0,X.jsx)(Ple,{align:`start`,side:`bottom`,sideOffset:4,children:(0,X.jsxs)(Lle,{"data-active-tone":o,className:Z(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})})]})}):(0,X.jsx)(`div`,{...j,className:Z(j.className),ref:D,children:(0,X.jsxs)(`div`,{className:Z(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})}function Q7({icon:e,caption:t}){return(0,X.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,X.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,X.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var Vle=(0,K.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,X.jsx)(i7,{...a,appearance:r??`default`,"aria-label":e,className:Z(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(Q7,{icon:t,caption:n}),ref:o})})});function Hle({checked:e}){let t=`caps-radio-${(0,K.useId)().replaceAll(`:`,``)}`,n=(0,K.useRef)(null),r=(0,K.useRef)(e).current,i=(0,K.useRef)(e),a=(0,K.useRef)(null),o=EP(a),{reduced:s}=o;return(0,K.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=r8(o,{ease:`outCubic`,duration:75}),c=e?n8(o,{bounce:.65,duration:300}):r8(o,{ease:`inCubic`,duration:100}),l=FI(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,X.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(zI,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(BI,{id:`${t}-shadow`}),(0,X.jsx)(VI,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,X.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var $7=(0,K.createContext)(null),Ule=(0,K.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,K.useId)(),d=(0,K.useRef)(null);(0,K.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,K.useState)(n),h=s??p;return(0,K.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,X.jsx)($7.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,X.jsx)(`fieldset`,{...c,className:Z(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),e9=(0,K.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,K.useContext)($7);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,X.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,X.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:Z(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,X.jsx)(Hle,{checked:c}):t]})}),Wle=(0,K.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,K.useContext)($7),s=(0,K.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,X.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,X.jsx)(e9,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,X.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,X.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,X.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,X.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Gle=(0,K.forwardRef)(function({label:e,icon:t,caption:n,className:r,...i},a){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,children:(0,X.jsx)(e9,{...i,"aria-label":e,className:Z(`caps-icon-choice-input`,r),indicator:(0,X.jsx)(Q7,{icon:t,caption:n}),ref:a})})}),Kle=nb(fb),qle=nb(mb),Jle=nb(xb(jb)),Yle=nb(_b(fb)),t9=_b(Tb(File)),Xle=nb(t9),n9=yb([fb,jb,mb,ub,db,_b(fb),t9]),Zle=nb(n9),r9=e=>_d(Kle(e.state.value),()=>``),i9=e=>_d(qle(e.state.value),()=>!1),Qle=e=>_d(Jle(e.state.value),()=>null),$le=e=>_d(Yle(e.state.value),()=>[]),eue=e=>_d(Xle(e.state.value),()=>[]),tue=e=>_d(Zle(e.state.value),()=>null);function nue({field:e,spec:t,locked:n,...r}){let[i,a]=(0,K.useState)(!1);return(0,X.jsxs)(F5,{children:[(0,X.jsx)(O5,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:r9(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,X.jsx)(XI,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,X.jsx)(Lie,{"aria-hidden":`true`}):(0,X.jsx)(Rie,{"aria-hidden":`true`})})]})}var rue={text:`text`,email:`email`,url:`url`,tel:`tel`};function iue({spec:e,field:t,locked:n,...r}){let i=eue(t),a=n||e.readOnly===!0,o=(0,K.useRef)(null);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(MP,{asChild:!0,children:(0,X.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,X.jsx)(XI,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,X.jsx)(G7,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function aue({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,X.jsx)(O5,{...a,type:rue[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,X.jsx)(e7,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,X.jsx)(nue,{...r,field:t,spec:e,locked:n});case`money`:return(0,X.jsxs)(F5,{children:[(0,X.jsx)(I5,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,X.jsx)(O5,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,X.jsx)(O5,{...a,type:`date`,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,X.jsx)(mse,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:Qle(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,X.jsxs)(H5,{...a,value:r9(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,X.jsx)(Ble,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:r9(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,X.jsx)(Rle,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===r9(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,X.jsx)(iue,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,X.jsx)(i7,{...a,disabled:n||e.readOnly===!0,checked:i9(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,X.jsx)(U5,{...a,disabled:n||e.readOnly===!0,checked:i9(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var oue=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function sue({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=$le(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsx)(z5,{legend:o,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,X.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,X.jsx)(Vle,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):e.options.map(r=>(0,X.jsx)(B5,{label:r.label,description:r.description,orientation:`inline`,children:(0,X.jsx)(i7,{name:e.name,value:r.value,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}})},r.value))})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,X.jsx)(z5,{legend:o,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,X.jsx)(Ule,{name:e.name,"aria-label":o,value:r9(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,X.jsx)(Gle,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,X.jsx)(Wle,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,X.jsx)(B5,{label:t.label,orientation:`inline`,children:(0,X.jsx)(e9,{value:t.value,disabled:t.disabled})},t.value))})})}function cue({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:tue(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function lue({form:e,spec:t,locked:n,layout:r}){let i=E5({form:e,name:t.name}),a=w5(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?vle(i.state.meta):void 0;if(t.render===void 0&&oue.has(t.kind))return(0,X.jsx)(sue,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,X.jsx)(B5,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,X.jsx)(aue,{spec:t,field:i,locked:n}):(0,X.jsx)(cue,{spec:t,field:i,locked:n,error:o,render:t.render})})}var uue=nb(gb(fb,n9));function a9({form:e,spec:t,locked:n,layout:r}){let i=t.when;return w5(e.store,e=>i===void 0||i(_d(uue(e.values),()=>({}))))?(0,X.jsx)(lue,{form:e,spec:t,locked:n,layout:r}):null}function due({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,X.jsx)(a9,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,X.jsx)(lse,{title:t.title,description:t.description,layout:r,children:i})}function fue({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,X.jsx)(due,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,X.jsx)(a9,{form:i,spec:a,locked:n,layout:r},t)})}var o9=class{annotation;constructor(e){this.annotation=e}},pue=class{sections;constructor(e){this.sections=e}},s9=`caps/form`,c9=0;function l9(e){c9+=1;let t={[`${s9}:${String(c9)}`]:new o9(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}fb.annotate(l9({kind:`secret`})).pipe(Cb(`Secret`));var u9=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function mue(e){return Object.values(e??{}).reduce((e,t)=>t instanceof o9?{...e,...t.annotation}:e,{})}function d9(e){return e.reduce((e,t)=>({...e,...mue(t)}),{})}function f9(e){let t=e?.[s9];return t instanceof pue?t.sections:{}}var p9=nb(fb);function m9(e){if(Eg(e))return gd(p9(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!Ag(e))return null;let t=[];for(let n of e.types){if(xg(n))continue;let e=m9(n);if(e===null)return null;t.push(...e)}return t}function h9(e){if(Cg(e))return{type:`string`,literals:[]};if(wg(e))return{type:`number`,nullable:!1};if(Tg(e))return{type:`boolean`};let t=m9(e);if(t!==null)return{type:`string`,literals:t};if(Og(e)){let[t]=e.rest;if(t===void 0)return null;if(Cg(t))return{type:`strings`,literals:[]};let n=m9(t);return n===null?null:{type:`strings`,literals:n}}if(Ag(e)){let t=e.types.filter(e=>!xg(e)&&!bg(e)),n=e.types.some(e=>bg(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=h9(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function hue(e){let t=e.ast;if(!kg(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=Q_(e.type),r=d9([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:h9(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:zte(e.type),description:Bte(e.type)}}),sections:f9(Rte(t))}}function g9(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof ho)n=!0,t=t.unwrap();else if(t instanceof yo)r=!0,t=t.unwrap();else if(t instanceof xo)t=t.unwrap();else if(t instanceof ko)t=t.in;else return{node:t,optional:n,nullable:r}}function _9(e){if(e instanceof Qa){let t=e.options.map(e=>_9(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof co?e.options:e instanceof uo?[...e.values]:null;if(t===null)return null;let n=t.map(e=>p9(e));return n.every(hd)?n.map(e=>e.value):null}function gue(e){let{node:t,nullable:n}=g9(e);if(t instanceof ua)return{type:`string`,literals:[]};if(t instanceof Na)return{type:`number`,nullable:n};if(t instanceof La)return{type:`boolean`};let r=_9(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof qa){let e=g9(t.element).node;if(e instanceof ua)return{type:`strings`,literals:[]};let n=_9(e);return n===null?null:{type:`strings`,literals:n}}return null}function v9(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof ho||e instanceof yo||e instanceof xo?e.unwrap():e instanceof ko?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>$n.get(e))}function y9(e){return v9(e).reduce((e,t)=>({...e,...t}),{})}function _ue(e){return Object.entries(e.shape)}function vue(e){let t=g9(e).node;if(!(t instanceof Ya))throw Error(`A schema form needs a z.object.`);return{fields:_ue(t).map(([e,t])=>{let n=d9(v9(t)),r=n.kind===`file`?{type:`files`}:gue(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=y9(t);return{name:e,valueType:r,optional:g9(t).optional,annotation:n,title:i.title,description:i.description}}),sections:f9(y9(e))}}function yue(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??u9(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function bue(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function xue(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function Sue(e){let t=e instanceof ca?vue(e):hue(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=yue(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??u9(e.name),help:a,kind:n??bue(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=xue(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function b9(e){let t=e instanceof ca?e:$y(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>x9(e)):x9(n)}}}}function x9(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var S9=`onServer`;function Cue(e){let t=e?.querySelector(`[aria-invalid="true"]`);t?.matches(`input, select, textarea, button, [tabindex]`)?t.focus():t?.querySelector(`input, select, textarea, button`)?.focus()}function wue(e){return e.state.meta.errorMap.onServer!==void 0}function Tue(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[S9]:void 0}}))}function Eue(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[S9]:n}}))}function C9(e){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(e.defaultValues),[s,c]=(0,K.useState)(null);Y8(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,K.useMemo)(()=>Sue(l),[l]),d=(0,K.useMemo)(()=>b9(l),[l]),f=D5({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),wue(e)&&Tue(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await b9(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&Eue(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function w9(e){return{dirty:w5(e.form.store,e=>!e.isDefaultValue),submitting:w5(e.form.store,e=>e.isSubmitting),canSubmit:w5(e.form.store,e=>e.canSubmit)}}function T9({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=w9(e),f=(0,K.useRef)(null);return(0,X.jsxs)(sse,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{setTimeout(()=>{Cue(f.current)},0)})},children:[c??(0,X.jsx)(fue,{model:e,disabled:l,layout:o}),s===void 0?(0,X.jsx)(kue,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function Due({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=C9({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,X.jsx)(T9,{...a,model:o})}function Oue(e){return`model`in e?(0,X.jsx)(T9,{...e}):(0,X.jsx)(Due,{...e})}function kue({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=w9(e),d=u?null:e.saved&&!l?(0,X.jsx)(l8,{tone:`success`,size:`compact`,label:e.saved}):l?(0,X.jsx)(l8,{tone:`neutral`,size:`compact`,label:o}):null;return(0,X.jsxs)(R5,{...c,error:e.error,status:d,children:[r?(0,X.jsx)(XI,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,X.jsx)(XI,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,X.jsx)(XI,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var E9={error:0,warning:1,info:2};function Aue(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||E9[e.tone]-E9[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function jue(e,t,n){let r=Aue(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:NC(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var Mue={Setup:(0,X.jsx)(DL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,X.jsx)(bL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,X.jsx)(kL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function Nue({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,X.jsx)(Z5,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,X.jsx)(Pue,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function Pue({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,X.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,X.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,X.jsx)(tL,{level:3,children:e}),(0,X.jsx)(Pse,{children:t.map(e=>(0,X.jsx)(Q5,{icon:Mue[e.group],primary:e.title,secondary:e.detail,actions:(0,X.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map(e=>(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,X.jsx)(QI,{"aria-label":`Dismiss ${e.title}`,icon:(0,X.jsx)(AL,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,X.jsx)($5,{children:`All caught up.`}),t&&t.items.length>0?(0,X.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,X.jsx)(tL,{level:3,children:`Uploading`}),(0,X.jsx)(G7,{...t})]}):null,(0,X.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,X.jsx)(`span`,{className:`prints-footer-note`,children:`Clear keeps setup notices`}),(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function Fue({folder:e}){return(0,X.jsx)(C6,{open:e.editing,onOpenChange:e.setEditing,children:(0,X.jsxs)(O6,{children:[(0,X.jsx)(A6,{children:(0,X.jsx)(j6,{children:`Save prints to`})}),(0,X.jsx)(Lue,{folder:e},e.computerId),(0,X.jsx)(k6,{children:(0,X.jsx)(M6,{render:(0,X.jsx)(XI,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Iue=q({path:Qb.check(Db(eb(XA),{message:`Enter an absolute Computer folder, such as /media.`})).annotate(l9({label:`Folder`,placeholder:`/media`}))});function Lue({folder:e}){let t=(0,K.useRef)(!1),n=C9({schema:Iue,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Oue,{model:n,disabled:i,footer:(0,X.jsxs)(R5,{divider:!1,children:[(0,X.jsx)(fP,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,X.jsx)(fP,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,X.jsx)(Q5,{role:`alert`,icon:(0,X.jsx)(Bie,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,X.jsx)($5,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}function Rue({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,canWrite:s,generationError:c,recoveryError:l,pendingGenerations:u,activeGenerations:d,gallerySlots:f,computerId:p,failed:m,uploadError:h,uploads:g,permissions:_,resume:v,discard:y,retryUpload:b}){let x=[];if(e)p===null?x.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&x.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{_()}}]}):x.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):x.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=lx(new Y(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));x.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}if(e&&p!==null&&!s&&x.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`}),c!==null){let e=c.mediaKind??`media`;x.push({key:c.key,group:`Images`,tone:`error`,short:{image:`Image failed`,video:`Video failed`,media:`Media failed`}[e],title:`Couldn’t create ${e}`,detail:c.message,actions:c.billing?[{label:`Open Billing`,run:c.billing}]:c.retry?[{label:`Retry`,run:c.retry}]:[]})}l!==null&&x.push({key:`recovery:${l}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:l});for(let e of u){if(d.has(e.reference.requestId)||f.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`Unfinished ${ZL(a,e.input.settings.model)?.kind??`media`}`;x.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`info`,short:t,title:t,detail:e.reference.computerId===p?e.input.settings.prompt:`${e.input.settings.prompt} · on Computer ${e.reference.computerId}`,actions:[...e.reference.computerId===p?[{label:`Resume`,run:()=>{v(e)}}]:[],{label:`Discard`,run:()=>{y(e)}}]})}m.length>0&&x.push({key:`files:${m.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:m.join(`, `)}),h!==null&&x.push({key:`uploads:${h}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:h});for(let e of g)(e.status===`error`||e.status===`cancelled`)&&x.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{b(e.id)}}]});return x}function zue(e,t){let n=NS(OM(e)),r=FS(wA({queryKey:TM.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>Pj(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var D9=0,O9=1,Bue=2,Vue=0,k9=1;function Hue(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function Uue(e,t){let n=e.list;if(n.index===t)return n.next===null?Vue:(e.list=n.next,k9);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,k9;r=n,n=n.next}}var A9={low:0,max:0,high:0,C:Bue,P:void 0,R:void 0,L:void 0,list:void 0};A9.P=A9,A9.L=A9,A9.R=A9;function j9(e){let t=e.high;e.max=e.L===A9&&e.R===A9?t:e.L===A9?Math.max(e.R.max,t):e.R===A9?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function M9(e){let t=e;for(;t.P!==A9;)j9(t.P),t=t.P}function N9(e,t){if(t.R===A9)return;let n=t.R;t.R=n.L,n.L!==A9&&(n.L.P=t),n.P=t.P,t.P===A9?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,j9(t),j9(n)}function P9(e,t){if(t.L===A9)return;let n=t.L;t.L=n.R,n.R!==A9&&(n.R.P=t),n.P=t.P,t.P===A9?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,j9(t),j9(n)}function F9(e,t,n){t.P===A9?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function Wue(e,t){let n;for(;t!==A9&&t.C===O9;)t===t.P.L?(n=t.P.R,n.C===D9&&(n.C=O9,t.P.C=D9,N9(e,t.P),n=t.P.R),n.L.C===O9&&n.R.C===O9?(n.C=D9,t=t.P):(n.R.C===O9&&(n.L.C=O9,n.C=D9,P9(e,n),n=t.P.R),n.C=t.P.C,t.P.C=O9,n.R.C=O9,N9(e,t.P),t=e.root)):(n=t.P.L,n.C===D9&&(n.C=O9,t.P.C=D9,P9(e,t.P),n=t.P.L),n.R.C===O9&&n.L.C===O9?(n.C=D9,t=t.P):(n.L.C===O9&&(n.R.C=O9,n.C=D9,N9(e,n),n=t.P.L),n.C=t.P.C,t.P.C=O9,n.L.C=O9,P9(e,t.P),t=e.root));t.C=O9}function Gue(e){for(;e.L!==A9;)e=e.L;return e}function Kue(e,t){let n;for(;t.P.C===D9;)t.P===t.P.P.L?(n=t.P.P.R,n.C===D9?(t.P.C=O9,n.C=O9,t.P.P.C=D9,t=t.P.P):(t===t.P.R&&(t=t.P,N9(e,t)),t.P.C=O9,t.P.P.C=D9,P9(e,t.P.P))):(n=t.P.P.L,n.C===D9?(t.P.C=O9,n.C=O9,t.P.P.C=D9,t=t.P.P):(t===t.P.L&&(t=t.P,P9(e,t)),t.P.C=O9,t.P.P.C=D9,N9(e,t.P.P)));e.root.C=O9}function que(){let e={root:A9,size:0},t={};return{insert(n,r,i){let a=e.root,o=A9;for(;a!==A9&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==A9){if(!Hue(o,r,i))return;o.high=Math.max(o.high,r),j9(o),M9(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:D9,P:o,L:A9,R:A9,list:{index:i,high:r,next:null}};o===A9?e.root=s:(s.low<o.low?o.L=s:o.R=s,M9(s)),Kue(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=Uue(r,n);if(i===void 0)return;if(i===k9){r.high=r.list.high,j9(r),M9(r),e.size--;return}let a=r,o=a.C,s;r.L===A9?(s=r.R,F9(e,r,r.R)):r.R===A9?(s=r.L,F9(e,r,r.L)):(a=Gue(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(F9(e,a,a.R),a.R=r.R,a.R.P=a),F9(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),j9(s),M9(s),o===O9&&Wue(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===A9||t>e.max)&&(e.L!==A9&&i.push(e.L),e.R!==A9&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var Jue=e=>{let t=K.useRef(e);return K.useEffect(()=>{t.current=e}),t},I9=(e,t)=>{let n=t||Yue,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},Yue=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],L9=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},R9=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},Xue=e=>{let t=e.length,n=R9(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=R9(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=R9(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},Zue=(e,t)=>{let n,{g:r,s:i}=Xue(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},Que=new WeakMap;function $ue(){let e=K.useState(ede)[1];return K.useRef(()=>e({})).current}var ede={},z9=K.createElement;function tde(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=ide,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=$ue(),w=ode(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),N=j(),P=[],F=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,I=Jue(b);h=v*h;let L=g+h,R=N<L&&M<T;if(O(Math.max(0,g-h/2),L,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};P.push(z9(d,{key:a,ref:w(e),role:F,style:typeof f==`object`&&f?Object.assign({},o,f):o},V9(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),R){let e=Math.min(T-M,Math.ceil((g+h-N)/p*D)),t=M,n=ade(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);P.push(z9(d,{key:i,ref:w(t),role:F,style:typeof f==`object`?Object.assign({},n,f):n},V9(y,t,e,E)))}}K.useEffect(()=>{typeof I.current==`function`&&S!==void 0&&I.current(x,S,r),B9=`1`},[x,S,r,I]),K.useEffect(()=>{R&&C()},[R,t]);let z=nde(_,k(T,p));return z9(i,{ref:u,key:B9,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?rde(z,s):z,children:P})}var B9=`0`,V9=Zue([L9,{},WeakMap,L9],(e,t,n,r)=>z9(e,{index:t,data:n,width:r})),nde=I9((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),H9=(e,t)=>e[0]===t[0]&&e[1]===t[1],rde=I9((e,t)=>Object.assign({},e,t),H9);function ide(e,t){return t}var ade=I9(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),ode=I9((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),Que.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},H9),sde=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=que(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=cde(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},cde=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},U9=0,lde=320,ude=656;function dde(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=4?2:t>=1280?4:t>=ude?3:2}function W9({item:e}){return HX(e.path)?(0,X.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,X.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var fde=(0,K.memo)(function({item:e}){let t=(0,K.useRef)(null);(0,K.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,K.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,K.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return xse(async()=>{let{animate:e,spring:t}=await Promise.resolve().then(()=>Qre);return{animate:e,spring:t}},void 0,import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,X.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[(0,X.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,onClick:()=>{e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,X.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n||e.error?(0,X.jsx)(N6,{"data-media-pending":e.pending?`true`:void 0,failure:e.error?(0,X.jsx)(`span`,{title:e.error,className:`prints-tile-failed`,children:(0,X.jsx)(l8,{size:`compact`,appearance:`chip`,glyph:`bang`,tone:`error`,label:`Not saved`})}):void 0,indicator:(0,X.jsx)(JI,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`}),label:e.pendingLabel??`Preparing image…`,status:e.pending?e.error?`failed`:`generating`:`done`,children:e.pending?null:(0,X.jsx)(W9,{item:e})}):(0,X.jsx)(W9,{item:e})})}),e.error?(0,X.jsxs)(`div`,{className:`prints-gallery-pending-actions`,children:[e.onRetry?(0,X.jsx)(QI,{"aria-label":`Retry ${e.path}`,icon:(0,X.jsx)(TL,{}),onClick:e.onRetry}):null,e.onDismiss?(0,X.jsx)(QI,{"aria-label":`Dismiss ${e.path}`,icon:(0,X.jsx)(AL,{}),onClick:e.onDismiss}):null]}):null,(0,X.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&e.onInfo?(0,X.jsx)(QI,{"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,X.jsx)(xL,{})}):null,!e.pending&&e.onToggleReference?(0,X.jsx)(QI,{className:`prints-gallery-reference`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,X.jsx)(vL,{}):(0,X.jsx)(bL,{})}):null]})]})}),pde=(0,K.memo)(function({children:e,style:t,...n}){return(0,X.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function mde(e,t){let[n,r]=(0,K.useState)({height:0,width:0});return(0,K.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function hde(e){let[t,n]=(0,K.useState)(0),[r,i]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function gde(e,t){let n=Math.max(1,dde(e.length,t));return(0,K.useMemo)(()=>{let r=Math.floor((t-(n-1)*U9)/n),i=sde(n,r,U9);return r>0&&e.forEach((e,t)=>{let n=e.height>0?e.width/e.height:1;i.set(t,r/n)}),i},[e,t,n])}var _de=(0,K.memo)(function({data:e,width:t}){let n=e.height>0?e.width/e.height:1;return(0,X.jsx)(`div`,{"data-media-tile":e.key,style:{height:t/n,width:t},children:(0,X.jsx)(fde,{item:e})})});function G9(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function vde(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||G9(e,t))&&n()}function yde(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var bde=(0,K.memo)(function({items:e,scrollRef:t,focus:n}){let r=mde(t,e.length),i=r.width||lde,a=gde(e,i),{isScrolling:o,scrollTop:s}=hde(t),c=(0,K.useRef)(new Set),l=(0,K.useRef)(null),u=(0,K.useRef)(null);(0,K.useEffect)(()=>{if(!n)return;let o=l.current===n.requestId;if(o&&u.current===i)return;let s=t.current,c=e.findIndex(e=>e.key===n.key),d=a.get(c);if(!s||!d||r.height===0)return;let f=s.querySelector(`[data-media-grid]`);if(!f)return;let p=yde(s,f,d);if(o){vde(s,n.key,()=>{u.current=i});return}G9(s,n.key)?(l.current=n.requestId,u.current=i,n.onFocus()):s.scrollTo({top:p,behavior:`instant`})},[n,e,r.height,t,s,a,i]),(0,K.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.reduce((e,t,n)=>t.pending&&!t.onVisible&&!c.current.has(t.key)?n:e,-1);if(c.current=new Set(e.map(e=>e.key)),i<0)return;let o=a.get(i),s=n.querySelector(`[data-media-grid]`);if(!o||!s)return;let l=s.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop+o.top,u=l+o.height;l>=n.scrollTop&&u<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,l-Math.max(0,(n.clientHeight-o.height)/2)),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,a]);let d=(0,K.useCallback)(({data:e,width:t})=>(0,X.jsx)(_de,{data:e,width:t}),[]);return tde({as:pde,height:r.height,isScrolling:o,itemKey:e=>e.key,items:e,overscanBy:2,positioner:a,render:d,scrollTop:s})});function xde({items:e,scrollRef:t,focus:n}){return(0,X.jsx)(`section`,{"data-media-mosaic":!0,children:(0,X.jsx)(bde,{items:e,scrollRef:t,focus:n})})}function Sde(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...t.filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}var K9=`prints-prompt-counter`;function Cde({busy:e,disabled:t,draft:n,label:r,onGenerate:i,promptOver:a}){return(0,X.jsx)(jse,{"aria-describedby":a?K9:void 0,"aria-label":r,className:`prints-generate`,"data-generation-submit":!0,disabled:t||a,onClick:i,state:Wse({draft:n,busy:e}),title:r})}function wde({caretRequest:e,disabled:t,maxLength:n,addedLength:r=0,menu:i,mentionCount:a,onCaret:o,onChange:s,onMentionDismiss:c,onMentionMove:l,onMentionPick:u,onSend:d,onSlashMove:f,onSlashPick:p,placeholder:m,slashCount:h,value:g}){let _=(0,K.useRef)(null),v=(0,K.useRef)(g),[y,b]=(0,K.useState)([]),[x,S]=(0,K.useState)(-1),[C,w]=(0,K.useState)(!1),T=(0,K.useRef)(!1),E=(0,K.useRef)(!1);v.current=g,(0,K.useLayoutEffect)(()=>{if(C||t||!E.current)return;E.current=!1;let e=_.current;e&&e.ownerDocument.activeElement===e.ownerDocument.body&&e.focus({preventScroll:!0})},[t,C]),(0,K.useLayoutEffect)(()=>{let t=_.current;!t||e?.value!==g||(t.setSelectionRange(e.caret,e.caret),t.focus({preventScroll:!0}))},[e,g]),Kse(_,g);let D=(0,K.useCallback)(async()=>{let e=v.current.trim();if(!(!e||t||T.current)&&!(n!==void 0&&e.length+r>n)){E.current=_.current===_.current?.ownerDocument.activeElement,T.current=!0,w(!0);try{if(!await d())return;b(t=>t.at(-1)===e?t:[...t,e].slice(-20)),S(-1)}finally{T.current=!1,w(!1)}}},[t,n,d,r]),O=g.trim().length,k=O>0?O+r:0,A=n!==void 0&&k>n;return(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,X.jsx)(e7,{"aria-invalid":A?!0:void 0,"aria-label":`Image prompt`,className:`w-full`,"data-generation-prompt":!0,...Ise(i),disabled:t===!0||C,onChange:e=>{s(e.currentTarget.value),o(e.currentTarget.selectionStart),S(-1)},onSelect:e=>{o(e.currentTarget.selectionStart)},onKeyDown:e=>{if(q5(e))return;let t=Fse(e);if(a>0&&t!==null){e.preventDefault(),t===`next`?l(1):t===`previous`?l(-1):t===`accept`?u():c();return}if(g.startsWith(`/`)&&t!==null&&(h>0||t===`dismiss`||e.key===`Enter`)){if(e.preventDefault(),t===`dismiss`)s(g.slice(1));else if(h)t===`next`?f(1):t===`previous`?f(-1):p();else return;return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),D();return}if(e.key===`ArrowUp`&&_.current?.selectionStart===0&&y.length&&(x===-1||x>0)){e.preventDefault();let t=x===-1?y.length-1:x-1;S(t),s(y[t]);return}if(e.key===`ArrowDown`&&x!==-1){e.preventDefault();let t=x+1;t>=y.length?(S(-1),s(``)):(S(t),s(y[t]))}},placeholder:m,ref:_,rows:1,value:g}),n!==void 0&&k>0?(0,X.jsx)(`p`,{className:`px-3 pb-1 text-xs tabular-nums ${A?`text-error`:`text-dim`}`,"data-prompt-counter":!0,id:K9,role:A?`alert`:`status`,children:A?`${String(k)} / ${String(n)} characters. This model accepts up to ${String(n)}; shorten the prompt${r>0?` or its style and characters`:``} by ${String(k-n)} or pick another model.`:`${String(k)} / ${String(n)}`}):null]})}function Tde({index:e,listId:t,matches:n,onHighlight:r,onPick:i}){return(0,X.jsx)(n7,{open:!0,rows:n.map(e=>({key:e.id,label:`/${e.slash}`,detail:e.description??e.title})),selected:e,listId:t,label:`Commands`,kind:`commands`,empty:`No matching commands`,onHighlight:r,onChoose:i})}function Ede(e,t){let[n,r]=(0,K.useState)(0),i=t.startsWith(`/`),a=(0,K.useMemo)(()=>{if(!i)return[];let n=Ese(e.map((e,t)=>({alias:e.slash,commandId:e.id,command:e.command,title:e.title,description:e.description,category:`Prompt`,order:t,keys:[],availability:{status:`available`}})),t,{idleCategory:`Prompt`});return n.kind===`commands`?n.items.flatMap(({command:t})=>e.find(e=>e.id===t.commandId)??[]):[]},[t,e,i]);return(0,K.useEffect)(()=>{r(0)},[t]),{moveSlash:e=>{r(t=>a.length?(t+e+a.length)%a.length:0)},highlightSlash:r,resetSlash:()=>{r(0)},slashIndex:n,slashMatches:a,slashOpen:i}}function Dde({images:e,index:t,listId:n,matches:r,onHighlight:i,onPick:a}){return(0,X.jsx)(n7,{open:!0,rows:r.map(t=>{let n=t.references.at(0)?.path,r=e.find(e=>e.path===n);return{key:String(t.id),label:`@${t.name}`,detail:t.description||void 0,media:(0,X.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:r?(0,X.jsx)(`img`,{src:r.url,alt:``}):null})}}),selected:t,listId:n,label:`Characters`,kind:`characters`,onHighlight:i,onChoose:a})}function Ode(e,t){let[n,r]=(0,K.useState)(0),[i,a]=(0,K.useState)(0),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),u=o===t?null:_M(t,n),d=u?vM(e,u.query):[];return(0,K.useEffect)(()=>{a(0)},[t]),{caretRequest:c,matches:d,index:i,setCaret:r,highlight:a,dismiss:()=>{s(t)},move:e=>{a(t=>d.length?(t+e+d.length)%d.length:0)},complete:e=>{let i=d.at(e);if(!u||!i)return null;let a=`${t.slice(0,u.start)}@${i.name} ${t.slice(n)}`,o=u.start+i.name.length+2;return l({value:a,caret:o}),r(o),a}}}function kde(e){let t=_x(),n=NS(jM(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(TM.characters(e),n)}}),i=FS(r((e,t,n)=>CM(e.capabilities,t,n))),a=FS(r((e,t,n)=>wM(e.capabilities,t,n))),o=i.error??a.error??n.error;return{characters:n.data?.characters??[],error:o?lx(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}var q9=eb(rM),J9=e=>e.split(`/`).at(-1)??e;function Ade({paths:e,images:t}){return(0,X.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,X.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,X.jsx)(`img`,{src:n.url,alt:J9(e)}):null},e)})})}function jde({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,K.useState)(null),f=(0,K.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):q9(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,X.jsx)(C6,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,X.jsxs)(O6,{children:[(0,X.jsx)(A6,{children:(0,X.jsx)(j6,{children:`Characters`})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,X.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,X.jsx)(Ade,{paths:e.references.map(e=>e.path),images:t}),(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,X.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,X.jsx)(XI,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(O5,{"aria-label":`Character name`,"aria-invalid":!q9(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,X.jsx)(e7,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,X.jsxs)(XI,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,X.jsx)(kL,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,X.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,X.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,X.jsx)(`li`,{title:e.path,children:(0,X.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,X.jsx)(`img`,{src:e.url,alt:``}),(0,X.jsx)(`span`,{className:`prints-character-check`,children:(0,X.jsx)(i7,{"aria-label":`Use ${J9(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,X.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,X.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,X.jsx)(k6,{children:(0,X.jsx)(M6,{render:(0,X.jsx)(XI,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Y9=q({destination:ob(xb(fb)),height:ob(Hb),model:ob(fb),prompt:ob(fb),references:ob(_b(q({computerId:ob(fb),path:fb,role:ob(bb([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:ob(xb(mb)),steps:ob(xb(Hb)),style:ob(xb(fb)),width:ob(Hb)}),Mde=so(da(),Uo()).parse(structuredClone(tx(Y9,{onExcessProperty:`error`}).schema)),X9=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),Nde=X9(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),Pde=X9(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,Mde),Fde=X9(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function Ide(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(Nde,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(Pde,({arguments:e})=>{if(n)return;let r=ib(Y9,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(Fde,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function Lde(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...PL.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(NL[t].width)} × ${String(NL[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function Rde(e,t){let n=(0,K.useRef)(e);n.current=e;let r=Zk(t,{sourceId:`media-prompt`,namespace:`media`},(0,K.useCallback)(()=>Lde(()=>n.current),[])),i=(0,K.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,K.useMemo)(()=>Cse(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function Z9(e){let t=_x(),n=NS(kM(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(TM.styles(e),n)}}),i=FS(r((e,t,n)=>$j(e.capabilities,t,n))),a=FS(r((e,t,n)=>eM(e.capabilities,t,n))),o=i.error??a.error??n.error;return{styles:n.data?.styles??[],error:o?lx(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}function Q9(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function zde(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function Bde(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?Q9(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=ZL(i,n.model),c=o??s??ZL(i,a.model);if(c===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let l=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${XL(c)} instead.`:null,u=n.references.slice(0,n.typed.references),d=e===`animate`?{path:r,role:`first-frame`}:{path:r},f=[d,...u.filter(e=>!jL(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&c.input.maxReferences===0)return{kind:`refused`,message:`${c.label} does not take reference images.`};let p=e===`reuse`?u:e===`remix`?f:[d],m=QL(a,c),h={width:n.width??m.width,height:n.height??m.height},g=o===void 0?YL(h,c,void 0):zde(c,h.width,h.height)??m,_=o===void 0&&c.input.steps!==`fixed`&&n.steps!==null&&c.id===n.model?n.steps:m.steps,v=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:l,draft:{...m,destination:void 0,prompt:n.typed.prompt,references:p,steps:_,style:v,width:g.width,height:g.height}}}function Vde({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,X.jsxs)(H5,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,X.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,X.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function Hde({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,K.useState)(null);return(0,X.jsx)(C6,{open:n,onOpenChange:r,children:(0,X.jsxs)(O6,{children:[(0,X.jsx)(A6,{children:(0,X.jsx)(j6,{children:`Styles`})}),(0,X.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,X.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,X.jsx)(XI,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(O5,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,X.jsx)(e7,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,X.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,X.jsx)(k6,{children:(0,X.jsx)(M6,{render:(0,X.jsx)(XI,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Ude=[`a mushroom knight`,`moss on a keyboard`,`your Agent's selfie`];function Wde(e){Goe.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function Gde(e){let t=(0,K.useRef)(!1),n=D5({defaultValues:LL(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,K.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function Kde({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,onEditStyles:o,onEditCharacters:s}){let c=t?.input.dimensions===`none`,l=t!==void 0&&t.sizes!==null,u=t?.video??null;return(0,X.jsxs)(`div`,{className:`prints-settings`,children:[(0,X.jsx)(B5,{label:`Style`,orientation:`horizontal`,children:n}),(0,X.jsx)(B5,{label:`Size`,orientation:`horizontal`,children:(0,X.jsx)(H5,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:c,title:c?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:c?`provider`:i,children:c?(0,X.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,X.jsxs)(X.Fragment,{children:[l&&!r.some(e=>e.value===i)?(0,X.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,r.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value)),l?null:(0,X.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!c&&!l&&i===`custom`?(0,X.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,X.jsx)(e.Field,{name:`width`,children:e=>(0,X.jsx)(B5,{label:`Width`,children:(0,X.jsx)(O5,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,X.jsx)(e.Field,{name:`height`,children:e=>(0,X.jsx)(B5,{label:`Height`,children:(0,X.jsx)(O5,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,u?(0,X.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,X.jsx)(B5,{label:`Length`,orientation:`horizontal`,children:(0,X.jsx)(H5,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(u.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:u.durations.map(e=>(0,X.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,u?.supportsAudio?(0,X.jsx)(e.Field,{name:`generateAudio`,children:e=>u.defaultGenerateAudio===null?(0,X.jsx)(B5,{label:`Audio`,orientation:`horizontal`,children:(0,X.jsxs)(H5,{"aria-label":`Video audio`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,X.jsx)(`option`,{value:``,children:`Model default`}),(0,X.jsx)(`option`,{value:`on`,children:`On`}),(0,X.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,X.jsx)(B5,{label:`Audio`,orientation:`horizontal`,children:(0,X.jsx)(U5,{"aria-label":`Video audio`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,X.jsx)(e.Field,{name:`steps`,children:e=>(0,X.jsx)(B5,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,X.jsx)(O5,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,X.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{o()},children:`Edit styles…`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Characters…`})]})]})}function qde({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,values:c,computerId:l,mediaDirectory:u,referenceImages:d,characters:f,characterDialog:p,onSubmit:m,styleControls:h,addedLength:g}){let _=ZL(i,c.model),v=c.prompt.trim().length,y=_!==void 0&&v>0&&v+g>_.maxPromptLength,b=tR(_),x=_?.video??null,S=nR(c.references,_),C=_===void 0?void 0:rR(S,_,x?.formats.find(e=>e.width===c.width&&e.height===c.height)?.resolution),w=_?.input.maxReferences??0,T=c.references.length>w,[E,D]=(0,K.useState)(!1),[O,k]=(0,K.useState)(!1),A=_!==void 0&&_.sizes!==null,j=JL(_),M=A?`${String(c.width)}x${String(c.height)}`:E?`custom`:j.find(e=>e.width===c.width&&e.height===c.height)?.value??`custom`,[N,P]=(0,K.useState)(!1),F=Rde({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{D(!1),r.setFieldValue(`width`,NL[e].width),r.setFieldValue(`height`,NL[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),P(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[I,L]=(0,K.useState)(!1),R=Ode(f,c.prompt),z=Ede(F.items,c.prompt),B=(0,K.useId)(),V=`${B}-commands`,H=`${B}-characters`,ee=gM({computerId:l,prompt:c.prompt,saved:f,references:c.references,model:_===void 0?void 0:{label:_.label,maxReferences:_.input.maxReferences}}),te=fM(c.prompt,f).characters,U=e=>{let t=z.slashMatches.at(e);t&&(z.resetSlash(),F.run(t.command))},W=h({open:N,onOpenChange:P}),ne=[c.style,qL(_,c.width,c.height),x&&c.durationSeconds!==void 0?`${String(c.durationSeconds)}s`:void 0,x?.supportsAudio&&c.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),re=(0,X.jsx)(Kde,{form:r,selected:_,stylePicker:W.picker,sizeChoices:j,sizeMode:M,onCustomSize:D,onEditStyles:()=>{k(!1),P(!0)},onEditCharacters:()=>{k(!1),L(!0)}});return(0,X.jsxs)(Gse,{"aria-label":`Image generation`,"data-generation-form":!0,attachments:c.references.length>0?(0,X.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,children:c.references.map((e,t)=>{let n=l!==null&&jL(e,l)?d.find(t=>t.path===e.path):void 0,i=S[t]?.role,a=eR(b,S,t);return(0,X.jsxs)(`div`,{className:`prints-reference-tile`,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,X.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,X.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,X.jsxs)(`span`,{children:[`Ref `,t+1]})}),i===void 0?null:a===void 0?(0,X.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:$L[i]}):(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${$L[i]}. Use as ${$L[a]}`,title:`Use as ${$L[a]}`,onClick:()=>{r.setFieldValue(`references`,S.map((e,n)=>n===t?{...e,role:a}:e))},children:$L[i]}),(0,X.jsx)(QI,{icon:(0,X.jsx)(AL,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,c.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??l,e.path]))})}):void 0,input:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),m()},children:(0,X.jsx)(r.Field,{name:`prompt`,children:e=>(0,X.jsxs)(`div`,{className:`prints-prompt`,children:[z.slashOpen?(0,X.jsx)(Tde,{index:z.slashIndex,listId:V,matches:z.slashMatches,onHighlight:z.highlightSlash,onPick:U}):null,!z.slashOpen&&R.matches.length>0?(0,X.jsx)(Dde,{images:d,index:R.index,listId:H,matches:R.matches,onHighlight:R.highlight,onPick:t=>{let n=R.complete(t);n!==null&&e.handleChange(n)}}):null,(0,X.jsx)(wde,{caretRequest:R.caretRequest,menu:z.slashOpen?{open:z.slashMatches.length>0,listId:V,selected:z.slashIndex}:{open:R.matches.length>0,listId:H,selected:R.index},mentionCount:z.slashOpen?0:R.matches.length,onCaret:R.setCaret,onMentionDismiss:R.dismiss,onMentionMove:R.move,onMentionPick:()=>{let t=R.complete(R.index);t!==null&&e.handleChange(t)},disabled:!o||a||i.length===0||s,maxLength:_?.maxPromptLength,addedLength:g,onChange:t=>{e.handleChange(t)},onSend:m,onSlashMove:z.moveSlash,onSlashPick:()=>{U(z.slashIndex)},placeholder:`What are we making?`,slashCount:z.slashMatches.length,value:e.state.value}),c.references.length>0||C!==void 0||te.length>0?(0,X.jsxs)(`div`,{className:`prints-composer-notes`,children:[c.references.length>0?(0,X.jsxs)(`span`,{className:`prints-reference-count`,"data-generation-references":!0,"data-over-limit":T?``:void 0,role:T?`alert`:void 0,children:[c.references.length,` / `,w,` `,`references`,T?w===0?` — this model takes none; remove them or pick another model`:` — over this model's limit; remove some to generate`:null]}):null,C===void 0?null:(0,X.jsx)(`span`,{className:`prints-reference-count`,"data-generation-reference-roles":!0,"data-over-limit":``,role:`alert`,children:C}),te.length>0?(0,X.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,"data-over-limit":ee.kind===`refused`?``:void 0,role:ee.kind===`refused`?`alert`:void 0,children:ee.kind===`refused`?ee.message:`Characters: ${te.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t?(0,X.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,X.jsx)(`span`,{children:t.group===`Images`&&t.detail?t.detail:(0,X.jsxs)(X.Fragment,{children:[t.title,`. `,t.detail]})}),t.actions?.map(e=>(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,X.jsxs)(X.Fragment,{children:[e,(0,X.jsx)(r.Field,{name:`model`,children:e=>(0,X.jsx)(mle,{models:i,emptyLabel:l===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:t=>{let n=ZL(i,t);if(e.handleChange(t),!n)return;let a=r.store.state.fieldMeta,o=QL(c,n),s=YL(c,n,_);(n.input.dimensions===`none`||n.sizes!==null)&&D(!1),r.setFieldValue(`width`,s.width),r.setFieldValue(`height`,s.height),r.setFieldValue(`durationSeconds`,o.durationSeconds),r.setFieldValue(`generateAudio`,o.generateAudio),(n.input.steps===`fixed`||!a.steps?.isTouched)&&r.setFieldValue(`steps`,o.steps)},value:e.state.value})}),l&&u?(0,X.jsxs)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Saved to ${l}:${u}`,children:[`Saves to `,u]}):null]}),action:(0,X.jsx)(Cde,{busy:s,draft:c.prompt,disabled:!o||a||i.length===0||s,label:BL(_),onGenerate:()=>{m()},promptOver:y}),items:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,X.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,X.jsx)(DL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),ne.length>0?ne.join(` · `):`Settings`]}),content:re}],openId:O?`settings`:null,onOpenChange:e=>{k(e===`settings`)}},children:[W.dialog,p({open:I,onOpenChange:L})]})}function Jde({connection:e}){let t=(0,K.useRef)(e);t.current=e;let n=hle(e?.app??null),[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(),s=zue(e?.app??null,n.computerId),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(),m=(0,K.useRef)(0);(0,K.useEffect)(()=>{l(null),d(null),p(void 0)},[e,n.computerId,n.path]);let h=n.path,{gallery:g,images:_,failed:v,loading:y,gallerySlots:b,canBrowse:x,canRead:S,canWrite:C,reserveSlot:w,failSlot:T,clearSlotError:E,removeSlot:D,addComputerFile:O,retryFile:k,uploads:A,uploadFiles:j}=qae(e,n),[M,N]=(0,K.useState)(Date.now),P=b.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,K.useEffect)(()=>{if(!P)return;let e=setInterval(()=>{N(Date.now())},1e3);return()=>{clearInterval(e)}},[P]);let F=YA(e,(e,t,n)=>(g.refresh(),O(e,t,n)));(0,K.useEffect)(()=>{p(void 0)},[F.target?.requestId]);let I=g.entries.some(e=>e.path===F.target?.path);(0,K.useEffect)(()=>{F.target&&!I&&g.nextPageReady&&g.loadMore()},[F.target,I,g.nextPageReady,g.loadMore]);let L=_.find(e=>e.source.kind===`computer`&&e.source.computerId===F.target?.computerId&&e.source.path===F.target.path),R=Z9(e?.app??null),z=kde(e?.app??null),B=soe({connection:e,folder:n,styles:R.styles,characters:z.characters,effects:{reserve:w,failed:T,notifyFailure:Wde,saved:({result:e},t)=>{S?O(e.destination.path,t,e.destination.computerId):T(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:V,models:H,modelsLoading:ee,modelsError:te,canGenerate:U,mediaCapability:W,pendingGenerations:ne,activeGenerations:re,recoveryError:ie}=B,ae=(0,K.useRef)(H),oe=(0,K.useRef)(B);oe.current=B;let se=(0,K.useRef)(null),G=(0,K.useRef)(null),ce=(0,K.useRef)(0),[le,ue]=(0,K.useState)(null),de=(0,K.useRef)(B.submit);de.current=async e=>{let t=await B.submit(e);return t&&ue(null),t};let fe=Gde(de),pe=e=>{fe.setFieldValue(`model`,e.model),fe.setFieldValue(`width`,e.width),fe.setFieldValue(`height`,e.height),fe.setFieldValue(`steps`,e.steps),fe.setFieldValue(`durationSeconds`,e.durationSeconds),fe.setFieldValue(`generateAudio`,e.generateAudio),fe.setFieldValue(`prompt`,e.prompt),fe.setFieldValue(`references`,e.references),fe.setFieldValue(`style`,e.style),fe.setFieldValue(`destination`,void 0)},me=(0,K.useRef)(fe);me.current=fe;let he=w5(fe.store,e=>e.values),ge=w5(fe.store,e=>e.isSubmitting),_e=e?.app;(0,K.useEffect)(()=>{if(_e)return Ide(_e,{readDraft:()=>me.current.store.state.values,readModels:()=>ae.current,setDraft:e=>{let t=me.current;if(e.model!==void 0){let n=ZL(ae.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=QL(t.store.state.values,n),i=ZL(ae.current,t.store.state.values.model),a=YL(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>me.current.store.state.isSubmitting||oe.current.isRunning()?Promise.resolve(!1):me.current.submitCurrent()})},[_e]),(0,K.useEffect)(()=>{ae.current=H},[H]),(0,K.useEffect)(()=>{if(H.length===0||te)return;let e=H.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??H[0];if(!fe.store.state.fieldMeta.model?.isTouched){let t=QL(fe.store.state.values,e);fe.setFieldValue(`model`,t.model),fe.store.state.fieldMeta.width?.isTouched||fe.setFieldValue(`width`,t.width),fe.store.state.fieldMeta.height?.isTouched||fe.setFieldValue(`height`,t.height),fe.store.state.fieldMeta.steps?.isTouched||fe.setFieldValue(`steps`,t.steps)}},[fe,te,H]);let ve=ZL(H,he.model),ye=he.references,be=ve?.input.maxReferences??0,xe=(0,K.useRef)({addComputerFile:O,retryPath:B.retryPath,uploads:A});xe.current={addComputerFile:O,retryPath:B.retryPath,uploads:A};let Se=L?m8(L):null,Ce=(0,K.useMemo)(()=>_.map(e=>({key:m8(e),selected:m8(e)===Se,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:ye.some(t=>e.source.kind===`computer`&&jL(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:ye.length>=be&&!ye.some(t=>e.source.kind===`computer`&&jL(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&be>0?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=ye.some(e=>jL(e,n)&&e.path===t);fe.setFieldValue(`references`,r?ye.filter(e=>!jL(e,n)||e.path!==t):[...ye,{path:t}])}:void 0,onInfo:()=>{l(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{l(null),d(m8(e))}})),[_,ye,be,fe,Se]),we=(0,K.useMemo)(()=>{let e=n.computerId;if(!e)return Ce;let t=new Map(Ce.map(e=>[e.key,e])),r=[...g.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{g.loadFile(n.path)},error:v.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{k(n.path)}}}),i=new Set(r.map(e=>e.key));return[...r,...Ce.filter(e=>!i.has(e.key)&&e.key!==Se)]},[Ce,g.entries,g.loadFile,k,v,n.computerId,Se]),Te=V.kind===`pending`,Ee=(0,K.useMemo)(()=>Sde(we,b,e=>{let n=A.items.find(t=>t.id===e.uploadId),r=e.error??(n?.status===`error`||n?.status===`cancelled`?n.message:void 0);return{key:e.key,path:e.path,width:e.width,height:e.height,url:``,pending:!0,error:r,pendingLabel:n?.status===`complete`||V.kind===`completed`?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:VL(H.find(e=>e.kind===`video`),M-e.startedAt,e.resumed),onOpen:()=>void 0,onRetry:r&&(S||n&&n.status!==`complete`)?()=>{if(E(e.key),n&&n.status!==`complete`){xe.current.uploads.retry(n.id);return}!e.uploadId&&xe.current.retryPath(e.path)||t.current&&xe.current.addComputerFile(e.path,t.current,e.computerId)}:void 0,onDismiss:r?()=>{D(e.key),e.uploadId&&xe.current.uploads.remove(e.uploadId)}:void 0}}),[we,b,A.items,V.kind,S,H,M]),De=ge||Te,Oe=b.some(e=>e.error!==void 0),ke=A.items.filter(e=>e.computerId===n.computerId),Ae=V.kind===`error`&&te===null?{key:B.errorKey,mediaKind:V.mediaKind,message:V.message,billing:V.action===`billing`&&e?()=>{e.app.ui.openTeamBilling().catch(n=>{JX(`open-team-billing`,n),t.current===e&&B.reportRecoveryError(n)})}:void 0,retry:Oe&&V.retryable!==!1?B.retry:void 0}:null,je=Rue({connected:e!==null,mediaCapability:W,modelsError:te,retryModels:B.retryModels,modelsLoading:ee,models:H,canGenerate:U,canWrite:C,generationError:Ae,recoveryError:ie,pendingGenerations:ne,activeGenerations:re,gallerySlots:b,computerId:n.computerId,failed:v,uploadError:A.error,uploads:ke,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{B.reportRecoveryError(e)})},resume:e=>{B.resume(e)},discard:e=>{B.discard(e)},retryUpload:e=>{A.retry(e)}});s.error&&je.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:s.error});let Me=s.visible(je),Ne={generating:re.size,uploading:ke.filter(e=>e.status===`sending`||e.status===`queued`).length},Pe={items:ke.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{A.cancel(e)},onRetry:e=>{A.retry(e)},onRemove:e=>{A.remove(e)}},Fe=new Set([...g.entries.map(e=>`${n.computerId??``}:${e.path}`),..._.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,Ie=jue(Me,Ne,r);Xk(e?.app,[...n.available?[vse(n.path,{checking:n.busy&&n.path===null,editing:n.editing})]:[],...Ie===null?[]:[Ie],...x?[{kind:`text`,id:`prints`,text:`${String(Fe)} ${Fe===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(o(e.anchor?.start),i(e=>!e),!0):e.itemId!==`folder`||!n.available?!1:(n.setEditing(!0),!0),t=>{JX(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{JX(`prints.status.toast`,e)})});let Le=_.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url}]:[]),Re=e=>{d(null),m.current+=1,p({key:e,requestId:`viewer-close-${String(m.current)}`,onFocus:()=>void 0})},ze=(t,n,r)=>(0,X.jsx)(aZ,{image:t,app:e?.app??null,referenceImages:Le,models:H,canAnimate:Q9(H)!==void 0,download:r,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=Bde(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:H,styles:R.styles.map(e=>e.name),current:fe.store.state.values});return r.kind===`refused`?r.message:(pe(r.draft),ue(r.notice===null?null:{model:r.draft.model,message:r.notice}),l(null),u!==null&&Re(m8(t)),null)},onClose:n},t.url);return(0,X.jsxs)(`main`,{className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":V.kind,"data-computer-capability":x?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&C&&(e.preventDefault(),j(t.map(e=>(ce.current+=1,new File([e],`paste-${String(ce.current)}-${p8(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,X.jsx)(rse,{id:`prints-generation-notices`}),(0,X.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,X.jsx)(i8,{screen:!0,surface:!0,surfaceSize:`lg`,surfaceDepth:`deep`,ref:se,className:`flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":y||g.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&C&&j(t)},children:(0,X.jsxs)(`div`,{className:`prints-gallery-content`,children:[Ee.length>0?(0,X.jsx)(xde,{items:Ee,scrollRef:se,focus:u===null?f??(L&&F.target?{key:`${F.target.computerId}:${F.target.path}`,requestId:F.target.requestId,onFocus:()=>{l(L)}}:void 0):void 0}):y||g.loading?(0,X.jsx)(W5,{variant:`hint`,role:`status`,"aria-live":`polite`,title:`Loading prints…`,description:`Your library is on its way.`}):(0,X.jsx)(W5,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`panel`,visual:(0,X.jsx)(bL,{}),title:`Nothing printed yet.`,description:n.computerId===null?`Your images will appear here.`:n.available&&h===null?`Pick a folder in the composer below, then describe something or drop in images.`:`Describe something and it lands here, or drop in images from your Computer.`,...W?{suggestions:Ude.map(e=>({label:e,onSelect:()=>{fe.setFieldValue(`prompt`,e)}}))}:{}}),g.hasNextPage&&(0,X.jsx)(XI,{variant:`ghost`,disabled:g.loading,onClick:g.loadMore,children:g.loading?`Loading images…`:`Load more images`})]})}),F.error?(0,X.jsx)(`p`,{role:`alert`,children:`Could not open this print. It may no longer be available on this Computer.`}):null,c&&(c.source.kind===`local`||c.source.connection===e&&c.source.computerId===n.computerId)?ze(c,()=>{l(null)}):null]}),(0,X.jsx)($ae,{items:Ee,images:_,viewerKey:u,app:e?.app??null,onNavigate:d,onClose:Re,renderInfo:(e,t)=>ze(e,t,null)}),(0,X.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,X.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,X.jsx)(`input`,{ref:G,type:`file`,disabled:!C||h===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{j(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,X.jsx)(qde,{addedLength:pM(he.prompt,R.styles.find(e=>e.name===he.style)?.text,z.characters),styleControls:e=>({picker:(0,X.jsx)(Vde,{styles:R.styles,selected:he.style,disabled:!W||ee||De,onSelect:e=>{fe.setFieldValue(`style`,e)}}),dialog:(0,X.jsx)(Hde,{open:e.open,onOpenChange:e.onOpenChange,styles:R.styles,selected:he.style,busy:R.busy,error:R.error,onSelect:e=>{fe.setFieldValue(`style`,e)},onSave:R.save,onDelete:(e,t)=>{R.remove(e.id,t)}})}),characters:z.characters,characterDialog:e=>(0,X.jsx)(jde,{open:e.open,onOpenChange:e.onOpenChange,characters:z.characters,images:Le,busy:z.busy,error:z.error,canUpload:C&&h!==null,onUpload:()=>G.current?.click(),onSave:z.save,onDelete:(e,t)=>{z.remove(e.id,t)}}),guidance:Me.find(e=>e.blocking&&e.group===`Setup`)??(le!==null&&le.model===he.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:le.message,actions:[{label:`Dismiss`,run:()=>{ue(null)}}]}:void 0),commandApp:_e,actions:(0,X.jsx)(fP,{"aria-label":`Upload images`,title:C?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,X.jsx)(kL,{}),label:null,className:`prints-upload-key`,disabled:!C||h===null,onClick:()=>G.current?.click()}),form:fe,mediaCapability:W&&U&&C&&h!==null,models:H,modelsLoading:ee,onSubmit:fe.submitCurrent,submitting:De,values:he,computerId:n.computerId,mediaDirectory:h,referenceImages:Le}),Ie===null?null:(0,X.jsx)(Nue,{notices:Me,uploads:Pe,open:r,inset:a,onOpenChange:i,onDismiss:s.dismiss,onDismissAll:()=>{s.dismissAll(je)},onLoadMore:B.hasMore?B.loadMore:void 0})]}),(0,X.jsx)(Fue,{folder:n})]})}var $9=document.getElementById(`media-root`);if(!$9)throw Error(`Media root is missing`);Gk($9,{name:`Prints`,queryClient:SA()},({app:e})=>(0,K.createElement)(Jde,{connection:e?{app:e}:null}));
91
+ `))return{kind:`none`};let r=t.search(/\s/u);if(r<0){let r=t.slice(1);return{kind:`commands`,query:r,items:Tse(e.filter(e=>e.availability.status===`available`&&(r.length===0?e.category===(n.idleCategory??`Conversation`)||K5.includes(e.alias):e.category!==`Advanced`||e.alias.toLocaleLowerCase().startsWith(r.toLocaleLowerCase()))),e=>e.alias,r,e=>{let t=K5.indexOf(e.alias);return r.length===0&&t>=0?t-K5.length:e.order}).map(({entry:e,indices:t})=>({command:e,label:`/${e.alias}`,matches:t.map(e=>e+1),insert:e.grammar===void 0?`/${e.alias}`:`/${e.alias} `}))}}let i=t.slice(1,r),a=e.find(e=>e.alias===i);if(a?.grammar===void 0||a.availability.status!==`available`)return{kind:`none`};let o=t.slice(r).trimStart(),s=(o.includes(` `)?[]:a.grammar.words??[]).filter(e=>e.word.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())).map(e=>({word:e,label:e.word,matches:Array.from({length:o.length},(e,t)=>t),insert:`/${i} ${e.word}`}));return{kind:`arguments`,command:a,query:o,hint:`/${i} ${a.grammar.hint}`,items:s}}var Dse=hA({keyCode:_A(229)});function q5(e){return e.nativeEvent.isComposing||ye(Dse,e.nativeEvent).success}function Ose(e,t){return e.animate(t.reduced?[{opacity:1},{opacity:0}]:[{opacity:1,transform:`none`},{opacity:0,transform:`translateY(-120%)`}],{duration:t.reduced?t.fast:t.normal,easing:OP(t,t.easeExit),fill:`backwards`})}function kse(e,t){let n=-12*Math.min(1.5,t.bounce/.3);return e.animate(t.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translateY(70%)`},{opacity:1,transform:`translateY(${String(n)}%)`,offset:.6},{opacity:1,transform:`none`}],{duration:t.reduced?t.fast:t.springDuration,easing:OP(t,t.ease),fill:`backwards`})}function J5(e,t,n){return e.animate([{opacity:1-n},{opacity:n}],{duration:t.reduced?t.fast:t.normal,delay:n===1&&!t.reduced?t.fast/2:0,easing:OP(t,t.ease),fill:`backwards`})}function Ase(e,t){let n=1+.05*Math.min(1.5,.4+t.bounce/.3);return e.animate([{transform:`scale(1)`},{transform:`scale(${String(n)})`,offset:.4},{transform:`scale(1)`}],{duration:t.springDuration,easing:OP(t,`ease-out`)})}var jse=(0,K.forwardRef)(function({state:e,onStop:t,stopLabel:n=`Stop`,iconSize:r=20,onClick:i,disabled:a,className:o,tone:s=`primary`,"aria-label":c,...l},u){let d=(0,K.useRef)(null);(0,K.useImperativeHandle)(u,()=>d.current);let f=(0,K.useRef)(e);(0,K.useLayoutEffect)(()=>{let t=d.current,n=f.current;if(f.current=e,!t||n===e||!kP(t))return;let r=t.querySelector(`[data-glyph="arrow"]`),i=t.querySelector(`[data-glyph="busy"]`);if(!r||!i)return;let a=TP(t),o=[];return e===`busy`?o.push(Ose(r,a),J5(i,a,1)):n===`busy`&&o.push(J5(i,a,0),kse(r,a)),n===`empty`&&e===`ready`&&!a.reduced&&o.push(Ase(t,a)),()=>{for(let e of o)e.cancel()}},[e]);let p=e===`busy`,m=p&&t!==void 0;return(0,X.jsx)(fP,{...l,ref:d,className:Z(`caps-send-action`,o),tone:s,"aria-busy":p?!0:void 0,"aria-label":m?n:c,"data-send-state":e,disabled:a===!0||e===`empty`||p&&!m,onClick:m?t:i,label:null,icon:(0,X.jsxs)(`span`,{className:`caps-send-glyph`,"data-state":e,children:[(0,X.jsx)(`span`,{"data-glyph":`arrow`,children:(0,X.jsx)(Nie,{"aria-hidden":`true`,size:r})}),(0,X.jsx)(`span`,{"data-glyph":`busy`,children:t===void 0?(0,X.jsx)(JI,{decorative:!0,size:`sm`}):(0,X.jsx)(OL,{"aria-hidden":`true`,fill:`currentColor`,size:Math.round(r*.7)})})]})})}),Mse=(0,K.forwardRef)(function({className:e,label:t,...n},r){return(0,X.jsx)(fP,{...n,ref:r,className:Z(`parakeet-composer-model-key`,e),label:t,readout:(0,X.jsx)(yL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),Y5=(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,ref:n,className:Z(`caps-popover-anchor`,e)})}),X5=(0,K.forwardRef)(function({className:e,open:t,side:n=`top`,...r},i){return t?(0,X.jsx)(`div`,{...r,ref:i,className:Z(`caps-popover`,e),"data-side":n}):null}),Nse=(0,K.forwardRef)(function({active:e,className:t,onMouseDown:n,...r},i){return(0,X.jsx)(`div`,{role:`option`,"aria-selected":e,...r,ref:i,className:Z(`caps-popover-option`,t),"data-active":e,onMouseDown:e=>{e.preventDefault(),n?.(e)}})});function Z5({items:e,openId:t,onOpenChange:n,leading:r,trailing:i,renderTrigger:a,placement:o=`housing`,align:s=`end`,hostInset:c,className:l,...u}){let d=(0,K.useId)(),f=(0,K.useRef)(null),p=(0,K.useRef)(null),m=(0,K.useRef)(new Map),h=e.find(e=>e.id===t&&!e.disabled),g=h?.id,_=()=>{g&&m.current.get(g)?.focus(),n(null)};return(0,K.useEffect)(()=>{g&&p.current?.focus()},[g]),(0,K.useEffect)(()=>{c===void 0?f.current?.style.removeProperty(`--caps-status-tray-host-inset`):f.current?.style.setProperty(`--caps-status-tray-host-inset`,`${String(Math.max(0,c))}px`)},[c]),(0,K.useEffect)(()=>{if(!g)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),m.current.get(g)?.focus(),n(null))},t=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&n(null)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[g,n]),(0,X.jsxs)(Y5,{...u,ref:f,className:Z(`caps-status-tray`,l),"data-placement":o,"data-align":s,children:[h?(0,X.jsxs)(X5,{open:!0,ref:p,tabIndex:-1,side:`top`,id:`${d}-${h.id}`,role:`dialog`,"aria-labelledby":`${d}-title`,className:`caps-status-tray-panel`,"data-status-tray-panel":h.id,children:[(0,X.jsxs)(`div`,{className:`caps-status-tray-head`,children:[h.tone?(0,X.jsx)(l8,{size:`compact`,tone:h.tone,glyph:h.glyph??`dot`}):null,(0,X.jsx)(`span`,{id:`${d}-title`,className:`caps-status-tray-title`,children:h.title??h.label}),h.actions,(0,X.jsx)(QI,{"aria-label":`Close tray`,icon:(0,X.jsx)(AL,{"aria-hidden":`true`}),onClick:_})]}),(0,X.jsx)(`div`,{className:`caps-status-tray-body`,children:h.content})]}):null,o===`host`?null:(0,X.jsxs)(`div`,{className:`caps-status-tray-row`,children:[r,(0,X.jsx)(`div`,{className:`caps-status-tray-chips`,children:e.map(e=>{let r={ref:t=>{t?m.current.set(e.id,t):m.current.delete(e.id)},type:`button`,className:a?void 0:`caps-status-tray-chip`,"aria-expanded":g===e.id,"aria-controls":g===e.id?`${d}-${e.id}`:void 0,"aria-label":e.accessibleLabel,disabled:e.disabled,title:e.disabled?e.accessibleLabel:void 0,"aria-haspopup":`dialog`,"data-status-tray-chip":e.id,onClick:()=>{n(t===e.id?null:e.id)},children:(0,X.jsxs)(X.Fragment,{children:[e.tone?(0,X.jsx)(l8,{size:`compact`,glyph:e.glyph??`dot`,motion:e.motion??`none`,tone:e.tone}):null,(0,X.jsx)(`span`,{className:`caps-status-tray-label`,children:e.label}),e.count!==void 0&&e.count>0?(0,X.jsx)(`span`,{className:`caps-status-tray-count`,children:e.count}):null]})};return(0,X.jsxs)(K.Fragment,{children:[a?a(r):(0,X.jsx)(`button`,{...r}),e.after]},e.id)})}),i]})]})}function Pse({children:e,className:t,...n}){return(0,X.jsx)(`div`,{...n,className:Z(`caps-status-tray-list`,t),children:e})}function Q5({icon:e,primary:t,secondary:n,actions:r,className:i,...a}){return(0,X.jsxs)(`div`,{...a,className:Z(`caps-status-tray-item`,i),children:[e?(0,X.jsx)(`span`,{className:`caps-status-tray-icon`,children:e}):null,(0,X.jsxs)(`span`,{className:`caps-status-tray-text`,children:[(0,X.jsx)(`span`,{className:`caps-status-tray-primary`,children:t}),n?(0,X.jsx)(`span`,{className:`caps-status-tray-secondary`,children:n}):null]}),r?(0,X.jsx)(`span`,{className:`caps-status-tray-actions`,children:r}):null]})}function $5({children:e=`All caught up.`,title:t}){return(0,X.jsxs)(`div`,{className:`caps-status-tray-note`,children:[t?(0,X.jsx)(`strong`,{className:`caps-status-tray-note-title`,children:t}):null,(0,X.jsx)(`p`,{children:e})]})}var e7=(0,K.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:Z(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})});function t7(e,t){return`${e}-${String(t)}`}function Fse(e){switch(e.key){case`ArrowDown`:return`next`;case`ArrowUp`:return`previous`;case`Enter`:return e.shiftKey?null:`accept`;case`Tab`:return`accept`;case`Escape`:return`dismiss`;default:return null}}function Ise(e){return{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":e.open,"aria-controls":e.open?e.listId:void 0,"aria-activedescendant":e.open?t7(e.listId,e.selected):void 0}}function n7({open:e,rows:t,selected:n,listId:r,label:i,kind:a,hint:o,empty:s,onHighlight:c,onChoose:l}){return(0,X.jsx)(X5,{open:e,side:`top`,"data-parakeet-slash":``,children:(0,X.jsxs)(`div`,{className:`parakeet-slash-menu`,"data-kind":a,children:[o===void 0?null:(0,X.jsx)(`p`,{className:`parakeet-slash-hint`,children:o}),t.length===0?s===void 0?null:(0,X.jsx)(`p`,{className:`parakeet-slash-hint`,children:s}):(0,X.jsx)(`div`,{id:r,role:`listbox`,"aria-label":i,children:t.map((e,t)=>(0,X.jsxs)(Nse,{id:t7(r,t),active:t===n,"aria-disabled":e.disabled===!0||void 0,"data-disabled":e.disabled===!0,onMouseEnter:()=>{c(t)},onClick:()=>{l(t)},children:[e.media===void 0?null:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`parakeet-slash-media`,children:e.media}),(0,X.jsx)(`span`,{className:`parakeet-slash-label`,children:e.label}),(0,X.jsx)(`span`,{className:`parakeet-slash-detail`,children:e.detail}),e.keys===void 0||e.keys.length===0?null:(0,X.jsx)(`kbd`,{className:`parakeet-slash-keys`,children:e.keys})]},e.key))})]})})}var r7={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},Lse={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function Rse({state:e}){let t=`caps-checkbox-${(0,K.useId)().replaceAll(`:`,``)}`,n=(0,K.useRef)(null),r=(0,K.useRef)(e).current,i=(0,K.useRef)(e),a=jP();return(0,K.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=TP(n.current),c=r8(s,{ease:`inCubic`,duration:160}),l=FI(n.current,{d:{to:r7[e],...o?t8:r8(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?t8:t?r8(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...r8(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:DP(s,120),...n8(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,X.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(zI,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(BI,{id:`${t}-shadow`}),(0,X.jsx)(VI,{id:`${t}-inset`}),(0,X.jsx)(UI,{id:`${t}-goo`,values:Lse}),(0,X.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,X.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,X.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,X.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,X.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,X.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,X.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,X.jsx)(`path`,{ref:n,d:r7[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,X.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,X.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,X.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var i7=(0,K.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,K.useRef)(null),[d,f]=(0,K.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,K.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,K.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,K.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,X.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,X.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:Z(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,X.jsx)(Rse,{state:m}):n]})}),a7=`data-glide-stand-in`;function o7(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left+e.scrollLeft-e.clientLeft,y:r.top-n.top+e.scrollTop-e.clientTop,width:r.width,height:r.height}}function s7(e){return{transform:`translate(${String(e.x)}px, ${String(e.y)}px)`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}}function c7(e){let t=(0,K.useRef)(null);return(0,K.useCallback)(n=>{t.current?.(),t.current=n?zse(n,e):null},[e])}function zse(e,t){if(!kP(e))return()=>void 0;let n=e.ownerDocument,r=e.querySelector(t),i=r?o7(e,r):null,a=null,o=null,s=new Set,c=()=>{for(let e of s)e.removeAttribute(a7);s.clear(),a&&(a.hidden=!0),o=null},l=()=>{if(a)return a;let t=n.createElement(`span`);return t.className=`caps-glide`,t.setAttribute(`aria-hidden`,`true`),e.prepend(t),e.classList.add(`caps-glide-host`),getComputedStyle(e).position===`static`&&e.classList.add(`caps-glide-anchor`),a=t,t},u=(t,n)=>{let r=TP(e),u=o7(e,t),d=o&&a?o7(e,a):i;if(i=u,o?.cancel(),c(),r.reduced||d===null||Math.abs(d.y-u.y)<1&&Math.abs(d.x-u.x)<1)return;t.setAttribute(a7,`measure`);let f=getComputedStyle(t),p=f.backgroundColor,m=f.borderRadius;for(let e of[t,n])e&&(e.setAttribute(a7,``),s.add(e));let h=l();h.hidden=!1,h.style.backgroundColor=p,h.style.borderRadius=m;let g=h.animate([s7(d),s7(u)],{duration:r.normal,easing:OP(r,r.ease),fill:`forwards`});o=g,g.addEventListener(`finish`,()=>{o===g&&c()})},d=()=>{let n=e.querySelector(t);if(n===r)return;let i=r;r=n,n&&u(n,i)},f=new MutationObserver(d);return f.observe(e,{subtree:!0,attributes:!0,attributeFilter:[`data-highlighted`,`data-active`,`data-navigation`,`aria-selected`]}),e.addEventListener(`pointerover`,d),e.addEventListener(`pointerout`,d),()=>{f.disconnect(),e.removeEventListener(`pointerover`,d),e.removeEventListener(`pointerout`,d),o?.cancel(),c(),a?.remove()}}function Bse({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,K.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,K.useState)(null);(0,K.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}function Vse({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=K.useRef(e!==void 0),[a,o]=K.useState(()=>t);return[i&&e!==void 0?e:a,K.useCallback(e=>{i||o(e)},[])]}var Hse=RM(`card caps-card`,{variants:{variant:{surface:`caps-card-surface`,outline:`caps-card-outline`,interactive:`caps-card-interactive`,game:`caps-card-game caps-card-interactive`,fit:`caps-card-fit`},density:{regular:``,compact:`caps-card-compact`}},defaultVariants:{variant:`surface`,density:`regular`}}),l7=(0,K.forwardRef)(function({className:e,density:t,featured:n=!1,state:r,variant:i,...a},o){return(0,X.jsx)(`div`,{...a,className:Z(Hse({density:t,variant:i}),n&&`caps-card-featured`,e),"data-state":r,ref:o})});(0,K.forwardRef)(function({className:e,density:t,variant:n,width:r=`default`,...i},a){return(0,X.jsx)(`main`,{className:`caps-centered-card-stage`,children:(0,X.jsx)(l7,{...i,className:Z(`caps-centered-card`,r===`wide`&&`caps-centered-card-wide`,e),ref:a,variant:n??`surface`,...t?{density:t}:{}})})}),(0,K.forwardRef)(function({alignment:e=`start`,className:t,...n},r){return(0,X.jsx)(`div`,{...n,className:Z(`caps-card-header`,e===`center`&&`caps-card-header-centered`,t),ref:r})}),(0,K.forwardRef)(function({className:e,level:t=3,...n},r){return(0,X.jsx)(t===2?`h2`:`h3`,{...n,className:Z(`caps-card-title`,e),ref:r})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`p`,{...t,className:Z(`caps-card-description`,e),ref:n})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,className:Z(`caps-card-content`,e),ref:n})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(`div`,{...t,className:Z(`caps-card-footer`,e),ref:n})});var Use=(0,K.forwardRef)(function({action:e,attachments:t,className:n,input:r,toolbar:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:Z(`caps-composer`,n),children:[t===void 0?null:(0,X.jsx)(`div`,{className:`caps-composer-attachments`,children:t}),(0,X.jsx)(`div`,{className:`caps-composer-input`,children:r}),i===void 0&&e===void 0?null:(0,X.jsxs)(`div`,{className:`caps-composer-bar`,children:[(0,X.jsx)(`div`,{className:`caps-composer-toolbar`,children:i}),e]})]})});function Wse({draft:e,hasAttachments:t=!1,busy:n,queueWhileBusy:r=!1,blocked:i=!1}){let a=!i&&(e.trim().length>0||t);return n&&(!r||!a)?`busy`:a?`ready`:`empty`}function Gse({attachments:e,action:t,children:n,className:r,input:i,menu:a,row:o,...s}){return(0,X.jsxs)(Y5,{className:`parakeet-composer-anchor`,children:[a,(0,X.jsxs)(l7,{...s,className:Z(`parakeet-composer-shell`,r),children:[(0,X.jsx)(Use,{action:t,attachments:e,input:i,toolbar:o===void 0?void 0:(0,X.jsx)(Z5,{className:`parakeet-composer-row`,align:`start`,items:o.items,openId:o.openId,onOpenChange:o.onOpenChange,renderTrigger:({children:e,...t})=>(0,X.jsx)(fP,{...t,label:e,expanded:t[`aria-expanded`]===!0}),leading:o.controls,trailing:(0,X.jsxs)(`span`,{className:`parakeet-composer-trailing`,children:[o.status,o.readout==null?null:(0,X.jsx)(`span`,{className:`parakeet-composer-readout`,children:o.readout}),(0,X.jsx)(`span`,{className:`parakeet-composer-action`,children:o.action})]})})}),n]})]})}function Kse(e,t){(0,K.useLayoutEffect)(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${String(t.scrollHeight)}px`)},[e,t])}var u7=K.createContext(void 0);function qse(e){let t=K.useContext(u7);if(t===void 0&&!e)throw Error(sZ(33));return t}var d7=K.createContext(void 0);function f7(e){let t=K.useContext(d7);if(t===void 0&&!e)throw Error(sZ(36));return t}var Jse=K.createContext(void 0);function p7(e=!0){let t=K.useContext(Jse);if(t===void 0&&!e)throw Error(sZ(25));return t}var m7=K.createContext(null);function h7(e=`root`){let t=K.useContext(m7),n=K.useContext(d7);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var Yse={visible:!0,ref:null};function Xse(){return Yse}function g7(e,t,n=`root`){let r=h7(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Xse)({label:e.label,children:e.children,render:e.render}),a=fZ(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var _7=K.createContext(void 0);function Zse(){let e=K.useContext(_7);if(e===void 0)throw Error(sZ(30));return e}function Qse(e){e.preventDefault()}function $se(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=f7(),u=p7(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return K.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?Qse:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:c$})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!z$&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&ZQ(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var v7={type:`regular-item`};function y7(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=K.useRef(null),{getButtonProps:d,buttonRef:f}=QQ({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=$se({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=K.useCallback(e=>kZ(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=fZ(u,f);return K.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var b7=K.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function ece(){return K.useContext(b7)}function x7(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=ece(),u=K.useRef(-1),[d,f]=K.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=K.useRef(null),h=K.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return KQ(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var tce=`data-checked`,nce=`data-unchecked`,S7={checked(e){return e?{[tce]:``}:{[nce]:``}},...$Z},rce=K.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=f7(),m=x7({guess:!0,label:a}),h=w$(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=y7({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:v7}),C=K.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=t$(c$,e.nativeEvent,void 0,{preventUnmountOnClose:SZ});u?.(!l,t)}let T=HZ(`div`,e,{state:C,stateAttributesMapping:S7,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,X.jsx)(_7.Provider,{value:C,children:T})}),ice=K.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=Vse({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=g7(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,X.jsx)(rce,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),ace=K.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Zse(),c=K.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=j2(s.checked);return I2({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),HZ(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:S7,props:{"aria-hidden":!0,...o},enabled:a||u})}),oce=K.createContext(void 0);function sce(){let e=K.useContext(oce);if(e===void 0)throw Error(sZ(31));return e}var cce=K.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=w$(a),c=sce();return KQ(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),HZ(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),lce=K.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=f7(),f=x7({guess:!0,label:a}),p=w$(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=y7({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:v7});return HZ(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),uce=K.forwardRef(function(e,t){let n=g7(e,t);return n.visible?(0,X.jsx)(lce,{...e,ref:n.ref}):null}),dce=K.createContext(void 0);function C7(e){let t=K.useContext(dce);if(t===void 0&&!e)throw Error(sZ(69));return t}function w7(e){return e===`starting`?Z0:wZ}var fce=K.createContext(void 0);function pce(){return K.useContext(fce)}function mce(e,t){let n=KZ(e.render);if(K.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function hce(e,t,n){let r=mce(e,t),i=r===t?void 0:r;return[r,K.useCallback(e=>n?.(e?i:void 0),[i,n])]}function gce(e,t,n){let r=KZ(e.render),i=K.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var _ce=K.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=f7(),m=pce(),{side:h,align:g}=qse(),_=C7(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=hce(e,u,d),L=gce(e,C,N),R=w.type===`menu`?m:void 0,z=w.type===`context-menu`,B=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(B=()=>l.state.activeIndex===null&&P),I2({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),K.useEffect(()=>{function e(e){l.setOpen(!1,t$(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),F4(D,{enabled:A&&!j&&!z&&w.type!==`menubar`,closeDelay:k});let V=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:H,handleFocus:ee}=(K.useContext(m7)?.useParentHandoff??yce)(l,w,v,f),te=HZ(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,V,I],stateAttributesMapping:pQ,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&a6.has(e.key)&&e.stopPropagation()},onFocus:ee},w7(y),c,{"data-rootownerid":E}]}),U=w.type===void 0||z;(C||w.type===`menubar`&&T!==`outside-press`)&&(U=!0);let W=R?.getReturnElement??H;return(0,X.jsx)(E2,{context:D,openInteractionType:M,modal:z,disabled:!x,returnFocus:a??W??U,explicitReturnFocus:a===void 0&&W?!1:void 0,initialFocus:B,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:te})}),vce={parentVirtualFocusRef:void 0,handleFocus:void 0};function yce(){return vce}var bce=K.forwardRef(function(e,t){let n=h7()?.Popup??_ce;return(0,X.jsx)(n,{...e,ref:t})}),T7=K.createContext(void 0);function xce(){let e=K.useContext(T7);if(e===void 0)throw Error(sZ(32));return e}var Sce=K.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=f7();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,X.jsx)(T7.Provider,{value:n,children:(0,X.jsx)(s2,{ref:t,...r,portalOwnerRole:o})})});function Cce(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=K.useState(null),d=K.useRef(null),f=p2(n),p=K.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Z3({...e,elements:{...p,...l&&{reference:l}}}),h=K.useCallback(e=>{let t=bQ(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=K.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=K.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=K.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return KQ(()=>{o&&(d.current=o)},[o]),KQ(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),K.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var wce=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=R1(e,t)||{};if(l==null)return{};let d=n0(u),f={x:n,y:r},p=W1(i),m=H1(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=L1(D,k,O),j=!c.arrow&&B1(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Tce=(e,t)=>{let{name:n,fn:r}=wce(e);return{name:n,fn:r,options:[e,t]}},Ece={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Dce={sideX:`left`,sideY:`top`},Oce=`--available-width`,kce=`--available-height`,Ace=`--anchor-width`,jce=`--anchor-height`,Mce=`--transform-origin`,E7=Oce,D7=kce;function O7(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function k7(e,t,n){let{rects:r,placement:i}=e;return{side:O7(t,z1(i),n),align:B1(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function A7(e){return Nce(e,Cce)}function Nce(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=UQ(O),A=O?k:n,j=S1(n),M=S1(g),N=K6()===`rtl`,[P,F]=K.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?z1(P):null,R=P&&I?B1(P)||`center`:null,z=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],B=R||o,V=B===`center`?z:`${z}-${B}`,H=l;typeof H==`number`?H={top:H,right:H,bottom:H,left:H}:H&&={top:H.top||0,right:H.right||0,bottom:H.bottom||0,left:H.left||0};let ee=+(i===`bottom`),te=+(i===`top`),U=+(i===`right`),W=+(i===`left`),ne={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:H},re=K.useRef(null),ie=S1(a),ae=S1(s),oe=typeof a==`function`?0:a,se=typeof s==`function`?0:s,G=[];p&&G.push(p),G.push(Q3(e=>{let t=k7(e,i,N),n=typeof ie.current==`function`?ie.current(t):ie.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[oe,se,N,i]));let ce=w===`none`&&C!==`shift`,le=!ce&&(u||E||C===`shift`),ue=C===`none`?null:t6({...ne,padding:{top:H.top+1+ee,right:H.right+1+W,bottom:H.bottom+1+te,left:H.left+1+U},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),de=ce?null:$3({...ne,rootBoundary:D,mainAxis:w!==`none`,crossAxis:le,limiter:u||E?void 0:e6(e=>{if(!re.current)return{};let{width:t,height:n}=re.current.getBoundingClientRect(),r=U1(z1(e.placement)),i=r===`y`?t:n,a=r===`y`?H.left+H.right:H.top+H.bottom;return{offset:i/2+a/2}})},[ne,u,E,D,H,w]);C===`shift`||w===`shift`||B===`center`?G.push(de,ue):G.push(ue,de),G.push(n6({...ne,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(E7,`${t}px`),i.setProperty(D7,`${n}px`);let a=_Q(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Ace,`${u}px`),i.setProperty(jce,`${d}px`)}}),Tce(e=>({element:re.current||XQ(e.elements.floating).createElement(`div`),padding:re.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=z1(r),u=B1(r),d=U1(l)===`y`,f=re.current,p=typeof a==`function`?a(k7(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return le&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Mce,d?`${m} ${h}`:`${h} ${m}`),{}}},Ece,b),KQ(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let fe=K.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:pe,elements:me,x:he,y:ge,middlewareData:_e,update:ve,placement:ye,context:be,isPositioned:xe,floatingStyles:Se}=t({rootContext:h,open:m?g:void 0,placement:V,middleware:G,strategy:r,whileElementsMounted:m?void 0:(...e)=>z3(...e,fe),nodeId:y,externalTree:S}),{sideX:Ce,sideY:we}=_e.adaptiveOrigin||Dce,Te=xe?r:`fixed`,Ee=K.useMemo(()=>{let e;return e=xe?b?{position:Te,[Ce]:he,[we]:ge}:{...Se,position:Te}:{position:Te,top:0,left:0},e[E7]=`100vw`,e[D7]=`100vh`,xe||(e.opacity=0),e},[b,Te,Ce,he,we,ge,Se,xe]),De=K.useRef(null);KQ(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(j7(t)?t.current:t)||null;n!==De.current&&(pe.setPositionReference(n),De.current=n)},[g,pe,A,j]),K.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&j7(e)&&e.current!==De.current&&(pe.setPositionReference(e.current),De.current=e.current)},[g,pe,A,j]),K.useEffect(()=>{if(m&&g&&me.reference&&me.floating)return z3(me.reference,me.floating,ve,fe)},[m,g,me,ve,fe]);let Oe=z1(ye),ke=O7(i,Oe,N),Ae=B1(ye)||`center`,je=!!_e.hide?.referenceHidden;KQ(()=>{x&&g&&xe&&(Oe!==z||I&&Ae!==B)&&F(ye)},[x,I,g,xe,ye,Oe,Ae,z,B]);let Me=K.useMemo(()=>({position:`absolute`,top:_e.arrow?.y,left:_e.arrow?.x}),[_e.arrow]),Ne=_e.arrow?.centerOffset!==0;return K.useMemo(()=>({positionerStyles:Ee,arrowStyles:Me,arrowRef:re,arrowUncentered:Ne,side:ke,align:Ae,physicalSide:Oe,anchorHidden:je,refs:pe,context:be,isPositioned:xe,update:ve}),[Ee,Me,re,Ne,ke,Ae,Oe,je,pe,be,xe,ve])}function j7(e){return e!=null&&`current`in e}function Pce(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=UQ(i),[,o]=K.useState(0),s=dZ(Ice).current,c=dZ(Fce).current,l=K.useRef(0),u=K.useRef(!0),d=K.useRef(null),f=K.useRef(null),p=UQ(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=UQ((e,t)=>{c.set(e,t),p()}),h=UQ(e=>{c.delete(e),p()}),g=UQ(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!zce(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&M7(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Rce(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=UQ(()=>{let[e,t]=Lce(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});KQ(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),KQ(()=>{u.current&&v()}),KQ(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=UQ(e=>(s.add(e),()=>{s.delete(e)})),b=K.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,X.jsx)(b7.Provider,{value:b,children:t})}function Fce(){return new Map}function Ice(){return new Set}function Lce(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>M7(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Rce(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function zce(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function M7(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function N7(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=K.useRef(null),o=K.useRef(null),s=F2(r);KQ(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),KQ(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function P7(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),HZ(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},w7(r),i],stateAttributesMapping:fQ})}var Bce=20;function F7(e,t,n,r){let[i,a]=K.useState(!1);KQ(()=>{if(!e||!t||n==null){a(!1);return}let r=XQ(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-Bce)},[e,t,n]),v6(e&&(!t||i),r)}var Vce=K.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=$0,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=f7(),x=xce(),S=p7(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),z=n,B=c,V=l,H=s,ee=h;C.type===`context-menu`&&(z=n??C.context?.anchor,H??=`start`,!o&&H!==`center`&&(V=e.alignOffset??2,B=e.sideOffset??-5));let te=o,U=H;C.type===`menu`?(te??=`inline-end`,U??=`start`,ee=e.collisionAvoidance??e2):C.type===`menubar`&&(te??=C.context.orientation===`vertical`?`inline-end`:`bottom`,U??=`start`);let W=C.type===`context-menu`,ne=A7({anchor:z,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:te,sideOffset:B,align:U,alignOffset:V,arrowPadding:W?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ee,shift:W?{crossAxis:!(`side`in ee&&ee.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});K.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,t$(g$)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),K.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,t$(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let re=k$();K.useEffect(()=>{D||re.clear()},[D,re]),K.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?re.isStarted()||re.start(e,()=>{v.setOpen(!1,t$(g$))}):v.setOpen(!1,t$(g$))}else re.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,re]),K.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),N7({store:v,domReference:R,positionerElement:M,open:D});let ie={open:D,side:ne.side,align:ne.align,anchorHidden:ne.anchorHidden,nested:C.type===`menu`,instant:N},ae=C.type===`menubar`&&C.context.modal;F7(D&&(ae||O&&F!==`trigger-hover`),k===`touch`,M,A);let oe=P7(e,ie,{styles:ne.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),se=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),G=null;return C.type===`menubar`?G=C.context.contentElement:C.type===void 0&&(G=A),(0,X.jsxs)(u7.Provider,{value:ne,children:[se&&(0,X.jsx)(d6,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:u6(!D),cutout:G}),(0,X.jsx)(h2,{id:I,children:(0,X.jsx)(Pce,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:oe})})]})}),Hce=K.createContext(null);function I7(e){let t=K.useContext(Hce);if(t===null&&!e)throw Error(sZ(5));return t}function Uce(e){return e==null?r$:e.type.startsWith(`key`)?p$:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?m$:r$}var Wce={...E4,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=E4.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>V$&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!E4.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Gce=class extends _4{constructor(e,t,n=!1){let r=new Z2,i=qce(r,t,n,e);super(i,Kce(r),Wce),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function Kce(e){return{positionerRef:K.createRef(),popupRef:K.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:K.createRef(),beforeTriggerFocusGuardRef:K.createRef(),beforeContentFocusGuardRef:K.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function qce(e,t,n=!1,r){return{...b4(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:wZ,inputProps:wZ,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new l2,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:wZ,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var L7=K.createContext(null);function R7(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Jce(e,t){return e===`list-navigation`||R7(e,t)}var Yce=o4(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=p7(!0),C=f7(!0),w=I7(!0),T=C?.store,E=C?.virtualFocus??!1,D=K.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=w$(),k=w$(),[A,j]=K.useState(void 0),M=(A??k)||void 0,N=f2(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=dZ(()=>F?P?.state.instantType:void 0).current,L=dZ(()=>{let e=new Gce({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),z=m2(R),B=L.useState(`open`),V=L.useState(`activeTriggerElement`),H=L.useState(`positionerElement`),ee=L.useState(`hoverEnabled`),te=L.useState(`disabled`),U=L.useState(`lastOpenChangeReason`),W=L.useState(`parent`),ne=L.useState(`activeIndex`),re=L.useState(`keyboardOpen`),ie=L.useState(`payload`),ae=L.useState(`floatingParentNodeId`),oe=K.useRef(null),se=K.useRef(W.type!==`context-menu`),G=k$(),ce=K.useRef(!0),le=k$(),ue=ae!=null,{openMethod:de,triggerProps:fe}=rae(B);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:W.type===void 0?c:void 0,openMethod:de,rootId:O}),q2(L);let{forceUnmount:pe,transitionStatus:me}=J2(B,L,()=>{L.set(`allowMouseEnter`,!1)},F),he=F2(L.context.popupRef);K.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!B){e();return}if(me!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return he(e,t.signal),()=>{t.abort()}},[I,B,me,he,L]),KQ(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:z,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:z,floatingParentNodeId:N})},[S,C,z,N,V,L]),K.useEffect(()=>{if(B||(oe.current=null),W.type===`context-menu`){if(!B){G.clear(),se.current=!1;return}G.start(500,()=>{se.current=!0})}},[G,B,W.type]),KQ(()=>{!B&&!ee&&L.set(`hoverEnabled`,!0)},[B,ee,L]);let ge=UQ((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||B===e&&t.trigger===V&&U===n)return;let i=G2(t);if(!e&&t.trigger==null&&(t.trigger=V??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ce.current)return;e&&n===`trigger-focus`?(ce.current=!1,le.start(300,()=>{ce.current=!0})):(ce.current=!0,le.clear());let o=!e&&(n===`escape-key`||n==null);oe.current=t.event;let s=W2(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Jce(n,a),s.instantType=W.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:R7(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),_e=A2({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:ge}),ve=_e.context.events;KQ(()=>{let e=({open:e,eventDetails:t})=>ge(e,t);return ve.on(`setOpen`,e),()=>{ve?.off(`setOpen`,e)}},[ve,ge]),KQ(()=>L.subscribeToParentMenu(),[L]);let ye=K.useCallback(()=>{L.setOpen(!1,t$(_$))},[L]);K.useImperativeHandle(d,()=>({unmount:pe,close:ye}),[pe,ye]);let be;W.type===`context-menu`&&(be=W.context),K.useImperativeHandle(be?.positionerRef,()=>H,[H]),K.useImperativeHandle(be?.actionsRef,()=>({setOpen:ge}),[ge]);let xe=k2(_e,{enabled:!te,bubbles:{escapeKey:f&&W.type===`menu`},outsidePress(){return W.type!==`context-menu`||oe.current?.type===`contextmenu`||se.current},externalTree:ue?R:void 0}),Se=K6(),Ce=W4(_e,{enabled:!te,listRef:L.context.itemDomElements,activeIndex:ne,virtual:v,nested:W.type===`menubar`||!v&&W.type!==void 0,parentOrientation:W.type===`menubar`?W.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?re:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Se===`rtl`,disabledIndices:CZ,onNavigate(e,t){L.setActiveIndex(e,Uce(t),t?.nativeEvent)},openOnArrowKeyDown:W.type!==`context-menu`&&!(v&&_),externalTree:!v&&ue?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),we=K.useCallback(e=>{L.context.typingRef.current=e},[L]),Te=G4(_e,{enabled:!te&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:ne,resetMs:500,onMatch:(e,t)=>{B&&e!==ne&&L.setActiveIndex(e,p$,t.nativeEvent)},onTyping:we}),Ee=UQ(a),De=K.useRef(-1),Oe=UQ(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(De.current===n&&L.context.reportedItem===t)return;De.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=r$,L.context.highlightEvent=void 0,a&&Ee(t,n$(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});KQ(()=>{Oe()},[ne,Oe]);let ke=K.useMemo(()=>{if(!v)return Ce.reference;if(!Ce.trigger)return wZ;let{onFocus:e,...t}=Ce.trigger;return t},[v,Ce.reference,Ce.trigger]);L.useSyncedValue(`inputProps`,v?Ce.reference??wZ:wZ);let Ae=K.useMemo(()=>{let e=kZ(Te.reference,ke,xe.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},fe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=B,e},[L,Te.reference,ke,xe.reference,fe,B]),je=K.useMemo(()=>{let e=kZ(Ce.trigger,xe.trigger,fe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ce.trigger,xe.trigger,fe]);dZ(()=>(L.update({inactiveTriggerProps:je}),null)),Y2(L,{floatingRootContext:_e,activeTriggerProps:Ae,inactiveTriggerProps:je,popupProps:K.useMemo(()=>kZ(R2,{onMouseMove(){L.set(`allowMouseEnter`,!0),W.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Te.floating,Ce.floating,xe.floating),[W.type,L,Te.floating,Ce.floating,xe.floating]),itemProps:Ce.item??wZ});let Me=K.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Oe}),[L,D,u,l,b,k,v,E,Oe]),Ne=typeof t==`function`?t({payload:ie}):t,Pe=(0,X.jsxs)(d7.Provider,{value:Me,children:[p&&(0,X.jsx)(V2,{handle:p,store:L}),Ne]});return(W.type===void 0||W.type===`context-menu`)&&(Pe=(0,X.jsx)(g2,{externalTree:R,children:Pe})),Pe});function Xce(e){let t=K.useContext(L7);if(t===null)return(0,X.jsx)(Yce,{...e});let n=t.Root;return(0,X.jsx)(L7.Provider,{value:null,children:(0,X.jsx)(n,{...t.options,...e})})}var z7=5;function Zce(e,t){let n=Qce(t);return e.clientX>=n.left-z7&&e.clientX<=n.right+z7&&e.clientY>=n.top-z7&&e.clientY<=n.bottom+z7}function Qce(e){let t=e.getBoundingClientRect(),n=_Q(e);if(U$)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function $ce(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=JQ(),{ref:i,index:a}=x7(e),o=n===a,s=K.useRef(null),c=fZ(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function ele(e){let{render:t,className:n,style:r,state:i=wZ,props:a=CZ,refs:o=CZ,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=$ce({metadata:s});return HZ(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function B7(e){if(xQ(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!NQ(e))return B7(IQ(e))}function V7(e,t){function n(n,r,i){let a=n.currentTarget;n2.flushSync(()=>{e.setOpen(!1,t$(u$,n.nativeEvent,a))}),j0(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&M0(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function tle(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=K.useRef(!1);return K.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,XQ(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:wZ,[t,n,r])}var nle=s4(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=f7(!0),h=D4(d)??m?.store;if(!h)throw Error(sZ(85));let g=w$(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=K.useRef(null),S=ile(),C=JQ(!0),w=p2(),T=K.useMemo(()=>w??new l2,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=K2(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:m2(T),floatingParentNodeId:f2(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=QQ({disabled:A,native:o});K.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=K.useRef(null),P=k$(),F=UQ(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Z$(N.current,t)||Z$(h.select(`positionerElement`),t)||t===N.current||(t==null||B7(t)!==h.select(`rootId`))&&(Zce(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:h$}))});K.useEffect(()=>{let e=XQ(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=L4(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:$4({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=rle(y,h.select(`lastOpenChangeReason`)),z=D2(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),B=k4(v,{enabled:!A&&I}),V=tle({open:y,enabled:O,mouseDownAction:`open`}),H=K.useMemo(()=>kZ(B.reference,z.reference),[B.reference,z.reference]),ee=h.useState(`triggerProps`,D),te=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:U,handleFocusTargetFocus:W}=V7(h,x),ne={disabled:A,open:y},re=[N,t,M,E,x],ie=[H,L??wZ,ee,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),XQ(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},te,O?{role:`menuitem`}:{},V,p,j],ae=HZ(`button`,e,{enabled:!O,stateAttributesMapping:dQ,state:ne,ref:re,props:ie});return O?(0,X.jsx)(ele,{tag:`button`,render:n,className:r,style:i,state:ne,refs:re,props:ie,stateAttributesMapping:dQ}):y?(0,X.jsxs)(K.Fragment,{children:[(0,X.jsx)(A1,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:U},`${g}-pre-focus-guard`),(0,X.jsx)(K.Fragment,{children:ae},g),(0,X.jsx)(A1,{ref:h.context.triggerFocusTargetRef,onFocus:W},`${g}-post-focus-guard`)]}):(0,X.jsx)(K.Fragment,{children:ae},g)});function rle(e,t){let n=k$(),[r,i]=K.useState(!1);return KQ(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function ile(){let e=I7(!0);return K.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var ale=K.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return HZ(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),H7=(0,K.createContext)(null);function ole({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,K.useRef)(null),o=e??a;return x6(()=>o.current?.close()),(0,X.jsx)(H7.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,X.jsx)(Xce,{...i,actionsRef:o,onOpenChange:(e,t)=>{if(n===`host`&&!e&&t.reason===`escape-key`){t.cancel(),t.allowPropagation();return}r?.(e,t)},children:t})})}function sle(){let e=(0,K.useContext)(H7);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var cle=(0,K.forwardRef)(function({className:e,render:t,type:n=`button`,...r},i){return(0,X.jsx)(nle,{...r,className:t=>Z(`btn caps-dropdown-trigger`,uP(e,t)),ref:i,render:t,type:n})}),lle=(0,K.forwardRef)(function({container:e,...t},n){let r=b6(`popover`);return e==null&&r===null?null:(0,X.jsx)(Sce,{...t,container:e??r,ref:n})}),ule=(0,K.forwardRef)(function({collisionBoundary:e,...t},n){let r=b6(`popover`);return(0,X.jsx)(Vce,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),dle=(0,K.forwardRef)(function({className:e,finalFocus:t,...n},r){let{interactionOwner:i}=sle(),a=(0,K.useRef)(null);(0,K.useImperativeHandle)(r,()=>a.current);let o=c7(`.caps-dropdown-item[data-highlighted]`),s=(0,K.useCallback)(e=>{a.current=e,o(e)},[o]);return(0,X.jsx)(bce,{...n,className:t=>Z(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,uP(e,t)),finalFocus:i===`host`?!1:t??!0,ref:s})}),fle=(0,K.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,X.jsx)(lle,{container:r,keepMounted:i,children:(0,X.jsx)(ule,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,X.jsx)(dle,{...s,ref:c,children:n})})})}),U7=`caps-dropdown-item flex w-full items-center gap-sm rounded-field px-md py-sm text-left text-sm outline-none transition-colors hover:bg-base-200 focus-visible:bg-base-200 aria-[current=page]:bg-base-200 aria-[current=page]:font-semibold disabled:cursor-not-allowed disabled:text-base-content/40 data-disabled:cursor-not-allowed data-disabled:text-base-content/40`;(0,K.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:r=`default`,...i},a){return(0,X.jsx)(uce,{...i,className:t=>Z(U7,r===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,uP(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:a})});var ple=(0,K.forwardRef)(function({children:e,className:t,onClick:n,onSelect:r,...i},a){return(0,X.jsxs)(ice,{...i,className:e=>Z(U7,uP(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||r?.(e)},ref:a,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,X.jsx)(ace,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})});(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(ale,{...t,className:t=>Z(`my-xs h-px bg-base-300`,uP(e,t)),ref:n})}),(0,K.forwardRef)(function({className:e,...t},n){return(0,X.jsx)(cce,{...t,className:t=>Z(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,uP(e,t)),ref:n})});function mle({disabled:e,emptyLabel:t,models:n,onChange:r,value:i}){let a=n.find(e=>e.id===i),[o,s]=(0,K.useState)(null);return(0,X.jsx)(`span`,{className:`contents`,ref:s,children:(0,X.jsxs)(ole,{children:[(0,X.jsx)(cle,{"aria-label":`Generation model`,"data-generation-model":i,disabled:e||n.length===0,render:(e,n)=>(0,X.jsx)(Mse,{...e,expanded:n.open,label:a===void 0?t:XL(a)})}),(0,X.jsx)(fle,{"data-generation-model-menu":!0,container:o,side:`top`,align:`start`,"aria-label":`Generation models`,children:n.map(e=>(0,X.jsx)(ple,{"data-generation-model-option":e.id,checked:e.id===i,closeOnClick:!0,onSelect:()=>{r(e.id)},children:XL(e)},e.id))})]})})}function hle(e){let t=Yk(e),n=(0,K.useRef)(e);n.current=e;let r=_x(),i=NS(DM(e)),a=IS(f8(e,i.data?.configured?i.data.path:null)),[o,s]=(0,K.useState)(null),c=n=>n?.app===e&&n.computerId===t,l=FS({mutationKey:TM.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new Y(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(ER).mkdir({path:r}),a(),await TR(e.capabilities,{path:r,limit:1,offset:0}),a(),Ij(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&s(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:d8.listing(n.owner,n.path),exact:!0})])}),u=l.variables?.owner===e&&l.variables.id===t,d=i.isFetching||u&&l.isPending,f=async(n,r)=>{if(!e||!t||d)return`Computer selection changed. Try again.`;let i=n.trim();if(!eb(XA)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await l.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:TM.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},p=i.isError||a.isError;return{path:p?null:i.data?.path??null,galleryPath:p||!i.data?.configured?null:i.data.path,computerId:t,available:e?.capabilities.has(TA)===!0,writable:e?.capabilities.has(ER)===!0,busy:d,error:p?`Your media folder is unavailable. Choose or create a folder.`:null,editing:c(o),setEditing:n=>{s(n?{app:e,computerId:t}:null)},choose:f,ensureCreated:async()=>i.data?i.data.configured?null:f(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:d8.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:TM.folder(e),exact:!0})}}}var gle=nb(fb),_le=nb(q({message:fb}));function vle(e){for(let t of e.errors){let e=bd(vd(xd(_le(t),e=>e.message),()=>gle(t)));if(e!==void 0&&e.length>0)return e}}var yle={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},W7=(0,K.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,X.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:Z(`progress caps-gooey-motion caps-gooey-progress w-full`,yle[t],e),ref:r})});(0,K.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:Z(`caps-game-meter`,i),children:[(0,X.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,X.jsx)(W7,{"aria-label":e,value:t,max:n,tone:r})]})});function G7({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,X.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,X.jsx)(xle,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function K7({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,X.jsx)(QI,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,X.jsx)(TL,{}):(0,X.jsx)(AL,{}),onClick:()=>void n(t),type:`button`}):null}function ble({item:e}){return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,X.jsx)(`div`,{className:`caps-upload-details`,children:(0,X.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function xle({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,X.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,X.jsx)(zie,{className:`size-4`})}),(0,X.jsx)(ble,{item:e}),(0,X.jsx)(Sle,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,X.jsx)(W7,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function Sle({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,X.jsx)(K7,{action:e.retry,id:t,onAction:i,retry:!0}),(0,X.jsx)(K7,{action:e.cancel,id:t,onAction:n}),(0,X.jsx)(K7,{action:e.remove,id:t,onAction:r})]})}var q7=K.createContext(void 0);function J7(e){let t=K.useContext(q7);if(t===void 0&&!e)throw Error(sZ(47));return t}var Cle={...E4,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!E4.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&E4.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>E4.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},wle=class extends _4{constructor(e,t,n){let r=new Z2;super(Tle(e,r,t,n),Ele(r),Cle)}setOpen=(e,t)=>{let n=t.reason===a$,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=G2(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=W2(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),n2.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Tle(e,t,n,r=!1){let i={...b4(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Ele(e){return{popupRef:K.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:K.createRef(),beforeTriggerFocusGuardRef:K.createRef(),beforeContentFocusGuardRef:K.createRef(),stickIfOpenTimeout:new O$,stickIfOpen:!0,triggerElements:e}}var Y7=o4(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=Ole(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),X2(u,d),q2(u);let{forceUnmount:m}=J2(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),K.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),K.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,t$(_$))}),[m,u]);let h=d||f||s!=null;return(0,X.jsxs)(q7.Provider,{value:u,children:[s&&(0,X.jsx)(V2,{handle:s,store:u}),h&&(0,X.jsx)(kle,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function Dle(e){return J7(!0)?(0,X.jsx)(Y7,{props:e}):(0,X.jsx)(g2,{children:(0,X.jsx)(Y7,{props:e})})}function Ole(e,t){let n=B2((e,n)=>new wle(t,e,n));return K.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function kle({store:e,modal:t}){let n=k2(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Y2(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var Ale=s4(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=J7(!0),h=D4(s)??m;if(!h)throw Error(sZ(74));let g=w$(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=K.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=K2(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=L4(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:$4(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=D2(v,{stickIfOpen:UQ(()=>h.context.stickIfOpen)}),k=y6(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=QQ({disabled:a,native:o}),N={open(e){return w?dQ.open(e):uQ.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=V7(h,x),I=HZ(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[Q0]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,X.jsx)(K.Fragment,{children:I},g);return E?(0,X.jsxs)(K.Fragment,{children:[(0,X.jsx)(A1,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,X.jsx)(A1,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),X7=K.createContext(void 0);function jle(){let e=K.useContext(X7);if(e===void 0)throw Error(sZ(45));return e}var Mle=K.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return J7().useState(`mounted`)||n?(0,X.jsx)(X7.Provider,{value:n,children:(0,X.jsx)(s2,{ref:t,...r})}):null}),Z7=K.createContext(void 0);function Nle(){let e=K.useContext(Z7);if(!e)throw Error(sZ(46));return e}var Ple=K.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=e2,..._}=e,v=J7(),y=jle(),b=m2(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=A7({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});N7({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;F7(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=P7(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,X.jsxs)(Z7.Provider,{value:j,children:[S&&M&&(0,X.jsx)(d6,{inert:u6(!C),cutout:T}),(0,X.jsx)(h2,{id:b,children:P})]})}),Fle=K.createContext(void 0);function Ile(){let[e,t]=K.useState(0),n=UQ(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:K.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Lle=K.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=J7(),l=Nle(),u=C7(!0)!=null,{context:d,hasClosePart:f}=Ile(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);I2({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),F4(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?z2(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=HZ(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...R2,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&a6.has(e.key)&&e.stopPropagation()}},w7(g),s],stateAttributesMapping:pQ});return(0,X.jsx)(E2,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:xQ(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,X.jsx)(Fle.Provider,{value:d,children:M})})}),Rle=(0,K.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,X.jsxs)(`button`,{...r,ref:i,type:n,className:Z(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(yL,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function zle({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(t),[x,S]=(0,K.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,K.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=Bse({getKey:n,isDisabled:o,items:T});(0,K.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(q5(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,K.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function Ble(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,K.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:R,onPointerMove:z,activeItem:B,activeKey:V,commit:H,groups:ee,inputValue:te,listboxId:U,onInputChange:W,onInputKeyDown:ne,open:re,optionId:ie,selectedKeys:ae,setOpen:oe}=zle({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});x6(()=>{O&&oe(!1)});let se=b6(`popover`),G=s===void 0?se:s,ce=c7(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),le=(0,X.jsx)(O5,{..._,...O?{}:L,"aria-activedescendant":B?ie(f(B)):void 0,"aria-autocomplete":`list`,"aria-controls":U,"aria-expanded":!0,className:Z(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),W(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||ne(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:te}),ue=(0,X.jsx)(`div`,{id:U,ref:ce,className:`caps-combobox-list`,"data-navigation":R?`keyboard`:`pointer`,onPointerMove:z,role:`listbox`,"aria-multiselectable":C??void 0,children:ee.every(e=>e.items.length===0)?(0,X.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ee.map(e=>(0,X.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,X.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=V===t,i={active:r,disabled:n,selected:ae.includes(t)};return(0,X.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&R,disabled:n,id:ie(t),onClick:()=>{H(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,X.jsx)(vL,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,X.jsx)(`div`,{...j,className:Z(j.className),ref:D,children:(0,X.jsxs)(Dle,{modal:!0,onOpenChange:oe,open:re,children:[(0,X.jsx)(Ale,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),G===null?null:(0,X.jsx)(Mle,{container:G,children:(0,X.jsx)(Ple,{align:`start`,side:`bottom`,sideOffset:4,children:(0,X.jsxs)(Lle,{"data-active-tone":o,className:Z(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})})]})}):(0,X.jsx)(`div`,{...j,className:Z(j.className),ref:D,children:(0,X.jsxs)(`div`,{className:Z(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})}function Q7({icon:e,caption:t}){return(0,X.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,X.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,X.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var Vle=(0,K.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,X.jsx)(i7,{...a,appearance:r??`default`,"aria-label":e,className:Z(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(Q7,{icon:t,caption:n}),ref:o})})});function Hle({checked:e}){let t=`caps-radio-${(0,K.useId)().replaceAll(`:`,``)}`,n=(0,K.useRef)(null),r=(0,K.useRef)(e).current,i=(0,K.useRef)(e),a=(0,K.useRef)(null),o=EP(a),{reduced:s}=o;return(0,K.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=r8(o,{ease:`outCubic`,duration:75}),c=e?n8(o,{bounce:.65,duration:300}):r8(o,{ease:`inCubic`,duration:100}),l=FI(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,X.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(zI,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(BI,{id:`${t}-shadow`}),(0,X.jsx)(VI,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,X.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var $7=(0,K.createContext)(null),Ule=(0,K.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,K.useId)(),d=(0,K.useRef)(null);(0,K.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,K.useState)(n),h=s??p;return(0,K.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,X.jsx)($7.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,X.jsx)(`fieldset`,{...c,className:Z(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),e9=(0,K.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,K.useContext)($7);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,X.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,X.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:Z(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,X.jsx)(Hle,{checked:c}):t]})}),Wle=(0,K.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,K.useContext)($7),s=(0,K.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,X.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,X.jsx)(e9,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,X.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,X.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,X.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,X.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Gle=(0,K.forwardRef)(function({label:e,icon:t,caption:n,className:r,...i},a){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,children:(0,X.jsx)(e9,{...i,"aria-label":e,className:Z(`caps-icon-choice-input`,r),indicator:(0,X.jsx)(Q7,{icon:t,caption:n}),ref:a})})}),Kle=nb(fb),qle=nb(mb),Jle=nb(xb(jb)),Yle=nb(_b(fb)),t9=_b(Tb(File)),Xle=nb(t9),n9=yb([fb,jb,mb,ub,db,_b(fb),t9]),Zle=nb(n9),r9=e=>_d(Kle(e.state.value),()=>``),i9=e=>_d(qle(e.state.value),()=>!1),Qle=e=>_d(Jle(e.state.value),()=>null),$le=e=>_d(Yle(e.state.value),()=>[]),eue=e=>_d(Xle(e.state.value),()=>[]),tue=e=>_d(Zle(e.state.value),()=>null);function nue({field:e,spec:t,locked:n,...r}){let[i,a]=(0,K.useState)(!1);return(0,X.jsxs)(F5,{children:[(0,X.jsx)(O5,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:r9(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,X.jsx)(XI,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,X.jsx)(Lie,{"aria-hidden":`true`}):(0,X.jsx)(Rie,{"aria-hidden":`true`})})]})}var rue={text:`text`,email:`email`,url:`url`,tel:`tel`};function iue({spec:e,field:t,locked:n,...r}){let i=eue(t),a=n||e.readOnly===!0,o=(0,K.useRef)(null);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(MP,{asChild:!0,children:(0,X.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,X.jsx)(XI,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,X.jsx)(G7,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function aue({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,X.jsx)(O5,{...a,type:rue[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,X.jsx)(e7,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,X.jsx)(nue,{...r,field:t,spec:e,locked:n});case`money`:return(0,X.jsxs)(F5,{children:[(0,X.jsx)(I5,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,X.jsx)(O5,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,X.jsx)(O5,{...a,type:`date`,readOnly:e.readOnly,value:r9(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,X.jsx)(mse,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:Qle(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,X.jsxs)(H5,{...a,value:r9(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,X.jsx)(Ble,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:r9(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,X.jsx)(Rle,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===r9(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,X.jsx)(iue,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,X.jsx)(i7,{...a,disabled:n||e.readOnly===!0,checked:i9(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,X.jsx)(U5,{...a,disabled:n||e.readOnly===!0,checked:i9(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var oue=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function sue({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=$le(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsx)(z5,{legend:o,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,X.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,X.jsx)(Vle,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):e.options.map(r=>(0,X.jsx)(B5,{label:r.label,description:r.description,orientation:`inline`,children:(0,X.jsx)(i7,{name:e.name,value:r.value,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}})},r.value))})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,X.jsx)(z5,{legend:o,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,X.jsx)(Ule,{name:e.name,"aria-label":o,value:r9(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,X.jsx)(Gle,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,X.jsx)(Wle,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,X.jsx)(B5,{label:t.label,orientation:`inline`,children:(0,X.jsx)(e9,{value:t.value,disabled:t.disabled})},t.value))})})}function cue({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:tue(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function lue({form:e,spec:t,locked:n,layout:r}){let i=E5({form:e,name:t.name}),a=w5(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?vle(i.state.meta):void 0;if(t.render===void 0&&oue.has(t.kind))return(0,X.jsx)(sue,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,X.jsx)(B5,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,X.jsx)(aue,{spec:t,field:i,locked:n}):(0,X.jsx)(cue,{spec:t,field:i,locked:n,error:o,render:t.render})})}var uue=nb(gb(fb,n9));function a9({form:e,spec:t,locked:n,layout:r}){let i=t.when;return w5(e.store,e=>i===void 0||i(_d(uue(e.values),()=>({}))))?(0,X.jsx)(lue,{form:e,spec:t,locked:n,layout:r}):null}function due({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,X.jsx)(a9,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,X.jsx)(lse,{title:t.title,description:t.description,layout:r,children:i})}function fue({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,X.jsx)(due,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,X.jsx)(a9,{form:i,spec:a,locked:n,layout:r},t)})}var o9=class{annotation;constructor(e){this.annotation=e}},pue=class{sections;constructor(e){this.sections=e}},s9=`caps/form`,c9=0;function l9(e){c9+=1;let t={[`${s9}:${String(c9)}`]:new o9(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}fb.annotate(l9({kind:`secret`})).pipe(Cb(`Secret`));var u9=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function mue(e){return Object.values(e??{}).reduce((e,t)=>t instanceof o9?{...e,...t.annotation}:e,{})}function d9(e){return e.reduce((e,t)=>({...e,...mue(t)}),{})}function f9(e){let t=e?.[s9];return t instanceof pue?t.sections:{}}var p9=nb(fb);function m9(e){if(Eg(e))return gd(p9(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!Ag(e))return null;let t=[];for(let n of e.types){if(xg(n))continue;let e=m9(n);if(e===null)return null;t.push(...e)}return t}function h9(e){if(Cg(e))return{type:`string`,literals:[]};if(wg(e))return{type:`number`,nullable:!1};if(Tg(e))return{type:`boolean`};let t=m9(e);if(t!==null)return{type:`string`,literals:t};if(Og(e)){let[t]=e.rest;if(t===void 0)return null;if(Cg(t))return{type:`strings`,literals:[]};let n=m9(t);return n===null?null:{type:`strings`,literals:n}}if(Ag(e)){let t=e.types.filter(e=>!xg(e)&&!bg(e)),n=e.types.some(e=>bg(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=h9(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function hue(e){let t=e.ast;if(!kg(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=Q_(e.type),r=d9([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:h9(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:zte(e.type),description:Bte(e.type)}}),sections:f9(Rte(t))}}function g9(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof ho)n=!0,t=t.unwrap();else if(t instanceof yo)r=!0,t=t.unwrap();else if(t instanceof xo)t=t.unwrap();else if(t instanceof ko)t=t.in;else return{node:t,optional:n,nullable:r}}function _9(e){if(e instanceof Qa){let t=e.options.map(e=>_9(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof co?e.options:e instanceof uo?[...e.values]:null;if(t===null)return null;let n=t.map(e=>p9(e));return n.every(hd)?n.map(e=>e.value):null}function gue(e){let{node:t,nullable:n}=g9(e);if(t instanceof ua)return{type:`string`,literals:[]};if(t instanceof Na)return{type:`number`,nullable:n};if(t instanceof La)return{type:`boolean`};let r=_9(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof qa){let e=g9(t.element).node;if(e instanceof ua)return{type:`strings`,literals:[]};let n=_9(e);return n===null?null:{type:`strings`,literals:n}}return null}function v9(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof ho||e instanceof yo||e instanceof xo?e.unwrap():e instanceof ko?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>$n.get(e))}function y9(e){return v9(e).reduce((e,t)=>({...e,...t}),{})}function _ue(e){return Object.entries(e.shape)}function vue(e){let t=g9(e).node;if(!(t instanceof Ya))throw Error(`A schema form needs a z.object.`);return{fields:_ue(t).map(([e,t])=>{let n=d9(v9(t)),r=n.kind===`file`?{type:`files`}:gue(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=y9(t);return{name:e,valueType:r,optional:g9(t).optional,annotation:n,title:i.title,description:i.description}}),sections:f9(y9(e))}}function yue(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??u9(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function bue(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function xue(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function Sue(e){let t=e instanceof ca?vue(e):hue(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=yue(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??u9(e.name),help:a,kind:n??bue(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=xue(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function b9(e){let t=e instanceof ca?e:$y(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>x9(e)):x9(n)}}}}function x9(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var S9=`onServer`;function Cue(e){let t=e?.querySelector(`[aria-invalid="true"]`);t?.matches(`input, select, textarea, button, [tabindex]`)?t.focus():t?.querySelector(`input, select, textarea, button`)?.focus()}function wue(e){return e.state.meta.errorMap.onServer!==void 0}function Tue(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[S9]:void 0}}))}function Eue(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[S9]:n}}))}function C9(e){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(e.defaultValues),[s,c]=(0,K.useState)(null);Y8(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,K.useMemo)(()=>Sue(l),[l]),d=(0,K.useMemo)(()=>b9(l),[l]),f=D5({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),wue(e)&&Tue(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await b9(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&Eue(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function w9(e){return{dirty:w5(e.form.store,e=>!e.isDefaultValue),submitting:w5(e.form.store,e=>e.isSubmitting),canSubmit:w5(e.form.store,e=>e.canSubmit)}}function T9({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=w9(e),f=(0,K.useRef)(null);return(0,X.jsxs)(sse,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{setTimeout(()=>{Cue(f.current)},0)})},children:[c??(0,X.jsx)(fue,{model:e,disabled:l,layout:o}),s===void 0?(0,X.jsx)(kue,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function Due({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=C9({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,X.jsx)(T9,{...a,model:o})}function Oue(e){return`model`in e?(0,X.jsx)(T9,{...e}):(0,X.jsx)(Due,{...e})}function kue({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=w9(e),d=u?null:e.saved&&!l?(0,X.jsx)(l8,{tone:`success`,size:`compact`,label:e.saved}):l?(0,X.jsx)(l8,{tone:`neutral`,size:`compact`,label:o}):null;return(0,X.jsxs)(R5,{...c,error:e.error,status:d,children:[r?(0,X.jsx)(XI,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,X.jsx)(XI,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,X.jsx)(XI,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var E9={error:0,warning:1,info:2};function Aue(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||E9[e.tone]-E9[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function jue(e,t,n){let r=Aue(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:NC(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var Mue={Setup:(0,X.jsx)(DL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,X.jsx)(bL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,X.jsx)(kL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function Nue({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,X.jsx)(Z5,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,X.jsx)(Pue,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function Pue({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,X.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,X.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,X.jsx)(tL,{level:3,children:e}),(0,X.jsx)(Pse,{children:t.map(e=>(0,X.jsx)(Q5,{icon:Mue[e.group],primary:e.title,secondary:e.detail,actions:(0,X.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map(e=>(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,X.jsx)(QI,{"aria-label":`Dismiss ${e.title}`,icon:(0,X.jsx)(AL,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,X.jsx)($5,{children:`All caught up.`}),t&&t.items.length>0?(0,X.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,X.jsx)(tL,{level:3,children:`Uploading`}),(0,X.jsx)(G7,{...t})]}):null,(0,X.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,X.jsx)(`span`,{className:`prints-footer-note`,children:`Clear keeps setup notices`}),(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function Fue({folder:e}){return(0,X.jsx)(C6,{open:e.editing,onOpenChange:e.setEditing,children:(0,X.jsxs)(O6,{children:[(0,X.jsx)(A6,{children:(0,X.jsx)(j6,{children:`Save prints to`})}),(0,X.jsx)(Lue,{folder:e},e.computerId),(0,X.jsx)(k6,{children:(0,X.jsx)(M6,{render:(0,X.jsx)(XI,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Iue=q({path:Qb.check(Db(eb(XA),{message:`Enter an absolute Computer folder, such as /media.`})).annotate(l9({label:`Folder`,placeholder:`/media`}))});function Lue({folder:e}){let t=(0,K.useRef)(!1),n=C9({schema:Iue,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Oue,{model:n,disabled:i,footer:(0,X.jsxs)(R5,{divider:!1,children:[(0,X.jsx)(fP,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,X.jsx)(fP,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,X.jsx)(Q5,{role:`alert`,icon:(0,X.jsx)(Bie,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,X.jsx)($5,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}function Rue({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,canWrite:s,generationError:c,recoveryError:l,pendingGenerations:u,activeGenerations:d,gallerySlots:f,computerId:p,failed:m,uploadError:h,uploads:g,permissions:_,resume:v,discard:y,retryUpload:b}){let x=[];if(e)p===null?x.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&x.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{_()}}]}):x.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):x.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=lx(new Y(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));x.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}if(e&&p!==null&&!s&&x.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`}),c!==null){let e=c.mediaKind??`media`;x.push({key:c.key,group:`Images`,tone:`error`,short:{image:`Image failed`,video:`Video failed`,media:`Media failed`}[e],title:`Couldn’t create ${e}`,detail:c.message,actions:c.billing?[{label:`Open Billing`,run:c.billing}]:c.retry?[{label:`Retry`,run:c.retry}]:[]})}l!==null&&x.push({key:`recovery:${l}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:l});for(let e of u){if(d.has(e.reference.requestId)||f.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`Unfinished ${ZL(a,e.input.settings.model)?.kind??`media`}`;x.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`info`,short:t,title:t,detail:e.reference.computerId===p?e.input.settings.prompt:`${e.input.settings.prompt} · on Computer ${e.reference.computerId}`,actions:[...e.reference.computerId===p?[{label:`Resume`,run:()=>{v(e)}}]:[],{label:`Discard`,run:()=>{y(e)}}]})}m.length>0&&x.push({key:`files:${m.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:m.join(`, `)}),h!==null&&x.push({key:`uploads:${h}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:h});for(let e of g)(e.status===`error`||e.status===`cancelled`)&&x.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{b(e.id)}}]});return x}function zue(e,t){let n=NS(OM(e)),r=FS(wA({queryKey:TM.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>Pj(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var D9=0,O9=1,Bue=2,Vue=0,k9=1;function Hue(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function Uue(e,t){let n=e.list;if(n.index===t)return n.next===null?Vue:(e.list=n.next,k9);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,k9;r=n,n=n.next}}var A9={low:0,max:0,high:0,C:Bue,P:void 0,R:void 0,L:void 0,list:void 0};A9.P=A9,A9.L=A9,A9.R=A9;function j9(e){let t=e.high;e.max=e.L===A9&&e.R===A9?t:e.L===A9?Math.max(e.R.max,t):e.R===A9?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function M9(e){let t=e;for(;t.P!==A9;)j9(t.P),t=t.P}function N9(e,t){if(t.R===A9)return;let n=t.R;t.R=n.L,n.L!==A9&&(n.L.P=t),n.P=t.P,t.P===A9?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,j9(t),j9(n)}function P9(e,t){if(t.L===A9)return;let n=t.L;t.L=n.R,n.R!==A9&&(n.R.P=t),n.P=t.P,t.P===A9?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,j9(t),j9(n)}function F9(e,t,n){t.P===A9?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function Wue(e,t){let n;for(;t!==A9&&t.C===O9;)t===t.P.L?(n=t.P.R,n.C===D9&&(n.C=O9,t.P.C=D9,N9(e,t.P),n=t.P.R),n.L.C===O9&&n.R.C===O9?(n.C=D9,t=t.P):(n.R.C===O9&&(n.L.C=O9,n.C=D9,P9(e,n),n=t.P.R),n.C=t.P.C,t.P.C=O9,n.R.C=O9,N9(e,t.P),t=e.root)):(n=t.P.L,n.C===D9&&(n.C=O9,t.P.C=D9,P9(e,t.P),n=t.P.L),n.R.C===O9&&n.L.C===O9?(n.C=D9,t=t.P):(n.L.C===O9&&(n.R.C=O9,n.C=D9,N9(e,n),n=t.P.L),n.C=t.P.C,t.P.C=O9,n.L.C=O9,P9(e,t.P),t=e.root));t.C=O9}function Gue(e){for(;e.L!==A9;)e=e.L;return e}function Kue(e,t){let n;for(;t.P.C===D9;)t.P===t.P.P.L?(n=t.P.P.R,n.C===D9?(t.P.C=O9,n.C=O9,t.P.P.C=D9,t=t.P.P):(t===t.P.R&&(t=t.P,N9(e,t)),t.P.C=O9,t.P.P.C=D9,P9(e,t.P.P))):(n=t.P.P.L,n.C===D9?(t.P.C=O9,n.C=O9,t.P.P.C=D9,t=t.P.P):(t===t.P.L&&(t=t.P,P9(e,t)),t.P.C=O9,t.P.P.C=D9,N9(e,t.P.P)));e.root.C=O9}function que(){let e={root:A9,size:0},t={};return{insert(n,r,i){let a=e.root,o=A9;for(;a!==A9&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==A9){if(!Hue(o,r,i))return;o.high=Math.max(o.high,r),j9(o),M9(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:D9,P:o,L:A9,R:A9,list:{index:i,high:r,next:null}};o===A9?e.root=s:(s.low<o.low?o.L=s:o.R=s,M9(s)),Kue(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=Uue(r,n);if(i===void 0)return;if(i===k9){r.high=r.list.high,j9(r),M9(r),e.size--;return}let a=r,o=a.C,s;r.L===A9?(s=r.R,F9(e,r,r.R)):r.R===A9?(s=r.L,F9(e,r,r.L)):(a=Gue(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(F9(e,a,a.R),a.R=r.R,a.R.P=a),F9(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),j9(s),M9(s),o===O9&&Wue(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===A9||t>e.max)&&(e.L!==A9&&i.push(e.L),e.R!==A9&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var Jue=e=>{let t=K.useRef(e);return K.useEffect(()=>{t.current=e}),t},I9=(e,t)=>{let n=t||Yue,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},Yue=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],L9=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},R9=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},Xue=e=>{let t=e.length,n=R9(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=R9(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=R9(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},Zue=(e,t)=>{let n,{g:r,s:i}=Xue(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},Que=new WeakMap;function $ue(){let e=K.useState(ede)[1];return K.useRef(()=>e({})).current}var ede={},z9=K.createElement;function tde(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=ide,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=$ue(),w=ode(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),N=j(),P=[],F=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,I=Jue(b);h=v*h;let L=g+h,R=N<L&&M<T;if(O(Math.max(0,g-h/2),L,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};P.push(z9(d,{key:a,ref:w(e),role:F,style:typeof f==`object`&&f?Object.assign({},o,f):o},V9(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),R){let e=Math.min(T-M,Math.ceil((g+h-N)/p*D)),t=M,n=ade(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);P.push(z9(d,{key:i,ref:w(t),role:F,style:typeof f==`object`?Object.assign({},n,f):n},V9(y,t,e,E)))}}K.useEffect(()=>{typeof I.current==`function`&&S!==void 0&&I.current(x,S,r),B9=`1`},[x,S,r,I]),K.useEffect(()=>{R&&C()},[R,t]);let z=nde(_,k(T,p));return z9(i,{ref:u,key:B9,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?rde(z,s):z,children:P})}var B9=`0`,V9=Zue([L9,{},WeakMap,L9],(e,t,n,r)=>z9(e,{index:t,data:n,width:r})),nde=I9((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),H9=(e,t)=>e[0]===t[0]&&e[1]===t[1],rde=I9((e,t)=>Object.assign({},e,t),H9);function ide(e,t){return t}var ade=I9(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),ode=I9((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),Que.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},H9),sde=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=que(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=cde(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},cde=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},U9=0,lde=320,ude=656;function dde(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=4?2:t>=1280?4:t>=ude?3:2}function W9({item:e}){return HX(e.path)?(0,X.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,X.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var fde=(0,K.memo)(function({item:e}){let t=(0,K.useRef)(null);(0,K.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,K.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,K.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return xse(async()=>{let{animate:e,spring:t}=await Promise.resolve().then(()=>Qre);return{animate:e,spring:t}},void 0,import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,X.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[(0,X.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,onClick:()=>{e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,X.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n||e.error?(0,X.jsx)(N6,{"data-media-pending":e.pending?`true`:void 0,failure:e.error?(0,X.jsx)(`span`,{title:e.error,className:`prints-tile-failed`,children:(0,X.jsx)(l8,{size:`compact`,appearance:`chip`,glyph:`bang`,tone:`error`,label:`Not saved`})}):void 0,indicator:(0,X.jsx)(JI,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`}),label:e.pendingLabel??`Preparing image…`,status:e.pending?e.error?`failed`:`generating`:`done`,children:e.pending?null:(0,X.jsx)(W9,{item:e})}):(0,X.jsx)(W9,{item:e})})}),e.error?(0,X.jsxs)(`div`,{className:`prints-gallery-pending-actions`,children:[e.onRetry?(0,X.jsx)(QI,{"aria-label":`Retry ${e.path}`,icon:(0,X.jsx)(TL,{}),onClick:e.onRetry}):null,e.onDismiss?(0,X.jsx)(QI,{"aria-label":`Dismiss ${e.path}`,icon:(0,X.jsx)(AL,{}),onClick:e.onDismiss}):null]}):null,(0,X.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&e.onInfo?(0,X.jsx)(QI,{"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,X.jsx)(xL,{})}):null,!e.pending&&e.onToggleReference?(0,X.jsx)(QI,{className:`prints-gallery-reference`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,X.jsx)(vL,{}):(0,X.jsx)(bL,{})}):null]})]})}),pde=(0,K.memo)(function({children:e,style:t,...n}){return(0,X.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function mde(e,t){let[n,r]=(0,K.useState)({height:0,width:0});return(0,K.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function hde(e){let[t,n]=(0,K.useState)(0),[r,i]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function gde(e,t){let n=Math.max(1,dde(e.length,t));return(0,K.useMemo)(()=>{let r=Math.floor((t-(n-1)*U9)/n),i=sde(n,r,U9);return r>0&&e.forEach((e,t)=>{let n=e.height>0?e.width/e.height:1;i.set(t,r/n)}),i},[e,t,n])}var _de=(0,K.memo)(function({data:e,width:t}){let n=e.height>0?e.width/e.height:1;return(0,X.jsx)(`div`,{"data-media-tile":e.key,style:{height:t/n,width:t},children:(0,X.jsx)(fde,{item:e})})});function G9(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function vde(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||G9(e,t))&&n()}function yde(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var bde=(0,K.memo)(function({items:e,scrollRef:t,focus:n}){let r=mde(t,e.length),i=r.width||lde,a=gde(e,i),{isScrolling:o,scrollTop:s}=hde(t),c=(0,K.useRef)(new Set),l=(0,K.useRef)(null),u=(0,K.useRef)(null);(0,K.useEffect)(()=>{if(!n)return;let o=l.current===n.requestId;if(o&&u.current===i)return;let s=t.current,c=e.findIndex(e=>e.key===n.key),d=a.get(c);if(!s||!d||r.height===0)return;let f=s.querySelector(`[data-media-grid]`);if(!f)return;let p=yde(s,f,d);if(o){vde(s,n.key,()=>{u.current=i});return}G9(s,n.key)?(l.current=n.requestId,u.current=i,n.onFocus()):s.scrollTo({top:p,behavior:`instant`})},[n,e,r.height,t,s,a,i]),(0,K.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.reduce((e,t,n)=>t.pending&&!t.onVisible&&!c.current.has(t.key)?n:e,-1);if(c.current=new Set(e.map(e=>e.key)),i<0)return;let o=a.get(i),s=n.querySelector(`[data-media-grid]`);if(!o||!s)return;let l=s.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop+o.top,u=l+o.height;l>=n.scrollTop&&u<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,l-Math.max(0,(n.clientHeight-o.height)/2)),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,a]);let d=(0,K.useCallback)(({data:e,width:t})=>(0,X.jsx)(_de,{data:e,width:t}),[]);return tde({as:pde,height:r.height,isScrolling:o,itemKey:e=>e.key,items:e,overscanBy:2,positioner:a,render:d,scrollTop:s})});function xde({items:e,scrollRef:t,focus:n}){return(0,X.jsx)(`section`,{"data-media-mosaic":!0,children:(0,X.jsx)(bde,{items:e,scrollRef:t,focus:n})})}function Sde(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...t.filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}var K9=`prints-prompt-counter`;function Cde({busy:e,disabled:t,draft:n,label:r,onGenerate:i,promptOver:a}){return(0,X.jsx)(jse,{"aria-describedby":a?K9:void 0,"aria-label":r,className:`prints-generate`,"data-generation-submit":!0,disabled:t||a,onClick:i,state:Wse({draft:n,busy:e}),title:r})}function wde({caretRequest:e,disabled:t,maxLength:n,addedLength:r=0,menu:i,mentionCount:a,onCaret:o,onChange:s,onMentionDismiss:c,onMentionMove:l,onMentionPick:u,onSend:d,onSlashMove:f,onSlashPick:p,placeholder:m,slashCount:h,value:g}){let _=(0,K.useRef)(null),v=(0,K.useRef)(g),[y,b]=(0,K.useState)([]),[x,S]=(0,K.useState)(-1),[C,w]=(0,K.useState)(!1),T=(0,K.useRef)(!1),E=(0,K.useRef)(!1);v.current=g,(0,K.useLayoutEffect)(()=>{if(C||t||!E.current)return;E.current=!1;let e=_.current;e&&e.ownerDocument.activeElement===e.ownerDocument.body&&e.focus({preventScroll:!0})},[t,C]),(0,K.useLayoutEffect)(()=>{let t=_.current;!t||e?.value!==g||(t.setSelectionRange(e.caret,e.caret),t.focus({preventScroll:!0}))},[e,g]),Kse(_,g);let D=(0,K.useCallback)(async()=>{let e=v.current.trim();if(!(!e||t||T.current)&&!(n!==void 0&&e.length+r>n)){E.current=_.current===_.current?.ownerDocument.activeElement,T.current=!0,w(!0);try{if(!await d())return;b(t=>t.at(-1)===e?t:[...t,e].slice(-20)),S(-1)}finally{T.current=!1,w(!1)}}},[t,n,d,r]),O=g.trim().length,k=O>0?O+r:0,A=n!==void 0&&k>n;return(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,X.jsx)(e7,{"aria-invalid":A?!0:void 0,"aria-label":`Image prompt`,className:`w-full`,"data-generation-prompt":!0,...Ise(i),disabled:t===!0||C,onChange:e=>{s(e.currentTarget.value),o(e.currentTarget.selectionStart),S(-1)},onSelect:e=>{o(e.currentTarget.selectionStart)},onKeyDown:e=>{if(q5(e))return;let t=Fse(e);if(a>0&&t!==null){e.preventDefault(),t===`next`?l(1):t===`previous`?l(-1):t===`accept`?u():c();return}if(g.startsWith(`/`)&&t!==null&&(h>0||t===`dismiss`||e.key===`Enter`)){if(e.preventDefault(),t===`dismiss`)s(g.slice(1));else if(h)t===`next`?f(1):t===`previous`?f(-1):p();else return;return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),D();return}if(e.key===`ArrowUp`&&_.current?.selectionStart===0&&y.length&&(x===-1||x>0)){e.preventDefault();let t=x===-1?y.length-1:x-1;S(t),s(y[t]);return}if(e.key===`ArrowDown`&&x!==-1){e.preventDefault();let t=x+1;t>=y.length?(S(-1),s(``)):(S(t),s(y[t]))}},placeholder:m,ref:_,rows:1,value:g}),n!==void 0&&k>0?(0,X.jsx)(`p`,{className:`px-3 pb-1 text-xs tabular-nums ${A?`text-error`:`text-dim`}`,"data-prompt-counter":!0,id:K9,role:A?`alert`:`status`,children:A?`${String(k)} / ${String(n)} characters. This model accepts up to ${String(n)}; shorten the prompt${r>0?` or its style and characters`:``} by ${String(k-n)} or pick another model.`:`${String(k)} / ${String(n)}`}):null]})}function Tde({index:e,listId:t,matches:n,onHighlight:r,onPick:i}){return(0,X.jsx)(n7,{open:!0,rows:n.map(e=>({key:e.id,label:`/${e.slash}`,detail:e.description??e.title})),selected:e,listId:t,label:`Commands`,kind:`commands`,empty:`No matching commands`,onHighlight:r,onChoose:i})}function Ede(e,t){let[n,r]=(0,K.useState)(0),i=t.startsWith(`/`),a=(0,K.useMemo)(()=>{if(!i)return[];let n=Ese(e.map((e,t)=>({alias:e.slash,commandId:e.id,command:e.command,title:e.title,description:e.description,category:`Prompt`,order:t,keys:[],availability:{status:`available`}})),t,{idleCategory:`Prompt`});return n.kind===`commands`?n.items.flatMap(({command:t})=>e.find(e=>e.id===t.commandId)??[]):[]},[t,e,i]);return(0,K.useEffect)(()=>{r(0)},[t]),{moveSlash:e=>{r(t=>a.length?(t+e+a.length)%a.length:0)},highlightSlash:r,resetSlash:()=>{r(0)},slashIndex:n,slashMatches:a,slashOpen:i}}function Dde({images:e,index:t,listId:n,matches:r,onHighlight:i,onPick:a}){return(0,X.jsx)(n7,{open:!0,rows:r.map(t=>{let n=t.references.at(0)?.path,r=e.find(e=>e.path===n);return{key:String(t.id),label:`@${t.name}`,detail:t.description||void 0,media:(0,X.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:r?(0,X.jsx)(`img`,{src:r.url,alt:``}):null})}}),selected:t,listId:n,label:`Characters`,kind:`characters`,onHighlight:i,onChoose:a})}function Ode(e,t){let[n,r]=(0,K.useState)(0),[i,a]=(0,K.useState)(0),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),u=o===t?null:_M(t,n),d=u?vM(e,u.query):[];return(0,K.useEffect)(()=>{a(0)},[t]),{caretRequest:c,matches:d,index:i,setCaret:r,highlight:a,dismiss:()=>{s(t)},move:e=>{a(t=>d.length?(t+e+d.length)%d.length:0)},complete:e=>{let i=d.at(e);if(!u||!i)return null;let a=`${t.slice(0,u.start)}@${i.name} ${t.slice(n)}`,o=u.start+i.name.length+2;return l({value:a,caret:o}),r(o),a}}}function kde(e){let t=_x(),n=NS(jM(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(TM.characters(e),n)}}),i=FS(r((e,t,n)=>CM(e.capabilities,t,n))),a=FS(r((e,t,n)=>wM(e.capabilities,t,n))),o=i.error??a.error??n.error;return{characters:n.data?.characters??[],error:o?lx(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}var q9=eb(rM),J9=e=>e.split(`/`).at(-1)??e;function Ade({paths:e,images:t}){return(0,X.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,X.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,X.jsx)(`img`,{src:n.url,alt:J9(e)}):null},e)})})}function jde({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,K.useState)(null),f=(0,K.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):q9(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,X.jsx)(C6,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,X.jsxs)(O6,{children:[(0,X.jsx)(A6,{children:(0,X.jsx)(j6,{children:`Characters`})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,X.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,X.jsx)(Ade,{paths:e.references.map(e=>e.path),images:t}),(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,X.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,X.jsx)(XI,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(O5,{"aria-label":`Character name`,"aria-invalid":!q9(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,X.jsx)(e7,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,X.jsxs)(XI,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,X.jsx)(kL,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,X.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,X.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,X.jsx)(`li`,{title:e.path,children:(0,X.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,X.jsx)(`img`,{src:e.url,alt:``}),(0,X.jsx)(`span`,{className:`prints-character-check`,children:(0,X.jsx)(i7,{"aria-label":`Use ${J9(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,X.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,X.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,X.jsx)(k6,{children:(0,X.jsx)(M6,{render:(0,X.jsx)(XI,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Y9=q({destination:ob(xb(fb)),height:ob(Hb),model:ob(fb),prompt:ob(fb),references:ob(_b(q({computerId:ob(fb),path:fb,role:ob(bb([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:ob(xb(mb)),steps:ob(xb(Hb)),style:ob(xb(fb)),width:ob(Hb)}),Mde=so(da(),Uo()).parse(structuredClone(tx(Y9,{onExcessProperty:`error`}).schema)),X9=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),Nde=X9(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),Pde=X9(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,Mde),Fde=X9(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function Ide(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(Nde,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(Pde,({arguments:e})=>{if(n)return;let r=ib(Y9,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(Fde,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function Lde(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...PL.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(NL[t].width)} × ${String(NL[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function Rde(e,t){let n=(0,K.useRef)(e);n.current=e;let r=Zk(t,{sourceId:`media-prompt`,namespace:`media`},(0,K.useCallback)(()=>Lde(()=>n.current),[])),i=(0,K.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,K.useMemo)(()=>Cse(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function Z9(e){let t=_x(),n=NS(kM(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(TM.styles(e),n)}}),i=FS(r((e,t,n)=>$j(e.capabilities,t,n))),a=FS(r((e,t,n)=>eM(e.capabilities,t,n))),o=i.error??a.error??n.error;return{styles:n.data?.styles??[],error:o?lx(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}function Q9(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function zde(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function Bde(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?Q9(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=ZL(i,n.model),c=o??s??ZL(i,a.model);if(c===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let l=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${XL(c)} instead.`:null,u=n.references.slice(0,n.typed.references),d=e===`animate`?{path:r,role:`first-frame`}:{path:r},f=[d,...u.filter(e=>!jL(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&c.input.maxReferences===0)return{kind:`refused`,message:`${c.label} does not take reference images.`};let p=e===`reuse`?u:e===`remix`?f:[d],m=QL(a,c),h={width:n.width??m.width,height:n.height??m.height},g=o===void 0?YL(h,c,void 0):zde(c,h.width,h.height)??m,_=o===void 0&&c.input.steps!==`fixed`&&n.steps!==null&&c.id===n.model?n.steps:m.steps,v=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:l,draft:{...m,destination:void 0,prompt:n.typed.prompt,references:p,steps:_,style:v,width:g.width,height:g.height}}}function Vde({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,X.jsxs)(H5,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,X.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,X.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function Hde({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,K.useState)(null);return(0,X.jsx)(C6,{open:n,onOpenChange:r,children:(0,X.jsxs)(O6,{children:[(0,X.jsx)(A6,{children:(0,X.jsx)(j6,{children:`Styles`})}),(0,X.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,X.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,X.jsx)(XI,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(O5,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,X.jsx)(e7,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,X.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,X.jsx)(k6,{children:(0,X.jsx)(M6,{render:(0,X.jsx)(XI,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Ude=[`a mushroom knight`,`moss on a keyboard`,`your Agent's selfie`];function Wde(e){Goe.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function Gde(e){let t=(0,K.useRef)(!1),n=D5({defaultValues:LL(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,K.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function Kde({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,onEditStyles:o,onEditCharacters:s}){let c=t?.input.dimensions===`none`,l=t!==void 0&&t.sizes!==null,u=t?.video??null;return(0,X.jsxs)(`div`,{className:`prints-settings`,children:[(0,X.jsx)(B5,{label:`Style`,orientation:`horizontal`,children:n}),(0,X.jsx)(B5,{label:`Size`,orientation:`horizontal`,children:(0,X.jsx)(H5,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:c,title:c?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:c?`provider`:i,children:c?(0,X.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,X.jsxs)(X.Fragment,{children:[l&&!r.some(e=>e.value===i)?(0,X.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,r.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value)),l?null:(0,X.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!c&&!l&&i===`custom`?(0,X.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,X.jsx)(e.Field,{name:`width`,children:e=>(0,X.jsx)(B5,{label:`Width`,children:(0,X.jsx)(O5,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,X.jsx)(e.Field,{name:`height`,children:e=>(0,X.jsx)(B5,{label:`Height`,children:(0,X.jsx)(O5,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,u?(0,X.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,X.jsx)(B5,{label:`Length`,orientation:`horizontal`,children:(0,X.jsx)(H5,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(u.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:u.durations.map(e=>(0,X.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,u?.supportsAudio?(0,X.jsx)(e.Field,{name:`generateAudio`,children:e=>u.defaultGenerateAudio===null?(0,X.jsx)(B5,{label:`Audio`,orientation:`horizontal`,children:(0,X.jsxs)(H5,{"aria-label":`Video audio`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,X.jsx)(`option`,{value:``,children:`Model default`}),(0,X.jsx)(`option`,{value:`on`,children:`On`}),(0,X.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,X.jsx)(B5,{label:`Audio`,orientation:`horizontal`,children:(0,X.jsx)(U5,{"aria-label":`Video audio`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,X.jsx)(e.Field,{name:`steps`,children:e=>(0,X.jsx)(B5,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,X.jsx)(O5,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,X.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{o()},children:`Edit styles…`}),(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Characters…`})]})]})}function qde({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,values:c,computerId:l,mediaDirectory:u,referenceImages:d,characters:f,characterDialog:p,onSubmit:m,styleControls:h,addedLength:g}){let _=ZL(i,c.model),v=c.prompt.trim().length,y=_!==void 0&&v>0&&v+g>_.maxPromptLength,b=tR(_),x=_?.video??null,S=nR(c.references,_),C=_===void 0?void 0:rR(S,_,x?.formats.find(e=>e.width===c.width&&e.height===c.height)?.resolution),w=_?.input.maxReferences??0,T=c.references.length>w,[E,D]=(0,K.useState)(!1),[O,k]=(0,K.useState)(!1),A=_!==void 0&&_.sizes!==null,j=JL(_),M=A?`${String(c.width)}x${String(c.height)}`:E?`custom`:j.find(e=>e.width===c.width&&e.height===c.height)?.value??`custom`,[N,P]=(0,K.useState)(!1),F=Rde({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{D(!1),r.setFieldValue(`width`,NL[e].width),r.setFieldValue(`height`,NL[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),P(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[I,L]=(0,K.useState)(!1),R=Ode(f,c.prompt),z=Ede(F.items,c.prompt),B=(0,K.useId)(),V=`${B}-commands`,H=`${B}-characters`,ee=gM({computerId:l,prompt:c.prompt,saved:f,references:c.references,model:_===void 0?void 0:{label:_.label,maxReferences:_.input.maxReferences}}),te=fM(c.prompt,f).characters,U=e=>{let t=z.slashMatches.at(e);t&&(z.resetSlash(),F.run(t.command))},W=h({open:N,onOpenChange:P}),ne=[c.style,qL(_,c.width,c.height),x&&c.durationSeconds!==void 0?`${String(c.durationSeconds)}s`:void 0,x?.supportsAudio&&c.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),re=(0,X.jsx)(Kde,{form:r,selected:_,stylePicker:W.picker,sizeChoices:j,sizeMode:M,onCustomSize:D,onEditStyles:()=>{k(!1),P(!0)},onEditCharacters:()=>{k(!1),L(!0)}});return(0,X.jsxs)(Gse,{"aria-label":`Image generation`,"data-generation-form":!0,attachments:c.references.length>0?(0,X.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,children:c.references.map((e,t)=>{let n=l!==null&&jL(e,l)?d.find(t=>t.path===e.path):void 0,i=S[t]?.role,a=eR(b,S,t);return(0,X.jsxs)(`div`,{className:`prints-reference-tile`,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,X.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,X.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,X.jsxs)(`span`,{children:[`Ref `,t+1]})}),i===void 0?null:a===void 0?(0,X.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:$L[i]}):(0,X.jsx)(XI,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${$L[i]}. Use as ${$L[a]}`,title:`Use as ${$L[a]}`,onClick:()=>{r.setFieldValue(`references`,S.map((e,n)=>n===t?{...e,role:a}:e))},children:$L[i]}),(0,X.jsx)(QI,{icon:(0,X.jsx)(AL,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,c.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??l,e.path]))})}):void 0,input:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),m()},children:(0,X.jsx)(r.Field,{name:`prompt`,children:e=>(0,X.jsxs)(`div`,{className:`prints-prompt`,children:[z.slashOpen?(0,X.jsx)(Tde,{index:z.slashIndex,listId:V,matches:z.slashMatches,onHighlight:z.highlightSlash,onPick:U}):null,!z.slashOpen&&R.matches.length>0?(0,X.jsx)(Dde,{images:d,index:R.index,listId:H,matches:R.matches,onHighlight:R.highlight,onPick:t=>{let n=R.complete(t);n!==null&&e.handleChange(n)}}):null,(0,X.jsx)(wde,{caretRequest:R.caretRequest,menu:z.slashOpen?{open:z.slashMatches.length>0,listId:V,selected:z.slashIndex}:{open:R.matches.length>0,listId:H,selected:R.index},mentionCount:z.slashOpen?0:R.matches.length,onCaret:R.setCaret,onMentionDismiss:R.dismiss,onMentionMove:R.move,onMentionPick:()=>{let t=R.complete(R.index);t!==null&&e.handleChange(t)},disabled:!o||a||i.length===0||s,maxLength:_?.maxPromptLength,addedLength:g,onChange:t=>{e.handleChange(t)},onSend:m,onSlashMove:z.moveSlash,onSlashPick:()=>{U(z.slashIndex)},placeholder:`What are we making?`,slashCount:z.slashMatches.length,value:e.state.value}),c.references.length>0||C!==void 0||te.length>0?(0,X.jsxs)(`div`,{className:`prints-composer-notes`,children:[c.references.length>0?(0,X.jsxs)(`span`,{className:`prints-reference-count`,"data-generation-references":!0,"data-over-limit":T?``:void 0,role:T?`alert`:void 0,children:[c.references.length,` / `,w,` `,`references`,T?w===0?` — this model takes none; remove them or pick another model`:` — over this model's limit; remove some to generate`:null]}):null,C===void 0?null:(0,X.jsx)(`span`,{className:`prints-reference-count`,"data-generation-reference-roles":!0,"data-over-limit":``,role:`alert`,children:C}),te.length>0?(0,X.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,"data-over-limit":ee.kind===`refused`?``:void 0,role:ee.kind===`refused`?`alert`:void 0,children:ee.kind===`refused`?ee.message:`Characters: ${te.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t?(0,X.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,X.jsx)(`span`,{children:t.group===`Images`&&t.detail?t.detail:(0,X.jsxs)(X.Fragment,{children:[t.title,`. `,t.detail]})}),t.actions?.map(e=>(0,X.jsx)(XI,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,X.jsxs)(X.Fragment,{children:[e,(0,X.jsx)(r.Field,{name:`model`,children:e=>(0,X.jsx)(mle,{models:i,emptyLabel:l===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:t=>{let n=ZL(i,t);if(e.handleChange(t),!n)return;let a=r.store.state.fieldMeta,o=QL(c,n),s=YL(c,n,_);(n.input.dimensions===`none`||n.sizes!==null)&&D(!1),r.setFieldValue(`width`,s.width),r.setFieldValue(`height`,s.height),r.setFieldValue(`durationSeconds`,o.durationSeconds),r.setFieldValue(`generateAudio`,o.generateAudio),(n.input.steps===`fixed`||!a.steps?.isTouched)&&r.setFieldValue(`steps`,o.steps)},value:e.state.value})}),l&&u?(0,X.jsxs)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Saved to ${l}:${u}`,children:[`Saves to `,u]}):null]}),action:(0,X.jsx)(Cde,{busy:s,draft:c.prompt,disabled:!o||a||i.length===0||s,label:BL(_),onGenerate:()=>{m()},promptOver:y}),items:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,X.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,X.jsx)(DL,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),ne.length>0?ne.join(` · `):`Settings`]}),content:re}],openId:O?`settings`:null,onOpenChange:e=>{k(e===`settings`)}},children:[W.dialog,p({open:I,onOpenChange:L})]})}function Jde({connection:e}){let t=(0,K.useRef)(e);t.current=e;let n=hle(e?.app??null),[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(),s=zue(e?.app??null,n.computerId),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(),m=(0,K.useRef)(0);(0,K.useEffect)(()=>{l(null),d(null),p(void 0)},[e,n.computerId,n.path]);let h=n.path,{gallery:g,images:_,failed:v,loading:y,gallerySlots:b,canBrowse:x,canRead:S,canWrite:C,reserveSlot:w,failSlot:T,clearSlotError:E,removeSlot:D,addComputerFile:O,retryFile:k,uploads:A,uploadFiles:j}=qae(e,n),[M,N]=(0,K.useState)(Date.now),P=b.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,K.useEffect)(()=>{if(!P)return;let e=setInterval(()=>{N(Date.now())},1e3);return()=>{clearInterval(e)}},[P]);let F=YA(e,(e,t,n)=>(g.refresh(),O(e,t,n)));(0,K.useLayoutEffect)(()=>{p(void 0),F.target&&(l(null),d(null))},[F.target]);let I=g.entries.some(e=>e.path===F.target?.path);(0,K.useEffect)(()=>{F.target&&!I&&g.nextPageReady&&g.loadMore()},[F.target,I,g.nextPageReady,g.loadMore]);let L=_.find(e=>e.source.kind===`computer`&&e.source.computerId===F.target?.computerId&&e.source.path===F.target.path),R=Z9(e?.app??null),z=kde(e?.app??null),B=soe({connection:e,folder:n,styles:R.styles,characters:z.characters,effects:{reserve:w,failed:T,notifyFailure:Wde,saved:({result:e},t)=>{S?O(e.destination.path,t,e.destination.computerId):T(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:V,models:H,modelsLoading:ee,modelsError:te,canGenerate:U,mediaCapability:W,pendingGenerations:ne,activeGenerations:re,recoveryError:ie}=B,ae=(0,K.useRef)(H),oe=(0,K.useRef)(B);oe.current=B;let se=(0,K.useRef)(null),G=(0,K.useRef)(null),ce=(0,K.useRef)(0),[le,ue]=(0,K.useState)(null),de=(0,K.useRef)(B.submit);de.current=async e=>{let t=await B.submit(e);return t&&ue(null),t};let fe=Gde(de),pe=e=>{fe.setFieldValue(`model`,e.model),fe.setFieldValue(`width`,e.width),fe.setFieldValue(`height`,e.height),fe.setFieldValue(`steps`,e.steps),fe.setFieldValue(`durationSeconds`,e.durationSeconds),fe.setFieldValue(`generateAudio`,e.generateAudio),fe.setFieldValue(`prompt`,e.prompt),fe.setFieldValue(`references`,e.references),fe.setFieldValue(`style`,e.style),fe.setFieldValue(`destination`,void 0)},me=(0,K.useRef)(fe);me.current=fe;let he=w5(fe.store,e=>e.values),ge=w5(fe.store,e=>e.isSubmitting),_e=e?.app;(0,K.useEffect)(()=>{if(_e)return Ide(_e,{readDraft:()=>me.current.store.state.values,readModels:()=>ae.current,setDraft:e=>{let t=me.current;if(e.model!==void 0){let n=ZL(ae.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=QL(t.store.state.values,n),i=ZL(ae.current,t.store.state.values.model),a=YL(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>me.current.store.state.isSubmitting||oe.current.isRunning()?Promise.resolve(!1):me.current.submitCurrent()})},[_e]),(0,K.useEffect)(()=>{ae.current=H},[H]),(0,K.useEffect)(()=>{if(H.length===0||te)return;let e=H.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??H[0];if(!fe.store.state.fieldMeta.model?.isTouched){let t=QL(fe.store.state.values,e);fe.setFieldValue(`model`,t.model),fe.store.state.fieldMeta.width?.isTouched||fe.setFieldValue(`width`,t.width),fe.store.state.fieldMeta.height?.isTouched||fe.setFieldValue(`height`,t.height),fe.store.state.fieldMeta.steps?.isTouched||fe.setFieldValue(`steps`,t.steps)}},[fe,te,H]);let ve=ZL(H,he.model),ye=he.references,be=ve?.input.maxReferences??0,xe=(0,K.useRef)({addComputerFile:O,retryPath:B.retryPath,uploads:A});xe.current={addComputerFile:O,retryPath:B.retryPath,uploads:A};let Se=L?m8(L):null,Ce=(0,K.useMemo)(()=>_.map(e=>({key:m8(e),selected:m8(e)===Se,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:ye.some(t=>e.source.kind===`computer`&&jL(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:ye.length>=be&&!ye.some(t=>e.source.kind===`computer`&&jL(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&be>0?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=ye.some(e=>jL(e,n)&&e.path===t);fe.setFieldValue(`references`,r?ye.filter(e=>!jL(e,n)||e.path!==t):[...ye,{path:t}])}:void 0,onInfo:()=>{l(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{l(null),d(m8(e))}})),[_,ye,be,fe,Se]),we=(0,K.useMemo)(()=>{let e=n.computerId;if(!e)return Ce;let t=new Map(Ce.map(e=>[e.key,e])),r=[...g.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{g.loadFile(n.path)},error:v.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{k(n.path)}}}),i=new Set(r.map(e=>e.key));return[...r,...Ce.filter(e=>!i.has(e.key)&&e.key!==Se)]},[Ce,g.entries,g.loadFile,k,v,n.computerId,Se]),Te=V.kind===`pending`,Ee=(0,K.useMemo)(()=>Sde(we,b,e=>{let n=A.items.find(t=>t.id===e.uploadId),r=e.error??(n?.status===`error`||n?.status===`cancelled`?n.message:void 0);return{key:e.key,path:e.path,width:e.width,height:e.height,url:``,pending:!0,error:r,pendingLabel:n?.status===`complete`||V.kind===`completed`?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:VL(H.find(e=>e.kind===`video`),M-e.startedAt,e.resumed),onOpen:()=>void 0,onRetry:r&&(S||n&&n.status!==`complete`)?()=>{if(E(e.key),n&&n.status!==`complete`){xe.current.uploads.retry(n.id);return}!e.uploadId&&xe.current.retryPath(e.path)||t.current&&xe.current.addComputerFile(e.path,t.current,e.computerId)}:void 0,onDismiss:r?()=>{D(e.key),e.uploadId&&xe.current.uploads.remove(e.uploadId)}:void 0}}),[we,b,A.items,V.kind,S,H,M]),De=ge||Te,Oe=b.some(e=>e.error!==void 0),ke=A.items.filter(e=>e.computerId===n.computerId),Ae=V.kind===`error`&&te===null?{key:B.errorKey,mediaKind:V.mediaKind,message:V.message,billing:V.action===`billing`&&e?()=>{e.app.ui.openTeamBilling().catch(n=>{JX(`open-team-billing`,n),t.current===e&&B.reportRecoveryError(n)})}:void 0,retry:Oe&&V.retryable!==!1?B.retry:void 0}:null,je=Rue({connected:e!==null,mediaCapability:W,modelsError:te,retryModels:B.retryModels,modelsLoading:ee,models:H,canGenerate:U,canWrite:C,generationError:Ae,recoveryError:ie,pendingGenerations:ne,activeGenerations:re,gallerySlots:b,computerId:n.computerId,failed:v,uploadError:A.error,uploads:ke,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{B.reportRecoveryError(e)})},resume:e=>{B.resume(e)},discard:e=>{B.discard(e)},retryUpload:e=>{A.retry(e)}});s.error&&je.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:s.error});let Me=s.visible(je),Ne={generating:re.size,uploading:ke.filter(e=>e.status===`sending`||e.status===`queued`).length},Pe={items:ke.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{A.cancel(e)},onRetry:e=>{A.retry(e)},onRemove:e=>{A.remove(e)}},Fe=new Set([...g.entries.map(e=>`${n.computerId??``}:${e.path}`),..._.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,Ie=jue(Me,Ne,r);Xk(e?.app,[...n.available?[vse(n.path,{checking:n.busy&&n.path===null,editing:n.editing})]:[],...Ie===null?[]:[Ie],...x?[{kind:`text`,id:`prints`,text:`${String(Fe)} ${Fe===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(o(e.anchor?.start),i(e=>!e),!0):e.itemId!==`folder`||!n.available?!1:(n.setEditing(!0),!0),t=>{JX(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{JX(`prints.status.toast`,e)})});let Le=_.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url}]:[]),Re=e=>{d(null),m.current+=1,p({key:e,requestId:`viewer-close-${String(m.current)}`,onFocus:()=>void 0})},ze=(t,n,r)=>(0,X.jsx)(aZ,{image:t,app:e?.app??null,referenceImages:Le,models:H,canAnimate:Q9(H)!==void 0,download:r,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=Bde(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:H,styles:R.styles.map(e=>e.name),current:fe.store.state.values});return r.kind===`refused`?r.message:(pe(r.draft),ue(r.notice===null?null:{model:r.draft.model,message:r.notice}),l(null),u!==null&&Re(m8(t)),null)},onClose:n},t.url);return(0,X.jsxs)(`main`,{className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":V.kind,"data-computer-capability":x?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&C&&(e.preventDefault(),j(t.map(e=>(ce.current+=1,new File([e],`paste-${String(ce.current)}-${p8(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,X.jsx)(rse,{id:`prints-generation-notices`}),(0,X.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,X.jsx)(i8,{screen:!0,surface:!0,surfaceSize:`lg`,surfaceDepth:`deep`,ref:se,className:`flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":y||g.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&C&&j(t)},children:(0,X.jsxs)(`div`,{className:`prints-gallery-content`,children:[Ee.length>0?(0,X.jsx)(xde,{items:Ee,scrollRef:se,focus:u===null?f??(L&&F.target?{key:`${F.target.computerId}:${F.target.path}`,requestId:F.target.requestId,onFocus:()=>{l(null),d(m8(L))}}:void 0):void 0}):y||g.loading?(0,X.jsx)(W5,{variant:`hint`,role:`status`,"aria-live":`polite`,title:`Loading prints…`,description:`Your library is on its way.`}):(0,X.jsx)(W5,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`panel`,visual:(0,X.jsx)(bL,{}),title:`Nothing printed yet.`,description:n.computerId===null?`Your images will appear here.`:n.available&&h===null?`Pick a folder in the composer below, then describe something or drop in images.`:`Describe something and it lands here, or drop in images from your Computer.`,...W?{suggestions:Ude.map(e=>({label:e,onSelect:()=>{fe.setFieldValue(`prompt`,e)}}))}:{}}),g.hasNextPage&&(0,X.jsx)(XI,{variant:`ghost`,disabled:g.loading,onClick:g.loadMore,children:g.loading?`Loading images…`:`Load more images`})]})}),F.error?(0,X.jsx)(`p`,{role:`alert`,children:`Could not open this print. It may no longer be available on this Computer.`}):null,c&&(c.source.kind===`local`||c.source.connection===e&&c.source.computerId===n.computerId)?ze(c,()=>{l(null)}):null]}),(0,X.jsx)($ae,{items:Ee,images:_,viewerKey:u,app:e?.app??null,onNavigate:d,onClose:Re,renderInfo:(e,t)=>ze(e,t,null)}),(0,X.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,X.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,X.jsx)(`input`,{ref:G,type:`file`,disabled:!C||h===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{j(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,X.jsx)(qde,{addedLength:pM(he.prompt,R.styles.find(e=>e.name===he.style)?.text,z.characters),styleControls:e=>({picker:(0,X.jsx)(Vde,{styles:R.styles,selected:he.style,disabled:!W||ee||De,onSelect:e=>{fe.setFieldValue(`style`,e)}}),dialog:(0,X.jsx)(Hde,{open:e.open,onOpenChange:e.onOpenChange,styles:R.styles,selected:he.style,busy:R.busy,error:R.error,onSelect:e=>{fe.setFieldValue(`style`,e)},onSave:R.save,onDelete:(e,t)=>{R.remove(e.id,t)}})}),characters:z.characters,characterDialog:e=>(0,X.jsx)(jde,{open:e.open,onOpenChange:e.onOpenChange,characters:z.characters,images:Le,busy:z.busy,error:z.error,canUpload:C&&h!==null,onUpload:()=>G.current?.click(),onSave:z.save,onDelete:(e,t)=>{z.remove(e.id,t)}}),guidance:Me.find(e=>e.blocking&&e.group===`Setup`)??(le!==null&&le.model===he.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:le.message,actions:[{label:`Dismiss`,run:()=>{ue(null)}}]}:void 0),commandApp:_e,actions:(0,X.jsx)(fP,{"aria-label":`Upload images`,title:C?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,X.jsx)(kL,{}),label:null,className:`prints-upload-key`,disabled:!C||h===null,onClick:()=>G.current?.click()}),form:fe,mediaCapability:W&&U&&C&&h!==null,models:H,modelsLoading:ee,onSubmit:fe.submitCurrent,submitting:De,values:he,computerId:n.computerId,mediaDirectory:h,referenceImages:Le}),Ie===null?null:(0,X.jsx)(Nue,{notices:Me,uploads:Pe,open:r,inset:a,onOpenChange:i,onDismiss:s.dismiss,onDismissAll:()=>{s.dismissAll(je)},onLoadMore:B.hasMore?B.loadMore:void 0})]}),(0,X.jsx)(Fue,{folder:n})]})}var $9=document.getElementById(`media-root`);if(!$9)throw Error(`Media root is missing`);Gk($9,{name:`Prints`,queryClient:SA()},({app:e})=>(0,K.createElement)(Jde,{connection:e?{app:e}:null}));