mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
3 lines
3.2 KiB
JavaScript
3 lines
3.2 KiB
JavaScript
![]() |
import{d as C,g as v,j as M,D,E as m,m as s,q as u,S as h,l as p,M as I,z as g,K as R}from"./chunk-449c23a2.js";import{a as j,b as A}from"./chunk-a740628f.js";import{_ as S}from"./chunk-323c539f.js";import{c as U}from"./chunk-ca3460ec.js";import{u as k}from"./chunk-767079b6.js";import{_ as B}from"./chunk-aa4619b6.js";import"./chunk-a3974c29.js";import"../entries/src_pages_Home.page.16dc467b.js";import"./chunk-cf010ec4.js";import"./chunk-ee54c1e8.js";import"./chunk-66ac4853.js";import"./chunk-2749dac9.js";import"./chunk-015e5c20.js";import"./chunk-416dc92c.js";import"./chunk-567e13ca.js";import"./chunk-26a03a7a.js";import"./chunk-f823181b.js";import"./chunk-9519e52e.js";import"./chunk-f94e2689.js";import"./chunk-1d5b5526.js";import"./chunk-fc34c9a6.js";import"./chunk-af6e0163.js";import"./chunk-b0332f36.js";import"./chunk-f206ee20.js";import"./chunk-05af1949.js";function f(e){var t=new Error(e);return t.source="ulid",t}var d="0123456789ABCDEFGHJKMNPQRSTVWXYZ",l=d.length,b=Math.pow(2,48)-1,O=10,V=16;function L(e){var t=Math.floor(e()*l);return t===l&&(t=l-1),d.charAt(t)}function G(e,t){if(isNaN(e))throw new Error(e+" must be a number");if(e>b)throw f("cannot encode time greater than "+b);if(e<0)throw f("time must be positive");if(Number.isInteger(e)===!1)throw f("time must be an integer");for(var r=void 0,o="";t>0;t--)r=e%l,o=d.charAt(r)+o,e=(e-r)/l;return o}function J(e,t){for(var r="";e>0;e--)r=L(t)+r;return r}function T(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments[1];t||(t=typeof window<"u"?window:null);var r=t&&(t.crypto||t.msCrypto);if(r)return function(){var a=new Uint8Array(1);return r.getRandomValues(a),a[0]/255};try{var o=require("crypto");return function(){return o.randomBytes(1).readUInt8()/255}}catch{}if(e){try{console.error("secure crypto unusable, falling back to insecure Math.random()!")}catch{}return function(){return Math.random()}}throw f("secure crypto unusable, insecure Math.random not allowed")}function $(e){return e||(e=T()),function(r){return isNaN(r)&&(r=Date.now()),G(r,O)+J(V,e)}}var q=$();const F={flex:"","flex-col":"","justify-center":"","gap-2":""},K={flex:"","items-center":""},Q=m("label",{"w-75px":""}," Quantity:",-1),X={"m-0":"","m-x-auto":""},z={flex:"","justify-center":"","gap-2":""},yt=C({__name:"ulid-generator",setup(e){const t=v("ulid-generator-amount",1),r=[{label:"Raw",value:"raw"},{label:"JSON",value:"json"}],o=v("ulid-generator-format",r[0].value),[a,y]=U(()=>{const c=j.times(t.value,()=>q());return o.value==="json"?JSON.stringify(c,null,2):c.join(`
|
||
|
`)}),{copy:N}=k({source:a,text:"ULIDs copied to the clipboard"});return(c,n)=>{const x=B,w=S,E=A,_=R;return M(),D("div",F,[m("div",K,[Q,s(x,{value:u(t),"onUpdate:value":n[0]||(n[0]=i=>h(t)?t.value=i:null),min:"1",max:"100","flex-1":""},null,8,["value"])]),s(w,{value:u(o),"onUpdate:value":n[1]||(n[1]=i=>h(o)?o.value=i:null),options:r,label:"Format: ","label-width":"75px"},null,8,["value"]),s(E,{"mt-5":"",flex:"","data-test-id":"ulids"},{default:p(()=>[m("pre",X,I(u(a)),1)]),_:1}),m("div",z,[s(_,{"data-test-id":"refresh",onClick:n[2]||(n[2]=i=>u(y)())},{default:p(()=>[g(" Refresh ")]),_:1}),s(_,{onClick:n[3]||(n[3]=i=>u(N)())},{default:p(()=>[g(" Copy ")]),_:1})])])}}});export{yt as default};
|