forge-terminal 0.1.0 → 0.2.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.
- package/README.md +305 -24
- package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
- package/dist/chunks/available-2VX7K7W6.js +3 -0
- package/dist/chunks/boot-ODZZHFUI.js +3 -0
- package/dist/chunks/cfb-V6M2PYOD.js +13 -0
- package/dist/chunks/chunk-2WYHI73Y.js +3 -0
- package/dist/chunks/chunk-4YHKTP7I.js +3 -0
- package/dist/chunks/chunk-5PYTOHLZ.js +3 -0
- package/dist/chunks/chunk-7YQR2MVH.js +3 -0
- package/dist/chunks/chunk-DRBA23IQ.js +3 -0
- package/dist/chunks/chunk-EOYBXOCV.js +4 -0
- package/dist/chunks/chunk-FQV57RMH.js +3 -0
- package/dist/chunks/chunk-IMKI5F4I.js +4 -0
- package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
- package/dist/chunks/chunk-L2WK7CJG.js +3 -0
- package/dist/chunks/chunk-LFE3WRU4.js +3 -0
- package/dist/chunks/chunk-MHFY7HF6.js +10 -0
- package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
- package/dist/chunks/chunk-QVACE4IE.js +3 -0
- package/dist/chunks/chunk-TMUK2DD3.js +3 -0
- package/dist/chunks/chunk-UNVHKJW4.js +41 -0
- package/dist/chunks/chunk-V4GHQGQM.js +4 -0
- package/dist/chunks/chunk-VB665HTV.js +3 -0
- package/dist/chunks/chunk-YHK5VE5R.js +3 -0
- package/dist/chunks/colour-QV2C3R7R.js +3 -0
- package/dist/chunks/config-command-UXJY623L.js +3 -0
- package/dist/chunks/dist-J2V6ITHG.js +29 -0
- package/dist/chunks/es-T2U7NBLD.js +3 -0
- package/dist/chunks/execute-4WJCUM7J.js +3 -0
- package/dist/chunks/extensions-command-6WZV2AES.js +3 -0
- package/dist/chunks/launch-2OI4ZLBQ.js +66 -0
- package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
- package/dist/chunks/lock-R6GZXCCW.js +3 -0
- package/dist/chunks/manager-H52ENJOH.js +4 -0
- package/dist/chunks/paths-XY2345OS.js +3 -0
- package/dist/chunks/pdf-compress-IMRFBLZF.js +3 -0
- package/dist/chunks/react-devtools-core-UM4FS6CU.js +3 -0
- package/dist/chunks/run-N3F4EM7E.js +4 -0
- package/dist/chunks/server-5RWSVTOM.js +73 -0
- package/dist/chunks/theme-GW7CQPUO.js +3 -0
- package/dist/chunks/word-OGQ2KZAJ.js +24 -0
- package/dist/index.js +67 -95
- package/dist/third-party-licenses.txt +2856 -0
- package/package.json +28 -21
- package/skills/forge/SKILL.md +128 -0
- package/dist/cli/args.js +0 -278
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/config-command.js +0 -55
- package/dist/cli/config-command.js.map +0 -1
- package/dist/cli/execute.js +0 -377
- package/dist/cli/execute.js.map +0 -1
- package/dist/cli/report.js +0 -123
- package/dist/cli/report.js.map +0 -1
- package/dist/cli/spinner.js +0 -60
- package/dist/cli/spinner.js.map +0 -1
- package/dist/cli/stdin.js +0 -47
- package/dist/cli/stdin.js.map +0 -1
- package/dist/config/preferences.js +0 -143
- package/dist/config/preferences.js.map +0 -1
- package/dist/core/actions/compress.js +0 -157
- package/dist/core/actions/compress.js.map +0 -1
- package/dist/core/actions/convert.js +0 -270
- package/dist/core/actions/convert.js.map +0 -1
- package/dist/core/actions/extract.js +0 -94
- package/dist/core/actions/extract.js.map +0 -1
- package/dist/core/actions/index.js +0 -23
- package/dist/core/actions/index.js.map +0 -1
- package/dist/core/actions/merge.js +0 -16
- package/dist/core/actions/merge.js.map +0 -1
- package/dist/core/actions/rotate.js +0 -36
- package/dist/core/actions/rotate.js.map +0 -1
- package/dist/core/actions/split.js +0 -65
- package/dist/core/actions/split.js.map +0 -1
- package/dist/core/atomic.js +0 -61
- package/dist/core/atomic.js.map +0 -1
- package/dist/core/capabilities.js +0 -59
- package/dist/core/capabilities.js.map +0 -1
- package/dist/core/compress.js +0 -76
- package/dist/core/compress.js.map +0 -1
- package/dist/core/describe.js +0 -49
- package/dist/core/describe.js.map +0 -1
- package/dist/core/errors.js +0 -469
- package/dist/core/errors.js.map +0 -1
- package/dist/core/execute-jobs.js +0 -122
- package/dist/core/execute-jobs.js.map +0 -1
- package/dist/core/formats.js +0 -108
- package/dist/core/formats.js.map +0 -1
- package/dist/core/order.js +0 -44
- package/dist/core/order.js.map +0 -1
- package/dist/core/output-path.js +0 -176
- package/dist/core/output-path.js.map +0 -1
- package/dist/core/pages.js +0 -107
- package/dist/core/pages.js.map +0 -1
- package/dist/core/pdf-compress.js +0 -206
- package/dist/core/pdf-compress.js.map +0 -1
- package/dist/core/plan.js +0 -42
- package/dist/core/plan.js.map +0 -1
- package/dist/core/resolve.js +0 -115
- package/dist/core/resolve.js.map +0 -1
- package/dist/core/run.js +0 -66
- package/dist/core/run.js.map +0 -1
- package/dist/core/suggest.js +0 -50
- package/dist/core/suggest.js.map +0 -1
- package/dist/core/types.js +0 -2
- package/dist/core/types.js.map +0 -1
- package/dist/core/units.js +0 -94
- package/dist/core/units.js.map +0 -1
- package/dist/core/write-safety.js +0 -128
- package/dist/core/write-safety.js.map +0 -1
- package/dist/engines/heic.js +0 -166
- package/dist/engines/heic.js.map +0 -1
- package/dist/engines/image.js +0 -342
- package/dist/engines/image.js.map +0 -1
- package/dist/engines/pdf.js +0 -444
- package/dist/engines/pdf.js.map +0 -1
- package/dist/engines/pdfium.js +0 -161
- package/dist/engines/pdfium.js.map +0 -1
- package/dist/engines/registry.js +0 -65
- package/dist/engines/registry.js.map +0 -1
- package/dist/engines/types.js +0 -2
- package/dist/engines/types.js.map +0 -1
- package/dist/engines/word.js +0 -385
- package/dist/engines/word.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shell/App.js +0 -1972
- package/dist/shell/App.js.map +0 -1
- package/dist/shell/ClickTargets.js +0 -183
- package/dist/shell/ClickTargets.js.map +0 -1
- package/dist/shell/ThemeContext.js +0 -21
- package/dist/shell/ThemeContext.js.map +0 -1
- package/dist/shell/blocks.js +0 -160
- package/dist/shell/blocks.js.map +0 -1
- package/dist/shell/clipboard.js +0 -64
- package/dist/shell/clipboard.js.map +0 -1
- package/dist/shell/commands.js +0 -51
- package/dist/shell/commands.js.map +0 -1
- package/dist/shell/components/Banner.js +0 -73
- package/dist/shell/components/Banner.js.map +0 -1
- package/dist/shell/components/CommandPalette.js +0 -37
- package/dist/shell/components/CommandPalette.js.map +0 -1
- package/dist/shell/components/FileCard.js +0 -59
- package/dist/shell/components/FileCard.js.map +0 -1
- package/dist/shell/components/HintBar.js +0 -18
- package/dist/shell/components/HintBar.js.map +0 -1
- package/dist/shell/components/Hints.js +0 -21
- package/dist/shell/components/Hints.js.map +0 -1
- package/dist/shell/components/MergeList.js +0 -268
- package/dist/shell/components/MergeList.js.map +0 -1
- package/dist/shell/components/ModeHeader.js +0 -21
- package/dist/shell/components/ModeHeader.js.map +0 -1
- package/dist/shell/components/PageGrid.js +0 -324
- package/dist/shell/components/PageGrid.js.map +0 -1
- package/dist/shell/components/PathInput.js +0 -147
- package/dist/shell/components/PathInput.js.map +0 -1
- package/dist/shell/components/Progress.js +0 -43
- package/dist/shell/components/Progress.js.map +0 -1
- package/dist/shell/components/Prompt.js +0 -667
- package/dist/shell/components/Prompt.js.map +0 -1
- package/dist/shell/components/ResultLinks.js +0 -26
- package/dist/shell/components/ResultLinks.js.map +0 -1
- package/dist/shell/components/Select.js +0 -152
- package/dist/shell/components/Select.js.map +0 -1
- package/dist/shell/components/Slider.js +0 -48
- package/dist/shell/components/Slider.js.map +0 -1
- package/dist/shell/components/StagedFiles.js +0 -92
- package/dist/shell/components/StagedFiles.js.map +0 -1
- package/dist/shell/components/ThemePicker.js +0 -18
- package/dist/shell/components/ThemePicker.js.map +0 -1
- package/dist/shell/components/UnitRow.js +0 -30
- package/dist/shell/components/UnitRow.js.map +0 -1
- package/dist/shell/flows/pdf.js +0 -424
- package/dist/shell/flows/pdf.js.map +0 -1
- package/dist/shell/frame-geometry.js +0 -56
- package/dist/shell/frame-geometry.js.map +0 -1
- package/dist/shell/hyperlink.js +0 -27
- package/dist/shell/hyperlink.js.map +0 -1
- package/dist/shell/intro.js +0 -101
- package/dist/shell/intro.js.map +0 -1
- package/dist/shell/launch.js +0 -75
- package/dist/shell/launch.js.map +0 -1
- package/dist/shell/mark.js +0 -134
- package/dist/shell/mark.js.map +0 -1
- package/dist/shell/mouse.js +0 -209
- package/dist/shell/mouse.js.map +0 -1
- package/dist/shell/redraw.js +0 -36
- package/dist/shell/redraw.js.map +0 -1
- package/dist/shell/reveal.js +0 -24
- package/dist/shell/reveal.js.map +0 -1
- package/dist/shell/stage.js +0 -34
- package/dist/shell/stage.js.map +0 -1
- package/dist/shell/terminal-write.js +0 -16
- package/dist/shell/terminal-write.js.map +0 -1
- package/dist/shell/theme.js +0 -178
- package/dist/shell/theme.js.map +0 -1
- package/dist/shell/useFrameOrigin.js +0 -175
- package/dist/shell/useFrameOrigin.js.map +0 -1
- package/dist/shell/useKeys.js +0 -28
- package/dist/shell/useKeys.js.map +0 -1
- package/dist/shell/useMouse.js +0 -150
- package/dist/shell/useMouse.js.map +0 -1
- package/dist/shell/useMouseRouting.js +0 -69
- package/dist/shell/useMouseRouting.js.map +0 -1
- package/dist/shell/width.js +0 -62
- package/dist/shell/width.js.map +0 -1
- package/dist/utils/display-path.js +0 -31
- package/dist/utils/display-path.js.map +0 -1
- package/dist/utils/unescape-path.js +0 -68
- package/dist/utils/unescape-path.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
var u=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function a(t,f){if(t.isTTY!==!0)return{update:()=>{},tick:()=>{},stop:()=>{}};let r=0,n="",e=!1,i=60,o=()=>{e||t.write(`\r${" ".repeat(i)}\r${u[r%u.length]} ${f}${n}`)};return{update(s){n=s===""?"":` \xB7 ${s}`,r++,o()},tick(){r++,o()},stop(){e||(e=!0,t.write(`\r${" ".repeat(i)}\r`))}}}var R=new Set(["iTerm.app","WezTerm","ghostty","vscode"]),O=new Set(["xterm-kitty","xterm-ghostty"]);function E(t=process.env){return t.FORGE_POWERLINE==="1"?!0:t.FORGE_POWERLINE==="0"||t.NO_COLOR!==void 0&&t.NO_COLOR!==""?!1:R.has(t.TERM_PROGRAM??"")||O.has(t.TERM??"")}function c(t=process.env){return t.FORGE_TRUECOLOR==="1"?!0:t.FORGE_TRUECOLOR==="0"||t.NO_COLOR!==void 0&&t.NO_COLOR!==""?!1:t.COLORTERM==="truecolor"||t.COLORTERM==="24bit"?!0:R.has(t.TERM_PROGRAM??"")||O.has(t.TERM??"")}export{u as a,a as b,E as c,c as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{g as Se,h as vt,i as it,k as Ae,l as It,m as wt,n as Mt}from"./chunk-L2WK7CJG.js";import{c as ye}from"./chunk-EOYBXOCV.js";import{A as ge,E as be,F as st,R as gt,a as B,b as ce,c as mt,d as nt,e as Nt,p as le,s as pe,t as fe,x as de,y as he,z as me}from"./chunk-DRBA23IQ.js";import{c as ot,e as Mn}from"./chunk-TMUK2DD3.js";var yt=ot((du,un)=>{"use strict";var nn="[^\\\\/]",go="(?=.)",rn="[^/]",zt="(?:\\/|$)",on="(?:^|\\/)",Qt=`\\.{1,2}${zt}`,bo="(?!\\.)",yo=`(?!${on}${Qt})`,So=`(?!\\.{0,1}${zt})`,Ao=`(?!${Qt})`,xo="[^.\\/]",Ro=`${rn}*?`,Eo="/",sn={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:go,QMARK:rn,END_ANCHOR:zt,DOTS_SLASH:Qt,NO_DOT:bo,NO_DOTS:yo,NO_DOT_SLASH:So,NO_DOTS_SLASH:Ao,QMARK_NO_DOT:xo,STAR:Ro,START_ANCHOR:on,SEP:Eo},_o={...sn,SLASH_LITERAL:"[\\\\/]",QMARK:nn,STAR:`${nn}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},vo={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};un.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:vo,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?_o:sn}}});var St=ot(U=>{"use strict";var{REGEX_BACKSLASH:Io,REGEX_REMOVE_BACKSLASH:wo,REGEX_SPECIAL_CHARS:ko,REGEX_SPECIAL_CHARS_GLOBAL:Oo}=yt();U.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);U.hasRegexChars=t=>ko.test(t);U.isRegexChar=t=>t.length===1&&U.hasRegexChars(t);U.escapeRegex=t=>t.replace(Oo,"\\$1");U.toPosixSlashes=t=>t.replace(Io,"/");U.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};U.removeBackslashes=t=>t.replace(wo,e=>e==="\\"?"":e);U.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?U.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};U.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};U.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${t})${o}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s};U.basename=(t,{windows:e}={})=>{let n=t.split(e?/[\\/]/:"/"),r=n[n.length-1];return r===""?n[n.length-2]:r}});var mn=ot((mu,hn)=>{"use strict";var an=St(),{CHAR_ASTERISK:Yt,CHAR_AT:Co,CHAR_BACKWARD_SLASH:At,CHAR_COMMA:$o,CHAR_DOT:Zt,CHAR_EXCLAMATION_MARK:Vt,CHAR_FORWARD_SLASH:dn,CHAR_LEFT_CURLY_BRACE:te,CHAR_LEFT_PARENTHESES:ee,CHAR_LEFT_SQUARE_BRACKET:To,CHAR_PLUS:Po,CHAR_QUESTION_MARK:cn,CHAR_RIGHT_CURLY_BRACE:Lo,CHAR_RIGHT_PARENTHESES:ln,CHAR_RIGHT_SQUARE_BRACKET:Fo}=yt(),pn=t=>t===dn||t===At,fn=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Do=(t,e)=>{let n=e||{},r=t.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],u=[],p=t,m=-1,g=0,b=0,f=!1,y=!1,S=!1,x=!1,R=!1,T=!1,A=!1,G=!1,Q=!1,F=!1,C=0,k,E,I={value:"",depth:0,isGlob:!1},l=()=>m>=r,W=()=>p.charCodeAt(m+1),N=()=>(k=E,p.charCodeAt(++m));for(;m<r;){E=N();let w;if(E===At){A=I.backslashes=!0,E=N(),E===te&&(T=!0);continue}if(T===!0||E===te){for(C++;l()!==!0&&(E=N());){if(E===At){A=I.backslashes=!0,N();continue}if(E===te){C++;continue}if(T!==!0&&E===Zt&&(E=N())===Zt){if(f=I.isBrace=!0,S=I.isGlob=!0,F=!0,o===!0)continue;break}if(T!==!0&&E===$o){if(f=I.isBrace=!0,S=I.isGlob=!0,F=!0,o===!0)continue;break}if(E===Lo&&(C--,C===0)){T=!1,f=I.isBrace=!0,F=!0;break}}if(o===!0)continue;break}if(E===dn){if(s.push(m),i.push(I),I={value:"",depth:0,isGlob:!1},F===!0)continue;if(k===Zt&&m===g+1){g+=2;continue}b=m+1;continue}if(n.noext!==!0&&(E===Po||E===Co||E===Yt||E===cn||E===Vt)===!0&&W()===ee){if(S=I.isGlob=!0,x=I.isExtglob=!0,F=!0,E===Vt&&m===g&&(Q=!0),o===!0){for(;l()!==!0&&(E=N());){if(E===At){A=I.backslashes=!0,E=N();continue}if(E===ln){S=I.isGlob=!0,F=!0;break}}continue}break}if(E===Yt){if(k===Yt&&(R=I.isGlobstar=!0),S=I.isGlob=!0,F=!0,o===!0)continue;break}if(E===cn){if(S=I.isGlob=!0,F=!0,o===!0)continue;break}if(E===To){for(;l()!==!0&&(w=N());){if(w===At){A=I.backslashes=!0,N();continue}if(w===Fo){y=I.isBracket=!0,S=I.isGlob=!0,F=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&E===Vt&&m===g){G=I.negated=!0,g++;continue}if(n.noparen!==!0&&E===ee){if(S=I.isGlob=!0,o===!0){for(;l()!==!0&&(E=N());){if(E===ee){A=I.backslashes=!0,E=N();continue}if(E===ln){F=!0;break}}continue}break}if(S===!0){if(F=!0,o===!0)continue;break}}n.noext===!0&&(x=!1,S=!1);let D=p,c="",a="";g>0&&(c=p.slice(0,g),p=p.slice(g),b-=g),D&&S===!0&&b>0?(D=p.slice(0,b),a=p.slice(b)):S===!0?(D="",a=p):D=p,D&&D!==""&&D!=="/"&&D!==p&&pn(D.charCodeAt(D.length-1))&&(D=D.slice(0,-1)),n.unescape===!0&&(a&&(a=an.removeBackslashes(a)),D&&A===!0&&(D=an.removeBackslashes(D)));let X={prefix:c,input:t,start:g,base:D,glob:a,isBrace:f,isBracket:y,isGlob:S,isExtglob:x,isGlobstar:R,negated:G,negatedExtglob:Q};if(n.tokens===!0&&(X.maxDepth=0,pn(E)||i.push(I),X.tokens=i),n.parts===!0||n.tokens===!0){let w;for(let L=0;L<s.length;L++){let V=w?w+1:g,K=s[L],tt=t.slice(V,K);n.tokens&&(L===0&&g!==0?(i[L].isPrefix=!0,i[L].value=c):i[L].value=tt,fn(i[L]),X.maxDepth+=i[L].depth),(L!==0||tt!=="")&&u.push(tt),w=K}if(w&&w+1<t.length){let L=t.slice(w+1);u.push(L),n.tokens&&(i[i.length-1].value=L,fn(i[i.length-1]),X.maxDepth+=i[i.length-1].depth)}X.slashes=s,X.parts=u}return X};hn.exports=Do});var Sn=ot((gu,yn)=>{"use strict";var xt=yt(),J=St(),{MAX_LENGTH:Ht,POSIX_REGEX_SOURCE:Ho,REGEX_NON_SPECIAL_CHARS:No,REGEX_SPECIAL_CHARS_BACKREF:Mo,REPLACEMENTS:gn}=xt,Bo=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let n=`[${t.join("-")}]`;try{new RegExp(n)}catch{return t.map(o=>J.escapeRegex(o)).join("..")}return n},dt=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,bn=t=>{let e=[],n=0,r=0,o=0,s="",i=!1;for(let u of t){if(i===!0){s+=u,i=!1;continue}if(u==="\\"){s+=u,i=!0;continue}if(u==='"'){o=o===1?0:1,s+=u;continue}if(o===0){if(u==="[")n++;else if(u==="]"&&n>0)n--;else if(n===0){if(u==="(")r++;else if(u===")"&&r>0)r--;else if(u==="|"&&r===0){e.push(s),s="";continue}}}s+=u}return e.push(s),e},qo=t=>{let e=!1;for(let n of t){if(e===!0){e=!1;continue}if(n==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},re=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(qo(e))return e.replace(/\\(.)/g,"$1")},Go=t=>{let e=t.map(re).filter(Boolean);for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let o=e[n],s=e[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},ne=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<t.length;i++){let u=t[i];if(s===!0){s=!1;continue}if(u==="\\"){s=!0;continue}if(u==='"'){o=o===1?0:1;continue}if(o!==1){if(u==="["){n++;continue}if(u==="]"&&n>0){n--;continue}if(!(n>0)){if(u==="("){r++;continue}if(u===")"&&(r--,r===0))return e===!0&&i!==t.length-1?void 0:{type:t[0],body:t.slice(2,i),end:i}}}}},Wo=t=>`${t.length===1?J.escapeRegex(t[0]):`[${t.map(n=>J.escapeRegex(n)).join("")}]`}*`,jo=t=>{let e=0,n=[];for(;e<t.length;){let r=ne(t.slice(e),!1);if(!r||r.type!=="*")return;let o=bn(r.body).map(i=>i.trim());if(o.length!==1)return;let s=re(o[0]);if(!s||s.length!==1)return;n.push(s),e+=r.end+1}if(!(n.length<1))return n},Uo=t=>{let e=0,n=t.trim(),r=ne(n);for(;r;)e++,n=r.body.trim(),r=ne(n);return e},Jo=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:xt.DEFAULT_MAX_EXTGLOB_RECURSION,r=bn(t).map(u=>u.trim());if(r.length>1&&(r.some(u=>u==="")||r.some(u=>/^[*?]+$/.test(u))||Go(r)))return{risky:!0};let o=[],s=!1,i=!0;for(let u of r){let p=jo(u);if(p){s=!0,o.push(...p);continue}let m=re(u);if(m&&m.length===1){o.push(m);continue}if(i=!1,Uo(u)>n)return{risky:!0}}return s?i?{risky:!0,safeOutput:Wo([...new Set(o)])}:{risky:!0}:{risky:!1}},oe=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=gn[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(Ht,n.maxLength):Ht,o=t.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],u=n.capture?"":"?:",p=xt.globChars(n.windows),m=xt.extglobChars(p),{DOT_LITERAL:g,PLUS_LITERAL:b,SLASH_LITERAL:f,ONE_CHAR:y,DOTS_SLASH:S,NO_DOT:x,NO_DOT_SLASH:R,NO_DOTS_SLASH:T,QMARK:A,QMARK_NO_DOT:G,STAR:Q,START_ANCHOR:F}=p,C=h=>`(${u}(?:(?!${F}${h.dot?S:g}).)*?)`,k=n.dot?"":x,E=n.dot?A:G,I=n.bash===!0?C(n):Q;n.capture&&(I=`(${I})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let l={input:t,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};t=J.removePrefix(t,l),o=t.length;let W=[],N=[],D=[],c=s,a,X=()=>l.index===o-1,w=l.peek=(h=1)=>t[l.index+h],L=l.advance=()=>t[++l.index]||"",V=()=>t.slice(l.index+1),K=(h="",P=0)=>{l.consumed+=h,l.index+=P},tt=h=>{l.output+=h.output!=null?h.output:h.value,K(h.value)},Hn=()=>{let h=1;for(;w()==="!"&&(w(2)!=="("||w(3)==="?");)L(),l.start++,h++;return h%2===0?!1:(l.negated=!0,l.start++,!0)},Et=h=>{l[h]++,D.push(h)},et=h=>{l[h]--,D.pop()},_=h=>{if(c.type==="globstar"){let P=l.braces>0&&(h.type==="comma"||h.type==="brace"),d=h.extglob===!0||W.length&&(h.type==="pipe"||h.type==="paren");h.type!=="slash"&&h.type!=="paren"&&!P&&!d&&(l.output=l.output.slice(0,-c.output.length),c.type="star",c.value="*",c.output=I,l.output+=c.output)}if(W.length&&h.type!=="paren"&&(W[W.length-1].inner+=h.value),(h.value||h.output)&&tt(h),c&&c.type==="text"&&h.type==="text"){c.output=(c.output||c.value)+h.value,c.value+=h.value;return}h.prev=c,i.push(h),c=h},_t=(h,P)=>{let d={...m[P],conditions:1,inner:""};d.prev=c,d.parens=l.parens,d.output=l.output,d.startIndex=l.index,d.tokensIndex=i.length;let v=(n.capture?"(":"")+d.open;Et("parens"),_({type:h,value:P,output:l.output?"":y}),_({type:"paren",extglob:!0,value:L(),output:v}),W.push(d)},Nn=h=>{let P=t.slice(h.startIndex,l.index+1),d=t.slice(h.startIndex+2,l.index),v=Jo(d,n);if((h.type==="plus"||h.type==="star")&&v.risky){let O=v.safeOutput?(h.output?"":y)+(n.capture?`(${v.safeOutput})`:v.safeOutput):void 0,Y=i[h.tokensIndex];Y.type="text",Y.value=P,Y.output=O||J.escapeRegex(P);for(let Z=h.tokensIndex+1;Z<i.length;Z++)i[Z].value="",i[Z].output="",delete i[Z].suffix;l.output=h.output+Y.output,l.backtrack=!0,_({type:"paren",extglob:!0,value:a,output:""}),et("parens");return}let $=h.close+(n.capture?")":""),M;if(h.type==="negate"){let O=I;if(h.inner&&h.inner.length>1&&h.inner.includes("/")&&(O=C(n)),(O!==I||X()||/^\)+$/.test(V()))&&($=h.close=`)$))${O}`),h.inner.includes("*")&&(M=V())&&/^\.[^\\/.]+$/.test(M)){let Y=oe(M,{...e,fastpaths:!1}).output;$=h.close=`)${Y})${O})`}h.prev.type==="bos"&&(l.negatedExtglob=!0)}_({type:"paren",extglob:!0,value:a,output:$}),et("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let h=!1,P=t.replace(Mo,(d,v,$,M,O,Y)=>M==="\\"?(h=!0,d):M==="?"?v?v+M+(O?A.repeat(O.length):""):Y===0?E+(O?A.repeat(O.length):""):A.repeat($.length):M==="."?g.repeat($.length):M==="*"?v?v+M+(O?I:""):I:v?d:`\\${d}`);return h===!0&&(n.unescape===!0?P=P.replace(/\\/g,""):P=P.replace(/\\+/g,d=>d.length%2===0?"\\\\":d?"\\":"")),P===t&&n.contains===!0?(l.output=t,l):(l.output=J.wrapOutput(P,l,e),l)}for(;!X();){if(a=L(),a==="\0")continue;if(a==="\\"){let d=w();if(d==="/"&&n.bash!==!0||d==="."||d===";")continue;if(!d){a+="\\",_({type:"text",value:a});continue}let v=/^\\+/.exec(V()),$=0;if(v&&v[0].length>2&&($=v[0].length,l.index+=$,$%2!==0&&(a+="\\")),n.unescape===!0?a=L():a+=L(),l.brackets===0){_({type:"text",value:a});continue}}if(l.brackets>0&&(a!=="]"||c.value==="["||c.value==="[^")){if(n.posix!==!1&&a===":"){let d=c.value.slice(1);if(d.includes("[")&&(c.posix=!0,d.includes(":"))){let v=c.value.lastIndexOf("["),$=c.value.slice(0,v),M=c.value.slice(v+2),O=Ho[M];if(O){c.value=$+O,l.backtrack=!0,L(),!s.output&&i.indexOf(c)===1&&(s.output=y);continue}}}(a==="["&&w()!==":"||a==="-"&&w()==="]")&&(a=`\\${a}`),a==="]"&&(c.value==="["||c.value==="[^")&&(a=`\\${a}`),n.posix===!0&&a==="!"&&c.value==="["&&(a="^"),c.value+=a,tt({value:a});continue}if(l.quotes===1&&a!=='"'){a=J.escapeRegex(a),c.value+=a,tt({value:a});continue}if(a==='"'){l.quotes=l.quotes===1?0:1,n.keepQuotes===!0&&_({type:"text",value:a});continue}if(a==="("){Et("parens"),_({type:"paren",value:a});continue}if(a===")"){if(l.parens===0&&n.strictBrackets===!0)throw new SyntaxError(dt("opening","("));let d=W[W.length-1];if(d&&l.parens===d.parens+1){Nn(W.pop());continue}_({type:"paren",value:a,output:l.parens?")":"\\)"}),et("parens");continue}if(a==="["){if(n.nobracket===!0||!V().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(dt("closing","]"));a=`\\${a}`}else Et("brackets");_({type:"bracket",value:a});continue}if(a==="]"){if(n.nobracket===!0||c&&c.type==="bracket"&&c.value.length===1){_({type:"text",value:a,output:`\\${a}`});continue}if(l.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(dt("opening","["));_({type:"text",value:a,output:`\\${a}`});continue}et("brackets");let d=c.value.slice(1);if(c.posix!==!0&&d[0]==="^"&&!d.includes("/")&&(a=`/${a}`),c.value+=a,tt({value:a}),n.literalBrackets===!1||J.hasRegexChars(d))continue;let v=J.escapeRegex(c.value);if(l.output=l.output.slice(0,-c.value.length),n.literalBrackets===!0){l.output+=v,c.value=v;continue}c.value=`(${u}${v}|${c.value})`,l.output+=c.value;continue}if(a==="{"&&n.nobrace!==!0){Et("braces");let d={type:"brace",value:a,output:"(",outputIndex:l.output.length,tokensIndex:l.tokens.length};N.push(d),_(d);continue}if(a==="}"){let d=N[N.length-1];if(n.nobrace===!0||!d){_({type:"text",value:a,output:a});continue}let v=")";if(d.dots===!0){let $=i.slice(),M=[];for(let O=$.length-1;O>=0&&(i.pop(),$[O].type!=="brace");O--)$[O].type!=="dots"&&M.unshift($[O].value);v=Bo(M,n),l.backtrack=!0}if(d.comma!==!0&&d.dots!==!0){let $=l.output.slice(0,d.outputIndex),M=l.tokens.slice(d.tokensIndex);d.value=d.output="\\{",a=v="\\}",l.output=$;for(let O of M)l.output+=O.output||O.value}_({type:"brace",value:a,output:v}),et("braces"),N.pop();continue}if(a==="|"){W.length>0&&W[W.length-1].conditions++,_({type:"text",value:a});continue}if(a===","){let d=a,v=N[N.length-1];v&&D[D.length-1]==="braces"&&(v.comma=!0,d="|"),_({type:"comma",value:a,output:d});continue}if(a==="/"){if(c.type==="dot"&&l.index===l.start+1){l.start=l.index+1,l.consumed="",l.output="",i.pop(),c=s;continue}_({type:"slash",value:a,output:f});continue}if(a==="."){if(l.braces>0&&c.type==="dot"){c.value==="."&&(c.output=g);let d=N[N.length-1];c.type="dots",c.output+=a,c.value+=a,d.dots=!0;continue}if(l.braces+l.parens===0&&c.type!=="bos"&&c.type!=="slash"){_({type:"text",value:a,output:g});continue}_({type:"dot",value:a,output:g});continue}if(a==="?"){if(!(c&&c.value==="(")&&n.noextglob!==!0&&w()==="("&&w(2)!=="?"){_t("qmark",a);continue}if(c&&c.type==="paren"){let v=w(),$=a;(c.value==="("&&!/[!=<:]/.test(v)||v==="<"&&!/<([!=]|\w+>)/.test(V()))&&($=`\\${a}`),_({type:"text",value:a,output:$});continue}if(n.dot!==!0&&(c.type==="slash"||c.type==="bos")){_({type:"qmark",value:a,output:G});continue}_({type:"qmark",value:a,output:A});continue}if(a==="!"){if(n.noextglob!==!0&&w()==="("&&(w(2)!=="?"||!/[!=<:]/.test(w(3)))){_t("negate",a);continue}if(n.nonegate!==!0&&l.index===0){Hn();continue}}if(a==="+"){if(n.noextglob!==!0&&w()==="("&&w(2)!=="?"){_t("plus",a);continue}if(c&&c.value==="("||n.regex===!1){_({type:"plus",value:a,output:b});continue}if(c&&(c.type==="bracket"||c.type==="paren"||c.type==="brace")||l.parens>0){_({type:"plus",value:a});continue}_({type:"plus",value:b});continue}if(a==="@"){if(n.noextglob!==!0&&w()==="("&&w(2)!=="?"){_({type:"at",extglob:!0,value:a,output:""});continue}_({type:"text",value:a});continue}if(a!=="*"){(a==="$"||a==="^")&&(a=`\\${a}`);let d=No.exec(V());d&&(a+=d[0],l.index+=d[0].length),_({type:"text",value:a});continue}if(c&&(c.type==="globstar"||c.star===!0)){c.type="star",c.star=!0,c.value+=a,c.output=I,l.backtrack=!0,l.globstar=!0,K(a);continue}let h=V();if(n.noextglob!==!0&&/^\([^?]/.test(h)){_t("star",a);continue}if(c.type==="star"){if(n.noglobstar===!0){K(a);continue}let d=c.prev,v=d.prev,$=d.type==="slash"||d.type==="bos",M=v&&(v.type==="star"||v.type==="globstar");if(n.bash===!0&&(!$||h[0]&&h[0]!=="/")){_({type:"star",value:a,output:""});continue}let O=l.braces>0&&(d.type==="comma"||d.type==="brace"),Y=W.length&&(d.type==="pipe"||d.type==="paren");if(!$&&d.type!=="paren"&&!O&&!Y){_({type:"star",value:a,output:""});continue}for(;h.slice(0,3)==="/**";){let Z=t[l.index+4];if(Z&&Z!=="/")break;h=h.slice(3),K("/**",3)}if(d.type==="bos"&&X()){c.type="globstar",c.value+=a,c.output=C(n),l.output=c.output,l.globstar=!0,K(a);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&!M&&X()){l.output=l.output.slice(0,-(d.output+c.output).length),d.output=`(?:${d.output}`,c.type="globstar",c.output=C(n)+(n.strictSlashes?")":"|$)"),c.value+=a,l.globstar=!0,l.output+=d.output+c.output,K(a);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&h[0]==="/"){let Z=h[1]!==void 0?"|$":"";l.output=l.output.slice(0,-(d.output+c.output).length),d.output=`(?:${d.output}`,c.type="globstar",c.output=`${C(n)}${f}|${f}${Z})`,c.value+=a,l.output+=d.output+c.output,l.globstar=!0,K(a+L()),_({type:"slash",value:"/",output:""});continue}if(d.type==="bos"&&h[0]==="/"){c.type="globstar",c.value+=a,c.output=`(?:^|${f}|${C(n)}${f})`,l.output=c.output,l.globstar=!0,K(a+L()),_({type:"slash",value:"/",output:""});continue}l.output=l.output.slice(0,-c.output.length),c.type="globstar",c.output=C(n),c.value+=a,l.output+=c.output,l.globstar=!0,K(a);continue}let P={type:"star",value:a,output:I};if(n.bash===!0){P.output=".*?",(c.type==="bos"||c.type==="slash")&&(P.output=k+P.output),_(P);continue}if(c&&(c.type==="bracket"||c.type==="paren")&&n.regex===!0){P.output=a,_(P);continue}(l.index===l.start||c.type==="slash"||c.type==="dot")&&(c.type==="dot"?(l.output+=R,c.output+=R):n.dot===!0?(l.output+=T,c.output+=T):(l.output+=k,c.output+=k),w()!=="*"&&(l.output+=y,c.output+=y)),_(P)}for(;l.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing","]"));l.output=J.escapeLast(l.output,"["),et("brackets")}for(;l.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing",")"));l.output=J.escapeLast(l.output,"("),et("parens")}for(;l.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing","}"));l.output=J.escapeLast(l.output,"{"),et("braces")}if(n.strictSlashes!==!0&&(c.type==="star"||c.type==="bracket")&&_({type:"maybe_slash",value:"",output:`${f}?`}),l.backtrack===!0){l.output="";for(let h of l.tokens)l.output+=h.output!=null?h.output:h.value,h.suffix&&(l.output+=h.suffix)}return l};oe.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(Ht,n.maxLength):Ht,o=t.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);t=gn[t]||t;let{DOT_LITERAL:s,SLASH_LITERAL:i,ONE_CHAR:u,DOTS_SLASH:p,NO_DOT:m,NO_DOTS:g,NO_DOTS_SLASH:b,STAR:f,START_ANCHOR:y}=xt.globChars(n.windows),S=n.dot?g:m,x=n.dot?b:m,R=n.capture?"":"?:",T={negated:!1,prefix:""},A=n.bash===!0?".*?":f;n.capture&&(A=`(${A})`);let G=k=>k.noglobstar===!0?A:`(${R}(?:(?!${y}${k.dot?p:s}).)*?)`,Q=k=>{switch(k){case"*":return`${S}${u}${A}`;case".*":return`${s}${u}${A}`;case"*.*":return`${S}${A}${s}${u}${A}`;case"*/*":return`${S}${A}${i}${u}${x}${A}`;case"**":return S+G(n);case"**/*":return`(?:${S}${G(n)}${i})?${x}${u}${A}`;case"**/*.*":return`(?:${S}${G(n)}${i})?${x}${A}${s}${u}${A}`;case"**/.*":return`(?:${S}${G(n)}${i})?${s}${u}${A}`;default:{let E=/^(.*?)\.(\w+)$/.exec(k);if(!E)return;let I=Q(E[1]);return I?I+s+E[2]:void 0}}},F=J.removePrefix(t,T),C=Q(F);return C&&n.strictSlashes!==!0&&(C+=`${i}?`),C};yn.exports=oe});var Rn=ot((bu,xn)=>{"use strict";var Xo=mn(),se=Sn(),An=St(),Ko=yt(),zo=t=>t&&typeof t=="object"&&!Array.isArray(t),H=(t,e,n=!1)=>{if(Array.isArray(t)){let g=t.map(f=>H(f,e,n));return f=>{for(let y of g){let S=y(f);if(S)return S}return!1}}let r=zo(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=e||{},s=o.windows,i=r?H.compileRe(t,e):H.makeRe(t,e,!1,!0),u=i.state;delete i.state;let p=()=>!1;if(o.ignore){let g={...e,ignore:null,onMatch:null,onResult:null};p=H(o.ignore,g,n)}let m=(g,b=!1)=>{let{isMatch:f,match:y,output:S}=H.test(g,i,e,{glob:t,posix:s}),x={glob:t,state:u,regex:i,posix:s,input:g,output:S,match:y,isMatch:f};return typeof o.onResult=="function"&&o.onResult(x),f===!1?(x.isMatch=!1,b?x:!1):p(g)?(typeof o.onIgnore=="function"&&o.onIgnore(x),x.isMatch=!1,b?x:!1):(typeof o.onMatch=="function"&&o.onMatch(x),b?x:!0)};return n&&(m.state=u),m};H.test=(t,e,n,{glob:r,posix:o}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?An.toPosixSlashes:null),u=t===r,p=u&&i?i(t):t;return u===!1&&(p=i?i(t):t,u=p===r),(u===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?u=H.matchBase(t,e,n,o):u=e.exec(p)),{isMatch:!!u,match:u,output:p}};H.matchBase=(t,e,n,r=n&&n.windows)=>(e instanceof RegExp?e:H.makeRe(e,n)).test(An.basename(t,{windows:r}));H.isMatch=(t,e,n)=>H(e,n)(t);H.parse=(t,e)=>Array.isArray(t)?t.map(n=>H.parse(n,e)):se(t,{...e,fastpaths:!1});H.scan=(t,e)=>Xo(t,e);H.compileRe=(t,e,n=!1,r=!1)=>{if(n===!0)return t.output;let o=e||{},s=o.contains?"":"^",i=o.contains?"":"$",u=`${s}(?:${t.output})${i}`;t&&t.negated===!0&&(u=`^(?!${u}).*$`);let p=H.toRegex(u,e);return r===!0&&(p.state=t),p};H.makeRe=(t,e={},n=!1,r=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(o.output=se.fastpaths(t,e)),o.output||(o=se(t,e)),H.compileRe(o,e,n,r)};H.toRegex=(t,e)=>{try{let n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(n){if(e&&e.debug===!0)throw n;return/$^/}};H.constants=Ko;xn.exports=H});var In=ot((yu,vn)=>{"use strict";var En=Rn(),Qo=St();function _n(t,e,n=!1){return e&&(e.windows===null||e.windows===void 0)&&(e={...e,windows:Qo.isWindows()}),En(t,e,n)}Object.assign(_n,En);vn.exports=_n});import{dirname as Gn}from"node:path";import{homedir as kt}from"node:os";import{dirname as Bn,join as ut}from"node:path";function qn(t,e){return t===e?"Same folder":t===ut(kt(),"Desktop")?"Desktop":t===ut(kt(),"Downloads")?"Downloads":t===ut(e,"converted")?"New subfolder":t.split("/").pop()||t}function Ot(t,e,{subfolder:n=!1}={}){let r=Bn(t.path),o=ye(e.defaultOutput),s=[{label:qn(o,r),path:o},{label:"Desktop",path:ut(kt(),"Desktop")},{label:"Same folder",path:r},{label:"Downloads",path:ut(kt(),"Downloads")},...n?[{label:"New subfolder",path:ut(r,"converted")}]:[]],i=new Set,u=s.filter(p=>i.has(p.path)?!1:(i.add(p.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:u}}var j=t=>typeof t=="string"&&t!==""?t:void 0;var Wn=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,jn=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Un="-small",xe={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{let e=Wn(t);return e!==void 0?B[e.format].lossy:(jn(t)?.images?.compressible??0)>0},options(t,e,n){let r=t[0];if(!r)return[];let o=[{kind:"select",id:"mode",label:`Compress ${r.path.split("/").pop()??"this file"}`,choices:[{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality")o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality});else if(e.mode==="size")o.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return o;return o.push(Ot(r,n)),o},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw st(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let r=t[0];if(!r)return[];let o=(r.path.split("/").pop()??"file").replace(/\.[^.]+$/,""),i=`${typeof e.destination=="string"?e.destination:Gn(r.path)}/${o}${Un}${mt(r.format)}`;return[{op:"convert",sources:[r],target:r.format,outputs:[i],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{}}}]}};function Ct(t){let e=Object.keys(B);return[...t].sort((n,r)=>e.indexOf(n)-e.indexOf(r))}function Bt(t){let e=new Set;for(let n of It)if(n.reads.has(t.format))for(let r of n.writes)e.add(r);return Ct([...e])}function Re(t){return Bt(t).map(e=>({id:e,label:B[e].label,hint:B[e].hint,lossy:B[e].lossy}))}function Jn(){let t=new Set;for(let e of It)for(let n of e.reads)t.add(n);return Ct([...t])}function Xn(){let t=new Set;for(let e of It)for(let n of e.writes)t.add(n);return Ct([...t])}function qt(t){return Se.writes.has(t)}function Xs(){let t=new Set(Jn()),e=new Set(Xn());return Ct([...new Set([...t,...e])]).map(n=>({id:n,label:B[n].label,extensions:[...B[n].extensions],read:t.has(n),write:e.has(n),lossy:B[n].lossy}))}import{existsSync as Gt,statSync as Kn}from"node:fs";import{basename as at,dirname as zn,extname as ct,isAbsolute as Qn,join as z,relative as Yn,resolve as q,sep as Zn}from"node:path";function Ee(t){return t.endsWith("/")||t.endsWith(Zn)||Gt(t)&&Kn(t).isDirectory()?!0:ct(t)===""}function Vn(t,e){let n=at(t),r=ct(n);return(r?n.slice(0,-r.length):n)+mt(e)}function _e(t,e,n){if(!n)return t;let r=Yn(q(n),e);return!r||r.startsWith("..")?t:z(t,r)}function Wt(t){let e=q(t.sourcePath),n=Vn(e,t.target);if(!t.output)return z(q(e,".."),n);let r=Qn(t.output)?t.output:q(t.output);return Ee(t.output)?z(_e(r,q(e,".."),t.sourceRoot),n):q(r)}function jt(t){let e=Wt(t);if(t.output&&!Ee(t.output))return e;let n=ct(e);return z(q(e,".."),`${at(e,n)}-${t.suffix}${n}`)}function Zs(t){if(!Gt(t))return t;let e=q(t,".."),n=at(t),r=ct(n),o=r?n.slice(0,-r.length):n;for(let s=1;s<1e4;s++){let i=z(e,`${o} (${s})${r}`);if(!Gt(i))return i}throw new Error(`no free name beside ${n}`)}function $t(t){let e=q(t,".."),n=at(t),r=ct(n);return{dir:e,stem:r?n.slice(0,-r.length):n,ext:r||".pdf"}}function lt(t,e){let{dir:n,stem:r,ext:o}=$t(q(t));return z(n,`${r}-${e}${o}`)}function ve(t,e){let{dir:n,stem:r,ext:o}=$t(q(t)),s=String(e).length;return Array.from({length:e},(i,u)=>z(n,`${r}-${String(u+1).padStart(s,"0")}${o}`))}function Ie(t,e,n,r,o){let{stem:s}=$t(q(t)),i=r?_e(q(r),q(t,".."),o):q(t,".."),u=mt(n),p=String(Math.max(1,...e.map(f=>f+1))).length,m=e.map(f=>z(i,`${s}-${String(f+1).padStart(p,"0")}${u}`)),[g,...b]=m;if(g===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[g,...b]}function we(t,e,n){if(!n)return[lt(t,"extract")];let{dir:r,stem:o,ext:s}=$t(q(t));return e.map(i=>z(r,`${o}-p${i+1}${s}`))}function ke(t){let e=q(t[0]??"merged.pdf");if(new Set(t.map(r=>q(r,".."))).size===1){let r=q(e,"..");return z(r,`${at(r)}-merged.pdf`)}return lt(e,"merged")}function bt(t,e,n){let r=e?t.map(s=>z(e,at(s))):t,[o]=r;return!n||r.length!==1||o===void 0?r:[z(zn(o),`${n}${ct(o)}`)]}function pt(t,e,n){return bt([t],e,n)[0]??t}function tr(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function er(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function nr(t,e){return Array.isArray(e)?it(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?it(vt(e,t.pages)):Array.from({length:t.pages},(n,r)=>r)}function rr(t,e){let n=B[t.format].lossy,r=B[e].lossy;if(n&&!r)return{hint:"likely bigger",tone:"warn"};if(!n&&r)return{hint:"likely smaller",tone:"ok"}}function or(t){let e=Re(t).filter(r=>r.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${B[t.format].label} to`,choices:e.map(r=>{let o=rr(t,r.id);return{value:r.id,label:r.label,hint:o?.hint??r.hint,...o===void 0?{}:{tone:o.tone}}}),default:n?n.id:""}}function sr(t){let e=t.target,n=typeof e=="string"?ce(e):void 0;if(!n)throw st(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var Oe={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let r=t[0];if(!r)return[];let o=[or(r)],s=e.target;return typeof s!="string"||(r.kind==="document"&&qt(s)&&o.push(tr(r),er()),B[s]?.lossy&&o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),o.push(Ot(r,n,{subfolder:!0}))),o},plan(t,e){let n=t[0];if(!n)return[];let r=sr(e),o=r.id,s={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};r.lossy&&typeof e.quality=="number"&&(s.quality=e.quality);let i=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&qt(o)){let p=Number(e.dpi);s.dpi=Number.isFinite(p)&&p>0?p:150;let m=nr(n,e.pages);s.pages=m;let g=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,b=Ie(n.path,m,o,i,g);return[{op:"convert",sources:[n],outputs:b,target:o,options:s}]}let u=Wt({sourcePath:n.path,target:o,...i===void 0?{}:{output:`${i}/`}});return[{op:"convert",sources:[n],outputs:[u],target:o,options:s}]}};var Tt=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function di(t,e){let n=Bt(t);return n.includes(e)?void 0:fe(t,e,n)}function Ce(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var $e=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:B.png.hint}]}),ir=t=>t===1?"sharp":`${t}x`,Te={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7 or 4\xD7",requires:"boost",appliesTo:t=>Tt(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},$e()],plan(t,e){let n=Tt(t);if(!n)return[];let r=Ce(e),o=Number(e.scale??2),s=o===4?4:o===1?1:2;return n.map(i=>({op:"boost",sources:[i],outputs:[jt({sourcePath:i.path,target:r.target,suffix:ir(s),...r.output===void 0?{}:{output:r.output},...r.roots?.get(i.path)===void 0?{}:{sourceRoot:r.roots.get(i.path)}})],scale:s,target:r.target,options:{background:r.background,keepMetadata:r.keepMetadata,...r.quality===void 0?{}:{quality:r.quality}}}))}},Pe={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>Tt(t)!==void 0,unavailable:()=>"images only",options:()=>[$e()],plan(t,e){let n=Tt(t);if(!n)return[];let r=Ce(e);return n.map(o=>({op:"remove-background",sources:[o],outputs:[jt({sourcePath:o.path,target:r.target,suffix:"cutout",...r.output===void 0?{}:{output:r.output},...r.roots?.get(o.path)===void 0?{}:{sourceRoot:r.roots.get(o.path)}})],target:r.target,options:{background:r.background,keepMetadata:r.keepMetadata,...r.quality===void 0?{}:{quality:r.quality}}}))}};var Pt=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,Le={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:t=>(Pt(t)?.pages??0)>1,unavailable:t=>Pt(t)===void 0?"one PDF at a time":"only one page",options(t){let e=Pt(t);return e?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${e.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(t,e){let n=Pt(t);if(!n)return[];let r=Array.isArray(e.cuts)?e.cuts:[],o=Ae(r,n.pages).length,s=bt(ve(n.path,o),j(e.destination),j(e.name));return[{op:"split",sources:[n],outputs:s,cuts:r}]}};function Si(t){return Array.from({length:Math.max(0,t-1)},(e,n)=>n)}function Ai(t,e){if(!Number.isInteger(e)||e<1)throw st("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=e;r<t;r+=e)n.push(r-1);return n}var ft=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0;function Fe(t,e){return Array.isArray(e.pages)?it(e.pages):typeof e.pages=="string"?it(vt(e.pages,t.pages)):[]}var De=t=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${t.pages}`}),He={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:t=>ft(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=ft(t);return e?[De(e),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(t,e){let n=ft(t);if(!n)return[];let r=Fe(n,e),o=e.separate==="many";return[{op:"extract",sources:[n],outputs:bt(we(n.path,r,o),j(e.destination),j(e.name)),pages:r,separate:o}]}},Ne={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:t=>ft(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=ft(t);return e?[De(e)]:[]},plan(t,e){let n=ft(t);return n?[{op:"delete",sources:[n],outputs:[pt(lt(n.path,"trimmed"),j(e.destination),j(e.name))],pages:Fe(n,e)}]:[]}};var Ut=t=>t.filter(e=>e.kind==="document"&&e.format==="pdf"),Me={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:t=>Ut(t).length>=2&&Ut(t).length===t.length,unavailable:t=>Ut(t).length!==t.length?"PDFs only":"needs 2+ files",options:()=>[],plan(t,e){let n=pt(ke(t.map(r=>r.path)),j(e.destination),j(e.name));return[{op:"merge",sources:t,outputs:[n]}]}};var Be=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,qe={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:t=>Be(t)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(t,e){let n=Be(t);if(!n)return[];let o=Number(e.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[pt(lt(n.path,"rotated"),j(e.destination),j(e.name))],turns:o}]}};var ur=[Oe,xe,Me,Le,He,Ne,qe],ar=[Te,Pe];function Mi(t,e=new Set){return[...ur,...ar.filter(n=>n.requires&&e.has(n.requires))].filter(n=>n.appliesTo(t))}function Bi(t,e){return t.appliesTo(e)?void 0:t.unavailable?.(e)}function cr(t=1,e=100){let n=Math.max(1,e-t+1);return 1+Math.max(0,Math.ceil(Math.log2(n)))}async function Ge(t){let e=t.min??1,n=t.max??100,r=cr(e,n),o=0,s=async f=>(o+=1,t.onAttempt?.(o,r),t.encode(f)),i=()=>t.signal?.aborted===!0,u=await s(n);if(i())return{quality:n,bytes:u,missed:!1,cancelled:!0};if(u<=t.targetBytes)return{quality:n,bytes:u,missed:!1};let p=e,m=n,g;for(;p<=m;){let f=Math.floor((p+m)/2),y=await s(f);if(i())return{quality:f,bytes:y,missed:!1,cancelled:!0};y<=t.targetBytes?(g={quality:f,bytes:y,missed:!1},p=f+1):m=f-1}if(g)return g;let b=await t.encode(e);return{quality:e,bytes:b,missed:!0}}import{cpus as lr}from"node:os";function pr(){return Math.max(1,Math.min(lr().length,4))}function Lt(t){let e=t!==void 0&&Number.isFinite(t)?t:void 0;return Math.max(1,e??pr())}async function Jt(t,e,n){let r=0,o=async()=>{for(;r<t.length;){let i=r++;await n(t[i],i)}},s=Math.min(Lt(e),t.length);await Promise.all(Array.from({length:s},o))}async function We(t,e){let n=e.onEvent??(()=>{}),r=e.engineFor??wt,o=Lt(e.concurrency),s=t.length,i=[],u=[],p=0;await Jt(t,o,async(f,y)=>{n({type:"job:start",job:f,index:y,total:s});let S=r(f);if(!S){p++;let x=f.sources[0].path,R={path:x,error:gt(x,new Error(`no engine runs ${f.op}`))};u[y]=R,n({type:"job:error",job:f,failure:R,completed:p,total:s});return}try{let x=await S.run(f,R=>n({type:"job:phase",job:f,progress:R}),e.signal);i[y]=x,p++,n({type:"job:done",job:f,result:x,completed:p,total:s})}catch(x){p++;let R=f.sources[0].path,T=nt(x)?x:gt(R,x),A={path:R,error:T};u[y]=A,n({type:"job:error",job:f,failure:A,completed:p,total:s})}});let m=i.filter(f=>f!==void 0),g=u.filter(f=>f!==void 0),b={results:m,failures:g,inputBytes:m.reduce((f,y)=>f+y.job.sources[0].bytes,0),outputBytes:m.reduce((f,y)=>f+y.outputBytes,0)};return n({type:"batch:done",summary:b}),b}import{existsSync as fr}from"node:fs";import{resolve as Ft}from"node:path";function dr(t){let e=t.sources[0]?.path??t.outputs[0]??"",n=new Set;for(let r of t.outputs){let o=Ft(r);if(n.has(o))return{output:r,error:me(e,r)};n.add(o)}}function hr(t,e,n){let r=dr(t);if(r)return r;let o=new Set(t.sources.map(i=>Ft(i.path))),s=t.sources[0]?.path??t.outputs[0]??"";for(let i of t.outputs){let u=Ft(i);if(o.has(u)&&!n)return{output:i,error:ge(i,t.op)};let p=e.get(u);if(p){let m=p.sources[0]?.path??p.outputs[0]??"";return{output:i,error:he([m,s],i)}}if(fr(u)&&!n)return{output:i,error:de(i,t.op)}}}function je(t,e){let n=[],r=[],o=new Map;for(let s of t){let i=hr(s,o,e.force);if(i){let u=s.sources[0]?.path??i.output;r.push({path:u,error:i.error});continue}for(let u of s.outputs)o.set(Ft(u),s);n.push(s)}return{jobs:n,failures:r}}async function mr(t,e,n,r,o){let s=t.sources[0].path,i=f=>({kind:"failed",failure:{path:s,error:nt(f)?f:gt(s,f)}}),u;try{u=await n(t)?.measurer?.(t)}catch(f){return i(f)}if(!u||u.ladder.length===0)return{kind:"refused",failure:{path:s,error:le(t.sources[0],t.target)}};let p=u;if(o?.aborted)return{kind:"cancelled"};let m=Number.POSITIVE_INFINITY,g;try{for(let f of p.ladder){let y=await Ge({encode:S=>p.measure({...t.options,...f,quality:S}),targetBytes:e,onAttempt:(S,x)=>r({type:"search:attempt",job:t,attempt:S,of:x,rung:f}),...o===void 0?{}:{signal:o}});if(y.cancelled)return{kind:"cancelled"};if(y.bytes<m&&(m=y.bytes,g={...f,quality:y.quality}),!y.missed)return t.options={...t.options,...f,quality:y.quality},{kind:"ready"}}}catch(f){return i(f)}return{kind:"unreachable",entry:{job:t,smallest:m,settings:g??{quality:1},error:pe(t.sources[0],e,m)}}}async function nu(t,e){let n=e.onEvent??(()=>{}),r=e.engineFor??wt,o=e.targetBytes,s=je(t,{force:e.force}),i=o===void 0?0:s.jobs.filter(R=>R.op==="convert").length,u=[],p=0;await Jt(s.jobs,Lt(e.concurrency),async(R,T)=>{if(o===void 0||R.op!=="convert"){u[T]={kind:"ready"};return}if(e.signal?.aborted){u[T]={kind:"cancelled"};return}let A=await mr(R,o,r,n,e.signal);u[T]=A,A.kind!=="cancelled"&&(p+=1,n({type:"search:settled",job:R,completed:p,total:i}))});let m=[...s.failures],g=[],b=[],f=[],y=!1;for(let[R,T]of s.jobs.entries()){let A=u[R]??{kind:"ready"};A.kind==="ready"?f.push(T):A.kind==="refused"?m.push(A.failure):A.kind==="failed"?b.push(A.failure):A.kind==="unreachable"?g.push(A.entry):y=!0}if(y)return{results:[],refusals:m,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let S=new Set,x=await We(f,{...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.engineFor===void 0?{}:{engineFor:e.engineFor},...e.signal===void 0?{}:{signal:e.signal},onEvent:R=>{R.type==="job:error"&&!e.signal?.aborted&&S.add(R.failure),n(R)}});if(e.signal?.aborted&&x.failures.length>0){let R=x.failures.filter(T=>S.has(T));return{...x,refusals:m,unreachable:g,failures:[...b,...R],cancelled:!0}}return{results:x.results,refusals:m,unreachable:g,failures:[...b,...x.failures],inputBytes:x.inputBytes,outputBytes:x.outputBytes}}import{existsSync as ws}from"node:fs";import{stat as ks}from"node:fs/promises";import{resolve as ae}from"node:path";import{readdir as Yo,readdirSync as Zo,realpath as Vo,realpathSync as ts,stat as es,statSync as ns}from"fs";import{isAbsolute as rs,posix as rt,resolve as os}from"path";import{fileURLToPath as ss}from"url";import{createRequire as gr}from"module";import{basename as br,dirname as Kt,normalize as yr,relative as Sr,resolve as Ar,sep as Xe}from"path";import*as xr from"fs";var Ue=gr(import.meta.url);function Rr(t){let e=yr(t);return e.length>1&&e[e.length-1]===Xe&&(e=e.substring(0,e.length-1)),e}var Er=/[\\/]/g;function Ke(t,e){return t.replace(Er,e)}var _r=/^[a-z]:[\\/]$/i;function vr(t){return t==="/"||_r.test(t)}function Xt(t,e){let{resolvePaths:n,normalizePath:r,pathSeparator:o}=e,s=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(n&&(t=Ar(t)),(r||s)&&(t=Rr(t)),t===".")return"";let i=t[t.length-1]!==o;return Ke(i?t+o:t,o)}function ze(t,e){return e+t}function Ir(t,e){return function(n,r){return r.startsWith(t)?r.slice(t.length)+n:Ke(Sr(t,r),e.pathSeparator)+e.pathSeparator+n}}function wr(t){return t}function kr(t,e,n){return e+t+n}function Or(t,e){let{relativePaths:n,includeBasePath:r}=e;return n&&t?Ir(t,e):r?ze:wr}function Cr(t){return function(e,n){n.push(e.substring(t.length)||".")}}function $r(t){return function(e,n,r){let o=e.substring(t.length)||".";r.every(s=>s(o,!0))&&n.push(o)}}var Tr=(t,e)=>{e.push(t||".")},Pr=(t,e,n)=>{let r=t||".";n.every(o=>o(r,!0))&&e.push(r)},Lr=()=>{};function Fr(t,e){let{includeDirs:n,filters:r,relativePaths:o}=e;return n?o?r&&r.length?$r(t):Cr(t):r&&r.length?Pr:Tr:Lr}var Dr=(t,e,n,r)=>{r.every(o=>o(t,!1))&&n.files++},Hr=(t,e,n,r)=>{r.every(o=>o(t,!1))&&e.push(t)},Nr=(t,e,n,r)=>{n.files++},Mr=(t,e)=>{e.push(t)},Br=()=>{};function qr(t){let{excludeFiles:e,filters:n,onlyCounts:r}=t;return e?Br:n&&n.length?r?Dr:Hr:r?Nr:Mr}var Gr=t=>t,Wr=()=>[""].slice(0,0);function jr(t){return t.group?Wr:Gr}var Ur=(t,e,n)=>{t.push({directory:e,files:n,dir:e})},Jr=()=>{};function Xr(t){return t.group?Ur:Jr}var Kr=function(t,e,n){let{queue:r,fs:o,options:{suppressErrors:s}}=e;r.enqueue(),o.realpath(t,(i,u)=>{if(i)return r.dequeue(s?null:i,e);o.stat(u,(p,m)=>{if(p)return r.dequeue(s?null:p,e);if(m.isDirectory()&&Qe(t,u,e))return r.dequeue(null,e);n(m,u),r.dequeue(null,e)})})},zr=function(t,e,n){let{queue:r,fs:o,options:{suppressErrors:s}}=e;r.enqueue();try{let i=o.realpathSync(t),u=o.statSync(i);if(u.isDirectory()&&Qe(t,i,e))return;n(u,i)}catch(i){if(!s)throw i}};function Qr(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?zr:Kr}function Qe(t,e,n){if(n.options.useRealPaths)return Yr(e,n);let r=Kt(t),o=1;for(;r!==n.root&&o<2;){let s=n.symlinks.get(r);!!s&&(s===e||s.startsWith(e)||e.startsWith(s))?o++:r=Kt(r)}return n.symlinks.set(t,e),o>1}function Yr(t,e){return e.visited.includes(t+e.options.pathSeparator)}var Zr=t=>t.counts,Vr=t=>t.groups,to=t=>t.paths,eo=t=>t.paths.slice(0,t.options.maxFiles),no=(t,e,n)=>(Dt(e,n,t.counts,t.options.suppressErrors),null),ro=(t,e,n)=>(Dt(e,n,t.paths,t.options.suppressErrors),null),oo=(t,e,n)=>(Dt(e,n,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),so=(t,e,n)=>(Dt(e,n,t.groups,t.options.suppressErrors),null);function Dt(t,e,n,r){e(t&&!r?t:null,n)}function io(t,e){let{onlyCounts:n,group:r,maxFiles:o}=t;return n?e?Zr:no:r?e?Vr:so:o?e?eo:oo:e?to:ro}var Ye={withFileTypes:!0},uo=(t,e,n,r,o)=>{if(t.queue.enqueue(),r<0)return t.queue.dequeue(null,t);let{fs:s}=t;t.visited.push(e),t.counts.directories++,s.readdir(e||".",Ye,(i,u=[])=>{o(u,n,r),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},ao=(t,e,n,r,o)=>{let{fs:s}=t;if(r<0)return;t.visited.push(e),t.counts.directories++;let i=[];try{i=s.readdirSync(e||".",Ye)}catch(u){if(!t.options.suppressErrors)throw u}o(i,n,r)};function co(t){return t?ao:uo}var lo=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},po=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},fo=class{aborted=!1;abort(){this.aborted=!0}},Ze=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,e,n){this.isSynchronous=!n,this.callbackInvoker=io(e,this.isSynchronous),this.root=Xt(t,e),this.state={root:vr(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new po,options:e,queue:new lo((r,o)=>this.callbackInvoker(o,r,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new fo,fs:e.fs||xr},this.joinPath=Or(this.root,e),this.pushDirectory=Fr(this.root,e),this.pushFile=qr(e),this.getArray=jr(e),this.groupFiles=Xr(e),this.resolveSymlink=Qr(e,this.isSynchronous),this.walkDirectory=co(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,e,n)=>{let{paths:r,options:{filters:o,resolveSymlinks:s,excludeSymlinks:i,exclude:u,maxFiles:p,signal:m,useRealPaths:g,pathSeparator:b},controller:f}=this.state;if(f.aborted||m&&m.aborted||p&&r.length>p)return;let y=this.getArray(this.state.paths);for(let S=0;S<t.length;++S){let x=t[S];if(x.isFile()||x.isSymbolicLink()&&!s&&!i){let R=this.joinPath(x.name,e);this.pushFile(R,y,this.state.counts,o)}else if(x.isDirectory()){let R=kr(x.name,e,this.state.options.pathSeparator);if(u&&u(x.name,R))continue;this.pushDirectory(R,r,o),this.walkDirectory(this.state,R,R,n-1,this.walk)}else if(this.resolveSymlink&&x.isSymbolicLink()){let R=ze(x.name,e);this.resolveSymlink(R,this.state,(T,A)=>{if(T.isDirectory()){if(A=Xt(A,this.state.options),u&&u(x.name,g?A:R+b))return;this.walkDirectory(this.state,A,g?A:R+b,n-1,this.walk)}else{A=g?A:R;let G=br(A),Q=Xt(Kt(A),this.state.options);A=this.joinPath(G,Q),this.pushFile(A,y,this.state.counts,o)}})}}this.groupFiles(this.state.groups,e,y)}};function ho(t,e){return new Promise((n,r)=>{Ve(t,e,(o,s)=>{if(o)return r(o);n(s)})})}function Ve(t,e,n){new Ze(t,e,n).start()}function mo(t,e){return new Ze(t,e).start()}var Je=class{constructor(t,e){this.root=t,this.options=e}withPromise(){return ho(this.root,this.options)}withCallback(t){Ve(this.root,this.options,t)}sync(){return mo(this.root,this.options)}},tn=null;try{Ue.resolve("picomatch"),tn=Ue("picomatch")}catch{}var en=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:Xe,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new Je(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new Je(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){let n=this.globFunction||tn;if(!n)throw new Error("Please specify a glob function to use glob matching.");var r=this.globCache[t.join("\0")];return r||(r=n(t,...e),this.globCache[t.join("\0")]=r),this.options.filters.push(o=>r(o)),this}};var ht=Mn(In(),1),is=Array.isArray,Cn=/\\/g,us=/^[A-Za-z]:$/,$n=process.platform==="win32",as=/^(\/?\.\.)+$/;function cs(t,e={}){let n=t.length,r=Array(n),o=Array(n),s,i;for(s=0;s<n;s++){let u=Tn(t[s]);r[s]=u;let p=u.length,m=Array(p);for(i=0;i<p;i++)m[i]=(0,ht.default)(u[i],e);o[s]=m}return u=>{let p=u.split("/");if(p[0]===".."&&as.test(u))return!0;for(s=0;s<n;s++){let m=r[s],g=o[s],b=p.length,f=Math.min(b,m.length);for(i=0;i<f;){let y=m[i];if(y.includes("/"))return!0;if(!g[i](p[i]))break;if(!e.noglobstar&&y==="**")return!0;i++}if(i===b)return!0}return!1}}var ls=/^[A-Z]:\/$/i,ps=$n?t=>ls.test(t):t=>t==="/";function wn(t,e,n){if(t===e||e.startsWith(`${t}/`)){if(n){let o=t.length+ +!ps(t);return(s,i)=>s.slice(o,i?-1:void 0)||"."}let r=e.slice(t.length+1);return r?(o,s)=>{if(o===".")return r;let i=`${r}/${o}`;return s?i.slice(0,-1):i}:(o,s)=>s&&o!=="."?o.slice(0,-1):o}return n?r=>rt.relative(t,r)||".":r=>rt.relative(t,`${e}/${r}`)||"."}function fs(t,e){if(e.startsWith(`${t}/`)){let n=e.slice(t.length+1);return r=>`${n}/${r}`}return n=>{let r=rt.relative(t,`${e}/${n}`);return n[n.length-1]==="/"&&r!==""?`${r}/`:r||"."}}function kn(t){return t.replace(us,e=>`${e}/`)}var ds={parts:!0};function Tn(t){var e;let n=ht.default.scan(t,ds);return!((e=n.parts)===null||e===void 0)&&e.length?n.parts:[t]}var hs=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,ms=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,gs=t=>t.replace(hs,"\\$&"),bs=t=>t.replace(ms,"\\$&"),ys=$n?bs:gs;function Ss(t,e){if(e?.caseSensitiveMatch===!1)return!0;let n=ht.default.scan(t);return n.isGlob||n.negated}function Rt(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function Pn(t){return typeof t=="string"?[t]:t??[]}var As=/^(\/?\.\.)+/,xs=/\\(?=[()[\]{}!*+?@|])/g;function ie(t,e,n,r){var o;let s=e.cwd,i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1)),i[i.length-1]!=="*"&&e.expandDirectories&&(i+="/**");let u=ys(s);i=rs(i.replace(xs,""))?rt.relative(u,i):rt.normalize(i);let p=(o=As.exec(i))===null||o===void 0?void 0:o[0],m=Tn(i);if(p){let b=(p.length+1)/3,f=0,y=u.split("/");for(;f<b&&m[f+b]===y[y.length+f-b];)i=i.slice(0,(b-f-1)*3)+i.slice((b-f)*3+m[f+b].length+1)||".",f++;let S=rt.join(s,p.slice(f*3));S[0]!=="."&&n.root.length>S.length&&(n.root=kn(S),n.depthOffset=-b+f)}if(!r&&n.depthOffset>=0){var g;(g=n.commonPath)!==null&&g!==void 0||(n.commonPath=m);let b=[],f=Math.min(n.commonPath.length,m.length);for(let y=0;y<f;y++){let S=m[y];if(S==="**"&&!m[y+1]){b.pop();break}if(y===m.length-1||S!==n.commonPath[y]||Ss(S))break;b.push(S)}n.depthOffset=b.length,n.commonPath=b,n.root=kn(b.length>0?rt.join(s,...b):s)}return i}function Rs(t,e,n){let r=[],o=[];for(let s of t.ignore)s&&(s[0]!=="!"||s[1]==="(")&&o.push(ie(s,t,n,!0));for(let s of e)s&&(s[0]!=="!"||s[1]==="("?r.push(ie(s,t,n,!1)):(s[1]!=="!"||s[2]==="(")&&o.push(ie(s.slice(1),t,n,!0)));return{match:r,ignore:o}}function Es(t,e){let n=t.cwd,r={root:n,depthOffset:0},o=Rs(t,e,r);t.debug&&Rt("internal processing patterns:",o);let{absolute:s,caseSensitiveMatch:i,debug:u,dot:p,followSymbolicLinks:m,onlyDirectories:g}=t,b=r.root.replace(Cn,""),f={dot:p,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},y=(0,ht.default)(o.match,f),S=(0,ht.default)(o.ignore,f),x=cs(o.match,f),R=wn(n,b,s),T=s?R:wn(n,b,!0),A=(F,C)=>{let k=T(C,!0);return k!=="."&&!x(k)||S(k)},G;t.deep!==void 0&&(G=Math.round(t.deep-r.depthOffset));let Q=new en({filters:[u?(F,C)=>{let k=R(F,C),E=y(k)&&!S(k);return E&&Rt(`matched ${k}`),E}:(F,C)=>{let k=R(F,C);return y(k)&&!S(k)}],exclude:u?(F,C)=>{let k=A(F,C);return Rt(`${k?"skipped":"crawling"} ${C}`),k}:A,fs:t.fs,pathSeparator:"/",relativePaths:!s,resolvePaths:s,includeBasePath:s,resolveSymlinks:m,excludeSymlinks:!m,excludeFiles:g,includeDirs:g||!t.onlyFiles,maxDepth:G,signal:t.signal}).crawl(b);return t.debug&&Rt("internal properties:",{...r,root:b}),[Q,n!==b&&!s&&fs(n,b)]}function _s(t,e){if(e)for(let n=t.length-1;n>=0;n--)t[n]=e(t[n]);return t}var On={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function vs(t){let e=Object.assign({},t);for(let n in On)e[n]===void 0&&Object.assign(e,{[n]:On[n]});return e.cwd=(e.cwd instanceof URL?ss(e.cwd):os(e.cwd||process.cwd())).replace(Cn,"/"),e.ignore=Pn(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||Yo,readdirSync:e.fs.readdirSync||Zo,realpath:e.fs.realpath||Vo,realpathSync:e.fs.realpathSync||ts,stat:e.fs.stat||es,statSync:e.fs.statSync||ns}),e.debug&&Rt("globbing with options:",e),e}function Is(t,e={}){var n;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let r=is(t)||typeof t=="string",o=Pn((n=r?t:t.patterns)!==null&&n!==void 0?n:"**/*"),s=vs(r?e:t);return o.length>0?Es(s,o):[]}async function ue(t,e){let[n,r]=Is(t,e);return n?_s(await n.withPromise(),r):[]}var Ln=Object.values(B).flatMap(t=>t.extensions).map(t=>t.slice(1));function Os(t){return/[*?[\]{}]/.test(t)}async function Cs(t,e){let n=e?`**/*.{${Ln.join(",")}}`:`*.{${Ln.join(",")}}`;return(await ue([n],{cwd:t,absolute:!0,onlyFiles:!0,caseSensitiveMatch:!1})).sort()}async function Fn(t,e,n,r){let o=await Cs(t,e);if(o.length===0){n.push({path:t,error:be(t)});return}for(let s of o)await r(s,t,!1)}async function $u(t,e){let n=[],r=[],o=new Map,s=ae(t);return await Fn(s,e.recursive,r,async(i,u)=>{try{n.push(await Mt(i)),o.set(i,u)}catch(p){nt(p)&&r.push({path:i,error:p})}}),{sources:n,failures:r,roots:o}}async function Tu(t,e){let n=[],r=[],o=new Map,s=new Set,i=async(u,p,m)=>{let g=ae(u);if(!s.has(g)){s.add(g);try{n.push(await Mt(g)),p&&o.set(g,p)}catch(b){if(nt(b))r.push({path:g,error:b});else if(m)throw b}}};for(let u of t){let p=ae(u);if(Os(u)&&!ws(p)){let g=await ue([u],{absolute:!0,onlyFiles:!0});g.length===0&&r.push({path:p,error:Nt(p)});for(let b of g.sort())await i(b,void 0,!1);continue}let m;try{m=await ks(p)}catch{r.push({path:p,error:Nt(p)});continue}if(m.isDirectory()){await Fn(p,e.recursive,r,i);continue}await i(p,void 0,!0)}return{sources:n,failures:r,roots:o}}import{homedir as $s}from"node:os";import{isAbsolute as Ts,relative as Ps,sep as Ls}from"node:path";function Dn(t,e){let n=Ps(e,t);if(n==="")return"";if(!(n===".."||n.startsWith(`..${Ls}`)||Ts(n)))return n}function Du(t,e={}){if(e.cwd!==void 0){let r=Dn(t,e.cwd);if(r!==void 0)return r===""?".":r}let n=Dn(t,e.home??$s());return n!==void 0?n===""?"~":`~/${n}`:t}export{Ot as a,xe as b,Bt as c,Jn as d,Xn as e,qt as f,Xs as g,Ee as h,Wt as i,Zs as j,Oe as k,di as l,Te as m,Pe as n,qe as o,Le as p,Si as q,Ai as r,ur as s,Mi as t,Bi as u,je as v,nu as w,$u as x,Tu as y,Du as z};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{access as b,readFile as l}from"node:fs/promises";import{homedir as x}from"node:os";import{join as n}from"node:path";var u="https://github.com/AtharvaN16/forge-terminal/releases/download",p=[{id:"boost",title:"Boost resolution",summary:"Sharpen, or boost resolution 2x or 4x, with a local AI model",version:"1.0.0",minMacos:14,assets:{arm64:{url:`${u}/ext-boost-v1.0.0/forge-ext-boost-1.0.0-arm64.tar.gz`,bytes:14866325,sha256:"7af24c92f95b1cd34618adde4a90926c91a8db4347d640be4921f1dc706a9a2e"}},licence:"Real-ESRGAN general-x4v3 (BSD-3-Clause), ONNX Runtime (MIT)"},{id:"remove-background",title:"Remove background",summary:"Cut the subject out of a photo, on this Mac",version:"1.0.0",minMacos:14,assets:{universal:{url:`${u}/ext-remove-background-v1.0.0/forge-ext-remove-background-1.0.0-universal.tar.gz`,bytes:32489,sha256:"9f6e055c0ce25f7504e10c7871e506a813bc75d6536396a675a8c075c4eb4686"}},licence:"Uses Apple Vision on-device; helper is MIT"}];function f(e){return p.find(t=>t.id===e)}function y(){let e=process.env.XDG_CONFIG_HOME,t=e!==void 0&&e.length>0?e:n(x(),".config");return n(t,"forge","extensions")}var v=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function C(e){if(f(e)!==void 0)try{let t=n(y(),e),r=(await l(n(t,"current"),"utf8")).trim();if(!v.test(r))return;let o=n(t,r),i=JSON.parse(await l(n(o,"manifest.json"),"utf8"));if(typeof i!="object"||i===null)return;let{id:m,version:g,entry:s,kind:a,files:d}=i;if(m!==e||g!==r||a!=="node"&&a!=="exec"||typeof s!="string"||typeof d!="object"||d===null||!(s in d))return;let c=n(o,s);return c.startsWith(`${o}/`)?(await b(c),{id:e,version:r,dir:o,entry:c,kind:a}):void 0}catch{return}}export{p as a,f as b,y as c,v as d,C as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as n,d as f,e as u}from"./chunk-EOYBXOCV.js";import{F as o}from"./chunk-DRBA23IQ.js";var d=["output","theme","quality"];async function c(r){if(r.action==="path")return{stdout:[n()],exitCode:0,config:{path:n()},warnings:[]};if(r.action==="list"){let{prefs:t,warning:i}=await f(),s=[`output ${t.defaultOutput}`,`theme ${t.theme??"not set"}`,`quality ${t.quality}`,"",n()];return i!==void 0&&s.unshift(`\u26A0 ${i}`,""),{stdout:s,exitCode:0,config:{output:t.defaultOutput,theme:t.theme??null,quality:t.quality,path:n()},warnings:i===void 0?[]:[{code:"config-unreadable",message:i}]}}let{key:a,value:e}=r;if(a==="theme"){if(e!=="dark"&&e!=="light")throw o(`Theme must be dark or light, not ${e}.`);return await u({theme:e}),{stdout:[`theme is now ${e}`],exitCode:0,config:{theme:e},warnings:[]}}if(a==="quality"){let t=Number(e);if(!Number.isInteger(t)||t<1||t>100)throw o(`Quality must be a whole number between 1 and 100, not ${e}.`);return await u({quality:t}),{stdout:[`quality is now ${t}`],exitCode:0,config:{quality:t},warnings:[]}}if(e.trim().length===0)throw o("Output must be a folder path.");return await u({defaultOutput:e}),{stdout:[`output is now ${e}`],exitCode:0,config:{output:e},warnings:[]}}export{d as a,c as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a}from"./chunk-J7FLFHQJ.js";import{basename as n,dirname as d}from"node:path";var i={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless"},webp:{id:"webp",label:"WebP",extensions:[".webp"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smaller, modern",defaultQuality:80},avif:{id:"avif",label:"AVIF",extensions:[".avif"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},gif:{id:"gif",label:"GIF",extensions:[".gif"],hasAlpha:!0,animatable:!0,lossy:!1,hint:"animation"},tiff:{id:"tiff",label:"TIFF",extensions:[".tif",".tiff"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"archival"},pdf:{id:"pdf",label:"PDF",extensions:[".pdf"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"document"},docx:{id:"docx",label:"DOCX",extensions:[".docx"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"Word document"},doc:{id:"doc",label:"DOC",extensions:[".doc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"legacy Word"}},h=Object.keys(i);function g(e){return i[e.toLowerCase()]}function f(e){let t=i[e].extensions[0];if(!t)throw new Error(`format ${e} declares no extensions`);return t}var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function u(e){return e instanceof o}function y(e){return new o({code:"file-not-found",title:"File not found",detail:`${n(e)} could not be found.`,short:`${n(e)} could not be found.`,hint:"Check the filename and try again."})}function $(e){return new o({code:"not-a-file",title:"Not a file",detail:`${n(e)} is not a file.`,short:`${n(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function F(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${n(e)} could not be read.`,short:`${n(e)} could not be read.`,hint:"Check the file permissions and try again."})}function E(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${n(e)} could not be found: part of its path is not a directory.`,short:`part of ${n(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function v(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${n(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${n(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function k(e){return new o({code:"path-too-long",title:"Path too long",detail:`${n(e)}'s path is too long for the filesystem to resolve.`,short:`${n(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function C(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${n(e)} could not be checked.`,short:`${n(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function I(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${n(e)} is ${t}, which Forge cannot read.`,short:`${n(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function T(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${n(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function S(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${n(e)} has no visible pixels.`})}function H(e){return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${n(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function P(e,t){let r=n(e.path);if(t!==void 0&&t!==e.format){let s=i[t].label;return i[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${r} \u2192 ${s} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${s} is lossless \u2014 there is no quality to trade away, so ${r} cannot be made to fit as ${s}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let s=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:s>0?`${r}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${r} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${r} is ${i[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${r} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${r} is ${i[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function D(e){let t=n(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${i[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function A(e,t,r){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:r??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:r??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function j(e,t,r){return new o({code:"target-unreachable",title:"Cannot get that small",detail:`${n(e.path)} is ${a(r)} even at the lowest quality, which is still over ${a(t)}.`,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function O(e,t,r){return new o({code:"unsupported-target",title:`Can't convert ${n(e.path)} to ${t}`,detail:`${n(e.path)} is a ${i[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${r.join(", ")}`})}function N(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${n(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${n(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function R(e,t,r){return new o({code:"corrupt-source",title:`Damaged ${i[t].label}`,detail:`${n(e)} is a ${i[t].label} file, but its content could not be read.`,short:`${n(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:r})}function U(e,t={}){let r=n(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${r} is password-protected.`,short:`${r} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${r} --to jpeg --password-stdin`})}var l=e=>e==="convert"||e==="boost"||e==="remove-background";function M(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${n(e)} is already there.`,hint:l(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function z(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${n(e[0])} and ${n(e[1])} would both become ${n(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function W(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${n(e)} would write ${n(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function J(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${n(e)} is both the input and the output.`,hint:l(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:l(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function c(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${n(d(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var p=new Set(["EACCES","EPERM","EROFS"]);function L(e,t){if(u(t))return t;let r=t?.code;return r!==void 0&&p.has(r)?c(e,t):t}function _(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function B(e){return new o({code:"empty-directory",title:"No images found",detail:`${n(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function G(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function q(e,t,r){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${r} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function Q(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function V(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function X(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function Y(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function K(e,t){return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this Mac: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function Z(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function ee(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function te(e,t,r){let s=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${s}.`,hint:r==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:r==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function oe(e){return new o({code:"no-subject",title:"No subject found",detail:`${n(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function ne(e,t,r){return r===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${n(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${n(e)} is too large to boost that far; ${t}x is the most it can take.`:`${n(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function re(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${n(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function ie(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function se(e,t={}){let r=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&r.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&r.push("",` ${e.cause.stack??e.cause.message}`),r}export{i as a,g as b,f as c,u as d,y as e,$ as f,F as g,E as h,v as i,k as j,C as k,I as l,T as m,S as n,H as o,P as p,D as q,A as r,j as s,O as t,N as u,R as v,U as w,M as x,z as y,W as z,J as A,c as B,L as C,_ as D,B as E,G as F,q as G,Q as H,V as I,X as J,Y as K,K as L,Z as M,ee as N,te as O,oe as P,ne as Q,re as R,ie as S,se as T};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{mkdir as g,readFile as d,rename as p,unlink as h,writeFile as m}from"node:fs/promises";import{homedir as o}from"node:os";import{dirname as y,join as f}from"node:path";var u={defaultOutput:"~/Desktop",quality:80};function c(){let e=process.env.XDG_CONFIG_HOME,t=e!==void 0&&e.length>0?e:f(o(),".config");return f(t,"forge","config.json")}function E(e){return e==="~"?o():e.startsWith("~/")?f(o(),e.slice(2)):e}function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){let t={...u},r=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:r.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:r.push("defaultOutput")),e.quality!==void 0){let n=e.quality;typeof n=="number"&&Number.isInteger(n)&&n>=1&&n<=100?t.quality=n:r.push("quality")}return{prefs:t,rejected:r}}async function P(){let e;try{e=await d(c(),"utf8")}catch{return}try{let t=JSON.parse(e);return l(t)?t:void 0}catch{return}}async function N(){let e=c(),t;try{t=await d(e,"utf8")}catch(s){return s.code==="ENOENT"?{prefs:u}:{prefs:u,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let r;try{r=JSON.parse(t)}catch{return{prefs:u,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!l(r))return{prefs:u,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:n,rejected:i}=O(r);return i.length===0?{prefs:n}:{prefs:n,warning:`Ignored invalid config ${i.length===1?"setting":"settings"}: ${i.join(", ")}.`}}async function j(e){let t=c();await g(y(t),{recursive:!0});let n={...await P()??{}};for(let[s,a]of Object.entries(e))a!==void 0&&(n[s]=a);let i=`${t}.${process.pid}.tmp`;try{await m(i,`${JSON.stringify(n,null,2)}
|
|
4
|
+
`,"utf8"),await p(i,t)}catch(s){throw await h(i).catch(()=>{}),s}}export{u as a,c as b,E as c,N as d,j as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{F as u,a as s}from"./chunk-DRBA23IQ.js";function d(e){if(s[e].hasAlpha)return;let t=Object.keys(s).filter(r=>s[r].hasAlpha&&r!=="heic").join(", ");return u(`${s[e].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${t}.`)}var a=16384,i=1e8;function f(e,t,r){let n=Math.max(e,t)*r;if(n>a)return{side:n};let o=e*r*t*r;if(o>i)return{megapixels:Math.round(o/1e6)}}function c(e){switch(e.op){case"convert":return e.target===e.sources[0].format?"compressed":"converted";case"merge":return"merged";case"split":return"split";case"extract":return"extracted";case"delete":return"deleted from";case"rotate":return"rotated";case"boost":return e.scale===1?"sharpened":"boosted";case"remove-background":return"cut out";default:{let t=e;throw new Error(`describeResult has no verb for ${JSON.stringify(t)}`)}}}function l(e){let{job:t}=e,r=t.sources.map(o=>({path:o.path,bytes:o.bytes})),n=r.length===1&&t.outputs.length===1?r[0]:void 0;return{verb:c(t),sources:r,outputs:[...t.outputs],outputBytes:e.outputBytes,...n?{size:{from:n.bytes,to:e.outputBytes}}:{},warnings:e.warnings}}export{d as a,a as b,f as c,l as d};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as C,c as I,d as X,e as Z,f as $,g as _,h as ee,i as R,k,l as te,m as re,n as oe,q as se,r as ne,s as ae,t as ue,u as ie,w as x,y as m,z as P}from"./chunk-4YHKTP7I.js";import{f as U}from"./chunk-L2WK7CJG.js";import{c as L,d as V,e as H,f as Y,g as K,h as Q}from"./chunk-VB665HTV.js";import{a as G}from"./chunk-FQV57RMH.js";import{a as l}from"./chunk-V4GHQGQM.js";import{F as D,G as W,J as q,T as z,a as v,d as w,p as M,r as O,t as A,w as E}from"./chunk-DRBA23IQ.js";import{a as f,b as T}from"./chunk-J7FLFHQJ.js";import{readFile as ke}from"node:fs/promises";import{basename as Fe,dirname as xe,resolve as Se}from"node:path";async function pe(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=I(o);if(!s.includes(e.target)){t.push({path:o.path,error:A(o,e.target,s)});continue}let a=R({sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)});r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Pe}from"node:path";function ve(e,r=new Set){let t={path:Pe(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:I(e).filter(a=>!o||$(a)),actions:ue([e],r).filter(a=>!o||a.id===k.id).map(a=>a.id)};return e.kind==="image"?{...t,width:e.width,height:e.height,...s}:{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function ce(e){let r=await m(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-2VX7K7W6.js"),o=await t();return{probes:r.sources.map(s=>ve(s,o)),failures:r.failures}}import{basename as F,dirname as Ie}from"node:path";var S=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function de(e,r){let t=P(Ie(e),S(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function fe(e,r){let{pct:t,direction:o}=T(e,r);return o==="same"?"same size":`${t}% ${o}`}function le(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let n=[`\u2713 ${F(o.path)} \u2192 ${s.length} files${de(s[0],r)}`,` ${s.map(u=>F(u)).join(", ")}`,` ${f(o.bytes)} \u2192 ${f(t.outputBytes)} total`];for(let u of t.warnings)n.push("",`\u26A0 ${u.message}`);return n}let a=[`\u2713 ${F(o.path)} \u2192 ${P(s[0],S(r))}`,` ${f(o.bytes)} \u2192 ${f(t.outputBytes)} \xB7 ${fe(o.bytes,t.outputBytes)}`];for(let n of t.warnings)a.push("",`\u26A0 ${n.message}`);return a}function me(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${f(e.inputBytes)} \u2192 ${f(e.outputBytes)} \xB7 ${fe(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let a of s.job.outputs)t.push(` ${P(a,S(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ge(e,r={}){let t=e.results.flatMap(i=>i.job.outputs),o=t.map(i=>F(i)).join(", "),s=t.length===1?"file":"files",a=t[0]===void 0?"":de(t[0],r),n=[`\u2713 ${t.length} ${s} \xB7 ${o}${a}`],u=e.results.flatMap(i=>i.warnings);for(let i of u)n.push("",`\u26A0 ${i.message}`);return n}function j(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...z(o.error,{debug:r.debug}),"");return t}function he(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let a=v[s],n=r.has(s)?"read and write":"read only";t.push(` ${a.label.padEnd(6)} ${a.extensions.join(" ").padEnd(12)} ${n}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>v[s].label);if(o.length>0){let s=o.join(", "),[a,n]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${a} read only because Forge cannot yet write ${n}.`)}return t}function ye(e,r={}){let t=[v[e.format].label,f(e.bytes)];return e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,S(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as be}from"node:readline";import{PassThrough as $e}from"node:stream";function Re(e){return new Promise(r=>{let t=be({input:e,terminal:!1}),o=!1,s=a=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(a.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function we(e){if(e.stdin)return Re(process.stdin);if(!process.stdin.isTTY)return;let r=new $e,t=be({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
|
|
4
|
+
`),t.close()}}function J(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function je(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(n=>n.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw D("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:se(o)};if(s.mode==="every-n")return{cuts:ne(o,s.n)};let a=Math.max(o-1,0);for(let n of s.after)if(!Number.isInteger(n)||n<1||n>a)throw W(String(n),`"${n}" is outside 1 and ${a} \u2014 ${t?Fe(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(n=>n-1)}}function Be(e,r){let t;return()=>r?(t??=we({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Oe(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:E(e.path)}};let u;try{u=await U(await ke(e.path),s)}catch{return{failure:{path:e.path,error:E(e.path,{attempted:!0})}}}u.destroy()}let a;try{a=k.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(u){if(!w(u))throw u;return{failure:{path:e.path,error:u}}}let n=a[0];if(n?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(n.options.password=s),{job:n}}function N(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var y=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function Ee(e){let r=await m(e.inputs,{recursive:!1});if(r.sources.length===0)return y("pageop",r.failures);let t=ae.find(n=>n.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let n=ie(t,r.sources)??"not available for these files";return y("pageop",[...r.failures,{path:o,error:O(e.action,n)}])}let s;try{s=t.plan(r.sources,je(e,r.sources))}catch(n){if(!w(n))throw n;return y("pageop",[...r.failures,{path:o,error:n}])}let a=await x(s,{force:e.force});return{kind:"pageop",results:a.results,failures:[...r.failures,...a.refusals,...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Ce(e,r){let t=await m(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let u of t.sources){if(!C.appliesTo([u])){s.push({path:u.path,error:M(u)});continue}let i=e.output!==void 0&&!ee(e.output)?Se(e.output):void 0,g=e.output===void 0||i!==void 0?xe(u.path):xe(R({sourcePath:u.path,target:u.format,output:e.output,sourceRoot:t.roots.get(u.path)})),[p]=C.plan([u],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},destination:g});p?.op==="convert"&&(i!==void 0&&(p.outputs=[i]),e.dpi!==void 0&&(p.options.dpi=e.dpi),o.push(p))}let a=o.length>1;a&&r.onProgress?.({completed:0,total:o.length});let n=await x(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:N(r,a)});return{kind:"compress",results:n.results,failures:[...t.failures,...s,...n.refusals,...n.unreachable.map(u=>({path:u.job.sources[0].path,error:u.error})),...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Je(e,r){let t=e.kind,o=e.op==="remove-background"?G(e.target):void 0;if(o)return y(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-XY2345OS.js");if(!await s(e.op))return y(t,[{path:"",error:q(e.op)}]);let a=await m(e.inputs,{recursive:e.recursive}),n=e.op==="boost"?re:oe,u=[],i=[];for(let d of a.sources){if(!n.appliesTo([d])){i.push({path:d.path,error:O(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let b=te(d,e.target);if(b){i.push({path:d.path,error:b});continue}u.push(...n.plan([d],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let g=u.length>1;g&&r.onProgress?.({completed:0,total:u.length});let p=await x(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:N(r,g)});return{kind:t,results:p.results,failures:[...a.failures,...i,...p.refusals,...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ne(e,r){let t=await m(e.inputs,{recursive:e.recursive}),o=c=>c.kind==="document"&&c.format==="pdf",s=$(e.target),a=s?t.sources.filter(o):[],n=s?t.sources.filter(c=>!o(c)):t.sources,u=[],i=[],g=Be(e.passwordStdin??!1,r.interactive??!0);for(let c of a){let B=await Oe(c,e,g,t.roots.get(c.path));"failure"in B?i.push(B.failure):u.push(B.job)}let p=await pe({resolved:{sources:n,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),d=[...p.jobs,...u],b=d.length>1;b&&r.onProgress?.({completed:0,total:d.length});let h=await x(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:N(r,b)});return{kind:"convert",results:h.results,failures:[...t.failures,...i,...p.failures,...h.refusals,...h.unreachable.map(c=>({path:c.job.sources[0].path,error:c.error})),...h.failures],inputBytes:h.inputBytes,outputBytes:h.outputBytes}}async function Te(e,r={}){try{return e.kind==="pageop"?await Ee(e):e.kind==="extension-op"?await Je(e,r):e.kind==="compress"?await Ce(e,r):await Ne(e,r)}catch(t){if(!w(t))throw t;return y(e.kind,[{path:"",error:t}])}}function Me(e,r){let t=J(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(L(l,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ge(e):e.results.length===1?le(e):me(e);return{exitCode:t,stdout:o,stderr:j(e.failures,{debug:r.debug})}}function Ae(e,r){let t=[{path:"",error:e}],o=J(t);return r.json?{exitCode:o,stdout:[JSON.stringify(V(l,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:j(t,{debug:r.debug})}}async function De(e,r){let{runConfig:t}=await import("./config-command-UXJY623L.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(K(l,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function It(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await De(e,t);if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-6WZV2AES.js"),a=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(Q(l,a.data))]:a.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(H(l,_()))],stderr:[]}:{exitCode:0,stdout:he(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:a}=await ce(e.inputs),n=J(a);return t?{exitCode:n,stdout:[JSON.stringify(Y(l,{probes:s,failures:a}))],stderr:[]}:{exitCode:n,stdout:s.flatMap((u,i)=>[...i>0?[""]:[],...ye(u)]),stderr:j(a,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:a}=await import("./colour-QV2C3R7R.js"),n={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,n):await a(e,n)}return e.kind==="shell"?{exitCode:0,stdout:[],stderr:[]}:Me(await Te(e,r),{json:t,debug:o})}catch(s){if(!w(s))throw s;return Ae(s,{json:t,debug:o})}}export{ce as a,J as b,Te as c,Me as d,It as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
function o(n){let[e,r]=n>=1e9?[n/1e9,"GB"]:n>=1e6?[n/1e6,"MB"]:n>=1e3?[n/1e3,"KB"]:[n,"B"];return r==="B"?`${Math.round(e)} B`:`${e>=100?Math.round(e).toString():(Math.round(e*10)/10).toString()} ${r}`}function c(n,e){if(n===e)return{pct:0,direction:"same"};if(n===0)return{pct:0,direction:"larger"};let r=(n-e)/n*100;return{pct:Math.round(Math.abs(r)*10)/10,direction:r>0?"smaller":"larger"}}var i={b:1,kb:1e3,mb:1e6,gb:1e9},u={b:"B",kb:"KB",mb:"MB",gb:"GB"};function s(n){if(d(n)===void 0)return;let e=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(n);if(e)return`${Number(e[1])} ${u[(e[2]??"b").toLowerCase()]}`}function d(n){let e=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(n);if(!e)return;let r=Number(e[1]);if(!Number.isFinite(r)||r<=0)return;let t=i[(e[2]??"b").toLowerCase()];if(t!==void 0)return Math.round(r*t)}export{o as a,c as b,s as c,d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as me}from"./chunk-FQV57RMH.js";import{B as pe,C as D,D as fe,G as R,H as C,J as de,Q as ue,R as S,a as l,d as E,e as te,f as re,g as M,h as oe,i as ne,j as ae,k as ie,l as se,o as T,u as ce,v as _,w as v}from"./chunk-DRBA23IQ.js";import{readFile as It,rm as Dt}from"node:fs/promises";import{randomBytes as Ge}from"node:crypto";import{constants as Ue}from"node:fs";import{access as Ke,mkdir as Ve,rename as Ze,rm as Qe,writeFile as Ye}from"node:fs/promises";import{dirname as Xe}from"node:path";async function $(e){let t=Xe(e);try{await Ve(t,{recursive:!0})}catch(r){let o=D(e,r);throw o===r?fe(e,r):o}try{await Ke(t,Ue.W_OK)}catch(r){throw pe(e,r)}}async function m(e,t){await $(e);let r=`${e}.${Ge(6).toString("hex")}.tmp`;try{return await Ye(r,t),await Ze(r,e),t.byteLength}catch(o){throw await Qe(r,{force:!0}).catch(()=>{}),D(e,o)}}import{randomBytes as pt}from"node:crypto";import{constants as ft}from"node:fs";import{access as dt,readFile as Ee,rename as ut,rm as mt,stat as gt,writeFile as lt}from"node:fs/promises";import{basename as ve,dirname as wt,join as ht}from"node:path";import{execFile as je}from"node:child_process";import{randomBytes as et}from"node:crypto";import{open as tt,rm as rt}from"node:fs/promises";import{tmpdir as ot}from"node:os";import{join as nt}from"node:path";import{promisify as at}from"node:util";var H=at(je),A;async function k(){if(A!==void 0)return A;try{await H("/usr/bin/sips",["--help"],{timeout:5e3}),A=!0}catch{A=!1}return A}async function q(e){let t=nt(ot(),`forge-heic-${et(8).toString("hex")}.png`),r=async()=>{await rt(t,{force:!0}).catch(()=>{})};try{return await H("/usr/bin/sips",["-s","format","png",e,"--out",t],{timeout:12e4}),{path:t,cleanup:r}}catch(o){throw await r(),o}}var it=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),st=new Set(["avif","avis"]);async function ge(e){let t;try{t=await tt(e,"r")}catch{return!1}try{let r=Buffer.alloc(64),{bytesRead:o}=await t.read(r,0,64,0);if(o<12||r.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(r.readUInt32BE(0),o),a=[];for(let i=8;i+4<=n;i+=4)a.push(r.toString("latin1",i,i+4));return a.some(i=>st.has(i))?!1:a.some(i=>it.has(i))}catch{return!1}finally{await t.close().catch(()=>{})}}async function le(e){let{stdout:t}=await H("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4});return{width:Number(/pixelWidth:\s*(\d+)/.exec(t)?.[1]??0),height:Number(/pixelHeight:\s*(\d+)/.exec(t)?.[1]??0),hasAlpha:/hasAlpha:\s*yes/i.test(t)}}function w(e){let t;return()=>(t??=e(),t)}var h=w(async()=>(await import("sharp")).default),y=w(()=>import("./es-T2U7NBLD.js")),we=w(()=>import("@hyzyla/pdfium")),he=w(async()=>(await import("./lib-TPEJ5CJJ.js")).default),ye=w(async()=>(await import("./word-OGQ2KZAJ.js")).default),xe=w(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Pe=w(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function ct(){let e=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!e?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:e.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",e)}}var be=w(ct);var yt=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),xt=new Set(["jpeg","png","webp","avif","gif","tiff"]),Pt={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function bt(e,t){if(t.format==="heif")return t.compression==="av1"?"avif":"heic";let r=Pt[t.format??""];if(!r)throw se(e,t.format??"an unknown format");return r}async function Et(e){let t;try{t=await gt(e)}catch(n){let a=n.code;throw a==="ENOENT"?te(e):a==="EACCES"||a==="EPERM"?M(e):a==="ENOTDIR"?oe(e):a==="ELOOP"?ne(e):a==="ENAMETOOLONG"?ae(e):ie(e,n)}if(!t.isFile())throw re(e);try{await dt(e,ft.R_OK)}catch{throw M(e)}if(await ge(e)){if(!await k())throw T(e);let n;try{n=await le(e)}catch(a){throw _(e,"heic",a)}if(n.width===0||n.height===0)throw _(e,"heic",void 0);return{kind:"image",path:e,format:"heic",width:n.width,height:n.height,bytes:t.size,hasAlpha:n.hasAlpha,frames:1}}let r=await h(),o;try{o=await r(e).metadata()}catch(n){throw ce(e,n)}return{kind:"image",path:e,format:bt(e,o),width:o.width??0,height:o.height??0,bytes:t.size,hasAlpha:o.hasAlpha??!1,frames:o.pages??1}}function P(e,t,r){let o=r??l[t].defaultQuality;switch(t){case"jpeg":return e.jpeg({quality:o,mozjpeg:!0});case"webp":return e.webp({quality:o});case"avif":return e.avif({quality:o});case"png":return e.png({compressionLevel:9});case"gif":return e.gif();case"tiff":return e.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this")}}async function z(e,t){let r=wt(t);await $(t);let o=ht(r,`.forge-tmp-${pt(6).toString("hex")}-${ve(t)}`);try{return await lt(o,e),await ut(o,t),e.length}catch(n){throw await mt(o,{force:!0}).catch(()=>{}),D(t,n)}}async function B(e,t,r,o,n){if(e.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&e.format==="heic"&&!await k())throw T(e.path);let a=n===void 0&&e.format==="heic"?await q(e.path):void 0,i=async()=>{await a?.cleanup()},c=(await h())(n??a?.path??e.path,o?{animated:!0}:{});return c=c.rotate(),e.hasAlpha&&!l[t].hasAlpha&&(c=c.flatten({background:r.background})),c=r.keepMetadata?c.keepMetadata():c.keepIccProfile(),{pipeline:c,cleanup:i}}async function Se(e,t){let r={background:"#ffffff",keepMetadata:!1},{pipeline:o,cleanup:n}=await B(e,"png",r,!1);try{await o.png({compressionLevel:1}).toFile(t)}finally{await n()}}async function zr(e,t,r){let{pipeline:o,cleanup:n}=await B(e,t,r,!1);try{return await P(o,t,r.quality).toBuffer()}finally{await n()}}async function vt(e,t){if(e.op!=="convert")throw new Error(`image engine cannot ${e.op}`);let r=e.sources[0],o=e.outputs[0];if(r.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=l[e.target],a=[];t({phase:"reading"});let i=r.frames>1,s=i&&n.animatable;i&&!n.animatable&&a.push({code:"animation-flattened",message:`${ve(r.path)} has ${r.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`}),t({phase:"decoding"});let{pipeline:c,cleanup:p}=await B(r,e.target,e.options,s);try{await $(o),t({phase:"encoding"});let f=await P(c,e.target,e.options.quality).toBuffer();t({phase:"writing"});let u=await z(f,o);return{job:e,outputBytes:u,warnings:a}}catch(f){throw E(f)?f:S(r.path,f)}finally{await p()}}async function St(e){if(e.format!=="heic")return Ee(e.path);if(!await k())throw T(e.path);let t=await q(e.path);try{return await Ee(t.path)}finally{await t.cleanup()}}async function Ft(e){if(e.op!=="convert"||!l[e.target].lossy)return;let t=e.sources[0];if(t.kind!=="image")return;let r=await St(t);return{ladder:[{}],measure:async o=>{let{pipeline:n}=await B(t,e.target,o,!1,r);return(await P(n,e.target,o.quality).toBuffer()).length}}}var Fe={id:"image",reads:yt,writes:xt,ops:new Set(["convert"]),probe:Et,run:vt,measurer:Ft};var Rt=new Set(["pdf"]),At=new Set(["jpeg","png"]),Tt=new Set(["convert"]),Ie;function $t(){return Ie??=we().then(e=>e.PDFiumLibrary.init()),Ie}async function De(e,t){return await(await $t()).loadDocument(e,t)}async function Re(e){let t=await De(e);try{let r=[];for(let o=0;o<t.getPageCount();o++)r.push(t.getPage(o).getText());return r}finally{t.destroy()}}var Ae={id:"pdfium",reads:Rt,writes:At,ops:Tt,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(e,t){if(e.op!=="convert")throw new Error(`pdfium cannot ${e.op}`);let r=e.sources[0];if(r.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(r.encrypted&&e.options.password===void 0)throw v(r.path);let o=e.options.dpi??150,n=e.options.pages??Array.from({length:r.pages},(s,c)=>c);if(n.length!==e.outputs.length)throw new Error(`pdfium was given ${n.length} pages but ${e.outputs.length} outputs`);for(let s of n)if(s<0||s>=r.pages)throw new Error(`pdfium was asked for page ${s}, but ${r.path} has ${r.pages} pages`);let a=await h(),i=await De(await It(r.path),e.options.password);try{let s=[],c=0;try{for(let[p,f]of n.entries()){let u=await i.getPage(f).render({scale:o/72,render:"bitmap",transparent:!0}),d=a(u.data,{raw:{width:u.width,height:u.height,channels:4}}).flatten({background:e.options.background}),g=await P(d,e.target,e.options.quality).toBuffer(),x=e.outputs[p];c+=await m(x,g),s.push(x),t({phase:"page",done:p+1,total:n.length})}}catch(p){throw await Promise.all(s.map(f=>Dt(f,{force:!0}))),p}return{job:e,outputBytes:c,warnings:[]}}finally{i.destroy()}}};function jr(e,t){let r=e.split(",").map(a=>a.trim()).filter(a=>a!=="");if(r.length===0)throw R(e,"That selects no pages.",t);let o=new Set,n=(a,i)=>{if(!Number.isInteger(a)||a<1||a>t)throw R(i,`"${i}" is outside 1 and ${t}.`,t);return a};for(let a of r){let i=a.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let s=n(Number(i[1]),a),c=i[2]===""?t:n(Number(i[2]),a);if(c<s)throw R(a,`"${a}" ends before it starts.`,t);for(let p=s;p<=c;p++)o.add(p-1);continue}if(!/^\d+$/.test(a))throw R(a,`"${a}" is not a page number.`,t);o.add(n(Number(a),a)-1)}return[...o].sort((a,i)=>a-i)}function Te(e){return[...new Set(e)].sort((t,r)=>t-r)}function eo(e){if(e.length===0)return"";let t=[...new Set(e)].sort((a,i)=>a-i),r=[],o=t[0],n=o;for(let a of t.slice(1)){if(a===n+1){n=a;continue}r.push(o===n?`${o+1}`:`${o+1}-${n+1}`),o=a,n=a}return r.push(o===n?`${o+1}`:`${o+1}-${n+1}`),r.join(", ")}function $e(e,t){let r=[...new Set(e)].sort((a,i)=>a-i).filter(a=>a>=0&&a<t-1),o=[],n=0;for(let a of r)o.push({from:n,to:a}),n=a+1;return o.push({from:n,to:t-1}),o}import{mkdtemp as kt,rm as Bt}from"node:fs/promises";import{tmpdir as Lt}from"node:os";import{basename as ke,join as L}from"node:path";var Le=(e,t,r)=>me(e,t,r)===void 0;function Be(e,t,r=Number.POSITIVE_INFINITY){return[4,2].find(o=>o<r&&Le(e,t,o))??0}async function Ot(e,t,r){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(r?.aborted)throw r.reason??new Error("aborted");let o=e.sources[0],n=e.outputs[0],a=e.op;if(e.op==="boost"&&!Le(o.width,o.height,e.scale))throw ue(o.path,Be(o.width,o.height),e.scale);let{installed:i,extensionsRoot:s}=await import("./paths-XY2345OS.js"),c=await i(a);if(!c)throw de(a);let{runExtension:p}=await import("./run-N3F4EM7E.js"),f=[];o.frames>1&&f.push({code:"animation-flattened",message:`${ke(o.path)} has ${o.frames} frames. Only the first frame was used.`});let u=await kt(L(Lt(),"forge-ext-"));try{t({phase:"decoding"});let d=L(u,"in.png"),g=L(u,"out.png");await Se(o,d);let x=e.op==="boost"?["--in",d,"--out",g,"--scale",String(e.scale),"--cache",L(s(),"boost","cache")]:[d,g];await p(c,x,{subject:o.path,what:`${Jt(e)} is running on ${ke(o.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),...e.op==="boost"?{maxScale:Be(o.width,o.height,e.scale)}:{},...r===void 0?{}:{signal:r}});let N=(await h())(g);l[e.target].hasAlpha||(N=N.flatten({background:e.options.background}));let qe=await P(N,e.target,e.options.quality).toBuffer();t({phase:"writing"});let ze=await z(qe,n);return{job:e,outputBytes:ze,warnings:f}}catch(d){throw E(d)?d:S(o.path,d)}finally{await Bt(u,{recursive:!0,force:!0}).catch(()=>{})}}function Jt(e){return e.op!=="boost"?"Remove background":e.scale===2||e.scale===4?`Boost resolution ${e.scale}\xD7`:"Sharpen"}var Oe={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Ot};import{readFile as O,rm as Je,stat as Wt}from"node:fs/promises";import{basename as Nt}from"node:path";var U=w(()=>import("./pdf-compress-IMRFBLZF.js")),Mt=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),_t=new Set(["pdf"]);async function F(e){return(await y()).PDFDocument.load(await O(e),{ignoreEncryption:!0})}async function Ct(e){let{surveyDocument:t}=await U(),r=await F(e),{size:o}=await Wt(e);return{kind:"document",path:e,format:"pdf",bytes:o,pages:r.getPageCount(),encrypted:r.isEncrypted,images:t(r)}}function I(e){for(let t of e)if(t.encrypted)throw v(t.path)}async function Ht(e,t,r){let o=await h(),n=t.format==="jpeg"||t.format==="png",a=n?(await o(r).metadata()).orientation:void 0;if(n&&(a===void 0||a===1))return t.format==="jpeg"?e.embedJpg(r):e.embedPng(r);if(t.format==="jpeg"){let i=await o(r).rotate().jpeg({quality:l.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await o(r).rotate().png().toBuffer())}async function qt(e,t){let r=e.sources[0];if(r.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let o=[];r.frames>1&&o.push({code:"animation-flattened",message:`${Nt(r.path)} has ${r.frames} frames, and ${l.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let n=await O(r.path);t({phase:"encoding"});let i=await(await y()).PDFDocument.create(),s=await Ht(i,r,n);i.addPage([s.width,s.height]).drawImage(s,{x:0,y:0,width:s.width,height:s.height}),t({phase:"writing"});let p=await m(e.outputs[0],await i.save());return{job:e,outputBytes:p,warnings:o}}async function zt(e,t){I(e.sources.filter(i=>i.kind==="document"));let o=await(await y()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let s=await F(i.path),c=await o.copyPages(s,s.getPageIndices());for(let p of c)o.addPage(p)}t({phase:"writing"});let n=await o.save(),a=await m(e.outputs[0],n);return{job:e,outputBytes:a,warnings:[]}}async function Gt(e,t){let r=e.sources[0];I([r]);let o=await y();t({phase:"reading"});let n=await F(r.path),a=$e(e.cuts,n.getPageCount()),i=[],s=0;try{for(let[c,p]of a.entries()){let f=await o.PDFDocument.create(),u=Array.from({length:p.to-p.from+1},(x,ee)=>p.from+ee),d=await f.copyPages(n,u);for(let x of d)f.addPage(x);let g=e.outputs[c];if(g===void 0)throw new Error(`split produced ${a.length} parts but was given ${e.outputs.length} outputs`);s+=await m(g,await f.save()),i.push(g),t({phase:"page",done:c+1,total:a.length})}}catch(c){throw await Promise.all(i.map(p=>Je(p,{force:!0}))),c}return{job:e,outputBytes:s,warnings:[]}}async function G(e,t){let o=await(await y()).PDFDocument.create(),n=await o.copyPages(e,t);for(let a of n)o.addPage(a);return o.save()}async function Ut(e,t){let r=e.sources[0];if(I([r]),e.pages.length===0)throw C("That extract selects no pages.");t({phase:"reading"});let o=await F(r.path),n=Te(e.pages),a=[],i=0;try{if(e.separate)for(let[s,c]of n.entries()){let p=e.outputs[s];i+=await m(p,await G(o,[c])),a.push(p),t({phase:"page",done:s+1,total:n.length})}else{t({phase:"writing"});let s=e.outputs[0];i=await m(s,await G(o,n)),a.push(s)}}catch(s){throw await Promise.all(a.map(c=>Je(c,{force:!0}))),s}return{job:e,outputBytes:i,warnings:[]}}async function Kt(e,t){let r=e.sources[0];I([r]),t({phase:"reading"});let o=await F(r.path),n=new Set(e.pages),a=o.getPageIndices().filter(s=>!n.has(s));if(a.length===0)throw C("That would delete every page.");t({phase:"writing"});let i=await m(e.outputs[0],await G(o,a));return{job:e,outputBytes:i,warnings:[]}}async function Vt(e,t){let r=e.sources[0];I([r]);let o=await y();t({phase:"reading"});let n=await F(r.path);for(let i of n.getPages()){let c=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(o.degrees(c))}t({phase:"writing"});let a=await m(e.outputs[0],await n.save());return{job:e,outputBytes:a,warnings:[]}}async function Zt(e,t){let r=e.sources[0];I([r]);let{compressPdf:o}=await U();t({phase:"reading"});let n=await O(r.path);t({phase:"encoding"});let{bytes:a,recompressed:i,skipped:s,fromDpi:c,toDpi:p}=await o(n,{quality:e.options.quality??60,dpi:e.options.dpi??150});t({phase:"writing"});let f=await m(e.outputs[0],a),u=g=>g===1?"":"s",d=[];return i===0&&s===0?d.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?d.push({code:"pdf-no-images",message:`None of its ${s} image${u(s)} could be re-encoded \u2014 they are not JPEG data.`}):s>0&&d.push({code:"pdf-images-skipped",message:`${i} image${u(i)} recompressed, ${s} skipped (not JPEG).`}),c!==void 0&&p!==void 0&&d.push({code:"pdf-downsampled",message:`Images reduced from ${c} to ${p} dpi. Pass --dpi ${c} to keep them.`}),{job:e,outputBytes:f,warnings:d}}async function Qt(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:r}=await U(),o=await O(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(n=>({dpi:n})),measure:async n=>(await r(o,{quality:n.quality??60,...n.dpi===void 0?{}:{dpi:n.dpi}})).bytes.byteLength}}var We={id:"pdf",measurer:Qt,reads:Mt,writes:_t,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Ct,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Zt(e,t):qt(e,t);case"merge":return zt(e,t);case"split":return Gt(e,t);case"extract":return Ut(e,t);case"delete":return Kt(e,t);case"rotate":return Vt(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as Yt}from"node:child_process";import{mkdtemp as Xt,readFile as Y,rm as jt}from"node:fs/promises";import{tmpdir as er}from"node:os";import{basename as tr,extname as rr,join as Ne}from"node:path";import{promisify as or}from"node:util";var Q=or(Yt),K=Buffer.from([208,207,17,224,161,177,26,225]);async function nr(e){if(e.length<K.length||!e.subarray(0,K.length).equals(K))return!1;let t=await Pe();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function ar(e){let t=await xe();try{let r=new t(e);if(!r.getEntry("word/document.xml"))return;let o=0,n=r.getEntry("docProps/app.xml");if(n){let a=/<Pages>(\d+)<\/Pages>/.exec(r.readAsText(n));a?.[1]&&(o=Number(a[1]))}return{pages:o}}catch{return}}async function ir(e){let t=await Y(e),r=await ar(t);if(r)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:r.pages,encrypted:!1};if(await nr(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}var Me="/Applications/LibreOffice.app/Contents/MacOS/soffice",sr=0;async function cr(){sr++;try{return await Q("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}try{return await Q(Me,["--version"],{timeout:5e3}),Me}catch{return}}var _e,pr=!1,fr;async function dr(){return pr?fr:(_e??=cr(),_e)}var X="\f";function J(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function ur(e){if(e.format==="docx"){let r=await he(),{value:o}=await r.extractRawText({path:e.path});return J(o)}if(e.format==="doc"){let r=await ye(),n=await new r().extract(e.path);return J(n.getBody())}return(await Re(await Y(e.path))).flatMap((r,o)=>o===0?J(r):[X,...J(r)])}var V=612,W=792,b=54,Z=11,Ce=14;async function mr(e){let{PDFDocument:t,StandardFonts:r}=await y(),o=await t.create(),n=await o.embedFont(r.Helvetica),a=V-b*2,i=o.addPage([V,W]),s=W-b,c=()=>{i=o.addPage([V,W]),s=W-b};for(let p of e){if(p===X){c();continue}let f="";for(let u of p.split(/\s+/).filter(Boolean)){let d=f?`${f} ${u}`:u;f&&n.widthOfTextAtSize(d,Z)>a?(s<b&&c(),i.drawText(f,{x:b,y:s,size:Z,font:n}),s-=Ce,f=u):f=d}f&&(s<b&&c(),i.drawText(f,{x:b,y:s,size:Z,font:n}),s-=Ce)}return o.save()}async function gr(e){let{Document:t,Packer:r,PageBreak:o,Paragraph:n}=await be(),a=e.map(s=>s===X?new n({children:[new o]}):new n(s)),i=new t({sections:[{children:a}]});return r.toBuffer(i)}var lr=new Set(["docx","doc","pdf"]),wr=new Set(["docx","pdf"]),hr=new Set(["convert"]),yr={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};async function xr(e,t,r){let o=await Xt(Ne(er(),"forge-word-"));try{await Q(e,[`-env:UserInstallation=file://${o}/profile`,"--headless","--convert-to",r,"--outdir",o,t],{timeout:12e4});let n=tr(t,rr(t));return await Y(Ne(o,`${n}.${r}`))}finally{await jt(o,{recursive:!0,force:!0})}}async function Pr(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let r=e.sources[0];if(r.kind!=="document")throw new Error("the word engine can only convert a document source");if(r.encrypted)throw v(r.path);t({phase:"reading"});let o=await dr();t({phase:"encoding"});let n=[],a;try{if(o!==void 0)a=await xr(o,r.path,e.target);else{let s=await ur(r);a=e.target==="pdf"?await mr(s):await gr(s),n.push(yr)}}catch(s){throw S(r.path,s)}t({phase:"writing"});let i=await m(e.outputs[0],a);return{job:e,outputBytes:i,warnings:n}}var He={id:"word",reads:lr,writes:wr,ops:hr,probe:ir,run:Pr};var j=[Fe,We,He,Oe,Ae];function Jo(e){if(e.op==="convert"){let t=e.sources[0].format;return j.find(r=>r.reads.has(t)&&r.writes.has(e.target))}return j.find(t=>t.ops.has(e.op))}async function Wo(e){let t;for(let r of j)try{return await r.probe(e)}catch(o){E(t)||(t=o)}throw t}export{k as a,q as b,ge as c,h as d,zr as e,De as f,Ae as g,jr as h,Te as i,eo as j,$e as k,j as l,Jo as m,Wo as n};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as I}from"./chunk-TMUK2DD3.js";var V=I(B=>{"use strict";var Ai=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function Di(e,i){return Object.prototype.hasOwnProperty.call(e,i)}B.assign=function(e){for(var i=Array.prototype.slice.call(arguments,1);i.length;){var t=i.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(var a in t)Di(t,a)&&(e[a]=t[a])}}return e};B.shrinkBuf=function(e,i){return e.length===i?e:e.subarray?e.subarray(0,i):(e.length=i,e)};var Zi={arraySet:function(e,i,t,a,r){if(i.subarray&&e.subarray){e.set(i.subarray(t,t+a),r);return}for(var n=0;n<a;n++)e[r+n]=i[t+n]},flattenChunks:function(e){var i,t,a,r,n,_;for(a=0,i=0,t=e.length;i<t;i++)a+=e[i].length;for(_=new Uint8Array(a),r=0,i=0,t=e.length;i<t;i++)n=e[i],_.set(n,r),r+=n.length;return _}},Ri={arraySet:function(e,i,t,a,r){for(var n=0;n<a;n++)e[r+n]=i[t+n]},flattenChunks:function(e){return[].concat.apply([],e)}};B.setTyped=function(e){e?(B.Buf8=Uint8Array,B.Buf16=Uint16Array,B.Buf32=Int32Array,B.assign(B,Zi)):(B.Buf8=Array,B.Buf16=Array,B.Buf32=Array,B.assign(B,Ri))};B.setTyped(Ai)});var oa=I(be=>{"use strict";var Ni=V(),Oi=4,Kt=0,Pt=1,Ii=2;function se(e){for(var i=e.length;--i>=0;)e[i]=0}var Bi=0,Wt=1,Ci=2,Li=3,Fi=258,ut=29,De=256,ze=De+1+ut,ce=30,vt=19,Vt=2*ze+1,fe=15,ft=16,Mi=7,ct=256,Jt=16,Qt=17,$t=18,ot=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Ye=[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],Hi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ea=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Ui=512,J=new Array((ze+2)*2);se(J);var ye=new Array(ce*2);se(ye);var me=new Array(Ui);se(me);var Te=new Array(Fi-Li+1);se(Te);var st=new Array(ut);se(st);var Xe=new Array(ce);se(Xe);function lt(e,i,t,a,r){this.static_tree=e,this.extra_bits=i,this.extra_base=t,this.elems=a,this.max_length=r,this.has_stree=e&&e.length}var ta,aa,ia;function _t(e,i){this.dyn_tree=e,this.max_code=0,this.stat_desc=i}function ra(e){return e<256?me[e]:me[256+(e>>>7)]}function Ae(e,i){e.pending_buf[e.pending++]=i&255,e.pending_buf[e.pending++]=i>>>8&255}function L(e,i,t){e.bi_valid>ft-t?(e.bi_buf|=i<<e.bi_valid&65535,Ae(e,e.bi_buf),e.bi_buf=i>>ft-e.bi_valid,e.bi_valid+=t-ft):(e.bi_buf|=i<<e.bi_valid&65535,e.bi_valid+=t)}function X(e,i,t){L(e,t[i*2],t[i*2+1])}function na(e,i){var t=0;do t|=e&1,e>>>=1,t<<=1;while(--i>0);return t>>>1}function Ki(e){e.bi_valid===16?(Ae(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function Pi(e,i){var t=i.dyn_tree,a=i.max_code,r=i.stat_desc.static_tree,n=i.stat_desc.has_stree,_=i.stat_desc.extra_bits,f=i.stat_desc.extra_base,d=i.stat_desc.max_length,l,h,x,u,o,s,c=0;for(u=0;u<=fe;u++)e.bl_count[u]=0;for(t[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<Vt;l++)h=e.heap[l],u=t[t[h*2+1]*2+1]+1,u>d&&(u=d,c++),t[h*2+1]=u,!(h>a)&&(e.bl_count[u]++,o=0,h>=f&&(o=_[h-f]),s=t[h*2],e.opt_len+=s*(u+o),n&&(e.static_len+=s*(r[h*2+1]+o)));if(c!==0){do{for(u=d-1;e.bl_count[u]===0;)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[d]--,c-=2}while(c>0);for(u=d;u!==0;u--)for(h=e.bl_count[u];h!==0;)x=e.heap[--l],!(x>a)&&(t[x*2+1]!==u&&(e.opt_len+=(u-t[x*2+1])*t[x*2],t[x*2+1]=u),h--)}}function fa(e,i,t){var a=new Array(fe+1),r=0,n,_;for(n=1;n<=fe;n++)a[n]=r=r+t[n-1]<<1;for(_=0;_<=i;_++){var f=e[_*2+1];f!==0&&(e[_*2]=na(a[f]++,f))}}function Yi(){var e,i,t,a,r,n=new Array(fe+1);for(t=0,a=0;a<ut-1;a++)for(st[a]=t,e=0;e<1<<ot[a];e++)Te[t++]=a;for(Te[t-1]=a,r=0,a=0;a<16;a++)for(Xe[a]=r,e=0;e<1<<Ye[a];e++)me[r++]=a;for(r>>=7;a<ce;a++)for(Xe[a]=r<<7,e=0;e<1<<Ye[a]-7;e++)me[256+r++]=a;for(i=0;i<=fe;i++)n[i]=0;for(e=0;e<=143;)J[e*2+1]=8,e++,n[8]++;for(;e<=255;)J[e*2+1]=9,e++,n[9]++;for(;e<=279;)J[e*2+1]=7,e++,n[7]++;for(;e<=287;)J[e*2+1]=8,e++,n[8]++;for(fa(J,ze+1,n),e=0;e<ce;e++)ye[e*2+1]=5,ye[e*2]=na(e,5);ta=new lt(J,ot,De+1,ze,fe),aa=new lt(ye,Ye,0,ce,fe),ia=new lt(new Array(0),Hi,0,vt,Mi)}function la(e){var i;for(i=0;i<ze;i++)e.dyn_ltree[i*2]=0;for(i=0;i<ce;i++)e.dyn_dtree[i*2]=0;for(i=0;i<vt;i++)e.bl_tree[i*2]=0;e.dyn_ltree[ct*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function _a(e){e.bi_valid>8?Ae(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Xi(e,i,t,a){_a(e),a&&(Ae(e,t),Ae(e,~t)),Ni.arraySet(e.pending_buf,e.window,i,t,e.pending),e.pending+=t}function Yt(e,i,t,a){var r=i*2,n=t*2;return e[r]<e[n]||e[r]===e[n]&&a[i]<=a[t]}function ht(e,i,t){for(var a=e.heap[t],r=t<<1;r<=e.heap_len&&(r<e.heap_len&&Yt(i,e.heap[r+1],e.heap[r],e.depth)&&r++,!Yt(i,a,e.heap[r],e.depth));)e.heap[t]=e.heap[r],t=r,r<<=1;e.heap[t]=a}function Xt(e,i,t){var a,r,n=0,_,f;if(e.last_lit!==0)do a=e.pending_buf[e.d_buf+n*2]<<8|e.pending_buf[e.d_buf+n*2+1],r=e.pending_buf[e.l_buf+n],n++,a===0?X(e,r,i):(_=Te[r],X(e,_+De+1,i),f=ot[_],f!==0&&(r-=st[_],L(e,r,f)),a--,_=ra(a),X(e,_,t),f=Ye[_],f!==0&&(a-=Xe[_],L(e,a,f)));while(n<e.last_lit);X(e,ct,i)}function dt(e,i){var t=i.dyn_tree,a=i.stat_desc.static_tree,r=i.stat_desc.has_stree,n=i.stat_desc.elems,_,f,d=-1,l;for(e.heap_len=0,e.heap_max=Vt,_=0;_<n;_++)t[_*2]!==0?(e.heap[++e.heap_len]=d=_,e.depth[_]=0):t[_*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=d<2?++d:0,t[l*2]=1,e.depth[l]=0,e.opt_len--,r&&(e.static_len-=a[l*2+1]);for(i.max_code=d,_=e.heap_len>>1;_>=1;_--)ht(e,t,_);l=n;do _=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ht(e,t,1),f=e.heap[1],e.heap[--e.heap_max]=_,e.heap[--e.heap_max]=f,t[l*2]=t[_*2]+t[f*2],e.depth[l]=(e.depth[_]>=e.depth[f]?e.depth[_]:e.depth[f])+1,t[_*2+1]=t[f*2+1]=l,e.heap[1]=l++,ht(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Pi(e,i),fa(t,d,e.bl_count)}function qt(e,i,t){var a,r=-1,n,_=i[1],f=0,d=7,l=4;for(_===0&&(d=138,l=3),i[(t+1)*2+1]=65535,a=0;a<=t;a++)n=_,_=i[(a+1)*2+1],!(++f<d&&n===_)&&(f<l?e.bl_tree[n*2]+=f:n!==0?(n!==r&&e.bl_tree[n*2]++,e.bl_tree[Jt*2]++):f<=10?e.bl_tree[Qt*2]++:e.bl_tree[$t*2]++,f=0,r=n,_===0?(d=138,l=3):n===_?(d=6,l=3):(d=7,l=4))}function Gt(e,i,t){var a,r=-1,n,_=i[1],f=0,d=7,l=4;for(_===0&&(d=138,l=3),a=0;a<=t;a++)if(n=_,_=i[(a+1)*2+1],!(++f<d&&n===_)){if(f<l)do X(e,n,e.bl_tree);while(--f!==0);else n!==0?(n!==r&&(X(e,n,e.bl_tree),f--),X(e,Jt,e.bl_tree),L(e,f-3,2)):f<=10?(X(e,Qt,e.bl_tree),L(e,f-3,3)):(X(e,$t,e.bl_tree),L(e,f-11,7));f=0,r=n,_===0?(d=138,l=3):n===_?(d=6,l=3):(d=7,l=4)}}function qi(e){var i;for(qt(e,e.dyn_ltree,e.l_desc.max_code),qt(e,e.dyn_dtree,e.d_desc.max_code),dt(e,e.bl_desc),i=vt-1;i>=3&&e.bl_tree[ea[i]*2+1]===0;i--);return e.opt_len+=3*(i+1)+5+5+4,i}function Gi(e,i,t,a){var r;for(L(e,i-257,5),L(e,t-1,5),L(e,a-4,4),r=0;r<a;r++)L(e,e.bl_tree[ea[r]*2+1],3);Gt(e,e.dyn_ltree,i-1),Gt(e,e.dyn_dtree,t-1)}function ji(e){var i=4093624447,t;for(t=0;t<=31;t++,i>>>=1)if(i&1&&e.dyn_ltree[t*2]!==0)return Kt;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return Pt;for(t=32;t<De;t++)if(e.dyn_ltree[t*2]!==0)return Pt;return Kt}var jt=!1;function Wi(e){jt||(Yi(),jt=!0),e.l_desc=new _t(e.dyn_ltree,ta),e.d_desc=new _t(e.dyn_dtree,aa),e.bl_desc=new _t(e.bl_tree,ia),e.bi_buf=0,e.bi_valid=0,la(e)}function ha(e,i,t,a){L(e,(Bi<<1)+(a?1:0),3),Xi(e,i,t,!0)}function Vi(e){L(e,Wt<<1,3),X(e,ct,J),Ki(e)}function Ji(e,i,t,a){var r,n,_=0;e.level>0?(e.strm.data_type===Ii&&(e.strm.data_type=ji(e)),dt(e,e.l_desc),dt(e,e.d_desc),_=qi(e),r=e.opt_len+3+7>>>3,n=e.static_len+3+7>>>3,n<=r&&(r=n)):r=n=t+5,t+4<=r&&i!==-1?ha(e,i,t,a):e.strategy===Oi||n===r?(L(e,(Wt<<1)+(a?1:0),3),Xt(e,J,ye)):(L(e,(Ci<<1)+(a?1:0),3),Gi(e,e.l_desc.max_code+1,e.d_desc.max_code+1,_+1),Xt(e,e.dyn_ltree,e.dyn_dtree)),la(e),a&&_a(e)}function Qi(e,i,t){return e.pending_buf[e.d_buf+e.last_lit*2]=i>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=i&255,e.pending_buf[e.l_buf+e.last_lit]=t&255,e.last_lit++,i===0?e.dyn_ltree[t*2]++:(e.matches++,i--,e.dyn_ltree[(Te[t]+De+1)*2]++,e.dyn_dtree[ra(i)*2]++),e.last_lit===e.lit_bufsize-1}be._tr_init=Wi;be._tr_stored_block=ha;be._tr_flush_block=Ji;be._tr_tally=Qi;be._tr_align=Vi});var bt=I((yn,da)=>{"use strict";function $i(e,i,t,a){for(var r=e&65535|0,n=e>>>16&65535|0,_=0;t!==0;){_=t>2e3?2e3:t,t-=_;do r=r+i[a++]|0,n=n+r|0;while(--_);r%=65521,n%=65521}return r|n<<16|0}da.exports=$i});var wt=I((zn,ua)=>{"use strict";function er(){for(var e,i=[],t=0;t<256;t++){e=t;for(var a=0;a<8;a++)e=e&1?3988292384^e>>>1:e>>>1;i[t]=e}return i}var tr=er();function ar(e,i,t,a){var r=tr,n=a+t;e^=-1;for(var _=a;_<n;_++)e=e>>>8^r[(e^i[_])&255];return e^-1}ua.exports=ar});var qe=I((mn,va)=>{"use strict";va.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var Ea=I(j=>{"use strict";var C=V(),M=oa(),wa=bt(),ee=wt(),ir=qe(),oe=0,rr=1,nr=3,ne=4,ca=5,G=0,sa=1,H=-2,fr=-3,gt=-5,lr=-1,_r=1,Ge=2,hr=3,or=4,dr=0,ur=2,Je=8,vr=9,cr=15,sr=8,br=29,wr=256,xt=wr+1+br,gr=30,pr=19,xr=2*xt+1,kr=15,E=3,ie=258,P=ie+E+1,Er=32,Qe=42,kt=69,je=73,We=91,Ve=103,le=113,Re=666,N=1,Ne=2,_e=3,pe=4,Sr=3;function re(e,i){return e.msg=ir[i],i}function ba(e){return(e<<1)-(e>4?9:0)}function ae(e){for(var i=e.length;--i>=0;)e[i]=0}function te(e){var i=e.state,t=i.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(C.arraySet(e.output,i.pending_buf,i.pending_out,t,e.next_out),e.next_out+=t,i.pending_out+=t,e.total_out+=t,e.avail_out-=t,i.pending-=t,i.pending===0&&(i.pending_out=0))}function O(e,i){M._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,i),e.block_start=e.strstart,te(e.strm)}function z(e,i){e.pending_buf[e.pending++]=i}function Ze(e,i){e.pending_buf[e.pending++]=i>>>8&255,e.pending_buf[e.pending++]=i&255}function yr(e,i,t,a){var r=e.avail_in;return r>a&&(r=a),r===0?0:(e.avail_in-=r,C.arraySet(i,e.input,e.next_in,r,t),e.state.wrap===1?e.adler=wa(e.adler,i,r,t):e.state.wrap===2&&(e.adler=ee(e.adler,i,r,t)),e.next_in+=r,e.total_in+=r,r)}function ga(e,i){var t=e.max_chain_length,a=e.strstart,r,n,_=e.prev_length,f=e.nice_match,d=e.strstart>e.w_size-P?e.strstart-(e.w_size-P):0,l=e.window,h=e.w_mask,x=e.prev,u=e.strstart+ie,o=l[a+_-1],s=l[a+_];e.prev_length>=e.good_match&&(t>>=2),f>e.lookahead&&(f=e.lookahead);do if(r=i,!(l[r+_]!==s||l[r+_-1]!==o||l[r]!==l[a]||l[++r]!==l[a+1])){a+=2,r++;do;while(l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&a<u);if(n=ie-(u-a),a=u-ie,n>_){if(e.match_start=i,_=n,n>=f)break;o=l[a+_-1],s=l[a+_]}}while((i=x[i&h])>d&&--t!==0);return _<=e.lookahead?_:e.lookahead}function he(e){var i=e.w_size,t,a,r,n,_;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=i+(i-P)){C.arraySet(e.window,e.window,i,i,0),e.match_start-=i,e.strstart-=i,e.block_start-=i,a=e.hash_size,t=a;do r=e.head[--t],e.head[t]=r>=i?r-i:0;while(--a);a=i,t=a;do r=e.prev[--t],e.prev[t]=r>=i?r-i:0;while(--a);n+=i}if(e.strm.avail_in===0)break;if(a=yr(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=a,e.lookahead+e.insert>=E)for(_=e.strstart-e.insert,e.ins_h=e.window[_],e.ins_h=(e.ins_h<<e.hash_shift^e.window[_+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[_+E-1])&e.hash_mask,e.prev[_&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=_,_++,e.insert--,!(e.lookahead+e.insert<E)););}while(e.lookahead<P&&e.strm.avail_in!==0)}function zr(e,i){var t=65535;for(t>e.pending_buf_size-5&&(t=e.pending_buf_size-5);;){if(e.lookahead<=1){if(he(e),e.lookahead===0&&i===oe)return N;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var a=e.block_start+t;if((e.strstart===0||e.strstart>=a)&&(e.lookahead=e.strstart-a,e.strstart=a,O(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-P&&(O(e,!1),e.strm.avail_out===0))return N}return e.insert=0,i===ne?(O(e,!0),e.strm.avail_out===0?_e:pe):(e.strstart>e.block_start&&(O(e,!1),e.strm.avail_out===0),N)}function pt(e,i){for(var t,a;;){if(e.lookahead<P){if(he(e),e.lookahead<P&&i===oe)return N;if(e.lookahead===0)break}if(t=0,e.lookahead>=E&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+E-1])&e.hash_mask,t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-P&&(e.match_length=ga(e,t)),e.match_length>=E)if(a=M._tr_tally(e,e.strstart-e.match_start,e.match_length-E),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=E){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+E-1])&e.hash_mask,t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else a=M._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(a&&(O(e,!1),e.strm.avail_out===0))return N}return e.insert=e.strstart<E-1?e.strstart:E-1,i===ne?(O(e,!0),e.strm.avail_out===0?_e:pe):e.last_lit&&(O(e,!1),e.strm.avail_out===0)?N:Ne}function we(e,i){for(var t,a,r;;){if(e.lookahead<P){if(he(e),e.lookahead<P&&i===oe)return N;if(e.lookahead===0)break}if(t=0,e.lookahead>=E&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+E-1])&e.hash_mask,t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=E-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-P&&(e.match_length=ga(e,t),e.match_length<=5&&(e.strategy===_r||e.match_length===E&&e.strstart-e.match_start>4096)&&(e.match_length=E-1)),e.prev_length>=E&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-E,a=M._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-E),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+E-1])&e.hash_mask,t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=E-1,e.strstart++,a&&(O(e,!1),e.strm.avail_out===0))return N}else if(e.match_available){if(a=M._tr_tally(e,0,e.window[e.strstart-1]),a&&O(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return N}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(a=M._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<E-1?e.strstart:E-1,i===ne?(O(e,!0),e.strm.avail_out===0?_e:pe):e.last_lit&&(O(e,!1),e.strm.avail_out===0)?N:Ne}function mr(e,i){for(var t,a,r,n,_=e.window;;){if(e.lookahead<=ie){if(he(e),e.lookahead<=ie&&i===oe)return N;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=E&&e.strstart>0&&(r=e.strstart-1,a=_[r],a===_[++r]&&a===_[++r]&&a===_[++r])){n=e.strstart+ie;do;while(a===_[++r]&&a===_[++r]&&a===_[++r]&&a===_[++r]&&a===_[++r]&&a===_[++r]&&a===_[++r]&&a===_[++r]&&r<n);e.match_length=ie-(n-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=E?(t=M._tr_tally(e,1,e.match_length-E),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=M._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(O(e,!1),e.strm.avail_out===0))return N}return e.insert=0,i===ne?(O(e,!0),e.strm.avail_out===0?_e:pe):e.last_lit&&(O(e,!1),e.strm.avail_out===0)?N:Ne}function Tr(e,i){for(var t;;){if(e.lookahead===0&&(he(e),e.lookahead===0)){if(i===oe)return N;break}if(e.match_length=0,t=M._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(O(e,!1),e.strm.avail_out===0))return N}return e.insert=0,i===ne?(O(e,!0),e.strm.avail_out===0?_e:pe):e.last_lit&&(O(e,!1),e.strm.avail_out===0)?N:Ne}function q(e,i,t,a,r){this.good_length=e,this.max_lazy=i,this.nice_length=t,this.max_chain=a,this.func=r}var ge;ge=[new q(0,0,0,0,zr),new q(4,4,8,4,pt),new q(4,5,16,8,pt),new q(4,6,32,32,pt),new q(4,4,16,16,we),new q(8,16,32,32,we),new q(8,16,128,128,we),new q(8,32,128,256,we),new q(32,128,258,1024,we),new q(32,258,258,4096,we)];function Ar(e){e.window_size=2*e.w_size,ae(e.head),e.max_lazy_match=ge[e.level].max_lazy,e.good_match=ge[e.level].good_length,e.nice_match=ge[e.level].nice_length,e.max_chain_length=ge[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=E-1,e.match_available=0,e.ins_h=0}function Dr(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Je,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(xr*2),this.dyn_dtree=new C.Buf16((2*gr+1)*2),this.bl_tree=new C.Buf16((2*pr+1)*2),ae(this.dyn_ltree),ae(this.dyn_dtree),ae(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(kr+1),this.heap=new C.Buf16(2*xt+1),ae(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*xt+1),ae(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pa(e){var i;return!e||!e.state?re(e,H):(e.total_in=e.total_out=0,e.data_type=ur,i=e.state,i.pending=0,i.pending_out=0,i.wrap<0&&(i.wrap=-i.wrap),i.status=i.wrap?Qe:le,e.adler=i.wrap===2?0:1,i.last_flush=oe,M._tr_init(i),G)}function xa(e){var i=pa(e);return i===G&&Ar(e.state),i}function Zr(e,i){return!e||!e.state||e.state.wrap!==2?H:(e.state.gzhead=i,G)}function ka(e,i,t,a,r,n){if(!e)return H;var _=1;if(i===lr&&(i=6),a<0?(_=0,a=-a):a>15&&(_=2,a-=16),r<1||r>vr||t!==Je||a<8||a>15||i<0||i>9||n<0||n>or)return re(e,H);a===8&&(a=9);var f=new Dr;return e.state=f,f.strm=e,f.wrap=_,f.gzhead=null,f.w_bits=a,f.w_size=1<<f.w_bits,f.w_mask=f.w_size-1,f.hash_bits=r+7,f.hash_size=1<<f.hash_bits,f.hash_mask=f.hash_size-1,f.hash_shift=~~((f.hash_bits+E-1)/E),f.window=new C.Buf8(f.w_size*2),f.head=new C.Buf16(f.hash_size),f.prev=new C.Buf16(f.w_size),f.lit_bufsize=1<<r+6,f.pending_buf_size=f.lit_bufsize*4,f.pending_buf=new C.Buf8(f.pending_buf_size),f.d_buf=1*f.lit_bufsize,f.l_buf=3*f.lit_bufsize,f.level=i,f.strategy=n,f.method=t,xa(e)}function Rr(e,i){return ka(e,i,Je,cr,sr,dr)}function Nr(e,i){var t,a,r,n;if(!e||!e.state||i>ca||i<0)return e?re(e,H):H;if(a=e.state,!e.output||!e.input&&e.avail_in!==0||a.status===Re&&i!==ne)return re(e,e.avail_out===0?gt:H);if(a.strm=e,t=a.last_flush,a.last_flush=i,a.status===Qe)if(a.wrap===2)e.adler=0,z(a,31),z(a,139),z(a,8),a.gzhead?(z(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),z(a,a.gzhead.time&255),z(a,a.gzhead.time>>8&255),z(a,a.gzhead.time>>16&255),z(a,a.gzhead.time>>24&255),z(a,a.level===9?2:a.strategy>=Ge||a.level<2?4:0),z(a,a.gzhead.os&255),a.gzhead.extra&&a.gzhead.extra.length&&(z(a,a.gzhead.extra.length&255),z(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=ee(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=kt):(z(a,0),z(a,0),z(a,0),z(a,0),z(a,0),z(a,a.level===9?2:a.strategy>=Ge||a.level<2?4:0),z(a,Sr),a.status=le);else{var _=Je+(a.w_bits-8<<4)<<8,f=-1;a.strategy>=Ge||a.level<2?f=0:a.level<6?f=1:a.level===6?f=2:f=3,_|=f<<6,a.strstart!==0&&(_|=Er),_+=31-_%31,a.status=le,Ze(a,_),a.strstart!==0&&(Ze(a,e.adler>>>16),Ze(a,e.adler&65535)),e.adler=1}if(a.status===kt)if(a.gzhead.extra){for(r=a.pending;a.gzindex<(a.gzhead.extra.length&65535)&&!(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=ee(e.adler,a.pending_buf,a.pending-r,r)),te(e),r=a.pending,a.pending===a.pending_buf_size));)z(a,a.gzhead.extra[a.gzindex]&255),a.gzindex++;a.gzhead.hcrc&&a.pending>r&&(e.adler=ee(e.adler,a.pending_buf,a.pending-r,r)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=je)}else a.status=je;if(a.status===je)if(a.gzhead.name){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=ee(e.adler,a.pending_buf,a.pending-r,r)),te(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindex<a.gzhead.name.length?n=a.gzhead.name.charCodeAt(a.gzindex++)&255:n=0,z(a,n)}while(n!==0);a.gzhead.hcrc&&a.pending>r&&(e.adler=ee(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.gzindex=0,a.status=We)}else a.status=We;if(a.status===We)if(a.gzhead.comment){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=ee(e.adler,a.pending_buf,a.pending-r,r)),te(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindex<a.gzhead.comment.length?n=a.gzhead.comment.charCodeAt(a.gzindex++)&255:n=0,z(a,n)}while(n!==0);a.gzhead.hcrc&&a.pending>r&&(e.adler=ee(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.status=Ve)}else a.status=Ve;if(a.status===Ve&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&te(e),a.pending+2<=a.pending_buf_size&&(z(a,e.adler&255),z(a,e.adler>>8&255),e.adler=0,a.status=le)):a.status=le),a.pending!==0){if(te(e),e.avail_out===0)return a.last_flush=-1,G}else if(e.avail_in===0&&ba(i)<=ba(t)&&i!==ne)return re(e,gt);if(a.status===Re&&e.avail_in!==0)return re(e,gt);if(e.avail_in!==0||a.lookahead!==0||i!==oe&&a.status!==Re){var d=a.strategy===Ge?Tr(a,i):a.strategy===hr?mr(a,i):ge[a.level].func(a,i);if((d===_e||d===pe)&&(a.status=Re),d===N||d===_e)return e.avail_out===0&&(a.last_flush=-1),G;if(d===Ne&&(i===rr?M._tr_align(a):i!==ca&&(M._tr_stored_block(a,0,0,!1),i===nr&&(ae(a.head),a.lookahead===0&&(a.strstart=0,a.block_start=0,a.insert=0))),te(e),e.avail_out===0))return a.last_flush=-1,G}return i!==ne?G:a.wrap<=0?sa:(a.wrap===2?(z(a,e.adler&255),z(a,e.adler>>8&255),z(a,e.adler>>16&255),z(a,e.adler>>24&255),z(a,e.total_in&255),z(a,e.total_in>>8&255),z(a,e.total_in>>16&255),z(a,e.total_in>>24&255)):(Ze(a,e.adler>>>16),Ze(a,e.adler&65535)),te(e),a.wrap>0&&(a.wrap=-a.wrap),a.pending!==0?G:sa)}function Or(e){var i;return!e||!e.state?H:(i=e.state.status,i!==Qe&&i!==kt&&i!==je&&i!==We&&i!==Ve&&i!==le&&i!==Re?re(e,H):(e.state=null,i===le?re(e,fr):G))}function Ir(e,i){var t=i.length,a,r,n,_,f,d,l,h;if(!e||!e.state||(a=e.state,_=a.wrap,_===2||_===1&&a.status!==Qe||a.lookahead))return H;for(_===1&&(e.adler=wa(e.adler,i,t,0)),a.wrap=0,t>=a.w_size&&(_===0&&(ae(a.head),a.strstart=0,a.block_start=0,a.insert=0),h=new C.Buf8(a.w_size),C.arraySet(h,i,t-a.w_size,a.w_size,0),i=h,t=a.w_size),f=e.avail_in,d=e.next_in,l=e.input,e.avail_in=t,e.next_in=0,e.input=i,he(a);a.lookahead>=E;){r=a.strstart,n=a.lookahead-(E-1);do a.ins_h=(a.ins_h<<a.hash_shift^a.window[r+E-1])&a.hash_mask,a.prev[r&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=r,r++;while(--n);a.strstart=r,a.lookahead=E-1,he(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=E-1,a.match_available=0,e.next_in=d,e.input=l,e.avail_in=f,a.wrap=_,G}j.deflateInit=Rr;j.deflateInit2=ka;j.deflateReset=xa;j.deflateResetKeep=pa;j.deflateSetHeader=Zr;j.deflate=Nr;j.deflateEnd=Or;j.deflateSetDictionary=Ir;j.deflateInfo="pako deflate (from Nodeca project)"});var Et=I(xe=>{"use strict";var $e=V(),Sa=!0,ya=!0;try{String.fromCharCode.apply(null,[0])}catch{Sa=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ya=!1}var Oe=new $e.Buf8(256);for(Q=0;Q<256;Q++)Oe[Q]=Q>=252?6:Q>=248?5:Q>=240?4:Q>=224?3:Q>=192?2:1;var Q;Oe[254]=Oe[254]=1;xe.string2buf=function(e){var i,t,a,r,n,_=e.length,f=0;for(r=0;r<_;r++)t=e.charCodeAt(r),(t&64512)===55296&&r+1<_&&(a=e.charCodeAt(r+1),(a&64512)===56320&&(t=65536+(t-55296<<10)+(a-56320),r++)),f+=t<128?1:t<2048?2:t<65536?3:4;for(i=new $e.Buf8(f),n=0,r=0;n<f;r++)t=e.charCodeAt(r),(t&64512)===55296&&r+1<_&&(a=e.charCodeAt(r+1),(a&64512)===56320&&(t=65536+(t-55296<<10)+(a-56320),r++)),t<128?i[n++]=t:t<2048?(i[n++]=192|t>>>6,i[n++]=128|t&63):t<65536?(i[n++]=224|t>>>12,i[n++]=128|t>>>6&63,i[n++]=128|t&63):(i[n++]=240|t>>>18,i[n++]=128|t>>>12&63,i[n++]=128|t>>>6&63,i[n++]=128|t&63);return i};function za(e,i){if(i<65534&&(e.subarray&&ya||!e.subarray&&Sa))return String.fromCharCode.apply(null,$e.shrinkBuf(e,i));for(var t="",a=0;a<i;a++)t+=String.fromCharCode(e[a]);return t}xe.buf2binstring=function(e){return za(e,e.length)};xe.binstring2buf=function(e){for(var i=new $e.Buf8(e.length),t=0,a=i.length;t<a;t++)i[t]=e.charCodeAt(t);return i};xe.buf2string=function(e,i){var t,a,r,n,_=i||e.length,f=new Array(_*2);for(a=0,t=0;t<_;){if(r=e[t++],r<128){f[a++]=r;continue}if(n=Oe[r],n>4){f[a++]=65533,t+=n-1;continue}for(r&=n===2?31:n===3?15:7;n>1&&t<_;)r=r<<6|e[t++]&63,n--;if(n>1){f[a++]=65533;continue}r<65536?f[a++]=r:(r-=65536,f[a++]=55296|r>>10&1023,f[a++]=56320|r&1023)}return za(f,a)};xe.utf8border=function(e,i){var t;for(i=i||e.length,i>e.length&&(i=e.length),t=i-1;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?i:t+Oe[e[t]]>i?t:i}});var St=I((Dn,ma)=>{"use strict";function Br(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}ma.exports=Br});var Za=I(Ce=>{"use strict";var Ie=Ea(),Be=V(),zt=Et(),mt=qe(),Cr=St(),Da=Object.prototype.toString,Lr=0,yt=4,ke=0,Ta=1,Aa=2,Fr=-1,Mr=0,Hr=8;function de(e){if(!(this instanceof de))return new de(e);this.options=Be.assign({level:Fr,method:Hr,chunkSize:16384,windowBits:15,memLevel:8,strategy:Mr,to:""},e||{});var i=this.options;i.raw&&i.windowBits>0?i.windowBits=-i.windowBits:i.gzip&&i.windowBits>0&&i.windowBits<16&&(i.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Cr,this.strm.avail_out=0;var t=Ie.deflateInit2(this.strm,i.level,i.method,i.windowBits,i.memLevel,i.strategy);if(t!==ke)throw new Error(mt[t]);if(i.header&&Ie.deflateSetHeader(this.strm,i.header),i.dictionary){var a;if(typeof i.dictionary=="string"?a=zt.string2buf(i.dictionary):Da.call(i.dictionary)==="[object ArrayBuffer]"?a=new Uint8Array(i.dictionary):a=i.dictionary,t=Ie.deflateSetDictionary(this.strm,a),t!==ke)throw new Error(mt[t]);this._dict_set=!0}}de.prototype.push=function(e,i){var t=this.strm,a=this.options.chunkSize,r,n;if(this.ended)return!1;n=i===~~i?i:i===!0?yt:Lr,typeof e=="string"?t.input=zt.string2buf(e):Da.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;do{if(t.avail_out===0&&(t.output=new Be.Buf8(a),t.next_out=0,t.avail_out=a),r=Ie.deflate(t,n),r!==Ta&&r!==ke)return this.onEnd(r),this.ended=!0,!1;(t.avail_out===0||t.avail_in===0&&(n===yt||n===Aa))&&(this.options.to==="string"?this.onData(zt.buf2binstring(Be.shrinkBuf(t.output,t.next_out))):this.onData(Be.shrinkBuf(t.output,t.next_out)))}while((t.avail_in>0||t.avail_out===0)&&r!==Ta);return n===yt?(r=Ie.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ke):(n===Aa&&(this.onEnd(ke),t.avail_out=0),!0)};de.prototype.onData=function(e){this.chunks.push(e)};de.prototype.onEnd=function(e){e===ke&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Be.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Tt(e,i){var t=new de(i);if(t.push(e,!0),t.err)throw t.msg||mt[t.err];return t.result}function Ur(e,i){return i=i||{},i.raw=!0,Tt(e,i)}function Kr(e,i){return i=i||{},i.gzip=!0,Tt(e,i)}Ce.Deflate=de;Ce.deflate=Tt;Ce.deflateRaw=Ur;Ce.gzip=Kr});var Na=I((Rn,Ra)=>{"use strict";var et=30,Pr=12;Ra.exports=function(i,t){var a,r,n,_,f,d,l,h,x,u,o,s,c,k,b,T,A,p,v,m,S,w,y,Z,g;a=i.state,r=i.next_in,Z=i.input,n=r+(i.avail_in-5),_=i.next_out,g=i.output,f=_-(t-i.avail_out),d=_+(i.avail_out-257),l=a.dmax,h=a.wsize,x=a.whave,u=a.wnext,o=a.window,s=a.hold,c=a.bits,k=a.lencode,b=a.distcode,T=(1<<a.lenbits)-1,A=(1<<a.distbits)-1;e:do{c<15&&(s+=Z[r++]<<c,c+=8,s+=Z[r++]<<c,c+=8),p=k[s&T];t:for(;;){if(v=p>>>24,s>>>=v,c-=v,v=p>>>16&255,v===0)g[_++]=p&65535;else if(v&16){m=p&65535,v&=15,v&&(c<v&&(s+=Z[r++]<<c,c+=8),m+=s&(1<<v)-1,s>>>=v,c-=v),c<15&&(s+=Z[r++]<<c,c+=8,s+=Z[r++]<<c,c+=8),p=b[s&A];a:for(;;){if(v=p>>>24,s>>>=v,c-=v,v=p>>>16&255,v&16){if(S=p&65535,v&=15,c<v&&(s+=Z[r++]<<c,c+=8,c<v&&(s+=Z[r++]<<c,c+=8)),S+=s&(1<<v)-1,S>l){i.msg="invalid distance too far back",a.mode=et;break e}if(s>>>=v,c-=v,v=_-f,S>v){if(v=S-v,v>x&&a.sane){i.msg="invalid distance too far back",a.mode=et;break e}if(w=0,y=o,u===0){if(w+=h-v,v<m){m-=v;do g[_++]=o[w++];while(--v);w=_-S,y=g}}else if(u<v){if(w+=h+u-v,v-=u,v<m){m-=v;do g[_++]=o[w++];while(--v);if(w=0,u<m){v=u,m-=v;do g[_++]=o[w++];while(--v);w=_-S,y=g}}}else if(w+=u-v,v<m){m-=v;do g[_++]=o[w++];while(--v);w=_-S,y=g}for(;m>2;)g[_++]=y[w++],g[_++]=y[w++],g[_++]=y[w++],m-=3;m&&(g[_++]=y[w++],m>1&&(g[_++]=y[w++]))}else{w=_-S;do g[_++]=g[w++],g[_++]=g[w++],g[_++]=g[w++],m-=3;while(m>2);m&&(g[_++]=g[w++],m>1&&(g[_++]=g[w++]))}}else if((v&64)===0){p=b[(p&65535)+(s&(1<<v)-1)];continue a}else{i.msg="invalid distance code",a.mode=et;break e}break}}else if((v&64)===0){p=k[(p&65535)+(s&(1<<v)-1)];continue t}else if(v&32){a.mode=Pr;break e}else{i.msg="invalid literal/length code",a.mode=et;break e}break}}while(r<n&&_<d);m=c>>3,r-=m,c-=m<<3,s&=(1<<c)-1,i.next_in=r,i.next_out=_,i.avail_in=r<n?5+(n-r):5-(r-n),i.avail_out=_<d?257+(d-_):257-(_-d),a.hold=s,a.bits=c}});var Ma=I((Nn,Fa)=>{"use strict";var Oa=V(),Ee=15,Ia=852,Ba=592,Ca=0,At=1,La=2,Yr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Xr=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],qr=[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,0,0],Gr=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];Fa.exports=function(i,t,a,r,n,_,f,d){var l=d.bits,h=0,x=0,u=0,o=0,s=0,c=0,k=0,b=0,T=0,A=0,p,v,m,S,w,y=null,Z=0,g,K=new Oa.Buf16(Ee+1),He=new Oa.Buf16(Ee+1),Ue=null,Ht=0,Ut,Ke,Pe;for(h=0;h<=Ee;h++)K[h]=0;for(x=0;x<r;x++)K[t[a+x]]++;for(s=l,o=Ee;o>=1&&K[o]===0;o--);if(s>o&&(s=o),o===0)return n[_++]=1<<24|64<<16|0,n[_++]=1<<24|64<<16|0,d.bits=1,0;for(u=1;u<o&&K[u]===0;u++);for(s<u&&(s=u),b=1,h=1;h<=Ee;h++)if(b<<=1,b-=K[h],b<0)return-1;if(b>0&&(i===Ca||o!==1))return-1;for(He[1]=0,h=1;h<Ee;h++)He[h+1]=He[h]+K[h];for(x=0;x<r;x++)t[a+x]!==0&&(f[He[t[a+x]]++]=x);if(i===Ca?(y=Ue=f,g=19):i===At?(y=Yr,Z-=257,Ue=Xr,Ht-=257,g=256):(y=qr,Ue=Gr,g=-1),A=0,x=0,h=u,w=_,c=s,k=0,m=-1,T=1<<s,S=T-1,i===At&&T>Ia||i===La&&T>Ba)return 1;for(;;){Ut=h-k,f[x]<g?(Ke=0,Pe=f[x]):f[x]>g?(Ke=Ue[Ht+f[x]],Pe=y[Z+f[x]]):(Ke=96,Pe=0),p=1<<h-k,v=1<<c,u=v;do v-=p,n[w+(A>>k)+v]=Ut<<24|Ke<<16|Pe|0;while(v!==0);for(p=1<<h-1;A&p;)p>>=1;if(p!==0?(A&=p-1,A+=p):A=0,x++,--K[h]===0){if(h===o)break;h=t[a+f[x]]}if(h>s&&(A&S)!==m){for(k===0&&(k=s),w+=u,c=h-k,b=1<<c;c+k<o&&(b-=K[c+k],!(b<=0));)c++,b<<=1;if(T+=1<<c,i===At&&T>Ia||i===La&&T>Ba)return 1;m=A&S,n[m]=s<<24|c<<16|w-_|0}}return A!==0&&(n[w+A]=h-k<<24|64<<16|0),d.bits=s,0}});var xi=I(Y=>{"use strict";var F=V(),It=bt(),W=wt(),jr=Na(),Le=Ma(),Wr=0,di=1,ui=2,Ha=4,Vr=5,tt=6,ue=0,Jr=1,Qr=2,U=-2,vi=-3,Bt=-4,$r=-5,Ua=8,ci=1,Ka=2,Pa=3,Ya=4,Xa=5,qa=6,Ga=7,ja=8,Wa=9,Va=10,rt=11,$=12,Dt=13,Ja=14,Zt=15,Qa=16,$a=17,ei=18,ti=19,at=20,it=21,ai=22,ii=23,ri=24,ni=25,fi=26,Rt=27,li=28,_i=29,D=30,Ct=31,en=32,tn=852,an=592,rn=15,nn=rn;function hi(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function fn(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new F.Buf16(320),this.work=new F.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function si(e){var i;return!e||!e.state?U:(i=e.state,e.total_in=e.total_out=i.total=0,e.msg="",i.wrap&&(e.adler=i.wrap&1),i.mode=ci,i.last=0,i.havedict=0,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new F.Buf32(tn),i.distcode=i.distdyn=new F.Buf32(an),i.sane=1,i.back=-1,ue)}function bi(e){var i;return!e||!e.state?U:(i=e.state,i.wsize=0,i.whave=0,i.wnext=0,si(e))}function wi(e,i){var t,a;return!e||!e.state||(a=e.state,i<0?(t=0,i=-i):(t=(i>>4)+1,i<48&&(i&=15)),i&&(i<8||i>15))?U:(a.window!==null&&a.wbits!==i&&(a.window=null),a.wrap=t,a.wbits=i,bi(e))}function gi(e,i){var t,a;return e?(a=new fn,e.state=a,a.window=null,t=wi(e,i),t!==ue&&(e.state=null),t):U}function ln(e){return gi(e,nn)}var oi=!0,Nt,Ot;function _n(e){if(oi){var i;for(Nt=new F.Buf32(512),Ot=new F.Buf32(32),i=0;i<144;)e.lens[i++]=8;for(;i<256;)e.lens[i++]=9;for(;i<280;)e.lens[i++]=7;for(;i<288;)e.lens[i++]=8;for(Le(di,e.lens,0,288,Nt,0,e.work,{bits:9}),i=0;i<32;)e.lens[i++]=5;Le(ui,e.lens,0,32,Ot,0,e.work,{bits:5}),oi=!1}e.lencode=Nt,e.lenbits=9,e.distcode=Ot,e.distbits=5}function pi(e,i,t,a){var r,n=e.state;return n.window===null&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new F.Buf8(n.wsize)),a>=n.wsize?(F.arraySet(n.window,i,t-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(r=n.wsize-n.wnext,r>a&&(r=a),F.arraySet(n.window,i,t-a,r,n.wnext),a-=r,a?(F.arraySet(n.window,i,t-a,a,0),n.wnext=a,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=r))),0}function hn(e,i){var t,a,r,n,_,f,d,l,h,x,u,o,s,c,k=0,b,T,A,p,v,m,S,w,y=new F.Buf8(4),Z,g,K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return U;t=e.state,t.mode===$&&(t.mode=Dt),_=e.next_out,r=e.output,d=e.avail_out,n=e.next_in,a=e.input,f=e.avail_in,l=t.hold,h=t.bits,x=f,u=d,w=ue;e:for(;;)switch(t.mode){case ci:if(t.wrap===0){t.mode=Dt;break}for(;h<16;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(t.wrap&2&&l===35615){t.check=0,y[0]=l&255,y[1]=l>>>8&255,t.check=W(t.check,y,2,0),l=0,h=0,t.mode=Ka;break}if(t.flags=0,t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",t.mode=D;break}if((l&15)!==Ua){e.msg="unknown compression method",t.mode=D;break}if(l>>>=4,h-=4,S=(l&15)+8,t.wbits===0)t.wbits=S;else if(S>t.wbits){e.msg="invalid window size",t.mode=D;break}t.dmax=1<<S,e.adler=t.check=1,t.mode=l&512?Va:$,l=0,h=0;break;case Ka:for(;h<16;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(t.flags=l,(t.flags&255)!==Ua){e.msg="unknown compression method",t.mode=D;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=D;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&(y[0]=l&255,y[1]=l>>>8&255,t.check=W(t.check,y,2,0)),l=0,h=0,t.mode=Pa;case Pa:for(;h<32;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}t.head&&(t.head.time=l),t.flags&512&&(y[0]=l&255,y[1]=l>>>8&255,y[2]=l>>>16&255,y[3]=l>>>24&255,t.check=W(t.check,y,4,0)),l=0,h=0,t.mode=Ya;case Ya:for(;h<16;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&(y[0]=l&255,y[1]=l>>>8&255,t.check=W(t.check,y,2,0)),l=0,h=0,t.mode=Xa;case Xa:if(t.flags&1024){for(;h<16;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&(y[0]=l&255,y[1]=l>>>8&255,t.check=W(t.check,y,2,0)),l=0,h=0}else t.head&&(t.head.extra=null);t.mode=qa;case qa:if(t.flags&1024&&(o=t.length,o>f&&(o=f),o&&(t.head&&(S=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Array(t.head.extra_len)),F.arraySet(t.head.extra,a,n,o,S)),t.flags&512&&(t.check=W(t.check,a,o,n)),f-=o,n+=o,t.length-=o),t.length))break e;t.length=0,t.mode=Ga;case Ga:if(t.flags&2048){if(f===0)break e;o=0;do S=a[n+o++],t.head&&S&&t.length<65536&&(t.head.name+=String.fromCharCode(S));while(S&&o<f);if(t.flags&512&&(t.check=W(t.check,a,o,n)),f-=o,n+=o,S)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=ja;case ja:if(t.flags&4096){if(f===0)break e;o=0;do S=a[n+o++],t.head&&S&&t.length<65536&&(t.head.comment+=String.fromCharCode(S));while(S&&o<f);if(t.flags&512&&(t.check=W(t.check,a,o,n)),f-=o,n+=o,S)break e}else t.head&&(t.head.comment=null);t.mode=Wa;case Wa:if(t.flags&512){for(;h<16;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(l!==(t.check&65535)){e.msg="header crc mismatch",t.mode=D;break}l=0,h=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=$;break;case Va:for(;h<32;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}e.adler=t.check=hi(l),l=0,h=0,t.mode=rt;case rt:if(t.havedict===0)return e.next_out=_,e.avail_out=d,e.next_in=n,e.avail_in=f,t.hold=l,t.bits=h,Qr;e.adler=t.check=1,t.mode=$;case $:if(i===Vr||i===tt)break e;case Dt:if(t.last){l>>>=h&7,h-=h&7,t.mode=Rt;break}for(;h<3;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}switch(t.last=l&1,l>>>=1,h-=1,l&3){case 0:t.mode=Ja;break;case 1:if(_n(t),t.mode=at,i===tt){l>>>=2,h-=2;break e}break;case 2:t.mode=$a;break;case 3:e.msg="invalid block type",t.mode=D}l>>>=2,h-=2;break;case Ja:for(l>>>=h&7,h-=h&7;h<32;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",t.mode=D;break}if(t.length=l&65535,l=0,h=0,t.mode=Zt,i===tt)break e;case Zt:t.mode=Qa;case Qa:if(o=t.length,o){if(o>f&&(o=f),o>d&&(o=d),o===0)break e;F.arraySet(r,a,n,o,_),f-=o,n+=o,d-=o,_+=o,t.length-=o;break}t.mode=$;break;case $a:for(;h<14;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(t.nlen=(l&31)+257,l>>>=5,h-=5,t.ndist=(l&31)+1,l>>>=5,h-=5,t.ncode=(l&15)+4,l>>>=4,h-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=D;break}t.have=0,t.mode=ei;case ei:for(;t.have<t.ncode;){for(;h<3;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}t.lens[K[t.have++]]=l&7,l>>>=3,h-=3}for(;t.have<19;)t.lens[K[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,Z={bits:t.lenbits},w=Le(Wr,t.lens,0,19,t.lencode,0,t.work,Z),t.lenbits=Z.bits,w){e.msg="invalid code lengths set",t.mode=D;break}t.have=0,t.mode=ti;case ti:for(;t.have<t.nlen+t.ndist;){for(;k=t.lencode[l&(1<<t.lenbits)-1],b=k>>>24,T=k>>>16&255,A=k&65535,!(b<=h);){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(A<16)l>>>=b,h-=b,t.lens[t.have++]=A;else{if(A===16){for(g=b+2;h<g;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(l>>>=b,h-=b,t.have===0){e.msg="invalid bit length repeat",t.mode=D;break}S=t.lens[t.have-1],o=3+(l&3),l>>>=2,h-=2}else if(A===17){for(g=b+3;h<g;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}l>>>=b,h-=b,S=0,o=3+(l&7),l>>>=3,h-=3}else{for(g=b+7;h<g;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}l>>>=b,h-=b,S=0,o=11+(l&127),l>>>=7,h-=7}if(t.have+o>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=D;break}for(;o--;)t.lens[t.have++]=S}}if(t.mode===D)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=D;break}if(t.lenbits=9,Z={bits:t.lenbits},w=Le(di,t.lens,0,t.nlen,t.lencode,0,t.work,Z),t.lenbits=Z.bits,w){e.msg="invalid literal/lengths set",t.mode=D;break}if(t.distbits=6,t.distcode=t.distdyn,Z={bits:t.distbits},w=Le(ui,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,Z),t.distbits=Z.bits,w){e.msg="invalid distances set",t.mode=D;break}if(t.mode=at,i===tt)break e;case at:t.mode=it;case it:if(f>=6&&d>=258){e.next_out=_,e.avail_out=d,e.next_in=n,e.avail_in=f,t.hold=l,t.bits=h,jr(e,u),_=e.next_out,r=e.output,d=e.avail_out,n=e.next_in,a=e.input,f=e.avail_in,l=t.hold,h=t.bits,t.mode===$&&(t.back=-1);break}for(t.back=0;k=t.lencode[l&(1<<t.lenbits)-1],b=k>>>24,T=k>>>16&255,A=k&65535,!(b<=h);){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(T&&(T&240)===0){for(p=b,v=T,m=A;k=t.lencode[m+((l&(1<<p+v)-1)>>p)],b=k>>>24,T=k>>>16&255,A=k&65535,!(p+b<=h);){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}l>>>=p,h-=p,t.back+=p}if(l>>>=b,h-=b,t.back+=b,t.length=A,T===0){t.mode=fi;break}if(T&32){t.back=-1,t.mode=$;break}if(T&64){e.msg="invalid literal/length code",t.mode=D;break}t.extra=T&15,t.mode=ai;case ai:if(t.extra){for(g=t.extra;h<g;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=ii;case ii:for(;k=t.distcode[l&(1<<t.distbits)-1],b=k>>>24,T=k>>>16&255,A=k&65535,!(b<=h);){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if((T&240)===0){for(p=b,v=T,m=A;k=t.distcode[m+((l&(1<<p+v)-1)>>p)],b=k>>>24,T=k>>>16&255,A=k&65535,!(p+b<=h);){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}l>>>=p,h-=p,t.back+=p}if(l>>>=b,h-=b,t.back+=b,T&64){e.msg="invalid distance code",t.mode=D;break}t.offset=A,t.extra=T&15,t.mode=ri;case ri:if(t.extra){for(g=t.extra;h<g;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=D;break}t.mode=ni;case ni:if(d===0)break e;if(o=u-d,t.offset>o){if(o=t.offset-o,o>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=D;break}o>t.wnext?(o-=t.wnext,s=t.wsize-o):s=t.wnext-o,o>t.length&&(o=t.length),c=t.window}else c=r,s=_-t.offset,o=t.length;o>d&&(o=d),d-=o,t.length-=o;do r[_++]=c[s++];while(--o);t.length===0&&(t.mode=it);break;case fi:if(d===0)break e;r[_++]=t.length,d--,t.mode=it;break;case Rt:if(t.wrap){for(;h<32;){if(f===0)break e;f--,l|=a[n++]<<h,h+=8}if(u-=d,e.total_out+=u,t.total+=u,u&&(e.adler=t.check=t.flags?W(t.check,r,u,_-u):It(t.check,r,u,_-u)),u=d,(t.flags?l:hi(l))!==t.check){e.msg="incorrect data check",t.mode=D;break}l=0,h=0}t.mode=li;case li:if(t.wrap&&t.flags){for(;h<32;){if(f===0)break e;f--,l+=a[n++]<<h,h+=8}if(l!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=D;break}l=0,h=0}t.mode=_i;case _i:w=Jr;break e;case D:w=vi;break e;case Ct:return Bt;case en:default:return U}return e.next_out=_,e.avail_out=d,e.next_in=n,e.avail_in=f,t.hold=l,t.bits=h,(t.wsize||u!==e.avail_out&&t.mode<D&&(t.mode<Rt||i!==Ha))&&pi(e,e.output,e.next_out,u-e.avail_out)?(t.mode=Ct,Bt):(x-=e.avail_in,u-=e.avail_out,e.total_in+=x,e.total_out+=u,t.total+=u,t.wrap&&u&&(e.adler=t.check=t.flags?W(t.check,r,u,e.next_out-u):It(t.check,r,u,e.next_out-u)),e.data_type=t.bits+(t.last?64:0)+(t.mode===$?128:0)+(t.mode===at||t.mode===Zt?256:0),(x===0&&u===0||i===Ha)&&w===ue&&(w=$r),w)}function on(e){if(!e||!e.state)return U;var i=e.state;return i.window&&(i.window=null),e.state=null,ue}function dn(e,i){var t;return!e||!e.state||(t=e.state,(t.wrap&2)===0)?U:(t.head=i,i.done=!1,ue)}function un(e,i){var t=i.length,a,r,n;return!e||!e.state||(a=e.state,a.wrap!==0&&a.mode!==rt)?U:a.mode===rt&&(r=1,r=It(r,i,t,0),r!==a.check)?vi:(n=pi(e,i,t,t),n?(a.mode=Ct,Bt):(a.havedict=1,ue))}Y.inflateReset=bi;Y.inflateReset2=wi;Y.inflateResetKeep=si;Y.inflateInit=ln;Y.inflateInit2=gi;Y.inflate=hn;Y.inflateEnd=on;Y.inflateGetHeader=dn;Y.inflateSetDictionary=un;Y.inflateInfo="pako inflate (from Nodeca project)"});var Lt=I((In,ki)=>{"use strict";ki.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var Si=I((Bn,Ei)=>{"use strict";function vn(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}Ei.exports=vn});var zi=I(Me=>{"use strict";var Se=xi(),Fe=V(),nt=Et(),R=Lt(),Ft=qe(),cn=St(),sn=Si(),yi=Object.prototype.toString;function ve(e){if(!(this instanceof ve))return new ve(e);this.options=Fe.assign({chunkSize:16384,windowBits:0,to:""},e||{});var i=this.options;i.raw&&i.windowBits>=0&&i.windowBits<16&&(i.windowBits=-i.windowBits,i.windowBits===0&&(i.windowBits=-15)),i.windowBits>=0&&i.windowBits<16&&!(e&&e.windowBits)&&(i.windowBits+=32),i.windowBits>15&&i.windowBits<48&&(i.windowBits&15)===0&&(i.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cn,this.strm.avail_out=0;var t=Se.inflateInit2(this.strm,i.windowBits);if(t!==R.Z_OK)throw new Error(Ft[t]);if(this.header=new sn,Se.inflateGetHeader(this.strm,this.header),i.dictionary&&(typeof i.dictionary=="string"?i.dictionary=nt.string2buf(i.dictionary):yi.call(i.dictionary)==="[object ArrayBuffer]"&&(i.dictionary=new Uint8Array(i.dictionary)),i.raw&&(t=Se.inflateSetDictionary(this.strm,i.dictionary),t!==R.Z_OK)))throw new Error(Ft[t])}ve.prototype.push=function(e,i){var t=this.strm,a=this.options.chunkSize,r=this.options.dictionary,n,_,f,d,l,h=!1;if(this.ended)return!1;_=i===~~i?i:i===!0?R.Z_FINISH:R.Z_NO_FLUSH,typeof e=="string"?t.input=nt.binstring2buf(e):yi.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;do{if(t.avail_out===0&&(t.output=new Fe.Buf8(a),t.next_out=0,t.avail_out=a),n=Se.inflate(t,R.Z_NO_FLUSH),n===R.Z_NEED_DICT&&r&&(n=Se.inflateSetDictionary(this.strm,r)),n===R.Z_BUF_ERROR&&h===!0&&(n=R.Z_OK,h=!1),n!==R.Z_STREAM_END&&n!==R.Z_OK)return this.onEnd(n),this.ended=!0,!1;t.next_out&&(t.avail_out===0||n===R.Z_STREAM_END||t.avail_in===0&&(_===R.Z_FINISH||_===R.Z_SYNC_FLUSH))&&(this.options.to==="string"?(f=nt.utf8border(t.output,t.next_out),d=t.next_out-f,l=nt.buf2string(t.output,f),t.next_out=d,t.avail_out=a-d,d&&Fe.arraySet(t.output,t.output,f,d,0),this.onData(l)):this.onData(Fe.shrinkBuf(t.output,t.next_out))),t.avail_in===0&&t.avail_out===0&&(h=!0)}while((t.avail_in>0||t.avail_out===0)&&n!==R.Z_STREAM_END);return n===R.Z_STREAM_END&&(_=R.Z_FINISH),_===R.Z_FINISH?(n=Se.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===R.Z_OK):(_===R.Z_SYNC_FLUSH&&(this.onEnd(R.Z_OK),t.avail_out=0),!0)};ve.prototype.onData=function(e){this.chunks.push(e)};ve.prototype.onEnd=function(e){e===R.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Fe.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Mt(e,i){var t=new ve(i);if(t.push(e,!0),t.err)throw t.msg||Ft[t.err];return t.result}function bn(e,i){return i=i||{},i.raw=!0,Mt(e,i)}Me.Inflate=ve;Me.inflate=Mt;Me.inflateRaw=bn;Me.ungzip=Mt});var kn=I((Ln,Ti)=>{"use strict";var wn=V().assign,gn=Za(),pn=zi(),xn=Lt(),mi={};wn(mi,gn,pn,xn);Ti.exports=mi});export{kn as a};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as L,b as O,d as j,n as M}from"./chunk-L2WK7CJG.js";import{b as h,c as b,d as A,e as F,f as x,g as w,h as R}from"./chunk-QVACE4IE.js";import{a as k,d as C,m as v,o as I,u as S}from"./chunk-DRBA23IQ.js";var D=[[15,"rose"],[45,"red"],[70,"orange"],[95,"amber"],[120,"yellow"],[140,"lime"],[165,"green"],[185,"teal"],[215,"cyan"],[250,"sky"],[280,"blue"],[295,"indigo"],[315,"violet"],[340,"purple"],[355,"pink"],[360,"rose"]];function T(t){let{C:e,h:r}=x(b(t));return e<.03?"grey":(D.find(([n])=>r<n)??[360,"rose"])[1]}var d=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),z=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",$='font-family="Inter"';function P(t,e,r,n="light"){let o=n==="dark",i=o?"#FAFAFA":"#111111",s=o?"#A1A1AA":"#71717A",c=o?"#FFFFFF":"#000000",a=r.length>8?64:104,l=10,g=48+r.length*a+Math.max(0,r.length-1)*l,m=84+a+56,p=a>80?12:10,f=`<text id="title" x="24" y="38" ${$} font-size="15" font-weight="600" fill="${i}">${d(t)}</text><text id="subtitle" x="24" y="58" ${$} font-size="12" fill="${s}">${d(e)}</text>`,U=r.map((u,W)=>`<g id="${z(u.id)}" transform="translate(${24+W*(a+l)} 80)"><rect id="swatch" width="${a}" height="${a}" rx="${p}" fill="${u.hex}" stroke="${c}" stroke-opacity="0.08"/><text id="name" x="1" y="${a+22}" ${$} font-size="13" font-weight="600" fill="${i}">${d(u.name)}</text><text id="value" x="1" y="${a+40}" ${$} font-size="11" fill="${s}">${d(u.value)}</text></g>`).join(`
|
|
4
|
+
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${g}" height="${m}" viewBox="0 0 ${g} ${m}">
|
|
5
|
+
<g id="${z(t)}">
|
|
6
|
+
<rect id="card" width="${g}" height="${m}" rx="0" fill="${o?"#18181B":"#FFFFFF"}"/>
|
|
7
|
+
${f}
|
|
8
|
+
${U}
|
|
9
|
+
</g>
|
|
10
|
+
</svg>`}function Z(t,e,r="light",n){let o=t.replace(/\.[^.]+$/,""),i=e.length;return P(t,n?`${i} shade${i===1?"":"s"} of ${n}`:`${i} colour${i===1?"":"s"}, most of the image first`,e.map((s,c)=>({id:`${o}-${c+1}`,name:s.hex,value:R(s.rgb),hex:s.hex})),r)}function _(t,e,r="light"){let n=T(t);return P(`${n[0]?.toUpperCase()??""}${n.slice(1)}`,`from ${h(t)} \xB7 50\u2013950 in OKLCH`,e.map(o=>({id:`${n}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}var y=t=>{let e=t/255;return e<=.04045?e/12.92:((e+.055)/1.055)**2.4},B=({r:t,g:e,b:r})=>.2126*y(t)+.7152*y(e)+.0722*y(r);function E(t,e){let[r,n]=[B(t),B(e)].sort((o,i)=>i-o);return(r+.05)/(n+.05)}function et(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"large":"fails"}var G={r:255,g:255,b:255},N={r:0,g:0,b:0},H=t=>Math.floor(t*10)/10;function rt(t){return{white:H(E(t,G)),black:H(E(t,N))}}var K=[50,100,200,300,400,500,600,700,800,900,950],q=[1,.86,.68,.46,.22],J=[.2,.4,.6,.8,1];function it(t){let{L:e,C:r,h:n}=x(b(t)),o=r<.015,i=Math.max(.975,e),s=e<.16?.42*e:Math.max(.16,.42*e);return K.map((c,a)=>{if(a===5)return{step:c,rgb:{...t},hex:h(t),reference:!0};let l=a<5,g=l?q[a]:J[a-6],m=l?e+(i-e)*g:e-(e-s)*g,p=o?0:r*(l?1-.88*g:1-.45*g);for(;p>0&&!F(w({L:m,C:p,h:n}));)p-=.002;let f=A(w({L:m,C:Math.max(0,p),h:n}));return{step:c,rgb:f,hex:h(f),reference:!1}})}async function pt(t,e=192){let r=await M(t);if(r.kind!=="image")throw v(t,`a ${k[r.format].label}`);let n=r.format==="heic";if(n&&!await L())throw I(t);let o=n?await O(t):void 0;try{let s=(await j())(o?.path??t,{animated:!1}),{data:c,info:a}=await(n?s:s.rotate()).resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:r,pixels:{width:a.width,height:a.height,rgba:new Uint8Array(c.buffer,c.byteOffset,c.length)}}}catch(i){throw C(i)?i:S(t,i)}finally{await o?.cleanup()}}export{Z as a,_ as b,et as c,rt as d,it as e,pt as f};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as w,c as A}from"./chunk-QVACE4IE.js";var d=(e,s,r)=>(e.L[s]-r[0])**2+(e.A[s]-r[1])**2+(e.B[s]-r[2])**2;function O(e,s){let r=e.L.length,u=[0,0,0];for(let a=0;a<r;a++)u[0]+=e.L[a],u[1]+=e.A[a],u[2]+=e.B[a];let n=[[u[0]/r,u[1]/r,u[2]/r]],t=new Float64Array(r).fill(Number.POSITIVE_INFINITY);for(;n.length<s;){let a=n[n.length-1],o=0,b=-1;for(let m=0;m<r;m++){let c=d(e,m,a);c<t[m]&&(t[m]=c),t[m]>b&&(b=t[m],o=m)}n.push([e.L[o],e.A[o],e.B[o]])}return n}function G(e,s,r){let u=0,n=Number.POSITIVE_INFINITY;for(let t=0;t<r.length;t++){let a=d(e,s,r[t]);a<n&&(n=a,u=t)}return u}function E(e,s){let r=e.L.length,u=O(e,s),n=new Int32Array(r).fill(-1);for(let a=0;a<30;a++){let o=0;for(let m=0;m<r;m++){let c=G(e,m,u);n[m]!==c&&(n[m]=c,o++)}let b=u.map(()=>[0,0,0,0]);for(let m=0;m<r;m++){let c=b[n[m]];c[0]=c[0]+e.L[m],c[1]=c[1]+e.A[m],c[2]=c[2]+e.B[m],c[3]=c[3]+1}if(b.forEach(([m,c,h,i],l)=>{i&&(u[l]=[m/i,c/i,h/i])}),o===0)break}let t=u.map(a=>({centre:a,members:[]}));for(let a=0;a<r;a++)t[n[a]]?.members.push(a);return t.filter(a=>a.members.length>0)}function M(e,s){let r=e;for(;;){let u,n=s**2;for(let i=0;i<r.length;i++)for(let l=i+1;l<r.length;l++){let f=r[i].centre,g=r[l].centre,p=(f[0]-g[0])**2+(f[1]-g[1])**2+(f[2]-g[2])**2;p<n&&(n=p,u=[i,l])}if(!u)return r;let[t,a]=u,o=r[t],b=r[a],m=o.members.length,c=b.members.length,h=o.centre.map((i,l)=>(i*m+b.centre[l]*c)/(m+c));r=r.filter((i,l)=>l!==t&&l!==a),r.push({centre:h,members:[...o.members,...b.members]})}}function N(e,s,r){let u=e.L.length,n=[...s].sort((o,b)=>b.members.length-o.members.length),t=n.filter((o,b)=>b===0||o.members.length/u>=r),a=t.map(o=>o.centre);for(let o of n)if(!t.includes(o))for(let b of o.members)t[G(e,b,a)].members.push(b);return t}function y(e,s,r,u){let n=e.length;if(n===0)return[];let t={L:e,A:s,B:r},a=M(E(t,Math.min(u.k,n)),u.merge);return N(t,a,u.minShare)}var F={k:8,merge:.06,minShare:.015},L={k:4,merge:.03,minShare:.02},T=-1,C=-2,P=128,S=64,I=(e,s)=>({r:e.rgba[s*4],g:e.rgba[s*4+1],b:e.rgba[s*4+2]});function R(e,s,r){let u=s.length,n=new Float64Array(u),t=new Float64Array(u),a=new Float64Array(u);return s.forEach((o,b)=>{let m=A(I(e,o));n[b]=m.L,t[b]=m.a,a[b]=m.b}),y(n,t,a,r).map(o=>{let b=o.members[0],m=Number.POSITIVE_INFINITY;for(let h of o.members){let i=(n[h]-o.centre[0])**2+(t[h]-o.centre[1])**2+(a[h]-o.centre[2])**2;i<m&&(m=i,b=h)}let c=I(e,s[b]);return{rgb:c,hex:w(c),share:o.members.length/u,centre:{L:o.centre[0],a:o.centre[1],b:o.centre[2]},members:Uint32Array.from(o.members.map(h=>s[h])).sort()}}).sort((o,b)=>b.share-o.share||(o.hex<b.hex?-1:1))}function D(e){let s=[];for(let r=0;r<e.width*e.height;r++)e.rgba[r*4+3]>=P&&s.push(r);return R(e,s,F)}function k(e,s){return R(e,[...s.members],L)}function U(e,s){return s.members.length>=S&&k(e,s).length>1}function V(e){let s=e.map(n=>n*100),r=s.map(Math.floor),u=Math.round(s.reduce((n,t)=>n+t,0))-r.reduce((n,t)=>n+t,0);return s.map((n,t)=>[n-Math.floor(n),t]).sort((n,t)=>t[0]-n[0]||n[1]-t[1]).forEach(([,n])=>{u-- >0&&(r[n]=r[n]+1)}),r}function Y(e,s,r=24){let u=new Int32Array(e.width*e.height).fill(C);s.forEach((o,b)=>{for(let m of o.members)u[m]=b});let n=e.width>=e.height,t=n?r:Math.max(1,Math.round(r*e.width/e.height)),a=n?Math.max(1,Math.round(r*e.height/e.width)):r;return Array.from({length:a},(o,b)=>Array.from({length:t},(m,c)=>{let h=Math.min(e.width-1,Math.floor((c+.5)*e.width/t)),l=Math.min(e.height-1,Math.floor((b+.5)*e.height/a))*e.width+h;return e.rgba[l*4+3]<P?T:u[l]}))}export{T as a,C as b,D as c,k as d,U as e,V as f,Y as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
var m=t=>t<=.04045?t/12.92:((t+.055)/1.055)**2.4,i=t=>t<=.0031308?12.92*t:1.055*t**.4166666666666667-.055;function g(t){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!n)return;let r=n[1],e=r.length===3?[...r].map(o=>o+o).join(""):r;return{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16)}}function x({r:t,g:n,b:r}){return`#${[t,n,r].map(e=>e.toString(16).padStart(2,"0")).join("").toUpperCase()}`}function h({r:t,g:n,b:r}){let e=m(t/255),o=m(n/255),a=m(r/255),b=Math.cbrt(.4122214708*e+.5363325363*o+.0514459929*a),u=Math.cbrt(.2119034982*e+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*e+.2817188376*o+.6299787005*a);return{L:.2104542553*b+.793617785*u-.0040720468*c,a:1.9779984951*b-2.428592205*u+.4505937099*c,b:.0259040371*b+.7827717662*u-.808675766*c}}function s({L:t,a:n,b:r}){let e=(t+.3963377774*n+.2158037573*r)**3,o=(t-.1055613458*n-.0638541728*r)**3,a=(t-.0894841775*n-1.291485548*r)**3;return[4.0767416621*e-3.3077115913*o+.2309699292*a,-1.2684380046*e+2.6097574011*o-.3413193965*a,-.0041960863*e-.7034186147*o+1.707614701*a]}function f(t){let[n,r,e]=s(t).map(o=>Math.round(Math.max(0,Math.min(1,i(Math.max(0,o))))*255));return{r:n,g:r,b:e}}function L(t){return s(t).every(n=>n>=-1e-4&&n<=1+1e-4)}function p({L:t,a:n,b:r}){return{L:t,C:Math.hypot(n,r),h:(Math.atan2(r,n)*180/Math.PI+360)%360}}function l({L:t,C:n,h:r}){let e=r*Math.PI/180;return{L:t,a:n*Math.cos(e),b:n*Math.sin(e)}}function M({r:t,g:n,b:r}){return`rgb(${t} ${n} ${r})`}function d(t){let{L:n,C:r,h:e}=p(h(t)),o=r<5e-4?0:e;return`oklch(${(n*100).toFixed(0)}% ${r.toFixed(3)} ${o.toFixed(0)})`}export{g as a,x as b,h as c,f as d,L as e,p as f,l as g,M as h,d as i};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
var h=Object.create;var f=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b,c)=>()=>{if(c)throw c[0];try{return a&&(b=a(a=0)),b}catch(d){throw c=[d],d}};var o=(a,b)=>()=>{try{return b||a((b={exports:{}}).exports,b),b.exports}catch(c){throw b=0,c}},p=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0})},g=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of j(b))!l.call(a,e)&&e!==c&&f(a,e,{get:()=>b[e],enumerable:!(d=i(b,e))||d.enumerable});return a};var q=(a,b,c)=>(c=a!=null?h(k(a)):{},g(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a)),r=a=>g(f({},"__esModule",{value:!0}),a);export{m as a,n as b,o as c,p as d,q as e,r as f};
|