@fungi.computer/prints 0.17.5 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/assets/audio-waveform-CKaaFNjh.js +1 -0
  2. package/dist/assets/audio-waveform-view-CqGGEmLT.js +1 -0
  3. package/dist/assets/button-oE2Hrd5D.js +83 -0
  4. package/dist/assets/computer-Dlwsjq-K.js +1 -0
  5. package/dist/assets/dialog-BXLOuKaF.js +1 -0
  6. package/dist/assets/dist-Cc0qB3Mq.js +1 -0
  7. package/dist/assets/dropdown-menu-Bp_cc0HZ.js +1 -0
  8. package/dist/assets/ellipsis-DlNHenkt.js +1 -0
  9. package/dist/assets/generation-quote-DLlxvJxr.js +2 -0
  10. package/dist/assets/heart-BquDo4lf.js +1 -0
  11. package/dist/assets/images-CQ3EhUoY.js +1 -0
  12. package/dist/assets/index-0YeCF6OC.js +2 -0
  13. package/dist/assets/{index-ifZ9J_zI.css → index-BM24cAh6.css} +1 -1
  14. package/dist/assets/keycap-D2RkH2IS.js +1 -0
  15. package/dist/assets/library-rail-CA4Qg4FP.js +1266 -0
  16. package/dist/assets/library-view--GUDH_qa.js +1 -0
  17. package/dist/assets/log-event-R2fM9w5a.js +1 -0
  18. package/dist/assets/{print-download-button-BUMpO07b.js → print-download-button-hClIKKJA.js} +2 -2
  19. package/dist/assets/print-info-drawer-CtimiOWW.js +2 -0
  20. package/dist/assets/print-viewer-APDEs41V.js +2 -0
  21. package/dist/assets/prints-folder-dialog--W4H7Jx6.js +1 -0
  22. package/dist/assets/query-CvXKo0g1.js +1 -0
  23. package/dist/assets/status-DNJRO5m5.js +1 -0
  24. package/dist/assets/textarea-LIOZDOK4.js +1 -0
  25. package/dist/assets/upload-queue-BHAaEiPu.js +1 -0
  26. package/dist/assets/useMutation-RbhZiO3b.js +1 -0
  27. package/dist/assets/useTriggerFocusGuards-Bddw7Qdn.js +1 -0
  28. package/dist/index.html +21 -5
  29. package/package.json +8 -8
  30. package/dist/assets/generation-quote-CqTlWg6P.js +0 -2
  31. package/dist/assets/index-CWujOKND.js +0 -1267
  32. package/dist/assets/local-images-B1UCxAnA.js +0 -1
  33. package/dist/assets/log-event-DrObgwCc.js +0 -83
  34. package/dist/assets/print-info-drawer-QvgjDcHc.js +0 -2
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,C as n,D as r,Dt as i,En as a,Et as o,F as s,I as c,K as l,N as u,O as d,Tt as f,Vn as p,gn as m,k as ee,lt as h,q as g,st as te,v as _,x as ne}from"./button-oE2Hrd5D.js";import{At as re,Mt as ie,Nt as v,Rt as y,a as b,at as ae,i as x,jt as oe,n as se,r as S,s as C,yt as ce}from"./dist-Cc0qB3Mq.js";import{l as le,n as w,t as ue}from"./log-event-R2fM9w5a.js";import{c as de,d as fe,f as pe,l as me,o as he,p as ge,s as _e,u as ve}from"./query-CvXKo0g1.js";var T=e(p(),1);function ye(e,t,n){let r=ge(),i=pe(),a=re(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,he(o),me(o,i,s),fe(i);let[l]=T.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(T.useSyncExternalStore(T.useCallback(e=>{let t=d?l.subscribe(ae.batchCalls(e)):ce;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),T.useEffect(()=>{l.setOptions(o)},[o,l]),de(o,u))throw _e(o,l,i);if(ve({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}var be=`gilled.velvety.spored.saprotrophic.mycorrhizal.luminescent.honeycomb.truffley.wispy.earthy.mossy.woody.waxy.gelatinous.coral.inkcapped.feathery.stiped.ringed.annulate.scaly.shaggy.fuzzy.spiky.conical.umbral.parasol.leathery.damp.dewy.bristly.powdery.yeasty.musty.ancient.patient.steady.faithful.hardy.rootbound.forested.shaded.sunlit.sporeladen.golden.honeyed.amber.ivory.crimson.violet.indigo.silver.mossgreen.midnight.creamy.buttery.porcelain.glossy.matte.ribbed.fluted.wavy.lobed.branched.curled.folded.hooded.crowned.blushing.weeping.laughing.dancing.singing.whistling.glowing.ghostly.fairy.elfin.rustic.homey.barnraised.pasture.orchard.mill.woven.gardened.herded.trailed.ridged.meadow.fielded.vined.rooted.tendered.seasoned.ripe.wild.tame.broody.stubborn.gentle.drowsy.watchful.wandering.migratory.burrowed.nested.perched.loamy.mulched.composted.fermented.brewed.cured.smoked.pickled.preserved.aged.vintage.heirloom.grandmothers.forgotten.remembered.beloved.cherished.worn.weathered.windblown.rainsoaked.frosted.snowed.bloomed.flowered.seeded.sprouted.grafted.pruned.harvested.threshed.milled.baked.proofed.risen.folded.twisted.braided.stitched.patched.mended.polished.burnished.glazed.gilded.verdigris.patinaed.microdosed.tripping.wavy.prismatic.shimmering.rippling.echoing.oracular.mystic.kaleidoscopic.auroral.nebular.azure.psychedelic.transcendent.visionary.wandering.dreaming.phantom.spectral.iridescent.liminal.tidal.celestial.cosmic.astral.ethereal.incandescent`.split(`.`),xe=`shiitake.morel.chanterelle.bolete.puffball.oyster.enoki.maitake.lionsmane.truffle.porcini.agaric.amanita.bracket.conk.stipe.cap.gill.spore.hypha.mycelium.sporocarp.earthstar.stinkhorn.jelly.milkcap.blewit.cep.hedgehog.woodear.waxcap.inkcap.birdnest.cup.saddle.fieldcap.rust.smut.ergot.lichen.yeast.mold.toadstool.fruitingbody.basidiocarp.ascocarp.perithecium.apothecium.cystidium.basidium.clamp.septa.rhizomorph.sclerotium.gemma.annulus.volva.pileus.lamella.trama.gleba.peridium.sporangium.zygospora.conidia.teleomorph.anamorph.saprobe.endophyte.epiphyte.decomposer.recycler.alchemist.mycorrhiza.hyphae.web.net.lattice.thread.strand.root.tendril.runner.vine.ivy.moss.fern.liverwort.mule.cairn.almanac.parrot.birddog.watchdog.pigeon.ranch.barn.coop.pasture.meadow.field.orchard.gate.fence.silo.well.windmill.homestead.trail.ridge.creek.hill.grove.vineyard.apiary.garden.plot.furrow.shed.stable.trough.hayloft.rootcellar.smokehouse.springhouse.millstone.weathervane.lantern.tinderbox.candlemold.honeycomb.beeswax.propolis.nectar.pollen.comb.burrow.den.nest.perch.warren.colony.swarm.flock.herd.pod.grist.flour.starter.mother.scoby.kombucha.miso.tempeh.cheese.rennet.whey.curd.cream.butter.braid.loaf.crust.crumb.fiddlehead.sorrel.ramp.morelberry.huckleberry.thimbleberry.salmonberry.serviceberry.chokecherry.microdose.trip.shroom.liberty.teacher.treasure.wanderer.seeker.dreamer.shaman.visionary.tripper.oracle.seer.augur.prism.fractal.kaleidoscope.spectrum.nebula.aurora.comet.meteor.eclipse.zenith.horizon.mirage.echo.ripple.shimmer.glimmer.phantom.twilight.starlight.moonbeam`.split(`.`);function E(e){let t=Math.floor(4294967296/e.length)*e.length,n;do{let e=crypto.getRandomValues(new Uint32Array(1))[0];if(e===void 0)throw Error(`CSPRNG returned no candidate value`);n=e}while(n>=t);let r=e[n%e.length];if(r===void 0)throw Error(`Candidate vocabulary is empty`);return r}function Se(e){if(e?.count===1/0)throw RangeError(`words count must be finite`);let t=Math.max(1,Math.floor(e?.count??2)),n=e?.separator??`-`,r=[E(be)];for(let e=1;e<t;e++)r.push(E(xe));return r.join(n)}var Ce=C(`app.backend`,1,m(()=>x({request:b(S(a().transform(e=>y(e))))}))),we=C(`app.methods`,1,m(()=>x({call:b(S(a().transform(e=>y(e))))}))),D=72e4,O=ne(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),k=D+18e4,Te=`4 generations are running. Wait for one to finish.`,Ee=c({error:d(`generation_limit`),limit:r,message:s}),A=class extends oe{constructor(e){super(e,{code:`CONFLICT`,retryable:!0})}};function De(e,t){return e.computerId===void 0||e.computerId===t}var j=`@cf/black-forest-labs/flux-2-klein-4b`,Oe=`Image creation is unavailable for this Computer right now.`,M={landscape:{height:768,width:1024},portrait:{height:1024,width:768},square:{height:1024,width:1024}},N=[`landscape`,`portrait`,`square`];function P(e){return e instanceof w&&e.stage===`provider`&&e.provider!==void 0&&`reason`in e.provider&&e.provider.reason===`credits_exhausted`}function ke(e){if(!(e instanceof w)||e.stage!==`provider`)return;let t=e.provider;if(t===void 0||!(`code`in t))return;let n=e.code===`MEDIA_PROVIDER_FAILURE_UNCHARGED`?` You weren’t charged.`:``,r=(e,t,r)=>({title:e,message:t+n,retryable:r});switch(t.reason){case`content_refused`:return r(`Generation refused`,`The model refused this prompt (content policy). Try rewording it.`,!1);case`invalid_input`:return r(`Generation failed`,t.detail===void 0?`The provider rejected the input. Check the prompt and the reference image’s size and format.`:`The provider rejected the input: ${t.detail}.`,!1);case`rate_limited`:return r(`Generation failed`,`The provider is overloaded. Retry in a minute.`,!0);case`provider_unavailable`:return r(`Generation failed`,`The provider is having an outage. Retry in a minute.`,!0);case`timeout`:return r(`Still waiting`,`The model took too long to answer. Retry to ask again.`,!0);case`spending_limit`:return r(`Generation failed`,`The provider’s daily allowance is used up. Try another model, or retry tomorrow.`,!1);case`credits_exhausted`:return;case void 0:return t.detail===void 0?void 0:r(`Generation failed`,`The model stopped before it finished: ${t.detail}. Retry, or pick another model.`,!1)}}function F(e){if(e instanceof A)return{title:`Too many generations`,message:e.message,retryable:!0};if(P(e))return{title:`AI Gateway credits unavailable`,message:`Cloudflare AI Gateway couldn't fund this request. Check the account's credits and billing in the Cloudflare dashboard under AI Gateway, or choose a Workers AI model such as Flux.${e.code===`MEDIA_PROVIDER_FAILURE_UNCHARGED`?` You weren't charged.`:``}`,retryable:!1};let t=ke(e);return t===void 0?e instanceof w&&e.stage!==`provider`?{...v(e),message:e.message}:v(e,{INSUFFICIENT_CREDIT:{title:`Couldn’t create image`,message:`Media generation needs Team credits. Add credits in Billing, then retry.`},DAILY_LIMIT_REACHED:{title:`Couldn’t create image`,message:`Today's spending limit for this Oyster is used up. It resets at 00:00 UTC.`},MEDIA_PROVIDER_FAILURE:{title:`Generation failed`,message:`The model stopped before it finished. Retry, or pick another model.`},MEDIA_PROVIDER_FAILURE_UNCHARGED:{title:`Generation failed`,message:`The model stopped before it finished. You weren’t charged. Retry, or pick another model.`},SAFETY_FILTER_REFUSED:{title:`Generation refused`,message:`The model refused this prompt. Change the prompt or reference image, then retry.`},TIMEOUT:{title:`Still waiting`,message:`The model didn’t answer in time. Retry to ask again.`},SETUP_REQUIRED:{title:`Setup needed`,message:`This model isn’t connected. Connect one in Settings, then retry.`},DISCONNECTED:{title:`Connection lost`,message:`Prints lost its connection. Reopen it, then retry.`},HOST_FAILURE:{title:`Couldn’t create image`,message:`Couldn't generate this media. Try again.`}}):t}function Ae(e){let t=l(c({code:ee(ie)}))(e);return{reason:t._tag===`Some`?t.value.code:P(e)?`INSUFFICIENT_CREDIT`:`UNKNOWN`,message:F(e).message}}function je(){return{destination:void 0,height:768,model:j,prompt:``,references:[],steps:void 0,width:1024}}function Me(e,t,n=`png`){if(e.trim().length===0)throw Error(`Media generation token must not be empty.`);let r=e.trim();if(!/^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$/.test(r))throw Error(`Media generation basename contains invalid characters.`);return`${t.replace(/\/$/,``)}/generated-${r}.${n}`}function Ne(e,t,n){let r=e.destination?.trim();if(r)return r;let i=n?.outputFormats.includes(`png`)?`png`:n?.outputFormats[0]??`png`,a=n?.kind===`video`?`mp4`:n?.kind===`audio`?`mp3`:i===`jpeg`?`jpg`:i;return Me(Se({count:4}),t,a)}function Pe(e){return e?.kind===`audio`?e.audio?.mode===`music`?`Generate music`:`Generate speech`:e?.kind===`video`?`Generate video`:`Generate image`}function Fe(e){return e.filter(e=>e.kind!==`audio`&&e.transform===null)}function Ie(e){return e.filter(e=>e.kind===`audio`)}function Le(e){let{references:t,width:n,height:r,...i}=e.settings;return{...i,references:t??[],destination:e.destination.path,width:n??1,height:r??1}}function Re(e,t){return e?.kind===`audio`?le:{width:t.width,height:t.height}}function ze(e,t,n=!1){if(e===void 0)return`Creating media…`;if(e.kind===`audio`)return e.audio?.mode===`music`?`Composing music…`:`Making speech…`;if(e.transform?.operation===`remove_background`)return`Removing background…`;if(e.transform?.operation===`upscale`)return`Upscaling…`;if(e.kind!==`video`)return`Creating image…`;if(t===void 0)return`Creating video… Videos take about 2 minutes`;let r=Math.max(0,Math.floor(t/1e3));return`Creating video… ${String(Math.floor(r/60))}:${String(r%60).padStart(2,`0`)} elapsed${n?` since reopening`:``} · Videos take about 2 minutes`}var I=(e,t)=>t===0?e:I(t,e%t),L=(e,t,n)=>n===void 0?`${String(e)} × ${String(t)} · ${H(e,t)}`:`${String(e)} × ${String(t)} · ${String(n[0])}:${String(n[1])}`,R=[[1,1],[4,3],[3,4],[3,2],[2,3],[16,9],[9,16],[21,9]],z=16,Be=256,Ve=4e6,B=1048576;function V(e,t,n,r){let i=Math.floor((e.input.maxDimension??4096)/z)*z,a=e=>Math.round(e/z)*z,o=e=>Math.min(i,Math.max(Be,e)),s=I(t,n),c=t/s*z,l=n/s*z,u=r&&e.input.maxDimensionDocumented,d,f;if(Math.max(c,l)<=i/4){let e=u?Math.floor(i/Math.max(c,l)):Math.max(1,Math.round(Math.sqrt(B/(c*l))));d=c*e,f=l*e}else{let e=t/n;d=u?e>=1?i:a(i*e):a(Math.sqrt(B*e)),f=u?e>=1?a(i/e):i:a(d/e)}let p=Math.max(d,f)/i;return p>1&&(d=a(d/p),f=a(f/p)),{width:o(d),height:o(f)}}function He(e){if(e.kind!==`image`||e.input.dimensions!==`own`)return[];let t=new Set,n=new Set;for(let e of N){let{width:r,height:i}=M[e],a=I(r,i);n.add(`${String(r/a)}:${String(i/a)}`),t.add(`${String(r)}x${String(i)}`)}let r=[];for(let[i,a]of R){let o=n.has(`${String(i)}:${String(a)}`)?[]:[{size:V(e,i,a,!1),group:`Standard`}];e.input.maxDimensionDocumented&&o.push({size:V(e,i,a,!0),group:`Largest`});for(let{size:{width:e,height:n},group:s}of o){let o=`${String(e)}x${String(n)}`;t.has(o)||(t.add(o),r.push({value:o,label:L(e,n,[i,a]),width:e,height:n,group:s}))}}return r}function H(e,t){let n=e/t,r=R.find(([e,t])=>Math.abs(n/(e/t)-1)<=.02);if(r!==void 0)return`${String(r[0])}:${String(r[1])}`;let i=I(e,t),a=e/i,o=t/i;return a<=21&&o<=21?`${String(a)}:${String(o)}`:`${n.toFixed(2)}:1`}function Ue(e,t,n){if(e?.kind!==`image`||e.input.dimensions!==`own`||!(t>0&&n>0))return;let r=Math.log(t/n);if(e.sizes!==null){let t;for(let n of e.sizes){let e=/^(\d+)x(\d+)$/u.exec(n);if(e===null)continue;let i=Number(e[1]),a=Number(e[2]),o=Math.abs(Math.log(i/a)-r);(t===void 0||o<t.gap-1e-9)&&(t={width:i,height:a,gap:o})}return t===void 0?void 0:{width:t.width,height:t.height}}let i=R.find(([e,r])=>Math.abs(t/n/(e/r)-1)<=.02);return i===void 0?V(e,t,n,!1):V(e,i[0],i[1],!1)}function We(e,t,n){if(e?.input.dimensions===`none`)return null;let r=e?.video?.formats.find(e=>e.width===t&&e.height===n);if(r!==void 0)return`${r.resolution} ${r.aspectRatio}`;let i=I(t,n),a=t/i,o=n/i;return a<=21&&o<=21?`${String(a)}:${String(o)}`:`${String(t)} × ${String(n)}`}function Ge(e){return e?.video!==void 0&&e.video!==null?e.video.formats.map(e=>({value:`${String(e.width)}x${String(e.height)}`,label:`${e.resolution} · ${e.aspectRatio} · ${String(e.width)} × ${String(e.height)}`,width:e.width,height:e.height})):e!==void 0&&e.sizes!==null?e.sizes.flatMap(e=>{let t=/^(\d+)x(\d+)$/u.exec(e);if(t===null)return[];let n=Number(t[1]),r=Number(t[2]);return[{value:e,label:L(n,r),width:n,height:r,group:n*r>=Ve?`Largest`:`Standard`}]}):[...N.map(e=>({value:e,label:L(M[e].width,M[e].height),...M[e],group:`Standard`})),...e===void 0?[]:He(e)]}function Ke(e,t,n){return n?.kind===`video`&&t.kind===`video`||t.input.dimensions!==`none`&&i(g(G(()=>t))({model:t.id,width:e.width,height:e.height}))?{width:e.width,height:e.height}:{width:t.input.defaultWidth,height:t.input.defaultHeight}}function qe(e){return e.label.split(` — `)[0]??e.label}function Je(e,t){return e.find(e=>e.id===t)}function Ye(e,t){return{...e,height:t.input.defaultHeight,model:t.id,steps:t.input.steps===`fixed`?void 0:t.input.defaultSteps??void 0,durationSeconds:t.video?.defaultSeconds??t.audio?.seconds?.default,voiceId:t.audio?.defaultVoiceId??void 0,generateAudio:t.video?.defaultGenerateAudio??void 0,width:t.input.defaultWidth}}var Xe={"first-frame":`First frame`,"last-frame":`Last frame`,reference:`Reference`};function Ze(e,t,n){let r=t[n]?.role,i=r===void 0?0:e.indexOf(r)+1;return[...e.slice(i),...e.slice(0,i)].find(e=>e!==r&&(e===`reference`||!t.some((t,r)=>r!==n&&t.role===e)))}function U(e){return e?.video?.referenceRoles??[]}function W(e,t,n=!1){let r=U(t);if(t?.video==null)return e.map(({path:e,computerId:t})=>t===void 0?{path:e}:{path:e,computerId:t});let i=e.map(e=>e.role!==void 0&&r.includes(e.role)?e.role:void 0),a=e=>i.includes(e),o=r.includes(`last-frame`),s=n&&r.includes(`reference`)||a(`reference`)||!a(`first-frame`)&&!a(`last-frame`)&&e.length>(o?2:1);return e.map((e,t)=>{let n=i[t];return n===void 0&&(n=s&&r.includes(`reference`)?`reference`:!a(`first-frame`)&&r.includes(`first-frame`)?`first-frame`:o&&!a(`last-frame`)?`last-frame`:r.includes(`reference`)?`reference`:`first-frame`,i[t]=n),{...e,role:n}})}function Qe(e,t,n){let r=t.video;if(r===null||e.length===0)return;let i=t=>e.filter(e=>e.role===t).length,a=i(`first-frame`),o=i(`last-frame`),s=i(`reference`);if(a>1||o>1)return r.referenceRoles.includes(`last-frame`)?`${t.label} takes one first frame and one last frame.`:`${t.label} takes one first frame.`;if(o>0&&a===0)return`A last frame needs a first frame as well.`;if(s>0&&a+o>0)return`Frames and references cannot be mixed. Use a first and last frame, or references.`;if(s>r.maxReferenceImages)return r.maxReferenceImages===0?`${t.label} takes no reference images.`:`${t.label} takes up to ${String(r.maxReferenceImages)} reference images.`;if(s>0&&n!==void 0&&!r.referenceResolutions.some(e=>e===n))return`${t.label} takes reference images only at ${r.referenceResolutions.join(`, `)}.`}function $e(e,t){let n=t.video?.formats.find(t=>t.width===e.width&&t.height===e.height);if(t.kind===`video`&&n===void 0)throw Error(`Choose a supported video resolution and aspect ratio.`);if(t.kind===`audio`){let n={model:e.model,prompt:e.prompt.trim()};return t.audio?.mode===`speech`&&e.voiceId!==void 0&&(n.voiceId=e.voiceId),t.audio?.mode===`music`&&e.durationSeconds!==void 0&&(n.durationSeconds=e.durationSeconds),{destination:{path:e.destination?.trim()??``},settings:n}}let r={height:e.height,model:e.model,prompt:e.prompt.trim(),width:e.width};return n!==void 0&&(r.resolution=n.resolution,r.aspectRatio=n.aspectRatio),e.steps!==void 0&&(r.steps=e.steps),e.durationSeconds!==void 0&&(r.durationSeconds=e.durationSeconds),e.references.length>0&&(r.references=W(e.references,t)),t.video?.supportsAudio===!0&&e.generateAudio!==void 0&&(r.generateAudio=e.generateAudio),{destination:{path:e.destination?.trim()??``},settings:r}}function G(e){return c({model:s,width:u,height:u,durationSeconds:h(t(u)),steps:h(t(u))}).check(te(t=>{let n=e(t.model);if(!Number.isSafeInteger(t.width)||t.width<1)return{path:[`width`],issue:`Width must be a positive integer.`};if(!Number.isSafeInteger(t.height)||t.height<1)return{path:[`height`],issue:`Height must be a positive integer.`};if(n!==void 0){if(n.input.dimensions===`own`){let e=n.input.maxDimension??4096;if(t.width<256||t.height<256)return{path:[t.width<256?`width`:`height`],issue:`${n.label} requires dimensions of at least 256 × 256.`};if(t.width>e||t.height>e)return{path:[t.width>e?`width`:`height`],issue:`${n.label} accepts dimensions up to ${String(e)}.`}}if(n.sizes!==null&&!n.sizes.includes(`${String(t.width)}x${String(t.height)}`))return{path:[`width`],issue:`${n.label} accepts only these sizes: ${n.sizes.join(`, `)}.`};if(n.audio?.seconds!=null&&t.durationSeconds!==void 0&&(!Number.isSafeInteger(t.durationSeconds)||t.durationSeconds<n.audio.seconds.min||t.durationSeconds>n.audio.seconds.max))return{path:[`durationSeconds`],issue:`${n.label} makes tracks from ${String(n.audio.seconds.min)} to ${String(n.audio.seconds.max)} seconds.`};if(n.video!==null&&t.durationSeconds!==void 0&&(!Number.isSafeInteger(t.durationSeconds)||t.durationSeconds<n.video.minSeconds||t.durationSeconds>n.video.maxSeconds))return{path:[`durationSeconds`],issue:`${n.label} makes clips from ${String(n.video.minSeconds)} to ${String(n.video.maxSeconds)} seconds.`};if(n.input.steps===`fixed`&&t.steps!==void 0)return{path:[`steps`],issue:`${n.label} uses fixed steps.`};if(t.steps!==void 0&&(!Number.isSafeInteger(t.steps)||t.steps<1||n.input.maxSteps!==null&&t.steps>n.input.maxSteps))return{path:[`steps`],issue:`${n.label} accepts at most ${String(n.input.maxSteps??`the provider limit`)} steps.`}}}))}function et(e,t){let n=e.trim().length;return n>t.maxPromptLength?{length:n,excess:n-t.maxPromptLength}:null}function tt(e,t){if(e.destination?.trim().length===0)return`A destination file path is required.`;if(e.prompt.trim().length===0)return t?.kind===`video`?`Describe the video to generate.`:t?.kind===`audio`?t.audio?.mode===`music`?`Describe the music to generate.`:`Write what the voice should say.`:`Describe the image to generate.`;if(t===void 0)return`Choose a model from the granted registry.`;let n=et(e.prompt,t);if(n!==null)return`${t.label} accepts prompts up to ${String(t.maxPromptLength)} characters; this one is ${String(n.length)}. Shorten it by ${String(n.excess)}.`;let r=g(G(()=>t))(e);if(o(r))return f()(r.failure.issue).issues.map(e=>e.message).join(` `);if(e.references.length>t.input.maxReferences)return`${t.label} accepts at most ${String(t.input.maxReferences)} reference images.`;if(e.references.length>0&&t.input.referenceField===null)return`${t.label} does not accept reference images.`;if(t.video!==null){let n=t.video.formats.find(t=>t.width===e.width&&t.height===e.height);return Qe(W(e.references,t),t,n?.resolution)}}var K=n(),q=(0,T.forwardRef)(function({className:e,size:t=`md`,depth:n=`shallow`,placement:r=`standalone`,...i},a){return(0,K.jsx)(`div`,{...i,ref:a,"data-surface-size":t,"data-surface-depth":n,"data-surface-placement":r,className:_(`caps-surface`,e)})}),J=(0,T.forwardRef)(function({className:e,...t},n){return(0,K.jsx)(`div`,{...t,ref:n,className:_(`caps-screen`,e)})});(0,T.forwardRef)(function({children:e,className:t,depth:n=`deep`,fit:r=`content`,density:i=`normal`,...a},o){let s=r===`fill`;return(0,K.jsx)(q,{...a,className:_(t,s&&`flex min-h-0 flex-1`),depth:n,ref:o,children:(0,K.jsx)(`div`,{className:_(`caps-display-gasket`,s&&`flex min-h-0 min-w-0 flex-1`),"data-display-density":i,children:(0,K.jsx)(J,{className:_(s&&`flex min-h-0 min-w-0 flex-1 overflow-hidden`),children:e})})})}),(0,T.forwardRef)(function({className:e,icon:t,status:n,title:r,...i},a){return(0,K.jsxs)(`header`,{...i,className:_(`caps-screen-header`,e),ref:a,children:[t?(0,K.jsx)(`span`,{className:`caps-screen-header-icon`,"aria-hidden":`true`,children:t}):null,(0,K.jsx)(`span`,{className:`caps-screen-header-title`,children:r}),n?(0,K.jsx)(`span`,{className:`caps-screen-header-status`,children:n}):null]})}),(0,T.forwardRef)(function({appearance:e,className:t,...n},r){return(0,K.jsx)(`div`,{...n,className:_(`caps-screen-cells`,t),"data-appearance":e===`compact`?e:void 0,ref:r})}),(0,T.forwardRef)(function({children:e,className:t,legend:n,readout:r,icon:i,appearance:a,wide:o=!1,...s},c){return(0,K.jsxs)(`div`,{...s,className:_(`caps-screen-cell`,t),"data-wide":o||void 0,"data-appearance":a===`compact`?a:void 0,ref:c,children:[i?(0,K.jsx)(`span`,{className:`caps-screen-cell-icon`,children:i}):null,n?(0,K.jsx)(`span`,{className:`caps-screen-cell-legend`,children:n}):null,r?(0,K.jsx)(`span`,{className:`caps-screen-cell-readout`,children:r}):null,a===`compact`?(0,K.jsx)(`div`,{className:`caps-screen-cell-controls`,children:e}):e]})});function nt(e,t){se.error(e,{id:t,toasterId:`prints-generation-notices`})}var Y=(0,T.createContext)(null),rt=(0,T.forwardRef)(function({children:e,defaultValue:t,onValueChange:n,value:r,...i},a){let[o,s]=(0,T.useState)(t),c=r??o,l=(0,T.useId)(),u=e=>{r===void 0&&s(e),n?.(e)},d=(e,t)=>`${l}-${e}-${encodeURIComponent(t)}`;return(0,K.jsx)(Y.Provider,{value:{onValueChange:u,panelId:e=>d(`panel`,e),selectedValue:c,tabId:e=>d(`tab`,e)},children:(0,K.jsx)(`div`,{...i,className:_(`w-full`,i.className),ref:a,children:e})})});function X(){let e=(0,T.useContext)(Y);if(!e)throw Error(`Tabs parts must be used inside <Tabs>`);return e}var Z=(0,T.forwardRef)(function({className:e,variant:t=`bordered`,...n},r){return(0,K.jsx)(`div`,{...n,"aria-orientation":n[`aria-orientation`]??`horizontal`,className:_(t===`segmented`?`tabs caps-tabs-segmented w-full`:`tabs tabs-border flex w-full items-center gap-xs`,e),"data-variant":t,ref:r,role:`tablist`})}),it=(0,T.forwardRef)(function({className:e,disabled:t,onClick:n,onKeyDown:r,value:i,...a},o){let s=X(),c=s.selectedValue===i,l=e=>{let t=e.currentTarget.closest(`[role="tablist"]`);if(!(t instanceof HTMLElement))return;let n=Array.from(t.querySelectorAll(`[role="tab"]`)).filter(e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`),r=n.indexOf(e.currentTarget);if(r<0||n.length===0)return;let a;if(e.key===`ArrowRight`)a=(r+1)%n.length;else if(e.key===`ArrowLeft`)a=(r-1+n.length)%n.length;else if(e.key===`Home`)a=0;else if(e.key===`End`)a=n.length-1;else return;e.preventDefault();let o=n[a];o?.focus(),o&&s.onValueChange(o.dataset.tabValue??i)};return(0,K.jsx)(`button`,{...a,"aria-controls":s.panelId(i),"aria-disabled":t?!0:void 0,"aria-selected":c,className:_(`tab whitespace-nowrap text-base-content transition-colors focus-visible:outline-none focus-visible:ring-2 caps-focus-color`,c&&`tab-active`,e),"data-tab-value":i,disabled:t,id:s.tabId(i),onClick:e=>{n?.(e),!e.defaultPrevented&&!t&&s.onValueChange(i)},onKeyDown:e=>{r?.(e),e.defaultPrevented||l(e)},ref:o,role:`tab`,tabIndex:t?-1:c?0:-1,type:a.type??`button`})});(0,T.forwardRef)(function({children:e,className:t,forceMount:n=!1,value:r,...i},a){let o=X(),s=o.selectedValue===r;return!s&&!n?null:(0,K.jsx)(`div`,{...i,"aria-labelledby":o.tabId(r),className:_(`mt-md focus-visible:outline-none`,t),hidden:!s,id:o.panelId(r),ref:a,role:`tabpanel`,tabIndex:0,children:e})});var at=`modulepreload`,ot=function(e,t){return new URL(e,t).href},Q={},st=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=ot(t,n),t=s(t),t in Q)return;Q[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`:at,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 ct(e,t=`length`){let n=Math.max(0,t===`length`?Math.ceil(e):Math.floor(e)),r=Math.floor(n/60);return`${String(r)}:${String(n%60).padStart(2,`0`)}`}function lt(e,t=64){let n=e.reduce((e,t)=>Math.max(e,t.length),0);if(n===0||t<=0)return Object.freeze(Array.from({length:Math.max(t,0)},()=>0));let r=Array.from({length:t},()=>0);for(let i=0;i<t;i+=1){let a=Math.floor(i*n/t),o=Math.max(a+1,Math.floor((i+1)*n/t)),s=0;for(let t of e){let e=Math.min(o,t.length);for(let n=a;n<e;n+=1)s=Math.max(s,Math.abs(t[n]??0))}r[i]=s}let i=r.reduce((e,t)=>Math.max(e,t),0);return Object.freeze(i===0?r:r.map(e=>e/i))}async function ut(e,t=64){let n=await new OfflineAudioContext(1,1,44100).decodeAudioData(e);return{peaks:lt(Array.from({length:n.numberOfChannels},(e,t)=>n.getChannelData(t)),t),durationSeconds:n.duration}}var $=new Map;async function dt(e,t){let n=await fetch(e);if(!n.ok)throw Error(`audio responded ${String(n.status)}`);return ut(await n.arrayBuffer(),t)}function ft(e,t){let n=`${String(t)}:${e}`,r=$.get(n);if(r!==void 0)return r;let i=dt(e,t).catch(e=>{throw $.delete(n),e});return $.set(n,i),i}function pt(e,t=64){let[n,r]=(0,T.useState)({status:`loading`});return(0,T.useEffect)(()=>{if(e===``){r({status:`failed`});return}let n=!0;return r({status:`loading`}),ft(e,t).then(e=>{n&&r({status:`ready`,...e})},e=>{ue(`decode-audio-waveform`,e),n&&r({status:`failed`})}),()=>{n=!1}},[e,t]),n}export{Fe as A,A as B,$e as C,Je as D,Ue as E,Ge as F,Ce as G,Te as H,Ke as I,we as K,L,U as M,W as N,qe as O,We as P,tt as R,Ae as S,De as T,Ee as U,k as V,O as W,F as _,Z as a,Pe as b,J as c,Oe as d,Xe as f,je as g,Ie as h,rt as i,H as j,Ze as k,q as l,M as m,pt as n,it as o,N as p,ye as q,st as r,nt as s,ct as t,j as u,Ye as v,ze as w,Ne as x,Le as y,Re as z};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Cn as n,En as r,F as i,I as a,O as o,Tn as s,V as c,Vn as l,W as u,_ as d,_n as f,at as p,bn as m,d as h,dn as g,fn as _,g as v,gn as y,it as b,l as x,m as S,n as C,sn as w,t as T,v as E,w as D,wn as O,x as k,yn as A}from"./button-oE2Hrd5D.js";import{At as j,Rt as M,a as N,i as P,jt as F,o as I,r as L,s as R}from"./dist-Cc0qB3Mq.js";import{c as z,d as ee,n as B}from"./library-view--GUDH_qa.js";import{t as V}from"./log-event-R2fM9w5a.js";import{g as H,h as te,i as ne,m as U,t as W}from"./query-CvXKo0g1.js";import{K as G,O as K,W as re,a as q,c as ie,i as ae,l as oe,n as se,o as ce,q as le,t as ue}from"./audio-waveform-CKaaFNjh.js";import{a as de,i as fe,n as pe,o as me,r as he,t as ge}from"./computer-Dlwsjq-K.js";import{i as _e,o as ve,r as ye,t as be}from"./status-DNJRO5m5.js";import{r as xe}from"./modules-C4mfDnjH.js";import{Dt as Se,Et as Ce,Ot as we,Tn as Te,Tt as Ee,an as De,gn as Oe,in as ke,mn as Ae,sn as je,wn as Me,xn as Ne,yn as Pe}from"./useTriggerFocusGuards-Bddw7Qdn.js";import{c as Fe,l as Ie,n as Le,r as Re,t as ze}from"./dropdown-menu-Bp_cc0HZ.js";import{t as Be}from"./keycap-D2RkH2IS.js";var Ve=class extends U{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:te(t,n.data),hasPreviousPage:H(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function He(e){return e}function Ue(e,t){return le(e,Ve,t)}var We=c([a({kind:o(`compose`),text:i.pipe(u(p(1)),u(b(2e3)))}),a({kind:o(`navigate`),params:D(a({key:i.pipe(u(p(1)),u(b(64))),value:i.pipe(u(b(1024)))})).pipe(u(b(16)))})]);c([a({role:i.pipe(u(p(1)),u(b(80))),intent:We}),a({appId:i.pipe(u(p(1)),u(b(128))),intent:We})],{mode:`oneOf`});var Ge=n({displayName:O().min(1).max(80).nullable()}).nullable(),Ke=R(`apps.open`,1,y(()=>P({open:I,role:N(L(Ge))})));R(`apps.call`,1,y(()=>P({call:N(L(r().transform(e=>M(e))))})));var qe=O().regex(/^[a-zA-Z0-9._-]{1,128}$/).refine(e=>e!==`.`&&e!==`..`),J=O().regex(/^[0-9a-f]{40}$/);n({ref:O().startsWith(`refs/`).max(1024),before:J,after:J}),y(()=>O().min(1).max(512));var Je=`files`,Ye=n({name:O(),email:O()}),Xe=n({hash:J,treeHash:J,message:O(),author:Ye,committer:Ye,parents:g(J),authoredAt:A(),committedAt:A()}),Ze=n({name:O(),mode:O(),hash:J,type:w([`blob`,`tree`,`commit`])});n({ref:O(),commit:Xe,path:O(),entries:g(Ze)});var Qe=65536,$e=O().min(1).max(1024).refine(e=>!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`.git`),`Choose a relative repository file path.`),et=O().min(1).max(256),tt={repo:qe,branch:et,path:$e},nt=w([`pending`,`synced`,`conflict`,`failed`]),rt=n({text:O(),revision:A().int().positive(),state:nt,theirs:n({blob:J.nullable(),commit:J}).optional(),failure:w([`branch_missing`,`access_changed`,`sync_failed`,`permanent_material`]).optional()});n({...tt,baseBlob:J.nullable(),baseCommit:J,text:O().max(Qe),revision:A().int().positive().nullable()});var it=s([n({kind:f(`saved`),revision:A().int().positive(),state:f(`pending`)}),n({kind:f(`synced`),revision:A().int().positive(),commit:J}),n({kind:f(`conflict`),revision:A().int().nonnegative(),theirs:rt.shape.theirs.optional()}),n({kind:f(`failed`),revision:A().int().positive(),reason:w([`branch_missing`,`access_changed`,`sync_failed`,`permanent_material`])}),n({kind:f(`refused`),reason:w([`not-source-writer`,`background-unavailable`])})]);n({...tt,revision:A().int().positive()}),s([n({kind:w([`discarded`,`not_found`])}),n({kind:f(`conflict`),revision:A().int().positive()})]),n({settled:g(n({...tt,result:it})),more:_()}),n({version:A().int().positive().nullable(),commit:J,blob:J.nullable(),pending:rt.optional(),ref:O(),path:O(),size:A(),binary:_(),text:O().nullable()}),n({ref:O(),commits:g(n({commit:Xe,agent:O().nullable()})),next:O().optional()}),n({ref:O(),commit:Xe,paths:g(O()),truncated:_()}),n({kind:f(`rebuilding`)}),n({done:_(),cursor:O().nullable()}),s([n({repository:qe,branch:et,path:$e}),n({path:O().min(1).max(1024)})]);var at=k(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ot=k(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),st=k(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ct=k(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),lt=k(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),ut=k(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),Y=e(l(),1),dt=m({error:O()}),ft=O().min(1).max(4096),pt=w([`not_granted`,`not_found`,`conflict`,`invalid`,`unavailable`]),mt=m({moved:g(m({from:ft,to:ft})),failed:g(m({path:ft,error:pt}))}),ht=m({files:g(m({path:ft,kind:w([`image`,`video`,`audio`]).nullable(),model:O().nullable(),modelLabel:O().nullable(),durationSeconds:A().nullable(),favorite:_()}))}),gt=m({paths:g(ft),next:ft.nullable()});async function _t(e,t,n,r){let i=await e.capabilities.require(G).call(t,JSON.stringify(n)),a=r.safeParse(i);if(a.success)return a.data;let o=dt.safeParse(i);throw new F(o.success?`Prints refused ${t}: ${o.data.error}`:`Prints answered ${t} in an unexpected shape`,{code:`PROTOCOL`,retryable:!1})}function vt(e,t){return _t(e,`moveFiles`,{paths:[...t.paths],folder:t.folder,createFolder:t.createFolder??!1,name:t.name},mt)}async function yt(e,t){return(await _t(e,`describeFiles`,{paths:[...t]},ht)).files}async function bt(e,t,n){await _t(e,`setFavorite`,{paths:[...t],favorite:n},m({favorite:_(),count:A()}))}function xt(e,t,n){return _t(e,`listFavorites`,{after:t,limit:n},gt)}var St=24,Ct=256,wt=e=>e===null?null:e.kind===`folder`?e.path:`${e.kind}:${e.path}`,X={all:e=>ne.of(e,`prints`,`gallery`),listings:e=>[...X.all(e),`listing`],listing:(e,t)=>[...X.listings(e),t],file:(e,t)=>[...X.all(e),`file`,t],describedAll:e=>[...X.all(e),`described`],described:(e,t)=>[...X.describedAll(e),...t]};function Tt(e,t){return t.modifiedAt-e.modifiedAt||(e.path<t.path?-1:+(e.path>t.path))}function Et(e){let t=new Map;for(let n of e)for(let e of n.entries)t.set(e.path,e);return[...t.values()].sort(Tt)}var Dt=/\.(avif|gif|jpe?g|png|svg|webp|mp4|mp3)$/i;function Ot(e,t){let n=e?.context.get().computerId,r=t?.path??null,i={queue:r===null?[]:[r],offset:0,after:null};return He({queryKey:X.listing(e,wt(t)),initialPageParam:i,enabled:!!(n&&r&&e.capabilities.has(ge)&&e.capabilities.has(pe)),queryFn:async({pageParam:r,signal:i})=>{if(!e||!n||!t)throw new F(`No Computer folder selected`,{code:`SELECTION_CHANGED`,retryable:!1});let a=()=>{if(i.throwIfAborted(),e.context.get().computerId!==n)throw new F(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};if(t.kind===`favorites`){let n=[];a();let i=await xt(e,r.after,Ct);return a(),{entries:i.paths.filter(e=>Dt.test(e)).map(e=>({path:e,name:e.slice(e.lastIndexOf(`/`)+1),modifiedAt:0,size:0,...kt(t.path,e)})),folders:n,next:i.next===null?null:{queue:[],offset:0,after:i.next}}}let o=[],s=[],c=[...r.queue],l=r.offset;for(;o.length<Ct&&c.length>0;){a();let n=c[0],r=await fe(e.capabilities,{path:n,limit:Ct-o.length,offset:l});if(a(),r.nextOffset!==null&&r.nextOffset<=l)throw new F(`Directory pagination did not advance`,{code:`PROTOCOL`,retryable:!1});let i=r.path.replace(/\/$/,``);for(let e of r.entries)e.name.startsWith(`.`)||(e.type===`directory`?t.kind===`all`?c.push(`${i}/${e.name}`):s.push(e.name):e.type===`file`&&Dt.test(e.name)&&o.push({...e,path:`${i}/${e.name}`,...kt(t.path,`${i}/${e.name}`)}));r.nextOffset===null?(c=c.slice(1),l=0):l=r.nextOffset}return{entries:o,folders:s,next:c.length===0?null:{queue:c,offset:l,after:null}}},getNextPageParam:e=>e.next})}function kt(e,t){let n=B(e,t);return n===void 0?{}:{folder:n}}function At(e,t,n){return{...W(e,pe,[...X.file(e,t.path),t.modifiedAt,t.size],async(n,r)=>{if(!e)throw new F(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});let i=await de(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(pe)),structuralSharing:!1}}function jt(e,t){let n=e?.app??null,r=z(n),i=j(),[a,o]=(0,Y.useState)(()=>new Set),s=(0,Y.useCallback)(e=>{if(!r)return;let t=`${r}:${e}`;o(e=>e.has(t)?e:new Set([...e,t]))},[r]),c=(0,Y.useCallback)(e=>{s(e),i.resetQueries({queryKey:X.file(n,e)})},[n,i,s]),l=Ot(n,t),u=Ue(l),d=u.fetchNextPage;(0,Y.useEffect)(()=>{l.enabled&&u.hasNextPage&&!u.isFetching&&!u.error&&d({cancelRefetch:!1})},[l.enabled,u.hasNextPage,u.isFetching,u.error,d]);let f=!u.hasNextPage||u.error!==null,p=(0,Y.useMemo)(()=>l.enabled&&u.data&&f?Et(u.data.pages):[],[u.data,l.enabled,f]),m=`${r??``}|${wt(t)??``}`,[h,g]=(0,Y.useState)({key:m,count:St}),_=h.key===m?h.count:St,v=(0,Y.useMemo)(()=>p.slice(0,_),[p,_]),y=p.length>_,b=(0,Y.useCallback)(e=>({files:e.flatMap((e,t)=>e.data?[{path:v[t].path,file:e.data}]:[]),failures:e.flatMap((e,t)=>e.isError?[v[t].name]:[]),loading:e.some(e=>e.isLoading)}),[v]),x=ee({queries:v.map(e=>At(n,e,!!(r&&a.has(`${r}:${e.path}`)))),combine:b});return(0,Y.useEffect)(()=>{if(!n)return;let e=X.all(n),t=X.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:v,folders:(0,Y.useMemo)(()=>[...new Set(u.data?.pages.flatMap(e=>e.folders)??[])],[u.data]),loadFile:s,retryFile:c,files:x.files,failures:x.failures,error:u.error,loading:u.isFetching||!f||x.loading,hasNextPage:y,nextPageReady:y,refresh:()=>{u.refetch({cancelRefetch:!1})},loadMore:()=>{y&&g({key:m,count:_+St})}}}function Mt(e){return e.replace(/\s/gu,` `).replace(/ +/g,` `).trim()}function Nt(e,t,n){let r=e.replace(/\/$/,``),i=t.lastIndexOf(`.`),a=i>0?t.slice(0,i):t,o=i>0?t.slice(i):``,s=`${r}/${t}`;for(let e=2;n(s);e+=1)s=`${r}/${a} ${String(e)}${o}`;return s}async function Pt(e,t){let n=e.replace(/\/$/,``),r=new Set,i=0;for(;i!==null;){let e=await t(i);if(e.nextOffset!==null&&e.nextOffset<=i)throw Error(`Directory pagination did not advance`);for(let t of e.entries)r.add(`${n}/${t.name}`);i=e.nextOffset}return r}function Ft(e,t){let[n,r]=(0,Y.useState)([]),i=(0,Y.useRef)(new Map),a=(0,Y.useRef)(Promise.resolve()),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(new Map),l=(0,Y.useRef)(e);l.current=e;let u=(0,Y.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,Y.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 Ie(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){V(`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 me(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){V(`refresh-upload-preview`,t),d(e.id,`complete`,`Written; fresh preview unavailable`)}}catch(t){n()||V(`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,Y.useCallback)(()=>{for(let e of c.current.values())e.abort()},[]);return(0,Y.useEffect)(()=>()=>{m();for(let e of i.current.values())URL.revokeObjectURL(e.previewUrl)},[m]),{items:n,error:o,cancelAll:m,add(e,t,n,r=new Set){s(null);let a=[...i.current.values()].reduce((e,t)=>e+t.file.size,0);for(let o of e){if(!o.type.startsWith(`image/`)){s(`Only image files can be uploaded here`);continue}if(i.current.size>=8||a+o.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 c=Nt(t,Mt(o.name),e=>r.has(e)||i.current.has(e)),l={computerId:e,id:c,file:o,previewUrl:URL.createObjectURL(o),app:n,path:c,status:`queued`,message:`Queued`};i.current.set(l.id,l),a+=o.size,p(l)}},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 It(e){return e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name}function Lt(e){return e.connection.app.ui.openNavigation({computerId:e.computerId,path:e.path})}function Rt(e){let[t,n]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(n(!1),!e?.capabilities.has(Ke))return;let t=!0;return e.capabilities.require(Ke).role(Je).then(e=>{t&&n(e!==null)},e=>{V(`files-editor-role`,e)}),()=>{t=!1}},[e]),t}function zt(e,t){let n=t.landingPath,r=z(e?.app),i=(0,Y.useRef)(new Set),a=(0,Y.useRef)(0),o=(0,Y.useRef)(e);o.current=e;let s=e?.app.capabilities.has(ge)===!0,c=e?.app.capabilities.has(pe)===!0,l=e?.app.capabilities.has(he)===!0,u=jt(e,t.source),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)([]),[h,g]=(0,Y.useState)([]),[_,v]=(0,Y.useState)([]);(0,Y.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,Y.useState)(!1),S=(0,Y.useMemo)(()=>[...u.error?[`Could not refresh the Media gallery`]:[],...u.failures],[u.error,u.failures]),C=(0,Y.useRef)(new WeakMap),w=(0,Y.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,Y.useCallback)(()=>{a.current+=1;for(let e of i.current)e.abort();i.current.clear()},[]);(0,Y.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,Y.useEffect)(()=>{if(e)return e.app.context.subscribe(e=>{e.computerId!==r&&T()})},[e,r,T]),(0,Y.useEffect)(()=>{v([]),f(e=>e.filter(e=>e.kind===`local`))},[r]);let E=(0,Y.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 de(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||(V(`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,Y.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,Y.useRef)(new Set),k=(0,Y.useRef)(new Set),A=(0,Y.useRef)(new Map),j=(0,Y.useRef)(new Map),M=(0,Y.useCallback)(e=>{URL.revokeObjectURL(e),O.current.delete(e);let t=j.current.get(e);t&&A.current.delete(t),j.current.delete(e)},[]);(0,Y.useEffect)(()=>{let e=!0,t=new Set,n=new Map,r=new Set,i=[...w].sort((e,t)=>Tt({modifiedAt:e.file.lastModified,path:e.kind===`computer`?e.path:e.file.name},{modifiedAt:t.file.lastModified,path:t.kind===`computer`?t.path:t.file.name})).map(e=>{let t=A.current.get(e.file)??URL.createObjectURL(e.file);return A.current.set(e.file,t),j.current.set(t,e.file),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 Ie(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&&(V(`decode-gallery-image`,t),M(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)&&!k.current.has(e)&&M(e)}},[w,S,M]),(0,Y.useEffect)(()=>{let e=new Set(p.map(e=>e.url));for(let t of k.current)e.has(t)||M(t);k.current=e},[p,M]),(0,Y.useEffect)(()=>{let e=O.current;return()=>{for(let t of e)URL.revokeObjectURL(t);e.clear()}},[]);let N=Ft(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,Y.useEffect)(()=>{let t=N.cancelAll,n=e?.app.lifecycle.subscribe(e=>{(e===`disposing`||e===`disconnected`||e===`disposed`)&&t()});return()=>{n?.(),t()}},[e,N.cancelAll]),{images:p,failed:h,loading:b,gallery:u,gallerySlots:_,canBrowse:s,canRead:c,canWrite:l,reserveSlot:y,addComputerFile:E,retryFile:D,uploads:N,uploadFiles:async i=>{if(!e||!l||n===null)return;let a=e,s=r,c=await t.ensureCreated();if(c){g([c]);return}if(o.current!==a||a.app.context.get().computerId!==s)return;let u;try{u=await Pt(n,e=>fe(a.app.capabilities,{path:n,limit:500,offset:e}))}catch(e){V(`list-upload-destination`,e),g([`Could not check the Computer folder. No upload was sent.`]);return}o.current===a&&a.app.context.get().computerId===s&&N.add(i,n,a.app,u)},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))}}}var Bt=Y.createContext(void 0);function Vt(){let e=Y.useContext(Bt);if(e===void 0)throw Error(Pe(53));return e}function Z(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 Q=t(),Ht=`base-ui-disable-scrollbar`,Ut={className:Ht,getElement(e){return(0,Q.jsx)(`style`,{nonce:e,href:Ht,precedence:`base-ui:low`,children:`.${Ht}{scrollbar-width:none}.${Ht}::-webkit-scrollbar{display:none}`})}},Wt=`data-has-overflow-x`,Gt=`data-has-overflow-y`,Kt=`data-overflow-x-start`,qt=`data-overflow-x-end`,Jt=`data-overflow-y-start`,Yt=`data-overflow-y-end`,Xt=e=>t=>t?{[e]:``}:null,Zt={hasOverflowX:Xt(Wt),hasOverflowY:Xt(Gt),overflowXStart:Xt(Kt),overflowXEnd:Xt(qt),overflowYStart:Xt(Jt),overflowYEnd:Xt(Yt),cornerHidden:()=>null},Qt=Y.createContext(void 0),$t={disableStyleElements:!1};function en(){return Y.useContext(Qt)??$t}var tn=`--scroll-area-corner-height`,nn=`--scroll-area-corner-width`,rn=`data-orientation`,an={x:0,y:0},on={width:0,height:0},sn={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},cn={x:!0,y:!0,corner:!0},ln=Y.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=un(i),d=Ae(),f=Ne(),p=Ne(),{nonce:m,disableStyleElements:h}=en(),[g,_]=Y.useState(!1),[v,y]=Y.useState(!1),[b,x]=Y.useState(!1),[S,C]=Y.useState(!1),[w,T]=Y.useState(!1),[E,D]=Y.useState(on),[O,k]=Y.useState(on),[A,j]=Y.useState(sn),[M,N]=Y.useState(cn),P=Y.useRef(null),F=Y.useRef(null),I=Y.useRef(null),L=Y.useRef(null),R=Y.useRef(null),z=Y.useRef(null),ee=Y.useRef(null),B=Y.useRef(null),V=Y.useRef(0),H=Y.useRef(0),te=Y.useRef(0),ne=Y.useRef(0),U=Y.useRef(`vertical`),W=Y.useRef(an),G=Y.useRef(null);function K(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let re=Te(e=>{let t=e.x-W.current.x,n=e.y-W.current.y;W.current=e,n!==0&&K(!0),t!==0&&K(!1)}),q=Te(()=>{let e=F.current;e&&G.current===null&&(G.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),ie=Te(e=>{if(e.button!==0||B.current!==null&&(U.current===`vertical`?R.current:z.current)?.hasPointerCapture(B.current))return;B.current=e.pointerId,V.current=e.clientY,H.current=e.clientX,U.current=e.currentTarget.getAttribute(rn);let t=F.current;t&&(te.current=t.scrollTop,ne.current=t.scrollLeft,q()),(U.current===`vertical`?R.current:z.current)?.setPointerCapture(e.pointerId)}),ae=Te(e=>{if(e.pointerId!==B.current)return;B.current=null,(U.current===`vertical`?x:y)(!1),G.current!==null&&(F.current&&(F.current.style.scrollSnapType=G.current),G.current=null);let t=U.current===`vertical`?R.current:z.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),oe=Te(e=>{if(e.pointerId!==B.current)return;if(e.buttons%2==0){ae(e);return}let t=F.current;if(!t)return;let n=U.current===`vertical`,r=n?R.current:z.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=Z(i,`padding`,a),s=Z(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-V.current:e.clientX-H.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?te.current:ne.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),K(n)});function se(e){C(e.pointerType===`touch`)}function ce(e){if(se(e),e.pointerType!==`touch`){let t=ke(P.current,e.target);_(t)}}let le=Y.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]),ue={role:`presentation`,onPointerEnter:ce,onPointerMove:ce,onPointerDown:se,onPointerLeave(){_(!1)},style:{position:`relative`,[tn]:`${E.height}px`,[nn]:`${E.width}px`}},de=Oe(`div`,e,{state:le,ref:[t,P],props:[ue,o],stateAttributesMapping:Zt}),fe=Y.useMemo(()=>({handlePointerDown:ie,handlePointerMove:oe,handlePointerUp:ae,handleScroll:re,disableViewportSnap:q,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:ee,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:le,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[ie,oe,ae,re,q,E,O,w,S,v,b,g,d,M,A,le,s,c,l,u]);return(0,Q.jsxs)(Bt.Provider,{value:fe,children:[!h&&Ut.getElement(m),de]})});function un(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 dn(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var fn=Y.createContext(void 0);function pn(){let e=Y.useContext(fn);if(e===void 0)throw Error(Pe(55));return e}function mn(e,t){if(t<=0)return 0;let n=dn(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 hn=`--scroll-area-overflow-x-start`,gn=`--scroll-area-overflow-x-end`,_n=`--scroll-area-overflow-y-start`,vn=`--scroll-area-overflow-y-end`,yn=`--scroll-area-thumb-height`,bn=`--scroll-area-thumb-width`,xn=[hn,gn,_n,vn],Sn=!1;function Cn(){Sn||je||(typeof CSS<`u`&&`registerProperty`in CSS&&xn.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),Sn=!0)}var wn=Y.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}=Vt(),T=Se(),E=Y.useRef(!0),D=Y.useRef([NaN,NaN,NaN,NaN]),O=Ne(),k=Ne(),A=Te(()=>{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=Tn(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=mn(T===`rtl`?-w:w,P),L=P-I);let R=A?0:mn(x,F),z=A?0:F-R,ee=j?0:b,B=A?0:y,V=0,H=0;!j&&!A&&(V=t?.offsetWidth||0,H=n?.offsetHeight||0);let te=f.width===0&&f.height===0,ne=te?V:0,U=te?H:0,W=Z(n,`padding`,`x`),G=Z(t,`padding`,`y`),K=Z(i,`margin`,`x`),re=Z(r,`margin`,`y`),q=ee-W-K,ie=B-G-re,ae=n?Math.min(n.offsetWidth-ne,q):q,oe=t?Math.min(t.offsetHeight-U,ie):ie,se=Math.max(16,ae*M),ce=Math.max(16,oe*N);if(m(e=>En(e,{width:se,height:ce})),t&&r){let e=Dn(r,yn,x,F,h,ce,t.offsetHeight-ce-G-re);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-se-W-K,t=Dn(i,bn,T===`rtl`?-w:w,P,_,se,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let le=[I,L,R,z];xn.forEach((t,n)=>{e.style.setProperty(t,`${le[n]}px`)}),a&&p(e=>En(e,{width:V,height:H})),g(e=>En(e,k));let ue={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&z>C.yEnd};S(e=>En(e,ue))});we(()=>{Cn()},[]),we(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),we(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),we(()=>{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=Ce(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(Me))).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:Ut.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=Oe(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:Zt}),P=Y.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Q.jsx)(fn.Provider,{value:P,children:N})});function Tn(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function En(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function Dn(e,t,n,r,i,a,o){let s=dn(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 On=Y.createContext(void 0);function kn(){let e=Y.useContext(On);if(e===void 0)throw Error(Pe(54));return e}var An=Y.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}=Vt(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=Se(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;Y.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 Ee(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=De(e.nativeEvent),n=T?h.current:g.current;if(n&&ke(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=Z(n,`margin`,a),s=Z(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(${tn})`,insetInlineEnd:0,[yn]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${nn})`,bottom:0,[bn]:`${S.width}px`}}},M=Oe(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:Zt});return A?(0,Q.jsx)(On.Provider,{value:i,children:M}):null}),jn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{computeThumbPosition:o}=pn(),{hasMeasuredScrollbar:s,viewportState:c}=Vt(),l=Y.useRef(null),u=Y.useRef(s);return we(()=>{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]),Oe(`div`,e,{ref:[t,l],state:c,stateAttributesMapping:Zt,props:[{role:`presentation`,style:{minWidth:`fit-content`}},a]})}),Mn=Y.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}=Vt(),m=kn(),h=m===`vertical`;return Oe(`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]})});function Nn(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 Pn(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 Fn=(0,Y.forwardRef)(function({children:e,className:t,surface:n=!1,surfaceSize:r,surfaceDepth:i,screen:a=!1,...o},s){let c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=v();(0,Y.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=S(t),i=ye(r,{ease:`outQuad`,duration:45}),a=_e(r,{bounce:.18,duration:180});n=xe(t,{scaleY:[{to:e.scaleY,...i},{to:1,...a}],scaleX:[{to:e.scaleX,...i},{to:1,...a}]})},d=(e,t)=>{let n=Nn(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=Pn(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,Q.jsx)(wn,{render:a?(0,Q.jsx)(ie,{}):(0,Q.jsx)(`div`,{}),...o,ref:s,className:`caps-scroll-viewport`,children:(0,Q.jsx)(jn,{style:{minWidth:0},children:e})});return(0,Q.jsxs)(ln,{render:n?(0,Q.jsx)(oe,{size:r??`md`,depth:i??`shallow`}):(0,Q.jsx)(`div`,{}),ref:c,className:E(`caps-scroll-area`,t),children:[a?(0,Q.jsx)(`div`,{className:`caps-display-gasket caps-scroll-display`,children:d}):d,(0,Q.jsx)(oe,{size:`sm`,depth:`deep`,placement:`embedded`,className:`caps-scroll-track-surface`,children:(0,Q.jsx)(An,{className:`caps-scroll-track`,children:(0,Q.jsx)(Mn,{className:`caps-scroll-thumb`,children:(0,Q.jsx)(`span`,{className:`caps-scroll-thumb-surface`,ref:l})})})})]})}),In=(0,Y.forwardRef)(function({className:e,count:t,density:n=`row`,dismissAriaLabel:r,dismissLabel:i=`Dismiss`,message:a,onDismiss:o,onRetry:s,retryAriaLabel:c,retryLabel:l=`Retry`,role:u=`status`,...d},f){return(0,Q.jsxs)(`div`,{...d,className:E(`caps-failure-line`,e),"data-density":n,ref:f,role:u,children:[(0,Q.jsx)(be,{glyph:`dot`,tone:`error`}),(0,Q.jsxs)(`span`,{className:`caps-failure-line-copy`,children:[(0,Q.jsx)(`span`,{children:a}),t!==void 0&&t>1?(0,Q.jsxs)(`span`,{className:`caps-failure-line-count`,children:[`Failed `,t,` times`]}):null]}),s||o?(0,Q.jsxs)(`span`,{className:`caps-failure-line-actions`,children:[s?(0,Q.jsx)(T,{"aria-label":c,size:`sm`,variant:`outline`,onClick:s,children:l}):null,o?(0,Q.jsx)(T,{"aria-label":r,size:`sm`,variant:`ghost`,onClick:o,children:i}):null]}):null]})});function Ln(e){return e?.closest(`[data-app-pane="media"]`)??e}var Rn={voice:`Voice`,sfx:`Sound effects`,music:`Music`};function zn(e){return e.audio.mode===`speech`?`voice`:`music`}function Bn(e){return e.flatMap(e=>e.audio===null?[]:[{id:e.id,label:e.label,audio:e.audio}])}function Vn(e){return e.audio===null?null:e.audio.mode===`speech`?`voice`:`music`}function Hn(e){let t=new Set(e.map(zn));return[`voice`,`sfx`,`music`].filter(e=>t.has(e))}function Un(e,t){return e.filter(e=>zn(e)===t)}function Wn({modes:e,value:t,onChange:n,disabled:r=!1}){return(0,Q.jsx)(ae,{className:`prints-audio-modes`,value:t,onValueChange:t=>{let r=e.find(e=>e===t);r!==void 0&&n(r)},children:(0,Q.jsx)(q,{"aria-label":`Audio type`,className:`prints-audio-modes-list`,variant:`segmented`,children:e.map(e=>(0,Q.jsx)(ce,{"data-audio-mode":e,disabled:r,value:e,children:Rn[e]},e))})})}function Gn({label:e,name:t,options:n,value:r,disabled:i,onChange:a,icon:o,compact:s=!1}){let[c,l]=(0,Y.useState)(null);return(0,Q.jsx)(`span`,{className:`contents`,ref:l,children:(0,Q.jsxs)(ze,{children:[(0,Q.jsx)(Fe,{"aria-label":t,disabled:i||n.length===0,render:(t,n)=>(0,Q.jsx)(Be,{...t,className:E(`parakeet-composer-model-key`,s&&`prints-audio-key-compact`),expanded:n.open,icon:o,label:e,readout:(0,Q.jsx)(ve,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),(0,Q.jsx)(Re,{align:`start`,"aria-label":t,container:Ln(c),side:`top`,children:n.map(e=>(0,Q.jsx)(Le,{checked:e.value===r,closeOnClick:!0,onSelect:()=>{a(e.value)},children:e.label},String(e.value)))})]})})}function Kn({models:e,value:t,onChange:n,disabled:r=!1}){let i=e.find(e=>e.id===t);return(0,Q.jsx)(Gn,{disabled:r,label:i===void 0?`Model`:K(i),name:`Generation model`,onChange:n,options:e.map(e=>({value:e.id,label:e.label})),value:t})}function qn({voices:e,value:t,onChange:n,disabled:r=!1}){let i=e.find(e=>e.id===t);return(0,Q.jsx)(Gn,{disabled:r,compact:!0,icon:(0,Q.jsx)(ct,{}),label:i?.label??`Voice`,name:`Voice`,onChange:n,options:e.map(e=>({value:e.id,label:e.label})),value:t})}var Jn=[10,15,30,60,90,120,180,300,600];function Yn(e){let t=Jn.filter(t=>t>=e.min&&t<=e.max);return[...new Set([...t,e.default])].sort((e,t)=>e-t)}function Xn({seconds:e,value:t,onChange:n,disabled:r=!1}){return(0,Q.jsx)(Gn,{disabled:r,compact:!0,icon:(0,Q.jsx)(re,{}),label:ue(t),name:`Length`,onChange:n,options:Yn(e).map(e=>({value:e,label:ue(e)})),value:t})}var Zn={queued:`Waiting to start`,generating:`Generating`,refining:`Refining`,done:void 0,failed:void 0},Qn=(0,Y.forwardRef)(function({status:e,children:t,aspectRatio:n,label:r,indicator:i,failure:a,className:o,style:s,...c},l){let u=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(l,()=>u.current);let f=(0,Y.useRef)(e),[p,m]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(e);g!==e&&(_(e),m(e===`done`)),(0,Y.useLayoutEffect)(()=>{let t=u.current,n=f.current;if(f.current=e,!t||n===e)return;if(!x(t)){m(!1);return}let r=S(t),i=h(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`,()=>{m(!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 v=e===`queued`||e===`generating`||e===`refining`,y=r??Zn[e],b=e===`done`||e===`refining`;return(0,Q.jsxs)(`div`,{...c,ref:u,className:E(`caps-generation-frame`,o),"data-status":e,"data-aspect":n===void 0?void 0:``,"aria-busy":v,style:n===void 0?s:{aspectRatio:n,...s},children:[e===`done`&&!p?null:(0,Q.jsxs)(`div`,{className:E(`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,Q.jsx)(C,{decorative:!0,size:`lg`,variant:`bloom`}):null,y===void 0?null:(0,Q.jsx)(d,{children:y})]}),b?(0,Q.jsx)(`div`,{className:`caps-generation-media`,"data-layer":`media`,children:t}):null,e===`failed`&&a!==void 0?(0,Q.jsx)(`div`,{className:`caps-generation-failure`,"data-layer":`failure`,role:`alert`,children:a}):null]})}),$=null;function $n(e,t){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(t);r.current=t;let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(0);(0,Y.useEffect)(()=>()=>{let e=n.current;e!==null&&(e.pause(),$===e&&($=null),n.current=null)},[e]),(0,Y.useEffect)(()=>{if(!i)return;let e=0,t=()=>{let r=n.current;r!==null&&r.duration>0&&s(Math.min(1,r.currentTime/r.duration)),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>{cancelAnimationFrame(e)}},[i]);let c=(0,Y.useCallback)(()=>{if(n.current!==null)return n.current;let t=new Audio(e);return t.preload=`auto`,t.addEventListener(`ended`,()=>{a(!1),s(0),$===t&&($=null)}),t.addEventListener(`pause`,()=>{a(!1)}),t.addEventListener(`error`,()=>{a(!1),r.current(`This audio could not be played.`)}),n.current=t,t},[e]);return{playing:i,progress:o,toggle:(0,Y.useCallback)(()=>{let e=c();if(!e.paused){e.pause();return}$!==null&&$!==e&&$.pause(),$=e,a(!0),e.play().catch(e=>{V(`play-audio`,e),a(!1),r.current(`This audio could not be played.`)})},[c]),seek:(0,Y.useCallback)(e=>{let t=c();Number.isFinite(t.duration)&&t.duration>0&&(t.currentTime=Math.min(1,Math.max(0,e))*t.duration,s(Math.min(1,Math.max(0,e))))},[c])}}function er({url:e,progress:t=0,bars:n=64,className:r}){let i=se(e,n),a=i.status===`ready`?i.peaks:null;return(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:E(`prints-waveform`,r),"data-waveform":i.status,children:Array.from({length:n},(e,r)=>(0,Q.jsx)(`span`,{className:`prints-waveform-bar`,"data-played":r/n<t?``:void 0,style:{height:`max(2px, ${String((a?.[r]??0)*100)}%)`}},r))})}export{at as A,yt as C,lt as D,ut as E,st as O,Ot as S,bt as T,Lt as _,Xn as a,Mt as b,qn as c,Hn as d,Un as f,It as g,Fn as h,Rn as i,Ue as j,ot as k,Vn as l,In as m,$n as n,Wn as o,Ln as p,Qn as r,Kn as s,er as t,Bn as u,Rt as v,vt as w,X as x,zt as y};